feat(vms/evm/sync/evmstate): add leaf-range request handler#5406
Open
powerslider wants to merge 1 commit into
Open
feat(vms/evm/sync/evmstate): add leaf-range request handler#5406powerslider wants to merge 1 commit into
powerslider wants to merge 1 commit into
Conversation
- Serves leaf-range requests at `p2p.EVMLeafsRequestHandlerID`, used by - `evmstate.Handler` / `evmstate.Responder` bind `syncpb.GetLeafRequest` and `syncpb.GetLeafResponse` to the generic shell. - `evmstate.SnapshotProvider` is the optional fast-path lookup. - `evmstate.Stats + evmstate.NoopStats` for the metrics surface. - `synctest.NewTrieDB` / `FillTrie` / `CorruptTrie` / `StaticSnapshot` / `StaticPair` / `LeafRecorder` for tests. resolves #5405 Signed-off-by: Tsvetan Dimitrov ([email protected])
powerslider
commented
May 20, 2026
Comment on lines
+283
to
+295
| // Slow path: walk snapshot keys in fixed-size segments and verify | ||
| // each against the trie. Valid segments are appended directly. | ||
| // Invalid segments are bridged from the trie when the next valid | ||
| // segment arrives: fill the trie up to and including that | ||
| // segment's first key, drop the trailing key (the segment is | ||
| // about to append it), then append the segment. | ||
| // | ||
| // Example with snapKeys=[A B C D E], snapshotSegmentLen=2, [C D] invalid: | ||
| // i=0 [A B] valid append -> resp=[A B] | ||
| // i=2 [C D] invalid mark gap -> resp unchanged | ||
| // i=4 [E] valid trie-fill to E -> resp=[A B C D E] | ||
| // drop trailing E -> resp=[A B C D] | ||
| // append [E] -> resp=[A B C D E] |
Contributor
Author
There was a problem hiding this comment.
Did my absolute best to describe the algorithm in a single comment with an example. Feedback is welcomed here if we can improve this description further.
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.
Why this should be merged
Check #5405
How this works
p2p.EVMLeafsRequestHandlerID, used byevmstate.Handler/evmstate.Responderbindsyncpb.GetLeafRequestandsyncpb.GetLeafResponseto the generic shell.evmstate.SnapshotProvideris the optional fast-path lookup.evmstate.Stats + evmstate.NoopStatsfor the metrics surface.synctest.NewTrieDB/FillTrie/CorruptTrie/StaticSnapshot/StaticPair/LeafRecorderfor tests.How this was tested
Need to be documented in RELEASES.md?
no
resolves #5405
Signed-off-by: Tsvetan Dimitrov ([email protected])