refactor: extract wsdb/lmdblib/kvdb into native-packages, decoupled from barretenberg#24392
Open
charlielye wants to merge 3 commits into
Open
refactor: extract wsdb/lmdblib/kvdb into native-packages, decoupled from barretenberg#24392charlielye wants to merge 3 commits into
charlielye wants to merge 3 commits 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/wsdb-decouple
branch
from
July 2, 2026 15:45
7abc60b to
8080d99
Compare
Contributor
Author
|
!ci |
charlielye
force-pushed
the
cl/wsdb-decouple
branch
2 times, most recently
from
July 2, 2026 16:54
1ecdf78 to
852c256
Compare
Contributor
Author
|
!ci |
charlielye
force-pushed
the
cl/wsdb-decouple
branch
from
July 2, 2026 19:11
852c256 to
780cdf5
Compare
Contributor
Author
|
!ci |
1 similar comment
Contributor
Author
|
!ci |
charlielye
force-pushed
the
cl/wsdb-decouple
branch
from
July 2, 2026 20:16
780cdf5 to
b53635f
Compare
Contributor
Author
|
!ci |
charlielye
force-pushed
the
cl/wsdb-decouple
branch
from
July 2, 2026 21:26
b53635f to
4d09a60
Compare
charlielye
force-pushed
the
cl/native-packages-wsdb
branch
from
July 3, 2026 18:20
2218d58 to
9849bc2
Compare
charlielye
force-pushed
the
cl/wsdb-decouple
branch
2 times, most recently
from
July 3, 2026 21:33
e63fbb2 to
0cf020f
Compare
charlielye
changed the base branch from
cl/native-packages-wsdb
to
cl/ipc-6-memory-merkle-db
July 3, 2026 21:33
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
Replace the in-process NAPI AVM with an out-of-process bb-avm-sim binary reached over IPC. The simulator drives a pool of bb-avm-sim processes (AvmSimulatorPool) behind an AvmExecutor that also runs the CDB server answering the C++ AVM's contract-data callbacks; per-fork work goes through AvmExecutor.forFork. The pool prewarms one process on spawn so the first simulate() runs at steady-state cost. Also adds the bench_compare script + bench-regression skill for PR perf checks.
Adds a self-contained in-memory MemoryMerkleDB (LowLevelMerkleDBInterface) and migrates vm2 simulation, the public-tx test tester, and the AVM fuzzer's FuzzerWorldStateManager off the on-disk world_state onto it (prod continues to use the WSDB-IPC-backed DB). This leaves the AVM fuzzer + vm2 test paths free of world_state, which the native-packages extraction depends on.
Moves the world-state DB server (+ persistent merkle), the lmdb C++ wrapper (lmdblib), and the kv-store NAPI (kvdb) out of barretenberg into native-packages siblings, leaving barretenberg free of DB code — and in the same step decouples wsdb from barretenberg's C++ headers. The extraction splits barretenberg's merkle_tree headers: barretenberg keeps only the response/types the AVM's LowLevelMerkleDBInterface returns and its hints serialize, while the full async tree engine (content-addressed trees + world_state) and its response/tree_meta/types move into wsdb. wsdb then compiles with zero barretenberg headers — its own FieldElement (32-byte canonical) + a poseidon2 c_bind are the only barretenberg link. Forks the bb-free common utils, moves merkle_tree Signal into wsdb, keeps lmdb keys backward-compatible (little-endian uint256), switches lmdblib to upstream msgpack + FetchContent (bb-free), and wires the lmdblib/wsdb C++ tests into the CI test engine. The standalone aztec-wsdb binary and the kvdb .node build against prebuilt barretenberg; lmdblib/kvdb are fully barretenberg-free.
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
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.