pub struct EvmBuilder<'a, BuilderStage, EXT, DB: Database> { /* private fields */ }
Expand description
Evm Builder allows building or modifying EVM. Note that some of the methods that changes underlying structures will reset the registered handler to default mainnet.
Implementations§
Source§impl<'a, EXT, DB: Database> EvmBuilder<'a, SetGenericStage, EXT, DB>
impl<'a, EXT, DB: Database> EvmBuilder<'a, SetGenericStage, EXT, DB>
Sourcepub fn with_empty_db(self) -> EvmBuilder<'a, SetGenericStage, EXT, EmptyDB>
pub fn with_empty_db(self) -> EvmBuilder<'a, SetGenericStage, EXT, EmptyDB>
Sourcepub fn with_db<ODB: Database>(
self,
db: ODB,
) -> EvmBuilder<'a, SetGenericStage, EXT, ODB>
pub fn with_db<ODB: Database>( self, db: ODB, ) -> EvmBuilder<'a, SetGenericStage, EXT, ODB>
Sourcepub fn with_ref_db<ODB: DatabaseRef>(
self,
db: ODB,
) -> EvmBuilder<'a, SetGenericStage, EXT, WrapDatabaseRef<ODB>>
pub fn with_ref_db<ODB: DatabaseRef>( self, db: ODB, ) -> EvmBuilder<'a, SetGenericStage, EXT, WrapDatabaseRef<ODB>>
Sets the DatabaseRef
that will be used by Evm
.
Sourcepub fn with_external_context<OEXT>(
self,
external: OEXT,
) -> EvmBuilder<'a, SetGenericStage, OEXT, DB>
pub fn with_external_context<OEXT>( self, external: OEXT, ) -> EvmBuilder<'a, SetGenericStage, OEXT, DB>
Sets the external context that will be used by Evm
.
Sourcepub fn with_env_with_handler_cfg(
self,
env_with_handler_cfg: EnvWithHandlerCfg,
) -> EvmBuilder<'a, HandlerStage, EXT, DB>
pub fn with_env_with_handler_cfg( self, env_with_handler_cfg: EnvWithHandlerCfg, ) -> EvmBuilder<'a, HandlerStage, EXT, DB>
Sets Builder with EnvWithHandlerCfg
.
Sourcepub fn with_context_with_handler_cfg<OEXT, ODB: Database>(
self,
context_with_handler_cfg: ContextWithHandlerCfg<OEXT, ODB>,
) -> EvmBuilder<'a, HandlerStage, OEXT, ODB>
pub fn with_context_with_handler_cfg<OEXT, ODB: Database>( self, context_with_handler_cfg: ContextWithHandlerCfg<OEXT, ODB>, ) -> EvmBuilder<'a, HandlerStage, OEXT, ODB>
Sets Builder with ContextWithHandlerCfg
.
Sourcepub fn with_cfg_env_with_handler_cfg(
self,
cfg_env_and_spec_id: CfgEnvWithHandlerCfg,
) -> EvmBuilder<'a, HandlerStage, EXT, DB>
pub fn with_cfg_env_with_handler_cfg( self, cfg_env_and_spec_id: CfgEnvWithHandlerCfg, ) -> EvmBuilder<'a, HandlerStage, EXT, DB>
Sets Builder with CfgEnvWithHandlerCfg
.
Sourcepub fn with_handler_cfg(
self,
handler_cfg: HandlerCfg,
) -> EvmBuilder<'a, HandlerStage, EXT, DB>
pub fn with_handler_cfg( self, handler_cfg: HandlerCfg, ) -> EvmBuilder<'a, HandlerStage, EXT, DB>
Sets Builder with HandlerCfg
Sourcepub fn optimism(self) -> EvmBuilder<'a, HandlerStage, EXT, DB>
pub fn optimism(self) -> EvmBuilder<'a, HandlerStage, EXT, DB>
Sets the Optimism handler with latest spec.
If optimism-default-handler
feature is enabled this is not needed.
Sourcepub fn mainnet(self) -> EvmBuilder<'a, HandlerStage, EXT, DB>
pub fn mainnet(self) -> EvmBuilder<'a, HandlerStage, EXT, DB>
Sets the mainnet handler with latest spec.
Enabled only with optimism-default-handler
feature.
Source§impl<'a, EXT, DB: Database> EvmBuilder<'a, HandlerStage, EXT, DB>
impl<'a, EXT, DB: Database> EvmBuilder<'a, HandlerStage, EXT, DB>
Sourcepub fn new(evm: Evm<'a, EXT, DB>) -> Self
pub fn new(evm: Evm<'a, EXT, DB>) -> Self
Creates new builder from Evm, Evm is consumed and all field are moved to Builder. It will preserve set handler and context.
Builder is in HandlerStage and both database and external are set.
Sourcepub fn reset_handler_with_empty_db(
self,
) -> EvmBuilder<'a, HandlerStage, EXT, EmptyDB>
pub fn reset_handler_with_empty_db( self, ) -> EvmBuilder<'a, HandlerStage, EXT, EmptyDB>
Sourcepub fn reset_handler_with_mainnet(self) -> EvmBuilder<'a, HandlerStage, EXT, DB>
pub fn reset_handler_with_mainnet(self) -> EvmBuilder<'a, HandlerStage, EXT, DB>
Resets the Handler
and sets base mainnet handler.
Enabled only with optimism-default-handler
feature.
Sourcepub fn reset_handler_with_db<ODB: Database>(
self,
db: ODB,
) -> EvmBuilder<'a, SetGenericStage, EXT, ODB>
pub fn reset_handler_with_db<ODB: Database>( self, db: ODB, ) -> EvmBuilder<'a, SetGenericStage, EXT, ODB>
Sourcepub fn reset_handler_with_ref_db<ODB: DatabaseRef>(
self,
db: ODB,
) -> EvmBuilder<'a, SetGenericStage, EXT, WrapDatabaseRef<ODB>>
pub fn reset_handler_with_ref_db<ODB: DatabaseRef>( self, db: ODB, ) -> EvmBuilder<'a, SetGenericStage, EXT, WrapDatabaseRef<ODB>>
Resets Handler
and sets the DatabaseRef
that will be used by Evm
and resets the Handler
to default mainnet.
Sourcepub fn reset_handler_with_external_context<OEXT>(
self,
external: OEXT,
) -> EvmBuilder<'a, SetGenericStage, OEXT, DB>
pub fn reset_handler_with_external_context<OEXT>( self, external: OEXT, ) -> EvmBuilder<'a, SetGenericStage, OEXT, DB>
Source§impl<'a, BuilderStage, EXT, DB: Database> EvmBuilder<'a, BuilderStage, EXT, DB>
impl<'a, BuilderStage, EXT, DB: Database> EvmBuilder<'a, BuilderStage, EXT, DB>
Sourcepub fn with_handler(
self,
handler: Handler<'a, Context<EXT, DB>, EXT, DB>,
) -> EvmBuilder<'a, BuilderStage, EXT, DB>
pub fn with_handler( self, handler: Handler<'a, Context<EXT, DB>, EXT, DB>, ) -> EvmBuilder<'a, BuilderStage, EXT, DB>
This modifies the EvmBuilder to make it easy to construct an Evm
with a specific
handler.
§Example
use revm::{EvmBuilder, Handler, primitives::{SpecId, HandlerCfg}};
use revm_interpreter::primitives::CancunSpec;
let builder = EvmBuilder::default();
// get the desired handler
let mainnet = Handler::mainnet::<CancunSpec>();
let builder = builder.with_handler(mainnet);
// build the EVM
let evm = builder.build();
Sourcepub fn append_handler_register(
self,
handle_register: HandleRegister<EXT, DB>,
) -> EvmBuilder<'a, HandlerStage, EXT, DB>
pub fn append_handler_register( self, handle_register: HandleRegister<EXT, DB>, ) -> EvmBuilder<'a, HandlerStage, EXT, DB>
Register Handler that modifies the behavior of EVM.
Check Handler
for more information.
When called, EvmBuilder will transition from SetGenericStage to HandlerStage.
Sourcepub fn append_handler_register_box(
self,
handle_register: HandleRegisterBox<'a, EXT, DB>,
) -> EvmBuilder<'a, HandlerStage, EXT, DB>
pub fn append_handler_register_box( self, handle_register: HandleRegisterBox<'a, EXT, DB>, ) -> EvmBuilder<'a, HandlerStage, EXT, DB>
Register Handler that modifies the behavior of EVM.
Check Handler
for more information.
When called, EvmBuilder will transition from SetGenericStage to HandlerStage.
Sourcepub fn with_spec_id(self, spec_id: SpecId) -> Self
pub fn with_spec_id(self, spec_id: SpecId) -> Self
Sets specification Id , that will mark the version of EVM. It represent the hard fork of ethereum.
§Note
When changed it will reapply all handle registers, this can be expensive operation depending on registers.
Sourcepub fn modify_external_context(self, f: impl FnOnce(&mut EXT)) -> Self
pub fn modify_external_context(self, f: impl FnOnce(&mut EXT)) -> Self
Allows modification of external context.
Sourcepub fn modify_env(self, f: impl FnOnce(&mut Box<Env>)) -> Self
pub fn modify_env(self, f: impl FnOnce(&mut Box<Env>)) -> Self
Allows modification of Evm Environment.
Sourcepub fn modify_tx_env(self, f: impl FnOnce(&mut TxEnv)) -> Self
pub fn modify_tx_env(self, f: impl FnOnce(&mut TxEnv)) -> Self
Allows modification of Evm’s Transaction Environment.
Sourcepub fn with_tx_env(self, tx_env: TxEnv) -> Self
pub fn with_tx_env(self, tx_env: TxEnv) -> Self
Sets Evm’s Transaction Environment.
Sourcepub fn modify_block_env(self, f: impl FnOnce(&mut BlockEnv)) -> Self
pub fn modify_block_env(self, f: impl FnOnce(&mut BlockEnv)) -> Self
Allows modification of Evm’s Block Environment.
Sourcepub fn with_block_env(self, block_env: BlockEnv) -> Self
pub fn with_block_env(self, block_env: BlockEnv) -> Self
Sets Evm’s Block Environment.
Sourcepub fn modify_cfg_env(self, f: impl FnOnce(&mut CfgEnv)) -> Self
pub fn modify_cfg_env(self, f: impl FnOnce(&mut CfgEnv)) -> Self
Allows modification of Evm’s Config Environment.
Sourcepub fn with_clear_env(self) -> Self
pub fn with_clear_env(self) -> Self
Clears Environment of EVM.
Sourcepub fn with_clear_tx_env(self) -> Self
pub fn with_clear_tx_env(self) -> Self
Clears Transaction environment of EVM.
Sourcepub fn with_clear_block_env(self) -> Self
pub fn with_clear_block_env(self) -> Self
Clears Block environment of EVM.
Sourcepub fn reset_handler(self) -> Self
pub fn reset_handler(self) -> Self
Resets Handler
to default mainnet.
Trait Implementations§
Auto Trait Implementations§
impl<'a, BuilderStage, EXT, DB> Freeze for EvmBuilder<'a, BuilderStage, EXT, DB>
impl<'a, BuilderStage, EXT, DB> !RefUnwindSafe for EvmBuilder<'a, BuilderStage, EXT, DB>
impl<'a, BuilderStage, EXT, DB> !Send for EvmBuilder<'a, BuilderStage, EXT, DB>
impl<'a, BuilderStage, EXT, DB> !Sync for EvmBuilder<'a, BuilderStage, EXT, DB>
impl<'a, BuilderStage, EXT, DB> Unpin for EvmBuilder<'a, BuilderStage, EXT, DB>
impl<'a, BuilderStage, EXT, DB> !UnwindSafe for EvmBuilder<'a, BuilderStage, EXT, DB>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self
to use its Binary
implementation when Debug
-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self
to use its Display
implementation when
Debug
-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self
to use its LowerExp
implementation when
Debug
-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self
to use its LowerHex
implementation when
Debug
-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self
to use its Octal
implementation when Debug
-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self
to use its Pointer
implementation when
Debug
-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self
to use its UpperExp
implementation when
Debug
-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self
to use its UpperHex
implementation when
Debug
-formatted.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self
, then passes self.as_ref()
into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self
, then passes self.as_mut()
into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self
, then passes self.deref()
into the pipe function.Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B>
of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B>
of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R>
view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R>
view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target
of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target
of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap()
only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut()
only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow()
only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut()
only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref()
only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut()
only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref()
only in debug builds, and is erased in release
builds.