reth_evm

Trait ConfigureEvmEnv

Source
pub trait ConfigureEvmEnv:
    Send
    + Sync
    + Unpin
    + Clone
    + 'static {
    type Header: BlockHeader;
    type Transaction;
    type Error: Error + Send + Sync;

    // Required methods
    fn fill_tx_env(
        &self,
        tx_env: &mut TxEnv,
        transaction: &Self::Transaction,
        sender: Address,
    );
    fn fill_tx_env_system_contract_call(
        &self,
        env: &mut Env,
        caller: Address,
        contract: Address,
        data: Bytes,
    );
    fn fill_cfg_env(
        &self,
        cfg_env: &mut CfgEnvWithHandlerCfg,
        header: &Self::Header,
    );
    fn next_cfg_and_block_env(
        &self,
        parent: &Self::Header,
        attributes: NextBlockEnvAttributes,
    ) -> Result<EvmEnv, Self::Error>;

    // Provided methods
    fn tx_env(&self, transaction: &Self::Transaction, signer: Address) -> TxEnv { ... }
    fn cfg_env(&self, header: &Self::Header) -> CfgEnvWithHandlerCfg { ... }
    fn fill_block_env(
        &self,
        block_env: &mut BlockEnv,
        header: &Self::Header,
        after_merge: bool,
    ) { ... }
    fn cfg_and_block_env(&self, header: &Self::Header) -> EvmEnv { ... }
    fn fill_cfg_and_block_env(
        &self,
        cfg: &mut CfgEnvWithHandlerCfg,
        block_env: &mut BlockEnv,
        header: &Self::Header,
    ) { ... }
}
Expand description

This represents the set of methods used to configure the EVM’s environment before block execution.

Default trait method implementation is done w.r.t. L1.

Required Associated Types§

Source

type Header: BlockHeader

The header type used by the EVM.

Source

type Transaction

The transaction type.

Source

type Error: Error + Send + Sync

The error type that is returned by Self::next_cfg_and_block_env.

Required Methods§

Source

fn fill_tx_env( &self, tx_env: &mut TxEnv, transaction: &Self::Transaction, sender: Address, )

Fill transaction environment from a transaction and the given sender address.

Source

fn fill_tx_env_system_contract_call( &self, env: &mut Env, caller: Address, contract: Address, data: Bytes, )

Fill transaction environment with a system contract call.

Source

fn fill_cfg_env( &self, cfg_env: &mut CfgEnvWithHandlerCfg, header: &Self::Header, )

Fill [CfgEnvWithHandlerCfg] fields according to the chain spec and given header.

This must set the corresponding spec id in the handler cfg, based on timestamp or total difficulty

Source

fn next_cfg_and_block_env( &self, parent: &Self::Header, attributes: NextBlockEnvAttributes, ) -> Result<EvmEnv, Self::Error>

Returns the configured EvmEnv for parent + 1 block.

This is intended for usage in block building after the merge and requires additional attributes that can’t be derived from the parent block: attributes that are determined by the CL, such as the timestamp, suggested fee recipient, and randomness value.

Provided Methods§

Source

fn tx_env(&self, transaction: &Self::Transaction, signer: Address) -> TxEnv

Returns a [TxEnv] from a transaction and [Address].

Source

fn cfg_env(&self, header: &Self::Header) -> CfgEnvWithHandlerCfg

Returns a [CfgEnvWithHandlerCfg] for the given header.

Source

fn fill_block_env( &self, block_env: &mut BlockEnv, header: &Self::Header, after_merge: bool, )

Fill [BlockEnv] field according to the chain spec and given header

Source

fn cfg_and_block_env(&self, header: &Self::Header) -> EvmEnv

Creates a new EvmEnv for the given header.

Source

fn fill_cfg_and_block_env( &self, cfg: &mut CfgEnvWithHandlerCfg, block_env: &mut BlockEnv, header: &Self::Header, )

Convenience function to call both fill_cfg_env and ConfigureEvmEnv::fill_block_env.

Note: Implementers should ensure that all fields are required fields are filled.

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.

Implementations on Foreign Types§

Source§

impl<'a, T: 'a + ConfigureEvmEnv + ?Sized> ConfigureEvmEnv for &'a T
where &'a T: Send + Sync + Unpin + Clone + 'static,

Source§

type Header = <T as ConfigureEvmEnv>::Header

Source§

type Transaction = <T as ConfigureEvmEnv>::Transaction

Source§

type Error = <T as ConfigureEvmEnv>::Error

Source§

fn tx_env(&self, transaction: &Self::Transaction, signer: Address) -> TxEnv

Source§

fn fill_tx_env( &self, tx_env: &mut TxEnv, transaction: &Self::Transaction, sender: Address, )

Source§

fn fill_tx_env_system_contract_call( &self, env: &mut Env, caller: Address, contract: Address, data: Bytes, )

Source§

fn cfg_env(&self, header: &Self::Header) -> CfgEnvWithHandlerCfg

Source§

fn fill_cfg_env( &self, cfg_env: &mut CfgEnvWithHandlerCfg, header: &Self::Header, )

Source§

fn fill_block_env( &self, block_env: &mut BlockEnv, header: &Self::Header, after_merge: bool, )

Source§

fn cfg_and_block_env(&self, header: &Self::Header) -> EvmEnv

Source§

fn fill_cfg_and_block_env( &self, cfg: &mut CfgEnvWithHandlerCfg, block_env: &mut BlockEnv, header: &Self::Header, )

Source§

fn next_cfg_and_block_env( &self, parent: &Self::Header, attributes: NextBlockEnvAttributes, ) -> Result<EvmEnv, Self::Error>

Source§

impl<T: ConfigureEvmEnv + ?Sized> ConfigureEvmEnv for Arc<T>
where Arc<T>: Send + Sync + Unpin + Clone + 'static,

Source§

type Header = <T as ConfigureEvmEnv>::Header

Source§

type Transaction = <T as ConfigureEvmEnv>::Transaction

Source§

type Error = <T as ConfigureEvmEnv>::Error

Source§

fn tx_env(&self, transaction: &Self::Transaction, signer: Address) -> TxEnv

Source§

fn fill_tx_env( &self, tx_env: &mut TxEnv, transaction: &Self::Transaction, sender: Address, )

Source§

fn fill_tx_env_system_contract_call( &self, env: &mut Env, caller: Address, contract: Address, data: Bytes, )

Source§

fn cfg_env(&self, header: &Self::Header) -> CfgEnvWithHandlerCfg

Source§

fn fill_cfg_env( &self, cfg_env: &mut CfgEnvWithHandlerCfg, header: &Self::Header, )

Source§

fn fill_block_env( &self, block_env: &mut BlockEnv, header: &Self::Header, after_merge: bool, )

Source§

fn cfg_and_block_env(&self, header: &Self::Header) -> EvmEnv

Source§

fn fill_cfg_and_block_env( &self, cfg: &mut CfgEnvWithHandlerCfg, block_env: &mut BlockEnv, header: &Self::Header, )

Source§

fn next_cfg_and_block_env( &self, parent: &Self::Header, attributes: NextBlockEnvAttributes, ) -> Result<EvmEnv, Self::Error>

Implementors§