Skip to content

Commit

Permalink
tmp: Panic in tests.. Fixing
Browse files Browse the repository at this point in the history
  • Loading branch information
CPerezz committed Feb 7, 2024
1 parent 7fefc24 commit 116fc20
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 8 deletions.
10 changes: 6 additions & 4 deletions halo2_backend/src/plonk/evaluation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ impl ValueSource {
rotations: &[usize],
constants: &[F],
intermediates: &[F],
// Why Option??
// TODO: Why Option??
fixed_values: &[Option<Polynomial<F, B>>],
advice_values: &[Option<Polynomial<F, B>>],
instance_values: &[Option<Polynomial<F, B>>],
Expand All @@ -72,15 +72,15 @@ impl ValueSource {
ValueSource::Constant(idx) => constants[*idx],
ValueSource::Intermediate(idx) => intermediates[*idx],
ValueSource::Fixed(column_index, rotation) => {
assert!(fixed_values[*column_index].is_some());
// assert!(fixed_values[*column_index].is_some());
fixed_values[*column_index].as_ref().unwrap()[rotations[*rotation]]
}
ValueSource::Advice(column_index, rotation) => {
assert!(advice_values[*column_index].is_some());
// assert!(advice_values[*column_index].is_some());
advice_values[*column_index].as_ref().unwrap()[rotations[*rotation]]
}
ValueSource::Instance(column_index, rotation) => {
assert!(advice_values[*column_index].is_some());
// assert!(advice_values[*column_index].is_some());
instance_values[*column_index].as_ref().unwrap()[rotations[*rotation]]
}
ValueSource::Challenge(index) => challenges[*index],
Expand Down Expand Up @@ -1192,6 +1192,7 @@ pub fn evaluate<F: Field, B: Basis>(
) -> Vec<F> {
let mut values = vec![F::ZERO; size];
let isize = size as i32;
println!("Hello!");
parallelize(&mut values, |values, start| {
for (i, value) in values.iter_mut().enumerate() {
let idx = start + i;
Expand All @@ -1218,5 +1219,6 @@ pub fn evaluate<F: Field, B: Basis>(
);
}
});
println!("Hello!");
values
}
2 changes: 2 additions & 0 deletions halo2_proofs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ gumdrop = "0.8"
proptest = "1"
dhat = "0.3.2"
serde_json = "1"
# timer
ark-std = { version = "0.4", features = ["print-trace"] }

[target.'cfg(all(target_arch = "wasm32", target_os = "unknown"))'.dev-dependencies]
getrandom = { version = "0.2", features = ["js"] }
Expand Down
13 changes: 10 additions & 3 deletions halo2_proofs/tests/plonk_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use std::marker::PhantomData;

#[test]
fn plonk_api() {
const K: u32 = 5;
const K: u32 = 18;

/// This represents an advice column at a certain row in the ConstraintSystem
#[derive(Copy, Clone, Debug)]
Expand Down Expand Up @@ -374,7 +374,7 @@ fn plonk_api() {

let _ = cs.public_input(&mut layouter, || Value::known(F::ONE + F::ONE))?;

for _ in 0..10 {
for _ in 0..1 << K - 2 {

Check warning on line 377 in halo2_proofs/tests/plonk_api.rs

View workflow job for this annotation

GitHub Actions / Clippy (beta)

operator precedence can trip the unwary

warning: operator precedence can trip the unwary --> halo2_proofs/tests/plonk_api.rs:377:25 | 377 | for _ in 0..1 << K - 2 { | ^^^^^^^^^^ help: consider parenthesizing your expression: `1 << (K - 2)` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#precedence = note: `-W clippy::precedence` implied by `-W clippy::all`
let a: Value<Assigned<_>> = self.a.into();
let mut a_squared = Value::unknown();
let (a0, _, c0) = cs.raw_multiply(&mut layouter, || {
Expand Down Expand Up @@ -531,6 +531,8 @@ fn plonk_api() {
assert!(strategy.finalize());
}

use ark_std::{end_timer, start_timer};

fn test_plonk_api_gwc() {
use halo2_proofs::poly::kzg::commitment::{KZGCommitmentScheme, ParamsKZG};
use halo2_proofs::poly::kzg::multiopen::{ProverGWC, VerifierGWC};
Expand All @@ -545,9 +547,12 @@ fn plonk_api() {

let pk = keygen::<KZGCommitmentScheme<_>>(&params);

let proof_gen = start_timer!(|| "Proof Gen for K=20 with Plonk API example");

let proof = create_proof::<_, ProverGWC<_>, _, _, Blake2bWrite<_, _, Challenge255<_>>>(
rng, &params, &pk,
);
end_timer!(proof_gen);

let verifier_params = params.verifier_params();

Expand All @@ -574,9 +579,11 @@ fn plonk_api() {

let pk = keygen::<KZGCommitmentScheme<_>>(&params);

let proof_gen = start_timer!(|| "Proof Gen for K=20 with Plonk API example");
let proof = create_proof::<_, ProverSHPLONK<_>, _, _, Blake2bWrite<_, _, Challenge255<_>>>(
rng, &params, &pk,
);
end_timer!(proof_gen);

let verifier_params = params.verifier_params();

Expand Down Expand Up @@ -1022,5 +1029,5 @@ fn plonk_api() {

test_plonk_api_ipa();
test_plonk_api_gwc();
test_plonk_api_shplonk();
//test_plonk_api_shplonk();
}
2 changes: 1 addition & 1 deletion rust-toolchain
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.67.0
1.70.0

0 comments on commit 116fc20

Please sign in to comment.