Skip to content
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

fix(engine): return error on StateRootTask multiproof and root calculation failures #13356

Merged
merged 1 commit into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions crates/engine/tree/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ reth-consensus.workspace = true
reth-engine-primitives.workspace = true
reth-errors.workspace = true
reth-evm.workspace = true
reth-execution-errors.workspace = true
reth-network-p2p.workspace = true
reth-payload-builder-primitives.workspace = true
reth-payload-builder.workspace = true
Expand Down
22 changes: 19 additions & 3 deletions crates/engine/tree/src/tree/root.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
use alloy_primitives::map::{HashMap, HashSet};
use rayon::iter::{ParallelBridge, ParallelIterator};
use reth_evm::system_calls::OnStateHook;
use reth_execution_errors::StateProofError;
use reth_provider::{
providers::ConsistentDbView, BlockReader, DBProvider, DatabaseProviderFactory,
StateCommitmentProvider,
Expand All @@ -15,7 +16,7 @@ use reth_trie_db::DatabaseProof;
use reth_trie_parallel::root::ParallelStateRootError;
use reth_trie_sparse::{
blinded::{BlindedProvider, BlindedProviderFactory},
errors::{SparseStateTrieResult, SparseTrieError, SparseTrieErrorKind},
errors::{SparseStateTrieError, SparseStateTrieResult, SparseTrieError, SparseTrieErrorKind},
SparseStateTrie,
};
use revm_primitives::{keccak256, EvmState, B256};
Expand Down Expand Up @@ -82,13 +83,17 @@ pub enum StateRootMessage<BPF: BlindedProviderFactory> {
/// The index of this proof in the sequence of state updates
sequence_number: u64,
},
/// Error during proof calculation
ProofCalculationError(StateProofError),
/// State root calculation completed
RootCalculated {
/// The updated sparse trie
trie: Box<SparseStateTrie<BPF>>,
/// Time taken to calculate the root
elapsed: Duration,
},
/// Error during state root calculation
RootCalculationError(SparseStateTrieError),
/// Signals state update stream end.
FinishedStateUpdates,
}
Expand Down Expand Up @@ -344,7 +349,8 @@ where
});
}
Err(e) => {
error!(target: "engine::root", error = ?e, "Could not calculate multiproof");
let _ =
state_root_message_sender.send(StateRootMessage::ProofCalculationError(e));
}
}
});
Expand Down Expand Up @@ -403,7 +409,7 @@ where
let _ = tx.send(StateRootMessage::RootCalculated { trie, elapsed });
}
Err(e) => {
error!(target: "engine::root", error = ?e, "Could not calculate state root");
let _ = tx.send(StateRootMessage::RootCalculationError(e));
}
}
});
Expand Down Expand Up @@ -524,6 +530,16 @@ where
return Ok((root, trie_updates));
}
}
StateRootMessage::ProofCalculationError(e) => {
return Err(ParallelStateRootError::Other(format!(
"could not calculate multiproof: {e:?}"
)))
}
StateRootMessage::RootCalculationError(e) => {
return Err(ParallelStateRootError::Other(format!(
Copy link
Collaborator

@shekhirin shekhirin Dec 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

think we should introduce a custom error enum for the state root task, we seem to abuse the ParallelStateRootError::Other. can be done in a separate PR via a good first issue

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shekhirin, this is a good idea. Can we create this custom error enum within the state root task?

"could not calculate state root: {e:?}"
)))
}
},
Err(_) => {
// this means our internal message channel is closed, which shouldn't happen
Expand Down
Loading