diff --git a/Makefile b/Makefile
index 5c0315c30559..cdc8273c59b5 100644
--- a/Makefile
+++ b/Makefile
@@ -144,7 +144,7 @@ avm-transpiler-cross: avm-transpiler-cross-amd64-macos avm-transpiler-cross-arm6
#==============================================================================
# Barretenberg - Aggregate target for all barretenberg sub-projects.
-barretenberg: bb-cpp bb-ts bb-avm-sim bb-rs bb-acir bb-docs bb-sol bb-bbup bb-crs
+barretenberg: bb-cpp bb-ts bb-avm-sim bb-cdb bb-rs bb-acir bb-docs bb-sol bb-bbup bb-crs
# BB C++ - Main aggregate target.
bb-cpp: bb-cpp-native bb-cpp-wasm bb-cpp-wasm-threads
@@ -277,6 +277,12 @@ bb-avm-sim: ipc-codegen ipc-runtime bb-cpp-native
bb-avm-sim-cross-copy: bb-avm-sim bb-cpp-cross
$(call build,$@,barretenberg/ts,cross_copy_bb_avm_sim)
+# Generated @aztec/cdb server bindings. Ordered after bb-avm-sim rather than run
+# alongside it: both regenerate the same barretenberg/ts workspaces and install
+# into the same node_modules.
+bb-cdb: ipc-codegen ipc-runtime bb-avm-sim
+ $(call build,$@,barretenberg/ts,build_cdb)
+
# BB Rust - barretenberg-rs FFI crate
bb-rs: bb-ts bb-cpp-native
$(call build,$@,barretenberg/rust)
@@ -518,7 +524,7 @@ yarn-project: noir-projects-labs labs-aztec-toolchain
# If we still in the monorepo, we need to additionally depend on everything else explicitly.
# In the labs repo, we will consume them differently.
# TODO(fcarreiro): comment this out when pinning binaries.
-yarn-project: bb-ts l1-contracts wsdb bb-avm-sim constants-codegen noir-projects-fnd
+yarn-project: bb-ts l1-contracts wsdb bb-avm-sim bb-cdb constants-codegen noir-projects-fnd
yarn-project-tests: yarn-project
$(call test,$@,yarn-project/end-to-end)
diff --git a/barretenberg/ts/.gitignore b/barretenberg/ts/.gitignore
index f3043ded7e12..9399d0021b0f 100644
--- a/barretenberg/ts/.gitignore
+++ b/barretenberg/ts/.gitignore
@@ -8,6 +8,7 @@ bb.js/build
bb.js/.tsbuildinfo*
bb.js/*.tsbuildinfo
bb-avm-sim/
+cdb/
.tsbuildinfo*
*.tsbuildinfo
*.log
diff --git a/barretenberg/ts/bb.js/bootstrap.sh b/barretenberg/ts/bb.js/bootstrap.sh
index 0dda2bc1950f..559bd74694b6 100755
--- a/barretenberg/ts/bb.js/bootstrap.sh
+++ b/barretenberg/ts/bb.js/bootstrap.sh
@@ -13,7 +13,7 @@ hash=$(hash_str \
${AVM_TRANSPILER:-1})
function prepare_project {
- (cd .. && ./bootstrap.sh generate_bb_avm_sim_package)
+ (cd .. && ./bootstrap.sh generate_packages)
(cd .. && npm_install_deps)
}
diff --git a/barretenberg/ts/bootstrap.sh b/barretenberg/ts/bootstrap.sh
index 3ce36ccbbbab..7dec20254d62 100755
--- a/barretenberg/ts/bootstrap.sh
+++ b/barretenberg/ts/bootstrap.sh
@@ -4,6 +4,7 @@ source $(git rev-parse --show-toplevel)/ci3/source_bootstrap
ROOT=$(git rev-parse --show-toplevel)
BB_AVM_SIM_BINARY=bb-avm-sim
BB_AVM_SIM_PACKAGE=@aztec/bb-avm-sim
+CDB_PACKAGE=@aztec/cdb
hash=$(hash_str \
$(bb.js/bootstrap.sh hash) \
@@ -29,6 +30,27 @@ function generate_bb_avm_sim_package {
--package-ipc-path-args 'msgpack,run,--input,{path}'
}
+# Server binding package for the AVM CDB protocol: generated wire types +
+# Handler/dispatch + the schema itself. Pure TS — no binary, no arch packages.
+function generate_cdb_package {
+ node --experimental-strip-types --experimental-transform-types --no-warnings \
+ "$ROOT/ipc-codegen/src/generate.ts" \
+ --schema "$ROOT/barretenberg/cpp/src/barretenberg/cdb/cdb_schema.json" \
+ --lang ts \
+ --server \
+ --out "$ROOT/barretenberg/ts/cdb/src/generated" \
+ --package "$ROOT/barretenberg/ts/cdb" \
+ --package-name "$CDB_PACKAGE"
+}
+
+# Both bb-avm-sim and cdb are gitignored workspaces declared in package.json, so
+# `yarn install --immutable` fails against the committed lockfile unless both exist.
+# Generate them together before installing, whichever one we're about to build.
+function generate_packages {
+ generate_bb_avm_sim_package
+ generate_cdb_package
+}
+
function copy_bb_avm_sim_native {
local target_dir="bb-avm-sim/build/$(arch)-$(os)"
mkdir -p "$target_dir"
@@ -62,16 +84,24 @@ function build_bb_js {
function build_bb_avm_sim {
echo_header "bb-avm-sim package build"
- generate_bb_avm_sim_package
+ generate_packages
copy_bb_avm_sim_native
npm_install_deps
yarn workspace "$BB_AVM_SIM_PACKAGE" build
prepare_bb_avm_sim_arch_packages "$(arch)-$(os)=build/$(arch)-$(os)/$BB_AVM_SIM_BINARY"
}
+function build_cdb {
+ echo_header "cdb package build"
+ generate_packages
+ npm_install_deps
+ yarn workspace "$CDB_PACKAGE" build
+}
+
function build {
build_bb_js
build_bb_avm_sim
+ build_cdb
}
function test_cmds {
@@ -91,7 +121,7 @@ function cross_copy_bb_js {
}
function cross_copy_bb_avm_sim {
- generate_bb_avm_sim_package
+ generate_packages
copy_bb_avm_sim_cross "$@"
npm_install_deps
yarn workspace "$BB_AVM_SIM_PACKAGE" build
@@ -110,10 +140,13 @@ function get_projects {
done
echo "$PWD/bb-avm-sim"
fi
+ if [ -d cdb ]; then
+ echo "$PWD/cdb"
+ fi
}
function release_bb_avm_sim {
- generate_bb_avm_sim_package
+ generate_packages
copy_bb_avm_sim_native
copy_bb_avm_sim_cross
npm_install_deps
@@ -125,13 +158,21 @@ function release_bb_avm_sim {
(cd bb-avm-sim && retry "deploy_npm ${REF_NAME#v}")
}
+function release_cdb {
+ generate_packages
+ npm_install_deps
+ yarn workspace "$CDB_PACKAGE" build
+ (cd cdb && retry "deploy_npm ${REF_NAME#v}")
+}
+
function release {
(cd bb.js && ./bootstrap.sh release)
release_bb_avm_sim
+ release_cdb
}
-export -f generate_bb_avm_sim_package copy_bb_avm_sim_native copy_bb_avm_sim_cross
-export -f build_bb_js build_bb_avm_sim build cross_copy_bb_js cross_copy_bb_avm_sim release
+export -f generate_bb_avm_sim_package copy_bb_avm_sim_native copy_bb_avm_sim_cross generate_cdb_package generate_packages
+export -f build_bb_js build_bb_avm_sim build_cdb build cross_copy_bb_js cross_copy_bb_avm_sim release release_cdb
case "$cmd" in
"")
diff --git a/barretenberg/ts/package.json b/barretenberg/ts/package.json
index e5eb74a741d1..9f136dbfcf4c 100644
--- a/barretenberg/ts/package.json
+++ b/barretenberg/ts/package.json
@@ -9,7 +9,8 @@
"workspaces": [
"bb.js",
"bb-avm-sim",
- "bb-avm-sim/packages/*"
+ "bb-avm-sim/packages/*",
+ "cdb"
],
"resolutions": {
"@aztec/ipc-runtime": "portal:../../ipc-runtime/ts"
diff --git a/barretenberg/ts/yarn.lock b/barretenberg/ts/yarn.lock
index 12446106f22f..4b72d80ecffa 100644
--- a/barretenberg/ts/yarn.lock
+++ b/barretenberg/ts/yarn.lock
@@ -102,6 +102,17 @@ __metadata:
languageName: unknown
linkType: soft
+"@aztec/cdb@workspace:cdb":
+ version: 0.0.0-use.local
+ resolution: "@aztec/cdb@workspace:cdb"
+ dependencies:
+ "@types/node": "npm:^22.15.17"
+ msgpackr: "npm:^1.11.2"
+ tslib: "npm:^2.4.0"
+ typescript: "npm:^5.3.3"
+ languageName: unknown
+ linkType: soft
+
"@aztec/ipc-runtime@portal:../../ipc-runtime/ts::locator=%40aztec%2Fbarretenberg-ts-packages%40workspace%3A.":
version: 0.0.0-use.local
resolution: "@aztec/ipc-runtime@portal:../../ipc-runtime/ts::locator=%40aztec%2Fbarretenberg-ts-packages%40workspace%3A."
diff --git a/ipc-codegen/README.md b/ipc-codegen/README.md
index 2e53e7b3736d..3cf0e6e79f25 100644
--- a/ipc-codegen/README.md
+++ b/ipc-codegen/README.md
@@ -102,7 +102,7 @@ node --experimental-strip-types --experimental-transform-types --no-warnings \
|---|---|
| `--server` | Emit server dispatch (matches request name to handler, deserialises, calls handler, serialises response). Pair it with an `ipc::IpcServer` from ipc-runtime. |
| `--client` | Emit a typed client class/struct with one method per command. Pair it with an `ipc::IpcClient` (C++) or the equivalent Rust/Zig/TS binding. |
-| `--package
` | TS only. Emit a complete package wrapper around the generated async client. The wrapper launches a native service binary, connects over UDS or SHM, and resolves the binary from an override path, environment variable, installed arch package, or local `build//` directory. |
+| `--package ` | TS only. Emit a complete package shell. Which of the two shells you get depends on the role flags. With `--client` (or with neither role flag): a wrapper around the generated async client that launches a native service binary, connects over UDS or SHM, and resolves the binary from an override path, environment variable, installed arch package, or local `build//` directory. With `--server` and no `--client`: a pure-TS server binding package instead, holding wire types, the `Handler` interface and `handleRequest`/`dispatch`, plus the schema file at the package root, with no binary launcher and no arch packages. The byte transport is then supplied by the consumer, e.g. `UdsIpcServer` from ipc-runtime. Passing `--server --client` selects the client shell. |
| `--uds` | Rust/Zig only. Copies the `Backend` trait template (and `error.rs` for Rust) into `` so consumers can plug ipc-runtime — or any custom transport — behind the generated client. The flag name is historical: the trait is transport-agnostic. |
| `--ffi` | Rust/Zig only. Adds the `ffi_backend` template (a thin wrapper exposing the generated client over a C ABI for embedding in other languages). |
@@ -131,11 +131,11 @@ flags below are only for legacy positional schemas, which have no `service`.
|---|---|
| `--curve-constants` | TS only. Also emit `curve_constants.ts` with bn254/grumpkin/secp moduli & generators for schemas that need curve constants. |
| `--skeleton ` | One-shot scaffolding: writes a `_handlers.{ts,rs,zig,cpp}` stub, `main`, and a build file into `` if they don't already exist. Skipped on subsequent runs. |
-| `--package-name ` | TS package mode only. Package name to write into the generated wrapper `package.json`. |
-| `--binary-name ` | TS package mode only. Native service binary name to launch. |
-| `--binary-env-var ` | TS package mode only. Environment variable that can override the binary path. Defaults to `_PATH`. |
-| `--package-transports ` | TS package mode only. Comma-separated transports supported by the generated wrapper. |
-| `--ipc-runtime-dependency ` | TS package mode only. Dependency spec for `@aztec/ipc-runtime`, e.g. a release version or local `file:` dependency in examples. |
+| `--package-name ` | TS package mode only. Package name to write into the generated `package.json`. |
+| `--binary-name ` | Client package shell only; ignored by the server shell. Native service binary name to launch. |
+| `--binary-env-var ` | Client package shell only; ignored by the server shell. Environment variable that can override the binary path. Defaults to `_PATH`. |
+| `--package-transports ` | Client package shell only; ignored by the server shell. Comma-separated transports supported by the generated wrapper. |
+| `--ipc-runtime-dependency ` | Client package shell only; ignored by the server shell. Dependency spec for `@aztec/ipc-runtime`, e.g. a release version or local `file:` dependency in examples. |
## Worked examples
diff --git a/ipc-codegen/src/generate.ts b/ipc-codegen/src/generate.ts
index e6d146522013..f6f3b7ac400e 100644
--- a/ipc-codegen/src/generate.ts
+++ b/ipc-codegen/src/generate.ts
@@ -25,7 +25,7 @@ import {
rmSync,
} from "fs";
import { execSync } from "child_process";
-import { dirname, join, resolve } from "path";
+import { basename, dirname, join, resolve } from "path";
import { fileURLToPath } from "url";
import {
SchemaVisitor,
@@ -38,6 +38,7 @@ import { TypeScriptCodegen } from "./typescript_codegen.ts";
import {
defaultBinaryEnvVar,
TypeScriptPackageCodegen,
+ TypeScriptServerPackageCodegen,
} from "./typescript_package_codegen.ts";
import { RustCodegen } from "./rust_codegen.ts";
import { ZigCodegen } from "./zig_codegen.ts";
@@ -85,7 +86,10 @@ Required:
Optional:
--server Generate server dispatch
--client Generate client
- --package Generate a TS package shell around a spawned IPC service (ts only)
+ --package Generate a TS package shell around a spawned IPC service (ts only).
+ With --server and no --client, generates a server binding
+ package instead: wire types + Handler/dispatch + the schema
+ file, no binary or arch packages
--package-name TS package name for --package
--binary-name Native service binary name for --package
--binary-env-var Env var overriding the binary path for --package
@@ -357,6 +361,9 @@ function generate(args: Args) {
switch (args.lang) {
case "ts": {
+ // --package with --server (and no --client) means a server binding
+ // package: no spawned binary, so no client APIs or arch packages.
+ const serverPackage = !!args.packageDir && args.server && !args.client;
const gen = new TypeScriptCodegen({
stripMethodPrefix: stripMethodPrefix ? prefix : undefined,
});
@@ -366,7 +373,7 @@ function generate(args: Args) {
// No transport template copy — consumers import UdsIpcServer from
// '@aztec/ipc-runtime' (or hand a compatible byte-handler in).
}
- if (args.client || args.packageDir) {
+ if (args.client || (args.packageDir && !serverPackage)) {
writeFile("async.ts", gen.generateAsyncApi(compiled));
writeFile("sync.ts", gen.generateSyncApi(compiled));
// No transport template copy — consumers import IpcClient from
@@ -377,25 +384,8 @@ function generate(args: Args) {
}
if (args.packageDir) {
const packageDir = resolve(args.packageDir);
- const binaryName =
- args.binaryName || toSnakeCase(prefix).replace(/_/g, "-");
const packageName =
args.packageName || `${toSnakeCase(prefix).replace(/_/g, "-")}-ipc`;
- const packageGen = new TypeScriptPackageCodegen({
- prefix,
- packageName,
- binaryName,
- binaryEnvVar: args.binaryEnvVar || defaultBinaryEnvVar(binaryName),
- ipcRuntimeDependency: args.ipcRuntimeDependency,
- transports: args.packageTransports
- .split(",")
- .map((t) => t.trim())
- .filter(Boolean),
- ipcPathArgs: args.packageIpcPathArgs
- .split(",")
- .map((arg) => arg.trim())
- .filter(Boolean),
- });
const writePackage = (
name: string,
content: string,
@@ -413,22 +403,55 @@ function generate(args: Args) {
}
console.log(` ${path} (package)`);
};
- writePackage("package.json", packageGen.generatePackageJson());
- writePackage("tsconfig.json", packageGen.generateTsconfig());
- writePackage("README.md", packageGen.generateReadme());
- writePackage("src/index.ts", packageGen.generateIndex());
- writePackage("src/platform.ts", packageGen.generatePlatform());
- if (binaryName) {
- writePackage("src/bin.ts", packageGen.generateBin());
- }
- for (const manifest of packageGen.generateArchPackageManifests()) {
- writePackage(manifest.path, manifest.content);
+ if (serverPackage) {
+ const schemaFileName = basename(absSchema);
+ const packageGen = new TypeScriptServerPackageCodegen({
+ prefix,
+ packageName,
+ schemaFileName,
+ });
+ writePackage("package.json", packageGen.generatePackageJson());
+ writePackage("tsconfig.json", packageGen.generateTsconfig());
+ writePackage("README.md", packageGen.generateReadme());
+ writePackage("src/index.ts", packageGen.generateIndex());
+ // Ship the schema itself: it is the wire contract the package was
+ // generated from, and lets consumers regenerate bindings.
+ writePackage(schemaFileName, readFileSync(absSchema, "utf-8"));
+ } else {
+ const binaryName =
+ args.binaryName || toSnakeCase(prefix).replace(/_/g, "-");
+ const packageGen = new TypeScriptPackageCodegen({
+ prefix,
+ packageName,
+ binaryName,
+ binaryEnvVar: args.binaryEnvVar || defaultBinaryEnvVar(binaryName),
+ ipcRuntimeDependency: args.ipcRuntimeDependency,
+ transports: args.packageTransports
+ .split(",")
+ .map((t) => t.trim())
+ .filter(Boolean),
+ ipcPathArgs: args.packageIpcPathArgs
+ .split(",")
+ .map((arg) => arg.trim())
+ .filter(Boolean),
+ });
+ writePackage("package.json", packageGen.generatePackageJson());
+ writePackage("tsconfig.json", packageGen.generateTsconfig());
+ writePackage("README.md", packageGen.generateReadme());
+ writePackage("src/index.ts", packageGen.generateIndex());
+ writePackage("src/platform.ts", packageGen.generatePlatform());
+ if (binaryName) {
+ writePackage("src/bin.ts", packageGen.generateBin());
+ }
+ for (const manifest of packageGen.generateArchPackageManifests()) {
+ writePackage(manifest.path, manifest.content);
+ }
+ writePackage(
+ "scripts/prepare_arch_packages.sh",
+ packageGen.generatePrepareArchPackagesScript(),
+ { executable: true },
+ );
}
- writePackage(
- "scripts/prepare_arch_packages.sh",
- packageGen.generatePrepareArchPackagesScript(),
- { executable: true },
- );
}
break;
}
diff --git a/ipc-codegen/src/typescript_package_codegen.ts b/ipc-codegen/src/typescript_package_codegen.ts
index 32f4238447f3..5f0c3824d7c4 100644
--- a/ipc-codegen/src/typescript_package_codegen.ts
+++ b/ipc-codegen/src/typescript_package_codegen.ts
@@ -31,9 +31,7 @@ function envName(binaryName: string): string {
}
function packageStem(packageName: string): string {
- return packageName.startsWith("@")
- ? packageName.split("/")[1]!
- : packageName;
+ return packageName.startsWith("@") ? packageName.split("/")[1]! : packageName;
}
function archPackageNames(packageName: string): Record {
@@ -49,13 +47,133 @@ const ARCH_PACKAGES = [
{ buildDir: "amd64-linux", suffix: "linux-x64", os: "linux", cpu: "x64" },
{ buildDir: "arm64-linux", suffix: "linux-arm64", os: "linux", cpu: "arm64" },
{ buildDir: "amd64-macos", suffix: "darwin-x64", os: "darwin", cpu: "x64" },
- { buildDir: "arm64-macos", suffix: "darwin-arm64", os: "darwin", cpu: "arm64" },
+ {
+ buildDir: "arm64-macos",
+ suffix: "darwin-arm64",
+ os: "darwin",
+ cpu: "arm64",
+ },
] as const;
export function defaultBinaryEnvVar(binaryName: string): string {
return envName(binaryName);
}
+function generatePackageTsconfig(): string {
+ return (
+ JSON.stringify(
+ {
+ compilerOptions: {
+ target: "ES2022",
+ module: "NodeNext",
+ moduleResolution: "NodeNext",
+ declaration: true,
+ declarationMap: true,
+ composite: true,
+ outDir: "dest",
+ rootDir: "src",
+ tsBuildInfoFile: ".tsbuildinfo",
+ strict: true,
+ esModuleInterop: true,
+ skipLibCheck: true,
+ forceConsistentCasingInFileNames: true,
+ },
+ include: ["src/**/*.ts"],
+ },
+ null,
+ 2,
+ ) + "\n"
+ );
+}
+
+export interface TypeScriptServerPackageOptions {
+ prefix: string;
+ packageName: string;
+ /** Basename of the schema file shipped at the package root (the wire contract). */
+ schemaFileName: string;
+}
+
+/**
+ * Package shell for a server-side binding package: pure generated TS (wire
+ * types + Handler/dispatch) plus the schema itself. No binary, no arch
+ * packages — the transport is provided by the consumer (e.g. UdsIpcServer
+ * from @aztec/ipc-runtime).
+ */
+export class TypeScriptServerPackageCodegen {
+ constructor(private opts: TypeScriptServerPackageOptions) {}
+
+ generatePackageJson(): string {
+ const pkg = {
+ name: this.opts.packageName,
+ version: "0.1.0",
+ type: "module",
+ exports: {
+ ".": {
+ types: "./dest/index.d.ts",
+ default: "./dest/index.js",
+ },
+ // Expose the schema for consumers that want to regenerate bindings
+ // or inspect the wire contract.
+ [`./${this.opts.schemaFileName}`]: `./${this.opts.schemaFileName}`,
+ },
+ files: ["dest/", this.opts.schemaFileName, "README.md"],
+ scripts: {
+ clean: "rm -rf dest .tsbuildinfo",
+ build: "tsc -p tsconfig.json",
+ },
+ dependencies: {
+ msgpackr: "^1.11.2",
+ tslib: "^2.4.0",
+ },
+ devDependencies: {
+ "@types/node": "^22.15.17",
+ typescript: "^5.3.3",
+ },
+ };
+ return JSON.stringify(pkg, null, 2) + "\n";
+ }
+
+ generateTsconfig(): string {
+ return generatePackageTsconfig();
+ }
+
+ generateIndex(): string {
+ return `export * from './generated/api_types.js';
+export * from './generated/server.js';
+`;
+ }
+
+ generateReadme(): string {
+ return `# ${this.opts.packageName}
+
+Generated TypeScript server bindings for the ${this.opts.prefix} IPC service:
+wire types, the \`Handler\` interface, and \`handleRequest\`/\`dispatch\`. The
+byte transport is provided by the consumer — e.g. \`UdsIpcServer\` from
+\`@aztec/ipc-runtime\`.
+
+\`\`\`ts
+import { UdsIpcServer } from '@aztec/ipc-runtime';
+import { type Handler, handleRequest } from '${this.opts.packageName}';
+
+const handler: Handler = /* implement the generated interface */;
+const server = await UdsIpcServer.listen(socketPath, (_clientId, request) =>
+ handleRequest(handler, request),
+);
+\`\`\`
+
+The schema this package was generated from ships at
+\`${this.opts.packageName}/${this.opts.schemaFileName}\`; its hash is exported
+as \`SCHEMA_HASH\`.
+
+## Build
+
+The whole package (shell and \`src/\`) is generated by ipc-codegen; build
+through the owning project's \`./bootstrap.sh\`, which regenerates and then
+runs \`yarn build\`.
+`;
+ }
+}
+
export class TypeScriptPackageCodegen {
constructor(private opts: TypeScriptPackageOptions) {}
@@ -92,7 +210,10 @@ export class TypeScriptPackageCodegen {
tslib: "^2.4.0",
},
optionalDependencies: Object.fromEntries(
- Object.values(archPackages).map((packageName) => [packageName, "0.1.0"]),
+ Object.values(archPackages).map((packageName) => [
+ packageName,
+ "0.1.0",
+ ]),
),
devDependencies: {
"@types/node": "^22.15.17",
@@ -149,28 +270,7 @@ process.exit(result.status ?? 1);
}
generateTsconfig(): string {
- return JSON.stringify(
- {
- compilerOptions: {
- target: "ES2022",
- module: "NodeNext",
- moduleResolution: "NodeNext",
- declaration: true,
- declarationMap: true,
- composite: true,
- outDir: "dest",
- rootDir: "src",
- tsBuildInfoFile: ".tsbuildinfo",
- strict: true,
- esModuleInterop: true,
- skipLibCheck: true,
- forceConsistentCasingInFileNames: true,
- },
- include: ["src/**/*.ts"],
- },
- null,
- 2,
- ) + "\n";
+ return generatePackageTsconfig();
}
generateIndex(): string {
@@ -229,12 +329,14 @@ class SpawnedBackend implements IpcClientAsync {
private exitPromise: Promise,
private logPath: string | undefined,
) {
-${supportsShm
- ? ` // Detect unexpected server death. Over SHM there is no connection to break,
+${
+ supportsShm
+ ? ` // Detect unexpected server death. Over SHM there is no connection to break,
// so without this an in-flight call waits forever for a reply that will
// never arrive. Reject in-flight calls and point at the log file.`
- : ` // Detect unexpected server death and reject in-flight calls with the
- // child log path included in the error.`}
+ : ` // Detect unexpected server death and reject in-flight calls with the
+ // child log path included in the error.`
+}
this.child.on('exit', (code, signal) => {
if (this.destroying) {
return;
@@ -362,7 +464,9 @@ async function connectClient(
if (transport === 'uds') {
return await UdsIpcClient.connect(ipcPath, { connectTimeoutMs: Math.max(1, deadline - Date.now()) });
}
-${supportsShm ? ` if (transport === 'shm') {
+${
+ supportsShm
+ ? ` if (transport === 'shm') {
return createNapiShmAsyncClient(ipcPath.replace(/\\.shm$/, ''), {
// Pass clientId through as-is: when unset, the client self-allocates a
// free producer slot (don't default to 0, which aliases every client).
@@ -370,7 +474,9 @@ ${supportsShm ? ` if (transport === 'shm') {
customAddonPath: options.napiPath,
});
}
-` : ""} throw new Error('Unsupported transport: ' + transport);
+`
+ : ""
+} throw new Error('Unsupported transport: ' + transport);
} catch (err) {
lastError = err;
await new Promise(resolve => setTimeout(resolve, 50));
@@ -385,7 +491,9 @@ function cleanupIpcPath(ipcPath: string, transport: ${serviceTransport}) {
if (transport === 'uds' && existsSync(ipcPath)) {
unlinkSync(ipcPath);
}
-${supportsShm ? ` if (transport === 'shm') {
+${
+ supportsShm
+ ? ` if (transport === 'shm') {
const shmName = ipcPath.replace(/\\.shm$/, '');
for (const suffix of ['_request', '_response']) {
const shmPath = '/dev/shm/' + shmName + suffix;
@@ -394,7 +502,9 @@ ${supportsShm ? ` if (transport === 'shm') {
}
}
}
-` : ""}
+`
+ : ""
+}
} catch {}
}
diff --git a/release-image/Dockerfile.base.dockerignore b/release-image/Dockerfile.base.dockerignore
index b81140f52f7b..3eebd4d0750b 100644
--- a/release-image/Dockerfile.base.dockerignore
+++ b/release-image/Dockerfile.base.dockerignore
@@ -3,6 +3,7 @@
!/barretenberg/ts/bb.js/package.json
!/barretenberg/ts/bb-avm-sim/package.json
!/barretenberg/ts/bb-avm-sim/packages/*/package.json
+!/barretenberg/ts/cdb/package.json
!/noir/packages/*/package.json
!/wsdb/ts/package.json
!/wsdb/ts/packages/*/package.json
diff --git a/release-image/Dockerfile.dockerignore b/release-image/Dockerfile.dockerignore
index 573a36a3c80c..16f269333919 100644
--- a/release-image/Dockerfile.dockerignore
+++ b/release-image/Dockerfile.dockerignore
@@ -9,6 +9,8 @@
!/barretenberg/ts/bb-avm-sim/build/
!/barretenberg/ts/bb-avm-sim/package.json
!/barretenberg/ts/bb-avm-sim/packages/
+!/barretenberg/ts/cdb/dest/
+!/barretenberg/ts/cdb/package.json
!/ipc-runtime/ts/dest/
!/ipc-runtime/ts/package.json
!/wsdb/ts/dest/
diff --git a/yarn-project/.gitignore b/yarn-project/.gitignore
index df4f3a3b8951..c1a513244107 100644
--- a/yarn-project/.gitignore
+++ b/yarn-project/.gitignore
@@ -61,7 +61,6 @@ cli-wallet/test/data
cli/src/config/generated
ethereum/src/generated
slasher/src/generated
-simulator/src/public/cdb/generated
.claude/settings.local.json
.yarn/*
diff --git a/yarn-project/.prettierignore b/yarn-project/.prettierignore
index 4900b8cce190..219400e4e966 100644
--- a/yarn-project/.prettierignore
+++ b/yarn-project/.prettierignore
@@ -20,5 +20,4 @@ noir-protocol-circuits-types/src/vk_tree.ts
noir-protocol-circuits-types/src/client_artifacts_helper.ts
constants/src/constants.gen.ts
cli/src/config/generated
-simulator/src/public/cdb/generated
sqlite3mc-wasm/vendor/
diff --git a/yarn-project/bootstrap.sh b/yarn-project/bootstrap.sh
index 3322dce01594..37251ee176ea 100755
--- a/yarn-project/bootstrap.sh
+++ b/yarn-project/bootstrap.sh
@@ -141,7 +141,6 @@ function compile_all {
noir-protocol-circuits-types \
protocol-contracts \
pxe \
- simulator \
standard-contracts
cat joblog.txt
diff --git a/yarn-project/package.json b/yarn-project/package.json
index 0c9a4aed3a63..1b25fbea4fe5 100644
--- a/yarn-project/package.json
+++ b/yarn-project/package.json
@@ -90,6 +90,7 @@
"@aztec/bb-avm-sim-linux-arm64": "portal:../barretenberg/ts/bb-avm-sim/packages/bb-avm-sim-linux-arm64",
"@aztec/bb-avm-sim-linux-x64": "portal:../barretenberg/ts/bb-avm-sim/packages/bb-avm-sim-linux-x64",
"@aztec/bb.js": "portal:../barretenberg/ts/bb.js",
+ "@aztec/cdb": "portal:../barretenberg/ts/cdb",
"@aztec/ipc-runtime": "portal:../ipc-runtime/ts",
"@aztec/l1-artifacts": "portal:../l1-contracts/l1-artifacts",
"@aztec/wsdb": "portal:../wsdb/ts",
diff --git a/yarn-project/simulator/eslint.config.js b/yarn-project/simulator/eslint.config.js
index 1069d0e36402..28178e9148da 100644
--- a/yarn-project/simulator/eslint.config.js
+++ b/yarn-project/simulator/eslint.config.js
@@ -1,9 +1,6 @@
import config from '@aztec/foundation/eslint';
-import { globalIgnores } from 'eslint/config';
-
export default [
- globalIgnores(['src/public/cdb/generated/**']),
...config,
{
files: ['src/public/avm/testing/account_proof_fetcher.ts'],
diff --git a/yarn-project/simulator/package.json b/yarn-project/simulator/package.json
index d00ef45ce210..0c38b56fbabd 100644
--- a/yarn-project/simulator/package.json
+++ b/yarn-project/simulator/package.json
@@ -19,9 +19,8 @@
"build": "yarn clean && ../scripts/tsc.sh",
"build:dev": "../scripts/tsc.sh --watch",
"clean": "rm -rf ./dest .tsbuildinfo",
- "generate": "node --experimental-strip-types --experimental-transform-types --no-warnings ../../ipc-codegen/src/generate.ts --schema ../../barretenberg/cpp/src/barretenberg/cdb/cdb_schema.json --lang ts --server --out src/public/cdb/generated",
"test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --passWithNoTests --maxWorkers=${JEST_MAX_WORKERS:-8}",
- "build:fuzzer": "yarn clean && yarn generate && ../scripts/tsc.sh"
+ "build:fuzzer": "yarn clean && ../scripts/tsc.sh"
},
"inherits": [
"../package.common.json"
@@ -65,6 +64,7 @@
},
"dependencies": {
"@aztec/bb-avm-sim": "0.1.0",
+ "@aztec/cdb": "0.1.0",
"@aztec/constants": "workspace:^",
"@aztec/foundation": "workspace:^",
"@aztec/ipc-runtime": "0.1.0",
diff --git a/yarn-project/simulator/src/public/cdb_ipc_server.ts b/yarn-project/simulator/src/public/cdb_ipc_server.ts
index 72116bd746e7..e0017c6d9694 100644
--- a/yarn-project/simulator/src/public/cdb_ipc_server.ts
+++ b/yarn-project/simulator/src/public/cdb_ipc_server.ts
@@ -6,6 +6,26 @@
* server. This class only implements the generated handler interface and routes requests to
* PublicContractsDB instances by fork ID.
*/
+import {
+ type CdbAddContracts,
+ type CdbAddContractsResponse,
+ type CdbCommitCheckpoint,
+ type CdbCommitCheckpointResponse,
+ type CdbCreateCheckpoint,
+ type CdbCreateCheckpointResponse,
+ type CdbGetBytecodeCommitment,
+ type CdbGetBytecodeCommitmentResponse,
+ type CdbGetContractClass,
+ type CdbGetContractClassResponse,
+ type CdbGetContractInstance,
+ type CdbGetContractInstanceResponse,
+ type CdbGetDebugFunctionName,
+ type CdbGetDebugFunctionNameResponse,
+ type Handler as CdbHandler,
+ type CdbRevertCheckpoint,
+ type CdbRevertCheckpointResponse,
+ handleRequest,
+} from '@aztec/cdb';
import { Fr } from '@aztec/foundation/curves/bn254';
import { type Logger, createLogger } from '@aztec/foundation/log';
import { UdsIpcServer } from '@aztec/ipc-runtime';
@@ -18,25 +38,6 @@ import * as os from 'node:os';
import * as path from 'node:path';
import { threadId } from 'node:worker_threads';
-import type {
- CdbAddContracts,
- CdbAddContractsResponse,
- CdbCommitCheckpoint,
- CdbCommitCheckpointResponse,
- CdbCreateCheckpoint,
- CdbCreateCheckpointResponse,
- CdbGetBytecodeCommitment,
- CdbGetBytecodeCommitmentResponse,
- CdbGetContractClass,
- CdbGetContractClassResponse,
- CdbGetContractInstance,
- CdbGetContractInstanceResponse,
- CdbGetDebugFunctionName,
- CdbGetDebugFunctionNameResponse,
- CdbRevertCheckpoint,
- CdbRevertCheckpointResponse,
-} from './cdb/generated/api_types.js';
-import { type Handler as CdbHandler, handleRequest } from './cdb/generated/server.js';
import type { PublicContractsDB } from './public_db_sources.js';
const encoder = new Encoder({ useRecords: false });
diff --git a/yarn-project/yarn.lock b/yarn-project/yarn.lock
index ffd7d41c6b66..4ddb86792b3d 100644
--- a/yarn-project/yarn.lock
+++ b/yarn-project/yarn.lock
@@ -1117,6 +1117,15 @@ __metadata:
languageName: unknown
linkType: soft
+"@aztec/cdb@portal:../barretenberg/ts/cdb::locator=%40aztec%2Faztec3-packages%40workspace%3A.":
+ version: 0.0.0-use.local
+ resolution: "@aztec/cdb@portal:../barretenberg/ts/cdb::locator=%40aztec%2Faztec3-packages%40workspace%3A."
+ dependencies:
+ msgpackr: "npm:^1.11.2"
+ tslib: "npm:^2.4.0"
+ languageName: node
+ linkType: soft
+
"@aztec/cli-wallet@workspace:cli-wallet":
version: 0.0.0-use.local
resolution: "@aztec/cli-wallet@workspace:cli-wallet"
@@ -2062,6 +2071,7 @@ __metadata:
resolution: "@aztec/simulator@workspace:simulator"
dependencies:
"@aztec/bb-avm-sim": "npm:0.1.0"
+ "@aztec/cdb": "npm:0.1.0"
"@aztec/constants": "workspace:^"
"@aztec/foundation": "workspace:^"
"@aztec/ipc-runtime": "npm:0.1.0"