Skip to content

Commit

Permalink
cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
YaoGalteland committed May 6, 2024
1 parent 42f1b0a commit 2b89fae
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 29 deletions.
36 changes: 13 additions & 23 deletions halo2_gadgets/src/utilities/lookup_range_check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,10 @@ pub(crate) mod tests {
};
use pasta_curves::pallas;

use crate::utilities::test_circuit::{read_test_case, test_proof_size, write_test_case, Proof, read_all_proofs, write_all_test_case};
use crate::utilities::test_circuit::{
read_all_proofs, read_test_case, test_proof_size, write_all_test_case, write_test_case,
Proof,
};
use halo2_proofs::poly::commitment::Params;
use pasta_curves::vesta::Affine;
use std::{convert::TryInto, fs, marker::PhantomData};
Expand Down Expand Up @@ -648,13 +651,13 @@ pub(crate) mod tests {
}
}


if std::env::var_os("CIRCUIT_TEST_GENERATE_NEW_PROOF").is_some() {
}
else {
} else {
// Parse the hardcoded proof test case.
let proofs= {
let test_case_bytes = fs::read("src/utilities/circuit_proof_test_case_short_range_check.bin").unwrap();
let proofs = {

Check warning on line 657 in halo2_gadgets/src/utilities/lookup_range_check.rs

View workflow job for this annotation

GitHub Actions / Clippy (beta)

unused variable: `proofs`

warning: unused variable: `proofs` --> halo2_gadgets/src/utilities/lookup_range_check.rs:657:17 | 657 | let proofs = { | ^^^^^^ help: if this is intentional, prefix it with an underscore: `_proofs` | = note: `#[warn(unused_variables)]` on by default

Check failure on line 657 in halo2_gadgets/src/utilities/lookup_range_check.rs

View workflow job for this annotation

GitHub Actions / Clippy (MSRV)

unused variable: `proofs`

error: unused variable: `proofs` --> halo2_gadgets/src/utilities/lookup_range_check.rs:657:17 | 657 | let proofs = { | ^^^^^^ help: if this is intentional, prefix it with an underscore: `_proofs` | = note: `-D unused-variables` implied by `-D warnings`

Check warning on line 657 in halo2_gadgets/src/utilities/lookup_range_check.rs

View workflow job for this annotation

GitHub Actions / Test on ubuntu-latest

unused variable: `proofs`

Check warning on line 657 in halo2_gadgets/src/utilities/lookup_range_check.rs

View workflow job for this annotation

GitHub Actions / Test on ubuntu-latest with beta features

unused variable: `proofs`

Check warning on line 657 in halo2_gadgets/src/utilities/lookup_range_check.rs

View workflow job for this annotation

GitHub Actions / Test on ubuntu-latest with beta features

unused variable: `proofs`

Check warning on line 657 in halo2_gadgets/src/utilities/lookup_range_check.rs

View workflow job for this annotation

GitHub Actions / Test on ubuntu-latest

unused variable: `proofs`

Check warning on line 657 in halo2_gadgets/src/utilities/lookup_range_check.rs

View workflow job for this annotation

GitHub Actions / Test on ubuntu-latest with nightly features

unused variable: `proofs`

Check warning on line 657 in halo2_gadgets/src/utilities/lookup_range_check.rs

View workflow job for this annotation

GitHub Actions / Test on ubuntu-latest with nightly features

unused variable: `proofs`

Check warning on line 657 in halo2_gadgets/src/utilities/lookup_range_check.rs

View workflow job for this annotation

GitHub Actions / Test on windows-latest with beta features

unused variable: `proofs`

Check warning on line 657 in halo2_gadgets/src/utilities/lookup_range_check.rs

View workflow job for this annotation

GitHub Actions / Test on windows-latest

unused variable: `proofs`

Check warning on line 657 in halo2_gadgets/src/utilities/lookup_range_check.rs

View workflow job for this annotation

GitHub Actions / Test on windows-latest with nightly features

unused variable: `proofs`

Check warning on line 657 in halo2_gadgets/src/utilities/lookup_range_check.rs

View workflow job for this annotation

GitHub Actions / Test on macOS-latest with beta features

unused variable: `proofs`

Check warning on line 657 in halo2_gadgets/src/utilities/lookup_range_check.rs

View workflow job for this annotation

GitHub Actions / Test on windows-latest with nightly features

unused variable: `proofs`

Check warning on line 657 in halo2_gadgets/src/utilities/lookup_range_check.rs

View workflow job for this annotation

GitHub Actions / Test on macOS-latest with nightly features

unused variable: `proofs`

Check warning on line 657 in halo2_gadgets/src/utilities/lookup_range_check.rs

View workflow job for this annotation

GitHub Actions / Test on macOS-latest

unused variable: `proofs`

Check warning on line 657 in halo2_gadgets/src/utilities/lookup_range_check.rs

View workflow job for this annotation

GitHub Actions / Test on macOS-latest with beta features

unused variable: `proofs`

Check warning on line 657 in halo2_gadgets/src/utilities/lookup_range_check.rs

View workflow job for this annotation

GitHub Actions / Test on macOS-latest with nightly features

unused variable: `proofs`

Check warning on line 657 in halo2_gadgets/src/utilities/lookup_range_check.rs

View workflow job for this annotation

GitHub Actions / Test on macOS-latest

unused variable: `proofs`
let test_case_bytes =
fs::read("src/utilities/circuit_proof_test_case_short_range_check.bin")
.unwrap();
read_all_proofs(&test_case_bytes[..]).expect("proof must be valid")
};
}
Expand Down Expand Up @@ -694,8 +697,7 @@ pub(crate) mod tests {
let proof = Proof::create(&vk, &params, circuit).unwrap();
assert!(proof.verify(&vk, &params).is_ok());
proofs.push(proof.clone());

Check failure on line 699 in halo2_gadgets/src/utilities/lookup_range_check.rs

View workflow job for this annotation

GitHub Actions / Clippy (MSRV)

redundant clone

error: redundant clone --> halo2_gadgets/src/utilities/lookup_range_check.rs:699:38 | 699 | proofs.push(proof.clone()); | ^^^^^^^^ help: remove this | = note: `-D clippy::redundant-clone` implied by `-D warnings` note: this value is dropped without further use --> halo2_gadgets/src/utilities/lookup_range_check.rs:699:33 | 699 | proofs.push(proof.clone()); | ^^^^^ = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_clone
}
else {
} else {
match proofs.get(0) {

Check warning on line 701 in halo2_gadgets/src/utilities/lookup_range_check.rs

View workflow job for this annotation

GitHub Actions / Clippy (beta)

accessing first element with `proofs.get(0)`

warning: accessing first element with `proofs.get(0)` --> halo2_gadgets/src/utilities/lookup_range_check.rs:701:27 | 701 | match proofs.get(0) { | ^^^^^^^^^^^^^ help: try: `proofs.first()` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#get_first = note: `-W clippy::get-first` implied by `-W clippy::all` = help: to override `-W clippy::all` add `#[allow(clippy::get_first)]`
Some(proof) => {
println!("proof={:?}", proof);
Expand All @@ -707,8 +709,6 @@ pub(crate) mod tests {
}
}
}


}

// Edge case: K bits
Expand Down Expand Up @@ -742,8 +742,7 @@ pub(crate) mod tests {
let proof = Proof::create(&vk, &params, circuit).unwrap();
assert!(proof.verify(&vk, &params).is_ok());
proofs.push(proof.clone());

Check failure on line 744 in halo2_gadgets/src/utilities/lookup_range_check.rs

View workflow job for this annotation

GitHub Actions / Clippy (MSRV)

redundant clone

error: redundant clone --> halo2_gadgets/src/utilities/lookup_range_check.rs:744:38 | 744 | proofs.push(proof.clone()); | ^^^^^^^^ help: remove this | note: this value is dropped without further use --> halo2_gadgets/src/utilities/lookup_range_check.rs:744:33 | 744 | proofs.push(proof.clone()); | ^^^^^ = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_clone
}
else {
} else {
match proofs.get(1) {
Some(proof) => {
println!("proof={:?}", proof);
Expand All @@ -755,7 +754,6 @@ pub(crate) mod tests {
}
}
}

}

// Element within `num_bits`
Expand Down Expand Up @@ -789,8 +787,7 @@ pub(crate) mod tests {
let proof = Proof::create(&vk, &params, circuit).unwrap();
assert!(proof.verify(&vk, &params).is_ok());
proofs.push(proof.clone());

Check failure on line 789 in halo2_gadgets/src/utilities/lookup_range_check.rs

View workflow job for this annotation

GitHub Actions / Clippy (MSRV)

redundant clone

error: redundant clone --> halo2_gadgets/src/utilities/lookup_range_check.rs:789:38 | 789 | proofs.push(proof.clone()); | ^^^^^^^^ help: remove this | note: this value is dropped without further use --> halo2_gadgets/src/utilities/lookup_range_check.rs:789:33 | 789 | proofs.push(proof.clone()); | ^^^^^ = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_clone
}
else {
} else {
match proofs.get(2) {
Some(proof) => {
println!("proof={:?}", proof);
Expand All @@ -806,9 +803,8 @@ pub(crate) mod tests {

if std::env::var_os("CIRCUIT_TEST_GENERATE_NEW_PROOF").is_some() {
let create_proof = || -> std::io::Result<()> {

let file = std::fs::File::create(
"src/utilities/circuit_proof_test_case_short_range_check.bin"
"src/utilities/circuit_proof_test_case_short_range_check.bin",
)?;
write_all_test_case(file, &proofs)
};
Expand All @@ -832,8 +828,6 @@ pub(crate) mod tests {
},
}])
);


}

// Element larger than K bits
Expand Down Expand Up @@ -862,8 +856,6 @@ pub(crate) mod tests {
},
])
);


}

// Element which is not within `num_bits`, but which has a shifted value within
Expand Down Expand Up @@ -892,8 +884,6 @@ pub(crate) mod tests {
},
}])
);


}
}
}
9 changes: 3 additions & 6 deletions halo2_gadgets/src/utilities/test_circuit.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
//! functions used for circuit test

use std::io;
use halo2_proofs::plonk;
use halo2_proofs::plonk::{Circuit, SingleVerifier, VerifyingKey};
use halo2_proofs::poly::commitment::Params;
use halo2_proofs::transcript::{Blake2bRead, Blake2bWrite};
use pasta_curves::vesta::Affine;
use pasta_curves::{pallas, vesta};
use rand::rngs::OsRng;
use std::io;
use std::io::{Read, Write};

/// A proof structure
Expand Down Expand Up @@ -90,10 +90,7 @@ pub fn read_test_case<R: Read>(mut r: R) -> std::io::Result<Proof> {
}

/// write multiple proofs to a file
pub(crate) fn write_all_test_case<W: Write>(
mut w: W,
proofs: &Vec<Proof>,
) -> std::io::Result<()> {
pub(crate) fn write_all_test_case<W: Write>(mut w: W, proofs: &Vec<Proof>) -> std::io::Result<()> {

Check warning on line 93 in halo2_gadgets/src/utilities/test_circuit.rs

View workflow job for this annotation

GitHub Actions / Clippy (beta)

function `write_all_test_case` is never used

warning: function `write_all_test_case` is never used --> halo2_gadgets/src/utilities/test_circuit.rs:93:15 | 93 | pub(crate) fn write_all_test_case<W: Write>(mut w: W, proofs: &Vec<Proof>) -> std::io::Result<()> { | ^^^^^^^^^^^^^^^^^^^

Check warning on line 93 in halo2_gadgets/src/utilities/test_circuit.rs

View workflow job for this annotation

GitHub Actions / Bitrot check

function `write_all_test_case` is never used

Check warning on line 93 in halo2_gadgets/src/utilities/test_circuit.rs

View workflow job for this annotation

GitHub Actions / Book tests

function is never used: `write_all_test_case`

Check warning on line 93 in halo2_gadgets/src/utilities/test_circuit.rs

View workflow job for this annotation

GitHub Actions / Book tests

function is never used: `write_all_test_case`

Check warning on line 93 in halo2_gadgets/src/utilities/test_circuit.rs

View workflow job for this annotation

GitHub Actions / Build target wasm32-wasi

function is never used: `write_all_test_case`

Check warning on line 93 in halo2_gadgets/src/utilities/test_circuit.rs

View workflow job for this annotation

GitHub Actions / Build target wasm32-unknown-unknown

function is never used: `write_all_test_case`

Check warning on line 93 in halo2_gadgets/src/utilities/test_circuit.rs

View workflow job for this annotation

GitHub Actions / Build target wasm32-wasi

function is never used: `write_all_test_case`

Check failure on line 93 in halo2_gadgets/src/utilities/test_circuit.rs

View workflow job for this annotation

GitHub Actions / Clippy (MSRV)

function is never used: `write_all_test_case`

error: function is never used: `write_all_test_case` --> halo2_gadgets/src/utilities/test_circuit.rs:93:15 | 93 | pub(crate) fn write_all_test_case<W: Write>(mut w: W, proofs: &Vec<Proof>) -> std::io::Result<()> { | ^^^^^^^^^^^^^^^^^^^

Check warning on line 93 in halo2_gadgets/src/utilities/test_circuit.rs

View workflow job for this annotation

GitHub Actions / Build target wasm32-unknown-unknown

function is never used: `write_all_test_case`

Check warning on line 93 in halo2_gadgets/src/utilities/test_circuit.rs

View workflow job for this annotation

GitHub Actions / Test on ubuntu-latest

function is never used: `write_all_test_case`

Check warning on line 93 in halo2_gadgets/src/utilities/test_circuit.rs

View workflow job for this annotation

GitHub Actions / Test on ubuntu-latest with beta features

function is never used: `write_all_test_case`

Check warning on line 93 in halo2_gadgets/src/utilities/test_circuit.rs

View workflow job for this annotation

GitHub Actions / Test on ubuntu-latest with beta features

function is never used: `write_all_test_case`

Check warning on line 93 in halo2_gadgets/src/utilities/test_circuit.rs

View workflow job for this annotation

GitHub Actions / Test on ubuntu-latest

function is never used: `write_all_test_case`

Check warning on line 93 in halo2_gadgets/src/utilities/test_circuit.rs

View workflow job for this annotation

GitHub Actions / Test on ubuntu-latest with nightly features

function is never used: `write_all_test_case`

Check warning on line 93 in halo2_gadgets/src/utilities/test_circuit.rs

View workflow job for this annotation

GitHub Actions / Test on ubuntu-latest with nightly features

function is never used: `write_all_test_case`

Check warning on line 93 in halo2_gadgets/src/utilities/test_circuit.rs

View workflow job for this annotation

GitHub Actions / Test on windows-latest with beta features

function is never used: `write_all_test_case`

Check warning on line 93 in halo2_gadgets/src/utilities/test_circuit.rs

View workflow job for this annotation

GitHub Actions / Test on windows-latest

function is never used: `write_all_test_case`

Check warning on line 93 in halo2_gadgets/src/utilities/test_circuit.rs

View workflow job for this annotation

GitHub Actions / Test on windows-latest with beta features

function is never used: `write_all_test_case`

Check warning on line 93 in halo2_gadgets/src/utilities/test_circuit.rs

View workflow job for this annotation

GitHub Actions / Test on windows-latest

function is never used: `write_all_test_case`

Check warning on line 93 in halo2_gadgets/src/utilities/test_circuit.rs

View workflow job for this annotation

GitHub Actions / Test on windows-latest with nightly features

function is never used: `write_all_test_case`

Check warning on line 93 in halo2_gadgets/src/utilities/test_circuit.rs

View workflow job for this annotation

GitHub Actions / Test on macOS-latest with beta features

function is never used: `write_all_test_case`

Check warning on line 93 in halo2_gadgets/src/utilities/test_circuit.rs

View workflow job for this annotation

GitHub Actions / Test on windows-latest with nightly features

function is never used: `write_all_test_case`

Check warning on line 93 in halo2_gadgets/src/utilities/test_circuit.rs

View workflow job for this annotation

GitHub Actions / Test on macOS-latest with nightly features

function is never used: `write_all_test_case`

Check warning on line 93 in halo2_gadgets/src/utilities/test_circuit.rs

View workflow job for this annotation

GitHub Actions / Test on macOS-latest

function is never used: `write_all_test_case`

Check warning on line 93 in halo2_gadgets/src/utilities/test_circuit.rs

View workflow job for this annotation

GitHub Actions / Test on macOS-latest with beta features

function is never used: `write_all_test_case`

Check warning on line 93 in halo2_gadgets/src/utilities/test_circuit.rs

View workflow job for this annotation

GitHub Actions / Test on macOS-latest with nightly features

function is never used: `write_all_test_case`

Check warning on line 93 in halo2_gadgets/src/utilities/test_circuit.rs

View workflow job for this annotation

GitHub Actions / Test on macOS-latest

function is never used: `write_all_test_case`
for proof in proofs {
w.write_all(proof.as_ref())?;
}
Expand All @@ -109,4 +106,4 @@ pub fn read_all_proofs<R: Read>(mut r: R) -> io::Result<Vec<Proof>> {
proofs.push(Proof::new(buffer.clone()));
}
Ok(proofs)
}
}

0 comments on commit 2b89fae

Please sign in to comment.