Skip to content

add ReceiptRoot integrity check#20902

Merged
AskAlexSharov merged 10 commits intomainfrom
dwightbot/receipt-root-range-opt
Apr 30, 2026
Merged

add ReceiptRoot integrity check#20902
AskAlexSharov merged 10 commits intomainfrom
dwightbot/receipt-root-range-opt

Conversation

@sudeepdino008
Copy link
Copy Markdown
Member

@sudeepdino008 sudeepdino008 commented Apr 29, 2026

Adds a new integrity check that reads receipts from RCache domain,
computes the receipt root via DeriveSha, and compares it with
block.header.ReceiptHash.

This is similar to StateRootVerifyByHistory but for receipt roots
instead of state roots.

Closes #19421
Open one ReceiptCacheV2Stream per chunk and call txNumsReader.Min once,
instead of doing both per block. Walk the stream cursor and verify each
block's receipt root when txNum crosses the block boundary.

On a 140k-block hoodi sample this is ~40x faster (168s -> 4s,
single-threaded).
ReceiptForStorage omits Bloom on disk; DeriveSha depends on it, so
the integrity check produced a wrong root for any block with logs
(e.g. mainnet 50303). Recompute Bloom per receipt before appending.
Diagnostic logging for the still-failing pre-fix mismatches: dumps
per-receipt fields (type, status, postStateLen, cumGas, numLogs,
bloomZero) when computed root differs from header.
Temporary: skip parallelChunkCheck and only verify block 49401 to
isolate the receipt-root mismatch with focused per-receipt logging.
EIP-658 changed the consensus receipt encoding at Byzantium
(mainnet 4,370,000): pre-Byzantium receipts contain a 32-byte
PostState (intermediate state root); post-Byzantium receipts
contain a 1-byte status. MakeReceipt only sets Status, so RCache
cannot reconstruct the PostState, and the canonical receipt root
is unrecoverable for pre-Byzantium blocks. Start the check at
ByzantiumBlock instead.
@sudeepdino008 sudeepdino008 marked this pull request as ready for review April 29, 2026 11:00
@AskAlexSharov AskAlexSharov enabled auto-merge April 29, 2026 11:22
@AskAlexSharov AskAlexSharov added this pull request to the merge queue Apr 29, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Apr 29, 2026
@AskAlexSharov AskAlexSharov enabled auto-merge April 30, 2026 04:05
@AskAlexSharov AskAlexSharov added this pull request to the merge queue Apr 30, 2026
Merged via the queue into main with commit 318c753 Apr 30, 2026
37 checks passed
@AskAlexSharov AskAlexSharov deleted the dwightbot/receipt-root-range-opt branch April 30, 2026 06:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants