Skip to main content

Module shrink

Module shrink 

Source

Re-exportsΒ§

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; πŸ”’

StructsΒ§

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

EnumsΒ§

CheckSequenceFailureSite
Concrete failure site observed while replaying a sequence through check_sequence.
ShrinkErrorPolicy πŸ”’
How run_shrink_loop handles a predicate error.
TerminalFailureSite πŸ”’

ConstantsΒ§

LIVE_SHRINK_SEQUENCE_EDGE_CALLS πŸ”’

TraitsΒ§

ReplayPolicy πŸ”’
What a sequence replay does with each kept call and with the final state.

FunctionsΒ§

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 πŸ”’