@aztec/aztec 0.0.1-commit.d3ec352c → 0.0.1-commit.d58ff9d0

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 (173) hide show
  1. package/dest/bin/index.js +14 -5
  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 +69 -31
  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 +53 -48
  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 +174 -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/prover.d.ts +4 -0
  33. package/dest/cli/cmds/prover.d.ts.map +1 -0
  34. package/dest/cli/cmds/prover.js +24 -0
  35. package/dest/cli/cmds/standby.d.ts +56 -0
  36. package/dest/cli/cmds/standby.d.ts.map +1 -0
  37. package/dest/cli/cmds/standby.js +140 -0
  38. package/dest/cli/cmds/start_bot.d.ts +3 -3
  39. package/dest/cli/cmds/start_bot.d.ts.map +1 -1
  40. package/dest/cli/cmds/start_bot.js +18 -10
  41. package/dest/cli/cmds/start_node.d.ts +3 -2
  42. package/dest/cli/cmds/start_node.d.ts.map +1 -1
  43. package/dest/cli/cmds/start_node.js +83 -52
  44. package/dest/cli/cmds/start_p2p_bootstrap.d.ts +2 -2
  45. package/dest/cli/cmds/start_p2p_bootstrap.d.ts.map +1 -1
  46. package/dest/cli/cmds/start_p2p_bootstrap.js +2 -3
  47. package/dest/cli/cmds/start_prover_agent.d.ts +1 -1
  48. package/dest/cli/cmds/start_prover_agent.d.ts.map +1 -1
  49. package/dest/cli/cmds/start_prover_agent.js +8 -20
  50. package/dest/cli/cmds/start_prover_broker.d.ts +1 -1
  51. package/dest/cli/cmds/start_prover_broker.d.ts.map +1 -1
  52. package/dest/cli/cmds/start_prover_broker.js +25 -16
  53. package/dest/cli/cmds/start_txe.d.ts +2 -2
  54. package/dest/cli/cmds/start_txe.d.ts.map +1 -1
  55. package/dest/cli/cmds/start_txe.js +6 -5
  56. package/dest/cli/cmds/utils/artifacts.d.ts +26 -0
  57. package/dest/cli/cmds/utils/artifacts.d.ts.map +1 -0
  58. package/dest/cli/cmds/utils/artifacts.js +24 -0
  59. package/dest/cli/cmds/utils/collect_crate_dirs.d.ts +21 -0
  60. package/dest/cli/cmds/utils/collect_crate_dirs.d.ts.map +1 -0
  61. package/dest/cli/cmds/utils/collect_crate_dirs.js +114 -0
  62. package/dest/cli/cmds/utils/needs_recompile.d.ts +10 -0
  63. package/dest/cli/cmds/utils/needs_recompile.d.ts.map +1 -0
  64. package/dest/cli/cmds/utils/needs_recompile.js +90 -0
  65. package/dest/cli/cmds/utils/spawn.d.ts +3 -0
  66. package/dest/cli/cmds/utils/spawn.d.ts.map +1 -0
  67. package/dest/cli/cmds/utils/spawn.js +16 -0
  68. package/dest/cli/cmds/utils/warn_if_aztec_version_mismatch.d.ts +4 -0
  69. package/dest/cli/cmds/utils/warn_if_aztec_version_mismatch.d.ts.map +1 -0
  70. package/dest/cli/cmds/utils/warn_if_aztec_version_mismatch.js +61 -0
  71. package/dest/cli/util.d.ts +14 -20
  72. package/dest/cli/util.d.ts.map +1 -1
  73. package/dest/cli/util.js +38 -101
  74. package/dest/examples/token.js +12 -12
  75. package/dest/examples/util.d.ts +2 -2
  76. package/dest/examples/util.d.ts.map +1 -1
  77. package/dest/local-network/auth_registry.d.ts +5 -0
  78. package/dest/local-network/auth_registry.d.ts.map +1 -0
  79. package/dest/local-network/auth_registry.js +17 -0
  80. package/dest/local-network/banana_fpc.d.ts +3 -2
  81. package/dest/local-network/banana_fpc.d.ts.map +1 -1
  82. package/dest/local-network/banana_fpc.js +14 -10
  83. package/dest/local-network/local-network.d.ts +18 -41
  84. package/dest/local-network/local-network.d.ts.map +1 -1
  85. package/dest/local-network/local-network.js +98 -76
  86. package/dest/testing/cheat_codes.d.ts +19 -23
  87. package/dest/testing/cheat_codes.d.ts.map +1 -1
  88. package/dest/testing/cheat_codes.js +17 -43
  89. package/dest/testing/epoch_test_settler.d.ts +19 -0
  90. package/dest/testing/epoch_test_settler.d.ts.map +1 -0
  91. package/dest/testing/epoch_test_settler.js +42 -0
  92. package/dest/testing/index.d.ts +4 -2
  93. package/dest/testing/index.d.ts.map +1 -1
  94. package/dest/testing/index.js +3 -1
  95. package/dest/testing/local-network.d.ts +51 -0
  96. package/dest/testing/local-network.d.ts.map +1 -0
  97. package/dest/testing/local-network.js +60 -0
  98. package/dest/testing/token_allowed_setup.d.ts +12 -0
  99. package/dest/testing/token_allowed_setup.d.ts.map +1 -0
  100. package/dest/testing/token_allowed_setup.js +24 -0
  101. package/package.json +36 -33
  102. package/scripts/add_crate.sh +53 -0
  103. package/scripts/aztec.sh +26 -9
  104. package/scripts/init.sh +23 -19
  105. package/scripts/new.sh +48 -24
  106. package/scripts/setup_workspace.sh +69 -0
  107. package/scripts/templates/blank/contract/Nargo.toml +6 -0
  108. package/scripts/templates/blank/contract/src/main.nr +10 -0
  109. package/scripts/templates/blank/test/Nargo.toml +7 -0
  110. package/scripts/templates/blank/test/src/lib.nr +11 -0
  111. package/scripts/templates/counter/contract/Nargo.toml +7 -0
  112. package/scripts/templates/counter/contract/src/main.nr +48 -0
  113. package/scripts/templates/counter/test/Nargo.toml +7 -0
  114. package/scripts/templates/counter/test/src/lib.nr +32 -0
  115. package/src/bin/index.ts +15 -5
  116. package/src/cli/admin_api_key_store.ts +128 -0
  117. package/src/cli/aztec_start_action.ts +69 -23
  118. package/src/cli/aztec_start_options.ts +61 -55
  119. package/src/cli/cli.ts +4 -37
  120. package/src/cli/cmds/compile.ts +205 -0
  121. package/src/cli/cmds/migrate_ha_db.ts +43 -0
  122. package/src/cli/cmds/profile.ts +26 -0
  123. package/src/cli/cmds/profile_flamegraph.ts +64 -0
  124. package/src/cli/cmds/profile_gates.ts +84 -0
  125. package/src/cli/cmds/profile_utils.ts +58 -0
  126. package/src/cli/cmds/prover.ts +42 -0
  127. package/src/cli/cmds/standby.ts +184 -0
  128. package/src/cli/cmds/start_bot.ts +18 -12
  129. package/src/cli/cmds/start_node.ts +93 -53
  130. package/src/cli/cmds/start_p2p_bootstrap.ts +3 -3
  131. package/src/cli/cmds/start_prover_agent.ts +9 -20
  132. package/src/cli/cmds/start_prover_broker.ts +29 -26
  133. package/src/cli/cmds/start_txe.ts +7 -5
  134. package/src/cli/cmds/utils/artifacts.ts +49 -0
  135. package/src/cli/cmds/utils/collect_crate_dirs.ts +118 -0
  136. package/src/cli/cmds/utils/needs_recompile.ts +98 -0
  137. package/src/cli/cmds/utils/spawn.ts +16 -0
  138. package/src/cli/cmds/utils/warn_if_aztec_version_mismatch.ts +76 -0
  139. package/src/cli/util.ts +41 -120
  140. package/src/examples/token.ts +21 -13
  141. package/src/examples/util.ts +1 -1
  142. package/src/local-network/auth_registry.ts +19 -0
  143. package/src/local-network/banana_fpc.ts +17 -9
  144. package/src/local-network/local-network.ts +124 -111
  145. package/src/testing/cheat_codes.ts +18 -49
  146. package/src/testing/epoch_test_settler.ts +47 -0
  147. package/src/testing/index.ts +3 -1
  148. package/src/testing/local-network.ts +97 -0
  149. package/src/testing/token_allowed_setup.ts +26 -0
  150. package/dest/cli/cmds/start_archiver.d.ts +0 -9
  151. package/dest/cli/cmds/start_archiver.d.ts.map +0 -1
  152. package/dest/cli/cmds/start_archiver.js +0 -50
  153. package/dest/cli/cmds/start_blob_sink.d.ts +0 -3
  154. package/dest/cli/cmds/start_blob_sink.d.ts.map +0 -1
  155. package/dest/cli/cmds/start_blob_sink.js +0 -33
  156. package/dest/cli/cmds/start_prover_node.d.ts +0 -7
  157. package/dest/cli/cmds/start_prover_node.d.ts.map +0 -1
  158. package/dest/cli/cmds/start_prover_node.js +0 -108
  159. package/dest/cli/release_version.d.ts +0 -2
  160. package/dest/cli/release_version.d.ts.map +0 -1
  161. package/dest/cli/release_version.js +0 -14
  162. package/dest/testing/anvil_test_watcher.d.ts +0 -34
  163. package/dest/testing/anvil_test_watcher.d.ts.map +0 -1
  164. package/dest/testing/anvil_test_watcher.js +0 -144
  165. package/scripts/compile.sh +0 -44
  166. package/scripts/extract_function.js +0 -47
  167. package/scripts/flamegraph.sh +0 -59
  168. package/scripts/setup_project.sh +0 -31
  169. package/src/cli/cmds/start_archiver.ts +0 -61
  170. package/src/cli/cmds/start_blob_sink.ts +0 -57
  171. package/src/cli/cmds/start_prover_node.ts +0 -124
  172. package/src/cli/release_version.ts +0 -21
  173. package/src/testing/anvil_test_watcher.ts +0 -166
package/src/bin/index.ts CHANGED
@@ -2,7 +2,8 @@
2
2
  //
3
3
  import { injectCommands as injectBuilderCommands } from '@aztec/builder';
4
4
  import { injectCommands as injectAztecNodeCommands } from '@aztec/cli/aztec_node';
5
- import { enrichEnvironmentWithChainName, enrichEnvironmentWithNetworkConfig } from '@aztec/cli/config';
5
+ import { enrichEnvironmentWithChainName } from '@aztec/cli/config/chain';
6
+ import { enrichEnvironmentWithNetworkConfig } from '@aztec/cli/config/network';
6
7
  import { injectCommands as injectContractCommands } from '@aztec/cli/contracts';
7
8
  import { injectCommands as injectInfrastructureCommands } from '@aztec/cli/infrastructure';
8
9
  import { injectCommands as injectL1Commands } from '@aztec/cli/l1';
@@ -10,12 +11,17 @@ import { injectCommands as injectMiscCommands } from '@aztec/cli/misc';
10
11
  import { injectCommands as injectValidatorKeysCommands } from '@aztec/cli/validator_keys';
11
12
  import { getActiveNetworkName } from '@aztec/foundation/config';
12
13
  import { createConsoleLogger, createLogger } from '@aztec/foundation/log';
14
+ import { getPackageVersion } from '@aztec/stdlib/update-checker';
13
15
 
14
16
  import { Command } from 'commander';
15
17
 
16
- import { NETWORK_FLAG } from '../cli/aztec_start_options.js';
18
+ import { injectCompileCommand } from '../cli/cmds/compile.js';
19
+ import { injectMigrateCommand } from '../cli/cmds/migrate_ha_db.js';
20
+ import { injectProfileCommand } from '../cli/cmds/profile.js';
21
+ import { injectProverCommand } from '../cli/cmds/prover.js';
17
22
  import { injectAztecCommands } from '../cli/index.js';
18
- import { getCliVersion } from '../cli/release_version.js';
23
+
24
+ const NETWORK_FLAG = 'network';
19
25
 
20
26
  const userLog = createConsoleLogger();
21
27
  const debugLogger = createLogger('cli');
@@ -42,9 +48,9 @@ async function main() {
42
48
  await enrichEnvironmentWithNetworkConfig(networkName);
43
49
  enrichEnvironmentWithChainName(networkName);
44
50
 
45
- const cliVersion = getCliVersion();
51
+ const cliVersion = getPackageVersion();
46
52
  let program = new Command('aztec');
47
- program.description('Aztec command line interface').version(cliVersion);
53
+ program.description('Aztec command line interface').version(cliVersion).enablePositionalOptions();
48
54
  program = injectAztecCommands(program, userLog, debugLogger);
49
55
  program = injectBuilderCommands(program);
50
56
  program = injectContractCommands(program, userLog, debugLogger);
@@ -53,6 +59,10 @@ async function main() {
53
59
  program = injectAztecNodeCommands(program, userLog, debugLogger);
54
60
  program = injectMiscCommands(program, userLog);
55
61
  program = injectValidatorKeysCommands(program, userLog);
62
+ program = injectCompileCommand(program, userLog);
63
+ program = injectProfileCommand(program, userLog);
64
+ program = injectMigrateCommand(program, userLog);
65
+ program = injectProverCommand(program, userLog);
56
66
 
57
67
  await program.parseAsync(process.argv);
58
68
  }
@@ -0,0 +1,128 @@
1
+ import { randomBytes } from '@aztec/foundation/crypto/random';
2
+ import { sha256Hash } from '@aztec/foundation/json-rpc/server';
3
+ import type { Logger } from '@aztec/foundation/log';
4
+
5
+ import { promises as fs } from 'fs';
6
+ import { join } from 'path';
7
+
8
+ /** Subdirectory under dataDirectory for admin API key storage. */
9
+ const ADMIN_STORE_DIR = 'admin';
10
+ const HASH_FILE_NAME = 'api_key_hash';
11
+
12
+ /**
13
+ * Result of resolving the admin API key.
14
+ * Contains the SHA-256 hex hash of the API key to be used by the auth middleware,
15
+ * and optionally the raw key when newly generated (so the caller can display it).
16
+ */
17
+ export interface AdminApiKeyResolution {
18
+ /** The SHA-256 hash of the API key. */
19
+ apiKeyHash: Buffer;
20
+ /**
21
+ * The raw API key, only present when a new key was generated during this call.
22
+ * The caller MUST display this to the operator — it will not be stored or returned again.
23
+ */
24
+ rawKey?: string;
25
+ }
26
+
27
+ export interface ResolveAdminApiKeyOptions {
28
+ /** SHA-256 hex hash of a pre-generated API key. When set, the node uses this hash directly. */
29
+ adminApiKeyHash?: string;
30
+ /** If true, disable admin API key auth entirely. */
31
+ disableAdminApiKey?: boolean;
32
+ /** If true, force-generate a new key even if one is already persisted. */
33
+ resetAdminApiKey?: boolean;
34
+ /** Root data directory for persistent storage. */
35
+ dataDirectory?: string;
36
+ }
37
+
38
+ /**
39
+ * Resolves the admin API key for the admin RPC endpoint.
40
+ *
41
+ * Strategy:
42
+ * 1. If opt-out flag is set (`disableAdminApiKey`), return undefined (no auth).
43
+ * 2. If a pre-generated hash is provided (`adminApiKeyHash`), use it directly.
44
+ * 3. If a data directory exists, look for a persisted hash file
45
+ * at `<dataDirectory>/admin/api_key_hash`:
46
+ * - If `resetAdminApiKey` is set, skip loading and force-generate a new key.
47
+ * - Found: use the stored hash (operator already saved the key from first run).
48
+ * - Not found: auto-generate a random key, display it once, persist the hash.
49
+ * 3. If no data directory: generate a random key
50
+ * each run and display it (cannot persist).
51
+ *
52
+ * @param options - The options for resolving the admin API key.
53
+ * @param log - Logger for outputting the key and status messages.
54
+ * @returns The resolved API key hash, or undefined if auth is disabled.
55
+ */
56
+ export async function resolveAdminApiKey(
57
+ options: ResolveAdminApiKeyOptions,
58
+ log: Logger,
59
+ ): Promise<AdminApiKeyResolution | undefined> {
60
+ // Operator explicitly opted out of admin auth
61
+ if (options.disableAdminApiKey) {
62
+ log.warn('Admin API key authentication is DISABLED (--disable-admin-api-key / AZTEC_DISABLE_ADMIN_API_KEY)');
63
+ return undefined;
64
+ }
65
+
66
+ // Operator provided a pre-generated hash (e.g. via AZTEC_ADMIN_API_KEY_HASH env var)
67
+ if (options.adminApiKeyHash) {
68
+ const hex = options.adminApiKeyHash.trim();
69
+ if (hex.length !== 64 || !/^[0-9a-f]{64}$/.test(hex)) {
70
+ throw new Error(`Invalid admin API key hash: expected 64-char hex string, got "${hex}"`);
71
+ }
72
+ log.info('Admin API key authentication enabled (using pre-configured key hash)');
73
+ return { apiKeyHash: Buffer.from(hex, 'hex') };
74
+ }
75
+
76
+ // Persistent storage available, load or generate key
77
+ if (options.dataDirectory) {
78
+ const adminDir = join(options.dataDirectory, ADMIN_STORE_DIR);
79
+ const hashFilePath = join(adminDir, HASH_FILE_NAME);
80
+
81
+ // Unless a reset is forced, try to load the existing hash from disk
82
+ if (!options.resetAdminApiKey) {
83
+ try {
84
+ const storedHash = (await fs.readFile(hashFilePath, 'utf-8')).trim();
85
+ if (storedHash.length === 64) {
86
+ log.info('Admin API key authentication enabled (loaded stored key hash from disk)');
87
+ return { apiKeyHash: Buffer.from(storedHash, 'hex') };
88
+ }
89
+ log.warn(`Invalid stored admin API key hash at ${hashFilePath}, regenerating...`);
90
+ } catch (err: any) {
91
+ if (err.code !== 'ENOENT') {
92
+ log.warn(`Failed to read admin API key hash from ${hashFilePath}: ${err.message}`);
93
+ }
94
+ // File doesn't exist — fall through to generate
95
+ }
96
+ } else {
97
+ log.warn('Admin API key reset requested — generating a new key');
98
+ }
99
+
100
+ // Generate a new key, persist the hash, and return the raw key for the caller to display
101
+ const { rawKey, hash } = generateApiKey();
102
+ await fs.mkdir(adminDir, { recursive: true });
103
+ await fs.writeFile(hashFilePath, hash.toString('hex'), 'utf-8');
104
+ // Set restrictive permissions (owner read/write only)
105
+ await fs.chmod(hashFilePath, 0o600);
106
+
107
+ log.info('Admin API key authentication enabled (new key generated and hash persisted to disk)');
108
+ return { apiKeyHash: hash, rawKey };
109
+ }
110
+
111
+ // No data directory, generate a temporary key per session
112
+ const { rawKey, hash } = generateApiKey();
113
+
114
+ log.warn('No data directory configured — admin API key cannot be persisted.');
115
+ log.warn('A temporary key has been generated for this session only.');
116
+
117
+ return { apiKeyHash: hash, rawKey };
118
+ }
119
+
120
+ /**
121
+ * Generates a cryptographically random API key and its SHA-256 hash.
122
+ * @returns The raw key (hex string) and its SHA-256 hash as a Buffer.
123
+ */
124
+ function generateApiKey(): { rawKey: string; hash: Buffer } {
125
+ const rawKey = randomBytes(32).toString('hex');
126
+ const hash = sha256Hash(rawKey);
127
+ return { rawKey, hash };
128
+ }
@@ -1,17 +1,20 @@
1
+ import { registerAztecNodeRpcHandlers } from '@aztec/aztec-node';
2
+ import { getActiveNetworkName } from '@aztec/foundation/config';
1
3
  import {
2
4
  type NamespacedApiHandlers,
3
5
  createNamespacedSafeJsonRpcServer,
6
+ getApiKeyAuthMiddleware,
4
7
  startHttpRpcServer,
5
8
  } from '@aztec/foundation/json-rpc/server';
6
9
  import type { LogFn, Logger } from '@aztec/foundation/log';
7
10
  import type { ChainConfig } from '@aztec/stdlib/config';
8
- import { AztecNodeApiSchema } 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,45 +23,39 @@ 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
  {
34
36
  l1Mnemonic: localNetwork.l1Mnemonic,
35
37
  l1RpcUrls: options.l1RpcUrls,
36
- deployAztecContractsSalt: localNetwork.deployAztecContractsSalt,
37
38
  testAccounts: localNetwork.testAccounts,
38
- realProofs: false,
39
39
  },
40
40
  userLog,
41
41
  );
42
42
 
43
43
  // Start Node and PXE JSON-RPC server
44
44
  signalHandlers.push(stop);
45
- services.node = [node, AztecNodeApiSchema];
45
+ registerAztecNodeRpcHandlers(node, services, adminServices, { debug: true });
46
46
  } else {
47
+ // Route --prover-node through startNode
48
+ if (options.proverNode && !options.node) {
49
+ options.node = true;
50
+ }
51
+
47
52
  if (options.node) {
48
53
  const { startNode } = await import('./cmds/start_node.js');
49
- ({ config } = await startNode(options, signalHandlers, services, adminServices, userLog));
54
+ const networkName = getActiveNetworkName(options.network);
55
+ ({ config } = await startNode(options, signalHandlers, services, adminServices, userLog, networkName));
50
56
  } else if (options.bot) {
51
57
  const { startBot } = await import('./cmds/start_bot.js');
52
58
  await startBot(options, signalHandlers, services, userLog);
53
- } else if (options.proverNode) {
54
- const { startProverNode } = await import('./cmds/start_prover_node.js');
55
- ({ config } = await startProverNode(options, signalHandlers, services, userLog));
56
- } else if (options.blobSink) {
57
- const { startBlobSink } = await import('./cmds/start_blob_sink.js');
58
- await startBlobSink(options, signalHandlers, userLog);
59
- } else if (options.archiver) {
60
- const { startArchiver } = await import('./cmds/start_archiver.js');
61
- ({ config } = await startArchiver(options, signalHandlers, services));
62
59
  } else if (options.p2pBootstrap) {
63
60
  const { startP2PBootstrap } = await import('./cmds/start_p2p_bootstrap.js');
64
61
  ({ config } = await startP2PBootstrap(options, signalHandlers, services, userLog));
@@ -70,7 +67,7 @@ export async function aztecStart(options: any, userLog: LogFn, debugLogger: Logg
70
67
  await startProverBroker(options, signalHandlers, services, userLog);
71
68
  } else if (options.txe) {
72
69
  const { startTXE } = await import('./cmds/start_txe.js');
73
- await startTXE(options, debugLogger);
70
+ await startTXE(options, signalHandlers, debugLogger);
74
71
  } else if (options.sequencer) {
75
72
  userLog(`Cannot run a standalone sequencer without a node`);
76
73
  process.exit(1);
@@ -82,13 +79,21 @@ export async function aztecStart(options: any, userLog: LogFn, debugLogger: Logg
82
79
 
83
80
  installSignalHandlers(debugLogger.info, signalHandlers);
84
81
  const versions = getVersions(config);
82
+ const versioningOpts = { packageVersion };
85
83
 
86
84
  // Start the main JSON-RPC server
87
85
  if (Object.entries(services).length > 0) {
86
+ if (services.aztec) {
87
+ const { BarretenbergSync } = await import('@aztec/bb.js');
88
+ // JSON-RPC schema parsing may decompress compressed Chonk proofs before the node handler runs.
89
+ await BarretenbergSync.initSingleton();
90
+ }
91
+
88
92
  const rpcServer = createNamespacedSafeJsonRpcServer(services, {
93
+ diagnostic: getOtelJsonRpcDiagnosticsMiddleware(),
89
94
  http200OnError: false,
90
95
  log: debugLogger,
91
- middlewares: [getOtelJsonRpcPropagationMiddleware(), getVersioningMiddleware(versions)],
96
+ middlewares: [getOtelJsonRpcPropagationMiddleware(), getVersioningMiddleware(versions, versioningOpts)],
92
97
  maxBatchSize: options.rpcMaxBatchSize,
93
98
  maxBodySizeBytes: options.rpcMaxBodySize,
94
99
  });
@@ -98,14 +103,55 @@ export async function aztecStart(options: any, userLog: LogFn, debugLogger: Logg
98
103
 
99
104
  // If there are any admin services, start a separate JSON-RPC server for them
100
105
  if (Object.entries(adminServices).length > 0) {
106
+ const adminMiddlewares = [getOtelJsonRpcPropagationMiddleware(), getVersioningMiddleware(versions, versioningOpts)];
107
+
108
+ // Resolve the admin API key (auto-generated and persisted, or opt-out)
109
+ const apiKeyResolution = await resolveAdminApiKey(
110
+ {
111
+ adminApiKeyHash: options.adminApiKeyHash,
112
+ disableAdminApiKey: options.disableAdminApiKey,
113
+ resetAdminApiKey: options.resetAdminApiKey,
114
+ dataDirectory: options.dataDirectory,
115
+ },
116
+ debugLogger,
117
+ );
118
+ if (apiKeyResolution) {
119
+ adminMiddlewares.unshift(getApiKeyAuthMiddleware(apiKeyResolution.apiKeyHash));
120
+ } else {
121
+ debugLogger.warn('No admin API key set — admin endpoint is unauthenticated');
122
+ }
123
+
101
124
  const rpcServer = createNamespacedSafeJsonRpcServer(adminServices, {
125
+ diagnostic: getOtelJsonRpcDiagnosticsMiddleware(),
102
126
  http200OnError: false,
103
127
  log: debugLogger,
104
- middlewares: [getOtelJsonRpcPropagationMiddleware(), getVersioningMiddleware(versions)],
128
+ middlewares: adminMiddlewares,
105
129
  maxBatchSize: options.rpcMaxBatchSize,
106
130
  maxBodySizeBytes: options.rpcMaxBodySize,
107
131
  });
108
132
  const { port } = await startHttpRpcServer(rpcServer, { port: options.adminPort });
109
133
  debugLogger.info(`Aztec Server admin API listening on port ${port}`, versions);
134
+
135
+ // Display the API key after the server has started
136
+ // Uses userLog which is never filtered by LOG_LEVEL.
137
+ if (apiKeyResolution?.rawKey) {
138
+ const separator = '='.repeat(70);
139
+ userLog('');
140
+ userLog(separator);
141
+ userLog(' ADMIN API KEY (save this — it will NOT be shown again)');
142
+ userLog('');
143
+ userLog(` ${apiKeyResolution.rawKey}`);
144
+ userLog('');
145
+ userLog(` Use via header: x-api-key: <key>`);
146
+ userLog(` Or via header: Authorization: Bearer <key>`);
147
+ if (options.dataDirectory) {
148
+ userLog('');
149
+ userLog(' The key hash has been persisted — on next restart, the same key will be used.');
150
+ }
151
+ userLog('');
152
+ userLog(' To disable admin auth: --disable-admin-api-key or AZTEC_DISABLE_ADMIN_API_KEY=true');
153
+ userLog(separator);
154
+ userLog('');
155
+ }
110
156
  }
111
157
  }
@@ -1,8 +1,9 @@
1
1
  import { type ArchiverConfig, archiverConfigMappings } from '@aztec/archiver/config';
2
- import { sequencerClientConfigMappings } from '@aztec/aztec-node/config';
3
- import { blobSinkConfigMappings } from '@aztec/blob-sink/server';
2
+ import { blobClientConfigMapping } from '@aztec/blob-client/client/config';
4
3
  import { botConfigMappings } from '@aztec/bot/config';
5
- import { l1ContractAddressesMapping, l1ContractsConfigMappings, l1ReaderConfigMappings } from '@aztec/ethereum';
4
+ import { l1ContractsConfigMappings } from '@aztec/ethereum/config';
5
+ import { l1ContractAddressesMapping } from '@aztec/ethereum/l1-contract-addresses';
6
+ import { l1ReaderConfigMappings } from '@aztec/ethereum/l1-reader';
6
7
  import { getKeys } from '@aztec/foundation/collection';
7
8
  import {
8
9
  type ConfigMapping,
@@ -11,15 +12,16 @@ import {
11
12
  isBooleanConfigValue,
12
13
  omitConfigMappings,
13
14
  } from '@aztec/foundation/config';
14
- import { dataConfigMappings } from '@aztec/kv-store/config';
15
15
  import { sharedNodeConfigMappings } from '@aztec/node-lib/config';
16
16
  import { bootnodeConfigMappings, p2pConfigMappings } from '@aztec/p2p/config';
17
- import { proverAgentConfigMappings, proverBrokerConfigMappings } from '@aztec/prover-client/broker';
17
+ import { proverAgentConfigMappings, proverBrokerConfigMappings } from '@aztec/prover-client/broker/config';
18
18
  import { proverNodeConfigMappings } from '@aztec/prover-node/config';
19
19
  import { allPxeConfigMappings } from '@aztec/pxe/config';
20
- import { chainConfigMappings } from '@aztec/stdlib/config';
21
- import { telemetryClientConfigMappings } from '@aztec/telemetry-client';
22
- import { worldStateConfigMappings } from '@aztec/world-state';
20
+ import { sequencerClientConfigMappings } from '@aztec/sequencer-client/config';
21
+ import { chainConfigMappings, nodeRpcConfigMappings } from '@aztec/stdlib/config';
22
+ import { dataConfigMappings } from '@aztec/stdlib/kv-store';
23
+ import { telemetryClientConfigMappings } from '@aztec/telemetry-client/config';
24
+ import { worldStateConfigMappings } from '@aztec/world-state/config';
23
25
 
24
26
  import { DefaultMnemonic } from '../mnemonic.js';
25
27
 
@@ -34,7 +36,7 @@ export interface AztecStartOption {
34
36
  parseVal?: (val: string) => any;
35
37
  }
36
38
 
37
- export const getOptions = (namespace: string, configMappings: Record<string, ConfigMapping>) => {
39
+ export const getOptions = (namespace: string, configMappings: Record<string, ConfigMapping<unknown>>) => {
38
40
  const options: AztecStartOption[] = [];
39
41
  for (const [key, { env, defaultValue: def, parseEnv, description, printDefault, fallback }] of Object.entries(
40
42
  configMappings,
@@ -56,7 +58,11 @@ export const getOptions = (namespace: string, configMappings: Record<string, Con
56
58
  return options;
57
59
  };
58
60
 
59
- const configToFlag = (flag: string, configMapping: ConfigMapping, overrideDefaultValue?: any): AztecStartOption => {
61
+ const configToFlag = (
62
+ flag: string,
63
+ configMapping: ConfigMapping<unknown>,
64
+ overrideDefaultValue?: any,
65
+ ): AztecStartOption => {
60
66
  if (!configMapping.isBoolean) {
61
67
  flag += ' <value>';
62
68
  }
@@ -103,8 +109,7 @@ export const aztecStartOptions: { [key: string]: AztecStartOption[] } = {
103
109
  env: 'NETWORK',
104
110
  },
105
111
 
106
- configToFlag('--auto-update', sharedNodeConfigMappings.autoUpdate),
107
- configToFlag('--auto-update-url', sharedNodeConfigMappings.autoUpdateUrl),
112
+ configToFlag('--enable-auto-shutdown', sharedNodeConfigMappings.enableAutoShutdown),
108
113
 
109
114
  configToFlag('--sync-mode', sharedNodeConfigMappings.syncMode),
110
115
  configToFlag('--snapshots-urls', sharedNodeConfigMappings.snapshotsUrls),
@@ -125,12 +130,10 @@ export const aztecStartOptions: { [key: string]: AztecStartOption[] } = {
125
130
  env: 'MNEMONIC',
126
131
  },
127
132
  {
128
- flag: '--local-network.deployAztecContractsSalt <value>',
129
- description:
130
- 'Numeric salt for deploying L1 Aztec contracts before starting the local network. Needs mnemonic or private key to be set.',
131
- env: 'DEPLOY_AZTEC_CONTRACTS_SALT',
132
- defaultValue: undefined,
133
- parseVal: (val: string) => (val ? parseInt(val) : undefined),
133
+ flag: '--local-network.testAccounts',
134
+ description: 'Deploy test accounts on local network start',
135
+ env: 'TEST_ACCOUNTS',
136
+ ...booleanConfigHelper(true),
134
137
  },
135
138
  ],
136
139
  API: [
@@ -148,20 +151,53 @@ export const aztecStartOptions: { [key: string]: AztecStartOption[] } = {
148
151
  env: 'AZTEC_ADMIN_PORT',
149
152
  parseVal: val => parseInt(val, 10),
150
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
+ },
151
185
  {
152
186
  flag: '--api-prefix <value>',
153
187
  description: 'Prefix for API routes on any service that is started',
154
188
  defaultValue: '',
155
189
  env: 'API_PREFIX',
156
190
  },
191
+ configToFlag('--rpcMaxBatchSize', nodeRpcConfigMappings.rpcMaxBatchSize),
192
+ configToFlag('--rpcMaxBodySize', nodeRpcConfigMappings.rpcMaxBodySize),
157
193
  ],
158
194
  ETHEREUM: [
159
195
  configToFlag('--l1-chain-id', l1ReaderConfigMappings.l1ChainId),
160
196
  // Do not set default for CLI: keep undefined unless provided via flag or env
161
197
  configToFlag('--l1-rpc-urls', { ...l1ReaderConfigMappings.l1RpcUrls, defaultValue: undefined }),
162
- configToFlag('--l1-consensus-host-urls', blobSinkConfigMappings.l1ConsensusHostUrls),
163
- configToFlag('--l1-consensus-host-api-keys', blobSinkConfigMappings.l1ConsensusHostApiKeys),
164
- configToFlag('--l1-consensus-host-api-key-headers', blobSinkConfigMappings.l1ConsensusHostApiKeyHeaders),
198
+ configToFlag('--l1-consensus-host-urls', blobClientConfigMapping.l1ConsensusHostUrls),
199
+ configToFlag('--l1-consensus-host-api-keys', blobClientConfigMapping.l1ConsensusHostApiKeys),
200
+ configToFlag('--l1-consensus-host-api-key-headers', blobClientConfigMapping.l1ConsensusHostApiKeyHeaders),
165
201
  ],
166
202
  'L1 CONTRACTS': [
167
203
  configToFlag('--registry-address', l1ContractAddressesMapping.registryAddress),
@@ -174,7 +210,7 @@ export const aztecStartOptions: { [key: string]: AztecStartOption[] } = {
174
210
  'WORLD STATE': [
175
211
  configToFlag('--world-state-data-directory', worldStateConfigMappings.worldStateDataDirectory),
176
212
  configToFlag('--world-state-db-map-size-kb', worldStateConfigMappings.worldStateDbMapSizeKb),
177
- configToFlag('--world-state-block-history', worldStateConfigMappings.worldStateBlockHistory),
213
+ configToFlag('--world-state-checkpoint-history', worldStateConfigMappings.worldStateCheckpointHistory),
178
214
  ],
179
215
  // We can't easily auto-generate node options as they're parts of modules defined below
180
216
  'AZTEC NODE': [
@@ -186,12 +222,6 @@ export const aztecStartOptions: { [key: string]: AztecStartOption[] } = {
186
222
  },
187
223
  ],
188
224
  ARCHIVER: [
189
- {
190
- flag: '--archiver',
191
- description: 'Starts Aztec Archiver with options',
192
- defaultValue: undefined,
193
- env: undefined,
194
- },
195
225
  ...getOptions(
196
226
  'archiver',
197
227
  omitConfigMappings(archiverConfigMappings, Object.keys(l1ContractsConfigMappings) as (keyof ArchiverConfig)[]),
@@ -208,21 +238,13 @@ export const aztecStartOptions: { [key: string]: AztecStartOption[] } = {
208
238
  'sequencer',
209
239
  omitConfigMappings(sequencerClientConfigMappings, [
210
240
  'fakeProcessingDelayPerTxMs',
241
+ 'fakeThrowAfterProcessingTxCount',
211
242
  'skipCollectingAttestations',
212
243
  'skipInvalidateBlockAsProposer',
213
244
  'blobSinkMapSizeKb',
214
245
  ]),
215
246
  ),
216
247
  ],
217
- 'BLOB SINK': [
218
- {
219
- flag: '--blob-sink',
220
- description: 'Starts Aztec Blob Sink with options',
221
- defaultValue: undefined,
222
- env: undefined,
223
- },
224
- ...getOptions('blobSink', blobSinkConfigMappings),
225
- ],
226
248
  'PROVER NODE': [
227
249
  {
228
250
  flag: '--prover-node',
@@ -234,12 +256,8 @@ export const aztecStartOptions: { [key: string]: AztecStartOption[] } = {
234
256
  'proverNode',
235
257
  omitConfigMappings(proverNodeConfigMappings, [
236
258
  // filter out options passed separately
237
- ...getKeys(archiverConfigMappings),
238
259
  ...getKeys(proverBrokerConfigMappings),
239
260
  ...getKeys(proverAgentConfigMappings),
240
- ...getKeys(p2pConfigMappings),
241
- ...getKeys(worldStateConfigMappings),
242
- ...getKeys(sharedNodeConfigMappings),
243
261
  ]),
244
262
  ),
245
263
  ],
@@ -250,11 +268,7 @@ export const aztecStartOptions: { [key: string]: AztecStartOption[] } = {
250
268
  defaultValue: undefined,
251
269
  env: undefined,
252
270
  },
253
- ...getOptions(
254
- 'proverBroker',
255
- // filter out archiver options from prover node options as they're passed separately in --archiver
256
- proverBrokerConfigMappings,
257
- ),
271
+ ...getOptions('proverBroker', proverBrokerConfigMappings),
258
272
  ],
259
273
  'PROVER AGENT': [
260
274
  {
@@ -302,15 +316,7 @@ export const aztecStartOptions: { [key: string]: AztecStartOption[] } = {
302
316
  },
303
317
  ...getOptions('bot', botConfigMappings),
304
318
  ],
305
- PXE: [
306
- {
307
- flag: '--pxe',
308
- description: 'Starts Aztec PXE with options',
309
- defaultValue: undefined,
310
- env: undefined,
311
- },
312
- ...getOptions('pxe', allPxeConfigMappings),
313
- ],
319
+ PXE: [...getOptions('pxe', allPxeConfigMappings)],
314
320
  TXE: [
315
321
  {
316
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
  }