Trait EvmFactory

Source
pub trait EvmFactory<'a>: DbConnect<'a> {
    type Ext: Sync;

    // Required method
    fn create(
        &'a self,
    ) -> Result<EvmNeedsCfg<'a, Self::Ext, Self::Database>, Self::Error>;

    // Provided methods
    fn create_with_cfg<C>(
        &'a self,
        cfg: &C,
    ) -> Result<EvmNeedsBlock<'a, Self::Ext, Self::Database>, Self::Error>
       where C: Cfg { ... }
    fn create_with_block<C, B>(
        &'a self,
        cfg: &C,
        block: &B,
    ) -> Result<EvmNeedsTx<'a, Self::Ext, Self::Database>, Self::Error>
       where C: Cfg,
             B: Block { ... }
    fn create_with_tx<C, B, T>(
        &'a self,
        cfg: &C,
        block: &B,
        tx: &T,
    ) -> Result<EvmReady<'a, Self::Ext, Self::Database>, Self::Error>
       where C: Cfg,
             B: Block,
             T: Tx { ... }
    fn transact<C, B, T>(
        &'a self,
        cfg: &C,
        block: &B,
        tx: &T,
    ) -> Result<Result<EvmTransacted<'a, Self::Ext, Self::Database>, EvmErrored<'a, Self::Ext, Self::Database>>, Self::Error>
       where C: Cfg,
             B: Block,
             T: Tx { ... }
    fn run<C, B, T>(
        &'a self,
        cfg: &C,
        block: &B,
        tx: &T,
    ) -> Result<ResultAndState, EVMError<<Self::Database as Database>::Error>>
       where C: Cfg,
             B: Block,
             T: Tx { ... }
}
Expand description

Trait for types that can create EVM instances.

Factories should contain configuration information like chain EXT types, and database connections. They are intended to enable parallel instantiation of multiple EVMs in multiple threads sharing some configuration or backing store.

The lifetime on this trait allows the resulting EVM to borrow from the connector. E.g. the connector may contain some Db and the resulting EVM may contain &Db. This allows for (e.g.) shared caches between EVMs on multiple threads.

Required Associated Types§

Source

type Ext: Sync

The Ext type used in the resulting EVM.

Required Methods§

Source

fn create( &'a self, ) -> Result<EvmNeedsCfg<'a, Self::Ext, Self::Database>, Self::Error>

Create a new EVM instance with the given database connection and extension.

Provided Methods§

Source

fn create_with_cfg<C>( &'a self, cfg: &C, ) -> Result<EvmNeedsBlock<'a, Self::Ext, Self::Database>, Self::Error>
where C: Cfg,

Create a new EVM instance and parameterize it with a Cfg.

Source

fn create_with_block<C, B>( &'a self, cfg: &C, block: &B, ) -> Result<EvmNeedsTx<'a, Self::Ext, Self::Database>, Self::Error>
where C: Cfg, B: Block,

Create a new EVM instance and parameterize it with a Cfg and a Block.

Source

fn create_with_tx<C, B, T>( &'a self, cfg: &C, block: &B, tx: &T, ) -> Result<EvmReady<'a, Self::Ext, Self::Database>, Self::Error>
where C: Cfg, B: Block, T: Tx,

Create a new EVM instance, and parameterize it with a Cfg, a Block, and a Tx, yielding an EvmReady.

Source

fn transact<C, B, T>( &'a self, cfg: &C, block: &B, tx: &T, ) -> Result<Result<EvmTransacted<'a, Self::Ext, Self::Database>, EvmErrored<'a, Self::Ext, Self::Database>>, Self::Error>
where C: Cfg, B: Block, T: Tx,

Create a new EVM instance, parameterize it with a Cfg, a Block, and a Tx, and run the transaction, yielding either EvmTransacted or EvmErrored.

Source

fn run<C, B, T>( &'a self, cfg: &C, block: &B, tx: &T, ) -> Result<ResultAndState, EVMError<<Self::Database as Database>::Error>>
where C: Cfg, B: Block, T: Tx,

Run a transaction, take the ResultAndState, and discard the Evm. This is a high-level shortcut function.

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§