Trait EvmTr

Source
pub trait EvmTr {
    type Context: ContextTr;
    type Instructions: InstructionProvider;
    type Precompiles: PrecompileProvider<Self::Context>;
    type Frame: FrameTr;

    // Required methods
    fn ctx(&mut self) -> &mut Self::Context;
    fn ctx_ref(&self) -> &Self::Context;
    fn ctx_instructions(
        &mut self,
    ) -> (&mut Self::Context, &mut Self::Instructions);
    fn ctx_precompiles(
        &mut self,
    ) -> (&mut Self::Context, &mut Self::Precompiles);
    fn frame_stack(&mut self) -> &mut FrameStack<Self::Frame>;
    fn frame_init(
        &mut self,
        frame_input: <Self::Frame as FrameTr>::FrameInit,
    ) -> Result<FrameInitResult<'_, Self::Frame>, ContextDbError<Self::Context>>;
    fn frame_run(
        &mut self,
    ) -> Result<FrameInitOrResult<Self::Frame>, ContextDbError<Self::Context>>;
    fn frame_return_result(
        &mut self,
        result: <Self::Frame as FrameTr>::FrameResult,
    ) -> Result<Option<<Self::Frame as FrameTr>::FrameResult>, ContextDbError<Self::Context>>;

    // Provided method
    fn ctx_mut(&mut self) -> &mut Self::Context { ... }
}
Expand description

A trait that integrates context, instruction set, and precompiles to create an EVM struct.

In addition to execution capabilities, this trait provides getter methods for its component fields.

Required Associated Types§

Source

type Context: ContextTr

The context type that implements ContextTr to provide access to execution state

Source

type Instructions: InstructionProvider

The instruction set type that implements InstructionProvider to define available operations

Source

type Precompiles: PrecompileProvider<Self::Context>

The type containing the available precompiled contracts

Source

type Frame: FrameTr

The type containing the frame

Required Methods§

Source

fn ctx(&mut self) -> &mut Self::Context

Returns a mutable reference to the execution context

Source

fn ctx_ref(&self) -> &Self::Context

Returns an immutable reference to the execution context

Source

fn ctx_instructions(&mut self) -> (&mut Self::Context, &mut Self::Instructions)

Returns mutable references to both the context and instruction set. This enables atomic access to both components when needed.

Source

fn ctx_precompiles(&mut self) -> (&mut Self::Context, &mut Self::Precompiles)

Returns mutable references to both the context and precompiles. This enables atomic access to both components when needed.

Source

fn frame_stack(&mut self) -> &mut FrameStack<Self::Frame>

Returns a mutable reference to the frame stack.

Source

fn frame_init( &mut self, frame_input: <Self::Frame as FrameTr>::FrameInit, ) -> Result<FrameInitResult<'_, Self::Frame>, ContextDbError<Self::Context>>

Initializes the frame for the given frame input. Frame is pushed to the frame stack.

Source

fn frame_run( &mut self, ) -> Result<FrameInitOrResult<Self::Frame>, ContextDbError<Self::Context>>

Run the frame from the top of the stack. Returns the frame init or result.

If frame has returned result it would mark it as finished.

Source

fn frame_return_result( &mut self, result: <Self::Frame as FrameTr>::FrameResult, ) -> Result<Option<<Self::Frame as FrameTr>::FrameResult>, ContextDbError<Self::Context>>

Returns the result of the frame to the caller. Frame is popped from the frame stack. Consumes the frame result or returns it if there is more frames to run.

Provided Methods§

Source

fn ctx_mut(&mut self) -> &mut Self::Context

Returns a mutable reference to the execution context

Implementations on Foreign Types§

Source§

impl<'a, T: 'a + EvmTr + ?Sized> EvmTr for &'a mut T

Source§

type Context = <T as EvmTr>::Context

Source§

type Instructions = <T as EvmTr>::Instructions

Source§

type Precompiles = <T as EvmTr>::Precompiles

Source§

type Frame = <T as EvmTr>::Frame

Source§

fn ctx(&mut self) -> &mut Self::Context

Source§

fn ctx_mut(&mut self) -> &mut Self::Context

Source§

fn ctx_ref(&self) -> &Self::Context

Source§

fn ctx_instructions(&mut self) -> (&mut Self::Context, &mut Self::Instructions)

Source§

fn ctx_precompiles(&mut self) -> (&mut Self::Context, &mut Self::Precompiles)

Source§

fn frame_stack(&mut self) -> &mut FrameStack<Self::Frame>

Source§

fn frame_init( &mut self, frame_input: <Self::Frame as FrameTr>::FrameInit, ) -> Result<FrameInitResult<'_, Self::Frame>, ContextDbError<Self::Context>>

Source§

fn frame_run( &mut self, ) -> Result<FrameInitOrResult<Self::Frame>, ContextDbError<Self::Context>>

Source§

fn frame_return_result( &mut self, result: <Self::Frame as FrameTr>::FrameResult, ) -> Result<Option<<Self::Frame as FrameTr>::FrameResult>, ContextDbError<Self::Context>>

Source§

impl<CTX, INSP, I, P> EvmTr for Evm<CTX, INSP, I, P, EthFrame<EthInterpreter>>
where CTX: ContextTr, I: InstructionProvider<Context = CTX, InterpreterTypes = EthInterpreter>, P: PrecompileProvider<CTX, Output = InterpreterResult>,

Source§

fn frame_init( &mut self, frame_input: <Self::Frame as FrameTr>::FrameInit, ) -> Result<FrameInitResult<'_, Self::Frame>, ContextDbError<CTX>>

Initializes the frame for the given frame input. Frame is pushed to the frame stack.

Source§

fn frame_run( &mut self, ) -> Result<FrameInitOrResult<Self::Frame>, ContextDbError<CTX>>

Run the frame from the top of the stack. Returns the frame init or result.

Source§

fn frame_return_result( &mut self, result: <Self::Frame as FrameTr>::FrameResult, ) -> Result<Option<<Self::Frame as FrameTr>::FrameResult>, ContextDbError<Self::Context>>

Returns the result of the frame to the caller. Frame is popped from the frame stack.

Source§

type Context = CTX

Source§

type Instructions = I

Source§

type Precompiles = P

Source§

type Frame = EthFrame

Source§

fn ctx(&mut self) -> &mut Self::Context

Source§

fn ctx_ref(&self) -> &Self::Context

Source§

fn frame_stack(&mut self) -> &mut FrameStack<Self::Frame>

Source§

fn ctx_instructions(&mut self) -> (&mut Self::Context, &mut Self::Instructions)

Source§

fn ctx_precompiles(&mut self) -> (&mut Self::Context, &mut Self::Precompiles)

Source§

impl<T: EvmTr + ?Sized> EvmTr for Box<T>

Source§

type Context = <T as EvmTr>::Context

Source§

type Instructions = <T as EvmTr>::Instructions

Source§

type Precompiles = <T as EvmTr>::Precompiles

Source§

type Frame = <T as EvmTr>::Frame

Source§

fn ctx(&mut self) -> &mut Self::Context

Source§

fn ctx_mut(&mut self) -> &mut Self::Context

Source§

fn ctx_ref(&self) -> &Self::Context

Source§

fn ctx_instructions(&mut self) -> (&mut Self::Context, &mut Self::Instructions)

Source§

fn ctx_precompiles(&mut self) -> (&mut Self::Context, &mut Self::Precompiles)

Source§

fn frame_stack(&mut self) -> &mut FrameStack<Self::Frame>

Source§

fn frame_init( &mut self, frame_input: <Self::Frame as FrameTr>::FrameInit, ) -> Result<FrameInitResult<'_, Self::Frame>, ContextDbError<Self::Context>>

Source§

fn frame_run( &mut self, ) -> Result<FrameInitOrResult<Self::Frame>, ContextDbError<Self::Context>>

Source§

fn frame_return_result( &mut self, result: <Self::Frame as FrameTr>::FrameResult, ) -> Result<Option<<Self::Frame as FrameTr>::FrameResult>, ContextDbError<Self::Context>>

Implementors§