diff --git a/yarn-project/aztec/src/cli/aztec_start_action.ts b/yarn-project/aztec/src/cli/aztec_start_action.ts index 1d758b227682..f7c3c7c5ff07 100644 --- a/yarn-project/aztec/src/cli/aztec_start_action.ts +++ b/yarn-project/aztec/src/cli/aztec_start_action.ts @@ -23,14 +23,14 @@ export async function aztecStart(options: any, userLog: LogFn, debugLogger: Logg const signalHandlers: Array<() => Promise> = []; const services: NamespacedApiHandlers = {}; const adminServices: NamespacedApiHandlers = {}; + const packageVersion = getPackageVersion(); let config: ChainConfig | undefined = undefined; if (options.localNetwork) { - const cliVersion = getPackageVersion() ?? 'unknown'; const localNetwork = extractNamespacedOptions(options, 'local-network'); localNetwork.testAccounts = true; userLog(`${splash}\n${github}\n\n`); - userLog(`Setting up Aztec local network ${cliVersion}, please stand by...`); + userLog(`Setting up Aztec local network ${packageVersion ?? 'unknown'}, please stand by...`); const { node, stop } = await createLocalNetwork( { @@ -90,13 +90,14 @@ export async function aztecStart(options: any, userLog: LogFn, debugLogger: Logg installSignalHandlers(debugLogger.info, signalHandlers); const versions = getVersions(config); + const versioningOpts = { packageVersion }; // Start the main JSON-RPC server if (Object.entries(services).length > 0) { const rpcServer = createNamespacedSafeJsonRpcServer(services, { http200OnError: false, log: debugLogger, - middlewares: [getOtelJsonRpcPropagationMiddleware(), getVersioningMiddleware(versions)], + middlewares: [getOtelJsonRpcPropagationMiddleware(), getVersioningMiddleware(versions, versioningOpts)], maxBatchSize: options.rpcMaxBatchSize, maxBodySizeBytes: options.rpcMaxBodySize, }); @@ -106,7 +107,7 @@ export async function aztecStart(options: any, userLog: LogFn, debugLogger: Logg // If there are any admin services, start a separate JSON-RPC server for them if (Object.entries(adminServices).length > 0) { - const adminMiddlewares = [getOtelJsonRpcPropagationMiddleware(), getVersioningMiddleware(versions)]; + const adminMiddlewares = [getOtelJsonRpcPropagationMiddleware(), getVersioningMiddleware(versions, versioningOpts)]; // Resolve the admin API key (auto-generated and persisted, or opt-out) const apiKeyResolution = await resolveAdminApiKey( diff --git a/yarn-project/stdlib/src/versioning/versioning.ts b/yarn-project/stdlib/src/versioning/versioning.ts index 86926603f306..32efb4da71de 100644 --- a/yarn-project/stdlib/src/versioning/versioning.ts +++ b/yarn-project/stdlib/src/versioning/versioning.ts @@ -115,7 +115,7 @@ export function validatePartialComponentVersionsMatch( } /** Returns a Koa middleware that injects the versioning info as headers. */ -export function getVersioningMiddleware(versions: Partial) { +export function getVersioningMiddleware(versions: Partial, opts?: { packageVersion?: string }) { return async (ctx: Koa.Context, next: () => Promise) => { try { await next(); @@ -128,6 +128,9 @@ export function getVersioningMiddleware(versions: Partial) { ctx.set(`x-aztec-${key}`, value.toString()); } } + if (opts?.packageVersion) { + ctx.set('x-aztec-packageVersion', opts.packageVersion); + } } }; }