Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recognise that namespace can't fail #490

Merged
merged 3 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ceno_zkvm/src/circuit_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -423,8 +423,8 @@ impl<E: ExtensionField> ConstraintSystem<E> {
pub fn namespace<NR: Into<String>, N: FnOnce() -> NR, T>(
&mut self,
name_fn: N,
cb: impl FnOnce(&mut ConstraintSystem<E>) -> Result<T, ZKVMError>,
) -> Result<T, ZKVMError> {
cb: impl FnOnce(&mut ConstraintSystem<E>) -> T,
) -> T {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Specifically, this works exactly as before, when the 'new' T happens to be a Result<_, ZKVMError>.

self.ns.push_namespace(name_fn().into());
let t = cb(self);
self.ns.pop_namespace();
Expand Down
12 changes: 2 additions & 10 deletions ceno_zkvm/src/instructions/riscv/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<E>::new(cs);
let config = AddInstruction::construct_circuit(&mut circuit_builder);
Ok(config)
},
|cs| AddInstruction::construct_circuit(&mut CircuitBuilder::<E>::new(cs)),
);
let _sub_config = cs.namespace(
|| "sub",
|cs| {
let mut circuit_builder = CircuitBuilder::<E>::new(cs);
let config = SubInstruction::construct_circuit(&mut circuit_builder);
Ok(config)
},
|cs| SubInstruction::construct_circuit(&mut CircuitBuilder::<E>::new(cs)),
);
let param = Pcs::setup(1 << 10).unwrap();
let (pp, _) = Pcs::trim(&param, 1 << 10).unwrap();
Expand Down
Loading