fix(l1): report a block whose receipts are absent instead of answering empty - #7208
Conversation
get_receipts_for_block returns a bare Vec, so "this block's receipts are not stored" and "this block had no transactions" are the same value. get_all_block_receipts passed that straight through, so debug_getRawReceipts answered an empty list for a block that has transactions — a wrong answer rather than a reported failure. Check the receipt count against the block's own transaction count, and report a block whose body is absent rather than validating against nothing. This mirrors the mismatch check the by-index receipt path already performs. Genesis keeps its existing short circuit, since it legitimately has none. This matters ahead of history pruning (#6673): an absent receipt set stops being a corruption signal and becomes a normal steady-state outcome, so every path that conflates it with emptiness starts returning wrong answers on every node rather than on a corrupted one.
|
🤖 Kimi Code ReviewThe PR correctly addresses the ambiguity between "receipts not stored" and "block had no transactions" in the RPC layer. This is an important fix for future pruning support.
Lines 456-477: The validation logic is sound. However, consider using
Lines 24-34: The assertion Lines 55-58: Same as above regarding General observations:
The logic correctly preserves the early return for genesis (block 0) while adding necessary validation for all other blocks. Automated review by Kimi (Moonshot AI) · kimi-k2.5 · custom prompt |
🤖 Claude Code ReviewReview: PR 7208 — Report a block whose receipts are absent instead of answering emptySummary: Fixes Correctness
Minor / non-blocking observations
Tests
Overall this is a small, well-scoped, low-risk correctness fix with good test coverage. No blocking issues found. Automated review by Claude (Anthropic) · sonnet · custom prompt |
Lines of code reportTotal lines added: Detailed view |
🤖 Codex Code Review
Aside from that, the receipt-count check itself is sound, and the new tests cover the main missing-receipts regression plus the genesis exception. I could not run Automated review by OpenAI Codex · gpt-5.4 · custom prompt |
Motivation
get_receipts_for_blockreturns a bareVec(crates/storage/store.rs:1491-1497), so "this block's receipts are not stored" and "this block had no transactions" are the same value.get_all_block_receiptspassed that straight through with no length check, sodebug_getRawReceiptsanswered an empty list for a block that has transactions — a wrong answer rather than a reported failure.The sibling by-index path already guards against this (
crates/networking/rpc/eth/block.rs:408-414, "Return 500 on receipt count mismatch"); the all-receipts path did not.This matters ahead of history pruning (#6673). Today an absent receipt set means corruption, which is rare. Once pruning lands it becomes a normal steady-state outcome, so every path that conflates "absent" with "empty" starts returning wrong answers on every node rather than on a corrupted one. Making these paths honest is a prerequisite for pruning being safe to enable, and it is worth doing on its own merits regardless.
Description
get_all_block_receiptsnow checks the receipt count against the block's own transaction count, and reports a block whose body is absent rather than validating against nothing. Genesis keeps its existing short circuit, since it legitimately has no receipts.The error is
RpcErr::Internalto match the sibling path. Once #7069 lands itsPrunedHistoryUnavailablevariant (JSON-RPC code 4444), both sites should move to it together — an absent-because-pruned block deserves a distinct code from a corrupt one, and splitting that out keeps this change reviewable.Tests
Two tests in
test/tests/rpc/raw_receipts_completeness_tests.rs. The harness stores blocks and their transactions but no receipts, which is exactly the shape a pruned block presents — body present, receipts gone:test result: FAILED) and pass with it