-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
docs(trie): hashed post state & cursors #3572
Conversation
Codecov Report
... and 40 files with indirect coverage changes
Flags with carried forward coverage won't be shown. Click here to find out more.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ty,
what would be useful is an explainer how this works:
reth/crates/storage/provider/src/traits/state.rs
Lines 222 to 223 in b4801f9
/// Returns the state root of the PostState on top of the current state. | |
fn state_root(&self, post_state: PostState) -> Result<H256>; |
especially on PostState, it's not obvious how all the pieces tie together here which makes it very hard to understand why this can be a perf bottleneck:
there are like 4 steps required here to get the state root:
reth/crates/blockchain-tree/src/chain.rs
Lines 201 to 220 in b4801f9
let canonical_fork = post_state_data_provider.canonical_fork(); | |
let state_provider = db.history_by_block_number(canonical_fork.number)?; | |
let provider = PostStateProvider::new(state_provider, post_state_data_provider); | |
let mut executor = externals.executor_factory.with_sp(&provider); | |
let post_state = executor.execute_and_verify_receipt(&block, U256::MAX, Some(senders))?; | |
// check state root if the block extends the canonical chain. | |
if block_kind.extends_canonical_head() { | |
// check state root | |
let state_root = provider.state_root(post_state.clone())?; | |
if block.state_root != state_root { | |
return Err(ConsensusError::BodyStateRootDiff { | |
got: state_root, | |
expected: block.state_root, | |
} | |
.into()) | |
} | |
} |
@mattsse since this is already documented on reth/crates/storage/provider/src/post_state/mod.rs Lines 216 to 247 in 0042e9b
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
send it
Description
Improve documentation for the
HashedPostState
and cursors.@mattsse PTAL.