Skip to content
Closed
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
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,13 @@ ipc-codegen:
ipc-codegen-tests: ipc-codegen
$(call test,$@,ipc-codegen)

.PHONY: ipc-runtime ipc-runtime-tests
ipc-runtime:
$(call build,$@,ipc-runtime)

ipc-runtime-tests: ipc-runtime
$(call test,$@,ipc-runtime)

#==============================================================================
# .claude tooling
#==============================================================================
Expand Down
4 changes: 3 additions & 1 deletion barretenberg/cpp/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,9 @@ if(NOT FUZZING AND NOT WASM AND NOT BB_LITE)
add_subdirectory(barretenberg/world_state)
# 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/ipc)
# ipc-runtime lives outside barretenberg/cpp/ so it's portable to non-bb services.
# CMake binary dir kept under build/ so artifacts land alongside other libs.
add_subdirectory(${CMAKE_SOURCE_DIR}/../../ipc-runtime/cpp ${CMAKE_BINARY_DIR}/ipc-runtime)
add_subdirectory(barretenberg/wsdb)
add_subdirectory(barretenberg/wsdb_client)
add_subdirectory(barretenberg/nodejs_module)
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()
2 changes: 1 addition & 1 deletion barretenberg/cpp/src/barretenberg/api/api_msgpack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <vector>

#if !defined(__wasm__) && !defined(_WIN32)
#include "barretenberg/ipc/ipc_server.hpp"
#include "ipc_runtime/ipc_server.hpp"
#include <csignal>
#include <thread>
#include <unistd.h>
Expand Down
2 changes: 1 addition & 1 deletion barretenberg/cpp/src/barretenberg/api/api_msgpack.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include <string>

#ifndef __wasm__
#include "barretenberg/ipc/ipc_server.hpp"
#include "ipc_runtime/ipc_server.hpp"
#endif

namespace bb {
Expand Down
4 changes: 2 additions & 2 deletions barretenberg/cpp/src/barretenberg/bb/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ if (NOT(FUZZING))
target_link_libraries(bb PRIVATE avm_transpiler)
endif()
if(NOT WASM AND NOT BB_LITE)
target_link_libraries(bb PRIVATE ipc)
target_link_libraries(bb PRIVATE ipc_runtime)
endif()
if(ENABLE_STACKTRACES)
target_link_libraries(
Expand Down Expand Up @@ -63,7 +63,7 @@ if (NOT(FUZZING))
target_link_libraries(bb-avm PRIVATE avm_transpiler)
endif()
if(NOT WASM AND NOT BB_LITE)
target_link_libraries(bb-avm PRIVATE ipc)
target_link_libraries(bb-avm PRIVATE ipc_runtime)
endif()
if(ENABLE_STACKTRACES)
target_link_libraries(
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,10 @@
barretenberg_module(ipc_bench crypto_poseidon2 ipc)
barretenberg_module(ipc_bench crypto_poseidon2 ipc_runtime)

# barretenberg_module's bench codepath only links MODULE_DEPENDENCIES to the
# exe, not to the *_bench_objects lib. Existing bench deps live under
# barretenberg/cpp/src/ which is already on -I, so they didn't notice;
# ipc_runtime lives at /ipc-runtime/cpp/ so its include directory has to be
# threaded into the bench_objects target explicitly.
if(TARGET ipc_bench_objects)
target_link_libraries(ipc_bench_objects PRIVATE ipc_runtime)
endif()
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include "barretenberg/bbapi/bbapi.hpp"
#include "barretenberg/crypto/poseidon2/poseidon2.hpp"
#include "barretenberg/ecc/curves/bn254/fr.hpp"
#include "barretenberg/ipc/ipc_client.hpp"
#include "barretenberg/serialize/msgpack_impl.hpp"
#include "ipc_runtime/ipc_client.hpp"
#include <array>
#include <atomic>
#include <benchmark/benchmark.h>
Expand Down
2 changes: 0 additions & 2 deletions barretenberg/cpp/src/barretenberg/ipc/CMakeLists.txt

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ string(REGEX REPLACE "[\r\n\"]" "" NODE_API_HEADERS_DIR ${NODE_API_HEADERS_DIR})
add_library(nodejs_module SHARED ${SOURCE_FILES})
set_target_properties(nodejs_module PROPERTIES PREFIX "" SUFFIX ".node")
target_include_directories(nodejs_module PRIVATE ${NODE_API_HEADERS_DIR} ${NODE_ADDON_API_DIR})
target_link_libraries(nodejs_module PRIVATE world_state ipc vm2_sim)
target_link_libraries(nodejs_module PRIVATE world_state ipc_runtime vm2_sim)

# On macOS, Node.js N-API symbols are provided by the runtime, not at link time
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "barretenberg/nodejs_module/msgpack_client/msgpack_client_async.hpp"
#include "barretenberg/ipc/ipc_client.hpp"
#include "ipc_runtime/ipc_client.hpp"
#include "napi.h"
#include <cstdint>
#include <vector>
Expand All @@ -18,7 +18,7 @@ MsgpackClientAsync::MsgpackClientAsync(const Napi::CallbackInfo& info)
std::string shm_name = info[0].As<Napi::String>();

// Create shared memory client (SPSC-only, no max_clients needed)
client_ = bb::ipc::IpcClient::create_shm(shm_name);
client_ = ipc::IpcClient::create_shm(shm_name);

// Connect to bb server
if (!client_->connect()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include "barretenberg/ipc/ipc_client.hpp"
#include "ipc_runtime/ipc_client.hpp"
#include "napi.h"
#include <atomic>
#include <mutex>
Expand Down Expand Up @@ -71,7 +71,7 @@ class MsgpackClientAsync : public Napi::ObjectWrap<MsgpackClientAsync> {
void poll_responses();

// IPC client for shared memory communication
std::unique_ptr<bb::ipc::IpcClient> client_;
std::unique_ptr<ipc::IpcClient> client_;

// Background polling thread (detached - will be cleaned up by OS on process exit)
std::thread poll_thread_;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "barretenberg/nodejs_module/msgpack_client/msgpack_client_wrapper.hpp"
#include "barretenberg/ipc/ipc_client.hpp"
#include "ipc_runtime/ipc_client.hpp"
#include "napi.h"
#include <cstdint>
#include <vector>
Expand All @@ -18,7 +18,7 @@ MsgpackClientWrapper::MsgpackClientWrapper(const Napi::CallbackInfo& info)
std::string shm_name = info[0].As<Napi::String>();

// Create shared memory client (SPSC-only, no max_clients needed)
client_ = bb::ipc::IpcClient::create_shm(shm_name);
client_ = ipc::IpcClient::create_shm(shm_name);

// Connect to bb server
if (!client_->connect()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include "barretenberg/ipc/ipc_client.hpp"
#include "ipc_runtime/ipc_client.hpp"
#include "napi.h"
#include <memory>

Expand Down Expand Up @@ -32,7 +32,7 @@ class MsgpackClientWrapper : public Napi::ObjectWrap<MsgpackClientWrapper> {
static Napi::Function get_class(Napi::Env env);

private:
std::unique_ptr<bb::ipc::IpcClient> client_;
std::unique_ptr<ipc::IpcClient> client_;
bool connected_ = false;
};

Expand Down
4 changes: 2 additions & 2 deletions barretenberg/cpp/src/barretenberg/wsdb/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ if(NOT(FUZZING) AND NOT(WASM))
wsdb_ipc_client
PUBLIC
barretenberg
ipc
ipc_runtime
)

# aztec-wsdb binary (standalone world state database server)
Expand All @@ -26,7 +26,7 @@ if(NOT(FUZZING) AND NOT(WASM))
PRIVATE
barretenberg
world_state
ipc
ipc_runtime
env
)
if(ENABLE_STACKTRACES)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
#pragma once

#include "barretenberg/common/try_catch_shim.hpp"
#include "barretenberg/ipc/ipc_client.hpp"
#include "barretenberg/wsdb/wsdb_execute.hpp"
#include "ipc_runtime/ipc_client.hpp"

#include <memory>
#include <string>
Expand Down
2 changes: 1 addition & 1 deletion barretenberg/cpp/src/barretenberg/wsdb/wsdb_ipc_server.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#include "barretenberg/wsdb/wsdb_ipc_server.hpp"
#include "barretenberg/common/log.hpp"
#include "barretenberg/crypto/merkle_tree/indexed_tree/indexed_leaf.hpp"
#include "barretenberg/ipc/ipc_server.hpp"
#include "barretenberg/serialize/msgpack.hpp"
#include "barretenberg/world_state/world_state.hpp"
#include "barretenberg/wsdb/wsdb_execute.hpp"
#include "ipc_runtime/ipc_server.hpp"

#include <csignal>
#include <cstdint>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ if(NOT(FUZZING) AND NOT(WASM))
PUBLIC
barretenberg
wsdb_ipc_client
ipc
ipc_runtime
vm2_sim
)
set_target_properties(wsdb_client PROPERTIES POSITION_INDEPENDENT_CODE ON)
Expand Down
37 changes: 24 additions & 13 deletions barretenberg/ts/src/cbind/cpp_codegen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,18 @@ export class CppCodegen {
/** Check if a command modifies state (non-const) */
private isWriteCommand(command: Command): boolean {
const name = command.name.toLowerCase();
return name.includes('add') || name.includes('create') ||
name.includes('commit') || name.includes('revert') ||
name.includes('register') || name.includes('shutdown') ||
name.includes('delete') || name.includes('sync') ||
name.includes('rollback') || name.includes('unwind');
return (
name.includes('add') ||
name.includes('create') ||
name.includes('commit') ||
name.includes('revert') ||
name.includes('register') ||
name.includes('shutdown') ||
name.includes('delete') ||
name.includes('sync') ||
name.includes('rollback') ||
name.includes('unwind')
);
}

/** Generate the header file */
Expand All @@ -75,17 +82,19 @@ export class CppCodegen {
const className = `${prefix}IpcClient`;
const guardName = `${ns.replace(/::/g, '_').toUpperCase()}_${prefix.toUpperCase()}_IPC_CLIENT_GENERATED_HPP`;

const methods = schema.commands.map(cmd => {
const sig = this.generateMethodSignature(cmd, schema);
return ` ${sig};`;
}).join('\n');
const methods = schema.commands
.map(cmd => {
const sig = this.generateMethodSignature(cmd, schema);
return ` ${sig};`;
})
.join('\n');

return `// AUTOGENERATED FILE - DO NOT EDIT
#pragma once

#include "barretenberg/common/try_catch_shim.hpp"
#include "${this.opts.executeHeader}"
#include "barretenberg/ipc/ipc_client.hpp"
#include "ipc_runtime/ipc_client.hpp"

#include <memory>
#include <string>
Expand Down Expand Up @@ -127,9 +136,11 @@ ${methods}
const responseType = `${prefix}CommandResponse`;
const errorType = `${prefix}ErrorResponse`;

const methods = schema.commands.map(cmd => {
return this.generateMethodImpl(cmd, schema, className);
}).join('\n');
const methods = schema.commands
.map(cmd => {
return this.generateMethodImpl(cmd, schema, className);
})
.join('\n');

return `// AUTOGENERATED FILE - DO NOT EDIT

Expand Down
24 changes: 17 additions & 7 deletions ipc-codegen/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ function build {
examples/echo-schema/generate.sh

echo "Building Rust echo binaries..."
# The Rust crate compiles the ipc-runtime sources itself via the `cc`
# build-dependency; no prebuilt archive needed.
(cd examples/rust/echo && cargo build --quiet)

echo "Building Zig echo binaries..."
Expand All @@ -36,17 +38,25 @@ function build {
(cd examples/ts/echo && npm install --no-package-lock --quiet)
fi

# C++ needs msgpack-c headers. We pick them up from a local bb cmake build
# for now; if absent the C++ matrix pairs are skipped in test_cmds below.
# C++ echo binaries compile the ipc-runtime .cpp sources directly into each
# binary (no prebuilt archive, no IPC_RUNTIME_LIB_DIR). msgpack-c headers
# are borrowed from bb's cmake build until we have a standalone source.
local IPC_RUNTIME_INC IPC_RUNTIME_SRCS
IPC_RUNTIME_INC="$(cd ../ipc-runtime/cpp 2>/dev/null && pwd)" || true
if [ -n "${IPC_RUNTIME_INC:-}" ]; then
# Skip *.test.cpp — those depend on gtest which is bb's build dep.
IPC_RUNTIME_SRCS="$(ls "$IPC_RUNTIME_INC"/ipc_runtime/*.cpp "$IPC_RUNTIME_INC"/ipc_runtime/shm/*.cpp 2>/dev/null | grep -v '\.test\.cpp$' | tr '\n' ' ')"
fi
local MSGPACK_INC
MSGPACK_INC="$(cd ../barretenberg/cpp/build/_deps/msgpack-c/src/msgpack-c/include 2>/dev/null && pwd)" || true
if [ -n "${MSGPACK_INC:-}" ] && [ -d "$MSGPACK_INC" ]; then
if [ -n "${IPC_RUNTIME_SRCS:-}" ] && [ -n "${MSGPACK_INC:-}" ] && [ -d "$MSGPACK_INC" ]; then
echo "Building C++ echo binaries..."
local CXX_FLAGS="-std=c++20 -I $MSGPACK_INC -DMSGPACK_NO_BOOST -DMSGPACK_USE_STD_VARIANT_ADAPTOR"
(cd examples/cpp/echo && clang++ $CXX_FLAGS -o echo_server echo_server.cpp)
(cd examples/cpp/echo && clang++ $CXX_FLAGS -o echo_client echo_client.cpp generated/echo_ipc_client.cpp)
# THROW/RETHROW satisfy barretenberg's patched msgpack-c (the same source we pull in).
local CXX_FLAGS="-std=c++20 -I $MSGPACK_INC -I $IPC_RUNTIME_INC -DMSGPACK_NO_BOOST -DMSGPACK_USE_STD_VARIANT_ADAPTOR -DTHROW=throw -DRETHROW=throw"
(cd examples/cpp/echo && clang++ $CXX_FLAGS -o echo_server echo_server.cpp $IPC_RUNTIME_SRCS -lpthread)
(cd examples/cpp/echo && clang++ $CXX_FLAGS -o echo_client echo_client.cpp generated/echo_ipc_client.cpp $IPC_RUNTIME_SRCS -lpthread)
else
echo "Skipping C++ echo build — msgpack-c not present at ../barretenberg/cpp/build/_deps/"
echo "Skipping C++ echo build — ipc-runtime sources or msgpack-c not available"
fi

# NB: the golden msgpack fixtures under examples/echo-schema/golden/ are
Expand Down
30 changes: 30 additions & 0 deletions ipc-codegen/examples/rust/echo/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions ipc-codegen/examples/rust/echo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ path = "src/echo_client.rs"
rmp-serde = "1.1"
serde = { version = "1.0", features = ["derive"] }
thiserror = "1.0"
ipc-runtime = { path = "../../../../ipc-runtime/rust" }
Loading
Loading