Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions yarn-project/aztec/src/cli/aztec_start_action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ export async function aztecStart(options: any, userLog: LogFn, debugLogger: Logg
const signalHandlers: Array<() => Promise<void>> = [];
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(
{
Expand Down Expand Up @@ -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,
});
Expand All @@ -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(
Expand Down
5 changes: 4 additions & 1 deletion yarn-project/stdlib/src/versioning/versioning.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export function validatePartialComponentVersionsMatch(
}

/** Returns a Koa middleware that injects the versioning info as headers. */
export function getVersioningMiddleware(versions: Partial<ComponentsVersions>) {
export function getVersioningMiddleware(versions: Partial<ComponentsVersions>, opts?: { packageVersion?: string }) {
return async (ctx: Koa.Context, next: () => Promise<void>) => {
try {
await next();
Expand All @@ -128,6 +128,9 @@ export function getVersioningMiddleware(versions: Partial<ComponentsVersions>) {
ctx.set(`x-aztec-${key}`, value.toString());
}
}
if (opts?.packageVersion) {
ctx.set('x-aztec-packageVersion', opts.packageVersion);
}
}
};
}
Expand Down
Loading