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
2 changes: 1 addition & 1 deletion aztec-up/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ EOF
# TODO(AD): we have kludged a retry here. a local NPM install ought to be robust enough not to.
echo "Deploying packages to local npm registry (version: $version)..."
{
echo $root/barretenberg/ts
(cd $root/barretenberg/ts && ./bootstrap.sh get_projects)
$root/noir/bootstrap.sh get_projects
$root/yarn-project/bootstrap.sh get_projects
} | DRY_RUN= parallel --tag --line-buffer --halt now,fail=1 "retry 'cd {} && dump_fail \"deploy_npm $version\" >/dev/null'"
Expand Down
6 changes: 6 additions & 0 deletions barretenberg/cpp/.rebuild_patterns
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,9 @@
^barretenberg/cpp/scripts/
^barretenberg/cpp/bootstrap.sh
^barretenberg/cpp/CMakePresets.json
# bbapi and ipc_runtime generate C++ headers via ipc-codegen at CMake-time.
# Treat the codegen sources + templates as part of bb-cpp's input so the CI
# cache key invalidates when the codegen changes.
^ipc-codegen/src/.*\.ts$
^ipc-codegen/templates/cpp/.*$
^ipc-runtime/cpp/.*$
1 change: 1 addition & 0 deletions barretenberg/cpp/CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,7 @@
"CC": "$env{WASI_SDK_PREFIX}/bin/clang",
"CXX": "$env{WASI_SDK_PREFIX}/bin/clang++",
"CXXFLAGS": "-DBB_VERBOSE -fvisibility=hidden",
"LDFLAGS": "--no-wasm-opt",
"AR": "$env{WASI_SDK_PREFIX}/bin/llvm-ar",
"RANLIB": "$env{WASI_SDK_PREFIX}/bin/llvm-ranlib"
},
Expand Down
1 change: 1 addition & 0 deletions barretenberg/cpp/cmake/module.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ function(barretenberg_module_with_sources MODULE_NAME)
target_link_libraries(
${BENCHMARK_NAME}_bench_objects
PRIVATE
${MODULE_DEPENDENCIES}
benchmark::benchmark
${TRACY_LIBS}
${TBB_IMPORTED_TARGETS}
Expand Down
7 changes: 2 additions & 5 deletions barretenberg/cpp/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,8 @@ if(NOT FUZZING AND NOT WASM AND NOT BB_LITE)
add_subdirectory(barretenberg/nodejs_module)
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
# bb_ipc_server.hpp dispatcher.
if(NOT FUZZING AND NOT BB_LITE)
# Pull in ipc-runtime for native IPC servers and clients.
if(NOT FUZZING AND NOT WASM AND NOT BB_LITE)
add_subdirectory(${CMAKE_SOURCE_DIR}/../../ipc-runtime/cpp ${CMAKE_BINARY_DIR}/ipc-runtime)
endif()

Expand Down
2 changes: 1 addition & 1 deletion barretenberg/cpp/src/barretenberg/api/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ if(AVM_TRANSPILER_LIB)
endif()

if(NOT WASM AND NOT BB_LITE)
target_link_libraries(api_objects PRIVATE ipc)
target_link_libraries(api_objects PRIVATE ipc_runtime)
endif()
70 changes: 48 additions & 22 deletions barretenberg/cpp/src/barretenberg/api/api_chonk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
#include "barretenberg/api/file_io.hpp"
#include "barretenberg/api/json_output.hpp"
#include "barretenberg/api/log.hpp"
#include "barretenberg/bbapi/bbapi.hpp"
#include "barretenberg/bbapi/bbapi_handlers.hpp"
#include "barretenberg/bbapi/bbapi_shared.hpp"
#include "barretenberg/bbapi/bbapi_wire_convert.hpp"
#include "barretenberg/bbapi/generated/bb_types.hpp"
#include "barretenberg/chonk/chonk.hpp"
#include "barretenberg/chonk/chonk_verifier.hpp"
#include "barretenberg/chonk/mock_circuit_producer.hpp"
Expand Down Expand Up @@ -33,16 +36,21 @@ namespace { // anonymous namespace
*/
void write_chonk_vk(std::vector<uint8_t> bytecode, const std::filesystem::path& output_path, const API::Flags& flags)
{
bbapi::BBApiRequest request;
auto response =
bbapi::ChonkComputeVk{ .circuit = { .bytecode = std::move(bytecode) }, .use_zk_flavor = flags.use_zk_flavor }
.execute();
bbapi::handle_chonk_compute_vk(request,
bbapi::wire::ChonkComputeVk{
.circuit = bbapi::wire::CircuitInputNoVK{ .bytecode = std::move(bytecode) },
.use_zk_flavor = flags.use_zk_flavor,
});

const bool is_stdout = output_path == "-";
if (is_stdout) {
write_bytes_to_stdout(response.bytes);
} else if (flags.output_format == "json") {
// Note: Chonk VK doesn't have a hash, so we pass an empty string
std::string json_content = VkJson::build(response.fields, "", flags.scheme);
// Note: Chonk VK doesn't have a hash, so we pass an empty string.
auto fields = bbapi::fr_vec_from_wire(response.fields);
std::string json_content = VkJson::build(fields, "", flags.scheme);
write_file(output_path / "vk.json", std::vector<uint8_t>(json_content.begin(), json_content.end()));
info("VK (JSON) saved to ", output_path / "vk.json");
} else {
Expand All @@ -60,21 +68,25 @@ void ChonkAPI::prove(const Flags& flags,
request.vk_policy = bbapi::parse_vk_policy(flags.vk_policy);
std::vector<PrivateExecutionStepRaw> raw_steps = PrivateExecutionStepRaw::load_and_decompress(input_path);

bbapi::ChonkStart{ .num_circuits = static_cast<uint32_t>(raw_steps.size()) }.execute(request);
bbapi::handle_chonk_start(request,
bbapi::wire::ChonkStart{ .num_circuits = static_cast<uint32_t>(raw_steps.size()) });
info("Chonk: starting with ", raw_steps.size(), " circuits");
for (size_t i = 0; i < raw_steps.size(); ++i) {
const auto& step = raw_steps[i];
bbapi::ChonkLoad{
.circuit = { .name = step.function_name, .bytecode = step.bytecode, .verification_key = step.vk },
}
.execute(request);
bbapi::handle_chonk_load(request,
bbapi::wire::ChonkLoad{ .circuit = bbapi::wire::CircuitInput{
.name = step.function_name,
.bytecode = step.bytecode,
.verification_key = step.vk,
} });

// NOLINTNEXTLINE(bugprone-unchecked-optional-access): we know the optional has been set here.
info("Chonk: accumulating " + step.function_name);
bbapi::ChonkAccumulate{ .witness = step.witness }.execute(request);
bbapi::handle_chonk_accumulate(request, bbapi::wire::ChonkAccumulate{ .witness = step.witness });
}

auto proof = bbapi::ChonkProve{}.execute(request).proof;
auto wire_proof = bbapi::handle_chonk_prove(request, bbapi::wire::ChonkProve{}).proof;
auto proof = bbapi::chonk_proof_from_wire(std::move(wire_proof));

const bool output_to_stdout = output_dir == "-";

Expand Down Expand Up @@ -117,7 +129,9 @@ bool ChonkAPI::verify([[maybe_unused]] const Flags& flags,

auto vk_buffer = read_vk_file(vk_path);

auto response = bbapi::ChonkVerify{ .proof = std::move(proof), .vk = std::move(vk_buffer) }.execute();
bbapi::BBApiRequest request;
auto response = bbapi::handle_chonk_verify(
request, bbapi::wire::ChonkVerify{ .proof = bbapi::chonk_proof_to_wire(proof), .vk = std::move(vk_buffer) });
return response.valid;
}

Expand Down Expand Up @@ -147,7 +161,14 @@ bool ChonkAPI::batch_verify([[maybe_unused]] const Flags& flags, const std::file

info("ChonkAPI::batch_verify - found ", proofs.size(), " proof/vk pairs in ", proofs_dir.string());

auto response = bbapi::ChonkBatchVerify{ .proofs = std::move(proofs), .vks = std::move(vks) }.execute();
std::vector<bbapi::wire::ChonkProof> wire_proofs;
wire_proofs.reserve(proofs.size());
for (const auto& p : proofs) {
wire_proofs.push_back(bbapi::chonk_proof_to_wire(p));
}
bbapi::BBApiRequest request;
auto response = bbapi::handle_chonk_batch_verify(
request, bbapi::wire::ChonkBatchVerify{ .proofs = std::move(wire_proofs), .vks = std::move(vks) });
return response.valid;
}

Expand Down Expand Up @@ -221,12 +242,14 @@ bool ChonkAPI::check_precomputed_vks(const Flags& flags, const std::filesystem::
return false;
}
const bool use_zk_flavor = (i == raw_steps.size() - 1);
auto response =
bbapi::ChonkCheckPrecomputedVk{
.circuit = { .name = step.function_name, .bytecode = step.bytecode, .verification_key = step.vk },
auto response = bbapi::handle_chonk_check_precomputed_vk(
request,
bbapi::wire::ChonkCheckPrecomputedVk{
.circuit = bbapi::wire::CircuitInput{ .name = step.function_name,
.bytecode = step.bytecode,
.verification_key = step.vk },
.use_zk_flavor = use_zk_flavor,
}
.execute();
});

if (!response.valid) {
info("VK mismatch detected for function ", step.function_name);
Expand Down Expand Up @@ -271,9 +294,12 @@ void chonk_gate_count(const std::string& bytecode_path, bool include_gates_per_o
bbapi::BBApiRequest request;

auto bytecode = get_bytecode(bytecode_path);
auto response = bbapi::ChonkStats{ .circuit = { .name = "ivc_circuit", .bytecode = std::move(bytecode) },
.include_gates_per_opcode = include_gates_per_opcode }
.execute(request);
auto response = bbapi::handle_chonk_stats(
request,
bbapi::wire::ChonkStats{
.circuit = bbapi::wire::CircuitInputNoVK{ .name = "ivc_circuit", .bytecode = std::move(bytecode) },
.include_gates_per_opcode = include_gates_per_opcode,
});

// Build the circuit report. It always has one function, corresponding to the ACIR constraint systems.
// NOTE: can be reconsidered
Expand Down
Loading
Loading