Skip to content

Commit

Permalink
Ensure unique leaf columns in smt-subtree bench
Browse files Browse the repository at this point in the history
  • Loading branch information
krushimir committed Feb 12, 2025
1 parent 1e59686 commit 733b894
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions benches/smt-subtree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ fn smt_subtree_random(c: &mut Criterion) {
})
.collect();
leaves.sort();
leaves.dedup_by_key(|leaf| leaf.col);
leaves
},
|leaves| {
Expand Down
9 changes: 9 additions & 0 deletions src/merkle/smt/full/concurrent/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,15 @@ fn build_subtree(
tree_depth: u8,
bottom_depth: u8,
) -> (UnorderedMap<NodeIndex, InnerNode>, SubtreeLeaf) {
#[cfg(debug_assertions)]
{
let mut seen_cols = BTreeSet::new();
for leaf in &leaves {
if !seen_cols.insert(leaf.col) {
panic!("Duplicate column found in subtree: {}", leaf.col);
}
}
}
debug_assert!(bottom_depth <= tree_depth);
debug_assert!(Integer::is_multiple_of(&bottom_depth, &SUBTREE_DEPTH));
debug_assert!(leaves.len() <= usize::pow(2, SUBTREE_DEPTH as u32));
Expand Down

0 comments on commit 733b894

Please sign in to comment.