chore: move and integrate ConfigureEvmFor (#13896)

This commit is contained in:
Dan Cline
2025-01-21 12:56:17 -05:00
committed by GitHub
parent c1fd0ce4a1
commit ace28d8a90
11 changed files with 59 additions and 60 deletions

View File

@ -6,7 +6,7 @@ use pretty_assertions::Comparison;
use reth_chainspec::{EthChainSpec, EthereumHardforks}; use reth_chainspec::{EthChainSpec, EthereumHardforks};
use reth_engine_primitives::InvalidBlockHook; use reth_engine_primitives::InvalidBlockHook;
use reth_evm::{ use reth_evm::{
state_change::post_block_balance_increments, system_calls::SystemCaller, ConfigureEvm, Evm, state_change::post_block_balance_increments, system_calls::SystemCaller, ConfigureEvmFor, Evm,
}; };
use reth_primitives::{NodePrimitives, RecoveredBlock, SealedHeader}; use reth_primitives::{NodePrimitives, RecoveredBlock, SealedHeader};
use reth_primitives_traits::{BlockBody, SignedTransaction}; use reth_primitives_traits::{BlockBody, SignedTransaction};
@ -63,7 +63,7 @@ where
) -> eyre::Result<()> ) -> eyre::Result<()>
where where
N: NodePrimitives, N: NodePrimitives,
EvmConfig: ConfigureEvm<Header = N::BlockHeader, Transaction = N::SignedTx>, EvmConfig: ConfigureEvmFor<N>,
{ {
// TODO(alexey): unify with `DebugApi::debug_execution_witness` // TODO(alexey): unify with `DebugApi::debug_execution_witness`
@ -289,7 +289,7 @@ where
+ Send + Send
+ Sync + Sync
+ 'static, + 'static,
EvmConfig: ConfigureEvm<Header = N::BlockHeader, Transaction = N::SignedTx>, EvmConfig: ConfigureEvmFor<N>,
{ {
fn on_invalid_block( fn on_invalid_block(
&self, &self,

View File

@ -6,9 +6,9 @@ use reth_ethereum_engine_primitives::{
EthBuiltPayload, EthPayloadAttributes, EthPayloadBuilderAttributes, EthBuiltPayload, EthPayloadAttributes, EthPayloadBuilderAttributes,
}; };
use reth_ethereum_payload_builder::EthereumBuilderConfig; use reth_ethereum_payload_builder::EthereumBuilderConfig;
use reth_evm::ConfigureEvm; use reth_evm::ConfigureEvmFor;
use reth_evm_ethereum::EthEvmConfig; use reth_evm_ethereum::EthEvmConfig;
use reth_node_api::{FullNodeTypes, HeaderTy, NodeTypesWithEngine, TxTy}; use reth_node_api::{FullNodeTypes, NodeTypesWithEngine, TxTy};
use reth_node_builder::{ use reth_node_builder::{
components::PayloadServiceBuilder, BuilderContext, PayloadBuilderConfig, PayloadTypes, components::PayloadServiceBuilder, BuilderContext, PayloadBuilderConfig, PayloadTypes,
}; };
@ -33,7 +33,7 @@ impl EthereumPayloadBuilder {
where where
Types: NodeTypesWithEngine<ChainSpec = ChainSpec, Primitives = EthPrimitives>, Types: NodeTypesWithEngine<ChainSpec = ChainSpec, Primitives = EthPrimitives>,
Node: FullNodeTypes<Types = Types>, Node: FullNodeTypes<Types = Types>,
Evm: ConfigureEvm<Header = HeaderTy<Types>, Transaction = TxTy<Node::Types>>, Evm: ConfigureEvmFor<Types::Primitives>,
Pool: TransactionPool<Transaction: PoolTransaction<Consensus = TxTy<Node::Types>>> Pool: TransactionPool<Transaction: PoolTransaction<Consensus = TxTy<Node::Types>>>
+ Unpin + Unpin
+ 'static, + 'static,

31
crates/evm/src/aliases.rs Normal file
View File

@ -0,0 +1,31 @@
//! Helper aliases when working with [`NodePrimitives`] and the traits in this crate.
use crate::{ConfigureEvm, ConfigureEvmEnv};
use reth_primitives_traits::NodePrimitives;
/// This is a type alias to make type bounds simpler when we have a [`NodePrimitives`] and need a
/// [`ConfigureEvmEnv`] whose associated types match the [`NodePrimitives`] associated types.
pub trait ConfigureEvmEnvFor<N: NodePrimitives>:
ConfigureEvmEnv<Header = N::BlockHeader, Transaction = N::SignedTx>
{
}
impl<N, C> ConfigureEvmEnvFor<N> for C
where
N: NodePrimitives,
C: ConfigureEvmEnv<Header = N::BlockHeader, Transaction = N::SignedTx>,
{
}
/// This is a type alias to make type bounds simpler when we have a [`NodePrimitives`] and need a
/// [`ConfigureEvm`] whose associated types match the [`NodePrimitives`] associated types.
pub trait ConfigureEvmFor<N: NodePrimitives>:
ConfigureEvm<Header = N::BlockHeader, Transaction = N::SignedTx>
{
}
impl<N, C> ConfigureEvmFor<N> for C
where
N: NodePrimitives,
C: ConfigureEvm<Header = N::BlockHeader, Transaction = N::SignedTx>,
{
}

View File

@ -29,6 +29,9 @@ pub mod env;
pub mod execute; pub mod execute;
pub use env::EvmEnv; pub use env::EvmEnv;
mod aliases;
pub use aliases::*;
#[cfg(feature = "std")] #[cfg(feature = "std")]
pub mod metrics; pub mod metrics;
pub mod noop; pub mod noop;

View File

@ -1,6 +1,5 @@
//! Traits for configuring a node. //! Traits for configuring a node.
use crate::ConfigureEvm;
use alloy_rpc_types_engine::JwtSecret; use alloy_rpc_types_engine::JwtSecret;
use reth_consensus::{ConsensusError, FullConsensus}; use reth_consensus::{ConsensusError, FullConsensus};
use reth_db_api::{ use reth_db_api::{
@ -8,10 +7,10 @@ use reth_db_api::{
Database, Database,
}; };
use reth_engine_primitives::BeaconConsensusEngineHandle; use reth_engine_primitives::BeaconConsensusEngineHandle;
use reth_evm::execute::BlockExecutorProvider; use reth_evm::{execute::BlockExecutorProvider, ConfigureEvmFor};
use reth_network_api::FullNetwork; use reth_network_api::FullNetwork;
use reth_node_core::node_config::NodeConfig; use reth_node_core::node_config::NodeConfig;
use reth_node_types::{HeaderTy, NodeTypes, NodeTypesWithDBAdapter, NodeTypesWithEngine, TxTy}; use reth_node_types::{NodeTypes, NodeTypesWithDBAdapter, NodeTypesWithEngine, TxTy};
use reth_payload_builder_primitives::PayloadBuilder; use reth_payload_builder_primitives::PayloadBuilder;
use reth_provider::FullProvider; use reth_provider::FullProvider;
use reth_tasks::TaskExecutor; use reth_tasks::TaskExecutor;
@ -52,7 +51,7 @@ pub trait FullNodeComponents: FullNodeTypes + Clone + 'static {
type Pool: TransactionPool<Transaction: PoolTransaction<Consensus = TxTy<Self::Types>>> + Unpin; type Pool: TransactionPool<Transaction: PoolTransaction<Consensus = TxTy<Self::Types>>> + Unpin;
/// The node's EVM configuration, defining settings for the Ethereum Virtual Machine. /// The node's EVM configuration, defining settings for the Ethereum Virtual Machine.
type Evm: ConfigureEvm<Header = HeaderTy<Self::Types>, Transaction = TxTy<Self::Types>>; type Evm: ConfigureEvmFor<<Self::Types as NodeTypes>::Primitives>;
/// The type that knows how to execute blocks. /// The type that knows how to execute blocks.
type Executor: BlockExecutorProvider<Primitives = <Self::Types as NodeTypes>::Primitives>; type Executor: BlockExecutorProvider<Primitives = <Self::Types as NodeTypes>::Primitives>;

View File

@ -1,6 +1,5 @@
use reth_evm::{ConfigureEvm, ConfigureEvmEnv};
use reth_network::NetworkPrimitives; use reth_network::NetworkPrimitives;
use reth_node_api::{BlockBody, NodePrimitives}; use reth_node_api::BlockBody;
use reth_provider::BlockReader; use reth_provider::BlockReader;
/// This is a type alias to make type bounds simpler, when we have a [`NetworkPrimitives`] and need /// This is a type alias to make type bounds simpler, when we have a [`NetworkPrimitives`] and need
@ -26,31 +25,3 @@ where
>, >,
{ {
} }
/// This is a type alias to make type bounds simpler when we have a [`NodePrimitives`] and need a
/// [`ConfigureEvmEnv`] whose associated types match the [`NodePrimitives`] associated types.
pub trait ConfigureEvmEnvFor<N: NodePrimitives>:
ConfigureEvmEnv<Header = N::BlockHeader, Transaction = N::SignedTx>
{
}
impl<N, C> ConfigureEvmEnvFor<N> for C
where
N: NodePrimitives,
C: ConfigureEvmEnv<Header = N::BlockHeader, Transaction = N::SignedTx>,
{
}
/// This is a type alias to make type bounds simpler when we have a [`NodePrimitives`] and need a
/// [`ConfigureEvm`] whose associated types match the [`NodePrimitives`] associated types.
pub trait ConfigureEvmFor<N: NodePrimitives>:
ConfigureEvm<Header = N::BlockHeader, Transaction = N::SignedTx>
{
}
impl<N, C> ConfigureEvmFor<N> for C
where
N: NodePrimitives,
C: ConfigureEvm<Header = N::BlockHeader, Transaction = N::SignedTx>,
{
}

View File

@ -5,10 +5,10 @@ use crate::{
Components, ConsensusBuilder, ExecutorBuilder, NetworkBuilder, NodeComponents, Components, ConsensusBuilder, ExecutorBuilder, NetworkBuilder, NodeComponents,
PayloadServiceBuilder, PoolBuilder, PayloadServiceBuilder, PoolBuilder,
}, },
BuilderContext, ConfigureEvm, FullNodeTypes, BuilderContext, FullNodeTypes,
}; };
use reth_consensus::{ConsensusError, FullConsensus}; use reth_consensus::{ConsensusError, FullConsensus};
use reth_evm::execute::BlockExecutorProvider; use reth_evm::{execute::BlockExecutorProvider, ConfigureEvmFor};
use reth_network::NetworkPrimitives; use reth_network::NetworkPrimitives;
use reth_node_api::{BlockTy, BodyTy, HeaderTy, NodeTypes, NodeTypesWithEngine, TxTy}; use reth_node_api::{BlockTy, BodyTy, HeaderTy, NodeTypes, NodeTypesWithEngine, TxTy};
use reth_payload_builder::PayloadBuilderHandle; use reth_payload_builder::PayloadBuilderHandle;
@ -405,7 +405,7 @@ where
Pool: TransactionPool<Transaction: PoolTransaction<Consensus = TxTy<Node::Types>>> Pool: TransactionPool<Transaction: PoolTransaction<Consensus = TxTy<Node::Types>>>
+ Unpin + Unpin
+ 'static, + 'static,
EVM: ConfigureEvm<Header = HeaderTy<Node::Types>, Transaction = TxTy<Node::Types>>, EVM: ConfigureEvmFor<<Node::Types as NodeTypes>::Primitives>,
Executor: BlockExecutorProvider<Primitives = <Node::Types as NodeTypes>::Primitives>, Executor: BlockExecutorProvider<Primitives = <Node::Types as NodeTypes>::Primitives>,
Cons: FullConsensus<<Node::Types as NodeTypes>::Primitives, Error = ConsensusError> Cons: FullConsensus<<Node::Types as NodeTypes>::Primitives, Error = ConsensusError>
+ Clone + Clone

View File

@ -1,7 +1,7 @@
//! EVM component for the node builder. //! EVM component for the node builder.
use crate::{BuilderContext, FullNodeTypes}; use crate::{BuilderContext, FullNodeTypes};
use reth_evm::execute::BlockExecutorProvider; use reth_evm::{execute::BlockExecutorProvider, ConfigureEvmFor};
use reth_node_api::{ConfigureEvm, HeaderTy, TxTy}; use reth_node_api::NodeTypes;
use std::future::Future; use std::future::Future;
/// A type that knows how to build the executor types. /// A type that knows how to build the executor types.
@ -9,7 +9,7 @@ pub trait ExecutorBuilder<Node: FullNodeTypes>: Send {
/// The EVM config to use. /// The EVM config to use.
/// ///
/// This provides the node with the necessary configuration to configure an EVM. /// This provides the node with the necessary configuration to configure an EVM.
type EVM: ConfigureEvm<Header = HeaderTy<Node::Types>, Transaction = TxTy<Node::Types>>; type EVM: ConfigureEvmFor<<Node::Types as NodeTypes>::Primitives>;
/// The type that knows how to execute blocks. /// The type that knows how to execute blocks.
type Executor: BlockExecutorProvider< type Executor: BlockExecutorProvider<
@ -26,7 +26,7 @@ pub trait ExecutorBuilder<Node: FullNodeTypes>: Send {
impl<Node, F, Fut, EVM, Executor> ExecutorBuilder<Node> for F impl<Node, F, Fut, EVM, Executor> ExecutorBuilder<Node> for F
where where
Node: FullNodeTypes, Node: FullNodeTypes,
EVM: ConfigureEvm<Header = HeaderTy<Node::Types>, Transaction = TxTy<Node::Types>>, EVM: ConfigureEvmFor<<Node::Types as NodeTypes>::Primitives>,
Executor: Executor:
BlockExecutorProvider<Primitives = <Node::Types as reth_node_api::NodeTypes>::Primitives>, BlockExecutorProvider<Primitives = <Node::Types as reth_node_api::NodeTypes>::Primitives>,
F: FnOnce(&BuilderContext<Node>) -> Fut + Send, F: FnOnce(&BuilderContext<Node>) -> Fut + Send,

View File

@ -24,7 +24,7 @@ use reth_network_p2p::BlockClient;
use crate::{ConfigureEvm, FullNodeTypes}; use crate::{ConfigureEvm, FullNodeTypes};
use reth_consensus::{ConsensusError, FullConsensus}; use reth_consensus::{ConsensusError, FullConsensus};
use reth_evm::execute::BlockExecutorProvider; use reth_evm::{execute::BlockExecutorProvider, ConfigureEvmFor};
use reth_network::{NetworkHandle, NetworkPrimitives}; use reth_network::{NetworkHandle, NetworkPrimitives};
use reth_network_api::FullNetwork; use reth_network_api::FullNetwork;
use reth_node_api::{ use reth_node_api::{
@ -43,7 +43,7 @@ pub trait NodeComponents<T: FullNodeTypes>: Clone + Unpin + Send + Sync + 'stati
type Pool: TransactionPool<Transaction: PoolTransaction<Consensus = TxTy<T::Types>>> + Unpin; type Pool: TransactionPool<Transaction: PoolTransaction<Consensus = TxTy<T::Types>>> + Unpin;
/// The node's EVM configuration, defining settings for the Ethereum Virtual Machine. /// The node's EVM configuration, defining settings for the Ethereum Virtual Machine.
type Evm: ConfigureEvm<Header = HeaderTy<T::Types>, Transaction = TxTy<T::Types>>; type Evm: ConfigureEvmFor<<T::Types as NodeTypes>::Primitives>;
/// The type that knows how to execute blocks. /// The type that knows how to execute blocks.
type Executor: BlockExecutorProvider<Primitives = <T::Types as NodeTypes>::Primitives>; type Executor: BlockExecutorProvider<Primitives = <T::Types as NodeTypes>::Primitives>;

View File

@ -19,7 +19,7 @@ use reth_evm::{
}, },
state_change::post_block_balance_increments, state_change::post_block_balance_increments,
system_calls::{OnStateHook, SystemCaller}, system_calls::{OnStateHook, SystemCaller},
ConfigureEvm, Evm, TxEnvOverrides, ConfigureEvmFor, Evm, TxEnvOverrides,
}; };
use reth_optimism_chainspec::OpChainSpec; use reth_optimism_chainspec::OpChainSpec;
use reth_optimism_consensus::validate_block_post_execution; use reth_optimism_consensus::validate_block_post_execution;
@ -73,12 +73,7 @@ where
Receipt = OpReceipt, Receipt = OpReceipt,
SignedTx: OpTransaction, SignedTx: OpTransaction,
>, >,
EvmConfig: Clone EvmConfig: Clone + Unpin + Sync + Send + 'static + ConfigureEvmFor<N>,
+ Unpin
+ Sync
+ Send
+ 'static
+ ConfigureEvm<Header = N::BlockHeader, Transaction = N::SignedTx>,
{ {
type Primitives = N; type Primitives = N;
type Strategy<DB: Database<Error: Into<ProviderError> + Display>> = type Strategy<DB: Database<Error: Into<ProviderError> + Display>> =
@ -151,7 +146,7 @@ where
SignedTx: OpTransaction, SignedTx: OpTransaction,
Receipt: DepositReceipt, Receipt: DepositReceipt,
>, >,
EvmConfig: ConfigureEvm<Header = N::BlockHeader, Transaction = N::SignedTx>, EvmConfig: ConfigureEvmFor<N>,
{ {
type DB = DB; type DB = DB;
type Primitives = N; type Primitives = N;

View File

@ -9,9 +9,9 @@ use crate::{
use op_alloy_consensus::OpPooledTransaction; use op_alloy_consensus::OpPooledTransaction;
use reth_basic_payload_builder::{BasicPayloadJobGenerator, BasicPayloadJobGeneratorConfig}; use reth_basic_payload_builder::{BasicPayloadJobGenerator, BasicPayloadJobGeneratorConfig};
use reth_chainspec::{EthChainSpec, Hardforks}; use reth_chainspec::{EthChainSpec, Hardforks};
use reth_evm::{execute::BasicBlockExecutorProvider, ConfigureEvm}; use reth_evm::{execute::BasicBlockExecutorProvider, ConfigureEvmFor};
use reth_network::{NetworkConfig, NetworkHandle, NetworkManager, NetworkPrimitives, PeersInfo}; use reth_network::{NetworkConfig, NetworkHandle, NetworkManager, NetworkPrimitives, PeersInfo};
use reth_node_api::{AddOnsContext, FullNodeComponents, HeaderTy, NodeAddOns, TxTy}; use reth_node_api::{AddOnsContext, FullNodeComponents, NodeAddOns, TxTy};
use reth_node_builder::{ use reth_node_builder::{
components::{ components::{
ComponentsBuilder, ConsensusBuilder, ExecutorBuilder, NetworkBuilder, ComponentsBuilder, ConsensusBuilder, ExecutorBuilder, NetworkBuilder,
@ -484,7 +484,7 @@ where
Pool: TransactionPool<Transaction: PoolTransaction<Consensus = TxTy<Node::Types>>> Pool: TransactionPool<Transaction: PoolTransaction<Consensus = TxTy<Node::Types>>>
+ Unpin + Unpin
+ 'static, + 'static,
Evm: ConfigureEvm<Header = HeaderTy<Node::Types>, Transaction = TxTy<Node::Types>>, Evm: ConfigureEvmFor<<Node::Types as NodeTypes>::Primitives>,
{ {
let payload_builder = reth_optimism_payload_builder::OpPayloadBuilder::with_builder_config( let payload_builder = reth_optimism_payload_builder::OpPayloadBuilder::with_builder_config(
evm_config, evm_config,