Trait Executor

Source
pub trait Executor<DB: Database>: Sized {
    type Primitives: NodePrimitives;
    type Error;

    // Required methods
    fn execute_one(
        &mut self,
        block: &RecoveredBlock<<Self::Primitives as NodePrimitives>::Block>,
    ) -> Result<BlockExecutionResult<<Self::Primitives as NodePrimitives>::Receipt>, Self::Error>;
    fn execute_one_with_state_hook<F>(
        &mut self,
        block: &RecoveredBlock<<Self::Primitives as NodePrimitives>::Block>,
        state_hook: F,
    ) -> Result<BlockExecutionResult<<Self::Primitives as NodePrimitives>::Receipt>, Self::Error>
       where F: OnStateHook + 'static;
    fn into_state(self) -> State<DB>;
    fn size_hint(&self) -> usize;

    // Provided methods
    fn execute(
        self,
        block: &RecoveredBlock<<Self::Primitives as NodePrimitives>::Block>,
    ) -> Result<BlockExecutionOutput<<Self::Primitives as NodePrimitives>::Receipt>, Self::Error> { ... }
    fn execute_batch<'a, I>(
        self,
        blocks: I,
    ) -> Result<ExecutionOutcome<<Self::Primitives as NodePrimitives>::Receipt>, Self::Error>
       where I: IntoIterator<Item = &'a RecoveredBlock<<Self::Primitives as NodePrimitives>::Block>> { ... }
    fn execute_with_state_closure<F>(
        self,
        block: &RecoveredBlock<<Self::Primitives as NodePrimitives>::Block>,
        f: F,
    ) -> Result<BlockExecutionOutput<<Self::Primitives as NodePrimitives>::Receipt>, Self::Error>
       where F: FnMut(&State<DB>) { ... }
    fn execute_with_state_hook<F>(
        self,
        block: &RecoveredBlock<<Self::Primitives as NodePrimitives>::Block>,
        state_hook: F,
    ) -> Result<BlockExecutionOutput<<Self::Primitives as NodePrimitives>::Receipt>, Self::Error>
       where F: OnStateHook + 'static { ... }
}
Expand description

A type that knows how to execute a block. It is assumed to operate on a crate::Evm internally and use State as database.

Required Associated Types§

Source

type Primitives: NodePrimitives

The primitive types used by the executor.

Source

type Error

The error type returned by the executor.

Required Methods§

Source

fn execute_one( &mut self, block: &RecoveredBlock<<Self::Primitives as NodePrimitives>::Block>, ) -> Result<BlockExecutionResult<<Self::Primitives as NodePrimitives>::Receipt>, Self::Error>

Executes a single block and returns BlockExecutionResult, without the state changes.

Source

fn execute_one_with_state_hook<F>( &mut self, block: &RecoveredBlock<<Self::Primitives as NodePrimitives>::Block>, state_hook: F, ) -> Result<BlockExecutionResult<<Self::Primitives as NodePrimitives>::Receipt>, Self::Error>
where F: OnStateHook + 'static,

Executes the EVM with the given input and accepts a state hook closure that is invoked with the EVM state after execution.

Source

fn into_state(self) -> State<DB>

Consumes the executor and returns the State containing all state changes.

Source

fn size_hint(&self) -> usize

The size hint of the batch’s tracked state size.

This is used to optimize DB commits depending on the size of the state.

Provided Methods§

Source

fn execute( self, block: &RecoveredBlock<<Self::Primitives as NodePrimitives>::Block>, ) -> Result<BlockExecutionOutput<<Self::Primitives as NodePrimitives>::Receipt>, Self::Error>

Consumes the type and executes the block.

§Note

Execution happens without any validation of the output.

§Returns

The output of the block execution.

Source

fn execute_batch<'a, I>( self, blocks: I, ) -> Result<ExecutionOutcome<<Self::Primitives as NodePrimitives>::Receipt>, Self::Error>
where I: IntoIterator<Item = &'a RecoveredBlock<<Self::Primitives as NodePrimitives>::Block>>,

Executes multiple inputs in the batch, and returns an aggregated ExecutionOutcome.

Source

fn execute_with_state_closure<F>( self, block: &RecoveredBlock<<Self::Primitives as NodePrimitives>::Block>, f: F, ) -> Result<BlockExecutionOutput<<Self::Primitives as NodePrimitives>::Receipt>, Self::Error>
where F: FnMut(&State<DB>),

Executes the EVM with the given input and accepts a state closure that is invoked with the EVM state after execution.

Source

fn execute_with_state_hook<F>( self, block: &RecoveredBlock<<Self::Primitives as NodePrimitives>::Block>, state_hook: F, ) -> Result<BlockExecutionOutput<<Self::Primitives as NodePrimitives>::Receipt>, Self::Error>
where F: OnStateHook + 'static,

Executes the EVM with the given input and accepts a state hook closure that is invoked with the EVM state after execution.

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<A, B, DB> Executor<DB> for Either<A, B>
where A: Executor<DB>, B: Executor<DB, Primitives = A::Primitives, Error = A::Error>, DB: Database,

Source§

type Primitives = <A as Executor<DB>>::Primitives

Source§

type Error = <A as Executor<DB>>::Error

Source§

impl<F, DB> Executor<DB> for BasicBlockExecutor<F, DB>
where F: ConfigureEvm, DB: Database,