feat: prepare snap v2 vision#9
Draft
lean-apple wants to merge 16 commits into
Draft
Conversation
Decode received BALs with DecodedBal::from_rlp_bytes and compare against the header's block_access_list_hash using the canonical EIP-7928 hash of the decoded list, instead of keccak256 of the raw bytes. Surface distinct missing, malformed, and hash-mismatch errors and return the decoded BAL. Aligns snap/2 verification with execution/payload validation.
poll_flush now drains the eth/snap proxy channels onto the wire before reporting flushed, and poll_next surfaces flush errors instead of dropping them. decode_versioned returns a typed SnapProtocolError (surfaced as EthStreamError::InvalidSnapMessage), so malformed bodies are distinguished from invalid or removed (0x06/0x07) message ids.
…ted stream SnapClient now forwards requests over an mpsc channel to the SessionManager, which routes each to the first snap-capable active session. The session sends it via EthRlpxConnection::start_send_snap, assigns a connection-unique request_id, tracks it in an inflight map with a deadline, and resolves the client's future when the matching response arrives (or on timeout). Removes the temporary SnapPeers registry and the SnapProtocolHandler / SnapConnection satellite path; snap is now driven entirely through the dedicated EthSnapStream. Inbound snap requests are not served yet.
Thread a BalStoreHandle from NetworkConfig through the SessionManager into each ActiveSession (default no-op store; set via NetworkConfigBuilder:: with_bal_store). Inbound snap/2 requests are now served by a pure helper in snap/server.rs: GetBlockAccessLists is answered from the BAL store with missing entries as empty, request order preserved, the tail truncated at the response-byte/QoS limit, and the peer's request_id echoed. Bulk-state ranges (GetAccountRange / GetStorageRanges / GetByteCodes) are not served yet; they need range iteration and boundary proofs.
… guard - Served snap responses now count toward request-response backpressure: OutgoingMessage::Snap delegates to SnapProtocolMessage::is_response, so a peer can't grow the outgoing queue past the existing response throttle. - fetch_and_verify_bals validates the response itself (it is generic over any SnapClient): rejects a mismatched request_id and a response carrying more entries than requested (tail truncation is still allowed). - SnapSyncStage::execute fails explicitly instead of reporting a no-op done: true, so the scaffolding can't be wired in as a silent success. - BAL server logs store-lookup errors instead of silently returning empty. Adds tests for response classification, BAL response validation, and the existing serve behavior.
- e2e: a GetBlockAccessLists request and its BlockAccessLists response round-trip over two live EthSnapStreams (real handshake + demux). - make serve_snap_request's match exhaustive (no catch-all) so a new snap message forces a decision, and update the SnapSyncStage module doc to reflect that execute now fails explicitly. - unit tests: SnapProtocolMessage::set_request_id, serve hash-count truncation to the per-request limit, and ignoring an unknown snap response id without panicking or queuing output.
Lightweight workflow on ubuntu-latest that builds and runs the snap, eth-wire and session tests (including the live EthSnapStream e2e) and checks the snap sync stage compiles. Faster feedback than the full unit matrix for this branch.
Rely on the inherited reth workflows (which fall back to the GitHub-native ubuntu-latest runner on forks) instead of a dedicated snap job.
Adds an in-memory BalStore returning real bytes for known hashes so the serve helper is exercised against a populated store (present hash returns its bytes, missing hash is an empty entry, request order preserved), not just the no-op store.
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.
Maps the reth-side integration path for EIP-8189 snap/2.
The intended direction is v2-first: typed snap/2 message validity, a dedicated
eth + snap/2negotiated stream,SnapClientrouted through the session manager, response correlation inActiveSession, BAL verification, and the first server behavior forGetBlockAccessLists.snap/2 integration map
Protocol validity and wire typing
0x00..0x05;0x06/0x07;0x08/0x09;Dedicated
eth + snap/2transportRLPxcapability next toeth;EthSnapStreamfor exactlyeth + snap/2;Client request routing
SnapClientroutes throughSessionManager;ActiveSessionowns the actual connection and response correlation;BAL verification
block_access_list_hash, not raw-byte hashing;First server behavior: BAL serving
GetBlockAccessListsis the first useful interop target;BalStoreHandle;Bulk-state serving is intentionally separate
GetAccountRange,GetStorageRanges, andGetByteCodesrequire state range iteration and proof handling;Sync stage boundary
Later cleanup
Already done
TODO/ to continue in prs
eth + snap/2stream/session path.SnapClientthrough the session manager.0x06/0x07.block_access_list_hash.