Skip to content

Commit

Permalink
feat(tree): enter tracing span for each storage trie in state root ta…
Browse files Browse the repository at this point in the history
…sk (#14363)
  • Loading branch information
shekhirin authored Feb 10, 2025
1 parent 37adaf2 commit a7f895e
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions crates/engine/tree/src/tree/root.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ use std::{
},
time::{Duration, Instant},
};
use tracing::{debug, error, trace};
use tracing::{debug, error, trace, trace_span};

/// The level below which the sparse trie hashes are calculated in [`update_sparse_trie`].
const SPARSE_TRIE_INCREMENTAL_LEVEL: usize = 2;
Expand Down Expand Up @@ -1098,20 +1098,22 @@ where
.map(|(address, storage)| (address, storage, trie.take_storage_trie(&address)))
.par_bridge()
.map(|(address, storage, storage_trie)| {
trace!(target: "engine::root::sparse", ?address, "Updating storage");
let span = trace_span!(target: "engine::root::sparse", "Storage trie", ?address);
let _enter = span.enter();
trace!(target: "engine::root::sparse", "Updating storage");
let mut storage_trie = storage_trie.ok_or(SparseTrieErrorKind::Blind)?;

if storage.wiped {
trace!(target: "engine::root::sparse", ?address, "Wiping storage");
trace!(target: "engine::root::sparse", "Wiping storage");
storage_trie.wipe()?;
}
for (slot, value) in storage.storage {
let slot_nibbles = Nibbles::unpack(slot);
if value.is_zero() {
trace!(target: "engine::root::sparse", ?address, ?slot, "Removing storage slot");
trace!(target: "engine::root::sparse", ?slot, "Removing storage slot");
storage_trie.remove_leaf(&slot_nibbles)?;
} else {
trace!(target: "engine::root::sparse", ?address, ?slot, "Updating storage slot");
trace!(target: "engine::root::sparse", ?slot, "Updating storage slot");
storage_trie
.update_leaf(slot_nibbles, alloy_rlp::encode_fixed_size(&value).to_vec())?;
}
Expand All @@ -1121,9 +1123,7 @@ where

SparseStateTrieResult::Ok((address, storage_trie))
})
.for_each_init(|| tx.clone(), |tx, result| {
tx.send(result).unwrap()
});
.for_each_init(|| tx.clone(), |tx, result| tx.send(result).unwrap());
drop(tx);
for result in rx {
let (address, storage_trie) = result?;
Expand Down

0 comments on commit a7f895e

Please sign in to comment.