pub trait EvmFactory {
type Evm<DB: Database>: Evm<DB = DB, Tx = Self::Tx, HaltReason = Self::HaltReason, Error = Self::Error<DB::Error>, Spec = Self::Spec>;
type Tx: IntoTxEnv<Self::Tx> + Send + Sync + 'static;
type Error<DBError: Error + Send + Sync + 'static>: EvmError;
type HaltReason: HaltReasonTr + Send + Sync + 'static;
type Spec: Ord + Serialize + Debug + Copy + Send + Sync + 'static;
type Header: EvmBlockHeader<Spec = Self::Spec> + Clone + Serialize + DeserializeOwned + Send + Sync + 'static;
// Required methods
fn new_tx(address: Address, data: Bytes) -> Self::Tx;
fn create_evm<DB: Database>(
db: DB,
chain_id: ChainId,
spec: Self::Spec,
header: &Self::Header,
) -> Self::Evm<DB>;
}
Expand description
Abstracts the creation and configuration of a specific EVM implementation.
This trait acts as a factory pattern, allowing generic code (like Contract
and CallBuilder
)
to operate with different underlying EVM engines (e.g., revm
) without being
tightly coupled to a specific implementation. Implementers define the concrete types
associated with their chosen EVM and provide the logic to instantiate it.
Required Associated Types§
Sourcetype Evm<DB: Database>: Evm<DB = DB, Tx = Self::Tx, HaltReason = Self::HaltReason, Error = Self::Error<DB::Error>, Spec = Self::Spec>
type Evm<DB: Database>: Evm<DB = DB, Tx = Self::Tx, HaltReason = Self::HaltReason, Error = Self::Error<DB::Error>, Spec = Self::Spec>
The concrete EVM execution environment type created by this factory.
Sourcetype Tx: IntoTxEnv<Self::Tx> + Send + Sync + 'static
type Tx: IntoTxEnv<Self::Tx> + Send + Sync + 'static
The transaction environment type compatible with Self::Evm
.
Sourcetype Error<DBError: Error + Send + Sync + 'static>: EvmError
type Error<DBError: Error + Send + Sync + 'static>: EvmError
The error type returned by Self::Evm
during execution.
Sourcetype HaltReason: HaltReasonTr + Send + Sync + 'static
type HaltReason: HaltReasonTr + Send + Sync + 'static
The type representing reasons why Self::Evm
might halt execution.
Sourcetype Spec: Ord + Serialize + Debug + Copy + Send + Sync + 'static
type Spec: Ord + Serialize + Debug + Copy + Send + Sync + 'static
The EVM specification identifier (e.g., Shanghai, Cancun) used by Self::Evm
.
Sourcetype Header: EvmBlockHeader<Spec = Self::Spec> + Clone + Serialize + DeserializeOwned + Send + Sync + 'static
type Header: EvmBlockHeader<Spec = Self::Spec> + Clone + Serialize + DeserializeOwned + Send + Sync + 'static
The block header type providing execution context (e.g., timestamp, number, basefee).
Required Methods§
Sourcefn new_tx(address: Address, data: Bytes) -> Self::Tx
fn new_tx(address: Address, data: Bytes) -> Self::Tx
Creates a new transaction environment instance for a basic call.
Implementers should create an instance of Self::Tx
,
populate it with the target address
and input data
, and apply appropriate
defaults for other transaction fields (like caller, value, gas limit, etc.)
required by the specific EVM implementation.
Sourcefn create_evm<DB: Database>(
db: DB,
chain_id: ChainId,
spec: Self::Spec,
header: &Self::Header,
) -> Self::Evm<DB>
fn create_evm<DB: Database>( db: DB, chain_id: ChainId, spec: Self::Spec, header: &Self::Header, ) -> Self::Evm<DB>
Creates a new instance of the EVM defined by Self::Evm
.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.