pub(crate) struct Backend {
pub(crate) journaled_state: Journal<InMemoryDB>,
pub(crate) method_with_inspector_counter: usize,
pub(crate) method_without_inspector_counter: usize,
}
Expand description
Backend for cheatcodes.
The problematic cheatcodes are only supported in fork mode, so we’ll omit the non-fork behavior of the Foundry
Backend
.
Fields§
§journaled_state: Journal<InMemoryDB>
In fork mode, Foundry stores (JournaledState
, Database
) pairs for each fork.
method_with_inspector_counter: usize
Counters to be able to assert that we mutated the object that we expected to mutate.
method_without_inspector_counter: usize
Implementations§
Trait Implementations§
Source§impl DatabaseExt for Backend
impl DatabaseExt for Backend
Source§fn method_that_takes_inspector_as_argument<InspectorT, BlockT, TxT, CfgT, InstructionProviderT, PrecompileT>(
&mut self,
env: Env<BlockT, TxT, CfgT>,
inspector: InspectorT,
) -> Result<()>where
InspectorT: Inspector<Context<BlockT, TxT, CfgT, InMemoryDB, Backend>, EthInterpreter>,
BlockT: Block,
TxT: Transaction,
CfgT: Cfg,
InstructionProviderT: InstructionProvider<Context = Context<BlockT, TxT, CfgT, InMemoryDB, Backend>, InterpreterTypes = EthInterpreter> + Default,
PrecompileT: PrecompileProvider<Context<BlockT, TxT, CfgT, InMemoryDB, Backend>, Output = InterpreterResult> + Default,
fn method_that_takes_inspector_as_argument<InspectorT, BlockT, TxT, CfgT, InstructionProviderT, PrecompileT>(
&mut self,
env: Env<BlockT, TxT, CfgT>,
inspector: InspectorT,
) -> Result<()>where
InspectorT: Inspector<Context<BlockT, TxT, CfgT, InMemoryDB, Backend>, EthInterpreter>,
BlockT: Block,
TxT: Transaction,
CfgT: Cfg,
InstructionProviderT: InstructionProvider<Context = Context<BlockT, TxT, CfgT, InMemoryDB, Backend>, InterpreterTypes = EthInterpreter> + Default,
PrecompileT: PrecompileProvider<Context<BlockT, TxT, CfgT, InMemoryDB, Backend>, Output = InterpreterResult> + Default,
Mimics
DatabaseExt::transact
See commit_transaction
for the genericsSource§fn method_that_constructs_inspector<BlockT, TxT, CfgT, InstructionProviderT, PrecompileT>(
&mut self,
env: Env<BlockT, TxT, CfgT>,
) -> Result<()>where
BlockT: Block,
TxT: Transaction,
CfgT: Cfg,
InstructionProviderT: InstructionProvider<Context = Context<BlockT, TxT, CfgT, InMemoryDB, Backend>, InterpreterTypes = EthInterpreter> + Default,
PrecompileT: PrecompileProvider<Context<BlockT, TxT, CfgT, InMemoryDB, Backend>, Output = InterpreterResult> + Default,
fn method_that_constructs_inspector<BlockT, TxT, CfgT, InstructionProviderT, PrecompileT>(
&mut self,
env: Env<BlockT, TxT, CfgT>,
) -> Result<()>where
BlockT: Block,
TxT: Transaction,
CfgT: Cfg,
InstructionProviderT: InstructionProvider<Context = Context<BlockT, TxT, CfgT, InMemoryDB, Backend>, InterpreterTypes = EthInterpreter> + Default,
PrecompileT: PrecompileProvider<Context<BlockT, TxT, CfgT, InMemoryDB, Backend>, Output = InterpreterResult> + Default,
Mimics
DatabaseExt::roll_fork_to_transaction
Source§impl JournalExt for Backend
impl JournalExt for Backend
Source§fn last_journal(&self) -> &[JournalEntry]
fn last_journal(&self) -> &[JournalEntry]
Get the journal entries that are created from last checkpoint.
new checkpoint is created when sub call is made.
Source§fn evm_state_mut(&mut self) -> &mut EvmState
fn evm_state_mut(&mut self) -> &mut EvmState
Return the mutable current Journaled state.
Source§impl JournalTr for Backend
impl JournalTr for Backend
type Database = CacheDB<EmptyDBTyped<Infallible>>
type FinalOutput = JournalOutput
Source§fn new(database: InMemoryDB) -> Self
fn new(database: InMemoryDB) -> Self
Creates new Journaled state. Read more
Source§fn sload(
&mut self,
address: Address,
key: U256,
) -> Result<StateLoad<U256>, <Self::Database as Database>::Error>
fn sload( &mut self, address: Address, key: U256, ) -> Result<StateLoad<U256>, <Self::Database as Database>::Error>
Returns the storage value from Journal state. Read more
Source§fn sstore(
&mut self,
address: Address,
key: U256,
value: U256,
) -> Result<StateLoad<SStoreResult>, <Self::Database as Database>::Error>
fn sstore( &mut self, address: Address, key: U256, value: U256, ) -> Result<StateLoad<SStoreResult>, <Self::Database as Database>::Error>
Stores the storage value in Journal state.
Source§fn tstore(&mut self, address: Address, key: U256, value: U256)
fn tstore(&mut self, address: Address, key: U256, value: U256)
Stores transient storage value.
Source§fn selfdestruct(
&mut self,
address: Address,
target: Address,
) -> Result<StateLoad<SelfDestructResult>, Infallible>
fn selfdestruct( &mut self, address: Address, target: Address, ) -> Result<StateLoad<SelfDestructResult>, Infallible>
Marks the account for selfdestruction and transfers all the balance to the target.
Source§fn warm_account_and_storage(
&mut self,
address: Address,
storage_keys: impl IntoIterator<Item = U256>,
) -> Result<(), <Self::Database as Database>::Error>
fn warm_account_and_storage( &mut self, address: Address, storage_keys: impl IntoIterator<Item = U256>, ) -> Result<(), <Self::Database as Database>::Error>
Warms the account and storage.
Source§fn warm_account(&mut self, address: Address)
fn warm_account(&mut self, address: Address)
Warms the account.
Source§fn warm_precompiles(&mut self, addresses: HashSet<Address>)
fn warm_precompiles(&mut self, addresses: HashSet<Address>)
Warms the precompiles.
Source§fn precompile_addresses(&self) -> &HashSet<Address>
fn precompile_addresses(&self) -> &HashSet<Address>
Returns the addresses of the precompiles.
Source§fn set_spec_id(&mut self, spec_id: SpecId)
fn set_spec_id(&mut self, spec_id: SpecId)
Sets the spec id.
Source§fn touch_account(&mut self, address: Address)
fn touch_account(&mut self, address: Address)
Touches the account.
Source§fn transfer(
&mut self,
from: Address,
to: Address,
balance: U256,
) -> Result<Option<TransferError>, Infallible>
fn transfer( &mut self, from: Address, to: Address, balance: U256, ) -> Result<Option<TransferError>, Infallible>
Transfers the balance from one account to another.
Source§fn inc_account_nonce(
&mut self,
address: Address,
) -> Result<Option<u64>, Infallible>
fn inc_account_nonce( &mut self, address: Address, ) -> Result<Option<u64>, Infallible>
Increments the nonce of the account.
Source§fn load_account(
&mut self,
address: Address,
) -> Result<StateLoad<&mut Account>, Infallible>
fn load_account( &mut self, address: Address, ) -> Result<StateLoad<&mut Account>, Infallible>
Loads the account.
Source§fn load_account_code(
&mut self,
address: Address,
) -> Result<StateLoad<&mut Account>, Infallible>
fn load_account_code( &mut self, address: Address, ) -> Result<StateLoad<&mut Account>, Infallible>
Loads the account code.
Source§fn load_account_delegated(
&mut self,
address: Address,
) -> Result<StateLoad<AccountLoad>, Infallible>
fn load_account_delegated( &mut self, address: Address, ) -> Result<StateLoad<AccountLoad>, Infallible>
Loads the account delegated.
Source§fn set_code_with_hash(&mut self, address: Address, code: Bytecode, hash: B256)
fn set_code_with_hash(&mut self, address: Address, code: Bytecode, hash: B256)
Sets bytecode with hash. Assume that account is warm.
Source§fn code(
&mut self,
address: Address,
) -> Result<StateLoad<Bytes>, <Self::Database as Database>::Error>
fn code( &mut self, address: Address, ) -> Result<StateLoad<Bytes>, <Self::Database as Database>::Error>
Returns account code bytes and if address is cold loaded. Read more
Source§fn code_hash(
&mut self,
address: Address,
) -> Result<StateLoad<B256>, <Self::Database as Database>::Error>
fn code_hash( &mut self, address: Address, ) -> Result<StateLoad<B256>, <Self::Database as Database>::Error>
Gets code hash of account. Read more
Source§fn clear(&mut self)
fn clear(&mut self)
Called at the end of the transaction to clean all residue data from journal.
Source§fn checkpoint(&mut self) -> JournalCheckpoint
fn checkpoint(&mut self) -> JournalCheckpoint
Creates a checkpoint of the current state. State can be revert to this point
if needed.
Source§fn checkpoint_commit(&mut self)
fn checkpoint_commit(&mut self)
Commits the changes made since the last checkpoint.
Source§fn checkpoint_revert(&mut self, checkpoint: JournalCheckpoint)
fn checkpoint_revert(&mut self, checkpoint: JournalCheckpoint)
Reverts the changes made since the last checkpoint.
Source§fn create_account_checkpoint(
&mut self,
caller: Address,
address: Address,
balance: U256,
spec_id: SpecId,
) -> Result<JournalCheckpoint, TransferError>
fn create_account_checkpoint( &mut self, caller: Address, address: Address, balance: U256, spec_id: SpecId, ) -> Result<JournalCheckpoint, TransferError>
Creates a checkpoint of the account creation.
Source§fn finalize(&mut self) -> Self::FinalOutput
fn finalize(&mut self) -> Self::FinalOutput
Does cleanup and returns modified state. Read more
Auto Trait Implementations§
impl Freeze for Backend
impl RefUnwindSafe for Backend
impl Send for Backend
impl Sync for Backend
impl Unpin for Backend
impl UnwindSafe for Backend
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Conv for T
impl<T> Conv for T
§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
Causes
self
to use its Binary
implementation when Debug
-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
Causes
self
to use its Display
implementation when
Debug
-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
Causes
self
to use its LowerExp
implementation when
Debug
-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
Causes
self
to use its LowerHex
implementation when
Debug
-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
Causes
self
to use its Octal
implementation when Debug
-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
Causes
self
to use its Pointer
implementation when
Debug
-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
Causes
self
to use its UpperExp
implementation when
Debug
-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
Causes
self
to use its UpperHex
implementation when
Debug
-formatted.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
Formats each item in a sequence. Read more
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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>
Converts
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>
Converts
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 more§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Pipes by value. This is generally the method you want to use. Read more
§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,
Borrows
self
and passes that borrow into the pipe function. Read more§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,
Mutably borrows
self
and passes that borrow into the pipe function. Read more§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
§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
§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
Borrows
self
, then passes self.as_ref()
into the pipe function.§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
Mutably borrows
self
, then passes self.as_mut()
into the pipe
function.§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
Borrows
self
, then passes self.deref()
into the pipe function.§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Immutable access to the
Borrow<B>
of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
Mutable access to the
BorrowMut<B>
of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
Immutable access to the
AsRef<R>
view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
Mutable access to the
AsMut<R>
view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Immutable access to the
Deref::Target
of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Mutable access to the
Deref::Target
of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
Calls
.tap()
only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
Calls
.tap_mut()
only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
Calls
.tap_borrow()
only in debug builds, and is erased in release
builds.§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
Calls
.tap_borrow_mut()
only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
Calls
.tap_ref()
only in debug builds, and is erased in release
builds.§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
Calls
.tap_ref_mut()
only in debug builds, and is erased in release
builds.§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
Calls
.tap_deref()
only in debug builds, and is erased in release
builds.