Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ bb-cpp-full: bb-cpp bb-cpp-gcc bb-cpp-fuzzing bb-cpp-windows bb-cpp-asan bb-cpp-
bb-ts: bb-cpp-wasm bb-cpp-wasm-threads bb-cpp-native ipc-runtime
$(call build,$@,barretenberg/ts,build_bb_js)

# Copies the cross-compiles into bb.js.
# Copies the cross-compiled bb binaries into bb.js-api, which bb.js runs through.
bb-ts-cross-copy: bb-ts bb-cpp-cross
$(call build,$@,barretenberg/ts,cross_copy_bb_js)

Expand All @@ -266,10 +266,10 @@ bb-ts-cross-copy: bb-ts bb-cpp-cross
bb-avm-sim: ipc-codegen ipc-runtime bb-cpp-native bb-ts
$(call build,$@,barretenberg/ts,build_bb_avm_sim)

# Ordered after bb-cdb for the same reason bb-cdb is ordered after bb-avm-sim:
# all three regenerate the same barretenberg/ts workspaces and install into the
# same node_modules.
bb-avm-sim-cross-copy: bb-avm-sim bb-cdb bb-cpp-cross
# Ordered after bb-cdb (and after bb-ts-cross-copy, which builds bb.js-api's cross copies)
# for the same reason bb-cdb is ordered after bb-avm-sim: they all regenerate the same
# barretenberg/ts workspaces and install into the same node_modules.
bb-avm-sim-cross-copy: bb-avm-sim bb-cdb bb-ts-cross-copy bb-cpp-cross
$(call build,$@,barretenberg/ts,cross_copy_bb_avm_sim)

# Generated @aztec-foundation/cdb server bindings. Ordered after bb-avm-sim rather than run
Expand Down
7 changes: 6 additions & 1 deletion barretenberg/acir_tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@
"basic-ftp": "^5.2.0",
"node-forge": "^1.3.2",
"serialize-javascript": "^7.0.3",
"@aztec-foundation/ipc-runtime": "portal:../../ipc-runtime/ts"
"@aztec-foundation/ipc-runtime": "portal:../../ipc-runtime/ts",
"@aztec-foundation/bb.js-api": "portal:../ts/bb.js-api",
"@aztec-foundation/bb.js-api-darwin-arm64": "portal:../ts/bb.js-api/packages/bb.js-api-darwin-arm64",
"@aztec-foundation/bb.js-api-darwin-x64": "portal:../ts/bb.js-api/packages/bb.js-api-darwin-x64",
"@aztec-foundation/bb.js-api-linux-arm64": "portal:../ts/bb.js-api/packages/bb.js-api-linux-arm64",
"@aztec-foundation/bb.js-api-linux-x64": "portal:../ts/bb.js-api/packages/bb.js-api-linux-x64"
}
}
66 changes: 57 additions & 9 deletions barretenberg/acir_tests/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,65 @@ __metadata:
languageName: node
linkType: hard

"@aztec-foundation/bb.js-api-darwin-arm64@portal:../ts/bb.js-api/packages/bb.js-api-darwin-arm64::locator=%40aztec%2Facir-tests%40workspace%3A.":
version: 0.0.0-use.local
resolution: "@aztec-foundation/bb.js-api-darwin-arm64@portal:../ts/bb.js-api/packages/bb.js-api-darwin-arm64::locator=%40aztec%2Facir-tests%40workspace%3A."
conditions: os=darwin & cpu=arm64
languageName: node
linkType: soft

"@aztec-foundation/bb.js-api-darwin-x64@portal:../ts/bb.js-api/packages/bb.js-api-darwin-x64::locator=%40aztec%2Facir-tests%40workspace%3A.":
version: 0.0.0-use.local
resolution: "@aztec-foundation/bb.js-api-darwin-x64@portal:../ts/bb.js-api/packages/bb.js-api-darwin-x64::locator=%40aztec%2Facir-tests%40workspace%3A."
conditions: os=darwin & cpu=x64
languageName: node
linkType: soft

"@aztec-foundation/bb.js-api-linux-arm64@portal:../ts/bb.js-api/packages/bb.js-api-linux-arm64::locator=%40aztec%2Facir-tests%40workspace%3A.":
version: 0.0.0-use.local
resolution: "@aztec-foundation/bb.js-api-linux-arm64@portal:../ts/bb.js-api/packages/bb.js-api-linux-arm64::locator=%40aztec%2Facir-tests%40workspace%3A."
conditions: os=linux & cpu=arm64
languageName: node
linkType: soft

"@aztec-foundation/bb.js-api-linux-x64@portal:../ts/bb.js-api/packages/bb.js-api-linux-x64::locator=%40aztec%2Facir-tests%40workspace%3A.":
version: 0.0.0-use.local
resolution: "@aztec-foundation/bb.js-api-linux-x64@portal:../ts/bb.js-api/packages/bb.js-api-linux-x64::locator=%40aztec%2Facir-tests%40workspace%3A."
conditions: os=linux & cpu=x64
languageName: node
linkType: soft

"@aztec-foundation/bb.js-api@portal:../ts/bb.js-api::locator=%40aztec%2Facir-tests%40workspace%3A.":
version: 0.0.0-use.local
resolution: "@aztec-foundation/bb.js-api@portal:../ts/bb.js-api::locator=%40aztec%2Facir-tests%40workspace%3A."
dependencies:
"@aztec-foundation/bb.js-api-darwin-arm64": "npm:0.1.0"
"@aztec-foundation/bb.js-api-darwin-x64": "npm:0.1.0"
"@aztec-foundation/bb.js-api-linux-arm64": "npm:0.1.0"
"@aztec-foundation/bb.js-api-linux-x64": "npm:0.1.0"
"@aztec-foundation/ipc-runtime": "@aztec-foundation/ipc-runtime"
msgpackr: "npm:^1.11.2"
tslib: "npm:^2.4.0"
dependenciesMeta:
"@aztec-foundation/bb.js-api-darwin-arm64":
optional: true
"@aztec-foundation/bb.js-api-darwin-x64":
optional: true
"@aztec-foundation/bb.js-api-linux-arm64":
optional: true
"@aztec-foundation/bb.js-api-linux-x64":
optional: true
bin:
bb: ./dest/bin.js
languageName: node
linkType: soft

"@aztec-foundation/bb.js@portal:../../ts/bb.js::locator=bbjs-test%40workspace%3Abbjs-test":
version: 0.0.0-use.local
resolution: "@aztec-foundation/bb.js@portal:../../ts/bb.js::locator=bbjs-test%40workspace%3Abbjs-test"
dependencies:
"@aztec-foundation/bb.js-api": "workspace:^"
"@aztec-foundation/ipc-runtime": "@aztec-foundation/ipc-runtime"
comlink: "npm:^4.4.1"
commander: "npm:^12.1.0"
idb-keyval: "npm:^6.2.1"
msgpackr: "npm:^1.11.2"
Expand All @@ -33,8 +86,8 @@ __metadata:
version: 0.0.0-use.local
resolution: "@aztec-foundation/bb.js@portal:../../ts/bb.js::locator=browser-test-app%40workspace%3Abrowser-test-app"
dependencies:
"@aztec-foundation/bb.js-api": "workspace:^"
"@aztec-foundation/ipc-runtime": "@aztec-foundation/ipc-runtime"
comlink: "npm:^4.4.1"
commander: "npm:^12.1.0"
idb-keyval: "npm:^6.2.1"
msgpackr: "npm:^1.11.2"
Expand All @@ -49,6 +102,8 @@ __metadata:
"@aztec-foundation/ipc-runtime@portal:../../ipc-runtime/ts::locator=%40aztec%2Facir-tests%40workspace%3A.":
version: 0.0.0-use.local
resolution: "@aztec-foundation/ipc-runtime@portal:../../ipc-runtime/ts::locator=%40aztec%2Facir-tests%40workspace%3A."
bin:
ipc-runtime-prepare-arch-packages: ./scripts/prepare_arch_packages.mjs
languageName: node
linkType: soft

Expand Down Expand Up @@ -1604,13 +1659,6 @@ __metadata:
languageName: node
linkType: hard

"comlink@npm:^4.4.1":
version: 4.4.2
resolution: "comlink@npm:4.4.2"
checksum: 10c0/38aa1f455cf08e94aaa8fc494fd203cc0ef02ece6c21404b7931ce17567e8a72deacddab98aa5650cfd78332ff24c34610586f6fb27fd19dc77e753ed1980deb
languageName: node
linkType: hard

"command-exists@npm:^1.2.8":
version: 1.2.9
resolution: "command-exists@npm:1.2.9"
Expand Down
9 changes: 7 additions & 2 deletions barretenberg/cpp/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,12 @@ add_subdirectory(barretenberg/transcript)
add_subdirectory(barretenberg/translator_vm)
add_subdirectory(barretenberg/ultra_honk)
add_subdirectory(barretenberg/vm2_stub)
add_subdirectory(barretenberg/wasi)
# wasi implements the reactor's env against wasm builtins (__builtin_wasm_memory_size
# and friends), which a native compiler does not have. Only the WASM branch below
# consumes wasi_objects, so there is nothing to build here otherwise.
if(WASM)
add_subdirectory(barretenberg/wasi)
endif()

if(NOT FUZZING AND NOT WASM AND NOT BB_LITE)
# Mobile builds exclude these modules that aren't needed on mobile
Expand Down Expand Up @@ -222,7 +227,7 @@ add_library(
)

# bb-external: static library for external consumers (e.g. barretenberg-rs).
# Uses the core object list without lmdb/world_state — FFI consumers only need ipc_ffi_entry().
# Uses the core object list without lmdb/world_state — FFI consumers only need bb_ipc_ffi_entry().
# Built with -fvisibility=hidden; only WASM_EXPORT symbols remain visible.
if(NOT WASM)
# world_state_reference (the in-memory reference merkle DB and its bb_wsref_* C ABI) rides
Expand Down
1 change: 0 additions & 1 deletion barretenberg/cpp/src/barretenberg/bb/cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
#include "barretenberg/bbapi/bbapi.hpp"
#include "barretenberg/bbapi/bbapi_schema.hpp"
#include "barretenberg/bbapi/bbapi_ultra_honk.hpp"
#include "barretenberg/bbapi/c_bind.hpp"
#include "barretenberg/common/bb_bench.hpp"
#include "barretenberg/common/get_bytecode.hpp"
#include "barretenberg/common/memory_profile.hpp"
Expand Down
12 changes: 11 additions & 1 deletion barretenberg/cpp/src/barretenberg/bbapi/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ set(BB_GEN_DIR ${CMAKE_CURRENT_SOURCE_DIR}/generated)
if(NOT FUZZING)
set(BB_GEN_OUTPUTS
${BB_GEN_DIR}/bb_dispatch.hpp
${BB_GEN_DIR}/bb_ffi.cpp
${BB_GEN_DIR}/bb_ffi.hpp
${BB_GEN_DIR}/bb_ipc_server.hpp
${BB_GEN_DIR}/bb_types.hpp
${BB_GEN_DIR}/ipc_codegen/msgpack_adaptor.hpp
Expand All @@ -20,6 +22,7 @@ if(NOT FUZZING)
${IPC_CODEGEN_DIR}/src/*.ts
${IPC_CODEGEN_DIR}/templates/cpp/*.hpp
)
# --ffi emits the in-process entry (bb_ipc_ffi_entry) bb.js's wasm backend and barretenberg-rs call.
add_custom_command(
OUTPUT ${BB_GEN_OUTPUTS}
COMMAND node --experimental-strip-types --experimental-transform-types --no-warnings
Expand All @@ -28,11 +31,12 @@ if(NOT FUZZING)
--lang cpp
--out ${BB_GEN_DIR}
--server
--ffi
--cpp-namespace bb::bbapi
--cpp-include-dir barretenberg/bbapi/generated
--strip-method-prefix
DEPENDS ${BB_SCHEMA} ${IPC_CODEGEN_SRC}
COMMENT "Generating BB IPC wire types + server dispatch from bb_schema.json"
COMMENT "Generating BB IPC wire types + server dispatch + FFI entry from bb_schema.json"
VERBATIM
)
add_custom_target(bb_ipc_generated DEPENDS ${BB_GEN_OUTPUTS})
Expand All @@ -48,6 +52,12 @@ barretenberg_module(bbapi common chonk dsl crypto_poseidon2 crypto_pedersen_comm

if(NOT FUZZING)
add_dependencies(bbapi_objects bb_ipc_generated)
# The FFI entry is generated at build time, so the module's configure-time source glob misses it
# on a clean tree; list it explicitly (skipping the duplicate once the glob does see it).
get_target_property(BBAPI_SOURCES bbapi_objects SOURCES)
if(NOT "${BB_GEN_DIR}/bb_ffi.cpp" IN_LIST BBAPI_SOURCES)
target_sources(bbapi_objects PRIVATE ${BB_GEN_DIR}/bb_ffi.cpp)
endif()
endif()

# bbapi_tests needs vm2_stub to resolve dsl's AVM recursion constraint references
Expand Down
36 changes: 0 additions & 36 deletions barretenberg/cpp/src/barretenberg/bbapi/bb_curve_constants.json

This file was deleted.

4 changes: 4 additions & 0 deletions barretenberg/cpp/src/barretenberg/bbapi/bb_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,10 @@
"response": {
"dummy": "u8"
}
},
"Warmup": {
"request": {},
"response": {}
}
}
}
41 changes: 41 additions & 0 deletions barretenberg/cpp/src/barretenberg/bbapi/bbapi_handlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
#include "barretenberg/crypto/poseidon2/poseidon2_permutation.hpp"
#include "barretenberg/crypto/schnorr/schnorr.hpp"
#include "barretenberg/crypto/sha256/sha256.hpp"
#include "barretenberg/ecc/scalar_multiplication/scalar_multiplication.hpp"
#include "barretenberg/polynomials/polynomial.hpp"
#include "barretenberg/srs/factories/bn254_crs_data.hpp"
#include "barretenberg/srs/factories/bn254_g1_chunk_hashes.hpp"
#include "barretenberg/srs/global_crs.hpp"
Expand Down Expand Up @@ -576,4 +578,43 @@ void handle_srs_init_grumpkin_srs(BBApiRequest& /*ctx*/,
respond.ok({});
}

void handle_warmup(BBApiRequest& /*ctx*/, wire::BbWarmup&& /*cmd*/, Responder<wire::BbWarmupResponse> respond)
{
// Run the prover's hot loops once — field arithmetic, batch inversion, Poseidon2 and a Pippenger
// MSM — so a tiering JIT (wasm) has optimized them before real work runs through them.
constexpr size_t NUM_POINTS = 1 << 14;
constexpr size_t NUM_HASHES = 1 << 10;

// Successive doublings of the generator: sums of distinct subsets of {2^i G} are distinct, so the
// MSM's addition tree never meets two equal points, which the unsafe (SRS-shaped) path cannot
// handle. Small multiples of G would (G + 4G = 2G + 3G).
std::vector<g1::element> points(NUM_POINTS);
points[0] = g1::one;
for (size_t i = 1; i < NUM_POINTS; ++i) {
points[i] = points[i - 1].dbl();
}
g1::element::batch_normalize(points.data(), NUM_POINTS);
std::vector<g1::affine_element> affine_points(NUM_POINTS);
for (size_t i = 0; i < NUM_POINTS; ++i) {
affine_points[i] = g1::affine_element(points[i]);
}
Polynomial<fr> scalars = Polynomial<fr>::random(NUM_POINTS);
g1::element commitment = scalar_multiplication::pippenger_unsafe<curve::BN254>(scalars, affine_points);

std::vector<fr> elements(NUM_POINTS);
for (size_t i = 0; i < NUM_POINTS; ++i) {
elements[i] = scalars[i].sqr() + fr(static_cast<uint64_t>(i + 1));
}
fr::batch_invert(elements.data(), NUM_POINTS);

fr acc = elements[0];
for (size_t i = 0; i < NUM_HASHES; ++i) {
acc = crypto::Poseidon2<crypto::Poseidon2Bn254ScalarFieldParams>::hash({ acc, elements[i] });
}
if (commitment.is_point_at_infinity() || acc.is_zero()) {
throw_or_abort("Warmup: degenerate result");
}
respond.ok({});
}

} // namespace bb::bbapi
Original file line number Diff line number Diff line change
Expand Up @@ -170,4 +170,5 @@ void handle_chonk_batch_verifier_stop(BBApiRequest& ctx,
void handle_srs_init_grumpkin_srs(BBApiRequest& ctx,
wire::BbSrsInitGrumpkinSrs&& cmd,
Responder<wire::BbSrsInitGrumpkinSrsResponse> respond);
void handle_warmup(BBApiRequest& ctx, wire::BbWarmup&& cmd, Responder<wire::BbWarmupResponse> respond);
} // namespace bb::bbapi
54 changes: 0 additions & 54 deletions barretenberg/cpp/src/barretenberg/bbapi/c_bind.cpp

This file was deleted.

13 changes: 0 additions & 13 deletions barretenberg/cpp/src/barretenberg/bbapi/c_bind.hpp

This file was deleted.

Loading
Loading