mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-01-08 23:08:19 -05:00
chore: RecoveredBlock -> Block (#16321)
Co-authored-by: Roman Krasiuk <rokrassyuk@gmail.com>
This commit is contained in:
@@ -1,21 +1,22 @@
|
||||
use crate::{witness_db::WitnessDatabase, ExecutionWitness};
|
||||
use alloc::{
|
||||
boxed::Box,
|
||||
collections::BTreeMap,
|
||||
string::{String, ToString},
|
||||
sync::Arc,
|
||||
vec::Vec,
|
||||
};
|
||||
use alloy_consensus::{Block, BlockHeader, Header};
|
||||
use alloy_consensus::{BlockHeader, Header};
|
||||
use alloy_primitives::{keccak256, map::B256Map, B256};
|
||||
use alloy_rlp::Decodable;
|
||||
use reth_chainspec::ChainSpec;
|
||||
use reth_consensus::{Consensus, HeaderValidator};
|
||||
use reth_errors::ConsensusError;
|
||||
use reth_ethereum_consensus::{validate_block_post_execution, EthBeaconConsensus};
|
||||
use reth_ethereum_primitives::TransactionSigned;
|
||||
use reth_ethereum_primitives::Block;
|
||||
use reth_evm::{execute::Executor, ConfigureEvm};
|
||||
use reth_evm_ethereum::execute::EthExecutorProvider;
|
||||
use reth_primitives_traits::RecoveredBlock;
|
||||
use reth_primitives_traits::{block::error::BlockRecoveryError, Block as _, RecoveredBlock};
|
||||
use reth_revm::state::Bytecode;
|
||||
use reth_trie_common::{HashedPostState, KeccakKeyHasher};
|
||||
use reth_trie_sparse::{blinded::DefaultBlindedProviderFactory, SparseStateTrie};
|
||||
@@ -84,6 +85,10 @@ pub enum StatelessValidationError {
|
||||
/// The expected pre-state root from the previous block
|
||||
expected: B256,
|
||||
},
|
||||
|
||||
/// Error when recovering signers
|
||||
#[error("error recovering the signers in the block")]
|
||||
SignerRecovery(#[from] Box<BlockRecoveryError<Block>>),
|
||||
}
|
||||
|
||||
/// Performs stateless validation of a block using the provided witness data.
|
||||
@@ -122,10 +127,14 @@ pub enum StatelessValidationError {
|
||||
/// If all steps succeed the function returns `Some` containing the hash of the validated
|
||||
/// `current_block`.
|
||||
pub fn stateless_validation(
|
||||
current_block: RecoveredBlock<Block<TransactionSigned>>,
|
||||
current_block: Block,
|
||||
witness: ExecutionWitness,
|
||||
chain_spec: Arc<ChainSpec>,
|
||||
) -> Result<B256, StatelessValidationError> {
|
||||
let current_block = current_block
|
||||
.try_into_recovered()
|
||||
.map_err(|err| StatelessValidationError::SignerRecovery(Box::new(err)))?;
|
||||
|
||||
let mut ancestor_headers: Vec<Header> = witness
|
||||
.headers
|
||||
.iter()
|
||||
@@ -209,7 +218,7 @@ pub fn stateless_validation(
|
||||
/// transition function.
|
||||
fn validate_block_consensus(
|
||||
chain_spec: Arc<ChainSpec>,
|
||||
block: &RecoveredBlock<Block<TransactionSigned>>,
|
||||
block: &RecoveredBlock<Block>,
|
||||
) -> Result<(), StatelessValidationError> {
|
||||
let consensus = EthBeaconConsensus::new(chain_spec);
|
||||
|
||||
@@ -295,7 +304,7 @@ pub fn verify_execution_witness(
|
||||
/// If both checks pass, it returns a [`BTreeMap`] mapping the block number of each
|
||||
/// ancestor header to its corresponding block hash.
|
||||
fn compute_ancestor_hashes(
|
||||
current_block: &RecoveredBlock<Block<TransactionSigned>>,
|
||||
current_block: &RecoveredBlock<Block>,
|
||||
ancestor_headers: &[Header],
|
||||
) -> Result<BTreeMap<u64, B256>, StatelessValidationError> {
|
||||
let mut ancestor_hashes = BTreeMap::new();
|
||||
|
||||
@@ -319,7 +319,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, execution_witness, chain_spec.clone())
|
||||
stateless_validation(block.into_block(), execution_witness, chain_spec.clone())
|
||||
.expect("stateless validation failed");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user