Skip to content

feat(ipc): add /ipc-codegen and /ipc-runtime foundation packages#23610

Open
charlielye wants to merge 1 commit into
nextfrom
cl/ipc-foundation
Open

feat(ipc): add /ipc-codegen and /ipc-runtime foundation packages#23610
charlielye wants to merge 1 commit into
nextfrom
cl/ipc-foundation

Conversation

@charlielye

@charlielye charlielye commented May 28, 2026

Copy link
Copy Markdown
Contributor

Summary

Foundation PR for the IPC migration stack. Adds the reusable IPC code generator and runtime packages used by the follow-up wsdb, bb, Rust, bb.js, and AVM cutover PRs.

This PR is intentionally additive for production consumers: it introduces the shared infrastructure, examples, and tests, but existing services are migrated in later PRs.

Stack

  1. feat(ipc): add /ipc-codegen and /ipc-runtime foundation packages #23610 cl/ipc-foundation — this PR
  2. refactor(wsdb): migrate aztec-wsdb to ipc-codegen + ipc-runtime #23611 cl/ipc-wsdb-migrate
  3. refactor(bbapi): migrate bb binary to ipc-codegen + ipc-runtime #23612 cl/ipc-bb-migrate
  4. refactor(barretenberg-rs): migrate to ipc-codegen + ipc-runtime; drop PipeBackend #23613 cl/ipc-bb-rs-migrate
  5. refactor(bb.js): migrate to ipc-codegen + ipc-runtime; delete legacy bb::ipc #23614 cl/ipc-bb-js-migrate
  6. refactor: cut TS world state and NAPI AVM over to WSDB IPC; delete NAPI WSDB #23036 cl/ipc-3-avm-wsdb-cutover
  7. feat: add aztec-avm + aztec-cdb binaries and IPC supporting code (inert) #23084 cl/ipc-4-avm-binary
  8. feat: AVM cutover — delete NAPI AVM, wire IPC simulator pool + CDB IPC server [PR 3b] #23697 cl/ipc-5-avm-cutover

What is added

/ipc-codegen

Schema-driven multi-language codegen for msgpack-framed IPC clients and servers.

  • Emits C++, Rust, TypeScript, and Zig clients/servers from schema JSON.
  • Supports aliases for stronger local names over primitive wire types.
  • Uses bin32 for fixed-size 32-byte values instead of dynamic vectors.
  • Emits C++ schema reflection so a schema can be extracted from code before regenerating consumers.
  • Emits standalone TypeScript service packages that can spawn a generated service binary over UDS or SHM.
  • Generated TypeScript service wrappers now declare their per-arch binary packages in optionalDependencies; consumers install the wrapper and the package manager selects the matching arch package by os/cpu.
  • Echo examples are self-contained projects under ipc-codegen/echo_example/{cpp,rust,ts,zig,ts_package} with local build/bootstrap docs.

/ipc-runtime

Shared transport/runtime implementation used by generated clients and servers.

  • C++ runtime with UDS, SHM, signal handling, parent-death behavior, and server/client helpers.
  • Rust bindings over the C ABI.
  • TypeScript package @aztec/ipc-runtime for UDS and NAPI SHM clients.
  • Zig bindings.

Validation

  • ipc-codegen/bootstrap.sh
  • ipc-runtime/bootstrap.sh
  • Echo example cross-language matrix, including native SHM combinations.
  • Generated TypeScript package bootstrap for the echo service package.
  • Root ./bootstrap.sh passed on this branch during stack validation.
  • Latest PR-boundary check: this PR has no barretenberg/cpp diff relative to origin/next; the barretenberg C++ integration lives in refactor(wsdb): migrate aztec-wsdb to ipc-codegen + ipc-runtime #23611.

@socket-security

socket-security Bot commented May 28, 2026

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addedcargo/​thiserror@​1.0.698110093100100
Addednpm/​@​types/​node@​22.19.191001008196100
Addednpm/​tsx@​4.22.41001008293100
Addednpm/​node-api-headers@​1.8.01001009990100
Addednpm/​node-addon-api@​8.7.01001009992100
Addednpm/​msgpackr@​1.12.110010010095100

View full report

charlielye added a commit that referenced this pull request May 28, 2026
Cuts the aztec-wsdb service over to consume the foundation packages
added in PR #23610. Wsdb_schema.json is the source of truth; the codegen
emits `generated/wsdb_ipc_{client,server}.{hpp,cpp}` and `wsdb_types.hpp`
on build (gitignored). Handlers operate on wire types directly with
field-by-field conversion at the boundary — no msgpack_roundtrip.

**C++ server**:
- New: wsdb_handlers.{cpp,hpp}, wsdb_request.hpp, wsdb_wire_convert.hpp,
  wsdb_schema.json. Server uses `ipc::make_server`,
  `ipc::install_default_signal_handlers`, and the codegen-emitted
  `make_wsdb_handler` dispatcher.
- Deleted: wsdb_commands.hpp, wsdb_execute.{cpp,hpp},
  wsdb_ipc_client_generated.{cpp,hpp}. Replaced by codegen output and
  inline handler bodies.

**C++ AVM client**:
- wsdb_ipc_merkle_db.{cpp,hpp} moved from barretenberg/wsdb_client/ to
  barretenberg/vm2/simulation/dbs/ (next to its sibling DB
  implementations). Constructs the codegen-generated `WsdbIpcClient`.
- barretenberg/wsdb_client/ dir removed.
- vm2/CMakeLists.txt updated to link the wsdb_ipc_client target.
- Top-level CMakeLists.txt drops add_subdirectory(barretenberg/wsdb_client).

**TS codegen invocation**:
- barretenberg/ts/src/aztec-wsdb/generate.ts deleted (codegen moved to
  /ipc-codegen in PR #23610). The wsdb_ipc_client generated by the C++
  build is independent.

**yarn-project**:
- yarn-project/world-state/src/native/ipc_world_state_instance.ts
  deleted. Already orphaned on next (no importers); the AVM sibling
  stack re-adds it later after rebasing on top of this stack.

**serialize/msgpack.hpp**:
- Predefines `IPC_CODEGEN_USE_BB_MSGPACK_ADAPTORS` so codegen-emitted
  msgpack_struct_map_impl.hpp yields to barretenberg's existing
  struct-map adaptor. Without this, both adaptors specialize the same
  primary template for `SERIALIZATION_FIELDS`-bearing types →
  "ambiguous partial specializations" compile error.

The legacy `barretenberg/cpp/src/barretenberg/ipc/` library (namespace
`bb::ipc`) stays in place — bb, nodejs_module, and api still link it.
Follow-up PRs migrate those consumers and the old subdir is deleted
once nothing references it.

Verification:
- `cd barretenberg/cpp/build && ninja aztec-wsdb` clean
- `./bin/aztec-wsdb msgpack schema` round-trips against
  wsdb_schema.json (pre-existing alias-vs-primitive mismatch in the
  committed JSON, not introduced here)
- bb binary still builds (legacy ipc/ stays for now)
charlielye added a commit that referenced this pull request May 28, 2026
… PipeBackend

Cuts the Rust crate over to consume the foundation packages (PR #23610).
Schema = `bb_schema.json` (committed in PR #23612). The codegen emits
`barretenberg-rs/src/generated/{bb_types,bb_client}.rs` on build;
`backend.rs`, `error.rs`, `ffi_backend.rs` are template-copied once into
the same dir.

**Removed**:
- `src/backend.rs` and `src/error.rs` (now codegen-emitted templates in
  `src/generated/`).
- `src/types.rs` (replaced by codegen `bb_types.rs`).
- `src/backends/ffi.rs` and `src/backends/pipe.rs` (the backends/
  directory). The old `PipeBackend` (forked bb subprocess + stdin/stdout
  pipe transport) is gone in favor of `ipc_runtime::IpcClient` over UDS
  or SHM. The codegen-emitted `Backend` trait abstracts the transport;
  `impl Backend for ipc_runtime::IpcClient` lives in the runtime crate.

**Modified**:
- `Cargo.toml` / `bootstrap.sh` (depend on `ipc-runtime`).
- `src/lib.rs` (re-exports updated for the codegen-emitted modules).
- `src/fr_ext.rs` (new — extra constructors / accessors on the codegen
  `Fr` newtype that downstream callers rely on; kept as a separate impl
  block so `src/generated/bb_types.rs` stays a pure regen target).

**Tests**:
- `barretenberg/rust/tests/` updated: dropped legacy `blake2s.rs`,
  `pedersen.rs`, `poseidon.rs`, `utils.rs` and `pipe_test.rs` (the
  PipeBackend tests). The `ffi/` test modules now exercise the codegen
  `BbApi<ipc_runtime::IpcClient>` surface.

Verification:
- `BB_LIB_DIR=… cargo build --release` for `barretenberg-rs/` — clean.
- `BB_LIB_DIR=… cargo build --features ffi --release --tests` for
  `tests/` — pre-existing test compile errors (120) match the stack tip;
  the schema-visitor change for `array<unsigned char, N != 32>` (now
  `[u8; N]` instead of `Vec<u8>`) rippled into the test source. Fixing
  the test crate is a follow-up.

The crate's library surface (the part downstream consumers see) is
green.
charlielye added a commit that referenced this pull request May 28, 2026
…bb::ipc

Last PR in the IPC migration stack (base: #23613 barretenberg-rs).
Cuts bb.js's TS surface + its NAPI substrate over to the foundation
packages (PR #23610). Two backends:
- WASM (`bb_backends/wasm.ts`): uses `cbindCall('bbapi', bytes)`
  via WASM exports. The C++ side (in PR #23612) pipes bytes through
  codegen `make_bb_handler`. No TS-side changes — wire-compatible.
- Native UDS / SHM (`bb_backends/node/native_socket.ts`): uses
  `UdsIpcClient` from `@aztec/ipc-runtime`.

**TS**:
- `barretenberg/ts/scripts/generate.sh`: regen script that calls
  `node ipc-codegen/src/generate.ts` for bb (TS + Rust bindings) and
  for aztec-wsdb (TS bindings).
- `barretenberg/ts/src/cbind/`: codegen sources moved into
  `/ipc-codegen/src/` in PR #23610. The deletions land here. The
  generated/ subdir is gitignored and regenerated by the bb.js build.
- `barretenberg/ts/src/bb_backends/node/native_socket.ts`: uses
  `UdsIpcClient` from `@aztec/ipc-runtime`.
- `barretenberg/ts/package.json` / `yarn.lock`: depend on
  `@aztec/ipc-runtime`.
- `barretenberg/ts/src/bbapi/chonk_pinned_inputs.test.ts` deleted (drift
  from the original stack rebase — referenced obsolete domain command
  types).

**C++ NAPI substrate**:
- `barretenberg/cpp/src/barretenberg/nodejs_module/msgpack_client/`:
  `msgpack_client_{wrapper,async}.{cpp,hpp}` use
  `ipc_runtime/ipc_client.hpp` for transport.
- `barretenberg/cpp/src/barretenberg/nodejs_module/CMakeLists.txt`: link
  `ipc_runtime`.

**Legacy ipc subdir gone**:
- `barretenberg/cpp/src/barretenberg/ipc/` removed entirely.
  After this PR no consumer references `bb::ipc::` — every transport
  surface routes through `ipc::` from ipc-runtime.
- Top-level `barretenberg/cpp/src/CMakeLists.txt`: drop the
  `add_subdirectory(barretenberg/ipc)` and the transitional comment
  about the legacy subdir.

Verification:
- `ninja bb aztec-wsdb bbapi_tests` clean (legacy bb::ipc gone)
- `./bin/bbapi_tests` — 30/30
- `cd barretenberg/ts && yarn build && yarn test`
- bb-prover e2e against migrated bb.js

End state after the full 5-PR stack:
- bb / wsdb servers route through codegen `make_<prefix>_handler` +
  `ipc::make_server` + `ipc::install_default_signal_handlers`.
- bb.js / barretenberg-rs clients route through codegen-emitted typed
  surfaces over `ipc_runtime::IpcClient` (Rust) /
  `@aztec/ipc-runtime`'s `UdsIpcClient` (TS).
- No `msgpack_roundtrip` at handler boundaries.
- No parallel domain command types.
- No hand-rolled UDS/SHM transport.
charlielye added a commit that referenced this pull request May 28, 2026
… PipeBackend

Cuts the Rust crate over to consume the foundation packages (PR #23610).
Schema = `bb_schema.json` (committed in PR #23612). The codegen emits
`barretenberg-rs/src/generated/{bb_types,bb_client}.rs` on build;
`backend.rs`, `error.rs`, `ffi_backend.rs` are template-copied once into
the same dir.

**Removed**:
- `src/backend.rs` and `src/error.rs` (now codegen-emitted templates in
  `src/generated/`).
- `src/types.rs` (replaced by codegen `bb_types.rs`).
- `src/backends/ffi.rs` and `src/backends/pipe.rs` (the backends/
  directory). The old `PipeBackend` (forked bb subprocess + stdin/stdout
  pipe transport) is gone in favor of `ipc_runtime::IpcClient` over UDS
  or SHM. The codegen-emitted `Backend` trait abstracts the transport;
  `impl Backend for ipc_runtime::IpcClient` lives in the runtime crate.

**Modified**:
- `Cargo.toml` / `bootstrap.sh` (depend on `ipc-runtime`).
- `src/lib.rs` (re-exports updated for the codegen-emitted modules).
- `src/fr_ext.rs` (new — extra constructors / accessors on the codegen
  `Fr` newtype that downstream callers rely on; kept as a separate impl
  block so `src/generated/bb_types.rs` stays a pure regen target).

**Tests**:
- `barretenberg/rust/tests/` updated: dropped legacy `blake2s.rs`,
  `pedersen.rs`, `poseidon.rs`, `utils.rs` and `pipe_test.rs` (the
  PipeBackend tests). The `ffi/` test modules now exercise the codegen
  `BbApi<ipc_runtime::IpcClient>` surface.

Verification:
- `BB_LIB_DIR=… cargo build --release` for `barretenberg-rs/` — clean.
- `BB_LIB_DIR=… cargo build --features ffi --release --tests` for
  `tests/` — pre-existing test compile errors (120) match the stack tip;
  the schema-visitor change for `array<unsigned char, N != 32>` (now
  `[u8; N]` instead of `Vec<u8>`) rippled into the test source. Fixing
  the test crate is a follow-up.

The crate's library surface (the part downstream consumers see) is
green.
charlielye added a commit that referenced this pull request May 28, 2026
…bb::ipc

Last PR in the IPC migration stack (base: #23613 barretenberg-rs).
Cuts bb.js's TS surface + its NAPI substrate over to the foundation
packages (PR #23610). Two backends:
- WASM (`bb_backends/wasm.ts`): uses `cbindCall('bbapi', bytes)`
  via WASM exports. The C++ side (in PR #23612) pipes bytes through
  codegen `make_bb_handler`. No TS-side changes — wire-compatible.
- Native UDS / SHM (`bb_backends/node/native_socket.ts`): uses
  `UdsIpcClient` from `@aztec/ipc-runtime`.

**TS**:
- `barretenberg/ts/scripts/generate.sh`: regen script that calls
  `node ipc-codegen/src/generate.ts` for bb (TS + Rust bindings) and
  for aztec-wsdb (TS bindings).
- `barretenberg/ts/src/cbind/`: codegen sources moved into
  `/ipc-codegen/src/` in PR #23610. The deletions land here. The
  generated/ subdir is gitignored and regenerated by the bb.js build.
- `barretenberg/ts/src/bb_backends/node/native_socket.ts`: uses
  `UdsIpcClient` from `@aztec/ipc-runtime`.
- `barretenberg/ts/package.json` / `yarn.lock`: depend on
  `@aztec/ipc-runtime`.
- `barretenberg/ts/src/bbapi/chonk_pinned_inputs.test.ts` deleted (drift
  from the original stack rebase — referenced obsolete domain command
  types).

**C++ NAPI substrate**:
- `barretenberg/cpp/src/barretenberg/nodejs_module/msgpack_client/`:
  `msgpack_client_{wrapper,async}.{cpp,hpp}` use
  `ipc_runtime/ipc_client.hpp` for transport.
- `barretenberg/cpp/src/barretenberg/nodejs_module/CMakeLists.txt`: link
  `ipc_runtime`.

**Legacy ipc subdir gone**:
- `barretenberg/cpp/src/barretenberg/ipc/` removed entirely.
  After this PR no consumer references `bb::ipc::` — every transport
  surface routes through `ipc::` from ipc-runtime.
- Top-level `barretenberg/cpp/src/CMakeLists.txt`: drop the
  `add_subdirectory(barretenberg/ipc)` and the transitional comment
  about the legacy subdir.

Verification:
- `ninja bb aztec-wsdb bbapi_tests` clean (legacy bb::ipc gone)
- `./bin/bbapi_tests` — 30/30
- `cd barretenberg/ts && yarn build && yarn test`
- bb-prover e2e against migrated bb.js

End state after the full 5-PR stack:
- bb / wsdb servers route through codegen `make_<prefix>_handler` +
  `ipc::make_server` + `ipc::install_default_signal_handlers`.
- bb.js / barretenberg-rs clients route through codegen-emitted typed
  surfaces over `ipc_runtime::IpcClient` (Rust) /
  `@aztec/ipc-runtime`'s `UdsIpcClient` (TS).
- No `msgpack_roundtrip` at handler boundaries.
- No parallel domain command types.
- No hand-rolled UDS/SHM transport.
charlielye added a commit that referenced this pull request May 28, 2026
Cuts the aztec-wsdb service over to consume the foundation packages
added in PR #23610. Wsdb_schema.json is the source of truth; the codegen
emits `generated/wsdb_ipc_{client,server}.{hpp,cpp}` and `wsdb_types.hpp`
on build (gitignored). Handlers operate on wire types directly with
field-by-field conversion at the boundary — no msgpack_roundtrip.

**C++ server**:
- New: wsdb_handlers.{cpp,hpp}, wsdb_request.hpp, wsdb_wire_convert.hpp,
  wsdb_schema.json. Server uses `ipc::make_server`,
  `ipc::install_default_signal_handlers`, and the codegen-emitted
  `make_wsdb_handler` dispatcher.
- Deleted: wsdb_commands.hpp, wsdb_execute.{cpp,hpp},
  wsdb_ipc_client_generated.{cpp,hpp}. Replaced by codegen output and
  inline handler bodies.

**C++ AVM client**:
- wsdb_ipc_merkle_db.{cpp,hpp} moved from barretenberg/wsdb_client/ to
  barretenberg/vm2/simulation/dbs/ (next to its sibling DB
  implementations). Constructs the codegen-generated `WsdbIpcClient`.
- barretenberg/wsdb_client/ dir removed.
- vm2/CMakeLists.txt updated to link the wsdb_ipc_client target.
- Top-level CMakeLists.txt drops add_subdirectory(barretenberg/wsdb_client).

**TS codegen invocation**:
- barretenberg/ts/src/aztec-wsdb/generate.ts deleted (codegen moved to
  /ipc-codegen in PR #23610). The wsdb_ipc_client generated by the C++
  build is independent.

**yarn-project**:
- yarn-project/world-state/src/native/ipc_world_state_instance.ts
  deleted. Already orphaned on next (no importers); the AVM sibling
  stack re-adds it later after rebasing on top of this stack.

**serialize/msgpack.hpp**:
- Predefines `IPC_CODEGEN_USE_BB_MSGPACK_ADAPTORS` so codegen-emitted
  msgpack_struct_map_impl.hpp yields to barretenberg's existing
  struct-map adaptor. Without this, both adaptors specialize the same
  primary template for `SERIALIZATION_FIELDS`-bearing types →
  "ambiguous partial specializations" compile error.

The legacy `barretenberg/cpp/src/barretenberg/ipc/` library (namespace
`bb::ipc`) stays in place — bb, nodejs_module, and api still link it.
Follow-up PRs migrate those consumers and the old subdir is deleted
once nothing references it.

Verification:
- `cd barretenberg/cpp/build && ninja aztec-wsdb` clean
- `./bin/aztec-wsdb msgpack schema` round-trips against
  wsdb_schema.json (pre-existing alias-vs-primitive mismatch in the
  committed JSON, not introduced here)
- bb binary still builds (legacy ipc/ stays for now)
charlielye added a commit that referenced this pull request May 28, 2026
… PipeBackend

Cuts the Rust crate over to consume the foundation packages (PR #23610).
Schema = `bb_schema.json` (committed in PR #23612). The codegen emits
`barretenberg-rs/src/generated/{bb_types,bb_client}.rs` on build;
`backend.rs`, `error.rs`, `ffi_backend.rs` are template-copied once into
the same dir.

**Removed**:
- `src/backend.rs` and `src/error.rs` (now codegen-emitted templates in
  `src/generated/`).
- `src/types.rs` (replaced by codegen `bb_types.rs`).
- `src/backends/ffi.rs` and `src/backends/pipe.rs` (the backends/
  directory). The old `PipeBackend` (forked bb subprocess + stdin/stdout
  pipe transport) is gone in favor of `ipc_runtime::IpcClient` over UDS
  or SHM. The codegen-emitted `Backend` trait abstracts the transport;
  `impl Backend for ipc_runtime::IpcClient` lives in the runtime crate.

**Modified**:
- `Cargo.toml` / `bootstrap.sh` (depend on `ipc-runtime`).
- `src/lib.rs` (re-exports updated for the codegen-emitted modules).
- `src/fr_ext.rs` (new — extra constructors / accessors on the codegen
  `Fr` newtype that downstream callers rely on; kept as a separate impl
  block so `src/generated/bb_types.rs` stays a pure regen target).

**Tests**:
- `barretenberg/rust/tests/` updated: dropped legacy `blake2s.rs`,
  `pedersen.rs`, `poseidon.rs`, `utils.rs` and `pipe_test.rs` (the
  PipeBackend tests). The `ffi/` test modules now exercise the codegen
  `BbApi<ipc_runtime::IpcClient>` surface.

Verification:
- `BB_LIB_DIR=… cargo build --release` for `barretenberg-rs/` — clean.
- `BB_LIB_DIR=… cargo build --features ffi --release --tests` for
  `tests/` — pre-existing test compile errors (120) match the stack tip;
  the schema-visitor change for `array<unsigned char, N != 32>` (now
  `[u8; N]` instead of `Vec<u8>`) rippled into the test source. Fixing
  the test crate is a follow-up.

The crate's library surface (the part downstream consumers see) is
green.
charlielye added a commit that referenced this pull request May 28, 2026
…bb::ipc

Last PR in the IPC migration stack (base: #23613 barretenberg-rs).
Cuts bb.js's TS surface + its NAPI substrate over to the foundation
packages (PR #23610). Two backends:
- WASM (`bb_backends/wasm.ts`): uses `cbindCall('bbapi', bytes)`
  via WASM exports. The C++ side (in PR #23612) pipes bytes through
  codegen `make_bb_handler`. No TS-side changes — wire-compatible.
- Native UDS / SHM (`bb_backends/node/native_socket.ts`): uses
  `UdsIpcClient` from `@aztec/ipc-runtime`.

**TS**:
- `barretenberg/ts/scripts/generate.sh`: regen script that calls
  `node ipc-codegen/src/generate.ts` for bb (TS + Rust bindings) and
  for aztec-wsdb (TS bindings).
- `barretenberg/ts/src/cbind/`: codegen sources moved into
  `/ipc-codegen/src/` in PR #23610. The deletions land here. The
  generated/ subdir is gitignored and regenerated by the bb.js build.
- `barretenberg/ts/src/bb_backends/node/native_socket.ts`: uses
  `UdsIpcClient` from `@aztec/ipc-runtime`.
- `barretenberg/ts/package.json` / `yarn.lock`: depend on
  `@aztec/ipc-runtime`.
- `barretenberg/ts/src/bbapi/chonk_pinned_inputs.test.ts` deleted (drift
  from the original stack rebase — referenced obsolete domain command
  types).

**C++ NAPI substrate**:
- `barretenberg/cpp/src/barretenberg/nodejs_module/msgpack_client/`:
  `msgpack_client_{wrapper,async}.{cpp,hpp}` use
  `ipc_runtime/ipc_client.hpp` for transport.
- `barretenberg/cpp/src/barretenberg/nodejs_module/CMakeLists.txt`: link
  `ipc_runtime`.

**Legacy ipc subdir gone**:
- `barretenberg/cpp/src/barretenberg/ipc/` removed entirely.
  After this PR no consumer references `bb::ipc::` — every transport
  surface routes through `ipc::` from ipc-runtime.
- Top-level `barretenberg/cpp/src/CMakeLists.txt`: drop the
  `add_subdirectory(barretenberg/ipc)` and the transitional comment
  about the legacy subdir.

Verification:
- `ninja bb aztec-wsdb bbapi_tests` clean (legacy bb::ipc gone)
- `./bin/bbapi_tests` — 30/30
- `cd barretenberg/ts && yarn build && yarn test`
- bb-prover e2e against migrated bb.js

End state after the full 5-PR stack:
- bb / wsdb servers route through codegen `make_<prefix>_handler` +
  `ipc::make_server` + `ipc::install_default_signal_handlers`.
- bb.js / barretenberg-rs clients route through codegen-emitted typed
  surfaces over `ipc_runtime::IpcClient` (Rust) /
  `@aztec/ipc-runtime`'s `UdsIpcClient` (TS).
- No `msgpack_roundtrip` at handler boundaries.
- No parallel domain command types.
- No hand-rolled UDS/SHM transport.
@charlielye charlielye force-pushed the cl/ipc-foundation branch from 41fcedb to 0588ea3 Compare May 28, 2026 09:39
charlielye added a commit that referenced this pull request May 28, 2026
Cuts the aztec-wsdb service over to consume the foundation packages
added in PR #23610. Wsdb_schema.json is the source of truth; the codegen
emits `generated/wsdb_ipc_{client,server}.{hpp,cpp}` and `wsdb_types.hpp`
on build (gitignored). Handlers operate on wire types directly with
field-by-field conversion at the boundary — no msgpack_roundtrip.

**C++ server**:
- New: wsdb_handlers.{cpp,hpp}, wsdb_request.hpp, wsdb_wire_convert.hpp,
  wsdb_schema.json. Server uses `ipc::make_server`,
  `ipc::install_default_signal_handlers`, and the codegen-emitted
  `make_wsdb_handler` dispatcher.
- Deleted: wsdb_commands.hpp, wsdb_execute.{cpp,hpp},
  wsdb_ipc_client_generated.{cpp,hpp}. Replaced by codegen output and
  inline handler bodies.

**C++ AVM client**:
- wsdb_ipc_merkle_db.{cpp,hpp} moved from barretenberg/wsdb_client/ to
  barretenberg/vm2/simulation/dbs/ (next to its sibling DB
  implementations). Constructs the codegen-generated `WsdbIpcClient`.
- barretenberg/wsdb_client/ dir removed.
- vm2/CMakeLists.txt updated to link the wsdb_ipc_client target.
- Top-level CMakeLists.txt drops add_subdirectory(barretenberg/wsdb_client).

**TS codegen invocation**:
- barretenberg/ts/src/aztec-wsdb/generate.ts deleted (codegen moved to
  /ipc-codegen in PR #23610). The wsdb_ipc_client generated by the C++
  build is independent.

**yarn-project**:
- yarn-project/world-state/src/native/ipc_world_state_instance.ts
  deleted. Already orphaned on next (no importers); the AVM sibling
  stack re-adds it later after rebasing on top of this stack.

**serialize/msgpack.hpp**:
- Predefines `IPC_CODEGEN_USE_BB_MSGPACK_ADAPTORS` so codegen-emitted
  msgpack_struct_map_impl.hpp yields to barretenberg's existing
  struct-map adaptor. Without this, both adaptors specialize the same
  primary template for `SERIALIZATION_FIELDS`-bearing types →
  "ambiguous partial specializations" compile error.

The legacy `barretenberg/cpp/src/barretenberg/ipc/` library (namespace
`bb::ipc`) stays in place — bb, nodejs_module, and api still link it.
Follow-up PRs migrate those consumers and the old subdir is deleted
once nothing references it.

Verification:
- `cd barretenberg/cpp/build && ninja aztec-wsdb` clean
- `./bin/aztec-wsdb msgpack schema` round-trips against
  wsdb_schema.json (pre-existing alias-vs-primitive mismatch in the
  committed JSON, not introduced here)
- bb binary still builds (legacy ipc/ stays for now)
charlielye added a commit that referenced this pull request May 28, 2026
… PipeBackend

Cuts the Rust crate over to consume the foundation packages (PR #23610).
Schema = `bb_schema.json` (committed in PR #23612). The codegen emits
`barretenberg-rs/src/generated/{bb_types,bb_client}.rs` on build;
`backend.rs`, `error.rs`, `ffi_backend.rs` are template-copied once into
the same dir.

**Removed**:
- `src/backend.rs` and `src/error.rs` (now codegen-emitted templates in
  `src/generated/`).
- `src/types.rs` (replaced by codegen `bb_types.rs`).
- `src/backends/ffi.rs` and `src/backends/pipe.rs` (the backends/
  directory). The old `PipeBackend` (forked bb subprocess + stdin/stdout
  pipe transport) is gone in favor of `ipc_runtime::IpcClient` over UDS
  or SHM. The codegen-emitted `Backend` trait abstracts the transport;
  `impl Backend for ipc_runtime::IpcClient` lives in the runtime crate.

**Modified**:
- `Cargo.toml` / `bootstrap.sh` (depend on `ipc-runtime`).
- `src/lib.rs` (re-exports updated for the codegen-emitted modules).
- `src/fr_ext.rs` (new — extra constructors / accessors on the codegen
  `Fr` newtype that downstream callers rely on; kept as a separate impl
  block so `src/generated/bb_types.rs` stays a pure regen target).

**Tests**:
- `barretenberg/rust/tests/` updated: dropped legacy `blake2s.rs`,
  `pedersen.rs`, `poseidon.rs`, `utils.rs` and `pipe_test.rs` (the
  PipeBackend tests). The `ffi/` test modules now exercise the codegen
  `BbApi<ipc_runtime::IpcClient>` surface.

Verification:
- `BB_LIB_DIR=… cargo build --release` for `barretenberg-rs/` — clean.
- `BB_LIB_DIR=… cargo build --features ffi --release --tests` for
  `tests/` — pre-existing test compile errors (120) match the stack tip;
  the schema-visitor change for `array<unsigned char, N != 32>` (now
  `[u8; N]` instead of `Vec<u8>`) rippled into the test source. Fixing
  the test crate is a follow-up.

The crate's library surface (the part downstream consumers see) is
green.
charlielye added a commit that referenced this pull request May 28, 2026
…bb::ipc

Last PR in the IPC migration stack (base: #23613 barretenberg-rs).
Cuts bb.js's TS surface + its NAPI substrate over to the foundation
packages (PR #23610). Two backends:
- WASM (`bb_backends/wasm.ts`): uses `cbindCall('bbapi', bytes)`
  via WASM exports. The C++ side (in PR #23612) pipes bytes through
  codegen `make_bb_handler`. No TS-side changes — wire-compatible.
- Native UDS / SHM (`bb_backends/node/native_socket.ts`): uses
  `UdsIpcClient` from `@aztec/ipc-runtime`.

**TS**:
- `barretenberg/ts/scripts/generate.sh`: regen script that calls
  `node ipc-codegen/src/generate.ts` for bb (TS + Rust bindings) and
  for aztec-wsdb (TS bindings).
- `barretenberg/ts/src/cbind/`: codegen sources moved into
  `/ipc-codegen/src/` in PR #23610. The deletions land here. The
  generated/ subdir is gitignored and regenerated by the bb.js build.
- `barretenberg/ts/src/bb_backends/node/native_socket.ts`: uses
  `UdsIpcClient` from `@aztec/ipc-runtime`.
- `barretenberg/ts/package.json` / `yarn.lock`: depend on
  `@aztec/ipc-runtime`.
- `barretenberg/ts/src/bbapi/chonk_pinned_inputs.test.ts` deleted (drift
  from the original stack rebase — referenced obsolete domain command
  types).

**C++ NAPI substrate**:
- `barretenberg/cpp/src/barretenberg/nodejs_module/msgpack_client/`:
  `msgpack_client_{wrapper,async}.{cpp,hpp}` use
  `ipc_runtime/ipc_client.hpp` for transport.
- `barretenberg/cpp/src/barretenberg/nodejs_module/CMakeLists.txt`: link
  `ipc_runtime`.

**Legacy ipc subdir gone**:
- `barretenberg/cpp/src/barretenberg/ipc/` removed entirely.
  After this PR no consumer references `bb::ipc::` — every transport
  surface routes through `ipc::` from ipc-runtime.
- Top-level `barretenberg/cpp/src/CMakeLists.txt`: drop the
  `add_subdirectory(barretenberg/ipc)` and the transitional comment
  about the legacy subdir.

Verification:
- `ninja bb aztec-wsdb bbapi_tests` clean (legacy bb::ipc gone)
- `./bin/bbapi_tests` — 30/30
- `cd barretenberg/ts && yarn build && yarn test`
- bb-prover e2e against migrated bb.js

End state after the full 5-PR stack:
- bb / wsdb servers route through codegen `make_<prefix>_handler` +
  `ipc::make_server` + `ipc::install_default_signal_handlers`.
- bb.js / barretenberg-rs clients route through codegen-emitted typed
  surfaces over `ipc_runtime::IpcClient` (Rust) /
  `@aztec/ipc-runtime`'s `UdsIpcClient` (TS).
- No `msgpack_roundtrip` at handler boundaries.
- No parallel domain command types.
- No hand-rolled UDS/SHM transport.
charlielye added a commit that referenced this pull request May 28, 2026
Cuts the aztec-wsdb service over to consume the foundation packages
added in PR #23610. Wsdb_schema.json is the source of truth; the codegen
emits `generated/wsdb_ipc_{client,server}.{hpp,cpp}` and `wsdb_types.hpp`
on build (gitignored). Handlers operate on wire types directly with
field-by-field conversion at the boundary — no msgpack_roundtrip.

**C++ server**:
- New: wsdb_handlers.{cpp,hpp}, wsdb_request.hpp, wsdb_wire_convert.hpp,
  wsdb_schema.json. Server uses `ipc::make_server`,
  `ipc::install_default_signal_handlers`, and the codegen-emitted
  `make_wsdb_handler` dispatcher.
- Deleted: wsdb_commands.hpp, wsdb_execute.{cpp,hpp},
  wsdb_ipc_client_generated.{cpp,hpp}. Replaced by codegen output and
  inline handler bodies.

**C++ AVM client**:
- wsdb_ipc_merkle_db.{cpp,hpp} moved from barretenberg/wsdb_client/ to
  barretenberg/vm2/simulation/dbs/ (next to its sibling DB
  implementations). Constructs the codegen-generated `WsdbIpcClient`.
- barretenberg/wsdb_client/ dir removed.
- vm2/CMakeLists.txt updated to link the wsdb_ipc_client target.
- Top-level CMakeLists.txt drops add_subdirectory(barretenberg/wsdb_client).

**TS codegen invocation**:
- barretenberg/ts/src/aztec-wsdb/generate.ts deleted (codegen moved to
  /ipc-codegen in PR #23610). The wsdb_ipc_client generated by the C++
  build is independent.

**yarn-project**:
- yarn-project/world-state/src/native/ipc_world_state_instance.ts
  deleted. Already orphaned on next (no importers); the AVM sibling
  stack re-adds it later after rebasing on top of this stack.

**serialize/msgpack.hpp**:
- Predefines `IPC_CODEGEN_USE_BB_MSGPACK_ADAPTORS` so codegen-emitted
  msgpack_struct_map_impl.hpp yields to barretenberg's existing
  struct-map adaptor. Without this, both adaptors specialize the same
  primary template for `SERIALIZATION_FIELDS`-bearing types →
  "ambiguous partial specializations" compile error.

The legacy `barretenberg/cpp/src/barretenberg/ipc/` library (namespace
`bb::ipc`) stays in place — bb, nodejs_module, and api still link it.
Follow-up PRs migrate those consumers and the old subdir is deleted
once nothing references it.

Verification:
- `cd barretenberg/cpp/build && ninja aztec-wsdb` clean
- `./bin/aztec-wsdb msgpack schema` round-trips against
  wsdb_schema.json (pre-existing alias-vs-primitive mismatch in the
  committed JSON, not introduced here)
- bb binary still builds (legacy ipc/ stays for now)
charlielye added a commit that referenced this pull request May 28, 2026
… PipeBackend

Cuts the Rust crate over to consume the foundation packages (PR #23610).
Schema = `bb_schema.json` (committed in PR #23612). The codegen emits
`barretenberg-rs/src/generated/{bb_types,bb_client}.rs` on build;
`backend.rs`, `error.rs`, `ffi_backend.rs` are template-copied once into
the same dir.

**Removed**:
- `src/backend.rs` and `src/error.rs` (now codegen-emitted templates in
  `src/generated/`).
- `src/types.rs` (replaced by codegen `bb_types.rs`).
- `src/backends/ffi.rs` and `src/backends/pipe.rs` (the backends/
  directory). The old `PipeBackend` (forked bb subprocess + stdin/stdout
  pipe transport) is gone in favor of `ipc_runtime::IpcClient` over UDS
  or SHM. The codegen-emitted `Backend` trait abstracts the transport;
  `impl Backend for ipc_runtime::IpcClient` lives in the runtime crate.

**Modified**:
- `Cargo.toml` / `bootstrap.sh` (depend on `ipc-runtime`).
- `src/lib.rs` (re-exports updated for the codegen-emitted modules).
- `src/fr_ext.rs` (new — extra constructors / accessors on the codegen
  `Fr` newtype that downstream callers rely on; kept as a separate impl
  block so `src/generated/bb_types.rs` stays a pure regen target).

**Tests**:
- `barretenberg/rust/tests/` updated: dropped legacy `blake2s.rs`,
  `pedersen.rs`, `poseidon.rs`, `utils.rs` and `pipe_test.rs` (the
  PipeBackend tests). The `ffi/` test modules now exercise the codegen
  `BbApi<ipc_runtime::IpcClient>` surface.

Verification:
- `BB_LIB_DIR=… cargo build --release` for `barretenberg-rs/` — clean.
- `BB_LIB_DIR=… cargo build --features ffi --release --tests` for
  `tests/` — pre-existing test compile errors (120) match the stack tip;
  the schema-visitor change for `array<unsigned char, N != 32>` (now
  `[u8; N]` instead of `Vec<u8>`) rippled into the test source. Fixing
  the test crate is a follow-up.

The crate's library surface (the part downstream consumers see) is
green.
charlielye added a commit that referenced this pull request May 28, 2026
…bb::ipc

Last PR in the IPC migration stack (base: #23613 barretenberg-rs).
Cuts bb.js's TS surface + its NAPI substrate over to the foundation
packages (PR #23610). Two backends:
- WASM (`bb_backends/wasm.ts`): uses `cbindCall('bbapi', bytes)`
  via WASM exports. The C++ side (in PR #23612) pipes bytes through
  codegen `make_bb_handler`. No TS-side changes — wire-compatible.
- Native UDS / SHM (`bb_backends/node/native_socket.ts`): uses
  `UdsIpcClient` from `@aztec/ipc-runtime`.

**TS**:
- `barretenberg/ts/scripts/generate.sh`: regen script that calls
  `node ipc-codegen/src/generate.ts` for bb (TS + Rust bindings) and
  for aztec-wsdb (TS bindings).
- `barretenberg/ts/src/cbind/`: codegen sources moved into
  `/ipc-codegen/src/` in PR #23610. The deletions land here. The
  generated/ subdir is gitignored and regenerated by the bb.js build.
- `barretenberg/ts/src/bb_backends/node/native_socket.ts`: uses
  `UdsIpcClient` from `@aztec/ipc-runtime`.
- `barretenberg/ts/package.json` / `yarn.lock`: depend on
  `@aztec/ipc-runtime`.
- `barretenberg/ts/src/bbapi/chonk_pinned_inputs.test.ts` deleted (drift
  from the original stack rebase — referenced obsolete domain command
  types).

**C++ NAPI substrate**:
- `barretenberg/cpp/src/barretenberg/nodejs_module/msgpack_client/`:
  `msgpack_client_{wrapper,async}.{cpp,hpp}` use
  `ipc_runtime/ipc_client.hpp` for transport.
- `barretenberg/cpp/src/barretenberg/nodejs_module/CMakeLists.txt`: link
  `ipc_runtime`.

**Legacy ipc subdir gone**:
- `barretenberg/cpp/src/barretenberg/ipc/` removed entirely.
  After this PR no consumer references `bb::ipc::` — every transport
  surface routes through `ipc::` from ipc-runtime.
- Top-level `barretenberg/cpp/src/CMakeLists.txt`: drop the
  `add_subdirectory(barretenberg/ipc)` and the transitional comment
  about the legacy subdir.

Verification:
- `ninja bb aztec-wsdb bbapi_tests` clean (legacy bb::ipc gone)
- `./bin/bbapi_tests` — 30/30
- `cd barretenberg/ts && yarn build && yarn test`
- bb-prover e2e against migrated bb.js

End state after the full 5-PR stack:
- bb / wsdb servers route through codegen `make_<prefix>_handler` +
  `ipc::make_server` + `ipc::install_default_signal_handlers`.
- bb.js / barretenberg-rs clients route through codegen-emitted typed
  surfaces over `ipc_runtime::IpcClient` (Rust) /
  `@aztec/ipc-runtime`'s `UdsIpcClient` (TS).
- No `msgpack_roundtrip` at handler boundaries.
- No parallel domain command types.
- No hand-rolled UDS/SHM transport.
charlielye added a commit that referenced this pull request May 28, 2026
Cuts the aztec-wsdb service over to consume the foundation packages
added in PR #23610. Wsdb_schema.json is the source of truth; the codegen
emits `generated/wsdb_ipc_{client,server}.{hpp,cpp}` and `wsdb_types.hpp`
on build (gitignored). Handlers operate on wire types directly with
field-by-field conversion at the boundary — no msgpack_roundtrip.

**C++ server**:
- New: wsdb_handlers.{cpp,hpp}, wsdb_request.hpp, wsdb_wire_convert.hpp,
  wsdb_schema.json. Server uses `ipc::make_server`,
  `ipc::install_default_signal_handlers`, and the codegen-emitted
  `make_wsdb_handler` dispatcher.
- Deleted: wsdb_commands.hpp, wsdb_execute.{cpp,hpp},
  wsdb_ipc_client_generated.{cpp,hpp}. Replaced by codegen output and
  inline handler bodies.

**C++ AVM client**:
- wsdb_ipc_merkle_db.{cpp,hpp} moved from barretenberg/wsdb_client/ to
  barretenberg/vm2/simulation/dbs/ (next to its sibling DB
  implementations). Constructs the codegen-generated `WsdbIpcClient`.
- barretenberg/wsdb_client/ dir removed.
- vm2/CMakeLists.txt updated to link the wsdb_ipc_client target.
- Top-level CMakeLists.txt drops add_subdirectory(barretenberg/wsdb_client).

**TS codegen invocation**:
- barretenberg/ts/src/aztec-wsdb/generate.ts deleted (codegen moved to
  /ipc-codegen in PR #23610). The wsdb_ipc_client generated by the C++
  build is independent.

**yarn-project**:
- yarn-project/world-state/src/native/ipc_world_state_instance.ts
  deleted. Already orphaned on next (no importers); the AVM sibling
  stack re-adds it later after rebasing on top of this stack.

**serialize/msgpack.hpp**:
- Predefines `IPC_CODEGEN_USE_BB_MSGPACK_ADAPTORS` so codegen-emitted
  msgpack_struct_map_impl.hpp yields to barretenberg's existing
  struct-map adaptor. Without this, both adaptors specialize the same
  primary template for `SERIALIZATION_FIELDS`-bearing types →
  "ambiguous partial specializations" compile error.

The legacy `barretenberg/cpp/src/barretenberg/ipc/` library (namespace
`bb::ipc`) stays in place — bb, nodejs_module, and api still link it.
Follow-up PRs migrate those consumers and the old subdir is deleted
once nothing references it.

Verification:
- `cd barretenberg/cpp/build && ninja aztec-wsdb` clean
- `./bin/aztec-wsdb msgpack schema` round-trips against
  wsdb_schema.json (pre-existing alias-vs-primitive mismatch in the
  committed JSON, not introduced here)
- bb binary still builds (legacy ipc/ stays for now)
charlielye added a commit that referenced this pull request May 28, 2026
Cuts the aztec-wsdb service over to consume the foundation packages
added in PR #23610. Wsdb_schema.json is the source of truth; the codegen
emits `generated/wsdb_ipc_{client,server}.{hpp,cpp}` and `wsdb_types.hpp`
on build (gitignored). Handlers operate on wire types directly with
field-by-field conversion at the boundary — no msgpack_roundtrip.

**C++ server**:
- New: wsdb_handlers.{cpp,hpp}, wsdb_request.hpp, wsdb_wire_convert.hpp,
  wsdb_schema.json. Server uses `ipc::make_server`,
  `ipc::install_default_signal_handlers`, and the codegen-emitted
  `make_wsdb_handler` dispatcher.
- Deleted: wsdb_commands.hpp, wsdb_execute.{cpp,hpp},
  wsdb_ipc_client_generated.{cpp,hpp}. Replaced by codegen output and
  inline handler bodies.

**C++ AVM client**:
- wsdb_ipc_merkle_db.{cpp,hpp} moved from barretenberg/wsdb_client/ to
  barretenberg/vm2/simulation/dbs/ (next to its sibling DB
  implementations). Constructs the codegen-generated `WsdbIpcClient`.
- barretenberg/wsdb_client/ dir removed.
- vm2/CMakeLists.txt updated to link the wsdb_ipc_client target.
- Top-level CMakeLists.txt drops add_subdirectory(barretenberg/wsdb_client).

**TS codegen invocation**:
- barretenberg/ts/src/aztec-wsdb/generate.ts deleted (codegen moved to
  /ipc-codegen in PR #23610). The wsdb_ipc_client generated by the C++
  build is independent.

**yarn-project**:
- yarn-project/world-state/src/native/ipc_world_state_instance.ts
  deleted. Already orphaned on next (no importers); the AVM sibling
  stack re-adds it later after rebasing on top of this stack.

**serialize/msgpack.hpp**:
- Predefines `IPC_CODEGEN_USE_BB_MSGPACK_ADAPTORS` so codegen-emitted
  msgpack_struct_map_impl.hpp yields to barretenberg's existing
  struct-map adaptor. Without this, both adaptors specialize the same
  primary template for `SERIALIZATION_FIELDS`-bearing types →
  "ambiguous partial specializations" compile error.

The legacy `barretenberg/cpp/src/barretenberg/ipc/` library (namespace
`bb::ipc`) stays in place — bb, nodejs_module, and api still link it.
Follow-up PRs migrate those consumers and the old subdir is deleted
once nothing references it.

Verification:
- `cd barretenberg/cpp/build && ninja aztec-wsdb` clean
- `./bin/aztec-wsdb msgpack schema` round-trips against
  wsdb_schema.json (pre-existing alias-vs-primitive mismatch in the
  committed JSON, not introduced here)
- bb binary still builds (legacy ipc/ stays for now)
charlielye added a commit that referenced this pull request May 28, 2026
… PipeBackend

Cuts the Rust crate over to consume the foundation packages (PR #23610).
Schema = `bb_schema.json` (committed in PR #23612). The codegen emits
`barretenberg-rs/src/generated/{bb_types,bb_client}.rs` on build;
`backend.rs`, `error.rs`, `ffi_backend.rs` are template-copied once into
the same dir.

**Removed**:
- `src/backend.rs` and `src/error.rs` (now codegen-emitted templates in
  `src/generated/`).
- `src/types.rs` (replaced by codegen `bb_types.rs`).
- `src/backends/ffi.rs` and `src/backends/pipe.rs` (the backends/
  directory). The old `PipeBackend` (forked bb subprocess + stdin/stdout
  pipe transport) is gone in favor of `ipc_runtime::IpcClient` over UDS
  or SHM. The codegen-emitted `Backend` trait abstracts the transport;
  `impl Backend for ipc_runtime::IpcClient` lives in the runtime crate.

**Modified**:
- `Cargo.toml` / `bootstrap.sh` (depend on `ipc-runtime`).
- `src/lib.rs` (re-exports updated for the codegen-emitted modules).
- `src/fr_ext.rs` (new — extra constructors / accessors on the codegen
  `Fr` newtype that downstream callers rely on; kept as a separate impl
  block so `src/generated/bb_types.rs` stays a pure regen target).

**Tests**:
- `barretenberg/rust/tests/` updated: dropped legacy `blake2s.rs`,
  `pedersen.rs`, `poseidon.rs`, `utils.rs` and `pipe_test.rs` (the
  PipeBackend tests). The `ffi/` test modules now exercise the codegen
  `BbApi<ipc_runtime::IpcClient>` surface.

Verification:
- `BB_LIB_DIR=… cargo build --release` for `barretenberg-rs/` — clean.
- `BB_LIB_DIR=… cargo build --features ffi --release --tests` for
  `tests/` — pre-existing test compile errors (120) match the stack tip;
  the schema-visitor change for `array<unsigned char, N != 32>` (now
  `[u8; N]` instead of `Vec<u8>`) rippled into the test source. Fixing
  the test crate is a follow-up.

The crate's library surface (the part downstream consumers see) is
green.
charlielye added a commit that referenced this pull request May 28, 2026
…bb::ipc

Last PR in the IPC migration stack (base: #23613 barretenberg-rs).
Cuts bb.js's TS surface + its NAPI substrate over to the foundation
packages (PR #23610). Two backends:
- WASM (`bb_backends/wasm.ts`): uses `cbindCall('bbapi', bytes)`
  via WASM exports. The C++ side (in PR #23612) pipes bytes through
  codegen `make_bb_handler`. No TS-side changes — wire-compatible.
- Native UDS / SHM (`bb_backends/node/native_socket.ts`): uses
  `UdsIpcClient` from `@aztec/ipc-runtime`.

**TS**:
- `barretenberg/ts/scripts/generate.sh`: regen script that calls
  `node ipc-codegen/src/generate.ts` for bb (TS + Rust bindings) and
  for aztec-wsdb (TS bindings).
- `barretenberg/ts/src/cbind/`: codegen sources moved into
  `/ipc-codegen/src/` in PR #23610. The deletions land here. The
  generated/ subdir is gitignored and regenerated by the bb.js build.
- `barretenberg/ts/src/bb_backends/node/native_socket.ts`: uses
  `UdsIpcClient` from `@aztec/ipc-runtime`.
- `barretenberg/ts/package.json` / `yarn.lock`: depend on
  `@aztec/ipc-runtime`.
- `barretenberg/ts/src/bbapi/chonk_pinned_inputs.test.ts` deleted (drift
  from the original stack rebase — referenced obsolete domain command
  types).

**C++ NAPI substrate**:
- `barretenberg/cpp/src/barretenberg/nodejs_module/msgpack_client/`:
  `msgpack_client_{wrapper,async}.{cpp,hpp}` use
  `ipc_runtime/ipc_client.hpp` for transport.
- `barretenberg/cpp/src/barretenberg/nodejs_module/CMakeLists.txt`: link
  `ipc_runtime`.

**Legacy ipc subdir gone**:
- `barretenberg/cpp/src/barretenberg/ipc/` removed entirely.
  After this PR no consumer references `bb::ipc::` — every transport
  surface routes through `ipc::` from ipc-runtime.
- Top-level `barretenberg/cpp/src/CMakeLists.txt`: drop the
  `add_subdirectory(barretenberg/ipc)` and the transitional comment
  about the legacy subdir.

Verification:
- `ninja bb aztec-wsdb bbapi_tests` clean (legacy bb::ipc gone)
- `./bin/bbapi_tests` — 30/30
- `cd barretenberg/ts && yarn build && yarn test`
- bb-prover e2e against migrated bb.js

End state after the full 5-PR stack:
- bb / wsdb servers route through codegen `make_<prefix>_handler` +
  `ipc::make_server` + `ipc::install_default_signal_handlers`.
- bb.js / barretenberg-rs clients route through codegen-emitted typed
  surfaces over `ipc_runtime::IpcClient` (Rust) /
  `@aztec/ipc-runtime`'s `UdsIpcClient` (TS).
- No `msgpack_roundtrip` at handler boundaries.
- No parallel domain command types.
- No hand-rolled UDS/SHM transport.
charlielye added a commit that referenced this pull request May 28, 2026
… PipeBackend

Cuts the Rust crate over to consume the foundation packages (PR #23610).
Schema = `bb_schema.json` (committed in PR #23612). The codegen emits
`barretenberg-rs/src/generated/{bb_types,bb_client}.rs` on build;
`backend.rs`, `error.rs`, `ffi_backend.rs` are template-copied once into
the same dir.

**Removed**:
- `src/backend.rs` and `src/error.rs` (now codegen-emitted templates in
  `src/generated/`).
- `src/types.rs` (replaced by codegen `bb_types.rs`).
- `src/backends/ffi.rs` and `src/backends/pipe.rs` (the backends/
  directory). The old `PipeBackend` (forked bb subprocess + stdin/stdout
  pipe transport) is gone in favor of `ipc_runtime::IpcClient` over UDS
  or SHM. The codegen-emitted `Backend` trait abstracts the transport;
  `impl Backend for ipc_runtime::IpcClient` lives in the runtime crate.

**Modified**:
- `Cargo.toml` / `bootstrap.sh` (depend on `ipc-runtime`).
- `src/lib.rs` (re-exports updated for the codegen-emitted modules).
- `src/fr_ext.rs` (new — extra constructors / accessors on the codegen
  `Fr` newtype that downstream callers rely on; kept as a separate impl
  block so `src/generated/bb_types.rs` stays a pure regen target).

**Tests**:
- `barretenberg/rust/tests/` updated: dropped legacy `blake2s.rs`,
  `pedersen.rs`, `poseidon.rs`, `utils.rs` and `pipe_test.rs` (the
  PipeBackend tests). The `ffi/` test modules now exercise the codegen
  `BbApi<ipc_runtime::IpcClient>` surface.

Verification:
- `BB_LIB_DIR=… cargo build --release` for `barretenberg-rs/` — clean.
- `BB_LIB_DIR=… cargo build --features ffi --release --tests` for
  `tests/` — pre-existing test compile errors (120) match the stack tip;
  the schema-visitor change for `array<unsigned char, N != 32>` (now
  `[u8; N]` instead of `Vec<u8>`) rippled into the test source. Fixing
  the test crate is a follow-up.

The crate's library surface (the part downstream consumers see) is
green.
charlielye added a commit that referenced this pull request May 28, 2026
…bb::ipc

Last PR in the IPC migration stack (base: #23613 barretenberg-rs).
Cuts bb.js's TS surface + its NAPI substrate over to the foundation
packages (PR #23610). Two backends:
- WASM (`bb_backends/wasm.ts`): uses `cbindCall('bbapi', bytes)`
  via WASM exports. The C++ side (in PR #23612) pipes bytes through
  codegen `make_bb_handler`. No TS-side changes — wire-compatible.
- Native UDS / SHM (`bb_backends/node/native_socket.ts`): uses
  `UdsIpcClient` from `@aztec/ipc-runtime`.

**TS**:
- `barretenberg/ts/scripts/generate.sh`: regen script that calls
  `node ipc-codegen/src/generate.ts` for bb (TS + Rust bindings) and
  for aztec-wsdb (TS bindings).
- `barretenberg/ts/src/cbind/`: codegen sources moved into
  `/ipc-codegen/src/` in PR #23610. The deletions land here. The
  generated/ subdir is gitignored and regenerated by the bb.js build.
- `barretenberg/ts/src/bb_backends/node/native_socket.ts`: uses
  `UdsIpcClient` from `@aztec/ipc-runtime`.
- `barretenberg/ts/package.json` / `yarn.lock`: depend on
  `@aztec/ipc-runtime`.
- `barretenberg/ts/src/bbapi/chonk_pinned_inputs.test.ts` deleted (drift
  from the original stack rebase — referenced obsolete domain command
  types).

**C++ NAPI substrate**:
- `barretenberg/cpp/src/barretenberg/nodejs_module/msgpack_client/`:
  `msgpack_client_{wrapper,async}.{cpp,hpp}` use
  `ipc_runtime/ipc_client.hpp` for transport.
- `barretenberg/cpp/src/barretenberg/nodejs_module/CMakeLists.txt`: link
  `ipc_runtime`.

**Legacy ipc subdir gone**:
- `barretenberg/cpp/src/barretenberg/ipc/` removed entirely.
  After this PR no consumer references `bb::ipc::` — every transport
  surface routes through `ipc::` from ipc-runtime.
- Top-level `barretenberg/cpp/src/CMakeLists.txt`: drop the
  `add_subdirectory(barretenberg/ipc)` and the transitional comment
  about the legacy subdir.

Verification:
- `ninja bb aztec-wsdb bbapi_tests` clean (legacy bb::ipc gone)
- `./bin/bbapi_tests` — 30/30
- `cd barretenberg/ts && yarn build && yarn test`
- bb-prover e2e against migrated bb.js

End state after the full 5-PR stack:
- bb / wsdb servers route through codegen `make_<prefix>_handler` +
  `ipc::make_server` + `ipc::install_default_signal_handlers`.
- bb.js / barretenberg-rs clients route through codegen-emitted typed
  surfaces over `ipc_runtime::IpcClient` (Rust) /
  `@aztec/ipc-runtime`'s `UdsIpcClient` (TS).
- No `msgpack_roundtrip` at handler boundaries.
- No parallel domain command types.
- No hand-rolled UDS/SHM transport.
charlielye added a commit that referenced this pull request May 28, 2026
Cuts the aztec-wsdb service over to consume the foundation packages
added in PR #23610. Wsdb_schema.json is the source of truth; the codegen
emits `generated/wsdb_ipc_{client,server}.{hpp,cpp}` and `wsdb_types.hpp`
on build (gitignored). Handlers operate on wire types directly with
field-by-field conversion at the boundary — no msgpack_roundtrip.

**C++ server**:
- New: wsdb_handlers.{cpp,hpp}, wsdb_request.hpp, wsdb_wire_convert.hpp,
  wsdb_schema.json. Server uses `ipc::make_server`,
  `ipc::install_default_signal_handlers`, and the codegen-emitted
  `make_wsdb_handler` dispatcher.
- Deleted: wsdb_commands.hpp, wsdb_execute.{cpp,hpp},
  wsdb_ipc_client_generated.{cpp,hpp}. Replaced by codegen output and
  inline handler bodies.

**C++ AVM client**:
- wsdb_ipc_merkle_db.{cpp,hpp} moved from barretenberg/wsdb_client/ to
  barretenberg/vm2/simulation/dbs/ (next to its sibling DB
  implementations). Constructs the codegen-generated `WsdbIpcClient`.
- barretenberg/wsdb_client/ dir removed.
- vm2/CMakeLists.txt updated to link the wsdb_ipc_client target.
- Top-level CMakeLists.txt drops add_subdirectory(barretenberg/wsdb_client).

**TS codegen invocation**:
- barretenberg/ts/src/aztec-wsdb/generate.ts deleted (codegen moved to
  /ipc-codegen in PR #23610). The wsdb_ipc_client generated by the C++
  build is independent.

**yarn-project**:
- yarn-project/world-state/src/native/ipc_world_state_instance.ts
  deleted. Already orphaned on next (no importers); the AVM sibling
  stack re-adds it later after rebasing on top of this stack.

**serialize/msgpack.hpp**:
- Predefines `IPC_CODEGEN_USE_BB_MSGPACK_ADAPTORS` so codegen-emitted
  msgpack_struct_map_impl.hpp yields to barretenberg's existing
  struct-map adaptor. Without this, both adaptors specialize the same
  primary template for `SERIALIZATION_FIELDS`-bearing types →
  "ambiguous partial specializations" compile error.

The legacy `barretenberg/cpp/src/barretenberg/ipc/` library (namespace
`bb::ipc`) stays in place — bb, nodejs_module, and api still link it.
Follow-up PRs migrate those consumers and the old subdir is deleted
once nothing references it.

Verification:
- `cd barretenberg/cpp/build && ninja aztec-wsdb` clean
- `./bin/aztec-wsdb msgpack schema` round-trips against
  wsdb_schema.json (pre-existing alias-vs-primitive mismatch in the
  committed JSON, not introduced here)
- bb binary still builds (legacy ipc/ stays for now)
charlielye added a commit that referenced this pull request May 28, 2026
… PipeBackend

Cuts the Rust crate over to consume the foundation packages (PR #23610).
Schema = `bb_schema.json` (committed in PR #23612). The codegen emits
`barretenberg-rs/src/generated/{bb_types,bb_client}.rs` on build;
`backend.rs`, `error.rs`, `ffi_backend.rs` are template-copied once into
the same dir.

**Removed**:
- `src/backend.rs` and `src/error.rs` (now codegen-emitted templates in
  `src/generated/`).
- `src/types.rs` (replaced by codegen `bb_types.rs`).
- `src/backends/ffi.rs` and `src/backends/pipe.rs` (the backends/
  directory). The old `PipeBackend` (forked bb subprocess + stdin/stdout
  pipe transport) is gone in favor of `ipc_runtime::IpcClient` over UDS
  or SHM. The codegen-emitted `Backend` trait abstracts the transport;
  `impl Backend for ipc_runtime::IpcClient` lives in the runtime crate.

**Modified**:
- `Cargo.toml` / `bootstrap.sh` (depend on `ipc-runtime`).
- `src/lib.rs` (re-exports updated for the codegen-emitted modules).
- `src/fr_ext.rs` (new — extra constructors / accessors on the codegen
  `Fr` newtype that downstream callers rely on; kept as a separate impl
  block so `src/generated/bb_types.rs` stays a pure regen target).

**Tests**:
- `barretenberg/rust/tests/` updated: dropped legacy `blake2s.rs`,
  `pedersen.rs`, `poseidon.rs`, `utils.rs` and `pipe_test.rs` (the
  PipeBackend tests). The `ffi/` test modules now exercise the codegen
  `BbApi<ipc_runtime::IpcClient>` surface.

Verification:
- `BB_LIB_DIR=… cargo build --release` for `barretenberg-rs/` — clean.
- `BB_LIB_DIR=… cargo build --features ffi --release --tests` for
  `tests/` — pre-existing test compile errors (120) match the stack tip;
  the schema-visitor change for `array<unsigned char, N != 32>` (now
  `[u8; N]` instead of `Vec<u8>`) rippled into the test source. Fixing
  the test crate is a follow-up.

The crate's library surface (the part downstream consumers see) is
green.
charlielye added a commit that referenced this pull request May 28, 2026
…bb::ipc

Last PR in the IPC migration stack (base: #23613 barretenberg-rs).
Cuts bb.js's TS surface + its NAPI substrate over to the foundation
packages (PR #23610). Two backends:
- WASM (`bb_backends/wasm.ts`): uses `cbindCall('bbapi', bytes)`
  via WASM exports. The C++ side (in PR #23612) pipes bytes through
  codegen `make_bb_handler`. No TS-side changes — wire-compatible.
- Native UDS / SHM (`bb_backends/node/native_socket.ts`): uses
  `UdsIpcClient` from `@aztec/ipc-runtime`.

**TS**:
- `barretenberg/ts/scripts/generate.sh`: regen script that calls
  `node ipc-codegen/src/generate.ts` for bb (TS + Rust bindings) and
  for aztec-wsdb (TS bindings).
- `barretenberg/ts/src/cbind/`: codegen sources moved into
  `/ipc-codegen/src/` in PR #23610. The deletions land here. The
  generated/ subdir is gitignored and regenerated by the bb.js build.
- `barretenberg/ts/src/bb_backends/node/native_socket.ts`: uses
  `UdsIpcClient` from `@aztec/ipc-runtime`.
- `barretenberg/ts/package.json` / `yarn.lock`: depend on
  `@aztec/ipc-runtime`.
- `barretenberg/ts/src/bbapi/chonk_pinned_inputs.test.ts` deleted (drift
  from the original stack rebase — referenced obsolete domain command
  types).

**C++ NAPI substrate**:
- `barretenberg/cpp/src/barretenberg/nodejs_module/msgpack_client/`:
  `msgpack_client_{wrapper,async}.{cpp,hpp}` use
  `ipc_runtime/ipc_client.hpp` for transport.
- `barretenberg/cpp/src/barretenberg/nodejs_module/CMakeLists.txt`: link
  `ipc_runtime`.

**Legacy ipc subdir gone**:
- `barretenberg/cpp/src/barretenberg/ipc/` removed entirely.
  After this PR no consumer references `bb::ipc::` — every transport
  surface routes through `ipc::` from ipc-runtime.
- Top-level `barretenberg/cpp/src/CMakeLists.txt`: drop the
  `add_subdirectory(barretenberg/ipc)` and the transitional comment
  about the legacy subdir.

Verification:
- `ninja bb aztec-wsdb bbapi_tests` clean (legacy bb::ipc gone)
- `./bin/bbapi_tests` — 30/30
- `cd barretenberg/ts && yarn build && yarn test`
- bb-prover e2e against migrated bb.js

End state after the full 5-PR stack:
- bb / wsdb servers route through codegen `make_<prefix>_handler` +
  `ipc::make_server` + `ipc::install_default_signal_handlers`.
- bb.js / barretenberg-rs clients route through codegen-emitted typed
  surfaces over `ipc_runtime::IpcClient` (Rust) /
  `@aztec/ipc-runtime`'s `UdsIpcClient` (TS).
- No `msgpack_roundtrip` at handler boundaries.
- No parallel domain command types.
- No hand-rolled UDS/SHM transport.
charlielye added a commit that referenced this pull request May 28, 2026
… PipeBackend

Cuts the Rust crate over to consume the foundation packages (PR #23610).
Schema = `bb_schema.json` (committed in PR #23612). The codegen emits
`barretenberg-rs/src/generated/{bb_types,bb_client}.rs` on build;
`backend.rs`, `error.rs`, `ffi_backend.rs` are template-copied once into
the same dir.

**Removed**:
- `src/backend.rs` and `src/error.rs` (now codegen-emitted templates in
  `src/generated/`).
- `src/types.rs` (replaced by codegen `bb_types.rs`).
- `src/backends/ffi.rs` and `src/backends/pipe.rs` (the backends/
  directory). The old `PipeBackend` (forked bb subprocess + stdin/stdout
  pipe transport) is gone in favor of `ipc_runtime::IpcClient` over UDS
  or SHM. The codegen-emitted `Backend` trait abstracts the transport;
  `impl Backend for ipc_runtime::IpcClient` lives in the runtime crate.

**Modified**:
- `Cargo.toml` / `bootstrap.sh` (depend on `ipc-runtime`).
- `src/lib.rs` (re-exports updated for the codegen-emitted modules).
- `src/fr_ext.rs` (new — extra constructors / accessors on the codegen
  `Fr` newtype that downstream callers rely on; kept as a separate impl
  block so `src/generated/bb_types.rs` stays a pure regen target).

**Tests**:
- `barretenberg/rust/tests/` updated: dropped legacy `blake2s.rs`,
  `pedersen.rs`, `poseidon.rs`, `utils.rs` and `pipe_test.rs` (the
  PipeBackend tests). The `ffi/` test modules now exercise the codegen
  `BbApi<ipc_runtime::IpcClient>` surface.

Verification:
- `BB_LIB_DIR=… cargo build --release` for `barretenberg-rs/` — clean.
- `BB_LIB_DIR=… cargo build --features ffi --release --tests` for
  `tests/` — pre-existing test compile errors (120) match the stack tip;
  the schema-visitor change for `array<unsigned char, N != 32>` (now
  `[u8; N]` instead of `Vec<u8>`) rippled into the test source. Fixing
  the test crate is a follow-up.

The crate's library surface (the part downstream consumers see) is
green.
charlielye added a commit that referenced this pull request May 28, 2026
…bb::ipc

Last PR in the IPC migration stack (base: #23613 barretenberg-rs).
Cuts bb.js's TS surface + its NAPI substrate over to the foundation
packages (PR #23610). Two backends:
- WASM (`bb_backends/wasm.ts`): uses `cbindCall('bbapi', bytes)`
  via WASM exports. The C++ side (in PR #23612) pipes bytes through
  codegen `make_bb_handler`. No TS-side changes — wire-compatible.
- Native UDS / SHM (`bb_backends/node/native_socket.ts`): uses
  `UdsIpcClient` from `@aztec/ipc-runtime`.

**TS**:
- `barretenberg/ts/scripts/generate.sh`: regen script that calls
  `node ipc-codegen/src/generate.ts` for bb (TS + Rust bindings) and
  for aztec-wsdb (TS bindings).
- `barretenberg/ts/src/cbind/`: codegen sources moved into
  `/ipc-codegen/src/` in PR #23610. The deletions land here. The
  generated/ subdir is gitignored and regenerated by the bb.js build.
- `barretenberg/ts/src/bb_backends/node/native_socket.ts`: uses
  `UdsIpcClient` from `@aztec/ipc-runtime`.
- `barretenberg/ts/package.json` / `yarn.lock`: depend on
  `@aztec/ipc-runtime`.
- `barretenberg/ts/src/bbapi/chonk_pinned_inputs.test.ts` deleted (drift
  from the original stack rebase — referenced obsolete domain command
  types).

**C++ NAPI substrate**:
- `barretenberg/cpp/src/barretenberg/nodejs_module/msgpack_client/`:
  `msgpack_client_{wrapper,async}.{cpp,hpp}` use
  `ipc_runtime/ipc_client.hpp` for transport.
- `barretenberg/cpp/src/barretenberg/nodejs_module/CMakeLists.txt`: link
  `ipc_runtime`.

**Legacy ipc subdir gone**:
- `barretenberg/cpp/src/barretenberg/ipc/` removed entirely.
  After this PR no consumer references `bb::ipc::` — every transport
  surface routes through `ipc::` from ipc-runtime.
- Top-level `barretenberg/cpp/src/CMakeLists.txt`: drop the
  `add_subdirectory(barretenberg/ipc)` and the transitional comment
  about the legacy subdir.

Verification:
- `ninja bb aztec-wsdb bbapi_tests` clean (legacy bb::ipc gone)
- `./bin/bbapi_tests` — 30/30
- `cd barretenberg/ts && yarn build && yarn test`
- bb-prover e2e against migrated bb.js

End state after the full 5-PR stack:
- bb / wsdb servers route through codegen `make_<prefix>_handler` +
  `ipc::make_server` + `ipc::install_default_signal_handlers`.
- bb.js / barretenberg-rs clients route through codegen-emitted typed
  surfaces over `ipc_runtime::IpcClient` (Rust) /
  `@aztec/ipc-runtime`'s `UdsIpcClient` (TS).
- No `msgpack_roundtrip` at handler boundaries.
- No parallel domain command types.
- No hand-rolled UDS/SHM transport.
@charlielye charlielye force-pushed the cl/ipc-foundation branch from ffa4943 to 3e62454 Compare May 29, 2026 12:30
charlielye added a commit that referenced this pull request May 29, 2026
Cuts the aztec-wsdb service over to consume the foundation packages
added in PR #23610. Wsdb_schema.json is the source of truth; the codegen
emits `generated/wsdb_ipc_{client,server}.{hpp,cpp}` and `wsdb_types.hpp`
on build (gitignored). Handlers operate on wire types directly with
field-by-field conversion at the boundary — no msgpack_roundtrip.

**C++ server**:
- New: wsdb_handlers.{cpp,hpp}, wsdb_request.hpp, wsdb_wire_convert.hpp,
  wsdb_schema.json. Server uses `ipc::make_server`,
  `ipc::install_default_signal_handlers`, and the codegen-emitted
  `make_wsdb_handler` dispatcher.
- Deleted: wsdb_commands.hpp, wsdb_execute.{cpp,hpp},
  wsdb_ipc_client_generated.{cpp,hpp}. Replaced by codegen output and
  inline handler bodies.

**C++ AVM client**:
- wsdb_ipc_merkle_db.{cpp,hpp} moved from barretenberg/wsdb_client/ to
  barretenberg/vm2/simulation/dbs/ (next to its sibling DB
  implementations). Constructs the codegen-generated `WsdbIpcClient`.
- barretenberg/wsdb_client/ dir removed.
- vm2/CMakeLists.txt updated to link the wsdb_ipc_client target.
- Top-level CMakeLists.txt drops add_subdirectory(barretenberg/wsdb_client).

**TS codegen invocation**:
- barretenberg/ts/src/aztec-wsdb/generate.ts deleted (codegen moved to
  /ipc-codegen in PR #23610). The wsdb_ipc_client generated by the C++
  build is independent.

**yarn-project**:
- yarn-project/world-state/src/native/ipc_world_state_instance.ts
  deleted. Already orphaned on next (no importers); the AVM sibling
  stack re-adds it later after rebasing on top of this stack.

**serialize/msgpack.hpp**:
- Predefines `IPC_CODEGEN_USE_BB_MSGPACK_ADAPTORS` so codegen-emitted
  msgpack_struct_map_impl.hpp yields to barretenberg's existing
  struct-map adaptor. Without this, both adaptors specialize the same
  primary template for `SERIALIZATION_FIELDS`-bearing types →
  "ambiguous partial specializations" compile error.

The legacy `barretenberg/cpp/src/barretenberg/ipc/` library (namespace
`bb::ipc`) stays in place — bb, nodejs_module, and api still link it.
Follow-up PRs migrate those consumers and the old subdir is deleted
once nothing references it.

Verification:
- `cd barretenberg/cpp/build && ninja aztec-wsdb` clean
- `./bin/aztec-wsdb msgpack schema` round-trips against
  wsdb_schema.json (pre-existing alias-vs-primitive mismatch in the
  committed JSON, not introduced here)
- bb binary still builds (legacy ipc/ stays for now)
charlielye added a commit that referenced this pull request May 29, 2026
… PipeBackend

Cuts the Rust crate over to consume the foundation packages (PR #23610).
Schema = `bb_schema.json` (committed in PR #23612). The codegen emits
`barretenberg-rs/src/generated/{bb_types,bb_client}.rs` on build;
`backend.rs`, `error.rs`, `ffi_backend.rs` are template-copied once into
the same dir.

**Removed**:
- `src/backend.rs` and `src/error.rs` (now codegen-emitted templates in
  `src/generated/`).
- `src/types.rs` (replaced by codegen `bb_types.rs`).
- `src/backends/ffi.rs` and `src/backends/pipe.rs` (the backends/
  directory). The old `PipeBackend` (forked bb subprocess + stdin/stdout
  pipe transport) is gone in favor of `ipc_runtime::IpcClient` over UDS
  or SHM. The codegen-emitted `Backend` trait abstracts the transport;
  `impl Backend for ipc_runtime::IpcClient` lives in the runtime crate.

**Modified**:
- `Cargo.toml` / `bootstrap.sh` (depend on `ipc-runtime`).
- `src/lib.rs` (re-exports updated for the codegen-emitted modules).
- `src/fr_ext.rs` (new — extra constructors / accessors on the codegen
  `Fr` newtype that downstream callers rely on; kept as a separate impl
  block so `src/generated/bb_types.rs` stays a pure regen target).

**Tests**:
- `barretenberg/rust/tests/` updated: dropped legacy `blake2s.rs`,
  `pedersen.rs`, `poseidon.rs`, `utils.rs` and `pipe_test.rs` (the
  PipeBackend tests). The `ffi/` test modules now exercise the codegen
  `BbApi<ipc_runtime::IpcClient>` surface.

Verification:
- `BB_LIB_DIR=… cargo build --release` for `barretenberg-rs/` — clean.
- `BB_LIB_DIR=… cargo build --features ffi --release --tests` for
  `tests/` — pre-existing test compile errors (120) match the stack tip;
  the schema-visitor change for `array<unsigned char, N != 32>` (now
  `[u8; N]` instead of `Vec<u8>`) rippled into the test source. Fixing
  the test crate is a follow-up.

The crate's library surface (the part downstream consumers see) is
green.
charlielye added a commit that referenced this pull request May 29, 2026
…bb::ipc

Last PR in the IPC migration stack (base: #23613 barretenberg-rs).
Cuts bb.js's TS surface + its NAPI substrate over to the foundation
packages (PR #23610). Two backends:
- WASM (`bb_backends/wasm.ts`): uses `cbindCall('bbapi', bytes)`
  via WASM exports. The C++ side (in PR #23612) pipes bytes through
  codegen `make_bb_handler`. No TS-side changes — wire-compatible.
- Native UDS / SHM (`bb_backends/node/native_socket.ts`): uses
  `UdsIpcClient` from `@aztec/ipc-runtime`.

**TS**:
- `barretenberg/ts/scripts/generate.sh`: regen script that calls
  `node ipc-codegen/src/generate.ts` for bb (TS + Rust bindings) and
  for aztec-wsdb (TS bindings).
- `barretenberg/ts/src/cbind/`: codegen sources moved into
  `/ipc-codegen/src/` in PR #23610. The deletions land here. The
  generated/ subdir is gitignored and regenerated by the bb.js build.
- `barretenberg/ts/src/bb_backends/node/native_socket.ts`: uses
  `UdsIpcClient` from `@aztec/ipc-runtime`.
- `barretenberg/ts/package.json` / `yarn.lock`: depend on
  `@aztec/ipc-runtime`.
- `barretenberg/ts/src/bbapi/chonk_pinned_inputs.test.ts` deleted (drift
  from the original stack rebase — referenced obsolete domain command
  types).

**C++ NAPI substrate**:
- `barretenberg/cpp/src/barretenberg/nodejs_module/msgpack_client/`:
  `msgpack_client_{wrapper,async}.{cpp,hpp}` use
  `ipc_runtime/ipc_client.hpp` for transport.
- `barretenberg/cpp/src/barretenberg/nodejs_module/CMakeLists.txt`: link
  `ipc_runtime`.

**Legacy ipc subdir gone**:
- `barretenberg/cpp/src/barretenberg/ipc/` removed entirely.
  After this PR no consumer references `bb::ipc::` — every transport
  surface routes through `ipc::` from ipc-runtime.
- Top-level `barretenberg/cpp/src/CMakeLists.txt`: drop the
  `add_subdirectory(barretenberg/ipc)` and the transitional comment
  about the legacy subdir.

Verification:
- `ninja bb aztec-wsdb bbapi_tests` clean (legacy bb::ipc gone)
- `./bin/bbapi_tests` — 30/30
- `cd barretenberg/ts && yarn build && yarn test`
- bb-prover e2e against migrated bb.js

End state after the full 5-PR stack:
- bb / wsdb servers route through codegen `make_<prefix>_handler` +
  `ipc::make_server` + `ipc::install_default_signal_handlers`.
- bb.js / barretenberg-rs clients route through codegen-emitted typed
  surfaces over `ipc_runtime::IpcClient` (Rust) /
  `@aztec/ipc-runtime`'s `UdsIpcClient` (TS).
- No `msgpack_roundtrip` at handler boundaries.
- No parallel domain command types.
- No hand-rolled UDS/SHM transport.
@charlielye charlielye force-pushed the cl/ipc-foundation branch from 3e62454 to 66e928d Compare May 29, 2026 14:50
charlielye added a commit that referenced this pull request May 29, 2026
Cuts the aztec-wsdb service over to consume the foundation packages
added in PR #23610. Wsdb_schema.json is the source of truth; the codegen
emits `generated/wsdb_ipc_{client,server}.{hpp,cpp}` and `wsdb_types.hpp`
on build (gitignored). Handlers operate on wire types directly with
field-by-field conversion at the boundary — no msgpack_roundtrip.

**C++ server**:
- New: wsdb_handlers.{cpp,hpp}, wsdb_request.hpp, wsdb_wire_convert.hpp,
  wsdb_schema.json. Server uses `ipc::make_server`,
  `ipc::install_default_signal_handlers`, and the codegen-emitted
  `make_wsdb_handler` dispatcher.
- Deleted: wsdb_commands.hpp, wsdb_execute.{cpp,hpp},
  wsdb_ipc_client_generated.{cpp,hpp}. Replaced by codegen output and
  inline handler bodies.

**C++ AVM client**:
- wsdb_ipc_merkle_db.{cpp,hpp} moved from barretenberg/wsdb_client/ to
  barretenberg/vm2/simulation/dbs/ (next to its sibling DB
  implementations). Constructs the codegen-generated `WsdbIpcClient`.
- barretenberg/wsdb_client/ dir removed.
- vm2/CMakeLists.txt updated to link the wsdb_ipc_client target.
- Top-level CMakeLists.txt drops add_subdirectory(barretenberg/wsdb_client).

**TS codegen invocation**:
- barretenberg/ts/src/aztec-wsdb/generate.ts deleted (codegen moved to
  /ipc-codegen in PR #23610). The wsdb_ipc_client generated by the C++
  build is independent.

**yarn-project**:
- yarn-project/world-state/src/native/ipc_world_state_instance.ts
  deleted. Already orphaned on next (no importers); the AVM sibling
  stack re-adds it later after rebasing on top of this stack.

**serialize/msgpack.hpp**:
- Predefines `IPC_CODEGEN_USE_BB_MSGPACK_ADAPTORS` so codegen-emitted
  msgpack_struct_map_impl.hpp yields to barretenberg's existing
  struct-map adaptor. Without this, both adaptors specialize the same
  primary template for `SERIALIZATION_FIELDS`-bearing types →
  "ambiguous partial specializations" compile error.

The legacy `barretenberg/cpp/src/barretenberg/ipc/` library (namespace
`bb::ipc`) stays in place — bb, nodejs_module, and api still link it.
Follow-up PRs migrate those consumers and the old subdir is deleted
once nothing references it.

Verification:
- `cd barretenberg/cpp/build && ninja aztec-wsdb` clean
- `./bin/aztec-wsdb msgpack schema` round-trips against
  wsdb_schema.json (pre-existing alias-vs-primitive mismatch in the
  committed JSON, not introduced here)
- bb binary still builds (legacy ipc/ stays for now)
charlielye added a commit that referenced this pull request May 29, 2026
… PipeBackend

Cuts the Rust crate over to consume the foundation packages (PR #23610).
Schema = `bb_schema.json` (committed in PR #23612). The codegen emits
`barretenberg-rs/src/generated/{bb_types,bb_client}.rs` on build;
`backend.rs`, `error.rs`, `ffi_backend.rs` are template-copied once into
the same dir.

**Removed**:
- `src/backend.rs` and `src/error.rs` (now codegen-emitted templates in
  `src/generated/`).
- `src/types.rs` (replaced by codegen `bb_types.rs`).
- `src/backends/ffi.rs` and `src/backends/pipe.rs` (the backends/
  directory). The old `PipeBackend` (forked bb subprocess + stdin/stdout
  pipe transport) is gone in favor of `ipc_runtime::IpcClient` over UDS
  or SHM. The codegen-emitted `Backend` trait abstracts the transport;
  `impl Backend for ipc_runtime::IpcClient` lives in the runtime crate.

**Modified**:
- `Cargo.toml` / `bootstrap.sh` (depend on `ipc-runtime`).
- `src/lib.rs` (re-exports updated for the codegen-emitted modules).
- `src/fr_ext.rs` (new — extra constructors / accessors on the codegen
  `Fr` newtype that downstream callers rely on; kept as a separate impl
  block so `src/generated/bb_types.rs` stays a pure regen target).

**Tests**:
- `barretenberg/rust/tests/` updated: dropped legacy `blake2s.rs`,
  `pedersen.rs`, `poseidon.rs`, `utils.rs` and `pipe_test.rs` (the
  PipeBackend tests). The `ffi/` test modules now exercise the codegen
  `BbApi<ipc_runtime::IpcClient>` surface.

Verification:
- `BB_LIB_DIR=… cargo build --release` for `barretenberg-rs/` — clean.
- `BB_LIB_DIR=… cargo build --features ffi --release --tests` for
  `tests/` — pre-existing test compile errors (120) match the stack tip;
  the schema-visitor change for `array<unsigned char, N != 32>` (now
  `[u8; N]` instead of `Vec<u8>`) rippled into the test source. Fixing
  the test crate is a follow-up.

The crate's library surface (the part downstream consumers see) is
green.
charlielye added a commit that referenced this pull request May 29, 2026
…bb::ipc

Last PR in the IPC migration stack (base: #23613 barretenberg-rs).
Cuts bb.js's TS surface + its NAPI substrate over to the foundation
packages (PR #23610). Two backends:
- WASM (`bb_backends/wasm.ts`): uses `cbindCall('bbapi', bytes)`
  via WASM exports. The C++ side (in PR #23612) pipes bytes through
  codegen `make_bb_handler`. No TS-side changes — wire-compatible.
- Native UDS / SHM (`bb_backends/node/native_socket.ts`): uses
  `UdsIpcClient` from `@aztec/ipc-runtime`.

**TS**:
- `barretenberg/ts/scripts/generate.sh`: regen script that calls
  `node ipc-codegen/src/generate.ts` for bb (TS + Rust bindings) and
  for aztec-wsdb (TS bindings).
- `barretenberg/ts/src/cbind/`: codegen sources moved into
  `/ipc-codegen/src/` in PR #23610. The deletions land here. The
  generated/ subdir is gitignored and regenerated by the bb.js build.
- `barretenberg/ts/src/bb_backends/node/native_socket.ts`: uses
  `UdsIpcClient` from `@aztec/ipc-runtime`.
- `barretenberg/ts/package.json` / `yarn.lock`: depend on
  `@aztec/ipc-runtime`.
- `barretenberg/ts/src/bbapi/chonk_pinned_inputs.test.ts` deleted (drift
  from the original stack rebase — referenced obsolete domain command
  types).

**C++ NAPI substrate**:
- `barretenberg/cpp/src/barretenberg/nodejs_module/msgpack_client/`:
  `msgpack_client_{wrapper,async}.{cpp,hpp}` use
  `ipc_runtime/ipc_client.hpp` for transport.
- `barretenberg/cpp/src/barretenberg/nodejs_module/CMakeLists.txt`: link
  `ipc_runtime`.

**Legacy ipc subdir gone**:
- `barretenberg/cpp/src/barretenberg/ipc/` removed entirely.
  After this PR no consumer references `bb::ipc::` — every transport
  surface routes through `ipc::` from ipc-runtime.
- Top-level `barretenberg/cpp/src/CMakeLists.txt`: drop the
  `add_subdirectory(barretenberg/ipc)` and the transitional comment
  about the legacy subdir.

Verification:
- `ninja bb aztec-wsdb bbapi_tests` clean (legacy bb::ipc gone)
- `./bin/bbapi_tests` — 30/30
- `cd barretenberg/ts && yarn build && yarn test`
- bb-prover e2e against migrated bb.js

End state after the full 5-PR stack:
- bb / wsdb servers route through codegen `make_<prefix>_handler` +
  `ipc::make_server` + `ipc::install_default_signal_handlers`.
- bb.js / barretenberg-rs clients route through codegen-emitted typed
  surfaces over `ipc_runtime::IpcClient` (Rust) /
  `@aztec/ipc-runtime`'s `UdsIpcClient` (TS).
- No `msgpack_roundtrip` at handler boundaries.
- No parallel domain command types.
- No hand-rolled UDS/SHM transport.
charlielye added a commit that referenced this pull request May 29, 2026
… PipeBackend

Cuts the Rust crate over to consume the foundation packages (PR #23610).
Schema = `bb_schema.json` (committed in PR #23612). The codegen emits
`barretenberg-rs/src/generated/{bb_types,bb_client}.rs` on build;
`backend.rs`, `error.rs`, `ffi_backend.rs` are template-copied once into
the same dir.

**Removed**:
- `src/backend.rs` and `src/error.rs` (now codegen-emitted templates in
  `src/generated/`).
- `src/types.rs` (replaced by codegen `bb_types.rs`).
- `src/backends/ffi.rs` and `src/backends/pipe.rs` (the backends/
  directory). The old `PipeBackend` (forked bb subprocess + stdin/stdout
  pipe transport) is gone in favor of `ipc_runtime::IpcClient` over UDS
  or SHM. The codegen-emitted `Backend` trait abstracts the transport;
  `impl Backend for ipc_runtime::IpcClient` lives in the runtime crate.

**Modified**:
- `Cargo.toml` / `bootstrap.sh` (depend on `ipc-runtime`).
- `src/lib.rs` (re-exports updated for the codegen-emitted modules).
- `src/fr_ext.rs` (new — extra constructors / accessors on the codegen
  `Fr` newtype that downstream callers rely on; kept as a separate impl
  block so `src/generated/bb_types.rs` stays a pure regen target).

**Tests**:
- `barretenberg/rust/tests/` updated: dropped legacy `blake2s.rs`,
  `pedersen.rs`, `poseidon.rs`, `utils.rs` and `pipe_test.rs` (the
  PipeBackend tests). The `ffi/` test modules now exercise the codegen
  `BbApi<ipc_runtime::IpcClient>` surface.

Verification:
- `BB_LIB_DIR=… cargo build --release` for `barretenberg-rs/` — clean.
- `BB_LIB_DIR=… cargo build --features ffi --release --tests` for
  `tests/` — pre-existing test compile errors (120) match the stack tip;
  the schema-visitor change for `array<unsigned char, N != 32>` (now
  `[u8; N]` instead of `Vec<u8>`) rippled into the test source. Fixing
  the test crate is a follow-up.

The crate's library surface (the part downstream consumers see) is
green.
charlielye added a commit that referenced this pull request May 29, 2026
…bb::ipc

Last PR in the IPC migration stack (base: #23613 barretenberg-rs).
Cuts bb.js's TS surface + its NAPI substrate over to the foundation
packages (PR #23610). Two backends:
- WASM (`bb_backends/wasm.ts`): uses `cbindCall('bbapi', bytes)`
  via WASM exports. The C++ side (in PR #23612) pipes bytes through
  codegen `make_bb_handler`. No TS-side changes — wire-compatible.
- Native UDS / SHM (`bb_backends/node/native_socket.ts`): uses
  `UdsIpcClient` from `@aztec/ipc-runtime`.

**TS**:
- `barretenberg/ts/scripts/generate.sh`: regen script that calls
  `node ipc-codegen/src/generate.ts` for bb (TS + Rust bindings) and
  for aztec-wsdb (TS bindings).
- `barretenberg/ts/src/cbind/`: codegen sources moved into
  `/ipc-codegen/src/` in PR #23610. The deletions land here. The
  generated/ subdir is gitignored and regenerated by the bb.js build.
- `barretenberg/ts/src/bb_backends/node/native_socket.ts`: uses
  `UdsIpcClient` from `@aztec/ipc-runtime`.
- `barretenberg/ts/package.json` / `yarn.lock`: depend on
  `@aztec/ipc-runtime`.
- `barretenberg/ts/src/bbapi/chonk_pinned_inputs.test.ts` deleted (drift
  from the original stack rebase — referenced obsolete domain command
  types).

**C++ NAPI substrate**:
- `barretenberg/cpp/src/barretenberg/nodejs_module/msgpack_client/`:
  `msgpack_client_{wrapper,async}.{cpp,hpp}` use
  `ipc_runtime/ipc_client.hpp` for transport.
- `barretenberg/cpp/src/barretenberg/nodejs_module/CMakeLists.txt`: link
  `ipc_runtime`.

**Legacy ipc subdir gone**:
- `barretenberg/cpp/src/barretenberg/ipc/` removed entirely.
  After this PR no consumer references `bb::ipc::` — every transport
  surface routes through `ipc::` from ipc-runtime.
- Top-level `barretenberg/cpp/src/CMakeLists.txt`: drop the
  `add_subdirectory(barretenberg/ipc)` and the transitional comment
  about the legacy subdir.

Verification:
- `ninja bb aztec-wsdb bbapi_tests` clean (legacy bb::ipc gone)
- `./bin/bbapi_tests` — 30/30
- `cd barretenberg/ts && yarn build && yarn test`
- bb-prover e2e against migrated bb.js

End state after the full 5-PR stack:
- bb / wsdb servers route through codegen `make_<prefix>_handler` +
  `ipc::make_server` + `ipc::install_default_signal_handlers`.
- bb.js / barretenberg-rs clients route through codegen-emitted typed
  surfaces over `ipc_runtime::IpcClient` (Rust) /
  `@aztec/ipc-runtime`'s `UdsIpcClient` (TS).
- No `msgpack_roundtrip` at handler boundaries.
- No parallel domain command types.
- No hand-rolled UDS/SHM transport.
@charlielye charlielye force-pushed the cl/ipc-foundation branch from 66e928d to e6fa350 Compare May 29, 2026 15:39
charlielye added a commit that referenced this pull request May 29, 2026
Cuts the aztec-wsdb service over to consume the foundation packages
added in PR #23610. Wsdb_schema.json is the source of truth; the codegen
emits `generated/wsdb_ipc_{client,server}.{hpp,cpp}` and `wsdb_types.hpp`
on build (gitignored). Handlers operate on wire types directly with
field-by-field conversion at the boundary — no msgpack_roundtrip.

**C++ server**:
- New: wsdb_handlers.{cpp,hpp}, wsdb_request.hpp, wsdb_wire_convert.hpp,
  wsdb_schema.json. Server uses `ipc::make_server`,
  `ipc::install_default_signal_handlers`, and the codegen-emitted
  `make_wsdb_handler` dispatcher.
- Deleted: wsdb_commands.hpp, wsdb_execute.{cpp,hpp},
  wsdb_ipc_client_generated.{cpp,hpp}. Replaced by codegen output and
  inline handler bodies.

**C++ AVM client**:
- wsdb_ipc_merkle_db.{cpp,hpp} moved from barretenberg/wsdb_client/ to
  barretenberg/vm2/simulation/dbs/ (next to its sibling DB
  implementations). Constructs the codegen-generated `WsdbIpcClient`.
- barretenberg/wsdb_client/ dir removed.
- vm2/CMakeLists.txt updated to link the wsdb_ipc_client target.
- Top-level CMakeLists.txt drops add_subdirectory(barretenberg/wsdb_client).

**TS codegen invocation**:
- barretenberg/ts/src/aztec-wsdb/generate.ts deleted (codegen moved to
  /ipc-codegen in PR #23610). The wsdb_ipc_client generated by the C++
  build is independent.

**yarn-project**:
- yarn-project/world-state/src/native/ipc_world_state_instance.ts
  deleted. Already orphaned on next (no importers); the AVM sibling
  stack re-adds it later after rebasing on top of this stack.

**serialize/msgpack.hpp**:
- Predefines `IPC_CODEGEN_USE_BB_MSGPACK_ADAPTORS` so codegen-emitted
  msgpack_struct_map_impl.hpp yields to barretenberg's existing
  struct-map adaptor. Without this, both adaptors specialize the same
  primary template for `SERIALIZATION_FIELDS`-bearing types →
  "ambiguous partial specializations" compile error.

The legacy `barretenberg/cpp/src/barretenberg/ipc/` library (namespace
`bb::ipc`) stays in place — bb, nodejs_module, and api still link it.
Follow-up PRs migrate those consumers and the old subdir is deleted
once nothing references it.

Verification:
- `cd barretenberg/cpp/build && ninja aztec-wsdb` clean
- `./bin/aztec-wsdb msgpack schema` round-trips against
  wsdb_schema.json (pre-existing alias-vs-primitive mismatch in the
  committed JSON, not introduced here)
- bb binary still builds (legacy ipc/ stays for now)
charlielye added a commit that referenced this pull request May 29, 2026
… PipeBackend

Cuts the Rust crate over to consume the foundation packages (PR #23610).
Schema = `bb_schema.json` (committed in PR #23612). The codegen emits
`barretenberg-rs/src/generated/{bb_types,bb_client}.rs` on build;
`backend.rs`, `error.rs`, `ffi_backend.rs` are template-copied once into
the same dir.

**Removed**:
- `src/backend.rs` and `src/error.rs` (now codegen-emitted templates in
  `src/generated/`).
- `src/types.rs` (replaced by codegen `bb_types.rs`).
- `src/backends/ffi.rs` and `src/backends/pipe.rs` (the backends/
  directory). The old `PipeBackend` (forked bb subprocess + stdin/stdout
  pipe transport) is gone in favor of `ipc_runtime::IpcClient` over UDS
  or SHM. The codegen-emitted `Backend` trait abstracts the transport;
  `impl Backend for ipc_runtime::IpcClient` lives in the runtime crate.

**Modified**:
- `Cargo.toml` / `bootstrap.sh` (depend on `ipc-runtime`).
- `src/lib.rs` (re-exports updated for the codegen-emitted modules).
- `src/fr_ext.rs` (new — extra constructors / accessors on the codegen
  `Fr` newtype that downstream callers rely on; kept as a separate impl
  block so `src/generated/bb_types.rs` stays a pure regen target).

**Tests**:
- `barretenberg/rust/tests/` updated: dropped legacy `blake2s.rs`,
  `pedersen.rs`, `poseidon.rs`, `utils.rs` and `pipe_test.rs` (the
  PipeBackend tests). The `ffi/` test modules now exercise the codegen
  `BbApi<ipc_runtime::IpcClient>` surface.

Verification:
- `BB_LIB_DIR=… cargo build --release` for `barretenberg-rs/` — clean.
- `BB_LIB_DIR=… cargo build --features ffi --release --tests` for
  `tests/` — pre-existing test compile errors (120) match the stack tip;
  the schema-visitor change for `array<unsigned char, N != 32>` (now
  `[u8; N]` instead of `Vec<u8>`) rippled into the test source. Fixing
  the test crate is a follow-up.

The crate's library surface (the part downstream consumers see) is
green.
Comment thread ipc-codegen/src/cpp_codegen.ts Outdated
Comment thread ipc-runtime/cpp/ipc_runtime/ipc_server.hpp Outdated
@ludamad

ludamad commented Jun 10, 2026

Copy link
Copy Markdown
Collaborator

Looks good. I think I got your intent well, communicating via code works. It's a lot of 'well if it works...' stuff, so happy to approve and let you do the hard part

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants