refactor: extract wsdb/lmdblib/kvdb into native-packages, decoupled from barretenberg - #24392
Open
charlielye wants to merge 1 commit into
Open
refactor: extract wsdb/lmdblib/kvdb into native-packages, decoupled from barretenberg#24392charlielye wants to merge 1 commit into
charlielye wants to merge 1 commit into
Conversation
charlielye
force-pushed
the
cl/native-packages-wsdb
branch
from
July 1, 2026 13:36
09345bd to
1240a13
Compare
charlielye
requested review from
a team,
IlyasRidhuan,
MirandaWood,
Thunkar and
jeanmon
as code owners
July 1, 2026 13:36
charlielye
force-pushed
the
cl/wsdb-decouple
branch
from
July 1, 2026 13:39
281f517 to
b4e06cc
Compare
charlielye
force-pushed
the
cl/native-packages-wsdb
branch
from
July 1, 2026 14:43
1240a13 to
b9d3ca7
Compare
charlielye
force-pushed
the
cl/wsdb-decouple
branch
from
July 1, 2026 14:43
b4e06cc to
5bc1216
Compare
Contributor
Author
|
!ci |
charlielye
force-pushed
the
cl/native-packages-wsdb
branch
from
July 1, 2026 16:52
b9d3ca7 to
cb30112
Compare
charlielye
force-pushed
the
cl/wsdb-decouple
branch
from
July 1, 2026 16:52
5bc1216 to
8b51f8b
Compare
Contributor
Author
|
!ci |
1 similar comment
Contributor
Author
|
!ci |
charlielye
force-pushed
the
cl/wsdb-decouple
branch
from
July 2, 2026 09:49
8b51f8b to
4acea16
Compare
Contributor
Author
|
!ci |
charlielye
force-pushed
the
cl/wsdb-decouple
branch
from
July 2, 2026 11:10
4acea16 to
92b6c37
Compare
Contributor
Author
|
!ci |
charlielye
force-pushed
the
cl/wsdb-decouple
branch
from
July 2, 2026 11:52
92b6c37 to
1cb151b
Compare
Contributor
Author
|
!ci |
charlielye
force-pushed
the
cl/wsdb-decouple
branch
from
July 2, 2026 12:06
1cb151b to
89b77d0
Compare
Contributor
Author
|
!ci |
charlielye
force-pushed
the
cl/native-packages-wsdb
branch
from
July 2, 2026 13:53
cb30112 to
9685f11
Compare
charlielye
force-pushed
the
cl/wsdb-decouple
branch
from
July 2, 2026 13:54
89b77d0 to
ec55119
Compare
Contributor
Author
|
!ci |
charlielye
force-pushed
the
cl/native-packages-wsdb
branch
from
July 2, 2026 15:33
9685f11 to
74d5b73
Compare
Contributor
Author
|
!ci |
charlielye
force-pushed
the
cl/wsdb-decouple
branch
from
July 2, 2026 15:36
ec55119 to
7abc60b
Compare
charlielye
force-pushed
the
cl/native-packages-wsdb
branch
from
July 2, 2026 15:45
74d5b73 to
2218d58
Compare
charlielye
force-pushed
the
cl/ipc-6-memory-merkle-db
branch
from
July 7, 2026 16:42
029257b to
62ffd7a
Compare
charlielye
force-pushed
the
cl/wsdb-decouple
branch
from
July 7, 2026 16:42
0cf020f to
c61c77a
Compare
charlielye
force-pushed
the
cl/ipc-6-memory-merkle-db
branch
from
July 17, 2026 15:25
62ffd7a to
8443e1a
Compare
charlielye
force-pushed
the
cl/wsdb-decouple
branch
2 times, most recently
from
July 20, 2026 15:53
8b2ae61 to
6113a7c
Compare
charlielye
force-pushed
the
cl/ipc-6-memory-merkle-db
branch
from
July 23, 2026 10:02
8443e1a to
3b9cd59
Compare
charlielye
force-pushed
the
cl/wsdb-decouple
branch
from
July 23, 2026 10:02
6113a7c to
af82589
Compare
charlielye
force-pushed
the
cl/ipc-6-memory-merkle-db
branch
from
July 23, 2026 11:26
3b9cd59 to
ec066c6
Compare
charlielye
force-pushed
the
cl/wsdb-decouple
branch
from
July 23, 2026 11:26
af82589 to
d6a7a02
Compare
charlielye
force-pushed
the
cl/wsdb-decouple
branch
from
July 31, 2026 14:31
d6a7a02 to
493f825
Compare
charlielye
force-pushed
the
cl/ipc-6-memory-merkle-db
branch
from
July 31, 2026 17:30
638fa33 to
6b50835
Compare
charlielye
force-pushed
the
cl/wsdb-decouple
branch
3 times, most recently
from
August 3, 2026 10:38
a8a2b77 to
ee71811
Compare
charlielye
force-pushed
the
cl/ipc-6-memory-merkle-db
branch
from
August 4, 2026 12:54
c601182 to
bebe8ca
Compare
charlielye
force-pushed
the
cl/wsdb-decouple
branch
2 times, most recently
from
August 4, 2026 13:29
1bd6411 to
9f1b36b
Compare
charlielye
force-pushed
the
cl/ipc-6-memory-merkle-db
branch
from
August 4, 2026 14:20
0a5f500 to
af48fb8
Compare
charlielye
force-pushed
the
cl/wsdb-decouple
branch
2 times, most recently
from
August 4, 2026 16:23
d559569 to
a500914
Compare
rangozd
pushed a commit
to rangozd/aztec-packages
that referenced
this pull request
Aug 5, 2026
…otocol#23697) ## Summary Cuts the public simulator over from the legacy in-process NAPI AVM path to the generated `@aztec/bb-avm-sim` IPC service package introduced in AztecProtocol#23084. The simulator now drives a pool of out-of-process AVM instances over IPC and owns a TypeScript CDB IPC server for contract-data callbacks, while world-state access continues through the generated wsdb package/service from the lower stack. ## Stack Merged into `next`: AztecProtocol#23610 `cl/ipc-foundation` · AztecProtocol#23611 `cl/ipc-wsdb-migrate` · AztecProtocol#23036 `cl/ipc-3-avm-wsdb-cutover` · AztecProtocol#23084 `cl/ipc-4-avm-binary` This chain (bottom → top): 1. AztecProtocol#23697 `cl/ipc-5-avm-cutover` — **this PR** (base `next`) 2. AztecProtocol#24306 `cl/ipc-6-memory-merkle-db` — in-memory `MemoryMerkleDB` reference; drops `world_state` from vm2 3. AztecProtocol#24392 `cl/wsdb-decouple` — extract wsdb/lmdblib/kvdb into `native-packages/`, decoupled from barretenberg headers Parallel IPC stack (independent, also based on `next`): AztecProtocol#23612 `cl/ipc-bb-migrate` → AztecProtocol#23613 `cl/ipc-bb-rs-migrate` → AztecProtocol#23614 `cl/ipc-bb-js-migrate`. ## What changes ### AVM simulator cutover - Adds `AvmSimulatorPool`, which owns the out-of-process `@aztec/bb-avm-sim` instances and implements a small `AvmSimulator` interface (`simulate` / `simulateWithHints`). Checkout/return is fully internal: `simulate` blocks until an instance is free and releases it when done, so callers never see the pool mechanics or the IPC transport. - Bundles the pool and the CDB server into an `AvmExecutor` facade. `AvmExecutor.forFork(forkId, contractsDB, timestamp)` hands out a `ForkedAvmSimulator` that registers the fork's contracts DB with the CDB server for the duration of each `simulate` call. The executor is spawned once and injected into the node, public processor, checkpoint builder, TXE, and the fuzzer. - Adds `AbortSignal`-based cancellation end to end: `PublicTxSimulator` cancels via an `AbortController`, which signals the external C++ AVM process (SIGUSR1) to stop at the next opcode / before the next world-state write, replacing the old in-process cancellation. - Renames socket-specific parameters to generic IPC paths where the value may be UDS or SHM. - Uses explicit async disposal (`AsyncDisposable` / `await using`) for the AVM executor, CDB server, wsdb service, and the tests/fixtures that own those resources. ### CDB server generation - Converts the AVM and CDB schemas to the newer friendly schema format. - Removes the unused CDB shutdown command; process backends are controlled by normal process signalling. - Generates TypeScript CDB server command/response types and request dispatch from the CDB schema. - Backs `CdbIpcServer` with the shared `UdsIpcServer` transport from `@aztec/ipc-runtime` (socket, framing, per-connection response ordering) rather than hand-rolled framing; `CdbIpcServer` only implements the generated handler interface. - Ignores generated CDB TypeScript output and produces it from the `simulator` generation step during bootstrap. ### Legacy NAPI cleanup - Deletes the old AVM NAPI simulation implementation. - Deletes the remaining msgpack client side-channel code from `nodejs_module`. - Removes AVM simulation exports from `@aztec/native`, leaving the remaining native module focused on the native pieces that still live there. ## Validation - `yarn build` from `yarn-project/simulator` - `make bb-avm-sim` - `cmake --build build --target bb-avm-sim nodejs_module` from `barretenberg/cpp` - `yarn build` from `yarn-project` - `./bootstrap.sh format --check simulator` from `yarn-project` - `JEST_MAX_WORKERS=1 yarn test public/cdb_ipc_server.test.ts public/public_processor/apps_tests/token.test.ts public/public_tx_simulator/apps_tests/token.test.ts public/public_processor/apps_tests/deployments.test.ts public/public_processor/public_processor.test.ts` from `yarn-project/simulator`
charlielye
force-pushed
the
cl/ipc-6-memory-merkle-db
branch
from
August 5, 2026 08:27
5041b6b to
fafdd72
Compare
charlielye
force-pushed
the
cl/wsdb-decouple
branch
from
August 5, 2026 08:27
a500914 to
2933629
Compare
charlielye
force-pushed
the
cl/ipc-6-memory-merkle-db
branch
from
August 5, 2026 13:25
fafdd72 to
94d004c
Compare
charlielye
force-pushed
the
cl/wsdb-decouple
branch
from
August 5, 2026 13:25
2933629 to
be4f21e
Compare
charlielye
force-pushed
the
cl/wsdb-decouple
branch
from
August 21, 2026 17:07
f6df655 to
315139e
Compare
Moves the world-state DB service (world_state engine, persistent content-addressed merkle storage, lmdb tree store, IPC server) out of barretenberg into native-packages/wsdb, compiling with zero barretenberg headers: bb is linked only as a prebuilt archive for the poseidon2 c_bind and for the new bb_wsref_* C ABI over the in-memory reference world state (world_state_reference), against which this package's conformance test drives its WorldState and asserts agreement on roots, sibling paths, low-leaf lookups, preimages and checkpointing. Constants stay in lockstep via a wsdb-local remake-constants hook on the protocol constants-codegen (generated header, no longer checked in).
charlielye
force-pushed
the
cl/wsdb-decouple
branch
from
August 21, 2026 17:43
90afacf to
f97bfb1
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.
What
Two changes that belong together, in one commit:
wsdb), the lmdb C++ wrapper (lmdblib), and the kv-store NAPI (kvdb) out of barretenberg into top-levelnative-packages/siblings, leaving barretenberg free of DB code.wsdbfrom barretenberg's C++ headers, so its world-state/merkle/storage core, its test suite, and theaztec-wsdbbinary compile with zero barretenberg headers on the include path — barretenberg is only linked (libbarretenberg.a), purely to satisfy a small flat poseidon2 c_bind.Together this lets
wsdb/lmdblib/kvdband barretenberg eventually live in independently-owned repos / CI without sharing a compiler, stdlib, or build flags — the only thingswsdband barretenberg share are the IPC schema (already the case) and a couple ofextern "C"hash calls.Extraction (barretenberg →
native-packages/)native-packages/siblings:wsdb(world-state DB server + persistent content-addressed merkle),lmdblib(the C++ lmdb wrapper),kvdb(the kv-storenodejs_module.nodeNAPI addon that owns theLMDBStorewrapper).merkle_treeheaders are split: barretenberg keeps only the response/types the AVM'sLowLevelMerkleDBInterfacereturns and its hints serialize; the full async tree engine (content-addressed trees +world_state) and itsresponse/tree_meta/typesmove intowsdb.world_state,lmdblib,wsdb, and the merkle-tree benchmarks are deleted frombarretenberg/cpp.aztec-wsdbbinary and thekvdb.nodebuild against prebuilt barretenberg;lmdblib/kvdbare fully barretenberg-free.lmdblibswitches to upstream msgpack + FetchContent. Thelmdblib/wsdbC++ tests are wired into the CI test engine.Decoupling
wsdbfrom barretenberg headersbarretenberg/crypto/poseidon2/poseidon2_capi.cpp, inlibbarretenberg.a): flatbb_poseidon2_hash+bb_poseidon2_hash_pair_with_separator. Field elements cross as 32 canonical bytes — no bb field type, stdlib, or build-flag agreement required. This is the only computation wsdb can't own (it must match what the AVM proves and what is committed on L1), so it is single-sourced in barretenberg.azteclabs::wsdb::FieldElement: a 32-byte field value with no arithmetic (wsdb only stores/orders/compares/serialises field values and feeds them to the hash). Ausing fr = FieldElement;alias insidenamespace azteclabs::wsdblets the forked merkle headers compile unchanged.types,hash_path,merkle_tree_id,tree_meta,indexed_leaf,response,memory_tree,signal) intowsdbundernamespace azteclabs::wsdb::merkle_tree, swappingSERIALIZATION_FIELDS→MSGPACK_DEFINE_MAP(msgpack-c directly). The msgpack values are byte-identical tobb::fr, so on-disk lmdb data and the IPC wire are unchanged.log,assert,thread_pool,bitop,random, a minimaluint256_t(for the reference/test nullifier abs-diff search),aztec_constants, and vendoredcli11.Proof
aztec-wsdb+wsdb_testsbuild withBB_SRCremoved from the include dirs; 0 bb#includes remain in the decoupled set. (Also verified locally from the combined commit:lmdblib+aztec-wsdbcompile and link.)wsdb_testspass.-DWSDB_BUILD_BB_TESTS=ON) provesFieldElement+ the c_bind are byte-identical tobb::frand bb'sPoseidon2HashPolicy(hash, msgpack, ordering, domain separators) — 6 tests pass.-march).Notes / follow-ups
FrKeyType = fr, comparatorvalue_cmp<fr>). msgpack values are unchanged. This is fine for a fresh service (re-sync) but is not backward-compatible with databases written before this change.wsdb/memory_merkle_db.test.cpp) is left in-tree but not wired into the default build; reviving it (it links both wsdb's forked merkle headers and barretenberg's real ones in one TU) is a follow-up. The bb-linked parity target covers the consensus-critical byte-identity guarantee in the meantime.