Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(trie): more logs for proofs #13843

Merged
merged 4 commits into from
Jan 27, 2025
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
27 changes: 24 additions & 3 deletions crates/trie/trie/src/proof/blinded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ 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 std::{sync::Arc, time::Instant};
use tracing::trace;

/// Factory for instantiating providers capable of retrieving blinded trie nodes via proofs.
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 = 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.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 = Instant::now();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we call this a bunch because this is called in a loop.

imo this clock overhead is too expensive to perform on this level

Copy link
Collaborator Author

@shekhirin shekhirin Jan 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's called in a loop but only for those nodes that are blinded, and we usually don't have a lot of them that need to be revealed. Nevertheless, added a check for the TRACE level for target to be enabled, so that we don't do Instant::now when not needed.


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.elapsed(),
?path,
?node,
?tree_mask,
?hash_mask,
"Blinded node for storage trie"
);
Ok(node.map(|node| RevealedNode { node, tree_mask, hash_mask }))
}
}
Loading