Skip to content

feat(vms/evm/sync/evmstate): add leaf-range request handler#5406

Open
powerslider wants to merge 1 commit into
powerslider/5403-block-proto-handlerfrom
powerslider/5405-leaf-proto-handler
Open

feat(vms/evm/sync/evmstate): add leaf-range request handler#5406
powerslider wants to merge 1 commit into
powerslider/5403-block-proto-handlerfrom
powerslider/5405-leaf-proto-handler

Conversation

@powerslider
Copy link
Copy Markdown
Contributor

Why this should be merged

Check #5405

How this works

  • 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.

How this was tested

  • UT for the new handler.

Need to be documented in RELEASES.md?

no

resolves #5405

Signed-off-by: Tsvetan Dimitrov ([email protected])

- 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 powerslider self-assigned this May 20, 2026
@powerslider powerslider requested a review from a team as a code owner May 20, 2026 12:38
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]
Copy link
Copy Markdown
Contributor Author

@powerslider powerslider May 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@powerslider powerslider requested a review from a team May 20, 2026 12:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

1 participant