diff --git a/compiler/tests/pil.rs b/compiler/tests/pil.rs index 6eda3a1ec..3459f5415 100644 --- a/compiler/tests/pil.rs +++ b/compiler/tests/pil.rs @@ -1,4 +1,6 @@ -use number::GoldilocksField; +use backend::Backend; +use compiler::compile_pil_or_asm; +use number::{Bn254Field, GoldilocksField}; use std::path::Path; use test_log::test; @@ -17,19 +19,34 @@ pub fn verify_pil(file_name: &str, query_callback: Option Option) { + compile_pil_or_asm( + format!("../test_data/pil/{file_name}").as_str(), + inputs, + &mktemp::Temp::new_dir().unwrap(), + true, + Some(Backend::Halo2), + ); +} + #[test] fn test_fibonacci() { - verify_pil("fibonacci.pil", None); + let f = "fibonacci.pil"; + verify_pil(f, None); + halo2_proof(f, Default::default()); } #[test] fn test_fibonacci_macro() { - verify_pil("fib_macro.pil", None); + let f = "fib_macro.pil"; + verify_pil(f, None); + halo2_proof(f, Default::default()); } #[test] fn test_global() { verify_pil("global.pil", None); + // Halo2 would take too long for this. } #[test] @@ -46,6 +63,8 @@ fn test_sum_via_witness_query() { } }), ); + // prover query string uses a different convention, + // so we cannot directly use the halo2_proof function here. } #[test] @@ -59,6 +78,7 @@ fn test_witness_lookup() { _ => Some(7.into()), }), ); + // halo2 fails with "gates must contain at least one constraint" } #[test] @@ -70,9 +90,18 @@ fn test_underdetermined_zero_no_solution() { #[test] fn test_pair_lookup() { verify_pil("pair_lookup.pil", None); + // halo2 would take too long for this } #[test] fn test_block_lookup_or() { verify_pil("block_lookup_or.pil", None); + // halo2 would take too long for this +} + +#[test] +fn test_halo_without_lookup() { + let f = "halo_without_lookup.pil"; + verify_pil(f, None); + halo2_proof(f, Default::default()); } diff --git a/halo2/src/circuit_builder.rs b/halo2/src/circuit_builder.rs index 645851813..7f56d65a0 100644 --- a/halo2/src/circuit_builder.rs +++ b/halo2/src/circuit_builder.rs @@ -163,6 +163,14 @@ pub(crate) fn analyzed_to_circuit( _ => unimplemented!(), } } + if lookups.is_empty() { + // TODO something inside halo2 breaks (only in debug mode) if lookups is empty, + // so just add an empty lookup. + lookups.push(Lookup { + name: "".to_string(), + exps: (vec![], vec![]), + }); + } // build Plaf fixed. ------------------------------------------------------------------------- diff --git a/test_data/pil/halo_without_lookup.pil b/test_data/pil/halo_without_lookup.pil new file mode 100644 index 000000000..54ffb292a --- /dev/null +++ b/test_data/pil/halo_without_lookup.pil @@ -0,0 +1,5 @@ +// There is a bug in halo2 that makes it fail if we do not have at least one lookup. +namespace Assembly(2); + col fixed C = [0, 1]; + col witness w; + w = C;