Skip to content

feat: kv-store over IPC; aztec-kvdb binary; LMDBStore NAPI scaffold [PR 4] - #23698

Closed
charlielye wants to merge 0 commit into
cl/ipc-5-avm-cutoverfrom
cl/ipc-6-kvdb
Closed

charlielye wants to merge 0 commit into
cl/ipc-5-avm-cutoverfrom
cl/ipc-6-kvdb

Conversation

@charlielye

Copy link
Copy Markdown
Contributor

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++:

  • `barretenberg/cpp/src/barretenberg/kvdb/` — `aztec-kvdb` binary. Wraps `lmdblib::LMDBStore`, runs a `bb::messaging::MessageDispatcher`, exposes the same op set as the NAPI LMDBStoreWrapper (open_database, get, has, start_cursor, advance_cursor, advance_cursor_count, close_cursor, batch, stats, copy_store).
  • `barretenberg/cpp/src/barretenberg/kvdb/kvdb_messages.hpp` — wire schema. Moved from `nodejs_module/lmdb_store/lmdb_store_message.hpp`; namespace renamed `bb::nodejs::lmdb_store` → `bb::kvdb`, enum `LMDBStoreMessageType` → `KvdbMessageType`. The NAPI wrapper temporarily includes the new location until it's deleted.

TypeScript (bb.js):

  • `barretenberg/ts/src/aztec-kvdb/index.ts` — `KvdbBackend`: spawns the binary, talks UDS or SHM, implements `IMsgpackBackendAsync`. Mirrors `WsdbBackend`.
  • `findKvdbBinary` in `bb_backends/node/platform.ts`.
  • `copy_native.sh` ships `aztec-kvdb` alongside the other binaries.

What's still ahead in this PR

  • Swap `new MsgpackChannel(new NativeLMDBStore(...))` → `new MsgpackChannel(new KvdbBackend(...))` inside `yarn-project/kv-store/src/lmdb-v2/store.ts`.
  • Update spawn sites (archiver, p2p, pxe, slasher, validator-ha-signer factories + `aztec-node/server.ts`) to construct/accept a `KvdbBackend`.
  • Default `useShm: true` in production callers; verify the SHM transport end-to-end.
  • Delete `barretenberg/cpp/src/barretenberg/nodejs_module/lmdb_store/`, the `LMDBStore` export in `init_module.cpp`, the `NativeLMDBStore` export in `@aztec/native`, and the thin `yarn-project/kv-store/src/lmdb-v2/native/` wrapper.

Stack

Test plan

  • `aztec-kvdb msgpack run --input /tmp/foo.sock --data-dir /tmp/lmdb-test` accepts UDS connections
  • `@aztec/kv-store` `lmdb-v2` tests pass against KvdbBackend over UDS and SHM
  • Bench hot `get`/cursor-page latency vs NAPI baseline (target ~5× over SHM)
  • e2e `e2e_block_building` / `e2e_archiver_` / `e2e_p2p/`
  • Sandbox boots and serves transactions

Recreated from original PR #23238. Same realignment caveats as PR above.

@charlielye
charlielye force-pushed the cl/ipc-5-avm-cutover branch from 1c8d4f9 to a4e2e70 Compare May 29, 2026 14:19
@charlielye
charlielye force-pushed the cl/ipc-6-kvdb branch 2 times, most recently from e183c42 to f441723 Compare May 30, 2026 13:39
@charlielye
charlielye force-pushed the cl/ipc-5-avm-cutover branch 2 times, most recently from 0df283e to 42d8d4f Compare May 30, 2026 16:57
@charlielye
charlielye force-pushed the cl/ipc-5-avm-cutover branch from 42d8d4f to 7f602eb Compare May 30, 2026 18:30
@charlielye
charlielye force-pushed the cl/ipc-6-kvdb branch 2 times, most recently from 874f090 to 73fc07f Compare May 30, 2026 22:27
@charlielye
charlielye force-pushed the cl/ipc-5-avm-cutover branch from 7f602eb to 498b1ca Compare May 30, 2026 22:27
@charlielye
charlielye force-pushed the cl/ipc-5-avm-cutover branch from 498b1ca to 4597920 Compare May 31, 2026 13:23
@charlielye
charlielye force-pushed the cl/ipc-5-avm-cutover branch 2 times, most recently from 4a53618 to af3dc85 Compare June 1, 2026 11:39
@charlielye
charlielye force-pushed the cl/ipc-6-kvdb branch 2 times, most recently from c90eded to aaf3af1 Compare June 1, 2026 11:54
@charlielye
charlielye force-pushed the cl/ipc-5-avm-cutover branch 7 times, most recently from ce6510f to 00868aa Compare June 4, 2026 10:55
@charlielye
charlielye force-pushed the cl/ipc-5-avm-cutover branch 3 times, most recently from 05272f6 to 33b2454 Compare June 9, 2026 16:15
@charlielye
charlielye force-pushed the cl/ipc-5-avm-cutover branch 18 times, most recently from 2ff99c6 to d69bd93 Compare June 18, 2026 20:17
@charlielye
charlielye force-pushed the cl/ipc-5-avm-cutover branch 11 times, most recently from bb3a456 to d7662c1 Compare June 24, 2026 17:57
@charlielye
charlielye force-pushed the cl/ipc-5-avm-cutover branch from beff275 to 25da297 Compare June 26, 2026 12:43
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.

1 participant