fix: replace deprecated #[clap(...)] with #[command(...)] and #[arg(...)] (#413)
This commit is contained in:
parent
8649dd1e04
commit
442123602c
11 changed files with 23 additions and 33 deletions
|
@ -1,5 +1,6 @@
|
|||
## 0.15.0 (TBD)
|
||||
|
||||
- Replace deprecated #[clap(...)] with #[command(...)] and #[arg(...)] (#413).
|
||||
- Added default constructors to `MmrPeaks` and `PartialMmr` (#409).
|
||||
- Add module and function documentation. (#408).
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
//! tree will perform better than the sparse version. At the time of this writing (2024/11/24), this
|
||||
//! benchmark is about four times more efficient than the equivalent benchmark in
|
||||
//! `benches/smt-subtree.rs`.
|
||||
use std::{hint, mem, time::Duration};
|
||||
use std::{hint, time::Duration};
|
||||
|
||||
use criterion::{BatchSize, Criterion, criterion_group, criterion_main};
|
||||
use miden_crypto::{Felt, ONE, Word, merkle::MerkleTree};
|
||||
|
@ -60,7 +60,7 @@ criterion_main!(smt_subtree_group);
|
|||
// --------------------------------------------------------------------------------------------
|
||||
|
||||
fn generate_word(seed: &mut [u8; 32]) -> Word {
|
||||
mem::swap(seed, &mut prng_array(*seed));
|
||||
*seed = prng_array(*seed);
|
||||
let nums: [u64; 4] = prng_array(*seed);
|
||||
[Felt::new(nums[0]), Felt::new(nums[1]), Felt::new(nums[2]), Felt::new(nums[3])]
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use std::{fmt::Debug, hint, mem, time::Duration};
|
||||
use std::{fmt::Debug, hint, time::Duration};
|
||||
|
||||
use criterion::{BatchSize, BenchmarkId, Criterion, criterion_group, criterion_main};
|
||||
use miden_crypto::{
|
||||
|
@ -131,13 +131,13 @@ criterion_main!(smt_subtree_group);
|
|||
// --------------------------------------------------------------------------------------------
|
||||
|
||||
fn generate_value<T: Copy + Debug + Randomizable>(seed: &mut [u8; 32]) -> T {
|
||||
mem::swap(seed, &mut prng_array(*seed));
|
||||
*seed = prng_array(*seed);
|
||||
let value: [T; 1] = rand_utils::prng_array(*seed);
|
||||
value[0]
|
||||
}
|
||||
|
||||
fn generate_word(seed: &mut [u8; 32]) -> Word {
|
||||
mem::swap(seed, &mut prng_array(*seed));
|
||||
*seed = prng_array(*seed);
|
||||
let nums: [u64; 4] = prng_array(*seed);
|
||||
[Felt::new(nums[0]), Felt::new(nums[1]), Felt::new(nums[2]), Felt::new(nums[3])]
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use std::{fmt::Debug, hint, mem, time::Duration};
|
||||
use std::{fmt::Debug, hint, time::Duration};
|
||||
|
||||
use criterion::{BatchSize, BenchmarkId, Criterion, criterion_group, criterion_main};
|
||||
use miden_crypto::{Felt, ONE, Word, hash::rpo::RpoDigest, merkle::Smt};
|
||||
|
@ -59,13 +59,13 @@ fn prepare_entries(pair_count: u64, seed: &mut [u8; 32]) -> Vec<(RpoDigest, [Fel
|
|||
}
|
||||
|
||||
fn generate_value<T: Copy + Debug + Randomizable>(seed: &mut [u8; 32]) -> T {
|
||||
mem::swap(seed, &mut prng_array(*seed));
|
||||
*seed = prng_array(*seed);
|
||||
let value: [T; 1] = rand_utils::prng_array(*seed);
|
||||
value[0]
|
||||
}
|
||||
|
||||
fn generate_word(seed: &mut [u8; 32]) -> Word {
|
||||
mem::swap(seed, &mut prng_array(*seed));
|
||||
*seed = prng_array(*seed);
|
||||
let nums: [u64; 4] = prng_array(*seed);
|
||||
[Felt::new(nums[0]), Felt::new(nums[1]), Felt::new(nums[2]), Felt::new(nums[3])]
|
||||
}
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
use core::mem::swap;
|
||||
|
||||
use criterion::{Criterion, black_box, criterion_group, criterion_main};
|
||||
use miden_crypto::{
|
||||
Felt, Word,
|
||||
|
@ -71,7 +69,7 @@ criterion_main!(smt_group);
|
|||
// --------------------------------------------------------------------------------------------
|
||||
|
||||
fn generate_word(seed: &mut [u8; 32]) -> Word {
|
||||
swap(seed, &mut prng_array(*seed));
|
||||
*seed = prng_array(*seed);
|
||||
let nums: [u64; 4] = prng_array(*seed);
|
||||
[Felt::new(nums[0]), Felt::new(nums[1]), Felt::new(nums[2]), Felt::new(nums[3])]
|
||||
}
|
||||
|
|
|
@ -126,7 +126,7 @@ impl PartialOrd for RpoDigest {
|
|||
impl Display for RpoDigest {
|
||||
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
|
||||
let encoded: String = self.into();
|
||||
write!(f, "{}", encoded)?;
|
||||
write!(f, "{encoded}")?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -108,7 +108,7 @@ impl PartialOrd for RpxDigest {
|
|||
impl Display for RpxDigest {
|
||||
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
|
||||
let encoded: String = self.into();
|
||||
write!(f, "{}", encoded)?;
|
||||
write!(f, "{encoded}")?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,16 +10,16 @@ use rand::{Rng, prelude::IteratorRandom, rng};
|
|||
use rand_utils::rand_value;
|
||||
|
||||
#[derive(Parser, Debug)]
|
||||
#[clap(name = "Benchmark", about = "SMT benchmark", version, rename_all = "kebab-case")]
|
||||
#[command(name = "Benchmark", about = "SMT benchmark", version, rename_all = "kebab-case")]
|
||||
pub struct BenchmarkCmd {
|
||||
/// Size of the tree
|
||||
#[clap(short = 's', long = "size", default_value = "1000000")]
|
||||
#[arg(short = 's', long = "size", default_value = "1000000")]
|
||||
size: usize,
|
||||
/// Number of insertions
|
||||
#[clap(short = 'i', long = "insertions", default_value = "1000")]
|
||||
#[arg(short = 'i', long = "insertions", default_value = "1000")]
|
||||
insertions: usize,
|
||||
/// Number of updates
|
||||
#[clap(short = 'u', long = "updates", default_value = "1000")]
|
||||
#[arg(short = 'u', long = "updates", default_value = "1000")]
|
||||
updates: usize,
|
||||
}
|
||||
|
||||
|
|
|
@ -246,9 +246,7 @@ impl PartialMmr {
|
|||
|
||||
debug_assert!(
|
||||
old.is_none(),
|
||||
"Idx {:?} already contained an element {:?}",
|
||||
left_idx,
|
||||
old
|
||||
"Idx {left_idx:?} already contained an element {old:?}",
|
||||
);
|
||||
};
|
||||
if track_left {
|
||||
|
@ -257,9 +255,7 @@ impl PartialMmr {
|
|||
|
||||
debug_assert!(
|
||||
old.is_none(),
|
||||
"Idx {:?} already contained an element {:?}",
|
||||
right_idx,
|
||||
old
|
||||
"Idx {right_idx:?} already contained an element {old:?}",
|
||||
);
|
||||
};
|
||||
|
||||
|
|
|
@ -247,8 +247,7 @@ fn test_singlethreaded_subtrees() {
|
|||
let control_node = control.get_inner_node(index);
|
||||
assert_eq!(
|
||||
test_node, &control_node,
|
||||
"depth {} subtree {}: test node does not match control at index {:?}",
|
||||
current_depth, i, index,
|
||||
"depth {current_depth} subtree {i}: test node does not match control at index {index:?}",
|
||||
);
|
||||
}
|
||||
(nodes, subtree_root)
|
||||
|
@ -329,8 +328,7 @@ fn test_multithreaded_subtrees() {
|
|||
let control_node = control.get_inner_node(index);
|
||||
assert_eq!(
|
||||
test_node, &control_node,
|
||||
"depth {} subtree {}: test node does not match control at index {:?}",
|
||||
current_depth, i, index,
|
||||
"depth {current_depth} subtree {i}: test node does not match control at index {index:?}",
|
||||
);
|
||||
}
|
||||
(nodes, subtree_root)
|
||||
|
@ -428,8 +426,7 @@ fn test_singlethreaded_subtree_mutations() {
|
|||
let control_mutation = control.node_mutations().get(&index).unwrap();
|
||||
assert_eq!(
|
||||
control_mutation, mutation,
|
||||
"depth {} subtree {}: mutation does not match control at index {:?}",
|
||||
current_depth, i, index,
|
||||
"depth {current_depth} subtree {i}: mutation does not match control at index {index:?}",
|
||||
);
|
||||
}
|
||||
(mutations_per_subtree, subtree_root)
|
||||
|
|
|
@ -154,16 +154,14 @@ impl Deserializable for SparseMerklePath {
|
|||
let depth = source.read_u8()?;
|
||||
if depth > SMT_MAX_DEPTH {
|
||||
return Err(DeserializationError::InvalidValue(format!(
|
||||
"SparseMerklePath max depth exceeded ({} > {})",
|
||||
depth, SMT_MAX_DEPTH
|
||||
"SparseMerklePath max depth exceeded ({depth} > {SMT_MAX_DEPTH})",
|
||||
)));
|
||||
}
|
||||
let empty_nodes_mask = source.read_u64()?;
|
||||
let empty_nodes_count = empty_nodes_mask.count_ones();
|
||||
if empty_nodes_count > depth as u32 {
|
||||
return Err(DeserializationError::InvalidValue(format!(
|
||||
"SparseMerklePath has more empty nodes ({}) than its full length ({})",
|
||||
empty_nodes_count, depth
|
||||
"SparseMerklePath has more empty nodes ({empty_nodes_count}) than its full length ({depth})",
|
||||
)));
|
||||
}
|
||||
let count = depth as u32 - empty_nodes_count;
|
||||
|
|
Loading…
Add table
Reference in a new issue