@aztec/aztec 0.0.0-test.0 → 0.0.1-commit.03f7ef2

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 (148) hide show
  1. package/README.md +1 -1
  2. package/dest/bin/index.d.ts +1 -1
  3. package/dest/bin/index.js +21 -12
  4. package/dest/cli/aztec_start_action.d.ts +1 -1
  5. package/dest/cli/aztec_start_action.d.ts.map +1 -1
  6. package/dest/cli/aztec_start_action.js +35 -40
  7. package/dest/cli/aztec_start_options.d.ts +5 -3
  8. package/dest/cli/aztec_start_options.d.ts.map +1 -1
  9. package/dest/cli/aztec_start_options.js +143 -224
  10. package/dest/cli/cli.d.ts +1 -1
  11. package/dest/cli/cli.d.ts.map +1 -1
  12. package/dest/cli/cli.js +39 -2
  13. package/dest/cli/cmds/start_archiver.d.ts +1 -1
  14. package/dest/cli/cmds/start_archiver.d.ts.map +1 -1
  15. package/dest/cli/cmds/start_archiver.js +20 -12
  16. package/dest/cli/cmds/start_bot.d.ts +4 -7
  17. package/dest/cli/cmds/start_bot.d.ts.map +1 -1
  18. package/dest/cli/cmds/start_bot.js +25 -14
  19. package/dest/cli/cmds/start_node.d.ts +2 -2
  20. package/dest/cli/cmds/start_node.d.ts.map +1 -1
  21. package/dest/cli/cmds/start_node.js +68 -81
  22. package/dest/cli/cmds/start_p2p_bootstrap.d.ts +1 -1
  23. package/dest/cli/cmds/start_p2p_bootstrap.d.ts.map +1 -1
  24. package/dest/cli/cmds/start_p2p_bootstrap.js +9 -4
  25. package/dest/cli/cmds/start_prover_agent.d.ts +1 -1
  26. package/dest/cli/cmds/start_prover_agent.d.ts.map +1 -1
  27. package/dest/cli/cmds/start_prover_agent.js +32 -3
  28. package/dest/cli/cmds/start_prover_broker.d.ts +1 -1
  29. package/dest/cli/cmds/start_prover_broker.d.ts.map +1 -1
  30. package/dest/cli/cmds/start_prover_broker.js +10 -4
  31. package/dest/cli/cmds/start_prover_node.d.ts +1 -1
  32. package/dest/cli/cmds/start_prover_node.d.ts.map +1 -1
  33. package/dest/cli/cmds/start_prover_node.js +44 -46
  34. package/dest/cli/cmds/start_txe.d.ts +1 -1
  35. package/dest/cli/index.d.ts +1 -1
  36. package/dest/cli/preload_crs.d.ts +3 -0
  37. package/dest/cli/preload_crs.d.ts.map +1 -0
  38. package/dest/cli/preload_crs.js +6 -0
  39. package/dest/cli/release_version.d.ts +2 -0
  40. package/dest/cli/release_version.d.ts.map +1 -0
  41. package/dest/cli/release_version.js +14 -0
  42. package/dest/cli/util.d.ts +38 -7
  43. package/dest/cli/util.d.ts.map +1 -1
  44. package/dest/cli/util.js +198 -28
  45. package/dest/cli/versioning.d.ts +1 -1
  46. package/dest/cli/versioning.js +3 -3
  47. package/dest/examples/token.d.ts +1 -1
  48. package/dest/examples/token.js +31 -18
  49. package/dest/examples/util.d.ts +5 -6
  50. package/dest/examples/util.d.ts.map +1 -1
  51. package/dest/examples/util.js +5 -6
  52. package/dest/index.d.ts +2 -2
  53. package/dest/index.d.ts.map +1 -1
  54. package/dest/index.js +1 -1
  55. package/dest/local-network/banana_fpc.d.ts +10 -0
  56. package/dest/local-network/banana_fpc.d.ts.map +1 -0
  57. package/dest/{sandbox → local-network}/banana_fpc.js +20 -22
  58. package/dest/local-network/index.d.ts +4 -0
  59. package/dest/local-network/index.d.ts.map +1 -0
  60. package/dest/local-network/index.js +3 -0
  61. package/dest/local-network/local-network.d.ts +72 -0
  62. package/dest/local-network/local-network.d.ts.map +1 -0
  63. package/dest/local-network/local-network.js +182 -0
  64. package/dest/local-network/sponsored_fpc.d.ts +5 -0
  65. package/dest/local-network/sponsored_fpc.d.ts.map +1 -0
  66. package/dest/local-network/sponsored_fpc.js +18 -0
  67. package/dest/mnemonic.d.ts +1 -1
  68. package/dest/splash.d.ts +1 -1
  69. package/dest/testing/anvil_test_watcher.d.ts +34 -0
  70. package/dest/testing/anvil_test_watcher.d.ts.map +1 -0
  71. package/dest/testing/anvil_test_watcher.js +144 -0
  72. package/dest/testing/cheat_codes.d.ts +41 -0
  73. package/dest/testing/cheat_codes.d.ts.map +1 -0
  74. package/dest/testing/cheat_codes.js +62 -0
  75. package/dest/testing/index.d.ts +4 -0
  76. package/dest/testing/index.d.ts.map +1 -0
  77. package/dest/testing/index.js +3 -0
  78. package/package.json +54 -45
  79. package/scripts/aztec.sh +56 -0
  80. package/scripts/compile.sh +44 -0
  81. package/scripts/extract_function.js +47 -0
  82. package/scripts/flamegraph.sh +59 -0
  83. package/scripts/init.sh +35 -0
  84. package/scripts/new.sh +59 -0
  85. package/scripts/setup_project.sh +31 -0
  86. package/src/bin/index.ts +26 -12
  87. package/src/cli/aztec_start_action.ts +31 -38
  88. package/src/cli/aztec_start_options.ts +159 -222
  89. package/src/cli/cli.ts +46 -5
  90. package/src/cli/cmds/start_archiver.ts +21 -15
  91. package/src/cli/cmds/start_bot.ts +36 -13
  92. package/src/cli/cmds/start_node.ts +91 -86
  93. package/src/cli/cmds/start_p2p_bootstrap.ts +12 -4
  94. package/src/cli/cmds/start_prover_agent.ts +23 -3
  95. package/src/cli/cmds/start_prover_broker.ts +24 -4
  96. package/src/cli/cmds/start_prover_node.ts +54 -51
  97. package/src/cli/preload_crs.ts +7 -0
  98. package/src/cli/release_version.ts +21 -0
  99. package/src/cli/util.ts +208 -34
  100. package/src/cli/versioning.ts +3 -3
  101. package/src/examples/token.ts +23 -19
  102. package/src/examples/util.ts +6 -8
  103. package/src/index.ts +5 -6
  104. package/src/{sandbox → local-network}/banana_fpc.ts +21 -26
  105. package/src/local-network/index.ts +7 -0
  106. package/src/local-network/local-network.ts +222 -0
  107. package/src/local-network/sponsored_fpc.ts +26 -0
  108. package/src/testing/anvil_test_watcher.ts +166 -0
  109. package/src/testing/cheat_codes.ts +79 -0
  110. package/src/testing/index.ts +3 -0
  111. package/dest/cli/chain_l2_config.d.ts +0 -19
  112. package/dest/cli/chain_l2_config.d.ts.map +0 -1
  113. package/dest/cli/chain_l2_config.js +0 -56
  114. package/dest/cli/cmds/start_blob_sink.d.ts +0 -3
  115. package/dest/cli/cmds/start_blob_sink.d.ts.map +0 -1
  116. package/dest/cli/cmds/start_blob_sink.js +0 -17
  117. package/dest/cli/cmds/start_faucet.d.ts +0 -4
  118. package/dest/cli/cmds/start_faucet.d.ts.map +0 -1
  119. package/dest/cli/cmds/start_faucet.js +0 -20
  120. package/dest/cli/cmds/start_pxe.d.ts +0 -16
  121. package/dest/cli/cmds/start_pxe.d.ts.map +0 -1
  122. package/dest/cli/cmds/start_pxe.js +0 -95
  123. package/dest/cli/get_l1_config.d.ts +0 -7
  124. package/dest/cli/get_l1_config.d.ts.map +0 -1
  125. package/dest/cli/get_l1_config.js +0 -13
  126. package/dest/sandbox/banana_fpc.d.ts +0 -11
  127. package/dest/sandbox/banana_fpc.d.ts.map +0 -1
  128. package/dest/sandbox/index.d.ts +0 -5
  129. package/dest/sandbox/index.d.ts.map +0 -1
  130. package/dest/sandbox/index.js +0 -4
  131. package/dest/sandbox/sandbox.d.ts +0 -76
  132. package/dest/sandbox/sandbox.d.ts.map +0 -1
  133. package/dest/sandbox/sandbox.js +0 -181
  134. package/dest/sandbox/sponsored_fee_payment_method.d.ts +0 -23
  135. package/dest/sandbox/sponsored_fee_payment_method.d.ts.map +0 -1
  136. package/dest/sandbox/sponsored_fee_payment_method.js +0 -36
  137. package/dest/sandbox/sponsored_fpc.d.ts +0 -6
  138. package/dest/sandbox/sponsored_fpc.d.ts.map +0 -1
  139. package/dest/sandbox/sponsored_fpc.js +0 -26
  140. package/src/cli/chain_l2_config.ts +0 -74
  141. package/src/cli/cmds/start_blob_sink.ts +0 -31
  142. package/src/cli/cmds/start_faucet.ts +0 -34
  143. package/src/cli/cmds/start_pxe.ts +0 -129
  144. package/src/cli/get_l1_config.ts +0 -18
  145. package/src/sandbox/index.ts +0 -5
  146. package/src/sandbox/sandbox.ts +0 -229
  147. package/src/sandbox/sponsored_fee_payment_method.ts +0 -46
  148. package/src/sandbox/sponsored_fpc.ts +0 -38
package/src/cli/cli.ts CHANGED
@@ -31,18 +31,59 @@ export function injectAztecCommands(program: Command, userLog: LogFn, debugLogge
31
31
 
32
32
  program.configureHelp({ sortSubcommands: true });
33
33
 
34
- program.addHelpText(
35
- 'after',
36
- `
34
+ if (process.env.AZTEC_SHELL_WRAPPER) {
35
+ program.addHelpText(
36
+ 'after',
37
+ `
37
38
 
38
39
  Additional commands:
39
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
+
40
68
  test [options]: starts a dockerized TXE node via
41
69
  $ aztec start --txe
42
70
  then runs
43
- $ aztec-nargo test --silence-warnings --oracle-resolver=<TXE_ADDRESS> [options]
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
44
76
  `,
45
- );
77
+ );
78
+ }
79
+
80
+ program
81
+ .command('preload-crs')
82
+ .description('Preload the points data needed for proving and verifying')
83
+ .action(async options => {
84
+ const { preloadCrs } = await import('./preload_crs.js');
85
+ return await preloadCrs(options, userLog, debugLogger);
86
+ });
46
87
 
47
88
  return program;
48
89
  }
@@ -1,13 +1,19 @@
1
- import { Archiver, type ArchiverConfig, KVArchiverDataStore, archiverConfigMappings } from '@aztec/archiver';
2
- import { createLogger } from '@aztec/aztec.js';
3
- import { createBlobSinkClient } from '@aztec/blob-sink/client';
1
+ import {
2
+ Archiver,
3
+ type ArchiverConfig,
4
+ KVArchiverDataStore,
5
+ archiverConfigMappings,
6
+ getArchiverConfigFromEnv,
7
+ } from '@aztec/archiver';
8
+ import { createLogger } from '@aztec/aztec.js/log';
9
+ import { type BlobClientConfig, blobClientConfigMapping, createBlobClient } from '@aztec/blob-client/client';
10
+ import { getL1Config } from '@aztec/cli/config';
4
11
  import type { NamespacedApiHandlers } from '@aztec/foundation/json-rpc/server';
5
12
  import { type DataStoreConfig, dataConfigMappings } from '@aztec/kv-store/config';
6
13
  import { createStore } from '@aztec/kv-store/lmdb-v2';
7
14
  import { ArchiverApiSchema } from '@aztec/stdlib/interfaces/server';
8
15
  import { getConfigEnvVars as getTelemetryClientConfig, initTelemetryClient } from '@aztec/telemetry-client';
9
16
 
10
- import { getL1Config } from '../get_l1_config.js';
11
17
  import { extractRelevantOptions } from '../util.js';
12
18
 
13
19
  export type { ArchiverConfig, DataStoreConfig };
@@ -18,36 +24,36 @@ export async function startArchiver(
18
24
  signalHandlers: (() => Promise<void>)[],
19
25
  services: NamespacedApiHandlers,
20
26
  ): Promise<{ config: ArchiverConfig & DataStoreConfig }> {
21
- let archiverConfig = extractRelevantOptions<ArchiverConfig & DataStoreConfig>(
27
+ const envConfig = getArchiverConfigFromEnv();
28
+ const cliOptions = extractRelevantOptions<ArchiverConfig & DataStoreConfig & BlobClientConfig>(
22
29
  options,
23
- {
24
- ...archiverConfigMappings,
25
- ...dataConfigMappings,
26
- },
30
+ { ...archiverConfigMappings, ...dataConfigMappings, ...blobClientConfigMapping },
27
31
  'archiver',
28
32
  );
29
33
 
34
+ let archiverConfig = { ...envConfig, ...cliOptions };
35
+ archiverConfig.dataStoreMapSizeKb = archiverConfig.archiverStoreMapSizeKb ?? archiverConfig.dataStoreMapSizeKb;
36
+
30
37
  if (!archiverConfig.l1Contracts.registryAddress || archiverConfig.l1Contracts.registryAddress.isZero()) {
31
38
  throw new Error('L1 registry address is required to start an Archiver');
32
39
  }
33
40
 
34
- const { addresses, config } = await getL1Config(
41
+ const { addresses, config: l1Config } = await getL1Config(
35
42
  archiverConfig.l1Contracts.registryAddress,
36
43
  archiverConfig.l1RpcUrls,
37
44
  archiverConfig.l1ChainId,
38
45
  );
39
46
 
40
47
  archiverConfig.l1Contracts = addresses;
41
- archiverConfig = { ...archiverConfig, ...config };
48
+ archiverConfig = { ...archiverConfig, ...l1Config };
42
49
 
43
50
  const storeLog = createLogger('archiver:lmdb');
44
51
  const store = await createStore('archiver', KVArchiverDataStore.SCHEMA_VERSION, archiverConfig, storeLog);
45
52
  const archiverStore = new KVArchiverDataStore(store, archiverConfig.maxLogs);
46
53
 
47
- const telemetry = initTelemetryClient(getTelemetryClientConfig());
48
- // TODO(https://github.com/AztecProtocol/aztec-packages/issues/10056): place CL url in config here
49
- const blobSinkClient = createBlobSinkClient();
50
- const archiver = await Archiver.createAndSync(archiverConfig, archiverStore, { telemetry, blobSinkClient }, true);
54
+ const telemetry = await initTelemetryClient(getTelemetryClientConfig());
55
+ const blobClient = createBlobClient(archiverConfig, { logger: createLogger('archiver:blob-client:client') });
56
+ const archiver = await Archiver.createAndSync(archiverConfig, archiverStore, { telemetry, blobClient }, true);
51
57
  services.archiver = [archiver, ArchiverApiSchema];
52
58
  signalHandlers.push(archiver.stop);
53
59
 
@@ -1,11 +1,19 @@
1
- import { type BotConfig, BotRunner, botConfigMappings, getBotRunnerApiHandler } from '@aztec/bot';
1
+ import { type BotConfig, BotRunner, BotStore, botConfigMappings, getBotRunnerApiHandler } from '@aztec/bot';
2
2
  import type { NamespacedApiHandlers } from '@aztec/foundation/json-rpc/server';
3
3
  import type { LogFn } from '@aztec/foundation/log';
4
- import type { AztecNode, PXE } from '@aztec/stdlib/interfaces/client';
4
+ import { createStore, openTmpStore } from '@aztec/kv-store/lmdb-v2';
5
+ import { type CliPXEOptions, type PXEConfig, allPxeConfigMappings } from '@aztec/pxe/config';
6
+ import { type AztecNode, type AztecNodeAdmin, createAztecNodeClient } from '@aztec/stdlib/interfaces/client';
5
7
  import type { TelemetryClient } from '@aztec/telemetry-client';
6
- import { getConfigEnvVars as getTelemetryClientConfig, initTelemetryClient } from '@aztec/telemetry-client';
8
+ import {
9
+ getConfigEnvVars as getTelemetryClientConfig,
10
+ initTelemetryClient,
11
+ makeTracedFetch,
12
+ } from '@aztec/telemetry-client';
13
+ import { TestWallet } from '@aztec/test-wallet/server';
7
14
 
8
15
  import { extractRelevantOptions } from '../util.js';
16
+ import { getVersions } from '../versioning.js';
9
17
 
10
18
  export async function startBot(
11
19
  options: any,
@@ -20,26 +28,41 @@ export async function startBot(
20
28
  );
21
29
  process.exit(1);
22
30
  }
23
- // Start a PXE client that is used by the bot if required
24
- let pxe: PXE | undefined;
25
- if (options.pxe) {
26
- const { addPXE } = await import('./start_pxe.js');
27
- ({ pxe } = await addPXE(options, signalHandlers, services, userLog));
31
+
32
+ const fetch = makeTracedFetch([1, 2, 3], true);
33
+ const config = extractRelevantOptions<BotConfig>(options, botConfigMappings, 'bot');
34
+ if (!config.nodeUrl) {
35
+ throw new Error('The bot requires access to a Node');
28
36
  }
29
37
 
30
- const telemetry = initTelemetryClient(getTelemetryClientConfig());
31
- await addBot(options, signalHandlers, services, { pxe, telemetry });
38
+ const aztecNode = createAztecNodeClient(config.nodeUrl, getVersions(), fetch);
39
+
40
+ const pxeConfig = extractRelevantOptions<PXEConfig & CliPXEOptions>(options, allPxeConfigMappings, 'pxe');
41
+ const wallet = await TestWallet.create(aztecNode, pxeConfig);
42
+
43
+ const telemetry = await initTelemetryClient(getTelemetryClientConfig());
44
+ await addBot(options, signalHandlers, services, wallet, aztecNode, telemetry, undefined);
32
45
  }
33
46
 
34
- export function addBot(
47
+ export async function addBot(
35
48
  options: any,
36
49
  signalHandlers: (() => Promise<void>)[],
37
50
  services: NamespacedApiHandlers,
38
- deps: { pxe?: PXE; node?: AztecNode; telemetry: TelemetryClient },
51
+ wallet: TestWallet,
52
+ aztecNode: AztecNode,
53
+ telemetry: TelemetryClient,
54
+ aztecNodeAdmin?: AztecNodeAdmin,
39
55
  ) {
40
56
  const config = extractRelevantOptions<BotConfig>(options, botConfigMappings, 'bot');
41
57
 
42
- const botRunner = new BotRunner(config, deps);
58
+ const db = await (config.dataDirectory
59
+ ? createStore('bot', BotStore.SCHEMA_VERSION, config)
60
+ : openTmpStore('bot', true, config.dataStoreMapSizeKb));
61
+
62
+ const store = new BotStore(db);
63
+ await store.cleanupOldClaims();
64
+
65
+ const botRunner = new BotRunner(config, wallet, aztecNode, telemetry, aztecNodeAdmin, store);
43
66
  if (!config.noStart) {
44
67
  void botRunner.start(); // Do not block since bot setup takes time
45
68
  }
@@ -1,35 +1,48 @@
1
- import { getInitialTestAccounts } from '@aztec/accounts/testing';
1
+ import { getInitialTestAccountsData } from '@aztec/accounts/testing';
2
2
  import { type AztecNodeConfig, aztecNodeConfigMappings, getConfigEnvVars } from '@aztec/aztec-node';
3
- import { NULL_KEY } from '@aztec/ethereum';
3
+ import { Fr } from '@aztec/aztec.js/fields';
4
+ import { getSponsoredFPCAddress } from '@aztec/cli/cli-utils';
5
+ import { getL1Config } from '@aztec/cli/config';
6
+ import { getPublicClient } from '@aztec/ethereum/client';
7
+ import { SecretValue } from '@aztec/foundation/config';
4
8
  import type { NamespacedApiHandlers } from '@aztec/foundation/json-rpc/server';
5
9
  import type { LogFn } from '@aztec/foundation/log';
6
- import { AztecNodeApiSchema, type PXE } from '@aztec/stdlib/interfaces/client';
10
+ import { type CliPXEOptions, type PXEConfig, allPxeConfigMappings } from '@aztec/pxe/config';
11
+ import { AztecNodeAdminApiSchema, AztecNodeApiSchema } from '@aztec/stdlib/interfaces/client';
7
12
  import { P2PApiSchema } from '@aztec/stdlib/interfaces/server';
8
13
  import {
9
14
  type TelemetryClientConfig,
10
15
  initTelemetryClient,
11
16
  telemetryClientConfigMappings,
12
17
  } from '@aztec/telemetry-client';
18
+ import { TestWallet } from '@aztec/test-wallet/server';
13
19
  import { getGenesisValues } from '@aztec/world-state/testing';
14
20
 
15
- import { mnemonicToAccount, privateKeyToAccount } from 'viem/accounts';
16
-
17
- import { createAztecNode, deployContractsToL1 } from '../../sandbox/index.js';
18
- import { getL1Config } from '../get_l1_config.js';
19
- import { extractNamespacedOptions, extractRelevantOptions } from '../util.js';
21
+ import { createAztecNode } from '../../local-network/index.js';
22
+ import {
23
+ extractNamespacedOptions,
24
+ extractRelevantOptions,
25
+ preloadCrsDataForVerifying,
26
+ setupUpdateMonitor,
27
+ } from '../util.js';
20
28
 
21
29
  export async function startNode(
22
30
  options: any,
23
31
  signalHandlers: (() => Promise<void>)[],
24
32
  services: NamespacedApiHandlers,
33
+ adminServices: NamespacedApiHandlers,
25
34
  userLog: LogFn,
26
35
  ): Promise<{ config: AztecNodeConfig }> {
27
- // options specifically namespaced with --node.<option>
28
- const nodeSpecificOptions = extractNamespacedOptions(options, 'node');
36
+ // All options set from environment variables
37
+ const configFromEnvVars = getConfigEnvVars();
38
+
39
+ // Extract relevant options from command line arguments
40
+ const relevantOptions = extractRelevantOptions(options, aztecNodeConfigMappings, 'node');
41
+
29
42
  // All options that are relevant to the Aztec Node
30
43
  let nodeConfig: AztecNodeConfig = {
31
- ...getConfigEnvVars(),
32
- ...extractRelevantOptions(options, aztecNodeConfigMappings, 'node'),
44
+ ...configFromEnvVars,
45
+ ...relevantOptions,
33
46
  };
34
47
 
35
48
  if (options.proverNode) {
@@ -37,81 +50,63 @@ export async function startNode(
37
50
  process.exit(1);
38
51
  }
39
52
 
40
- const initialFundedAccounts = nodeConfig.testAccounts ? await getInitialTestAccounts() : [];
41
- const { genesisBlockHash, genesisArchiveRoot, prefilledPublicData } = await getGenesisValues(
42
- initialFundedAccounts.map(a => a.address),
43
- );
53
+ await preloadCrsDataForVerifying(nodeConfig, userLog);
44
54
 
45
- // Deploy contracts if needed
46
- if (nodeSpecificOptions.deployAztecContracts || nodeSpecificOptions.deployAztecContractsSalt) {
47
- let account;
48
- if (nodeSpecificOptions.publisherPrivateKey) {
49
- account = privateKeyToAccount(nodeSpecificOptions.publisherPrivateKey);
50
- } else if (options.l1Mnemonic) {
51
- account = mnemonicToAccount(options.l1Mnemonic);
52
- } else {
53
- throw new Error('--node.publisherPrivateKey or --l1-mnemonic is required to deploy L1 contracts');
54
- }
55
- // REFACTOR: We should not be calling a method from sandbox on the prod start flow
56
- await deployContractsToL1(nodeConfig, account!, undefined, {
57
- assumeProvenThroughBlockNumber: nodeSpecificOptions.assumeProvenThroughBlockNumber,
58
- salt: nodeSpecificOptions.deployAztecContractsSalt,
59
- genesisBlockHash,
60
- genesisArchiveRoot,
61
- });
62
- }
63
- // If not deploying, validate that any addresses and config provided are correct.
64
- else {
65
- if (!nodeConfig.l1Contracts.registryAddress || nodeConfig.l1Contracts.registryAddress.isZero()) {
66
- throw new Error('L1 registry address is required to start Aztec Node without --deploy-aztec-contracts option');
67
- }
68
- const { addresses, config } = await getL1Config(
69
- nodeConfig.l1Contracts.registryAddress,
70
- nodeConfig.l1RpcUrls,
71
- nodeConfig.l1ChainId,
72
- );
55
+ const testAccounts = nodeConfig.testAccounts ? (await getInitialTestAccountsData()).map(a => a.address) : [];
56
+ const sponsoredFPCAccounts = nodeConfig.sponsoredFPC ? [await getSponsoredFPCAddress()] : [];
57
+ const initialFundedAccounts = testAccounts.concat(sponsoredFPCAccounts);
73
58
 
74
- // TODO(#12272): will clean this up.
75
- nodeConfig = {
76
- ...nodeConfig,
77
- l1Contracts: {
78
- ...addresses,
79
- slashFactoryAddress: nodeConfig.l1Contracts.slashFactoryAddress,
80
- },
81
- ...config,
82
- };
59
+ userLog(`Initial funded accounts: ${initialFundedAccounts.map(a => a.toString()).join(', ')}`);
60
+
61
+ const { genesisArchiveRoot, prefilledPublicData } = await getGenesisValues(initialFundedAccounts);
62
+
63
+ userLog(`Genesis archive root: ${genesisArchiveRoot.toString()}`);
64
+
65
+ const followsCanonicalRollup =
66
+ typeof nodeConfig.rollupVersion !== 'number' || (nodeConfig.rollupVersion as unknown as string) === 'canonical';
67
+
68
+ if (!nodeConfig.l1Contracts.registryAddress || nodeConfig.l1Contracts.registryAddress.isZero()) {
69
+ throw new Error('L1 registry address is required to start Aztec Node');
83
70
  }
71
+ const { addresses, config } = await getL1Config(
72
+ nodeConfig.l1Contracts.registryAddress,
73
+ nodeConfig.l1RpcUrls,
74
+ nodeConfig.l1ChainId,
75
+ nodeConfig.rollupVersion,
76
+ );
84
77
 
85
- // if no publisher private key, then use l1Mnemonic
86
- if (!options.archiver) {
87
- // expect archiver url in node config
88
- const archiverUrl = nodeConfig.archiverUrl;
89
- if (!archiverUrl) {
90
- userLog('Archiver Service URL is required to start Aztec Node without --archiver option');
91
- throw new Error('Archiver Service URL is required to start Aztec Node without --archiver option');
92
- }
93
- nodeConfig.archiverUrl = archiverUrl;
78
+ process.env.ROLLUP_CONTRACT_ADDRESS ??= addresses.rollupAddress.toString();
79
+
80
+ if (!Fr.fromHexString(config.genesisArchiveTreeRoot).equals(genesisArchiveRoot)) {
81
+ throw new Error(
82
+ `The computed genesis archive tree root ${genesisArchiveRoot} does not match the expected genesis archive tree root ${config.genesisArchiveTreeRoot} for the rollup deployed at ${addresses.rollupAddress}`,
83
+ );
94
84
  }
95
85
 
96
- if (!options.sequencer) {
86
+ // TODO(#12272): will clean this up.
87
+ nodeConfig = {
88
+ ...nodeConfig,
89
+ l1Contracts: {
90
+ ...addresses,
91
+ slashFactoryAddress: nodeConfig.l1Contracts.slashFactoryAddress,
92
+ },
93
+ ...config,
94
+ };
95
+
96
+ if (!options.sequencer && !nodeConfig.fishermanMode) {
97
97
  nodeConfig.disableValidator = true;
98
98
  } else {
99
- const sequencerConfig = extractNamespacedOptions(options, 'sequencer');
100
- let account;
101
- if (!sequencerConfig.publisherPrivateKey || sequencerConfig.publisherPrivateKey === NULL_KEY) {
102
- if (!options.l1Mnemonic) {
103
- userLog(
104
- '--sequencer.publisherPrivateKey or --l1-mnemonic is required to start Aztec Node with --sequencer option',
105
- );
106
- throw new Error('Private key or Mnemonic is required to start Aztec Node with --sequencer option');
107
- } else {
108
- account = mnemonicToAccount(options.l1Mnemonic);
109
- const privKey = account.getHdKey().privateKey;
110
- nodeConfig.publisherPrivateKey = `0x${Buffer.from(privKey!).toString('hex')}`;
99
+ const sequencerConfig = {
100
+ ...configFromEnvVars,
101
+ ...extractNamespacedOptions(options, 'sequencer'),
102
+ };
103
+ // If no publisher private keys have been given, use the first validator key
104
+ if (sequencerConfig.publisherPrivateKeys === undefined || !sequencerConfig.publisherPrivateKeys.length) {
105
+ if (sequencerConfig.validatorPrivateKeys?.getValue().length) {
106
+ sequencerConfig.publisherPrivateKeys = [new SecretValue(sequencerConfig.validatorPrivateKeys.getValue()[0])];
111
107
  }
112
- } else {
113
- nodeConfig.publisherPrivateKey = sequencerConfig.publisherPrivateKey;
114
108
  }
109
+ nodeConfig.publisherPrivateKeys = sequencerConfig.publisherPrivateKeys;
115
110
  }
116
111
 
117
112
  if (nodeConfig.p2pEnabled) {
@@ -122,7 +117,7 @@ export async function startNode(
122
117
  }
123
118
 
124
119
  const telemetryConfig = extractRelevantOptions<TelemetryClientConfig>(options, telemetryClientConfigMappings, 'tel');
125
- const telemetry = initTelemetryClient(telemetryConfig);
120
+ const telemetry = await initTelemetryClient(telemetryConfig);
126
121
 
127
122
  // Create and start Aztec Node
128
123
  const node = await createAztecNode(nodeConfig, { telemetry }, { prefilledPublicData });
@@ -130,21 +125,31 @@ export async function startNode(
130
125
  // Add node and p2p to services list
131
126
  services.node = [node, AztecNodeApiSchema];
132
127
  services.p2p = [node.getP2P(), P2PApiSchema];
128
+ adminServices.nodeAdmin = [node, AztecNodeAdminApiSchema];
133
129
 
134
130
  // Add node stop function to signal handlers
135
131
  signalHandlers.push(node.stop.bind(node));
136
132
 
137
- // Add a PXE client that connects to this node if requested
138
- let pxe: PXE | undefined;
139
- if (options.pxe) {
140
- const { addPXE } = await import('./start_pxe.js');
141
- ({ pxe } = await addPXE(options, signalHandlers, services, userLog, { node }));
142
- }
143
-
144
133
  // Add a txs bot if requested
145
134
  if (options.bot) {
146
135
  const { addBot } = await import('./start_bot.js');
147
- await addBot(options, signalHandlers, services, { pxe, node, telemetry });
136
+
137
+ const pxeConfig = extractRelevantOptions<PXEConfig & CliPXEOptions>(options, allPxeConfigMappings, 'pxe');
138
+ const wallet = await TestWallet.create(node, pxeConfig);
139
+
140
+ await addBot(options, signalHandlers, services, wallet, node, telemetry, undefined);
141
+ }
142
+
143
+ if (nodeConfig.autoUpdate !== 'disabled' && nodeConfig.autoUpdateUrl) {
144
+ await setupUpdateMonitor(
145
+ nodeConfig.autoUpdate,
146
+ new URL(nodeConfig.autoUpdateUrl),
147
+ followsCanonicalRollup,
148
+ getPublicClient(nodeConfig!),
149
+ nodeConfig.l1Contracts.registryAddress,
150
+ signalHandlers,
151
+ async config => node.setConfig((await AztecNodeAdminApiSchema.setConfig.parameters().parseAsync([config]))[0]),
152
+ );
148
153
  }
149
154
 
150
155
  return { config: nodeConfig };
@@ -5,7 +5,11 @@ import { createStore } from '@aztec/kv-store/lmdb-v2';
5
5
  import { type BootnodeConfig, BootstrapNode, bootnodeConfigMappings } from '@aztec/p2p';
6
6
  import { emptyChainConfig } from '@aztec/stdlib/config';
7
7
  import { P2PBootstrapApiSchema } from '@aztec/stdlib/interfaces/server';
8
- import { getConfigEnvVars as getTelemetryClientConfig, initTelemetryClient } from '@aztec/telemetry-client';
8
+ import {
9
+ type TelemetryClientConfig,
10
+ initTelemetryClient,
11
+ telemetryClientConfigMappings,
12
+ } from '@aztec/telemetry-client';
9
13
 
10
14
  import { extractRelevantOptions } from '../util.js';
11
15
 
@@ -17,13 +21,17 @@ export async function startP2PBootstrap(
17
21
  ) {
18
22
  // Start a P2P bootstrap node.
19
23
  const config = extractRelevantOptions<BootnodeConfig>(options, bootnodeConfigMappings, 'p2p');
20
- userLog(`Starting P2P bootstrap node with config: ${jsonStringify(config)}`);
21
- const telemetryClient = initTelemetryClient(getTelemetryClientConfig());
24
+ const safeConfig = { ...config, peerIdPrivateKey: '<redacted>' };
25
+ userLog(`Starting P2P bootstrap node with config: ${jsonStringify(safeConfig)}`);
26
+
27
+ const telemetryConfig = extractRelevantOptions<TelemetryClientConfig>(options, telemetryClientConfigMappings, 'tel');
28
+ const telemetryClient = await initTelemetryClient(telemetryConfig);
29
+
22
30
  const store = await createStore('p2p-bootstrap', 1, config, createLogger('p2p:bootstrap:store'));
23
31
  const node = new BootstrapNode(store, telemetryClient);
24
32
  await node.start(config);
25
33
  signalHandlers.push(() => node.stop());
26
34
  services.bootstrap = [node, P2PBootstrapApiSchema];
27
- userLog(`P2P bootstrap node started on ${config.udpListenAddress}`);
35
+ userLog(`P2P bootstrap node started on ${config.p2pIp}:${config.p2pPort}`);
28
36
  return { config: emptyChainConfig };
29
37
  }
@@ -11,9 +11,10 @@ import {
11
11
  proverAgentConfigMappings,
12
12
  } from '@aztec/prover-client/broker';
13
13
  import { getProverNodeAgentConfigFromEnv } from '@aztec/prover-node';
14
+ import { ProverAgentApiSchema } from '@aztec/stdlib/interfaces/server';
14
15
  import { initTelemetryClient, makeTracedFetch, telemetryClientConfigMappings } from '@aztec/telemetry-client';
15
16
 
16
- import { extractRelevantOptions } from '../util.js';
17
+ import { extractRelevantOptions, preloadCrsDataForServerSideProving } from '../util.js';
17
18
  import { getVersions } from '../versioning.js';
18
19
 
19
20
  export async function startProverAgent(
@@ -33,17 +34,26 @@ export async function startProverAgent(
33
34
  };
34
35
 
35
36
  if (config.realProofs && (!config.bbBinaryPath || !config.acvmBinaryPath)) {
37
+ userLog(`Requested real proving but no path to bb or acvm binaries provided`);
36
38
  process.exit(1);
37
39
  }
38
40
 
39
41
  if (!config.proverBrokerUrl) {
42
+ userLog(`Missing prover broker URL. Pass --proverAgent.proverBrokerUrl <value>`);
40
43
  process.exit(1);
41
44
  }
42
45
 
43
- const fetch = makeTracedFetch([1, 2, 3], false, makeUndiciFetch(new Agent({ connections: 10 })));
46
+ await preloadCrsDataForServerSideProving(config, userLog);
47
+
48
+ const fetch = makeTracedFetch(
49
+ // retry connections every 3s, up to 30s before giving up
50
+ [1, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3],
51
+ false,
52
+ makeUndiciFetch(new Agent({ connections: 10 })),
53
+ );
44
54
  const broker = createProvingJobBrokerClient(config.proverBrokerUrl, getVersions(), fetch);
45
55
 
46
- const telemetry = initTelemetryClient(extractRelevantOptions(options, telemetryClientConfigMappings, 'tel'));
56
+ const telemetry = await initTelemetryClient(extractRelevantOptions(options, telemetryClientConfigMappings, 'tel'));
47
57
  const prover = await buildServerCircuitProver(config, telemetry);
48
58
  const proofStore = new InlineProofStore();
49
59
  const agents = times(
@@ -59,6 +69,16 @@ export async function startProverAgent(
59
69
  ),
60
70
  );
61
71
 
72
+ // expose all agents as individual services
73
+ for (let i = 0; i < agents.length; i++) {
74
+ services[`agent${i}`] = [agents[i], ProverAgentApiSchema, () => agents[i].getStatus().status !== 'stopped'];
75
+ }
76
+
77
+ // shortcut in the most common case of having a single running agent
78
+ if (agents.length === 1) {
79
+ services[`agent`] = [agents[0], ProverAgentApiSchema, () => agents[0].getStatus().status !== 'stopped'];
80
+ }
81
+
62
82
  await Promise.all(agents.map(agent => agent.start()));
63
83
 
64
84
  signalHandlers.push(async () => {
@@ -1,3 +1,5 @@
1
+ import { getL1Config } from '@aztec/cli/config';
2
+ import { getPublicClient } from '@aztec/ethereum/client';
1
3
  import type { NamespacedApiHandlers } from '@aztec/foundation/json-rpc/server';
2
4
  import type { LogFn } from '@aztec/foundation/log';
3
5
  import {
@@ -10,8 +12,7 @@ import { getProverNodeBrokerConfigFromEnv } from '@aztec/prover-node';
10
12
  import type { ProvingJobBroker } from '@aztec/stdlib/interfaces/server';
11
13
  import { getConfigEnvVars as getTelemetryClientConfig, initTelemetryClient } from '@aztec/telemetry-client';
12
14
 
13
- import { getL1Config } from '../get_l1_config.js';
14
- import { extractRelevantOptions } from '../util.js';
15
+ import { extractRelevantOptions, setupUpdateMonitor } from '../util.js';
15
16
 
16
17
  export async function startProverBroker(
17
18
  options: any,
@@ -33,12 +34,31 @@ export async function startProverBroker(
33
34
  throw new Error('L1 registry address is required to start Aztec Node without --deploy-aztec-contracts option');
34
35
  }
35
36
 
36
- const { addresses } = await getL1Config(config.l1Contracts.registryAddress, config.l1RpcUrls, config.l1ChainId);
37
+ const followsCanonicalRollup = typeof config.rollupVersion !== 'number';
38
+ const { addresses, config: rollupConfig } = await getL1Config(
39
+ config.l1Contracts.registryAddress,
40
+ config.l1RpcUrls,
41
+ config.l1ChainId,
42
+ config.rollupVersion,
43
+ );
37
44
 
38
45
  config.l1Contracts = addresses;
46
+ config.rollupVersion = rollupConfig.rollupVersion;
39
47
 
40
- const client = initTelemetryClient(getTelemetryClientConfig());
48
+ const client = await initTelemetryClient(getTelemetryClientConfig());
41
49
  const broker = await createAndStartProvingBroker(config, client);
50
+
51
+ if (options.autoUpdate !== 'disabled' && options.autoUpdateUrl) {
52
+ await setupUpdateMonitor(
53
+ options.autoUpdate,
54
+ new URL(options.autoUpdateUrl),
55
+ followsCanonicalRollup,
56
+ getPublicClient(config),
57
+ config.l1Contracts.registryAddress,
58
+ signalHandlers,
59
+ );
60
+ }
61
+
42
62
  services.proverBroker = [broker, ProvingJobBrokerSchema];
43
63
  signalHandlers.push(() => broker.stop());
44
64