Skip to content

Commit

Permalink
feat(trie): more logs for proofs (#13843)
Browse files Browse the repository at this point in the history
  • Loading branch information
shekhirin authored Jan 27, 2025
1 parent 79a5217 commit 3538c53
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
3 changes: 3 additions & 0 deletions crates/trie/parallel/src/proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ where
"Created cursors"
);

let target_slots_len = target_slots.len();
let proof_start = Instant::now();
let proof_result = StorageProof::new_hashed(
trie_cursor_factory,
Expand All @@ -189,6 +190,8 @@ where
trace!(
target: "trie::parallel",
?hashed_address,
prefix_set = ?prefix_set.len(),
target_slots = ?target_slots_len,
proof_time = ?proof_start.elapsed(),
"Completed proof calculation"
);
Expand Down
29 changes: 25 additions & 4 deletions crates/trie/trie/src/proof/blinded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ use reth_trie_common::{prefix_set::TriePrefixSetsMut, Nibbles};
use reth_trie_sparse::blinded::{
pad_path_to_key, BlindedProvider, BlindedProviderFactory, RevealedNode,
};
use std::sync::Arc;
use tracing::trace;
use std::{sync::Arc, time::Instant};
use tracing::{enabled, trace, Level};

/// Factory for instantiating providers capable of retrieving blinded trie nodes via proofs.
#[derive(Debug)]
Expand Down Expand Up @@ -88,6 +88,8 @@ where
H: HashedCursorFactory + Clone + Send + Sync,
{
fn blinded_node(&mut self, path: &Nibbles) -> Result<Option<RevealedNode>, SparseTrieError> {
let start = enabled!(target: "trie::proof::blinded", Level::TRACE).then(Instant::now);

let targets = HashMap::from_iter([(pad_path_to_key(path), HashSet::default())]);
let mut proof =
Proof::new(self.trie_cursor_factory.clone(), self.hashed_cursor_factory.clone())
Expand All @@ -98,8 +100,16 @@ where
let node = proof.account_subtree.into_inner().remove(path);
let tree_mask = proof.branch_node_tree_masks.remove(path);
let hash_mask = proof.branch_node_hash_masks.remove(path);
trace!(target: "trie::proof::blinded", ?path, ?node, "Blinded node for account trie");

trace!(
target: "trie::proof::blinded",
elapsed = ?start.unwrap().elapsed(),
?path,
?node,
?tree_mask,
?hash_mask,
"Blinded node for account trie"
);
Ok(node.map(|node| RevealedNode { node, tree_mask, hash_mask }))
}
}
Expand Down Expand Up @@ -135,6 +145,8 @@ where
H: HashedCursorFactory + Clone + Send + Sync,
{
fn blinded_node(&mut self, path: &Nibbles) -> Result<Option<RevealedNode>, SparseTrieError> {
let start = enabled!(target: "trie::proof::blinded", Level::TRACE).then(Instant::now);

let targets = HashSet::from_iter([pad_path_to_key(path)]);
let storage_prefix_set =
self.prefix_sets.storage_prefix_sets.get(&self.account).cloned().unwrap_or_default();
Expand All @@ -150,8 +162,17 @@ where
let node = proof.subtree.into_inner().remove(path);
let tree_mask = proof.branch_node_tree_masks.remove(path);
let hash_mask = proof.branch_node_hash_masks.remove(path);
trace!(target: "trie::proof::blinded", account = ?self.account, ?path, ?node, "Blinded node for storage trie");

trace!(
target: "trie::proof::blinded",
account = ?self.account,
elapsed = ?start.unwrap().elapsed(),
?path,
?node,
?tree_mask,
?hash_mask,
"Blinded node for storage trie"
);
Ok(node.map(|node| RevealedNode { node, tree_mask, hash_mask }))
}
}

0 comments on commit 3538c53

Please sign in to comment.