From 5ef21cdfec9801b12dd740acc00970c5c778a2f2 Mon Sep 17 00:00:00 2001 From: Federico Gimenez Date: Thu, 12 Dec 2024 16:23:52 +0100 Subject: [PATCH] fix(engine): return error on StateRootTask multiproof and root calculation failures (#13356) --- Cargo.lock | 1 + crates/engine/tree/Cargo.toml | 1 + crates/engine/tree/src/tree/root.rs | 22 +++++++++++++++++++--- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6189481ca..21278d66f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7406,6 +7406,7 @@ dependencies = [ "reth-errors", "reth-ethereum-engine-primitives", "reth-evm", + "reth-execution-errors", "reth-exex-types", "reth-metrics", "reth-network-p2p", diff --git a/crates/engine/tree/Cargo.toml b/crates/engine/tree/Cargo.toml index f428c8771..73f0a5268 100644 --- a/crates/engine/tree/Cargo.toml +++ b/crates/engine/tree/Cargo.toml @@ -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 diff --git a/crates/engine/tree/src/tree/root.rs b/crates/engine/tree/src/tree/root.rs index 7254cc882..723d70ac5 100644 --- a/crates/engine/tree/src/tree/root.rs +++ b/crates/engine/tree/src/tree/root.rs @@ -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, @@ -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}; @@ -82,6 +83,8 @@ pub enum StateRootMessage { /// 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 @@ -89,6 +92,8 @@ pub enum StateRootMessage { /// Time taken to calculate the root elapsed: Duration, }, + /// Error during state root calculation + RootCalculationError(SparseStateTrieError), /// Signals state update stream end. FinishedStateUpdates, } @@ -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)); } } }); @@ -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)); } } }); @@ -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!( + "could not calculate state root: {e:?}" + ))) + } }, Err(_) => { // this means our internal message channel is closed, which shouldn't happen