Expand description
Foundry’s executor backend: RPC forks, persistent accounts, snapshots and cheatcode policy over evm2.
§Execution contract
Backend owns an ExecutionLifecycle: the accepted state of every execution context (the
local database and each fork), the active selection, persistent accounts and snapshots. It does
not implement a database trait; executions run on [evm2::Evm]s built from it:
Backend::create_evmbuilds an EVM over the active context. The EVM does not borrow the backend: it reads the context’s accepted state through a shared view.- While the EVM runs, the backend is free. Inspectors that implement cheatcodes hold
&mut Backend(or aCowBackend) for the duration of the execution, and call its operations with the&mut Evmthey receive from their hooks. Operations that act on the running transaction, such as fork selection, snapshots,vm.transactor account refreshes, take that EVM explicitly together with theExecutionPhase; operations between executions, such asBackend::insert_account_info, do not. - After a committed execution,
Backend::parkaccepts the EVM’s state, environment and network state back into the active context. Dropping the EVM instead discards everything it did, as for calls.
Backend::inspect_commit wraps these steps for executions that need no backend access from
their inspector.
Structs§
- Backend
- Foundry’s executor backend.
- Blockchain
Db - A shareable Block database
- Blockchain
DbMeta - relevant identifying markers in the context of BlockchainDb
- CowBackend
- A clone-on-write
Backend. - Fork
Block - A block number and hash that identify the exact root of a fork.
- Shared
Backend - A cloneable backend type that shares access to the backend data with all its clones.
- Transaction
Validation Error - A transaction evm2 rejected, with Foundry’s wording of the reason. The evm2 error stays available to callers that downcast the report.
Enums§
- Account
Fetch Policy - Policy for loading remote account balances, nonces, and code.
- Backend
Error - Errors of
Backendoperations. - Database
Error - Errors encountered while loading fork state.
- Fork
Account Field - Account field changed by an out-of-band fork RPC mutation.
- Revert
Diagnostic - Represents possible diagnostic cases on revert
- Revert
State Snapshot Action - What to do when reverting a state snapshot.
Constants§
- GLOBAL_
FAIL_ SLOT bytes32("failed"), as a storage slot key intoCHEATCODE_ADDRESS.
Traits§
- Fork
Block Env - Marker trait for block environment types that can be used with the forking backend.
Functions§
- account_
fetch_ policy_ for_ source - Returns the account-loading policy required by a fork source.
- handler_
error - Returns a report for a transaction evm2 rejected or failed to execute, wrapped in an “EVM error” context.
- transaction_
error - Returns a report for a transaction evm2 rejected or failed to execute.
Type Aliases§
- Backend
Result - Database
Result - Result alias with
DatabaseErroras error - Local
Fork Id - Represents a numeric
ForkIdvalid only for the existence of theBackend. - RpcFork
Db - Backing database of an RPC fork: the shared fork cache, read by evm2.