diff --git a/ecdsa/Cargo.toml b/ecdsa/Cargo.toml index 522856ef..602fbb09 100644 --- a/ecdsa/Cargo.toml +++ b/ecdsa/Cargo.toml @@ -3,6 +3,9 @@ name = "plonky2_ecdsa" version = "0.1.0" edition = "2021" +[features] +parallel = ["maybe_rayon/parallel", "plonky2/parallel"] + [dependencies] anyhow = { version = "1.0.40", default-features = false } itertools = { version = "0.10.0", default-features = false } diff --git a/ecdsa/src/curve/curve_msm.rs b/ecdsa/src/curve/curve_msm.rs index bc04b6cc..21bcc404 100644 --- a/ecdsa/src/curve/curve_msm.rs +++ b/ecdsa/src/curve/curve_msm.rs @@ -1,7 +1,7 @@ use alloc::vec::Vec; use itertools::Itertools; -use maybe_rayon::{MaybeIntoParIter, MaybeParChunks}; +use maybe_rayon::*; use plonky2::field::types::{Field, PrimeField}; use crate::curve::curve_summation::affine_multisummation_best; diff --git a/field/src/lib.rs b/field/src/lib.rs index 33db5c27..dd4fc433 100644 --- a/field/src/lib.rs +++ b/field/src/lib.rs @@ -7,7 +7,6 @@ #![allow(clippy::return_self_not_must_use)] #![feature(generic_const_exprs)] #![feature(specialization)] -#![feature(stdsimd)] #![cfg_attr(not(test), no_std)] extern crate alloc; diff --git a/insertion/src/insertion_gate.rs b/insertion/src/insertion_gate.rs index 5694c2b4..a476002b 100644 --- a/insertion/src/insertion_gate.rs +++ b/insertion/src/insertion_gate.rs @@ -1,5 +1,5 @@ -use std::marker::PhantomData; -use std::ops::Range; +use core::marker::PhantomData; +use core::ops::Range; use plonky2::field::extension::{Extendable, FieldExtension}; use plonky2::field::types::Field; diff --git a/maybe_rayon/Cargo.toml b/maybe_rayon/Cargo.toml index f8cc95fb..b3c1e78a 100644 --- a/maybe_rayon/Cargo.toml +++ b/maybe_rayon/Cargo.toml @@ -3,7 +3,6 @@ name = "maybe_rayon" version = "0.1.0" edition = "2021" -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [features] parallel = ["rayon"] diff --git a/maybe_rayon/src/lib.rs b/maybe_rayon/src/lib.rs index d24ba2e5..c4bfb2e9 100644 --- a/maybe_rayon/src/lib.rs +++ b/maybe_rayon/src/lib.rs @@ -1,13 +1,16 @@ #[cfg(not(feature = "parallel"))] -use std::{ +use core::{ iter::{FlatMap, IntoIterator, Iterator}, slice::{Chunks, ChunksExact, ChunksExactMut, ChunksMut}, }; #[cfg(feature = "parallel")] -pub use rayon::prelude::{ - IndexedParallelIterator, ParallelDrainFull, ParallelDrainRange, ParallelExtend, - ParallelIterator, +pub use rayon::{ + self, + prelude::{ + IndexedParallelIterator, ParallelDrainFull, ParallelDrainRange, ParallelExtend, + ParallelIterator, + }, }; #[cfg(feature = "parallel")] use rayon::{ diff --git a/plonky2/Cargo.toml b/plonky2/Cargo.toml index 25fe16c7..88217d2d 100644 --- a/plonky2/Cargo.toml +++ b/plonky2/Cargo.toml @@ -41,7 +41,6 @@ num_cpus = { version = "1.14.0", default-features = false } plonky2 = { path = "." } rand = { version = "0.8.4", default-features = false, features = ["getrandom"] } rand_chacha = { version = "0.3.1", default-features = false } -rayon = { version = "1.5.1", default-features = false } serde_cbor = { version = "0.11.2" } structopt = { version = "0.3.26", default-features = false } tynm = { version = "0.1.6", default-features = false } diff --git a/plonky2/benches/hashing.rs b/plonky2/benches/hashing.rs index fd2e0991..485a6361 100644 --- a/plonky2/benches/hashing.rs +++ b/plonky2/benches/hashing.rs @@ -1,6 +1,3 @@ -#![allow(incomplete_features)] -#![feature(generic_const_exprs)] - mod allocator; use criterion::{criterion_group, criterion_main, BatchSize, Criterion}; diff --git a/plonky2/benches/merkle.rs b/plonky2/benches/merkle.rs index 27f23966..f9bae127 100644 --- a/plonky2/benches/merkle.rs +++ b/plonky2/benches/merkle.rs @@ -1,6 +1,3 @@ -#![allow(incomplete_features)] -#![feature(generic_const_exprs)] - mod allocator; use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion}; @@ -14,10 +11,7 @@ use tynm::type_name; const ELEMS_PER_LEAF: usize = 135; -pub(crate) fn bench_merkle_tree>(c: &mut Criterion) -where - [(); H::HASH_SIZE]:, -{ +pub(crate) fn bench_merkle_tree>(c: &mut Criterion) { let mut group = c.benchmark_group(&format!( "merkle-tree<{}, {}>", type_name::(), diff --git a/plonky2/examples/bench_recursion.rs b/plonky2/examples/bench_recursion.rs index dc88f764..27101d1a 100644 --- a/plonky2/examples/bench_recursion.rs +++ b/plonky2/examples/bench_recursion.rs @@ -2,8 +2,6 @@ // custom CLI argument parsing (even with harness disabled). We could also have // put it in `src/bin/`, but then we wouldn't have access to // `[dev-dependencies]`. -#![allow(incomplete_features)] -#![feature(generic_const_exprs)] use core::num::ParseIntError; use core::ops::RangeInclusive; @@ -11,6 +9,7 @@ use core::str::FromStr; use anyhow::{anyhow, Context as _, Result}; use log::{info, Level, LevelFilter}; +use maybe_rayon::rayon; use plonky2::gates::noop::NoopGate; use plonky2::hash::hash_types::RichField; use plonky2::iop::witness::{PartialWitness, Witness}; @@ -18,7 +17,7 @@ use plonky2::plonk::circuit_builder::CircuitBuilder; use plonky2::plonk::circuit_data::{ CircuitConfig, CommonCircuitData, VerifierCircuitTarget, VerifierOnlyCircuitData, }; -use plonky2::plonk::config::{AlgebraicHasher, GenericConfig, Hasher, PoseidonGoldilocksConfig}; +use plonky2::plonk::config::{AlgebraicHasher, GenericConfig, PoseidonGoldilocksConfig}; use plonky2::plonk::proof::{CompressedProofWithPublicInputs, ProofWithPublicInputs}; use plonky2::plonk::prover::prove; use plonky2::util::timing::TimingTree; @@ -65,10 +64,7 @@ struct Options { fn dummy_proof, C: GenericConfig, const D: usize>( config: &CircuitConfig, log2_size: usize, -) -> Result> -where - [(); C::Hasher::HASH_SIZE]:, -{ +) -> Result> { // 'size' is in degree, but we want number of noop gates. A non-zero amount of padding will be added and size will be rounded to the next power of two. To hit our target size, we go just under the previous power of two and hope padding is less than half the proof. let num_dummy_gates = match log2_size { 0 => return Err(anyhow!("size must be at least 1")), @@ -106,7 +102,6 @@ fn recursive_proof< ) -> Result> where InnerC::Hasher: AlgebraicHasher, - [(); C::Hasher::HASH_SIZE]:, { let (inner_proof, inner_vd, inner_cd) = inner; let mut builder = CircuitBuilder::::new(config.clone()); @@ -150,10 +145,7 @@ fn test_serialization, C: GenericConfig, proof: &ProofWithPublicInputs, vd: &VerifierOnlyCircuitData, cd: &CommonCircuitData, -) -> Result<()> -where - [(); C::Hasher::HASH_SIZE]:, -{ +) -> Result<()> { let proof_bytes = proof.to_bytes(); info!("Proof length: {} bytes", proof_bytes.len()); let proof_from_bytes = ProofWithPublicInputs::from_bytes(proof_bytes, cd)?; diff --git a/starky/src/constraint_consumer.rs b/starky/src/constraint_consumer.rs index 1a061c20..4cd8c0cd 100644 --- a/starky/src/constraint_consumer.rs +++ b/starky/src/constraint_consumer.rs @@ -1,4 +1,4 @@ -use std::marker::PhantomData; +use core::marker::PhantomData; use plonky2::field::extension::Extendable; use plonky2::field::packed::PackedField; diff --git a/starky/src/fibonacci_stark.rs b/starky/src/fibonacci_stark.rs index b8c8c01e..260e2c54 100644 --- a/starky/src/fibonacci_stark.rs +++ b/starky/src/fibonacci_stark.rs @@ -1,4 +1,4 @@ -use std::marker::PhantomData; +use core::marker::PhantomData; use plonky2::field::extension::{Extendable, FieldExtension}; use plonky2::field::packed::PackedField; diff --git a/starky/src/prover.rs b/starky/src/prover.rs index c9191f1d..4d69e838 100644 --- a/starky/src/prover.rs +++ b/starky/src/prover.rs @@ -1,4 +1,4 @@ -use std::iter::once; +use core::iter::once; use anyhow::{ensure, Result}; use itertools::Itertools; diff --git a/starky/src/recursive_verifier.rs b/starky/src/recursive_verifier.rs index 04858d55..be3b6bc6 100644 --- a/starky/src/recursive_verifier.rs +++ b/starky/src/recursive_verifier.rs @@ -1,4 +1,4 @@ -use std::iter::once; +use core::iter::once; use anyhow::{ensure, Result}; use itertools::Itertools; diff --git a/starky/src/verifier.rs b/starky/src/verifier.rs index fe0e41d2..78c6b63e 100644 --- a/starky/src/verifier.rs +++ b/starky/src/verifier.rs @@ -1,4 +1,4 @@ -use std::iter::once; +use core::iter::once; use anyhow::{anyhow, ensure, Result}; use itertools::Itertools;