Skip to content

Commit 18388a8

Browse files
authored
refactor: parallelize invariants (foundry-rs#5676)
* refactor: parallelize invariants * chore: clippy * collect before
1 parent 434a668 commit 18388a8

File tree

7 files changed

+374
-438
lines changed

7 files changed

+374
-438
lines changed

crates/evm/src/executor/inspector/cheatcodes/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,6 @@ impl Cheatcodes {
217217
// but only if the backend is in forking mode
218218
data.db.ensure_cheatcode_access_forking_mode(caller)?;
219219

220-
// TODO: Log the opcode for the debugger
221220
let opt = env::apply(self, data, caller, &decoded)
222221
.transpose()
223222
.or_else(|| util::apply(self, data, &decoded))

crates/evm/src/fuzz/invariant/error.rs

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,18 @@ impl InvariantFuzzError {
4141
calldata: &[BasicTxDetails],
4242
call_result: RawCallResult,
4343
inner_sequence: &[Option<BasicTxDetails>],
44-
shrink_sequence: bool,
44+
shrink: bool,
4545
) -> Self {
46-
let mut func = None;
47-
let origin: String;
48-
49-
if let Some(f) = error_func {
50-
func = Some(f.short_signature().into());
51-
origin = f.name.clone();
46+
let (func, origin) = if let Some(f) = error_func {
47+
(Some(f.short_signature().into()), f.name.as_str())
5248
} else {
53-
origin = "Revert".to_string();
54-
}
49+
(None, "Revert")
50+
};
51+
let revert_reason = decode_revert(
52+
call_result.result.as_ref(),
53+
Some(invariant_contract.abi),
54+
Some(call_result.exit_reason),
55+
);
5556

5657
InvariantFuzzError {
5758
logs: call_result.logs,
@@ -60,29 +61,20 @@ impl InvariantFuzzError {
6061
format!(
6162
"{}, reason: '{}'",
6263
origin,
63-
match decode_revert(
64-
call_result.result.as_ref(),
65-
Some(invariant_contract.abi),
66-
Some(call_result.exit_reason)
67-
) {
68-
Ok(e) => e,
64+
match &revert_reason {
65+
Ok(s) => s.clone(),
6966
Err(e) => e.to_string(),
7067
}
7168
)
7269
.into(),
7370
calldata.to_vec(),
7471
),
7572
return_reason: "".into(),
76-
revert_reason: decode_revert(
77-
call_result.result.as_ref(),
78-
Some(invariant_contract.abi),
79-
Some(call_result.exit_reason),
80-
)
81-
.unwrap_or_default(),
73+
revert_reason: revert_reason.unwrap_or_default(),
8274
addr: invariant_contract.address,
8375
func,
8476
inner_sequence: inner_sequence.to_vec(),
85-
shrink: shrink_sequence,
77+
shrink,
8678
}
8779
}
8880

0 commit comments

Comments
 (0)