Skip to main content Module invariant Copy item path Source use crate::executors::DURATION_BETWEEN_METRICS_REPORT ; π use crate::executors::EarlyExit ; π use crate::executors::EvmError ; π use crate::executors::Executor ; π use crate::executors::RawCallResult ; π use crate::executors::campaign::CampaignCallKind ; π use crate::executors::campaign::CampaignControl ; π use crate::executors::campaign::CampaignEvent ; π use crate::executors::campaign::CampaignSequenceOutcome ; π use crate::executors::campaign::FuzzCampaign ; π use crate::executors::campaign::FuzzCampaignMode ; π use crate::executors::corpus::CorpusInsertionMode ; π use crate::executors::corpus::DynamicTargetCtx ; π use crate::executors::corpus::ReplayTarget ; π use crate::executors::corpus::WorkerCorpus ; π use crate::executors::corpus::WorkerCorpusSeed ; π use crate::executors::corpus::persist_campaign_optimization ; π use crate::executors::fuzz::FuzzBranchFrontier ; π use crate::executors::fuzz::FuzzFrontierRecorder ; π use crate::executors::fuzz::StatefulFuzzBranchFrontierArtifact ; π use crate::executors::fuzz::merge_frontiers ; π use crate::executors::fuzz::write_frontier_artifact ; π use crate::executors::worker_seed ; π use crate::inspectors::Fuzzer ; π use alloy_dyn_abi::DynSolValue; π use alloy_dyn_abi::JsonAbiExt; π use alloy_json_abi::Function; π use alloy_json_abi::StateMutability; π use alloy_primitives::Address; π use alloy_primitives::Bytes; π use alloy_primitives::FixedBytes; π use alloy_primitives::I256; π use alloy_primitives::Selector; π use alloy_primitives::U256; π use alloy_primitives::map::AddressMap; π use alloy_primitives::map::AddressSet; π use alloy_primitives::map::HashMap; π use alloy_primitives::map::hash_map::Entry as AddressMapEntry; π use alloy_sol_types::SolCall; π use alloy_sol_types::sol; π use campaign::InvariantCampaignAggregator ; π use campaign::InvariantCampaignSpec ; π use campaign::InvariantCampaignState ; π use campaign::InvariantWorkerOutput ; π use campaign::InvariantWorkerPlan ; π use eyre::ContextCompat ; π use eyre::Result ; π use eyre::eyre ; π use foundry_common::TestFunctionExt ; π use foundry_common::contracts::ContractsByAddress ; π use foundry_common::contracts::ContractsByArtifact ; π use foundry_common::sh_eprintln ; π use foundry_common::sh_println ; π use foundry_config::FuzzCorpusConfig ; π use foundry_config::InvariantConfig ; π use foundry_config::InvariantDepthMode ; π use foundry_config::InvariantWorkers ; π use foundry_evm_core::constants::CALLER ; π use foundry_evm_core::constants::CHEATCODE_ADDRESS ; π use foundry_evm_core::constants::DEFAULT_CREATE2_DEPLOYER ; π use foundry_evm_core::constants::HARDHAT_CONSOLE_ADDRESS ; π use foundry_evm_core::constants::MAGIC_ASSUME ; π use foundry_evm_core::evm::FoundryEvmNetwork ; π use foundry_evm_core::precompiles::PRECOMPILES ; π use foundry_evm_coverage::HitMaps; π use foundry_evm_fuzz::BasicTxDetails ; π use foundry_evm_fuzz::FuzzCase ; π use foundry_evm_fuzz::FuzzFixtures ; π use foundry_evm_fuzz::ObservedCall ; π use foundry_evm_fuzz::invariant::ArtifactFilters ; π use foundry_evm_fuzz::invariant::FuzzRunIdentifiedContracts ; π use foundry_evm_fuzz::invariant::InvariantContract ; π use foundry_evm_fuzz::invariant::RandomCallGenerator ; π use foundry_evm_fuzz::invariant::SenderFilters ; π use foundry_evm_fuzz::invariant::TargetedContract ; π use foundry_evm_fuzz::invariant::TargetedContracts ; π use foundry_evm_fuzz::strategies::EvmFuzzState ; π use foundry_evm_fuzz::strategies::FuzzState ; π use foundry_evm_fuzz::strategies::TxGenerator ; π use foundry_evm_fuzz::strategies::override_call_strat ; π use foundry_evm_traces::CallTraceArena; π use foundry_evm_traces::SparsedTraceArena ; π use indicatif::ProgressBar; π use parking_lot::RwLock; π use proptest::prelude::Rng ; π use proptest::test_runner::RngAlgorithm; π use proptest::test_runner::TestRng; π use proptest::test_runner::TestRunner; π use rayon::iter::IntoParallelIterator; π use rayon::iter::ParallelIterator; π use result::assert_after_invariant ; π use result::can_continue ; π use result::invariant_preflight_check ; π use revm::state::Account; π use serde::Deserialize ; π use serde::Deserialize ; π use serde::Serialize ; π use serde::Serialize ; π use serde_json::Value ; π use serde_json::json ; π use std::collections::HashMap as Map; π use std::collections::HashSet ; π use std::collections::btree_map::Entry ; π use std::sync::Arc ; π use std::time::Duration ; π use std::time::Instant ; π use std::time::SystemTime ; π use std::time::UNIX_EPOCH ; π IInvariantTest Module containing a contractβs types and functions. campaign π error π replay π result π shrink π CheckSequenceOptions Options controlling how check_sequence evaluates a candidate call sequence. CheckSequenceOutcome Outcome from replaying an invariant call sequence through check_sequence . HandlerAssertionFailure A handler-side assertion bug: a require/assert inside a fuzzed handler that the
campaign reached. Deduped by (reverter, selector) site (Echidna/Medusa semantics),
shortest sequence wins on collision. HandlerReplayOutcome Result of a strict handler-bug replay: anchor asserts, no earlier call asserts, and the
recomputed edge fingerprint identifies which path the assertion took. InvariantCampaignSeed π Immutable state selected once for a logical invariant campaign and cloned into each worker. InvariantExecutor Wrapper around any Executor implementer which provides fuzzing support using [proptest]. InvariantFailureMetrics π Tracks invariant failure counts during a campaign. InvariantFailures Stores invariant test failures and revert counts. InvariantFuzzTestResult The outcome of an invariant fuzz test InvariantMetrics Contains invariant metrics for a single fuzzed selector. InvariantProgressContext π InvariantTest π Contains invariant test data. InvariantTestData π Contains data collected during invariant test runs. InvariantTestRun π Contains data for an invariant test run. InvariantThroughputMetrics π Campaign-level throughput metrics for invariant progress reporting. RecordedCallSequence π Recorded call sequence used by corpus feedback and frontier recording. ReplayErrorResult SequenceShrink Shrinker for a call sequence failure.
Iterates sequence call sequence top down and removes calls one by one.
If the failure is still reproducible with removed call then moves to the next one.
If the failure is not reproducible then restore removed call and moves to next one. ShrinkCandidateKeys Shared key set for shrinkers that need to skip duplicate concrete replays. ShrinkRun Shared shrink attempt driver. ShrinkRunStats Attempt counters collected while trying shrink candidates. CheckSequenceFailureSite Concrete failure site observed while replaying a sequence through check_sequence . FailureKey Identifies a single entry in the InvariantFailures map. Invariant predicate
failures and handler-side assertion bugs share one map keyed by this enum. InvariantFuzzError DEFAULT_DEPTH_FOR_INVARIANT_WORKER_CAP π Baseline depth used to preserve the previous default-depth worker heuristic. INVARIANT_FOCUS_WORKER_DIVISOR π Share of parallel workers reserved for selector focus mode. MAX_VIEW_CALLS_PER_TX π Maximum number of view calls made to harvest dictionary values after one invariant call. MIN_ESTIMATED_CALLS_PER_INVARIANT_WORKER π Minimum estimated handler calls assigned to each auto invariant worker. MIN_RUNS_PER_INVARIANT_WORKER π Minimum number of logical runs assigned to each auto invariant worker at the default invariant
depth. auto_invariant_worker_count π build_handler_failure_event π build_invariant_progress_json π Builds the machine-readable invariant progress payload emitted during a
campaign. call_after_invariant_function π Calls the afterInvariant() function on a contract.
Returns call result and if call succeeded.
The state after the call is not persisted. call_invariant_function π Calls the invariant function and returns call result and if succeeded. campaign_seed_and_corpus_seed_for_worker π check_sequence Checks if the given call sequence breaks the invariant. check_sequence_value Executes a call sequence and returns the optimization value (int256) from the invariant
function. Used during shrinking for optimization mode. collect_data π Collects data from call for fuzzing. However, it first verifies that the sender is not an EOA
before inserting it into the dictionary. Otherwise, we flood the dictionary with
randomly generated addresses. collect_view_values π Calls the view functions of targeted contracts that the successful call accessed (read or
written), and adds their decoded results to the fuzz dictionary, whole structs included. did_fail_on_assert Returns whether the current fuzz call should be treated as an assertion failure. execute_tx Executes an invariant replay fuzz call and returns the result. execute_tx_and_register_created Executes an invariant replay call on a validation executor and registers created targets. focused_campaign_seed_for_worker π focused_targeted_contracts π gas_report_samples_for_worker π handler_edge_fingerprint Edge-coverage fingerprint for a handler-side assertion call. Prefers a pre-merge
edges hash; falls back to keccak(target || selector) when edge coverage is disabled. handler_site_already_minimal True iff there is already a HandlerAssertionFailure for site no longer than
candidate_len. Used to skip inserting a not-strictly-shorter repro. invariant_focus_seed π invariant_focus_worker_count π invariant_focus_worker_index π invariant_run_depth π invariant_worker_collects_evm_cmp_log π invariant_worker_config π invariant_worker_count_with_threads π invariant_worker_runner π is_harvestable_view π Returns whether a function is a view whose result can be harvested without fuzzed inputs. max_invariant_workers_for_campaign π rate_per_sec π Converts a cumulative campaign total into an average per-second rate. record_new_invariant_failures π Bridges newly-recorded invariant breaks from failures.errors into the pulse
failure_metrics so the live progress stream reflects breaks as they happen.
Iterates in declaration order so the emitted βfailureβ events are deterministic. replay_error Replays and shrinks a call sequence, collecting logs and traces. replay_handler_failure_sequence Replays a handler-bug sequence and returns whether the anchor still asserts on the same
path. Rejects sequences with a pre-anchor assertion (would be a different bug). replay_run Replays a call sequence for collecting logs and traces.
Returns counterexample to be used when the call sequence is a failed scenario. round_rate_for_progress π should_continue_invariant_worker π shrink_sequence_by_removing Shared sequence shrinker. Tries to drop each call; predicate decides whether the candidate
should be accepted, rejected, or skipped without spending a replay attempt. snapshot_edge_fingerprint π Stable hash of the callβs edge coverage, taken before merge_edge_coverage
zeroes the buffer. Returns None when edge coverage is disabled.