feat: kv-store over IPC; aztec-kvdb binary; LMDBStore NAPI scaffold [PR 4]#23698
Open
charlielye wants to merge 95 commits into
Open
feat: kv-store over IPC; aztec-kvdb binary; LMDBStore NAPI scaffold [PR 4]#23698charlielye wants to merge 95 commits into
charlielye wants to merge 95 commits into
Conversation
1c8d4f9 to
a4e2e70
Compare
Two new top-level packages that no consumer in this PR uses yet — they
exist as a self-contained foundation that PR2..5 will adopt for the bb,
wsdb, bb.js, and barretenberg-rs migrations.
/ipc-codegen — multi-language codegen for msgpack-framed IPC services.
- src/{cpp,rust,typescript,zig}_codegen.ts emit per-language clients
and servers from a schema JSON (committed by each service).
- examples/{cpp,rust,ts,zig}/echo are live cross-language wire-compat
tests; the matrix verifies every (server-lang, client-lang) pair.
- examples/echo-schema/golden/ pins the wire format byte-for-byte.
/ipc-runtime — UDS + MPSC-SHM transport library plus per-language
bindings. C++ is the canonical implementation:
- cpp/ipc_runtime/{ipc_server,ipc_client,signal_handlers,serve_helper,
named_union,schema,c_abi,...}.{hpp,cpp}
- cpp/ipc_runtime/shm/ (MPSC/SPSC ring-buffer SHM)
- rust/src/lib.rs binds the C ABI as the `ipc-runtime` crate
- ts/src/{uds_client,uds_server,shm_client,types,index}.ts is the
`@aztec/ipc-runtime` Node package
- zig/src/{main,smoke}.zig binds the C ABI for Zig clients/servers
Strictly additive in this PR. The legacy `barretenberg/cpp/src/barretenberg/ipc/`
library (under namespace `bb::ipc`) stays in place — consumers continue
to use it. Follow-up PRs migrate one consumer at a time to `ipc::`
(top-level namespace, from ipc-runtime) and the legacy subdir is deleted
once nothing references it.
Build wiring:
- Makefile: new `ipc-codegen` / `ipc-codegen-tests` and `ipc-runtime` /
`ipc-runtime-tests` targets; `ipc-codegen-tests` joins the `fast` set.
- barretenberg/cpp/src/CMakeLists.txt: `add_subdirectory` for
ipc-runtime/cpp/ alongside the legacy barretenberg/ipc/.
- barretenberg/.gitignore: `**/generated/` (codegen output dirs).
Verification:
- `cd ipc-codegen && ./bootstrap.sh && ./bootstrap.sh test` — 18-test
matrix (golden corpus × 2 + 4×4 cross-language). Green.
- `cd ipc-runtime && ./bootstrap.sh && ./cpp/build/ipc_runtime_tests` —
2/2 SHM transport tests. Green.
- `cd ipc-runtime/rust && cargo build` — clean.
- `cd ipc-runtime/ts && yarn install && yarn build` — clean.
- `cd ipc-runtime/zig && zig build` — clean.
a4e2e70 to
0df283e
Compare
0df283e to
42d8d4f
Compare
7bd2e42 to
89c8c8c
Compare
184a3fc to
b16faa7
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Stacked on PR 3b (#23196). Adds an out-of-process `aztec-kvdb` binary that owns LMDB and serves it over UDS / MPSC SHM with the same `TypedMessage
` wire format `yarn-project/native/MsgpackChannel` already speaks. AztecLMDBStoreV2 will be migrated from `NativeLMDBStore` (NAPI) to `KvdbBackend` (IPC) in a follow-up commit on this same PR.
This first commit is inert: the binary builds and is shipped, but nothing in yarn-project uses it yet.
Why
After PR 3b lands, only one load-bearing NAPI consumer remains: the LMDB store used by archiver, p2p, pxe, slasher, and validator-ha-signer. Moving it out of NAPI removes the last embedding of a C++ subsystem in the Node.js process. The NAPI module is reduced to a thin SHM transport stub (`MsgpackClient`/`MsgpackClientAsync`, ~400 LOC) — pure IPC plumbing, no domain logic.
SHM is the production transport (~1–10 µs round-trip via futex doorbell); UDS is the dev/test fallback. This also activates the SHM code-path that has been dead in production since PR 1.
What's in this PR (so far)
C++:
TypeScript (bb.js):
What's still ahead in this PR
Stack
Test plan
Recreated from original PR #23238. Same realignment caveats as PR above.