Main properties:
- initial download complete (
preverified.tomlon disk): the localdata-fileoutranks the remote manifest and is never moved aside. A missingdata-fileis still downloaded. A local.torrentwhose infohash differs from the preverified one is ignored for the download decision but is left on disk, and only its sizes are used to check the file: on a mismatch the data backs neither manifest, so the download goes ahead under the preverified hash and the client completes the file by length, re-fetching only if the length disagrees. Otherwise the preverified download is skipped and the kept snapshot is seeded, under whatever infohash its local.torrentcarries. - initial download not complete: the remote manifest wins. Fetch the chain manifest (
chain.toml) and align the datadir to it (remote.torrentanddata-files); data whose local.torrentinfohash does not match the preverified one — including data with no readable.torrentat all — is renamed to.partand re-fetched.preverified.tomlis written locally once the set is complete, never downloaded.
Deriving a .torrent from a bare data-file happens on the seeding path (AddNewSeedableFile), which the complete path reaches: a kept snapshot is seeded, so metainfo that is missing, or present but malformed, is rebuilt from the data. The incomplete path never derives one — it fetches the remote .torrent instead.
The diagram below shows the components used to manage downloads between torrents and WebSeeds.
The Downloader uses BitTorrent to download snapshot files and metadata from peers and web peers.
However, this can result in slow or stalled downloads if the selected snapshot becomes unavailable. Use erigon snapshot reset or restart the downloader to sync to a different snapshot in this event. Pass --local=false keep files that aren't in the latest snapshot. This means only incomplete files that don't match the latest snapshot will be removed.
- Determine the pprof or debug port for your node. It can be exposed by passing
--pproftoerigonor settingGOPPROF=http(see http) inerigon's environment. This will give you ahost:portcombo of something likelocalhost:6061, where the host is the route to yourerigonnode.set hostport=localhost:6061 - Check
http://$hostport/downloader/torrentClientStatus. It shows current torrent client activity, including number of torrents# Torrents:, and on the same line, how many remain to be completed. The torrents are listed, incomplete first following that. - Check the goroutine listing at
http://$hostport/debug/pprof/goroutine?debug=1. Seehttp://$hostport/debug/pprof/for a directory listing of useful profiles. - Examine the CPU profile:
go tool pprof http://$hostport/debug/pprof/profile. - If you fail to determine the cause, provide the above information to the developers. This snippet describes one way to obtain all the required information:
set hostport=localhost:6061 curl http://$hostport/downloader/torrentClientStatus -o downloader-tcs.txt curl http://$hostport/debug/pprof/goroutine?debug=1 -o goroutine.txt curl http://$hostport/debug/pprof/profile?seconds=10 -o profile.pb.gz
The sections below describe the roles of the various control structures shown in the diagram above. They combine to perform the following management and control functions:
-
Definition of verified well know hashes for segment files - which identifies a known trusted universe of files (#$CHAIN.toml)
-
Management of the completion state of the local download process (BittorrentInfo)
-
Definition of the accepted local hash set which are used to ensure that the local snapshots retain a consistent specified view as other definitions in the environment changes. i.e. chain.toml gets re-versioned or BittorentInfo gets reset (preverified.toml).
-
Ability to override downloaded files with locally defined alternatives, for development or to fix errors and omissions (preverified.toml)
These are distributed in toml files in the following format. They can be hosted on a central server, embedded in the erigon binary or stored locally by a client (preverified.toml).
'v1.0-000000-000100-beaconblocks.seg' = 'eaee23c3db187c8be69e332b4ff50aa73380d0ef'
'v1.0-000000-000500-bodies.seg' = 'e9b5c5d1885ee3c6ab6005919e511e1e04c7e34e'
'v1.0-000000-000500-headers.seg' = 'df09957d8a28af3bc5137478885a8003677ca878'
'v1.0-000000-000500-transactions.seg' = '92bb09068baa8eab9d5ad5e69c1eecd404a82258'There is an embedded toml file in erigon seg repository during the erigon build process. It contains
the well known hash for a particular segment file in the following format.
