Skip to content

Commit

Permalink
chore: add docs for why descendant checks are safe
Browse files Browse the repository at this point in the history
  • Loading branch information
Rjected committed Nov 27, 2024
1 parent 24861bc commit 1424010
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions crates/engine/tree/src/tree/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2267,12 +2267,13 @@ where

// TODO: switch to calculate state root using `StateRootTask`.

// We attempt to compute state root in parallel if we are currently not persisting anything
// to database. This is safe, because the database state cannot change until we
// finish parallel computation. It is important that nothing is being persisted as
// we are computing in parallel, because we initialize a different database transaction
// per thread and it might end up with a different view of the database.
// let persistence_in_progress = self.persistence_state.in_progress();
// We only run the parallel state root if we are currently persisting blocks that are all
// ancestors of the one we are executing. If we're committing ancestor blocks, then: any
// trie updates being committed are a subset of the in-memory trie updates collected before
// fetching reverts. So any diff in reverts (pre vs post commit) is already covered by the
// in-memory trie updates we collect in `compute_state_root_parallel`.
//
// See https://github.com/paradigmxyz/reth/issues/12688 for more details
let is_descendant_block = self.persistence_state.current_action().map_or(true, |action| {
match action {
CurrentPersistenceAction::SavingBlocks { blocks } => {
Expand Down

0 comments on commit 1424010

Please sign in to comment.