Repository navigation
op-reth: test the proofs multiproof V2 path - #23420
Draft
einar-oplabs wants to merge 1 commit into
Draft
einar-oplabs wants to merge 1 commit into
einar-oplabs wants to merge 1 commit into
Conversation
Request the V1 and V2 multiproofs of the proofs state providers for the same targets and check that both verify against the state root and show the tip's account and storage values, over the InMemory and MDBX stores, with the proven block flushed to the store, buffered in the engine, or passed as the caller's trie input. The targets cover a contract with a live, a zeroed and a never-written slot, a destroyed account, an updated and an untouched EOA, and an account that never existed. The engine's buffer module and `TrieBufferState::insert` become crate visible so the test can build the buffered overlay. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This branch has not been deployed
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 reth 2.6 bump (#23046) made V2 multiproofs the default and added
DatabaseProof::overlay_multiproof_v2plusmultiproof_v2on both proofs state providers, with no test. This is the path reth's engine and RPC take through the proofs provider, so it gets the coverage #23394 asks for.What the tests cover
rust/op-reth/crates/trie/src/proof/tests.rs, tworstesttables.The fixture is two blocks on an empty proofs store. Block 1 creates a contract with two slots, an account with one slot, two EOAs, 256 filler accounts and 256 filler slots in each of the two storage tries. The tip, block 2, destroys the second account, sets one of the contract's slots to zero and updates one EOA. Both blocks' trie updates are computed with
StateRoot::overlay_root_with_updatesagainst the store, as the engine does.fixture_tip_rewrites_stored_branch_nodes(both backends) pins the property the fillers exist for: the tip rewrites stored branch nodes of the account trie and of the contract's storage trie and removes the destroyed account's storage branch nodes, so the proofs below read stored and overlaid branch nodes, not leaves alone.multiproof_v2_matches_multiproofrequests the V1multiproofand the V2multiproof_v2from the proofs state provider for the same targets and asserts that each resulting account proof verifies against the tip's state root (AccountProof::verify) and shows the tip's account info and storage values. The state root is computed from the plain tip state withstate_root_unsorted/storage_root_unsorted, independently of the store, and the case asserts the store agrees with it before any proof is requested.Targets (
#[case]):Matrix (
#[values]):InMemory,MdbxOpProofsStateProviderRefat the tip); buffered in the engine (TrieBufferState::state_provider, soMemoryOverlayOpProofsStateProviderReflays the block over the store at the parent); passed as the caller'sTrieInputover the store at the parent. The third value is one beyond the issue's {flushed, buffered overlay}; it feedsoverlay_multiproof_v2'sinputstraight fromOpProofsStateProviderRefrather than only through the overlay'sprepend_self.36 + 2 = 38 cells, 0.3 s in total.
Local verification
Mutation checks, both reverted:
InMemoryTrieCursorFactorynode overlay fromoverlay_multiproof_v2fails exactly the 24 buffered and trie-input cells, each on the V2 verification (ValueMismatch) while V1 still passes; the 14 flushed and fixture cells are unaffected. Therust-code-reviewerpass caught that the first fixture, with five accounts, never stored a branch node, so this mutation passed; the fillers and the fixture test are the fix.input.prepend_self(self.trie_input().clone())fromMemoryOverlayOpProofsStateProviderRef::multiproof_v2(run on that first fixture) fails exactly the 12 buffered cells on the V2 verification.Skipped cells
None.
Findings
No bug reproduced: on this stack both paths agree on every cell, including the destroyed account and the zeroed slot, over both backends and all three placements.
Seams for later PRs
engine::bufferandengine::buffer::stateare nowpub(crate)andTrieBufferState::insertispub(crate)(waspub(in crate::engine)), so tests outside the engine can build a buffered overlay provider withTrieBufferState::state_provider. The engine's live buffer stays inside the privateengine::state, so nothing outside the engine can mutate it.test_utils::destroyed_accountsgainsINITIAL_ANCHOR(the anchorseed_initial_storagesets) andplain_slot.rstestis now a dev-dependency ofreth-optimism-trie.Notes on the issue
The method under test does not exist on
develop, so, as the issue's verification criterion says, this lands on the bump stack rather than againstdevelop.Stacked on #23419, #23358 and #23046.
Closes #23394
🤖 Generated with Claude Code