Skip to content

Commit

Permalink
chore(invariant): remove shrink_sequence config (#7875)
Browse files Browse the repository at this point in the history
  • Loading branch information
grandizzy committed May 7, 2024
1 parent bfc6549 commit 6da2ff4
Show file tree
Hide file tree
Showing 9 changed files with 2 additions and 23 deletions.
1 change: 0 additions & 1 deletion crates/config/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,6 @@ call_override = false
dictionary_weight = 80
include_storage = true
include_push_bytes = true
shrink_sequence = true

[fmt]
line_length = 100
Expand Down
5 changes: 0 additions & 5 deletions crates/config/src/invariant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ pub struct InvariantConfig {
/// The fuzz dictionary configuration
#[serde(flatten)]
pub dictionary: FuzzDictionaryConfig,
/// Attempt to shrink the failure case to its smallest sequence of calls
/// TODO: remove this setting as it is now redundant with shrink_run_limit = 0
pub shrink_sequence: bool,
/// The maximum number of attempts to shrink the sequence
pub shrink_run_limit: usize,
/// The maximum number of rejects via `vm.assume` which can be encountered during a single
Expand All @@ -44,7 +41,6 @@ impl Default for InvariantConfig {
fail_on_revert: false,
call_override: false,
dictionary: FuzzDictionaryConfig { dictionary_weight: 80, ..Default::default() },
shrink_sequence: true,
shrink_run_limit: 2usize.pow(18_u32),
max_assume_rejects: 65536,
gas_report_samples: 256,
Expand Down Expand Up @@ -75,7 +71,6 @@ impl InlineConfigParser for InvariantConfig {
"depth" => conf_clone.depth = parse_config_u32(key, value)?,
"fail-on-revert" => conf_clone.fail_on_revert = parse_config_bool(key, value)?,
"call-override" => conf_clone.call_override = parse_config_bool(key, value)?,
"shrink-sequence" => conf_clone.shrink_sequence = parse_config_bool(key, value)?,
_ => Err(InlineConfigParserError::InvalidConfigProperty(key.to_string()))?,
}
}
Expand Down
1 change: 0 additions & 1 deletion crates/config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3714,7 +3714,6 @@ mod tests {
depth = 15
fail_on_revert = false
call_override = false
shrink_sequence = true
"#,
)?;

Expand Down
3 changes: 0 additions & 3 deletions crates/evm/evm/src/executors/invariant/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@ pub struct FailedInvariantCaseData {
pub func: Bytes,
/// Inner fuzzing Sequence coming from overriding calls.
pub inner_sequence: Vec<Option<BasicTxDetails>>,
/// Shrink the failed test case to the smallest sequence.
pub shrink_sequence: bool,
/// Shrink run limit
pub shrink_run_limit: usize,
/// Fail on revert, used to check sequence when shrinking.
Expand Down Expand Up @@ -103,7 +101,6 @@ impl FailedInvariantCaseData {
addr: invariant_contract.address,
func: func.selector().to_vec().into(),
inner_sequence: inner_sequence.to_vec(),
shrink_sequence: invariant_config.shrink_sequence,
shrink_run_limit: invariant_config.shrink_run_limit,
fail_on_revert: invariant_config.fail_on_revert,
}
Expand Down
4 changes: 0 additions & 4 deletions crates/evm/evm/src/executors/invariant/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,6 @@ impl<'a> InvariantExecutor<'a> {
return Err(eyre!("Invariant test function should have no inputs"))
}

if !self.config.shrink_sequence {
error!(target: "forge::test", "shrink_sequence config is deprecated and will be removed, use shrink_run_limit = 0")
}

let (fuzz_state, targeted_contracts, strat) =
self.prepare_fuzzing(&invariant_contract, fuzz_fixtures)?;

Expand Down
7 changes: 1 addition & 6 deletions crates/evm/evm/src/executors/invariant/replay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,7 @@ pub fn replay_error(
TestError::Abort(_) => Ok(None),
TestError::Fail(_, ref calls) => {
// Shrink sequence of failed calls.
let calls = if failed_case.shrink_sequence {
shrink_sequence(failed_case, calls, &executor)?
} else {
trace!(target: "forge::test", "Shrinking disabled.");
calls.clone()
};
let calls = shrink_sequence(failed_case, calls, &executor)?;

set_up_inner_replay(&mut executor, &failed_case.inner_sequence);
// Replay calls to get the counterexample and to collect logs, traces and coverage.
Expand Down
2 changes: 1 addition & 1 deletion crates/evm/evm/src/executors/invariant/shrink.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ pub(crate) fn shrink_sequence(
calls: &[BasicTxDetails],
executor: &Executor,
) -> eyre::Result<Vec<BasicTxDetails>> {
trace!(target: "forge::test", "Shrinking.");
trace!(target: "forge::test", "Shrinking sequence of {} calls.", calls.len());

// Special case test: the invariant is *unsatisfiable* - it took 0 calls to
// break the invariant -- consider emitting a warning.
Expand Down
1 change: 0 additions & 1 deletion crates/forge/tests/it/test_helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ impl ForgeTestProfile {
max_fuzz_dictionary_addresses: 10_000,
max_fuzz_dictionary_values: 10_000,
},
shrink_sequence: true,
shrink_run_limit: 2usize.pow(18u32),
max_assume_rejects: 65536,
gas_report_samples: 256,
Expand Down
1 change: 0 additions & 1 deletion testdata/foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ ffi = false
force = false
invariant_fail_on_revert = false
invariant_call_override = false
invariant_shrink_sequence = true
invariant_preserve_state = false
gas_limit = 9223372036854775807
gas_price = 0
Expand Down

0 comments on commit 6da2ff4

Please sign in to comment.