From 963f15e0a3f6c617ba8c549b3c222804f6b6b0d5 Mon Sep 17 00:00:00 2001 From: Franco Nieddu Date: Fri, 22 Nov 2024 15:01:49 +0100 Subject: [PATCH] chore: remarks DK --- .release-please-manifest.json | 2 +- Cargo.toml | 1 - co-noir/co-acvm/Cargo.toml | 2 +- co-noir/co-brillig/src/brillig_vm.rs | 12 +++++++----- co-noir/co-brillig/src/memory.rs | 6 ------ 5 files changed, 9 insertions(+), 14 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index db74307f9..5f6d35a68 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -8,7 +8,7 @@ "co-circom/co-plonk": "0.4.0", "co-noir/co-acvm": "0.3.0", "co-noir/co-builder": "0.1.0", - "co-noir/co-brillig": "0.1.0", + "co-noir/co-brillig": "0.0.1", "co-noir/co-noir": "0.3.0", "co-noir/co-ultrahonk": "0.2.0", "co-noir/ultrahonk": "0.2.0", diff --git a/Cargo.toml b/Cargo.toml index 1fa312c99..00ee177c3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -46,7 +46,6 @@ bytemuck = { version = "1.15", features = ["derive"] } byteorder = "1.5.0" bytes = "1.5.0" clap = { version = "4.4.8", features = ["derive"] } -co-brillig = { version = "0.1.0", path = "co-noir/co-brillig" } color-eyre = "0.6.3" criterion = { version = "0.5", features = ["async_tokio"] } eyre = "0.6" diff --git a/co-noir/co-acvm/Cargo.toml b/co-noir/co-acvm/Cargo.toml index 55186585f..7e689284e 100644 --- a/co-noir/co-acvm/Cargo.toml +++ b/co-noir/co-acvm/Cargo.toml @@ -14,7 +14,7 @@ acir.workspace = true acvm.workspace = true ark-bn254.workspace = true ark-ff.workspace = true -co-brillig.workspace = true +co-brillig= { version = "0.1.0", path = "../co-brillig" } eyre.workspace = true intmap.workspace = true itertools.workspace = true diff --git a/co-noir/co-brillig/src/brillig_vm.rs b/co-noir/co-brillig/src/brillig_vm.rs index 5e12836fc..be3adf3e7 100644 --- a/co-noir/co-brillig/src/brillig_vm.rs +++ b/co-noir/co-brillig/src/brillig_vm.rs @@ -53,9 +53,8 @@ where } fn run_inner(&mut self, id: &BrilligFunctionId) -> eyre::Result { - // TODO remove clone - let opcodes = self.unconstrained_functions[id.as_usize()].bytecode.clone(); - loop { + let opcodes = std::mem::take(&mut self.unconstrained_functions[id.as_usize()].bytecode); + let result = loop { let opcode = &opcodes[self.ip]; tracing::debug!("running opcode: {:?}", opcode); match opcode { @@ -139,10 +138,13 @@ where BrilligOpcode::BlackBox(blackbox_op) => self.handle_blackbox(*blackbox_op)?, BrilligOpcode::Trap { revert_data: _ } => todo!(), BrilligOpcode::Stop { return_data } => { - return self.handle_stop(*return_data); + break self.handle_stop(*return_data); } } - } + }; + // move the opcodes back in + self.unconstrained_functions[id.as_usize()].bytecode = opcodes; + result } /// Creates a new instance of the coBrillig-VM from the provided diff --git a/co-noir/co-brillig/src/memory.rs b/co-noir/co-brillig/src/memory.rs index 99145361d..0d582e9e8 100644 --- a/co-noir/co-brillig/src/memory.rs +++ b/co-noir/co-brillig/src/memory.rs @@ -3,12 +3,6 @@ use brillig::{IntegerBitSize, MemoryAddress}; use crate::mpc::BrilligDriver; -/** -* Copied form https://github.com/noir-lang/noir/blob/68c32b4ffd9b069fe4b119327dbf4018c17ab9d4/acvm-repo/brillig_vm/src/memory.rs -* -* We cannot use the implementation because it is bound to [AcirField] -**/ - pub(super) struct Memory where T: BrilligDriver,