Conversation
Adds snap/2 capability advertisement, GetBlockAccessLists (0x08) / BlockAccessLists (0x09) message types with version-aware Message dispatch, BAL storage API, and BAL persistence in all block-import paths. snap/1 remains supported. No server/client/healing logic yet; those land in the next run.
Adds the GetBlockAccessLists server responder with a 2 MiB cumulative soft cap, the client request method that returns the serving peer id for accurate failure attribution, the apply_bal / advance_state_via_bals replay engine with strict in-order application and per-block hash verification, and the snap_sync state machine branch that uses BAL replay under snap/2 with a final state-root check, falling back to snap/1 trie healing otherwise.
Adds server-side unit tests for process_block_access_lists_request (empty / known / mixed / size-cap / snap/1 dispatch rejection), two more apply_bal cases (pre-state-gap fresh storage slot creation and bad-state-root detection), and updates the public and internal snap_sync docs plus the sync_modes doc with the snap/2 wire protocol and BAL replay flow. End-to-end multi-node integration tests are deferred to a future external hive snap/2 simulator.
Lines of code reportTotal lines added: Detailed view |
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.
Motivation
Implements EIP-8189: snap/2, which replaces iterative trie-node fetching during state healing with Block Access List (EIP-7928) replay. This is cleaner, avoids the need for partial-trie reconstruction, and lets the local node serve the same BALs to peers over snap/2 once sync is complete.
Depends on EIP-7928 (BAL header commitment) already present in this repo.
Description
Wire protocol
snap(2)alongsidesnap(1); per-connection negotiation picks the highest common version.GetBlockAccessLists(0x08) andBlockAccessLists(0x09).GetTrieNodes/TrieNodes; snap/1 connections serve them unchanged.BlockAccessListsresponse:Vec<Option<BlockAccessList>>with 0x80 RLP sentinel for absent entries, preserving position correspondence with the request.rlpx/message.rsguard the new message range againstBASED_CAPABILITY_OFFSET.BAL persistence
BLOCK_ACCESS_LISTSwithstore_block_access_list,get_block_access_list,iter_block_access_lists_by_hashes.execute_blockreturnsOption<BlockAccessList>;store_blocktakesOption<&BlockAccessList>. Pre-Amsterdam blocks passNone.add_block,add_block_pipeline_inner,add_blocks_in_batch.execute_block/execute_block_from_state.Server / client / replay engine
process_block_access_lists_requestrespects a 2 MiB soft cap (BAL_RESPONSE_SOFT_CAP_BYTES); first slot always included; remaining over-cap slots filled withNone.request_block_access_listsreturns(Vec<Option<BlockAccessList>>, peer_id)to keep failure attribution coherent.apply_bal(sync/bal_healing/apply.rs) applies BAL as state diffs: balance/nonce/code/storage post-values; implicit-empty entry triggers account deletion; missing local slots treated as zero pre-value; storage writes go directly to backend.advance_state_via_balsfetches in batches, validates ordering/hash before each apply, applies in strict block order using locally-trackedcurrent_root, persists each BAL. On peer exhaustion falls back to snap/1heal_state_trie_wrap.Sync state machine
Staleness loop in
snap_sync.rsbranches on snap/2 peer reachability: V2 path runsadvance_state_via_balsthen validates finalstate_root; V1 path is unchanged.Tests
process_block_access_lists_request(empty, all-known, mixed, 2 MiB cap, snap/1 rejection).apply_balunit tests: account creation/destruction, storage deletion, code deployment, EIP-7702 delegation clear, fresh storage slot, bad-state-root detection.test/tests/blockchain/batch_tests.rs.cargo test -p ethrex-p2p: 37 passing (was 27).cargo test -p ethrex-test: 421 passing (was 416).Notes
test/tests/p2p/has no multi-node RLPx harness, and the existing hive devp2p snap simulator calls the external Godevp2pCLI. A dedicated hive snap/2 simulator is needed.STORE_SCHEMA_VERSIONincrates/storage/lib.rsfor the newBLOCK_ACCESS_LISTStable.Checklist
STORE_SCHEMA_VERSION(crates/storage/lib.rs) if the PR includes breaking changes to theStorerequiring a re-sync.