Skip to content

Commit

Permalink
perf(engine): use ParallelProof::multiproof in StateRootTask
Browse files Browse the repository at this point in the history
  • Loading branch information
fgimenez committed Dec 11, 2024
1 parent 8f6492d commit 2dcc160
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 24 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions crates/engine/tree/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ reth-prune.workspace = true
reth-revm.workspace = true
reth-stages-api.workspace = true
reth-tasks.workspace = true
reth-trie-db.workspace = true
reth-trie-parallel.workspace = true
reth-trie-sparse.workspace = true
reth-trie.workspace = true
Expand Down Expand Up @@ -120,5 +119,4 @@ test-utils = [
"reth-tracing",
"reth-trie/test-utils",
"reth-prune-types?/test-utils",
"reth-trie-db/test-utils",
]
27 changes: 6 additions & 21 deletions crates/engine/tree/src/tree/root.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@ use alloy_primitives::map::{HashMap, HashSet};
use rayon::iter::{ParallelBridge, ParallelIterator};
use reth_evm::system_calls::OnStateHook;
use reth_provider::{
providers::ConsistentDbView, BlockReader, DBProvider, DatabaseProviderFactory,
StateCommitmentProvider,
providers::ConsistentDbView, BlockReader, DatabaseProviderFactory, StateCommitmentProvider,
};
use reth_trie::{
proof::Proof, updates::TrieUpdates, HashedPostState, HashedStorage, MultiProof,
MultiProofTargets, Nibbles, TrieInput,
updates::TrieUpdates, HashedPostState, HashedStorage, MultiProof, MultiProofTargets, Nibbles,
TrieInput,
};
use reth_trie_db::DatabaseProof;
use reth_trie_parallel::root::ParallelStateRootError;
use reth_trie_parallel::{proof::ParallelProof, root::ParallelStateRootError};
use reth_trie_sparse::{
errors::{SparseStateTrieResult, SparseTrieErrorKind},
SparseStateTrie,
Expand Down Expand Up @@ -310,21 +308,8 @@ where

// Dispatch proof gathering for this state update
rayon::spawn(move || {
let provider = match view.provider_ro() {
Ok(provider) => provider,
Err(error) => {
error!(target: "engine::root", ?error, "Could not get provider");
return;
}
};

// TODO: replace with parallel proof
let result = Proof::overlay_multiproof(
provider.tx_ref(),
// TODO(alexey): this clone can be expensive, we should avoid it
input.as_ref().clone(),
proof_targets,
);
let result = ParallelProof::new(view, input.clone()).multiproof(proof_targets);

match result {
Ok(proof) => {
let _ = state_root_message_sender.send(StateRootMessage::ProofCalculated {
Expand Down

0 comments on commit 2dcc160

Please sign in to comment.