Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ci): Update Rust version and fix CI #66

Merged
merged 3 commits into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ name: Build and Test
on: push

env:
RUST_VERSION: 1.70.0
NIGHTLY_VERSION: nightly-2023-05-31
RUST_VERSION: 1.76.0
NIGHTLY_VERSION: nightly-2024-02-04
CARGO_VET_VERSION: 0.7.0
CARGO_VET_REPO: https://github.com/mozilla/cargo-vet

Expand Down
4 changes: 2 additions & 2 deletions crates/semaphore-depth-macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@
/// assert!(depth > 0);
/// }
///
/// #[test]
/// fn test_depth_non_zero_depth_16() {

Check warning on line 31 in crates/semaphore-depth-macros/src/lib.rs

View workflow job for this annotation

GitHub Actions / clippy

unit tests in doctest are not executed

warning: unit tests in doctest are not executed --> crates/semaphore-depth-macros/src/lib.rs:30:5 | 30 | /// #[test] | _____^ 31 | | /// fn test_depth_non_zero_depth_16() { | |___________________________________^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#test_attr_in_doctest = note: `#[warn(clippy::test_attr_in_doctest)]` on by default
/// test_depth_non_zero(16);
/// }
///
/// #[test]
/// fn test_depth_non_zero_depth_30() {

Check warning on line 36 in crates/semaphore-depth-macros/src/lib.rs

View workflow job for this annotation

GitHub Actions / clippy

unit tests in doctest are not executed

warning: unit tests in doctest are not executed --> crates/semaphore-depth-macros/src/lib.rs:35:5 | 35 | /// #[test] | _____^ 36 | | /// fn test_depth_non_zero_depth_30() { | |___________________________________^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#test_attr_in_doctest
/// test_depth_non_zero(30);
/// }
/// ```
Expand Down Expand Up @@ -101,8 +101,8 @@
}
}
syn::Expr::Macro(mcr) => {
let Ok(mut args) = mcr.mac.parse_body::<MacroArgs>() else {
return;
let Ok(mut args) = mcr.mac.parse_body::<MacroArgs>() else {
return;
};
for arg in &mut args.args {
self.visit_expr_mut(arg);
Expand Down
2 changes: 1 addition & 1 deletion src/lazy_merkle_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,13 @@
/// Creates a new memory mapped file specified by path and creates a tree
/// with dense prefix of the given depth with initial values
#[must_use]
pub fn new_mmapped_with_dense_prefix_with_init_values(
depth: usize,
prefix_depth: usize,
empty_value: &H::Hash,
initial_values: &[H::Hash],
file_path: &str,
) -> Result<LazyMerkleTree<H, Canonical>, DenseMMapError> {

Check warning on line 92 in src/lazy_merkle_tree.rs

View workflow job for this annotation

GitHub Actions / clippy

docs for function returning `Result` missing `# Errors` section

warning: docs for function returning `Result` missing `# Errors` section --> src/lazy_merkle_tree.rs:86:5 | 86 | / pub fn new_mmapped_with_dense_prefix_with_init_values( 87 | | depth: usize, 88 | | prefix_depth: usize, 89 | | empty_value: &H::Hash, 90 | | initial_values: &[H::Hash], 91 | | file_path: &str, 92 | | ) -> Result<LazyMerkleTree<H, Canonical>, DenseMMapError> { | |_____________________________________________________________^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#missing_errors_doc

Check warning on line 92 in src/lazy_merkle_tree.rs

View workflow job for this annotation

GitHub Actions / clippy

this function has an empty `#[must_use]` attribute, but returns a type already marked as `#[must_use]`

warning: this function has an empty `#[must_use]` attribute, but returns a type already marked as `#[must_use]` --> src/lazy_merkle_tree.rs:86:5 | 86 | / pub fn new_mmapped_with_dense_prefix_with_init_values( 87 | | depth: usize, 88 | | prefix_depth: usize, 89 | | empty_value: &H::Hash, 90 | | initial_values: &[H::Hash], 91 | | file_path: &str, 92 | | ) -> Result<LazyMerkleTree<H, Canonical>, DenseMMapError> { | |_____________________________________________________________^ | = help: either add some descriptive text or remove the attribute = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#double_must_use = note: `#[warn(clippy::double_must_use)]` implied by `#[warn(clippy::all)]`
Ok(LazyMerkleTree {
tree: AnyTree::new_mmapped_with_dense_prefix_with_init_values(
depth,
Expand Down Expand Up @@ -559,8 +559,8 @@
fn from(children: Children<H>) -> Self {
assert_eq!(children.left.depth(), children.right.depth());
let (depth, root) = {
let left = children.left.clone();

Check warning on line 562 in src/lazy_merkle_tree.rs

View workflow job for this annotation

GitHub Actions / clippy

redundant clone

warning: redundant clone --> src/lazy_merkle_tree.rs:562:37 | 562 | let left = children.left.clone(); | ^^^^^^^^ help: remove this | note: cloned value is neither consumed nor mutated --> src/lazy_merkle_tree.rs:562:24 | 562 | let left = children.left.clone(); | ^^^^^^^^^^^^^^^^^^^^^ = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_clone note: the lint level is defined here --> src/lib.rs:2:55 | 2 | #![warn(clippy::all, clippy::pedantic, clippy::cargo, clippy::nursery)] | ^^^^^^^^^^^^^^^ = note: `#[warn(clippy::redundant_clone)]` implied by `#[warn(clippy::nursery)]`
let right = children.right.clone();

Check warning on line 563 in src/lazy_merkle_tree.rs

View workflow job for this annotation

GitHub Actions / clippy

redundant clone

warning: redundant clone --> src/lazy_merkle_tree.rs:563:39 | 563 | let right = children.right.clone(); | ^^^^^^^^ help: remove this | note: cloned value is neither consumed nor mutated --> src/lazy_merkle_tree.rs:563:25 | 563 | let right = children.right.clone(); | ^^^^^^^^^^^^^^^^^^^^^^ = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_clone
let depth = left.depth() + 1;
let root = H::hash_node(&left.root(), &right.root());
(depth, root)
Expand Down Expand Up @@ -708,7 +708,7 @@
where
F: FnOnce(DenseTreeRef<H>) -> R,
{
let guard = self.storage.lock().expect("lock poisoned, terminating");

Check warning on line 711 in src/lazy_merkle_tree.rs

View workflow job for this annotation

GitHub Actions / clippy

temporary with significant `Drop` can be early dropped

warning: temporary with significant `Drop` can be early dropped --> src/lazy_merkle_tree.rs:711:13 | 710 | / { 711 | | let guard = self.storage.lock().expect("lock poisoned, terminating"); | | ^^^^^ 712 | | let r = DenseTreeRef { 713 | | depth: self.depth, ... | 718 | | fun(r) 719 | | } | |_____- temporary `guard` is currently being dropped at the end of its contained scope | = note: this might lead to unnecessary resource contention = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#significant_drop_tightening = note: `#[warn(clippy::significant_drop_tightening)]` implied by `#[warn(clippy::nursery)]` help: merge the temporary construction with its single usage | 711 ~ 712 + let r = self.storage.lock().expect("lock poisoned, terminating").; | help: remove separated single usage | 712 - let r = DenseTreeRef { 713 - depth: self.depth, 714 - root_index: self.root_index, 715 - storage: &guard, 716 - locked_storage: &self.storage, 717 - }; 712 + |
let r = DenseTreeRef {
depth: self.depth,
root_index: self.root_index,
Expand Down Expand Up @@ -744,7 +744,7 @@
}

fn update_with_mutation(&self, index: usize, value: &H::Hash) {
let mut storage = self.storage.lock().expect("lock poisoned, terminating");

Check warning on line 747 in src/lazy_merkle_tree.rs

View workflow job for this annotation

GitHub Actions / clippy

temporary with significant `Drop` can be early dropped

warning: temporary with significant `Drop` can be early dropped --> src/lazy_merkle_tree.rs:747:17 | 746 | fn update_with_mutation(&self, index: usize, value: &H::Hash) { | ___________________________________________________________________- 747 | | let mut storage = self.storage.lock().expect("lock poisoned, terminating"); | | ^^^^^^^ 748 | | let leaf_index_in_dense_tree = index + (self.root_index << self.depth); 749 | | storage[leaf_index_in_dense_tree] = value.clone(); ... | 756 | | } 757 | | } | |_____- temporary `storage` is currently being dropped at the end of its contained scope | = note: this might lead to unnecessary resource contention = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#significant_drop_tightening help: drop the temporary after the end of its last usage | 754 ~ storage[current] = H::hash_node(left, right); 755 + drop(storage); |
let leaf_index_in_dense_tree = index + (self.root_index << self.depth);
storage[leaf_index_in_dense_tree] = value.clone();
let mut current = leaf_index_in_dense_tree / 2;
Expand Down Expand Up @@ -945,7 +945,7 @@
where
F: FnOnce(DenseTreeMMapRef<H>) -> R,
{
let guard = self.storage.lock().expect("lock poisoned, terminating");

Check warning on line 948 in src/lazy_merkle_tree.rs

View workflow job for this annotation

GitHub Actions / clippy

temporary with significant `Drop` can be early dropped

warning: temporary with significant `Drop` can be early dropped --> src/lazy_merkle_tree.rs:948:13 | 947 | / { 948 | | let guard = self.storage.lock().expect("lock poisoned, terminating"); | | ^^^^^ 949 | | let r = DenseTreeMMapRef { 950 | | depth: self.depth, ... | 955 | | fun(r) 956 | | } | |_____- temporary `guard` is currently being dropped at the end of its contained scope | = note: this might lead to unnecessary resource contention = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#significant_drop_tightening help: merge the temporary construction with its single usage | 948 ~ 949 + let r = self.storage.lock().expect("lock poisoned, terminating").; | help: remove separated single usage | 949 - let r = DenseTreeMMapRef { 950 - depth: self.depth, 951 - root_index: self.root_index, 952 - storage: &guard, 953 - locked_storage: &self.storage, 954 - }; 949 + |
let r = DenseTreeMMapRef {
depth: self.depth,
root_index: self.root_index,
Expand Down Expand Up @@ -981,7 +981,7 @@
}

fn update_with_mutation(&self, index: usize, value: &H::Hash) {
let mut storage = self.storage.lock().expect("lock poisoned, terminating");

Check warning on line 984 in src/lazy_merkle_tree.rs

View workflow job for this annotation

GitHub Actions / clippy

temporary with significant `Drop` can be early dropped

warning: temporary with significant `Drop` can be early dropped --> src/lazy_merkle_tree.rs:984:17 | 983 | fn update_with_mutation(&self, index: usize, value: &H::Hash) { | ___________________________________________________________________- 984 | | let mut storage = self.storage.lock().expect("lock poisoned, terminating"); | | ^^^^^^^ 985 | | let leaf_index_in_dense_tree = index + (self.root_index << self.depth); 986 | | storage[leaf_index_in_dense_tree] = value.clone(); ... | 993 | | } 994 | | } | |_____- temporary `storage` is currently being dropped at the end of its contained scope | = note: this might lead to unnecessary resource contention = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#significant_drop_tightening help: drop the temporary after the end of its last usage | 991 ~ storage[current] = H::hash_node(left, right); 992 + drop(storage); |
let leaf_index_in_dense_tree = index + (self.root_index << self.depth);
storage[leaf_index_in_dense_tree] = value.clone();
let mut current = leaf_index_in_dense_tree / 2;
Expand Down Expand Up @@ -1149,7 +1149,7 @@
};

file.set_len(file_size).expect("cannot set file size");
if file.write_all(&buf).is_err() {
if file.write_all(buf).is_err() {
return Err(DenseMMapError::FileCannotWriteBytes);
}

Expand Down
13 changes: 8 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,11 @@ mod test {
#[cfg(feature = "bench")]
pub mod bench {
use crate::{
hash_to_field, identity::Identity, poseidon_tree::LazyPoseidonTree,
protocol::{generate_proof, generate_witness}, Field,
hash_to_field,
identity::Identity,
poseidon_tree::LazyPoseidonTree,
protocol::{generate_proof, generate_witness},
Field,
};
use criterion::Criterion;
use semaphore_depth_config::get_supported_depths;
Expand Down Expand Up @@ -182,18 +185,18 @@ pub mod bench {

fn bench_witness(criterion: &mut Criterion, depth: usize) {
let leaf = Field::from(0);

// Create tree
let mut hello = *b"hello";
let id = Identity::from_secret(&mut hello, None);
let mut tree = LazyPoseidonTree::new(depth, leaf).derived();
tree = tree.update(0, &id.commitment());
let merkle_proof = tree.proof(0);

// change signal and external_nullifier here
let signal_hash = hash_to_field(b"xxx");
let external_nullifier_hash = hash_to_field(b"appId");

criterion.bench_function(&format!("witness_{depth}"), move |b| {
b.iter(|| {
generate_witness(&id, &merkle_proof, external_nullifier_hash, signal_hash).unwrap();
Expand Down
Loading