diff --git a/field/src/lib.rs b/field/src/lib.rs index d2fd5832b9..1531a47db2 100644 --- a/field/src/lib.rs +++ b/field/src/lib.rs @@ -1,8 +1,8 @@ #![allow(incomplete_features)] -#![allow(clippy::too_many_arguments)] -#![allow(clippy::type_complexity)] #![allow(clippy::len_without_is_empty)] #![allow(clippy::needless_range_loop)] +#![deny(rustdoc::broken_intra_doc_links)] +#![deny(missing_debug_implementations)] #![feature(specialization)] #![cfg_attr(not(test), no_std)] #![cfg(not(test))] diff --git a/field/src/types.rs b/field/src/types.rs index 646dff7358..b2e43667c7 100644 --- a/field/src/types.rs +++ b/field/src/types.rs @@ -563,7 +563,7 @@ pub trait PrimeField64: PrimeField + Field64 { } /// An iterator over the powers of a certain base element `b`: `b^0, b^1, b^2, ...`. -#[derive(Clone)] +#[derive(Clone, Debug)] pub struct Powers { base: F, current: F, diff --git a/field/src/zero_poly_coset.rs b/field/src/zero_poly_coset.rs index 53b66a75d4..9773552852 100644 --- a/field/src/zero_poly_coset.rs +++ b/field/src/zero_poly_coset.rs @@ -4,6 +4,7 @@ use crate::packed::PackedField; use crate::types::Field; /// Precomputations of the evaluation of `Z_H(X) = X^n - 1` on a coset `gK` with `H <= K`. +#[derive(Debug)] pub struct ZeroPolyOnCoset { /// `n = |H|`. n: F, diff --git a/plonky2/src/fri/structure.rs b/plonky2/src/fri/structure.rs index 81e462da5c..7a580e50c6 100644 --- a/plonky2/src/fri/structure.rs +++ b/plonky2/src/fri/structure.rs @@ -10,6 +10,7 @@ use crate::hash::hash_types::RichField; use crate::iop::ext_target::ExtensionTarget; /// Describes an instance of a FRI-based batch opening. +#[derive(Debug)] pub struct FriInstanceInfo, const D: usize> { /// The oracles involved, not counting oracles created during the commit phase. pub oracles: Vec, @@ -18,6 +19,7 @@ pub struct FriInstanceInfo, const D: usize> { } /// Describes an instance of a FRI-based batch opening. +#[derive(Debug)] pub struct FriInstanceInfoTarget { /// The oracles involved, not counting oracles created during the commit phase. pub oracles: Vec, @@ -25,19 +27,21 @@ pub struct FriInstanceInfoTarget { pub batches: Vec>, } -#[derive(Copy, Clone)] +#[derive(Copy, Clone, Debug)] pub struct FriOracleInfo { pub num_polys: usize, pub blinding: bool, } /// A batch of openings at a particular point. +#[derive(Debug)] pub struct FriBatchInfo, const D: usize> { pub point: F::Extension, pub polynomials: Vec, } /// A batch of openings at a particular point. +#[derive(Debug)] pub struct FriBatchInfoTarget { pub point: ExtensionTarget, pub polynomials: Vec, @@ -66,21 +70,25 @@ impl FriPolynomialInfo { } /// Opened values of each polynomial. +#[derive(Debug)] pub struct FriOpenings, const D: usize> { pub batches: Vec>, } /// Opened values of each polynomial that's opened at a particular point. +#[derive(Debug)] pub struct FriOpeningBatch, const D: usize> { pub values: Vec, } /// Opened values of each polynomial. +#[derive(Debug)] pub struct FriOpeningsTarget { pub batches: Vec>, } /// Opened values of each polynomial that's opened at a particular point. +#[derive(Debug)] pub struct FriOpeningBatchTarget { pub values: Vec>, } diff --git a/plonky2/src/gadgets/arithmetic.rs b/plonky2/src/gadgets/arithmetic.rs index 0e6806ffb0..e162f1116f 100644 --- a/plonky2/src/gadgets/arithmetic.rs +++ b/plonky2/src/gadgets/arithmetic.rs @@ -424,7 +424,7 @@ impl, const D: usize> SimpleGenerator for Equ } /// Represents a base arithmetic operation in the circuit. Used to memoize results. -#[derive(Copy, Clone, Eq, PartialEq, Hash)] +#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)] pub(crate) struct BaseArithmeticOperation { const_0: F, const_1: F, diff --git a/plonky2/src/gadgets/arithmetic_extension.rs b/plonky2/src/gadgets/arithmetic_extension.rs index 649f4082ec..afea71df39 100644 --- a/plonky2/src/gadgets/arithmetic_extension.rs +++ b/plonky2/src/gadgets/arithmetic_extension.rs @@ -545,7 +545,7 @@ impl, const D: usize> SimpleGenerator } /// An iterator over the powers of a certain base element `b`: `b^0, b^1, b^2, ...`. -#[derive(Clone)] +#[derive(Clone, Debug)] pub struct PowersTarget { base: ExtensionTarget, current: ExtensionTarget, @@ -584,7 +584,7 @@ impl, const D: usize> CircuitBuilder { } /// Represents an extension arithmetic operation in the circuit. Used to memoize results. -#[derive(Copy, Clone, Eq, PartialEq, Hash)] +#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)] pub(crate) struct ExtensionArithmeticOperation, const D: usize> { const_0: F, const_1: F, diff --git a/plonky2/src/gadgets/polynomial.rs b/plonky2/src/gadgets/polynomial.rs index 94fbe3b1c6..f10f25312a 100644 --- a/plonky2/src/gadgets/polynomial.rs +++ b/plonky2/src/gadgets/polynomial.rs @@ -40,6 +40,7 @@ impl PolynomialCoeffsExtTarget { } } +#[derive(Debug)] pub struct PolynomialCoeffsExtAlgebraTarget(pub Vec>); impl PolynomialCoeffsExtAlgebraTarget { diff --git a/plonky2/src/gates/arithmetic_base.rs b/plonky2/src/gates/arithmetic_base.rs index 754895790a..ab3ac0bd57 100644 --- a/plonky2/src/gates/arithmetic_base.rs +++ b/plonky2/src/gates/arithmetic_base.rs @@ -44,16 +44,16 @@ impl ArithmeticGate { config.num_routed_wires / wires_per_op } - pub const fn wire_ith_multiplicand_0(i: usize) -> usize { + pub(crate) const fn wire_ith_multiplicand_0(i: usize) -> usize { 4 * i } - pub const fn wire_ith_multiplicand_1(i: usize) -> usize { + pub(crate) const fn wire_ith_multiplicand_1(i: usize) -> usize { 4 * i + 1 } - pub const fn wire_ith_addend(i: usize) -> usize { + pub(crate) const fn wire_ith_addend(i: usize) -> usize { 4 * i + 2 } - pub const fn wire_ith_output(i: usize) -> usize { + pub(crate) const fn wire_ith_output(i: usize) -> usize { 4 * i + 3 } } diff --git a/plonky2/src/gates/arithmetic_extension.rs b/plonky2/src/gates/arithmetic_extension.rs index 60eb912b61..e549f97045 100644 --- a/plonky2/src/gates/arithmetic_extension.rs +++ b/plonky2/src/gates/arithmetic_extension.rs @@ -40,16 +40,16 @@ impl ArithmeticExtensionGate { config.num_routed_wires / wires_per_op } - pub const fn wires_ith_multiplicand_0(i: usize) -> Range { + pub(crate) const fn wires_ith_multiplicand_0(i: usize) -> Range { 4 * D * i..4 * D * i + D } - pub const fn wires_ith_multiplicand_1(i: usize) -> Range { + pub(crate) const fn wires_ith_multiplicand_1(i: usize) -> Range { 4 * D * i + D..4 * D * i + 2 * D } - pub const fn wires_ith_addend(i: usize) -> Range { + pub(crate) const fn wires_ith_addend(i: usize) -> Range { 4 * D * i + 2 * D..4 * D * i + 3 * D } - pub const fn wires_ith_output(i: usize) -> Range { + pub(crate) const fn wires_ith_output(i: usize) -> Range { 4 * D * i + 3 * D..4 * D * i + 4 * D } } diff --git a/plonky2/src/gates/base_sum.rs b/plonky2/src/gates/base_sum.rs index 0f38415d4e..a169aa170a 100644 --- a/plonky2/src/gates/base_sum.rs +++ b/plonky2/src/gates/base_sum.rs @@ -40,11 +40,11 @@ impl BaseSumGate { Self::new(num_limbs) } - pub const WIRE_SUM: usize = 0; - pub const START_LIMBS: usize = 1; + pub(crate) const WIRE_SUM: usize = 0; + pub(crate) const START_LIMBS: usize = 1; /// Returns the index of the `i`th limb wire. - pub const fn limbs(&self) -> Range { + pub(crate) const fn limbs(&self) -> Range { Self::START_LIMBS..Self::START_LIMBS + self.num_limbs } } diff --git a/plonky2/src/gates/constant.rs b/plonky2/src/gates/constant.rs index cc62de7fe4..cbbcae37fd 100644 --- a/plonky2/src/gates/constant.rs +++ b/plonky2/src/gates/constant.rs @@ -30,12 +30,12 @@ impl ConstantGate { Self { num_consts } } - pub fn const_input(&self, i: usize) -> usize { + const fn const_input(&self, i: usize) -> usize { debug_assert!(i < self.num_consts); i } - pub fn wire_output(&self, i: usize) -> usize { + const fn wire_output(&self, i: usize) -> usize { debug_assert!(i < self.num_consts); i } diff --git a/plonky2/src/gates/coset_interpolation.rs b/plonky2/src/gates/coset_interpolation.rs index a1ebd214a4..eb133f173a 100644 --- a/plonky2/src/gates/coset_interpolation.rs +++ b/plonky2/src/gates/coset_interpolation.rs @@ -141,31 +141,31 @@ impl, const D: usize> CosetInterpolationGate self.start_intermediates() } - fn num_intermediates(&self) -> usize { - (self.num_points() - 2) / (self.degree() - 1) + const fn num_intermediates(&self) -> usize { + (self.num_points() - 2) / (self.degree - 1) } /// The wires corresponding to the i'th intermediate evaluation. - fn wires_intermediate_eval(&self, i: usize) -> Range { + const fn wires_intermediate_eval(&self, i: usize) -> Range { debug_assert!(i < self.num_intermediates()); let start = self.start_intermediates() + D * i; start..start + D } /// The wires corresponding to the i'th intermediate product. - fn wires_intermediate_prod(&self, i: usize) -> Range { + const fn wires_intermediate_prod(&self, i: usize) -> Range { debug_assert!(i < self.num_intermediates()); let start = self.start_intermediates() + D * (self.num_intermediates() + i); start..start + D } /// End of wire indices, exclusive. - fn end(&self) -> usize { + const fn end(&self) -> usize { self.start_intermediates() + D * (2 * self.num_intermediates() + 1) } /// Wire indices of the shifted point to evaluate the interpolant at. - fn wires_shifted_evaluation_point(&self) -> Range { + const fn wires_shifted_evaluation_point(&self) -> Range { let start = self.start_intermediates() + D * 2 * self.num_intermediates(); start..start + D } diff --git a/plonky2/src/gates/exponentiation.rs b/plonky2/src/gates/exponentiation.rs index 2b7164e1d2..aab9322db4 100644 --- a/plonky2/src/gates/exponentiation.rs +++ b/plonky2/src/gates/exponentiation.rs @@ -55,12 +55,12 @@ impl, const D: usize> ExponentiationGate { max_for_routed_wires.min(max_for_wires) } - pub const fn wire_base(&self) -> usize { + pub(crate) const fn wire_base(&self) -> usize { 0 } /// The `i`th bit of the exponent, in little-endian order. - pub fn wire_power_bit(&self, i: usize) -> usize { + pub(crate) const fn wire_power_bit(&self, i: usize) -> usize { debug_assert!(i < self.num_power_bits); 1 + i } @@ -69,7 +69,7 @@ impl, const D: usize> ExponentiationGate { 1 + self.num_power_bits } - pub fn wire_intermediate_value(&self, i: usize) -> usize { + pub(crate) const fn wire_intermediate_value(&self, i: usize) -> usize { debug_assert!(i < self.num_power_bits); 2 + self.num_power_bits + i } diff --git a/plonky2/src/gates/gate.rs b/plonky2/src/gates/gate.rs index 07de4fa33b..9bc8d1dcad 100644 --- a/plonky2/src/gates/gate.rs +++ b/plonky2/src/gates/gate.rs @@ -309,7 +309,7 @@ pub struct CurrentSlot, const D: usize> { } /// A gate along with any constants used to configure it. -#[derive(Clone)] +#[derive(Clone, Debug)] pub struct GateInstance, const D: usize> { pub gate_ref: GateRef, pub constants: Vec, diff --git a/plonky2/src/gates/multiplication_extension.rs b/plonky2/src/gates/multiplication_extension.rs index 143c854c66..633a4b21ca 100644 --- a/plonky2/src/gates/multiplication_extension.rs +++ b/plonky2/src/gates/multiplication_extension.rs @@ -40,13 +40,13 @@ impl MulExtensionGate { config.num_routed_wires / wires_per_op } - pub const fn wires_ith_multiplicand_0(i: usize) -> Range { + pub(crate) const fn wires_ith_multiplicand_0(i: usize) -> Range { 3 * D * i..3 * D * i + D } - pub const fn wires_ith_multiplicand_1(i: usize) -> Range { + pub(crate) const fn wires_ith_multiplicand_1(i: usize) -> Range { 3 * D * i + D..3 * D * i + 2 * D } - pub const fn wires_ith_output(i: usize) -> Range { + pub(crate) const fn wires_ith_output(i: usize) -> Range { 3 * D * i + 2 * D..3 * D * i + 3 * D } } diff --git a/plonky2/src/gates/noop.rs b/plonky2/src/gates/noop.rs index 54cb6422ef..f2387f6bc9 100644 --- a/plonky2/src/gates/noop.rs +++ b/plonky2/src/gates/noop.rs @@ -12,6 +12,7 @@ use crate::plonk::vars::{EvaluationTargets, EvaluationVars, EvaluationVarsBaseBa use crate::util::serialization::{Buffer, IoResult}; /// A gate which does nothing. +#[derive(Debug)] pub struct NoopGate; impl, const D: usize> Gate for NoopGate { diff --git a/plonky2/src/gates/poseidon.rs b/plonky2/src/gates/poseidon.rs index be9a064e43..fa880753ae 100644 --- a/plonky2/src/gates/poseidon.rs +++ b/plonky2/src/gates/poseidon.rs @@ -39,23 +39,23 @@ impl, const D: usize> PoseidonGate { } /// The wire index for the `i`th input to the permutation. - pub const fn wire_input(i: usize) -> usize { + pub(crate) const fn wire_input(i: usize) -> usize { i } /// The wire index for the `i`th output to the permutation. - pub const fn wire_output(i: usize) -> usize { + pub(crate) const fn wire_output(i: usize) -> usize { SPONGE_WIDTH + i } /// If this is set to 1, the first four inputs will be swapped with the next four inputs. This /// is useful for ordering hashes in Merkle proofs. Otherwise, this should be set to 0. - pub const WIRE_SWAP: usize = 2 * SPONGE_WIDTH; + pub(crate) const WIRE_SWAP: usize = 2 * SPONGE_WIDTH; const START_DELTA: usize = 2 * SPONGE_WIDTH + 1; /// A wire which stores `swap * (input[i + 4] - input[i])`; used to compute the swapped inputs. - fn wire_delta(i: usize) -> usize { + const fn wire_delta(i: usize) -> usize { assert!(i < 4); Self::START_DELTA + i } @@ -64,7 +64,7 @@ impl, const D: usize> PoseidonGate { /// A wire which stores the input of the `i`-th S-box of the `round`-th round of the first set /// of full rounds. - fn wire_full_sbox_0(round: usize, i: usize) -> usize { + const fn wire_full_sbox_0(round: usize, i: usize) -> usize { debug_assert!( round != 0, "First round S-box inputs are not stored as wires" @@ -78,7 +78,7 @@ impl, const D: usize> PoseidonGate { Self::START_FULL_0 + SPONGE_WIDTH * (poseidon::HALF_N_FULL_ROUNDS - 1); /// A wire which stores the input of the S-box of the `round`-th round of the partial rounds. - fn wire_partial_sbox(round: usize) -> usize { + const fn wire_partial_sbox(round: usize) -> usize { debug_assert!(round < poseidon::N_PARTIAL_ROUNDS); Self::START_PARTIAL + round } @@ -87,7 +87,7 @@ impl, const D: usize> PoseidonGate { /// A wire which stores the input of the `i`-th S-box of the `round`-th round of the second set /// of full rounds. - fn wire_full_sbox_1(round: usize, i: usize) -> usize { + const fn wire_full_sbox_1(round: usize, i: usize) -> usize { debug_assert!(round < poseidon::HALF_N_FULL_ROUNDS); debug_assert!(i < SPONGE_WIDTH); Self::START_FULL_1 + SPONGE_WIDTH * round + i diff --git a/plonky2/src/gates/poseidon_mds.rs b/plonky2/src/gates/poseidon_mds.rs index 9bd37e5e40..b692e2834e 100644 --- a/plonky2/src/gates/poseidon_mds.rs +++ b/plonky2/src/gates/poseidon_mds.rs @@ -33,12 +33,12 @@ impl + Poseidon, const D: usize> PoseidonMdsGate Range { + pub(crate) const fn wires_input(i: usize) -> Range { assert!(i < SPONGE_WIDTH); i * D..(i + 1) * D } - pub fn wires_output(i: usize) -> Range { + pub(crate) const fn wires_output(i: usize) -> Range { assert!(i < SPONGE_WIDTH); (SPONGE_WIDTH + i) * D..(SPONGE_WIDTH + i + 1) * D } diff --git a/plonky2/src/gates/public_input.rs b/plonky2/src/gates/public_input.rs index 3a754c7c91..e066e45e6e 100644 --- a/plonky2/src/gates/public_input.rs +++ b/plonky2/src/gates/public_input.rs @@ -19,10 +19,11 @@ use crate::plonk::vars::{ use crate::util::serialization::{Buffer, IoResult}; /// A gate whose first four wires will be equal to a hash of public inputs. +#[derive(Debug)] pub struct PublicInputGate; impl PublicInputGate { - pub const fn wires_public_inputs_hash() -> Range { + pub(crate) const fn wires_public_inputs_hash() -> Range { 0..4 } } diff --git a/plonky2/src/gates/random_access.rs b/plonky2/src/gates/random_access.rs index 086b119a5e..24abb58837 100644 --- a/plonky2/src/gates/random_access.rs +++ b/plonky2/src/gates/random_access.rs @@ -80,19 +80,19 @@ impl, const D: usize> RandomAccessGate { } /// For each copy, a wire containing the claimed index of the element. - pub fn wire_access_index(&self, copy: usize) -> usize { + pub(crate) const fn wire_access_index(&self, copy: usize) -> usize { debug_assert!(copy < self.num_copies); (2 + self.vec_size()) * copy } /// For each copy, a wire containing the element claimed to be at the index. - pub fn wire_claimed_element(&self, copy: usize) -> usize { + pub(crate) const fn wire_claimed_element(&self, copy: usize) -> usize { debug_assert!(copy < self.num_copies); (2 + self.vec_size()) * copy + 1 } /// For each copy, wires containing the entire list. - pub fn wire_list_item(&self, i: usize, copy: usize) -> usize { + pub(crate) const fn wire_list_item(&self, i: usize, copy: usize) -> usize { debug_assert!(i < self.vec_size()); debug_assert!(copy < self.num_copies); (2 + self.vec_size()) * copy + 2 + i @@ -102,7 +102,7 @@ impl, const D: usize> RandomAccessGate { (2 + self.vec_size()) * self.num_copies } - fn wire_extra_constant(&self, i: usize) -> usize { + const fn wire_extra_constant(&self, i: usize) -> usize { debug_assert!(i < self.num_extra_constants); self.start_extra_constants() + i } @@ -114,7 +114,7 @@ impl, const D: usize> RandomAccessGate { /// An intermediate wire where the prover gives the (purported) binary decomposition of the /// index. - pub fn wire_bit(&self, i: usize, copy: usize) -> usize { + pub(crate) const fn wire_bit(&self, i: usize, copy: usize) -> usize { debug_assert!(i < self.bits); debug_assert!(copy < self.num_copies); self.num_routed_wires() + copy * self.bits + i diff --git a/plonky2/src/gates/reducing.rs b/plonky2/src/gates/reducing.rs index 5e0fc9f473..0030550514 100644 --- a/plonky2/src/gates/reducing.rs +++ b/plonky2/src/gates/reducing.rs @@ -35,17 +35,17 @@ impl ReducingGate { (num_routed_wires - 3 * D).min((num_wires - 2 * D) / (D + 1)) } - pub const fn wires_output() -> Range { + pub(crate) const fn wires_output() -> Range { 0..D } - pub const fn wires_alpha() -> Range { + pub(crate) const fn wires_alpha() -> Range { D..2 * D } - pub const fn wires_old_acc() -> Range { + pub(crate) const fn wires_old_acc() -> Range { 2 * D..3 * D } const START_COEFFS: usize = 3 * D; - pub const fn wires_coeffs(&self) -> Range { + pub(crate) const fn wires_coeffs(&self) -> Range { Self::START_COEFFS..Self::START_COEFFS + self.num_coeffs } const fn start_accs(&self) -> usize { diff --git a/plonky2/src/gates/reducing_extension.rs b/plonky2/src/gates/reducing_extension.rs index 0ac3d9fd77..3b7bc9e26c 100644 --- a/plonky2/src/gates/reducing_extension.rs +++ b/plonky2/src/gates/reducing_extension.rs @@ -37,23 +37,23 @@ impl ReducingExtensionGate { ((num_routed_wires - 3 * D) / D).min((num_wires - 2 * D) / (D * 2)) } - pub const fn wires_output() -> Range { + pub(crate) const fn wires_output() -> Range { 0..D } - pub const fn wires_alpha() -> Range { + pub(crate) const fn wires_alpha() -> Range { D..2 * D } - pub const fn wires_old_acc() -> Range { + pub(crate) const fn wires_old_acc() -> Range { 2 * D..3 * D } const START_COEFFS: usize = 3 * D; - pub const fn wires_coeff(i: usize) -> Range { + pub(crate) const fn wires_coeff(i: usize) -> Range { Self::START_COEFFS + i * D..Self::START_COEFFS + (i + 1) * D } const fn start_accs(&self) -> usize { Self::START_COEFFS + self.num_coeffs * D } - fn wires_accs(&self, i: usize) -> Range { + const fn wires_accs(&self, i: usize) -> Range { debug_assert!(i < self.num_coeffs); if i == self.num_coeffs - 1 { // The last accumulator is the output. diff --git a/plonky2/src/gates/util.rs b/plonky2/src/gates/util.rs index 88d77471ee..bd5c0fee9c 100644 --- a/plonky2/src/gates/util.rs +++ b/plonky2/src/gates/util.rs @@ -6,6 +6,7 @@ use crate::field::packed::PackedField; /// Permits us to abstract the underlying memory layout. In particular, we can make a matrix of /// constraints where every column is an evaluation point and every row is a constraint index, with /// the matrix stored in row-contiguous form. +#[derive(Debug)] pub struct StridedConstraintConsumer<'a, P: PackedField> { // This is a particularly neat way of doing this, more so than a slice. We increase start by // stride at every step and terminate when it equals end. diff --git a/plonky2/src/iop/challenger.rs b/plonky2/src/iop/challenger.rs index 2daa7fdc4f..57660fd487 100644 --- a/plonky2/src/iop/challenger.rs +++ b/plonky2/src/iop/challenger.rs @@ -12,7 +12,7 @@ use crate::plonk::circuit_builder::CircuitBuilder; use crate::plonk::config::{AlgebraicHasher, GenericHashOut, Hasher}; /// Observes prover messages, and generates challenges by hashing the transcript, a la Fiat-Shamir. -#[derive(Clone)] +#[derive(Clone, Debug)] pub struct Challenger> { pub(crate) sponge_state: H::Permutation, pub(crate) input_buffer: Vec, @@ -161,6 +161,7 @@ impl> Default for Challenger { /// A recursive version of `Challenger`. The main difference is that `RecursiveChallenger`'s input /// buffer can grow beyond `H::Permutation::RATE`. This is so that `observe_element` etc do not need access /// to the `CircuitBuilder`. +#[derive(Debug)] pub struct RecursiveChallenger, H: AlgebraicHasher, const D: usize> { sponge_state: H::AlgebraicPermutation, diff --git a/plonky2/src/lib.rs b/plonky2/src/lib.rs index b0b6bfb4d9..8955194fc5 100644 --- a/plonky2/src/lib.rs +++ b/plonky2/src/lib.rs @@ -1,5 +1,7 @@ #![allow(clippy::too_many_arguments)] #![allow(clippy::needless_range_loop)] +#![deny(rustdoc::broken_intra_doc_links)] +#![deny(missing_debug_implementations)] #![cfg_attr(not(feature = "std"), no_std)] #[cfg(not(feature = "std"))] diff --git a/plonky2/src/plonk/circuit_builder.rs b/plonky2/src/plonk/circuit_builder.rs index b9c13f8147..de3ab16fdf 100644 --- a/plonky2/src/plonk/circuit_builder.rs +++ b/plonky2/src/plonk/circuit_builder.rs @@ -63,6 +63,7 @@ pub const NUM_COINS_LOOKUP: usize = 4; /// `ChallengeB` is used for the linear combination of input and output pairs in the polynomial RE. /// `ChallengeAlpha` is used for the running sums: 1/(alpha - combo_i). /// `ChallengeDelta` is a challenge on which to evaluate the interpolated LUT function. +#[derive(Debug)] pub enum LookupChallenges { ChallengeA = 0, ChallengeB = 1, @@ -135,6 +136,7 @@ pub struct LookupWire { /// // Verify the proof /// assert!(circuit_data.verify(proof).is_ok()); /// ``` +#[derive(Debug)] pub struct CircuitBuilder, const D: usize> { /// Circuit configuration to be used by this [`CircuitBuilder`]. pub config: CircuitConfig, diff --git a/plonky2/src/plonk/circuit_data.rs b/plonky2/src/plonk/circuit_data.rs index e4afb5680d..413de54c6e 100644 --- a/plonky2/src/plonk/circuit_data.rs +++ b/plonky2/src/plonk/circuit_data.rs @@ -252,6 +252,7 @@ impl, C: GenericConfig, const D: usize> /// structure as succinct as we can. Thus we include various precomputed data which isn't strictly /// required, like LDEs of preprocessed polynomials. If more succinctness was desired, we could /// construct a more minimal prover structure and convert back and forth. +#[derive(Debug)] pub struct ProverCircuitData< F: RichField + Extendable, C: GenericConfig, diff --git a/plonky2/src/plonk/copy_constraint.rs b/plonky2/src/plonk/copy_constraint.rs index cf7a6a19ac..309f207d8b 100644 --- a/plonky2/src/plonk/copy_constraint.rs +++ b/plonky2/src/plonk/copy_constraint.rs @@ -4,6 +4,7 @@ use alloc::string::String; use crate::iop::target::Target; /// A named copy constraint. +#[derive(Debug)] pub struct CopyConstraint { pub pair: (Target, Target), pub name: String, diff --git a/plonky2/src/plonk/proof.rs b/plonky2/src/plonk/proof.rs index a9151a9fc1..8cb8911a52 100644 --- a/plonky2/src/plonk/proof.rs +++ b/plonky2/src/plonk/proof.rs @@ -256,6 +256,7 @@ impl, C: GenericConfig, const D: usize> } } +#[derive(Debug)] pub struct ProofChallenges, const D: usize> { /// Random values used in Plonk's permutation argument. pub plonk_betas: Vec, diff --git a/plonky2/src/plonk/vars.rs b/plonky2/src/plonk/vars.rs index b9d6d790ff..6cffc45c80 100644 --- a/plonky2/src/plonk/vars.rs +++ b/plonky2/src/plonk/vars.rs @@ -132,6 +132,7 @@ impl<'a, F: Field> EvaluationVarsBase<'a, F> { } /// Iterator of views (`EvaluationVarsBase`) into a `EvaluationVarsBaseBatch`. +#[derive(Debug)] pub struct EvaluationVarsBaseBatchIter<'a, F: Field> { i: usize, vars_batch: EvaluationVarsBaseBatch<'a, F>, @@ -159,6 +160,7 @@ impl<'a, F: Field> Iterator for EvaluationVarsBaseBatchIter<'a, F> { /// Iterator of packed views (`EvaluationVarsBasePacked`) into a `EvaluationVarsBaseBatch`. /// Note: if the length of `EvaluationVarsBaseBatch` is not a multiple of `P::WIDTH`, then the /// leftovers at the end are ignored. +#[derive(Debug)] pub struct EvaluationVarsBaseBatchIterPacked<'a, P: PackedField> { /// Index to yield next, in units of `P::Scalar`. E.g. if `P::WIDTH == 4`, then we will yield /// the vars for points `i`, `i + 1`, `i + 2`, and `i + 3`, packed. @@ -219,7 +221,7 @@ impl<'a, const D: usize> EvaluationTargets<'a, D> { } } -#[derive(Copy, Clone)] +#[derive(Copy, Clone, Debug)] pub struct EvaluationTargets<'a, const D: usize> { pub local_constants: &'a [ExtensionTarget], pub local_wires: &'a [ExtensionTarget], diff --git a/plonky2/src/util/context_tree.rs b/plonky2/src/util/context_tree.rs index 2e70fd61ca..f3ba5b7282 100644 --- a/plonky2/src/util/context_tree.rs +++ b/plonky2/src/util/context_tree.rs @@ -8,6 +8,7 @@ use alloc::{ use log::{log, Level}; /// The hierarchy of contexts, and the gate count contributed by each one. Useful for debugging. +#[derive(Debug)] pub(crate) struct ContextTree { /// The name of this scope. name: String, diff --git a/plonky2/src/util/serialization/gate_serialization.rs b/plonky2/src/util/serialization/gate_serialization.rs index c26e60d3f2..f7880f8365 100644 --- a/plonky2/src/util/serialization/gate_serialization.rs +++ b/plonky2/src/util/serialization/gate_serialization.rs @@ -113,7 +113,6 @@ pub mod default { use crate::gates::reducing_extension::ReducingExtensionGate; use crate::hash::hash_types::RichField; use crate::util::serialization::GateSerializer; - /// A gate serializer that can be used to serialize all default gates supported /// by the `plonky2` library. /// Being a unit struct, it can be simply called as @@ -123,6 +122,7 @@ pub mod default { /// ``` /// Applications using custom gates should define their own serializer implementing /// the `GateSerializer` trait. This can be easily done through the `impl_gate_serializer` macro. + #[derive(Debug)] pub struct DefaultGateSerializer; impl, const D: usize> GateSerializer for DefaultGateSerializer { impl_gate_serializer! { diff --git a/plonky2/src/util/serialization/generator_serialization.rs b/plonky2/src/util/serialization/generator_serialization.rs index 15bae9acd1..527d8b4f6f 100644 --- a/plonky2/src/util/serialization/generator_serialization.rs +++ b/plonky2/src/util/serialization/generator_serialization.rs @@ -140,7 +140,7 @@ pub mod default { /// Applications using custom generators should define their own serializer implementing /// the `WitnessGeneratorSerializer` trait. This can be easily done through the /// `impl_generator_serializer` macro. - #[derive(Default)] + #[derive(Debug, Default)] pub struct DefaultGeneratorSerializer, const D: usize> { pub _phantom: PhantomData, } diff --git a/plonky2/src/util/timing.rs b/plonky2/src/util/timing.rs index 0ab721be52..f5c8f1763a 100644 --- a/plonky2/src/util/timing.rs +++ b/plonky2/src/util/timing.rs @@ -4,6 +4,7 @@ use web_time::{Duration, Instant}; /// The hierarchy of scopes, and the time consumed by each one. Useful for profiling. #[cfg(feature = "timing")] +#[derive(Debug)] pub struct TimingTree { /// The name of this scope. name: String, @@ -18,6 +19,7 @@ pub struct TimingTree { } #[cfg(not(feature = "timing"))] +#[derive(Debug)] pub struct TimingTree(Level); #[cfg(feature = "timing")]