mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
feat(engine): make benchmark inputs deterministic (#13536)
This commit is contained in:
@ -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
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
|
||||
@ -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<EvmState> {
|
||||
let mut rng = generators::rng();
|
||||
let mut runner = TestRunner::deterministic();
|
||||
let mut rng = runner.rng().clone();
|
||||
let all_addresses: Vec<Address> = (0..params.num_accounts).map(|_| rng.gen()).collect();
|
||||
let mut updates = Vec::new();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user