@aztec/aztec 0.0.1-commit.db765a8 → 0.0.1-commit.ddcf04837

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 (88) 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 +26 -7
  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 +9 -3
  8. package/dest/cli/cmds/compile.d.ts +1 -1
  9. package/dest/cli/cmds/compile.d.ts.map +1 -1
  10. package/dest/cli/cmds/compile.js +9 -1
  11. package/dest/cli/cmds/profile_flamegraph.d.ts +1 -1
  12. package/dest/cli/cmds/profile_flamegraph.d.ts.map +1 -1
  13. package/dest/cli/cmds/profile_flamegraph.js +2 -1
  14. package/dest/cli/cmds/profile_gates.d.ts +1 -1
  15. package/dest/cli/cmds/profile_gates.d.ts.map +1 -1
  16. package/dest/cli/cmds/profile_gates.js +2 -1
  17. package/dest/cli/cmds/standby.d.ts +32 -0
  18. package/dest/cli/cmds/standby.d.ts.map +1 -0
  19. package/dest/cli/cmds/standby.js +97 -0
  20. package/dest/cli/cmds/start_archiver.d.ts +2 -2
  21. package/dest/cli/cmds/start_archiver.d.ts.map +1 -1
  22. package/dest/cli/cmds/start_archiver.js +4 -2
  23. package/dest/cli/cmds/start_node.d.ts +3 -2
  24. package/dest/cli/cmds/start_node.d.ts.map +1 -1
  25. package/dest/cli/cmds/start_node.js +24 -90
  26. package/dest/cli/cmds/start_prover_agent.d.ts +1 -1
  27. package/dest/cli/cmds/start_prover_agent.d.ts.map +1 -1
  28. package/dest/cli/cmds/start_prover_agent.js +3 -15
  29. package/dest/cli/cmds/start_prover_broker.d.ts +1 -1
  30. package/dest/cli/cmds/start_prover_broker.d.ts.map +1 -1
  31. package/dest/cli/cmds/start_prover_broker.js +12 -6
  32. package/dest/cli/cmds/utils/collect_crate_dirs.d.ts +21 -0
  33. package/dest/cli/cmds/utils/collect_crate_dirs.d.ts.map +1 -0
  34. package/dest/cli/cmds/utils/collect_crate_dirs.js +114 -0
  35. package/dest/cli/cmds/utils/needs_recompile.d.ts +10 -0
  36. package/dest/cli/cmds/utils/needs_recompile.d.ts.map +1 -0
  37. package/dest/cli/cmds/utils/needs_recompile.js +90 -0
  38. package/dest/cli/cmds/utils/warn_if_aztec_version_mismatch.d.ts +4 -0
  39. package/dest/cli/cmds/utils/warn_if_aztec_version_mismatch.d.ts.map +1 -0
  40. package/dest/cli/cmds/utils/warn_if_aztec_version_mismatch.js +41 -0
  41. package/dest/cli/util.d.ts +3 -5
  42. package/dest/cli/util.d.ts.map +1 -1
  43. package/dest/cli/util.js +37 -78
  44. package/dest/local-network/local-network.d.ts +3 -4
  45. package/dest/local-network/local-network.d.ts.map +1 -1
  46. package/dest/local-network/local-network.js +12 -4
  47. package/dest/testing/anvil_test_watcher.d.ts +1 -1
  48. package/dest/testing/anvil_test_watcher.d.ts.map +1 -1
  49. package/dest/testing/anvil_test_watcher.js +36 -10
  50. package/dest/testing/cheat_codes.d.ts +11 -15
  51. package/dest/testing/cheat_codes.d.ts.map +1 -1
  52. package/dest/testing/cheat_codes.js +34 -32
  53. package/dest/testing/epoch_test_settler.d.ts +1 -1
  54. package/dest/testing/epoch_test_settler.d.ts.map +1 -1
  55. package/dest/testing/epoch_test_settler.js +3 -4
  56. package/dest/testing/index.d.ts +2 -1
  57. package/dest/testing/index.d.ts.map +1 -1
  58. package/dest/testing/index.js +1 -0
  59. package/dest/testing/token_allowed_setup.d.ts +7 -0
  60. package/dest/testing/token_allowed_setup.d.ts.map +1 -0
  61. package/dest/testing/token_allowed_setup.js +20 -0
  62. package/package.json +34 -34
  63. package/scripts/aztec.sh +4 -1
  64. package/src/bin/index.ts +2 -2
  65. package/src/cli/aztec_start_action.ts +15 -7
  66. package/src/cli/aztec_start_options.ts +15 -5
  67. package/src/cli/cmds/compile.ts +11 -1
  68. package/src/cli/cmds/profile_flamegraph.ts +2 -1
  69. package/src/cli/cmds/profile_gates.ts +2 -1
  70. package/src/cli/cmds/standby.ts +132 -0
  71. package/src/cli/cmds/start_archiver.ts +8 -2
  72. package/src/cli/cmds/start_node.ts +32 -112
  73. package/src/cli/cmds/start_prover_agent.ts +3 -6
  74. package/src/cli/cmds/start_prover_broker.ts +14 -14
  75. package/src/cli/cmds/utils/collect_crate_dirs.ts +118 -0
  76. package/src/cli/cmds/utils/needs_recompile.ts +98 -0
  77. package/src/cli/cmds/utils/warn_if_aztec_version_mismatch.ts +54 -0
  78. package/src/cli/util.ts +41 -74
  79. package/src/local-network/local-network.ts +11 -5
  80. package/src/testing/anvil_test_watcher.ts +33 -10
  81. package/src/testing/cheat_codes.ts +42 -36
  82. package/src/testing/epoch_test_settler.ts +3 -4
  83. package/src/testing/index.ts +1 -0
  84. package/src/testing/token_allowed_setup.ts +19 -0
  85. package/dest/cli/release_version.d.ts +0 -2
  86. package/dest/cli/release_version.d.ts.map +0 -1
  87. package/dest/cli/release_version.js +0 -14
  88. 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
 
@@ -290,92 +291,58 @@ export async function preloadCrsDataForServerSideProving(
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() ?? 'unknown',
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
357
- });
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
342
+ logger.warn(`New ${name} version available`, { latestVersion, currentVersion });
376
343
  });
377
-
378
344
  checker.start();
345
+ signalHandlers.push(() => checker.stop());
379
346
  }
380
347
 
381
348
  export function stringifyConfig(config: object): string {
@@ -21,7 +21,7 @@ import { protocolContractsHash } from '@aztec/protocol-contracts';
21
21
  import { SequencerState } from '@aztec/sequencer-client';
22
22
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
23
23
  import type { ProvingJobBroker } from '@aztec/stdlib/interfaces/server';
24
- import type { PublicDataTreeLeaf } from '@aztec/stdlib/trees';
24
+ import type { GenesisData } from '@aztec/stdlib/world-state';
25
25
  import {
26
26
  type TelemetryClient,
27
27
  getConfigEnvVars as getTelemetryClientConfig,
@@ -39,6 +39,7 @@ import { createAccountLogs } from '../cli/util.js';
39
39
  import { DefaultMnemonic } from '../mnemonic.js';
40
40
  import { AnvilTestWatcher } from '../testing/anvil_test_watcher.js';
41
41
  import { EpochTestSettler } from '../testing/epoch_test_settler.js';
42
+ import { getTokenAllowedSetupFunctions } from '../testing/token_allowed_setup.js';
42
43
  import { getBananaFPCAddress, setupBananaFPC } from './banana_fpc.js';
43
44
  import { getSponsoredFPCAddress } from './sponsored_fpc.js';
44
45
 
@@ -69,7 +70,7 @@ export async function deployContractsToL1(
69
70
  genesisArchiveRoot: opts.genesisArchiveRoot ?? new Fr(GENESIS_ARCHIVE_ROOT),
70
71
  feeJuicePortalInitialBalance: opts.feeJuicePortalInitialBalance,
71
72
  aztecTargetCommitteeSize: 0, // no committee in local network
72
- slasherFlavor: 'none', // no slashing in local network
73
+ slasherEnabled: false, // no slashing in local network
73
74
  realVerifier: false,
74
75
  });
75
76
 
@@ -102,9 +103,14 @@ export async function createLocalNetwork(config: Partial<LocalNetworkConfig> = {
102
103
  logger.warn(`Multiple L1 RPC URLs provided. Local networks will only use the first one: ${l1RpcUrl}`);
103
104
  }
104
105
 
106
+ // The local network deploys a banana FPC with Token contracts, so include Token entries
107
+ // in the setup allowlist so FPC-based fee payments work out of the box.
108
+ const tokenAllowList = await getTokenAllowedSetupFunctions();
109
+
105
110
  const aztecNodeConfig: AztecNodeConfig = {
106
111
  ...getConfigEnvVars(),
107
112
  ...config,
113
+ txPublicSetupAllowListExtend: [...tokenAllowList, ...(config.txPublicSetupAllowListExtend ?? [])],
108
114
  };
109
115
  const hdAccount = mnemonicToAccount(config.l1Mnemonic || DefaultMnemonic);
110
116
  if (
@@ -145,7 +151,7 @@ export async function createLocalNetwork(config: Partial<LocalNetworkConfig> = {
145
151
  ...(initialAccounts.length ? [bananaFPC, sponsoredFPC] : []),
146
152
  ...prefundAddresses,
147
153
  ];
148
- const { genesisArchiveRoot, prefilledPublicData, fundingNeeded } = await getGenesisValues(fundedAddresses);
154
+ const { genesisArchiveRoot, genesis, fundingNeeded } = await getGenesisValues(fundedAddresses);
149
155
 
150
156
  const dateProvider = new TestDateProvider();
151
157
 
@@ -184,7 +190,7 @@ export async function createLocalNetwork(config: Partial<LocalNetworkConfig> = {
184
190
  const telemetry = await initTelemetryClient(getTelemetryClientConfig());
185
191
  // Create a local blob client client inside the local network, no http connectivity
186
192
  const blobClient = createBlobClient();
187
- const node = await createAztecNode(aztecNodeConfig, { telemetry, blobClient, dateProvider }, { prefilledPublicData });
193
+ const node = await createAztecNode(aztecNodeConfig, { telemetry, blobClient, dateProvider }, { genesis });
188
194
 
189
195
  // Now that the node is up, let the watcher check for pending txs so it can skip unfilled slots faster when
190
196
  // transactions are waiting in the mempool. Also let it check if the sequencer is actively building, to avoid
@@ -253,7 +259,7 @@ export async function createAztecNode(
253
259
  dateProvider?: DateProvider;
254
260
  proverBroker?: ProvingJobBroker;
255
261
  } = {},
256
- options: { prefilledPublicData?: PublicDataTreeLeaf[] } = {},
262
+ options: { genesis?: GenesisData } = {},
257
263
  ) {
258
264
  // TODO(#12272): will clean this up. This is criminal.
259
265
  const { l1Contracts, ...rest } = getConfigEnvVars();
@@ -130,14 +130,21 @@ export class AnvilTestWatcher {
130
130
  return;
131
131
  }
132
132
 
133
- const l1Time = (await this.cheatcodes.timestamp()) * 1000;
133
+ const l1Time = (await this.cheatcodes.lastBlockTimestamp()) * 1000;
134
134
  const wallTime = this.dateProvider.now();
135
135
  if (l1Time > wallTime) {
136
136
  this.logger.warn(`L1 is ahead of wall time. Syncing wall time to L1 time`);
137
137
  this.dateProvider.setTime(l1Time);
138
138
  } 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));
139
+ // Warp L1 to the slot boundary at-or-before wall time. Rounding to a slot boundary (rather than
140
+ // `ceil(wallTime / 1000)`) keeps this loop's target aligned with `warpTimeIfNeeded`'s
141
+ // `nextSlotTimestamp` target, avoiding a race where the two loops pick timestamps a fraction of
142
+ // a second apart and one of them is then rejected by anvil as non-monotonic.
143
+ const wallSec = Math.floor(wallTime / 1000);
144
+ const targetSlot = await this.rollup.read.getSlotAt([BigInt(wallSec)]);
145
+ const targetTimestamp = Number(await this.rollup.read.getTimestampForSlot([targetSlot]));
146
+ this.logger.warn(`L1 is more than 1 L2 slot behind wall time. Warping to slot ${targetSlot} boundary`);
147
+ await this.warpToTimestamp(targetTimestamp);
141
148
  }
142
149
  }
143
150
 
@@ -151,8 +158,9 @@ export class AnvilTestWatcher {
151
158
 
152
159
  if (BigInt(currentSlot) === checkpointLog.slotNumber) {
153
160
  // 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`);
161
+ if (await this.warpToTimestamp(nextSlotTimestamp)) {
162
+ this.logger.info(`Slot ${currentSlot} was filled, jumped to next slot`);
163
+ }
156
164
  return;
157
165
  }
158
166
 
@@ -180,9 +188,10 @@ export class AnvilTestWatcher {
180
188
  }
181
189
 
182
190
  if (realNow - this.unfilledSlotFirstSeen.realTime > 2000) {
183
- await this.warpToTimestamp(nextSlotTimestamp);
191
+ if (await this.warpToTimestamp(nextSlotTimestamp)) {
192
+ this.logger.info(`Slot ${currentSlot} was missed with pending txs, jumped to next slot`);
193
+ }
184
194
  this.unfilledSlotFirstSeen = undefined;
185
- this.logger.info(`Slot ${currentSlot} was missed with pending txs, jumped to next slot`);
186
195
  }
187
196
 
188
197
  return;
@@ -192,19 +201,33 @@ export class AnvilTestWatcher {
192
201
  // Fallback: warp when the dateProvider time has passed the next slot timestamp.
193
202
  const currentTimestamp = this.dateProvider?.now() ?? Date.now();
194
203
  if (currentTimestamp > nextSlotTimestamp * 1000) {
195
- await this.warpToTimestamp(nextSlotTimestamp);
196
- this.logger.info(`Slot ${currentSlot} was missed, jumped to next slot`);
204
+ if (await this.warpToTimestamp(nextSlotTimestamp)) {
205
+ this.logger.info(`Slot ${currentSlot} was missed, jumped to next slot`);
206
+ }
197
207
  }
198
208
  } catch {
199
209
  this.logger.error('mineIfSlotFilled failed');
200
210
  }
201
211
  }
202
212
 
203
- private async warpToTimestamp(timestamp: number) {
213
+ /**
214
+ * Warps L1 to `timestamp`, unless L1 is already at or past it. Returns true when a warp actually
215
+ * happened, false when skipped or on error. Callers use the return value to gate success logs.
216
+ */
217
+ private async warpToTimestamp(timestamp: number): Promise<boolean> {
204
218
  try {
219
+ // Anvil rejects evm_setNextBlockTimestamp values <= the current block's timestamp. The two
220
+ // watcher loops can race and pick targets a fraction of a second apart; skip here rather than
221
+ // letting the second one error out noisily.
222
+ const lastTimestamp = await this.cheatcodes.lastBlockTimestamp();
223
+ if (timestamp <= lastTimestamp) {
224
+ return false;
225
+ }
205
226
  await this.cheatcodes.warp(timestamp, { resetBlockInterval: true });
227
+ return true;
206
228
  } catch (e) {
207
229
  this.logger.error(`Failed to warp to timestamp ${timestamp}: ${e}`);
230
+ return false;
208
231
  }
209
232
  }
210
233
  }
@@ -1,9 +1,8 @@
1
1
  import { EthCheatCodes, RollupCheatCodes } from '@aztec/ethereum/test';
2
- import { BlockNumber } from '@aztec/foundation/branded-types';
3
- import { retryUntil } from '@aztec/foundation/retry';
2
+ import { SlotNumber } from '@aztec/foundation/branded-types';
3
+ import { createLogger } from '@aztec/foundation/log';
4
4
  import type { DateProvider } from '@aztec/foundation/timer';
5
- import type { SequencerClient } from '@aztec/sequencer-client';
6
- import type { AztecNode } from '@aztec/stdlib/interfaces/client';
5
+ import type { AztecNode, AztecNodeDebug } from '@aztec/stdlib/interfaces/client';
7
6
 
8
7
  /**
9
8
  * A class that provides utility functions for interacting with the chain.
@@ -12,6 +11,8 @@ import type { AztecNode } from '@aztec/stdlib/interfaces/client';
12
11
  * codes, please consider whether it makes sense to just introduce new utils in your tests instead.
13
12
  */
14
13
  export class CheatCodes {
14
+ private logger = createLogger('aztecjs:cheat_codes');
15
+
15
16
  constructor(
16
17
  /** Cheat codes for L1.*/
17
18
  public eth: EthCheatCodes,
@@ -30,50 +31,55 @@ export class CheatCodes {
30
31
 
31
32
  /**
32
33
  * Warps the L1 timestamp to a target timestamp and mines an L2 block that advances the L2 timestamp to at least
33
- * the target timestamp. L2 timestamp is not advanced exactly to the target timestamp because it is determined
34
- * by the slot number, which advances in fixed intervals.
35
- * This is useful for testing time-dependent contract behavior.
36
- * @param sequencerClient - The sequencer client to use to force an empty block to be mined.
37
- * @param node - The Aztec node used to query if a new block has been mined.
34
+ * the target timestamp. If the target timestamp falls within the current L2 slot (which already has a block),
35
+ * the timestamp is automatically adjusted forward to the start of the next slot so that `mineBlock()` succeeds.
36
+ * @param node - The Aztec node used to force an empty block to be mined.
38
37
  * @param targetTimestamp - The target timestamp to warp to (in seconds)
39
38
  */
40
- async warpL2TimeAtLeastTo(sequencerClient: SequencerClient, node: AztecNode, targetTimestamp: bigint | number) {
41
- const currentL2BlockNumber: BlockNumber = await node.getBlockNumber();
39
+ async warpL2TimeAtLeastTo(node: AztecNodeDebug, targetTimestamp: bigint | number) {
40
+ const targetBigInt = BigInt(targetTimestamp);
41
+ const currentTimestamp = BigInt(await this.eth.lastBlockTimestamp());
42
42
 
43
- // We warp the L1 timestamp
44
- await this.eth.warp(targetTimestamp, { resetBlockInterval: true });
43
+ if (targetBigInt <= currentTimestamp) {
44
+ throw new Error(
45
+ `warpL2TimeAtLeastTo: target timestamp ${targetBigInt} is not in the future (current L1 timestamp is ${currentTimestamp}).`,
46
+ );
47
+ }
45
48
 
46
- // Wait until an L2 block is mined
47
- const sequencer = sequencerClient.getSequencer();
48
- const minTxsPerBlock = sequencer.getConfig().minTxsPerBlock;
49
- sequencer.updateConfig({ minTxsPerBlock: 0 });
49
+ const currentSlot = await this.rollup.getSlot();
50
+ const targetSlot = await this.rollup.getSlotAt(targetBigInt);
50
51
 
51
- await retryUntil(
52
- async () => {
53
- const newL2BlockNumber: BlockNumber = await node.getBlockNumber();
54
- return newL2BlockNumber > currentL2BlockNumber;
55
- },
56
- 'new block after warping L2 time',
57
- 36,
58
- 1,
59
- );
52
+ let effectiveTimestamp = targetBigInt;
60
53
 
61
- // Restore original minTxsPerBlock
62
- sequencer.updateConfig({ minTxsPerBlock });
54
+ if (targetSlot <= currentSlot) {
55
+ // Target lands in the same (or earlier) slot — auto-adjust to the next slot's start.
56
+ const nextSlot = SlotNumber(currentSlot + 1);
57
+ const nextSlotTimestamp = await this.rollup.getTimestampForSlot(nextSlot);
58
+ this.logger.warn(
59
+ `warpL2TimeAtLeastTo: target timestamp ${targetBigInt} falls in current slot ${currentSlot}. ` +
60
+ `Auto-adjusting to start of slot ${nextSlot} at timestamp ${nextSlotTimestamp}.`,
61
+ );
62
+ effectiveTimestamp = nextSlotTimestamp;
63
+ }
64
+
65
+ await this.eth.warp(effectiveTimestamp, { resetBlockInterval: true });
66
+ await node.mineBlock();
63
67
  }
64
68
 
65
69
  /**
66
70
  * Warps the L1 timestamp forward by a specified duration and mines an L2 block that advances the L2 timestamp at
67
- * least by the duration. L2 timestamp is not advanced exactly by the duration because it is determined by the slot
68
- * number, which advances in fixed intervals.
69
- * This is useful for testing time-dependent contract behavior.
70
- * @param sequencerClient - The sequencer client to use to force an empty block to be mined.
71
- * @param node - The Aztec node used to query if a new block has been mined.
71
+ * least by the duration. If the duration is too short to cross an L2 slot boundary, the warp is automatically
72
+ * extended to the start of the next slot so that `mineBlock()` succeeds.
73
+ * @param node - The Aztec node used to force an empty block to be mined.
72
74
  * @param duration - The duration to advance time by (in seconds)
73
75
  */
74
- async warpL2TimeAtLeastBy(sequencerClient: SequencerClient, node: AztecNode, duration: bigint | number) {
75
- const currentTimestamp = await this.eth.timestamp();
76
+ async warpL2TimeAtLeastBy(node: AztecNodeDebug, duration: bigint | number) {
77
+ if (BigInt(duration) <= 0n) {
78
+ throw new Error(`warpL2TimeAtLeastBy: duration must be positive, got ${duration} seconds.`);
79
+ }
80
+
81
+ const currentTimestamp = await this.eth.lastBlockTimestamp();
76
82
  const targetTimestamp = BigInt(currentTimestamp) + BigInt(duration);
77
- await this.warpL2TimeAtLeastTo(sequencerClient, node, targetTimestamp);
83
+ await this.warpL2TimeAtLeastTo(node, targetTimestamp);
78
84
  }
79
85
  }
@@ -4,7 +4,7 @@ import { type EpochNumber, SlotNumber } from '@aztec/foundation/branded-types';
4
4
  import type { Logger } from '@aztec/foundation/log';
5
5
  import { EpochMonitor } from '@aztec/prover-node';
6
6
  import type { EthAddress, L2BlockSource } from '@aztec/stdlib/block';
7
- import { computeL2ToL1MembershipWitnessFromMessagesInEpoch } from '@aztec/stdlib/messaging';
7
+ import { computeEpochOutHash } from '@aztec/stdlib/messaging';
8
8
 
9
9
  export class EpochTestSettler {
10
10
  private rollupCheatCodes: RollupCheatCodes;
@@ -51,9 +51,8 @@ export class EpochTestSettler {
51
51
  messagesInEpoch[checkpointIndex].push(block.body.txEffects.map(txEffect => txEffect.l2ToL1Msgs));
52
52
  }
53
53
 
54
- const [firstMessage] = messagesInEpoch.flat(3);
55
- if (firstMessage) {
56
- const { root: outHash } = computeL2ToL1MembershipWitnessFromMessagesInEpoch(messagesInEpoch, firstMessage);
54
+ const outHash = computeEpochOutHash(messagesInEpoch);
55
+ if (!outHash.isZero()) {
57
56
  await this.rollupCheatCodes.insertOutbox(epoch, outHash.toBigInt());
58
57
  } else {
59
58
  this.log.info(`No L2 to L1 messages in epoch ${epoch}`);
@@ -2,3 +2,4 @@ export { AnvilTestWatcher } from './anvil_test_watcher.js';
2
2
  export { EthCheatCodes, RollupCheatCodes } from '@aztec/ethereum/test';
3
3
  export { CheatCodes } from './cheat_codes.js';
4
4
  export { EpochTestSettler } from './epoch_test_settler.js';
5
+ export { getTokenAllowedSetupFunctions } from './token_allowed_setup.js';
@@ -0,0 +1,19 @@
1
+ import { TokenContractArtifact } from '@aztec/noir-contracts.js/Token';
2
+ import { buildAllowedElement } from '@aztec/p2p/msg_validators';
3
+ import { getContractClassFromArtifact } from '@aztec/stdlib/contract';
4
+ import type { AllowedElement } from '@aztec/stdlib/interfaces/server';
5
+
6
+ /**
7
+ * Returns Token-specific allowlist entries needed for FPC-based fee payments.
8
+ * These are test-only: FPC-based fee payment with custom tokens won't work on mainnet alpha.
9
+ */
10
+ export async function getTokenAllowedSetupFunctions(): Promise<AllowedElement[]> {
11
+ const tokenClassId = (await getContractClassFromArtifact(TokenContractArtifact)).id;
12
+ const target = { classId: tokenClassId };
13
+ return Promise.all([
14
+ // Token: needed for private transfers via FPC (transfer_to_public enqueues this)
15
+ buildAllowedElement(TokenContractArtifact, target, '_increase_public_balance', { onlySelf: true }),
16
+ // Token: needed for public transfers via FPC (fee_entrypoint_public enqueues this)
17
+ buildAllowedElement(TokenContractArtifact, target, 'transfer_in_public'),
18
+ ]);
19
+ }
@@ -1,2 +0,0 @@
1
- export declare const getCliVersion: () => any;
2
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicmVsZWFzZV92ZXJzaW9uLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvY2xpL3JlbGVhc2VfdmVyc2lvbi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFLQSxlQUFPLE1BQU0sYUFBYSxXQWV6QixDQUFDIn0=
@@ -1 +0,0 @@
1
- {"version":3,"file":"release_version.d.ts","sourceRoot":"","sources":["../../src/cli/release_version.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,aAAa,WAezB,CAAC"}
@@ -1,14 +0,0 @@
1
- import { fileURLToPath } from '@aztec/foundation/url';
2
- import { readFileSync } from 'fs';
3
- import { dirname, resolve } from 'path';
4
- export const getCliVersion = ()=>{
5
- const packageJsonPath = resolve(dirname(fileURLToPath(import.meta.url)), '../../package.json');
6
- const cliVersion = JSON.parse(readFileSync(packageJsonPath).toString()).version;
7
- // If the version is 0.1.0, this is a placeholder version and we are in a docker container; query release please for the latest version
8
- if (cliVersion === '0.1.0') {
9
- const releasePleasePath = resolve(dirname(fileURLToPath(import.meta.url)), '../../../../.release-please-manifest.json');
10
- const releaseVersion = JSON.parse(readFileSync(releasePleasePath).toString())['.'];
11
- return releaseVersion;
12
- }
13
- return cliVersion;
14
- };
@@ -1,21 +0,0 @@
1
- import { fileURLToPath } from '@aztec/foundation/url';
2
-
3
- import { readFileSync } from 'fs';
4
- import { dirname, resolve } from 'path';
5
-
6
- export const getCliVersion = () => {
7
- const packageJsonPath = resolve(dirname(fileURLToPath(import.meta.url)), '../../package.json');
8
- const cliVersion: string = JSON.parse(readFileSync(packageJsonPath).toString()).version;
9
-
10
- // If the version is 0.1.0, this is a placeholder version and we are in a docker container; query release please for the latest version
11
- if (cliVersion === '0.1.0') {
12
- const releasePleasePath = resolve(
13
- dirname(fileURLToPath(import.meta.url)),
14
- '../../../../.release-please-manifest.json',
15
- );
16
- const releaseVersion = JSON.parse(readFileSync(releasePleasePath).toString())['.'];
17
- return releaseVersion;
18
- }
19
-
20
- return cliVersion;
21
- };