core, eth/protocols/snap, eth/downloader: snap/2 sync logic#34626
Draft
jrhea wants to merge 18 commits intoethereum:masterfrom
Draft
core, eth/protocols/snap, eth/downloader: snap/2 sync logic#34626jrhea wants to merge 18 commits intoethereum:masterfrom
jrhea wants to merge 18 commits intoethereum:masterfrom
Conversation
053a490 to
d6bcd47
Compare
d08322a to
0fb927f
Compare
…ucture sync loop for snap/2
0286103 to
72c04c3
Compare
72c04c3 to
d111e9f
Compare
…use softResponseLimit for BAL requests
jrhea
commented
Apr 7, 2026
jrhea
commented
Apr 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replace the snap/1 sync logic with snap/2's.
What changed
Healing removed. The syncer no longer requests trie nodes from peers. Snap/1 serving is unchanged.
Sync loop restructured.
Sync()runs a download -> catch-up -> trie rebuild loop.Download. Still fetches account ranges, storage slots, and bytecodes from peers, writing flat state to disk. When the downloader restarts the syncer with a new pivot root, the syncer detects the change and runs BAL catch-up before resuming download.
BAL catch-up. When the pivot moves,
catchUp()fetches BALs from peers, verifies them against block headers, and applies the state diffs.Trie rebuild. After download completes,
triedb.GenerateTrie()rebuilds all tries from the flat state.Deep reorg detection. The downloader checks if the old pivot was reorged before restarting the syncer. If so, sync progress is wiped and the syncer starts fresh.
Skip snapshot generation. The downloaded flat state is the snapshot. SnapSyncComplete calls
RebuildFromSyncedState()instead ofRebuild().Notes
Storage roots left stale during sync. When BALs are applied during catch-up, account storageRoot fields become inconsistent. Rather than recomputing storage tries on every pivot move, they are left stale and all storage tries are rebuilt at the end from flat state.
On deep reorg we restart from scratch. A reorg > 64 blocks is catastrophic and rare enough that we wipe sync progress and start over. Causes include:
Current pivot is HEAD-64. Shorter slot times or faster finality could impact this.
Follow-up PRs
Metrics and progress logging. Add counters and timers for access list fetch/apply, trie rebuild, and pivot movements.
BALs are currently stored in the KV store. Long-term, they probably need to move to the freezer for cheaper retention over the weak subjectivity period.