From 18999b7f773c80544cbe8c53aa56294524a942de Mon Sep 17 00:00:00 2001 From: Soham Zemse <22412996+zemse@users.noreply.github.com> Date: Mon, 9 Sep 2024 14:11:23 +0530 Subject: [PATCH] add panic for less_than usage in riv64 remove tests --- ceno_zkvm/src/chip_handler/general.rs | 22 ++----- ceno_zkvm/src/scheme/mock_prover.rs | 94 --------------------------- 2 files changed, 7 insertions(+), 109 deletions(-) diff --git a/ceno_zkvm/src/chip_handler/general.rs b/ceno_zkvm/src/chip_handler/general.rs index d1d21b051..e8acc149b 100644 --- a/ceno_zkvm/src/chip_handler/general.rs +++ b/ceno_zkvm/src/chip_handler/general.rs @@ -285,6 +285,10 @@ impl<'a, E: ExtensionField> CircuitBuilder<'a, E> { NR: Into + Display + Clone, N: FnOnce() -> NR, { + #[cfg(feature = "riv64")] + panic!("less_than is not supported for riv64 yet"); + + #[cfg(feature = "riv32")] self.namespace( || "less_than", |cb| { @@ -314,18 +318,9 @@ impl<'a, E: ExtensionField> CircuitBuilder<'a, E> { ) }; - let diff = { - #[cfg(feature = "riv32")] - { - 0..2 - } - #[cfg(feature = "riv64")] - { - 0..4 - } - } - .map(|i| witin_u16(format!("diff_{i}"))) - .collect::, _>>()?; + let diff = (0..2) + .map(|i| witin_u16(format!("diff_{i}"))) + .collect::, _>>()?; let diff_expr = diff .iter() @@ -335,10 +330,7 @@ impl<'a, E: ExtensionField> CircuitBuilder<'a, E> { sum + if i > 0 { a * (1 << (16 * i)).into() } else { a } }); - #[cfg(feature = "riv32")] let range = Expression::Constant((u32::MAX as u64).into()); - #[cfg(feature = "riv64")] - let range = Expression::Constant(u64::MAX.into()); // TODO beyond modulus cb.require_equal(|| name.clone(), lhs - rhs, diff_expr - is_lt_expr * range)?; diff --git a/ceno_zkvm/src/scheme/mock_prover.rs b/ceno_zkvm/src/scheme/mock_prover.rs index 3f3eb6adb..888a75fd7 100644 --- a/ceno_zkvm/src/scheme/mock_prover.rs +++ b/ceno_zkvm/src/scheme/mock_prover.rs @@ -565,10 +565,6 @@ mod tests { .into_mle() .into(), vec![Goldilocks::from(u16::MAX as u64)].into_mle().into(), - #[cfg(feature = "riv64")] - vec![Goldilocks::from(u16::MAX as u64)].into_mle().into(), - #[cfg(feature = "riv64")] - vec![Goldilocks::from(u16::MAX as u64)].into_mle().into(), ]; MockProver::assert_satisfied(&mut builder, &wits_in, None); @@ -592,34 +588,6 @@ mod tests { .into_mle() .into(), vec![Goldilocks::from(u16::MAX as u64)].into_mle().into(), - #[cfg(feature = "riv64")] - vec![Goldilocks::from(u16::MAX as u64)].into_mle().into(), - #[cfg(feature = "riv64")] - vec![Goldilocks::from(u16::MAX as u64)].into_mle().into(), - ]; - - MockProver::assert_satisfied(&mut builder, &wits_in, None); - } - - #[test] - #[cfg(feature = "riv64")] - fn test_assert_lt_u64() { - let mut cs = ConstraintSystem::new(|| "test_lt_u64"); - let mut builder = CircuitBuilder::::new(&mut cs); - - let _ = AssertLtCircuit::construct_circuit(&mut builder).unwrap(); - - let wits_in = vec![ - vec![Goldilocks::from(u64::MAX - 5)].into_mle().into(), - vec![Goldilocks::from(u64::MAX - 3)].into_mle().into(), - vec![Goldilocks::from(u16::MAX as u64 + 3 - 5)] - .into_mle() - .into(), - vec![Goldilocks::from(u16::MAX as u64)].into_mle().into(), - #[cfg(feature = "riv64")] - vec![Goldilocks::from(u16::MAX as u64)].into_mle().into(), - #[cfg(feature = "riv64")] - vec![Goldilocks::from(u16::MAX as u64)].into_mle().into(), ]; MockProver::assert_satisfied(&mut builder, &wits_in, None); @@ -668,14 +636,6 @@ mod tests { vec![Goldilocks::from(u16::MAX as u64), Goldilocks::from(0)] .into_mle() .into(), - #[cfg(feature = "riv64")] - vec![Goldilocks::from(u16::MAX as u64), Goldilocks::from(0)] - .into_mle() - .into(), - #[cfg(feature = "riv64")] - vec![Goldilocks::from(u16::MAX as u64), Goldilocks::from(0)] - .into_mle() - .into(), ]; MockProver::assert_satisfied(&mut builder, &wits_in, None); @@ -713,60 +673,6 @@ mod tests { vec![Goldilocks::from(u16::MAX as u64), Goldilocks::from(0)] .into_mle() .into(), - #[cfg(feature = "riv64")] - vec![Goldilocks::from(u16::MAX as u64), Goldilocks::from(0)] - .into_mle() - .into(), - #[cfg(feature = "riv64")] - vec![Goldilocks::from(u16::MAX as u64), Goldilocks::from(0)] - .into_mle() - .into(), - ]; - - MockProver::assert_satisfied(&mut builder, &wits_in, None); - } - - #[test] - #[cfg(feature = "riv64")] - fn test_lt_u64() { - let mut cs = ConstraintSystem::new(|| "test_lt_u64"); - let mut builder = CircuitBuilder::::new(&mut cs); - - let _ = LtCircuit::construct_circuit(&mut builder).unwrap(); - - let wits_in = vec![ - vec![ - Goldilocks::from(u64::MAX - 5), - Goldilocks::from(u64::MAX - 3), - ] - .into_mle() - .into(), - vec![ - Goldilocks::from(u64::MAX - 3), - Goldilocks::from(u64::MAX - 5), - ] - .into_mle() - .into(), - vec![Goldilocks::from(1u64), Goldilocks::from(0u64)] - .into_mle() - .into(), - vec![ - Goldilocks::from(u16::MAX as u64 + 3 - 5), - Goldilocks::from(5 - 3), - ] - .into_mle() - .into(), - vec![Goldilocks::from(u16::MAX as u64), Goldilocks::from(0)] - .into_mle() - .into(), - #[cfg(feature = "riv64")] - vec![Goldilocks::from(u16::MAX as u64), Goldilocks::from(0)] - .into_mle() - .into(), - #[cfg(feature = "riv64")] - vec![Goldilocks::from(u16::MAX as u64), Goldilocks::from(0)] - .into_mle() - .into(), ]; MockProver::assert_satisfied(&mut builder, &wits_in, None);