Skip to content

feat: aztec-wsdb binary and IPC supporting code (inert)#23035

Merged
charlielye merged 3 commits into
cl/ipc-1-mpsc-shmfrom
cl/ipc-2-wsdb
May 12, 2026
Merged

feat: aztec-wsdb binary and IPC supporting code (inert)#23035
charlielye merged 3 commits into
cl/ipc-1-mpsc-shmfrom
cl/ipc-2-wsdb

Conversation

@charlielye
Copy link
Copy Markdown
Contributor

Summary

Adds the standalone aztec-wsdb binary plus all supporting code (C++ client library, TS spawner, IPC adapter) needed to move world state out of the Node.js process. This PR is inert: nothing yet uses the new binary. A follow-up PR (cl/ipc-3-avm-wsdb-cutover) will cut the NAPI AVM and the TS world state over to use it.

What's added

C++:

  • barretenberg/cpp/src/barretenberg/wsdb/ — `aztec-wsdb` standalone binary that runs the world state DB as an IPC server. Same WorldState surface as the in-process NAPI module, but exposed over msgpack via UDS or shared memory.
  • barretenberg/cpp/src/barretenberg/wsdb_client/ — `WsdbIpcMerkleDB` implements `LowLevelMerkleDBInterface` over WSDB IPC. The standalone AVM (or NAPI AVM after cutover) will use this in place of an in-process `WorldState` reference.
  • barretenberg/cpp/src/barretenberg/ipc/mpsc_shm_{client,server}.hpp — multi-producer single-consumer shared-memory transport. Lower latency than UDS for the AVM↔WSDB hop.

TypeScript (bb.js):

  • barretenberg/ts/src/aztec-wsdb/ — `WsdbBackend` spawns the `aztec-wsdb` binary and routes msgpack commands via the generated `AsyncApi`. Implements `IMsgpackBackendAsync`.
  • barretenberg/ts/src/cbind/cpp_codegen.ts — C++ codegen used by `aztec-wsdb`'s `generate.ts` to produce `wsdb_ipc_client_generated.{cpp,hpp}`. Small shared updates to `schema_visitor` / `typescript_codegen` / `rust_codegen`.

yarn-project:

  • yarn-project/world-state/src/native/ipc_world_state_instance.ts — `IpcWorldState` implements `NativeWorldStateInstance` over WSDB IPC. Not yet wired in.

Why split this way

The full WSDB-out-of-process cutover involves rewiring the NAPI AVM (which currently dereferences an in-process `WorldState*` pointer) to talk to `aztec-wsdb` over IPC, plus replacing TS NAPI WorldState with `IpcWorldState` everywhere it's used. This PR keeps the diff bounded by landing the binary and supporting code first; the cutover lands separately and should be a tiny diff.

Verification

  • aztec-wsdb builds: `cd barretenberg/cpp/build && ninja aztec-wsdb`
  • `wsdb_client` static library builds: `ninja wsdb_client`
  • bb.js builds (esm/cjs/browser): `cd barretenberg/ts && yarn build:esm && yarn build:cjs && yarn build:browser`
  • `@aztec/world-state` typechecks clean (the only TS errors in the build output are pre-existing on `next` in unrelated packages)

Stack

This is part of a stack splitting up #21331. Plan: `/mnt/user-data/charlie/.claude/plans/glittery-snuggling-horizon.md`.

  • PR 2a: this PR — binary + supporting code (inert)
  • PR 2b (next): NAPI AVM + TS world state cutover (~500 LOC, deletes NAPI WorldState C++ module)
  • PR 3: standalone `aztec-avm` + CDB IPC server, kills NAPI AVM
  • PR 4-6: pool, cancellation, optional MPSC SHM transport

Lays the groundwork for moving world state out of the Node.js process
into a standalone aztec-wsdb binary that communicates over UDS or
shared memory. This PR is inert: nothing yet uses the new binary.

C++:
- aztec-wsdb binary (barretenberg/cpp/src/barretenberg/wsdb/) — runs
  the world state DB as an IPC server, exposes the same WorldState
  surface over msgpack
- wsdb_client library (barretenberg/cpp/src/barretenberg/wsdb_client/)
  — LowLevelMerkleDBInterface impl over WSDB IPC; lets the AVM
  simulator talk to a standalone aztec-wsdb instead of in-process
- ipc/ — adds MPSC shared-memory transport for lower latency

TypeScript (bb.js):
- aztec-wsdb/ — WsdbBackend that spawns the binary and routes
  msgpack commands via a generated AsyncApi
- cbind/cpp_codegen.ts — C++ codegen used by aztec-wsdb's generate.ts;
  small shared updates to schema_visitor / typescript_codegen / rust_codegen

yarn-project:
- world-state/src/native/ipc_world_state_instance.ts — IpcWorldState
  implements NativeWorldStateInstance over WSDB IPC. Not yet wired in.

A follow-up PR cuts the NAPI AVM and TS world state over to use this.
@charlielye charlielye changed the base branch from next to cl/ipc-1-mpsc-shm May 7, 2026 13:51
@charlielye charlielye marked this pull request as ready for review May 7, 2026 14:01
ipc_world_state_instance.ts imports from @aztec/bb.js/aztec-wsdb and
msgpackr but the package didn't declare them — caused
import-x/no-extraneous-dependencies lint failures in CI.
@charlielye charlielye requested a review from ludamad May 7, 2026 17:51
NativeWorldStateService.tmp/.new resolves the binary via
findWsdbBinary() which looks at <bb.js packageRoot>/build/<platform>/
aztec-wsdb. copy_native.sh was only copying bb and nodejs_module.node,
so consumers (e.g. world-state) hit "aztec-wsdb binary not found" at
runtime. Mirror the existing bb copy.
Copy link
Copy Markdown
Collaborator

@ludamad ludamad left a comment

Choose a reason for hiding this comment

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

I did a skim. The patterns are familiar enough. I didn't read super deeply though.

@charlielye charlielye merged commit 1344f0d into cl/ipc-1-mpsc-shm May 12, 2026
14 checks passed
@charlielye charlielye deleted the cl/ipc-2-wsdb branch May 12, 2026 08:52
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