Skip to content

Commit

Permalink
refactor: Bump toolchain and clean lints (#387)
Browse files Browse the repository at this point in the history
- Upgraded the Rust toolchain version.
- clippy
  • Loading branch information
huitseeker authored Jun 12, 2024
1 parent f3d7790 commit 3043e8c
Show file tree
Hide file tree
Showing 9 changed files with 10 additions and 42 deletions.
4 changes: 2 additions & 2 deletions examples/hashchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@ impl<G: Group> StepCircuit<G::Scalar> for HashChainCircuit<G> {
let acc = &mut ns;

sponge.start(parameter, None, acc);
neptune::sponge::api::SpongeAPI::absorb(&mut sponge, num_absorbs, &elt, acc);
SpongeAPI::absorb(&mut sponge, num_absorbs, &elt, acc);

let output = neptune::sponge::api::SpongeAPI::squeeze(&mut sponge, 1, acc);
let output = SpongeAPI::squeeze(&mut sponge, 1, acc);
sponge.finish(acc).unwrap();
Elt::ensure_allocated(&output[0], &mut ns.namespace(|| "ensure allocated"), true)?
};
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[toolchain]
# The default profile includes rustc, rust-std, cargo, rust-docs, rustfmt and clippy.
profile = "default"
channel = "1.77"
channel = "1.78"
targets = [ "wasm32-unknown-unknown" ]

4 changes: 0 additions & 4 deletions src/gadgets/nonnative/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,12 @@ use ff::PrimeField;

trait OptionExt<T> {
fn grab(&self) -> Result<&T, SynthesisError>;
fn grab_mut(&mut self) -> Result<&mut T, SynthesisError>;
}

impl<T> OptionExt<T> for Option<T> {
fn grab(&self) -> Result<&T, SynthesisError> {
self.as_ref().ok_or(SynthesisError::AssignmentMissing)
}
fn grab_mut(&mut self) -> Result<&mut T, SynthesisError> {
self.as_mut().ok_or(SynthesisError::AssignmentMissing)
}
}

trait BitAccess {
Expand Down
4 changes: 2 additions & 2 deletions src/provider/poseidon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ where
assert_eq!(self.num_absorbs, self.state.len());

sponge.start(parameter, None, acc);
neptune::sponge::api::SpongeAPI::absorb(
SpongeAPI::absorb(
&mut sponge,
self.num_absorbs as u32,
&(0..self.state.len())
Expand All @@ -178,7 +178,7 @@ where
acc,
);

let output = neptune::sponge::api::SpongeAPI::squeeze(&mut sponge, 1, acc);
let output = SpongeAPI::squeeze(&mut sponge, 1, acc);
sponge.finish(acc).unwrap();
output
};
Expand Down
2 changes: 1 addition & 1 deletion src/provider/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub mod solidity_compatibility_utils {
) {
use rand_core::SeedableRng;

let mut rng = rand::rngs::StdRng::seed_from_u64(num_vars as u64);
let mut rng = StdRng::seed_from_u64(num_vars as u64);

let (poly, point, eval) =
crate::provider::util::test_utils::random_poly_with_eval::<E, StdRng>(num_vars, &mut rng);
Expand Down
2 changes: 1 addition & 1 deletion src/provider/util/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ pub mod test_utils {
) {
use rand_core::SeedableRng;

let mut rng = rand::rngs::StdRng::seed_from_u64(num_vars as u64);
let mut rng = StdRng::seed_from_u64(num_vars as u64);

let (poly, point, eval) = random_poly_with_eval::<E, StdRng>(num_vars, &mut rng);

Expand Down
15 changes: 0 additions & 15 deletions src/spartan/math.rs
Original file line number Diff line number Diff line change
@@ -1,23 +1,8 @@
pub trait Math {
fn pow2(self) -> usize;
fn get_bits(self, num_bits: usize) -> Vec<bool>;
fn log_2(self) -> usize;
}

impl Math for usize {
#[inline]
fn pow2(self) -> usize {
let base: Self = 2;
base.pow(self as u32)
}

/// Returns the `num_bits` from n in a canonical order
fn get_bits(self, num_bits: usize) -> Vec<bool> {
(0..num_bits)
.map(|shift_amount| ((self & (1 << (num_bits - shift_amount - 1))) > 0))
.collect::<Vec<bool>>()
}

fn log_2(self) -> usize {
assert_ne!(self, 0);

Expand Down
6 changes: 3 additions & 3 deletions src/spartan/polys/multilinear.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ impl<Scalar: PrimeField> Add for MultilinearPolynomial<Scalar> {

#[cfg(test)]
mod tests {
use crate::provider::{self, bn256_grumpkin::bn256, secp_secq::secp256k1};
use crate::provider::{bn256_grumpkin::bn256, secp_secq::secp256k1};

use super::*;
use rand_chacha::ChaCha20Rng;
Expand Down Expand Up @@ -293,8 +293,8 @@ mod tests {
#[test]
fn test_evaluation() {
test_evaluation_with::<pasta_curves::Fp>();
test_evaluation_with::<provider::bn256_grumpkin::bn256::Scalar>();
test_evaluation_with::<provider::secp_secq::secp256k1::Scalar>();
test_evaluation_with::<bn256::Scalar>();
test_evaluation_with::<secp256k1::Scalar>();
}

/// This binds the variables of a multilinear polynomial to a provided sequence
Expand Down
13 changes: 0 additions & 13 deletions src/supernova/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1155,19 +1155,6 @@ where
fn secondary_circuit(&self) -> Self::C2;
}

/// Extension trait to simplify getting scalar form of initial circuit index.
trait InitialProgramCounter<E1>: NonUniformCircuit<E1>
where
E1: CurveCycleEquipped,
{
/// Initial program counter is the initial circuit index as a `Scalar`.
fn initial_program_counter(&self) -> E1::Scalar {
E1::Scalar::from(self.initial_circuit_index() as u64)
}
}

impl<E1: CurveCycleEquipped, T: NonUniformCircuit<E1>> InitialProgramCounter<E1> for T {}

/// Compute the circuit digest of a supernova [`StepCircuit`].
///
/// Note for callers: This function should be called with its performance characteristics in mind.
Expand Down

0 comments on commit 3043e8c

Please sign in to comment.