@aztec/aztec 0.0.1-commit.b2a5d0dd1 → 0.0.1-commit.b3d3157a

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 (92) hide show
  1. package/dest/bin/index.js +1 -1
  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 +10 -6
  5. package/dest/cli/aztec_start_options.d.ts +1 -1
  6. package/dest/cli/aztec_start_options.d.ts.map +1 -1
  7. package/dest/cli/aztec_start_options.js +1 -14
  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 +12 -1
  11. package/dest/cli/cmds/profile.d.ts +1 -1
  12. package/dest/cli/cmds/profile.d.ts.map +1 -1
  13. package/dest/cli/cmds/profile.js +1 -1
  14. package/dest/cli/cmds/profile_gates.d.ts +2 -2
  15. package/dest/cli/cmds/profile_gates.d.ts.map +1 -1
  16. package/dest/cli/cmds/profile_gates.js +21 -3
  17. package/dest/cli/cmds/standby.d.ts +2 -4
  18. package/dest/cli/cmds/standby.d.ts.map +1 -1
  19. package/dest/cli/cmds/standby.js +1 -1
  20. package/dest/cli/cmds/start_bot.d.ts +1 -1
  21. package/dest/cli/cmds/start_bot.d.ts.map +1 -1
  22. package/dest/cli/cmds/start_bot.js +3 -3
  23. package/dest/cli/cmds/start_node.d.ts +1 -1
  24. package/dest/cli/cmds/start_node.d.ts.map +1 -1
  25. package/dest/cli/cmds/start_node.js +3 -5
  26. package/dest/cli/cmds/start_prover_agent.js +2 -2
  27. package/dest/cli/cmds/start_prover_broker.d.ts +1 -1
  28. package/dest/cli/cmds/start_prover_broker.d.ts.map +1 -1
  29. package/dest/cli/cmds/start_prover_broker.js +11 -8
  30. package/dest/cli/cmds/start_txe.d.ts +2 -2
  31. package/dest/cli/cmds/start_txe.d.ts.map +1 -1
  32. package/dest/cli/cmds/start_txe.js +6 -5
  33. package/dest/cli/cmds/utils/warn_if_aztec_version_mismatch.d.ts +1 -1
  34. package/dest/cli/cmds/utils/warn_if_aztec_version_mismatch.d.ts.map +1 -1
  35. package/dest/cli/cmds/utils/warn_if_aztec_version_mismatch.js +2 -3
  36. package/dest/cli/util.js +7 -5
  37. package/dest/local-network/auth_registry.d.ts +5 -0
  38. package/dest/local-network/auth_registry.d.ts.map +1 -0
  39. package/dest/local-network/auth_registry.js +17 -0
  40. package/dest/local-network/banana_fpc.d.ts +3 -2
  41. package/dest/local-network/banana_fpc.d.ts.map +1 -1
  42. package/dest/local-network/banana_fpc.js +11 -7
  43. package/dest/local-network/local-network.d.ts +3 -25
  44. package/dest/local-network/local-network.d.ts.map +1 -1
  45. package/dest/local-network/local-network.js +33 -11
  46. package/dest/testing/anvil_test_watcher.d.ts +9 -1
  47. package/dest/testing/anvil_test_watcher.d.ts.map +1 -1
  48. package/dest/testing/anvil_test_watcher.js +28 -0
  49. package/dest/testing/cheat_codes.d.ts +10 -5
  50. package/dest/testing/cheat_codes.d.ts.map +1 -1
  51. package/dest/testing/cheat_codes.js +40 -6
  52. package/dest/testing/epoch_test_settler.d.ts +1 -1
  53. package/dest/testing/epoch_test_settler.d.ts.map +1 -1
  54. package/dest/testing/epoch_test_settler.js +6 -4
  55. package/package.json +34 -33
  56. package/scripts/add_crate.sh +11 -60
  57. package/scripts/aztec.sh +2 -2
  58. package/scripts/init.sh +5 -5
  59. package/scripts/new.sh +2 -2
  60. package/scripts/setup_workspace.sh +3 -2
  61. package/scripts/templates/blank/contract/Nargo.toml +6 -0
  62. package/scripts/templates/blank/contract/src/main.nr +10 -0
  63. package/scripts/templates/blank/test/Nargo.toml +7 -0
  64. package/scripts/templates/blank/test/src/lib.nr +11 -0
  65. package/scripts/templates/counter/contract/Nargo.toml +7 -0
  66. package/scripts/templates/counter/contract/src/main.nr +48 -0
  67. package/scripts/templates/counter/test/Nargo.toml +7 -0
  68. package/scripts/templates/counter/test/src/lib.nr +32 -0
  69. package/src/bin/index.ts +1 -1
  70. package/src/cli/aztec_start_action.ts +11 -6
  71. package/src/cli/aztec_start_options.ts +2 -20
  72. package/src/cli/cmds/compile.ts +15 -1
  73. package/src/cli/cmds/profile.ts +2 -1
  74. package/src/cli/cmds/profile_gates.ts +20 -4
  75. package/src/cli/cmds/standby.ts +2 -2
  76. package/src/cli/cmds/start_bot.ts +3 -5
  77. package/src/cli/cmds/start_node.ts +3 -5
  78. package/src/cli/cmds/start_prover_agent.ts +2 -2
  79. package/src/cli/cmds/start_prover_broker.ts +10 -11
  80. package/src/cli/cmds/start_txe.ts +7 -5
  81. package/src/cli/cmds/utils/warn_if_aztec_version_mismatch.ts +2 -3
  82. package/src/cli/util.ts +7 -7
  83. package/src/local-network/auth_registry.ts +19 -0
  84. package/src/local-network/banana_fpc.ts +12 -8
  85. package/src/local-network/local-network.ts +34 -8
  86. package/src/testing/anvil_test_watcher.ts +32 -0
  87. package/src/testing/cheat_codes.ts +54 -7
  88. package/src/testing/epoch_test_settler.ts +3 -4
  89. package/dest/cli/cmds/start_archiver.d.ts +0 -9
  90. package/dest/cli/cmds/start_archiver.d.ts.map +0 -1
  91. package/dest/cli/cmds/start_archiver.js +0 -50
  92. package/src/cli/cmds/start_archiver.ts +0 -56
@@ -24,38 +24,37 @@ export async function startProverBroker(
24
24
  services: NamespacedApiHandlers,
25
25
  userLog: LogFn,
26
26
  ): Promise<{ broker: ProvingJobBroker; config: ProverBrokerConfig }> {
27
- if (options.node || options.sequencer || options.pxe || options.p2pBootstrap || options.txe) {
28
- userLog(`Starting a prover broker with --node, --sequencer, --pxe, --p2p-bootstrap, or --txe is not supported.`);
27
+ if (options.node || options.sequencer || options.p2pBootstrap || options.txe) {
28
+ userLog(`Starting a prover broker with --node, --sequencer, --p2p-bootstrap, or --txe is not supported.`);
29
29
  process.exit(1);
30
30
  }
31
31
 
32
- const config: ProverBrokerConfig = {
32
+ const baseConfig: ProverBrokerConfig = {
33
33
  ...getProverNodeBrokerConfigFromEnv(), // get default config from env
34
34
  ...extractRelevantOptions<ProverBrokerConfig>(options, proverBrokerConfigMappings, 'proverBroker'), // override with command line options
35
35
  };
36
36
 
37
- if (!config.l1Contracts.registryAddress || config.l1Contracts.registryAddress.isZero()) {
37
+ if (!baseConfig.registryAddress || baseConfig.registryAddress.isZero()) {
38
38
  throw new Error('L1 registry address is required to start Aztec Node without --deploy-aztec-contracts option');
39
39
  }
40
40
 
41
41
  const genesisConfig = getGenesisStateConfigEnvVars();
42
42
  const { genesisArchiveRoot } = await computeExpectedGenesisRoot(genesisConfig, userLog);
43
43
  await waitForCompatibleRollup(
44
- config,
44
+ baseConfig,
45
45
  { genesisArchiveRoot, vkTreeRoot: getVKTreeRoot(), protocolContractsHash },
46
46
  options.port,
47
47
  userLog,
48
48
  );
49
49
 
50
50
  const { addresses, config: rollupConfig } = await getL1Config(
51
- config.l1Contracts.registryAddress,
52
- config.l1RpcUrls,
53
- config.l1ChainId,
54
- config.rollupVersion,
51
+ baseConfig.registryAddress,
52
+ baseConfig.l1RpcUrls,
53
+ baseConfig.l1ChainId,
54
+ baseConfig.rollupVersion,
55
55
  );
56
56
 
57
- config.l1Contracts = addresses;
58
- config.rollupVersion = rollupConfig.rollupVersion;
57
+ const config: ProverBrokerConfig = { ...baseConfig, ...addresses, rollupVersion: rollupConfig.rollupVersion };
59
58
 
60
59
  const client = await initTelemetryClient(getTelemetryClientConfig());
61
60
  const broker = await createAndStartProvingBroker(config, client);
@@ -1,15 +1,17 @@
1
1
  import { startHttpRpcServer } from '@aztec/foundation/json-rpc/server';
2
2
  import type { Logger } from '@aztec/foundation/log';
3
- import { createTXERpcServer } from '@aztec/txe';
3
+ import { createTXERpcServer } from '@aztec/txe/server';
4
4
 
5
- export async function startTXE(options: any, debugLogger: Logger) {
5
+ export async function startTXE(options: any, signalHandlers: Array<() => Promise<void>>, debugLogger: Logger) {
6
6
  debugLogger.info(`Setting up TXE...`);
7
7
 
8
- const txeServer = createTXERpcServer(debugLogger);
9
- const { port } = await startHttpRpcServer(txeServer, {
8
+ const txeServer = await createTXERpcServer(debugLogger);
9
+ const httpServer = await startHttpRpcServer(txeServer, {
10
10
  port: options.port,
11
11
  timeoutMs: 1e3 * 60 * 5,
12
12
  });
13
13
 
14
- debugLogger.info(`TXE listening on port ${port}`);
14
+ signalHandlers.push(() => new Promise<void>(resolve => httpServer.close(() => resolve())));
15
+
16
+ debugLogger.info(`TXE listening on port ${httpServer.port}`);
15
17
  }
@@ -1,5 +1,5 @@
1
1
  import type { LogFn } from '@aztec/foundation/log';
2
- import { getPackageVersion } from '@aztec/stdlib/update-checker';
2
+ import { DEV_VERSION, getPackageVersion } from '@aztec/stdlib/update-checker';
3
3
 
4
4
  import TOML from '@iarna/toml';
5
5
  import { readFile } from 'fs/promises';
@@ -28,8 +28,7 @@ function isAztecNrGitUrl(gitUrl: string): boolean {
28
28
  /** Warns if any aztec-nr git dependency in a crate's Nargo.toml has a tag that doesn't match the CLI version. */
29
29
  export async function warnIfAztecVersionMismatch(log: LogFn, cliVersion?: string): Promise<void> {
30
30
  const version = cliVersion ?? getPackageVersion();
31
- if (!version) {
32
- log(`WARNING: aztec CLI version not found. Skipping dependency compatibility check.`);
31
+ if (version === DEV_VERSION) {
33
32
  return;
34
33
  }
35
34
 
package/src/cli/util.ts CHANGED
@@ -82,17 +82,17 @@ export async function createAccountLogs(accountManagers: AccountManager[], walle
82
82
  accountLogStrings.push(` Address: ${completeAddress.address.toString()}\n`);
83
83
  accountLogStrings.push(` Partial Address: ${completeAddress.partialAddress.toString()}\n`);
84
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`);
85
87
  accountLogStrings.push(
86
- ` Master nullifier public key: ${completeAddress.publicKeys.masterNullifierPublicKey.toString()}\n`,
88
+ ` Master outgoing viewing public key hash: ${completeAddress.publicKeys.ovpkMHash.toString()}\n\n`,
87
89
  );
90
+ accountLogStrings.push(` Master tagging public key hash: ${completeAddress.publicKeys.tpkMHash.toString()}\n\n`);
88
91
  accountLogStrings.push(
89
- ` Master incoming viewing public key: ${completeAddress.publicKeys.masterIncomingViewingPublicKey.toString()}\n\n`,
92
+ ` Master message-signing public key hash: ${completeAddress.publicKeys.mspkMHash.toString()}\n\n`,
90
93
  );
91
94
  accountLogStrings.push(
92
- ` Master outgoing viewing public key: ${completeAddress.publicKeys.masterOutgoingViewingPublicKey.toString()}\n\n`,
93
- );
94
- accountLogStrings.push(
95
- ` Master tagging public key: ${completeAddress.publicKeys.masterTaggingPublicKey.toString()}\n\n`,
95
+ ` Master fallback public key hash: ${completeAddress.publicKeys.fbpkMHash.toString()}\n\n`,
96
96
  );
97
97
  }
98
98
  }
@@ -311,7 +311,7 @@ export async function setupVersionChecker(
311
311
  const checks: Array<VersionCheck> = [];
312
312
  checks.push({
313
313
  name: 'node',
314
- currentVersion: getPackageVersion() ?? 'unknown',
314
+ currentVersion: getPackageVersion(),
315
315
  getLatestVersion: async () => {
316
316
  const cfg = await getNetworkConfig(network, cacheDir);
317
317
  return cfg?.nodeVersion;
@@ -0,0 +1,19 @@
1
+ import type { WaitOpts } from '@aztec/aztec.js/contracts';
2
+ import { publishContractClass, publishInstance } from '@aztec/aztec.js/deployment';
3
+ import type { Wallet } from '@aztec/aztec.js/wallet';
4
+ import { AuthRegistryArtifact, getStandardAuthRegistry } from '@aztec/standard-contracts/auth-registry';
5
+ import type { AztecAddress } from '@aztec/stdlib/aztec-address';
6
+
7
+ export async function publishStandardAuthRegistry(
8
+ wallet: Wallet,
9
+ from: AztecAddress,
10
+ waitOpts?: WaitOpts,
11
+ ): Promise<void> {
12
+ const { instance, contractClass } = await getStandardAuthRegistry();
13
+ if (!(await wallet.getContractClassMetadata(contractClass.id)).isContractClassPubliclyRegistered) {
14
+ await (await publishContractClass(wallet, AuthRegistryArtifact)).send({ from, wait: waitOpts });
15
+ }
16
+ if (!(await wallet.getContractMetadata(instance.address)).isContractPublished) {
17
+ await publishInstance(wallet, instance).send({ from, wait: waitOpts });
18
+ }
19
+ }
@@ -1,4 +1,5 @@
1
1
  import { type InitialAccountData, getInitialTestAccountsData } from '@aztec/accounts/testing';
2
+ import type { WaitOpts } from '@aztec/aztec.js/contracts';
2
3
  import type { Wallet } from '@aztec/aztec.js/wallet';
3
4
  import { Fr } from '@aztec/foundation/curves/bn254';
4
5
  import type { LogFn } from '@aztec/foundation/log';
@@ -45,19 +46,22 @@ export async function getBananaFPCAddress(initialAccounts: InitialAccountData[])
45
46
  return (await getBananaFPCInstance(initialAccounts)).address;
46
47
  }
47
48
 
48
- export async function setupBananaFPC(initialAccounts: InitialAccountData[], wallet: Wallet, log: LogFn) {
49
+ export async function setupBananaFPC(
50
+ initialAccounts: InitialAccountData[],
51
+ wallet: Wallet,
52
+ log: LogFn,
53
+ waitOpts?: WaitOpts,
54
+ ) {
49
55
  const bananaCoinAddress = await getBananaCoinAddress(initialAccounts);
50
56
  const admin = getBananaAdmin(initialAccounts);
51
57
  const [{ contract: bananaCoin }, { contract: fpc }] = await Promise.all([
52
- TokenContract.deploy(wallet, admin, bananaCoinArgs.name, bananaCoinArgs.symbol, bananaCoinArgs.decimal).send({
53
- from: admin,
54
- contractAddressSalt: BANANA_COIN_SALT,
58
+ TokenContract.deploy(wallet, admin, bananaCoinArgs.name, bananaCoinArgs.symbol, bananaCoinArgs.decimal, {
59
+ salt: BANANA_COIN_SALT,
55
60
  universalDeploy: true,
56
- }),
57
- FPCContract.deploy(wallet, bananaCoinAddress, admin).send({
61
+ }).send({ from: admin, wait: waitOpts }),
62
+ FPCContract.deploy(wallet, bananaCoinAddress, admin, { salt: BANANA_FPC_SALT, universalDeploy: true }).send({
58
63
  from: admin,
59
- contractAddressSalt: BANANA_FPC_SALT,
60
- universalDeploy: true,
64
+ wait: waitOpts,
61
65
  }),
62
66
  ]);
63
67
 
@@ -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';
@@ -21,6 +22,7 @@ import { protocolContractsHash } from '@aztec/protocol-contracts';
21
22
  import { SequencerState } from '@aztec/sequencer-client';
22
23
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
23
24
  import type { ProvingJobBroker } from '@aztec/stdlib/interfaces/server';
25
+ import { TxStatus } from '@aztec/stdlib/tx';
24
26
  import type { GenesisData } from '@aztec/stdlib/world-state';
25
27
  import {
26
28
  type TelemetryClient,
@@ -40,11 +42,18 @@ import { DefaultMnemonic } from '../mnemonic.js';
40
42
  import { AnvilTestWatcher } from '../testing/anvil_test_watcher.js';
41
43
  import { EpochTestSettler } from '../testing/epoch_test_settler.js';
42
44
  import { getTokenAllowedSetupFunctions } from '../testing/token_allowed_setup.js';
45
+ import { publishStandardAuthRegistry } from './auth_registry.js';
43
46
  import { getBananaFPCAddress, setupBananaFPC } from './banana_fpc.js';
44
47
  import { getSponsoredFPCAddress } from './sponsored_fpc.js';
45
48
 
46
49
  const logger = createLogger('local-network');
47
50
 
51
+ // The embedded wallet defaults to waiting for PROPOSED, which returns as soon as a tx lands in a
52
+ // proposed L2 block. That is flaky for the serial sandbox setup below: a proposed block can be
53
+ // pruned before its checkpoint is published, dropping a tx we already moved on from ("Tx dropped by
54
+ // P2P node"). Wait for the checkpoint so each setup tx is durably included before the next is sent.
55
+ const setupWaitOpts = { waitForStatus: TxStatus.CHECKPOINTED };
56
+
48
57
  const localAnvil = foundry;
49
58
 
50
59
  /**
@@ -59,7 +68,7 @@ export async function deployContractsToL1(
59
68
  genesisArchiveRoot?: Fr;
60
69
  feeJuicePortalInitialBalance?: bigint;
61
70
  } = {},
62
- ) {
71
+ ): Promise<L1ContractAddresses> {
63
72
  await waitForPublicClient(aztecNodeConfig);
64
73
 
65
74
  const l1Contracts = await deployAztecL1Contracts(aztecNodeConfig.l1RpcUrls[0], privateKey, foundry.id, {
@@ -74,10 +83,10 @@ export async function deployContractsToL1(
74
83
  realVerifier: false,
75
84
  });
76
85
 
77
- aztecNodeConfig.l1Contracts = l1Contracts.l1ContractAddresses;
86
+ Object.assign(aztecNodeConfig, l1Contracts.l1ContractAddresses);
78
87
  aztecNodeConfig.rollupVersion = l1Contracts.rollupVersion;
79
88
 
80
- return aztecNodeConfig.l1Contracts;
89
+ return l1Contracts.l1ContractAddresses;
81
90
  }
82
91
 
83
92
  /** Local network settings. */
@@ -205,6 +214,21 @@ export async function createLocalNetwork(config: Partial<LocalNetworkConfig> = {
205
214
  SequencerState.SYNCHRONIZING,
206
215
  ]);
207
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
+ }
208
232
  }
209
233
 
210
234
  let epochTestSettler: EpochTestSettler | undefined;
@@ -226,11 +250,14 @@ export async function createLocalNetwork(config: Partial<LocalNetworkConfig> = {
226
250
  });
227
251
 
228
252
  userLog('Setting up funded test accounts...');
229
- const accountManagers = await deployFundedSchnorrAccounts(wallet, initialAccounts);
253
+ const accountManagers = await deployFundedSchnorrAccounts(wallet, initialAccounts, setupWaitOpts);
230
254
  const accLogs = await createAccountLogs(accountManagers, wallet);
231
255
  userLog(accLogs.join(''));
232
256
 
233
- await setupBananaFPC(initialAccounts, wallet, userLog);
257
+ userLog('Publishing standard AuthRegistry contract...');
258
+ await publishStandardAuthRegistry(wallet, initialAccounts[0].address, setupWaitOpts);
259
+
260
+ await setupBananaFPC(initialAccounts, wallet, userLog, setupWaitOpts);
234
261
 
235
262
  userLog(`SponsoredFPC: ${await getSponsoredFPCAddress()}`);
236
263
 
@@ -262,11 +289,10 @@ export async function createAztecNode(
262
289
  options: { genesis?: GenesisData } = {},
263
290
  ) {
264
291
  // TODO(#12272): will clean this up. This is criminal.
265
- const { l1Contracts, ...rest } = getConfigEnvVars();
292
+ // Not sure why this was ever done. Will be fixed in A-989, A-991, A-990.
266
293
  const aztecNodeConfig: AztecNodeConfig = {
267
- ...rest,
294
+ ...getConfigEnvVars(),
268
295
  ...config,
269
- l1Contracts: { ...l1Contracts, ...config.l1Contracts },
270
296
  };
271
297
  const node = await AztecNodeService.createAndSync(
272
298
  aztecNodeConfig,
@@ -44,6 +44,12 @@ export class AnvilTestWatcher {
44
44
  // Tracks when we first observed the current unfilled slot with pending txs (real wall time).
45
45
  private unfilledSlotFirstSeen?: { slot: number; realTime: number };
46
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
+
47
53
  constructor(
48
54
  private cheatcodes: EthCheatCodes,
49
55
  rollupAddress: EthAddress,
@@ -86,6 +92,18 @@ export class AnvilTestWatcher {
86
92
  this.isSequencerBuilding = fn;
87
93
  }
88
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
+
89
107
  async start() {
90
108
  if (this.filledRunningPromise) {
91
109
  throw new Error('Watcher already watching for filled slot');
@@ -177,6 +195,20 @@ export class AnvilTestWatcher {
177
195
  return;
178
196
  }
179
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
+
180
212
  // If there are pending txs and the sequencer missed them, warp quickly (after a 2s real-time debounce) so the
181
213
  // sequencer can retry in the next slot. Without this, we'd have to wait a full real-time slot duration (~36s) for
182
214
  // the dateProvider to catch up to the next slot timestamp. We skip the warp if the sequencer is actively building
@@ -2,6 +2,7 @@ import { EthCheatCodes, RollupCheatCodes } from '@aztec/ethereum/test';
2
2
  import { SlotNumber } from '@aztec/foundation/branded-types';
3
3
  import { createLogger } from '@aztec/foundation/log';
4
4
  import type { DateProvider } from '@aztec/foundation/timer';
5
+ import type { AutomineSequencer } from '@aztec/sequencer-client';
5
6
  import type { AztecNode, AztecNodeDebug } from '@aztec/stdlib/interfaces/client';
6
7
 
7
8
  /**
@@ -18,15 +19,22 @@ export class CheatCodes {
18
19
  public eth: EthCheatCodes,
19
20
  /** Cheat codes for the Aztec Rollup contract on L1. */
20
21
  public rollup: RollupCheatCodes,
22
+ /** When wired, redirects time-warps through the AutomineSequencer queue (test-only). */
23
+ private automine?: AutomineSequencer,
21
24
  ) {}
22
25
 
23
- static async create(rpcUrls: string[], node: AztecNode, dateProvider: DateProvider): Promise<CheatCodes> {
26
+ static async create(
27
+ rpcUrls: string[],
28
+ node: AztecNode,
29
+ dateProvider: DateProvider,
30
+ automine?: AutomineSequencer,
31
+ ): Promise<CheatCodes> {
24
32
  const ethCheatCodes = new EthCheatCodes(rpcUrls, dateProvider);
25
33
  const rollupCheatCodes = new RollupCheatCodes(
26
34
  ethCheatCodes,
27
35
  await node.getNodeInfo().then(n => n.l1ContractAddresses),
28
36
  );
29
- return new CheatCodes(ethCheatCodes, rollupCheatCodes);
37
+ return new CheatCodes(ethCheatCodes, rollupCheatCodes, automine);
30
38
  }
31
39
 
32
40
  /**
@@ -36,7 +44,7 @@ export class CheatCodes {
36
44
  * @param node - The Aztec node used to force an empty block to be mined.
37
45
  * @param targetTimestamp - The target timestamp to warp to (in seconds)
38
46
  */
39
- async warpL2TimeAtLeastTo(node: AztecNodeDebug, targetTimestamp: bigint | number) {
47
+ async warpL2TimeAtLeastTo(node: AztecNode & AztecNodeDebug, targetTimestamp: bigint | number) {
40
48
  const targetBigInt = BigInt(targetTimestamp);
41
49
  const currentTimestamp = BigInt(await this.eth.lastBlockTimestamp());
42
50
 
@@ -46,10 +54,20 @@ export class CheatCodes {
46
54
  );
47
55
  }
48
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
+
49
66
  const currentSlot = await this.rollup.getSlot();
50
67
  const targetSlot = await this.rollup.getSlotAt(targetBigInt);
51
68
 
52
69
  let effectiveTimestamp = targetBigInt;
70
+ let effectiveTargetSlot = targetSlot;
53
71
 
54
72
  if (targetSlot <= currentSlot) {
55
73
  // Target lands in the same (or earlier) slot — auto-adjust to the next slot's start.
@@ -60,10 +78,32 @@ export class CheatCodes {
60
78
  `Auto-adjusting to start of slot ${nextSlot} at timestamp ${nextSlotTimestamp}.`,
61
79
  );
62
80
  effectiveTimestamp = nextSlotTimestamp;
81
+ effectiveTargetSlot = nextSlot;
63
82
  }
64
83
 
65
84
  await this.eth.warp(effectiveTimestamp, { resetBlockInterval: true });
66
- await node.mineBlock();
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
+ );
67
107
  }
68
108
 
69
109
  /**
@@ -73,13 +113,20 @@ export class CheatCodes {
73
113
  * @param node - The Aztec node used to force an empty block to be mined.
74
114
  * @param duration - The duration to advance time by (in seconds)
75
115
  */
76
- async warpL2TimeAtLeastBy(node: AztecNodeDebug, duration: bigint | number) {
116
+ async warpL2TimeAtLeastBy(node: AztecNode & AztecNodeDebug, duration: bigint | number) {
77
117
  if (BigInt(duration) <= 0n) {
78
118
  throw new Error(`warpL2TimeAtLeastBy: duration must be positive, got ${duration} seconds.`);
79
119
  }
80
120
 
81
- const currentTimestamp = await this.eth.lastBlockTimestamp();
82
- const targetTimestamp = BigInt(currentTimestamp) + BigInt(duration);
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);
83
130
  await this.warpL2TimeAtLeastTo(node, targetTimestamp);
84
131
  }
85
132
  }
@@ -31,8 +31,7 @@ export class EpochTestSettler {
31
31
  }
32
32
 
33
33
  async handleEpochReadyToProve(epoch: EpochNumber): Promise<boolean> {
34
- const checkpointedBlocks = await this.l2BlockSource.getCheckpointedBlocksForEpoch(epoch);
35
- const blocks = checkpointedBlocks.map(b => b.block);
34
+ const blocks = await this.l2BlockSource.getBlocks({ epoch, onlyCheckpointed: true });
36
35
  this.log.info(
37
36
  `Settling epoch ${epoch} with blocks ${blocks[0]?.header.getBlockNumber()} to ${blocks.at(-1)?.header.getBlockNumber()}`,
38
37
  { blocks: blocks.map(b => b.toBlockInfo()) },
@@ -53,12 +52,12 @@ export class EpochTestSettler {
53
52
 
54
53
  const outHash = computeEpochOutHash(messagesInEpoch);
55
54
  if (!outHash.isZero()) {
56
- await this.rollupCheatCodes.insertOutbox(epoch, outHash.toBigInt());
55
+ await this.rollupCheatCodes.insertOutbox(epoch, messagesInEpoch.length, outHash.toBigInt());
57
56
  } else {
58
57
  this.log.info(`No L2 to L1 messages in epoch ${epoch}`);
59
58
  }
60
59
 
61
- const lastCheckpoint = checkpointedBlocks.at(-1)?.checkpointNumber;
60
+ const lastCheckpoint = blocks.at(-1)?.checkpointNumber;
62
61
  if (lastCheckpoint !== undefined) {
63
62
  await this.rollupCheatCodes.markAsProven(lastCheckpoint);
64
63
  } else {
@@ -1,9 +0,0 @@
1
- import { type ArchiverConfig } from '@aztec/archiver';
2
- import type { NamespacedApiHandlers } from '@aztec/foundation/json-rpc/server';
3
- import { type DataStoreConfig } from '@aztec/stdlib/kv-store';
4
- export type { ArchiverConfig, DataStoreConfig };
5
- /** Starts a standalone archiver. */
6
- export declare function startArchiver(options: any, signalHandlers: (() => Promise<void>)[], services: NamespacedApiHandlers): Promise<{
7
- config: ArchiverConfig & DataStoreConfig;
8
- }>;
9
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3RhcnRfYXJjaGl2ZXIuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9jbGkvY21kcy9zdGFydF9hcmNoaXZlci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsS0FBSyxjQUFjLEVBQW9FLE1BQU0saUJBQWlCLENBQUM7QUFJeEgsT0FBTyxLQUFLLEVBQUUscUJBQXFCLEVBQUUsTUFBTSxtQ0FBbUMsQ0FBQztBQUUvRSxPQUFPLEVBQUUsS0FBSyxlQUFlLEVBQXNCLE1BQU0sd0JBQXdCLENBQUM7QUFLbEYsWUFBWSxFQUFFLGNBQWMsRUFBRSxlQUFlLEVBQUUsQ0FBQztBQUVoRCxvQ0FBb0M7QUFDcEMsd0JBQXNCLGFBQWEsQ0FDakMsT0FBTyxFQUFFLEdBQUcsRUFDWixjQUFjLEVBQUUsQ0FBQyxNQUFNLE9BQU8sQ0FBQyxJQUFJLENBQUMsQ0FBQyxFQUFFLEVBQ3ZDLFFBQVEsRUFBRSxxQkFBcUIsR0FDOUIsT0FBTyxDQUFDO0lBQUUsTUFBTSxFQUFFLGNBQWMsR0FBRyxlQUFlLENBQUE7Q0FBRSxDQUFDLENBcUN2RCJ9
@@ -1 +0,0 @@
1
- {"version":3,"file":"start_archiver.d.ts","sourceRoot":"","sources":["../../../src/cli/cmds/start_archiver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAoE,MAAM,iBAAiB,CAAC;AAIxH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAE/E,OAAO,EAAE,KAAK,eAAe,EAAsB,MAAM,wBAAwB,CAAC;AAKlF,YAAY,EAAE,cAAc,EAAE,eAAe,EAAE,CAAC;AAEhD,oCAAoC;AACpC,wBAAsB,aAAa,CACjC,OAAO,EAAE,GAAG,EACZ,cAAc,EAAE,CAAC,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,EACvC,QAAQ,EAAE,qBAAqB,GAC9B,OAAO,CAAC;IAAE,MAAM,EAAE,cAAc,GAAG,eAAe,CAAA;CAAE,CAAC,CAqCvD"}
@@ -1,50 +0,0 @@
1
- import { archiverConfigMappings, createArchiver, getArchiverConfigFromEnv } from '@aztec/archiver';
2
- import { createLogger } from '@aztec/aztec.js/log';
3
- import { blobClientConfigMapping, createBlobClient } from '@aztec/blob-client/client';
4
- import { getL1Config } from '@aztec/cli/config';
5
- import { ArchiverApiSchema } from '@aztec/stdlib/interfaces/server';
6
- import { dataConfigMappings } from '@aztec/stdlib/kv-store';
7
- import { getConfigEnvVars as getTelemetryClientConfig, initTelemetryClient } from '@aztec/telemetry-client';
8
- import { extractRelevantOptions } from '../util.js';
9
- /** Starts a standalone archiver. */ export async function startArchiver(options, signalHandlers, services) {
10
- const envConfig = getArchiverConfigFromEnv();
11
- const cliOptions = extractRelevantOptions(options, {
12
- // dataConfigMappings must come first: its l1Contracts only maps rollupAddress,
13
- // while archiverConfigMappings (spread later) maps all L1 contract addresses.
14
- ...dataConfigMappings,
15
- ...archiverConfigMappings,
16
- ...blobClientConfigMapping
17
- }, 'archiver');
18
- let archiverConfig = {
19
- ...envConfig,
20
- ...cliOptions
21
- };
22
- archiverConfig.dataStoreMapSizeKb = archiverConfig.archiverStoreMapSizeKb ?? archiverConfig.dataStoreMapSizeKb;
23
- if (!archiverConfig.l1Contracts.registryAddress || archiverConfig.l1Contracts.registryAddress.isZero()) {
24
- throw new Error('L1 registry address is required to start an Archiver');
25
- }
26
- const { addresses, config: l1Config } = await getL1Config(archiverConfig.l1Contracts.registryAddress, archiverConfig.l1RpcUrls, archiverConfig.l1ChainId);
27
- archiverConfig.l1Contracts = addresses;
28
- archiverConfig = {
29
- ...archiverConfig,
30
- ...l1Config
31
- };
32
- const telemetry = await initTelemetryClient(getTelemetryClientConfig());
33
- const blobClient = createBlobClient(archiverConfig, {
34
- logger: createLogger('archiver:blob-client:client')
35
- });
36
- const archiver = await createArchiver(archiverConfig, {
37
- telemetry,
38
- blobClient
39
- }, {
40
- blockUntilSync: true
41
- });
42
- services.archiver = [
43
- archiver,
44
- ArchiverApiSchema
45
- ];
46
- signalHandlers.push(archiver.stop);
47
- return {
48
- config: archiverConfig
49
- };
50
- }
@@ -1,56 +0,0 @@
1
- import { type ArchiverConfig, archiverConfigMappings, createArchiver, getArchiverConfigFromEnv } from '@aztec/archiver';
2
- import { createLogger } from '@aztec/aztec.js/log';
3
- import { type BlobClientConfig, blobClientConfigMapping, createBlobClient } from '@aztec/blob-client/client';
4
- import { getL1Config } from '@aztec/cli/config';
5
- import type { NamespacedApiHandlers } from '@aztec/foundation/json-rpc/server';
6
- import { ArchiverApiSchema } from '@aztec/stdlib/interfaces/server';
7
- import { type DataStoreConfig, dataConfigMappings } from '@aztec/stdlib/kv-store';
8
- import { getConfigEnvVars as getTelemetryClientConfig, initTelemetryClient } from '@aztec/telemetry-client';
9
-
10
- import { extractRelevantOptions } from '../util.js';
11
-
12
- export type { ArchiverConfig, DataStoreConfig };
13
-
14
- /** Starts a standalone archiver. */
15
- export async function startArchiver(
16
- options: any,
17
- signalHandlers: (() => Promise<void>)[],
18
- services: NamespacedApiHandlers,
19
- ): Promise<{ config: ArchiverConfig & DataStoreConfig }> {
20
- const envConfig = getArchiverConfigFromEnv();
21
- const cliOptions = extractRelevantOptions<ArchiverConfig & DataStoreConfig & BlobClientConfig>(
22
- options,
23
- {
24
- // dataConfigMappings must come first: its l1Contracts only maps rollupAddress,
25
- // while archiverConfigMappings (spread later) maps all L1 contract addresses.
26
- ...dataConfigMappings,
27
- ...archiverConfigMappings,
28
- ...blobClientConfigMapping,
29
- },
30
- 'archiver',
31
- );
32
-
33
- let archiverConfig = { ...envConfig, ...cliOptions };
34
- archiverConfig.dataStoreMapSizeKb = archiverConfig.archiverStoreMapSizeKb ?? archiverConfig.dataStoreMapSizeKb;
35
-
36
- if (!archiverConfig.l1Contracts.registryAddress || archiverConfig.l1Contracts.registryAddress.isZero()) {
37
- throw new Error('L1 registry address is required to start an Archiver');
38
- }
39
-
40
- const { addresses, config: l1Config } = await getL1Config(
41
- archiverConfig.l1Contracts.registryAddress,
42
- archiverConfig.l1RpcUrls,
43
- archiverConfig.l1ChainId,
44
- );
45
-
46
- archiverConfig.l1Contracts = addresses;
47
- archiverConfig = { ...archiverConfig, ...l1Config };
48
-
49
- const telemetry = await initTelemetryClient(getTelemetryClientConfig());
50
- const blobClient = createBlobClient(archiverConfig, { logger: createLogger('archiver:blob-client:client') });
51
- const archiver = await createArchiver(archiverConfig, { telemetry, blobClient }, { blockUntilSync: true });
52
- services.archiver = [archiver, ArchiverApiSchema];
53
- signalHandlers.push(archiver.stop);
54
-
55
- return { config: archiverConfig };
56
- }