triedb: add namespace state merge path - #2449
Conversation
64c33f0 to
30809d6
Compare
|
@claude review |
There was a problem hiding this comment.
Pull request overview
This PR extends the Ethereum execution “state” plumbing to support namespaced state deltas in the BlockState merge/validation path (used by TrieDB namespace reads), and adds a regression test that exercises reads + merges across two namespaces.
Changes:
- Add
State::get_namespace()accessor to expose the state’s optional namespace. - Update
BlockState::{can_merge,merge}to select the correctStateDeltasmap (global vs per-namespace) when validating/merging. - Extend the on-disk TrieDB test to cover namespaced merges and stale-state rejection.
Verdict: NEEDS CHANGES
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| category/execution/ethereum/state3/state.hpp | Exposes the optional namespace from State for downstream merge logic. |
| category/execution/ethereum/state2/block_state.cpp | Routes merge/validation to namespace-specific deltas when State is namespaced. |
| category/execution/ethereum/db/test/test_db.cpp | Expands namespace test to validate merge behavior and stale-state rejection. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
The changes cleanly extend BlockState::can_merge and BlockState::merge to route to the correct StateDeltas based on the State's namespace, mirroring the pattern already used in read_account / read_storage. The test covers namespace-scoped merges, cross-namespace isolation, and rejection of a stale state after an intervening merge.
A few very minor style/redundancy notes, none blocking:
MONAD_ASSERT(state_)at the top ofcan_mergeand the innerMONAD_ASSERT(deltas)in the loop are redundant now that the namespace branch already establishesdeltas(andstate_is a construction-time invariant).mergeusesNamespacedStateDeltas::accessor(write lock) but only needs aconst_accessorsince it mutates only the pointed-toStateDeltas, not the outer map.- The raw
deltaspointer outlives its accessor lock in both functions. This is safe today becausens_state_has noerasecode path, but worth keeping in mind if erasure is ever added.
Verdict: CORRECT
🤖 Generated with Claude Code
No description provided.