diff --git a/spartan/scripts/test_kind.sh b/spartan/scripts/test_kind.sh index 705aec4b735f..59a3902c9de6 100755 --- a/spartan/scripts/test_kind.sh +++ b/spartan/scripts/test_kind.sh @@ -126,6 +126,7 @@ export NAMESPACE="$namespace" export CONTAINER_PXE_PORT="8081" export CONTAINER_ETHEREUM_PORT="8545" export CONTAINER_NODE_PORT="8080" +export CONTAINER_NODE_ADMIN_PORT="8880" export CONTAINER_SEQUENCER_PORT="8080" export CONTAINER_PROVER_NODE_PORT="8080" export CONTAINER_METRICS_PORT="80" diff --git a/yarn-project/aztec-node/src/aztec-node/server.ts b/yarn-project/aztec-node/src/aztec-node/server.ts index f912fb54f54b..ebc2ad8dc046 100644 --- a/yarn-project/aztec-node/src/aztec-node/server.ts +++ b/yarn-project/aztec-node/src/aztec-node/server.ts @@ -50,7 +50,12 @@ import type { } from '@aztec/stdlib/contract'; import type { GasFees } from '@aztec/stdlib/gas'; import { computePublicDataTreeLeafSlot, siloNullifier } from '@aztec/stdlib/hash'; -import type { AztecNode, GetContractClassLogsResponse, GetPublicLogsResponse } from '@aztec/stdlib/interfaces/client'; +import type { + AztecNode, + AztecNodeAdmin, + GetContractClassLogsResponse, + GetPublicLogsResponse, +} from '@aztec/stdlib/interfaces/client'; import { type ClientProtocolCircuitVerifier, type L2LogsSource, @@ -93,7 +98,7 @@ import { NodeMetrics } from './node_metrics.js'; /** * The aztec node. */ -export class AztecNodeService implements AztecNode, Traceable { +export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable { private packageVersion: string; private metrics: NodeMetrics; diff --git a/yarn-project/aztec/src/cli/aztec_start_action.ts b/yarn-project/aztec/src/cli/aztec_start_action.ts index 0a71e99df596..9f7b0c900c2a 100644 --- a/yarn-project/aztec/src/cli/aztec_start_action.ts +++ b/yarn-project/aztec/src/cli/aztec_start_action.ts @@ -20,6 +20,7 @@ export async function aztecStart(options: any, userLog: LogFn, debugLogger: Logg // list of 'stop' functions to call when process ends const signalHandlers: Array<() => Promise> = []; const services: NamespacedApiHandlers = {}; + const adminServices: NamespacedApiHandlers = {}; let config: ChainConfig | undefined = undefined; if (options.sandbox) { @@ -55,7 +56,7 @@ export async function aztecStart(options: any, userLog: LogFn, debugLogger: Logg } if (options.node) { const { startNode } = await import('./cmds/start_node.js'); - ({ config } = await startNode(options, signalHandlers, services, userLog)); + ({ config } = await startNode(options, signalHandlers, services, adminServices, userLog)); } else if (options.bot) { const { startBot } = await import('./cmds/start_bot.js'); await startBot(options, signalHandlers, services, userLog); @@ -97,6 +98,8 @@ export async function aztecStart(options: any, userLog: LogFn, debugLogger: Logg installSignalHandlers(debugLogger.info, signalHandlers); const versions = getVersions(config); + + // Start the main JSON-RPC server if (Object.entries(services).length > 0) { const rpcServer = createNamespacedSafeJsonRpcServer(services, { http200OnError: false, @@ -106,4 +109,15 @@ export async function aztecStart(options: any, userLog: LogFn, debugLogger: Logg const { port } = await startHttpRpcServer(rpcServer, { port: options.port }); debugLogger.info(`Aztec Server listening on port ${port}`, versions); } + + // If there are any admin services, start a separate JSON-RPC server for them + if (Object.entries(adminServices).length > 0) { + const rpcServer = createNamespacedSafeJsonRpcServer(adminServices, { + http200OnError: false, + log: debugLogger, + middlewares: [getOtelJsonRpcPropagationMiddleware(), getVersioningMiddleware(versions)], + }); + const { port } = await startHttpRpcServer(rpcServer, { port: options.adminPort }); + debugLogger.info(`Aztec Server admin API listening on port ${port}`, versions); + } } diff --git a/yarn-project/aztec/src/cli/aztec_start_options.ts b/yarn-project/aztec/src/cli/aztec_start_options.ts index cfdc8e240bd8..dd0461414d11 100644 --- a/yarn-project/aztec/src/cli/aztec_start_options.ts +++ b/yarn-project/aztec/src/cli/aztec_start_options.ts @@ -97,11 +97,18 @@ export const aztecStartOptions: { [key: string]: AztecStartOption[] } = { API: [ { flag: '--port ', - description: 'Port to run the Aztec Services on on', + description: 'Port to run the Aztec Services on', defaultValue: 8080, envVar: 'AZTEC_PORT', parseVal: val => parseInt(val, 10), }, + { + flag: '--admin-port ', + description: 'Port to run admin APIs of Aztec Services on on', + defaultValue: 8880, + envVar: 'AZTEC_ADMIN_PORT', + parseVal: val => parseInt(val, 10), + }, { flag: '--api-prefix ', description: 'Prefix for API routes on any service that is started', diff --git a/yarn-project/aztec/src/cli/cmds/start_node.ts b/yarn-project/aztec/src/cli/cmds/start_node.ts index b8dbebaae06a..14a63904d42a 100644 --- a/yarn-project/aztec/src/cli/cmds/start_node.ts +++ b/yarn-project/aztec/src/cli/cmds/start_node.ts @@ -3,7 +3,7 @@ import { type AztecNodeConfig, aztecNodeConfigMappings, getConfigEnvVars } from import { NULL_KEY } from '@aztec/ethereum'; import type { NamespacedApiHandlers } from '@aztec/foundation/json-rpc/server'; import type { LogFn } from '@aztec/foundation/log'; -import { AztecNodeApiSchema, type PXE } from '@aztec/stdlib/interfaces/client'; +import { AztecNodeAdminApiSchema, AztecNodeApiSchema, type PXE } from '@aztec/stdlib/interfaces/client'; import { P2PApiSchema } from '@aztec/stdlib/interfaces/server'; import { type TelemetryClientConfig, @@ -22,6 +22,7 @@ export async function startNode( options: any, signalHandlers: (() => Promise)[], services: NamespacedApiHandlers, + adminServices: NamespacedApiHandlers, userLog: LogFn, ): Promise<{ config: AztecNodeConfig }> { // options specifically namespaced with --node.