diff --git a/src/main.rs b/src/main.rs index 07bdf15b..16126096 100644 --- a/src/main.rs +++ b/src/main.rs @@ -78,7 +78,7 @@ pub fn insertion(tree: &mut Smt, insertions: usize) -> Result<(), MerkleError> { } println!( - "An average insertion time measured by {insertions} inserts into an SMT with {size} leaves is {:.0} μs\n", + "The average insertion time measured by {insertions} inserts into an SMT with {size} leaves is {:.0} μs\n", // calculate the average insertion_times.iter().sum::() as f64 / (insertions as f64), ); @@ -104,7 +104,7 @@ pub fn batched_insertion(tree: &mut Smt, insertions: usize) -> Result<(), Merkle let compute_elapsed = now.elapsed().as_secs_f64() * 1000_f64; // time in ms println!( - "An average insert-batch computation time measured by a 1k-batch into an SMT with {size} leaves over {:.1} ms is {:.0} μs", + "The average insert-batch computation time measured by a {insertions}-batch into an SMT with {size} leaves over {:.1} ms is {:.0} μs", compute_elapsed, compute_elapsed * 1000_f64 / insertions as f64, // time in μs ); @@ -114,13 +114,13 @@ pub fn batched_insertion(tree: &mut Smt, insertions: usize) -> Result<(), Merkle let apply_elapsed = now.elapsed().as_secs_f64() * 1000_f64; // time in ms println!( - "An average insert-batch application time measured by a 1k-batch into an SMT with {size} leaves over {:.1} ms is {:.0} μs", + "The average insert-batch application time measured by a {insertions}-batch into an SMT with {size} leaves over {:.1} ms is {:.0} μs", apply_elapsed, apply_elapsed * 1000_f64 / insertions as f64, // time in μs ); println!( - "An average batch insertion time measured by a 1k-batch into an SMT with {size} leaves totals to {:.1} ms", + "The average batch insertion time measured by a {insertions}-batch into an SMT with {size} leaves totals to {:.1} ms", (compute_elapsed + apply_elapsed), ); @@ -141,20 +141,20 @@ pub fn batched_update( let size = tree.num_leaves(); let mut rng = thread_rng(); - let new_pairs: Vec<(RpoDigest, Word)> = entries - .into_iter() - .choose_multiple(&mut rng, updates) - .into_iter() - .map(|(key, _)| { - let value = if rng.gen_bool(REMOVAL_PROBABILITY) { - EMPTY_WORD - } else { - [ONE, ONE, ONE, Felt::new(rng.gen())] - }; - - (key, value) - }) - .collect(); + let new_pairs = + entries + .into_iter() + .choose_multiple(&mut rng, updates) + .into_iter() + .map(|(key, _)| { + let value = if rng.gen_bool(REMOVAL_PROBABILITY) { + EMPTY_WORD + } else { + [ONE, ONE, ONE, Felt::new(rng.gen())] + }; + + (key, value) + }); assert_eq!(new_pairs.len(), updates); @@ -167,19 +167,19 @@ pub fn batched_update( let apply_elapsed = now.elapsed().as_secs_f64() * 1000_f64; // time in ms println!( - "An average update-batch computation time measured by a 1k-batch into an SMT with {size} leaves over {:.1} ms is {:.0} μs", + "The average update-batch computation time measured by a {updates}-batch into an SMT with {size} leaves over {:.1} ms is {:.0} μs", compute_elapsed, compute_elapsed * 1000_f64 / updates as f64, // time in μs ); println!( - "An average update-batch application time measured by a 1k-batch into an SMT with {size} leaves over {:.1} ms is {:.0} μs", + "The average update-batch application time measured by a {updates}-batch into an SMT with {size} leaves over {:.1} ms is {:.0} μs", apply_elapsed, apply_elapsed * 1000_f64 / updates as f64, // time in μs ); println!( - "An average batch update time measured by a 1k-batch into an SMT with {size} leaves totals to {:.1} ms", + "The average batch update time measured by a {updates}-batch into an SMT with {size} leaves totals to {:.1} ms", (compute_elapsed + apply_elapsed), ); @@ -208,7 +208,7 @@ pub fn proof_generation(tree: &mut Smt) -> Result<(), MerkleError> { } println!( - "An average proving time measured by {NUM_PROOFS} value proofs in an SMT with {size} leaves in {:.0} μs", + "The average proving time measured by {NUM_PROOFS} value proofs in an SMT with {size} leaves in {:.0} μs", // calculate the average insertion_times.iter().sum::() as f64 / (NUM_PROOFS as f64), ); diff --git a/src/merkle/smt/mod.rs b/src/merkle/smt/mod.rs index 10eea88e..637f15f1 100644 --- a/src/merkle/smt/mod.rs +++ b/src/merkle/smt/mod.rs @@ -621,8 +621,8 @@ pub(crate) trait SparseMerkleTree { /// Constructs an `InnerNode` representing the sibling pair of which `first_leaf` is a part: /// - If `first_leaf` is a right child, the left child is copied from the `parent_node`. - /// - If `first_leaf` is a left child, the right child is taken from `iter` if it was also mutated - /// or copied from the `parent_node`. + /// - If `first_leaf` is a left child, the right child is taken from `iter` if it was also + /// mutated or copied from the `parent_node`. /// /// Returns the `InnerNode` containing the hashes of the sibling pair. fn fetch_sibling_pair( diff --git a/src/merkle/smt/tests.rs b/src/merkle/smt/tests.rs index 3d17d0ec..0e4a893c 100644 --- a/src/merkle/smt/tests.rs +++ b/src/merkle/smt/tests.rs @@ -120,12 +120,7 @@ fn generate_updates(entries: Vec<(RpoDigest, Word)>, updates: usize) -> Vec<(Rpo // Assertion to ensure input keys are unique assert!( - entries - .iter() - .map(|(key, _)| key) - .collect::>() - .len() - == entries.len(), + entries.iter().map(|(key, _)| key).collect::>().len() == entries.len(), "Input entries contain duplicate keys!" );