@aztec/aztec 0.0.1-commit.96dac018d → 0.0.1-commit.993d240

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 (124) hide show
  1. package/dest/bin/index.js +2 -2
  2. package/dest/cli/aztec_start_action.d.ts +1 -1
  3. package/dest/cli/aztec_start_action.d.ts.map +1 -1
  4. package/dest/cli/aztec_start_action.js +31 -14
  5. package/dest/cli/aztec_start_options.d.ts +2 -2
  6. package/dest/cli/aztec_start_options.d.ts.map +1 -1
  7. package/dest/cli/aztec_start_options.js +16 -17
  8. package/dest/cli/cli.js +3 -3
  9. package/dest/cli/cmds/compile.d.ts +1 -1
  10. package/dest/cli/cmds/compile.d.ts.map +1 -1
  11. package/dest/cli/cmds/compile.js +15 -9
  12. package/dest/cli/cmds/profile.d.ts +1 -1
  13. package/dest/cli/cmds/profile.d.ts.map +1 -1
  14. package/dest/cli/cmds/profile.js +1 -1
  15. package/dest/cli/cmds/profile_flamegraph.d.ts +1 -1
  16. package/dest/cli/cmds/profile_flamegraph.d.ts.map +1 -1
  17. package/dest/cli/cmds/profile_flamegraph.js +2 -1
  18. package/dest/cli/cmds/profile_gates.d.ts +2 -2
  19. package/dest/cli/cmds/profile_gates.d.ts.map +1 -1
  20. package/dest/cli/cmds/profile_gates.js +23 -4
  21. package/dest/cli/cmds/standby.d.ts +30 -0
  22. package/dest/cli/cmds/standby.d.ts.map +1 -0
  23. package/dest/cli/cmds/standby.js +97 -0
  24. package/dest/cli/cmds/start_bot.d.ts +1 -1
  25. package/dest/cli/cmds/start_bot.d.ts.map +1 -1
  26. package/dest/cli/cmds/start_bot.js +3 -3
  27. package/dest/cli/cmds/start_node.d.ts +3 -2
  28. package/dest/cli/cmds/start_node.d.ts.map +1 -1
  29. package/dest/cli/cmds/start_node.js +28 -40
  30. package/dest/cli/cmds/start_prover_agent.d.ts +1 -1
  31. package/dest/cli/cmds/start_prover_agent.d.ts.map +1 -1
  32. package/dest/cli/cmds/start_prover_agent.js +5 -17
  33. package/dest/cli/cmds/start_prover_broker.d.ts +1 -1
  34. package/dest/cli/cmds/start_prover_broker.d.ts.map +1 -1
  35. package/dest/cli/cmds/start_prover_broker.js +22 -13
  36. package/dest/cli/cmds/start_txe.d.ts +2 -2
  37. package/dest/cli/cmds/start_txe.d.ts.map +1 -1
  38. package/dest/cli/cmds/start_txe.js +6 -5
  39. package/dest/cli/cmds/utils/collect_crate_dirs.d.ts +21 -0
  40. package/dest/cli/cmds/utils/collect_crate_dirs.d.ts.map +1 -0
  41. package/dest/cli/cmds/utils/collect_crate_dirs.js +114 -0
  42. package/dest/cli/cmds/utils/needs_recompile.d.ts +10 -0
  43. package/dest/cli/cmds/utils/needs_recompile.d.ts.map +1 -0
  44. package/dest/cli/cmds/utils/needs_recompile.js +90 -0
  45. package/dest/cli/cmds/utils/warn_if_aztec_version_mismatch.d.ts +4 -0
  46. package/dest/cli/cmds/utils/warn_if_aztec_version_mismatch.d.ts.map +1 -0
  47. package/dest/cli/cmds/utils/warn_if_aztec_version_mismatch.js +61 -0
  48. package/dest/cli/util.d.ts +3 -5
  49. package/dest/cli/util.d.ts.map +1 -1
  50. package/dest/cli/util.js +46 -85
  51. package/dest/examples/token.js +4 -4
  52. package/dest/local-network/auth_registry.d.ts +4 -0
  53. package/dest/local-network/auth_registry.d.ts.map +1 -0
  54. package/dest/local-network/auth_registry.js +15 -0
  55. package/dest/local-network/banana_fpc.d.ts +1 -1
  56. package/dest/local-network/banana_fpc.d.ts.map +1 -1
  57. package/dest/local-network/banana_fpc.js +9 -7
  58. package/dest/local-network/local-network.d.ts +5 -28
  59. package/dest/local-network/local-network.d.ts.map +1 -1
  60. package/dest/local-network/local-network.js +44 -17
  61. package/dest/testing/anvil_test_watcher.d.ts +15 -3
  62. package/dest/testing/anvil_test_watcher.d.ts.map +1 -1
  63. package/dest/testing/anvil_test_watcher.js +68 -14
  64. package/dest/testing/cheat_codes.d.ts +18 -17
  65. package/dest/testing/cheat_codes.d.ts.map +1 -1
  66. package/dest/testing/cheat_codes.js +72 -36
  67. package/dest/testing/epoch_test_settler.d.ts +1 -1
  68. package/dest/testing/epoch_test_settler.d.ts.map +1 -1
  69. package/dest/testing/epoch_test_settler.js +9 -8
  70. package/dest/testing/index.d.ts +3 -2
  71. package/dest/testing/index.d.ts.map +1 -1
  72. package/dest/testing/index.js +1 -0
  73. package/dest/testing/token_allowed_setup.d.ts +7 -0
  74. package/dest/testing/token_allowed_setup.d.ts.map +1 -0
  75. package/dest/testing/token_allowed_setup.js +20 -0
  76. package/package.json +35 -34
  77. package/scripts/add_crate.sh +53 -0
  78. package/scripts/aztec.sh +10 -3
  79. package/scripts/init.sh +18 -24
  80. package/scripts/new.sh +45 -22
  81. package/scripts/setup_workspace.sh +12 -67
  82. package/scripts/templates/blank/contract/Nargo.toml +6 -0
  83. package/scripts/templates/blank/contract/src/main.nr +10 -0
  84. package/scripts/templates/blank/test/Nargo.toml +7 -0
  85. package/scripts/templates/blank/test/src/lib.nr +11 -0
  86. package/scripts/templates/counter/contract/Nargo.toml +7 -0
  87. package/scripts/templates/counter/contract/src/main.nr +48 -0
  88. package/scripts/templates/counter/test/Nargo.toml +7 -0
  89. package/scripts/templates/counter/test/src/lib.nr +32 -0
  90. package/src/bin/index.ts +2 -2
  91. package/src/cli/aztec_start_action.ts +20 -14
  92. package/src/cli/aztec_start_options.ts +23 -25
  93. package/src/cli/cli.ts +3 -3
  94. package/src/cli/cmds/compile.ts +18 -10
  95. package/src/cli/cmds/profile.ts +2 -1
  96. package/src/cli/cmds/profile_flamegraph.ts +2 -1
  97. package/src/cli/cmds/profile_gates.ts +22 -5
  98. package/src/cli/cmds/standby.ts +132 -0
  99. package/src/cli/cmds/start_bot.ts +3 -5
  100. package/src/cli/cmds/start_node.ts +43 -39
  101. package/src/cli/cmds/start_prover_agent.ts +5 -8
  102. package/src/cli/cmds/start_prover_broker.ts +23 -24
  103. package/src/cli/cmds/start_txe.ts +7 -5
  104. package/src/cli/cmds/utils/collect_crate_dirs.ts +118 -0
  105. package/src/cli/cmds/utils/needs_recompile.ts +98 -0
  106. package/src/cli/cmds/utils/warn_if_aztec_version_mismatch.ts +76 -0
  107. package/src/cli/util.ts +49 -82
  108. package/src/examples/token.ts +6 -4
  109. package/src/local-network/auth_registry.ts +14 -0
  110. package/src/local-network/banana_fpc.ts +5 -8
  111. package/src/local-network/local-network.ts +43 -14
  112. package/src/testing/anvil_test_watcher.ts +76 -13
  113. package/src/testing/cheat_codes.ts +92 -39
  114. package/src/testing/epoch_test_settler.ts +6 -8
  115. package/src/testing/index.ts +2 -1
  116. package/src/testing/token_allowed_setup.ts +19 -0
  117. package/dest/cli/cmds/start_archiver.d.ts +0 -9
  118. package/dest/cli/cmds/start_archiver.d.ts.map +0 -1
  119. package/dest/cli/cmds/start_archiver.js +0 -48
  120. package/dest/cli/release_version.d.ts +0 -2
  121. package/dest/cli/release_version.d.ts.map +0 -1
  122. package/dest/cli/release_version.js +0 -14
  123. package/src/cli/cmds/start_archiver.ts +0 -50
  124. package/src/cli/release_version.ts +0 -21
package/src/cli/util.ts CHANGED
@@ -1,17 +1,18 @@
1
1
  import type { AztecNodeConfig } from '@aztec/aztec-node';
2
2
  import type { AccountManager } from '@aztec/aztec.js/wallet';
3
+ import { getNetworkConfig } from '@aztec/cli/config';
4
+ import { RegistryContract } from '@aztec/ethereum/contracts';
3
5
  import type { ViemClient } from '@aztec/ethereum/types';
4
- import type { ConfigMappingsType } from '@aztec/foundation/config';
5
- import { EthAddress } from '@aztec/foundation/eth-address';
6
+ import type { ConfigMappingsType, NetworkNames } from '@aztec/foundation/config';
6
7
  import { jsonStringify } from '@aztec/foundation/json-rpc';
7
8
  import { type LogFn, createLogger } from '@aztec/foundation/log';
8
- import type { SharedNodeConfig } from '@aztec/node-lib/config';
9
9
  import type { ProverConfig } from '@aztec/stdlib/interfaces/server';
10
- import { getTelemetryClient } from '@aztec/telemetry-client/start';
10
+ import { type VersionCheck, getPackageVersion } from '@aztec/stdlib/update-checker';
11
11
  import type { EmbeddedWallet } from '@aztec/wallets/embedded';
12
12
 
13
13
  import chalk from 'chalk';
14
14
  import type { Command } from 'commander';
15
+ import type { Hex } from 'viem';
15
16
 
16
17
  import { type AztecStartOption, aztecStartOptions } from './aztec_start_options.js';
17
18
 
@@ -81,17 +82,17 @@ export async function createAccountLogs(accountManagers: AccountManager[], walle
81
82
  accountLogStrings.push(` Address: ${completeAddress.address.toString()}\n`);
82
83
  accountLogStrings.push(` Partial Address: ${completeAddress.partialAddress.toString()}\n`);
83
84
  accountLogStrings.push(` Secret Key: ${account.getSecretKey().toString()}\n`);
85
+ accountLogStrings.push(` Master nullifier public key hash: ${completeAddress.publicKeys.npkMHash.toString()}\n`);
86
+ accountLogStrings.push(` Master incoming viewing public key: ${completeAddress.publicKeys.ivpkM.toString()}\n\n`);
84
87
  accountLogStrings.push(
85
- ` Master nullifier public key: ${completeAddress.publicKeys.masterNullifierPublicKey.toString()}\n`,
88
+ ` Master outgoing viewing public key hash: ${completeAddress.publicKeys.ovpkMHash.toString()}\n\n`,
86
89
  );
90
+ accountLogStrings.push(` Master tagging public key hash: ${completeAddress.publicKeys.tpkMHash.toString()}\n\n`);
87
91
  accountLogStrings.push(
88
- ` Master incoming viewing public key: ${completeAddress.publicKeys.masterIncomingViewingPublicKey.toString()}\n\n`,
92
+ ` Master message-signing public key hash: ${completeAddress.publicKeys.mspkMHash.toString()}\n\n`,
89
93
  );
90
94
  accountLogStrings.push(
91
- ` Master outgoing viewing public key: ${completeAddress.publicKeys.masterOutgoingViewingPublicKey.toString()}\n\n`,
92
- );
93
- accountLogStrings.push(
94
- ` Master tagging public key: ${completeAddress.publicKeys.masterTaggingPublicKey.toString()}\n\n`,
95
+ ` Master fallback public key hash: ${completeAddress.publicKeys.fbpkMHash.toString()}\n\n`,
95
96
  );
96
97
  }
97
98
  }
@@ -271,7 +272,7 @@ export async function preloadCrsDataForVerifying(
271
272
  ): Promise<void> {
272
273
  if (realProofs) {
273
274
  const { Crs, GrumpkinCrs } = await import('@aztec/bb.js');
274
- await Promise.all([Crs.new(2 ** 1, undefined, log), GrumpkinCrs.new(2 ** 16 + 1, undefined, log)]);
275
+ await Promise.all([Crs.new(2 ** 1, undefined, log), GrumpkinCrs.new(2 ** 16, undefined, log)]);
275
276
  }
276
277
  }
277
278
 
@@ -286,96 +287,62 @@ export async function preloadCrsDataForServerSideProving(
286
287
  ): Promise<void> {
287
288
  if (realProofs) {
288
289
  const { Crs, GrumpkinCrs } = await import('@aztec/bb.js');
289
- await Promise.all([Crs.new(2 ** 25 + 1, undefined, log), GrumpkinCrs.new(2 ** 18 + 1, undefined, log)]);
290
+ await Promise.all([Crs.new(2 ** 25, undefined, log), GrumpkinCrs.new(2 ** 18, undefined, log)]);
290
291
  }
291
292
  }
292
293
 
293
- export async function setupUpdateMonitor(
294
- autoUpdateMode: SharedNodeConfig['autoUpdate'],
295
- updatesLocation: URL,
294
+ export async function setupVersionChecker(
295
+ network: NetworkNames,
296
296
  followsCanonicalRollup: boolean,
297
297
  publicClient: ViemClient,
298
- registryContractAddress: EthAddress,
299
298
  signalHandlers: Array<() => Promise<void>>,
300
- updateNodeConfig?: (config: object) => Promise<void>,
301
- ) {
302
- const logger = createLogger('update-check');
303
- const { UpdateChecker } = await import('@aztec/stdlib/update-checker');
304
- const checker = await UpdateChecker.new({
305
- baseURL: updatesLocation,
306
- publicClient,
307
- registryContractAddress,
308
- });
299
+ cacheDir?: string,
300
+ ): Promise<void> {
301
+ const networkConfig = await getNetworkConfig(network, cacheDir);
302
+ if (!networkConfig) {
303
+ return;
304
+ }
309
305
 
310
- // eslint-disable-next-line @typescript-eslint/no-misused-promises
311
- checker.on('newRollupVersion', async ({ latestVersion, currentVersion }) => {
312
- if (isShuttingDown()) {
313
- return;
314
- }
306
+ const { VersionChecker } = await import('@aztec/stdlib/update-checker');
315
307
 
316
- // if node follows canonical rollup then this is equivalent to a config update
317
- if (!followsCanonicalRollup) {
318
- return;
319
- }
308
+ const logger = createLogger('version_check');
309
+ const registry = new RegistryContract(publicClient, networkConfig.registryAddress as Hex);
320
310
 
321
- if (autoUpdateMode === 'config' || autoUpdateMode === 'config-and-version') {
322
- logger.info(`New rollup version detected. Please restart the node`, { latestVersion, currentVersion });
323
- await shutdown(logger.info, ExitCode.ROLLUP_UPGRADE, signalHandlers);
324
- } else if (autoUpdateMode === 'notify') {
325
- logger.warn(`New rollup detected. Please restart the node`, { latestVersion, currentVersion });
326
- }
311
+ const checks: Array<VersionCheck> = [];
312
+ checks.push({
313
+ name: 'node',
314
+ currentVersion: getPackageVersion(),
315
+ getLatestVersion: async () => {
316
+ const cfg = await getNetworkConfig(network, cacheDir);
317
+ return cfg?.nodeVersion;
318
+ },
327
319
  });
328
320
 
329
- // eslint-disable-next-line @typescript-eslint/no-misused-promises
330
- checker.on('newNodeVersion', async ({ latestVersion, currentVersion }) => {
331
- if (isShuttingDown()) {
332
- return;
333
- }
334
- if (autoUpdateMode === 'config-and-version') {
335
- logger.info(`New node version detected. Please update and restart the node`, { latestVersion, currentVersion });
336
- await shutdown(logger.info, ExitCode.VERSION_UPGRADE, signalHandlers);
337
- } else if (autoUpdateMode === 'notify') {
338
- logger.info(`New node version detected. Please update and restart the node`, { latestVersion, currentVersion });
321
+ if (followsCanonicalRollup) {
322
+ const getLatestVersion = async () => {
323
+ const version = (await registry.getRollupVersions()).at(-1);
324
+ return version !== undefined ? String(version) : undefined;
325
+ };
326
+ const currentVersion = await getLatestVersion();
327
+ if (currentVersion !== undefined) {
328
+ checks.push({
329
+ name: 'rollup',
330
+ currentVersion,
331
+ getLatestVersion,
332
+ });
339
333
  }
340
- });
334
+ }
341
335
 
342
- // eslint-disable-next-line @typescript-eslint/no-misused-promises
343
- checker.on('updateNodeConfig', async config => {
336
+ const checker = new VersionChecker(checks, 600_000, logger);
337
+ checker.on('newVersion', ({ name, latestVersion, currentVersion }) => {
344
338
  if (isShuttingDown()) {
345
339
  return;
346
340
  }
347
341
 
348
- if ((autoUpdateMode === 'config' || autoUpdateMode === 'config-and-version') && updateNodeConfig) {
349
- logger.warn(`Config change detected. Updating node`, config);
350
- try {
351
- await updateNodeConfig(config);
352
- } catch (err) {
353
- logger.warn('Failed to update config', { err });
354
- }
355
- }
356
- // don't notify on these config changes
342
+ logger.warn(`New ${name} version available`, { latestVersion, currentVersion });
357
343
  });
358
-
359
- checker.on('updatePublicTelemetryConfig', config => {
360
- if (autoUpdateMode === 'config' || autoUpdateMode === 'config-and-version') {
361
- logger.warn(`Public telemetry config change detected. Updating telemetry client`, config);
362
- try {
363
- const publicIncludeMetrics: unknown = (config as any).publicIncludeMetrics;
364
- if (Array.isArray(publicIncludeMetrics) && publicIncludeMetrics.every(m => typeof m === 'string')) {
365
- getTelemetryClient().setExportedPublicTelemetry(publicIncludeMetrics);
366
- }
367
- const publicMetricsCollectFrom: unknown = (config as any).publicMetricsCollectFrom;
368
- if (Array.isArray(publicMetricsCollectFrom) && publicMetricsCollectFrom.every(m => typeof m === 'string')) {
369
- getTelemetryClient().setPublicTelemetryCollectFrom(publicMetricsCollectFrom);
370
- }
371
- } catch (err) {
372
- logger.warn('Failed to update config', { err });
373
- }
374
- }
375
- // don't notify on these config changes
376
- });
377
-
378
344
  checker.start();
345
+ signalHandlers.push(() => checker.stop());
379
346
  }
380
347
 
381
348
  export function stringifyConfig(config: object): string {
@@ -32,7 +32,9 @@ async function main() {
32
32
  logger.info(`Fetched Alice and Bob accounts: ${alice.toString()}, ${bob.toString()}`);
33
33
 
34
34
  logger.info('Deploying Token...');
35
- const token = await TokenContract.deploy(wallet, alice, 'TokenName', 'TokenSymbol', 18).send({ from: alice });
35
+ const { contract: token } = await TokenContract.deploy(wallet, alice, 'TokenName', 'TokenSymbol', 18).send({
36
+ from: alice,
37
+ });
36
38
  logger.info('Token deployed');
37
39
 
38
40
  // Mint tokens to Alice
@@ -41,7 +43,7 @@ async function main() {
41
43
 
42
44
  logger.info(`${ALICE_MINT_BALANCE} tokens were successfully minted by Alice and transferred to private`);
43
45
 
44
- const balanceAfterMint = await token.methods.balance_of_private(alice).simulate({ from: alice });
46
+ const { result: balanceAfterMint } = await token.methods.balance_of_private(alice).simulate({ from: alice });
45
47
  logger.info(`Tokens successfully minted. New Alice's balance: ${balanceAfterMint}`);
46
48
 
47
49
  // We will now transfer tokens from Alice to Bob
@@ -49,10 +51,10 @@ async function main() {
49
51
  await token.methods.transfer(bob, TRANSFER_AMOUNT).send({ from: alice });
50
52
 
51
53
  // Check the new balances
52
- const aliceBalance = await token.methods.balance_of_private(alice).simulate({ from: alice });
54
+ const { result: aliceBalance } = await token.methods.balance_of_private(alice).simulate({ from: alice });
53
55
  logger.info(`Alice's balance ${aliceBalance}`);
54
56
 
55
- const bobBalance = await token.methods.balance_of_private(bob).simulate({ from: bob });
57
+ const { result: bobBalance } = await token.methods.balance_of_private(bob).simulate({ from: bob });
56
58
  logger.info(`Bob's balance ${bobBalance}`);
57
59
  }
58
60
 
@@ -0,0 +1,14 @@
1
+ import { publishContractClass, publishInstance } from '@aztec/aztec.js/deployment';
2
+ import type { Wallet } from '@aztec/aztec.js/wallet';
3
+ import { AuthRegistryArtifact, getStandardAuthRegistry } from '@aztec/standard-contracts/auth-registry';
4
+ import type { AztecAddress } from '@aztec/stdlib/aztec-address';
5
+
6
+ export async function publishStandardAuthRegistry(wallet: Wallet, from: AztecAddress): Promise<void> {
7
+ const { instance, contractClass } = await getStandardAuthRegistry();
8
+ if (!(await wallet.getContractClassMetadata(contractClass.id)).isContractClassPubliclyRegistered) {
9
+ await (await publishContractClass(wallet, AuthRegistryArtifact)).send({ from });
10
+ }
11
+ if (!(await wallet.getContractMetadata(instance.address)).isContractPublished) {
12
+ await publishInstance(wallet, instance).send({ from });
13
+ }
14
+ }
@@ -48,16 +48,13 @@ export async function getBananaFPCAddress(initialAccounts: InitialAccountData[])
48
48
  export async function setupBananaFPC(initialAccounts: InitialAccountData[], wallet: Wallet, log: LogFn) {
49
49
  const bananaCoinAddress = await getBananaCoinAddress(initialAccounts);
50
50
  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,
51
+ const [{ contract: bananaCoin }, { contract: fpc }] = await Promise.all([
52
+ TokenContract.deploy(wallet, admin, bananaCoinArgs.name, bananaCoinArgs.symbol, bananaCoinArgs.decimal, {
53
+ salt: BANANA_COIN_SALT,
55
54
  universalDeploy: true,
56
- }),
57
- FPCContract.deploy(wallet, bananaCoinAddress, admin).send({
55
+ }).send({ from: admin }),
56
+ FPCContract.deploy(wallet, bananaCoinAddress, admin, { salt: BANANA_FPC_SALT, universalDeploy: true }).send({
58
57
  from: admin,
59
- contractAddressSalt: BANANA_FPC_SALT,
60
- universalDeploy: true,
61
58
  }),
62
59
  ]);
63
60
 
@@ -11,6 +11,7 @@ import { waitForPublicClient } from '@aztec/ethereum/client';
11
11
  import { getL1ContractsConfigEnvVars } from '@aztec/ethereum/config';
12
12
  import { NULL_KEY } from '@aztec/ethereum/constants';
13
13
  import { deployAztecL1Contracts } from '@aztec/ethereum/deploy-aztec-l1-contracts';
14
+ import type { L1ContractAddresses } from '@aztec/ethereum/l1-contract-addresses';
14
15
  import { EthCheatCodes } from '@aztec/ethereum/test';
15
16
  import { SecretValue } from '@aztec/foundation/config';
16
17
  import { EthAddress } from '@aztec/foundation/eth-address';
@@ -19,8 +20,9 @@ import { DateProvider, TestDateProvider } from '@aztec/foundation/timer';
19
20
  import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
20
21
  import { protocolContractsHash } from '@aztec/protocol-contracts';
21
22
  import { SequencerState } from '@aztec/sequencer-client';
23
+ import { AztecAddress } from '@aztec/stdlib/aztec-address';
22
24
  import type { ProvingJobBroker } from '@aztec/stdlib/interfaces/server';
23
- import type { PublicDataTreeLeaf } from '@aztec/stdlib/trees';
25
+ import type { GenesisData } from '@aztec/stdlib/world-state';
24
26
  import {
25
27
  type TelemetryClient,
26
28
  getConfigEnvVars as getTelemetryClientConfig,
@@ -38,6 +40,8 @@ import { createAccountLogs } from '../cli/util.js';
38
40
  import { DefaultMnemonic } from '../mnemonic.js';
39
41
  import { AnvilTestWatcher } from '../testing/anvil_test_watcher.js';
40
42
  import { EpochTestSettler } from '../testing/epoch_test_settler.js';
43
+ import { getTokenAllowedSetupFunctions } from '../testing/token_allowed_setup.js';
44
+ import { publishStandardAuthRegistry } from './auth_registry.js';
41
45
  import { getBananaFPCAddress, setupBananaFPC } from './banana_fpc.js';
42
46
  import { getSponsoredFPCAddress } from './sponsored_fpc.js';
43
47
 
@@ -57,7 +61,7 @@ export async function deployContractsToL1(
57
61
  genesisArchiveRoot?: Fr;
58
62
  feeJuicePortalInitialBalance?: bigint;
59
63
  } = {},
60
- ) {
64
+ ): Promise<L1ContractAddresses> {
61
65
  await waitForPublicClient(aztecNodeConfig);
62
66
 
63
67
  const l1Contracts = await deployAztecL1Contracts(aztecNodeConfig.l1RpcUrls[0], privateKey, foundry.id, {
@@ -68,14 +72,14 @@ export async function deployContractsToL1(
68
72
  genesisArchiveRoot: opts.genesisArchiveRoot ?? new Fr(GENESIS_ARCHIVE_ROOT),
69
73
  feeJuicePortalInitialBalance: opts.feeJuicePortalInitialBalance,
70
74
  aztecTargetCommitteeSize: 0, // no committee in local network
71
- slasherFlavor: 'none', // no slashing in local network
75
+ slasherEnabled: false, // no slashing in local network
72
76
  realVerifier: false,
73
77
  });
74
78
 
75
- aztecNodeConfig.l1Contracts = l1Contracts.l1ContractAddresses;
79
+ Object.assign(aztecNodeConfig, l1Contracts.l1ContractAddresses);
76
80
  aztecNodeConfig.rollupVersion = l1Contracts.rollupVersion;
77
81
 
78
- return aztecNodeConfig.l1Contracts;
82
+ return l1Contracts.l1ContractAddresses;
79
83
  }
80
84
 
81
85
  /** Local network settings. */
@@ -101,9 +105,14 @@ export async function createLocalNetwork(config: Partial<LocalNetworkConfig> = {
101
105
  logger.warn(`Multiple L1 RPC URLs provided. Local networks will only use the first one: ${l1RpcUrl}`);
102
106
  }
103
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
+
104
112
  const aztecNodeConfig: AztecNodeConfig = {
105
113
  ...getConfigEnvVars(),
106
114
  ...config,
115
+ txPublicSetupAllowListExtend: [...tokenAllowList, ...(config.txPublicSetupAllowListExtend ?? [])],
107
116
  };
108
117
  const hdAccount = mnemonicToAccount(config.l1Mnemonic || DefaultMnemonic);
109
118
  if (
@@ -138,10 +147,13 @@ export async function createLocalNetwork(config: Partial<LocalNetworkConfig> = {
138
147
 
139
148
  const bananaFPC = await getBananaFPCAddress(initialAccounts);
140
149
  const sponsoredFPC = await getSponsoredFPCAddress();
141
- const fundedAddresses = initialAccounts.length
142
- ? [...initialAccounts.map(a => a.address), bananaFPC, sponsoredFPC]
143
- : [];
144
- const { genesisArchiveRoot, prefilledPublicData, fundingNeeded } = await getGenesisValues(fundedAddresses);
150
+ const prefundAddresses = (aztecNodeConfig.prefundAddresses ?? []).map(a => AztecAddress.fromString(a));
151
+ const fundedAddresses = [
152
+ ...initialAccounts.map(a => a.address),
153
+ ...(initialAccounts.length ? [bananaFPC, sponsoredFPC] : []),
154
+ ...prefundAddresses,
155
+ ];
156
+ const { genesisArchiveRoot, genesis, fundingNeeded } = await getGenesisValues(fundedAddresses);
145
157
 
146
158
  const dateProvider = new TestDateProvider();
147
159
 
@@ -180,7 +192,7 @@ export async function createLocalNetwork(config: Partial<LocalNetworkConfig> = {
180
192
  const telemetry = await initTelemetryClient(getTelemetryClientConfig());
181
193
  // Create a local blob client client inside the local network, no http connectivity
182
194
  const blobClient = createBlobClient();
183
- const node = await createAztecNode(aztecNodeConfig, { telemetry, blobClient, dateProvider }, { prefilledPublicData });
195
+ const node = await createAztecNode(aztecNodeConfig, { telemetry, blobClient, dateProvider }, { genesis });
184
196
 
185
197
  // Now that the node is up, let the watcher check for pending txs so it can skip unfilled slots faster when
186
198
  // transactions are waiting in the mempool. Also let it check if the sequencer is actively building, to avoid
@@ -195,6 +207,21 @@ export async function createLocalNetwork(config: Partial<LocalNetworkConfig> = {
195
207
  SequencerState.SYNCHRONIZING,
196
208
  ]);
197
209
  watcher?.setIsSequencerBuilding(() => !idleStates.has(sequencer.getState()));
210
+ // Under proposer pipelining the L1 publish for slot N happens during wall-clock slot N,
211
+ // but the proposer for slot N has already built the checkpoint during slot N-1 and is
212
+ // waiting for L1 to advance. We need to fast-forward L1 to wake that wait — and the wait
213
+ // we have to break first is `waitForValidParentCheckpointOnL1`, which blocks the
214
+ // checkpoint_proposal_job's background submission task until the archiver has synced past
215
+ // the build slot. That wait happens *before* `PUBLISHING_CHECKPOINT` is set, so a hook on
216
+ // that state transition would be circular (L1 has to advance before the state we'd use to
217
+ // advance L1 fires). The earliest pre-wait signal is `block-proposed`, which the sequencer
218
+ // emits once each block is built. In sandbox single-block-per-slot mode this is
219
+ // effectively "checkpoint built", and the watcher warp is harmless if a subsequent
220
+ // assembly/validation/parent-wait step aborts: L1 just sits one slot ahead, which the
221
+ // cascade absorbs.
222
+ if (watcher) {
223
+ sequencer.on('block-proposed', ({ slot }) => watcher!.setProposedTargetSlot(Number(slot)));
224
+ }
198
225
  }
199
226
 
200
227
  let epochTestSettler: EpochTestSettler | undefined;
@@ -220,6 +247,9 @@ export async function createLocalNetwork(config: Partial<LocalNetworkConfig> = {
220
247
  const accLogs = await createAccountLogs(accountManagers, wallet);
221
248
  userLog(accLogs.join(''));
222
249
 
250
+ userLog('Publishing standard AuthRegistry contract...');
251
+ await publishStandardAuthRegistry(wallet, initialAccounts[0].address);
252
+
223
253
  await setupBananaFPC(initialAccounts, wallet, userLog);
224
254
 
225
255
  userLog(`SponsoredFPC: ${await getSponsoredFPCAddress()}`);
@@ -249,14 +279,13 @@ export async function createAztecNode(
249
279
  dateProvider?: DateProvider;
250
280
  proverBroker?: ProvingJobBroker;
251
281
  } = {},
252
- options: { prefilledPublicData?: PublicDataTreeLeaf[] } = {},
282
+ options: { genesis?: GenesisData } = {},
253
283
  ) {
254
284
  // TODO(#12272): will clean this up. This is criminal.
255
- const { l1Contracts, ...rest } = getConfigEnvVars();
285
+ // Not sure why this was ever done. Will be fixed in A-989, A-991, A-990.
256
286
  const aztecNodeConfig: AztecNodeConfig = {
257
- ...rest,
287
+ ...getConfigEnvVars(),
258
288
  ...config,
259
- l1Contracts: { ...l1Contracts, ...config.l1Contracts },
260
289
  };
261
290
  const node = await AztecNodeService.createAndSync(
262
291
  aztecNodeConfig,
@@ -9,6 +9,11 @@ import { RollupAbi } from '@aztec/l1-artifacts/RollupAbi';
9
9
 
10
10
  import { type GetContractReturnType, getAddress, getContract } from 'viem';
11
11
 
12
+ export type AnvilTestWatcherOpts = {
13
+ isLocalNetwork?: boolean;
14
+ isMarkingAsProven?: boolean;
15
+ };
16
+
12
17
  /**
13
18
  * Represents a watcher for a rollup contract.
14
19
  *
@@ -17,7 +22,8 @@ import { type GetContractReturnType, getAddress, getContract } from 'viem';
17
22
  * block within the slot. And if so, it will time travel into the next slot.
18
23
  */
19
24
  export class AnvilTestWatcher {
20
- private isLocalNetwork: boolean = false;
25
+ private isLocalNetwork;
26
+ private isMarkingAsProven;
21
27
 
22
28
  private rollup: GetContractReturnType<typeof RollupAbi, ViemClient>;
23
29
  private rollupCheatCodes: RollupCheatCodes;
@@ -29,8 +35,6 @@ export class AnvilTestWatcher {
29
35
 
30
36
  private logger: Logger = createLogger(`aztecjs:utils:watcher`);
31
37
 
32
- private isMarkingAsProven = true;
33
-
34
38
  // Optional callback to check if there are pending txs in the mempool.
35
39
  private getPendingTxCount?: () => Promise<number>;
36
40
 
@@ -40,11 +44,18 @@ export class AnvilTestWatcher {
40
44
  // Tracks when we first observed the current unfilled slot with pending txs (real wall time).
41
45
  private unfilledSlotFirstSeen?: { slot: number; realTime: number };
42
46
 
47
+ // Latest target slot for which the proposer has built a block destined for L1 but which has
48
+ // not yet been committed. Set by the proposer-pipelining hook from `block-proposed` events so
49
+ // the watcher can advance L1 (and the injected date provider) to the target slot ahead of the
50
+ // publisher's `sendRequestsAt` sleep, instead of waiting a full wall-clock slot.
51
+ private proposedTargetSlot?: number;
52
+
43
53
  constructor(
44
54
  private cheatcodes: EthCheatCodes,
45
55
  rollupAddress: EthAddress,
46
56
  l1Client: ViemClient,
47
57
  private dateProvider?: TestDateProvider,
58
+ opts: AnvilTestWatcherOpts = {},
48
59
  ) {
49
60
  this.rollup = getContract({
50
61
  address: getAddress(rollupAddress.toString()),
@@ -56,6 +67,9 @@ export class AnvilTestWatcher {
56
67
  rollupAddress,
57
68
  });
58
69
 
70
+ this.isLocalNetwork = opts.isLocalNetwork ?? false;
71
+ this.isMarkingAsProven = opts.isMarkingAsProven ?? true;
72
+
59
73
  this.logger.debug(`Watcher created for rollup at ${rollupAddress}`);
60
74
  }
61
75
 
@@ -78,6 +92,18 @@ export class AnvilTestWatcher {
78
92
  this.isSequencerBuilding = fn;
79
93
  }
80
94
 
95
+ /**
96
+ * Records the target slot for which the proposer has built a block destined for L1. Used by
97
+ * the local-network watcher to fast-forward L1 (and the injected date provider) ahead of the
98
+ * pipelined publisher's `sendRequestsAt` sleep so it ends promptly instead of waiting a full
99
+ * wall-clock slot. Only ratchets up — late warps for stale slots are no-ops.
100
+ */
101
+ setProposedTargetSlot(slot: number) {
102
+ if (this.proposedTargetSlot === undefined || slot > this.proposedTargetSlot) {
103
+ this.proposedTargetSlot = slot;
104
+ }
105
+ }
106
+
81
107
  async start() {
82
108
  if (this.filledRunningPromise) {
83
109
  throw new Error('Watcher already watching for filled slot');
@@ -130,14 +156,21 @@ export class AnvilTestWatcher {
130
156
  return;
131
157
  }
132
158
 
133
- const l1Time = (await this.cheatcodes.timestamp()) * 1000;
159
+ const l1Time = (await this.cheatcodes.lastBlockTimestamp()) * 1000;
134
160
  const wallTime = this.dateProvider.now();
135
161
  if (l1Time > wallTime) {
136
162
  this.logger.warn(`L1 is ahead of wall time. Syncing wall time to L1 time`);
137
163
  this.dateProvider.setTime(l1Time);
138
164
  } else if (l1Time + Number(this.l2SlotDuration) * 1000 < wallTime) {
139
- this.logger.warn(`L1 is more than 1 L2 slot behind wall time. Warping to wall time`);
140
- await this.cheatcodes.warp(Math.ceil(wallTime / 1000));
165
+ // Warp L1 to the slot boundary at-or-before wall time. Rounding to a slot boundary (rather than
166
+ // `ceil(wallTime / 1000)`) keeps this loop's target aligned with `warpTimeIfNeeded`'s
167
+ // `nextSlotTimestamp` target, avoiding a race where the two loops pick timestamps a fraction of
168
+ // a second apart and one of them is then rejected by anvil as non-monotonic.
169
+ const wallSec = Math.floor(wallTime / 1000);
170
+ const targetSlot = await this.rollup.read.getSlotAt([BigInt(wallSec)]);
171
+ const targetTimestamp = Number(await this.rollup.read.getTimestampForSlot([targetSlot]));
172
+ this.logger.warn(`L1 is more than 1 L2 slot behind wall time. Warping to slot ${targetSlot} boundary`);
173
+ await this.warpToTimestamp(targetTimestamp);
141
174
  }
142
175
  }
143
176
 
@@ -151,8 +184,9 @@ export class AnvilTestWatcher {
151
184
 
152
185
  if (BigInt(currentSlot) === checkpointLog.slotNumber) {
153
186
  // The current slot has been filled, we should jump to the next slot.
154
- await this.warpToTimestamp(nextSlotTimestamp);
155
- this.logger.info(`Slot ${currentSlot} was filled, jumped to next slot`);
187
+ if (await this.warpToTimestamp(nextSlotTimestamp)) {
188
+ this.logger.info(`Slot ${currentSlot} was filled, jumped to next slot`);
189
+ }
156
190
  return;
157
191
  }
158
192
 
@@ -161,6 +195,20 @@ export class AnvilTestWatcher {
161
195
  return;
162
196
  }
163
197
 
198
+ // Pipelined-publish shortcut: if the proposer has built a block destined for a slot
199
+ // beyond the current L1 slot, fast-forward L1 to that slot's timestamp so the publisher's
200
+ // `sendRequestsAt(targetSlot)` sleep ends and the multicall mines inside the target slot.
201
+ // Without this, the publisher waits up to a full real-time slot for wall clock to catch up.
202
+ if (this.proposedTargetSlot !== undefined && this.proposedTargetSlot > currentSlot) {
203
+ const targetSlotTimestamp = Number(
204
+ await this.rollup.read.getTimestampForSlot([BigInt(this.proposedTargetSlot)]),
205
+ );
206
+ if (await this.warpToTimestamp(targetSlotTimestamp)) {
207
+ this.logger.info(`Warped L1 to target slot ${this.proposedTargetSlot} for pipelined publish`);
208
+ }
209
+ return;
210
+ }
211
+
164
212
  // If there are pending txs and the sequencer missed them, warp quickly (after a 2s real-time debounce) so the
165
213
  // sequencer can retry in the next slot. Without this, we'd have to wait a full real-time slot duration (~36s) for
166
214
  // the dateProvider to catch up to the next slot timestamp. We skip the warp if the sequencer is actively building
@@ -180,9 +228,10 @@ export class AnvilTestWatcher {
180
228
  }
181
229
 
182
230
  if (realNow - this.unfilledSlotFirstSeen.realTime > 2000) {
183
- await this.warpToTimestamp(nextSlotTimestamp);
231
+ if (await this.warpToTimestamp(nextSlotTimestamp)) {
232
+ this.logger.info(`Slot ${currentSlot} was missed with pending txs, jumped to next slot`);
233
+ }
184
234
  this.unfilledSlotFirstSeen = undefined;
185
- this.logger.info(`Slot ${currentSlot} was missed with pending txs, jumped to next slot`);
186
235
  }
187
236
 
188
237
  return;
@@ -192,19 +241,33 @@ export class AnvilTestWatcher {
192
241
  // Fallback: warp when the dateProvider time has passed the next slot timestamp.
193
242
  const currentTimestamp = this.dateProvider?.now() ?? Date.now();
194
243
  if (currentTimestamp > nextSlotTimestamp * 1000) {
195
- await this.warpToTimestamp(nextSlotTimestamp);
196
- this.logger.info(`Slot ${currentSlot} was missed, jumped to next slot`);
244
+ if (await this.warpToTimestamp(nextSlotTimestamp)) {
245
+ this.logger.info(`Slot ${currentSlot} was missed, jumped to next slot`);
246
+ }
197
247
  }
198
248
  } catch {
199
249
  this.logger.error('mineIfSlotFilled failed');
200
250
  }
201
251
  }
202
252
 
203
- private async warpToTimestamp(timestamp: number) {
253
+ /**
254
+ * Warps L1 to `timestamp`, unless L1 is already at or past it. Returns true when a warp actually
255
+ * happened, false when skipped or on error. Callers use the return value to gate success logs.
256
+ */
257
+ private async warpToTimestamp(timestamp: number): Promise<boolean> {
204
258
  try {
259
+ // Anvil rejects evm_setNextBlockTimestamp values <= the current block's timestamp. The two
260
+ // watcher loops can race and pick targets a fraction of a second apart; skip here rather than
261
+ // letting the second one error out noisily.
262
+ const lastTimestamp = await this.cheatcodes.lastBlockTimestamp();
263
+ if (timestamp <= lastTimestamp) {
264
+ return false;
265
+ }
205
266
  await this.cheatcodes.warp(timestamp, { resetBlockInterval: true });
267
+ return true;
206
268
  } catch (e) {
207
269
  this.logger.error(`Failed to warp to timestamp ${timestamp}: ${e}`);
270
+ return false;
208
271
  }
209
272
  }
210
273
  }