Trait Evm

pub trait Evm {
    type DB;
    type Tx: IntoTxEnv<Self::Tx>;
    type Error: EvmError;
    type HaltReason: HaltReasonTr + Send + Sync + 'static;
    type Spec: Debug + Copy + Hash + Eq + Send + Sync + Default + 'static;
    type Precompiles;
    type Inspector;

Show 17 methods // Required methods fn block(&self) -> &BlockEnv; fn chain_id(&self) -> u64; fn transact_raw( &mut self, tx: Self::Tx, ) -> Result<ResultAndState<Self::HaltReason>, Self::Error>; fn transact_system_call( &mut self, caller: Address, contract: Address, data: Bytes, ) -> Result<ResultAndState<Self::HaltReason>, Self::Error>; fn db_mut(&mut self) -> &mut Self::DB; fn finish(self) -> (Self::DB, EvmEnv<Self::Spec>) where Self: Sized; fn set_inspector_enabled(&mut self, enabled: bool); fn precompiles(&self) -> &Self::Precompiles; fn precompiles_mut(&mut self) -> &mut Self::Precompiles; fn inspector(&self) -> &Self::Inspector; fn inspector_mut(&mut self) -> &mut Self::Inspector; // Provided methods fn transact( &mut self, tx: impl IntoTxEnv<Self::Tx>, ) -> Result<ResultAndState<Self::HaltReason>, Self::Error> { ... } fn transact_commit( &mut self, tx: impl IntoTxEnv<Self::Tx>, ) -> Result<ExecutionResult<Self::HaltReason>, Self::Error> where Self::DB: DatabaseCommit { ... } fn into_db(self) -> Self::DB where Self: Sized { ... } fn into_env(self) -> EvmEnv<Self::Spec> where Self: Sized { ... } fn enable_inspector(&mut self) { ... } fn disable_inspector(&mut self) { ... }
}
Expand description

An instance of an ethereum virtual machine.

An EVM is commonly initialized with the corresponding block context and state and it’s only purpose is to execute transactions.

Executing a transaction will return the outcome of the transaction.

Required Associated Types§

type DB

Database type held by the EVM.

type Tx: IntoTxEnv<Self::Tx>

The transaction object that the EVM will execute.

Implementations are expected to rely on a single entrypoint for transaction execution such as revm::context::TxEnv. The actual set of valid inputs is not limited by allowing to provide any IntoTxEnv implementation for Evm::transact method.

type Error: EvmError

Error type returned by EVM. Contains either errors related to invalid transactions or internal irrecoverable execution errors.

type HaltReason: HaltReasonTr + Send + Sync + 'static

Halt reason. Enum over all possible reasons for halting the execution. When execution halts, it means that transaction is valid, however, it’s execution was interrupted (e.g because of running out of gas or overflowing stack).

type Spec: Debug + Copy + Hash + Eq + Send + Sync + Default + 'static

Identifier of the EVM specification. EVM is expected to use this identifier to determine which features are enabled.

type Precompiles

Precompiles used by the EVM.

type Inspector

Evm inspector.

Required Methods§

fn block(&self) -> &BlockEnv

Reference to BlockEnv.

fn chain_id(&self) -> u64

Returns the chain ID of the environment.

fn transact_raw( &mut self, tx: Self::Tx, ) -> Result<ResultAndState<Self::HaltReason>, Self::Error>

Executes a transaction and returns the outcome.

fn transact_system_call( &mut self, caller: Address, contract: Address, data: Bytes, ) -> Result<ResultAndState<Self::HaltReason>, Self::Error>

Executes a system call.

Note: this will only keep the target contract in the state. This is done because revm is loading BlockEnv::beneficiary into state by default, and we need to avoid it by also covering edge cases when beneficiary is set to the system contract address.

fn db_mut(&mut self) -> &mut Self::DB

Returns a mutable reference to the underlying database.

fn finish(self) -> (Self::DB, EvmEnv<Self::Spec>)
where Self: Sized,

Consumes the EVM and returns the inner EvmEnv.

fn set_inspector_enabled(&mut self, enabled: bool)

Determines whether additional transactions should be inspected or not.

See also EvmFactory::create_evm_with_inspector.

fn precompiles(&self) -> &Self::Precompiles

Getter of precompiles.

fn precompiles_mut(&mut self) -> &mut Self::Precompiles

Mutable getter of precompiles.

fn inspector(&self) -> &Self::Inspector

Getter of inspector.

fn inspector_mut(&mut self) -> &mut Self::Inspector

Mutable getter of inspector.

Provided Methods§

fn transact( &mut self, tx: impl IntoTxEnv<Self::Tx>, ) -> Result<ResultAndState<Self::HaltReason>, Self::Error>

Same as Evm::transact_raw, but takes a IntoTxEnv implementation, thus allowing to support transacting with an external type.

fn transact_commit( &mut self, tx: impl IntoTxEnv<Self::Tx>, ) -> Result<ExecutionResult<Self::HaltReason>, Self::Error>
where Self::DB: DatabaseCommit,

Executes a transaction and commits the state changes to the underlying database.

fn into_db(self) -> Self::DB
where Self: Sized,

Consumes the EVM and returns the inner database.

fn into_env(self) -> EvmEnv<Self::Spec>
where Self: Sized,

Consumes the EVM and returns the inner EvmEnv.

fn enable_inspector(&mut self)

Enables the configured inspector.

All additional transactions will be inspected if enabled.

fn disable_inspector(&mut self)

Disables the configured inspector.

Transactions will no longer be inspected.

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§

§

impl<DB, I, P> Evm for SeismicEvm<DB, I, P>
where DB: Database, I: Inspector<Context<BlockEnv, SeismicTransaction<TxEnv>, CfgEnv<SeismicSpecId>, DB, Journal<DB>, SeismicChain>>, P: PrecompileProvider<Context<BlockEnv, SeismicTransaction<TxEnv>, CfgEnv<SeismicSpecId>, DB, Journal<DB>, SeismicChain>, Output = InterpreterResult>,

§

type DB = DB

§

type Tx = SeismicTransaction<TxEnv>

§

type Error = EVMError<<DB as Database>::Error>

§

type HaltReason = SeismicHaltReason

§

type Spec = SeismicSpecId

§

type Precompiles = P

§

type Inspector = I

§

fn chain_id(&self) -> u64

§

fn block(&self) -> &BlockEnv

§

fn transact_raw( &mut self, tx: <SeismicEvm<DB, I, P> as Evm>::Tx, ) -> Result<ResultAndState<<SeismicEvm<DB, I, P> as Evm>::HaltReason>, <SeismicEvm<DB, I, P> as Evm>::Error>

§

fn transact( &mut self, tx: impl IntoTxEnv<<SeismicEvm<DB, I, P> as Evm>::Tx>, ) -> Result<ResultAndState<<SeismicEvm<DB, I, P> as Evm>::HaltReason>, <SeismicEvm<DB, I, P> as Evm>::Error>

§

fn transact_system_call( &mut self, caller: Address, contract: Address, data: Bytes, ) -> Result<ResultAndState<<SeismicEvm<DB, I, P> as Evm>::HaltReason>, <SeismicEvm<DB, I, P> as Evm>::Error>

§

fn db_mut(&mut self) -> &mut <SeismicEvm<DB, I, P> as Evm>::DB

§

fn finish( self, ) -> (<SeismicEvm<DB, I, P> as Evm>::DB, EvmEnv<<SeismicEvm<DB, I, P> as Evm>::Spec>)

§

fn set_inspector_enabled(&mut self, enabled: bool)

§

fn precompiles(&self) -> &<SeismicEvm<DB, I, P> as Evm>::Precompiles

§

fn precompiles_mut(&mut self) -> &mut <SeismicEvm<DB, I, P> as Evm>::Precompiles

§

fn inspector(&self) -> &<SeismicEvm<DB, I, P> as Evm>::Inspector

§

fn inspector_mut(&mut self) -> &mut <SeismicEvm<DB, I, P> as Evm>::Inspector

Implementors§

§

impl<DB, I, PRECOMPILE> Evm for EthEvm<DB, I, PRECOMPILE>

§

type DB = DB

§

type Tx = TxEnv

§

type Error = EVMError<<DB as Database>::Error>

§

type HaltReason = HaltReason

§

type Spec = SpecId

§

type Precompiles = PRECOMPILE

§

type Inspector = I

§

impl<L, R> Evm for Either<L, R>
where R: Evm<DB = <L as Evm>::DB, Tx = <L as Evm>::Tx, Error = <L as Evm>::Error, HaltReason = <L as Evm>::HaltReason, Spec = <L as Evm>::Spec, Precompiles = <L as Evm>::Precompiles, Inspector = <L as Evm>::Inspector>, L: Evm,

§

type DB = <L as Evm>::DB

§

type Tx = <L as Evm>::Tx

§

type Error = <L as Evm>::Error

§

type HaltReason = <L as Evm>::HaltReason

§

type Spec = <L as Evm>::Spec

§

type Precompiles = <L as Evm>::Precompiles

§

type Inspector = <L as Evm>::Inspector