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.
Re-exports§
use alloy_consensus::SignableTransaction;🔒use alloy_consensus::Signed;🔒use alloy_consensus::transaction::SignerRecoverable;🔒use alloy_eips::Typed2718;🔒use alloy_network::Network;🔒use alloy_primitives::Signature;🔒use alloy_rlp::Decodable;🔒use evm2::Evm;🔒use evm2::EvmTypes;🔒use evm2::ExecutionConfig;🔒use evm2::TxResult;🔒use evm2::Version;🔒use evm2::env::BlockEnv;🔒use evm2::evm::precompile::PrecompileProvider;🔒use evm2::registry::TxRegistry;🔒use foundry_common::FoundryReceiptResponse;🔒use foundry_common::FoundryTransactionBuilder;🔒use foundry_common::fmt::UIfmt;🔒use foundry_evm_hardforks::ExecutionSpec;🔒use foundry_evm_networks::NetworkConfigs;🔒use serde::Deserialize;🔒use serde::Deserialize;🔒use serde::Serialize;🔒use serde::Serialize;🔒use std::fmt::Debug;🔒use std::fmt::Debug;🔒pub use base::BaseEvmNetwork;basepub use monad::MonadEvmNetwork;monadpub use op::OpEvmNetwork;optimismpub use tempo::TempoEvmNetwork;pub use eth::*;
Modules§
- base
base - Base on evm2, using
base-evm2. - db 🔒
- Backing databases.
- env 🔒
- Execution environments and network extension state.
- eth
- Ethereum on evm2.
- fork 🔒
- Fork registry: which backing databases exist, which one is active, and the accepted state each inactive one resumes with.
- lifecycle 🔒
- Foundry’s execution lifecycle over evm2: fork switching, snapshots and nested execution.
- monad
monad - Monad on evm2, using
monad-evm2. - op
optimism - OP Stack on evm2, using
op-evm2. - snapshot 🔒
- User-visible state snapshots.
- tempo
- Tempo execution integration.
- tx 🔒
- Network-native transactions.
Structs§
- Accepted
View - A context’s accepted state layered over its backing database, shared without copying.
- Block
Context - Transactions of a block and its two ancestors, for network state that depends on the block
position of a transaction (see
FoundryEvmExt::for_block). - Destructed
Account - 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.
- EvmEnv
- The spec, runtime version and block an EVM is built with.
- Executed
Nested - The outcome of a
PreparedTx, to store withExecutionLifecycle::store_executed. - Execution
Lifecycle - Fork, snapshot and nested-execution lifecycle for one EVM network family.
- Fork
Code - 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.
- Fork
Entry - A registered fork.
- Fork
Info - Identity of a fork as Foundry users see it: its RPC endpoint and pinned block.
- Fork
Registry - Registered forks, the local context, the active selection and persistent accounts.
- Later
Writes - The persistent writes recorded since a restoration.
- Lifecycle
Snapshot - Everything a snapshot revert restores.
- Parked
- An execution context that is not running: its backing database, environment, network extension state and accepted state.
- Prepared
Tx - 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. - Replaced
State - A running state a restoration replaced.
- Restore
Frame - Snapshot
Restores - Running states replaced by snapshot restorations inside the open frames of a transaction.
- Stored
Ext - Network extension state stored outside a running EVM, such as by a parked context or a snapshot.
- Suspended
- What a running transaction carries from a suspended context into the next one.
Enums§
- Execution
Phase - Whether a lifecycle operation runs between transactions or inside one, such as from a cheatcode.
- Fork
Position - Canonical chain position of a fork’s accepted state.
- Persistent
Write - 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
Replaymode says otherwise. - Replay
- How a balance or nonce
PersistentWritereplays, 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§
- Backing
Db - A shareable backing database: every fork and every nested transaction reads through its own handle to the same source.
- Foundry
Database - Database view the factory needs at construction time.
- Foundry
EvmExt - Per-EVM network state, such as OP L1 block info or Monad’s reserve-balance context.
- Foundry
EvmFactory - Builds Foundry-configured EVMs for one evm2 [
EvmTypesHost] family. - Foundry
EvmNetwork - Binds an Alloy network to an evm2 factory.
- Foundry
Execution Hooks - Execution-family hooks for state Foundry changes outside ordinary EVM execution.
- Foundry
TxConversion - Converts an Alloy network’s native transactions into an evm2 execution family’s transactions.
- Foundry
TxResult Ext - Network-only transaction outcome flags.
- Sendable
Ext - Network extension state that can be copied without sharing thread-unsafe state.
Functions§
- apply_
account - Sets the account at
addressinstatetoinfo, or to no account, and writesslotsto its storage after wiping it ifwiped, as journaled writes, also recorded inpersistentif given. Fields that already hold their value are left alone;codeis only built when the code hash changes. - block_
txs - Converts every transaction of a full RPC block.
- carry_
execution_ policy - Returns
nextwith Foundry’s execution policy carried over fromcurrent. - cold_
account_ warm_ slots - Returns the warm slots of the
persistentaccounts the running transaction instateloaded but holds cold, such as the test contract after an isolated static call cooled it. - copy_
account - Copies the account info and code of
addressfromsourceintotarget, ifsourceholds the account. - destructed_
accounts - Returns the accounts the running transaction in
stateself-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.
- eth_
unsigned_ tx - Converts an unsigned Ethereum transaction into evm2’s Ethereum transaction.
- evm_env
- Returns the environment
evmcurrently 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. - fatal
- fetch_
parent - Fetches the parent of
block, orNonefor genesis. - full_
transactions - Returns the transactions of
block, which must contain full transactions. - loaded_
slots - Returns the accounts
stateloaded with their loaded slots. - merge_
changes - Applies a nested transaction’s
changesto the accounts selected byfiltertostateas journaled writes, also recorded inpersistentif given. - merge_
pending_ changes - Applies the changes of a nested transaction detached into
pendingto the running transaction’sstateas journaled writes, so they revert with the enclosing call. - merge_
untracked_ nested_ changes - Applies a nested transaction’s changes to the running transaction’s
stateas journaled writes and returns them asPersistentWrites, for the caller to replay when an enclosing call reverts, such as forbroadcastRawTransaction. - merge_
untracked_ pending_ changes_ with_ warmth - Applies the changes of a nested transaction that
childran and detached intopendingto the running transaction’sstatelikemerge_untracked_nested_changes, and also warms the accounts and slots the nested transaction left warm, such as forexecuteTransaction. - placeholder_
signature - Placeholder signature used to put an unsigned request into its network’s envelope.
- put_
transient - Writes
transientstorage taken withtake_transientinto the running transaction instate. - rebase_
loaded_ accounts - Replaces the accounts the running transaction in
stateloaded, except persistent ones, with their accepted state insource, as journaled writes: info and loaded storage slots. - 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
stategained sincecheckpoint, keeping all other warmth, including unjournaled changes made since. - restore_
originals - Turns the accepted values of the slots of
originalsin the freshstateback into pending writes of the running transaction over their transaction-start values. - 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. - unknown_
transaction_ type - Returns the error for an RPC transaction whose envelope
targetcannot represent. - unloaded_
changes - Returns the
changesto accounts and storage slots the running transaction instatehas not loaded, as a pending state to accept. Accounts that were created, self-destructed, wiped or given code are left out. - warm_
accounts - Returns the accounts the running transaction in
stateloaded 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. - with_
eip7702_ 🔒delegations - Enables EIP-7702 delegation resolution on
version.
Type Aliases§
- Block
EnvFor - Chain
For - EvmEnv
For - EvmFactory
For - Convenience type aliases for accessing associated types through
FoundryEvmNetwork. - Fork
Cursor - A fork’s canonical position and the network state retaining its block cursor.
- Foundry
EvmFor - Interpreter
For - Ledger
- Persistent writes with the depth and journal length they were recorded at.
- Message
For - Message
Result For - Network
For - SpecFor
- SpecOf
- Transaction
Request For - TxEnvelope
For - TxFor
- TxResult
For - Types
For