diff --git a/Cargo.toml b/Cargo.toml index 54eaaa3b1..f29445e5e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,7 +5,7 @@ members = [ "halo2_frontend", "halo2_middleware", "halo2_backend", - "halo2_test_utils", + "halo2_debug", "p3_frontend" ] resolver = "2" diff --git a/halo2_backend/Cargo.toml b/halo2_backend/Cargo.toml index d40fc1d9e..7f9982756 100644 --- a/halo2_backend/Cargo.toml +++ b/halo2_backend/Cargo.toml @@ -46,7 +46,7 @@ gumdrop = "0.8" proptest = "1" rand_core = { version = "0.6", default-features = false, features = ["getrandom"] } serde_json = "1" -halo2_test_utils = { path = "../halo2_test_utils" } +halo2_debug = { path = "../halo2_debug" } [target.'cfg(all(target_arch = "wasm32", target_os = "unknown"))'.dev-dependencies] getrandom = { version = "0.2", features = ["js"] } diff --git a/halo2_backend/src/arithmetic.rs b/halo2_backend/src/arithmetic.rs index f2c5034f4..5e7a38450 100644 --- a/halo2_backend/src/arithmetic.rs +++ b/halo2_backend/src/arithmetic.rs @@ -259,7 +259,7 @@ use halo2curves::pasta::Fp; #[test] fn test_lagrange_interpolate() { - use halo2_test_utils::test_rng; + use halo2_debug::test_rng; let rng = test_rng(); let points = (0..5).map(|_| Fp::random(rng)).collect::>(); diff --git a/halo2_backend/src/poly/domain.rs b/halo2_backend/src/poly/domain.rs index ba3b5bd4f..1da8a0360 100644 --- a/halo2_backend/src/poly/domain.rs +++ b/halo2_backend/src/poly/domain.rs @@ -478,7 +478,7 @@ pub struct PinnedEvaluationDomain<'a, F: Field> { #[test] fn test_rotate() { use crate::arithmetic::eval_polynomial; - use halo2_test_utils::test_rng; + use halo2_debug::test_rng; use halo2curves::pasta::pallas::Scalar; let domain = EvaluationDomain::::new(1, 3); @@ -518,7 +518,7 @@ fn test_rotate() { #[test] fn test_l_i() { use crate::arithmetic::{eval_polynomial, lagrange_interpolate}; - use halo2_test_utils::test_rng; + use halo2_debug::test_rng; use halo2curves::pasta::pallas::Scalar; let domain = EvaluationDomain::::new(1, 3); diff --git a/halo2_backend/src/poly/ipa/commitment.rs b/halo2_backend/src/poly/ipa/commitment.rs index 80a9c4a7b..05940b106 100644 --- a/halo2_backend/src/poly/ipa/commitment.rs +++ b/halo2_backend/src/poly/ipa/commitment.rs @@ -241,9 +241,9 @@ mod test { use crate::poly::ipa::msm::MSMIPA; use group::Curve; + use halo2_debug::test_rng; use halo2_middleware::ff::Field; use halo2_middleware::zal::impls::H2cEngine; - use halo2_test_utils::test_rng; #[test] fn test_commit_lagrange_epaffine() { diff --git a/halo2_backend/src/poly/ipa/msm.rs b/halo2_backend/src/poly/ipa/msm.rs index 77d4aa398..17e97151c 100644 --- a/halo2_backend/src/poly/ipa/msm.rs +++ b/halo2_backend/src/poly/ipa/msm.rs @@ -222,8 +222,8 @@ mod tests { commitment::{ParamsProver, MSM}, ipa::{commitment::ParamsIPA, msm::MSMIPA}, }; + use halo2_debug::test_rng; use halo2_middleware::zal::impls::H2cEngine; - use halo2_test_utils::test_rng; use halo2curves::{ pasta::{Ep, EpAffine, Fp, Fq}, CurveAffine, diff --git a/halo2_backend/src/poly/kzg/commitment.rs b/halo2_backend/src/poly/kzg/commitment.rs index 1236d5ac1..324a38050 100644 --- a/halo2_backend/src/poly/kzg/commitment.rs +++ b/halo2_backend/src/poly/kzg/commitment.rs @@ -453,9 +453,9 @@ mod test { use crate::poly::commitment::ParamsProver; use crate::poly::commitment::{Blind, Params}; use crate::poly::kzg::commitment::ParamsKZG; + use halo2_debug::test_rng; use halo2_middleware::ff::Field; use halo2_middleware::zal::impls::H2cEngine; - use halo2_test_utils::test_rng; #[test] fn test_commit_lagrange() { diff --git a/halo2_backend/src/poly/multiopen_test.rs b/halo2_backend/src/poly/multiopen_test.rs index adeec9663..58eff2702 100644 --- a/halo2_backend/src/poly/multiopen_test.rs +++ b/halo2_backend/src/poly/multiopen_test.rs @@ -15,9 +15,9 @@ mod test { TranscriptReadBuffer, TranscriptWriterBuffer, }; use group::Curve; + use halo2_debug::test_rng; use halo2_middleware::ff::WithSmallOrderMulGroup; use halo2_middleware::zal::{impls::H2cEngine, traits::MsmAccel}; - use halo2_test_utils::test_rng; #[test] fn test_roundtrip_ipa() { diff --git a/halo2_test_utils/Cargo.toml b/halo2_debug/Cargo.toml similarity index 63% rename from halo2_test_utils/Cargo.toml rename to halo2_debug/Cargo.toml index ac800ee7d..9e71ffdcc 100644 --- a/halo2_test_utils/Cargo.toml +++ b/halo2_debug/Cargo.toml @@ -1,25 +1,25 @@ [package] -name = "halo2_test_utils" +name = "halo2_debug" version = "0.3.0" authors = [ - "Sean Bowe ", - "Ying Tong Lai ", - "Daira Hopwood ", - "Jack Grigg ", "Privacy Scaling Explorations team", ] edition = "2021" rust-version = "1.66.0" description = """ -Fast PLONK-based zero-knowledge proving system with no trusted setup +Halo2 Debug. This package contains utilities for debugging and testing within +the halo2 ecosystem. """ license = "MIT OR Apache-2.0" repository = "https://github.com/privacy-scaling-explorations/halo2" documentation = "https://privacy-scaling-explorations.github.io/halo2/" -readme = "README.md" categories = ["cryptography"] keywords = ["halo", "proofs", "zkp", "zkSNARKs"] +[package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--cfg", "docsrs", "--html-in-header", "katex-header.html"] + [dependencies] tiny-keccak = { version = "2.0.2", features=["keccak"] } hex = "0.4.3" diff --git a/halo2_test_utils/src/lib.rs b/halo2_debug/src/lib.rs similarity index 100% rename from halo2_test_utils/src/lib.rs rename to halo2_debug/src/lib.rs diff --git a/halo2_frontend/Cargo.toml b/halo2_frontend/Cargo.toml index 3714c7dca..b5fc50ad0 100644 --- a/halo2_frontend/Cargo.toml +++ b/halo2_frontend/Cargo.toml @@ -60,7 +60,6 @@ bits = ["halo2curves/bits"] gadget-traces = ["backtrace"] thread-safe-region = [] circuit-params = [] -heap-profiling = [] cost-estimator = ["serde", "serde_derive"] derive_serde = ["halo2curves/derive_serde"] diff --git a/halo2_proofs/Cargo.toml b/halo2_proofs/Cargo.toml index c55eff45d..e7b20e012 100644 --- a/halo2_proofs/Cargo.toml +++ b/halo2_proofs/Cargo.toml @@ -44,7 +44,7 @@ harness = false halo2_middleware = { path = "../halo2_middleware" } halo2_backend = { path = "../halo2_backend" } halo2_frontend = { path = "../halo2_frontend" } -halo2_test_utils = { path = "../halo2_test_utils" } +halo2_debug = { path = "../halo2_debug" } halo2curves = { version = "0.6.1", default-features = false } rand_core = { version = "0.6", default-features = false, features = ["getrandom"] } plotters = { version = "0.3.0", default-features = false, optional = true } @@ -60,7 +60,6 @@ assert_matches = "1.5" criterion = "0.3" gumdrop = "0.8" proptest = "1" -dhat = "0.3.2" serde_json = "1" [target.'cfg(all(target_arch = "wasm32", target_os = "unknown"))'.dev-dependencies] @@ -82,7 +81,6 @@ thread-safe-region = ["halo2_frontend/thread-safe-region"] sanity-checks = ["halo2_backend/sanity-checks"] batch = ["rand_core/getrandom", "halo2_backend/batch"] circuit-params = ["halo2_frontend/circuit-params"] -heap-profiling = ["halo2_frontend/heap-profiling"] cost-estimator = ["halo2_frontend/cost-estimator"] derive_serde = ["halo2curves/derive_serde", "halo2_frontend/derive_serde", "halo2_backend/derive_serde"] diff --git a/halo2_proofs/benches/plonk.rs b/halo2_proofs/benches/plonk.rs index 2193ff91c..919766b97 100644 --- a/halo2_proofs/benches/plonk.rs +++ b/halo2_proofs/benches/plonk.rs @@ -2,11 +2,11 @@ extern crate criterion; use group::ff::Field; +use halo2_debug::test_rng; use halo2_proofs::circuit::{Cell, Layouter, SimpleFloorPlanner, Value}; use halo2_proofs::plonk::*; use halo2_proofs::poly::{commitment::ParamsProver, Rotation}; use halo2_proofs::transcript::{Blake2bRead, Blake2bWrite, Challenge255}; -use halo2_test_utils::test_rng; use halo2curves::pasta::{EqAffine, Fp}; use halo2_proofs::{ diff --git a/halo2_proofs/examples/circuit-layout.rs b/halo2_proofs/examples/circuit-layout.rs index 66e8b81c8..ad5629d80 100644 --- a/halo2_proofs/examples/circuit-layout.rs +++ b/halo2_proofs/examples/circuit-layout.rs @@ -295,7 +295,7 @@ impl Circuit for MyCircuit { fn main() { // Prepare the circuit you want to render. // You don't need to include any witness variables. - let a = Fp::random(halo2_test_utils::test_rng()); + let a = Fp::random(halo2_debug::test_rng()); let instance = Fp::one() + Fp::one(); let lookup_table = vec![instance, a, a, Fp::zero()]; let circuit: MyCircuit = MyCircuit { diff --git a/halo2_proofs/examples/two-chip.rs b/halo2_proofs/examples/two-chip.rs index 6a7744047..507bf920b 100644 --- a/halo2_proofs/examples/two-chip.rs +++ b/halo2_proofs/examples/two-chip.rs @@ -1,12 +1,12 @@ use std::marker::PhantomData; +use halo2_debug::test_rng; use halo2_proofs::{ arithmetic::Field, circuit::{AssignedCell, Chip, Layouter, Region, SimpleFloorPlanner, Value}, plonk::{Advice, Circuit, Column, ConstraintSystem, ErrorFront, Instance, Selector}, poly::Rotation, }; -use halo2_test_utils::test_rng; // ANCHOR: field-instructions /// A variable representing a number. diff --git a/halo2_proofs/src/plonk/prover.rs b/halo2_proofs/src/plonk/prover.rs index e2afcfd67..4362226da 100644 --- a/halo2_proofs/src/plonk/prover.rs +++ b/halo2_proofs/src/plonk/prover.rs @@ -108,8 +108,8 @@ fn test_create_proof() { }, transcript::{Blake2bWrite, Challenge255, TranscriptWriterBuffer}, }; + use halo2_debug::test_rng; use halo2_middleware::ff::Field; - use halo2_test_utils::test_rng; use halo2curves::bn256::Bn256; #[derive(Clone, Copy)] @@ -178,8 +178,8 @@ fn test_create_proof_custom() { }, transcript::{Blake2bWrite, Challenge255, TranscriptWriterBuffer}, }; + use halo2_debug::test_rng; use halo2_middleware::ff::Field; - use halo2_test_utils::test_rng; use halo2curves::bn256::Bn256; #[derive(Clone, Copy)] diff --git a/halo2_proofs/tests/compress_selectors.rs b/halo2_proofs/tests/compress_selectors.rs index 1d264f403..ae6b011c1 100644 --- a/halo2_proofs/tests/compress_selectors.rs +++ b/halo2_proofs/tests/compress_selectors.rs @@ -10,6 +10,7 @@ use halo2_proofs::poly::Rotation; use halo2_backend::transcript::{ Blake2bRead, Blake2bWrite, Challenge255, TranscriptReadBuffer, TranscriptWriterBuffer, }; +use halo2_debug::{assert_test_proof, one_rng}; use halo2_middleware::zal::impls::{H2cEngine, PlonkEngineConfig}; use halo2_proofs::arithmetic::Field; use halo2_proofs::plonk::{ @@ -19,7 +20,6 @@ use halo2_proofs::plonk::{ use halo2_proofs::poly::kzg::commitment::{KZGCommitmentScheme, ParamsKZG}; use halo2_proofs::poly::kzg::multiopen::{ProverSHPLONK, VerifierSHPLONK}; use halo2_proofs::poly::kzg::strategy::SingleStrategy; -use halo2_test_utils::{assert_test_proof, one_rng}; use halo2curves::bn256::{Bn256, Fr, G1Affine}; #[derive(Debug, Clone)] diff --git a/halo2_proofs/tests/frontend_backend_split.rs b/halo2_proofs/tests/frontend_backend_split.rs index fd757d5f4..bdfa6635c 100644 --- a/halo2_proofs/tests/frontend_backend_split.rs +++ b/halo2_proofs/tests/frontend_backend_split.rs @@ -1,10 +1,6 @@ #![allow(clippy::many_single_char_names)] #![allow(clippy::op_ref)] -#[cfg(feature = "heap-profiling")] -#[global_allocator] -static ALLOC: dhat::Alloc = dhat::Alloc; - use halo2_backend::{ plonk::{ keygen::{keygen_pk, keygen_vk}, @@ -15,6 +11,7 @@ use halo2_backend::{ Blake2bRead, Blake2bWrite, Challenge255, TranscriptReadBuffer, TranscriptWriterBuffer, }, }; +use halo2_debug::{assert_test_proof, one_rng}; use halo2_frontend::{ circuit::{ compile_circuit, AssignedCell, Layouter, Region, SimpleFloorPlanner, Value, @@ -28,7 +25,6 @@ use halo2_frontend::{ }, }; use halo2_middleware::{ff::Field, poly::Rotation}; -use halo2_test_utils::{assert_test_proof, one_rng}; use std::collections::HashMap; #[derive(Clone)] @@ -489,9 +485,6 @@ const WIDTH_FACTOR: usize = 1; #[test] fn test_mycircuit_full_legacy() { - #[cfg(all(feature = "heap-profiling", not(coverage)))] - let _profiler = dhat::Profiler::new_heap(); - use halo2_proofs::plonk::{ create_proof, keygen_pk as keygen_pk_legacy, keygen_vk as keygen_vk_legacy, }; @@ -555,9 +548,6 @@ fn test_mycircuit_full_legacy() { fn test_mycircuit_full_split() { use halo2_middleware::zal::impls::{H2cEngine, PlonkEngineConfig}; - #[cfg(all(feature = "heap-profiling", not(coverage)))] - let _profiler = dhat::Profiler::new_heap(); - let engine = PlonkEngineConfig::new() .set_curve::() .set_msm(H2cEngine::new()) diff --git a/halo2_proofs/tests/plonk_api.rs b/halo2_proofs/tests/plonk_api.rs index cf0a96b89..bcdfeabd3 100644 --- a/halo2_proofs/tests/plonk_api.rs +++ b/halo2_proofs/tests/plonk_api.rs @@ -3,6 +3,8 @@ use assert_matches::assert_matches; use ff::{FromUniformBytes, WithSmallOrderMulGroup}; +use halo2_debug::test_rng; +use halo2_debug::{assert_test_proof, one_rng}; use halo2_middleware::zal::{ impls::{PlonkEngine, PlonkEngineConfig}, traits::MsmAccel, @@ -22,8 +24,6 @@ use halo2_proofs::transcript::{ Blake2bRead, Blake2bWrite, Challenge255, EncodedChallenge, TranscriptReadBuffer, TranscriptWriterBuffer, }; -use halo2_test_utils::test_rng; -use halo2_test_utils::{assert_test_proof, one_rng}; use rand_core::RngCore; use std::marker::PhantomData; diff --git a/halo2_proofs/tests/serialization.rs b/halo2_proofs/tests/serialization.rs index 1a2d1e1fe..65421405b 100644 --- a/halo2_proofs/tests/serialization.rs +++ b/halo2_proofs/tests/serialization.rs @@ -4,6 +4,7 @@ use std::{ }; use ff::Field; +use halo2_debug::{assert_test_proof, one_rng}; use halo2_proofs::{ circuit::{Layouter, SimpleFloorPlanner, Value}, plonk::{ @@ -23,7 +24,6 @@ use halo2_proofs::{ }, SerdeFormat, }; -use halo2_test_utils::{assert_test_proof, one_rng}; use halo2curves::bn256::{Bn256, Fr, G1Affine}; #[derive(Clone, Copy)] diff --git a/halo2_proofs/tests/shuffle.rs b/halo2_proofs/tests/shuffle.rs index 97d8ce604..ee18a3e63 100644 --- a/halo2_proofs/tests/shuffle.rs +++ b/halo2_proofs/tests/shuffle.rs @@ -1,4 +1,5 @@ use ff::{BatchInvert, FromUniformBytes}; +use halo2_debug::{assert_test_proof, one_rng}; use halo2_proofs::{ arithmetic::{CurveAffine, Field}, circuit::{floor_planner::V1, Layouter, Value}, @@ -18,7 +19,6 @@ use halo2_proofs::{ Blake2bRead, Blake2bWrite, Challenge255, TranscriptReadBuffer, TranscriptWriterBuffer, }, }; -use halo2_test_utils::{assert_test_proof, one_rng}; use rand_chacha::ChaCha20Rng; use rand_core::{RngCore, SeedableRng}; use std::iter; diff --git a/halo2_proofs/tests/shuffle_api.rs b/halo2_proofs/tests/shuffle_api.rs index c405d23e3..951144fb8 100644 --- a/halo2_proofs/tests/shuffle_api.rs +++ b/halo2_proofs/tests/shuffle_api.rs @@ -1,6 +1,7 @@ use std::{marker::PhantomData, vec}; use ff::FromUniformBytes; +use halo2_debug::{assert_test_proof, one_rng}; use halo2_proofs::{ arithmetic::Field, circuit::{Layouter, SimpleFloorPlanner, Value}, @@ -22,7 +23,6 @@ use halo2_proofs::{ Blake2bRead, Blake2bWrite, Challenge255, TranscriptReadBuffer, TranscriptWriterBuffer, }, }; -use halo2_test_utils::{assert_test_proof, one_rng}; use halo2curves::{pasta::EqAffine, CurveAffine}; struct ShuffleChip { diff --git a/halo2_proofs/tests/vector-ops-unblinded.rs b/halo2_proofs/tests/vector-ops-unblinded.rs index 86fffb7c9..461a19293 100644 --- a/halo2_proofs/tests/vector-ops-unblinded.rs +++ b/halo2_proofs/tests/vector-ops-unblinded.rs @@ -4,6 +4,7 @@ use std::marker::PhantomData; use ff::FromUniformBytes; +use halo2_debug::{assert_test_proof, one_rng}; use halo2_proofs::{ arithmetic::{CurveAffine, Field}, circuit::{AssignedCell, Chip, Layouter, Region, SimpleFloorPlanner, Value}, @@ -21,7 +22,6 @@ use halo2_proofs::{ Blake2bRead, Blake2bWrite, Challenge255, TranscriptReadBuffer, TranscriptWriterBuffer, }, }; -use halo2_test_utils::{assert_test_proof, one_rng}; // ANCHOR: instructions trait NumericInstructions: Chip {