Skip to main content

Module evm

Module evm 

Source
Expand description

Foundry’s execution stack on evm2.

FoundryEvmNetwork binds an Alloy network to a FoundryEvmFactory, which owns the network’s evm2 type family ([EvmTypesHost]): spec, transaction, block and result extensions, the transaction registry and the precompiles. One marker exists per network family: EthEvmNetwork, OpEvmNetwork, BaseEvmNetwork, MonadEvmNetwork and TempoEvmNetwork.

Transactions stay network-native until execution (see tx). ExecutionLifecycle owns the accepted state that evm2’s State does not.

crate::backend::Backend layers RPC forks and Foundry’s cheatcode policy on top of the lifecycle.

Modules§

basebase
Base on evm2, using base-evm2.
eth
Ethereum on evm2.
monadmonad
Monad on evm2, using monad-evm2.
opoptimism
OP Stack on evm2, using op-evm2.
tempo
Tempo execution integration.

Structs§

BaseEvmNetwork
Base EVM network.
BlockContext
Transactions of a block and its two ancestors, for network state that depends on the block position of a transaction (see FoundryEvmExt::for_block).
DestructedAccount
The state a nested transaction left an account in before the transaction ended and destroyed it, which the running transaction keeps until it ends itself.
EthEvmFactory
Ethereum evm2 factory over evm2’s stock type family.
EthEvmNetwork
Ethereum EVM network.
EvmEnv
The spec, runtime version and block an EVM is built with.
ExecutedNested
The outcome of a PreparedTx, to store with ExecutionLifecycle::store_executed.
ExecutionLifecycle
Fork, snapshot and nested-execution lifecycle for one EVM network family.
ForkCode
Converts accounts of the fork cache, which holds raw code, into evm2 accounts.
ForkDb
A remote fork’s backing database: Foundry’s RPC-backed fork cache, read by evm2.
ForkEntry
A registered fork.
ForkInfo
Identity of a fork as Foundry users see it: its RPC endpoint and pinned block.
ForkRegistry
Registered forks, the local context, the active selection and persistent accounts.
LifecycleSnapshot
Everything a snapshot revert restores.
MonadEvmNetwork
Monad EVM network.
OpEvmNetwork
OP Stack EVM network.
Parked
An execution context that is not running: its backing database, environment, network extension state and accepted state.
PreparedTx
A transaction prepared to execute as a nested transaction of the running one, such as for vm.transact, whose inspector may hold the lifecycle’s owner while it runs.
SnapshotRestores
Running states replaced by snapshot restorations inside the open frames of a transaction.
StoredExt
Network extension state stored outside a running EVM, such as by a parked context or a snapshot.
TempoEvmNetwork
Tempo EVM network.

Enums§

ExecutionPhase
Whether a lifecycle operation runs between transactions or inside one, such as from a cheatcode.
ForkPosition
Canonical chain position of a fork’s accepted state.
PersistentWrite
A write that must survive reverts of the enclosing calls, such as a cheatcode’s state edit. It is applied as a journaled write, and the owner replays it after each enclosing call that reverts. Balance and nonce writes replay as deltas, so they compose with value transfers and nonce bumps undone by the revert, saturating at their bounds, unless their Replay mode says otherwise.
Replay
How a balance or nonce PersistentWrite replays, ordered by precedence when combined.
TxPayload
What an execution-time transaction is priced and validated as.

Constants§

FOUNDRY_POLICY_FEATURES
Features Foundry toggles independently of the fork.

Traits§

BackingDb
A shareable backing database: every fork and every nested transaction reads through its own handle to the same source.
FoundryDatabase
Database view the factory needs at construction time.
FoundryEvmExt
Per-EVM network state, such as OP L1 block info or Monad’s reserve-balance context.
FoundryEvmFactory
Builds Foundry-configured EVMs for one evm2 [EvmTypesHost] family.
FoundryEvmNetwork
Binds an Alloy network to an evm2 factory.
FoundryExecutionHooks
Execution-family hooks for state Foundry changes outside ordinary EVM execution.
FoundryTxConversion
Converts an Alloy network’s native transactions into an evm2 execution family’s transactions.
FoundryTxResultExt
Network-only transaction outcome flags.
SendableExt
Network extension state that can be copied without sharing thread-unsafe state.

Functions§

block_txs
Converts every transaction of a full RPC block.
bsc_p256
Returns BSC’s P256VERIFY on chain_id at timestamp. The outer option distinguishes BSC chains from unrelated chains, while the inner option disables P256 before Haber and otherwise tells whether it uses the Osaka gas schedule.
carry_execution_policy
Returns next with Foundry’s execution policy carried over from current.
celo_transfer
Runs Celo’s native token transfer precompile.
destructed_accounts
Returns the accounts the running transaction in state self-destructed, with their state before the transaction ends and destroys them, such as at the end of the root frame of a nested transaction.
eth_envelope_from_any_rpc
Returns the Ethereum envelope of a transaction fetched over RPC.
eth_tx
Converts a signed Ethereum envelope into evm2’s Ethereum transaction.
eth_tx_from_request
Converts a complete unsigned Ethereum request into a simulated evm2 transaction.
evm_env
Returns the environment evm currently executes with.
existing_account
Returns account, which a database reports as an existing empty account when it does not hold it, as an execution applying EIP-161 or not loads it. Under EIP-161 an empty account does not exist, so it is loaded as absent.
merge_pending_changes
Applies the changes of a nested transaction detached into pending to the running transaction’s state as journaled writes, so they revert with the enclosing call.
merge_untracked_nested_changes
Applies a nested transaction’s changes to the running transaction’s state as journaled writes and returns them as PersistentWrites, for the caller to replay when an enclosing call reverts, such as for broadcastRawTransaction.
merge_untracked_pending_changes_with_warmth
Applies the changes of a nested transaction that child ran and detached into pending to the running transaction’s state like merge_untracked_nested_changes, and also warms the accounts and slots the nested transaction left warm, such as for executeTransaction.
placeholder_signature
Placeholder signature used to put an unsigned request into its network’s envelope.
put_transient
Writes transient storage taken with take_transient into the running transaction in state.
release_inspector⚠
Clears evm’s inspector and returns the EVM without the borrows the inspector held, such as to park an EVM whose inspector borrowed the lifecycle’s owner.
restore_access_warmth
Undoes, without journaling, the warmth that the running transaction in state gained since checkpoint, keeping all other warmth, including unjournaled changes made since.
take_transient
Removes and returns the transient storage of the running transaction in state, as address, key and value, sorted so writing it back is deterministic.
warm_accounts
Returns the accounts the running transaction in state loaded and that are warm, with their warm slots.
warm_set
Returns the warmth of the running transaction in state: its base warm set and the accounts and slots it warmed, for a transaction that continues in a replaced state.

Type Aliases§

BlockEnvFor
ChainFor
EvmEnvFor
EvmFactoryFor
Convenience type aliases for accessing associated types through FoundryEvmNetwork.
ForkCursor
A fork’s canonical position and the network state retaining its block cursor.
FoundryEvmFor
InterpreterFor
MessageFor
MessageResultFor
NetworkFor
SpecFor
SpecOf
TransactionRequestFor
TxEnvelopeFor
TxFor
TxResultFor
TypesFor