Skip to content

fix(provider): scope pipeline consistency guard to blocks above hist_tip#181

Draft
chee-chyuan wants to merge 5 commits into
developfrom
fix/pipeline-consistency-historical-block-guard
Draft

fix(provider): scope pipeline consistency guard to blocks above hist_tip#181
chee-chyuan wants to merge 5 commits into
developfrom
fix/pipeline-consistency-historical-block-guard

Conversation

@chee-chyuan
Copy link
Copy Markdown

Closes bnb-chain/reth-bsc#338

The HistoryStateInconsistent guard introduced in #113 fired whenever any gap existed between the execution and history index checkpoints, rejecting all InPlainState reads regardless of the requested block number. This caused eth_replayBlockTransactions (and other historical RPC calls) to fail for blocks well below the inconsistent range while the node was in pipeline sync.

Only blocks where block_number > hist_tip are unsafe to read from plain state — for those, the history index is incomplete and may have missed writes in the gap. Blocks at or below hist_tip are fully covered by the index, so InPlainState is correct and safe to return.

Adds a test case reproducing the #338 scenario: gap exists (exec_tip=300 > hist_tip=200) but requested block (16) is below hist_tip — should succeed.

The HistoryStateInconsistent guard fired whenever any gap existed between
execution and history index checkpoints, rejecting all InPlainState reads
regardless of the requested block number. This broke eth_replayBlockTransactions
for historical blocks well below the inconsistent range during pipeline sync.

Only blocks where block_number > hist_tip are actually unsafe to read from
plain state — for those, the history index is incomplete and may have missed
writes in the gap. Blocks at or below hist_tip are fully covered by the index,
so InPlainState is correct and safe to return.

Fixes bnb-chain/reth-bsc#338

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@hashdit-bot
Copy link
Copy Markdown

hashdit-bot Bot commented May 5, 2026

Pull Request Review

This PR primarily fixes historical state read behavior by scoping HistoryStateInconsistent checks to only block numbers above hist_tip, which restores correctness for historical RPC calls (e.g., eth_replayBlockTransactions) during pipeline gaps. It also adds significant TrieDB/MDBX consistency and shutdown-hardening logic, including startup alignment/unwind decisions, deferred triedb flush ordering, pathdb reorg rewind handling, and graceful shutdown flush coordination. Additional changes include peer error classification/logging refinements, blobstore startup retention behavior, and broad test coverage expansions for edge cases.

Sensitive Content

No sensitive content detected.

Security Issues

No serious security issues detected.


Generated by Hashdit Bot. This tool can absolutely NOT replace manual audits.

@chee-chyuan chee-chyuan changed the base branch from main to develop May 5, 2026 05:09
@hashdit-bot
Copy link
Copy Markdown

hashdit-bot Bot commented May 5, 2026

Pull Request Review

This PR fixes the HistoryStateInconsistent guard logic so it only rejects InPlainState reads when the requested block_number is above hist_tip, instead of rejecting all reads whenever an execution/history gap exists. The change is applied in both account and storage lookup paths in historical.rs, and a regression test is added to validate that historical reads below hist_tip succeed even during pipeline inconsistency (exec_tip > hist_tip). It also includes a minor typo fix in a pool builder comment.

Sensitive Content

No sensitive content detected.

Security Issues

No serious security issues detected.


Generated by Hashdit Bot. This tool can absolutely NOT replace manual audits.

@hashdit-bot
Copy link
Copy Markdown

hashdit-bot Bot commented May 5, 2026

Pull Request Review

This PR fixes the historical state consistency guard logic so that HistoryStateInconsistent is only returned when the requested block_number is above hist_tip, instead of rejecting all InPlainState reads whenever an exec/history gap exists. The same conditional fix is applied to both account and storage paths in historical.rs. It also adds a regression test reproducing issue #338, confirming that reads for blocks below hist_tip succeed even when exec_tip > hist_tip.

Sensitive Content

No sensitive content detected.

Security Issues

No serious security issues detected.


Generated by Hashdit Bot. This tool can absolutely NOT replace manual audits.

@hashdit-bot
Copy link
Copy Markdown

hashdit-bot Bot commented May 5, 2026

Pull Request Review

This PR fixes the historical state consistency guard logic so it only rejects InPlainState reads when the requested block is above hist_tip, instead of rejecting all reads whenever any execution/history gap exists. It updates both account and storage inconsistency checks with the self.block_number > hist_tip condition, restoring correct behavior for historical RPC queries below the indexed history tip during pipeline sync. A regression test was added to reproduce issue #338 and verify that reads at block 16 succeed even when exec_tip=300 and hist_tip=200.

Sensitive Content

No sensitive content detected.

Security Issues

No serious security issues detected.


Generated by Hashdit Bot. This tool can absolutely NOT replace manual audits.

Fixed in hickory-resolver 0.26, pending upgrade.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@hashdit-bot
Copy link
Copy Markdown

hashdit-bot Bot commented May 5, 2026

Pull Request Review

This PR fixes an over-broad historical state consistency guard in the Rust storage provider so that HistoryStateInconsistent is only returned when the requested block_number is above hist_tip, rather than whenever any execution/history gap exists. It updates both account and storage paths in historical.rs and adds a regression test reproducing the reported sync-gap scenario (exec_tip=300, hist_tip=200, query at block 16) to ensure valid historical reads continue to work. It also includes a minor doc typo fix and adds two new RustSec advisory ignores in deny.toml.

Sensitive Content

No sensitive content detected.

Security Issues

No serious security issues detected.


Generated by Hashdit Bot. This tool can absolutely NOT replace manual audits.

if let Some((exec_tip, hist_tip)) =
self.pipeline_consistency.account_inconsistency()
self.pipeline_consistency.account_inconsistency() &&
self.block_number > hist_tip
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The more typical case is when the queried block is below hist_tip. In that scenario, if the key happens to have been modified within the (hist_tip, exec_tip] window, this returns wrong data from a future block — silently, with no error raised.

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.

Revm error: failed to apply 2935 system call failed to apply blockhash contract call: database error

2 participants