@aztec/aztec 0.0.1-commit.2f68f620 → 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 (63) hide show
  1. package/dest/bin/index.js +2 -0
  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 +6 -27
  5. package/dest/cli/aztec_start_options.js +1 -1
  6. package/dest/cli/cmds/compile.d.ts +1 -1
  7. package/dest/cli/cmds/compile.d.ts.map +1 -1
  8. package/dest/cli/cmds/compile.js +25 -17
  9. package/dest/cli/cmds/prover.d.ts +4 -0
  10. package/dest/cli/cmds/prover.d.ts.map +1 -0
  11. package/dest/cli/cmds/prover.js +24 -0
  12. package/dest/cli/cmds/standby.d.ts +28 -2
  13. package/dest/cli/cmds/standby.d.ts.map +1 -1
  14. package/dest/cli/cmds/standby.js +45 -2
  15. package/dest/cli/cmds/start_bot.d.ts +1 -1
  16. package/dest/cli/cmds/start_bot.d.ts.map +1 -1
  17. package/dest/cli/cmds/start_bot.js +5 -1
  18. package/dest/cli/cmds/start_node.d.ts +1 -1
  19. package/dest/cli/cmds/start_node.d.ts.map +1 -1
  20. package/dest/cli/cmds/start_node.js +13 -22
  21. package/dest/cli/cmds/utils/artifacts.d.ts +6 -1
  22. package/dest/cli/cmds/utils/artifacts.d.ts.map +1 -1
  23. package/dest/cli/util.d.ts +10 -5
  24. package/dest/cli/util.d.ts.map +1 -1
  25. package/dest/cli/util.js +20 -49
  26. package/dest/examples/token.js +3 -3
  27. package/dest/local-network/local-network.d.ts +4 -5
  28. package/dest/local-network/local-network.d.ts.map +1 -1
  29. package/dest/local-network/local-network.js +32 -75
  30. package/dest/testing/cheat_codes.d.ts +16 -23
  31. package/dest/testing/cheat_codes.d.ts.map +1 -1
  32. package/dest/testing/cheat_codes.js +20 -82
  33. package/dest/testing/epoch_test_settler.d.ts +2 -2
  34. package/dest/testing/epoch_test_settler.d.ts.map +1 -1
  35. package/dest/testing/epoch_test_settler.js +5 -26
  36. package/dest/testing/index.d.ts +1 -2
  37. package/dest/testing/index.d.ts.map +1 -1
  38. package/dest/testing/index.js +0 -1
  39. package/dest/testing/token_allowed_setup.d.ts +9 -4
  40. package/dest/testing/token_allowed_setup.d.ts.map +1 -1
  41. package/dest/testing/token_allowed_setup.js +12 -8
  42. package/package.json +34 -34
  43. package/scripts/templates/counter/contract/src/main.nr +4 -4
  44. package/src/bin/index.ts +2 -0
  45. package/src/cli/aztec_start_action.ts +3 -14
  46. package/src/cli/aztec_start_options.ts +1 -1
  47. package/src/cli/cmds/compile.ts +29 -16
  48. package/src/cli/cmds/prover.ts +42 -0
  49. package/src/cli/cmds/standby.ts +55 -3
  50. package/src/cli/cmds/start_bot.ts +6 -1
  51. package/src/cli/cmds/start_node.ts +16 -22
  52. package/src/cli/cmds/utils/artifacts.ts +5 -0
  53. package/src/cli/util.ts +21 -62
  54. package/src/examples/token.ts +11 -3
  55. package/src/local-network/local-network.ts +34 -87
  56. package/src/testing/cheat_codes.ts +19 -103
  57. package/src/testing/epoch_test_settler.ts +8 -30
  58. package/src/testing/index.ts +0 -1
  59. package/src/testing/token_allowed_setup.ts +15 -8
  60. package/dest/testing/anvil_test_watcher.d.ts +0 -54
  61. package/dest/testing/anvil_test_watcher.d.ts.map +0 -1
  62. package/dest/testing/anvil_test_watcher.js +0 -235
  63. package/src/testing/anvil_test_watcher.ts +0 -273
package/src/cli/util.ts CHANGED
@@ -1,18 +1,13 @@
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';
5
- import type { ViemClient } from '@aztec/ethereum/types';
6
- import type { ConfigMappingsType, NetworkNames } from '@aztec/foundation/config';
3
+ import type { ConfigMappingsType } from '@aztec/foundation/config';
7
4
  import { jsonStringify } from '@aztec/foundation/json-rpc';
8
- import { type LogFn, createLogger } from '@aztec/foundation/log';
5
+ import type { LogFn } from '@aztec/foundation/log';
9
6
  import type { ProverConfig } from '@aztec/stdlib/interfaces/server';
10
- import { type VersionCheck, getPackageVersion } from '@aztec/stdlib/update-checker';
11
7
  import type { EmbeddedWallet } from '@aztec/wallets/embedded';
12
8
 
13
9
  import chalk from 'chalk';
14
10
  import type { Command } from 'commander';
15
- import type { Hex } from 'viem';
16
11
 
17
12
  import { type AztecStartOption, aztecStartOptions } from './aztec_start_options.js';
18
13
 
@@ -51,6 +46,24 @@ export function isShuttingDown(): boolean {
51
46
  return shutdownPromise !== undefined;
52
47
  }
53
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
+
54
67
  export const installSignalHandlers = (logFn: LogFn, cb?: Array<() => Promise<void>>) => {
55
68
  const signals = [
56
69
  ['SIGINT', ExitCode.SIGINT],
@@ -81,7 +94,7 @@ export async function createAccountLogs(accountManagers: AccountManager[], walle
81
94
  if (registeredAccounts.find(a => a.item.equals(completeAddress.address))) {
82
95
  accountLogStrings.push(` Address: ${completeAddress.address.toString()}\n`);
83
96
  accountLogStrings.push(` Partial Address: ${completeAddress.partialAddress.toString()}\n`);
84
- accountLogStrings.push(` Secret Key: ${account.getSecretKey().toString()}\n`);
97
+ accountLogStrings.push(` Secret Key: ${accountManager.getSecretKey().toString()}\n`);
85
98
  accountLogStrings.push(` Master nullifier public key hash: ${completeAddress.publicKeys.npkMHash.toString()}\n`);
86
99
  accountLogStrings.push(` Master incoming viewing public key: ${completeAddress.publicKeys.ivpkM.toString()}\n\n`);
87
100
  accountLogStrings.push(
@@ -291,60 +304,6 @@ export async function preloadCrsDataForServerSideProving(
291
304
  }
292
305
  }
293
306
 
294
- export async function setupVersionChecker(
295
- network: NetworkNames,
296
- followsCanonicalRollup: boolean,
297
- publicClient: ViemClient,
298
- signalHandlers: Array<() => Promise<void>>,
299
- cacheDir?: string,
300
- ): Promise<void> {
301
- const networkConfig = await getNetworkConfig(network, cacheDir);
302
- if (!networkConfig) {
303
- return;
304
- }
305
-
306
- const { VersionChecker } = await import('@aztec/stdlib/update-checker');
307
-
308
- const logger = createLogger('version_check');
309
- const registry = new RegistryContract(publicClient, networkConfig.registryAddress as Hex);
310
-
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
- },
319
- });
320
-
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
- });
333
- }
334
- }
335
-
336
- const checker = new VersionChecker(checks, 600_000, logger);
337
- checker.on('newVersion', ({ name, latestVersion, currentVersion }) => {
338
- if (isShuttingDown()) {
339
- return;
340
- }
341
-
342
- logger.warn(`New ${name} version available`, { latestVersion, currentVersion });
343
- });
344
- checker.start();
345
- signalHandlers.push(() => checker.stop());
346
- }
347
-
348
307
  export function stringifyConfig(config: object): string {
349
308
  return Object.entries(config)
350
309
  .map(([key, value]) => `${key}=${jsonStringify(value)}`)
@@ -21,10 +21,18 @@ async function main() {
21
21
 
22
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;
@@ -1,25 +1,22 @@
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
13
  import type { L1ContractAddresses } from '@aztec/ethereum/l1-contract-addresses';
15
- import { EthCheatCodes } from '@aztec/ethereum/test';
16
14
  import { SecretValue } from '@aztec/foundation/config';
17
15
  import { EthAddress } from '@aztec/foundation/eth-address';
18
16
  import type { LogFn } from '@aztec/foundation/log';
19
17
  import { DateProvider, TestDateProvider } from '@aztec/foundation/timer';
20
18
  import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
21
19
  import { protocolContractsHash } from '@aztec/protocol-contracts';
22
- import { SequencerState } from '@aztec/sequencer-client';
23
20
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
24
21
  import type { ProvingJobBroker } from '@aztec/stdlib/interfaces/server';
25
22
  import { TxStatus } from '@aztec/stdlib/tx';
@@ -30,17 +27,15 @@ import {
30
27
  initTelemetryClient,
31
28
  } from '@aztec/telemetry-client';
32
29
  import { EmbeddedWallet } from '@aztec/wallets/embedded';
33
- import { deployFundedSchnorrAccounts } from '@aztec/wallets/testing';
30
+ import { createFundedInitializerlessAccounts } from '@aztec/wallets/testing';
34
31
  import { getGenesisValues } from '@aztec/world-state/testing';
35
32
 
36
- import { type Hex, createPublicClient, fallback, http as httpViemTransport } from 'viem';
33
+ import type { Hex } from 'viem';
37
34
  import { mnemonicToAccount, privateKeyToAddress } from 'viem/accounts';
38
35
  import { foundry } from 'viem/chains';
39
36
 
40
37
  import { createAccountLogs } from '../cli/util.js';
41
38
  import { DefaultMnemonic } from '../mnemonic.js';
42
- import { AnvilTestWatcher } from '../testing/anvil_test_watcher.js';
43
- import { EpochTestSettler } from '../testing/epoch_test_settler.js';
44
39
  import { getTokenAllowedSetupFunctions } from '../testing/token_allowed_setup.js';
45
40
  import { publishStandardAuthRegistry } from './auth_registry.js';
46
41
  import { getBananaFPCAddress, setupBananaFPC } from './banana_fpc.js';
@@ -54,8 +49,6 @@ const logger = createLogger('local-network');
54
49
  // P2P node"). Wait for the checkpoint so each setup tx is durably included before the next is sent.
55
50
  const setupWaitOpts = { waitForStatus: TxStatus.CHECKPOINTED };
56
51
 
57
- const localAnvil = foundry;
58
-
59
52
  /**
60
53
  * Function to deploy our L1 contracts to the local network L1
61
54
  * @param aztecNodeConfig - The Aztec Node Config
@@ -116,10 +109,33 @@ export async function createLocalNetwork(config: Partial<LocalNetworkConfig> = {
116
109
  // in the setup allowlist so FPC-based fee payments work out of the box.
117
110
  const tokenAllowList = await getTokenAllowedSetupFunctions();
118
111
 
112
+ const envConfig = getConfigEnvVars();
119
113
  const aztecNodeConfig: AztecNodeConfig = {
120
- ...getConfigEnvVars(),
114
+ ...envConfig,
121
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,
122
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,
123
139
  };
124
140
  const hdAccount = mnemonicToAccount(config.l1Mnemonic || DefaultMnemonic);
125
141
  if (
@@ -143,7 +159,7 @@ export async function createLocalNetwork(config: Partial<LocalNetworkConfig> = {
143
159
  const initialAccounts = await (async () => {
144
160
  if (config.testAccounts === true || config.testAccounts === undefined) {
145
161
  if (aztecNodeConfig.p2pEnabled) {
146
- userLog(`Not setting up test accounts as we are connecting to a network`);
162
+ userLog(`Not setting up test accounts when p2p is enabled`);
147
163
  } else {
148
164
  userLog(`Setting up test accounts`);
149
165
  return await getInitialTestAccountsData();
@@ -154,7 +170,7 @@ export async function createLocalNetwork(config: Partial<LocalNetworkConfig> = {
154
170
 
155
171
  const bananaFPC = await getBananaFPCAddress(initialAccounts);
156
172
  const sponsoredFPC = await getSponsoredFPCAddress();
157
- const prefundAddresses = (aztecNodeConfig.prefundAddresses ?? []).map(a => AztecAddress.fromString(a));
173
+ const prefundAddresses = (aztecNodeConfig.prefundAddresses ?? []).map(a => AztecAddress.fromStringUnsafe(a));
158
174
  const fundedAddresses = [
159
175
  ...initialAccounts.map(a => a.address),
160
176
  ...(initialAccounts.length ? [bananaFPC, sponsoredFPC] : []),
@@ -164,36 +180,11 @@ export async function createLocalNetwork(config: Partial<LocalNetworkConfig> = {
164
180
 
165
181
  const dateProvider = new TestDateProvider();
166
182
 
167
- let cheatcodes: EthCheatCodes | undefined;
168
- let rollupAddress: EthAddress | undefined;
169
- let watcher: AnvilTestWatcher | undefined;
170
183
  if (!aztecNodeConfig.p2pEnabled) {
171
- ({ rollupAddress } = await deployContractsToL1(
172
- aztecNodeConfig,
173
- aztecNodeConfig.validatorPrivateKeys.getValue()[0],
174
- {
175
- genesisArchiveRoot,
176
- feeJuicePortalInitialBalance: fundingNeeded,
177
- },
178
- ));
179
-
180
- const chain =
181
- aztecNodeConfig.l1RpcUrls.length > 0
182
- ? createEthereumChain([l1RpcUrl], aztecNodeConfig.l1ChainId)
183
- : { chainInfo: localAnvil };
184
-
185
- const publicClient = createPublicClient({
186
- chain: chain.chainInfo,
187
- transport: fallback([httpViemTransport(l1RpcUrl)]) as any,
184
+ await deployContractsToL1(aztecNodeConfig, aztecNodeConfig.validatorPrivateKeys.getValue()[0], {
185
+ genesisArchiveRoot,
186
+ feeJuicePortalInitialBalance: fundingNeeded,
188
187
  });
189
-
190
- cheatcodes = new EthCheatCodes([l1RpcUrl], dateProvider);
191
-
192
- watcher = new AnvilTestWatcher(cheatcodes, rollupAddress, publicClient, dateProvider);
193
- watcher.setisLocalNetwork(true);
194
- watcher.setIsMarkingAsProven(false); // Do not mark as proven in the watcher. It's marked in the epochTestSettler after the out hash is set.
195
-
196
- await watcher.start();
197
188
  }
198
189
 
199
190
  const telemetry = await initTelemetryClient(getTelemetryClientConfig());
@@ -201,48 +192,6 @@ export async function createLocalNetwork(config: Partial<LocalNetworkConfig> = {
201
192
  const blobClient = createBlobClient();
202
193
  const node = await createAztecNode(aztecNodeConfig, { telemetry, blobClient, dateProvider }, { genesis });
203
194
 
204
- // Now that the node is up, let the watcher check for pending txs so it can skip unfilled slots faster when
205
- // transactions are waiting in the mempool. Also let it check if the sequencer is actively building, to avoid
206
- // warping time out from under an in-progress block.
207
- watcher?.setGetPendingTxCount(() => node.getPendingTxCount());
208
- const sequencer = node.getSequencer()?.getSequencer();
209
- if (sequencer) {
210
- const idleStates: Set<string> = new Set([
211
- SequencerState.STOPPED,
212
- SequencerState.STOPPING,
213
- SequencerState.IDLE,
214
- SequencerState.SYNCHRONIZING,
215
- ]);
216
- watcher?.setIsSequencerBuilding(() => !idleStates.has(sequencer.getState()));
217
- // Under proposer pipelining the L1 publish for slot N happens during wall-clock slot N,
218
- // but the proposer for slot N has already built the checkpoint during slot N-1 and is
219
- // waiting for L1 to advance. We need to fast-forward L1 to wake that wait — and the wait
220
- // we have to break first is `waitForValidParentCheckpointOnL1`, which blocks the
221
- // checkpoint_proposal_job's background submission task until the archiver has synced past
222
- // the build slot. That wait happens *before* `PUBLISHING_CHECKPOINT` is set, so a hook on
223
- // that state transition would be circular (L1 has to advance before the state we'd use to
224
- // advance L1 fires). The earliest pre-wait signal is `block-proposed`, which the sequencer
225
- // emits once each block is built. In sandbox single-block-per-slot mode this is
226
- // effectively "checkpoint built", and the watcher warp is harmless if a subsequent
227
- // assembly/validation/parent-wait step aborts: L1 just sits one slot ahead, which the
228
- // cascade absorbs.
229
- if (watcher) {
230
- sequencer.on('block-proposed', ({ slot }) => watcher!.setProposedTargetSlot(Number(slot)));
231
- }
232
- }
233
-
234
- let epochTestSettler: EpochTestSettler | undefined;
235
- if (!aztecNodeConfig.p2pEnabled) {
236
- epochTestSettler = new EpochTestSettler(
237
- cheatcodes!,
238
- rollupAddress!,
239
- node.getBlockSource(),
240
- logger.createChild('epoch-settler'),
241
- { pollingIntervalMs: 200 },
242
- );
243
- await epochTestSettler.start();
244
- }
245
-
246
195
  if (initialAccounts.length) {
247
196
  const wallet = await EmbeddedWallet.create(node, {
248
197
  pxeConfig: { proverEnabled: aztecNodeConfig.realProofs },
@@ -250,7 +199,7 @@ export async function createLocalNetwork(config: Partial<LocalNetworkConfig> = {
250
199
  });
251
200
 
252
201
  userLog('Setting up funded test accounts...');
253
- const accountManagers = await deployFundedSchnorrAccounts(wallet, initialAccounts, setupWaitOpts);
202
+ const accountManagers = await createFundedInitializerlessAccounts(wallet, initialAccounts);
254
203
  const accLogs = await createAccountLogs(accountManagers, wallet);
255
204
  userLog(accLogs.join(''));
256
205
 
@@ -267,8 +216,6 @@ export async function createLocalNetwork(config: Partial<LocalNetworkConfig> = {
267
216
 
268
217
  const stop = async () => {
269
218
  await node.stop();
270
- await watcher?.stop();
271
- await epochTestSettler?.stop();
272
219
  };
273
220
 
274
221
  return { node, stop };
@@ -294,7 +241,7 @@ export async function createAztecNode(
294
241
  ...getConfigEnvVars(),
295
242
  ...config,
296
243
  };
297
- const node = await AztecNodeService.createAndSync(
244
+ const node = await createAztecNodeService(
298
245
  aztecNodeConfig,
299
246
  { ...deps, proverNodeDeps: { broker: deps.proverBroker } },
300
247
  options,
@@ -1,132 +1,48 @@
1
1
  import { EthCheatCodes, RollupCheatCodes } from '@aztec/ethereum/test';
2
- import { SlotNumber } from '@aztec/foundation/branded-types';
3
- import { createLogger } from '@aztec/foundation/log';
4
2
  import type { DateProvider } from '@aztec/foundation/timer';
5
- import type { AutomineSequencer } from '@aztec/sequencer-client';
6
3
  import type { AztecNode, AztecNodeDebug } from '@aztec/stdlib/interfaces/client';
7
4
 
8
5
  /**
9
- * A class that provides utility functions for interacting with the chain.
10
- * @deprecated There used to be 3 kinds of cheat codes: eth, rollup and aztec. We have nuked the Aztec ones because
11
- * they became unused (we now have better testing tools). If you are introducing a new functionality to the cheat
12
- * codes, please consider whether it makes sense to just introduce new utils in your tests instead.
6
+ * Wrapper for Aztec Debug API.
7
+ * @deprecated use the AztecNode debug API directly.
13
8
  */
14
9
  export class CheatCodes {
15
- private logger = createLogger('aztecjs:cheat_codes');
16
-
17
10
  constructor(
18
11
  /** Cheat codes for L1.*/
19
12
  public eth: EthCheatCodes,
20
13
  /** Cheat codes for the Aztec Rollup contract on L1. */
21
14
  public rollup: RollupCheatCodes,
22
- /** When wired, redirects time-warps through the AutomineSequencer queue (test-only). */
23
- private automine?: AutomineSequencer,
24
15
  ) {}
25
16
 
26
- static async create(
27
- rpcUrls: string[],
28
- node: AztecNode,
29
- dateProvider: DateProvider,
30
- automine?: AutomineSequencer,
31
- ): Promise<CheatCodes> {
17
+ static async create(rpcUrls: string[], node: AztecNode, dateProvider: DateProvider): Promise<CheatCodes> {
32
18
  const ethCheatCodes = new EthCheatCodes(rpcUrls, dateProvider);
33
19
  const rollupCheatCodes = new RollupCheatCodes(
34
20
  ethCheatCodes,
35
21
  await node.getNodeInfo().then(n => n.l1ContractAddresses),
36
22
  );
37
- return new CheatCodes(ethCheatCodes, rollupCheatCodes, automine);
23
+ return new CheatCodes(ethCheatCodes, rollupCheatCodes);
38
24
  }
39
25
 
40
26
  /**
41
- * Warps the L1 timestamp to a target timestamp and mines an L2 block that advances the L2 timestamp to at least
42
- * the target timestamp. If the target timestamp falls within the current L2 slot (which already has a block),
43
- * the timestamp is automatically adjusted forward to the start of the next slot so that `mineBlock()` succeeds.
44
- * @param node - The Aztec node used to force an empty block to be mined.
45
- * @param targetTimestamp - The target timestamp to warp to (in seconds)
27
+ * Warps the L1 timestamp to at least `targetTimestamp` and mines an L2 block advancing the L2 timestamp to at least
28
+ * the target. Forwards to the node's debug API, which serializes the warp through the automine sequencer queue.
29
+ * @param node - The Aztec node whose debug API performs the warp. Must run an automine sequencer.
30
+ * @param targetTimestamp - The target timestamp to warp to (in seconds).
31
+ * @deprecated Call `node.warpL2TimeAtLeastTo(targetTimestamp)` on the node debug API directly.
46
32
  */
47
- async warpL2TimeAtLeastTo(node: AztecNode & AztecNodeDebug, targetTimestamp: bigint | number) {
48
- const targetBigInt = BigInt(targetTimestamp);
49
- const currentTimestamp = BigInt(await this.eth.lastBlockTimestamp());
50
-
51
- if (targetBigInt <= currentTimestamp) {
52
- throw new Error(
53
- `warpL2TimeAtLeastTo: target timestamp ${targetBigInt} is not in the future (current L1 timestamp is ${currentTimestamp}).`,
54
- );
55
- }
56
-
57
- // AutomineSequencer owns time control through its serial queue — delegate to keep warps atomic
58
- // with respect to any in-flight build, and avoid the mineBlock-loop hack below.
59
- // `warpTo` internally builds an empty L2 checkpoint, which auto-mines exactly one L1 block at
60
- // the target slot boundary, so no separate `node.mineBlock()` is needed here.
61
- if (this.automine) {
62
- await this.automine.warpTo(Number(targetBigInt));
63
- return;
64
- }
65
-
66
- const currentSlot = await this.rollup.getSlot();
67
- const targetSlot = await this.rollup.getSlotAt(targetBigInt);
68
-
69
- let effectiveTimestamp = targetBigInt;
70
- let effectiveTargetSlot = targetSlot;
71
-
72
- if (targetSlot <= currentSlot) {
73
- // Target lands in the same (or earlier) slot — auto-adjust to the next slot's start.
74
- const nextSlot = SlotNumber(currentSlot + 1);
75
- const nextSlotTimestamp = await this.rollup.getTimestampForSlot(nextSlot);
76
- this.logger.warn(
77
- `warpL2TimeAtLeastTo: target timestamp ${targetBigInt} falls in current slot ${currentSlot}. ` +
78
- `Auto-adjusting to start of slot ${nextSlot} at timestamp ${nextSlotTimestamp}.`,
79
- );
80
- effectiveTimestamp = nextSlotTimestamp;
81
- effectiveTargetSlot = nextSlot;
82
- }
83
-
84
- await this.eth.warp(effectiveTimestamp, { resetBlockInterval: true });
85
-
86
- // The sequencer's polling loop may have a `work()` cycle in flight that captured pre-warp slot/timestamp values
87
- // just before our warp landed. That cycle would mine an L2 block at the stale slot — the L1 sync prunes such a
88
- // block from the canonical chain, but it lingers in local world state and the PXE will use it as the anchor for
89
- // subsequent txs, leading to `expiration_timestamp` values that are already in the past relative to L1. Mine
90
- // until we observe an L2 block at (or past) the post-warp slot, ensuring the next tx anchors to a fresh block.
91
- const maxAttempts = 5;
92
- for (let attempt = 1; attempt <= maxAttempts; attempt++) {
93
- await node.mineBlock();
94
- const blockData = await node.getBlockData('latest');
95
- const blockSlot = blockData?.header.globalVariables.slotNumber;
96
- if (blockSlot !== undefined && BigInt(blockSlot) >= BigInt(effectiveTargetSlot)) {
97
- return;
98
- }
99
- this.logger.warn(
100
- `warpL2TimeAtLeastTo: mined L2 block at slot ${blockSlot}, expected at least ${effectiveTargetSlot}. ` +
101
- `Retrying mineBlock (attempt ${attempt}/${maxAttempts}).`,
102
- );
103
- }
104
- throw new Error(
105
- `warpL2TimeAtLeastTo: failed to mine an L2 block at or past slot ${effectiveTargetSlot} after ${maxAttempts} attempts.`,
106
- );
33
+ warpL2TimeAtLeastTo(node: AztecNode & AztecNodeDebug, targetTimestamp: bigint | number): Promise<void> {
34
+ return node.warpL2TimeAtLeastTo(Number(targetTimestamp));
107
35
  }
108
36
 
109
37
  /**
110
- * Warps the L1 timestamp forward by a specified duration and mines an L2 block that advances the L2 timestamp at
111
- * least by the duration. If the duration is too short to cross an L2 slot boundary, the warp is automatically
112
- * extended to the start of the next slot so that `mineBlock()` succeeds.
113
- * @param node - The Aztec node used to force an empty block to be mined.
114
- * @param duration - The duration to advance time by (in seconds)
38
+ * Warps the L1 timestamp forward by at least `duration` seconds and mines an L2 block advancing the L2 timestamp at
39
+ * least by the duration. Forwards to the node's debug API, which serializes the warp through the automine sequencer
40
+ * queue.
41
+ * @param node - The Aztec node whose debug API performs the warp. Must run an automine sequencer.
42
+ * @param duration - The duration to advance time by (in seconds).
43
+ * @deprecated Call `node.warpL2TimeAtLeastBy(duration)` on the node debug API directly.
115
44
  */
116
- async warpL2TimeAtLeastBy(node: AztecNode & AztecNodeDebug, duration: bigint | number) {
117
- if (BigInt(duration) <= 0n) {
118
- throw new Error(`warpL2TimeAtLeastBy: duration must be positive, got ${duration} seconds.`);
119
- }
120
-
121
- // Advance relative to whichever clock leads. A live sequencer mines L2 blocks at slot boundaries that can run
122
- // ahead of anvil's L1 timestamp, so basing the target on L1 alone would advance the L2 timestamp by less than
123
- // `duration`. Anchoring to the latest L2 block timestamp when it leads guarantees the post-warp L2 block is at
124
- // least `duration` ahead of the current one.
125
- const currentL1Timestamp = BigInt(await this.eth.lastBlockTimestamp());
126
- const latestBlockData = await node.getBlockData('latest');
127
- const latestL2Timestamp = latestBlockData ? BigInt(latestBlockData.header.globalVariables.timestamp) : 0n;
128
- const baseTimestamp = latestL2Timestamp > currentL1Timestamp ? latestL2Timestamp : currentL1Timestamp;
129
- const targetTimestamp = baseTimestamp + BigInt(duration);
130
- await this.warpL2TimeAtLeastTo(node, targetTimestamp);
45
+ warpL2TimeAtLeastBy(node: AztecNode & AztecNodeDebug, duration: bigint | number): Promise<void> {
46
+ return node.warpL2TimeAtLeastBy(Number(duration));
131
47
  }
132
48
  }
@@ -1,10 +1,9 @@
1
- import { Fr } from '@aztec/aztec.js/fields';
2
1
  import { type EthCheatCodes, RollupCheatCodes } from '@aztec/ethereum/test';
3
- import { type EpochNumber, SlotNumber } from '@aztec/foundation/branded-types';
2
+ import type { EpochNumber } from '@aztec/foundation/branded-types';
4
3
  import type { Logger } from '@aztec/foundation/log';
4
+ import { settleEpochOutbox } from '@aztec/prover-client/test';
5
5
  import { EpochMonitor } from '@aztec/prover-node';
6
6
  import type { EthAddress, L2BlockSource } from '@aztec/stdlib/block';
7
- import { computeEpochOutHash } from '@aztec/stdlib/messaging';
8
7
 
9
8
  export class EpochTestSettler {
10
9
  private rollupCheatCodes: RollupCheatCodes;
@@ -31,33 +30,12 @@ export class EpochTestSettler {
31
30
  }
32
31
 
33
32
  async handleEpochReadyToProve(epoch: EpochNumber): Promise<boolean> {
34
- const blocks = await this.l2BlockSource.getBlocks({ epoch, onlyCheckpointed: true });
35
- this.log.info(
36
- `Settling epoch ${epoch} with blocks ${blocks[0]?.header.getBlockNumber()} to ${blocks.at(-1)?.header.getBlockNumber()}`,
37
- { blocks: blocks.map(b => b.toBlockInfo()) },
38
- );
39
- const messagesInEpoch: Fr[][][][] = [];
40
- let previousSlotNumber = SlotNumber.ZERO;
41
- let checkpointIndex = -1;
42
-
43
- for (const block of blocks) {
44
- const slotNumber = block.header.globalVariables.slotNumber;
45
- if (slotNumber !== previousSlotNumber) {
46
- checkpointIndex++;
47
- messagesInEpoch[checkpointIndex] = [];
48
- previousSlotNumber = slotNumber;
49
- }
50
- messagesInEpoch[checkpointIndex].push(block.body.txEffects.map(txEffect => txEffect.l2ToL1Msgs));
51
- }
52
-
53
- const outHash = computeEpochOutHash(messagesInEpoch);
54
- if (!outHash.isZero()) {
55
- await this.rollupCheatCodes.insertOutbox(epoch, messagesInEpoch.length, outHash.toBigInt());
56
- } else {
57
- this.log.info(`No L2 to L1 messages in epoch ${epoch}`);
58
- }
59
-
60
- const lastCheckpoint = blocks.at(-1)?.checkpointNumber;
33
+ const lastCheckpoint = await settleEpochOutbox({
34
+ rollupCheatCodes: this.rollupCheatCodes,
35
+ l2BlockSource: this.l2BlockSource,
36
+ epoch,
37
+ log: this.log,
38
+ });
61
39
  if (lastCheckpoint !== undefined) {
62
40
  await this.rollupCheatCodes.markAsProven(lastCheckpoint);
63
41
  } else {
@@ -1,4 +1,3 @@
1
- export { AnvilTestWatcher, type AnvilTestWatcherOpts } from './anvil_test_watcher.js';
2
1
  export { EthCheatCodes, RollupCheatCodes } from '@aztec/ethereum/test';
3
2
  export { CheatCodes } from './cheat_codes.js';
4
3
  export { EpochTestSettler } from './epoch_test_settler.js';
@@ -1,19 +1,26 @@
1
1
  import { TokenContractArtifact } from '@aztec/noir-contracts.js/Token';
2
2
  import { buildAllowedElement } from '@aztec/p2p/msg_validators';
3
+ import type { ContractArtifact } from '@aztec/stdlib/abi';
3
4
  import { getContractClassFromArtifact } from '@aztec/stdlib/contract';
4
5
  import type { AllowedElement } from '@aztec/stdlib/interfaces/server';
5
6
 
6
7
  /**
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.
8
+ * Returns the allowlist entries needed for FPC-based fee payments, keyed by the contract class of
9
+ * the `artifact` actually deployed as the fee token (defaults to canonical Token). The setup-phase
10
+ * validator matches these entries by class id, so a test deploying the codegen'd TestToken as its
11
+ * fee vehicle must pass `TestTokenContract.artifact` here -- otherwise the FPC fee calls are matched
12
+ * against the wrong class and rejected. Test-only: FPC fee payment with custom tokens won't work on
13
+ * mainnet alpha.
9
14
  */
10
- export async function getTokenAllowedSetupFunctions(): Promise<AllowedElement[]> {
11
- const tokenClassId = (await getContractClassFromArtifact(TokenContractArtifact)).id;
15
+ export async function getTokenAllowedSetupFunctions(
16
+ artifact: ContractArtifact = TokenContractArtifact,
17
+ ): Promise<AllowedElement[]> {
18
+ const tokenClassId = (await getContractClassFromArtifact(artifact)).id;
12
19
  const target = { classId: tokenClassId };
13
20
  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'),
21
+ // needed for private transfers via FPC (transfer_to_public enqueues this)
22
+ buildAllowedElement(artifact, target, '_increase_public_balance', { onlySelf: true }),
23
+ // needed for public transfers via FPC (fee_entrypoint_public enqueues this)
24
+ buildAllowedElement(artifact, target, 'transfer_in_public'),
18
25
  ]);
19
26
  }