Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: remove misleading/unneeded FxIndexSet type #7511

Merged
merged 1 commit into from
Mar 28, 2024
Merged
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
19 changes: 9 additions & 10 deletions crates/evm/fuzz/src/strategies/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use alloy_primitives::{Address, Bytes, Log, B256, U256};
use foundry_common::contracts::{ContractsByAddress, ContractsByArtifact};
use foundry_config::FuzzDictionaryConfig;
use foundry_evm_core::utils::StateChangeset;
use indexmap::IndexSet;
use parking_lot::RwLock;
use proptest::prelude::{BoxedStrategy, Strategy};
use revm::{
Expand All @@ -15,21 +16,19 @@ use revm::{
};
use std::{fmt, sync::Arc};

// We're using `IndexSet` to have a stable element order when restoring persisted state, as well as
// for performance when iterating over the sets.
type FxIndexSet<T> = indexmap::set::IndexSet<T>;

/// A set of arbitrary 32 byte data from the VM used to generate values for the strategy.
///
/// Wrapped in a shareable container.
pub type EvmFuzzState = Arc<RwLock<FuzzDictionary>>;

// We're using `IndexSet` to have a stable element order when restoring persisted state, as well as
// for performance when iterating over the sets.
#[derive(Default)]
pub struct FuzzDictionary {
/// Collected state values.
state_values: FxIndexSet<[u8; 32]>,
state_values: IndexSet<[u8; 32]>,
/// Addresses that already had their PUSH bytes collected.
addresses: FxIndexSet<Address>,
addresses: IndexSet<Address>,
}

impl fmt::Debug for FuzzDictionary {
Expand All @@ -43,22 +42,22 @@ impl fmt::Debug for FuzzDictionary {

impl FuzzDictionary {
#[inline]
pub fn values(&self) -> &FxIndexSet<[u8; 32]> {
pub fn values(&self) -> &IndexSet<[u8; 32]> {
&self.state_values
}

#[inline]
pub fn values_mut(&mut self) -> &mut FxIndexSet<[u8; 32]> {
pub fn values_mut(&mut self) -> &mut IndexSet<[u8; 32]> {
&mut self.state_values
}

#[inline]
pub fn addresses(&self) -> &FxIndexSet<Address> {
pub fn addresses(&self) -> &IndexSet<Address> {
&self.addresses
}

#[inline]
pub fn addresses_mut(&mut self) -> &mut FxIndexSet<Address> {
pub fn addresses_mut(&mut self) -> &mut IndexSet<Address> {
&mut self.addresses
}
}
Expand Down
Loading