Skip to content

Commit

Permalink
chore: fix formatting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
krushimir committed Dec 4, 2024
1 parent 824adc9 commit d38984d
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 23 deletions.
14 changes: 10 additions & 4 deletions benches/smt-subtree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,11 @@ fn smt_subtree_even(c: &mut Criterion) {
},
|leaves| {
// Benchmarked function.
let (subtree, _) =
build_subtree_for_bench(hint::black_box(leaves), hint::black_box(SMT_DEPTH), hint::black_box(SMT_DEPTH));
let (subtree, _) = build_subtree_for_bench(
hint::black_box(leaves),
hint::black_box(SMT_DEPTH),
hint::black_box(SMT_DEPTH),
);
assert!(!subtree.is_empty());
},
BatchSize::SmallInput,
Expand Down Expand Up @@ -100,8 +103,11 @@ fn smt_subtree_random(c: &mut Criterion) {
leaves
},
|leaves| {
let (subtree, _) =
build_subtree_for_bench(hint::black_box(leaves), hint::black_box(SMT_DEPTH), hint::black_box(SMT_DEPTH));
let (subtree, _) = build_subtree_for_bench(
hint::black_box(leaves),
hint::black_box(SMT_DEPTH),
hint::black_box(SMT_DEPTH),
);
assert!(!subtree.is_empty());
},
BatchSize::SmallInput,
Expand Down
9 changes: 2 additions & 7 deletions benches/smt-with-entries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ fn smt_with_entries(c: &mut Criterion) {
b.iter_batched(
|| {
// Setup.
prepare_entries(pair_count, &mut seed )
prepare_entries(pair_count, &mut seed)
},
|entries| {
// Benchmarked function.
Expand Down Expand Up @@ -50,12 +50,7 @@ fn prepare_entries(pair_count: u64, seed: &mut [u8; 32]) -> Vec<(RpoDigest, [Fel
.map(|i| {
let count = pair_count as f64;
let idx = ((i as f64 / count) * (count)) as u64;
let key = RpoDigest::new([
generate_value(seed),
ONE,
Felt::new(i),
Felt::new(idx),
]);
let key = RpoDigest::new([generate_value(seed), ONE, Felt::new(i), Felt::new(idx)]);
let value = generate_word(seed);
(key, value)
})
Expand Down
4 changes: 2 additions & 2 deletions src/merkle/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ mod path;
pub use path::{MerklePath, RootPath, ValuePath};

mod smt;
#[cfg(feature = "internal")]
pub use smt::build_subtree_for_bench;
pub use smt::{
LeafIndex, MutationSet, SimpleSmt, Smt, SmtLeaf, SmtLeafError, SmtProof, SmtProofError,
SubtreeLeaf, SMT_DEPTH, SMT_MAX_DEPTH, SMT_MIN_DEPTH,
};
#[cfg(feature="internal")]
pub use smt::build_subtree_for_bench;

mod mmr;
pub use mmr::{InOrderIndex, Mmr, MmrDelta, MmrError, MmrPeaks, MmrProof, PartialMmr};
Expand Down
8 changes: 4 additions & 4 deletions src/merkle/smt/full/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,17 @@ impl Smt {

/// Returns a new [Smt] instantiated with leaves set as specified by the provided entries.
///
/// If the `concurrent` feature is enabled, this function uses a parallel implementation to
/// If the `concurrent` feature is enabled, this function uses a parallel implementation to
/// process the entries efficiently, otherwise it defaults to the sequential implementation.
///
/// All leaves omitted from the entries list are set to [Self::EMPTY_VALUE].
///
///
/// # Errors
/// Returns an error if the provided entries contain multiple values for the same key.
pub fn with_entries(
entries: impl IntoIterator<Item = (RpoDigest, Word)>,
) -> Result<Self, MerkleError> {
#[cfg(feature="concurrent")]
#[cfg(feature = "concurrent")]
{
let mut seen_keys = BTreeSet::new();
let entries: Vec<_> = entries
Expand All @@ -101,7 +101,7 @@ impl Smt {
}
<Self as SparseMerkleTree<SMT_DEPTH>>::with_entries_par(entries)
}
#[cfg(not(feature="concurrent"))]
#[cfg(not(feature = "concurrent"))]
{
Self::with_entries_sequential(entries)
}
Expand Down
1 change: 0 additions & 1 deletion src/merkle/smt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,6 @@ pub(crate) trait SparseMerkleTree<const DEPTH: u8> {
let mut accumulator: PairComputations<u64, Self::Leaf> = Default::default();
let mut accumulated_leaves: Vec<SubtreeLeaf> = Vec::with_capacity(pairs.len() / 2);


// As we iterate, we'll keep track of the kv-pairs we've seen so far that correspond to a
// single leaf. When we see a pair that's in a different leaf, we'll swap these pairs
// out and store them in our accumulated leaves.
Expand Down
10 changes: 5 additions & 5 deletions src/merkle/smt/tests.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use alloc::{collections::BTreeMap, vec::Vec};

use super::{
build_subtree, InnerNode, LeafIndex, NodeIndex, PairComputations, SmtLeaf, SparseMerkleTree, SubtreeLeaf,
SubtreeLeavesIter, COLS_PER_SUBTREE, SUBTREE_DEPTH,
build_subtree, InnerNode, LeafIndex, NodeIndex, PairComputations, SmtLeaf, SparseMerkleTree,
SubtreeLeaf, SubtreeLeavesIter, COLS_PER_SUBTREE, SUBTREE_DEPTH,
};
use crate::{
hash::rpo::RpoDigest,
Expand Down Expand Up @@ -135,8 +135,8 @@ fn test_single_subtree() {
}

// The root returned should also match the equivalent node in the control tree.
let control_root_index = NodeIndex::new(SMT_DEPTH - SUBTREE_DEPTH, subtree_root.col)
.expect("Valid root index");
let control_root_index =
NodeIndex::new(SMT_DEPTH - SUBTREE_DEPTH, subtree_root.col).expect("Valid root index");
let control_root_node = control.get_inner_node(control_root_index);
let control_hash = control_root_node.hash();
assert_eq!(
Expand Down Expand Up @@ -238,7 +238,7 @@ fn test_singlethreaded_subtrees() {

// Do actual things.
let (nodes, subtree_root) = build_subtree(subtree, SMT_DEPTH, current_depth);

// Post-assertions.
for (&index, test_node) in nodes.iter() {
let control_node = control.get_inner_node(index);
Expand Down

0 comments on commit d38984d

Please sign in to comment.