Expand description
The forked-EVM state cache: lazy RPC loading, a layered write funnel, and cheap copy-on-write snapshots.
EvmCache is the core handle. It fronts a foundry_fork_db-backed fork
database with a hot revm cache layer, lazily fetching account and storage
state from a provider on the first miss and serving it locally thereafter.
Targeted writes and purges (StateUpdate, balance/code overrides, verified
code seeds) flow through a single write
funnel — never the RPC path — so event-driven state maintenance never round-trips.
EvmCache::snapshot produces an immutable, Arc-shared, cross-thread
EvmSnapshot (see snapshot) for parallel fan-out; overlay
layers per-simulation state on top. See the crate-root docs for the full
state stack and docs/INTERNALS.md
for the snapshot cost model.
Re-exports§
pub use overlay::EvmOverlay;pub use slot_observations::SlotObservationTracker;pub use snapshot::EvmSnapshot;
Modules§
- IERC20
- Module containing a contract’s types and functions.
- overlay
- Per-simulation state overlays layered over a snapshot or the live cache.
- slot_
observations - Storage-slot change-frequency tracking and freshness heuristics.
- snapshot
- Immutable, shareable EVM state snapshots.
Structs§
- Account
Proof - Account header + optional storage-proof slots from
eth_getProof.slotsis populated only for requested storage keys; an empty key list is a root-only probe (account fields +storage_hash, no slot payload). - AnyNetwork
Type - Re-export AnyNetwork for callers that need to construct providers. Types for a catch-all network.
- Block
Context Requirements - Which block-context header fields a cache requires to be present.
- Block
State Account Diff - Final account/storage values observed for one account in a block trace.
- Block
State Diff - Final state changes observed from a block-level state-diff trace.
- Block
State Storage Diff - Final value for one storage slot observed from a block trace.
- Cache
Config - Configuration for disk-based caching of EVM state.
- Call
Simulation Result - Outcome of a simulated call: status, return data, gas used, and the touched
access list.
#[non_exhaustive]— construct via the simulation APIs and match with a wildcard arm. - Code
Mismatch - One contradicted code claim from
EvmCache::verify_code_seeds. - Code
Verify Report - Outcome of
EvmCache::verify_code_seeds: how eachPendingcanonical code claim resolved against the chain at the pinned block. - EvmCache
- EVM cache with lazy-loading RPC backend.
- EvmCache
Builder - Fluent builder for
EvmCache. - EvmSession
- A session for executing multiple EVM operations without committing to the underlying DB.
- Immutable
Data Cache - Cache for immutable on-chain data that doesn’t change between blocks.
- Prewarm
Report - Outcome of
EvmCache::prewarm_slots. - Storage
Batch Config - Concrete tuning knobs for the provider-backed
StorageBatchFetchFn. - TxConfig
- Per-call transaction-environment overrides for a simulation.
Enums§
- Cache
Speed Mode - Preset runtime tuning profile for cache-side batch storage fetches.
- Code
Seed State - Provenance + trust state of an address’s cached bytecode, for code that did not arrive via the lazy RPC backend.
- Missing
Target Behavior - Behavior when overriding code at a target account that is not known to the cache/backend.
- Shared
Memory Capacity - How much EVM shared memory (per-context working memory) to pre-allocate for simulations.
- SimStatus
- Outcome of a balance-delta-tracking simulation.
- Storage
Fetch Strategy - How a cache’s batch storage fetcher loads slots.
Functions§
- load_
binary_ state - Load binary EVM state and populate the BlockchainDb.
- parse_
evm_ spec - Parse an EVM hardfork spec name (e.g. from TOML config) into a revm
SpecId. - point_
read_ storage_ fetcher - Build the classic point-read
StorageBatchFetchFn: JSON-RPC batches ofeth_getStorageAt, sized and throttled byStorageBatchConfig. - save_
binary_ state - Save the current BlockchainDb state to a binary file.
Type Aliases§
- Account
Fields Fetch Fn - Callback fetching
(balance, EXTCODEHASH)samples for many addresses at a pinned block — one bulketh_callby default (theACCOUNT_FIELDS_EXTRACTOR_CODEprogram). Sync and type-erased with the same bridging rules asStorageBatchFetchFn(multi-thread tokio runtime required for the default provider-backed implementation). - Account
Proof Fetch Fn - Callback for fetching account headers (and optional storage-proof slots)
directly from RPC via
eth_getProof, mirroringStorageBatchFetchFn. - Block
State Diff Fetch Fn - Callback for fetching one block’s state diff through debug/trace RPC.
- Fork
CacheDB - The database type used by the EVM cache. CacheDB wraps SharedBackend which lazily fetches data from RPC on-demand.
- RpcCall
Fn - Callback for making direct RPC
eth_callrequests, bypassing revm simulation. Used when batch-querying many contracts where revm’s lazy storage fetching would be prohibitively slow (e.g. querying 500+ gauge contracts). - Storage
Batch Fetch Fn - Callback for batch-fetching storage slots directly from RPC, bypassing SharedBackend.