Repository navigation
op-reth: live test of proofs execution across reth parent states - #23441
Closed
einar-oplabs wants to merge 3 commits into
Closed
einar-oplabs wants to merge 3 commits into
einar-oplabs wants to merge 3 commits into
Conversation
This was referenced Oct 15, 2026
einar-oplabs
force-pushed
the
einar/23384-proofs-parent-states
branch
2 times, most recently
from
October 15, 2026 16:36
6179143 to
ae1ad31
Compare
einar-oplabs
force-pushed
the
einar/23384-proofs-parent-states
branch
from
October 16, 2026 04:23
ae1ad31 to
cf9f0ca
Compare
Contributor
|
This pr has been automatically marked as stale and will be closed in 5 days if no updates |
Execute the call and BLOCKHASH blocks of a deploy, call, BLOCKHASH chain through the proofs engine against a real BlockchainProvider while a simulated reth moves the parent between memory, disk and an abandoned fork with reth's own persistence rule (threshold 7 and 50, masking 0 and 30, memory-block-buffer target 5). A proofs store hook fires reth's mid-execution transitions right after the engine snapshots the parent state. The abandoned-fork cases assert the bump's state-root failure and are ignored on develop, which skips such a parent with StateForHashNotFound. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> (cherry picked from commit 22bbc1d) (cherry picked from commit 852fb64a2d328e6a3c53af9eee89c4a59982a3e7)
Persist with reth's own save_blocks writer, keep live.rs's single-block helper and share its storage initialization, state the read hook's buffered-blocks precondition and check it right after execution, assert block locations uniformly, add the BLOCKHASH case whose deployment sits below reth's memory, name the persistence settings, use a fixed signer and run the hook inline. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> (cherry picked from commit cf9f0ca) (cherry picked from commit 6db279118b71060163e09b3b2208f6976e625bb0)
Reth now serves in-memory state through its OverlayManager, so the simulated reth registers the blocks it makes canonical, drops the ones it reorgs out or evicts, and the abandoned_fork case holds without #23046. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
einar-oplabs
force-pushed
the
einar/23384-proofs-parent-states
branch
from
November 9, 2026 22:30
cf9f0ca to
3754324
Compare
einar-oplabs
marked this pull request as ready for review
November 13, 2026 11:44
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.
The proofs engine executes a block against reth's state for the block's parent, and reth moves that parent between memory and disk on its own schedule. Each parent state is unit-tested in isolation on #23046, but nothing ran the whole execute path across the transitions, which is where the next reth bump breaks it.
What the test does
rust/op-reth/crates/trie/tests/live/parent_states.rs(a submodule oftests/live.rs) drives a realBlockchainProviderwhoseCanonicalInMemoryStateand database aSimulatedRethadvances with reth's own persistence rule: once the head runs more thanpersistence_thresholdblocks past the database tip, persist every block but the newestmemory_block_buffer_targetthrough reth'ssave_blockswriter in one transaction, then evict the persisted blocks from memory except the newestnum_state_masking_blocks. The chain is blockndeploying a contract,n+1calling it (slot 0 := 1) andn+2storingBLOCKHASH(n)(slot 1). The engine executesn+1(call content) orn+2(BLOCKHASHcontent) with the parent in one of these states:(50, 30)only; the deployment sits right above the first eviction boundary)EngineError::StateRootMismatchfor the block, store stays at the parentBLOCKHASHonly)BLOCKHASHonly)After a stored outcome the test checks the store's latest block, recomputes the state root at that block from the proofs store and compares it with the header, and reads the contract's slots back through
OpProofsStateProviderRef. Before and after execution it compares where reth holds the parent (canonical, in memory, persisted) with the expectation of the parent state.Mid-execution transitions go through
StoreWithReadHook, a proofs store whoseprovider_ro()runs a one-shot action: the engine's execute task opens that read view right after it snapshots reth's parent state, on develop and on #23046 alike, so the action lands between the snapshot and execution. The engine also opens a read view to find its tip when its block buffer is empty, so the cases keep the preceding blocks buffered, and the test asserts right afterexecute_blockreturns that the hook fired.Matrix
rstesttables over reth persistence threshold {7, 50} x masking {0, 30} x memory-block-buffer target {5} x block content {call,BLOCKHASH}, each#[case]naming the parent state and the outcome. reth rejectsnum_state_masking_blocks + memory_block_buffer_target >= persistence_threshold, so(7, 30)is not a valid cell and the matrix runs(7, 0),(50, 0)and(50, 30); the issue's matrix lists the invalid cell. 32 cases plus the six ignored ones:execute_block_across_reth_parent_states: {in memory, persisted and evicted, evicted while executing, abandoned fork} x 3 persistence settings x 2 contents (24; the in-memory and the two fork rows never reach a persistence cycle, so there the settings only exercise the simulation)execute_block_with_persisted_and_masked_parent:(50, 30)x 2 contents (2)execute_block_hash_read_below_reth_memory: 3 persistence settings (3)execute_block_hash_read_while_reth_reorgs_below_it: 3 persistence settings (3)live.rstestsThe issue's shared parameter matrix also lists the engine flush cadence (1, 2) and (5, 10). The test does not vary it:
EngineHandle::flushonly waits for a save already in flight and never starts one, so the engine is spawned withspawn_with_thresholds(n, n + 1)wherenis the number of blocks the case stores; the save fires after the block under test (after the parent for the mismatch case) andflushwaits for it. A cadence of 1 would also empty the buffer before the block under test and defeat the read hook.Harness changes in
tests/live.rsTxSpecgainsto: TxKind,dataandgas_limit, in the shape rust!: update reth to v2.6.0 #23046 gives it, plusTxSpec::createandTxSpec::call.initialize_storageholds the proofs-store initialization the scenario runner already did, so both tests share it.rstestandreth-chain-statejoin the dev-dependencies.Local verification
cargo clippy -p reth-optimism-trie --all-targets --all-featuresis clean and the files are formatted withjust fmt-fix.Ignored cells
The six
abandoned_forkcases (3 persistence settings x 2 contents) are#[ignore]d naming #23046. On develop the execute path resolves the parent withstate_by_block_hash, which fails withStateForHashNotFoundfor a parent reth no longer holds, and the task treats that as recoverable: it returnsOk(())and stores nothing. Each ignored case fails on develop with:#23046 replaces the historical state provider with a snapshot of reth's in-memory chain plus the Bytecodes table; a parent that is already off the canonical chain has no snapshot and the contract's code is not on disk, so execution fails the state-root check. The bump PR un-ignores the cases by deleting the
#[ignore]line.Verified on #23046's head
I ran the file on
93d9ec9d2f(the head of #23046) with the ignore removed. On reth 2.6BlockchainProvider::state_by_block_hashserves an in-memory block through anOverlayStateProviderfed by anOverlayManagerthe engine tree maintains next toCanonicalInMemoryState, soSimulatedRethmust register blocks there as well; with that adaptation, which belongs in the bump PR, all 39 tests pass with no ignores:The adaptation (plus
reth-storage-overlay.workspace = trueunder[dev-dependencies]):On the bump reth's
partial-persistencefeature is always on, soSimulatedReth::persistcan also pass the masked frontier (new_db_tip - num_state_masking_blocks) assave_blocks'new_partial_state_trieinstead of the database tip, which models the held-back hashed state and trie of masked blocks.Findings
save_blockspanics withserializing FinishCheckpoint requires the partial-persistence featureas soon as it is asked to hold back the hashed state and trie of masked blocks, and op-reth enables that feature nowhere. The simulation therefore gives the writer both frontiers at the database tip and masking only decides which persisted blocks stay in memory. Enabling the feature through this crate's dev-dependencies would unify it into every workspace test build, so I left it off.EngineHandle::flushonly waits for a save that is already in flight; it never starts one. The existing scenario runner never asserted the store's tip, which is why this went unnoticed.EngineHandle::flush(and in one run inexecute_block) instead of gettingEngineError::EngineDied;sampleshowed no engine or persistence thread left. I did not chase the mechanism, but an engine panic leaving callers waiting is worth a look.(persistence threshold 7, masking 30)is a configuration reth rejects (num_state_masking_blocks + memory_block_buffer_target < persistence_threshold), so it has no case.Seams for later PRs
SimulatedReth(reth's persistence rule overCanonicalInMemoryStateand the test database, withsave_blocks) andStoreWithReadHook(a one-shot action between the engine's parent-state snapshot and execution) live intests/live/parent_states.rsand can be lifted into the crate's test utilities when op-reth: live test of index-versus-execute proofs store parity over rich block content #23388 needs them.initialize_storageintests/live.rsseeds a proofs store from the test database at a given block.Stacked on #23437, #23434, #23429, #23428, #23421 and #23418.
Closes #23384
🤖 Generated with Claude Code