Skip to content
Merged
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
13 changes: 10 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ endef
# PHONY TARGETS - List every target that has a file/dir of the same name.
#==============================================================================

.PHONY: noir barretenberg noir-projects l1-contracts release-image boxes playground docs aztec-up spartan
.PHONY: noir barretenberg noir-projects l1-contracts release-image boxes playground docs aztec-up spartan wsdb

#==============================================================================
# BOOTSTRAP TARGETS
Expand Down Expand Up @@ -205,7 +205,7 @@ bb-cpp-asan:
bb-cpp-smt:
$(call build,$@,barretenberg/cpp,build_smt_verification)

bb-cpp-release-dir: bb-cpp-native bb-cpp-cross
bb-cpp-release-dir: bb-cpp-native bb-cpp-cross bb-cpp-wasm bb-cpp-wasm-threads
$(call build,$@,barretenberg/cpp,build_release_dir)

bb-cpp-full: bb-cpp bb-cpp-gcc bb-cpp-fuzzing bb-cpp-asan bb-cpp-smt bb-cpp-cross-arm64-macos bb-cpp-cross-arm64-ios bb-cpp-cross-arm64-android
Expand Down Expand Up @@ -306,6 +306,13 @@ ipc-runtime-cross-arm64-macos:

ipc-runtime-cross: ipc-runtime ipc-runtime-cross-arm64-linux ipc-runtime-cross-amd64-macos ipc-runtime-cross-arm64-macos

#==============================================================================
# WSDB
#==============================================================================

wsdb: ipc-codegen ipc-runtime bb-cpp-native
$(call build,$@,wsdb)

#==============================================================================
# .claude tooling
#==============================================================================
Expand Down Expand Up @@ -372,7 +379,7 @@ l1-contracts-tests: l1-contracts-verifier
# Yarn Project - TypeScript monorepo with all TS packages
#==============================================================================

yarn-project: bb-ts noir-projects l1-contracts
yarn-project: bb-ts noir-projects l1-contracts wsdb
$(call build,$@,yarn-project)

yarn-project-tests: yarn-project
Expand Down
8 changes: 4 additions & 4 deletions barretenberg/cpp/CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -800,25 +800,25 @@
"name": "amd64-linux",
"configurePreset": "amd64-linux",
"inheritConfigureEnvironment": true,
"targets": ["bb", "nodejs_module", "bb-external"]
"targets": ["bb", "nodejs_module", "bb-external", "aztec-wsdb"]
},
{
"name": "arm64-linux",
"configurePreset": "arm64-linux",
"inheritConfigureEnvironment": true,
"targets": ["bb", "nodejs_module", "bb-external"]
"targets": ["bb", "nodejs_module", "bb-external", "aztec-wsdb"]
},
{
"name": "amd64-macos",
"configurePreset": "amd64-macos",
"inheritConfigureEnvironment": true,
"targets": ["bb", "nodejs_module", "bb-external"]
"targets": ["bb", "nodejs_module", "bb-external", "aztec-wsdb"]
},
{
"name": "arm64-macos",
"configurePreset": "arm64-macos",
"inheritConfigureEnvironment": true,
"targets": ["bb", "nodejs_module", "bb-external"]
"targets": ["bb", "nodejs_module", "bb-external", "aztec-wsdb"]
},
{
"name": "amd64-windows",
Expand Down
2 changes: 1 addition & 1 deletion barretenberg/cpp/format.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ elif [ "$1" == "changed" ]; then
format_files "$files"
fi
elif [ "$1" == "check" ]; then
files=$(find ./src -iname *.hpp -o -iname *.cpp -o -iname *.tcc | grep -v bb/deps)
files=$(find ./src -iname *.hpp -o -iname *.cpp -o -iname *.tcc | grep -v bb/deps | grep -v '/generated/')
echo "$files" | parallel -N10 clang-format-20 --dry-run --Werror
elif [ -n "$1" ]; then
files=$(git diff-index --relative --name-only $1 | grep -e '\.\(cpp\|hpp\|tcc\)$')
Expand Down
12 changes: 10 additions & 2 deletions barretenberg/cpp/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ if(WASM)
add_link_options(-Wl,--export-memory,--import-memory,--stack-first,-z,stack-size=1048576,--max-memory=4294967296)
endif()

include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${MSGPACK_INCLUDE} ${TRACY_INCLUDE} ${LMDB_INCLUDE} ${LIBDEFLATE_INCLUDE} ${HTTPLIB_INCLUDE} ${BACKWARD_INCLUDE} ${NLOHMANN_JSON_INCLUDE})
include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${MSGPACK_INCLUDE} ${TRACY_INCLUDE} ${LMDB_INCLUDE} ${LIBDEFLATE_INCLUDE} ${HTTPLIB_INCLUDE} ${BACKWARD_INCLUDE} ${NLOHMANN_JSON_INCLUDE} ${CMAKE_CURRENT_SOURCE_DIR}/../../../ipc-runtime/cpp)

# Add avm-transpiler include path when library is provided
if(AVM_TRANSPILER_LIB)
Expand Down Expand Up @@ -128,10 +128,18 @@ if(NOT FUZZING AND NOT WASM AND NOT BB_LITE)
add_subdirectory(barretenberg/vm2)
add_subdirectory(barretenberg/ipc)
add_subdirectory(barretenberg/wsdb)
add_subdirectory(barretenberg/wsdb_client)
add_subdirectory(barretenberg/vm2_wsdb)
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)
add_subdirectory(${CMAKE_SOURCE_DIR}/../../ipc-runtime/cpp ${CMAKE_BINARY_DIR}/ipc-runtime)
endif()

if(FUZZING_AVM)
if(FUZZING)
# Only add these if they weren't added above (when NOT FUZZING AND NOT WASM)
Expand Down
16 changes: 15 additions & 1 deletion barretenberg/cpp/src/barretenberg/bbapi/bbapi_chonk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@
#include "barretenberg/stdlib_circuit_builders/mega_circuit_builder.hpp"

#ifndef __wasm__
#include <algorithm>
#include <cerrno>
#include <chrono>
#include <csignal>
#include <cstring>
#include <fcntl.h>
#include <limits>
#include <sys/stat.h>
#include <thread>
#include <unistd.h>
Expand Down Expand Up @@ -450,7 +452,9 @@ namespace {
bool write_all(int fd, const uint8_t* ptr, size_t len)
{
while (len > 0) {
const ssize_t written = ::write(fd, ptr, len);
const auto chunk_len =
static_cast<unsigned int>(std::min<size_t>(len, std::numeric_limits<unsigned int>::max()));
const ssize_t written = ::write(fd, ptr, chunk_len);
if (written > 0) {
ptr += written;
len -= static_cast<size_t>(written);
Expand Down Expand Up @@ -508,7 +512,9 @@ void ChonkBatchVerifierService::start(std::vector<std::shared_ptr<MegaZKFlavor::
}
}

#ifdef SIGPIPE
(void)std::signal(SIGPIPE, SIG_IGN);
#endif
fifo_path_ = fifo_path;
fifo_failed_.store(false);

Expand Down Expand Up @@ -570,6 +576,7 @@ bool ChonkBatchVerifierService::ensure_fifo_open()
return false;
}

#ifndef _WIN32
struct stat statbuf;
if (lstat(fifo_path_.c_str(), &statbuf) != 0) {
info("ChonkBatchVerifierService: failed to stat FIFO '", fifo_path_, "': ", std::strerror(errno));
Expand All @@ -579,17 +586,24 @@ bool ChonkBatchVerifierService::ensure_fifo_open()
info("ChonkBatchVerifierService: result path is not a FIFO: ", fifo_path_);
return false;
}
#endif

for (size_t attempt = 0; attempt < 100; ++attempt) {
#ifndef _WIN32
fifo_fd_ = open(fifo_path_.c_str(), O_WRONLY | O_NONBLOCK | O_CLOEXEC | O_NOFOLLOW);
#else
fifo_fd_ = open(fifo_path_.c_str(), O_WRONLY);
#endif
if (fifo_fd_ >= 0) {
#ifndef _WIN32
struct stat opened_statbuf;
if (fstat(fifo_fd_, &opened_statbuf) != 0 || !S_ISFIFO(opened_statbuf.st_mode)) {
info("ChonkBatchVerifierService: opened result path is not a FIFO: ", fifo_path_);
close(fifo_fd_);
fifo_fd_ = -1;
return false;
}
#endif
return true;
}
if (errno != ENXIO && errno != EINTR) {
Expand Down
11 changes: 10 additions & 1 deletion barretenberg/cpp/src/barretenberg/common/try_catch_shim.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,14 @@
#include <string>

// Tool to make header only libraries (i.e. CLI11 and msgpack, though it has a bundled copy)
// not use exceptions with minimally invaslive changes
// not use exceptions with minimally invaslive changes.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: pre-existing typo

//
// Macros are guarded so any parent project (e.g. ipc_codegen/throw.hpp under
// codegen-emitted code) that predefines them wins. Same convention as
// ipc_codegen/throw.hpp, so the two headers can be #included in any order
// without redefinition warnings.

#ifndef THROW

#ifdef BB_NO_EXCEPTIONS
struct __AbortStream {
Expand All @@ -21,3 +28,5 @@ struct __AbortStream {
#define THROW throw
#define RETHROW THROW
#endif

#endif // THROW
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

#include "barretenberg/common/log.hpp"
#include "msgpack.hpp"
#include "msgpack_impl/drop_keys.hpp"
#include <cstddef>
#include <string_view>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,30 @@
#pragma once

#ifndef IPC_CODEGEN_MSGPACK_CONCEPTS_DEFINED
#define IPC_CODEGEN_MSGPACK_CONCEPTS_DEFINED

struct DoNothing {
void operator()(auto...) {}
};

namespace msgpack_concepts {

template <typename T>
concept HasMsgPack = requires(T t, DoNothing nop) { t.msgpack(nop); };

template <typename T, typename... Args>
concept MsgpackConstructible = requires(T object, Args... args) { T{ args... }; };

} // namespace msgpack_concepts

#endif

namespace msgpack_concepts {

template <typename T>
concept HasMsgPackSchema = requires(const T t, DoNothing nop) { t.msgpack_schema(nop); };

template <typename T>
concept HasMsgPackPack = requires(T t, DoNothing nop) { t.msgpack_pack(nop); };
template <typename T, typename... Args>
concept MsgpackConstructible = requires(T object, Args... args) { T{ args... }; };

} // namespace msgpack_concepts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#pragma once
#include <tuple>

#ifndef IPC_CODEGEN_MSGPACK_DROP_KEYS_DEFINED
#define IPC_CODEGEN_MSGPACK_DROP_KEYS_DEFINED

namespace msgpack {
template <typename Tuple, std::size_t... Is> auto drop_keys_impl(Tuple&& tuple, std::index_sequence<Is...>)
{
Expand All @@ -20,3 +23,5 @@ template <typename... Args> auto drop_keys(std::tuple<Args...>&& tuple)
return drop_keys_impl(tuple, compile_time_0_to_n_div_2);
}
} // namespace msgpack

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
#include "drop_keys.hpp"
#include <msgpack.hpp>

#ifndef IPC_CODEGEN_MSGPACK_STRUCT_MAP_ADAPTOR_DEFINED
#define IPC_CODEGEN_MSGPACK_STRUCT_MAP_ADAPTOR_DEFINED

namespace msgpack::adaptor {
// reads structs with msgpack() method from a JSON-like dictionary
template <msgpack_concepts::HasMsgPack T> struct convert<T> {
Expand Down Expand Up @@ -61,3 +64,5 @@ template <msgpack_concepts::HasMsgPack T> struct pack<T> {
};

} // namespace msgpack::adaptor

#endif
16 changes: 16 additions & 0 deletions barretenberg/cpp/src/barretenberg/vm2_wsdb/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# VM2 adapter for native AVM simulation against aztec-wsdb.
if(TARGET vm2_sim AND TARGET wsdb_ipc_client)
add_library(
wsdb_ipc_merkle_db
STATIC
wsdb_ipc_merkle_db.cpp
)
target_link_libraries(
wsdb_ipc_merkle_db
PUBLIC
barretenberg
vm2_sim
wsdb_ipc_client
)
set_target_properties(wsdb_ipc_merkle_db PROPERTIES POSITION_INDEPENDENT_CODE ON)
endif()
Loading
Loading