From b5b8ff06fd8b32c664142332024b05614282369a Mon Sep 17 00:00:00 2001 From: Matthias Goergens Date: Mon, 28 Oct 2024 22:13:28 +0800 Subject: [PATCH] Recognise that `namespace` can't fail At least `ConstraintSystem::namespace` won't fail on its own. But it might fail, if the circus construction function (or so) you are passing to fails. The new type reflects that. --- ceno_zkvm/src/circuit_builder.rs | 4 ++-- ceno_zkvm/src/instructions/riscv/test.rs | 12 ++---------- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/ceno_zkvm/src/circuit_builder.rs b/ceno_zkvm/src/circuit_builder.rs index f5ef37825..8eae521ec 100644 --- a/ceno_zkvm/src/circuit_builder.rs +++ b/ceno_zkvm/src/circuit_builder.rs @@ -423,8 +423,8 @@ impl ConstraintSystem { pub fn namespace, N: FnOnce() -> NR, T>( &mut self, name_fn: N, - cb: impl FnOnce(&mut ConstraintSystem) -> Result, - ) -> Result { + cb: impl FnOnce(&mut ConstraintSystem) -> T, + ) -> T { self.ns.push_namespace(name_fn().into()); let t = cb(self); self.ns.pop_namespace(); diff --git a/ceno_zkvm/src/instructions/riscv/test.rs b/ceno_zkvm/src/instructions/riscv/test.rs index 09456f269..6513cd1f7 100644 --- a/ceno_zkvm/src/instructions/riscv/test.rs +++ b/ceno_zkvm/src/instructions/riscv/test.rs @@ -16,19 +16,11 @@ fn test_multiple_opcode() { let mut cs = ConstraintSystem::new(|| "riscv"); let _add_config = cs.namespace( || "add", - |cs| { - let mut circuit_builder = CircuitBuilder::::new(cs); - let config = AddInstruction::construct_circuit(&mut circuit_builder); - Ok(config) - }, + |cs| AddInstruction::construct_circuit(&mut CircuitBuilder::::new(cs)), ); let _sub_config = cs.namespace( || "sub", - |cs| { - let mut circuit_builder = CircuitBuilder::::new(cs); - let config = SubInstruction::construct_circuit(&mut circuit_builder); - Ok(config) - }, + |cs| SubInstruction::construct_circuit(&mut CircuitBuilder::::new(cs)), ); let param = Pcs::setup(1 << 10).unwrap(); let (pp, _) = Pcs::trim(¶m, 1 << 10).unwrap();