@aztec/aztec 0.0.1-commit.03f7ef2 → 0.0.1-commit.04d373f

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (158) hide show
  1. package/dest/bin/index.js +9 -3
  2. package/dest/cli/admin_api_key_store.d.ts +45 -0
  3. package/dest/cli/admin_api_key_store.d.ts.map +1 -0
  4. package/dest/cli/admin_api_key_store.js +98 -0
  5. package/dest/cli/aztec_start_action.d.ts +1 -1
  6. package/dest/cli/aztec_start_action.d.ts.map +1 -1
  7. package/dest/cli/aztec_start_action.js +80 -22
  8. package/dest/cli/aztec_start_options.d.ts +2 -2
  9. package/dest/cli/aztec_start_options.d.ts.map +1 -1
  10. package/dest/cli/aztec_start_options.js +43 -25
  11. package/dest/cli/cli.d.ts +1 -1
  12. package/dest/cli/cli.d.ts.map +1 -1
  13. package/dest/cli/cli.js +4 -37
  14. package/dest/cli/cmds/compile.d.ts +4 -0
  15. package/dest/cli/cmds/compile.d.ts.map +1 -0
  16. package/dest/cli/cmds/compile.js +166 -0
  17. package/dest/cli/cmds/migrate_ha_db.d.ts +3 -0
  18. package/dest/cli/cmds/migrate_ha_db.d.ts.map +1 -0
  19. package/dest/cli/cmds/migrate_ha_db.js +27 -0
  20. package/dest/cli/cmds/profile.d.ts +4 -0
  21. package/dest/cli/cmds/profile.d.ts.map +1 -0
  22. package/dest/cli/cmds/profile.js +8 -0
  23. package/dest/cli/cmds/profile_flamegraph.d.ts +4 -0
  24. package/dest/cli/cmds/profile_flamegraph.d.ts.map +1 -0
  25. package/dest/cli/cmds/profile_flamegraph.js +52 -0
  26. package/dest/cli/cmds/profile_gates.d.ts +4 -0
  27. package/dest/cli/cmds/profile_gates.d.ts.map +1 -0
  28. package/dest/cli/cmds/profile_gates.js +76 -0
  29. package/dest/cli/cmds/profile_utils.d.ts +18 -0
  30. package/dest/cli/cmds/profile_utils.d.ts.map +1 -0
  31. package/dest/cli/cmds/profile_utils.js +50 -0
  32. package/dest/cli/cmds/standby.d.ts +30 -0
  33. package/dest/cli/cmds/standby.d.ts.map +1 -0
  34. package/dest/cli/cmds/standby.js +97 -0
  35. package/dest/cli/cmds/start_bot.d.ts +3 -3
  36. package/dest/cli/cmds/start_bot.d.ts.map +1 -1
  37. package/dest/cli/cmds/start_bot.js +12 -8
  38. package/dest/cli/cmds/start_node.d.ts +3 -2
  39. package/dest/cli/cmds/start_node.d.ts.map +1 -1
  40. package/dest/cli/cmds/start_node.js +75 -35
  41. package/dest/cli/cmds/start_p2p_bootstrap.d.ts +2 -2
  42. package/dest/cli/cmds/start_p2p_bootstrap.d.ts.map +1 -1
  43. package/dest/cli/cmds/start_p2p_bootstrap.js +1 -2
  44. package/dest/cli/cmds/start_prover_agent.d.ts +1 -1
  45. package/dest/cli/cmds/start_prover_agent.d.ts.map +1 -1
  46. package/dest/cli/cmds/start_prover_agent.js +7 -19
  47. package/dest/cli/cmds/start_prover_broker.d.ts +1 -1
  48. package/dest/cli/cmds/start_prover_broker.d.ts.map +1 -1
  49. package/dest/cli/cmds/start_prover_broker.js +24 -15
  50. package/dest/cli/cmds/start_txe.d.ts +2 -2
  51. package/dest/cli/cmds/start_txe.d.ts.map +1 -1
  52. package/dest/cli/cmds/start_txe.js +6 -5
  53. package/dest/cli/cmds/utils/artifacts.d.ts +21 -0
  54. package/dest/cli/cmds/utils/artifacts.d.ts.map +1 -0
  55. package/dest/cli/cmds/utils/artifacts.js +24 -0
  56. package/dest/cli/cmds/utils/collect_crate_dirs.d.ts +21 -0
  57. package/dest/cli/cmds/utils/collect_crate_dirs.d.ts.map +1 -0
  58. package/dest/cli/cmds/utils/collect_crate_dirs.js +114 -0
  59. package/dest/cli/cmds/utils/needs_recompile.d.ts +10 -0
  60. package/dest/cli/cmds/utils/needs_recompile.d.ts.map +1 -0
  61. package/dest/cli/cmds/utils/needs_recompile.js +90 -0
  62. package/dest/cli/cmds/utils/spawn.d.ts +3 -0
  63. package/dest/cli/cmds/utils/spawn.d.ts.map +1 -0
  64. package/dest/cli/cmds/utils/spawn.js +16 -0
  65. package/dest/cli/cmds/utils/warn_if_aztec_version_mismatch.d.ts +4 -0
  66. package/dest/cli/cmds/utils/warn_if_aztec_version_mismatch.d.ts.map +1 -0
  67. package/dest/cli/cmds/utils/warn_if_aztec_version_mismatch.js +61 -0
  68. package/dest/cli/util.d.ts +7 -18
  69. package/dest/cli/util.d.ts.map +1 -1
  70. package/dest/cli/util.js +57 -91
  71. package/dest/examples/token.js +9 -9
  72. package/dest/local-network/auth_registry.d.ts +4 -0
  73. package/dest/local-network/auth_registry.d.ts.map +1 -0
  74. package/dest/local-network/auth_registry.js +15 -0
  75. package/dest/local-network/banana_fpc.d.ts +1 -1
  76. package/dest/local-network/banana_fpc.d.ts.map +1 -1
  77. package/dest/local-network/banana_fpc.js +11 -9
  78. package/dest/local-network/local-network.d.ts +7 -29
  79. package/dest/local-network/local-network.d.ts.map +1 -1
  80. package/dest/local-network/local-network.js +95 -37
  81. package/dest/testing/anvil_test_watcher.d.ts +23 -3
  82. package/dest/testing/anvil_test_watcher.d.ts.map +1 -1
  83. package/dest/testing/anvil_test_watcher.js +113 -22
  84. package/dest/testing/cheat_codes.d.ts +20 -17
  85. package/dest/testing/cheat_codes.d.ts.map +1 -1
  86. package/dest/testing/cheat_codes.js +72 -36
  87. package/dest/testing/epoch_test_settler.d.ts +19 -0
  88. package/dest/testing/epoch_test_settler.d.ts.map +1 -0
  89. package/dest/testing/epoch_test_settler.js +63 -0
  90. package/dest/testing/index.d.ts +4 -2
  91. package/dest/testing/index.d.ts.map +1 -1
  92. package/dest/testing/index.js +2 -0
  93. package/dest/testing/token_allowed_setup.d.ts +7 -0
  94. package/dest/testing/token_allowed_setup.d.ts.map +1 -0
  95. package/dest/testing/token_allowed_setup.js +20 -0
  96. package/package.json +36 -34
  97. package/scripts/add_crate.sh +53 -0
  98. package/scripts/aztec.sh +26 -9
  99. package/scripts/init.sh +23 -19
  100. package/scripts/new.sh +48 -24
  101. package/scripts/setup_workspace.sh +69 -0
  102. package/scripts/templates/blank/contract/Nargo.toml +6 -0
  103. package/scripts/templates/blank/contract/src/main.nr +10 -0
  104. package/scripts/templates/blank/test/Nargo.toml +7 -0
  105. package/scripts/templates/blank/test/src/lib.nr +11 -0
  106. package/scripts/templates/counter/contract/Nargo.toml +7 -0
  107. package/scripts/templates/counter/contract/src/main.nr +48 -0
  108. package/scripts/templates/counter/test/Nargo.toml +7 -0
  109. package/scripts/templates/counter/test/src/lib.nr +32 -0
  110. package/src/bin/index.ts +9 -3
  111. package/src/cli/admin_api_key_store.ts +128 -0
  112. package/src/cli/aztec_start_action.ts +72 -17
  113. package/src/cli/aztec_start_options.ts +51 -31
  114. package/src/cli/cli.ts +4 -37
  115. package/src/cli/cmds/compile.ts +192 -0
  116. package/src/cli/cmds/migrate_ha_db.ts +43 -0
  117. package/src/cli/cmds/profile.ts +26 -0
  118. package/src/cli/cmds/profile_flamegraph.ts +64 -0
  119. package/src/cli/cmds/profile_gates.ts +84 -0
  120. package/src/cli/cmds/profile_utils.ts +58 -0
  121. package/src/cli/cmds/standby.ts +132 -0
  122. package/src/cli/cmds/start_bot.ts +11 -10
  123. package/src/cli/cmds/start_node.ts +86 -40
  124. package/src/cli/cmds/start_p2p_bootstrap.ts +2 -2
  125. package/src/cli/cmds/start_prover_agent.ts +8 -19
  126. package/src/cli/cmds/start_prover_broker.ts +28 -25
  127. package/src/cli/cmds/start_txe.ts +7 -5
  128. package/src/cli/cmds/utils/artifacts.ts +44 -0
  129. package/src/cli/cmds/utils/collect_crate_dirs.ts +118 -0
  130. package/src/cli/cmds/utils/needs_recompile.ts +98 -0
  131. package/src/cli/cmds/utils/spawn.ts +16 -0
  132. package/src/cli/cmds/utils/warn_if_aztec_version_mismatch.ts +76 -0
  133. package/src/cli/util.ts +64 -102
  134. package/src/examples/token.ts +10 -10
  135. package/src/local-network/auth_registry.ts +14 -0
  136. package/src/local-network/banana_fpc.ts +8 -7
  137. package/src/local-network/local-network.ts +115 -41
  138. package/src/testing/anvil_test_watcher.ts +127 -20
  139. package/src/testing/cheat_codes.ts +92 -39
  140. package/src/testing/epoch_test_settler.ts +69 -0
  141. package/src/testing/index.ts +3 -1
  142. package/src/testing/token_allowed_setup.ts +19 -0
  143. package/dest/cli/cmds/start_archiver.d.ts +0 -9
  144. package/dest/cli/cmds/start_archiver.d.ts.map +0 -1
  145. package/dest/cli/cmds/start_archiver.js +0 -50
  146. package/dest/cli/cmds/start_prover_node.d.ts +0 -7
  147. package/dest/cli/cmds/start_prover_node.d.ts.map +0 -1
  148. package/dest/cli/cmds/start_prover_node.js +0 -108
  149. package/dest/cli/release_version.d.ts +0 -2
  150. package/dest/cli/release_version.d.ts.map +0 -1
  151. package/dest/cli/release_version.js +0 -14
  152. package/scripts/compile.sh +0 -44
  153. package/scripts/extract_function.js +0 -47
  154. package/scripts/flamegraph.sh +0 -59
  155. package/scripts/setup_project.sh +0 -31
  156. package/src/cli/cmds/start_archiver.ts +0 -61
  157. package/src/cli/cmds/start_prover_node.ts +0 -124
  158. package/src/cli/release_version.ts +0 -21
@@ -1,17 +1,20 @@
1
+ import { getActiveNetworkName } from '@aztec/foundation/config';
1
2
  import {
2
3
  type NamespacedApiHandlers,
3
4
  createNamespacedSafeJsonRpcServer,
5
+ getApiKeyAuthMiddleware,
4
6
  startHttpRpcServer,
5
7
  } from '@aztec/foundation/json-rpc/server';
6
8
  import type { LogFn, Logger } from '@aztec/foundation/log';
7
9
  import type { ChainConfig } from '@aztec/stdlib/config';
8
- import { AztecNodeApiSchema } from '@aztec/stdlib/interfaces/client';
10
+ import { AztecNodeAdminApiSchema, AztecNodeApiSchema, AztecNodeDebugApiSchema } from '@aztec/stdlib/interfaces/client';
11
+ import { getPackageVersion } from '@aztec/stdlib/update-checker';
9
12
  import { getVersioningMiddleware } from '@aztec/stdlib/versioning';
10
- import { getOtelJsonRpcPropagationMiddleware } from '@aztec/telemetry-client';
13
+ import { getOtelJsonRpcDiagnosticsMiddleware, getOtelJsonRpcPropagationMiddleware } from '@aztec/telemetry-client';
11
14
 
12
15
  import { createLocalNetwork } from '../local-network/index.js';
13
16
  import { github, splash } from '../splash.js';
14
- import { getCliVersion } from './release_version.js';
17
+ import { resolveAdminApiKey } from './admin_api_key_store.js';
15
18
  import { extractNamespacedOptions, installSignalHandlers } from './util.js';
16
19
  import { getVersions } from './versioning.js';
17
20
 
@@ -20,14 +23,13 @@ export async function aztecStart(options: any, userLog: LogFn, debugLogger: Logg
20
23
  const signalHandlers: Array<() => Promise<void>> = [];
21
24
  const services: NamespacedApiHandlers = {};
22
25
  const adminServices: NamespacedApiHandlers = {};
26
+ const packageVersion = getPackageVersion();
23
27
  let config: ChainConfig | undefined = undefined;
24
28
 
25
29
  if (options.localNetwork) {
26
- const cliVersion = getCliVersion();
27
- const localNetwork = extractNamespacedOptions(options, 'local-network');
28
- localNetwork.testAccounts = true;
30
+ const localNetwork = extractNamespacedOptions(options, 'localNetwork');
29
31
  userLog(`${splash}\n${github}\n\n`);
30
- userLog(`Setting up Aztec local network ${cliVersion}, please stand by...`);
32
+ userLog(`Setting up Aztec local network ${packageVersion}, please stand by...`);
31
33
 
32
34
  const { node, stop } = await createLocalNetwork(
33
35
  {
@@ -35,6 +37,11 @@ export async function aztecStart(options: any, userLog: LogFn, debugLogger: Logg
35
37
  l1RpcUrls: options.l1RpcUrls,
36
38
  testAccounts: localNetwork.testAccounts,
37
39
  realProofs: false,
40
+ // Setting the epoch duration to 2 by default for local network. This allows the epoch to be "proven" faster, so
41
+ // the users can consume out hash without having to wait for a long time.
42
+ // Note: We are not proving anything in the local network (realProofs == false). But in `createLocalNetwork`,
43
+ // the EpochTestSettler will set the out hash to the outbox when an epoch is complete.
44
+ aztecEpochDuration: 2,
38
45
  },
39
46
  userLog,
40
47
  );
@@ -42,19 +49,24 @@ export async function aztecStart(options: any, userLog: LogFn, debugLogger: Logg
42
49
  // Start Node and PXE JSON-RPC server
43
50
  signalHandlers.push(stop);
44
51
  services.node = [node, AztecNodeApiSchema];
52
+ adminServices.node = [node, AztecNodeAdminApiSchema];
53
+ services.nodeDebug = [node, AztecNodeDebugApiSchema];
45
54
  } else {
55
+ // Route --prover-node through startNode
56
+ if (options.proverNode && !options.node) {
57
+ options.node = true;
58
+ }
59
+
46
60
  if (options.node) {
47
61
  const { startNode } = await import('./cmds/start_node.js');
48
- ({ config } = await startNode(options, signalHandlers, services, adminServices, userLog));
62
+ const networkName = getActiveNetworkName(options.network);
63
+ ({ config } = await startNode(options, signalHandlers, services, adminServices, userLog, networkName));
64
+ if (options.nodeDebug && services.node) {
65
+ services.nodeDebug = [services.node[0], AztecNodeDebugApiSchema];
66
+ }
49
67
  } else if (options.bot) {
50
68
  const { startBot } = await import('./cmds/start_bot.js');
51
69
  await startBot(options, signalHandlers, services, userLog);
52
- } else if (options.proverNode) {
53
- const { startProverNode } = await import('./cmds/start_prover_node.js');
54
- ({ config } = await startProverNode(options, signalHandlers, services, userLog));
55
- } else if (options.archiver) {
56
- const { startArchiver } = await import('./cmds/start_archiver.js');
57
- ({ config } = await startArchiver(options, signalHandlers, services));
58
70
  } else if (options.p2pBootstrap) {
59
71
  const { startP2PBootstrap } = await import('./cmds/start_p2p_bootstrap.js');
60
72
  ({ config } = await startP2PBootstrap(options, signalHandlers, services, userLog));
@@ -66,7 +78,7 @@ export async function aztecStart(options: any, userLog: LogFn, debugLogger: Logg
66
78
  await startProverBroker(options, signalHandlers, services, userLog);
67
79
  } else if (options.txe) {
68
80
  const { startTXE } = await import('./cmds/start_txe.js');
69
- await startTXE(options, debugLogger);
81
+ await startTXE(options, signalHandlers, debugLogger);
70
82
  } else if (options.sequencer) {
71
83
  userLog(`Cannot run a standalone sequencer without a node`);
72
84
  process.exit(1);
@@ -78,13 +90,15 @@ export async function aztecStart(options: any, userLog: LogFn, debugLogger: Logg
78
90
 
79
91
  installSignalHandlers(debugLogger.info, signalHandlers);
80
92
  const versions = getVersions(config);
93
+ const versioningOpts = { packageVersion };
81
94
 
82
95
  // Start the main JSON-RPC server
83
96
  if (Object.entries(services).length > 0) {
84
97
  const rpcServer = createNamespacedSafeJsonRpcServer(services, {
98
+ diagnostic: getOtelJsonRpcDiagnosticsMiddleware(),
85
99
  http200OnError: false,
86
100
  log: debugLogger,
87
- middlewares: [getOtelJsonRpcPropagationMiddleware(), getVersioningMiddleware(versions)],
101
+ middlewares: [getOtelJsonRpcPropagationMiddleware(), getVersioningMiddleware(versions, versioningOpts)],
88
102
  maxBatchSize: options.rpcMaxBatchSize,
89
103
  maxBodySizeBytes: options.rpcMaxBodySize,
90
104
  });
@@ -94,14 +108,55 @@ export async function aztecStart(options: any, userLog: LogFn, debugLogger: Logg
94
108
 
95
109
  // If there are any admin services, start a separate JSON-RPC server for them
96
110
  if (Object.entries(adminServices).length > 0) {
111
+ const adminMiddlewares = [getOtelJsonRpcPropagationMiddleware(), getVersioningMiddleware(versions, versioningOpts)];
112
+
113
+ // Resolve the admin API key (auto-generated and persisted, or opt-out)
114
+ const apiKeyResolution = await resolveAdminApiKey(
115
+ {
116
+ adminApiKeyHash: options.adminApiKeyHash,
117
+ disableAdminApiKey: options.disableAdminApiKey,
118
+ resetAdminApiKey: options.resetAdminApiKey,
119
+ dataDirectory: options.dataDirectory,
120
+ },
121
+ debugLogger,
122
+ );
123
+ if (apiKeyResolution) {
124
+ adminMiddlewares.unshift(getApiKeyAuthMiddleware(apiKeyResolution.apiKeyHash));
125
+ } else {
126
+ debugLogger.warn('No admin API key set — admin endpoint is unauthenticated');
127
+ }
128
+
97
129
  const rpcServer = createNamespacedSafeJsonRpcServer(adminServices, {
130
+ diagnostic: getOtelJsonRpcDiagnosticsMiddleware(),
98
131
  http200OnError: false,
99
132
  log: debugLogger,
100
- middlewares: [getOtelJsonRpcPropagationMiddleware(), getVersioningMiddleware(versions)],
133
+ middlewares: adminMiddlewares,
101
134
  maxBatchSize: options.rpcMaxBatchSize,
102
135
  maxBodySizeBytes: options.rpcMaxBodySize,
103
136
  });
104
137
  const { port } = await startHttpRpcServer(rpcServer, { port: options.adminPort });
105
138
  debugLogger.info(`Aztec Server admin API listening on port ${port}`, versions);
139
+
140
+ // Display the API key after the server has started
141
+ // Uses userLog which is never filtered by LOG_LEVEL.
142
+ if (apiKeyResolution?.rawKey) {
143
+ const separator = '='.repeat(70);
144
+ userLog('');
145
+ userLog(separator);
146
+ userLog(' ADMIN API KEY (save this — it will NOT be shown again)');
147
+ userLog('');
148
+ userLog(` ${apiKeyResolution.rawKey}`);
149
+ userLog('');
150
+ userLog(` Use via header: x-api-key: <key>`);
151
+ userLog(` Or via header: Authorization: Bearer <key>`);
152
+ if (options.dataDirectory) {
153
+ userLog('');
154
+ userLog(' The key hash has been persisted — on next restart, the same key will be used.');
155
+ }
156
+ userLog('');
157
+ userLog(' To disable admin auth: --disable-admin-api-key or AZTEC_DISABLE_ADMIN_API_KEY=true');
158
+ userLog(separator);
159
+ userLog('');
160
+ }
106
161
  }
107
162
  }
@@ -12,14 +12,14 @@ import {
12
12
  isBooleanConfigValue,
13
13
  omitConfigMappings,
14
14
  } from '@aztec/foundation/config';
15
- import { dataConfigMappings } from '@aztec/kv-store/config';
16
15
  import { sharedNodeConfigMappings } from '@aztec/node-lib/config';
17
16
  import { bootnodeConfigMappings, p2pConfigMappings } from '@aztec/p2p/config';
18
17
  import { proverAgentConfigMappings, proverBrokerConfigMappings } from '@aztec/prover-client/broker/config';
19
18
  import { proverNodeConfigMappings } from '@aztec/prover-node/config';
20
19
  import { allPxeConfigMappings } from '@aztec/pxe/config';
21
20
  import { sequencerClientConfigMappings } from '@aztec/sequencer-client/config';
22
- import { chainConfigMappings } from '@aztec/stdlib/config';
21
+ import { chainConfigMappings, nodeRpcConfigMappings } from '@aztec/stdlib/config';
22
+ import { dataConfigMappings } from '@aztec/stdlib/kv-store';
23
23
  import { telemetryClientConfigMappings } from '@aztec/telemetry-client/config';
24
24
  import { worldStateConfigMappings } from '@aztec/world-state/config';
25
25
 
@@ -36,7 +36,7 @@ export interface AztecStartOption {
36
36
  parseVal?: (val: string) => any;
37
37
  }
38
38
 
39
- export const getOptions = (namespace: string, configMappings: Record<string, ConfigMapping>) => {
39
+ export const getOptions = (namespace: string, configMappings: Record<string, ConfigMapping<unknown>>) => {
40
40
  const options: AztecStartOption[] = [];
41
41
  for (const [key, { env, defaultValue: def, parseEnv, description, printDefault, fallback }] of Object.entries(
42
42
  configMappings,
@@ -58,7 +58,11 @@ export const getOptions = (namespace: string, configMappings: Record<string, Con
58
58
  return options;
59
59
  };
60
60
 
61
- const configToFlag = (flag: string, configMapping: ConfigMapping, overrideDefaultValue?: any): AztecStartOption => {
61
+ const configToFlag = (
62
+ flag: string,
63
+ configMapping: ConfigMapping<unknown>,
64
+ overrideDefaultValue?: any,
65
+ ): AztecStartOption => {
62
66
  if (!configMapping.isBoolean) {
63
67
  flag += ' <value>';
64
68
  }
@@ -105,8 +109,7 @@ export const aztecStartOptions: { [key: string]: AztecStartOption[] } = {
105
109
  env: 'NETWORK',
106
110
  },
107
111
 
108
- configToFlag('--auto-update', sharedNodeConfigMappings.autoUpdate),
109
- configToFlag('--auto-update-url', sharedNodeConfigMappings.autoUpdateUrl),
112
+ configToFlag('--enable-version-check', sharedNodeConfigMappings.enableVersionCheck),
110
113
 
111
114
  configToFlag('--sync-mode', sharedNodeConfigMappings.syncMode),
112
115
  configToFlag('--snapshots-urls', sharedNodeConfigMappings.snapshotsUrls),
@@ -126,6 +129,12 @@ export const aztecStartOptions: { [key: string]: AztecStartOption[] } = {
126
129
  defaultValue: DefaultMnemonic,
127
130
  env: 'MNEMONIC',
128
131
  },
132
+ {
133
+ flag: '--local-network.testAccounts',
134
+ description: 'Deploy test accounts on local network start',
135
+ env: 'TEST_ACCOUNTS',
136
+ ...booleanConfigHelper(true),
137
+ },
129
138
  ],
130
139
  API: [
131
140
  {
@@ -142,12 +151,45 @@ export const aztecStartOptions: { [key: string]: AztecStartOption[] } = {
142
151
  env: 'AZTEC_ADMIN_PORT',
143
152
  parseVal: val => parseInt(val, 10),
144
153
  },
154
+ {
155
+ flag: '--admin-api-key-hash <value>',
156
+ description:
157
+ 'SHA-256 hex hash of a pre-generated admin API key. When set, the node uses this hash for authentication instead of auto-generating a key.',
158
+ defaultValue: undefined,
159
+ env: 'AZTEC_ADMIN_API_KEY_HASH',
160
+ },
161
+ {
162
+ flag: '--disable-admin-api-key',
163
+ description:
164
+ 'Disable API key authentication on the admin RPC endpoint. By default, a key is auto-generated, displayed once, and its hash is persisted.',
165
+ defaultValue: false,
166
+ env: 'AZTEC_DISABLE_ADMIN_API_KEY',
167
+ // undefined means the flag was passed without a value (boolean toggle), treat as true.
168
+ parseVal: val => val === undefined || val === 'true' || val === '1',
169
+ },
170
+ {
171
+ flag: '--reset-admin-api-key',
172
+ description:
173
+ 'Force-generate a new admin API key, replacing any previously persisted key hash. The new key is displayed once at startup.',
174
+ defaultValue: false,
175
+ env: 'AZTEC_RESET_ADMIN_API_KEY',
176
+ parseVal: val => val === 'true' || val === '1',
177
+ },
178
+ {
179
+ flag: '--node-debug',
180
+ description: 'Expose debug endpoints (e.g. mineBlock) on the main RPC port',
181
+ defaultValue: false,
182
+ env: 'AZTEC_NODE_DEBUG',
183
+ parseVal: val => val === undefined || val === 'true' || val === '1',
184
+ },
145
185
  {
146
186
  flag: '--api-prefix <value>',
147
187
  description: 'Prefix for API routes on any service that is started',
148
188
  defaultValue: '',
149
189
  env: 'API_PREFIX',
150
190
  },
191
+ configToFlag('--rpcMaxBatchSize', nodeRpcConfigMappings.rpcMaxBatchSize),
192
+ configToFlag('--rpcMaxBodySize', nodeRpcConfigMappings.rpcMaxBodySize),
151
193
  ],
152
194
  ETHEREUM: [
153
195
  configToFlag('--l1-chain-id', l1ReaderConfigMappings.l1ChainId),
@@ -168,7 +210,7 @@ export const aztecStartOptions: { [key: string]: AztecStartOption[] } = {
168
210
  'WORLD STATE': [
169
211
  configToFlag('--world-state-data-directory', worldStateConfigMappings.worldStateDataDirectory),
170
212
  configToFlag('--world-state-db-map-size-kb', worldStateConfigMappings.worldStateDbMapSizeKb),
171
- configToFlag('--world-state-block-history', worldStateConfigMappings.worldStateBlockHistory),
213
+ configToFlag('--world-state-checkpoint-history', worldStateConfigMappings.worldStateCheckpointHistory),
172
214
  ],
173
215
  // We can't easily auto-generate node options as they're parts of modules defined below
174
216
  'AZTEC NODE': [
@@ -180,12 +222,6 @@ export const aztecStartOptions: { [key: string]: AztecStartOption[] } = {
180
222
  },
181
223
  ],
182
224
  ARCHIVER: [
183
- {
184
- flag: '--archiver',
185
- description: 'Starts Aztec Archiver with options',
186
- defaultValue: undefined,
187
- env: undefined,
188
- },
189
225
  ...getOptions(
190
226
  'archiver',
191
227
  omitConfigMappings(archiverConfigMappings, Object.keys(l1ContractsConfigMappings) as (keyof ArchiverConfig)[]),
@@ -220,12 +256,8 @@ export const aztecStartOptions: { [key: string]: AztecStartOption[] } = {
220
256
  'proverNode',
221
257
  omitConfigMappings(proverNodeConfigMappings, [
222
258
  // filter out options passed separately
223
- ...getKeys(archiverConfigMappings),
224
259
  ...getKeys(proverBrokerConfigMappings),
225
260
  ...getKeys(proverAgentConfigMappings),
226
- ...getKeys(p2pConfigMappings),
227
- ...getKeys(worldStateConfigMappings),
228
- ...getKeys(sharedNodeConfigMappings),
229
261
  ]),
230
262
  ),
231
263
  ],
@@ -236,11 +268,7 @@ export const aztecStartOptions: { [key: string]: AztecStartOption[] } = {
236
268
  defaultValue: undefined,
237
269
  env: undefined,
238
270
  },
239
- ...getOptions(
240
- 'proverBroker',
241
- // filter out archiver options from prover node options as they're passed separately in --archiver
242
- proverBrokerConfigMappings,
243
- ),
271
+ ...getOptions('proverBroker', proverBrokerConfigMappings),
244
272
  ],
245
273
  'PROVER AGENT': [
246
274
  {
@@ -288,15 +316,7 @@ export const aztecStartOptions: { [key: string]: AztecStartOption[] } = {
288
316
  },
289
317
  ...getOptions('bot', botConfigMappings),
290
318
  ],
291
- PXE: [
292
- {
293
- flag: '--pxe',
294
- description: 'Starts Aztec PXE with options',
295
- defaultValue: undefined,
296
- env: undefined,
297
- },
298
- ...getOptions('pxe', allPxeConfigMappings),
299
- ],
319
+ PXE: [...getOptions('pxe', allPxeConfigMappings)],
300
320
  TXE: [
301
321
  {
302
322
  flag: '--txe',
package/src/cli/cli.ts CHANGED
@@ -35,44 +35,11 @@ export function injectAztecCommands(program: Command, userLog: LogFn, debugLogge
35
35
  program.addHelpText(
36
36
  'after',
37
37
  `
38
+ Additional commands:
38
39
 
39
- Additional commands:
40
-
41
- init [folder] [options]: creates a new Noir project
42
- Options:
43
- --name <name> Name of the package
44
- --contract Use a contract template (default)
45
- --lib Use a library template
46
- --bin Use a binary template
47
- Examples:
48
- $ aztec init # creates a contract project in current directory
49
- $ aztec init --lib # creates a library project
50
-
51
- new <path> [options]: creates a new Noir project in a new directory
52
- Options:
53
- --name <name> Name of the package
54
- --contract Use a contract template (default)
55
- --lib Use a library template
56
- --bin Use a binary template
57
- Examples:
58
- $ aztec new my-project # creates a contract project in ./my-project
59
- $ aztec new my-lib --lib # creates a library project in ./my-lib
60
-
61
- compile [options]: compiles Aztec Noir contracts
62
- Compiles contracts with nargo compile and then postprocesses them to generate Aztec-specific artifacts including:
63
- - Transpiled contract artifacts
64
- - Verification keys
65
- The compiled contracts will be placed in the target/ directory by default.
66
- Supports standard nargo compile options.
67
-
68
- test [options]: starts a dockerized TXE node via
69
- $ aztec start --txe
70
- then runs
71
- $ aztec test --silence-warnings --oracle-resolver=<TXE_ADDRESS> [options]
72
-
73
- preload-crs: Downloads and caches the Common Reference String (CRS) data required for zero-knowledge proofs.
74
- Example:
75
- $ aztec preload-crs # preloads CRS data
40
+ init creates a new Aztec Noir workspace in the current directory.
41
+ new <name> creates a new Aztec Noir workspace in its own directory (or creates a new contract-test crates pair and adds it to the current workspace if run in workspace).
42
+ test [options] starts a TXE and runs "nargo test" using it as the oracle resolver.
76
43
  `,
77
44
  );
78
45
  }
@@ -0,0 +1,192 @@
1
+ import { findBbBinary } from '@aztec/bb.js';
2
+ import type { LogFn } from '@aztec/foundation/log';
3
+ import { getPackageVersion } from '@aztec/stdlib/update-checker';
4
+
5
+ import { execFileSync } from 'child_process';
6
+ import type { Command } from 'commander';
7
+ import { readFile, writeFile } from 'fs/promises';
8
+ import { join } from 'path';
9
+
10
+ import { readArtifactFiles } from './utils/artifacts.js';
11
+ import { needsRecompile } from './utils/needs_recompile.js';
12
+ import { run } from './utils/spawn.js';
13
+ import { warnIfAztecVersionMismatch } from './utils/warn_if_aztec_version_mismatch.js';
14
+
15
+ /** Returns paths to contract artifacts in the target directory. */
16
+ async function collectContractArtifacts(): Promise<string[]> {
17
+ let files;
18
+ try {
19
+ files = await readArtifactFiles('target');
20
+ } catch (err: any) {
21
+ if (err?.message?.includes('does not exist')) {
22
+ return [];
23
+ }
24
+ throw err;
25
+ }
26
+ return files.filter(f => Array.isArray(f.content.functions)).map(f => f.filePath);
27
+ }
28
+
29
+ /** Stamps the Aztec stack version into the contract artifacts. */
30
+ async function stampAztecVersion(artifactPaths: string[]): Promise<void> {
31
+ const version = getPackageVersion();
32
+ for (const path of artifactPaths) {
33
+ const artifact = JSON.parse(await readFile(path, 'utf-8'));
34
+ // eslint-disable-next-line camelcase
35
+ artifact.aztec_version = version;
36
+ await writeFile(path, JSON.stringify(artifact, null, 2) + '\n');
37
+ }
38
+ }
39
+
40
+ /** Returns the set of package names that are contract crates in the current workspace. */
41
+ async function getContractPackageNames(): Promise<Set<string>> {
42
+ const contractNames = new Set<string>();
43
+
44
+ let rootToml: string;
45
+ try {
46
+ rootToml = await readFile('Nargo.toml', 'utf-8');
47
+ } catch {
48
+ return contractNames;
49
+ }
50
+
51
+ const membersMatch = rootToml.match(/members\s*=\s*\[([^\]]*)\]/);
52
+ if (membersMatch) {
53
+ const members = membersMatch[1]
54
+ .split(',')
55
+ .map(m => m.trim().replace(/^"|"$/g, ''))
56
+ .filter(m => m.length > 0);
57
+
58
+ for (const member of members) {
59
+ try {
60
+ const memberToml = await readFile(join(member, 'Nargo.toml'), 'utf-8');
61
+ if (/type\s*=\s*"contract"/.test(memberToml)) {
62
+ const nameMatch = memberToml.match(/name\s*=\s*"([^"]+)"/);
63
+ if (nameMatch) {
64
+ contractNames.add(nameMatch[1]);
65
+ }
66
+ }
67
+ } catch {
68
+ // Member directory might not exist or have no Nargo.toml; skip.
69
+ }
70
+ }
71
+ } else {
72
+ // Single-crate project (no workspace): check if the root Nargo.toml itself is a contract.
73
+ if (/type\s*=\s*"contract"/.test(rootToml)) {
74
+ const nameMatch = rootToml.match(/name\s*=\s*"([^"]+)"/);
75
+ if (nameMatch) {
76
+ contractNames.add(nameMatch[1]);
77
+ }
78
+ }
79
+ }
80
+
81
+ return contractNames;
82
+ }
83
+
84
+ /** Checks that no tests exist in contract crates and fails with a helpful message if they do. */
85
+ async function checkNoTestsInContracts(nargo: string, log: LogFn): Promise<void> {
86
+ const contractPackages = await getContractPackageNames();
87
+ if (contractPackages.size === 0) {
88
+ return;
89
+ }
90
+
91
+ let output: string;
92
+ try {
93
+ // We list tests for all the crates in the workspace
94
+ output = execFileSync(nargo, ['test', '--list-tests', '--silence-warnings'], {
95
+ encoding: 'utf-8',
96
+ stdio: ['pipe', 'pipe', 'inherit'],
97
+ });
98
+ } catch {
99
+ // If listing tests fails (e.g. test crate has compile errors), skip the check.
100
+ return;
101
+ }
102
+
103
+ // The output of the `nargo test --list-tests` command is as follows:
104
+ // ```
105
+ // crate_name_1 test_name_1
106
+ // crate_name_2 test_name_2
107
+ // ...
108
+ // crate_name_n test_name_n
109
+ // ```
110
+ //
111
+ // We parse the individual lines and then we check if any contract crate appeared in the parsed output.
112
+ const lines = output
113
+ .trim()
114
+ .split('\n')
115
+ .filter(line => line.length > 0);
116
+ const testsInContracts: { packageName: string; testName: string }[] = [];
117
+
118
+ for (const line of lines) {
119
+ const spaceIndex = line.indexOf(' ');
120
+ if (spaceIndex === -1) {
121
+ continue;
122
+ }
123
+ const packageName = line.substring(0, spaceIndex);
124
+ const testName = line.substring(spaceIndex + 1);
125
+ if (contractPackages.has(packageName)) {
126
+ testsInContracts.push({ packageName, testName });
127
+ }
128
+ }
129
+
130
+ if (testsInContracts.length > 0) {
131
+ const details = testsInContracts.map(t => ` ${t.packageName}::${t.testName}`).join('\n');
132
+ log(
133
+ `WARNING: Found tests in contract crate(s):\n${details}\n\n` +
134
+ `Tests should be in a dedicated test crate, not in the contract crate.\n` +
135
+ `Learn more: https://docs.aztec.network/errors/1`,
136
+ );
137
+ }
138
+ }
139
+
140
+ /** Compiles Aztec Noir contracts and postprocesses artifacts. */
141
+ async function compileAztecContract(nargoArgs: string[], log: LogFn): Promise<void> {
142
+ await warnIfAztecVersionMismatch(log);
143
+
144
+ if (!(await needsRecompile())) {
145
+ log('No source changes detected, skipping compilation.');
146
+ return;
147
+ }
148
+
149
+ const nargo = process.env.NARGO ?? 'nargo';
150
+ const bb = process.env.BB ?? findBbBinary() ?? 'bb';
151
+
152
+ await run(nargo, ['compile', ...nargoArgs]);
153
+
154
+ // Ensure contract crates contain no tests (tests belong in the test crate).
155
+ await checkNoTestsInContracts(nargo, log);
156
+
157
+ const artifacts = await collectContractArtifacts();
158
+
159
+ if (artifacts.length > 0) {
160
+ log('Postprocessing contracts...');
161
+ const bbArgs = artifacts.flatMap(a => ['-i', a]);
162
+ await run(bb, ['aztec_process', ...bbArgs]);
163
+
164
+ await stampAztecVersion(artifacts);
165
+ }
166
+
167
+ log('Compilation complete!');
168
+ }
169
+
170
+ export function injectCompileCommand(program: Command, log: LogFn): Command {
171
+ program
172
+ .command('compile')
173
+ .argument('[nargo-args...]')
174
+ .passThroughOptions()
175
+ .allowUnknownOption()
176
+ .description(
177
+ 'Compile Aztec Noir contracts using nargo and postprocess them to generate transpiled artifacts and verification keys. All options are forwarded to nargo compile.',
178
+ )
179
+ .addHelpText('after', () => {
180
+ // Show nargo's own compile options so users see all available flags in one place.
181
+ const nargo = process.env.NARGO ?? 'nargo';
182
+ try {
183
+ const output = execFileSync(nargo, ['compile', '--help'], { encoding: 'utf-8' });
184
+ return `\nUnderlying nargo compile options:\n\n${output}`;
185
+ } catch {
186
+ return '\n(Run "nargo compile --help" to see available nargo options)';
187
+ }
188
+ })
189
+ .action((nargoArgs: string[]) => compileAztecContract(nargoArgs, log));
190
+
191
+ return program;
192
+ }
@@ -0,0 +1,43 @@
1
+ import { runMigrations } from '@aztec/validator-ha-signer/migrations';
2
+
3
+ import type { Command } from 'commander';
4
+
5
+ export function injectMigrateCommand(program: Command, log: (msg: string) => void): Command {
6
+ const migrateCommand = program.command('migrate-ha-db').description('Run validator-ha-signer database migrations');
7
+
8
+ migrateCommand
9
+ .command('up')
10
+ .description('Apply pending migrations')
11
+ .requiredOption('--database-url <string>', 'PostgreSQL connection string', process.env.DATABASE_URL)
12
+ .option('--verbose', 'Enable verbose output', false)
13
+ .action(async options => {
14
+ const migrations = await runMigrations(options.databaseUrl, {
15
+ direction: 'up',
16
+ verbose: options.verbose,
17
+ });
18
+ if (migrations.length > 0) {
19
+ log(`Applied migrations: ${migrations.join(', ')}`);
20
+ } else {
21
+ log('No migrations to apply - schema is up to date');
22
+ }
23
+ });
24
+
25
+ migrateCommand
26
+ .command('down')
27
+ .description('Rollback the last migration')
28
+ .requiredOption('--database-url <string>', 'PostgreSQL connection string', process.env.DATABASE_URL)
29
+ .option('--verbose', 'Enable verbose output', false)
30
+ .action(async options => {
31
+ const migrations = await runMigrations(options.databaseUrl, {
32
+ direction: 'down',
33
+ verbose: options.verbose,
34
+ });
35
+ if (migrations.length > 0) {
36
+ log(`Rolled back migrations: ${migrations.join(', ')}`);
37
+ } else {
38
+ log('No migrations to rollback');
39
+ }
40
+ });
41
+
42
+ return program;
43
+ }
@@ -0,0 +1,26 @@
1
+ import type { LogFn } from '@aztec/foundation/log';
2
+
3
+ import type { Command } from 'commander';
4
+
5
+ import { profileFlamegraph } from './profile_flamegraph.js';
6
+ import { profileGates } from './profile_gates.js';
7
+
8
+ export function injectProfileCommand(program: Command, log: LogFn): Command {
9
+ const profile = program.command('profile').description('Profile compiled Aztec artifacts.');
10
+
11
+ profile
12
+ .command('gates')
13
+ .argument('[target-dir]', 'Path to the compiled artifacts directory', './target')
14
+ .option('--json', 'Output gate counts as JSON instead of a table', false)
15
+ .description('Display gate counts for all compiled Aztec artifacts in a target directory.')
16
+ .action((targetDir: string, options: { json: boolean }) => profileGates(targetDir, options.json, log));
17
+
18
+ profile
19
+ .command('flamegraph')
20
+ .argument('<contract-artifact>', 'Path to the compiled contract artifact JSON')
21
+ .argument('<function>', 'Name of the contract function to profile')
22
+ .description('Generate a gate count flamegraph SVG for a contract function.')
23
+ .action((artifactPath: string, functionName: string) => profileFlamegraph(artifactPath, functionName, log));
24
+
25
+ return program;
26
+ }