fix(p2p): remove legacy step field from BlocksByRange request#365
Conversation
The leanSpec BlocksByRangeRequest container has two fields (start_slot, count); the legacy phase-0 step parameter was deprecated in Altair and explicitly omitted from the lean spec. Our request struct still carried `step: u64`, so SSZ decode requires 24 bytes for the request payload while peers (and the ethereum/hive lean simulator) send the spec-compliant 16-byte (start_slot, count) encoding. The mismatch causes every inbound BlocksByRange request to fail decoding before it reaches the handler. Drop the field from the wire type, remove the step==0 validation, and simplify canonical_blocks_by_range to walk contiguous slots. Updates the existing unit test to the new signature. Verified against hive's reqresp/blocks_by_range suite (all 4 tests pass; previously hung at fixture timeout because the SSZ decode error prevented any response).
Greptile SummaryThis PR removes the deprecated
Confidence Score: 5/5Safe to merge — the change is a targeted spec-alignment fix with correct arithmetic and no regressions in logic. The removal of No files require special attention.
|
| Filename | Overview |
|---|---|
| crates/net/p2p/src/req_resp/messages.rs | Removes the legacy step: u64 field from BlocksByRangeRequest, shrinking the SSZ-encoded size from 24 bytes to 16 bytes to match the lean spec. |
| crates/net/p2p/src/req_resp/handlers.rs | Removes the step parameter from canonical_blocks_by_range, drops the dead step == 0 validation, and replaces the index-based iteration with a direct slot range; logic and edge cases (checked arithmetic, missed slots) all look correct. |
Sequence Diagram
sequenceDiagram
participant Peer
participant P2PServer
participant Handler as handle_blocks_by_range_request
participant Store
Peer->>P2PServer: BlocksByRangeRequest (16 bytes: start_slot, count)
P2PServer->>Handler: dispatch request
Handler->>Handler: "validate count (0 or > MAX_REQUEST_BLOCKS → INVALID_REQUEST)"
Handler->>Store: canonical_blocks_by_range(start_slot, count)
Store-->>Handler: walk chain head → start_slot, collect roots_by_slot
Handler->>Handler: "iterate start_slot..=end_slot, filter_map to blocks"
Handler-->>Peer: Response::success(blocks)
Reviews (1): Last reviewed commit: "fix(p2p): remove legacy step field from ..." | Re-trigger Greptile
🤖 Claude Code ReviewHere is my review of PR #365: PR #365 —
|
🤖 Kimi Code ReviewOverall Assessment: This PR removes the deprecated Critical Issues1. Protocol Breaking Change (Fork Versioning Required)File: Removing the Action Required: Gate this change behind a fork version check. The handler must support both schemas based on the negotiated protocol version or fork epoch. If this targets a specific hard fork (e.g., Capella/Deneb), the code must use the old schema for prior forks and the new schema for the target fork and later. // Suggested pattern:
pub enum BlocksByRangeRequest {
PreFork { start_slot: u64, count: u64, step: u64 },
PostFork { start_slot: u64, count: u64 },
}Code Quality & Safety2. Arithmetic Safety Improvement (Positive)File: Removing let Some(end_slot) = count
.checked_sub(1)
.and_then(|last_offset| start_slot.checked_add(last_offset))is correct for computing 3. Performance: HashMap CapacityFile:
let mut roots_by_slot = HashMap::with_capacity(count as usize);4. Logic CorrectnessFile: The iteration change from stepped indices to contiguous range Security Considerations
TestingFile: The test update correctly removes the
Summary
Automated review by Kimi (Moonshot AI) · kimi-k2.5 · custom prompt |
🤖 Codex Code Review
No other major issues stood out in the touched code. I couldn’t run Automated review by OpenAI Codex · gpt-5.4 · custom prompt |
Summary
step: u64field fromBlocksByRangeRequest. The leanSpec container has only(start_slot, count);stepwas deprecated in Altair and explicitly omitted from the lean spec.step == 0validation and simplifycanonical_blocks_by_rangeto walk contiguous slots; update the existing unit test to the new signature.Test plan
cargo test -p ethlambda-p2preqresp/blocks_by_rangesuite: all 4 tests pass (previously hung at fixture timeout because the SSZ decode error prevented any response).