diff --git a/Cargo.lock b/Cargo.lock index 0f001fea0..91ab9d891 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7998,7 +7998,6 @@ dependencies = [ name = "reth-node-api" version = "1.1.2" dependencies = [ - "alloy-consensus", "alloy-rpc-types-engine", "eyre", "reth-beacon-consensus", diff --git a/crates/engine/invalid-block-hooks/src/witness.rs b/crates/engine/invalid-block-hooks/src/witness.rs index 98ee8dd2d..08681a9d1 100644 --- a/crates/engine/invalid-block-hooks/src/witness.rs +++ b/crates/engine/invalid-block-hooks/src/witness.rs @@ -1,4 +1,4 @@ -use alloy_consensus::Header; +use alloy_consensus::BlockHeader; use alloy_primitives::{keccak256, B256, U256}; use alloy_rpc_types_debug::ExecutionWitness; use eyre::OptionExt; @@ -8,8 +8,8 @@ use reth_engine_primitives::InvalidBlockHook; use reth_evm::{ state_change::post_block_balance_increments, system_calls::SystemCaller, ConfigureEvm, }; -use reth_primitives::{Receipt, SealedBlockWithSenders, SealedHeader}; -use reth_primitives_traits::SignedTransaction; +use reth_primitives::{NodePrimitives, SealedBlockWithSenders, SealedHeader, TransactionSigned}; +use reth_primitives_traits::{HeaderTy, SignedTransaction}; use reth_provider::{BlockExecutionOutput, ChainSpecProvider, StateProviderFactory}; use reth_revm::{ database::StateProviderDatabase, db::states::bundle_state::BundleRetention, @@ -54,15 +54,18 @@ where + Send + Sync + 'static, - EvmConfig: ConfigureEvm
, { - fn on_invalid_block( + fn on_invalid_block( &self, - parent_header: &SealedHeader, - block: &SealedBlockWithSenders, - output: &BlockExecutionOutput, + parent_header: &SealedHeader, + block: &SealedBlockWithSenders, + output: &BlockExecutionOutput, trie_updates: Option<(&TrieUpdates, B256)>, - ) -> eyre::Result<()> { + ) -> eyre::Result<()> + where + N: NodePrimitives, + EvmConfig: ConfigureEvm
, + { // TODO(alexey): unify with `DebugApi::debug_execution_witness` // Setup database. @@ -86,7 +89,7 @@ where SystemCaller::new(self.evm_config.clone(), self.provider.chain_spec()); // Apply pre-block system contract calls. - system_caller.apply_pre_execution_changes(&block.clone().unseal(), &mut evm)?; + system_caller.apply_pre_execution_changes(&block.clone().unseal().block, &mut evm)?; // Re-execute all of the transactions in the block to load all touched accounts into // the cache DB. @@ -106,7 +109,7 @@ where // NOTE: This is not mut because we are not doing the DAO irregular state change here let balance_increments = post_block_balance_increments( self.provider.chain_spec().as_ref(), - &block.block.clone().unseal(), + &block.clone().unseal().block, U256::MAX, ); @@ -163,24 +166,24 @@ where keys: state_preimages, }; let re_executed_witness_path = self.save_file( - format!("{}_{}.witness.re_executed.json", block.number, block.hash()), + format!("{}_{}.witness.re_executed.json", block.number(), block.hash()), &response, )?; if let Some(healthy_node_client) = &self.healthy_node_client { // Compare the witness against the healthy node. let healthy_node_witness = futures::executor::block_on(async move { - DebugApiClient::debug_execution_witness(healthy_node_client, block.number.into()) + DebugApiClient::debug_execution_witness(healthy_node_client, block.number().into()) .await })?; let healthy_path = self.save_file( - format!("{}_{}.witness.healthy.json", block.number, block.hash()), + format!("{}_{}.witness.healthy.json", block.number(), block.hash()), &healthy_node_witness, )?; // If the witnesses are different, write the diff to the output directory. if response != healthy_node_witness { - let filename = format!("{}_{}.witness.diff", block.number, block.hash()); + let filename = format!("{}_{}.witness.diff", block.number(), block.hash()); let diff_path = self.save_diff(filename, &response, &healthy_node_witness)?; warn!( target: "engine::invalid_block_hooks::witness", @@ -210,15 +213,15 @@ where if bundle_state != output.state { let original_path = self.save_file( - format!("{}_{}.bundle_state.original.json", block.number, block.hash()), + format!("{}_{}.bundle_state.original.json", block.number(), block.hash()), &output.state, )?; let re_executed_path = self.save_file( - format!("{}_{}.bundle_state.re_executed.json", block.number, block.hash()), + format!("{}_{}.bundle_state.re_executed.json", block.number(), block.hash()), &bundle_state, )?; - let filename = format!("{}_{}.bundle_state.diff", block.number, block.hash()); + let filename = format!("{}_{}.bundle_state.diff", block.number(), block.hash()); let diff_path = self.save_diff(filename, &bundle_state, &output.state)?; warn!( @@ -236,26 +239,27 @@ where state_provider.state_root_with_updates(hashed_state)?; if let Some((original_updates, original_root)) = trie_updates { if re_executed_root != original_root { - let filename = format!("{}_{}.state_root.diff", block.number, block.hash()); + let filename = format!("{}_{}.state_root.diff", block.number(), block.hash()); let diff_path = self.save_diff(filename, &re_executed_root, &original_root)?; warn!(target: "engine::invalid_block_hooks::witness", ?original_root, ?re_executed_root, diff_path = %diff_path.display(), "State root mismatch after re-execution"); } // If the re-executed state root does not match the _header_ state root, also log that. - if re_executed_root != block.state_root { - let filename = format!("{}_{}.header_state_root.diff", block.number, block.hash()); - let diff_path = self.save_diff(filename, &re_executed_root, &block.state_root)?; - warn!(target: "engine::invalid_block_hooks::witness", header_state_root=?block.state_root, ?re_executed_root, diff_path = %diff_path.display(), "Re-executed state root does not match block state root"); + if re_executed_root != block.state_root() { + let filename = + format!("{}_{}.header_state_root.diff", block.number(), block.hash()); + let diff_path = self.save_diff(filename, &re_executed_root, &block.state_root())?; + warn!(target: "engine::invalid_block_hooks::witness", header_state_root=?block.state_root(), ?re_executed_root, diff_path = %diff_path.display(), "Re-executed state root does not match block state root"); } if &trie_output != original_updates { // Trie updates are too big to diff, so we just save the original and re-executed let original_path = self.save_file( - format!("{}_{}.trie_updates.original.json", block.number, block.hash()), + format!("{}_{}.trie_updates.original.json", block.number(), block.hash()), original_updates, )?; let re_executed_path = self.save_file( - format!("{}_{}.trie_updates.re_executed.json", block.number, block.hash()), + format!("{}_{}.trie_updates.re_executed.json", block.number(), block.hash()), &trie_output, )?; warn!( @@ -292,23 +296,24 @@ where } } -impl InvalidBlockHook for InvalidBlockWitnessHook +impl InvalidBlockHook for InvalidBlockWitnessHook where + N: NodePrimitives, P: StateProviderFactory + ChainSpecProvider + Send + Sync + 'static, - EvmConfig: ConfigureEvm
, + EvmConfig: ConfigureEvm
>, { fn on_invalid_block( &self, - parent_header: &SealedHeader, - block: &SealedBlockWithSenders, - output: &BlockExecutionOutput, + parent_header: &SealedHeader, + block: &SealedBlockWithSenders, + output: &BlockExecutionOutput, trie_updates: Option<(&TrieUpdates, B256)>, ) { - if let Err(err) = self.on_invalid_block(parent_header, block, output, trie_updates) { + if let Err(err) = self.on_invalid_block::(parent_header, block, output, trie_updates) { warn!(target: "engine::invalid_block_hooks::witness", %err, "Failed to invoke hook"); } } diff --git a/crates/engine/local/src/service.rs b/crates/engine/local/src/service.rs index b06750d66..b8cab9997 100644 --- a/crates/engine/local/src/service.rs +++ b/crates/engine/local/src/service.rs @@ -72,7 +72,7 @@ where payload_builder: PayloadBuilderHandle, payload_validator: V, tree_config: TreeConfig, - invalid_block_hook: Box, + invalid_block_hook: Box>, sync_metrics_tx: MetricEventsSender, to_engine: UnboundedSender>, from_engine: EngineMessageStream, diff --git a/crates/engine/primitives/src/invalid_block_hook.rs b/crates/engine/primitives/src/invalid_block_hook.rs index 13c606511..cfd127ae6 100644 --- a/crates/engine/primitives/src/invalid_block_hook.rs +++ b/crates/engine/primitives/src/invalid_block_hook.rs @@ -1,35 +1,36 @@ use alloy_primitives::B256; use reth_execution_types::BlockExecutionOutput; -use reth_primitives::{Receipt, SealedBlockWithSenders, SealedHeader}; +use reth_primitives::{NodePrimitives, SealedBlockWithSenders, SealedHeader}; use reth_trie::updates::TrieUpdates; /// An invalid block hook. -pub trait InvalidBlockHook: Send + Sync { +pub trait InvalidBlockHook: Send + Sync { /// Invoked when an invalid block is encountered. fn on_invalid_block( &self, - parent_header: &SealedHeader, - block: &SealedBlockWithSenders, - output: &BlockExecutionOutput, + parent_header: &SealedHeader, + block: &SealedBlockWithSenders, + output: &BlockExecutionOutput, trie_updates: Option<(&TrieUpdates, B256)>, ); } -impl InvalidBlockHook for F +impl InvalidBlockHook for F where + N: NodePrimitives, F: Fn( - &SealedHeader, - &SealedBlockWithSenders, - &BlockExecutionOutput, + &SealedHeader, + &SealedBlockWithSenders, + &BlockExecutionOutput, Option<(&TrieUpdates, B256)>, ) + Send + Sync, { fn on_invalid_block( &self, - parent_header: &SealedHeader, - block: &SealedBlockWithSenders, - output: &BlockExecutionOutput, + parent_header: &SealedHeader, + block: &SealedBlockWithSenders, + output: &BlockExecutionOutput, trie_updates: Option<(&TrieUpdates, B256)>, ) { self(parent_header, block, output, trie_updates) diff --git a/crates/engine/service/src/service.rs b/crates/engine/service/src/service.rs index d3c07c638..bc3e36bea 100644 --- a/crates/engine/service/src/service.rs +++ b/crates/engine/service/src/service.rs @@ -78,7 +78,7 @@ where payload_builder: PayloadBuilderHandle, payload_validator: V, tree_config: TreeConfig, - invalid_block_hook: Box, + invalid_block_hook: Box>, sync_metrics_tx: MetricEventsSender, ) -> Self where diff --git a/crates/engine/tree/src/tree/invalid_block_hook.rs b/crates/engine/tree/src/tree/invalid_block_hook.rs index 98244ed13..7c7b0631d 100644 --- a/crates/engine/tree/src/tree/invalid_block_hook.rs +++ b/crates/engine/tree/src/tree/invalid_block_hook.rs @@ -1,6 +1,6 @@ use alloy_primitives::B256; use reth_engine_primitives::InvalidBlockHook; -use reth_primitives::{Receipt, SealedBlockWithSenders, SealedHeader}; +use reth_primitives::{NodePrimitives, SealedBlockWithSenders, SealedHeader}; use reth_provider::BlockExecutionOutput; use reth_trie::updates::TrieUpdates; @@ -9,32 +9,32 @@ use reth_trie::updates::TrieUpdates; #[non_exhaustive] pub struct NoopInvalidBlockHook; -impl InvalidBlockHook for NoopInvalidBlockHook { +impl InvalidBlockHook for NoopInvalidBlockHook { fn on_invalid_block( &self, - _parent_header: &SealedHeader, - _block: &SealedBlockWithSenders, - _output: &BlockExecutionOutput, + _parent_header: &SealedHeader, + _block: &SealedBlockWithSenders, + _output: &BlockExecutionOutput, _trie_updates: Option<(&TrieUpdates, B256)>, ) { } } /// Multiple [`InvalidBlockHook`]s that are executed in order. -pub struct InvalidBlockHooks(pub Vec>); +pub struct InvalidBlockHooks(pub Vec>>); -impl std::fmt::Debug for InvalidBlockHooks { +impl std::fmt::Debug for InvalidBlockHooks { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { f.debug_struct("InvalidBlockHooks").field("len", &self.0.len()).finish() } } -impl InvalidBlockHook for InvalidBlockHooks { +impl InvalidBlockHook for InvalidBlockHooks { fn on_invalid_block( &self, - parent_header: &SealedHeader, - block: &SealedBlockWithSenders, - output: &BlockExecutionOutput, + parent_header: &SealedHeader, + block: &SealedBlockWithSenders, + output: &BlockExecutionOutput, trie_updates: Option<(&TrieUpdates, B256)>, ) { for hook in &self.0 { diff --git a/crates/engine/tree/src/tree/mod.rs b/crates/engine/tree/src/tree/mod.rs index 16e07e518..c65035973 100644 --- a/crates/engine/tree/src/tree/mod.rs +++ b/crates/engine/tree/src/tree/mod.rs @@ -469,6 +469,7 @@ pub enum TreeAction { /// emitting events. pub struct EngineApiTreeHandler where + N: NodePrimitives, T: EngineTypes, { provider: P, @@ -507,7 +508,7 @@ where /// Metrics for the engine api. metrics: EngineApiMetrics, /// An invalid block hook. - invalid_block_hook: Box, + invalid_block_hook: Box>, /// The engine API variant of this handler engine_kind: EngineApiKind, /// Captures the types the engine operates on @@ -516,6 +517,8 @@ where impl std::fmt::Debug for EngineApiTreeHandler +where + N: NodePrimitives, { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { f.debug_struct("EngineApiTreeHandler") @@ -597,7 +600,7 @@ where } /// Sets the invalid block hook. - fn set_invalid_block_hook(&mut self, invalid_block_hook: Box) { + fn set_invalid_block_hook(&mut self, invalid_block_hook: Box>) { self.invalid_block_hook = invalid_block_hook; } @@ -616,7 +619,7 @@ where payload_builder: PayloadBuilderHandle, canonical_in_memory_state: CanonicalInMemoryState, config: TreeConfig, - invalid_block_hook: Box, + invalid_block_hook: Box>, kind: EngineApiKind, ) -> (Sender>>, UnboundedReceiver) { let best_block_number = provider.best_block_number().unwrap_or(0); diff --git a/crates/ethereum/evm/src/execute.rs b/crates/ethereum/evm/src/execute.rs index 65fbbdd25..e21b42433 100644 --- a/crates/ethereum/evm/src/execute.rs +++ b/crates/ethereum/evm/src/execute.rs @@ -152,7 +152,7 @@ where let env = self.evm_env_for_block(&block.header, total_difficulty); let mut evm = self.evm_config.evm_with_env(&mut self.state, env); - self.system_caller.apply_pre_execution_changes(block, &mut evm)?; + self.system_caller.apply_pre_execution_changes(&block.block, &mut evm)?; Ok(()) } @@ -247,7 +247,7 @@ where drop(evm); let mut balance_increments = - post_block_balance_increments(&self.chain_spec, block, total_difficulty); + post_block_balance_increments(&self.chain_spec, &block.block, total_difficulty); // Irregular state change at Ethereum DAO hardfork if self.chain_spec.fork(EthereumHardfork::Dao).transitions_at_block(block.number) { diff --git a/crates/evm/src/state_change.rs b/crates/evm/src/state_change.rs index 0e207fc2d..5104c4663 100644 --- a/crates/evm/src/state_change.rs +++ b/crates/evm/src/state_change.rs @@ -1,43 +1,55 @@ //! State changes that are not related to transactions. +use alloy_consensus::BlockHeader; use alloy_eips::eip4895::Withdrawal; use alloy_primitives::{map::HashMap, Address, U256}; use reth_chainspec::EthereumHardforks; use reth_consensus_common::calc; -use reth_primitives::Block; +use reth_primitives_traits::BlockBody; /// Collect all balance changes at the end of the block. /// /// Balance changes might include the block reward, uncle rewards, withdrawals, or irregular /// state changes (DAO fork). #[inline] -pub fn post_block_balance_increments( +pub fn post_block_balance_increments( chain_spec: &ChainSpec, block: &Block, total_difficulty: U256, -) -> HashMap { +) -> HashMap +where + ChainSpec: EthereumHardforks, + Block: reth_primitives_traits::Block, +{ let mut balance_increments = HashMap::default(); // Add block rewards if they are enabled. - if let Some(base_block_reward) = - calc::base_block_reward(chain_spec, block.number, block.difficulty, total_difficulty) - { + if let Some(base_block_reward) = calc::base_block_reward( + chain_spec, + block.header().number(), + block.header().difficulty(), + total_difficulty, + ) { // Ommer rewards - for ommer in &block.body.ommers { - *balance_increments.entry(ommer.beneficiary).or_default() += - calc::ommer_reward(base_block_reward, block.number, ommer.number); + if let Some(ommers) = block.body().ommers() { + for ommer in ommers { + *balance_increments.entry(ommer.beneficiary()).or_default() += + calc::ommer_reward(base_block_reward, block.header().number(), ommer.number()); + } } // Full block reward - *balance_increments.entry(block.beneficiary).or_default() += - calc::block_reward(base_block_reward, block.body.ommers.len()); + *balance_increments.entry(block.header().beneficiary()).or_default() += calc::block_reward( + base_block_reward, + block.body().ommers().map(|s| s.len()).unwrap_or(0), + ); } // process withdrawals insert_post_block_withdrawals_balance_increments( chain_spec, - block.timestamp, - block.body.withdrawals.as_ref().map(|w| w.as_slice()), + block.header().timestamp(), + block.body().withdrawals().as_ref().map(|w| w.as_slice()), &mut balance_increments, ); diff --git a/crates/evm/src/system_calls/eip2935.rs b/crates/evm/src/system_calls/eip2935.rs index 4848feb72..0cc2b83a3 100644 --- a/crates/evm/src/system_calls/eip2935.rs +++ b/crates/evm/src/system_calls/eip2935.rs @@ -4,7 +4,6 @@ use alloc::{boxed::Box, string::ToString}; use alloy_eips::eip2935::HISTORY_STORAGE_ADDRESS; use crate::ConfigureEvm; -use alloy_consensus::Header; use alloy_primitives::B256; use reth_chainspec::EthereumHardforks; use reth_execution_errors::{BlockExecutionError, BlockValidationError}; @@ -35,7 +34,7 @@ pub(crate) fn transact_blockhashes_contract_call( where DB: Database, DB::Error: core::fmt::Display, - EvmConfig: ConfigureEvm
, + EvmConfig: ConfigureEvm, { if !chain_spec.is_prague_active_at_timestamp(block_timestamp) { return Ok(None) diff --git a/crates/evm/src/system_calls/eip4788.rs b/crates/evm/src/system_calls/eip4788.rs index 2ad02c26e..bfd579721 100644 --- a/crates/evm/src/system_calls/eip4788.rs +++ b/crates/evm/src/system_calls/eip4788.rs @@ -2,7 +2,6 @@ use alloc::{boxed::Box, string::ToString}; use crate::ConfigureEvm; -use alloy_consensus::Header; use alloy_eips::eip4788::BEACON_ROOTS_ADDRESS; use alloy_primitives::B256; use reth_chainspec::EthereumHardforks; @@ -31,7 +30,7 @@ pub(crate) fn transact_beacon_root_contract_call( where DB: Database, DB::Error: core::fmt::Display, - EvmConfig: ConfigureEvm
, + EvmConfig: ConfigureEvm, Spec: EthereumHardforks, { if !chain_spec.is_cancun_active_at_timestamp(block_timestamp) { diff --git a/crates/evm/src/system_calls/eip7002.rs b/crates/evm/src/system_calls/eip7002.rs index f20b7a54c..d3c6d8490 100644 --- a/crates/evm/src/system_calls/eip7002.rs +++ b/crates/evm/src/system_calls/eip7002.rs @@ -1,7 +1,6 @@ //! [EIP-7002](https://eips.ethereum.org/EIPS/eip-7002) system call implementation. use crate::ConfigureEvm; use alloc::{boxed::Box, format}; -use alloy_consensus::Header; use alloy_eips::eip7002::WITHDRAWAL_REQUEST_PREDEPLOY_ADDRESS; use alloy_primitives::Bytes; use reth_execution_errors::{BlockExecutionError, BlockValidationError}; @@ -21,7 +20,7 @@ pub(crate) fn transact_withdrawal_requests_contract_call( where DB: Database, DB::Error: core::fmt::Display, - EvmConfig: ConfigureEvm
, + EvmConfig: ConfigureEvm, { // get previous env let previous_env = Box::new(evm.context.env().clone()); diff --git a/crates/evm/src/system_calls/eip7251.rs b/crates/evm/src/system_calls/eip7251.rs index 112f724df..28ae0160c 100644 --- a/crates/evm/src/system_calls/eip7251.rs +++ b/crates/evm/src/system_calls/eip7251.rs @@ -1,7 +1,6 @@ //! [EIP-7251](https://eips.ethereum.org/EIPS/eip-7251) system call implementation. use crate::ConfigureEvm; use alloc::{boxed::Box, format}; -use alloy_consensus::Header; use alloy_eips::eip7251::CONSOLIDATION_REQUEST_PREDEPLOY_ADDRESS; use alloy_primitives::Bytes; use reth_execution_errors::{BlockExecutionError, BlockValidationError}; @@ -22,7 +21,7 @@ pub(crate) fn transact_consolidation_requests_contract_call( where DB: Database, DB::Error: core::fmt::Display, - EvmConfig: ConfigureEvm
, + EvmConfig: ConfigureEvm, { // get previous env let previous_env = Box::new(evm.context.env().clone()); diff --git a/crates/evm/src/system_calls/mod.rs b/crates/evm/src/system_calls/mod.rs index 2a5b80ad6..8af72094b 100644 --- a/crates/evm/src/system_calls/mod.rs +++ b/crates/evm/src/system_calls/mod.rs @@ -2,7 +2,7 @@ use crate::ConfigureEvm; use alloc::{boxed::Box, sync::Arc}; -use alloy_consensus::Header; +use alloy_consensus::BlockHeader; use alloy_eips::{ eip7002::WITHDRAWAL_REQUEST_TYPE, eip7251::CONSOLIDATION_REQUEST_TYPE, eip7685::Requests, }; @@ -10,7 +10,6 @@ use alloy_primitives::Bytes; use core::fmt::Display; use reth_chainspec::EthereumHardforks; use reth_execution_errors::BlockExecutionError; -use reth_primitives::Block; use revm::{Database, DatabaseCommit, Evm}; use revm_primitives::{BlockEnv, CfgEnvWithHandlerCfg, EnvWithHandlerCfg, EvmState, B256}; @@ -91,11 +90,11 @@ where impl SystemCaller where - EvmConfig: ConfigureEvm
, + EvmConfig: ConfigureEvm, Chainspec: EthereumHardforks, { /// Apply pre execution changes. - pub fn apply_pre_execution_changes( + pub fn apply_pre_execution_changes( &mut self, block: &Block, evm: &mut Evm<'_, Ext, DB>, @@ -103,17 +102,18 @@ where where DB: Database + DatabaseCommit, DB::Error: Display, + Block: reth_primitives_traits::Block
, { self.apply_blockhashes_contract_call( - block.timestamp, - block.number, - block.parent_hash, + block.header().timestamp(), + block.header().number(), + block.header().parent_hash(), evm, )?; self.apply_beacon_root_contract_call( - block.timestamp, - block.number, - block.parent_beacon_block_root, + block.header().timestamp(), + block.header().number(), + block.header().parent_beacon_block_root(), evm, )?; diff --git a/crates/node/api/Cargo.toml b/crates/node/api/Cargo.toml index ab4595d33..7d209a90f 100644 --- a/crates/node/api/Cargo.toml +++ b/crates/node/api/Cargo.toml @@ -26,6 +26,5 @@ reth-node-types.workspace = true reth-node-core.workspace = true alloy-rpc-types-engine.workspace = true -alloy-consensus.workspace = true eyre.workspace = true diff --git a/crates/node/api/src/node.rs b/crates/node/api/src/node.rs index 83947208c..1b490c4cf 100644 --- a/crates/node/api/src/node.rs +++ b/crates/node/api/src/node.rs @@ -1,14 +1,13 @@ //! Traits for configuring a node. use crate::ConfigureEvm; -use alloy_consensus::Header; use alloy_rpc_types_engine::JwtSecret; use reth_beacon_consensus::BeaconConsensusEngineHandle; use reth_consensus::FullConsensus; use reth_evm::execute::BlockExecutorProvider; use reth_network_api::FullNetwork; use reth_node_core::node_config::NodeConfig; -use reth_node_types::{NodeTypes, NodeTypesWithDB, NodeTypesWithEngine, TxTy}; +use reth_node_types::{HeaderTy, NodeTypes, NodeTypesWithDB, NodeTypesWithEngine, TxTy}; use reth_payload_builder_primitives::PayloadBuilder; use reth_provider::FullProvider; use reth_tasks::TaskExecutor; @@ -50,7 +49,7 @@ pub trait FullNodeComponents: FullNodeTypes + Clone + 'static { type Pool: TransactionPool>> + Unpin; /// The node's EVM configuration, defining settings for the Ethereum Virtual Machine. - type Evm: ConfigureEvm
; + type Evm: ConfigureEvm
>; /// The type that knows how to execute blocks. type Executor: BlockExecutorProvider::Primitives>; diff --git a/crates/node/builder/src/components/builder.rs b/crates/node/builder/src/components/builder.rs index 4c04c9200..15f6c1231 100644 --- a/crates/node/builder/src/components/builder.rs +++ b/crates/node/builder/src/components/builder.rs @@ -7,10 +7,9 @@ use crate::{ }, BuilderContext, ConfigureEvm, FullNodeTypes, }; -use alloy_consensus::Header; use reth_consensus::FullConsensus; use reth_evm::execute::BlockExecutorProvider; -use reth_node_api::{NodeTypes, NodeTypesWithEngine, TxTy}; +use reth_node_api::{HeaderTy, NodeTypes, NodeTypesWithEngine, TxTy}; use reth_payload_builder::PayloadBuilderHandle; use reth_transaction_pool::{PoolTransaction, TransactionPool}; use std::{future::Future, marker::PhantomData}; @@ -378,7 +377,7 @@ where Pool: TransactionPool>> + Unpin + 'static, - EVM: ConfigureEvm
, + EVM: ConfigureEvm
>, Executor: BlockExecutorProvider::Primitives>, Cons: FullConsensus<::Primitives> + Clone + Unpin + 'static, { diff --git a/crates/node/builder/src/components/execute.rs b/crates/node/builder/src/components/execute.rs index 0c75ef301..5ecc67d8b 100644 --- a/crates/node/builder/src/components/execute.rs +++ b/crates/node/builder/src/components/execute.rs @@ -1,8 +1,7 @@ //! EVM component for the node builder. use crate::{BuilderContext, FullNodeTypes}; -use alloy_consensus::Header; use reth_evm::execute::BlockExecutorProvider; -use reth_node_api::ConfigureEvm; +use reth_node_api::{ConfigureEvm, HeaderTy}; use std::future::Future; /// A type that knows how to build the executor types. @@ -10,7 +9,7 @@ pub trait ExecutorBuilder: Send { /// The EVM config to use. /// /// This provides the node with the necessary configuration to configure an EVM. - type EVM: ConfigureEvm
; + type EVM: ConfigureEvm
>; /// The type that knows how to execute blocks. type Executor: BlockExecutorProvider< @@ -27,7 +26,7 @@ pub trait ExecutorBuilder: Send { impl ExecutorBuilder for F where Node: FullNodeTypes, - EVM: ConfigureEvm
, + EVM: ConfigureEvm
>, Executor: BlockExecutorProvider::Primitives>, F: FnOnce(&BuilderContext) -> Fut + Send, diff --git a/crates/node/builder/src/components/mod.rs b/crates/node/builder/src/components/mod.rs index 22a47e3da..764277dcb 100644 --- a/crates/node/builder/src/components/mod.rs +++ b/crates/node/builder/src/components/mod.rs @@ -22,12 +22,11 @@ pub use payload::*; pub use pool::*; use crate::{ConfigureEvm, FullNodeTypes}; -use alloy_consensus::Header; use reth_consensus::FullConsensus; use reth_evm::execute::BlockExecutorProvider; use reth_network::NetworkHandle; use reth_network_api::FullNetwork; -use reth_node_api::{NodeTypes, NodeTypesWithEngine, TxTy}; +use reth_node_api::{HeaderTy, NodeTypes, NodeTypesWithEngine, TxTy}; use reth_payload_builder::PayloadBuilderHandle; use reth_transaction_pool::{PoolTransaction, TransactionPool}; @@ -41,7 +40,7 @@ pub trait NodeComponents: Clone + Unpin + Send + Sync + 'stati type Pool: TransactionPool>> + Unpin; /// The node's EVM configuration, defining settings for the Ethereum Virtual Machine. - type Evm: ConfigureEvm
; + type Evm: ConfigureEvm
>; /// The type that knows how to execute blocks. type Executor: BlockExecutorProvider::Primitives>; @@ -100,7 +99,7 @@ where Pool: TransactionPool>> + Unpin + 'static, - EVM: ConfigureEvm
, + EVM: ConfigureEvm
>, Executor: BlockExecutorProvider::Primitives>, Cons: FullConsensus<::Primitives> + Clone + Unpin + 'static, { @@ -140,7 +139,7 @@ impl Clone for Components, + EVM: ConfigureEvm
>, Executor: BlockExecutorProvider, Cons: Clone, { diff --git a/crates/node/builder/src/launch/common.rs b/crates/node/builder/src/launch/common.rs index 25c81a8d5..f4557bd22 100644 --- a/crates/node/builder/src/launch/common.rs +++ b/crates/node/builder/src/launch/common.rs @@ -22,7 +22,9 @@ use reth_evm::noop::NoopBlockExecutorProvider; use reth_fs_util as fs; use reth_invalid_block_hooks::InvalidBlockWitnessHook; use reth_network_p2p::headers::client::HeadersClient; -use reth_node_api::{FullNodePrimitives, FullNodeTypes, NodeTypes, NodeTypesWithDB}; +use reth_node_api::{ + FullNodePrimitives, FullNodeTypes, NodePrimitives, NodeTypes, NodeTypesWithDB, +}; use reth_node_core::{ args::InvalidBlockHookType, dirs::{ChainPath, DataDirPath}, @@ -39,7 +41,7 @@ use reth_node_metrics::{ server::{MetricServer, MetricServerConfig}, version::VersionInfo, }; -use reth_primitives::Head; +use reth_primitives::{Head, TransactionSigned}; use reth_provider::{ providers::{ProviderNodeTypes, StaticFileProvider}, BlockHashReader, BlockNumReader, ChainSpecProvider, ProviderError, ProviderFactory, @@ -870,11 +872,16 @@ impl Attached::ChainSpec>, WithComponents>, > where - T: FullNodeTypes, + T: FullNodeTypes< + Provider: StateProviderFactory + ChainSpecProvider, + Types: ProviderNodeTypes>, + >, CB: NodeComponentsBuilder, { /// Returns the [`InvalidBlockHook`] to use for the node. - pub fn invalid_block_hook(&self) -> eyre::Result> { + pub fn invalid_block_hook( + &self, + ) -> eyre::Result::Primitives>>> { let Some(ref hook) = self.node_config().debug.invalid_block_hook else { return Ok(Box::new(NoopInvalidBlockHook::default())) }; @@ -898,7 +905,7 @@ where InvalidBlockHookType::PreState | InvalidBlockHookType::Opcode => { eyre::bail!("invalid block hook {hook:?} is not implemented yet") } - } as Box) + } as Box>) }) .collect::>()?; diff --git a/crates/optimism/evm/src/execute.rs b/crates/optimism/evm/src/execute.rs index 549f52c89..3673f73a8 100644 --- a/crates/optimism/evm/src/execute.rs +++ b/crates/optimism/evm/src/execute.rs @@ -258,7 +258,7 @@ where _receipts: &[Receipt], ) -> Result { let balance_increments = - post_block_balance_increments(&self.chain_spec.clone(), block, total_difficulty); + post_block_balance_increments(&self.chain_spec.clone(), &block.block, total_difficulty); // increment balances self.state .increment_balances(balance_increments.clone())