@aztec/end-to-end 0.0.1-commit.d6f2b3f94 → 0.0.1-commit.d939eb5aa

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 (174) hide show
  1. package/README.md +27 -0
  2. package/dest/bench/client_flows/client_flows_benchmark.d.ts +2 -2
  3. package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -1
  4. package/dest/bench/client_flows/client_flows_benchmark.js +22 -29
  5. package/dest/bench/utils.d.ts +1 -1
  6. package/dest/bench/utils.d.ts.map +1 -1
  7. package/dest/bench/utils.js +6 -3
  8. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +6 -3
  9. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts.map +1 -1
  10. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.js +23 -13
  11. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +2 -2
  12. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts.map +1 -1
  13. package/dest/e2e_deploy_contract/deploy_test.d.ts +2 -2
  14. package/dest/e2e_deploy_contract/deploy_test.d.ts.map +1 -1
  15. package/dest/e2e_epochs/epochs_test.d.ts +11 -7
  16. package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
  17. package/dest/e2e_epochs/epochs_test.js +60 -38
  18. package/dest/e2e_fees/fees_test.d.ts +2 -2
  19. package/dest/e2e_fees/fees_test.d.ts.map +1 -1
  20. package/dest/e2e_fees/fees_test.js +19 -12
  21. package/dest/e2e_nested_contract/nested_contract_test.d.ts +1 -1
  22. package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +1 -1
  23. package/dest/e2e_nested_contract/nested_contract_test.js +4 -6
  24. package/dest/e2e_p2p/inactivity_slash_test.js +3 -3
  25. package/dest/e2e_p2p/p2p_network.d.ts +9 -10
  26. package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
  27. package/dest/e2e_p2p/p2p_network.js +38 -20
  28. package/dest/e2e_p2p/reqresp/utils.d.ts +3 -3
  29. package/dest/e2e_p2p/reqresp/utils.d.ts.map +1 -1
  30. package/dest/e2e_p2p/reqresp/utils.js +46 -9
  31. package/dest/e2e_p2p/shared.d.ts +26 -8
  32. package/dest/e2e_p2p/shared.d.ts.map +1 -1
  33. package/dest/e2e_p2p/shared.js +51 -45
  34. package/dest/e2e_token_contract/token_contract_test.d.ts +4 -2
  35. package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -1
  36. package/dest/e2e_token_contract/token_contract_test.js +19 -9
  37. package/dest/fixtures/authwit_proxy.d.ts +15 -0
  38. package/dest/fixtures/authwit_proxy.d.ts.map +1 -0
  39. package/dest/fixtures/authwit_proxy.js +34 -0
  40. package/dest/fixtures/e2e_prover_test.d.ts +7 -6
  41. package/dest/fixtures/e2e_prover_test.d.ts.map +1 -1
  42. package/dest/fixtures/e2e_prover_test.js +37 -49
  43. package/dest/fixtures/elu_monitor.d.ts +21 -0
  44. package/dest/fixtures/elu_monitor.d.ts.map +1 -0
  45. package/dest/fixtures/elu_monitor.js +102 -0
  46. package/dest/fixtures/fixtures.d.ts +5 -1
  47. package/dest/fixtures/fixtures.d.ts.map +1 -1
  48. package/dest/fixtures/fixtures.js +6 -0
  49. package/dest/fixtures/get_bb_config.d.ts +1 -1
  50. package/dest/fixtures/get_bb_config.d.ts.map +1 -1
  51. package/dest/fixtures/get_bb_config.js +5 -5
  52. package/dest/fixtures/ha_setup.d.ts +1 -1
  53. package/dest/fixtures/ha_setup.d.ts.map +1 -1
  54. package/dest/fixtures/ha_setup.js +3 -1
  55. package/dest/fixtures/setup.d.ts +41 -17
  56. package/dest/fixtures/setup.d.ts.map +1 -1
  57. package/dest/fixtures/setup.js +76 -95
  58. package/dest/fixtures/setup_p2p_test.d.ts +10 -7
  59. package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
  60. package/dest/fixtures/setup_p2p_test.js +18 -15
  61. package/dest/fixtures/token_utils.d.ts +2 -2
  62. package/dest/fixtures/token_utils.d.ts.map +1 -1
  63. package/dest/fixtures/token_utils.js +5 -7
  64. package/dest/legacy-jest-resolver.d.cts +3 -0
  65. package/dest/legacy-jest-resolver.d.cts.map +1 -0
  66. package/dest/shared/cross_chain_test_harness.d.ts +1 -1
  67. package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
  68. package/dest/shared/cross_chain_test_harness.js +13 -13
  69. package/dest/shared/gas_portal_test_harness.js +2 -2
  70. package/dest/shared/index.d.ts +2 -1
  71. package/dest/shared/index.d.ts.map +1 -1
  72. package/dest/shared/index.js +1 -0
  73. package/dest/shared/jest_setup.js +41 -1
  74. package/dest/shared/mock_state_view.d.ts +86 -0
  75. package/dest/shared/mock_state_view.d.ts.map +1 -0
  76. package/dest/shared/mock_state_view.js +186 -0
  77. package/dest/shared/submit-transactions.d.ts +2 -2
  78. package/dest/shared/submit-transactions.d.ts.map +1 -1
  79. package/dest/shared/submit-transactions.js +1 -1
  80. package/dest/shared/uniswap_l1_l2.d.ts +1 -1
  81. package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
  82. package/dest/shared/uniswap_l1_l2.js +14 -17
  83. package/dest/simulators/lending_simulator.d.ts +1 -1
  84. package/dest/simulators/lending_simulator.d.ts.map +1 -1
  85. package/dest/simulators/lending_simulator.js +4 -4
  86. package/dest/simulators/token_simulator.d.ts +1 -1
  87. package/dest/simulators/token_simulator.d.ts.map +1 -1
  88. package/dest/simulators/token_simulator.js +3 -24
  89. package/dest/spartan/setup_test_wallets.d.ts +12 -3
  90. package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
  91. package/dest/spartan/setup_test_wallets.js +100 -39
  92. package/dest/spartan/tx_metrics.js +1 -1
  93. package/dest/spartan/utils/bot.d.ts +3 -2
  94. package/dest/spartan/utils/bot.d.ts.map +1 -1
  95. package/dest/spartan/utils/bot.js +2 -1
  96. package/dest/spartan/utils/config.d.ts +7 -1
  97. package/dest/spartan/utils/config.d.ts.map +1 -1
  98. package/dest/spartan/utils/config.js +3 -1
  99. package/dest/spartan/utils/index.d.ts +4 -2
  100. package/dest/spartan/utils/index.d.ts.map +1 -1
  101. package/dest/spartan/utils/index.js +5 -1
  102. package/dest/spartan/utils/k8s.d.ts +3 -1
  103. package/dest/spartan/utils/k8s.d.ts.map +1 -1
  104. package/dest/spartan/utils/k8s.js +6 -0
  105. package/dest/spartan/utils/nodes.d.ts +4 -5
  106. package/dest/spartan/utils/nodes.d.ts.map +1 -1
  107. package/dest/spartan/utils/nodes.js +9 -9
  108. package/dest/spartan/utils/pod_logs.d.ts +25 -0
  109. package/dest/spartan/utils/pod_logs.d.ts.map +1 -0
  110. package/dest/spartan/utils/pod_logs.js +74 -0
  111. package/dest/test-wallet/test_wallet.d.ts +84 -0
  112. package/dest/test-wallet/test_wallet.d.ts.map +1 -0
  113. package/dest/test-wallet/test_wallet.js +249 -0
  114. package/dest/test-wallet/utils.d.ts +41 -0
  115. package/dest/test-wallet/utils.d.ts.map +1 -0
  116. package/dest/test-wallet/utils.js +71 -0
  117. package/dest/test-wallet/wallet_worker_script.d.ts +2 -0
  118. package/dest/test-wallet/wallet_worker_script.d.ts.map +1 -0
  119. package/dest/test-wallet/wallet_worker_script.js +48 -0
  120. package/dest/test-wallet/worker_wallet.d.ts +52 -0
  121. package/dest/test-wallet/worker_wallet.d.ts.map +1 -0
  122. package/dest/test-wallet/worker_wallet.js +151 -0
  123. package/dest/test-wallet/worker_wallet_schema.d.ts +279 -0
  124. package/dest/test-wallet/worker_wallet_schema.d.ts.map +1 -0
  125. package/dest/test-wallet/worker_wallet_schema.js +10 -0
  126. package/package.json +43 -43
  127. package/src/bench/client_flows/client_flows_benchmark.ts +26 -13
  128. package/src/bench/utils.ts +7 -2
  129. package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +30 -20
  130. package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +1 -1
  131. package/src/e2e_deploy_contract/deploy_test.ts +1 -1
  132. package/src/e2e_epochs/epochs_test.ts +78 -66
  133. package/src/e2e_fees/bridging_race.notest.ts +1 -1
  134. package/src/e2e_fees/fees_test.ts +15 -23
  135. package/src/e2e_nested_contract/nested_contract_test.ts +6 -4
  136. package/src/e2e_p2p/inactivity_slash_test.ts +3 -3
  137. package/src/e2e_p2p/p2p_network.ts +54 -33
  138. package/src/e2e_p2p/reqresp/utils.ts +58 -9
  139. package/src/e2e_p2p/shared.ts +73 -60
  140. package/src/e2e_token_contract/token_contract_test.ts +25 -8
  141. package/src/fixtures/authwit_proxy.ts +54 -0
  142. package/src/fixtures/dumps/epoch_proof_result.json +1 -1
  143. package/src/fixtures/e2e_prover_test.ts +44 -53
  144. package/src/fixtures/elu_monitor.ts +126 -0
  145. package/src/fixtures/fixtures.ts +10 -0
  146. package/src/fixtures/get_bb_config.ts +7 -6
  147. package/src/fixtures/ha_setup.ts +3 -1
  148. package/src/fixtures/setup.ts +108 -130
  149. package/src/fixtures/setup_p2p_test.ts +17 -25
  150. package/src/fixtures/token_utils.ts +3 -3
  151. package/src/guides/up_quick_start.sh +3 -3
  152. package/src/legacy-jest-resolver.cjs +135 -0
  153. package/src/shared/cross_chain_test_harness.ts +13 -9
  154. package/src/shared/gas_portal_test_harness.ts +1 -1
  155. package/src/shared/index.ts +1 -0
  156. package/src/shared/jest_setup.ts +51 -1
  157. package/src/shared/mock_state_view.ts +188 -0
  158. package/src/shared/submit-transactions.ts +3 -2
  159. package/src/shared/uniswap_l1_l2.ts +36 -29
  160. package/src/simulators/lending_simulator.ts +8 -4
  161. package/src/simulators/token_simulator.ts +6 -30
  162. package/src/spartan/setup_test_wallets.ts +141 -32
  163. package/src/spartan/tx_metrics.ts +1 -1
  164. package/src/spartan/utils/bot.ts +4 -1
  165. package/src/spartan/utils/config.ts +2 -0
  166. package/src/spartan/utils/index.ts +7 -0
  167. package/src/spartan/utils/k8s.ts +8 -0
  168. package/src/spartan/utils/nodes.ts +15 -10
  169. package/src/spartan/utils/pod_logs.ts +99 -0
  170. package/src/test-wallet/test_wallet.ts +351 -0
  171. package/src/test-wallet/utils.ts +112 -0
  172. package/src/test-wallet/wallet_worker_script.ts +60 -0
  173. package/src/test-wallet/worker_wallet.ts +214 -0
  174. package/src/test-wallet/worker_wallet_schema.ts +13 -0
@@ -1,12 +1,14 @@
1
1
  import { SchnorrAccountContractArtifact } from '@aztec/accounts/schnorr';
2
2
  import { type InitialAccountData, generateSchnorrAccounts } from '@aztec/accounts/testing';
3
- import { type Archiver, createArchiver } from '@aztec/archiver';
4
3
  import { type AztecNodeConfig, AztecNodeService, getConfigEnvVars } from '@aztec/aztec-node';
4
+ import { NO_FROM } from '@aztec/aztec.js/account';
5
5
  import { AztecAddress, EthAddress } from '@aztec/aztec.js/addresses';
6
6
  import {
7
7
  BatchCall,
8
8
  type ContractFunctionInteraction,
9
9
  type ContractMethod,
10
+ type DeployInteractionWaitOptions,
11
+ type DeployOptions,
10
12
  getContractClassFromArtifact,
11
13
  waitForProven,
12
14
  } from '@aztec/aztec.js/contracts';
@@ -16,7 +18,6 @@ import { type Logger, createLogger } from '@aztec/aztec.js/log';
16
18
  import type { AztecNode } from '@aztec/aztec.js/node';
17
19
  import type { Wallet } from '@aztec/aztec.js/wallet';
18
20
  import { AnvilTestWatcher, CheatCodes } from '@aztec/aztec/testing';
19
- import { createBlobClientWithFileStores } from '@aztec/blob-client/client';
20
21
  import { SPONSORED_FPC_SALT } from '@aztec/constants';
21
22
  import { isAnvilTestChain } from '@aztec/ethereum/chain';
22
23
  import { createExtendedL1Client } from '@aztec/ethereum/client';
@@ -30,13 +31,9 @@ import {
30
31
  type ZKPassportArgs,
31
32
  deployAztecL1Contracts,
32
33
  } from '@aztec/ethereum/deploy-aztec-l1-contracts';
33
- import {
34
- DelayedTxUtils,
35
- EthCheatCodes,
36
- EthCheatCodesWithState,
37
- createDelayedL1TxUtilsFromViemWallet,
38
- startAnvil,
39
- } from '@aztec/ethereum/test';
34
+ import type { Delayer } from '@aztec/ethereum/l1-tx-utils';
35
+ import { EthCheatCodes, EthCheatCodesWithState, startAnvil } from '@aztec/ethereum/test';
36
+ import type { Anvil } from '@aztec/ethereum/test';
40
37
  import { BlockNumber, EpochNumber } from '@aztec/foundation/branded-types';
41
38
  import { SecretValue } from '@aztec/foundation/config';
42
39
  import { randomBytes } from '@aztec/foundation/crypto/random';
@@ -45,21 +42,19 @@ import { withLoggerBindings } from '@aztec/foundation/log/server';
45
42
  import { retryUntil } from '@aztec/foundation/retry';
46
43
  import { sleep } from '@aztec/foundation/sleep';
47
44
  import { DateProvider, TestDateProvider } from '@aztec/foundation/timer';
48
- import type { DataStoreConfig } from '@aztec/kv-store/config';
49
45
  import { SponsoredFPCContract } from '@aztec/noir-contracts.js/SponsoredFPC';
50
46
  import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
51
47
  import type { P2PClientDeps } from '@aztec/p2p';
52
48
  import { MockGossipSubNetwork, getMockPubSubP2PServiceFactory } from '@aztec/p2p/test-helpers';
53
49
  import { protocolContractsHash } from '@aztec/protocol-contracts';
54
- import { type ProverNode, type ProverNodeConfig, type ProverNodeDeps, createProverNode } from '@aztec/prover-node';
50
+ import type { ProverNodeConfig } from '@aztec/prover-node';
55
51
  import { type PXEConfig, getPXEConfig } from '@aztec/pxe/server';
56
52
  import type { SequencerClient } from '@aztec/sequencer-client';
57
- import type { TestSequencerClient } from '@aztec/sequencer-client/test';
58
53
  import { type ContractInstanceWithAddress, getContractInstanceFromInstantiationParams } from '@aztec/stdlib/contract';
59
- import type { AztecNodeAdmin } from '@aztec/stdlib/interfaces/client';
54
+ import type { AztecNodeAdmin, AztecNodeDebug } from '@aztec/stdlib/interfaces/client';
60
55
  import { tryStop } from '@aztec/stdlib/interfaces/server';
61
- import type { P2PClientType } from '@aztec/stdlib/p2p';
62
56
  import type { PublicDataTreeLeaf } from '@aztec/stdlib/trees';
57
+ import type { GenesisData } from '@aztec/stdlib/world-state';
63
58
  import {
64
59
  type TelemetryClient,
65
60
  type TelemetryClientConfig,
@@ -67,10 +62,9 @@ import {
67
62
  initTelemetryClient,
68
63
  } from '@aztec/telemetry-client';
69
64
  import { BenchmarkTelemetryClient } from '@aztec/telemetry-client/bench';
70
- import { TestWallet, deployFundedSchnorrAccounts } from '@aztec/test-wallet/server';
65
+ import { deployFundedSchnorrAccounts } from '@aztec/wallets/testing';
71
66
  import { getGenesisValues } from '@aztec/world-state/testing';
72
67
 
73
- import type { Anvil } from '@viem/anvil';
74
68
  import fs from 'fs/promises';
75
69
  import { tmpdir } from 'os';
76
70
  import path from 'path';
@@ -84,6 +78,7 @@ import {
84
78
  } from 'viem/accounts';
85
79
  import { type Chain, foundry } from 'viem/chains';
86
80
 
81
+ import { TestWallet } from '../test-wallet/test_wallet.js';
87
82
  import { MNEMONIC, TEST_MAX_PENDING_TX_POOL_COUNT, TEST_PEER_CHECK_INTERVAL_MS } from './fixtures.js';
88
83
  import { getACVMConfig } from './get_acvm_config.js';
89
84
  import { getBBConfig } from './get_bb_config.js';
@@ -186,6 +181,8 @@ export type SetupOptions = {
186
181
  proverNodeConfig?: Partial<ProverNodeConfig>;
187
182
  /** Whether to use a mock gossip sub network for p2p clients. */
188
183
  mockGossipSubNetwork?: boolean;
184
+ /** Whether to add simulated latency to the mock gossipsub network (in ms) */
185
+ mockGossipSubNetworkLatency?: number;
189
186
  /** Whether to disable the anvil test watcher (can still be manually started) */
190
187
  disableAnvilTestWatcher?: boolean;
191
188
  /** Whether to enable anvil automine during deployment of L1 contracts (consider defaulting this to true). */
@@ -194,6 +191,11 @@ export type SetupOptions = {
194
191
  anvilAccounts?: number;
195
192
  /** Port to start anvil (defaults to 8545) */
196
193
  anvilPort?: number;
194
+ /**
195
+ * Number of slots per epoch for Anvil's finality simulation.
196
+ * Anvil reports `finalized = latest - slotsInAnEpoch * 2`.
197
+ */
198
+ anvilSlotsInAnEpoch?: number;
197
199
  /** Key to use for publishing L1 contracts */
198
200
  l1PublisherKey?: SecretValue<`0x${string}`>;
199
201
  /** ZkPassport configuration (domain, scope, mock verifier) */
@@ -213,13 +215,13 @@ export type EndToEndContext = {
213
215
  /** The Anvil instance (only set if anvil was started locally). */
214
216
  anvil: Anvil | undefined;
215
217
  /** The Aztec Node service or client a connected to it. */
216
- aztecNode: AztecNode;
218
+ aztecNode: AztecNode & AztecNodeDebug;
217
219
  /** The Aztec Node as a service. */
218
220
  aztecNodeService: AztecNodeService;
219
221
  /** Client to the Aztec Node admin interface. */
220
222
  aztecNodeAdmin: AztecNodeAdmin;
221
- /** The prover node service (only set if startProverNode is true) */
222
- proverNode: ProverNode | undefined;
223
+ /** The aztec node running the prover node subsystem (only set if startProverNode is true). */
224
+ proverNode: AztecNodeService | undefined;
223
225
  /** A client to the sequencer service. */
224
226
  sequencer: SequencerClient | undefined;
225
227
  /** Return values from deployAztecL1Contracts function. */
@@ -248,8 +250,12 @@ export type EndToEndContext = {
248
250
  telemetryClient: TelemetryClient;
249
251
  /** Mock gossip sub network used for gossipping messages (only if mockGossipSubNetwork was set to true in opts) */
250
252
  mockGossipSubNetwork: MockGossipSubNetwork | undefined;
251
- /** Prefilled public data used for setting up nodes. */
252
- prefilledPublicData: PublicDataTreeLeaf[] | undefined;
253
+ /** Delayer for sequencer L1 txs (only when enableDelayer is true). */
254
+ sequencerDelayer: Delayer | undefined;
255
+ /** Delayer for prover node L1 txs (only when enableDelayer and startProverNode are true). */
256
+ proverDelayer: Delayer | undefined;
257
+ /** Genesis data used for setting up nodes. */
258
+ genesis: GenesisData | undefined;
253
259
  /** ACVM config (only set if running locally). */
254
260
  acvmConfig: Awaited<ReturnType<typeof getACVMConfig>>;
255
261
  /** BB config (only set if running locally). */
@@ -275,7 +281,7 @@ export async function setup(
275
281
  let anvil: Anvil | undefined;
276
282
  try {
277
283
  opts.aztecTargetCommitteeSize ??= 0;
278
- opts.slasherFlavor ??= 'none';
284
+ opts.slasherEnabled ??= false;
279
285
 
280
286
  const config: AztecNodeConfig & SetupOptions = { ...getConfigEnvVars(), ...opts };
281
287
  // use initialValidators for the node config
@@ -287,8 +293,12 @@ export async function setup(
287
293
  config.realProofs = !!opts.realProofs;
288
294
  // Only enforce the time table if requested
289
295
  config.enforceTimeTable = !!opts.enforceTimeTable;
296
+ // Enable the tx delayer for tests (default config has it disabled, so we force-enable it here)
297
+ config.enableDelayer = true;
290
298
  config.listenAddress = '127.0.0.1';
291
299
 
300
+ config.minTxPoolAgeMs = opts.minTxPoolAgeMs ?? 0;
301
+
292
302
  const logger = getLogger();
293
303
 
294
304
  // Create a temp directory for any services that need it and cleanup later
@@ -298,6 +308,8 @@ export async function setup(
298
308
  config.dataDirectory = directoryToCleanup;
299
309
  }
300
310
 
311
+ const dateProvider = new TestDateProvider();
312
+
301
313
  if (!config.l1RpcUrls?.length) {
302
314
  if (!isAnvilTestChain(chain.id)) {
303
315
  throw new Error(`No ETHEREUM_HOSTS set but non anvil chain requested`);
@@ -306,6 +318,8 @@ export async function setup(
306
318
  l1BlockTime: opts.ethereumSlotDuration,
307
319
  accounts: opts.anvilAccounts,
308
320
  port: opts.anvilPort ?? (process.env.ANVIL_PORT ? parseInt(process.env.ANVIL_PORT) : undefined),
321
+ slotsInAnEpoch: opts.anvilSlotsInAnEpoch,
322
+ dateProvider,
309
323
  });
310
324
  anvil = res.anvil;
311
325
  config.l1RpcUrls = [res.rpcUrl];
@@ -317,8 +331,6 @@ export async function setup(
317
331
  logger.info(`Logging metrics to ${filename}`);
318
332
  setupMetricsLogger(filename);
319
333
  }
320
-
321
- const dateProvider = new TestDateProvider();
322
334
  const ethCheatCodes = new EthCheatCodesWithState(config.l1RpcUrls, dateProvider);
323
335
 
324
336
  if (opts.stateLoad) {
@@ -336,11 +348,11 @@ export async function setup(
336
348
  publisherPrivKeyHex = opts.l1PublisherKey.getValue();
337
349
  publisherHdAccount = privateKeyToAccount(publisherPrivKeyHex);
338
350
  } else if (
339
- config.publisherPrivateKeys &&
340
- config.publisherPrivateKeys.length > 0 &&
341
- config.publisherPrivateKeys[0].getValue() != NULL_KEY
351
+ config.sequencerPublisherPrivateKeys &&
352
+ config.sequencerPublisherPrivateKeys.length > 0 &&
353
+ config.sequencerPublisherPrivateKeys[0].getValue() != NULL_KEY
342
354
  ) {
343
- publisherPrivKeyHex = config.publisherPrivateKeys[0].getValue();
355
+ publisherPrivKeyHex = config.sequencerPublisherPrivateKeys[0].getValue();
344
356
  publisherHdAccount = privateKeyToAccount(publisherPrivKeyHex);
345
357
  } else if (!MNEMONIC) {
346
358
  throw new Error(`Mnemonic not provided and no publisher private key`);
@@ -349,7 +361,7 @@ export async function setup(
349
361
  const publisherPrivKeyRaw = publisherHdAccount.getHdKey().privateKey;
350
362
  const publisherPrivKey = publisherPrivKeyRaw === null ? null : Buffer.from(publisherPrivKeyRaw);
351
363
  publisherPrivKeyHex = `0x${publisherPrivKey!.toString('hex')}` as const;
352
- config.publisherPrivateKeys = [new SecretValue(publisherPrivKeyHex)];
364
+ config.sequencerPublisherPrivateKeys = [new SecretValue(publisherPrivKeyHex)];
353
365
  }
354
366
 
355
367
  if (config.coinbase === undefined) {
@@ -368,10 +380,12 @@ export async function setup(
368
380
  addressesToFund.push(sponsoredFPCAddress);
369
381
  }
370
382
 
371
- const { genesisArchiveRoot, prefilledPublicData, fundingNeeded } = await getGenesisValues(
383
+ const genesisTimestamp = BigInt(Math.floor(Date.now() / 1000));
384
+ const { genesisArchiveRoot, genesis, fundingNeeded } = await getGenesisValues(
372
385
  addressesToFund,
373
386
  opts.initialAccountFeeJuice,
374
387
  opts.genesisPublicData,
388
+ genesisTimestamp,
375
389
  );
376
390
 
377
391
  const wasAutomining = await ethCheatCodes.isAutoMining();
@@ -412,7 +426,13 @@ export async function setup(
412
426
  if (enableAutomine) {
413
427
  await ethCheatCodes.setAutomine(false);
414
428
  await ethCheatCodes.setIntervalMining(config.ethereumSlotDuration);
415
- dateProvider.setTime((await ethCheatCodes.timestamp()) * 1000);
429
+ }
430
+
431
+ // In compose mode (no local anvil), sync dateProvider to L1 time since it may have drifted
432
+ // ahead of system time due to the local-network watcher warping time forward on each filled slot.
433
+ // When running with a local anvil, the dateProvider is kept in sync via the stdout listener.
434
+ if (!anvil) {
435
+ dateProvider.setTime((await ethCheatCodes.lastBlockTimestamp()) * 1000);
416
436
  }
417
437
 
418
438
  if (opts.l2StartTime) {
@@ -451,10 +471,10 @@ export async function setup(
451
471
  }
452
472
 
453
473
  let mockGossipSubNetwork: MockGossipSubNetwork | undefined;
454
- let p2pClientDeps: P2PClientDeps<P2PClientType.Full> | undefined = undefined;
474
+ let p2pClientDeps: P2PClientDeps | undefined = undefined;
455
475
 
456
476
  if (opts.mockGossipSubNetwork) {
457
- mockGossipSubNetwork = new MockGossipSubNetwork();
477
+ mockGossipSubNetwork = new MockGossipSubNetwork(opts.mockGossipSubNetworkLatency);
458
478
  p2pClientDeps = { p2pServiceFactory: getMockPubSubP2PServiceFactory(mockGossipSubNetwork) };
459
479
  }
460
480
 
@@ -483,44 +503,37 @@ export async function setup(
483
503
  }
484
504
 
485
505
  const aztecNodeService = await withLoggerBindings({ actor: 'node-0' }, () =>
486
- AztecNodeService.createAndSync(
487
- config,
488
- { dateProvider, telemetry: telemetryClient, p2pClientDeps },
489
- { prefilledPublicData },
490
- ),
506
+ AztecNodeService.createAndSync(config, { dateProvider, telemetry: telemetryClient, p2pClientDeps }, { genesis }),
491
507
  );
492
508
  const sequencerClient = aztecNodeService.getSequencer();
493
509
 
494
- if (sequencerClient) {
495
- const publisher = (sequencerClient as TestSequencerClient).sequencer.publisher;
496
- publisher.l1TxUtils = DelayedTxUtils.fromL1TxUtils(publisher.l1TxUtils, config.ethereumSlotDuration, l1Client);
497
- }
498
-
499
- let proverNode: ProverNode | undefined = undefined;
510
+ let proverNode: AztecNodeService | undefined = undefined;
500
511
  if (opts.startProverNode) {
501
512
  logger.verbose('Creating and syncing a simulated prover node...');
502
513
  const proverNodePrivateKey = getPrivateKeyFromIndex(2);
503
514
  const proverNodePrivateKeyHex: Hex = `0x${proverNodePrivateKey!.toString('hex')}`;
504
515
  const proverNodeDataDirectory = path.join(directoryToCleanup, randomBytes(8).toString('hex'));
505
- const proverNodeConfig = {
506
- ...config.proverNodeConfig,
507
- dataDirectory: proverNodeDataDirectory,
508
- p2pEnabled: !!mockGossipSubNetwork,
516
+
517
+ const p2pClientDeps: Partial<P2PClientDeps> = {
518
+ p2pServiceFactory: mockGossipSubNetwork && getMockPubSubP2PServiceFactory(mockGossipSubNetwork!),
519
+ rpcTxProviders: [aztecNodeService],
509
520
  };
510
- proverNode = await createAndSyncProverNode(
521
+
522
+ ({ proverNode } = await createAndSyncProverNode(
511
523
  proverNodePrivateKeyHex,
512
524
  config,
513
- proverNodeConfig,
514
- aztecNodeService,
515
- prefilledPublicData,
516
525
  {
517
- p2pClientDeps: mockGossipSubNetwork
518
- ? { p2pServiceFactory: getMockPubSubP2PServiceFactory(mockGossipSubNetwork) }
519
- : undefined,
526
+ ...config.proverNodeConfig,
527
+ dataDirectory: proverNodeDataDirectory,
520
528
  },
521
- );
529
+ { dateProvider, p2pClientDeps, telemetry: telemetryClient },
530
+ { genesis },
531
+ ));
522
532
  }
523
533
 
534
+ const sequencerDelayer = sequencerClient?.getDelayer();
535
+ const proverDelayer = proverNode?.getProverNode()?.getDelayer();
536
+
524
537
  logger.verbose('Creating a pxe...');
525
538
  const pxeConfig = { ...getPXEConfig(), ...pxeOpts };
526
539
  pxeConfig.dataDirectory = path.join(directoryToCleanup, randomBytes(8).toString('hex'));
@@ -619,8 +632,10 @@ export async function setup(
619
632
  initialFundedAccounts,
620
633
  logger,
621
634
  mockGossipSubNetwork,
622
- prefilledPublicData,
635
+ genesis,
623
636
  proverNode,
637
+ sequencerDelayer,
638
+ proverDelayer,
624
639
  sequencer: sequencerClient,
625
640
  teardown,
626
641
  telemetryClient,
@@ -704,93 +719,55 @@ export async function waitForProvenChain(node: AztecNode, targetBlock?: BlockNum
704
719
  );
705
720
  }
706
721
 
722
+ /**
723
+ * Creates an AztecNodeService with the prover node enabled as a subsystem.
724
+ * Returns both the aztec node service (for lifecycle management) and the prover node (for test internals access).
725
+ */
707
726
  export function createAndSyncProverNode(
708
727
  proverNodePrivateKey: `0x${string}`,
709
- aztecNodeConfig: AztecNodeConfig,
710
- proverNodeConfig: Partial<ProverNodeConfig> & Pick<DataStoreConfig, 'dataDirectory'> & { dontStart?: boolean },
711
- aztecNode: AztecNode | undefined,
712
- prefilledPublicData: PublicDataTreeLeaf[] = [],
713
- proverNodeDeps: ProverNodeDeps = {},
714
- ) {
728
+ baseConfig: AztecNodeConfig,
729
+ configOverrides: Pick<AztecNodeConfig, 'dataDirectory'>,
730
+ deps: {
731
+ telemetry?: TelemetryClient;
732
+ dateProvider: DateProvider;
733
+ p2pClientDeps?: P2PClientDeps;
734
+ },
735
+ options: { genesis?: GenesisData; dontStart?: boolean },
736
+ ): Promise<{ proverNode: AztecNodeService }> {
715
737
  return withLoggerBindings({ actor: 'prover-0' }, async () => {
716
- const aztecNodeTxProvider = aztecNode && {
717
- getTxByHash: aztecNode.getTxByHash.bind(aztecNode),
718
- getTxsByHash: aztecNode.getTxsByHash.bind(aztecNode),
719
- stop: () => Promise.resolve(),
720
- };
721
-
722
- const blobClient = await createBlobClientWithFileStores(aztecNodeConfig, createLogger('blob-client:prover-node'));
723
-
724
- const archiverConfig = { ...aztecNodeConfig, dataDirectory: proverNodeConfig.dataDirectory };
725
- const archiver = await createArchiver(
726
- archiverConfig,
727
- { blobClient, dateProvider: proverNodeDeps.dateProvider },
728
- { blockUntilSync: true },
729
- );
730
-
731
- const proverConfig: ProverNodeConfig = {
732
- ...aztecNodeConfig,
733
- txCollectionNodeRpcUrls: [],
734
- realProofs: false,
735
- proverAgentCount: 2,
736
- publisherPrivateKeys: [new SecretValue(proverNodePrivateKey)],
737
- proverNodeMaxPendingJobs: 10,
738
- proverNodeMaxParallelBlocksPerEpoch: 32,
739
- proverNodePollingIntervalMs: 200,
740
- txGatheringIntervalMs: 1000,
741
- txGatheringBatchSize: 10,
742
- txGatheringMaxParallelRequestsPerNode: 10,
743
- txGatheringTimeoutMs: 24_000,
744
- proverNodeFailedEpochStore: undefined,
745
- proverId: EthAddress.fromNumber(1),
746
- proverNodeEpochProvingDelayMs: undefined,
747
- ...proverNodeConfig,
748
- };
749
-
750
- const l1TxUtils = createDelayedL1TxUtils(
751
- aztecNodeConfig,
752
- proverNodePrivateKey,
753
- 'prover-node',
754
- proverNodeDeps.dateProvider,
738
+ const proverNode = await AztecNodeService.createAndSync(
739
+ {
740
+ ...baseConfig,
741
+ ...configOverrides,
742
+ p2pPort: 0,
743
+ enableProverNode: true,
744
+ disableValidator: true,
745
+ proverPublisherPrivateKeys: [new SecretValue(proverNodePrivateKey)],
746
+ },
747
+ deps,
748
+ { genesis: options.genesis, dontStartProverNode: options.dontStart },
755
749
  );
756
750
 
757
- const proverNode = await createProverNode(
758
- proverConfig,
759
- { ...proverNodeDeps, aztecNodeTxProvider, archiver: archiver as Archiver, l1TxUtils },
760
- { prefilledPublicData },
761
- );
762
- getLogger().info(`Created and synced prover node`, { publisherAddress: l1TxUtils.client.account!.address });
763
- if (!proverNodeConfig.dontStart) {
764
- await proverNode.start();
751
+ if (!proverNode.getProverNode()) {
752
+ throw new Error('Prover node subsystem was not created despite enableProverNode being set');
765
753
  }
766
- return proverNode;
767
- });
768
- }
769
754
 
770
- function createDelayedL1TxUtils(
771
- aztecNodeConfig: AztecNodeConfig,
772
- privateKey: `0x${string}`,
773
- logName: string,
774
- dateProvider?: DateProvider,
775
- ) {
776
- const l1Client = createExtendedL1Client(aztecNodeConfig.l1RpcUrls, privateKey, foundry);
777
-
778
- const log = createLogger(logName);
779
- const l1TxUtils = createDelayedL1TxUtilsFromViemWallet(l1Client, log, dateProvider, aztecNodeConfig);
780
- l1TxUtils.enableDelayer(aztecNodeConfig.ethereumSlotDuration);
781
- return l1TxUtils;
755
+ getLogger().info(`Created and synced prover node`);
756
+ return { proverNode };
757
+ });
782
758
  }
783
759
 
784
760
  export type BalancesFn = ReturnType<typeof getBalancesFn>;
785
761
  export function getBalancesFn(
786
762
  symbol: string,
787
763
  method: ContractMethod,
788
- from: AztecAddress,
789
764
  logger: any,
790
765
  ): (...addresses: (AztecAddress | { address: AztecAddress })[]) => Promise<bigint[]> {
791
766
  const balances = async (...addressLikes: (AztecAddress | { address: AztecAddress })[]) => {
792
767
  const addresses = addressLikes.map(addressLike => ('address' in addressLike ? addressLike.address : addressLike));
793
- const b = await Promise.all(addresses.map(address => method(address).simulate({ from })));
768
+ const b = await Promise.all(
769
+ addresses.map(async address => (await method(address).simulate({ from: address })).result),
770
+ );
794
771
  const debugString = `${symbol} balances: ${addresses.map((address, i) => `${address}: ${b[i]}`).join(', ')}`;
795
772
  logger.verbose(debugString);
796
773
  return b;
@@ -859,7 +836,7 @@ export async function ensureAccountContractsPublished(wallet: Wallet, accountsTo
859
836
  * Returns deployed account data that can be used by tests.
860
837
  */
861
838
  export const deployAccounts =
862
- (numberOfAccounts: number, logger: Logger) =>
839
+ (numberOfAccounts: number, logger: Logger, deployOptions?: Partial<DeployOptions<DeployInteractionWaitOptions>>) =>
863
840
  async ({ wallet, initialFundedAccounts }: { wallet: TestWallet; initialFundedAccounts: InitialAccountData[] }) => {
864
841
  if (initialFundedAccounts.length < numberOfAccounts) {
865
842
  throw new Error(`Cannot deploy more than ${initialFundedAccounts.length} initial accounts.`);
@@ -876,8 +853,9 @@ export const deployAccounts =
876
853
  );
877
854
  const deployMethod = await accountManager.getDeployMethod();
878
855
  await deployMethod.send({
879
- from: AztecAddress.ZERO,
856
+ from: NO_FROM,
880
857
  skipClassPublication: i !== 0, // Publish the contract class at most once.
858
+ ...deployOptions,
881
859
  });
882
860
  }
883
861
 
@@ -908,7 +886,7 @@ export async function publicDeployAccounts(
908
886
 
909
887
  const batch = new BatchCall(wallet, calls);
910
888
 
911
- const txReceipt = await batch.send({ from: accountsToDeploy[0] });
889
+ const { receipt: txReceipt } = await batch.send({ from: accountsToDeploy[0] });
912
890
  if (waitUntilProven) {
913
891
  if (!node) {
914
892
  throw new Error('Need to provide an AztecNode to wait for proven.');
@@ -7,8 +7,7 @@ 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
- import type { PublicDataTreeLeaf } from '@aztec/stdlib/trees';
10
+ import type { GenesisData } from '@aztec/stdlib/world-state';
12
11
 
13
12
  import getPort from 'get-port';
14
13
 
@@ -41,7 +40,7 @@ export async function createNodes(
41
40
  bootstrapNodeEnr: string,
42
41
  numNodes: number,
43
42
  bootNodePort: number,
44
- prefilledPublicData?: PublicDataTreeLeaf[],
43
+ genesis?: GenesisData,
45
44
  dataDirectory?: string,
46
45
  metricsPort?: number,
47
46
  indexOffset = 0,
@@ -66,7 +65,7 @@ export async function createNodes(
66
65
  port,
67
66
  bootstrapNodeEnr,
68
67
  validatorIndices,
69
- prefilledPublicData,
68
+ genesis,
70
69
  dataDir,
71
70
  metricsPort,
72
71
  );
@@ -98,7 +97,7 @@ export async function createNode(
98
97
  tcpPort: number,
99
98
  bootstrapNode: string | undefined,
100
99
  addressIndex: number | number[],
101
- prefilledPublicData?: PublicDataTreeLeaf[],
100
+ genesis?: GenesisData,
102
101
  dataDirectory?: string,
103
102
  metricsPort?: number,
104
103
  ) {
@@ -109,7 +108,7 @@ export async function createNode(
109
108
  return await AztecNodeService.createAndSync(
110
109
  validatorConfig,
111
110
  { telemetry, dateProvider },
112
- { prefilledPublicData, dontStartSequencer: config.dontStartSequencer },
111
+ { genesis, dontStartSequencer: config.dontStartSequencer },
113
112
  );
114
113
  });
115
114
  }
@@ -120,7 +119,7 @@ export async function createNonValidatorNode(
120
119
  dateProvider: DateProvider,
121
120
  tcpPort: number,
122
121
  bootstrapNode: string | undefined,
123
- prefilledPublicData?: PublicDataTreeLeaf[],
122
+ genesis?: GenesisData,
124
123
  dataDirectory?: string,
125
124
  metricsPort?: number,
126
125
  ) {
@@ -131,10 +130,10 @@ 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
- return await AztecNodeService.createAndSync(config, { telemetry, dateProvider }, { prefilledPublicData });
136
+ return await AztecNodeService.createAndSync(config, { telemetry, dateProvider }, { genesis });
138
137
  });
139
138
  }
140
139
 
@@ -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'>>,
147
- prefilledPublicData?: PublicDataTreeLeaf[],
145
+ deps: { dateProvider: DateProvider },
146
+ genesis?: GenesisData,
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
+ { genesis },
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;
@@ -8,7 +8,6 @@ export async function deployToken(wallet: Wallet, admin: AztecAddress, initialAd
8
8
  logger.info(`Deploying Token contract...`);
9
9
  const { contract, instance } = await TokenContract.deploy(wallet, admin, 'TokenName', 'TokenSymbol', 18).send({
10
10
  from: admin,
11
- wait: { returnReceipt: true },
12
11
  });
13
12
 
14
13
  if (initialAdminBalance > 0n) {
@@ -25,8 +24,9 @@ export async function mintTokensToPrivate(
25
24
  minter: AztecAddress,
26
25
  recipient: AztecAddress,
27
26
  amount: bigint,
27
+ additionalScopes?: AztecAddress[],
28
28
  ) {
29
- await token.methods.mint_to_private(recipient, amount).send({ from: minter });
29
+ await token.methods.mint_to_private(recipient, amount).send({ from: minter, additionalScopes });
30
30
  }
31
31
 
32
32
  export async function expectTokenBalance(
@@ -38,7 +38,7 @@ export async function expectTokenBalance(
38
38
  ) {
39
39
  // Then check the balance
40
40
  const contractWithWallet = TokenContract.at(token.address, wallet);
41
- const balance = await contractWithWallet.methods.balance_of_private(owner).simulate({ from: owner });
41
+ const { result: balance } = await contractWithWallet.methods.balance_of_private(owner).simulate({ from: owner });
42
42
  logger.info(`Account ${owner} balance: ${balance}`);
43
43
  expect(balance).toBe(expectedBalance);
44
44
  }
@@ -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)