From 1b08ae4ece84a862d1d85a6e6b41bc64311bfb1e Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Mon, 20 May 2024 21:11:10 +0300 Subject: [PATCH] fix(fuzz) - consistent snapshot results between runs (#7951) * fix(fuzz) - consistent gas snapshot between runs * sort storage values before inserting * Revert "fix(fuzz) - consistent gas snapshot between runs" This reverts commit cf187fb2315c191782129c2fca0e3318a8a3a36d. --------- Co-authored-by: Arsenii Kulikov --- crates/evm/fuzz/src/strategies/state.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/crates/evm/fuzz/src/strategies/state.rs b/crates/evm/fuzz/src/strategies/state.rs index 1bb2a7e7a9fd..0bcf81baee50 100644 --- a/crates/evm/fuzz/src/strategies/state.rs +++ b/crates/evm/fuzz/src/strategies/state.rs @@ -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. /// @@ -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::>(); + for (slot, value) in values { self.insert_storage_value(slot, value, false); } }