Skip to content

Commit

Permalink
fix(fuzz) - consistent snapshot results between runs (#7951)
Browse files Browse the repository at this point in the history
* fix(fuzz) - consistent gas snapshot between runs

* sort storage values before inserting

* Revert "fix(fuzz) - consistent gas snapshot between runs"

This reverts commit cf187fb.

---------

Co-authored-by: Arsenii Kulikov <[email protected]>
  • Loading branch information
grandizzy and klkvr authored May 20, 2024
1 parent 1ddea96 commit 1b08ae4
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions crates/evm/fuzz/src/strategies/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ use revm::{
interpreter::opcode::{self, spec_opcode_gas},
primitives::{AccountInfo, SpecId},
};
use std::{collections::HashMap, fmt, sync::Arc};
use std::{
collections::{BTreeMap, HashMap},
fmt,
sync::Arc,
};

/// A set of arbitrary 32 byte data from the VM used to generate values for the strategy.
///
Expand Down Expand Up @@ -113,7 +117,9 @@ impl FuzzDictionary {
self.insert_push_bytes_values(address, &account.info, false);
// Insert storage values.
if self.config.include_storage {
for (slot, value) in &account.storage {
// Sort storage values before inserting to ensure deterministic dictionary.
let values = account.storage.iter().collect::<BTreeMap<_, _>>();
for (slot, value) in values {
self.insert_storage_value(slot, value, false);
}
}
Expand Down

0 comments on commit 1b08ae4

Please sign in to comment.