diff --git a/yarn-project/aztec/src/bin/index.ts b/yarn-project/aztec/src/bin/index.ts index 55294c642f0e..b032f9d64714 100644 --- a/yarn-project/aztec/src/bin/index.ts +++ b/yarn-project/aztec/src/bin/index.ts @@ -12,8 +12,11 @@ import { createConsoleLogger, createLogger } from '@aztec/foundation/log'; import { Command } from 'commander'; +import { NETWORK_FLAG, aztecStartOptions } from '../cli/aztec_start_options.js'; +import { enrichEnvironmentWithChainConfig } from '../cli/chain_l2_config.js'; import { injectAztecCommands } from '../cli/index.js'; import { getCliVersion } from '../cli/release_version.js'; +import { addOptions } from '../cli/util.js'; const userLog = createConsoleLogger(); const debugLogger = createLogger('cli'); @@ -26,6 +29,17 @@ async function main() { process.once('SIGINT', shutdown); process.once('SIGTERM', shutdown); + // We create a temp command object to detect the presence of the network option + // If it has been given then we enrich the environment with the chain config + const tempCmd = new Command('aztec').allowUnknownOption(); + addOptions(tempCmd, aztecStartOptions['NETWORK']); + tempCmd.parse(process.argv); + const networkValue = tempCmd.getOptionValue(NETWORK_FLAG); + + if (networkValue !== undefined) { + await enrichEnvironmentWithChainConfig(networkValue); + } + const cliVersion = getCliVersion(); let program = new Command('aztec'); program.description('Aztec command line interface').version(cliVersion); diff --git a/yarn-project/aztec/src/cli/aztec_start_action.ts b/yarn-project/aztec/src/cli/aztec_start_action.ts index 9ba1f849d256..c4b7c8e506e3 100644 --- a/yarn-project/aztec/src/cli/aztec_start_action.ts +++ b/yarn-project/aztec/src/cli/aztec_start_action.ts @@ -11,7 +11,6 @@ import { getOtelJsonRpcPropagationMiddleware } from '@aztec/telemetry-client'; import { createSandbox } from '../sandbox/index.js'; import { github, splash } from '../splash.js'; -import { enrichEnvironmentWithChainConfig } from './chain_l2_config.js'; import { getCliVersion } from './release_version.js'; import { extractNamespacedOptions, installSignalHandlers } from './util.js'; import { getVersions } from './versioning.js'; @@ -51,10 +50,6 @@ export async function aztecStart(options: any, userLog: LogFn, debugLogger: Logg userLog(`Not exposing PXE API through JSON-RPC server`); } } else { - // If a network is specified, enrich the environment with the chain config - if (options.network) { - await enrichEnvironmentWithChainConfig(options.network); - } if (options.node) { const { startNode } = await import('./cmds/start_node.js'); ({ config } = await startNode(options, signalHandlers, services, adminServices, userLog)); diff --git a/yarn-project/aztec/src/cli/aztec_start_options.ts b/yarn-project/aztec/src/cli/aztec_start_options.ts index ee7e435252f2..852176c80d75 100644 --- a/yarn-project/aztec/src/cli/aztec_start_options.ts +++ b/yarn-project/aztec/src/cli/aztec_start_options.ts @@ -65,11 +65,13 @@ export const universalOptions = [ 'dataStoreMapSizeKb', ]; +export const NETWORK_FLAG = 'network'; + // Define categories and options export const aztecStartOptions: { [key: string]: AztecStartOption[] } = { NETWORK: [ { - flag: '--network ', + flag: `--${NETWORK_FLAG} `, description: 'Network to run Aztec on', defaultValue: undefined, envVar: 'NETWORK', diff --git a/yarn-project/aztec/src/cli/chain_l2_config.ts b/yarn-project/aztec/src/cli/chain_l2_config.ts index bb7ca1fba3c5..97718e5b6ffc 100644 --- a/yarn-project/aztec/src/cli/chain_l2_config.ts +++ b/yarn-project/aztec/src/cli/chain_l2_config.ts @@ -47,7 +47,7 @@ export const alphaTestnetL2ChainConfig: L2ChainConfig = { aztecEpochDuration: 32, aztecProofSubmissionWindow: 64, testAccounts: true, - sponsoredFPC: true, + sponsoredFPC: false, p2pEnabled: true, p2pBootstrapNodes: [], registryAddress: '0xad85d55a4bbef35e95396191c22903aa717edf1c',