Expand description
Snapshot fuzzing: resume invariant runs from interesting states reached by earlier runs.
After every accepted call the storage writes are compressed into features. A slotβs values are a set, each value its own feature, until the slot took more than MAX_SET_VALUES distinct values; from then on they are a distribution, binned by sign-folded log2. Mapping and array entries are folded per contract, plus the log2 of how many of them are nonzero.
A call that reaches a feature no earlier call reached makes its post-call state a snapshot: the executor is cloned together with the call prefix that produced it. Later runs start either from the post-setUp state or from a snapshot, picked by a power schedule that favors snapshots whose features are still rare and whose runs keep finding new coverage or new states. Runs started from a snapshot carry its prefix in their inputs, so counterexamples, shrinking, replay and corpus entries still start from the post-setUp state.
Re-exportsΒ§
use crate::executors::Executor;πuse alloy_primitives::Address;πuse alloy_primitives::U256;πuse alloy_primitives::map::AddressMap;πuse alloy_primitives::map::HashMap;πuse alloy_primitives::map::HashSet;πuse evm2::evm::PendingState;πuse foundry_evm_core::constants::CHEATCODE_ADDRESS;πuse foundry_evm_core::eip2935::is_history_storage_address;πuse foundry_evm_core::evm::FoundryEvmNetwork;πuse foundry_evm_fuzz::BasicTxDetails;πuse proptest::prelude::Rng;πuse proptest::test_runner::TestRunner;πuse std::hash::BuildHasher;πuse std::hash::BuildHasherDefault;πuse std::hash::DefaultHasher;πuse std::sync::Arc;π
StructsΒ§
- Energy π
- RunStart π
- The state a run starts from.
- Snapshot π
- State
Snapshots π - Per-worker pool of snapshots and the state features seen so far.
EnumsΒ§
- Start π
- Where the current run started.
ConstantsΒ§
- COMPUTED_
SLOT π - Slots at or above 2^128 are treated as computed (mapping or dynamic array) slots.
- MAX_
PREFIX_ πDEPTHS - Snapshots are only taken while the reproducing sequence is at most this many run depths long.
- MAX_
SET_ πVALUES - Distinct values a slot may take before it is treated as a distribution rather than a set.
- MAX_
SNAPSHOTS π - Most snapshots kept per worker.
- MIN_
LIVENESS π - Least share of its find rate that a state keeps when every call made from it reverts.
- SNAPSHOT_
SLOT_ πBUDGET - Storage slots that the snapshots of all workers may copy together. Each snapshot holds a full copy of the backend, so workers keep fewer snapshots as their states grow, but at least two, so a run resumed from one snapshot can still replace the other.
FunctionsΒ§
- computed_
cardinality π - Nonzero computed slots per contract in the executorβs backend.
- log2_
bin π - Sign-folded bit length: small positive and small negative (twoβs complement) values land in different, magnitude-ordered bins.
- storage_
slots π - Storage slots held by the executorβs backend.