From d38984db8a9e351398b6cc91e3de4cdfb9dc1c63 Mon Sep 17 00:00:00 2001 From: krushimir Date: Wed, 4 Dec 2024 10:13:14 +0100 Subject: [PATCH] chore: fix formatting issues --- benches/smt-subtree.rs | 14 ++++++++++---- benches/smt-with-entries.rs | 9 ++------- src/merkle/mod.rs | 4 ++-- src/merkle/smt/full/mod.rs | 8 ++++---- src/merkle/smt/mod.rs | 1 - src/merkle/smt/tests.rs | 10 +++++----- 6 files changed, 23 insertions(+), 23 deletions(-) diff --git a/benches/smt-subtree.rs b/benches/smt-subtree.rs index df95c4a3..89cd66cb 100644 --- a/benches/smt-subtree.rs +++ b/benches/smt-subtree.rs @@ -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, @@ -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, diff --git a/benches/smt-with-entries.rs b/benches/smt-with-entries.rs index a24e0381..a3721281 100644 --- a/benches/smt-with-entries.rs +++ b/benches/smt-with-entries.rs @@ -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. @@ -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) }) diff --git a/src/merkle/mod.rs b/src/merkle/mod.rs index 83974559..2fdbc6ba 100644 --- a/src/merkle/mod.rs +++ b/src/merkle/mod.rs @@ -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}; diff --git a/src/merkle/smt/full/mod.rs b/src/merkle/smt/full/mod.rs index eb6171b4..56c08c66 100644 --- a/src/merkle/smt/full/mod.rs +++ b/src/merkle/smt/full/mod.rs @@ -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, ) -> Result { - #[cfg(feature="concurrent")] + #[cfg(feature = "concurrent")] { let mut seen_keys = BTreeSet::new(); let entries: Vec<_> = entries @@ -101,7 +101,7 @@ impl Smt { } >::with_entries_par(entries) } - #[cfg(not(feature="concurrent"))] + #[cfg(not(feature = "concurrent"))] { Self::with_entries_sequential(entries) } diff --git a/src/merkle/smt/mod.rs b/src/merkle/smt/mod.rs index d43e0e43..42020fcf 100644 --- a/src/merkle/smt/mod.rs +++ b/src/merkle/smt/mod.rs @@ -392,7 +392,6 @@ pub(crate) trait SparseMerkleTree { let mut accumulator: PairComputations = Default::default(); let mut accumulated_leaves: Vec = 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. diff --git a/src/merkle/smt/tests.rs b/src/merkle/smt/tests.rs index 9d99c765..23794c67 100644 --- a/src/merkle/smt/tests.rs +++ b/src/merkle/smt/tests.rs @@ -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, @@ -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!( @@ -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);