nit: use ref slice for random_account_change (#7714)

This commit is contained in:
Oliver Nordbjerg
2024-04-18 12:57:03 +02:00
committed by GitHub
parent 3a3b957961
commit 979e5427b3

View File

@ -196,7 +196,6 @@ pub type ChangeSet = Vec<(Address, Account, Vec<StorageEntry>)>;
type AccountState = (Account, Vec<StorageEntry>);
/// Generate a range of changesets for given blocks and accounts.
/// Assumes all accounts start with an empty storage.
///
/// Returns a Vec of account and storage changes for each block,
/// along with the final state of all accounts and storages.
@ -216,7 +215,7 @@ where
.map(|(addr, (acc, st))| (addr, (acc, st.into_iter().map(|e| (e.key, e.value)).collect())))
.collect();
let valid_addresses = state.keys().copied().collect();
let valid_addresses = state.keys().copied().collect::<Vec<_>>();
let mut changesets = Vec::new();
@ -279,7 +278,7 @@ where
/// Returns two addresses, a balance_change, and a Vec of new storage entries.
pub fn random_account_change<R: Rng>(
rng: &mut R,
valid_addresses: &Vec<Address>,
valid_addresses: &[Address],
n_storage_changes: Range<u64>,
key_range: Range<u64>,
) -> (Address, Address, U256, Vec<StorageEntry>) {
@ -340,6 +339,7 @@ pub fn random_contract_account_range<R: Rng>(
let mut accounts = Vec::with_capacity(acc_range.end.saturating_sub(acc_range.start) as usize);
for _ in acc_range {
let (address, eoa_account) = random_eoa_account(rng);
// todo: can a non-eoa account have a nonce > 0?
let account = Account { bytecode_hash: Some(rng.gen()), ..eoa_account };
accounts.push((address, account))
}