Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changelog/override-strategy-clones.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
forge: patch
foundry-evm-fuzz: patch
---

Reduced allocation overhead when generating invariant call overrides for contracts with many functions.
9 changes: 8 additions & 1 deletion crates/evm/fuzz/src/strategies/invariants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,14 @@ pub fn override_call_strat(
dictionary_weight: u32,
payable_value_weight: u32,
) -> impl Strategy<Value = CallDetails> + Send + Sync + 'static {
let contracts = Arc::new(contracts);
// Each generated call owns its function-selection strategy. Share the functions so
// constructing that strategy does not clone the entire target ABI on every call.
let contracts = Arc::new(
contracts
.into_iter()
.map(|(address, functions)| (address, Arc::new(functions)))
.collect::<Vec<_>>(),
);
let contracts_ref = contracts.clone();
proptest::prop_oneof![
80 => proptest::strategy::LazyJust::new(move || *target.read()),
Expand Down
Loading