diff --git a/Cargo.lock b/Cargo.lock index 2a61c35f0a5e..81074ad2572c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7363,6 +7363,7 @@ dependencies = [ "derive_more", "futures", "metrics", + "proptest", "rand 0.8.5", "rayon", "reth-beacon-consensus", diff --git a/crates/engine/tree/Cargo.toml b/crates/engine/tree/Cargo.toml index 84ca3291a33f..5f51e5d316d2 100644 --- a/crates/engine/tree/Cargo.toml +++ b/crates/engine/tree/Cargo.toml @@ -82,6 +82,7 @@ reth-static-file.workspace = true reth-testing-utils.workspace = true reth-tracing.workspace = true reth-trie-db.workspace = true +proptest.workspace = true # alloy alloy-rlp.workspace = true diff --git a/crates/engine/tree/benches/channel_perf.rs b/crates/engine/tree/benches/channel_perf.rs index 50c48a391f65..5eb919da8b34 100644 --- a/crates/engine/tree/benches/channel_perf.rs +++ b/crates/engine/tree/benches/channel_perf.rs @@ -3,6 +3,8 @@ #![allow(missing_docs)] use criterion::{criterion_group, criterion_main, BatchSize, BenchmarkId, Criterion}; +use proptest::test_runner::TestRunner; +use rand::Rng; use revm_primitives::{ Account, AccountInfo, AccountStatus, Address, EvmState, EvmStorage, EvmStorageSlot, HashMap, B256, U256, @@ -11,6 +13,8 @@ use std::{hint::black_box, thread}; /// Creates a mock state with the specified number of accounts for benchmarking fn create_bench_state(num_accounts: usize) -> EvmState { + let mut runner = TestRunner::deterministic(); + let mut rng = runner.rng().clone(); let mut state_changes = HashMap::default(); for i in 0..num_accounts { @@ -21,14 +25,14 @@ fn create_bench_state(num_accounts: usize) -> EvmState { info: AccountInfo { balance: U256::from(100), nonce: 10, - code_hash: B256::random(), + code_hash: B256::from_slice(&rng.gen::<[u8; 32]>()), code: Default::default(), }, storage, status: AccountStatus::Loaded, }; - let address = Address::random(); + let address = Address::with_last_byte(i as u8); state_changes.insert(address, account); } diff --git a/crates/engine/tree/benches/state_root_task.rs b/crates/engine/tree/benches/state_root_task.rs index 72770e726852..9958cf0cacb8 100644 --- a/crates/engine/tree/benches/state_root_task.rs +++ b/crates/engine/tree/benches/state_root_task.rs @@ -4,6 +4,8 @@ #![allow(missing_docs)] use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion}; +use proptest::test_runner::TestRunner; +use rand::Rng; use reth_engine_tree::tree::root::{StateRootConfig, StateRootTask}; use reth_evm::system_calls::OnStateHook; use reth_primitives::{Account as RethAccount, StorageEntry}; @@ -12,7 +14,6 @@ use reth_provider::{ test_utils::{create_test_provider_factory, MockNodeTypesWithDB}, AccountReader, HashingWriter, ProviderFactory, }; -use reth_testing_utils::generators::{self, Rng}; use reth_trie::{ hashed_cursor::HashedPostStateCursorFactory, proof::ProofBlindedProviderFactory, trie_cursor::InMemoryTrieCursorFactory, TrieInput, @@ -35,7 +36,8 @@ struct BenchParams { /// Generates a series of random state updates with configurable accounts, /// storage, and self-destructs fn create_bench_state_updates(params: &BenchParams) -> Vec { - let mut rng = generators::rng(); + let mut runner = TestRunner::deterministic(); + let mut rng = runner.rng().clone(); let all_addresses: Vec
= (0..params.num_accounts).map(|_| rng.gen()).collect(); let mut updates = Vec::new();