From 3538c53317d3d0ba15bf092742860607f5a5f108 Mon Sep 17 00:00:00 2001 From: Alexey Shekhirin <5773434+shekhirin@users.noreply.github.com> Date: Mon, 27 Jan 2025 11:39:27 +0000 Subject: [PATCH] feat(trie): more logs for proofs (#13843) --- crates/trie/parallel/src/proof.rs | 3 +++ crates/trie/trie/src/proof/blinded.rs | 29 +++++++++++++++++++++++---- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/crates/trie/parallel/src/proof.rs b/crates/trie/parallel/src/proof.rs index f7716ee13161..cafb74fdc929 100644 --- a/crates/trie/parallel/src/proof.rs +++ b/crates/trie/parallel/src/proof.rs @@ -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, @@ -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" ); diff --git a/crates/trie/trie/src/proof/blinded.rs b/crates/trie/trie/src/proof/blinded.rs index 9b838c2e9dc6..9e802cf5256f 100644 --- a/crates/trie/trie/src/proof/blinded.rs +++ b/crates/trie/trie/src/proof/blinded.rs @@ -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)] @@ -88,6 +88,8 @@ where H: HashedCursorFactory + Clone + Send + Sync, { fn blinded_node(&mut self, path: &Nibbles) -> Result, 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()) @@ -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 })) } } @@ -135,6 +145,8 @@ where H: HashedCursorFactory + Clone + Send + Sync, { fn blinded_node(&mut self, path: &Nibbles) -> Result, 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(); @@ -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 })) } }