Skip to content
This repository was archived by the owner on Apr 9, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 4 commits
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
28 changes: 28 additions & 0 deletions acvm_js/test/node/execute_circuit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Comment thread
kevaundray marked this conversation as resolved.
Outdated
Comment thread
kevaundray marked this conversation as resolved.
Outdated
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);
}
});
2 changes: 1 addition & 1 deletion blackbox_solver/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand Down
8 changes: 6 additions & 2 deletions blackbox_solver/src/barretenberg/wasm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

Expand Down