@aztec/end-to-end 0.0.1-commit.f2ce05ee → 0.0.1-commit.f81dbcf

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 (145) hide show
  1. package/dest/bench/client_flows/client_flows_benchmark.d.ts +2 -2
  2. package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -1
  3. package/dest/bench/client_flows/client_flows_benchmark.js +18 -11
  4. package/dest/bench/utils.d.ts +1 -1
  5. package/dest/bench/utils.d.ts.map +1 -1
  6. package/dest/bench/utils.js +6 -3
  7. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +4 -2
  8. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts.map +1 -1
  9. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.js +22 -12
  10. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +2 -2
  11. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts.map +1 -1
  12. package/dest/e2e_deploy_contract/deploy_test.d.ts +2 -2
  13. package/dest/e2e_deploy_contract/deploy_test.d.ts.map +1 -1
  14. package/dest/e2e_epochs/epochs_test.d.ts +9 -7
  15. package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
  16. package/dest/e2e_epochs/epochs_test.js +58 -33
  17. package/dest/e2e_fees/fees_test.d.ts +2 -2
  18. package/dest/e2e_fees/fees_test.d.ts.map +1 -1
  19. package/dest/e2e_fees/fees_test.js +18 -11
  20. package/dest/e2e_nested_contract/nested_contract_test.d.ts +1 -1
  21. package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +1 -1
  22. package/dest/e2e_nested_contract/nested_contract_test.js +4 -6
  23. package/dest/e2e_p2p/p2p_network.d.ts +2 -2
  24. package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
  25. package/dest/e2e_p2p/p2p_network.js +18 -5
  26. package/dest/e2e_p2p/reqresp/utils.d.ts +3 -3
  27. package/dest/e2e_p2p/reqresp/utils.d.ts.map +1 -1
  28. package/dest/e2e_p2p/reqresp/utils.js +32 -8
  29. package/dest/e2e_p2p/shared.d.ts +2 -2
  30. package/dest/e2e_p2p/shared.d.ts.map +1 -1
  31. package/dest/e2e_p2p/shared.js +3 -2
  32. package/dest/e2e_token_contract/token_contract_test.d.ts +4 -2
  33. package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -1
  34. package/dest/e2e_token_contract/token_contract_test.js +19 -9
  35. package/dest/fixtures/authwit_proxy.d.ts +15 -0
  36. package/dest/fixtures/authwit_proxy.d.ts.map +1 -0
  37. package/dest/fixtures/authwit_proxy.js +30 -0
  38. package/dest/fixtures/e2e_prover_test.d.ts +4 -4
  39. package/dest/fixtures/e2e_prover_test.d.ts.map +1 -1
  40. package/dest/fixtures/e2e_prover_test.js +33 -40
  41. package/dest/fixtures/fixtures.d.ts +5 -1
  42. package/dest/fixtures/fixtures.d.ts.map +1 -1
  43. package/dest/fixtures/fixtures.js +6 -0
  44. package/dest/fixtures/ha_setup.d.ts +1 -1
  45. package/dest/fixtures/ha_setup.d.ts.map +1 -1
  46. package/dest/fixtures/ha_setup.js +3 -1
  47. package/dest/fixtures/setup.d.ts +44 -24
  48. package/dest/fixtures/setup.d.ts.map +1 -1
  49. package/dest/fixtures/setup.js +64 -153
  50. package/dest/fixtures/setup_p2p_test.d.ts +6 -3
  51. package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
  52. package/dest/fixtures/setup_p2p_test.js +12 -9
  53. package/dest/fixtures/token_utils.d.ts +1 -1
  54. package/dest/fixtures/token_utils.d.ts.map +1 -1
  55. package/dest/fixtures/token_utils.js +2 -2
  56. package/dest/shared/cross_chain_test_harness.d.ts +1 -1
  57. package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
  58. package/dest/shared/cross_chain_test_harness.js +13 -13
  59. package/dest/shared/gas_portal_test_harness.js +2 -2
  60. package/dest/shared/index.d.ts +2 -1
  61. package/dest/shared/index.d.ts.map +1 -1
  62. package/dest/shared/index.js +1 -0
  63. package/dest/shared/mock_state_view.d.ts +86 -0
  64. package/dest/shared/mock_state_view.d.ts.map +1 -0
  65. package/dest/shared/mock_state_view.js +186 -0
  66. package/dest/shared/submit-transactions.d.ts +2 -2
  67. package/dest/shared/submit-transactions.d.ts.map +1 -1
  68. package/dest/shared/submit-transactions.js +1 -1
  69. package/dest/shared/uniswap_l1_l2.d.ts +1 -1
  70. package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
  71. package/dest/shared/uniswap_l1_l2.js +15 -18
  72. package/dest/simulators/lending_simulator.d.ts +1 -1
  73. package/dest/simulators/lending_simulator.d.ts.map +1 -1
  74. package/dest/simulators/lending_simulator.js +2 -2
  75. package/dest/simulators/token_simulator.d.ts +1 -1
  76. package/dest/simulators/token_simulator.d.ts.map +1 -1
  77. package/dest/simulators/token_simulator.js +3 -24
  78. package/dest/spartan/setup_test_wallets.d.ts +12 -3
  79. package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
  80. package/dest/spartan/setup_test_wallets.js +54 -11
  81. package/dest/spartan/utils/bot.d.ts +3 -2
  82. package/dest/spartan/utils/bot.d.ts.map +1 -1
  83. package/dest/spartan/utils/bot.js +2 -1
  84. package/dest/spartan/utils/index.d.ts +3 -2
  85. package/dest/spartan/utils/index.d.ts.map +1 -1
  86. package/dest/spartan/utils/index.js +3 -1
  87. package/dest/spartan/utils/k8s.d.ts +3 -1
  88. package/dest/spartan/utils/k8s.d.ts.map +1 -1
  89. package/dest/spartan/utils/k8s.js +6 -0
  90. package/dest/test-wallet/test_wallet.d.ts +83 -0
  91. package/dest/test-wallet/test_wallet.d.ts.map +1 -0
  92. package/dest/test-wallet/test_wallet.js +214 -0
  93. package/dest/test-wallet/utils.d.ts +41 -0
  94. package/dest/test-wallet/utils.d.ts.map +1 -0
  95. package/dest/test-wallet/utils.js +71 -0
  96. package/dest/test-wallet/wallet_worker_script.d.ts +2 -0
  97. package/dest/test-wallet/wallet_worker_script.d.ts.map +1 -0
  98. package/dest/test-wallet/wallet_worker_script.js +48 -0
  99. package/dest/test-wallet/worker_wallet.d.ts +52 -0
  100. package/dest/test-wallet/worker_wallet.d.ts.map +1 -0
  101. package/dest/test-wallet/worker_wallet.js +151 -0
  102. package/dest/test-wallet/worker_wallet_schema.d.ts +274 -0
  103. package/dest/test-wallet/worker_wallet_schema.d.ts.map +1 -0
  104. package/dest/test-wallet/worker_wallet_schema.js +10 -0
  105. package/package.json +40 -39
  106. package/src/bench/client_flows/client_flows_benchmark.ts +41 -38
  107. package/src/bench/utils.ts +8 -3
  108. package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +28 -15
  109. package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +4 -4
  110. package/src/e2e_deploy_contract/deploy_test.ts +3 -3
  111. package/src/e2e_epochs/epochs_test.ts +73 -63
  112. package/src/e2e_fees/bridging_race.notest.ts +1 -1
  113. package/src/e2e_fees/fees_test.ts +20 -28
  114. package/src/e2e_nested_contract/nested_contract_test.ts +7 -5
  115. package/src/e2e_p2p/inactivity_slash_test.ts +4 -4
  116. package/src/e2e_p2p/p2p_network.ts +32 -9
  117. package/src/e2e_p2p/reqresp/utils.ts +40 -12
  118. package/src/e2e_p2p/shared.ts +3 -2
  119. package/src/e2e_token_contract/token_contract_test.ts +26 -9
  120. package/src/fixtures/authwit_proxy.ts +50 -0
  121. package/src/fixtures/dumps/epoch_proof_result.json +1 -1
  122. package/src/fixtures/e2e_prover_test.ts +39 -43
  123. package/src/fixtures/fixtures.ts +10 -0
  124. package/src/fixtures/ha_setup.ts +3 -1
  125. package/src/fixtures/setup.ts +99 -214
  126. package/src/fixtures/setup_p2p_test.ts +9 -17
  127. package/src/fixtures/token_utils.ts +4 -2
  128. package/src/guides/up_quick_start.sh +3 -3
  129. package/src/shared/cross_chain_test_harness.ts +13 -9
  130. package/src/shared/gas_portal_test_harness.ts +1 -1
  131. package/src/shared/index.ts +1 -0
  132. package/src/shared/mock_state_view.ts +188 -0
  133. package/src/shared/submit-transactions.ts +3 -2
  134. package/src/shared/uniswap_l1_l2.ts +37 -30
  135. package/src/simulators/lending_simulator.ts +4 -2
  136. package/src/simulators/token_simulator.ts +6 -30
  137. package/src/spartan/setup_test_wallets.ts +92 -15
  138. package/src/spartan/utils/bot.ts +4 -1
  139. package/src/spartan/utils/index.ts +4 -0
  140. package/src/spartan/utils/k8s.ts +8 -0
  141. package/src/test-wallet/test_wallet.ts +306 -0
  142. package/src/test-wallet/utils.ts +112 -0
  143. package/src/test-wallet/wallet_worker_script.ts +60 -0
  144. package/src/test-wallet/worker_wallet.ts +213 -0
  145. package/src/test-wallet/worker_wallet_schema.ts +13 -0
@@ -1,6 +1,5 @@
1
1
  import { SchnorrAccountContractArtifact } from '@aztec/accounts/schnorr';
2
- import { type InitialAccountData, generateSchnorrAccounts, getInitialTestAccountsData } from '@aztec/accounts/testing';
3
- import { type Archiver, createArchiver } from '@aztec/archiver';
2
+ import { type InitialAccountData, generateSchnorrAccounts } from '@aztec/accounts/testing';
4
3
  import { type AztecNodeConfig, AztecNodeService, getConfigEnvVars } from '@aztec/aztec-node';
5
4
  import { AztecAddress, EthAddress } from '@aztec/aztec.js/addresses';
6
5
  import {
@@ -13,10 +12,9 @@ import {
13
12
  import { publishContractClass, publishInstance } from '@aztec/aztec.js/deployment';
14
13
  import { Fr } from '@aztec/aztec.js/fields';
15
14
  import { type Logger, createLogger } from '@aztec/aztec.js/log';
16
- import { type AztecNode, createAztecNodeClient, waitForNode } from '@aztec/aztec.js/node';
15
+ import type { AztecNode } from '@aztec/aztec.js/node';
17
16
  import type { Wallet } from '@aztec/aztec.js/wallet';
18
17
  import { AnvilTestWatcher, CheatCodes } from '@aztec/aztec/testing';
19
- import { createBlobClientWithFileStores } from '@aztec/blob-client/client';
20
18
  import { SPONSORED_FPC_SALT } from '@aztec/constants';
21
19
  import { isAnvilTestChain } from '@aztec/ethereum/chain';
22
20
  import { createExtendedL1Client } from '@aztec/ethereum/client';
@@ -30,13 +28,8 @@ import {
30
28
  type ZKPassportArgs,
31
29
  deployAztecL1Contracts,
32
30
  } from '@aztec/ethereum/deploy-aztec-l1-contracts';
33
- import {
34
- DelayedTxUtils,
35
- EthCheatCodes,
36
- EthCheatCodesWithState,
37
- createDelayedL1TxUtilsFromViemWallet,
38
- startAnvil,
39
- } from '@aztec/ethereum/test';
31
+ import type { Delayer } from '@aztec/ethereum/l1-tx-utils';
32
+ import { type Anvil, EthCheatCodes, EthCheatCodesWithState, startAnvil } from '@aztec/ethereum/test';
40
33
  import { BlockNumber, EpochNumber } from '@aztec/foundation/branded-types';
41
34
  import { SecretValue } from '@aztec/foundation/config';
42
35
  import { randomBytes } from '@aztec/foundation/crypto/random';
@@ -45,20 +38,17 @@ import { withLoggerBindings } from '@aztec/foundation/log/server';
45
38
  import { retryUntil } from '@aztec/foundation/retry';
46
39
  import { sleep } from '@aztec/foundation/sleep';
47
40
  import { DateProvider, TestDateProvider } from '@aztec/foundation/timer';
48
- import type { DataStoreConfig } from '@aztec/kv-store/config';
49
41
  import { SponsoredFPCContract } from '@aztec/noir-contracts.js/SponsoredFPC';
50
42
  import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
51
43
  import type { P2PClientDeps } from '@aztec/p2p';
52
44
  import { MockGossipSubNetwork, getMockPubSubP2PServiceFactory } from '@aztec/p2p/test-helpers';
53
45
  import { protocolContractsHash } from '@aztec/protocol-contracts';
54
- import { type ProverNode, type ProverNodeConfig, type ProverNodeDeps, createProverNode } from '@aztec/prover-node';
46
+ import type { ProverNodeConfig } from '@aztec/prover-node';
55
47
  import { type PXEConfig, getPXEConfig } from '@aztec/pxe/server';
56
48
  import type { SequencerClient } from '@aztec/sequencer-client';
57
- import type { TestSequencerClient } from '@aztec/sequencer-client/test';
58
49
  import { type ContractInstanceWithAddress, getContractInstanceFromInstantiationParams } from '@aztec/stdlib/contract';
59
50
  import type { AztecNodeAdmin } from '@aztec/stdlib/interfaces/client';
60
51
  import { tryStop } from '@aztec/stdlib/interfaces/server';
61
- import type { P2PClientType } from '@aztec/stdlib/p2p';
62
52
  import type { PublicDataTreeLeaf } from '@aztec/stdlib/trees';
63
53
  import {
64
54
  type TelemetryClient,
@@ -67,10 +57,9 @@ import {
67
57
  initTelemetryClient,
68
58
  } from '@aztec/telemetry-client';
69
59
  import { BenchmarkTelemetryClient } from '@aztec/telemetry-client/bench';
70
- import { TestWallet, deployFundedSchnorrAccounts } from '@aztec/test-wallet/server';
60
+ import { deployFundedSchnorrAccounts } from '@aztec/wallets/testing';
71
61
  import { getGenesisValues } from '@aztec/world-state/testing';
72
62
 
73
- import type { Anvil } from '@viem/anvil';
74
63
  import fs from 'fs/promises';
75
64
  import { tmpdir } from 'os';
76
65
  import path from 'path';
@@ -84,6 +73,7 @@ import {
84
73
  } from 'viem/accounts';
85
74
  import { type Chain, foundry } from 'viem/chains';
86
75
 
76
+ import { TestWallet } from '../test-wallet/test_wallet.js';
87
77
  import { MNEMONIC, TEST_MAX_PENDING_TX_POOL_COUNT, TEST_PEER_CHECK_INTERVAL_MS } from './fixtures.js';
88
78
  import { getACVMConfig } from './get_acvm_config.js';
89
79
  import { getBBConfig } from './get_bb_config.js';
@@ -92,9 +82,6 @@ import { getEndToEndTestTelemetryClient } from './with_telemetry_utils.js';
92
82
 
93
83
  export { startAnvil };
94
84
 
95
- const { AZTEC_NODE_URL = '' } = process.env;
96
- const getAztecUrl = () => AZTEC_NODE_URL;
97
-
98
85
  let telemetry: TelemetryClient | undefined = undefined;
99
86
  async function getTelemetryClient(partialConfig: Partial<TelemetryClientConfig> & { benchmark?: boolean } = {}) {
100
87
  if (!telemetry) {
@@ -197,6 +184,11 @@ export type SetupOptions = {
197
184
  anvilAccounts?: number;
198
185
  /** Port to start anvil (defaults to 8545) */
199
186
  anvilPort?: number;
187
+ /**
188
+ * Number of slots per epoch for Anvil's finality simulation.
189
+ * Anvil reports `finalized = latest - slotsInAnEpoch * 2`.
190
+ */
191
+ anvilSlotsInAnEpoch?: number;
200
192
  /** Key to use for publishing L1 contracts */
201
193
  l1PublisherKey?: SecretValue<`0x${string}`>;
202
194
  /** ZkPassport configuration (domain, scope, mock verifier) */
@@ -217,13 +209,13 @@ export type EndToEndContext = {
217
209
  anvil: Anvil | undefined;
218
210
  /** The Aztec Node service or client a connected to it. */
219
211
  aztecNode: AztecNode;
220
- /** The Aztec Node as a service (only set if running locally). */
221
- aztecNodeService: AztecNodeService | undefined;
222
- /** Client to the Aztec Node admin interface (undefined if connected to remote environment) */
223
- aztecNodeAdmin: AztecNodeAdmin | undefined;
224
- /** The prover node service (only set if startProverNode is true) */
225
- proverNode: ProverNode | undefined;
226
- /** A client to the sequencer service (undefined if connected to remote environment) */
212
+ /** The Aztec Node as a service. */
213
+ aztecNodeService: AztecNodeService;
214
+ /** Client to the Aztec Node admin interface. */
215
+ aztecNodeAdmin: AztecNodeAdmin;
216
+ /** The aztec node running the prover node subsystem (only set if startProverNode is true). */
217
+ proverNode: AztecNodeService | undefined;
218
+ /** A client to the sequencer service. */
227
219
  sequencer: SequencerClient | undefined;
228
220
  /** Return values from deployAztecL1Contracts function. */
229
221
  deployL1ContractsValues: DeployAztecL1ContractsReturnType;
@@ -243,14 +235,18 @@ export type EndToEndContext = {
243
235
  cheatCodes: CheatCodes;
244
236
  /** The cheat codes for L1 */
245
237
  ethCheatCodes: EthCheatCodes;
246
- /** The anvil test watcher (undefined if connected to remote environment) */
247
- watcher: AnvilTestWatcher | undefined;
248
- /** Allows tweaking current system time, used by the epoch cache only (undefined if connected to remote environment) */
249
- dateProvider: TestDateProvider | undefined;
238
+ /** The anvil test watcher. */
239
+ watcher: AnvilTestWatcher;
240
+ /** Allows tweaking current system time, used by the epoch cache only. */
241
+ dateProvider: TestDateProvider;
250
242
  /** Telemetry client */
251
- telemetryClient: TelemetryClient | undefined;
243
+ telemetryClient: TelemetryClient;
252
244
  /** Mock gossip sub network used for gossipping messages (only if mockGossipSubNetwork was set to true in opts) */
253
245
  mockGossipSubNetwork: MockGossipSubNetwork | undefined;
246
+ /** Delayer for sequencer L1 txs (only when enableDelayer is true). */
247
+ sequencerDelayer: Delayer | undefined;
248
+ /** Delayer for prover node L1 txs (only when enableDelayer and startProverNode are true). */
249
+ proverDelayer: Delayer | undefined;
254
250
  /** Prefilled public data used for setting up nodes. */
255
251
  prefilledPublicData: PublicDataTreeLeaf[] | undefined;
256
252
  /** ACVM config (only set if running locally). */
@@ -258,87 +254,11 @@ export type EndToEndContext = {
258
254
  /** BB config (only set if running locally). */
259
255
  bbConfig: Awaited<ReturnType<typeof getBBConfig>>;
260
256
  /** Directory to cleanup on teardown. */
261
- directoryToCleanup: string | undefined;
257
+ directoryToCleanup: string;
262
258
  /** Function to stop the started services. */
263
259
  teardown: () => Promise<void>;
264
260
  };
265
261
 
266
- /**
267
- * Function to setup the test against a remote deployment. It is assumed that L1 contract are already deployed
268
- */
269
- async function setupWithRemoteEnvironment(
270
- account: HDAccount | PrivateKeyAccount,
271
- config: AztecNodeConfig & SetupOptions,
272
- logger: Logger,
273
- numberOfAccounts: number,
274
- ): Promise<EndToEndContext> {
275
- const aztecNodeUrl = getAztecUrl();
276
- logger.verbose(`Creating Aztec Node client to remote host ${aztecNodeUrl}`);
277
- const aztecNode = createAztecNodeClient(aztecNodeUrl);
278
- await waitForNode(aztecNode, logger);
279
- logger.verbose('JSON RPC client connected to Aztec Node');
280
- logger.verbose(`Retrieving contract addresses from ${aztecNodeUrl}`);
281
- const { l1ContractAddresses, rollupVersion } = await aztecNode.getNodeInfo();
282
-
283
- const l1Client = createExtendedL1Client(config.l1RpcUrls, account, foundry);
284
-
285
- const deployL1ContractsValues: DeployAztecL1ContractsReturnType = {
286
- l1ContractAddresses,
287
- l1Client,
288
- rollupVersion,
289
- };
290
- const ethCheatCodes = new EthCheatCodes(config.l1RpcUrls, new DateProvider());
291
- const wallet = await TestWallet.create(aztecNode);
292
-
293
- if (config.walletMinFeePadding !== undefined) {
294
- wallet.setMinFeePadding(config.walletMinFeePadding);
295
- }
296
-
297
- const cheatCodes = await CheatCodes.create(config.l1RpcUrls, aztecNode, new DateProvider());
298
- const teardown = () => Promise.resolve();
299
-
300
- logger.verbose('Populating wallet from already registered accounts...');
301
- const initialFundedAccounts = await getInitialTestAccountsData();
302
-
303
- if (initialFundedAccounts.length < numberOfAccounts) {
304
- throw new Error(`Required ${numberOfAccounts} accounts. Found ${initialFundedAccounts.length}.`);
305
- }
306
-
307
- const testAccounts = await Promise.all(
308
- initialFundedAccounts.slice(0, numberOfAccounts).map(async account => {
309
- const accountManager = await wallet.createSchnorrAccount(account.secret, account.salt, account.signingKey);
310
- return accountManager.address;
311
- }),
312
- );
313
-
314
- return {
315
- anvil: undefined,
316
- aztecNode,
317
- aztecNodeService: undefined,
318
- aztecNodeAdmin: undefined,
319
- sequencer: undefined,
320
- proverNode: undefined,
321
- deployL1ContractsValues,
322
- config,
323
- aztecNodeConfig: config,
324
- initialFundedAccounts,
325
- wallet,
326
- accounts: testAccounts,
327
- logger,
328
- cheatCodes,
329
- ethCheatCodes,
330
- prefilledPublicData: undefined,
331
- mockGossipSubNetwork: undefined,
332
- watcher: undefined,
333
- dateProvider: undefined,
334
- telemetryClient: undefined,
335
- acvmConfig: undefined,
336
- bbConfig: undefined,
337
- directoryToCleanup: undefined,
338
- teardown,
339
- };
340
- }
341
-
342
262
  /**
343
263
  * Sets up the environment for the end-to-end tests.
344
264
  * @param numberOfAccounts - The number of new accounts to be created once the PXE is initiated.
@@ -366,8 +286,12 @@ export async function setup(
366
286
  config.realProofs = !!opts.realProofs;
367
287
  // Only enforce the time table if requested
368
288
  config.enforceTimeTable = !!opts.enforceTimeTable;
289
+ // Enable the tx delayer for tests (default config has it disabled, so we force-enable it here)
290
+ config.enableDelayer = true;
369
291
  config.listenAddress = '127.0.0.1';
370
292
 
293
+ config.minTxPoolAgeMs = opts.minTxPoolAgeMs ?? 0;
294
+
371
295
  const logger = getLogger();
372
296
 
373
297
  // Create a temp directory for any services that need it and cleanup later
@@ -381,16 +305,11 @@ export async function setup(
381
305
  if (!isAnvilTestChain(chain.id)) {
382
306
  throw new Error(`No ETHEREUM_HOSTS set but non anvil chain requested`);
383
307
  }
384
- if (AZTEC_NODE_URL) {
385
- throw new Error(
386
- `AZTEC_NODE_URL provided but no ETHEREUM_HOSTS set. Refusing to run, please set both variables so tests can deploy L1 contracts to the same Anvil instance`,
387
- );
388
- }
389
-
390
308
  const res = await startAnvil({
391
309
  l1BlockTime: opts.ethereumSlotDuration,
392
310
  accounts: opts.anvilAccounts,
393
311
  port: opts.anvilPort ?? (process.env.ANVIL_PORT ? parseInt(process.env.ANVIL_PORT) : undefined),
312
+ slotsInAnEpoch: opts.anvilSlotsInAnEpoch,
394
313
  });
395
314
  anvil = res.anvil;
396
315
  config.l1RpcUrls = [res.rpcUrl];
@@ -421,11 +340,11 @@ export async function setup(
421
340
  publisherPrivKeyHex = opts.l1PublisherKey.getValue();
422
341
  publisherHdAccount = privateKeyToAccount(publisherPrivKeyHex);
423
342
  } else if (
424
- config.publisherPrivateKeys &&
425
- config.publisherPrivateKeys.length > 0 &&
426
- config.publisherPrivateKeys[0].getValue() != NULL_KEY
343
+ config.sequencerPublisherPrivateKeys &&
344
+ config.sequencerPublisherPrivateKeys.length > 0 &&
345
+ config.sequencerPublisherPrivateKeys[0].getValue() != NULL_KEY
427
346
  ) {
428
- publisherPrivKeyHex = config.publisherPrivateKeys[0].getValue();
347
+ publisherPrivKeyHex = config.sequencerPublisherPrivateKeys[0].getValue();
429
348
  publisherHdAccount = privateKeyToAccount(publisherPrivKeyHex);
430
349
  } else if (!MNEMONIC) {
431
350
  throw new Error(`Mnemonic not provided and no publisher private key`);
@@ -434,18 +353,13 @@ export async function setup(
434
353
  const publisherPrivKeyRaw = publisherHdAccount.getHdKey().privateKey;
435
354
  const publisherPrivKey = publisherPrivKeyRaw === null ? null : Buffer.from(publisherPrivKeyRaw);
436
355
  publisherPrivKeyHex = `0x${publisherPrivKey!.toString('hex')}` as const;
437
- config.publisherPrivateKeys = [new SecretValue(publisherPrivKeyHex)];
356
+ config.sequencerPublisherPrivateKeys = [new SecretValue(publisherPrivKeyHex)];
438
357
  }
439
358
 
440
359
  if (config.coinbase === undefined) {
441
360
  config.coinbase = EthAddress.fromString(publisherHdAccount.address);
442
361
  }
443
362
 
444
- if (AZTEC_NODE_URL) {
445
- // we are setting up against a remote environment, l1 contracts are assumed to already be deployed
446
- return await setupWithRemoteEnvironment(publisherHdAccount!, config, logger, numberOfAccounts);
447
- }
448
-
449
363
  // Determine which addresses to fund in genesis
450
364
  const initialFundedAccounts =
451
365
  opts.initialFundedAccounts ??
@@ -502,9 +416,14 @@ export async function setup(
502
416
  if (enableAutomine) {
503
417
  await ethCheatCodes.setAutomine(false);
504
418
  await ethCheatCodes.setIntervalMining(config.ethereumSlotDuration);
505
- dateProvider.setTime((await ethCheatCodes.timestamp()) * 1000);
506
419
  }
507
420
 
421
+ // Always sync dateProvider to L1 time after deploying L1 contracts, regardless of mining mode.
422
+ // In compose mode, L1 time may have drifted ahead of system time due to the local-network watcher
423
+ // warping time forward on each filled slot. Without this sync, the sequencer computes the wrong
424
+ // slot from its dateProvider and cannot propose blocks.
425
+ dateProvider.setTime((await ethCheatCodes.timestamp()) * 1000);
426
+
508
427
  if (opts.l2StartTime) {
509
428
  await ethCheatCodes.warp(opts.l2StartTime, { resetBlockInterval: true });
510
429
  }
@@ -541,7 +460,7 @@ export async function setup(
541
460
  }
542
461
 
543
462
  let mockGossipSubNetwork: MockGossipSubNetwork | undefined;
544
- let p2pClientDeps: P2PClientDeps<P2PClientType.Full> | undefined = undefined;
463
+ let p2pClientDeps: P2PClientDeps | undefined = undefined;
545
464
 
546
465
  if (opts.mockGossipSubNetwork) {
547
466
  mockGossipSubNetwork = new MockGossipSubNetwork();
@@ -581,31 +500,33 @@ export async function setup(
581
500
  );
582
501
  const sequencerClient = aztecNodeService.getSequencer();
583
502
 
584
- if (sequencerClient) {
585
- const publisher = (sequencerClient as TestSequencerClient).sequencer.publisher;
586
- publisher.l1TxUtils = DelayedTxUtils.fromL1TxUtils(publisher.l1TxUtils, config.ethereumSlotDuration, l1Client);
587
- }
588
-
589
- let proverNode: ProverNode | undefined = undefined;
503
+ let proverNode: AztecNodeService | undefined = undefined;
590
504
  if (opts.startProverNode) {
591
505
  logger.verbose('Creating and syncing a simulated prover node...');
592
506
  const proverNodePrivateKey = getPrivateKeyFromIndex(2);
593
507
  const proverNodePrivateKeyHex: Hex = `0x${proverNodePrivateKey!.toString('hex')}`;
594
508
  const proverNodeDataDirectory = path.join(directoryToCleanup, randomBytes(8).toString('hex'));
595
- const proverNodeConfig = {
596
- ...config.proverNodeConfig,
597
- dataDirectory: proverNodeDataDirectory,
598
- p2pEnabled: false,
509
+
510
+ const p2pClientDeps: Partial<P2PClientDeps> = {
511
+ p2pServiceFactory: mockGossipSubNetwork && getMockPubSubP2PServiceFactory(mockGossipSubNetwork!),
512
+ rpcTxProviders: [aztecNodeService],
599
513
  };
600
- proverNode = await createAndSyncProverNode(
514
+
515
+ ({ proverNode } = await createAndSyncProverNode(
601
516
  proverNodePrivateKeyHex,
602
517
  config,
603
- proverNodeConfig,
604
- aztecNodeService,
605
- prefilledPublicData,
606
- );
518
+ {
519
+ ...config.proverNodeConfig,
520
+ dataDirectory: proverNodeDataDirectory,
521
+ },
522
+ { dateProvider, p2pClientDeps, telemetry: telemetryClient },
523
+ { prefilledPublicData },
524
+ ));
607
525
  }
608
526
 
527
+ const sequencerDelayer = sequencerClient?.getDelayer();
528
+ const proverDelayer = proverNode?.getProverNode()?.getDelayer();
529
+
609
530
  logger.verbose('Creating a pxe...');
610
531
  const pxeConfig = { ...getPXEConfig(), ...pxeOpts };
611
532
  pxeConfig.dataDirectory = path.join(directoryToCleanup, randomBytes(8).toString('hex'));
@@ -683,7 +604,7 @@ export async function setup(
683
604
  logger.error(`Error during e2e test teardown`, err);
684
605
  } finally {
685
606
  try {
686
- await telemetryClient?.stop();
607
+ await telemetryClient.stop();
687
608
  } catch (err) {
688
609
  logger.error(`Error during telemetry client stop`, err);
689
610
  }
@@ -706,6 +627,8 @@ export async function setup(
706
627
  mockGossipSubNetwork,
707
628
  prefilledPublicData,
708
629
  proverNode,
630
+ sequencerDelayer,
631
+ proverDelayer,
709
632
  sequencer: sequencerClient,
710
633
  teardown,
711
634
  telemetryClient,
@@ -789,93 +712,55 @@ export async function waitForProvenChain(node: AztecNode, targetBlock?: BlockNum
789
712
  );
790
713
  }
791
714
 
715
+ /**
716
+ * Creates an AztecNodeService with the prover node enabled as a subsystem.
717
+ * Returns both the aztec node service (for lifecycle management) and the prover node (for test internals access).
718
+ */
792
719
  export function createAndSyncProverNode(
793
720
  proverNodePrivateKey: `0x${string}`,
794
- aztecNodeConfig: AztecNodeConfig,
795
- proverNodeConfig: Partial<ProverNodeConfig> & Pick<DataStoreConfig, 'dataDirectory'> & { dontStart?: boolean },
796
- aztecNode: AztecNode | undefined,
797
- prefilledPublicData: PublicDataTreeLeaf[] = [],
798
- proverNodeDeps: ProverNodeDeps = {},
799
- ) {
721
+ baseConfig: AztecNodeConfig,
722
+ configOverrides: Pick<AztecNodeConfig, 'dataDirectory'>,
723
+ deps: {
724
+ telemetry?: TelemetryClient;
725
+ dateProvider: DateProvider;
726
+ p2pClientDeps?: P2PClientDeps;
727
+ },
728
+ options: { prefilledPublicData: PublicDataTreeLeaf[]; dontStart?: boolean },
729
+ ): Promise<{ proverNode: AztecNodeService }> {
800
730
  return withLoggerBindings({ actor: 'prover-0' }, async () => {
801
- const aztecNodeTxProvider = aztecNode && {
802
- getTxByHash: aztecNode.getTxByHash.bind(aztecNode),
803
- getTxsByHash: aztecNode.getTxsByHash.bind(aztecNode),
804
- stop: () => Promise.resolve(),
805
- };
806
-
807
- const blobClient = await createBlobClientWithFileStores(aztecNodeConfig, createLogger('blob-client:prover-node'));
808
-
809
- const archiverConfig = { ...aztecNodeConfig, dataDirectory: proverNodeConfig.dataDirectory };
810
- const archiver = await createArchiver(
811
- archiverConfig,
812
- { blobClient, dateProvider: proverNodeDeps.dateProvider },
813
- { blockUntilSync: true },
814
- );
815
-
816
- const proverConfig: ProverNodeConfig = {
817
- ...aztecNodeConfig,
818
- txCollectionNodeRpcUrls: [],
819
- realProofs: false,
820
- proverAgentCount: 2,
821
- publisherPrivateKeys: [new SecretValue(proverNodePrivateKey)],
822
- proverNodeMaxPendingJobs: 10,
823
- proverNodeMaxParallelBlocksPerEpoch: 32,
824
- proverNodePollingIntervalMs: 200,
825
- txGatheringIntervalMs: 1000,
826
- txGatheringBatchSize: 10,
827
- txGatheringMaxParallelRequestsPerNode: 10,
828
- txGatheringTimeoutMs: 24_000,
829
- proverNodeFailedEpochStore: undefined,
830
- proverId: EthAddress.fromNumber(1),
831
- proverNodeEpochProvingDelayMs: undefined,
832
- ...proverNodeConfig,
833
- };
834
-
835
- const l1TxUtils = createDelayedL1TxUtils(
836
- aztecNodeConfig,
837
- proverNodePrivateKey,
838
- 'prover-node',
839
- proverNodeDeps.dateProvider,
731
+ const proverNode = await AztecNodeService.createAndSync(
732
+ {
733
+ ...baseConfig,
734
+ ...configOverrides,
735
+ p2pPort: 0,
736
+ enableProverNode: true,
737
+ disableValidator: true,
738
+ proverPublisherPrivateKeys: [new SecretValue(proverNodePrivateKey)],
739
+ },
740
+ deps,
741
+ { ...options, dontStartProverNode: options.dontStart },
840
742
  );
841
743
 
842
- const proverNode = await createProverNode(
843
- proverConfig,
844
- { ...proverNodeDeps, aztecNodeTxProvider, archiver: archiver as Archiver, l1TxUtils },
845
- { prefilledPublicData },
846
- );
847
- getLogger().info(`Created and synced prover node`, { publisherAddress: l1TxUtils.client.account!.address });
848
- if (!proverNodeConfig.dontStart) {
849
- await proverNode.start();
744
+ if (!proverNode.getProverNode()) {
745
+ throw new Error('Prover node subsystem was not created despite enableProverNode being set');
850
746
  }
851
- return proverNode;
852
- });
853
- }
854
-
855
- function createDelayedL1TxUtils(
856
- aztecNodeConfig: AztecNodeConfig,
857
- privateKey: `0x${string}`,
858
- logName: string,
859
- dateProvider?: DateProvider,
860
- ) {
861
- const l1Client = createExtendedL1Client(aztecNodeConfig.l1RpcUrls, privateKey, foundry);
862
747
 
863
- const log = createLogger(logName);
864
- const l1TxUtils = createDelayedL1TxUtilsFromViemWallet(l1Client, log, dateProvider, aztecNodeConfig);
865
- l1TxUtils.enableDelayer(aztecNodeConfig.ethereumSlotDuration);
866
- return l1TxUtils;
748
+ getLogger().info(`Created and synced prover node`);
749
+ return { proverNode };
750
+ });
867
751
  }
868
752
 
869
753
  export type BalancesFn = ReturnType<typeof getBalancesFn>;
870
754
  export function getBalancesFn(
871
755
  symbol: string,
872
756
  method: ContractMethod,
873
- from: AztecAddress,
874
757
  logger: any,
875
758
  ): (...addresses: (AztecAddress | { address: AztecAddress })[]) => Promise<bigint[]> {
876
759
  const balances = async (...addressLikes: (AztecAddress | { address: AztecAddress })[]) => {
877
760
  const addresses = addressLikes.map(addressLike => ('address' in addressLike ? addressLike.address : addressLike));
878
- const b = await Promise.all(addresses.map(address => method(address).simulate({ from })));
761
+ const b = await Promise.all(
762
+ addresses.map(async address => (await method(address).simulate({ from: address })).result),
763
+ );
879
764
  const debugString = `${symbol} balances: ${addresses.map((address, i) => `${address}: ${b[i]}`).join(', ')}`;
880
765
  logger.verbose(debugString);
881
766
  return b;
@@ -993,7 +878,7 @@ export async function publicDeployAccounts(
993
878
 
994
879
  const batch = new BatchCall(wallet, calls);
995
880
 
996
- const txReceipt = await batch.send({ from: accountsToDeploy[0] });
881
+ const { receipt: txReceipt } = await batch.send({ from: accountsToDeploy[0] });
997
882
  if (waitUntilProven) {
998
883
  if (!node) {
999
884
  throw new Error('Need to provide an AztecNode to wait for proven.');
@@ -7,7 +7,6 @@ import { SecretValue } from '@aztec/foundation/config';
7
7
  import { withLoggerBindings } from '@aztec/foundation/log/server';
8
8
  import { bufferToHex } from '@aztec/foundation/string';
9
9
  import type { DateProvider } from '@aztec/foundation/timer';
10
- import type { ProverNodeConfig, ProverNodeDeps } from '@aztec/prover-node';
11
10
  import type { PublicDataTreeLeaf } from '@aztec/stdlib/trees';
12
11
 
13
12
  import getPort from 'get-port';
@@ -131,7 +130,7 @@ export async function createNonValidatorNode(
131
130
  ...p2pConfig,
132
131
  disableValidator: true,
133
132
  validatorPrivateKeys: undefined,
134
- publisherPrivateKeys: [],
133
+ sequencerPublisherPrivateKeys: [],
135
134
  };
136
135
  const telemetry = await getEndToEndTestTelemetryClient(metricsPort);
137
136
  return await AztecNodeService.createAndSync(config, { telemetry, dateProvider }, { prefilledPublicData });
@@ -143,31 +142,24 @@ export async function createProverNode(
143
142
  tcpPort: number,
144
143
  bootstrapNode: string | undefined,
145
144
  addressIndex: number,
146
- proverNodeDeps: ProverNodeDeps & Required<Pick<ProverNodeDeps, 'dateProvider'>>,
145
+ deps: { dateProvider: DateProvider },
147
146
  prefilledPublicData?: PublicDataTreeLeaf[],
148
147
  dataDirectory?: string,
149
148
  metricsPort?: number,
150
- ) {
149
+ ): Promise<{ proverNode: AztecNodeService }> {
151
150
  const actorIndex = proverCounter++;
152
151
  return await withLoggerBindings({ actor: `prover-${actorIndex}` }, async () => {
153
152
  const proverNodePrivateKey = getPrivateKeyFromIndex(ATTESTER_PRIVATE_KEYS_START_INDEX + addressIndex)!;
154
153
  const telemetry = await getEndToEndTestTelemetryClient(metricsPort);
155
154
 
156
- const proverConfig: Partial<ProverNodeConfig> = await createP2PConfig(
157
- config,
158
- bootstrapNode,
159
- tcpPort,
160
- dataDirectory,
161
- );
155
+ const p2pConfig = await createP2PConfig(config, bootstrapNode, tcpPort, dataDirectory);
162
156
 
163
- const aztecNodeRpcTxProvider = undefined;
164
157
  return await createAndSyncProverNode(
165
158
  bufferToHex(proverNodePrivateKey),
166
- config,
167
- { ...proverConfig, dataDirectory },
168
- aztecNodeRpcTxProvider,
169
- prefilledPublicData,
170
- { ...proverNodeDeps, telemetry },
159
+ { ...config, ...p2pConfig },
160
+ { dataDirectory },
161
+ { ...deps, telemetry },
162
+ { prefilledPublicData: prefilledPublicData ?? [] },
171
163
  );
172
164
  });
173
165
  }
@@ -215,7 +207,7 @@ export async function createValidatorConfig(
215
207
  ...config,
216
208
  ...p2pConfig,
217
209
  validatorPrivateKeys: new SecretValue(attesterPrivateKeys),
218
- publisherPrivateKeys: [new SecretValue(attesterPrivateKeys[0])],
210
+ sequencerPublisherPrivateKeys: [new SecretValue(attesterPrivateKeys[0])],
219
211
  };
220
212
 
221
213
  return nodeConfig;
@@ -6,7 +6,9 @@ import { TokenContract } from '@aztec/noir-contracts.js/Token';
6
6
 
7
7
  export async function deployToken(wallet: Wallet, admin: AztecAddress, initialAdminBalance: bigint, logger: Logger) {
8
8
  logger.info(`Deploying Token contract...`);
9
- const { contract, instance } = await TokenContract.deploy(wallet, admin, 'TokenName', 'TokenSymbol', 18).send({
9
+ const {
10
+ receipt: { contract, instance },
11
+ } = await TokenContract.deploy(wallet, admin, 'TokenName', 'TokenSymbol', 18).send({
10
12
  from: admin,
11
13
  wait: { returnReceipt: true },
12
14
  });
@@ -38,7 +40,7 @@ export async function expectTokenBalance(
38
40
  ) {
39
41
  // Then check the balance
40
42
  const contractWithWallet = TokenContract.at(token.address, wallet);
41
- const balance = await contractWithWallet.methods.balance_of_private(owner).simulate({ from: owner });
43
+ const { result: balance } = await contractWithWallet.methods.balance_of_private(owner).simulate({ from: owner });
42
44
  logger.info(`Account ${owner} balance: ${balance}`);
43
45
  expect(balance).toBe(expectedBalance);
44
46
  }
@@ -23,6 +23,8 @@ aztec-wallet create-account -a alice -f test0
23
23
  aztec-wallet create-account -a bob -f test0
24
24
  # docs:end:declare-accounts
25
25
 
26
+ aztec-wallet bridge-fee-juice 1000000000000000000000 accounts:alice --mint --no-wait
27
+
26
28
  DEPLOY_OUTPUT=$(aztec-wallet deploy ../noir-contracts.js/artifacts/token_contract-Token.json --args accounts:test0 Test TST 18 -f test0)
27
29
  TOKEN_ADDRESS=$(echo "$DEPLOY_OUTPUT" | grep -oE 'Contract deployed at 0x[0-9a-fA-F]+' | cut -d ' ' -f4)
28
30
  echo "Deployed contract at $TOKEN_ADDRESS"
@@ -38,9 +40,7 @@ fi
38
40
 
39
41
  TRANSFER_AMOUNT=42
40
42
 
41
- aztec-wallet create-authwit transfer_in_private accounts:test0 -ca last --args accounts:alice accounts:bob $TRANSFER_AMOUNT 1 -f alice
42
-
43
- aztec-wallet send transfer_in_private -ca last --args accounts:alice accounts:bob $TRANSFER_AMOUNT 1 -aw authwits:last -f test0
43
+ aztec-wallet send transfer_in_private -ca last --args accounts:alice accounts:bob $TRANSFER_AMOUNT 0 -f alice --payment method=fee_juice,claim
44
44
 
45
45
  # Test end result
46
46
  ALICE_BALANCE=$(aztec-wallet simulate balance_of_private -ca last --args accounts:alice -f alice)