fix: detect reorged sidechain blocks by canonical hash - #354
Merged
0xNeshi merged 1 commit intoJun 1, 2026
Conversation
Collaborator
|
Replaces #352 |
0xNeshi
pushed a commit
that referenced
this pull request
Jun 1, 2026
## Summary - Detect reorgs by comparing a previously scanned block against the current canonical block at the same height. - Store buffered block numbers alongside hashes so common ancestor lookup uses a single canonical block-by-number request. - Add regression coverage for providers that keep reorged sidechain blocks queryable by hash. ## Root Cause Some execution clients can still return a reorged sidechain block from `eth_getBlockByHash` after the canonical block at the same height has changed. Treating a successful hash lookup as proof that a buffered/scanned block is still canonical can miss same-height replacements, so the affected range is not replayed. ## Fix This change compares the saved block hash with the canonical block returned by `eth_getBlockByNumber` at the saved height. The reorg buffer stores `(BlockNumber, BlockHash)`, allowing common ancestor detection to validate canonicality with one RPC call per buffered candidate. ## Testing - `cargo test --features test-utils detects_reorg_when_old_hash_is_available_but_not_canonical` - `cargo check --features test-utils` This PR replaces #352 with a single signed commit. (cherry picked from commit 62de185)
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.
Summary
Root Cause
Some execution clients can still return a reorged sidechain block from
eth_getBlockByHashafter the canonical block at the same height has changed. Treating a successful hash lookup as proof that a buffered/scanned block is still canonical can miss same-height replacements, so the affected range is not replayed.Fix
This change compares the saved block hash with the canonical block returned by
eth_getBlockByNumberat the saved height. The reorg buffer stores(BlockNumber, BlockHash), allowing common ancestor detection to validate canonicality with one RPC call per buffered candidate.Testing
cargo test --features test-utils detects_reorg_when_old_hash_is_available_but_not_canonicalcargo check --features test-utilsThis PR replaces #352 with a single signed commit.