@aztec/aztec 0.0.1-commit.2ed92850 → 0.0.1-commit.3100065

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 +69 -32
  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 +39 -23
  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 +3 -4
  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/profile.d.ts +4 -0
  18. package/dest/cli/cmds/profile.d.ts.map +1 -0
  19. package/dest/cli/cmds/profile.js +8 -0
  20. package/dest/cli/cmds/profile_flamegraph.d.ts +4 -0
  21. package/dest/cli/cmds/profile_flamegraph.d.ts.map +1 -0
  22. package/dest/cli/cmds/profile_flamegraph.js +52 -0
  23. package/dest/cli/cmds/profile_gates.d.ts +4 -0
  24. package/dest/cli/cmds/profile_gates.d.ts.map +1 -0
  25. package/dest/cli/cmds/profile_gates.js +76 -0
  26. package/dest/cli/cmds/profile_utils.d.ts +18 -0
  27. package/dest/cli/cmds/profile_utils.d.ts.map +1 -0
  28. package/dest/cli/cmds/profile_utils.js +50 -0
  29. package/dest/cli/cmds/prover.d.ts +4 -0
  30. package/dest/cli/cmds/prover.d.ts.map +1 -0
  31. package/dest/cli/cmds/prover.js +24 -0
  32. package/dest/cli/cmds/standby.d.ts +56 -0
  33. package/dest/cli/cmds/standby.d.ts.map +1 -0
  34. package/dest/cli/cmds/standby.js +140 -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 +17 -9
  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 +82 -51
  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 +6 -18
  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 +26 -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 +13 -19
  69. package/dest/cli/util.d.ts.map +1 -1
  70. package/dest/cli/util.js +37 -100
  71. package/dest/examples/token.js +9 -9
  72. package/dest/local-network/auth_registry.d.ts +5 -0
  73. package/dest/local-network/auth_registry.d.ts.map +1 -0
  74. package/dest/local-network/auth_registry.js +17 -0
  75. package/dest/local-network/banana_fpc.d.ts +3 -2
  76. package/dest/local-network/banana_fpc.d.ts.map +1 -1
  77. package/dest/local-network/banana_fpc.js +12 -8
  78. package/dest/local-network/local-network.d.ts +10 -32
  79. package/dest/local-network/local-network.d.ts.map +1 -1
  80. package/dest/local-network/local-network.js +83 -72
  81. package/dest/testing/cheat_codes.d.ts +17 -23
  82. package/dest/testing/cheat_codes.d.ts.map +1 -1
  83. package/dest/testing/cheat_codes.js +17 -43
  84. package/dest/testing/epoch_test_settler.d.ts +2 -2
  85. package/dest/testing/epoch_test_settler.d.ts.map +1 -1
  86. package/dest/testing/epoch_test_settler.js +6 -26
  87. package/dest/testing/index.d.ts +2 -2
  88. package/dest/testing/index.d.ts.map +1 -1
  89. package/dest/testing/index.js +1 -1
  90. package/dest/testing/token_allowed_setup.d.ts +12 -0
  91. package/dest/testing/token_allowed_setup.d.ts.map +1 -0
  92. package/dest/testing/token_allowed_setup.js +24 -0
  93. package/package.json +35 -34
  94. package/scripts/add_crate.sh +53 -0
  95. package/scripts/aztec.sh +15 -5
  96. package/scripts/init.sh +23 -19
  97. package/scripts/new.sh +48 -24
  98. package/scripts/setup_workspace.sh +69 -0
  99. package/scripts/templates/blank/contract/Nargo.toml +6 -0
  100. package/scripts/templates/blank/contract/src/main.nr +10 -0
  101. package/scripts/templates/blank/test/Nargo.toml +7 -0
  102. package/scripts/templates/blank/test/src/lib.nr +11 -0
  103. package/scripts/templates/counter/contract/Nargo.toml +7 -0
  104. package/scripts/templates/counter/contract/src/main.nr +48 -0
  105. package/scripts/templates/counter/test/Nargo.toml +7 -0
  106. package/scripts/templates/counter/test/src/lib.nr +32 -0
  107. package/src/bin/index.ts +9 -3
  108. package/src/cli/admin_api_key_store.ts +128 -0
  109. package/src/cli/aztec_start_action.ts +69 -24
  110. package/src/cli/aztec_start_options.ts +48 -30
  111. package/src/cli/cli.ts +3 -4
  112. package/src/cli/cmds/compile.ts +205 -0
  113. package/src/cli/cmds/profile.ts +26 -0
  114. package/src/cli/cmds/profile_flamegraph.ts +64 -0
  115. package/src/cli/cmds/profile_gates.ts +84 -0
  116. package/src/cli/cmds/profile_utils.ts +58 -0
  117. package/src/cli/cmds/prover.ts +42 -0
  118. package/src/cli/cmds/standby.ts +184 -0
  119. package/src/cli/cmds/start_bot.ts +17 -11
  120. package/src/cli/cmds/start_node.ts +92 -52
  121. package/src/cli/cmds/start_p2p_bootstrap.ts +2 -2
  122. package/src/cli/cmds/start_prover_agent.ts +7 -10
  123. package/src/cli/cmds/start_prover_broker.ts +28 -25
  124. package/src/cli/cmds/start_txe.ts +7 -5
  125. package/src/cli/cmds/utils/artifacts.ts +49 -0
  126. package/src/cli/cmds/utils/collect_crate_dirs.ts +118 -0
  127. package/src/cli/cmds/utils/needs_recompile.ts +98 -0
  128. package/src/cli/cmds/utils/spawn.ts +16 -0
  129. package/src/cli/cmds/utils/warn_if_aztec_version_mismatch.ts +76 -0
  130. package/src/cli/util.ts +39 -118
  131. package/src/examples/token.ts +19 -9
  132. package/src/local-network/auth_registry.ts +19 -0
  133. package/src/local-network/banana_fpc.ts +13 -9
  134. package/src/local-network/local-network.ts +91 -81
  135. package/src/testing/cheat_codes.ts +18 -49
  136. package/src/testing/epoch_test_settler.ts +8 -32
  137. package/src/testing/index.ts +1 -1
  138. package/src/testing/token_allowed_setup.ts +26 -0
  139. package/dest/cli/cmds/start_archiver.d.ts +0 -9
  140. package/dest/cli/cmds/start_archiver.d.ts.map +0 -1
  141. package/dest/cli/cmds/start_archiver.js +0 -48
  142. package/dest/cli/cmds/start_prover_node.d.ts +0 -7
  143. package/dest/cli/cmds/start_prover_node.d.ts.map +0 -1
  144. package/dest/cli/cmds/start_prover_node.js +0 -108
  145. package/dest/cli/release_version.d.ts +0 -2
  146. package/dest/cli/release_version.d.ts.map +0 -1
  147. package/dest/cli/release_version.js +0 -14
  148. package/dest/testing/anvil_test_watcher.d.ts +0 -34
  149. package/dest/testing/anvil_test_watcher.d.ts.map +0 -1
  150. package/dest/testing/anvil_test_watcher.js +0 -144
  151. package/scripts/compile.sh +0 -44
  152. package/scripts/extract_function.js +0 -47
  153. package/scripts/flamegraph.sh +0 -59
  154. package/scripts/setup_project.sh +0 -31
  155. package/src/cli/cmds/start_archiver.ts +0 -50
  156. package/src/cli/cmds/start_prover_node.ts +0 -124
  157. package/src/cli/release_version.ts +0 -21
  158. package/src/testing/anvil_test_watcher.ts +0 -166
package/src/cli/util.ts CHANGED
@@ -1,14 +1,10 @@
1
1
  import type { AztecNodeConfig } from '@aztec/aztec-node';
2
2
  import type { AccountManager } from '@aztec/aztec.js/wallet';
3
- import type { ViemClient } from '@aztec/ethereum/types';
4
3
  import type { ConfigMappingsType } from '@aztec/foundation/config';
5
- import { Fr } from '@aztec/foundation/curves/bn254';
6
- import { EthAddress } from '@aztec/foundation/eth-address';
7
- import { type LogFn, createLogger } from '@aztec/foundation/log';
8
- import type { SharedNodeConfig } from '@aztec/node-lib/config';
4
+ import { jsonStringify } from '@aztec/foundation/json-rpc';
5
+ import type { LogFn } from '@aztec/foundation/log';
9
6
  import type { ProverConfig } from '@aztec/stdlib/interfaces/server';
10
- import { getTelemetryClient } from '@aztec/telemetry-client/start';
11
- import type { TestWallet } from '@aztec/test-wallet/server';
7
+ import type { EmbeddedWallet } from '@aztec/wallets/embedded';
12
8
 
13
9
  import chalk from 'chalk';
14
10
  import type { Command } from 'commander';
@@ -50,6 +46,24 @@ export function isShuttingDown(): boolean {
50
46
  return shutdownPromise !== undefined;
51
47
  }
52
48
 
49
+ /**
50
+ * Stops the node's subsystems (via the registered signal handlers) without exiting the process, leaving
51
+ * the HTTP health server listening so K8s liveness/readiness probes keep passing. Unlike {@link shutdown}
52
+ * this deliberately does not latch `shutdownPromise` or call `process.exit`; instead it re-arms
53
+ * SIGTERM/SIGINT so a later K8s pod deletion still terminates the wound-down pod with a clean exit.
54
+ */
55
+ export async function softShutdown(logFn: LogFn, signalHandlers: Array<() => Promise<void>>): Promise<void> {
56
+ logFn('Canonical rollup upgrade detected: stopping subsystems, health server stays up.', {
57
+ exitCode: ExitCode.ROLLUP_UPGRADE,
58
+ });
59
+ await Promise.allSettled(signalHandlers.map(fn => fn()));
60
+ for (const sig of ['SIGTERM', 'SIGINT'] as const) {
61
+ process.removeAllListeners(sig);
62
+ process.once(sig, () => process.exit(ExitCode.ROLLUP_UPGRADE));
63
+ }
64
+ logFn('Subsystems stopped due to rollup upgrade. Health server remains active.');
65
+ }
66
+
53
67
  export const installSignalHandlers = (logFn: LogFn, cb?: Array<() => Promise<void>>) => {
54
68
  const signals = [
55
69
  ['SIGINT', ExitCode.SIGINT],
@@ -68,41 +82,30 @@ export const installSignalHandlers = (logFn: LogFn, cb?: Array<() => Promise<voi
68
82
  /**
69
83
  * Creates logs for the initial accounts
70
84
  * @param accounts - The initial accounts
71
- * @param wallet - A TestWallet instance to get the registered accounts
85
+ * @param wallet - A EmbeddedWallet instance to get the registered accounts
72
86
  * @returns A string array containing the initial accounts details
73
87
  */
74
- export async function createAccountLogs(
75
- accountsWithSecretKeys: {
76
- /**
77
- * The account object
78
- */
79
- account: AccountManager;
80
- /**
81
- * The secret key of the account
82
- */
83
- secretKey: Fr;
84
- }[],
85
- wallet: TestWallet,
86
- ) {
88
+ export async function createAccountLogs(accountManagers: AccountManager[], wallet: EmbeddedWallet) {
87
89
  const registeredAccounts = await wallet.getAccounts();
88
90
  const accountLogStrings = [`Initial Accounts:\n\n`];
89
- for (const accountWithSecretKey of accountsWithSecretKeys) {
90
- const completeAddress = await accountWithSecretKey.account.getCompleteAddress();
91
+ for (const accountManager of accountManagers) {
92
+ const account = await accountManager.getAccount();
93
+ const completeAddress = account.getCompleteAddress();
91
94
  if (registeredAccounts.find(a => a.item.equals(completeAddress.address))) {
92
95
  accountLogStrings.push(` Address: ${completeAddress.address.toString()}\n`);
93
96
  accountLogStrings.push(` Partial Address: ${completeAddress.partialAddress.toString()}\n`);
94
- accountLogStrings.push(` Secret Key: ${accountWithSecretKey.secretKey.toString()}\n`);
95
- accountLogStrings.push(
96
- ` Master nullifier public key: ${completeAddress.publicKeys.masterNullifierPublicKey.toString()}\n`,
97
- );
97
+ accountLogStrings.push(` Secret Key: ${accountManager.getSecretKey().toString()}\n`);
98
+ accountLogStrings.push(` Master nullifier public key hash: ${completeAddress.publicKeys.npkMHash.toString()}\n`);
99
+ accountLogStrings.push(` Master incoming viewing public key: ${completeAddress.publicKeys.ivpkM.toString()}\n\n`);
98
100
  accountLogStrings.push(
99
- ` Master incoming viewing public key: ${completeAddress.publicKeys.masterIncomingViewingPublicKey.toString()}\n\n`,
101
+ ` Master outgoing viewing public key hash: ${completeAddress.publicKeys.ovpkMHash.toString()}\n\n`,
100
102
  );
103
+ accountLogStrings.push(` Master tagging public key hash: ${completeAddress.publicKeys.tpkMHash.toString()}\n\n`);
101
104
  accountLogStrings.push(
102
- ` Master outgoing viewing public key: ${completeAddress.publicKeys.masterOutgoingViewingPublicKey.toString()}\n\n`,
105
+ ` Master message-signing public key hash: ${completeAddress.publicKeys.mspkMHash.toString()}\n\n`,
103
106
  );
104
107
  accountLogStrings.push(
105
- ` Master tagging public key: ${completeAddress.publicKeys.masterTaggingPublicKey.toString()}\n\n`,
108
+ ` Master fallback public key hash: ${completeAddress.publicKeys.fbpkMHash.toString()}\n\n`,
106
109
  );
107
110
  }
108
111
  }
@@ -282,7 +285,7 @@ export async function preloadCrsDataForVerifying(
282
285
  ): Promise<void> {
283
286
  if (realProofs) {
284
287
  const { Crs, GrumpkinCrs } = await import('@aztec/bb.js');
285
- await Promise.all([Crs.new(2 ** 1, undefined, log), GrumpkinCrs.new(2 ** 16 + 1, undefined, log)]);
288
+ await Promise.all([Crs.new(2 ** 1, undefined, log), GrumpkinCrs.new(2 ** 16, undefined, log)]);
286
289
  }
287
290
  }
288
291
 
@@ -297,94 +300,12 @@ export async function preloadCrsDataForServerSideProving(
297
300
  ): Promise<void> {
298
301
  if (realProofs) {
299
302
  const { Crs, GrumpkinCrs } = await import('@aztec/bb.js');
300
- await Promise.all([Crs.new(2 ** 25 + 1, undefined, log), GrumpkinCrs.new(2 ** 18 + 1, undefined, log)]);
303
+ await Promise.all([Crs.new(2 ** 25, undefined, log), GrumpkinCrs.new(2 ** 18, undefined, log)]);
301
304
  }
302
305
  }
303
306
 
304
- export async function setupUpdateMonitor(
305
- autoUpdateMode: SharedNodeConfig['autoUpdate'],
306
- updatesLocation: URL,
307
- followsCanonicalRollup: boolean,
308
- publicClient: ViemClient,
309
- registryContractAddress: EthAddress,
310
- signalHandlers: Array<() => Promise<void>>,
311
- updateNodeConfig?: (config: object) => Promise<void>,
312
- ) {
313
- const logger = createLogger('update-check');
314
- const { UpdateChecker } = await import('@aztec/stdlib/update-checker');
315
- const checker = await UpdateChecker.new({
316
- baseURL: updatesLocation,
317
- publicClient,
318
- registryContractAddress,
319
- });
320
-
321
- // eslint-disable-next-line @typescript-eslint/no-misused-promises
322
- checker.on('newRollupVersion', async ({ latestVersion, currentVersion }) => {
323
- if (isShuttingDown()) {
324
- return;
325
- }
326
-
327
- // if node follows canonical rollup then this is equivalent to a config update
328
- if (!followsCanonicalRollup) {
329
- return;
330
- }
331
-
332
- if (autoUpdateMode === 'config' || autoUpdateMode === 'config-and-version') {
333
- logger.info(`New rollup version detected. Please restart the node`, { latestVersion, currentVersion });
334
- await shutdown(logger.info, ExitCode.ROLLUP_UPGRADE, signalHandlers);
335
- } else if (autoUpdateMode === 'notify') {
336
- logger.warn(`New rollup detected. Please restart the node`, { latestVersion, currentVersion });
337
- }
338
- });
339
-
340
- // eslint-disable-next-line @typescript-eslint/no-misused-promises
341
- checker.on('newNodeVersion', async ({ latestVersion, currentVersion }) => {
342
- if (isShuttingDown()) {
343
- return;
344
- }
345
- if (autoUpdateMode === 'config-and-version') {
346
- logger.info(`New node version detected. Please update and restart the node`, { latestVersion, currentVersion });
347
- await shutdown(logger.info, ExitCode.VERSION_UPGRADE, signalHandlers);
348
- } else if (autoUpdateMode === 'notify') {
349
- logger.info(`New node version detected. Please update and restart the node`, { latestVersion, currentVersion });
350
- }
351
- });
352
-
353
- // eslint-disable-next-line @typescript-eslint/no-misused-promises
354
- checker.on('updateNodeConfig', async config => {
355
- if (isShuttingDown()) {
356
- return;
357
- }
358
-
359
- if ((autoUpdateMode === 'config' || autoUpdateMode === 'config-and-version') && updateNodeConfig) {
360
- logger.warn(`Config change detected. Updating node`, config);
361
- try {
362
- await updateNodeConfig(config);
363
- } catch (err) {
364
- logger.warn('Failed to update config', { err });
365
- }
366
- }
367
- // don't notify on these config changes
368
- });
369
-
370
- checker.on('updatePublicTelemetryConfig', config => {
371
- if (autoUpdateMode === 'config' || autoUpdateMode === 'config-and-version') {
372
- logger.warn(`Public telemetry config change detected. Updating telemetry client`, config);
373
- try {
374
- const publicIncludeMetrics: unknown = (config as any).publicIncludeMetrics;
375
- if (Array.isArray(publicIncludeMetrics) && publicIncludeMetrics.every(m => typeof m === 'string')) {
376
- getTelemetryClient().setExportedPublicTelemetry(publicIncludeMetrics);
377
- }
378
- const publicMetricsCollectFrom: unknown = (config as any).publicMetricsCollectFrom;
379
- if (Array.isArray(publicMetricsCollectFrom) && publicMetricsCollectFrom.every(m => typeof m === 'string')) {
380
- getTelemetryClient().setPublicTelemetryCollectFrom(publicMetricsCollectFrom);
381
- }
382
- } catch (err) {
383
- logger.warn('Failed to update config', { err });
384
- }
385
- }
386
- // don't notify on these config changes
387
- });
388
-
389
- checker.start();
307
+ export function stringifyConfig(config: object): string {
308
+ return Object.entries(config)
309
+ .map(([key, value]) => `${key}=${jsonStringify(value)}`)
310
+ .join(' ');
390
311
  }
@@ -2,7 +2,7 @@ import { getInitialTestAccountsData } from '@aztec/accounts/testing';
2
2
  import { createAztecNodeClient } from '@aztec/aztec.js/node';
3
3
  import { createLogger } from '@aztec/foundation/log';
4
4
  import { TokenContract } from '@aztec/noir-contracts.js/Token';
5
- import { TestWallet } from '@aztec/test-wallet/server';
5
+ import { EmbeddedWallet } from '@aztec/wallets/embedded';
6
6
 
7
7
  const logger = createLogger('example:token');
8
8
 
@@ -19,12 +19,20 @@ const TRANSFER_AMOUNT = 33n;
19
19
  async function main() {
20
20
  logger.info('Running token contract test on HTTP interface.');
21
21
 
22
- const wallet = await TestWallet.create(node);
22
+ const wallet = await EmbeddedWallet.create(node);
23
23
 
24
- // During local network setup we deploy a few accounts. Below we add them to our wallet.
24
+ // During local network setup we create a few initializerless accounts. Below we add them to our wallet.
25
25
  const [aliceInitialAccountData, bobInitialAccountData] = await getInitialTestAccountsData();
26
- await wallet.createSchnorrAccount(aliceInitialAccountData.secret, aliceInitialAccountData.salt);
27
- await wallet.createSchnorrAccount(bobInitialAccountData.secret, bobInitialAccountData.salt);
26
+ await wallet.createSchnorrInitializerlessAccount(
27
+ aliceInitialAccountData.secret,
28
+ aliceInitialAccountData.salt,
29
+ aliceInitialAccountData.signingKey,
30
+ );
31
+ await wallet.createSchnorrInitializerlessAccount(
32
+ bobInitialAccountData.secret,
33
+ bobInitialAccountData.salt,
34
+ bobInitialAccountData.signingKey,
35
+ );
28
36
 
29
37
  const alice = aliceInitialAccountData.address;
30
38
  const bob = bobInitialAccountData.address;
@@ -32,7 +40,9 @@ async function main() {
32
40
  logger.info(`Fetched Alice and Bob accounts: ${alice.toString()}, ${bob.toString()}`);
33
41
 
34
42
  logger.info('Deploying Token...');
35
- const token = await TokenContract.deploy(wallet, alice, 'TokenName', 'TokenSymbol', 18).send({ from: alice });
43
+ const { contract: token } = await TokenContract.deploy(wallet, alice, 'TokenName', 'TokenSymbol', 18).send({
44
+ from: alice,
45
+ });
36
46
  logger.info('Token deployed');
37
47
 
38
48
  // Mint tokens to Alice
@@ -41,7 +51,7 @@ async function main() {
41
51
 
42
52
  logger.info(`${ALICE_MINT_BALANCE} tokens were successfully minted by Alice and transferred to private`);
43
53
 
44
- const balanceAfterMint = await token.methods.balance_of_private(alice).simulate({ from: alice });
54
+ const { result: balanceAfterMint } = await token.methods.balance_of_private(alice).simulate({ from: alice });
45
55
  logger.info(`Tokens successfully minted. New Alice's balance: ${balanceAfterMint}`);
46
56
 
47
57
  // We will now transfer tokens from Alice to Bob
@@ -49,10 +59,10 @@ async function main() {
49
59
  await token.methods.transfer(bob, TRANSFER_AMOUNT).send({ from: alice });
50
60
 
51
61
  // Check the new balances
52
- const aliceBalance = await token.methods.balance_of_private(alice).simulate({ from: alice });
62
+ const { result: aliceBalance } = await token.methods.balance_of_private(alice).simulate({ from: alice });
53
63
  logger.info(`Alice's balance ${aliceBalance}`);
54
64
 
55
- const bobBalance = await token.methods.balance_of_private(bob).simulate({ from: bob });
65
+ const { result: bobBalance } = await token.methods.balance_of_private(bob).simulate({ from: bob });
56
66
  logger.info(`Bob's balance ${bobBalance}`);
57
67
  }
58
68
 
@@ -0,0 +1,19 @@
1
+ import type { WaitOpts } from '@aztec/aztec.js/contracts';
2
+ import { publishContractClass, publishInstance } from '@aztec/aztec.js/deployment';
3
+ import type { Wallet } from '@aztec/aztec.js/wallet';
4
+ import { AuthRegistryArtifact, getStandardAuthRegistry } from '@aztec/standard-contracts/auth-registry';
5
+ import type { AztecAddress } from '@aztec/stdlib/aztec-address';
6
+
7
+ export async function publishStandardAuthRegistry(
8
+ wallet: Wallet,
9
+ from: AztecAddress,
10
+ waitOpts?: WaitOpts,
11
+ ): Promise<void> {
12
+ const { instance, contractClass } = await getStandardAuthRegistry();
13
+ if (!(await wallet.getContractClassMetadata(contractClass.id)).isContractClassPubliclyRegistered) {
14
+ await (await publishContractClass(wallet, AuthRegistryArtifact)).send({ from, wait: waitOpts });
15
+ }
16
+ if (!(await wallet.getContractMetadata(instance.address)).isContractPublished) {
17
+ await publishInstance(wallet, instance).send({ from, wait: waitOpts });
18
+ }
19
+ }
@@ -1,4 +1,5 @@
1
1
  import { type InitialAccountData, getInitialTestAccountsData } from '@aztec/accounts/testing';
2
+ import type { WaitOpts } from '@aztec/aztec.js/contracts';
2
3
  import type { Wallet } from '@aztec/aztec.js/wallet';
3
4
  import { Fr } from '@aztec/foundation/curves/bn254';
4
5
  import type { LogFn } from '@aztec/foundation/log';
@@ -45,19 +46,22 @@ export async function getBananaFPCAddress(initialAccounts: InitialAccountData[])
45
46
  return (await getBananaFPCInstance(initialAccounts)).address;
46
47
  }
47
48
 
48
- export async function setupBananaFPC(initialAccounts: InitialAccountData[], wallet: Wallet, log: LogFn) {
49
+ export async function setupBananaFPC(
50
+ initialAccounts: InitialAccountData[],
51
+ wallet: Wallet,
52
+ log: LogFn,
53
+ waitOpts?: WaitOpts,
54
+ ) {
49
55
  const bananaCoinAddress = await getBananaCoinAddress(initialAccounts);
50
56
  const admin = getBananaAdmin(initialAccounts);
51
- const [bananaCoin, fpc] = await Promise.all([
52
- TokenContract.deploy(wallet, admin, bananaCoinArgs.name, bananaCoinArgs.symbol, bananaCoinArgs.decimal).send({
53
- from: admin,
54
- contractAddressSalt: BANANA_COIN_SALT,
57
+ const [{ contract: bananaCoin }, { contract: fpc }] = await Promise.all([
58
+ TokenContract.deploy(wallet, admin, bananaCoinArgs.name, bananaCoinArgs.symbol, bananaCoinArgs.decimal, {
59
+ salt: BANANA_COIN_SALT,
55
60
  universalDeploy: true,
56
- }),
57
- FPCContract.deploy(wallet, bananaCoinAddress, admin).send({
61
+ }).send({ from: admin, wait: waitOpts }),
62
+ FPCContract.deploy(wallet, bananaCoinAddress, admin, { salt: BANANA_FPC_SALT, universalDeploy: true }).send({
58
63
  from: admin,
59
- contractAddressSalt: BANANA_FPC_SALT,
60
- universalDeploy: true,
64
+ wait: waitOpts,
61
65
  }),
62
66
  ]);
63
67
 
@@ -1,46 +1,53 @@
1
1
  #!/usr/bin/env -S node --no-warnings
2
2
  import { getInitialTestAccountsData } from '@aztec/accounts/testing';
3
- import { AztecNodeService } from '@aztec/aztec-node';
3
+ import { createAztecNodeService } from '@aztec/aztec-node';
4
4
  import { type AztecNodeConfig, getConfigEnvVars } from '@aztec/aztec-node/config';
5
5
  import { Fr } from '@aztec/aztec.js/fields';
6
6
  import { createLogger } from '@aztec/aztec.js/log';
7
7
  import { type BlobClientInterface, createBlobClient } from '@aztec/blob-client/client';
8
8
  import { GENESIS_ARCHIVE_ROOT } from '@aztec/constants';
9
- import { createEthereumChain } from '@aztec/ethereum/chain';
10
9
  import { waitForPublicClient } from '@aztec/ethereum/client';
11
10
  import { getL1ContractsConfigEnvVars } from '@aztec/ethereum/config';
12
11
  import { NULL_KEY } from '@aztec/ethereum/constants';
13
12
  import { deployAztecL1Contracts } from '@aztec/ethereum/deploy-aztec-l1-contracts';
14
- import { EthCheatCodes } from '@aztec/ethereum/test';
13
+ import type { L1ContractAddresses } from '@aztec/ethereum/l1-contract-addresses';
15
14
  import { SecretValue } from '@aztec/foundation/config';
16
15
  import { EthAddress } from '@aztec/foundation/eth-address';
17
16
  import type { LogFn } from '@aztec/foundation/log';
18
17
  import { DateProvider, TestDateProvider } from '@aztec/foundation/timer';
19
18
  import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
20
19
  import { protocolContractsHash } from '@aztec/protocol-contracts';
21
- import type { PublicDataTreeLeaf } from '@aztec/stdlib/trees';
20
+ import { AztecAddress } from '@aztec/stdlib/aztec-address';
21
+ import type { ProvingJobBroker } from '@aztec/stdlib/interfaces/server';
22
+ import { TxStatus } from '@aztec/stdlib/tx';
23
+ import type { GenesisData } from '@aztec/stdlib/world-state';
22
24
  import {
23
25
  type TelemetryClient,
24
26
  getConfigEnvVars as getTelemetryClientConfig,
25
27
  initTelemetryClient,
26
28
  } from '@aztec/telemetry-client';
27
- import { TestWallet, deployFundedSchnorrAccounts } from '@aztec/test-wallet/server';
29
+ import { EmbeddedWallet } from '@aztec/wallets/embedded';
30
+ import { createFundedInitializerlessAccounts } from '@aztec/wallets/testing';
28
31
  import { getGenesisValues } from '@aztec/world-state/testing';
29
32
 
30
- import { type Hex, createPublicClient, fallback, http as httpViemTransport } from 'viem';
33
+ import type { Hex } from 'viem';
31
34
  import { mnemonicToAccount, privateKeyToAddress } from 'viem/accounts';
32
35
  import { foundry } from 'viem/chains';
33
36
 
34
37
  import { createAccountLogs } from '../cli/util.js';
35
38
  import { DefaultMnemonic } from '../mnemonic.js';
36
- import { AnvilTestWatcher } from '../testing/anvil_test_watcher.js';
37
- import { EpochTestSettler } from '../testing/epoch_test_settler.js';
39
+ import { getTokenAllowedSetupFunctions } from '../testing/token_allowed_setup.js';
40
+ import { publishStandardAuthRegistry } from './auth_registry.js';
38
41
  import { getBananaFPCAddress, setupBananaFPC } from './banana_fpc.js';
39
42
  import { getSponsoredFPCAddress } from './sponsored_fpc.js';
40
43
 
41
44
  const logger = createLogger('local-network');
42
45
 
43
- const localAnvil = foundry;
46
+ // The embedded wallet defaults to waiting for PROPOSED, which returns as soon as a tx lands in a
47
+ // proposed L2 block. That is flaky for the serial sandbox setup below: a proposed block can be
48
+ // pruned before its checkpoint is published, dropping a tx we already moved on from ("Tx dropped by
49
+ // P2P node"). Wait for the checkpoint so each setup tx is durably included before the next is sent.
50
+ const setupWaitOpts = { waitForStatus: TxStatus.CHECKPOINTED };
44
51
 
45
52
  /**
46
53
  * Function to deploy our L1 contracts to the local network L1
@@ -54,7 +61,7 @@ export async function deployContractsToL1(
54
61
  genesisArchiveRoot?: Fr;
55
62
  feeJuicePortalInitialBalance?: bigint;
56
63
  } = {},
57
- ) {
64
+ ): Promise<L1ContractAddresses> {
58
65
  await waitForPublicClient(aztecNodeConfig);
59
66
 
60
67
  const l1Contracts = await deployAztecL1Contracts(aztecNodeConfig.l1RpcUrls[0], privateKey, foundry.id, {
@@ -65,14 +72,14 @@ export async function deployContractsToL1(
65
72
  genesisArchiveRoot: opts.genesisArchiveRoot ?? new Fr(GENESIS_ARCHIVE_ROOT),
66
73
  feeJuicePortalInitialBalance: opts.feeJuicePortalInitialBalance,
67
74
  aztecTargetCommitteeSize: 0, // no committee in local network
68
- slasherFlavor: 'none', // no slashing in local network
75
+ slasherEnabled: false, // no slashing in local network
69
76
  realVerifier: false,
70
77
  });
71
78
 
72
- aztecNodeConfig.l1Contracts = l1Contracts.l1ContractAddresses;
79
+ Object.assign(aztecNodeConfig, l1Contracts.l1ContractAddresses);
73
80
  aztecNodeConfig.rollupVersion = l1Contracts.rollupVersion;
74
81
 
75
- return aztecNodeConfig.l1Contracts;
82
+ return l1Contracts.l1ContractAddresses;
76
83
  }
77
84
 
78
85
  /** Local network settings. */
@@ -98,18 +105,48 @@ export async function createLocalNetwork(config: Partial<LocalNetworkConfig> = {
98
105
  logger.warn(`Multiple L1 RPC URLs provided. Local networks will only use the first one: ${l1RpcUrl}`);
99
106
  }
100
107
 
108
+ // The local network deploys a banana FPC with Token contracts, so include Token entries
109
+ // in the setup allowlist so FPC-based fee payments work out of the box.
110
+ const tokenAllowList = await getTokenAllowedSetupFunctions();
111
+
112
+ const envConfig = getConfigEnvVars();
101
113
  const aztecNodeConfig: AztecNodeConfig = {
102
- ...getConfigEnvVars(),
114
+ ...envConfig,
103
115
  ...config,
116
+ skipOrphanProposedBlockPruning: true,
117
+ // The local network builds node config from env without a DATA_DIRECTORY, so the validator's
118
+ // local signing protection runs against an ephemeral store. That is acceptable for this dev
119
+ // network; production validators must persist it and fail-fast when the data directory is unset.
120
+ allowEphemeralSigningProtection: config.allowEphemeralSigningProtection ?? true,
121
+ txPublicSetupAllowListExtend: [...tokenAllowList, ...(config.txPublicSetupAllowListExtend ?? [])],
122
+ // The local network runs against anvil with no committee, so it defaults to the deterministic
123
+ // AutomineSequencer, which owns L1 time control (warps the dateProvider and L1 timestamps to slot
124
+ // boundaries as it builds), replacing the deleted AnvilTestWatcher. This remains true when p2p is
125
+ // enabled for local peer testing; local-network is not a mode for connecting to an existing network.
126
+ useAutomineSequencer: config.useAutomineSequencer ?? true,
127
+ // The AutomineSequencer owns epoch proving in the local network — it writes epoch out hashes to
128
+ // the L1 Outbox and advances the proven tip as checkpoints land, through the same serial queue as
129
+ // its builds — replacing the standalone EpochTestSettler that used to race the build loop.
130
+ automineEnableProveEpoch: config.automineEnableProveEpoch ?? true,
131
+ // Defaults for the local network / sandbox; callers (e.g. the CLI) may override. No real proving
132
+ // happens here — the AutomineSequencer synthetically settles epochs. Short epochs let it write out
133
+ // hashes quickly (so users can consume L2-to-L1 messages without a long wait), with a wider
134
+ // proof-submission window so the synthetic settler has headroom before the rollup would prune an
135
+ // unproven checkpoint.
136
+ realProofs: config.realProofs ?? false,
137
+ aztecEpochDuration: config.aztecEpochDuration ?? 4,
138
+ aztecProofSubmissionEpochs: config.aztecProofSubmissionEpochs ?? 2,
104
139
  };
105
140
  const hdAccount = mnemonicToAccount(config.l1Mnemonic || DefaultMnemonic);
106
141
  if (
107
- aztecNodeConfig.publisherPrivateKeys == undefined ||
108
- !aztecNodeConfig.publisherPrivateKeys.length ||
109
- aztecNodeConfig.publisherPrivateKeys[0].getValue() === NULL_KEY
142
+ aztecNodeConfig.sequencerPublisherPrivateKeys == undefined ||
143
+ !aztecNodeConfig.sequencerPublisherPrivateKeys.length ||
144
+ aztecNodeConfig.sequencerPublisherPrivateKeys[0].getValue() === NULL_KEY
110
145
  ) {
111
146
  const privKey = hdAccount.getHdKey().privateKey;
112
- aztecNodeConfig.publisherPrivateKeys = [new SecretValue(`0x${Buffer.from(privKey!).toString('hex')}` as const)];
147
+ aztecNodeConfig.sequencerPublisherPrivateKeys = [
148
+ new SecretValue(`0x${Buffer.from(privKey!).toString('hex')}` as const),
149
+ ];
113
150
  }
114
151
  if (!aztecNodeConfig.validatorPrivateKeys?.getValue().length) {
115
152
  const privKey = hdAccount.getHdKey().privateKey;
@@ -122,7 +159,7 @@ export async function createLocalNetwork(config: Partial<LocalNetworkConfig> = {
122
159
  const initialAccounts = await (async () => {
123
160
  if (config.testAccounts === true || config.testAccounts === undefined) {
124
161
  if (aztecNodeConfig.p2pEnabled) {
125
- userLog(`Not setting up test accounts as we are connecting to a network`);
162
+ userLog(`Not setting up test accounts when p2p is enabled`);
126
163
  } else {
127
164
  userLog(`Setting up test accounts`);
128
165
  return await getInitialTestAccountsData();
@@ -133,76 +170,43 @@ export async function createLocalNetwork(config: Partial<LocalNetworkConfig> = {
133
170
 
134
171
  const bananaFPC = await getBananaFPCAddress(initialAccounts);
135
172
  const sponsoredFPC = await getSponsoredFPCAddress();
136
- const fundedAddresses = initialAccounts.length
137
- ? [...initialAccounts.map(a => a.address), bananaFPC, sponsoredFPC]
138
- : [];
139
- const { genesisArchiveRoot, prefilledPublicData, fundingNeeded } = await getGenesisValues(fundedAddresses);
173
+ const prefundAddresses = (aztecNodeConfig.prefundAddresses ?? []).map(a => AztecAddress.fromStringUnsafe(a));
174
+ const fundedAddresses = [
175
+ ...initialAccounts.map(a => a.address),
176
+ ...(initialAccounts.length ? [bananaFPC, sponsoredFPC] : []),
177
+ ...prefundAddresses,
178
+ ];
179
+ const { genesisArchiveRoot, genesis, fundingNeeded } = await getGenesisValues(fundedAddresses);
140
180
 
141
181
  const dateProvider = new TestDateProvider();
142
182
 
143
- let cheatcodes: EthCheatCodes | undefined;
144
- let rollupAddress: EthAddress | undefined;
145
- let watcher: AnvilTestWatcher | undefined;
146
183
  if (!aztecNodeConfig.p2pEnabled) {
147
- ({ rollupAddress } = await deployContractsToL1(
148
- aztecNodeConfig,
149
- aztecNodeConfig.validatorPrivateKeys.getValue()[0],
150
- {
151
- genesisArchiveRoot,
152
- feeJuicePortalInitialBalance: fundingNeeded,
153
- },
154
- ));
155
-
156
- const chain =
157
- aztecNodeConfig.l1RpcUrls.length > 0
158
- ? createEthereumChain([l1RpcUrl], aztecNodeConfig.l1ChainId)
159
- : { chainInfo: localAnvil };
160
-
161
- const publicClient = createPublicClient({
162
- chain: chain.chainInfo,
163
- transport: fallback([httpViemTransport(l1RpcUrl)]) as any,
184
+ await deployContractsToL1(aztecNodeConfig, aztecNodeConfig.validatorPrivateKeys.getValue()[0], {
185
+ genesisArchiveRoot,
186
+ feeJuicePortalInitialBalance: fundingNeeded,
164
187
  });
165
-
166
- cheatcodes = new EthCheatCodes([l1RpcUrl], dateProvider);
167
-
168
- watcher = new AnvilTestWatcher(cheatcodes, rollupAddress, publicClient, dateProvider);
169
- watcher.setisLocalNetwork(true);
170
- watcher.setIsMarkingAsProven(false); // Do not mark as proven in the watcher. It's marked in the epochTestSettler after the out hash is set.
171
-
172
- await watcher.start();
173
188
  }
174
189
 
175
190
  const telemetry = await initTelemetryClient(getTelemetryClientConfig());
176
191
  // Create a local blob client client inside the local network, no http connectivity
177
192
  const blobClient = createBlobClient();
178
- const node = await createAztecNode(aztecNodeConfig, { telemetry, blobClient, dateProvider }, { prefilledPublicData });
179
-
180
- let epochTestSettler: EpochTestSettler | undefined;
181
- if (!aztecNodeConfig.p2pEnabled) {
182
- epochTestSettler = new EpochTestSettler(
183
- cheatcodes!,
184
- rollupAddress!,
185
- node.getBlockSource(),
186
- logger.createChild('epoch-settler'),
187
- { pollingIntervalMs: 200 },
188
- );
189
- await epochTestSettler.start();
190
- }
193
+ const node = await createAztecNode(aztecNodeConfig, { telemetry, blobClient, dateProvider }, { genesis });
191
194
 
192
195
  if (initialAccounts.length) {
193
- const PXEConfig = { proverEnabled: aztecNodeConfig.realProofs };
194
- const wallet = await TestWallet.create(node, PXEConfig);
196
+ const wallet = await EmbeddedWallet.create(node, {
197
+ pxeConfig: { proverEnabled: aztecNodeConfig.realProofs },
198
+ ephemeral: true,
199
+ });
195
200
 
196
201
  userLog('Setting up funded test accounts...');
197
- const accountManagers = await deployFundedSchnorrAccounts(wallet, initialAccounts);
198
- const accountsWithSecrets = accountManagers.map((manager, i) => ({
199
- account: manager,
200
- secretKey: initialAccounts[i].secret,
201
- }));
202
- const accLogs = await createAccountLogs(accountsWithSecrets, wallet);
202
+ const accountManagers = await createFundedInitializerlessAccounts(wallet, initialAccounts);
203
+ const accLogs = await createAccountLogs(accountManagers, wallet);
203
204
  userLog(accLogs.join(''));
204
205
 
205
- await setupBananaFPC(initialAccounts, wallet, userLog);
206
+ userLog('Publishing standard AuthRegistry contract...');
207
+ await publishStandardAuthRegistry(wallet, initialAccounts[0].address, setupWaitOpts);
208
+
209
+ await setupBananaFPC(initialAccounts, wallet, userLog, setupWaitOpts);
206
210
 
207
211
  userLog(`SponsoredFPC: ${await getSponsoredFPCAddress()}`);
208
212
 
@@ -212,8 +216,6 @@ export async function createLocalNetwork(config: Partial<LocalNetworkConfig> = {
212
216
 
213
217
  const stop = async () => {
214
218
  await node.stop();
215
- await watcher?.stop();
216
- await epochTestSettler?.stop();
217
219
  };
218
220
 
219
221
  return { node, stop };
@@ -225,16 +227,24 @@ export async function createLocalNetwork(config: Partial<LocalNetworkConfig> = {
225
227
  */
226
228
  export async function createAztecNode(
227
229
  config: Partial<AztecNodeConfig> = {},
228
- deps: { telemetry?: TelemetryClient; blobClient?: BlobClientInterface; dateProvider?: DateProvider } = {},
229
- options: { prefilledPublicData?: PublicDataTreeLeaf[] } = {},
230
+ deps: {
231
+ telemetry?: TelemetryClient;
232
+ blobClient?: BlobClientInterface;
233
+ dateProvider?: DateProvider;
234
+ proverBroker?: ProvingJobBroker;
235
+ } = {},
236
+ options: { genesis?: GenesisData } = {},
230
237
  ) {
231
238
  // TODO(#12272): will clean this up. This is criminal.
232
- const { l1Contracts, ...rest } = getConfigEnvVars();
239
+ // Not sure why this was ever done. Will be fixed in A-989, A-991, A-990.
233
240
  const aztecNodeConfig: AztecNodeConfig = {
234
- ...rest,
241
+ ...getConfigEnvVars(),
235
242
  ...config,
236
- l1Contracts: { ...l1Contracts, ...config.l1Contracts },
237
243
  };
238
- const node = await AztecNodeService.createAndSync(aztecNodeConfig, deps, options);
244
+ const node = await createAztecNodeService(
245
+ aztecNodeConfig,
246
+ { ...deps, proverNodeDeps: { broker: deps.proverBroker } },
247
+ options,
248
+ );
239
249
  return node;
240
250
  }