Skip to content

Commit e96ede5

Browse files
authored
feat: logs for pushing nodes to the stack (#101)
1 parent a098d3f commit e96ede5

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

src/hash_builder/mod.rs

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -261,14 +261,17 @@ impl HashBuilder {
261261
let leaf_node = LeafNodeRef::new(&short_node_key, leaf_value);
262262
self.rlp_buf.clear();
263263
let rlp = leaf_node.rlp(&mut self.rlp_buf);
264+
265+
let path = current.slice(..len_from);
264266
trace!(
265267
target: "trie::hash_builder",
268+
?path,
266269
?leaf_node,
267270
?rlp,
268271
"pushing leaf node",
269272
);
270273
self.stack.push(rlp);
271-
self.retain_proof_from_buf(&current.slice(..len_from));
274+
self.retain_proof_from_buf(&path);
272275
}
273276
HashBuilderValueRef::Hash(hash) => {
274277
trace!(target: "trie::hash_builder", ?hash, "pushing branch node hash");
@@ -293,14 +296,17 @@ impl HashBuilder {
293296

294297
self.rlp_buf.clear();
295298
let rlp = extension_node.rlp(&mut self.rlp_buf);
299+
300+
let path = current.slice(..len_from);
296301
trace!(
297302
target: "trie::hash_builder",
303+
?path,
298304
?extension_node,
299305
?rlp,
300306
"pushing extension node",
301307
);
302308
self.stack.push(rlp);
303-
self.retain_proof_from_buf(&current.slice(..len_from));
309+
self.retain_proof_from_buf(&path);
304310
self.resize_masks(len_from);
305311
}
306312

@@ -358,7 +364,15 @@ impl HashBuilder {
358364

359365
self.rlp_buf.clear();
360366
let rlp = branch_node.rlp(&mut self.rlp_buf);
361-
self.retain_proof_from_buf(&current.slice(..len));
367+
let path = current.slice(..len);
368+
trace!(
369+
target: "trie::hash_builder",
370+
?path,
371+
?branch_node,
372+
?rlp,
373+
"pushing branch node",
374+
);
375+
self.retain_proof_from_buf(&path);
362376

363377
// Clears the stack from the branch node elements
364378
let first_child_idx = self.stack.len() - state_mask.count_ones() as usize;
@@ -370,7 +384,6 @@ impl HashBuilder {
370384
);
371385
self.stack.resize_with(first_child_idx, Default::default);
372386

373-
trace!(target: "trie::hash_builder", ?rlp, "pushing branch node with {state_mask:?} mask from stack");
374387
self.stack.push(rlp);
375388
children
376389
}
@@ -401,7 +414,6 @@ impl HashBuilder {
401414
children,
402415
(len == 0).then(|| self.current_root()),
403416
);
404-
trace!(target: "trie::hash_builder", ?node, "intermediate node");
405417
self.updated_branch_nodes.as_mut().unwrap().insert(common_prefix, node);
406418
}
407419
}

0 commit comments

Comments
 (0)