mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
perf(engine): cache proof targets in proof sequencer for state root task (#13310)
This commit is contained in:
@ -1,16 +1,13 @@
|
||||
use crate::{DatabaseHashedCursorFactory, DatabaseTrieCursorFactory};
|
||||
use alloy_primitives::{
|
||||
keccak256,
|
||||
map::{B256HashMap, B256HashSet, HashMap},
|
||||
Address, B256,
|
||||
};
|
||||
use alloy_primitives::{keccak256, map::HashMap, Address, B256};
|
||||
use reth_db_api::transaction::DbTx;
|
||||
use reth_execution_errors::StateProofError;
|
||||
use reth_trie::{
|
||||
hashed_cursor::HashedPostStateCursorFactory,
|
||||
proof::{Proof, StorageProof},
|
||||
trie_cursor::InMemoryTrieCursorFactory,
|
||||
AccountProof, HashedPostStateSorted, HashedStorage, MultiProof, StorageMultiProof, TrieInput,
|
||||
AccountProof, HashedPostStateSorted, HashedStorage, MultiProof, MultiProofTargets,
|
||||
StorageMultiProof, TrieInput,
|
||||
};
|
||||
|
||||
/// Extends [`Proof`] with operations specific for working with a database transaction.
|
||||
@ -30,7 +27,7 @@ pub trait DatabaseProof<'a, TX> {
|
||||
fn overlay_multiproof(
|
||||
tx: &'a TX,
|
||||
input: TrieInput,
|
||||
targets: B256HashMap<B256HashSet>,
|
||||
targets: MultiProofTargets,
|
||||
) -> Result<MultiProof, StateProofError>;
|
||||
}
|
||||
|
||||
@ -66,7 +63,7 @@ impl<'a, TX: DbTx> DatabaseProof<'a, TX>
|
||||
fn overlay_multiproof(
|
||||
tx: &'a TX,
|
||||
input: TrieInput,
|
||||
targets: B256HashMap<B256HashSet>,
|
||||
targets: MultiProofTargets,
|
||||
) -> Result<MultiProof, StateProofError> {
|
||||
let nodes_sorted = input.nodes.into_sorted();
|
||||
let state_sorted = input.state.into_sorted();
|
||||
|
||||
@ -39,7 +39,9 @@ fn includes_empty_node_preimage() {
|
||||
|
||||
let state_root = StateRoot::from_tx(provider.tx_ref()).root().unwrap();
|
||||
let multiproof = Proof::from_tx(provider.tx_ref())
|
||||
.multiproof(HashMap::from_iter([(hashed_address, HashSet::from_iter([hashed_slot]))]))
|
||||
.multiproof(
|
||||
HashMap::from_iter([(hashed_address, HashSet::from_iter([hashed_slot]))]).into(),
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
let witness = TrieWitness::from_tx(provider.tx_ref())
|
||||
@ -77,7 +79,9 @@ fn includes_nodes_for_destroyed_storage_nodes() {
|
||||
|
||||
let state_root = StateRoot::from_tx(provider.tx_ref()).root().unwrap();
|
||||
let multiproof = Proof::from_tx(provider.tx_ref())
|
||||
.multiproof(HashMap::from_iter([(hashed_address, HashSet::from_iter([hashed_slot]))]))
|
||||
.multiproof(
|
||||
HashMap::from_iter([(hashed_address, HashSet::from_iter([hashed_slot]))]).into(),
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
let witness =
|
||||
@ -122,10 +126,13 @@ fn correctly_decodes_branch_node_values() {
|
||||
|
||||
let state_root = StateRoot::from_tx(provider.tx_ref()).root().unwrap();
|
||||
let multiproof = Proof::from_tx(provider.tx_ref())
|
||||
.multiproof(HashMap::from_iter([(
|
||||
hashed_address,
|
||||
HashSet::from_iter([hashed_slot1, hashed_slot2]),
|
||||
)]))
|
||||
.multiproof(
|
||||
HashMap::from_iter([(
|
||||
hashed_address,
|
||||
HashSet::from_iter([hashed_slot1, hashed_slot2]),
|
||||
)])
|
||||
.into(),
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
let witness = TrieWitness::from_tx(provider.tx_ref())
|
||||
|
||||
Reference in New Issue
Block a user