Trait EvmFactory

Source
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§

Source

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.

Source

type Tx: IntoTxEnv<Self::Tx> + Send + Sync + 'static

The transaction environment type compatible with Self::Evm.

Source

type Error<DBError: Error + Send + Sync + 'static>: EvmError

The error type returned by Self::Evm during execution.

Source

type HaltReason: HaltReasonTr + Send + Sync + 'static

The type representing reasons why Self::Evm might halt execution.

Source

type Spec: Ord + Serialize + Debug + Copy + Send + Sync + 'static

The EVM specification identifier (e.g., Shanghai, Cancun) used by Self::Evm.

Source

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§

Source

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.

Source

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.

Implementors§

Source§

impl EvmFactory for EthEvmFactory

Source§

type Evm<DB: Database> = <EthEvmFactory as EvmFactory>::Evm<DB, NoOpInspector>

Source§

type Tx = <EthEvmFactory as EvmFactory>::Tx

Source§

type Error<DBError: Error + Send + Sync + 'static> = <EthEvmFactory as EvmFactory>::Error<DBError>

Source§

type HaltReason = <EthEvmFactory as EvmFactory>::HaltReason

Source§

type Spec = <EthEvmFactory as EvmFactory>::Spec

Source§

type Header = RlpHeader<Header>