feat: allow external block recovery in reth-stateless (#17755)

This commit is contained in:
Wolfgang Welz
2025-08-12 14:44:52 -04:00
committed by GitHub
parent 6e691c0f38
commit 810790c767
2 changed files with 7 additions and 14 deletions

View File

@@ -4,7 +4,6 @@ use crate::{
ExecutionWitness,
};
use alloc::{
boxed::Box,
collections::BTreeMap,
fmt::Debug,
string::{String, ToString},
@@ -19,9 +18,7 @@ use reth_errors::ConsensusError;
use reth_ethereum_consensus::{validate_block_post_execution, EthBeaconConsensus};
use reth_ethereum_primitives::{Block, EthPrimitives};
use reth_evm::{execute::Executor, ConfigureEvm};
use reth_primitives_traits::{
block::error::BlockRecoveryError, Block as _, RecoveredBlock, SealedHeader,
};
use reth_primitives_traits::{RecoveredBlock, SealedHeader};
use reth_trie_common::{HashedPostState, KeccakKeyHasher};
/// Errors that can occur during stateless validation.
@@ -89,9 +86,9 @@ pub enum StatelessValidationError {
expected: B256,
},
/// Error when recovering signers
#[error("error recovering the signers in the block")]
SignerRecovery(#[from] Box<BlockRecoveryError<Block>>),
/// Custom error.
#[error("{0}")]
Custom(&'static str),
}
/// Performs stateless validation of a block using the provided witness data.
@@ -130,7 +127,7 @@ pub enum StatelessValidationError {
/// If all steps succeed the function returns `Some` containing the hash of the validated
/// `current_block`.
pub fn stateless_validation<ChainSpec, E>(
current_block: Block,
current_block: RecoveredBlock<Block>,
witness: ExecutionWitness,
chain_spec: Arc<ChainSpec>,
evm_config: E,
@@ -154,7 +151,7 @@ where
///
/// See `stateless_validation` for detailed documentation of the validation process.
pub fn stateless_validation_with_trie<T, ChainSpec, E>(
current_block: Block,
current_block: RecoveredBlock<Block>,
witness: ExecutionWitness,
chain_spec: Arc<ChainSpec>,
evm_config: E,
@@ -164,10 +161,6 @@ where
ChainSpec: Send + Sync + EthChainSpec<Header = Header> + EthereumHardforks + Debug,
E: ConfigureEvm<Primitives = EthPrimitives> + Clone + 'static,
{
let current_block = current_block
.try_into_recovered()
.map_err(|err| StatelessValidationError::SignerRecovery(Box::new(err)))?;
let mut ancestor_headers: Vec<_> = witness
.headers
.iter()

View File

@@ -323,7 +323,7 @@ fn run_case(case: &BlockchainTest) -> Result<(), Error> {
// Now validate using the stateless client if everything else passes
for (block, execution_witness) in program_inputs {
stateless_validation(
block.into_block(),
block,
execution_witness,
chain_spec.clone(),
EthEvmConfig::new(chain_spec.clone()),