From e0be78b90e605f3f724ebae8676e637e2778d60e Mon Sep 17 00:00:00 2001 From: Cody Date: Thu, 5 Dec 2024 18:20:16 +0000 Subject: [PATCH 01/12] Playwright ReferenceError --- .../barretenberg/dsl/acir_proofs/c_bind.cpp | 80 ++++++++++++++++++- .../barretenberg/dsl/acir_proofs/c_bind.hpp | 11 ++- barretenberg/ts/src/barretenberg/backend.ts | 10 +++ barretenberg/ts/src/barretenberg_api/index.ts | 25 ++++++ .../browser_client_ivc_integration.test.ts | 38 ++------- yarn-project/ivc-integration/src/index.ts | 47 +++++++++++ yarn-project/ivc-integration/src/serve.ts | 3 +- 7 files changed, 177 insertions(+), 37 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/c_bind.cpp b/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/c_bind.cpp index 6e045c395c5d..cf09e9ef1485 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/c_bind.cpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/c_bind.cpp @@ -10,7 +10,7 @@ #include "barretenberg/plonk/proof_system/proving_key/serialize.hpp" #include "barretenberg/plonk/proof_system/verification_key/verification_key.hpp" #include "barretenberg/serialize/msgpack.hpp" -#include "barretenberg/srs/global_crs.hpp" +#include "barretenberg/srs/global_crs.hpp" // WORKTODO: unused? #include "honk_contract.hpp" #include #include @@ -274,6 +274,84 @@ WASM_EXPORT void acir_prove_and_verify_aztec_client(uint8_t const* acir_stack, *verified = result; } +WASM_EXPORT void acir_prove_aztec_client(uint8_t const* acir_stack, + uint8_t const* witness_stack, + uint8_t** out_proof, + uint8_t** out_vk) +{ + using Program = acir_format::AcirProgram; + + std::vector> witnesses = from_buffer>>(witness_stack); + std::vector> acirs = from_buffer>>(acir_stack); + std::vector folding_stack; + + for (auto [bincode, wit] : zip_view(acirs, witnesses)) { + acir_format::WitnessVector witness = acir_format::witness_buf_to_witness_data(wit); + acir_format::AcirFormat constraints = + acir_format::circuit_buf_to_acir_format(bincode, /*honk_recursion=*/false); + folding_stack.push_back(Program{ constraints, witness }); + } + // TODO(#7371) dedupe this with the rest of the similar code + // TODO(https://github.com/AztecProtocol/barretenberg/issues/1101): remove use of auto_verify_mode + ClientIVC ivc{ { CLIENT_IVC_BENCH_STRUCTURE }, /*auto_verify_mode=*/true }; + + // Accumulate the entire program stack into the IVC + // TODO(https://github.com/AztecProtocol/barretenberg/issues/1116): remove manual setting of is_kernel once databus + // has been integrated into noir kernel programs + bool is_kernel = false; + auto start = std::chrono::steady_clock::now(); + for (Program& program : folding_stack) { + // Construct a bberg circuit from the acir representation then accumulate it into the IVC + vinfo("constructing circuit..."); + auto circuit = acir_format::create_circuit( + program.constraints, false, 0, program.witness, false, ivc.goblin.op_queue); + + // Set the internal is_kernel flag based on the local mechanism only if it has not already been set to true + if (!circuit.databus_propagation_data.is_kernel) { + circuit.databus_propagation_data.is_kernel = is_kernel; + } + is_kernel = !is_kernel; + + vinfo("done constructing circuit. calling ivc.accumulate..."); + ivc.accumulate(circuit); + vinfo("done accumulating."); + } + auto end = std::chrono::steady_clock::now(); + auto diff = std::chrono::duration_cast(end - start); + vinfo("time to construct and accumulate all circuits: ", diff.count()); + + vinfo("calling ivc.prove ..."); + ClientIVC::Proof proof = ivc.prove(); + + end = std::chrono::steady_clock::now(); + diff = std::chrono::duration_cast(end - start); + vinfo("time to construct, accumulate, prove all circuits: ", diff.count()); + + *out_proof = to_heap_buffer(to_buffer(proof)); // WORKTODO: include size? + + auto eccvm_vk = std::make_shared(ivc.goblin.get_eccvm_proving_key()); + auto translator_vk = std::make_shared(ivc.goblin.get_translator_proving_key()); + *out_vk = to_heap_buffer(to_buffer(ClientIVC::VerificationKey{ ivc.honk_vk, eccvm_vk, translator_vk })); +} + +WASM_EXPORT void acir_verify_client_ivc(uint8_t const* proof_buf, uint8_t const* vk_buf, bool* result) +{ + // // TODO(https://github.com/AztecProtocol/barretenberg/issues/1163): Set these dynamically + // init_bn254_crs(1); + // init_grumpkin_crs(1 << 15); + + const auto proof = from_buffer(from_buffer>(proof_buf)); + const auto vk = from_buffer(vk_buf); + + vk.mega->pcs_verification_key = std::make_shared>(); + vk.eccvm->pcs_verification_key = + std::make_shared>(vk.eccvm->circuit_size + 1); + vk.translator->pcs_verification_key = std::make_shared>(); + + const bool verified = ClientIVC::verify(proof, vk); + *result = verified; +} + WASM_EXPORT void acir_prove_ultra_honk(uint8_t const* acir_vec, bool const* recursive, uint8_t const* witness_vec, diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/c_bind.hpp b/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/c_bind.hpp index 64197459b27b..ab2b5061d8c0 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/c_bind.hpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/c_bind.hpp @@ -41,8 +41,8 @@ WASM_EXPORT void acir_prove_and_verify_ultra_honk(uint8_t const* constraint_syst bool* result); /** - * @brief Construct and verify a MegaHonk proof - * + * @brief Construct and verify a ClientIVC proof + * @deprecated */ WASM_EXPORT void acir_prove_and_verify_mega_honk(uint8_t const* constraint_system_buf, bool const* recursive, @@ -53,6 +53,13 @@ WASM_EXPORT void acir_prove_and_verify_aztec_client(uint8_t const* constraint_sy uint8_t const* witness_buf, bool* result); +WASM_EXPORT void acir_prove_aztec_client(uint8_t const* acir_stack, + uint8_t const* witness_stack, + uint8_t** out_proof, + uint8_t** out_vk); + +WASM_EXPORT void acir_verify_aztec_client(uint8_t const* proof_buf, uint8_t const* vk_buf, bool* result); + /** * @brief Fold and verify a set of circuits using ClientIvc * diff --git a/barretenberg/ts/src/barretenberg/backend.ts b/barretenberg/ts/src/barretenberg/backend.ts index db292c1a9268..2815d1282587 100644 --- a/barretenberg/ts/src/barretenberg/backend.ts +++ b/barretenberg/ts/src/barretenberg/backend.ts @@ -292,6 +292,16 @@ export class AztecClientBackend { } } + async prove(witnessMsgpack: Uint8Array[]): Promise<[Uint8Array, Uint8Array]> { + await this.instantiate(); + return this.api.acirProveAztecClient(this.acirMsgpack, witnessMsgpack); + } + + // async verify(proof: Uint8Array): Promise { + // await this.instantiate(); + // return this.api.acirVerifyAztecClient(proof, vk); + // } + async proveAndVerify(witnessMsgpack: Uint8Array[]): Promise { await this.instantiate(); return this.api.acirProveAndVerifyAztecClient(this.acirMsgpack, witnessMsgpack); diff --git a/barretenberg/ts/src/barretenberg_api/index.ts b/barretenberg/ts/src/barretenberg_api/index.ts index 02cfcf5bf100..330ed1727a20 100644 --- a/barretenberg/ts/src/barretenberg_api/index.ts +++ b/barretenberg/ts/src/barretenberg_api/index.ts @@ -557,6 +557,31 @@ export class BarretenbergApi { return out[0]; } + async acirProveAztecClient(acirVec: Uint8Array[], witnessVec: Uint8Array[]): Promise<[Uint8Array, Uint8Array]> { + const inArgs = [acirVec, witnessVec].map(serializeBufferable); + const outTypes: OutputType[] = [BufferDeserializer()]; + const result = await this.wasm.callWasmExport( + 'acir_prove_aztec_client', + inArgs, + outTypes.map(t => t.SIZE_IN_BYTES), + ); + const out = result.map((r, i) => outTypes[i].fromBuffer(r)); + // console.log(`number of things in out: ${out.length}`); + return [out[0], out[1]]; + } + + // async acirVerifyAztecClient(proofBuf: Uint8Array, vkBuf: Uint8Array): Promise { + // const inArgs = [proofBuf, vkBuf].map(serializeBufferable); + // const outTypes: OutputType[] = [BoolDeserializer()]; + // const result = await this.wasm.callWasmExport( + // 'acir_verify_aztec_client', + // inArgs, + // outTypes.map(t => t.SIZE_IN_BYTES), + // ); + // const out = result.map((r, i) => outTypes[i].fromBuffer(r)); + // return out[0]; + // } + async acirProveUltraHonk(acirVec: Uint8Array, recursive: boolean, witnessVec: Uint8Array): Promise { const inArgs = [acirVec, recursive, witnessVec].map(serializeBufferable); const outTypes: OutputType[] = [BufferDeserializer()]; diff --git a/yarn-project/ivc-integration/src/browser_client_ivc_integration.test.ts b/yarn-project/ivc-integration/src/browser_client_ivc_integration.test.ts index 2c9332bc4918..3074b00d8fa2 100644 --- a/yarn-project/ivc-integration/src/browser_client_ivc_integration.test.ts +++ b/yarn-project/ivc-integration/src/browser_client_ivc_integration.test.ts @@ -1,18 +1,9 @@ import { jest } from '@jest/globals'; import chalk from 'chalk'; import createDebug from 'debug'; -import { - type Browser, - type Page, - chromium, - /* firefox, webkit */ -} from 'playwright'; +import { type Browser, type Page, chromium } from 'playwright'; -import { - generate3FunctionTestingIVCStack, - generate6FunctionTestingIVCStack, - proveAndVerifyAztecClient, -} from './index.js'; +import { generate3FunctionTestingIVCStack, proveThenVerifyAztecClient } from './index.js'; /* eslint-disable camelcase */ @@ -72,27 +63,8 @@ describe('Client IVC Integration', () => { it('Should generate a verifiable client IVC proof from a simple mock tx via bb.js', async () => { const [bytecodes, witnessStack] = await generate3FunctionTestingIVCStack(); - logger(`calling prove and verify...`); - const verifyResult = await proveAndVerifyAztecClient(page, bytecodes, witnessStack); - logger(`generated and verified proof. result: ${verifyResult}`); - - expect(verifyResult).toEqual(true); - }); - - // This test will verify a client IVC proof of a more complex tx: - // 1. Run a mock app that creates two commitments - // 2. Run the init kernel to process the app run - // 3. Run a mock app that reads one of those commitments - // 4. Run the inner kernel to process the second app run - // 5. Run the reset kernel to process the read request emitted by the reader app - // 6. Run the tail kernel to finish the client IVC chain - it('Should generate a verifiable client IVC proof from a simple mock tx via bb.js', async () => { - const [bytecodes, witnessStack] = await generate6FunctionTestingIVCStack(); - - logger(`calling prove and verify...`); - const verifyResult = await proveAndVerifyAztecClient(page, bytecodes, witnessStack); - logger(`generated and verified proof. result: ${verifyResult}`); - - expect(verifyResult).toEqual(true); + logger(`calling prove then verify...`); + const result = await proveThenVerifyAztecClient(page, bytecodes, witnessStack); + expect(result).toEqual(true); }); }); diff --git a/yarn-project/ivc-integration/src/index.ts b/yarn-project/ivc-integration/src/index.ts index dab8804a187e..4367efb5e311 100644 --- a/yarn-project/ivc-integration/src/index.ts +++ b/yarn-project/ivc-integration/src/index.ts @@ -252,6 +252,30 @@ export async function proveAndVerifyBrowser(bytecodes: string[], witnessStack: U return verified; } +export async function proveBrowser( + bytecodes: string[], + witnessStack: Uint8Array[], + threads?: number, +): Promise<[Uint8Array, Uint8Array]> { + const { AztecClientBackend } = await import('@aztec/bb.js'); + const preparedBytecodes = bytecodes.map(base64ToUint8Array).map((arr: Uint8Array) => ungzip(arr)); + const backend = new AztecClientBackend(preparedBytecodes, { threads }); + const [proof, vk] = await backend.prove(witnessStack.map((arr: Uint8Array) => ungzip(arr))); + + await backend.destroy(); // WORKTODO: share backend? + return [proof, vk]; +} + +// export async function verifyBrowser(proof: Uint8Array, threads?: number): Promise { +// const { AztecClientBackend } = await import('@aztec/bb.js'); +// const preparedBytecodes = bytecodes.map(base64ToUint8Array).map((arr: Uint8Array) => ungzip(arr)); +// const backend = new AztecClientBackend(preparedBytecodes, { threads }); +// const verified = await backend.verify(proof); + +// await backend.destroy(); // WORKTODO: share backend +// return proof; +// } + export async function proveAndVerifyAztecClient( page: Page, bytecodes: string[], @@ -269,3 +293,26 @@ export async function proveAndVerifyAztecClient( return result; } + +// WORKTODO: This functions will construct a proof using the `prove` flow, then verify +// the proof using the accompanying vk using the `verify` flow. proveAndVerify instead just +// receives a boolean signal via a single call to a backend function. +export async function proveThenVerifyAztecClient( + page: Page, + bytecodes: string[], + witnessStack: Uint8Array[], +): Promise { + const threads = 16; + + const result: boolean = await page.evaluate( + ([acir, witness, numThreads]) => { + console.log('trying to assign proveBrowser'); + (window as any).proveBrowser = proveBrowser; + const _proof = (window as any).proveBrowser(acir, witness, numThreads); + return true; + }, + [bytecodes, witnessStack, threads], + ); + + return result; +} diff --git a/yarn-project/ivc-integration/src/serve.ts b/yarn-project/ivc-integration/src/serve.ts index b16a125a05cb..edbd44b71376 100644 --- a/yarn-project/ivc-integration/src/serve.ts +++ b/yarn-project/ivc-integration/src/serve.ts @@ -1,6 +1,6 @@ import createDebug from 'debug'; -import { generate3FunctionTestingIVCStack, proveAndVerifyBrowser } from './index.js'; +import { generate3FunctionTestingIVCStack, proveAndVerifyBrowser, proveBrowser } from './index.js'; createDebug.enable('*'); const logger = createDebug('aztec:ivc-test'); @@ -79,6 +79,7 @@ function setupConsoleOutput() { } (window as any).proveAndVerifyBrowser = proveAndVerifyBrowser; +(window as any).proveBroswer = proveBrowser; document.addEventListener('DOMContentLoaded', function () { setupConsoleOutput(); // Initialize console output capture From 6ac7cc577b3254019a18ee7c0024f3806c8a4e83 Mon Sep 17 00:00:00 2001 From: Cody Date: Fri, 6 Dec 2024 21:03:47 +0000 Subject: [PATCH 02/12] Prove flow executes --- barretenberg/ts/src/barretenberg_api/index.ts | 5 ++- yarn-project/ivc-integration/package.json | 2 +- .../browser_client_ivc_integration.test.ts | 4 +- yarn-project/ivc-integration/src/index.ts | 42 ++----------------- yarn-project/ivc-integration/src/serve.ts | 3 +- yarn-project/yarn.lock | 28 ++++++++++++- 6 files changed, 36 insertions(+), 48 deletions(-) diff --git a/barretenberg/ts/src/barretenberg_api/index.ts b/barretenberg/ts/src/barretenberg_api/index.ts index 330ed1727a20..853e1549ad19 100644 --- a/barretenberg/ts/src/barretenberg_api/index.ts +++ b/barretenberg/ts/src/barretenberg_api/index.ts @@ -559,14 +559,15 @@ export class BarretenbergApi { async acirProveAztecClient(acirVec: Uint8Array[], witnessVec: Uint8Array[]): Promise<[Uint8Array, Uint8Array]> { const inArgs = [acirVec, witnessVec].map(serializeBufferable); - const outTypes: OutputType[] = [BufferDeserializer()]; + const outTypes: OutputType[] = [BufferDeserializer(), BufferDeserializer()]; const result = await this.wasm.callWasmExport( 'acir_prove_aztec_client', inArgs, outTypes.map(t => t.SIZE_IN_BYTES), ); const out = result.map((r, i) => outTypes[i].fromBuffer(r)); - // console.log(`number of things in out: ${out.length}`); + console.log(`number of things in outTypes: ${outTypes.length}`); + console.log(`number of things in out: ${out.length}`); return [out[0], out[1]]; } diff --git a/yarn-project/ivc-integration/package.json b/yarn-project/ivc-integration/package.json index 54c7f4097123..4389ae09ede2 100644 --- a/yarn-project/ivc-integration/package.json +++ b/yarn-project/ivc-integration/package.json @@ -72,7 +72,7 @@ "chalk": "^5.3.0", "change-case": "^5.4.4", "pako": "^2.1.0", - "playwright": "^1.48.2", + "playwright": "^1.49.0", "puppeteer": "^22.4.1", "tslib": "^2.4.0" }, diff --git a/yarn-project/ivc-integration/src/browser_client_ivc_integration.test.ts b/yarn-project/ivc-integration/src/browser_client_ivc_integration.test.ts index 3074b00d8fa2..41e1e8b356cb 100644 --- a/yarn-project/ivc-integration/src/browser_client_ivc_integration.test.ts +++ b/yarn-project/ivc-integration/src/browser_client_ivc_integration.test.ts @@ -3,7 +3,7 @@ import chalk from 'chalk'; import createDebug from 'debug'; import { type Browser, type Page, chromium } from 'playwright'; -import { generate3FunctionTestingIVCStack, proveThenVerifyAztecClient } from './index.js'; +import { generate3FunctionTestingIVCStack, proveAndVerifyAztecClient } from './index.js'; /* eslint-disable camelcase */ @@ -64,7 +64,7 @@ describe('Client IVC Integration', () => { const [bytecodes, witnessStack] = await generate3FunctionTestingIVCStack(); logger(`calling prove then verify...`); - const result = await proveThenVerifyAztecClient(page, bytecodes, witnessStack); + const result = await proveAndVerifyAztecClient(page, bytecodes, witnessStack); expect(result).toEqual(true); }); }); diff --git a/yarn-project/ivc-integration/src/index.ts b/yarn-project/ivc-integration/src/index.ts index 4367efb5e311..ccc0be0670aa 100644 --- a/yarn-project/ivc-integration/src/index.ts +++ b/yarn-project/ivc-integration/src/index.ts @@ -243,27 +243,14 @@ function base64ToUint8Array(base64: string): Uint8Array { } export async function proveAndVerifyBrowser(bytecodes: string[], witnessStack: Uint8Array[], threads?: number) { - const { AztecClientBackend } = await import('@aztec/bb.js'); - const preparedBytecodes = bytecodes.map(base64ToUint8Array).map((arr: Uint8Array) => ungzip(arr)); - const backend = new AztecClientBackend(preparedBytecodes, { threads }); - const verified = await backend.proveAndVerify(witnessStack.map((arr: Uint8Array) => ungzip(arr))); - - await backend.destroy(); - return verified; -} - -export async function proveBrowser( - bytecodes: string[], - witnessStack: Uint8Array[], - threads?: number, -): Promise<[Uint8Array, Uint8Array]> { const { AztecClientBackend } = await import('@aztec/bb.js'); const preparedBytecodes = bytecodes.map(base64ToUint8Array).map((arr: Uint8Array) => ungzip(arr)); const backend = new AztecClientBackend(preparedBytecodes, { threads }); const [proof, vk] = await backend.prove(witnessStack.map((arr: Uint8Array) => ungzip(arr))); - + logger(`proof length: ${proof.length}`); + logger(`vk length: ${vk.length}`); await backend.destroy(); // WORKTODO: share backend? - return [proof, vk]; + return true; } // export async function verifyBrowser(proof: Uint8Array, threads?: number): Promise { @@ -293,26 +280,3 @@ export async function proveAndVerifyAztecClient( return result; } - -// WORKTODO: This functions will construct a proof using the `prove` flow, then verify -// the proof using the accompanying vk using the `verify` flow. proveAndVerify instead just -// receives a boolean signal via a single call to a backend function. -export async function proveThenVerifyAztecClient( - page: Page, - bytecodes: string[], - witnessStack: Uint8Array[], -): Promise { - const threads = 16; - - const result: boolean = await page.evaluate( - ([acir, witness, numThreads]) => { - console.log('trying to assign proveBrowser'); - (window as any).proveBrowser = proveBrowser; - const _proof = (window as any).proveBrowser(acir, witness, numThreads); - return true; - }, - [bytecodes, witnessStack, threads], - ); - - return result; -} diff --git a/yarn-project/ivc-integration/src/serve.ts b/yarn-project/ivc-integration/src/serve.ts index edbd44b71376..b16a125a05cb 100644 --- a/yarn-project/ivc-integration/src/serve.ts +++ b/yarn-project/ivc-integration/src/serve.ts @@ -1,6 +1,6 @@ import createDebug from 'debug'; -import { generate3FunctionTestingIVCStack, proveAndVerifyBrowser, proveBrowser } from './index.js'; +import { generate3FunctionTestingIVCStack, proveAndVerifyBrowser } from './index.js'; createDebug.enable('*'); const logger = createDebug('aztec:ivc-test'); @@ -79,7 +79,6 @@ function setupConsoleOutput() { } (window as any).proveAndVerifyBrowser = proveAndVerifyBrowser; -(window as any).proveBroswer = proveBrowser; document.addEventListener('DOMContentLoaded', function () { setupConsoleOutput(); // Initialize console output capture diff --git a/yarn-project/yarn.lock b/yarn-project/yarn.lock index c53310ab30d3..7bdbf0feb0b0 100644 --- a/yarn-project/yarn.lock +++ b/yarn-project/yarn.lock @@ -730,7 +730,7 @@ __metadata: levelup: ^5.1.1 memdown: ^6.1.1 pako: ^2.1.0 - playwright: ^1.48.2 + playwright: ^1.49.0 puppeteer: ^22.4.1 resolve-typescript-plugin: ^2.0.1 serve: ^14.2.1 @@ -14827,7 +14827,16 @@ __metadata: languageName: node linkType: hard -"playwright@npm:1.48.2, playwright@npm:^1.48.2": +"playwright-core@npm:1.49.0": + version: 1.49.0 + resolution: "playwright-core@npm:1.49.0" + bin: + playwright-core: cli.js + checksum: d8423ad0cab2e672856529bf6b98b406e7e605da098b847b9b54ee8ebd8d716ed8880a9afff4b38f0a2e3f59b95661c74589116ce3ff2b5e0ae3561507086c94 + languageName: node + linkType: hard + +"playwright@npm:1.48.2": version: 1.48.2 resolution: "playwright@npm:1.48.2" dependencies: @@ -14842,6 +14851,21 @@ __metadata: languageName: node linkType: hard +"playwright@npm:^1.49.0": + version: 1.49.0 + resolution: "playwright@npm:1.49.0" + dependencies: + fsevents: 2.3.2 + playwright-core: 1.49.0 + dependenciesMeta: + fsevents: + optional: true + bin: + playwright: cli.js + checksum: f1bfb2fff65cad2ce996edab74ec231dfd21aeb5961554b765ce1eaec27efb87eaba37b00e91ecd27727b82861e5d8c230abe4960e93f6ada8be5ad1020df306 + languageName: node + linkType: hard + "pluralize@npm:^8.0.0": version: 8.0.0 resolution: "pluralize@npm:8.0.0" From f0194b05a1733ff7c776a3c40f5e9d5a0ef79b8e Mon Sep 17 00:00:00 2001 From: Cody Date: Fri, 6 Dec 2024 21:32:58 +0000 Subject: [PATCH 03/12] Verify flow fails, proof size read into bb is long 140B --- barretenberg/cpp/scripts/gzip-wasm.sh | 2 +- .../barretenberg/dsl/acir_proofs/c_bind.cpp | 4 +++- barretenberg/ts/scripts/build_wasm.sh | 6 ++--- barretenberg/ts/src/barretenberg/backend.ts | 8 +++---- barretenberg/ts/src/barretenberg_api/index.ts | 22 +++++++++---------- yarn-project/ivc-integration/src/index.ts | 15 +++---------- 6 files changed, 25 insertions(+), 32 deletions(-) diff --git a/barretenberg/cpp/scripts/gzip-wasm.sh b/barretenberg/cpp/scripts/gzip-wasm.sh index e5dd2ed1ea0e..fa52390df1c2 100755 --- a/barretenberg/cpp/scripts/gzip-wasm.sh +++ b/barretenberg/cpp/scripts/gzip-wasm.sh @@ -1,3 +1,3 @@ #!/bin/sh (cd ./build-wasm/bin && gzip barretenberg.wasm -c > barretenberg.wasm.gz) -(cd ./build-wasm-threads/bin && gzip barretenberg.wasm -c > barretenberg.wasm.gz) +(cd ./build-wasm-threads-assert/bin && gzip barretenberg.wasm -c > barretenberg.wasm.gz) diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/c_bind.cpp b/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/c_bind.cpp index cf09e9ef1485..0189698ba4dd 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/c_bind.cpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/c_bind.cpp @@ -334,14 +334,16 @@ WASM_EXPORT void acir_prove_aztec_client(uint8_t const* acir_stack, *out_vk = to_heap_buffer(to_buffer(ClientIVC::VerificationKey{ ivc.honk_vk, eccvm_vk, translator_vk })); } -WASM_EXPORT void acir_verify_client_ivc(uint8_t const* proof_buf, uint8_t const* vk_buf, bool* result) +WASM_EXPORT void acir_verify_aztec_client(uint8_t const* proof_buf, uint8_t const* vk_buf, bool* result) { // // TODO(https://github.com/AztecProtocol/barretenberg/issues/1163): Set these dynamically // init_bn254_crs(1); // init_grumpkin_crs(1 << 15); const auto proof = from_buffer(from_buffer>(proof_buf)); + vinfo("proof size : ", proof.size()); const auto vk = from_buffer(vk_buf); + vinfo("vk.mega log size : ", vk.mega->log_circuit_size); vk.mega->pcs_verification_key = std::make_shared>(); vk.eccvm->pcs_verification_key = diff --git a/barretenberg/ts/scripts/build_wasm.sh b/barretenberg/ts/scripts/build_wasm.sh index e0e283a20f27..6d1b07f6f0fe 100755 --- a/barretenberg/ts/scripts/build_wasm.sh +++ b/barretenberg/ts/scripts/build_wasm.sh @@ -4,7 +4,7 @@ set -e if [ -z "$SKIP_CPP_BUILD" ]; then # Build the wasms and strip debug symbols. cd ../cpp - cmake --preset wasm-threads -DCMAKE_MESSAGE_LOG_LEVEL=Warning && cmake --build --preset wasm-threads + cmake --preset wasm-threads-assert -DCMAKE_MESSAGE_LOG_LEVEL=Warning && cmake --build --preset wasm-threads-assert if [ -z "$SKIP_ST_BUILD" ]; then cmake --preset wasm -DCMAKE_MESSAGE_LOG_LEVEL=Warning && cmake --build --preset wasm fi @@ -20,5 +20,5 @@ fi # When building the browser bundle, both wasms are inlined directly. mkdir -p ./dest/node/barretenberg_wasm mkdir -p ./dest/node-cjs/barretenberg_wasm -cp ../cpp/build-wasm-threads/bin/barretenberg.wasm.gz ./dest/node/barretenberg_wasm/barretenberg-threads.wasm.gz -cp ../cpp/build-wasm-threads/bin/barretenberg.wasm.gz ./dest/node-cjs/barretenberg_wasm/barretenberg-threads.wasm.gz +cp ../cpp/build-wasm-threads-assert/bin/barretenberg.wasm.gz ./dest/node/barretenberg_wasm/barretenberg-threads.wasm.gz +cp ../cpp/build-wasm-threads-assert/bin/barretenberg.wasm.gz ./dest/node-cjs/barretenberg_wasm/barretenberg-threads.wasm.gz diff --git a/barretenberg/ts/src/barretenberg/backend.ts b/barretenberg/ts/src/barretenberg/backend.ts index 2815d1282587..424b011fa5b8 100644 --- a/barretenberg/ts/src/barretenberg/backend.ts +++ b/barretenberg/ts/src/barretenberg/backend.ts @@ -297,10 +297,10 @@ export class AztecClientBackend { return this.api.acirProveAztecClient(this.acirMsgpack, witnessMsgpack); } - // async verify(proof: Uint8Array): Promise { - // await this.instantiate(); - // return this.api.acirVerifyAztecClient(proof, vk); - // } + async verify(proof: Uint8Array, vk: Uint8Array): Promise { + await this.instantiate(); + return this.api.acirVerifyAztecClient(proof, vk); + } async proveAndVerify(witnessMsgpack: Uint8Array[]): Promise { await this.instantiate(); diff --git a/barretenberg/ts/src/barretenberg_api/index.ts b/barretenberg/ts/src/barretenberg_api/index.ts index 853e1549ad19..4f1750fdf468 100644 --- a/barretenberg/ts/src/barretenberg_api/index.ts +++ b/barretenberg/ts/src/barretenberg_api/index.ts @@ -571,17 +571,17 @@ export class BarretenbergApi { return [out[0], out[1]]; } - // async acirVerifyAztecClient(proofBuf: Uint8Array, vkBuf: Uint8Array): Promise { - // const inArgs = [proofBuf, vkBuf].map(serializeBufferable); - // const outTypes: OutputType[] = [BoolDeserializer()]; - // const result = await this.wasm.callWasmExport( - // 'acir_verify_aztec_client', - // inArgs, - // outTypes.map(t => t.SIZE_IN_BYTES), - // ); - // const out = result.map((r, i) => outTypes[i].fromBuffer(r)); - // return out[0]; - // } + async acirVerifyAztecClient(proofBuf: Uint8Array, vkBuf: Uint8Array): Promise { + const inArgs = [proofBuf, vkBuf].map(serializeBufferable); + const outTypes: OutputType[] = [BoolDeserializer()]; + const result = await this.wasm.callWasmExport( + 'acir_verify_aztec_client', + inArgs, + outTypes.map(t => t.SIZE_IN_BYTES), + ); + const out = result.map((r, i) => outTypes[i].fromBuffer(r)); + return out[0]; + } async acirProveUltraHonk(acirVec: Uint8Array, recursive: boolean, witnessVec: Uint8Array): Promise { const inArgs = [acirVec, recursive, witnessVec].map(serializeBufferable); diff --git a/yarn-project/ivc-integration/src/index.ts b/yarn-project/ivc-integration/src/index.ts index ccc0be0670aa..c854a8b8438a 100644 --- a/yarn-project/ivc-integration/src/index.ts +++ b/yarn-project/ivc-integration/src/index.ts @@ -249,20 +249,11 @@ export async function proveAndVerifyBrowser(bytecodes: string[], witnessStack: U const [proof, vk] = await backend.prove(witnessStack.map((arr: Uint8Array) => ungzip(arr))); logger(`proof length: ${proof.length}`); logger(`vk length: ${vk.length}`); - await backend.destroy(); // WORKTODO: share backend? - return true; + const verified = await backend.verify(proof, vk); + await backend.destroy(); + return verified; } -// export async function verifyBrowser(proof: Uint8Array, threads?: number): Promise { -// const { AztecClientBackend } = await import('@aztec/bb.js'); -// const preparedBytecodes = bytecodes.map(base64ToUint8Array).map((arr: Uint8Array) => ungzip(arr)); -// const backend = new AztecClientBackend(preparedBytecodes, { threads }); -// const verified = await backend.verify(proof); - -// await backend.destroy(); // WORKTODO: share backend -// return proof; -// } - export async function proveAndVerifyAztecClient( page: Page, bytecodes: string[], From 6597f6c0f9fe78c8cda3a0e5ce41330964c6840d Mon Sep 17 00:00:00 2001 From: Cody Date: Fri, 6 Dec 2024 23:29:27 +0000 Subject: [PATCH 04/12] Verify failing, logs not printing(..?) --- barretenberg/cpp/scripts/strip-wasm.sh | 2 +- .../cpp/src/barretenberg/common/serialize.hpp | 16 ++++++++++++++++ .../src/barretenberg/dsl/acir_proofs/c_bind.cpp | 10 ++++++++-- barretenberg/ts/scripts/build_wasm.sh | 6 +++--- 4 files changed, 28 insertions(+), 6 deletions(-) diff --git a/barretenberg/cpp/scripts/strip-wasm.sh b/barretenberg/cpp/scripts/strip-wasm.sh index 502bccb6d32a..7f5f0efcc650 100755 --- a/barretenberg/cpp/scripts/strip-wasm.sh +++ b/barretenberg/cpp/scripts/strip-wasm.sh @@ -1,3 +1,3 @@ #!/bin/sh /opt/wasi-sdk/bin/llvm-strip ./build-wasm/bin/barretenberg.wasm -/opt/wasi-sdk/bin/llvm-strip ./build-wasm-threads/bin/barretenberg.wasm +/opt/wasi-sdk/bin/llvm-strip ./build-wasm-threads-assert/bin/barretenberg.wasm diff --git a/barretenberg/cpp/src/barretenberg/common/serialize.hpp b/barretenberg/cpp/src/barretenberg/common/serialize.hpp index ac68aa702bf9..3894d69120c8 100644 --- a/barretenberg/cpp/src/barretenberg/common/serialize.hpp +++ b/barretenberg/cpp/src/barretenberg/common/serialize.hpp @@ -477,6 +477,22 @@ template std::vector to_buffer( return buf; } +// By default, if calling to_buffer on a vector of types, we don't prefix the vector size. +template std::vector to_buffer_with_size(T const& value) +{ + using serialize::write; + std::vector buf{ 0, 0, 0, 0 }; + write(buf, value); + uint32_t size = static_cast(buf.size()) - 4; + std::vector size_buf; + write(size_buf, size); + buf[0] = size_buf[0]; + buf[1] = size_buf[1]; + buf[2] = size_buf[2]; + buf[3] = size_buf[3]; + return buf; +} + // Some types to describe fixed size buffers for c_bind arguments. using in_buf32 = uint8_t const*; using out_buf32 = uint8_t*; diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/c_bind.cpp b/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/c_bind.cpp index 0189698ba4dd..a03b21723122 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/c_bind.cpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/c_bind.cpp @@ -327,11 +327,17 @@ WASM_EXPORT void acir_prove_aztec_client(uint8_t const* acir_stack, diff = std::chrono::duration_cast(end - start); vinfo("time to construct, accumulate, prove all circuits: ", diff.count()); - *out_proof = to_heap_buffer(to_buffer(proof)); // WORKTODO: include size? + auto buf = to_buffer_with_size(proof); + vinfo("first four bytes", buf[0], buf[1], buf[2], buf[3]); + *out_proof = to_heap_buffer(buf); // WORKTODO: include size? auto eccvm_vk = std::make_shared(ivc.goblin.get_eccvm_proving_key()); auto translator_vk = std::make_shared(ivc.goblin.get_translator_proving_key()); - *out_vk = to_heap_buffer(to_buffer(ClientIVC::VerificationKey{ ivc.honk_vk, eccvm_vk, translator_vk })); + + buf = to_buffer_with_size(ClientIVC::VerificationKey{ ivc.honk_vk, eccvm_vk, translator_vk }); + vinfo(buf[0], buf[1], buf[2], buf[3]); + vinfo("first four bytes", buf[0], buf[1], buf[2], buf[3]); + *out_vk = to_heap_buffer(buf); } WASM_EXPORT void acir_verify_aztec_client(uint8_t const* proof_buf, uint8_t const* vk_buf, bool* result) diff --git a/barretenberg/ts/scripts/build_wasm.sh b/barretenberg/ts/scripts/build_wasm.sh index 6d1b07f6f0fe..e0e283a20f27 100755 --- a/barretenberg/ts/scripts/build_wasm.sh +++ b/barretenberg/ts/scripts/build_wasm.sh @@ -4,7 +4,7 @@ set -e if [ -z "$SKIP_CPP_BUILD" ]; then # Build the wasms and strip debug symbols. cd ../cpp - cmake --preset wasm-threads-assert -DCMAKE_MESSAGE_LOG_LEVEL=Warning && cmake --build --preset wasm-threads-assert + cmake --preset wasm-threads -DCMAKE_MESSAGE_LOG_LEVEL=Warning && cmake --build --preset wasm-threads if [ -z "$SKIP_ST_BUILD" ]; then cmake --preset wasm -DCMAKE_MESSAGE_LOG_LEVEL=Warning && cmake --build --preset wasm fi @@ -20,5 +20,5 @@ fi # When building the browser bundle, both wasms are inlined directly. mkdir -p ./dest/node/barretenberg_wasm mkdir -p ./dest/node-cjs/barretenberg_wasm -cp ../cpp/build-wasm-threads-assert/bin/barretenberg.wasm.gz ./dest/node/barretenberg_wasm/barretenberg-threads.wasm.gz -cp ../cpp/build-wasm-threads-assert/bin/barretenberg.wasm.gz ./dest/node-cjs/barretenberg_wasm/barretenberg-threads.wasm.gz +cp ../cpp/build-wasm-threads/bin/barretenberg.wasm.gz ./dest/node/barretenberg_wasm/barretenberg-threads.wasm.gz +cp ../cpp/build-wasm-threads/bin/barretenberg.wasm.gz ./dest/node-cjs/barretenberg_wasm/barretenberg-threads.wasm.gz From 0c6e72afc50a564feeed67f2434c994539281376 Mon Sep 17 00:00:00 2001 From: Cody Date: Mon, 9 Dec 2024 20:56:54 +0000 Subject: [PATCH 05/12] it works --- barretenberg/cpp/scripts/gzip-wasm.sh | 2 +- barretenberg/cpp/scripts/strip-wasm.sh | 2 +- .../cpp/src/barretenberg/common/serialize.hpp | 2 +- .../barretenberg/dsl/acir_proofs/c_bind.cpp | 41 +++++++++++++++---- barretenberg/ts/src/barretenberg_api/index.ts | 4 +- barretenberg/ts/src/serialize/output_type.ts | 9 ++++ .../src/wasm_client_ivc_integration.test.ts | 11 +++-- 7 files changed, 56 insertions(+), 15 deletions(-) diff --git a/barretenberg/cpp/scripts/gzip-wasm.sh b/barretenberg/cpp/scripts/gzip-wasm.sh index fa52390df1c2..e5dd2ed1ea0e 100755 --- a/barretenberg/cpp/scripts/gzip-wasm.sh +++ b/barretenberg/cpp/scripts/gzip-wasm.sh @@ -1,3 +1,3 @@ #!/bin/sh (cd ./build-wasm/bin && gzip barretenberg.wasm -c > barretenberg.wasm.gz) -(cd ./build-wasm-threads-assert/bin && gzip barretenberg.wasm -c > barretenberg.wasm.gz) +(cd ./build-wasm-threads/bin && gzip barretenberg.wasm -c > barretenberg.wasm.gz) diff --git a/barretenberg/cpp/scripts/strip-wasm.sh b/barretenberg/cpp/scripts/strip-wasm.sh index 7f5f0efcc650..502bccb6d32a 100755 --- a/barretenberg/cpp/scripts/strip-wasm.sh +++ b/barretenberg/cpp/scripts/strip-wasm.sh @@ -1,3 +1,3 @@ #!/bin/sh /opt/wasi-sdk/bin/llvm-strip ./build-wasm/bin/barretenberg.wasm -/opt/wasi-sdk/bin/llvm-strip ./build-wasm-threads-assert/bin/barretenberg.wasm +/opt/wasi-sdk/bin/llvm-strip ./build-wasm-threads/bin/barretenberg.wasm diff --git a/barretenberg/cpp/src/barretenberg/common/serialize.hpp b/barretenberg/cpp/src/barretenberg/common/serialize.hpp index 3894d69120c8..500278d91f3f 100644 --- a/barretenberg/cpp/src/barretenberg/common/serialize.hpp +++ b/barretenberg/cpp/src/barretenberg/common/serialize.hpp @@ -483,7 +483,7 @@ template std::vector to_buffer_with_size(T const& value) using serialize::write; std::vector buf{ 0, 0, 0, 0 }; write(buf, value); - uint32_t size = static_cast(buf.size()) - 4; + uint32_t size = static_cast(buf.size() - 4); std::vector size_buf; write(size_buf, size); buf[0] = size_buf[0]; diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/c_bind.cpp b/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/c_bind.cpp index a03b21723122..5162181298d5 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/c_bind.cpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/c_bind.cpp @@ -15,6 +15,16 @@ #include #include +const auto print_buffer = [](const auto buf) { + std::cerr << std::showbase << std::hex; + std::cerr << static_cast(buf[0]) << static_cast(buf[1]) << static_cast(buf[2]) + << static_cast(buf[3]) << static_cast(buf[4]) << static_cast(buf[5]) + << static_cast(buf[6]) << static_cast(buf[7]) << static_cast(buf[8]) + << static_cast(buf[9]) << static_cast(buf[10]) << static_cast(buf[11]) + << static_cast(buf[12]) << static_cast(buf[13]) << static_cast(buf[14]) + << static_cast(buf[15]); +}; + WASM_EXPORT void acir_get_circuit_sizes( uint8_t const* acir_vec, bool const* recursive, bool const* honk_recursion, uint32_t* total, uint32_t* subgroup) { @@ -327,17 +337,24 @@ WASM_EXPORT void acir_prove_aztec_client(uint8_t const* acir_stack, diff = std::chrono::duration_cast(end - start); vinfo("time to construct, accumulate, prove all circuits: ", diff.count()); - auto buf = to_buffer_with_size(proof); - vinfo("first four bytes", buf[0], buf[1], buf[2], buf[3]); + vinfo("first 16 bytes of proof: "); + std::vector buf = to_buffer(proof); + print_buffer(buf); + + vinfo("first 16 bytes of heap buffer: "); *out_proof = to_heap_buffer(buf); // WORKTODO: include size? + print_buffer(*out_proof); auto eccvm_vk = std::make_shared(ivc.goblin.get_eccvm_proving_key()); auto translator_vk = std::make_shared(ivc.goblin.get_translator_proving_key()); - buf = to_buffer_with_size(ClientIVC::VerificationKey{ ivc.honk_vk, eccvm_vk, translator_vk }); - vinfo(buf[0], buf[1], buf[2], buf[3]); - vinfo("first four bytes", buf[0], buf[1], buf[2], buf[3]); + // vinfo("first entry of honk vk: ", ivc.honk_vk.get()[0]); + buf = to_buffer(ClientIVC::VerificationKey{ ivc.honk_vk, eccvm_vk, translator_vk }); + vinfo("first 16 bytes of vk buffer: "); + print_buffer(buf); *out_vk = to_heap_buffer(buf); + vinfo("first 16 bytes of vk heap buffer: "); + print_buffer(*out_vk); } WASM_EXPORT void acir_verify_aztec_client(uint8_t const* proof_buf, uint8_t const* vk_buf, bool* result) @@ -345,10 +362,20 @@ WASM_EXPORT void acir_verify_aztec_client(uint8_t const* proof_buf, uint8_t cons // // TODO(https://github.com/AztecProtocol/barretenberg/issues/1163): Set these dynamically // init_bn254_crs(1); // init_grumpkin_crs(1 << 15); + auto proof_vec = from_buffer>(proof_buf); + vinfo("read proof_vec, first 16 bytes"); + print_buffer(proof_vec); - const auto proof = from_buffer(from_buffer>(proof_buf)); + const auto proof = from_buffer(proof_vec); vinfo("proof size : ", proof.size()); - const auto vk = from_buffer(vk_buf); + vinfo("read mega proofs, first entry"); + vinfo(proof.mega_proof[0]); + + auto vk_vec = from_buffer>(vk_buf); + vinfo("read vk_vec, first 16 bytes: "); + print_buffer(vk_vec); + const auto vk = from_buffer(vk_vec); + // info(*vk.mega); vinfo("vk.mega log size : ", vk.mega->log_circuit_size); vk.mega->pcs_verification_key = std::make_shared>(); diff --git a/barretenberg/ts/src/barretenberg_api/index.ts b/barretenberg/ts/src/barretenberg_api/index.ts index 4f1750fdf468..1a91f02ff56e 100644 --- a/barretenberg/ts/src/barretenberg_api/index.ts +++ b/barretenberg/ts/src/barretenberg_api/index.ts @@ -566,8 +566,8 @@ export class BarretenbergApi { outTypes.map(t => t.SIZE_IN_BYTES), ); const out = result.map((r, i) => outTypes[i].fromBuffer(r)); - console.log(`number of things in outTypes: ${outTypes.length}`); - console.log(`number of things in out: ${out.length}`); + // console.log(`number of things in outTypes: ${outTypes.length}`); + // console.log(`number of things in out: ${out.length}`); return [out[0], out[1]]; } diff --git a/barretenberg/ts/src/serialize/output_type.ts b/barretenberg/ts/src/serialize/output_type.ts index bb4f7778b402..dafedf63ffa0 100644 --- a/barretenberg/ts/src/serialize/output_type.ts +++ b/barretenberg/ts/src/serialize/output_type.ts @@ -51,3 +51,12 @@ export function StringDeserializer(): OutputType { }, }; } + +// export function MsgpackDeserializer(): OutputType { +// return { +// fromBuffer: (buf: Uint8Array | BufferReader) => { +// const reader = BufferReader.asReader(buf); +// return reader.readString(); +// }, +// }; +// } diff --git a/yarn-project/ivc-integration/src/wasm_client_ivc_integration.test.ts b/yarn-project/ivc-integration/src/wasm_client_ivc_integration.test.ts index 5f105b7f71ec..f894378f72cd 100644 --- a/yarn-project/ivc-integration/src/wasm_client_ivc_integration.test.ts +++ b/yarn-project/ivc-integration/src/wasm_client_ivc_integration.test.ts @@ -1,6 +1,7 @@ import { createDebugLogger } from '@aztec/foundation/log'; import { jest } from '@jest/globals'; +import { writeFileSync } from 'fs'; import { ungzip } from 'pako'; import { @@ -55,8 +56,12 @@ describe('Client IVC Integration', () => { { threads }, ); - const verified = await backend.proveAndVerify(witnessStack.map((arr: Uint8Array) => ungzip(arr))); - logger.debug(`finished running proveAndVerify ${verified}`); + const [proof, vk] = await backend.prove(witnessStack.map((arr: Uint8Array) => ungzip(arr))); + writeFileSync('proof.bin', proof); + writeFileSync('vk.bin', vk); + logger.debug(`proof length: ${proof.length}`); + logger.debug(`vk length: ${vk.length}`); + const verified = await backend.verify(proof, vk); await backend.destroy(); return verified; } @@ -65,7 +70,7 @@ describe('Client IVC Integration', () => { // 1. Run a mock app that creates two commitments // 2. Run the init kernel to process the app run // 3. Run the tail kernel to finish the client IVC chain. - it('Should generate a verifiable client IVC proof from a simple mock tx via bb.js', async () => { + it.only('Should generate a verifiable client IVC proof from a simple mock tx via bb.js', async () => { const tx = { number_of_calls: '0x1', }; From 589c402d729c3df39da48486d2b019a2756cf3c4 Mon Sep 17 00:00:00 2001 From: Cody Date: Mon, 9 Dec 2024 21:42:55 +0000 Subject: [PATCH 06/12] Clean up --- .../cpp/src/barretenberg/common/serialize.hpp | 16 ----- .../barretenberg/dsl/acir_proofs/c_bind.cpp | 61 +++++-------------- barretenberg/ts/src/barretenberg_api/index.ts | 2 - barretenberg/ts/src/serialize/output_type.ts | 9 --- yarn-project/ivc-integration/src/index.ts | 2 - .../src/wasm_client_ivc_integration.test.ts | 5 -- 6 files changed, 14 insertions(+), 81 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/common/serialize.hpp b/barretenberg/cpp/src/barretenberg/common/serialize.hpp index 500278d91f3f..ac68aa702bf9 100644 --- a/barretenberg/cpp/src/barretenberg/common/serialize.hpp +++ b/barretenberg/cpp/src/barretenberg/common/serialize.hpp @@ -477,22 +477,6 @@ template std::vector to_buffer( return buf; } -// By default, if calling to_buffer on a vector of types, we don't prefix the vector size. -template std::vector to_buffer_with_size(T const& value) -{ - using serialize::write; - std::vector buf{ 0, 0, 0, 0 }; - write(buf, value); - uint32_t size = static_cast(buf.size() - 4); - std::vector size_buf; - write(size_buf, size); - buf[0] = size_buf[0]; - buf[1] = size_buf[1]; - buf[2] = size_buf[2]; - buf[3] = size_buf[3]; - return buf; -} - // Some types to describe fixed size buffers for c_bind arguments. using in_buf32 = uint8_t const*; using out_buf32 = uint8_t*; diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/c_bind.cpp b/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/c_bind.cpp index 5162181298d5..3765f500fd64 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/c_bind.cpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/c_bind.cpp @@ -10,21 +10,10 @@ #include "barretenberg/plonk/proof_system/proving_key/serialize.hpp" #include "barretenberg/plonk/proof_system/verification_key/verification_key.hpp" #include "barretenberg/serialize/msgpack.hpp" -#include "barretenberg/srs/global_crs.hpp" // WORKTODO: unused? #include "honk_contract.hpp" #include #include -const auto print_buffer = [](const auto buf) { - std::cerr << std::showbase << std::hex; - std::cerr << static_cast(buf[0]) << static_cast(buf[1]) << static_cast(buf[2]) - << static_cast(buf[3]) << static_cast(buf[4]) << static_cast(buf[5]) - << static_cast(buf[6]) << static_cast(buf[7]) << static_cast(buf[8]) - << static_cast(buf[9]) << static_cast(buf[10]) << static_cast(buf[11]) - << static_cast(buf[12]) << static_cast(buf[13]) << static_cast(buf[14]) - << static_cast(buf[15]); -}; - WASM_EXPORT void acir_get_circuit_sizes( uint8_t const* acir_vec, bool const* recursive, bool const* honk_recursion, uint32_t* total, uint32_t* subgroup) { @@ -332,59 +321,37 @@ WASM_EXPORT void acir_prove_aztec_client(uint8_t const* acir_stack, vinfo("calling ivc.prove ..."); ClientIVC::Proof proof = ivc.prove(); - end = std::chrono::steady_clock::now(); diff = std::chrono::duration_cast(end - start); vinfo("time to construct, accumulate, prove all circuits: ", diff.count()); - vinfo("first 16 bytes of proof: "); - std::vector buf = to_buffer(proof); - print_buffer(buf); - - vinfo("first 16 bytes of heap buffer: "); - *out_proof = to_heap_buffer(buf); // WORKTODO: include size? - print_buffer(*out_proof); + start = std::chrono::steady_clock::now(); + *out_proof = to_heap_buffer(to_buffer(proof)); + end = std::chrono::steady_clock::now(); + diff = std::chrono::duration_cast(end - start); + vinfo("time to serialize proof: ", diff.count()); + start = std::chrono::steady_clock::now(); auto eccvm_vk = std::make_shared(ivc.goblin.get_eccvm_proving_key()); auto translator_vk = std::make_shared(ivc.goblin.get_translator_proving_key()); - - // vinfo("first entry of honk vk: ", ivc.honk_vk.get()[0]); - buf = to_buffer(ClientIVC::VerificationKey{ ivc.honk_vk, eccvm_vk, translator_vk }); - vinfo("first 16 bytes of vk buffer: "); - print_buffer(buf); - *out_vk = to_heap_buffer(buf); - vinfo("first 16 bytes of vk heap buffer: "); - print_buffer(*out_vk); + *out_vk = to_heap_buffer(to_buffer(ClientIVC::VerificationKey{ ivc.honk_vk, eccvm_vk, translator_vk })); + end = std::chrono::steady_clock::now(); + diff = std::chrono::duration_cast(end - start); + vinfo("time to serialize proof: ", diff.count()); } WASM_EXPORT void acir_verify_aztec_client(uint8_t const* proof_buf, uint8_t const* vk_buf, bool* result) { - // // TODO(https://github.com/AztecProtocol/barretenberg/issues/1163): Set these dynamically - // init_bn254_crs(1); - // init_grumpkin_crs(1 << 15); - auto proof_vec = from_buffer>(proof_buf); - vinfo("read proof_vec, first 16 bytes"); - print_buffer(proof_vec); - - const auto proof = from_buffer(proof_vec); - vinfo("proof size : ", proof.size()); - vinfo("read mega proofs, first entry"); - vinfo(proof.mega_proof[0]); - - auto vk_vec = from_buffer>(vk_buf); - vinfo("read vk_vec, first 16 bytes: "); - print_buffer(vk_vec); - const auto vk = from_buffer(vk_vec); - // info(*vk.mega); - vinfo("vk.mega log size : ", vk.mega->log_circuit_size); + + const auto proof = from_buffer(from_buffer>(proof_buf)); + const auto vk = from_buffer(from_buffer>(vk_buf)); vk.mega->pcs_verification_key = std::make_shared>(); vk.eccvm->pcs_verification_key = std::make_shared>(vk.eccvm->circuit_size + 1); vk.translator->pcs_verification_key = std::make_shared>(); - const bool verified = ClientIVC::verify(proof, vk); - *result = verified; + *result = ClientIVC::verify(proof, vk); } WASM_EXPORT void acir_prove_ultra_honk(uint8_t const* acir_vec, diff --git a/barretenberg/ts/src/barretenberg_api/index.ts b/barretenberg/ts/src/barretenberg_api/index.ts index 1a91f02ff56e..1e642cec1743 100644 --- a/barretenberg/ts/src/barretenberg_api/index.ts +++ b/barretenberg/ts/src/barretenberg_api/index.ts @@ -566,8 +566,6 @@ export class BarretenbergApi { outTypes.map(t => t.SIZE_IN_BYTES), ); const out = result.map((r, i) => outTypes[i].fromBuffer(r)); - // console.log(`number of things in outTypes: ${outTypes.length}`); - // console.log(`number of things in out: ${out.length}`); return [out[0], out[1]]; } diff --git a/barretenberg/ts/src/serialize/output_type.ts b/barretenberg/ts/src/serialize/output_type.ts index dafedf63ffa0..bb4f7778b402 100644 --- a/barretenberg/ts/src/serialize/output_type.ts +++ b/barretenberg/ts/src/serialize/output_type.ts @@ -51,12 +51,3 @@ export function StringDeserializer(): OutputType { }, }; } - -// export function MsgpackDeserializer(): OutputType { -// return { -// fromBuffer: (buf: Uint8Array | BufferReader) => { -// const reader = BufferReader.asReader(buf); -// return reader.readString(); -// }, -// }; -// } diff --git a/yarn-project/ivc-integration/src/index.ts b/yarn-project/ivc-integration/src/index.ts index c854a8b8438a..001809b2e8a1 100644 --- a/yarn-project/ivc-integration/src/index.ts +++ b/yarn-project/ivc-integration/src/index.ts @@ -247,8 +247,6 @@ export async function proveAndVerifyBrowser(bytecodes: string[], witnessStack: U const preparedBytecodes = bytecodes.map(base64ToUint8Array).map((arr: Uint8Array) => ungzip(arr)); const backend = new AztecClientBackend(preparedBytecodes, { threads }); const [proof, vk] = await backend.prove(witnessStack.map((arr: Uint8Array) => ungzip(arr))); - logger(`proof length: ${proof.length}`); - logger(`vk length: ${vk.length}`); const verified = await backend.verify(proof, vk); await backend.destroy(); return verified; diff --git a/yarn-project/ivc-integration/src/wasm_client_ivc_integration.test.ts b/yarn-project/ivc-integration/src/wasm_client_ivc_integration.test.ts index f894378f72cd..0f47d5792665 100644 --- a/yarn-project/ivc-integration/src/wasm_client_ivc_integration.test.ts +++ b/yarn-project/ivc-integration/src/wasm_client_ivc_integration.test.ts @@ -1,7 +1,6 @@ import { createDebugLogger } from '@aztec/foundation/log'; import { jest } from '@jest/globals'; -import { writeFileSync } from 'fs'; import { ungzip } from 'pako'; import { @@ -57,10 +56,6 @@ describe('Client IVC Integration', () => { ); const [proof, vk] = await backend.prove(witnessStack.map((arr: Uint8Array) => ungzip(arr))); - writeFileSync('proof.bin', proof); - writeFileSync('vk.bin', vk); - logger.debug(`proof length: ${proof.length}`); - logger.debug(`vk length: ${vk.length}`); const verified = await backend.verify(proof, vk); await backend.destroy(); return verified; From d445cb514480599a2170d5eef23dd49e7de36823 Mon Sep 17 00:00:00 2001 From: Cody Date: Mon, 9 Dec 2024 22:16:22 +0000 Subject: [PATCH 07/12] Rename and shuffle --- .../browser_client_ivc_integration.test.ts | 54 +++++++++++++++++-- yarn-project/ivc-integration/src/index.ts | 31 ++++------- yarn-project/ivc-integration/src/serve.ts | 6 +-- .../src/wasm_client_ivc_integration.test.ts | 35 ++---------- 4 files changed, 67 insertions(+), 59 deletions(-) diff --git a/yarn-project/ivc-integration/src/browser_client_ivc_integration.test.ts b/yarn-project/ivc-integration/src/browser_client_ivc_integration.test.ts index 41e1e8b356cb..ada5bffd82b9 100644 --- a/yarn-project/ivc-integration/src/browser_client_ivc_integration.test.ts +++ b/yarn-project/ivc-integration/src/browser_client_ivc_integration.test.ts @@ -1,9 +1,18 @@ import { jest } from '@jest/globals'; import chalk from 'chalk'; import createDebug from 'debug'; -import { type Browser, type Page, chromium } from 'playwright'; +import { + type Browser, + type Page, + chromium, + /* firefox, webkit */ +} from 'playwright'; -import { generate3FunctionTestingIVCStack, proveAndVerifyAztecClient } from './index.js'; +import { + generate3FunctionTestingIVCStack, + generate6FunctionTestingIVCStack, + proveThenVerifyAztecClient, +} from './index.js'; /* eslint-disable camelcase */ @@ -40,6 +49,24 @@ function formatAndPrintLog(message: string): void { logger(formattedMessage); } +export async function proveThenVerifyAztecClientBrowser( + page: Page, + bytecodes: string[], + witnessStack: Uint8Array[], +): Promise { + const threads = 16; + + const result: boolean = await page.evaluate( + ([acir, witness, numThreads]) => { + (window as any).proveThenVerifyAztecClient = proveThenVerifyAztecClient; + return (window as any).proveThenVerifyAztecClient(acir, witness, numThreads); + }, + [bytecodes, witnessStack, threads], + ); + + return result; +} + describe('Client IVC Integration', () => { let page: Page; let browser: Browser; @@ -64,7 +91,26 @@ describe('Client IVC Integration', () => { const [bytecodes, witnessStack] = await generate3FunctionTestingIVCStack(); logger(`calling prove then verify...`); - const result = await proveAndVerifyAztecClient(page, bytecodes, witnessStack); - expect(result).toEqual(true); + const verifyResult = await proveThenVerifyAztecClientBrowser(page, bytecodes, witnessStack); + logger(`generated and verified proof. result: ${verifyResult}`); + + expect(verifyResult).toEqual(true); + }); + + // This test will verify a client IVC proof of a more complex tx: + // 1. Run a mock app that creates two commitments + // 2. Run the init kernel to process the app run + // 3. Run a mock app that reads one of those commitments + // 4. Run the inner kernel to process the second app run + // 5. Run the reset kernel to process the read request emitted by the reader app + // 6. Run the tail kernel to finish the client IVC chain + it('Should generate a verifiable client IVC proof from a simple mock tx via bb.js', async () => { + const [bytecodes, witnessStack] = await generate6FunctionTestingIVCStack(); + + logger(`calling prove and verify...`); + const verifyResult = await proveThenVerifyAztecClientBrowser(page, bytecodes, witnessStack); + logger(`generated and verified proof. result: ${verifyResult}`); + + expect(verifyResult).toEqual(true); }); }); diff --git a/yarn-project/ivc-integration/src/index.ts b/yarn-project/ivc-integration/src/index.ts index 001809b2e8a1..7a038b5b1e30 100644 --- a/yarn-project/ivc-integration/src/index.ts +++ b/yarn-project/ivc-integration/src/index.ts @@ -242,30 +242,19 @@ function base64ToUint8Array(base64: string): Uint8Array { return Uint8Array.from(atob(base64), c => c.charCodeAt(0)); } -export async function proveAndVerifyBrowser(bytecodes: string[], witnessStack: Uint8Array[], threads?: number) { - const { AztecClientBackend } = await import('@aztec/bb.js'); - const preparedBytecodes = bytecodes.map(base64ToUint8Array).map((arr: Uint8Array) => ungzip(arr)); - const backend = new AztecClientBackend(preparedBytecodes, { threads }); - const [proof, vk] = await backend.prove(witnessStack.map((arr: Uint8Array) => ungzip(arr))); - const verified = await backend.verify(proof, vk); - await backend.destroy(); - return verified; -} - -export async function proveAndVerifyAztecClient( - page: Page, +export async function proveThenVerifyAztecClient( bytecodes: string[], witnessStack: Uint8Array[], + threads?: number, ): Promise { - const threads = 16; - - const result: boolean = await page.evaluate( - ([acir, witness, numThreads]) => { - (window as any).proveAndVerifyBrowser = proveAndVerifyBrowser; - return (window as any).proveAndVerifyBrowser(acir, witness, numThreads); - }, - [bytecodes, witnessStack, threads], + const { AztecClientBackend } = await import('@aztec/bb.js'); + const backend = new AztecClientBackend( + bytecodes.map(base64ToUint8Array).map((arr: Uint8Array) => ungzip(arr)), + { threads }, ); - return result; + const [proof, vk] = await backend.prove(witnessStack.map((arr: Uint8Array) => ungzip(arr))); + const verified = await backend.verify(proof, vk); + await backend.destroy(); + return verified; } diff --git a/yarn-project/ivc-integration/src/serve.ts b/yarn-project/ivc-integration/src/serve.ts index b16a125a05cb..be23f1055562 100644 --- a/yarn-project/ivc-integration/src/serve.ts +++ b/yarn-project/ivc-integration/src/serve.ts @@ -1,6 +1,6 @@ import createDebug from 'debug'; -import { generate3FunctionTestingIVCStack, proveAndVerifyBrowser } from './index.js'; +import { generate3FunctionTestingIVCStack, proveThenVerifyAztecClient } from './index.js'; createDebug.enable('*'); const logger = createDebug('aztec:ivc-test'); @@ -78,7 +78,7 @@ function setupConsoleOutput() { }; } -(window as any).proveAndVerifyBrowser = proveAndVerifyBrowser; +(window as any).proveThenVerifyAztecClient = proveThenVerifyAztecClient; document.addEventListener('DOMContentLoaded', function () { setupConsoleOutput(); // Initialize console output capture @@ -89,7 +89,7 @@ document.addEventListener('DOMContentLoaded', function () { logger(`generating circuit and witness...`); const [bytecodes, witnessStack] = await generate3FunctionTestingIVCStack(); logger(`done. proving and verifying...`); - const verified = await proveAndVerifyBrowser(bytecodes, witnessStack); + const verified = await proveThenVerifyAztecClient(bytecodes, witnessStack); logger(`verified? ${verified}`); }); document.body.appendChild(button); diff --git a/yarn-project/ivc-integration/src/wasm_client_ivc_integration.test.ts b/yarn-project/ivc-integration/src/wasm_client_ivc_integration.test.ts index 0f47d5792665..c55f27f274ac 100644 --- a/yarn-project/ivc-integration/src/wasm_client_ivc_integration.test.ts +++ b/yarn-project/ivc-integration/src/wasm_client_ivc_integration.test.ts @@ -1,7 +1,6 @@ import { createDebugLogger } from '@aztec/foundation/log'; import { jest } from '@jest/globals'; -import { ungzip } from 'pako'; import { MOCK_MAX_COMMITMENTS_PER_TX, @@ -17,6 +16,7 @@ import { MockPrivateKernelResetVk, MockPrivateKernelTailCircuit, getVkAsFields, + proveThenVerifyAztecClient, witnessGenCreatorAppMockCircuit, witnessGenMockPrivateKernelInitCircuit, witnessGenMockPrivateKernelInnerCircuit, @@ -34,38 +34,11 @@ jest.setTimeout(120_000); describe('Client IVC Integration', () => { beforeEach(async () => {}); - function base64ToUint8Array(base64: string) { - const binaryString = atob(base64); - const len = binaryString.length; - const bytes = new Uint8Array(len); - for (let i = 0; i < len; i++) { - bytes[i] = binaryString.charCodeAt(i); - } - return bytes; - } - - async function proveAndVerifyAztecClient( - witnessStack: Uint8Array[], - bytecodes: string[], - threads?: number, - ): Promise { - const { AztecClientBackend } = await import('@aztec/bb.js'); - const backend = new AztecClientBackend( - bytecodes.map(base64ToUint8Array).map((arr: Uint8Array) => ungzip(arr)), - { threads }, - ); - - const [proof, vk] = await backend.prove(witnessStack.map((arr: Uint8Array) => ungzip(arr))); - const verified = await backend.verify(proof, vk); - await backend.destroy(); - return verified; - } - // This test will verify a client IVC proof of a simple tx: // 1. Run a mock app that creates two commitments // 2. Run the init kernel to process the app run // 3. Run the tail kernel to finish the client IVC chain. - it.only('Should generate a verifiable client IVC proof from a simple mock tx via bb.js', async () => { + it('Should generate a verifiable client IVC proof from a simple mock tx via bb.js', async () => { const tx = { number_of_calls: '0x1', }; @@ -96,7 +69,7 @@ describe('Client IVC Integration', () => { const witnessStack = [appWitnessGenResult.witness, initWitnessGenResult.witness, tailWitnessGenResult.witness]; logger.debug('built witness stack'); - const verifyResult = await proveAndVerifyAztecClient(witnessStack, bytecodes); + const verifyResult = await proveThenVerifyAztecClient(bytecodes, witnessStack); logger.debug(`generated and verified proof. result: ${verifyResult}`); expect(verifyResult).toEqual(true); @@ -163,7 +136,7 @@ describe('Client IVC Integration', () => { tailWitnessGenResult.witness, ]; - const verifyResult = await proveAndVerifyAztecClient(witnessStack, bytecodes); + const verifyResult = await proveThenVerifyAztecClient(bytecodes, witnessStack); logger.debug(`generated and verified proof. result: ${verifyResult}`); expect(verifyResult).toEqual(true); From 98ca403716a8cffc63453da2d2f9ac4250d48aa9 Mon Sep 17 00:00:00 2001 From: Cody Date: Mon, 9 Dec 2024 22:19:57 +0000 Subject: [PATCH 08/12] Tweak comments --- .../cpp/src/barretenberg/dsl/acir_proofs/c_bind.cpp | 2 +- .../src/browser_client_ivc_integration.test.ts | 6 +++--- .../ivc-integration/src/wasm_client_ivc_integration.test.ts | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/c_bind.cpp b/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/c_bind.cpp index 3765f500fd64..6f856e9d4151 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/c_bind.cpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/c_bind.cpp @@ -337,7 +337,7 @@ WASM_EXPORT void acir_prove_aztec_client(uint8_t const* acir_stack, *out_vk = to_heap_buffer(to_buffer(ClientIVC::VerificationKey{ ivc.honk_vk, eccvm_vk, translator_vk })); end = std::chrono::steady_clock::now(); diff = std::chrono::duration_cast(end - start); - vinfo("time to serialize proof: ", diff.count()); + vinfo("time to serialize vk: ", diff.count()); } WASM_EXPORT void acir_verify_aztec_client(uint8_t const* proof_buf, uint8_t const* vk_buf, bool* result) diff --git a/yarn-project/ivc-integration/src/browser_client_ivc_integration.test.ts b/yarn-project/ivc-integration/src/browser_client_ivc_integration.test.ts index ada5bffd82b9..74768e278b29 100644 --- a/yarn-project/ivc-integration/src/browser_client_ivc_integration.test.ts +++ b/yarn-project/ivc-integration/src/browser_client_ivc_integration.test.ts @@ -92,7 +92,7 @@ describe('Client IVC Integration', () => { logger(`calling prove then verify...`); const verifyResult = await proveThenVerifyAztecClientBrowser(page, bytecodes, witnessStack); - logger(`generated and verified proof. result: ${verifyResult}`); + logger(`generated then verified proof. result: ${verifyResult}`); expect(verifyResult).toEqual(true); }); @@ -107,9 +107,9 @@ describe('Client IVC Integration', () => { it('Should generate a verifiable client IVC proof from a simple mock tx via bb.js', async () => { const [bytecodes, witnessStack] = await generate6FunctionTestingIVCStack(); - logger(`calling prove and verify...`); + logger(`calling prove then verify...`); const verifyResult = await proveThenVerifyAztecClientBrowser(page, bytecodes, witnessStack); - logger(`generated and verified proof. result: ${verifyResult}`); + logger(`generated then verified proof. result: ${verifyResult}`); expect(verifyResult).toEqual(true); }); diff --git a/yarn-project/ivc-integration/src/wasm_client_ivc_integration.test.ts b/yarn-project/ivc-integration/src/wasm_client_ivc_integration.test.ts index c55f27f274ac..09611cae6058 100644 --- a/yarn-project/ivc-integration/src/wasm_client_ivc_integration.test.ts +++ b/yarn-project/ivc-integration/src/wasm_client_ivc_integration.test.ts @@ -70,7 +70,7 @@ describe('Client IVC Integration', () => { logger.debug('built witness stack'); const verifyResult = await proveThenVerifyAztecClient(bytecodes, witnessStack); - logger.debug(`generated and verified proof. result: ${verifyResult}`); + logger.debug(`generated then verified proof. result: ${verifyResult}`); expect(verifyResult).toEqual(true); }); @@ -137,7 +137,7 @@ describe('Client IVC Integration', () => { ]; const verifyResult = await proveThenVerifyAztecClient(bytecodes, witnessStack); - logger.debug(`generated and verified proof. result: ${verifyResult}`); + logger.debug(`generated then verified proof. result: ${verifyResult}`); expect(verifyResult).toEqual(true); }); From 99404856a51cbaa58f076c55a419b6cc8f6ea6a2 Mon Sep 17 00:00:00 2001 From: Cody Date: Mon, 9 Dec 2024 22:22:35 +0000 Subject: [PATCH 09/12] Revert playright version bump --- yarn-project/ivc-integration/package.json | 2 +- yarn-project/yarn.lock | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/yarn-project/ivc-integration/package.json b/yarn-project/ivc-integration/package.json index 4389ae09ede2..54c7f4097123 100644 --- a/yarn-project/ivc-integration/package.json +++ b/yarn-project/ivc-integration/package.json @@ -72,7 +72,7 @@ "chalk": "^5.3.0", "change-case": "^5.4.4", "pako": "^2.1.0", - "playwright": "^1.49.0", + "playwright": "^1.48.2", "puppeteer": "^22.4.1", "tslib": "^2.4.0" }, diff --git a/yarn-project/yarn.lock b/yarn-project/yarn.lock index 7bdbf0feb0b0..2a65a236703d 100644 --- a/yarn-project/yarn.lock +++ b/yarn-project/yarn.lock @@ -730,7 +730,7 @@ __metadata: levelup: ^5.1.1 memdown: ^6.1.1 pako: ^2.1.0 - playwright: ^1.49.0 + playwright: ^1.48.2 puppeteer: ^22.4.1 resolve-typescript-plugin: ^2.0.1 serve: ^14.2.1 From eb3bd8937a75584959e81c92e0373bd11f315533 Mon Sep 17 00:00:00 2001 From: Cody Date: Mon, 9 Dec 2024 22:24:11 +0000 Subject: [PATCH 10/12] Revert yarn.lock change --- yarn-project/yarn.lock | 26 +------------------------- 1 file changed, 1 insertion(+), 25 deletions(-) diff --git a/yarn-project/yarn.lock b/yarn-project/yarn.lock index 2a65a236703d..c53310ab30d3 100644 --- a/yarn-project/yarn.lock +++ b/yarn-project/yarn.lock @@ -14827,16 +14827,7 @@ __metadata: languageName: node linkType: hard -"playwright-core@npm:1.49.0": - version: 1.49.0 - resolution: "playwright-core@npm:1.49.0" - bin: - playwright-core: cli.js - checksum: d8423ad0cab2e672856529bf6b98b406e7e605da098b847b9b54ee8ebd8d716ed8880a9afff4b38f0a2e3f59b95661c74589116ce3ff2b5e0ae3561507086c94 - languageName: node - linkType: hard - -"playwright@npm:1.48.2": +"playwright@npm:1.48.2, playwright@npm:^1.48.2": version: 1.48.2 resolution: "playwright@npm:1.48.2" dependencies: @@ -14851,21 +14842,6 @@ __metadata: languageName: node linkType: hard -"playwright@npm:^1.49.0": - version: 1.49.0 - resolution: "playwright@npm:1.49.0" - dependencies: - fsevents: 2.3.2 - playwright-core: 1.49.0 - dependenciesMeta: - fsevents: - optional: true - bin: - playwright: cli.js - checksum: f1bfb2fff65cad2ce996edab74ec231dfd21aeb5961554b765ce1eaec27efb87eaba37b00e91ecd27727b82861e5d8c230abe4960e93f6ada8be5ad1020df306 - languageName: node - linkType: hard - "pluralize@npm:^8.0.0": version: 8.0.0 resolution: "pluralize@npm:8.0.0" From 65e3897db9d56d45f1f10fab5a2bce27025a9990 Mon Sep 17 00:00:00 2001 From: Cody Date: Mon, 9 Dec 2024 23:16:57 +0000 Subject: [PATCH 11/12] Remove unused import --- yarn-project/ivc-integration/src/index.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/yarn-project/ivc-integration/src/index.ts b/yarn-project/ivc-integration/src/index.ts index 7a038b5b1e30..d3fc886bf437 100644 --- a/yarn-project/ivc-integration/src/index.ts +++ b/yarn-project/ivc-integration/src/index.ts @@ -3,7 +3,6 @@ import { type CLIENT_IVC_VERIFICATION_KEY_LENGTH_IN_FIELDS } from '@aztec/circui import { type ForeignCallOutput, Noir } from '@noir-lang/noir_js'; import createDebug from 'debug'; import { ungzip } from 'pako'; -import { type Page } from 'playwright'; import MockAppCreatorCircuit from '../artifacts/app_creator.json' assert { type: 'json' }; import MockAppReaderCircuit from '../artifacts/app_reader.json' assert { type: 'json' }; From 2500fe29e858aa05b5b30a3f5bfddada60af727c Mon Sep 17 00:00:00 2001 From: Cody Date: Tue, 10 Dec 2024 02:34:16 +0000 Subject: [PATCH 12/12] Maybe Each is safer --- .../src/browser_client_ivc_integration.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/yarn-project/ivc-integration/src/browser_client_ivc_integration.test.ts b/yarn-project/ivc-integration/src/browser_client_ivc_integration.test.ts index 74768e278b29..7e6956cd10b6 100644 --- a/yarn-project/ivc-integration/src/browser_client_ivc_integration.test.ts +++ b/yarn-project/ivc-integration/src/browser_client_ivc_integration.test.ts @@ -71,7 +71,7 @@ describe('Client IVC Integration', () => { let page: Page; let browser: Browser; - beforeAll(async () => { + beforeEach(async () => { browser = await chromium.launch({ headless: true }); const context = await browser.newContext(); page = await context.newPage(); @@ -79,7 +79,7 @@ describe('Client IVC Integration', () => { await page.goto('http://localhost:8080'); }); - afterAll(async () => { + afterEach(async () => { await browser.close(); });