reth_evm::execute

Trait BlockExecutionStrategy

Source
pub trait BlockExecutionStrategy {
    type DB: Database;
    type Primitives: NodePrimitives;
    type Error: From<ProviderError> + Error;

    // Required methods
    fn apply_pre_execution_changes(
        &mut self,
        block: &BlockWithSenders<<Self::Primitives as NodePrimitives>::Block>,
    ) -> Result<(), Self::Error>;
    fn execute_transactions(
        &mut self,
        block: &BlockWithSenders<<Self::Primitives as NodePrimitives>::Block>,
    ) -> Result<ExecuteOutput<<Self::Primitives as NodePrimitives>::Receipt>, Self::Error>;
    fn apply_post_execution_changes(
        &mut self,
        block: &BlockWithSenders<<Self::Primitives as NodePrimitives>::Block>,
        receipts: &[<Self::Primitives as NodePrimitives>::Receipt],
    ) -> Result<Requests, Self::Error>;
    fn state_ref(&self) -> &State<Self::DB>;
    fn state_mut(&mut self) -> &mut State<Self::DB>;

    // Provided methods
    fn init(&mut self, _tx_env_overrides: Box<dyn TxEnvOverrides>) { ... }
    fn with_state_hook(&mut self, _hook: Option<Box<dyn OnStateHook>>) { ... }
    fn finish(&mut self) -> BundleState { ... }
    fn validate_block_post_execution(
        &self,
        _block: &BlockWithSenders<<Self::Primitives as NodePrimitives>::Block>,
        _receipts: &[<Self::Primitives as NodePrimitives>::Receipt],
        _requests: &Requests,
    ) -> Result<(), ConsensusError> { ... }
}
Expand description

Defines the strategy for executing a single block.

Required Associated Types§

Source

type DB: Database

Database this strategy operates on.

Source

type Primitives: NodePrimitives

Primitive types used by the strategy.

Source

type Error: From<ProviderError> + Error

The error type returned by this strategy’s methods.

Required Methods§

Source

fn apply_pre_execution_changes( &mut self, block: &BlockWithSenders<<Self::Primitives as NodePrimitives>::Block>, ) -> Result<(), Self::Error>

Applies any necessary changes before executing the block’s transactions.

Source

fn execute_transactions( &mut self, block: &BlockWithSenders<<Self::Primitives as NodePrimitives>::Block>, ) -> Result<ExecuteOutput<<Self::Primitives as NodePrimitives>::Receipt>, Self::Error>

Executes all transactions in the block.

Source

fn apply_post_execution_changes( &mut self, block: &BlockWithSenders<<Self::Primitives as NodePrimitives>::Block>, receipts: &[<Self::Primitives as NodePrimitives>::Receipt], ) -> Result<Requests, Self::Error>

Applies any necessary changes after executing the block’s transactions.

Source

fn state_ref(&self) -> &State<Self::DB>

Returns a reference to the current state.

Source

fn state_mut(&mut self) -> &mut State<Self::DB>

Returns a mutable reference to the current state.

Provided Methods§

Source

fn init(&mut self, _tx_env_overrides: Box<dyn TxEnvOverrides>)

Initialize the strategy with the given transaction environment overrides.

Source

fn with_state_hook(&mut self, _hook: Option<Box<dyn OnStateHook>>)

Sets a hook to be called after each state change during execution.

Source

fn finish(&mut self) -> BundleState

Returns the final bundle state.

Source

fn validate_block_post_execution( &self, _block: &BlockWithSenders<<Self::Primitives as NodePrimitives>::Block>, _receipts: &[<Self::Primitives as NodePrimitives>::Receipt], _requests: &Requests, ) -> Result<(), ConsensusError>

Validate a block with regard to execution results.

Implementors§