feat(tree): enter tracing span for each storage trie in state root task (#14363)

This commit is contained in:
Alexey Shekhirin
2025-02-10 12:44:55 +00:00
committed by GitHub
parent 37adaf2d2e
commit a7f895e72a

View File

@ -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;
@ -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())?;
}
@ -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?;