mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
perf: trie micro optimizations (#13282)
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
use crate::{DatabaseHashedCursorFactory, DatabaseTrieCursorFactory};
|
||||
use alloy_primitives::{
|
||||
keccak256,
|
||||
map::{HashMap, HashSet},
|
||||
map::{B256HashMap, B256HashSet, HashMap},
|
||||
Address, B256,
|
||||
};
|
||||
use reth_db_api::transaction::DbTx;
|
||||
@ -30,7 +30,7 @@ pub trait DatabaseProof<'a, TX> {
|
||||
fn overlay_multiproof(
|
||||
tx: &'a TX,
|
||||
input: TrieInput,
|
||||
targets: HashMap<B256, HashSet<B256>>,
|
||||
targets: B256HashMap<B256HashSet>,
|
||||
) -> Result<MultiProof, StateProofError>;
|
||||
}
|
||||
|
||||
@ -66,7 +66,7 @@ impl<'a, TX: DbTx> DatabaseProof<'a, TX>
|
||||
fn overlay_multiproof(
|
||||
tx: &'a TX,
|
||||
input: TrieInput,
|
||||
targets: HashMap<B256, HashSet<B256>>,
|
||||
targets: B256HashMap<B256HashSet>,
|
||||
) -> Result<MultiProof, StateProofError> {
|
||||
let nodes_sorted = input.nodes.into_sorted();
|
||||
let state_sorted = input.state.into_sorted();
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
use crate::{DatabaseHashedCursorFactory, DatabaseTrieCursorFactory, PrefixSetLoader};
|
||||
use alloy_primitives::{Address, BlockNumber, B256, U256};
|
||||
use alloy_primitives::{
|
||||
map::{AddressHashMap, B256HashMap},
|
||||
Address, BlockNumber, B256, U256,
|
||||
};
|
||||
use reth_db::tables;
|
||||
use reth_db_api::{
|
||||
cursor::DbCursorRO,
|
||||
@ -227,7 +230,7 @@ impl<TX: DbTx> DatabaseHashedPostState<TX> for HashedPostState {
|
||||
}
|
||||
|
||||
// Iterate over storage changesets and record value before first occurring storage change.
|
||||
let mut storages = HashMap::<Address, HashMap<B256, U256>>::default();
|
||||
let mut storages = AddressHashMap::<B256HashMap<U256>>::default();
|
||||
let mut storage_changesets_cursor = tx.cursor_read::<tables::StorageChangeSets>()?;
|
||||
for entry in
|
||||
storage_changesets_cursor.walk_range(BlockNumberAddress((from, Address::ZERO))..)?
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
use crate::{DatabaseHashedCursorFactory, DatabaseTrieCursorFactory};
|
||||
use alloy_primitives::{map::HashMap, Bytes, B256};
|
||||
use alloy_primitives::{map::B256HashMap, Bytes};
|
||||
use reth_db_api::transaction::DbTx;
|
||||
use reth_execution_errors::TrieWitnessError;
|
||||
use reth_trie::{
|
||||
@ -17,7 +17,7 @@ pub trait DatabaseTrieWitness<'a, TX> {
|
||||
tx: &'a TX,
|
||||
input: TrieInput,
|
||||
target: HashedPostState,
|
||||
) -> Result<HashMap<B256, Bytes>, TrieWitnessError>;
|
||||
) -> Result<B256HashMap<Bytes>, TrieWitnessError>;
|
||||
}
|
||||
|
||||
impl<'a, TX: DbTx> DatabaseTrieWitness<'a, TX>
|
||||
@ -31,7 +31,7 @@ impl<'a, TX: DbTx> DatabaseTrieWitness<'a, TX>
|
||||
tx: &'a TX,
|
||||
input: TrieInput,
|
||||
target: HashedPostState,
|
||||
) -> Result<HashMap<B256, Bytes>, TrieWitnessError> {
|
||||
) -> Result<B256HashMap<Bytes>, TrieWitnessError> {
|
||||
let nodes_sorted = input.nodes.into_sorted();
|
||||
let state_sorted = input.state.into_sorted();
|
||||
Self::from_tx(tx)
|
||||
|
||||
Reference in New Issue
Block a user