From 47fe9f53fbdf39b936d7e7ce8d07232f691b72da Mon Sep 17 00:00:00 2001 From: kevaundray Date: Sat, 2 Sep 2023 00:45:01 +0000 Subject: [PATCH 1/7] Add alvaros test --- acvm_js/test/node/execute_circuit.test.ts | 28 +++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/acvm_js/test/node/execute_circuit.test.ts b/acvm_js/test/node/execute_circuit.test.ts index 3b84d8d9..d0d00e40 100644 --- a/acvm_js/test/node/execute_circuit.test.ts +++ b/acvm_js/test/node/execute_circuit.test.ts @@ -205,3 +205,31 @@ it("successfully executes two circuits with same backend", async function () { expect(solvedWitness0).to.be.deep.eq(expectedWitnessMap); expect(solvedWitness1).to.be.deep.eq(expectedWitnessMap); }); + +it.only("successfully executes 500 circuits with same backend", async function () { + this.timeout(100000); + + // chose pedersen op here because it is the one with slow initialization + // that led to the decision to pull backend initialization into a separate + // function/wasmbind + const solver: WasmBlackBoxFunctionSolver = await createBlackBoxSolver(); + + const { bytecode, initialWitnessMap, expectedWitnessMap } = await import( + "../shared/pedersen" + ); + + for (let i = 0; i < 500; i++) { + console.log("Iteration", i); + const solvedWitness = await executeCircuitWithBlackBoxSolver( + solver, + bytecode, + initialWitnessMap, + () => { + throw Error("unexpected oracle"); + } + ); + console.log("Solved!"); + + expect(solvedWitness).to.be.deep.eq(expectedWitnessMap); + } +}); \ No newline at end of file From 0643ae7d4d53f75fd80b0d637b46b418a6477d08 Mon Sep 17 00:00:00 2001 From: kevaundray Date: Sat, 2 Sep 2023 00:47:18 +0000 Subject: [PATCH 2/7] lint --- acvm_js/test/node/execute_circuit.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/acvm_js/test/node/execute_circuit.test.ts b/acvm_js/test/node/execute_circuit.test.ts index d0d00e40..20101c19 100644 --- a/acvm_js/test/node/execute_circuit.test.ts +++ b/acvm_js/test/node/execute_circuit.test.ts @@ -232,4 +232,4 @@ it.only("successfully executes 500 circuits with same backend", async function ( expect(solvedWitness).to.be.deep.eq(expectedWitnessMap); } -}); \ No newline at end of file +}); From 975e541fa0bdf55f3be99afc0580996317b4cf9f Mon Sep 17 00:00:00 2001 From: kevaundray Date: Sat, 2 Sep 2023 01:33:19 +0000 Subject: [PATCH 3/7] switch to 0.5.0 --- blackbox_solver/build.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/blackbox_solver/build.rs b/blackbox_solver/build.rs index 3c911d9b..39db930b 100644 --- a/blackbox_solver/build.rs +++ b/blackbox_solver/build.rs @@ -7,7 +7,7 @@ use std::{ const BARRETENBERG_ARCHIVE: &str = "BARRETENBERG_ARCHIVE"; const BARRETENBERG_BIN_DIR: &str = "BARRETENBERG_BIN_DIR"; -const BARRETENBERG_ARCHIVE_FALLBACK: &str = "https://github.com/AztecProtocol/barretenberg/releases/download/barretenberg-v0.4.6/acvm_backend.wasm.tar.gz"; +const BARRETENBERG_ARCHIVE_FALLBACK: &str = "https://github.com/AztecProtocol/barretenberg/releases/download/barretenberg-v0.5.0/acvm_backend.wasm.tar.gz"; // const ARCHIVE_SHA256: &str = "1xpycikqlvsjcryi3hkbc4mwmmdz7zshw6f76vyf1qssq53asyfx"; fn unpack_wasm(archive_path: &Path, target_dir: &Path) -> Result<(), String> { From f044576216d3e87e7073d257daca375bbe6c8b32 Mon Sep 17 00:00:00 2001 From: kevaundray Date: Sat, 2 Sep 2023 19:08:10 +0000 Subject: [PATCH 4/7] call _initialize for wasi --- blackbox_solver/src/barretenberg/wasm/mod.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/blackbox_solver/src/barretenberg/wasm/mod.rs b/blackbox_solver/src/barretenberg/wasm/mod.rs index 78d77d99..1af01087 100644 --- a/blackbox_solver/src/barretenberg/wasm/mod.rs +++ b/blackbox_solver/src/barretenberg/wasm/mod.rs @@ -87,13 +87,17 @@ impl Barretenberg { #[cfg(not(target_arch = "wasm32"))] pub(crate) fn new() -> Barretenberg { let (instance, memory, store) = instance_load(); - Barretenberg { memory, instance, store: RefCell::new(store) } + let barretenberg = Barretenberg { memory, instance, store: RefCell::new(store) }; + barretenberg.call_multiple("_initialize", vec![]).unwrap(); + barretenberg } #[cfg(target_arch = "wasm32")] pub(crate) async fn initialize() -> Barretenberg { let (instance, memory, store) = instance_load().await; - Barretenberg { memory, instance, store: RefCell::new(store) } + let barretenberg = Barretenberg { memory, instance, store: RefCell::new(store) }; + barretenberg.call_multiple("_initialize", vec![]).unwrap(); + barretenberg } } From 831bd147df36a4beabc5b482b96aa2fdb86b2084 Mon Sep 17 00:00:00 2001 From: kevaundray Date: Sat, 2 Sep 2023 19:27:04 +0000 Subject: [PATCH 5/7] small cleanup --- acvm_js/test/node/execute_circuit.test.ts | 2 -- blackbox_solver/src/barretenberg/wasm/mod.rs | 9 +++++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/acvm_js/test/node/execute_circuit.test.ts b/acvm_js/test/node/execute_circuit.test.ts index 20101c19..4bbc0123 100644 --- a/acvm_js/test/node/execute_circuit.test.ts +++ b/acvm_js/test/node/execute_circuit.test.ts @@ -219,7 +219,6 @@ it.only("successfully executes 500 circuits with same backend", async function ( ); for (let i = 0; i < 500; i++) { - console.log("Iteration", i); const solvedWitness = await executeCircuitWithBlackBoxSolver( solver, bytecode, @@ -228,7 +227,6 @@ it.only("successfully executes 500 circuits with same backend", async function ( throw Error("unexpected oracle"); } ); - console.log("Solved!"); expect(solvedWitness).to.be.deep.eq(expectedWitnessMap); } diff --git a/blackbox_solver/src/barretenberg/wasm/mod.rs b/blackbox_solver/src/barretenberg/wasm/mod.rs index 1af01087..03938399 100644 --- a/blackbox_solver/src/barretenberg/wasm/mod.rs +++ b/blackbox_solver/src/barretenberg/wasm/mod.rs @@ -88,7 +88,7 @@ impl Barretenberg { pub(crate) fn new() -> Barretenberg { let (instance, memory, store) = instance_load(); let barretenberg = Barretenberg { memory, instance, store: RefCell::new(store) }; - barretenberg.call_multiple("_initialize", vec![]).unwrap(); + barretenberg.call_wasi_initialize(); barretenberg } @@ -96,9 +96,14 @@ impl Barretenberg { pub(crate) async fn initialize() -> Barretenberg { let (instance, memory, store) = instance_load().await; let barretenberg = Barretenberg { memory, instance, store: RefCell::new(store) }; - barretenberg.call_multiple("_initialize", vec![]).unwrap(); barretenberg } + /// Call initialization function for WASI, to initialize all of the appropriate + /// globals. + fn call_wasi_initialize(&self) { + self.call_multiple("_initialize", vec![]) + .expect("expected call to WASI initialization function to not fail"); + } } /// A wrapper around the arguments or return value from a WASM call. From d181f0f468a66469eca7274daf5aa125eb06d4ee Mon Sep 17 00:00:00 2001 From: kevaundray Date: Sun, 3 Sep 2023 10:26:28 +0000 Subject: [PATCH 6/7] add back call_wasi_initialize for wasm32 --- blackbox_solver/src/barretenberg/wasm/mod.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/blackbox_solver/src/barretenberg/wasm/mod.rs b/blackbox_solver/src/barretenberg/wasm/mod.rs index 03938399..995ef673 100644 --- a/blackbox_solver/src/barretenberg/wasm/mod.rs +++ b/blackbox_solver/src/barretenberg/wasm/mod.rs @@ -96,6 +96,7 @@ impl Barretenberg { pub(crate) async fn initialize() -> Barretenberg { let (instance, memory, store) = instance_load().await; let barretenberg = Barretenberg { memory, instance, store: RefCell::new(store) }; + barretenberg.call_wasi_initialize(); barretenberg } /// Call initialization function for WASI, to initialize all of the appropriate From a868ae3a0f28aef5ea00616b65a18335437aecbd Mon Sep 17 00:00:00 2001 From: kevaundray Date: Sun, 3 Sep 2023 10:42:11 +0000 Subject: [PATCH 7/7] lasse found: remove only --- acvm_js/test/node/execute_circuit.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/acvm_js/test/node/execute_circuit.test.ts b/acvm_js/test/node/execute_circuit.test.ts index 4bbc0123..dac93b9f 100644 --- a/acvm_js/test/node/execute_circuit.test.ts +++ b/acvm_js/test/node/execute_circuit.test.ts @@ -206,7 +206,7 @@ it("successfully executes two circuits with same backend", async function () { expect(solvedWitness1).to.be.deep.eq(expectedWitnessMap); }); -it.only("successfully executes 500 circuits with same backend", async function () { +it("successfully executes 500 circuits with same backend", async function () { this.timeout(100000); // chose pedersen op here because it is the one with slow initialization