Skip to content

feat(ipc-runtime/ts): TS UDS transport package; migrate bb.js + codegen template#23498

Open
charlielye wants to merge 1 commit into
cl/ipc-bbapi-server-signalsfrom
cl/ipc-runtime-ts
Open

feat(ipc-runtime/ts): TS UDS transport package; migrate bb.js + codegen template#23498
charlielye wants to merge 1 commit into
cl/ipc-bbapi-server-signalsfrom
cl/ipc-runtime-ts

Conversation

@charlielye
Copy link
Copy Markdown
Contributor

Summary

Stacked on #23497 (cl/ipc-bbapi-server-signals → cl/ipc-codegen-migrate-bb-wsdb).

New `@aztec/ipc-runtime` workspace package mirroring `ipc-runtime/{rust,zig}` — one TS UDS implementation shared by every consumer instead of the three near-identical copies we had:

  • `UdsIpcClient` — pipelined async UDS client (4-byte LE length prefix + msgpack), with connect retry for the bind-vs-listen race.
  • `UdsIpcServer` — per-connection FIFO handler dispatch over the same wire.
  • `NapiShmSyncClient` / `NapiShmAsyncClient` — thin wrappers over any NAPI module exposing `call(Buffer) / close()`. The NAPI binding itself stays in the consumer (bb.js already ships one), so this package is native-free.

Consumer migrations

  • ipc-codegen no longer ships `templates/ts/ipc_{client,server}.ts`. They were copy-pasted into every `generated/` and duplicated the same framing. The codegen still emits typed AsyncApi/SyncApi/Handler/dispatch wrappers; consumers supply the transport.
  • ipc-codegen/examples/ts/echo now uses `UdsIpcClient` / `UdsIpcServer` directly. The 4x4 cross-language matrix + 2 golden tests = 18/18 passing.
  • barretenberg/ts/src/bb_backends/node/native_socket.ts — the 365-LOC hand-rolled UDS client (state machine, FIFO queue, connect retry) collapses to ~115 LOC of bb-specific lifecycle (spawn, wait, kill) delegating transport to `UdsIpcClient`.

Deferred

bb.js's `native_shm.ts` already goes through bb's NAPI `MsgpackClient`, which wraps `ipc::IpcClient` — so SHM is already runtime-backed, just not via this package's `NapiShmSyncClient` wrapper. Mechanical migration; can land separately.

Test plan

  • `@aztec/ipc-runtime` typechecks + builds (`tsc -p tsconfig.json`)
  • `ipc-codegen ./bootstrap.sh test` — 18/18 cross-language tests green
  • `yarn build:esm` clean in barretenberg/ts
  • CI: bb-prover e2e exercises native_socket end-to-end

…gen template

New @aztec/ipc-runtime workspace package mirrors ipc-runtime/{rust,zig}:

- UdsIpcClient: pipelined async UDS client with connect retry. Wire
  protocol (4-byte LE length prefix + msgpack payload) matches the C++
  ipc::IpcServer socket transport, so any TS consumer talks to any
  bb/wsdb-style server with no per-service framing code.
- UdsIpcServer: per-connection FIFO handler dispatch with the same wire.
- NapiShmSyncClient / NapiShmAsyncClient: thin wrappers around any NAPI
  module exposing call(Buffer)/close(). The NAPI binding itself stays in
  the consumer (bb.js's nodejs_module.node), so this package is
  native-free.

ipc-codegen no longer ships templates/ts/ipc_{client,server}.ts. Both
were copy-pasted into every per-service generated/ directory and
duplicated the same length-prefix framing. The codegen still emits the
typed AsyncApi/SyncApi/Handler/dispatch wrappers; consumers provide the
transport.

Consumer migrations:
- ipc-codegen/examples/ts/echo: client + server now use UdsIpcClient /
  UdsIpcServer directly with manual msgpack. All 18 cross-language
  matrix tests (4x4 + 2 golden) pass.
- barretenberg/ts/src/bb_backends/node/native_socket.ts: the 365-LOC
  hand-rolled UDS client (state machine, FIFO queue, connect retry)
  collapses to ~115 LOC of bb-specific lifecycle (spawn, wait, kill)
  delegating transport to UdsIpcClient.

Deferred: bb.js's native_shm.ts already routes through bb's existing
MsgpackClient NAPI (which itself wraps ipc::IpcClient), so SHM is
already runtime-backed — just not through this package's wrapper.
Migration to NapiShmSyncClient is mechanical and can land separately.
@socket-security
Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addednpm/​@​types/​node@​22.19.191001008196100
Addednpm/​@​aztec/​ipc-runtime@​0.1.0100100100100100

View full report

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