Commit b6a4be3
authored
refactor: cut-over to new wsdb package - comms over uds ipc. (#23036)
## Summary
Cuts TypeScript world-state and the in-process C++ AVM (NAPI) over to
the standalone generated `@aztec/wsdb` package and the `aztec-wsdb` IPC
service. After this PR, both the TS world-state path and the C++ AVM
talk to world state **out-of-process over IPC** (UDS by default, SHM
optional); the in-process NAPI WSDB module is deleted.
The concurrent wsdb server this relies on (reactor + async handlers +
per-fork ordering, #24198) is **now merged into `next`**, so the IPC
world-state path introduced here serves parallel reads concurrently
rather than serializing them through a single server loop.
## IPC contract / schema
The wsdb wire API — the request/response messages between the TS & C++
clients and the `aztec-wsdb` server — is defined by a single schema,
from which `ipc-codegen` generates the C++ server dispatch, the C++/TS
clients, and the shared type definitions:
-
[`barretenberg/cpp/src/barretenberg/wsdb/wsdb_schema.jsonc`](https://github.com/AztecProtocol/aztec-packages/blob/cl/ipc-3-avm-wsdb-cutover/barretenberg/cpp/src/barretenberg/wsdb/wsdb_schema.jsonc)
## Stack
`next` already contains the merged foundation (#23610), wsdb migration
(#23611), and the concurrent wsdb server (#24198).
1. #23036 `cl/ipc-3-avm-wsdb-cutover` — **this PR**
2. #23084 `cl/ipc-4-avm-binary`
3. #23697 `cl/ipc-5-avm-cutover`
## What changes
### C++ / NAPI AVM path
- `AvmSimAPI::simulate` takes a `LowLevelMerkleDBInterface&` instead of
an in-process `WorldState&`.
- NAPI AVM accepts a WSDB socket path and constructs a generated wsdb
IPC client plus VM2 wsdb adapter per simulation.
- NAPI world-state module is deleted; the NAPI module no longer exposes
in-process `WorldState`.
- NAPI module links the current `ipc_runtime` path from the lower stack.
### TypeScript world-state path
- World-state startup is encapsulated behind the world-state
service/facade instead of leaking binary discovery into callers.
- `NativeWorldStateService` spawns `aztec-wsdb` through the generated
`@aztec/wsdb` package.
- The generated wsdb wrapper resolves its service binary from the
installed/local arch package optional dependency.
- The old `WorldStateRevisionWithHandle` shape is removed; callers use
ordinary revisions and, where needed, the wsdb socket path.
- Cleanup paths close spawned wsdb processes explicitly in tests and
service lifecycles.
- The client-side `WorldStateOpsQueue` is removed: ordering is now
enforced server-side per fork (in #24198), so the client just sends
requests directly.
### Test / runtime adjustments for the IPC backend
These adapt existing tests to the fact that world state is now a spawned
process rather than an in-process call:
- `NativeWorldStateService.tmp()` LMDB map sizes reduced 10 GB → 256 MB
per tree. With the IPC backend each `tmp()` spawns a separate
`aztec-wsdb` that maps these per tree, and oversized maps added real
cold-start I/O under parallel CI load. Production map sizes are
unaffected (`tmp()` is the test/dev helper).
- `validator.integration.test.ts` re-anchors its controlled clock
*after* world-state setup. Reexecution's deadline is the slot end; the
real wall-clock spent spawning `aztec-wsdb` during setup could otherwise
push past it before the test body runs.
- Bumped the reexecution test timeout to accommodate IPC setup latency
under load.
## End state after this PR
The TS world-state path and the C++ AVM path both talk to world state
over IPC. The in-process NAPI WSDB module is gone.
## Performance / concurrency
This is a cut-over, not a performance change. The work that keeps
parallel reads concurrent — the reactor + async-handler server with
per-fork ordering — lives in **#24198** and is already in `next`; this
PR just routes TS world-state and the C++ AVM through it. (For
reference: a naive IPC cut-over with a synchronous server loop would
serialize every read through one thread, flat at ~13k reads/s regardless
of concurrency — the reactor in #24198 is what avoids that. See that PR
for the server design and the full throughput analysis.)
To guard the cut-over against accidentally introducing a serialization
bottleneck, this PR keeps `parallel_read.bench.test.ts` (single
connection, pipelined) and adds `multi_connection_read.bench.test.ts` (N
separate connections — the real AVM-pool topology). On this branch,
single-connection pipelined reads reach ~30k/s over SHM at c16 (~80–86%
of the in-process baseline; the residual is per-op TS-facade overhead),
and multi-connection SHM aggregates ~40–47k/s at 7 connections — i.e.
the cut-over preserves read concurrency rather than serializing it.
## Validation
- `wsdb/bootstrap.sh` and root `./bootstrap.sh` pass on this branch.
- `native_world_state.test.ts` (50 tests incl. concurrent
mutating/non-mutating ordering) green, including at the reduced 256 MB
map sizes.
- `validator.integration.test.ts` green over the IPC backend after the
clock re-anchor.51 files changed
Lines changed: 1810 additions & 2542 deletions
File tree
- aztec-up
- barretenberg
- cpp/src/barretenberg
- nodejs_module
- avm_simulate
- world_state
- vm2
- ts/src/barretenberg
- docs/examples
- ipc-codegen/src
- ipc-runtime/cpp/ipc_runtime
- shm
- release-image
- yarn-project
- end-to-end/src/e2e_l1_publisher
- native/src
- p2p/src/msg_validators/tx_validator
- prover-client/src
- light
- mocks
- prover-node/src/actions
- simulator/src/public
- public_processor
- public_tx_simulator
- stdlib/src
- interfaces
- world-state
- validator-client/src
- world-state
- src
- instrumentation
- native
- synchronizer
- test
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
9 | 16 | | |
10 | 17 | | |
11 | 18 | | |
| |||
103 | 110 | | |
104 | 111 | | |
105 | 112 | | |
| 113 | + | |
106 | 114 | | |
| 115 | + | |
107 | 116 | | |
108 | 117 | | |
109 | 118 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
| 30 | + | |
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| |||
Lines changed: 16 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
| 16 | + | |
15 | 17 | | |
16 | 18 | | |
17 | 19 | | |
| |||
227 | 229 | | |
228 | 230 | | |
229 | 231 | | |
230 | | - | |
231 | | - | |
232 | | - | |
233 | | - | |
234 | | - | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
235 | 237 | | |
236 | | - | |
237 | | - | |
238 | | - | |
| 238 | + | |
239 | 239 | | |
240 | 240 | | |
241 | 241 | | |
| |||
281 | 281 | | |
282 | 282 | | |
283 | 283 | | |
284 | | - | |
285 | | - | |
286 | 284 | | |
287 | | - | |
| 285 | + | |
288 | 286 | | |
289 | 287 | | |
290 | 288 | | |
| |||
309 | 307 | | |
310 | 308 | | |
311 | 309 | | |
312 | | - | |
313 | | - | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
314 | 316 | | |
315 | | - | |
| 317 | + | |
316 | 318 | | |
317 | 319 | | |
318 | 320 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | | - | |
| 28 | + | |
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| |||
Lines changed: 0 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
6 | 5 | | |
7 | 6 | | |
8 | 7 | | |
9 | 8 | | |
10 | | - | |
11 | 9 | | |
12 | 10 | | |
13 | 11 | | |
| |||
0 commit comments