From 43d73820ee9d9e334967372048fae21edc457a11 Mon Sep 17 00:00:00 2001 From: Charlie <5764343+charlielye@users.noreply.github.com> Date: Sun, 18 Oct 2026 19:43:32 +0000 Subject: [PATCH 1/8] feat(bb)!: build wasm with exception handling; node 26, wasi-sdk 34 Every bb wasm build compiled with -fno-exceptions, so throw_or_abort called out to the JavaScript environment, whose throw unwound the module without running catch blocks or destructors, and the AVM simulator (which signals exceptional halts with C++ exceptions) could not build for wasm at all. wasi-sdk 33+ ships a sysroot with a C++ exception runtime, so the wasm and wasm-threads builds now use standard (exnref) wasm exception handling, and the toolchains move to versions that run it unflagged. bb wasm - arch.cmake: -fwasm-exceptions -mllvm -wasm-use-legacy-eh=false, linked with -lunwind, in place of -fno-exceptions. The wasm preset drops -DBB_NO_EXCEPTIONS and sets AVM off. - throw_or_abort throws std::runtime_error inside the module in wasm builds with exceptions, so bbapi answers with an ErrorResponse, as it does natively. bb.js's exception test now also checks the module no longer aborts (it fails on the old wasm). - The wasm build adds aztec, world_state_reference, vm2 (vm2_sim only) and crypto/merkle_tree, and the wasm build preset builds vm2_sim_smoke. That runs one hinted public transaction (vm2/testing/minimal_tx.testdata.bin) through AvmSimAPI::simulate_with_hinted_dbs after checking a TagMismatchException is caught; scripts/vm2_sim_smoke_test.sh runs it natively and in wasm under node and requires identical results. It runs in the default bb test_cmds. - wasm32 fixes in the simulator and the in-memory trees, where size_t is 32-bit: contract_crypto shifted a size_t by 32, which is undefined on wasm32 and would corrupt the first bytecode field; index_t to size_t casts in the in-memory indexed trees and their callers; ptrdiff_t in to_radix. - LLVM 23 (wasi-sdk 34) fixes: wasm32-wasip1-threads in place of the removed wasm32-wasi-threads target; missing and includes; static function templates in headers made inline (-Wunused-template); -Wno-c2y-extensions for google-benchmark, which builds with -pedantic-errors and uses __COUNTER__. - barretenberg.wasm grows 5% (17.17 MB to 18.03 MB), 3.4% gzipped (3.88 MB to 4.01 MB). UltraHonk 2^20 proving under wasmtime showed no difference beyond noise. Toolchains (build image and scripts/setup-container.sh) - node 24.15.0 to 26.12.0 (.nvmrc, bootstrap's expected minimum and install_node). Node 26 removed --experimental-transform-types; the ipc-codegen callers only need type stripping, so it is dropped. - wasi-sdk 27 to 34 at /opt/wasi-sdk. - wasmtime 20.0.2 to 46.0.3, the last release with wasi-threads (-Sthreads), which the threaded wasm tests and benchmarks use. Its invocations add -Wexceptions=y and -Wshared-memory=y. - playwright 1.49 to 1.63.0 (Chromium 153; exnref is unflagged from Chrome 137), in the image and headless-test. The CI image is not redeployed here. Until it is, the root bootstrap's transitional_toolchain_upgrade (run by prep and check, in CI or the devbox) installs wasi-sdk 34 at /opt/wasi-sdk and node, wasmtime and playwright's chromium under $HOME, passing PATH and PLAYWRIGHT_BROWSERS_PATH through to isolated test containers. In devbox:3.1 it takes about 36s the first time and 3s after. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01G5s7nEWrYapDK2CWpEzcAf --- .github/ISSUE_TEMPLATE/bug_report.yml | 2 +- .nvmrc | 2 +- .../.claude/skills/benchmark-chonk/SKILL.md | 2 +- .../.claude/skills/profile-chonk/SKILL.md | 2 +- .../.claude/skills/remote-bench/SKILL.md | 2 +- .../acir_tests/headless-test/package.json | 2 +- barretenberg/acir_tests/yarn.lock | 43 ++++--------- barretenberg/cpp/CLAUDE.md | 2 +- barretenberg/cpp/CMakePresets.json | 5 +- barretenberg/cpp/bootstrap.sh | 6 ++ barretenberg/cpp/cmake/arch.cmake | 6 +- barretenberg/cpp/cmake/benchmark.cmake | 4 ++ barretenberg/cpp/cmake/threading.cmake | 4 +- barretenberg/cpp/scripts/benchmark_wasm.sh | 2 +- .../cpp/scripts/benchmark_wasm_remote.sh | 2 +- .../cpp/scripts/profile_wasm_samply.sh | 2 +- barretenberg/cpp/scripts/run_wasi_command.mjs | 15 +++++ .../cpp/scripts/vm2_sim_smoke_test.sh | 19 ++++++ barretenberg/cpp/scripts/wasmtime.sh | 2 + barretenberg/cpp/src/CMakeLists.txt | 9 +++ .../cpp/src/barretenberg/bbapi/CMakeLists.txt | 2 +- .../commitment_schemes/shplonk/shplonk.hpp | 2 +- .../small_subgroup_ipa/small_subgroup_ipa.hpp | 2 +- .../src/barretenberg/common/ref_vector.hpp | 2 +- .../barretenberg/common/throw_or_abort.hpp | 7 +++ .../cpp/src/barretenberg/common/utils.cpp | 2 + .../src/barretenberg/crypto/CMakeLists.txt | 4 +- .../barretenberg/crypto/schnorr/schnorr.tcc | 2 +- .../retrieved_bytecodes_tree_check.cpp | 4 +- .../vm2/simulation/gadgets/to_radix.cpp | 2 +- .../written_public_data_slots_tree_check.cpp | 4 +- .../vm2/simulation/lib/contract_crypto.cpp | 2 +- .../simulation/lib/indexed_memory_tree.hpp | 14 +++-- .../src/barretenberg/vm2/tooling/stats.cpp | 1 + .../barretenberg/vm2_sim_smoke/CMakeLists.txt | 4 ++ .../vm2_sim_smoke/vm2_sim_smoke.cpp | 60 +++++++++++++++++++ .../memory_merkle_db.hpp | 6 +- barretenberg/rust/bootstrap.sh | 2 +- barretenberg/ts/bb.js/scripts/generate.sh | 2 +- .../src/bbapi/exception_handling.test.ts | 23 ++++++- bootstrap.sh | 40 +++++++++++-- build-images/src/Dockerfile | 24 ++++---- scripts/setup-container.sh | 22 +++---- 43 files changed, 263 insertions(+), 103 deletions(-) create mode 100644 barretenberg/cpp/scripts/run_wasi_command.mjs create mode 100755 barretenberg/cpp/scripts/vm2_sim_smoke_test.sh create mode 100644 barretenberg/cpp/src/barretenberg/vm2_sim_smoke/CMakeLists.txt create mode 100644 barretenberg/cpp/src/barretenberg/vm2_sim_smoke/vm2_sim_smoke.cpp diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index 234574c30e2..c4cb4386deb 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -51,7 +51,7 @@ body: attributes: label: Node Version description: Your Node.js version - placeholder: e.g. 24.15.0 + placeholder: e.g. 26.12.0 - type: textarea id: additional-context attributes: diff --git a/.nvmrc b/.nvmrc index f3c88209af5..3635429b74f 100644 --- a/.nvmrc +++ b/.nvmrc @@ -1 +1 @@ -v24.15.0 +v26.12.0 diff --git a/barretenberg/.claude/skills/benchmark-chonk/SKILL.md b/barretenberg/.claude/skills/benchmark-chonk/SKILL.md index ff46ce600a6..6e7eb9f674d 100644 --- a/barretenberg/.claude/skills/benchmark-chonk/SKILL.md +++ b/barretenberg/.claude/skills/benchmark-chonk/SKILL.md @@ -131,7 +131,7 @@ HARDWARE_CONCURRENCY=8 BB_BENCH=1 \ ``` The wasmtime wrapper sets: -- `-Wthreads=y -Sthreads=y` — enable WASM threads and shared memory +- `-Wthreads=y -Wshared-memory=y -Wexceptions=y -Sthreads=y` — enable WASM threads, shared memory and exception handling - `--env HARDWARE_CONCURRENCY` — thread count - `--env BB_BENCH` — enable operation counting (requires configuring with `-DENABLE_WASM_BENCH=ON`; it is OFF by default in the `wasm-threads` preset to keep the shipped wasm fast) - `--dir=$HOME/.bb-crs --dir=.` — filesystem access for CRS and working directory diff --git a/barretenberg/.claude/skills/profile-chonk/SKILL.md b/barretenberg/.claude/skills/profile-chonk/SKILL.md index df2977eb6c7..6d382439b44 100644 --- a/barretenberg/.claude/skills/profile-chonk/SKILL.md +++ b/barretenberg/.claude/skills/profile-chonk/SKILL.md @@ -138,7 +138,7 @@ ssh $BB_SSH_KEY $BB_SSH_INSTANCE " cd $REMOTE_DIR HARDWARE_CONCURRENCY=$HARDWARE_CONCURRENCY \ /home/ubuntu/.wasmtime/bin/wasmtime run \ - -Wthreads=y -Sthreads=y -Wshared-memory=y \ + -Wthreads=y -Wexceptions=y -Sthreads=y -Wshared-memory=y \ --env HARDWARE_CONCURRENCY --env HOME --env BB_BENCH=1 \ --dir=\$HOME/.bb-crs --dir=. \ ./bin/bb prove \ diff --git a/barretenberg/.claude/skills/remote-bench/SKILL.md b/barretenberg/.claude/skills/remote-bench/SKILL.md index a4845bc42d7..f34e43f4217 100644 --- a/barretenberg/.claude/skills/remote-bench/SKILL.md +++ b/barretenberg/.claude/skills/remote-bench/SKILL.md @@ -203,7 +203,7 @@ ssh $BB_SSH_KEY $BB_SSH_INSTANCE \ "cd $BB_SSH_CPP_PATH/build-wasm-threads && \ HARDWARE_CONCURRENCY=16 \ /home/ubuntu/.wasmtime/bin/wasmtime run \ - -Wthreads=y -Sthreads=y \ + -Wthreads=y -Wshared-memory=y -Wexceptions=y -Sthreads=y \ --env HARDWARE_CONCURRENCY \ --env HOME \ --env BB_BENCH=1 \ diff --git a/barretenberg/acir_tests/headless-test/package.json b/barretenberg/acir_tests/headless-test/package.json index 1f16ffb506e..0db3ad32e87 100644 --- a/barretenberg/acir_tests/headless-test/package.json +++ b/barretenberg/acir_tests/headless-test/package.json @@ -10,7 +10,7 @@ "dependencies": { "chalk": "^5.3.0", "commander": "^12.1.0", - "playwright": "1.49.0", + "playwright": "1.63.0", "puppeteer": "^24.22.3" }, "devDependencies": { diff --git a/barretenberg/acir_tests/yarn.lock b/barretenberg/acir_tests/yarn.lock index 91e9dd9eb49..0c3d79ceb2d 100644 --- a/barretenberg/acir_tests/yarn.lock +++ b/barretenberg/acir_tests/yarn.lock @@ -2466,16 +2466,6 @@ __metadata: languageName: node linkType: hard -"fsevents@npm:2.3.2": - version: 2.3.2 - resolution: "fsevents@npm:2.3.2" - dependencies: - node-gyp: "npm:latest" - checksum: 10c0/be78a3efa3e181cda3cf7a4637cb527bcebb0bd0ea0440105a3bb45b86f9245b307dc10a2507e8f4498a7d4ec349d1910f4d73e4d4495b16103106e07eee735b - conditions: os=darwin - languageName: node - linkType: hard - "fsevents@npm:~2.3.2": version: 2.3.3 resolution: "fsevents@npm:2.3.3" @@ -2486,15 +2476,6 @@ __metadata: languageName: node linkType: hard -"fsevents@patch:fsevents@npm%3A2.3.2#optional!builtin": - version: 2.3.2 - resolution: "fsevents@patch:fsevents@npm%3A2.3.2#optional!builtin::version=2.3.2&hash=df0bf1" - dependencies: - node-gyp: "npm:latest" - conditions: os=darwin - languageName: node - linkType: hard - "fsevents@patch:fsevents@npm%3A~2.3.2#optional!builtin": version: 2.3.3 resolution: "fsevents@patch:fsevents@npm%3A2.3.3#optional!builtin::version=2.3.3&hash=df0bf1" @@ -2675,7 +2656,7 @@ __metadata: dependencies: chalk: "npm:^5.3.0" commander: "npm:^12.1.0" - playwright: "npm:1.49.0" + playwright: "npm:1.63.0" puppeteer: "npm:^24.22.3" ts-node: "npm:^10.9.2" typescript: "npm:^5.4.2" @@ -4097,27 +4078,23 @@ __metadata: languageName: node linkType: hard -"playwright-core@npm:1.49.0": - version: 1.49.0 - resolution: "playwright-core@npm:1.49.0" +"playwright-core@npm:1.63.0": + version: 1.63.0 + resolution: "playwright-core@npm:1.63.0" bin: playwright-core: cli.js - checksum: 10c0/22c1a72fabdcc87bd1cd4d40a032d2c5b94cf94ba7484dc182048c3fa1c8ec26180b559d8cac4ca9870e8fd6bdf5ef9d9f54e7a31fd60d67d098fcffc5e4253b + checksum: 10c0/39c1ebae4029ca2e9371e00a5588d962038e24b6e0bdb7d0d27374dde04838f349b83ae0c8b3b648653d0935cba7fb9011f1201adaab9dd0db7801ad6c75e9aa languageName: node linkType: hard -"playwright@npm:1.49.0": - version: 1.49.0 - resolution: "playwright@npm:1.49.0" +"playwright@npm:1.63.0": + version: 1.63.0 + resolution: "playwright@npm:1.63.0" dependencies: - fsevents: "npm:2.3.2" - playwright-core: "npm:1.49.0" - dependenciesMeta: - fsevents: - optional: true + playwright-core: "npm:1.63.0" bin: playwright: cli.js - checksum: 10c0/e94d662747cd147d0573570fec90dadc013c1097595714036fc8934a075c5a82ab04a49111b03b1f762ea86429bdb7c94460901896901e20970b30ce817cc93f + checksum: 10c0/d1fd048a89be27c9aba6757dc4f70eff4a5163b49f439ad691767be8b2a482327d0dd1928b4f73c8fe0d8b33aab2c9dc2670424ab60f112d9e98e91b94e3b090 languageName: node linkType: hard diff --git a/barretenberg/cpp/CLAUDE.md b/barretenberg/cpp/CLAUDE.md index a31f266ece4..3e1cd891153 100644 --- a/barretenberg/cpp/CLAUDE.md +++ b/barretenberg/cpp/CLAUDE.md @@ -89,7 +89,7 @@ clang-format-20 -i These are load-bearing: violating them will compile on native but break WASM, or skew test output in CI. Use the listed alternative unconditionally. - **Logging: use `info(...)` / `vinfo(...)` from `barretenberg/common/log.hpp`, never `std::cout` or `std::cerr`.** The macros route through `log_function` and respect `bb_log_level`; direct `std::cout` is unfiltered, uncaptured in CI logs, and skews benchmark output. -- **Aborts and exceptions: use `throw_or_abort(msg)` from `barretenberg/common/throw_or_abort.hpp`, never bare `throw` or `std::abort()`.** WASM builds set `BB_NO_EXCEPTIONS`, which turns `throw` into `abort()` — bare `throw` compiles differently and misformats the message, and raw `std::abort()` drops the message entirely. For header-only libraries that must use exception syntax, use the `THROW`/`RETHROW` macros from `common/try_catch_shim.hpp`. +- **Aborts and exceptions: use `throw_or_abort(msg)` from `barretenberg/common/throw_or_abort.hpp`, never bare `throw` or `std::abort()`.** Builds that set `BB_NO_EXCEPTIONS` (the `clang20-no-exceptions` preset; WASM builds now use wasm exception handling) turn `throw_or_abort` into `abort()`, and raw `std::abort()` drops the message entirely. For header-only libraries that must use exception syntax, use the `THROW`/`RETHROW` macros from `common/try_catch_shim.hpp`. - **Assertions: use `BB_ASSERT(cond, msg)` / `BB_ASSERT_EQ` / `BB_ASSERT_NEQ` / `BB_ASSERT_GT` / etc. from `barretenberg/common/assert.hpp`, never bare `assert(...)`.** `BB_ASSERT` hooks into the benchmark-assertion framework and has distinct debug/release behavior; `assert` is stripped in release builds and silently diverges in WASM. - **Release builds: do not reach for the `release` CMake preset unless the user is reproducing a performance issue.** Debug/default presets are much faster to compile and sufficient for correctness work. diff --git a/barretenberg/cpp/CMakePresets.json b/barretenberg/cpp/CMakePresets.json index bcb0a8b9d32..07428005b14 100644 --- a/barretenberg/cpp/CMakePresets.json +++ b/barretenberg/cpp/CMakePresets.json @@ -422,7 +422,7 @@ "CMAKE_C_COMPILER_WORKS": "ON", "CMAKE_CXX_COMPILER_WORKS": "ON", "MULTITHREADING": "OFF", - "CMAKE_CXX_FLAGS": "-DBB_NO_EXCEPTIONS" + "AVM": "OFF" } }, { @@ -768,7 +768,8 @@ "targets": [ "barretenberg.wasm", "barretenberg.wasm.gz", - "barretenberg-debug.wasm" + "barretenberg-debug.wasm", + "vm2_sim_smoke" ] }, { diff --git a/barretenberg/cpp/bootstrap.sh b/barretenberg/cpp/bootstrap.sh index 58478b1f6a7..769597da18b 100755 --- a/barretenberg/cpp/bootstrap.sh +++ b/barretenberg/cpp/bootstrap.sh @@ -358,6 +358,11 @@ function test_cmds_wasm_threads { echo "$hash:CPUS=8 HARDWARE_CONCURRENCY=8 barretenberg/cpp/scripts/wasmtime.sh barretenberg/cpp/build-wasm-threads/bin/ecc_tests" } +function test_cmds_wasm { + # vm2_sim in wasm gives the native result for the same transaction, and catches the exceptions it relies on. + echo "$hash barretenberg/cpp/scripts/vm2_sim_smoke_test.sh" +} + function test_cmds_asan { local prefix="$hash:CPUS=4:MEM=8g" @@ -395,6 +400,7 @@ function test_cmds_nightly { function test_cmds { if [ -z "${1:-}" ]; then test_cmds_native + test_cmds_wasm if [ "$CI_FULL" -eq 1 ]; then test_cmds_wasm_threads test_cmds_asan diff --git a/barretenberg/cpp/cmake/arch.cmake b/barretenberg/cpp/cmake/arch.cmake index c8158dfb8cc..41132e9ea16 100644 --- a/barretenberg/cpp/cmake/arch.cmake +++ b/barretenberg/cpp/cmake/arch.cmake @@ -2,7 +2,11 @@ if(WASM) # Disable SLP vectorization on WASM as it's brokenly slow. To give an idea, with this off it still takes # 2m:18s to compile scalar_multiplication.cpp, and with it on I estimate it's 50-100 times longer. I never # had the patience to wait it out... - add_compile_options(-fno-exceptions -fno-slp-vectorize) + add_compile_options(-fno-slp-vectorize) + # Standard (exnref) wasm exception handling. wasi-sdk 33+ ships a sysroot built with it, selected by + # -fwasm-exceptions at link time; libunwind provides the unwinder. + add_compile_options(-fwasm-exceptions -mllvm -wasm-use-legacy-eh=false) + add_link_options(-fwasm-exceptions -lunwind) endif() # Target skylake on x86 for AVX2 etc. ARM is handled by the zig wrapper scripts diff --git a/barretenberg/cpp/cmake/benchmark.cmake b/barretenberg/cpp/cmake/benchmark.cmake index fb72f700766..d18755e9d5d 100644 --- a/barretenberg/cpp/cmake/benchmark.cmake +++ b/barretenberg/cpp/cmake/benchmark.cmake @@ -18,3 +18,7 @@ if(NOT benchmark_FOUND) set_property(DIRECTORY ${benchmark_SOURCE_DIR} PROPERTY EXCLUDE_FROM_ALL) set_property(DIRECTORY ${benchmark_BINARY_DIR} PROPERTY EXCLUDE_FROM_ALL) endif() +# The library builds with -pedantic-errors, and clang 23 (wasi-sdk 34) flags its __COUNTER__ as a C2y extension. +if(TARGET benchmark AND CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 23) + target_compile_options(benchmark PRIVATE -Wno-c2y-extensions) +endif() diff --git a/barretenberg/cpp/cmake/threading.cmake b/barretenberg/cpp/cmake/threading.cmake index 5092e8064c6..99c25b93768 100644 --- a/barretenberg/cpp/cmake/threading.cmake +++ b/barretenberg/cpp/cmake/threading.cmake @@ -3,8 +3,8 @@ if(MULTITHREADING) add_compile_options(-pthread) add_link_options(-pthread) if(WASM) - add_compile_options(--target=wasm32-wasi-threads) - add_link_options(--target=wasm32-wasi-threads -Wl,--shared-memory) + add_compile_options(--target=wasm32-wasip1-threads) + add_link_options(--target=wasm32-wasip1-threads -Wl,--shared-memory) # Prevent indirect call type mismatch errors in thread_local destructors # (without this the benchmark flow fails at destruction point for WASM) add_compile_options(-fno-c++-static-destructors) diff --git a/barretenberg/cpp/scripts/benchmark_wasm.sh b/barretenberg/cpp/scripts/benchmark_wasm.sh index 0b4483c7c09..a307fe3ffe7 100755 --- a/barretenberg/cpp/scripts/benchmark_wasm.sh +++ b/barretenberg/cpp/scripts/benchmark_wasm.sh @@ -17,4 +17,4 @@ cmake --build --preset wasm-threads --target $BENCHMARK cd build-wasm-threads # Consistency with _wasm.sh targets / shorter $COMMAND. cp ./bin/$BENCHMARK . -wasmtime run --env HARDWARE_CONCURRENCY=$HARDWARE_CONCURRENCY -Wthreads=y -Sthreads=y --dir=.. $COMMAND \ No newline at end of file +wasmtime run --env HARDWARE_CONCURRENCY=$HARDWARE_CONCURRENCY -Wthreads=y -Wshared-memory=y -Wexceptions=y -Sthreads=y --dir=.. $COMMAND \ No newline at end of file diff --git a/barretenberg/cpp/scripts/benchmark_wasm_remote.sh b/barretenberg/cpp/scripts/benchmark_wasm_remote.sh index 62213556579..18ce7aa0543 100755 --- a/barretenberg/cpp/scripts/benchmark_wasm_remote.sh +++ b/barretenberg/cpp/scripts/benchmark_wasm_remote.sh @@ -27,4 +27,4 @@ ssh $BB_SSH_KEY $BB_SSH_INSTANCE "mkdir -p $BB_SSH_CPP_PATH/build-wasm-threads" scp $BB_SSH_KEY ./bin/$BENCHMARK $BB_SSH_INSTANCE:$BB_SSH_CPP_PATH/build-wasm-threads # run wasm benchmarking ssh $BB_SSH_KEY $BB_SSH_INSTANCE \ - "cd $BB_SSH_CPP_PATH/build-wasm-threads ; /home/ubuntu/.wasmtime/bin/wasmtime run --env HARDWARE_CONCURRENCY=$HARDWARE_CONCURRENCY -Wthreads=y -Sthreads=y --dir=.. $COMMAND" + "cd $BB_SSH_CPP_PATH/build-wasm-threads ; /home/ubuntu/.wasmtime/bin/wasmtime run --env HARDWARE_CONCURRENCY=$HARDWARE_CONCURRENCY -Wthreads=y -Wshared-memory=y -Wexceptions=y -Sthreads=y --dir=.. $COMMAND" diff --git a/barretenberg/cpp/scripts/profile_wasm_samply.sh b/barretenberg/cpp/scripts/profile_wasm_samply.sh index 218ed2b8f89..27d0e333f30 100755 --- a/barretenberg/cpp/scripts/profile_wasm_samply.sh +++ b/barretenberg/cpp/scripts/profile_wasm_samply.sh @@ -16,4 +16,4 @@ cmake --build --preset wasm-threads --target $BENCHMARK cd build-wasm-threads # Consistency with _wasm.sh targets / shorter $COMMAND. cp ./bin/$BENCHMARK . -samply record wasmtime run --profile=perfmap --env HARDWARE_CONCURRENCY=$HARDWARE_CONCURRENCY -Wthreads=y -Sthreads=y --dir=.. $COMMAND \ No newline at end of file +samply record wasmtime run --profile=perfmap --env HARDWARE_CONCURRENCY=$HARDWARE_CONCURRENCY -Wthreads=y -Wshared-memory=y -Wexceptions=y -Sthreads=y --dir=.. $COMMAND \ No newline at end of file diff --git a/barretenberg/cpp/scripts/run_wasi_command.mjs b/barretenberg/cpp/scripts/run_wasi_command.mjs new file mode 100644 index 00000000000..639a4a50281 --- /dev/null +++ b/barretenberg/cpp/scripts/run_wasi_command.mjs @@ -0,0 +1,15 @@ +// Runs a bb wasi command (a module that imports its memory) under Node's WASI, with `dir` preopened at /data. +// Usage: node run_wasi_command.mjs [args...] +import { readFileSync } from "node:fs"; +import { WASI } from "node:wasi"; + +const [wasmPath, dir, ...args] = process.argv.slice(2); +const module = await WebAssembly.compile(readFileSync(wasmPath)); +const wasi = new WASI({ version: "preview1", args: [wasmPath, ...args], preopens: { "/data": dir }, returnOnExit: true }); +const importObject = wasi.getImportObject(); +const memory = new WebAssembly.Memory({ initial: 512, maximum: 65536 }); +for (const { module: from, name, kind } of WebAssembly.Module.imports(module)) { + if (kind === "memory") (importObject[from] ??= {})[name] = memory; +} +const instance = await WebAssembly.instantiate(module, importObject); +process.exitCode = wasi.start({ exports: { ...instance.exports, memory } }); diff --git a/barretenberg/cpp/scripts/vm2_sim_smoke_test.sh b/barretenberg/cpp/scripts/vm2_sim_smoke_test.sh new file mode 100755 index 00000000000..254701d449d --- /dev/null +++ b/barretenberg/cpp/scripts/vm2_sim_smoke_test.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash +# Runs the same hinted public transaction through vm2_sim natively and in wasm (under node, so V8), and checks the +# wasm run catches the simulator's C++ exceptions and reaches the native result. +set -euo pipefail +cd $(dirname $0)/.. + +native_bin=$(scripts/preset-build-dir ${NATIVE_PRESET:-clang20})/bin/vm2_sim_smoke +wasm_bin=build-wasm/bin/vm2_sim_smoke +inputs_dir=src/barretenberg/vm2/testing +inputs=minimal_tx.testdata.bin + +native=$($native_bin $inputs_dir/$inputs | grep -E '^(caught|revert_code)') +wasm=$(node --no-warnings scripts/run_wasi_command.mjs $wasm_bin $inputs_dir /data/$inputs | + grep -E '^(caught|revert_code)') + +echo "native: $native" +echo "wasm: $wasm" +[ "$(echo "$wasm" | grep -c '^caught TagMismatchException')" -eq 1 ] +[ "$native" == "$wasm" ] diff --git a/barretenberg/cpp/scripts/wasmtime.sh b/barretenberg/cpp/scripts/wasmtime.sh index 3ad657d5798..f59c4588e4b 100755 --- a/barretenberg/cpp/scripts/wasmtime.sh +++ b/barretenberg/cpp/scripts/wasmtime.sh @@ -5,6 +5,8 @@ set -eu export WASMTIME_BACKTRACE_DETAILS=1 exec wasmtime run \ -Wthreads=y \ + -Wshared-memory=y \ + -Wexceptions=y \ -Sthreads=y \ ${HARDWARE_CONCURRENCY:+--env HARDWARE_CONCURRENCY} \ --env HOME \ diff --git a/barretenberg/cpp/src/CMakeLists.txt b/barretenberg/cpp/src/CMakeLists.txt index 11967cf84c2..e6f2af8d45d 100644 --- a/barretenberg/cpp/src/CMakeLists.txt +++ b/barretenberg/cpp/src/CMakeLists.txt @@ -123,10 +123,19 @@ if(NOT FUZZING AND NOT WASM AND NOT BB_LITE) # NOTE: Do not conditionally base this on the AVM flag as it defines a necessary vm2_sim library. add_subdirectory(barretenberg/vm2) add_subdirectory(barretenberg/vm2_wsdb) + add_subdirectory(barretenberg/vm2_sim_smoke) add_subdirectory(barretenberg/cdb) add_subdirectory(barretenberg/avm) endif() +if(WASM) + # The AVM simulator, without the AVM prover (the wasm presets set AVM off). + add_subdirectory(barretenberg/aztec) + add_subdirectory(barretenberg/world_state_reference) + add_subdirectory(barretenberg/vm2) + add_subdirectory(barretenberg/vm2_sim_smoke) +endif() + # Pull in ipc-runtime as a C++ dependency. Provides the `ipc_runtime` # library target (static, or INTERFACE under WASM with transport sources # stubbed) that bbapi/wsdb/etc link against for the codegen-emitted diff --git a/barretenberg/cpp/src/barretenberg/bbapi/CMakeLists.txt b/barretenberg/cpp/src/barretenberg/bbapi/CMakeLists.txt index e7a90defb53..827c086d1de 100644 --- a/barretenberg/cpp/src/barretenberg/bbapi/CMakeLists.txt +++ b/barretenberg/cpp/src/barretenberg/bbapi/CMakeLists.txt @@ -22,7 +22,7 @@ if(NOT FUZZING) ) add_custom_command( OUTPUT ${BB_GEN_OUTPUTS} - COMMAND node --experimental-strip-types --experimental-transform-types --no-warnings + COMMAND node --experimental-strip-types --no-warnings ${IPC_CODEGEN_DIR}/src/generate.ts --schema ${BB_SCHEMA} --lang cpp diff --git a/barretenberg/cpp/src/barretenberg/commitment_schemes/shplonk/shplonk.hpp b/barretenberg/cpp/src/barretenberg/commitment_schemes/shplonk/shplonk.hpp index 98b5e0dc69c..0112f0bb328 100644 --- a/barretenberg/cpp/src/barretenberg/commitment_schemes/shplonk/shplonk.hpp +++ b/barretenberg/cpp/src/barretenberg/commitment_schemes/shplonk/shplonk.hpp @@ -615,7 +615,7 @@ template class ShplonkVerifier_ { * */ template -static std::vector compute_shplonk_batching_challenge_powers(const Fr& shplonk_batching_challenge, +inline std::vector compute_shplonk_batching_challenge_powers(const Fr& shplonk_batching_challenge, const size_t virtual_log_n, bool has_zk = false, bool committed_sumcheck = false) diff --git a/barretenberg/cpp/src/barretenberg/commitment_schemes/small_subgroup_ipa/small_subgroup_ipa.hpp b/barretenberg/cpp/src/barretenberg/commitment_schemes/small_subgroup_ipa/small_subgroup_ipa.hpp index 7422a1f9e86..ce188e77b32 100644 --- a/barretenberg/cpp/src/barretenberg/commitment_schemes/small_subgroup_ipa/small_subgroup_ipa.hpp +++ b/barretenberg/cpp/src/barretenberg/commitment_schemes/small_subgroup_ipa/small_subgroup_ipa.hpp @@ -420,7 +420,7 @@ template class SmallSubgroupIPAVerifier { * @return Polynomial */ template -static std::vector compute_challenge_polynomial_coeffs( +inline std::vector compute_challenge_polynomial_coeffs( const std::vector& multivariate_challenge) { diff --git a/barretenberg/cpp/src/barretenberg/common/ref_vector.hpp b/barretenberg/cpp/src/barretenberg/common/ref_vector.hpp index bfc92e13055..d4f1b63d5ec 100644 --- a/barretenberg/cpp/src/barretenberg/common/ref_vector.hpp +++ b/barretenberg/cpp/src/barretenberg/common/ref_vector.hpp @@ -173,7 +173,7 @@ template RefVector concatenate(const RefVector& ref_vector, c } /* @details Ensures a nested vector holds reference objects */ -template static std::vector> to_vector_of_ref_vectors(std::vector>& vec) +template inline std::vector> to_vector_of_ref_vectors(std::vector>& vec) { std::vector> result; for (std::vector& inner : vec) { diff --git a/barretenberg/cpp/src/barretenberg/common/throw_or_abort.hpp b/barretenberg/cpp/src/barretenberg/common/throw_or_abort.hpp index c6856f40c26..7956a978d22 100644 --- a/barretenberg/cpp/src/barretenberg/common/throw_or_abort.hpp +++ b/barretenberg/cpp/src/barretenberg/common/throw_or_abort.hpp @@ -1,9 +1,16 @@ #pragma once #include "barretenberg/env/throw_or_abort_impl.hpp" #include "log.hpp" +#include #include inline void throw_or_abort [[noreturn]] (std::string const& err) { +#if defined(__wasm__) && !defined(BB_NO_EXCEPTIONS) + // Throw inside the module, so catch blocks such as bbapi's error responses see it. The JavaScript environment's + // throw_or_abort_impl throws a JS error, which unwinds the module without running them or any destructors. + throw std::runtime_error(err); +#else throw_or_abort_impl(err.c_str()); +#endif } diff --git a/barretenberg/cpp/src/barretenberg/common/utils.cpp b/barretenberg/cpp/src/barretenberg/common/utils.cpp index 312ccb9a377..f55167a5273 100644 --- a/barretenberg/cpp/src/barretenberg/common/utils.cpp +++ b/barretenberg/cpp/src/barretenberg/common/utils.cpp @@ -1,5 +1,7 @@ #include "./utils.hpp" +#include + namespace bb::utils { std::vector hex_to_bytes(const std::string& hex) diff --git a/barretenberg/cpp/src/barretenberg/crypto/CMakeLists.txt b/barretenberg/cpp/src/barretenberg/crypto/CMakeLists.txt index a2911b6b687..63c1926142f 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/CMakeLists.txt +++ b/barretenberg/cpp/src/barretenberg/crypto/CMakeLists.txt @@ -12,6 +12,4 @@ add_subdirectory(ecdsa) add_subdirectory(aes128) add_subdirectory(poseidon2) -if (NOT WASM) - add_subdirectory(merkle_tree) -endif() +add_subdirectory(merkle_tree) diff --git a/barretenberg/cpp/src/barretenberg/crypto/schnorr/schnorr.tcc b/barretenberg/cpp/src/barretenberg/crypto/schnorr/schnorr.tcc index 16fe624c72d..b8f1d3d2eef 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/schnorr/schnorr.tcc +++ b/barretenberg/cpp/src/barretenberg/crypto/schnorr/schnorr.tcc @@ -51,7 +51,7 @@ template static inline Fq compute_schnorr_challenge_dst() * @return e as a bb::fr element */ template -static typename G1::Fq schnorr_generate_challenge(const typename G1::Fq& message_field, +inline typename G1::Fq schnorr_generate_challenge(const typename G1::Fq& message_field, const typename G1::affine_element& pubkey, const typename G1::affine_element& R) { diff --git a/barretenberg/cpp/src/barretenberg/vm2/simulation/gadgets/retrieved_bytecodes_tree_check.cpp b/barretenberg/cpp/src/barretenberg/vm2/simulation/gadgets/retrieved_bytecodes_tree_check.cpp index cb96ae66227..7ab61f3718a 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/simulation/gadgets/retrieved_bytecodes_tree_check.cpp +++ b/barretenberg/cpp/src/barretenberg/vm2/simulation/gadgets/retrieved_bytecodes_tree_check.cpp @@ -17,8 +17,8 @@ bool RetrievedBytecodesTreeCheck::contains(const FF& class_id) { const auto snapshot = tree.get_snapshot(); auto [exists, low_leaf_index] = tree.get_low_indexed_leaf(class_id); - auto sibling_path = tree.get_sibling_path(low_leaf_index); - auto low_leaf_preimage = tree.get_leaf_preimage(low_leaf_index); + auto sibling_path = tree.get_sibling_path(static_cast(low_leaf_index)); + auto low_leaf_preimage = tree.get_leaf_preimage(static_cast(low_leaf_index)); indexed_tree_check.assert_read(class_id, std::nullopt, // No siloing diff --git a/barretenberg/cpp/src/barretenberg/vm2/simulation/gadgets/to_radix.cpp b/barretenberg/cpp/src/barretenberg/vm2/simulation/gadgets/to_radix.cpp index 232d7ebac52..7976e78a186 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/simulation/gadgets/to_radix.cpp +++ b/barretenberg/cpp/src/barretenberg/vm2/simulation/gadgets/to_radix.cpp @@ -50,7 +50,7 @@ std::pair, /* truncated */ bool> ToRadix::to_le_radix(const bool truncated = num_limbs < limbs.size(); if (truncated) { - limbs.erase(limbs.begin() + num_limbs, limbs.end()); + limbs.erase(limbs.begin() + static_cast(num_limbs), limbs.end()); } return { limbs, truncated }; diff --git a/barretenberg/cpp/src/barretenberg/vm2/simulation/gadgets/written_public_data_slots_tree_check.cpp b/barretenberg/cpp/src/barretenberg/vm2/simulation/gadgets/written_public_data_slots_tree_check.cpp index e7908f33077..32b0d6e8e12 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/simulation/gadgets/written_public_data_slots_tree_check.cpp +++ b/barretenberg/cpp/src/barretenberg/vm2/simulation/gadgets/written_public_data_slots_tree_check.cpp @@ -24,8 +24,8 @@ bool WrittenPublicDataSlotsTreeCheck::contains(const AztecAddress& contract_addr const auto& tree = written_public_data_slots_tree_stack.top(); const auto snapshot = tree.get_snapshot(); auto [exists, low_leaf_index] = tree.get_low_indexed_leaf(leaf_slot); - auto sibling_path = tree.get_sibling_path(low_leaf_index); - auto low_leaf_preimage = tree.get_leaf_preimage(low_leaf_index); + auto sibling_path = tree.get_sibling_path(static_cast(low_leaf_index)); + auto low_leaf_preimage = tree.get_leaf_preimage(static_cast(low_leaf_index)); indexed_tree_check.assert_read(slot, IndexedTreeSiloingParameters{ diff --git a/barretenberg/cpp/src/barretenberg/vm2/simulation/lib/contract_crypto.cpp b/barretenberg/cpp/src/barretenberg/vm2/simulation/lib/contract_crypto.cpp index d74895f1def..370aa4bf476 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/simulation/lib/contract_crypto.cpp +++ b/barretenberg/cpp/src/barretenberg/vm2/simulation/lib/contract_crypto.cpp @@ -58,7 +58,7 @@ FF compute_public_bytecode_first_field(size_t bytecode_size) // Fr<0x00000000000000000000000000000000000000000000000000016b480f8411f1> From: max fields in bytes = 3000 * 31 = // 16b48, Dom sep = f8411f1 static_assert(DOM_SEP__PUBLIC_BYTECODE <= UINT32_MAX, "Public bytecode domain separator must fit in 32 bits"); - return FF(uint256_t(DOM_SEP__PUBLIC_BYTECODE) + uint256_t(bytecode_size << 32)); + return FF(uint256_t(DOM_SEP__PUBLIC_BYTECODE) + (uint256_t(bytecode_size) << 32)); } FF compute_public_bytecode_commitment(std::span bytecode) diff --git a/barretenberg/cpp/src/barretenberg/vm2/simulation/lib/indexed_memory_tree.hpp b/barretenberg/cpp/src/barretenberg/vm2/simulation/lib/indexed_memory_tree.hpp index 0bd01838ba0..c2575fb2298 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/simulation/lib/indexed_memory_tree.hpp +++ b/barretenberg/cpp/src/barretenberg/vm2/simulation/lib/indexed_memory_tree.hpp @@ -150,20 +150,22 @@ SequentialInsertionResult IndexedMemoryTree:: for (const auto& leaf_to_insert : leaves_to_insert) { FF key = leaf_to_insert.get_key(); GetLowIndexedLeafResponse find_low_leaf_result = get_low_indexed_leaf(key); - IndexedLeaf& low_leaf = leaves.at(find_low_leaf_result.index); + // index_t is 64-bit; size_t is 32-bit on wasm32. An index into this in-memory tree always fits. + const auto low_index = static_cast(find_low_leaf_result.index); + IndexedLeaf& low_leaf = leaves.at(low_index); - result.low_leaf_witness_data.push_back(LeafUpdateWitnessData( - low_leaf, find_low_leaf_result.index, tree.get_sibling_path(find_low_leaf_result.index))); + result.low_leaf_witness_data.push_back( + LeafUpdateWitnessData(low_leaf, find_low_leaf_result.index, tree.get_sibling_path(low_index))); if (!find_low_leaf_result.is_already_present) { // If the leaf is not already present, we point the low leaf to the new leaf and then insert the new leaf. IndexedLeaf new_indexed_leaf(leaf_to_insert, low_leaf.nextIndex, low_leaf.nextKey); - index_t insertion_index = leaves.size(); + size_t insertion_index = leaves.size(); low_leaf.nextIndex = insertion_index; low_leaf.nextKey = key; FF low_leaf_hash = HashingPolicy::hash(low_leaf.get_hash_inputs()); - tree.update_element(find_low_leaf_result.index, low_leaf_hash); + tree.update_element(low_index, low_leaf_hash); append_leaf(new_indexed_leaf); FF new_leaf_hash = HashingPolicy::hash(new_indexed_leaf.get_hash_inputs()); @@ -176,7 +178,7 @@ SequentialInsertionResult IndexedMemoryTree:: // Update the current leaf's value, don't change it's link low_leaf = IndexedLeaf(leaf_to_insert, low_leaf.nextIndex, low_leaf.nextKey); FF low_leaf_hash = HashingPolicy::hash(low_leaf.get_hash_inputs()); - tree.update_element(find_low_leaf_result.index, low_leaf_hash); + tree.update_element(low_index, low_leaf_hash); // Push an empty insertion witness result.insertion_witness_data.push_back( diff --git a/barretenberg/cpp/src/barretenberg/vm2/tooling/stats.cpp b/barretenberg/cpp/src/barretenberg/vm2/tooling/stats.cpp index 7f4113e93c7..548cf658c2f 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/tooling/stats.cpp +++ b/barretenberg/cpp/src/barretenberg/vm2/tooling/stats.cpp @@ -1,5 +1,6 @@ #include "barretenberg/vm2/tooling/stats.hpp" +#include #include #include #include diff --git a/barretenberg/cpp/src/barretenberg/vm2_sim_smoke/CMakeLists.txt b/barretenberg/cpp/src/barretenberg/vm2_sim_smoke/CMakeLists.txt new file mode 100644 index 00000000000..122ee5f5dfb --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/vm2_sim_smoke/CMakeLists.txt @@ -0,0 +1,4 @@ +# Runs one public transaction through vm2_sim from its hinted inputs. Built natively and under the wasm-eh preset, so +# the two can be compared; under wasm it also checks the simulator's C++ exceptions work. +add_executable(vm2_sim_smoke vm2_sim_smoke.cpp) +target_link_libraries(vm2_sim_smoke PRIVATE vm2_sim env) diff --git a/barretenberg/cpp/src/barretenberg/vm2_sim_smoke/vm2_sim_smoke.cpp b/barretenberg/cpp/src/barretenberg/vm2_sim_smoke/vm2_sim_smoke.cpp new file mode 100644 index 00000000000..dc4981f2f8b --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/vm2_sim_smoke/vm2_sim_smoke.cpp @@ -0,0 +1,60 @@ +// Runs one public transaction through vm2_sim from hinted inputs (AvmProvingInputs, msgpack), as `bb avm_simulate` +// does, and first checks that a C++ exception thrown inside the simulator is caught. +// +// Usage: vm2_sim_smoke +#include "barretenberg/vm2/avm_sim_api.hpp" +#include "barretenberg/vm2/common/tagged_value.hpp" + +#include +#include +#include + +using namespace bb::avm2; + +namespace { + +std::vector read_all(const char* path) +{ + std::vector data; + FILE* file = std::fopen(path, "rb"); + if (file == nullptr) { + return data; + } + uint8_t chunk[1 << 16]; + size_t n = 0; + while ((n = std::fread(chunk, 1, sizeof(chunk), file)) > 0) { + data.insert(data.end(), chunk, chunk + n); + } + std::fclose(file); + return data; +} + +} // namespace + +int main(int argc, char** argv) +{ + try { + auto sum = TaggedValue::from(1) + TaggedValue::from(1); + std::printf("FAIL: mismatched tags added without throwing (tag %d)\n", static_cast(sum.get_tag())); + return 1; + } catch (const TagMismatchException& e) { + std::printf("caught TagMismatchException: %s\n", e.what()); + } + + if (argc < 2) { + std::printf("usage: %s \n", argv[0]); + return 2; + } + auto bytes = read_all(argv[1]); + if (bytes.empty()) { + std::printf("FAIL: could not read %s\n", argv[1]); + return 1; + } + auto inputs = AvmSimAPI::ProvingInputs::from(bytes); + auto result = AvmSimAPI().simulate_with_hinted_dbs(inputs); + std::printf("revert_code=%d total_l2_gas=%u total_da_gas=%u\n", + static_cast(result.revert_code), + result.gas_used.total_gas.l2_gas, + result.gas_used.total_gas.da_gas); + return 0; +} diff --git a/barretenberg/cpp/src/barretenberg/world_state_reference/memory_merkle_db.hpp b/barretenberg/cpp/src/barretenberg/world_state_reference/memory_merkle_db.hpp index 03dc055724d..5e9046d8328 100644 --- a/barretenberg/cpp/src/barretenberg/world_state_reference/memory_merkle_db.hpp +++ b/barretenberg/cpp/src/barretenberg/world_state_reference/memory_merkle_db.hpp @@ -103,7 +103,7 @@ template class MemoryIndexedTree { leaves_.push_back(Leaf(LeafType::padding(i), /*nextIndex=*/0, /*nextKey=*/0)); } for (size_t i = 0; i < initial_size; ++i) { - index_t next_index = i == (initial_size - 1) ? 0 : i + 1; + size_t next_index = i == (initial_size - 1) ? 0 : i + 1; leaves_[i].nextIndex = next_index; leaves_[i].nextKey = leaves_[next_index].leaf.get_key(); tree_.update_element(i, HashingPolicy::hash(leaves_[i].get_hash_inputs())); @@ -131,7 +131,7 @@ template class MemoryIndexedTree { Leaf get_leaf_preimage(index_t leaf_index) const { BB_ASSERT_LT(leaf_index, leaves_.size(), "Leaf index out of bounds"); - return leaves_[leaf_index]; + return leaves_[static_cast(leaf_index)]; } FF get_leaf_value(index_t leaf_index) const { return tree_.get_node(0, leaf_index); } @@ -149,7 +149,7 @@ template class MemoryIndexedTree { FF key = leaf_to_insert.get_key(); GetLowIndexedLeafResponse find_low_leaf_result = get_low_indexed_leaf(key); - Leaf& low_leaf = leaves_[find_low_leaf_result.index]; + Leaf& low_leaf = leaves_[static_cast(find_low_leaf_result.index)]; result.low_leaf_witness_data.emplace_back( low_leaf, find_low_leaf_result.index, tree_.get_sibling_path(find_low_leaf_result.index)); diff --git a/barretenberg/rust/bootstrap.sh b/barretenberg/rust/bootstrap.sh index b49097e57f4..445dcff0d68 100755 --- a/barretenberg/rust/bootstrap.sh +++ b/barretenberg/rust/bootstrap.sh @@ -11,7 +11,7 @@ hash=$(hash_str $(cache_content_hash .rebuild_patterns)) # generated client never depends on hand-maintained copies of them. function generate { local root=$(git rev-parse --show-toplevel) - (cd barretenberg-rs && node --experimental-strip-types --experimental-transform-types --no-warnings \ + (cd barretenberg-rs && node --experimental-strip-types --no-warnings \ "$root/ipc-codegen/src/generate.ts" \ --schema "$root/barretenberg/cpp/src/barretenberg/bbapi/bb_schema.json" \ --lang rust \ diff --git a/barretenberg/ts/bb.js/scripts/generate.sh b/barretenberg/ts/bb.js/scripts/generate.sh index 5bb35ba4ca9..f9a0153c8ca 100755 --- a/barretenberg/ts/bb.js/scripts/generate.sh +++ b/barretenberg/ts/bb.js/scripts/generate.sh @@ -10,7 +10,7 @@ BBAPI="$ROOT/barretenberg/cpp/src/barretenberg/bbapi" # bb.js keeps its historical API surface (poseidon2Hash, Poseidon2Hash), so the # Bb service prefix is stripped from identifiers; wire tags keep it. -node --experimental-strip-types --experimental-transform-types --no-warnings \ +node --experimental-strip-types --no-warnings \ "$ROOT/ipc-codegen/src/generate.ts" \ --schema "$BBAPI/bb_schema.json" \ --lang ts \ diff --git a/barretenberg/ts/bb.js/src/bbapi/exception_handling.test.ts b/barretenberg/ts/bb.js/src/bbapi/exception_handling.test.ts index 3c90963fd11..e13674e1a89 100644 --- a/barretenberg/ts/bb.js/src/bbapi/exception_handling.test.ts +++ b/barretenberg/ts/bb.js/src/bbapi/exception_handling.test.ts @@ -23,9 +23,8 @@ describe('BBApi Exception Handling from bb.js', () => { g2Point: new Uint8Array(10), // Only 10 bytes (needs 128) - will cause exception }; - // In WASM builds, throw_or_abort calls abort directly which throws a generic Error - // In native builds with exceptions, our try-catch in bbapi converts it to ErrorResponse - // This test verifies that errors are catchable from bb.js (even if as generic Error in WASM) + // The wasm builds with exception handling, so bbapi's try-catch converts the C++ exception to an ErrorResponse, + // as it does natively. expect(() => { api.srsInitSrs(invalidCommand); }).toThrow(); @@ -49,4 +48,22 @@ describe('BBApi Exception Handling from bb.js', () => { expect((error as Error).message).toContain('invalid points_buf size'); } }); + + it('answers with an error response rather than aborting the module', async () => { + const logs: string[] = []; + const loggingBackend = await BarretenbergWasmSyncBackend.new(undefined, msg => logs.push(msg)); + try { + expect(() => + new SyncApi(loggingBackend).srsInitSrs({ + numPoints: 100, + pointsBuf: new Uint8Array(10), + g2Point: new Uint8Array(10), + }), + ).toThrow('invalid points_buf size'); + // The JS environment logs this when the module aborts rather than catching the exception itself. + expect(logs.filter(log => log.includes('aborted'))).toEqual([]); + } finally { + loggingBackend.destroy(); + } + }, 60000); }); diff --git a/bootstrap.sh b/bootstrap.sh index dde97c8dd0d..faa016dacf0 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -12,10 +12,10 @@ # Expected toolchain versions. export expected_min_clang_version=20.0.0 export expected_min_cmake_version=3.24 -export expected_min_node_version=24.12.0 +export expected_min_node_version=26.12.0 export expected_min_zig_version=0.15.1 export expected_abs_rust_version=1.89.0 -export expected_abs_wasi_version=27.0 +export expected_abs_wasi_version=34.0 export expected_abs_foundry_version=1.8.5 export expected_abs_yarn_version=4.13.0 @@ -66,8 +66,8 @@ function install_node { curl -s -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.4/install.sh | bash . "$HOME/.nvm/nvm.sh" --no-use fi - nvm install --lts - nvm alias default lts/* + nvm install $expected_min_node_version + nvm alias default $expected_min_node_version } function install_node_utils { @@ -204,6 +204,36 @@ function cleanup { } trap cleanup EXIT +### TRANSITIONAL TOOLCHAIN UPGRADE ##################################################################################### +# TODO: Delete this section and its calls (prep, check) once CI runs a build image (and AMI) with the toolchains +# build-images/src/Dockerfile now installs. Until then, upgrade the older image in place on every run: wasi-sdk at +# /opt/wasi-sdk (only builds use it), and node, wasmtime and playwright's chromium under $HOME, which isolated test +# containers mount too, so PATH and PLAYWRIGHT_BROWSERS_PATH are passed through to them. +function transitional_toolchain_upgrade { + [ "$(os)" == "linux" ] && { [ "${CI:-0}" -eq 1 ] || [ "$(whoami)" == "aztec-dev" ]; } || return 0 + local dir=$HOME/.cache/aztec-transitional-toolchains arch=$(uname -m) + local node_version=v$expected_min_node_version wasmtime_version=v46.0.3 playwright_version=1.63.0 + local node_arch=$([ "$arch" == "aarch64" ] && echo arm64 || echo x64) + mkdir -p $dir + install_wasi_sdk + if [ ! -x $dir/node-$node_version/bin/node ]; then + curl -fsSL https://nodejs.org/dist/$node_version/node-$node_version-linux-$node_arch.tar.xz | tar xJ -C $dir + mv $dir/node-$node_version-linux-$node_arch $dir/node-$node_version + fi + if [ ! -x $dir/wasmtime-$wasmtime_version/wasmtime ]; then + curl -fsSL https://github.com/bytecodealliance/wasmtime/releases/download/$wasmtime_version/wasmtime-$wasmtime_version-$arch-linux.tar.xz | tar xJ -C $dir + mv $dir/wasmtime-$wasmtime_version-$arch-linux $dir/wasmtime-$wasmtime_version + fi + export PATH=$dir/node-$node_version/bin:$dir/wasmtime-$wasmtime_version:$PATH + export PLAYWRIGHT_BROWSERS_PATH=$dir/ms-playwright + local out + if ! out=$(npx -y playwright@$playwright_version install chromium --only-shell 2>&1); then + echo "$out" + return 1 + fi + export ENV_VARS_TO_INJECT="${ENV_VARS_TO_INJECT:-} PATH PLAYWRIGHT_BROWSERS_PATH" +} + ### TOOLCHAIN CHECKS ################################################################################################### function check_minimum_version { local min_version=$1 @@ -417,6 +447,7 @@ function stop_txes { } function prep { + transitional_toolchain_upgrade check_toolchains pull_submodules } @@ -853,6 +884,7 @@ case "$cmd" in git clean -ffdx ;; "check") + transitional_toolchain_upgrade check_toolchains echo "Toolchains look good! 🎉" ;; diff --git a/build-images/src/Dockerfile b/build-images/src/Dockerfile index 67dd8ced00c..cd6a6a5e3b2 100644 --- a/build-images/src/Dockerfile +++ b/build-images/src/Dockerfile @@ -61,9 +61,9 @@ RUN curl -L https://foundry.paradigm.xyz | bash \ # We use this image for test isolation. FROM base-build AS build -# APT repo for node (24.15.0) +# APT repo for node (26.12.0) RUN curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg -ENV NODE_MAJOR=24 +ENV NODE_MAJOR=26 RUN echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list RUN apt update && \ @@ -102,7 +102,7 @@ RUN apt update && \ pkg-config \ libssl-dev \ # Node - nodejs=24.15.0-1nodesource1 \ + nodejs=26.12.0-1nodesource1 \ # Python (clang bindings for wasm bindgen.) python3 \ python3-clang \ @@ -121,10 +121,10 @@ RUN wget https://apt.llvm.org/llvm.sh && \ # Install wasi-sdk. RUN arch=$(uname -m) && \ if [ "$arch" = "aarch64" ]; then arch="arm64"; fi && \ - wget https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-27/wasi-sdk-27.0-${arch}-linux.tar.gz && \ - tar xvf wasi-sdk-27.0-${arch}-linux.tar.gz && \ - mv wasi-sdk-27.0-${arch}-linux /opt/wasi-sdk && \ - rm wasi-sdk-27.0-${arch}-linux.tar.gz + wget https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-34/wasi-sdk-34.0-${arch}-linux.tar.gz && \ + tar xvf wasi-sdk-34.0-${arch}-linux.tar.gz && \ + mv wasi-sdk-34.0-${arch}-linux /opt/wasi-sdk && \ + rm wasi-sdk-34.0-${arch}-linux.tar.gz # Install foundry. COPY --from=foundry /opt/foundry /opt/foundry @@ -154,9 +154,9 @@ RUN curl -fsSL https://releases.hashicorp.com/terraform/1.7.5/terraform_1.7.5_li && chmod +x /usr/local/bin/terraform \ && rm terraform.zip -# Install wasmtime. -RUN curl -fsSL https://github.com/bytecodealliance/wasmtime/releases/download/v20.0.2/wasmtime-v20.0.2-$(uname -m)-linux.tar.xz | tar xJ \ - && mv wasmtime-v20.0.2-$(uname -m)-linux/wasmtime /usr/local/bin \ +# Install wasmtime. 46 is the last release with wasi-threads (-Sthreads), which the threaded wasm tests use. +RUN curl -fsSL https://github.com/bytecodealliance/wasmtime/releases/download/v46.0.3/wasmtime-v46.0.3-$(uname -m)-linux.tar.xz | tar xJ \ + && mv wasmtime-v46.0.3-$(uname -m)-linux/wasmtime /usr/local/bin \ && rm -rf wasmtime* # Install zig. @@ -171,7 +171,7 @@ RUN curl -sL https://github.com/mikefarah/yq/releases/download/v4.42.1/yq_linux_ -o /usr/local/bin/yq && chmod +x /usr/local/bin/yq # Install playwright for browser testing. Ensure accessible for other users. -RUN npx -y playwright@1.49 install --with-deps && mv /root/.cache/ms-playwright /opt/ms-playwright +RUN npx -y playwright@1.63.0 install --with-deps && mv /root/.cache/ms-playwright /opt/ms-playwright ENV PLAYWRIGHT_BROWSERS_PATH=/opt/ms-playwright @@ -214,7 +214,7 @@ RUN apt update && \ zsh \ inotify-tools \ # Annoyingly unminimize upgrades nodejs. - nodejs=24.15.0-1nodesource1 \ + nodejs=26.12.0-1nodesource1 \ # smt_verification dependencies python3-venv \ python3-pip \ diff --git a/scripts/setup-container.sh b/scripts/setup-container.sh index a55da9c5ca6..02e6fece714 100644 --- a/scripts/setup-container.sh +++ b/scripts/setup-container.sh @@ -94,14 +94,14 @@ apt-get -y autoremove apt-get clean # ============================================================================= -# SECTION 2: Node.js 24 +# SECTION 2: Node.js 26 # ============================================================================= -log_info "Installing Node.js 24..." +log_info "Installing Node.js 26..." curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg -echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_24.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list +echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_26.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list apt-get update -apt-get install -y nodejs=24.15.0-1nodesource1 +apt-get install -y nodejs=26.12.0-1nodesource1 # ============================================================================= # SECTION 3: Clang 18/20 @@ -141,14 +141,14 @@ chmod +x /etc/profile.d/rust.sh # ============================================================================= # SECTION 5: wasi-sdk # ============================================================================= -log_info "Installing wasi-sdk 27..." +log_info "Installing wasi-sdk 34..." arch=$(uname -m) if [ "$arch" = "aarch64" ]; then arch="arm64"; fi -wget https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-27/wasi-sdk-27.0-${arch}-linux.tar.gz -tar xvf wasi-sdk-27.0-${arch}-linux.tar.gz -mv wasi-sdk-27.0-${arch}-linux /opt/wasi-sdk -rm wasi-sdk-27.0-${arch}-linux.tar.gz +wget https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-34/wasi-sdk-34.0-${arch}-linux.tar.gz +tar xvf wasi-sdk-34.0-${arch}-linux.tar.gz +mv wasi-sdk-34.0-${arch}-linux /opt/wasi-sdk +rm wasi-sdk-34.0-${arch}-linux.tar.gz # ============================================================================= # SECTION 6: Foundry @@ -209,8 +209,8 @@ curl -sL https://github.com/ProcursusTeam/ldid/releases/download/v2.1.5-procursu # ============================================================================= log_info "Installing wasmtime..." -curl -fsSL https://github.com/bytecodealliance/wasmtime/releases/download/v20.0.2/wasmtime-v20.0.2-$(uname -m)-linux.tar.xz | tar xJ -mv wasmtime-v20.0.2-$(uname -m)-linux/wasmtime /usr/local/bin +curl -fsSL https://github.com/bytecodealliance/wasmtime/releases/download/v46.0.3/wasmtime-v46.0.3-$(uname -m)-linux.tar.xz | tar xJ +mv wasmtime-v46.0.3-$(uname -m)-linux/wasmtime /usr/local/bin rm -rf wasmtime* # ============================================================================= From cc0672541994e74ea1350dd7dbff50fe533b16a1 Mon Sep 17 00:00:00 2001 From: Charlie <5764343+charlielye@users.noreply.github.com> Date: Tue, 20 Oct 2026 10:28:17 +0000 Subject: [PATCH 2/8] chore(bb): leave the AVM simulator's wasm build to its own PR This PR keeps to the toolchain and exception handling. The vm2_sim_smoke program, its test, the vm2-in-wasm CMake and the wasm32 fixes in the simulator move to the PR that builds bb-avm-sim as a wasm module for its generated package. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01G5s7nEWrYapDK2CWpEzcAf --- barretenberg/cpp/CMakePresets.json | 6 +- barretenberg/cpp/bootstrap.sh | 6 -- barretenberg/cpp/scripts/run_wasi_command.mjs | 15 ----- .../cpp/scripts/vm2_sim_smoke_test.sh | 19 ------ barretenberg/cpp/src/CMakeLists.txt | 9 --- .../src/barretenberg/crypto/CMakeLists.txt | 4 +- .../retrieved_bytecodes_tree_check.cpp | 4 +- .../vm2/simulation/gadgets/to_radix.cpp | 2 +- .../written_public_data_slots_tree_check.cpp | 4 +- .../vm2/simulation/lib/contract_crypto.cpp | 2 +- .../simulation/lib/indexed_memory_tree.hpp | 14 ++--- .../src/barretenberg/vm2/tooling/stats.cpp | 1 - .../barretenberg/vm2_sim_smoke/CMakeLists.txt | 4 -- .../vm2_sim_smoke/vm2_sim_smoke.cpp | 60 ------------------- .../memory_merkle_db.hpp | 6 +- 15 files changed, 20 insertions(+), 136 deletions(-) delete mode 100644 barretenberg/cpp/scripts/run_wasi_command.mjs delete mode 100755 barretenberg/cpp/scripts/vm2_sim_smoke_test.sh delete mode 100644 barretenberg/cpp/src/barretenberg/vm2_sim_smoke/CMakeLists.txt delete mode 100644 barretenberg/cpp/src/barretenberg/vm2_sim_smoke/vm2_sim_smoke.cpp diff --git a/barretenberg/cpp/CMakePresets.json b/barretenberg/cpp/CMakePresets.json index 07428005b14..8088676132a 100644 --- a/barretenberg/cpp/CMakePresets.json +++ b/barretenberg/cpp/CMakePresets.json @@ -421,8 +421,7 @@ "CMAKE_FIND_ROOT_PATH_MODE_PACKAGE": "ONLY", "CMAKE_C_COMPILER_WORKS": "ON", "CMAKE_CXX_COMPILER_WORKS": "ON", - "MULTITHREADING": "OFF", - "AVM": "OFF" + "MULTITHREADING": "OFF" } }, { @@ -768,8 +767,7 @@ "targets": [ "barretenberg.wasm", "barretenberg.wasm.gz", - "barretenberg-debug.wasm", - "vm2_sim_smoke" + "barretenberg-debug.wasm" ] }, { diff --git a/barretenberg/cpp/bootstrap.sh b/barretenberg/cpp/bootstrap.sh index 769597da18b..58478b1f6a7 100755 --- a/barretenberg/cpp/bootstrap.sh +++ b/barretenberg/cpp/bootstrap.sh @@ -358,11 +358,6 @@ function test_cmds_wasm_threads { echo "$hash:CPUS=8 HARDWARE_CONCURRENCY=8 barretenberg/cpp/scripts/wasmtime.sh barretenberg/cpp/build-wasm-threads/bin/ecc_tests" } -function test_cmds_wasm { - # vm2_sim in wasm gives the native result for the same transaction, and catches the exceptions it relies on. - echo "$hash barretenberg/cpp/scripts/vm2_sim_smoke_test.sh" -} - function test_cmds_asan { local prefix="$hash:CPUS=4:MEM=8g" @@ -400,7 +395,6 @@ function test_cmds_nightly { function test_cmds { if [ -z "${1:-}" ]; then test_cmds_native - test_cmds_wasm if [ "$CI_FULL" -eq 1 ]; then test_cmds_wasm_threads test_cmds_asan diff --git a/barretenberg/cpp/scripts/run_wasi_command.mjs b/barretenberg/cpp/scripts/run_wasi_command.mjs deleted file mode 100644 index 639a4a50281..00000000000 --- a/barretenberg/cpp/scripts/run_wasi_command.mjs +++ /dev/null @@ -1,15 +0,0 @@ -// Runs a bb wasi command (a module that imports its memory) under Node's WASI, with `dir` preopened at /data. -// Usage: node run_wasi_command.mjs [args...] -import { readFileSync } from "node:fs"; -import { WASI } from "node:wasi"; - -const [wasmPath, dir, ...args] = process.argv.slice(2); -const module = await WebAssembly.compile(readFileSync(wasmPath)); -const wasi = new WASI({ version: "preview1", args: [wasmPath, ...args], preopens: { "/data": dir }, returnOnExit: true }); -const importObject = wasi.getImportObject(); -const memory = new WebAssembly.Memory({ initial: 512, maximum: 65536 }); -for (const { module: from, name, kind } of WebAssembly.Module.imports(module)) { - if (kind === "memory") (importObject[from] ??= {})[name] = memory; -} -const instance = await WebAssembly.instantiate(module, importObject); -process.exitCode = wasi.start({ exports: { ...instance.exports, memory } }); diff --git a/barretenberg/cpp/scripts/vm2_sim_smoke_test.sh b/barretenberg/cpp/scripts/vm2_sim_smoke_test.sh deleted file mode 100755 index 254701d449d..00000000000 --- a/barretenberg/cpp/scripts/vm2_sim_smoke_test.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env bash -# Runs the same hinted public transaction through vm2_sim natively and in wasm (under node, so V8), and checks the -# wasm run catches the simulator's C++ exceptions and reaches the native result. -set -euo pipefail -cd $(dirname $0)/.. - -native_bin=$(scripts/preset-build-dir ${NATIVE_PRESET:-clang20})/bin/vm2_sim_smoke -wasm_bin=build-wasm/bin/vm2_sim_smoke -inputs_dir=src/barretenberg/vm2/testing -inputs=minimal_tx.testdata.bin - -native=$($native_bin $inputs_dir/$inputs | grep -E '^(caught|revert_code)') -wasm=$(node --no-warnings scripts/run_wasi_command.mjs $wasm_bin $inputs_dir /data/$inputs | - grep -E '^(caught|revert_code)') - -echo "native: $native" -echo "wasm: $wasm" -[ "$(echo "$wasm" | grep -c '^caught TagMismatchException')" -eq 1 ] -[ "$native" == "$wasm" ] diff --git a/barretenberg/cpp/src/CMakeLists.txt b/barretenberg/cpp/src/CMakeLists.txt index e6f2af8d45d..11967cf84c2 100644 --- a/barretenberg/cpp/src/CMakeLists.txt +++ b/barretenberg/cpp/src/CMakeLists.txt @@ -123,19 +123,10 @@ if(NOT FUZZING AND NOT WASM AND NOT BB_LITE) # NOTE: Do not conditionally base this on the AVM flag as it defines a necessary vm2_sim library. add_subdirectory(barretenberg/vm2) add_subdirectory(barretenberg/vm2_wsdb) - add_subdirectory(barretenberg/vm2_sim_smoke) add_subdirectory(barretenberg/cdb) add_subdirectory(barretenberg/avm) endif() -if(WASM) - # The AVM simulator, without the AVM prover (the wasm presets set AVM off). - add_subdirectory(barretenberg/aztec) - add_subdirectory(barretenberg/world_state_reference) - add_subdirectory(barretenberg/vm2) - add_subdirectory(barretenberg/vm2_sim_smoke) -endif() - # Pull in ipc-runtime as a C++ dependency. Provides the `ipc_runtime` # library target (static, or INTERFACE under WASM with transport sources # stubbed) that bbapi/wsdb/etc link against for the codegen-emitted diff --git a/barretenberg/cpp/src/barretenberg/crypto/CMakeLists.txt b/barretenberg/cpp/src/barretenberg/crypto/CMakeLists.txt index 63c1926142f..a2911b6b687 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/CMakeLists.txt +++ b/barretenberg/cpp/src/barretenberg/crypto/CMakeLists.txt @@ -12,4 +12,6 @@ add_subdirectory(ecdsa) add_subdirectory(aes128) add_subdirectory(poseidon2) -add_subdirectory(merkle_tree) +if (NOT WASM) + add_subdirectory(merkle_tree) +endif() diff --git a/barretenberg/cpp/src/barretenberg/vm2/simulation/gadgets/retrieved_bytecodes_tree_check.cpp b/barretenberg/cpp/src/barretenberg/vm2/simulation/gadgets/retrieved_bytecodes_tree_check.cpp index 7ab61f3718a..cb96ae66227 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/simulation/gadgets/retrieved_bytecodes_tree_check.cpp +++ b/barretenberg/cpp/src/barretenberg/vm2/simulation/gadgets/retrieved_bytecodes_tree_check.cpp @@ -17,8 +17,8 @@ bool RetrievedBytecodesTreeCheck::contains(const FF& class_id) { const auto snapshot = tree.get_snapshot(); auto [exists, low_leaf_index] = tree.get_low_indexed_leaf(class_id); - auto sibling_path = tree.get_sibling_path(static_cast(low_leaf_index)); - auto low_leaf_preimage = tree.get_leaf_preimage(static_cast(low_leaf_index)); + auto sibling_path = tree.get_sibling_path(low_leaf_index); + auto low_leaf_preimage = tree.get_leaf_preimage(low_leaf_index); indexed_tree_check.assert_read(class_id, std::nullopt, // No siloing diff --git a/barretenberg/cpp/src/barretenberg/vm2/simulation/gadgets/to_radix.cpp b/barretenberg/cpp/src/barretenberg/vm2/simulation/gadgets/to_radix.cpp index 7976e78a186..232d7ebac52 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/simulation/gadgets/to_radix.cpp +++ b/barretenberg/cpp/src/barretenberg/vm2/simulation/gadgets/to_radix.cpp @@ -50,7 +50,7 @@ std::pair, /* truncated */ bool> ToRadix::to_le_radix(const bool truncated = num_limbs < limbs.size(); if (truncated) { - limbs.erase(limbs.begin() + static_cast(num_limbs), limbs.end()); + limbs.erase(limbs.begin() + num_limbs, limbs.end()); } return { limbs, truncated }; diff --git a/barretenberg/cpp/src/barretenberg/vm2/simulation/gadgets/written_public_data_slots_tree_check.cpp b/barretenberg/cpp/src/barretenberg/vm2/simulation/gadgets/written_public_data_slots_tree_check.cpp index 32b0d6e8e12..e7908f33077 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/simulation/gadgets/written_public_data_slots_tree_check.cpp +++ b/barretenberg/cpp/src/barretenberg/vm2/simulation/gadgets/written_public_data_slots_tree_check.cpp @@ -24,8 +24,8 @@ bool WrittenPublicDataSlotsTreeCheck::contains(const AztecAddress& contract_addr const auto& tree = written_public_data_slots_tree_stack.top(); const auto snapshot = tree.get_snapshot(); auto [exists, low_leaf_index] = tree.get_low_indexed_leaf(leaf_slot); - auto sibling_path = tree.get_sibling_path(static_cast(low_leaf_index)); - auto low_leaf_preimage = tree.get_leaf_preimage(static_cast(low_leaf_index)); + auto sibling_path = tree.get_sibling_path(low_leaf_index); + auto low_leaf_preimage = tree.get_leaf_preimage(low_leaf_index); indexed_tree_check.assert_read(slot, IndexedTreeSiloingParameters{ diff --git a/barretenberg/cpp/src/barretenberg/vm2/simulation/lib/contract_crypto.cpp b/barretenberg/cpp/src/barretenberg/vm2/simulation/lib/contract_crypto.cpp index 370aa4bf476..d74895f1def 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/simulation/lib/contract_crypto.cpp +++ b/barretenberg/cpp/src/barretenberg/vm2/simulation/lib/contract_crypto.cpp @@ -58,7 +58,7 @@ FF compute_public_bytecode_first_field(size_t bytecode_size) // Fr<0x00000000000000000000000000000000000000000000000000016b480f8411f1> From: max fields in bytes = 3000 * 31 = // 16b48, Dom sep = f8411f1 static_assert(DOM_SEP__PUBLIC_BYTECODE <= UINT32_MAX, "Public bytecode domain separator must fit in 32 bits"); - return FF(uint256_t(DOM_SEP__PUBLIC_BYTECODE) + (uint256_t(bytecode_size) << 32)); + return FF(uint256_t(DOM_SEP__PUBLIC_BYTECODE) + uint256_t(bytecode_size << 32)); } FF compute_public_bytecode_commitment(std::span bytecode) diff --git a/barretenberg/cpp/src/barretenberg/vm2/simulation/lib/indexed_memory_tree.hpp b/barretenberg/cpp/src/barretenberg/vm2/simulation/lib/indexed_memory_tree.hpp index c2575fb2298..0bd01838ba0 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/simulation/lib/indexed_memory_tree.hpp +++ b/barretenberg/cpp/src/barretenberg/vm2/simulation/lib/indexed_memory_tree.hpp @@ -150,22 +150,20 @@ SequentialInsertionResult IndexedMemoryTree:: for (const auto& leaf_to_insert : leaves_to_insert) { FF key = leaf_to_insert.get_key(); GetLowIndexedLeafResponse find_low_leaf_result = get_low_indexed_leaf(key); - // index_t is 64-bit; size_t is 32-bit on wasm32. An index into this in-memory tree always fits. - const auto low_index = static_cast(find_low_leaf_result.index); - IndexedLeaf& low_leaf = leaves.at(low_index); + IndexedLeaf& low_leaf = leaves.at(find_low_leaf_result.index); - result.low_leaf_witness_data.push_back( - LeafUpdateWitnessData(low_leaf, find_low_leaf_result.index, tree.get_sibling_path(low_index))); + result.low_leaf_witness_data.push_back(LeafUpdateWitnessData( + low_leaf, find_low_leaf_result.index, tree.get_sibling_path(find_low_leaf_result.index))); if (!find_low_leaf_result.is_already_present) { // If the leaf is not already present, we point the low leaf to the new leaf and then insert the new leaf. IndexedLeaf new_indexed_leaf(leaf_to_insert, low_leaf.nextIndex, low_leaf.nextKey); - size_t insertion_index = leaves.size(); + index_t insertion_index = leaves.size(); low_leaf.nextIndex = insertion_index; low_leaf.nextKey = key; FF low_leaf_hash = HashingPolicy::hash(low_leaf.get_hash_inputs()); - tree.update_element(low_index, low_leaf_hash); + tree.update_element(find_low_leaf_result.index, low_leaf_hash); append_leaf(new_indexed_leaf); FF new_leaf_hash = HashingPolicy::hash(new_indexed_leaf.get_hash_inputs()); @@ -178,7 +176,7 @@ SequentialInsertionResult IndexedMemoryTree:: // Update the current leaf's value, don't change it's link low_leaf = IndexedLeaf(leaf_to_insert, low_leaf.nextIndex, low_leaf.nextKey); FF low_leaf_hash = HashingPolicy::hash(low_leaf.get_hash_inputs()); - tree.update_element(low_index, low_leaf_hash); + tree.update_element(find_low_leaf_result.index, low_leaf_hash); // Push an empty insertion witness result.insertion_witness_data.push_back( diff --git a/barretenberg/cpp/src/barretenberg/vm2/tooling/stats.cpp b/barretenberg/cpp/src/barretenberg/vm2/tooling/stats.cpp index 548cf658c2f..7f4113e93c7 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/tooling/stats.cpp +++ b/barretenberg/cpp/src/barretenberg/vm2/tooling/stats.cpp @@ -1,6 +1,5 @@ #include "barretenberg/vm2/tooling/stats.hpp" -#include #include #include #include diff --git a/barretenberg/cpp/src/barretenberg/vm2_sim_smoke/CMakeLists.txt b/barretenberg/cpp/src/barretenberg/vm2_sim_smoke/CMakeLists.txt deleted file mode 100644 index 122ee5f5dfb..00000000000 --- a/barretenberg/cpp/src/barretenberg/vm2_sim_smoke/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -# Runs one public transaction through vm2_sim from its hinted inputs. Built natively and under the wasm-eh preset, so -# the two can be compared; under wasm it also checks the simulator's C++ exceptions work. -add_executable(vm2_sim_smoke vm2_sim_smoke.cpp) -target_link_libraries(vm2_sim_smoke PRIVATE vm2_sim env) diff --git a/barretenberg/cpp/src/barretenberg/vm2_sim_smoke/vm2_sim_smoke.cpp b/barretenberg/cpp/src/barretenberg/vm2_sim_smoke/vm2_sim_smoke.cpp deleted file mode 100644 index dc4981f2f8b..00000000000 --- a/barretenberg/cpp/src/barretenberg/vm2_sim_smoke/vm2_sim_smoke.cpp +++ /dev/null @@ -1,60 +0,0 @@ -// Runs one public transaction through vm2_sim from hinted inputs (AvmProvingInputs, msgpack), as `bb avm_simulate` -// does, and first checks that a C++ exception thrown inside the simulator is caught. -// -// Usage: vm2_sim_smoke -#include "barretenberg/vm2/avm_sim_api.hpp" -#include "barretenberg/vm2/common/tagged_value.hpp" - -#include -#include -#include - -using namespace bb::avm2; - -namespace { - -std::vector read_all(const char* path) -{ - std::vector data; - FILE* file = std::fopen(path, "rb"); - if (file == nullptr) { - return data; - } - uint8_t chunk[1 << 16]; - size_t n = 0; - while ((n = std::fread(chunk, 1, sizeof(chunk), file)) > 0) { - data.insert(data.end(), chunk, chunk + n); - } - std::fclose(file); - return data; -} - -} // namespace - -int main(int argc, char** argv) -{ - try { - auto sum = TaggedValue::from(1) + TaggedValue::from(1); - std::printf("FAIL: mismatched tags added without throwing (tag %d)\n", static_cast(sum.get_tag())); - return 1; - } catch (const TagMismatchException& e) { - std::printf("caught TagMismatchException: %s\n", e.what()); - } - - if (argc < 2) { - std::printf("usage: %s \n", argv[0]); - return 2; - } - auto bytes = read_all(argv[1]); - if (bytes.empty()) { - std::printf("FAIL: could not read %s\n", argv[1]); - return 1; - } - auto inputs = AvmSimAPI::ProvingInputs::from(bytes); - auto result = AvmSimAPI().simulate_with_hinted_dbs(inputs); - std::printf("revert_code=%d total_l2_gas=%u total_da_gas=%u\n", - static_cast(result.revert_code), - result.gas_used.total_gas.l2_gas, - result.gas_used.total_gas.da_gas); - return 0; -} diff --git a/barretenberg/cpp/src/barretenberg/world_state_reference/memory_merkle_db.hpp b/barretenberg/cpp/src/barretenberg/world_state_reference/memory_merkle_db.hpp index 5e9046d8328..03dc055724d 100644 --- a/barretenberg/cpp/src/barretenberg/world_state_reference/memory_merkle_db.hpp +++ b/barretenberg/cpp/src/barretenberg/world_state_reference/memory_merkle_db.hpp @@ -103,7 +103,7 @@ template class MemoryIndexedTree { leaves_.push_back(Leaf(LeafType::padding(i), /*nextIndex=*/0, /*nextKey=*/0)); } for (size_t i = 0; i < initial_size; ++i) { - size_t next_index = i == (initial_size - 1) ? 0 : i + 1; + index_t next_index = i == (initial_size - 1) ? 0 : i + 1; leaves_[i].nextIndex = next_index; leaves_[i].nextKey = leaves_[next_index].leaf.get_key(); tree_.update_element(i, HashingPolicy::hash(leaves_[i].get_hash_inputs())); @@ -131,7 +131,7 @@ template class MemoryIndexedTree { Leaf get_leaf_preimage(index_t leaf_index) const { BB_ASSERT_LT(leaf_index, leaves_.size(), "Leaf index out of bounds"); - return leaves_[static_cast(leaf_index)]; + return leaves_[leaf_index]; } FF get_leaf_value(index_t leaf_index) const { return tree_.get_node(0, leaf_index); } @@ -149,7 +149,7 @@ template class MemoryIndexedTree { FF key = leaf_to_insert.get_key(); GetLowIndexedLeafResponse find_low_leaf_result = get_low_indexed_leaf(key); - Leaf& low_leaf = leaves_[static_cast(find_low_leaf_result.index)]; + Leaf& low_leaf = leaves_[find_low_leaf_result.index]; result.low_leaf_witness_data.emplace_back( low_leaf, find_low_leaf_result.index, tree_.get_sibling_path(find_low_leaf_result.index)); From 32c6a6760a62d6cb4fe8de5247278e8d7a0ce09a Mon Sep 17 00:00:00 2001 From: Charlie <5764343+charlielye@users.noreply.github.com> Date: Wed, 21 Oct 2026 14:40:35 +0000 Subject: [PATCH 3/8] fix(labs-patches): bump foundation's supertest to 7.1 for Node 26 supertest 6 resets the second of two concurrent requests on Node 26, which fails safe_json_rpc_client.test.ts. Carried until the aztec-node PR with the same change lands. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01G5s7nEWrYapDK2CWpEzcAf --- ...on-bump-supertest-to-7.1-for-Node-26.patch | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 labs-patches/0020-fix-foundation-bump-supertest-to-7.1-for-Node-26.patch diff --git a/labs-patches/0020-fix-foundation-bump-supertest-to-7.1-for-Node-26.patch b/labs-patches/0020-fix-foundation-bump-supertest-to-7.1-for-Node-26.patch new file mode 100644 index 00000000000..ca375487035 --- /dev/null +++ b/labs-patches/0020-fix-foundation-bump-supertest-to-7.1-for-Node-26.patch @@ -0,0 +1,64 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Charlie <5764343+charlielye@users.noreply.github.com> +Date: Wed, 21 Oct 2026 14:39:41 +0000 +Subject: [PATCH] fix(foundation): bump supertest to 7.1 for Node 26 + +On Node 26, supertest 6 resets the second of two concurrent requests +(read ECONNRESET), which fails the manual batching tests in +safe_json_rpc_client.test.ts. supertest 7.1.0 and later handle it, on +Node 24 as well. + +Co-Authored-By: Claude Opus 5.5 +Claude-Session: https://claude.ai/code/session_01G5s7nEWrYapDK2CWpEzcAf + +diff --git a/yarn-project/foundation/package.json b/yarn-project/foundation/package.json +index 50886664b3e554d48e9366bbf3ab3ea5a083feb1..50592fca7349e33aeea590b3eb8eec281a56a5ab 100644 +--- a/yarn-project/foundation/package.json ++++ b/yarn-project/foundation/package.json +@@ -196,7 +196,7 @@ + "globals": "^16.1.0", + "jest": "^30.0.0", + "prettier": "^3.5.3", +- "supertest": "^6.3.3", ++ "supertest": "^7.1.0", + "ts-node": "^10.9.1", + "typescript": "^5.3.3", + "typescript-eslint": "^8.32.1", +diff --git a/yarn-project/yarn.lock b/yarn-project/yarn.lock +index f3b1bd1dadbb21a3f7bb0349aebae010ea434490..177ceaa85180e6b5c889b71aaffa2c8da60e095c 100644 +GIT binary patch +delta 1066 +zcmZ`&O=z4&7-n~~`)xa|`PprPY1(c#MQSwbH~%x6LsRh3L+Pb$ih`l@TUN8X$tLYd +z3D`q&Ht4G$sCbhqUi3pO)}seO5wRB!p4y8xh$j(>lY@9sW?pz_-sgE?o_XH)UdKP* +z#-D!wXzztD(BAInbMSbjG2!{PjRWu|y-qVmJi2{STlYhlfg +zdbh%J?q<)E<-vNtyGlA~!Q&6>^RvtA{{td0@n(4rzOGi947L_Szqhp& +zM)1pK^>{I?*Up@rIw%ic>4nA3-i?9Tx;YB)-6rb5R|~aTardd(^W6&V$l~|wwJU!V +zUtY~Fm*A7D+2jOkcMrE(x58+%Hym_Z6y85I)`b3*Y`m26leO71?f(+4-EFo16}S!c +zmFyJ!*vyW>xA*Etx0zr(2p6bV)`sY*_exUlydW4;LA;?hDw8v(7!h7Z#+f5j*^pyK +zwB#`-fm?5#)FgWAi49EC=w0NDk(gj!8^VP3%BAZhx73mg7t-O|A%Jgwq5t%G3 +zgJVHP;*7S0N<}ay$>`3Jm@DQ@lp0HlIj1JiL$JYVVGNf#O-B#-+-=l~^;{X5v + +delta 890 +zcmY*XJ&2t}6y?2__g?Z%bocG9KLLqrEV6FGWB%vfHDWA86k{;KkjgN3el!+YqD!LH +zLQ*_!Y*a2*TBH%T2uSz}Z7j4?#Ky)#yHu`VFV2dM#hKv_Gxwf3=lptGeRfOT{ppX9 +zpBtWC7@WPmy1!W6AM~sH!?&L3d3p5n(~EoOMh%Dhd*{Z>-|*4VXoc^8Je>8DZZbR0 +zr*95d_=_De<142p6P}-(%-C?Z*5BHgJigU`MU&_M;_uH-AK?c-?`FJyX}UDjbAIl^ +zkz@SQrRfH5elQWdc(`4-2I9$Ga0+CR)~o7W@ikD8)@g89i%Levh#_i}NvCK`l``dI +zjIyp&YismCl#tNGs#9Bni6v-XY^!Vt$$N##Vl}NKi)d^?3rYt^fo$sd&YflEr#2OUhIupw&d0JYq04Cz2o)G)j($ti)(iP*q{Jyt;qr +zsm0FTwBc~Wk$z{d`||xYn5(%yvDK}w-zaatb9MXL);jRF?~T`Z8^xGkaiSZ-f5I<< +z*c<7&;=i}V3BC+sllk@L>kog9ru@c-;(=XbvXns==@i9^DuwJpnYK$0I!fx Date: Wed, 21 Oct 2026 16:00:50 +0000 Subject: [PATCH 4/8] fix(labs-patches): bump labs' playwright to 1.63.0 Chromium 131 from playwright 1.49 cannot compile bb's exnref wasm, which fails chonk_browser.test.ts, and the 1.49 pins point at browsers the CI image no longer installs. Carried until the aztec-node PR with the same change lands. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01G5s7nEWrYapDK2CWpEzcAf --- ...0021-chore-bump-playwright-to-1.63.0.patch | 124 ++++++++++++++++++ 1 file changed, 124 insertions(+) create mode 100644 labs-patches/0021-chore-bump-playwright-to-1.63.0.patch diff --git a/labs-patches/0021-chore-bump-playwright-to-1.63.0.patch b/labs-patches/0021-chore-bump-playwright-to-1.63.0.patch new file mode 100644 index 00000000000..4d3b3a48e2a --- /dev/null +++ b/labs-patches/0021-chore-bump-playwright-to-1.63.0.patch @@ -0,0 +1,124 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Charlie <5764343+charlielye@users.noreply.github.com> +Date: Wed, 21 Oct 2026 16:00:31 +0000 +Subject: [PATCH] chore: bump playwright to 1.63.0 + +Chromium 131, which playwright 1.49 ships, cannot compile wasm that uses +standard (exnref) exception handling, and fails with "invalid value type +'exn', enable with --experimental-wasm-exnref". aztec-packages is moving +bb's wasm to exnref and its CI image to playwright 1.63.0 browsers +(Chromium 153), which compile it. The 1.49 pins also point at browsers +that image no longer installs. + +Co-Authored-By: Claude Opus 5.5 +Claude-Session: https://claude.ai/code/session_01G5s7nEWrYapDK2CWpEzcAf + +diff --git a/playground/package.json b/playground/package.json +index 89a087c4c452e6888ba56b296cf616fa3a5c43f8..e79dd5c7b7798aed133e49cc19f160f79d13bb28 100644 +--- a/playground/package.json ++++ b/playground/package.json +@@ -42,7 +42,7 @@ + }, + "devDependencies": { + "@eslint/js": "^9.18.0", +- "@playwright/test": "1.49.0", ++ "@playwright/test": "1.63.0", + "@types/buffer-json": "^2", + "@types/node": "^22.15.17", + "@types/react": "^19.0.6", +diff --git a/playground/yarn.lock b/playground/yarn.lock +index 0a10b9416320c9fb18459be426293fb76dacb461..c51f597bafa7436e802e3e66b676c9c86eb3f15c 100644 +GIT binary patch +delta 580 +zcmYL`y^2&p5QVun(uEy_0b$KF98jvey1TjrLEk_hz@V$EJCXJ81vXfW4K8?NgBc7A +zMhu4C6&8#)F%S$EVIIK9NF)2A?uMtJs=jm1yI;HKKX=!Mvp(R*SF`P#E(|a3&6^rN +zz(oK4B?ZUQehBVnWj*>Tc(yqx>dwOE^Y?DQ+vv7?|LwxT_-NJ7$0sNK)!FU*>}9$C^!ff>bLX##c!1LnNyUNX +zoNQqvQve!CjLN|R#$ug>0-{0+Y6;1y7H|<`MaL2`H7ik2f{VeU0;6xxRE5EqYAl$f +zDG6)a7mAY%nS9|i-u&7v#@|Q%&XxaQ|B}DpzIK`Y&UkdvPbFOzpr&d=Ns*;k%A6zx +z@}${Sf>NtX-UJlK)!~#I8ww;PicKzBw38(@Y@@UV%&`{GW(6Cr&8*o50%u*40M!_) +XT)6dOgk3=a9v<9UY|cORXQzJvSDdx5 + +delta 854 +zcmaKq&x_VK5XQ+@#A>V5`h#sReccKz3NMpnl1cW~zd$^CGnph?Y +zFy1)7>-S6hFpgnyX~$@^R)1Li=KJNPksjmp=r4Px7uWYoRX_TZT9|IE?~(KL{<@u* +z5TQ6zE4o~Q&CY>tni3HcHEnW=7K?GzO2TYHKyd6!)GcBTma%aztyzX#Lu8Xut;rT` +z9r;YAa!e#w-cxGQBhgh2vpieZ-{@+O5u7*M(jGTFekCC#C-@j8Iuj3sbl|k2-Y_aV$B5P*ri}n222>W)){Qpjl8KTcr-DWOdJtCM9?96 +a*{hM4K-|DJXkw1GUw$J@KmK*Nv+)l^athx7 + +diff --git a/yarn-project/ivc-integration/package.json b/yarn-project/ivc-integration/package.json +index 130368d205d08892c3d972048079033caa3c0205..4b18bfe7627adf823ba430aac35ab5b7955d0d89 100644 +--- a/yarn-project/ivc-integration/package.json ++++ b/yarn-project/ivc-integration/package.json +@@ -68,7 +68,7 @@ + "@aztec-labs/stdlib": "workspace:^", + "change-case": "^5.4.4", + "pako": "^2.1.0", +- "playwright": "1.49.0", ++ "playwright": "1.63.0", + "puppeteer": "^24.22.3", + "tslib": "^2.4.0" + }, +@@ -80,7 +80,7 @@ + "@aztec-labs/simulator": "workspace:^", + "@aztec-labs/world-state": "workspace:^", + "@jest/globals": "^30.0.0", +- "@playwright/test": "1.49.0", ++ "@playwright/test": "1.63.0", + "@types/jest": "^30.0.0", + "@types/node": "^22.15.17", + "@types/pako": "^2.0.3", +diff --git a/yarn-project/kv-store/package.json b/yarn-project/kv-store/package.json +index b8ca0acb9e49a42205ae228c6dc196d527c3a8dd..edb24ec9b82acde79500c313ccdf3abcb42e766d 100644 +--- a/yarn-project/kv-store/package.json ++++ b/yarn-project/kv-store/package.json +@@ -54,7 +54,7 @@ + "@vitest/browser-playwright": "^4.0.0", + "buffer": "^6.0.3", + "jest": "^30.0.0", +- "playwright": "1.49.0", ++ "playwright": "1.63.0", + "ts-node": "^10.9.1", + "typescript": "^5.3.3", + "util": "^0.12.5", +diff --git a/yarn-project/yarn.lock b/yarn-project/yarn.lock +index 177ceaa85180e6b5c889b71aaffa2c8da60e095c..a9e0b59e45c81700379bd5ac3872f83472fea3ee 100644 +GIT binary patch +delta 693 +zcmaKpy=zoa5XIT7c`y46N{j{+10h%$SZ40W+_?e8%EHEkfNi*+U||djc9Mk@+gZ59 +zD$DRx$tVxfP42wKE+OYlY;8!ZkDcg|eS%dcSdjWFMASo28{k +z>A}Oh_qSG;uutv&&F=a3%vyJ$Q|jB*#rFDIcYgY}w;j$j{T;89CiI*U6|-j`;VlOp +zvNhT$$ckMu$$F)A_6D^`kiCV-31t=#WRNbAL(Ni>){>M^8qH5e{CMH5ffRbeY8%1ft-wX?f#RgtL>m_n)Yqo)c=e9y>90IV$-xg +zs-~V@-rBymTKJtX{lh5*HbDqxE}RIYW2?0f!hsc8Ar(9>TZuVoX@&L{l?+Kr=~*Tv +z97PVOZ2)j8izuY(bWjOJz+xnlQGir2YHZ(q>8%Vmdri^l@n&!K +GG5-Q`dCQjo + +delta 898 +zcmZ9KyK5Cu5XQN=kIh{ra*e1_BlsXiB6{8r(9*`ngouS8V7e5DOz%+{Q*D +zo>bOv#5VxtQmyZgWK0y{L%c% +zsc+lMi(aRC{d{$%LFVg^YhOCU;LSIO%kQ&|eJfX76n>*>bH`SUbkK1*<@?ot@=gaw4Jy9;sHg_*)XO+_-Dqtd-1T2DJLCGAX +zHyXV1pfrS_vPB(p4l1w^lkhRKAh|O}c*(PKmRXS^OWbI5DP=D$^U>QJcobkzfs-;S +zCPUy-37f1*NtC&B%_IF|b4^l<)FyQX$L6XJ+uGu&JSxhWrS73}I#j*VU+V5E`!95- +zmQB>rpf+AeE0i*bjstqlI9QWqW=i`&V~HrEMvh7O8AVz@@ +zgyA%$$ysZoQ$WWO1e3Mp +zPh1Bdk|r2jS#D@V3=}1H8H`dEC`qaE>Tzef9BDxSv#(pWbvCFSEDzfC +zRmrIvN50uaEJKb`zRo9!l$1xI;#C(#@Wl#n{AVVNN&IcD$cEM_9Ov=fL +zBsDS@gOrkao+C;Gl@f9;j10~&P1(#2(aK>p6hk+7 Date: Wed, 21 Oct 2026 16:40:06 +0000 Subject: [PATCH 5/8] fix: install full chromium in the transitional toolchain chonk_browser.test.ts launches puppeteer with playwright's chromium.executablePath(), which is the full chromium build. The transitional install only fetched the headless shell, so the path was missing and puppeteer fell back to a Chrome nobody installed. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01G5s7nEWrYapDK2CWpEzcAf --- bootstrap.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bootstrap.sh b/bootstrap.sh index faa016dacf0..bc2b44358d9 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -227,7 +227,8 @@ function transitional_toolchain_upgrade { export PATH=$dir/node-$node_version/bin:$dir/wasmtime-$wasmtime_version:$PATH export PLAYWRIGHT_BROWSERS_PATH=$dir/ms-playwright local out - if ! out=$(npx -y playwright@$playwright_version install chromium --only-shell 2>&1); then + # Full chromium, not just the headless shell: tests that launch through puppeteer take chromium.executablePath(). + if ! out=$(npx -y playwright@$playwright_version install chromium 2>&1); then echo "$out" return 1 fi From 3abad3b3ac72eba6790dafb6994cfc9127748161 Mon Sep 17 00:00:00 2001 From: Charlie <5764343+charlielye@users.noreply.github.com> Date: Wed, 21 Oct 2026 17:33:22 +0000 Subject: [PATCH 6/8] chore: tag the build images 3.2 The images built from this Dockerfile (node 26, wasi-sdk 34, wasmtime 46, playwright 1.63.0) go out as 3.2 so 3.1 keeps serving next and every other branch. CI, isolated tests, the AMI pre-pull and the devcontainer all move to 3.2. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01G5s7nEWrYapDK2CWpEzcAf --- .devcontainer/dev/devcontainer.json | 2 +- build-images/bootstrap.sh | 2 +- build-images/run.sh | 2 +- ci3/aws/ami_update.sh | 4 ++-- ci3/bootstrap_ec2 | 2 +- ci3/docker_isolate | 2 +- ci3/tests/signal_test | 4 ++-- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.devcontainer/dev/devcontainer.json b/.devcontainer/dev/devcontainer.json index 88631f248fd..cbef7f77374 100644 --- a/.devcontainer/dev/devcontainer.json +++ b/.devcontainer/dev/devcontainer.json @@ -1,6 +1,6 @@ { "name": "Development", - "image": "aztecprotocol/devbox:3.1", + "image": "aztecprotocol/devbox:3.2", "features": { // Use custom fork with noble added to list of supported distros. "./docker-in-docker": {} diff --git a/build-images/bootstrap.sh b/build-images/bootstrap.sh index 474aec6c76c..270480c9ac1 100755 --- a/build-images/bootstrap.sh +++ b/build-images/bootstrap.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash source $(git rev-parse --show-toplevel)/ci3/source_bootstrap -version="3.1" +version="3.2" arch=$(arch) branch=${BRANCH:-$(git rev-parse --abbrev-ref HEAD)} diff --git a/build-images/run.sh b/build-images/run.sh index 288937a7264..547623def41 100755 --- a/build-images/run.sh +++ b/build-images/run.sh @@ -41,5 +41,5 @@ else -vdevbox-var-lib-docker:/var/lib/docker \ -v$HOME/.ssh/id_rsa:/home/aztec-dev/.ssh/id_rsa:ro \ --privileged \ - aztecprotocol/devbox:3.1 + aztecprotocol/devbox:3.2 fi diff --git a/ci3/aws/ami_update.sh b/ci3/aws/ami_update.sh index 1ff6434e33f..aed2a0555a9 100755 --- a/ci3/aws/ami_update.sh +++ b/ci3/aws/ami_update.sh @@ -54,8 +54,8 @@ ssh $ssh_args -F build_instance_ssh_config ubuntu@$ip 'export CRS_FORMAT=uncompr # Pull devbox onto host, and build into docker-in-docker volume. ssh $ssh_args -F build_instance_ssh_config ubuntu@$ip " - docker run --privileged --rm -v bootstrap_ci_local_docker:/var/lib/docker aztecprotocol/devbox:3.1 bash -c \" - docker pull aztecprotocol/build:3.1 + docker run --privileged --rm -v bootstrap_ci_local_docker:/var/lib/docker aztecprotocol/devbox:3.2 bash -c \" + docker pull aztecprotocol/build:3.2 \" " diff --git a/ci3/bootstrap_ec2 b/ci3/bootstrap_ec2 index 402a5847998..b7189462525 100755 --- a/ci3/bootstrap_ec2 +++ b/ci3/bootstrap_ec2 @@ -401,7 +401,7 @@ start_build() { --pids-limit=65536 \ --shm-size=2g \ --ulimit nofile=1048576:1048576 \ - aztecprotocol/devbox:3.1 bash -c $(printf '%q' "$container_script") + aztecprotocol/devbox:3.2 bash -c $(printf '%q' "$container_script") } # If stdout is a tty, run in foreground, otherwise run in background and handle spot termination notices. diff --git a/ci3/docker_isolate b/ci3/docker_isolate index 210937e0d9a..bbf0880b161 100755 --- a/ci3/docker_isolate +++ b/ci3/docker_isolate @@ -79,7 +79,7 @@ cid=$(docker run -d \ -e TEST_TIMING_FILE \ -e RUN_ID \ "${arg_env_vars[@]}" \ - aztecprotocol/build:3.1 \ + aztecprotocol/build:3.2 \ /bin/bash -c "$cmd") set +x # At this point we know it's started, and can handle SIGTERM to kill the container. diff --git a/ci3/tests/signal_test b/ci3/tests/signal_test index e76d9735091..c4421de6536 100755 --- a/ci3/tests/signal_test +++ b/ci3/tests/signal_test @@ -73,8 +73,8 @@ if ! docker info &>/dev/null; then exit 0 fi -if ! docker image inspect aztecprotocol/build:3.1 &>/dev/null; then - echo "SKIP: aztecprotocol/build:3.1 image not available" +if ! docker image inspect aztecprotocol/build:3.2 &>/dev/null; then + echo "SKIP: aztecprotocol/build:3.2 image not available" exit 0 fi From ec52ea55190b201ec20bfcde0c6315bd68480092 Mon Sep 17 00:00:00 2001 From: Charlie <5764343+charlielye@users.noreply.github.com> Date: Wed, 21 Oct 2026 18:10:56 +0000 Subject: [PATCH 7/8] amis --- ci3/aws/ami_id_amd64 | 2 +- ci3/aws/ami_id_arm64 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ci3/aws/ami_id_amd64 b/ci3/aws/ami_id_amd64 index 43b3d727378..df270515a2a 100644 --- a/ci3/aws/ami_id_amd64 +++ b/ci3/aws/ami_id_amd64 @@ -1 +1 @@ -ami-0b92d1f5e1e85dd99 +ami-005af01ba84151744 diff --git a/ci3/aws/ami_id_arm64 b/ci3/aws/ami_id_arm64 index a34ef19e926..218856fd58c 100644 --- a/ci3/aws/ami_id_arm64 +++ b/ci3/aws/ami_id_arm64 @@ -1 +1 @@ -ami-0bd6dbacd3fb445bc +ami-0a6b922f8414b98e8 From 88232c8a151a870bea2837f3d0151fc6a67b23b8 Mon Sep 17 00:00:00 2001 From: Charlie <5764343+charlielye@users.noreply.github.com> Date: Wed, 21 Oct 2026 18:13:03 +0000 Subject: [PATCH 8/8] chore: drop the transitional toolchain upgrade The 3.2 build images and AMIs ship node 26.12.0, wasi-sdk 34, wasmtime 46.0.3 and playwright 1.63.0's browsers, so CI no longer needs to upgrade the 3.1 image in place. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01G5s7nEWrYapDK2CWpEzcAf --- bootstrap.sh | 33 --------------------------------- 1 file changed, 33 deletions(-) diff --git a/bootstrap.sh b/bootstrap.sh index bc2b44358d9..396d2ad9e2d 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -204,37 +204,6 @@ function cleanup { } trap cleanup EXIT -### TRANSITIONAL TOOLCHAIN UPGRADE ##################################################################################### -# TODO: Delete this section and its calls (prep, check) once CI runs a build image (and AMI) with the toolchains -# build-images/src/Dockerfile now installs. Until then, upgrade the older image in place on every run: wasi-sdk at -# /opt/wasi-sdk (only builds use it), and node, wasmtime and playwright's chromium under $HOME, which isolated test -# containers mount too, so PATH and PLAYWRIGHT_BROWSERS_PATH are passed through to them. -function transitional_toolchain_upgrade { - [ "$(os)" == "linux" ] && { [ "${CI:-0}" -eq 1 ] || [ "$(whoami)" == "aztec-dev" ]; } || return 0 - local dir=$HOME/.cache/aztec-transitional-toolchains arch=$(uname -m) - local node_version=v$expected_min_node_version wasmtime_version=v46.0.3 playwright_version=1.63.0 - local node_arch=$([ "$arch" == "aarch64" ] && echo arm64 || echo x64) - mkdir -p $dir - install_wasi_sdk - if [ ! -x $dir/node-$node_version/bin/node ]; then - curl -fsSL https://nodejs.org/dist/$node_version/node-$node_version-linux-$node_arch.tar.xz | tar xJ -C $dir - mv $dir/node-$node_version-linux-$node_arch $dir/node-$node_version - fi - if [ ! -x $dir/wasmtime-$wasmtime_version/wasmtime ]; then - curl -fsSL https://github.com/bytecodealliance/wasmtime/releases/download/$wasmtime_version/wasmtime-$wasmtime_version-$arch-linux.tar.xz | tar xJ -C $dir - mv $dir/wasmtime-$wasmtime_version-$arch-linux $dir/wasmtime-$wasmtime_version - fi - export PATH=$dir/node-$node_version/bin:$dir/wasmtime-$wasmtime_version:$PATH - export PLAYWRIGHT_BROWSERS_PATH=$dir/ms-playwright - local out - # Full chromium, not just the headless shell: tests that launch through puppeteer take chromium.executablePath(). - if ! out=$(npx -y playwright@$playwright_version install chromium 2>&1); then - echo "$out" - return 1 - fi - export ENV_VARS_TO_INJECT="${ENV_VARS_TO_INJECT:-} PATH PLAYWRIGHT_BROWSERS_PATH" -} - ### TOOLCHAIN CHECKS ################################################################################################### function check_minimum_version { local min_version=$1 @@ -448,7 +417,6 @@ function stop_txes { } function prep { - transitional_toolchain_upgrade check_toolchains pull_submodules } @@ -885,7 +853,6 @@ case "$cmd" in git clean -ffdx ;; "check") - transitional_toolchain_upgrade check_toolchains echo "Toolchains look good! 🎉" ;;