Skip to main content Module shrink Copy item path Source use crate::executors::EarlyExit ; π use crate::executors::EvmError ; π use crate::executors::Executor ; π use crate::executors::RawCallResult ; π use crate::executors::RawFailure ; π use crate::executors::campaign::CampaignCallKind ; π use crate::executors::campaign::apply_block_delay ; π use crate::executors::campaign::execute_invariant_replay_tx ; π use crate::executors::invariant::IInvariantTest ; π use crate::executors::invariant::call_after_invariant_function ; π use crate::executors::invariant::call_invariant_function ; π use crate::executors::invariant::error::handler_edge_fingerprint ; π use crate::executors::invariant::error::snapshot_edge_fingerprint ; π use crate::executors::invariant::result::did_fail_on_assert ; π use alloy_json_abi::Function; π use alloy_primitives::Address; π use alloy_primitives::B256; π use alloy_primitives::Bytes; π use alloy_primitives::I256; π use alloy_primitives::Selector; π use alloy_primitives::U256; π use alloy_primitives::map::HashSet; π use alloy_sol_types::SolCall; π use foundry_common::ContractsByAddress ; π use foundry_config::InvariantConfig ; π use foundry_evm_core::constants::MAGIC_ASSUME ; π use foundry_evm_core::decode::RevertDecoder ; π use foundry_evm_core::evm::FoundryEvmNetwork ; π use foundry_evm_fuzz::BaseCounterExample ; π use foundry_evm_fuzz::BasicTxDetails ; π use foundry_evm_fuzz::invariant::InvariantContract ; π use indicatif::ProgressBar; π use proptest::bits::BitSetLike; π use proptest::bits::VarBitSet; π use std::borrow::Cow ; π use std::cell::Cell ; π use std::fmt::Write ; π use std::hash::Hash ; π use std::hash::Hash ; π use std::ops::Range ; π use std::time::Instant ; π CandidateReplay Replays the candidates of a failing sequenceβs minimizer, reusing the state after the calls a
candidate shares with the previous one. CheckSequenceOptions Options controlling how check_sequence evaluates a candidate call sequence. CheckSequenceOutcome Outcome from replaying an invariant call sequence through check_sequence . CheckSequencePolicy π Replay policy of check_sequence : stops on a sequence call that fails, then checks the
invariant. 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. HandlerReplayPolicy π Replay policy of replay_handler_failure_sequence : stops on the anchor, the last kept call,
or on an earlier assertion. PrefixReplay π Replays the calls that a run of shrink candidates share. ReplayCounters π Counters carried across the calls of one sequence replay. 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. ShrinkProgress π Live shrink progress display. The progress bar itself is owned by forgeβs test runner; this
type only formats the transient message shown while invariant shrinking is active. ShrinkRun Shared shrink attempt driver. ShrinkRunStats Attempt counters collected while trying shrink candidates. ShrunkSequence CheckSequenceFailureSite Concrete failure site observed while replaying a sequence through check_sequence . ShrinkErrorPolicy π How run_shrink_loop handles a predicate error. TerminalFailureSite π LIVE_SHRINK_SEQUENCE_EDGE_CALLS π ReplayPolicy π What a sequence replay does with each kept call and with the final state. apply_warp_roll π Applies accumulated warp/roll to a call, returning a modified copy. assertion_failure_reason π build_shrunk_sequence π Builds the final shrunk sequence from the shrinker state. call_failure_reason π candidate_executor π Returns executor, or with a deadline a copy whose executions stop at it, for replaying
shrink candidates that the deadline must not wait for. 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. deadline_passed Returns whether deadline is set and has passed. finish_sequence_check π format_shrink_progress_message π handler_sequence_still_triggers_bug π Shrink predicate: anchor asserts on the same path as the originally recorded bug. handlers_succeeded π Mirrors the campaignβs handler gate, which checks failed() on every target, and not the test
contract, under legacy assertions. identify_failure π Records the failure identity, paused by CandidateReplay::new , and the provenance of the
calls executor runs next. push_shrink_progress_call π 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_kept_calls π Replays the kept calls of calls[range] on executor. kept holds the kept indices inside
the range in order. Returns the outcome of the call that stopped the replay, if any. reset_shrink_progress Resets the progress bar before each shrink. position = Some((i, N)) renders
[i/N] Shrink: <label> for multi-invariant campaigns. run_shrink_loop π Shared shrink loop driver. Tries to drop each call; predicate returns whether the
candidate still triggers the bug. selector_from_calldata π sequence_call_failure_site π shrink_handler_sequence π Shrinks a handler-bug sequence to the shortest prefix that still asserts on the anchor
AND keeps the same edge fingerprint (so we donβt change bug identity). shrink_sequence π 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. It also receives
the first index the candidate removes: every kept call before it is unchanged. shrink_sequence_value π Shrinks an optimization witness while preserving the best value seen during replay.
Warp and roll of removed calls move to the next kept call.
Returns the shrunk sequence and its value, which can exceed target_value. terminal_failure_site π