@aztec/end-to-end 0.0.1-commit.e3c1de76 → 0.0.1-commit.e588bc7e5

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 (192) 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 +21 -28
  4. package/dest/bench/client_flows/config.d.ts +2 -2
  5. package/dest/bench/client_flows/config.d.ts.map +1 -1
  6. package/dest/bench/client_flows/config.js +18 -0
  7. package/dest/bench/utils.d.ts +1 -1
  8. package/dest/bench/utils.d.ts.map +1 -1
  9. package/dest/bench/utils.js +6 -3
  10. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +4 -2
  11. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts.map +1 -1
  12. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.js +22 -12
  13. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +2 -2
  14. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts.map +1 -1
  15. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.js +3 -2
  16. package/dest/e2e_deploy_contract/deploy_test.d.ts +2 -2
  17. package/dest/e2e_deploy_contract/deploy_test.d.ts.map +1 -1
  18. package/dest/e2e_epochs/epochs_test.d.ts +11 -7
  19. package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
  20. package/dest/e2e_epochs/epochs_test.js +62 -34
  21. package/dest/e2e_fees/fees_test.d.ts +2 -2
  22. package/dest/e2e_fees/fees_test.d.ts.map +1 -1
  23. package/dest/e2e_fees/fees_test.js +18 -11
  24. package/dest/e2e_nested_contract/nested_contract_test.d.ts +1 -1
  25. package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +1 -1
  26. package/dest/e2e_nested_contract/nested_contract_test.js +4 -6
  27. package/dest/e2e_p2p/inactivity_slash_test.js +1 -1
  28. package/dest/e2e_p2p/p2p_network.d.ts +5 -4
  29. package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
  30. package/dest/e2e_p2p/p2p_network.js +24 -7
  31. package/dest/e2e_p2p/reqresp/utils.d.ts +3 -3
  32. package/dest/e2e_p2p/reqresp/utils.d.ts.map +1 -1
  33. package/dest/e2e_p2p/reqresp/utils.js +45 -8
  34. package/dest/e2e_p2p/shared.d.ts +22 -2
  35. package/dest/e2e_p2p/shared.d.ts.map +1 -1
  36. package/dest/e2e_p2p/shared.js +38 -3
  37. package/dest/e2e_storage_proof/fixtures/storage_proof_fetcher.d.ts +2 -0
  38. package/dest/e2e_storage_proof/fixtures/storage_proof_fetcher.d.ts.map +1 -0
  39. package/dest/e2e_storage_proof/fixtures/storage_proof_fetcher.js +184 -0
  40. package/dest/e2e_storage_proof/fixtures/storage_proof_fixture.d.ts +18 -0
  41. package/dest/e2e_storage_proof/fixtures/storage_proof_fixture.d.ts.map +1 -0
  42. package/dest/e2e_storage_proof/fixtures/storage_proof_fixture.js +120 -0
  43. package/dest/e2e_token_contract/token_contract_test.d.ts +4 -2
  44. package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -1
  45. package/dest/e2e_token_contract/token_contract_test.js +19 -9
  46. package/dest/fixtures/authwit_proxy.d.ts +15 -0
  47. package/dest/fixtures/authwit_proxy.d.ts.map +1 -0
  48. package/dest/fixtures/authwit_proxy.js +30 -0
  49. package/dest/fixtures/e2e_prover_test.d.ts +7 -6
  50. package/dest/fixtures/e2e_prover_test.d.ts.map +1 -1
  51. package/dest/fixtures/e2e_prover_test.js +36 -48
  52. package/dest/fixtures/elu_monitor.d.ts +21 -0
  53. package/dest/fixtures/elu_monitor.d.ts.map +1 -0
  54. package/dest/fixtures/elu_monitor.js +102 -0
  55. package/dest/fixtures/fixtures.d.ts +5 -1
  56. package/dest/fixtures/fixtures.d.ts.map +1 -1
  57. package/dest/fixtures/fixtures.js +6 -0
  58. package/dest/fixtures/get_bb_config.d.ts +1 -1
  59. package/dest/fixtures/get_bb_config.d.ts.map +1 -1
  60. package/dest/fixtures/get_bb_config.js +5 -5
  61. package/dest/fixtures/ha_setup.d.ts +71 -0
  62. package/dest/fixtures/ha_setup.d.ts.map +1 -0
  63. package/dest/fixtures/ha_setup.js +116 -0
  64. package/dest/fixtures/index.d.ts +2 -1
  65. package/dest/fixtures/index.d.ts.map +1 -1
  66. package/dest/fixtures/index.js +1 -0
  67. package/dest/fixtures/setup.d.ts +44 -23
  68. package/dest/fixtures/setup.d.ts.map +1 -1
  69. package/dest/fixtures/setup.js +70 -156
  70. package/dest/fixtures/setup_p2p_test.d.ts +15 -7
  71. package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
  72. package/dest/fixtures/setup_p2p_test.js +18 -12
  73. package/dest/fixtures/token_utils.d.ts +2 -2
  74. package/dest/fixtures/token_utils.d.ts.map +1 -1
  75. package/dest/fixtures/token_utils.js +5 -7
  76. package/dest/shared/cross_chain_test_harness.d.ts +1 -1
  77. package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
  78. package/dest/shared/cross_chain_test_harness.js +13 -13
  79. package/dest/shared/gas_portal_test_harness.js +2 -2
  80. package/dest/shared/index.d.ts +2 -1
  81. package/dest/shared/index.d.ts.map +1 -1
  82. package/dest/shared/index.js +1 -0
  83. package/dest/shared/jest_setup.js +41 -1
  84. package/dest/shared/mock_state_view.d.ts +86 -0
  85. package/dest/shared/mock_state_view.d.ts.map +1 -0
  86. package/dest/shared/mock_state_view.js +186 -0
  87. package/dest/shared/submit-transactions.d.ts +2 -2
  88. package/dest/shared/submit-transactions.d.ts.map +1 -1
  89. package/dest/shared/submit-transactions.js +1 -1
  90. package/dest/shared/uniswap_l1_l2.d.ts +1 -1
  91. package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
  92. package/dest/shared/uniswap_l1_l2.js +16 -17
  93. package/dest/simulators/lending_simulator.d.ts +1 -1
  94. package/dest/simulators/lending_simulator.d.ts.map +1 -1
  95. package/dest/simulators/lending_simulator.js +4 -4
  96. package/dest/simulators/token_simulator.d.ts +1 -1
  97. package/dest/simulators/token_simulator.d.ts.map +1 -1
  98. package/dest/simulators/token_simulator.js +3 -24
  99. package/dest/spartan/setup_test_wallets.d.ts +12 -3
  100. package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
  101. package/dest/spartan/setup_test_wallets.js +110 -18
  102. package/dest/spartan/tx_metrics.js +1 -1
  103. package/dest/spartan/utils/bot.d.ts +3 -2
  104. package/dest/spartan/utils/bot.d.ts.map +1 -1
  105. package/dest/spartan/utils/bot.js +2 -1
  106. package/dest/spartan/utils/config.d.ts +10 -1
  107. package/dest/spartan/utils/config.d.ts.map +1 -1
  108. package/dest/spartan/utils/config.js +4 -1
  109. package/dest/spartan/utils/index.d.ts +5 -3
  110. package/dest/spartan/utils/index.d.ts.map +1 -1
  111. package/dest/spartan/utils/index.js +5 -1
  112. package/dest/spartan/utils/k8s.d.ts +3 -1
  113. package/dest/spartan/utils/k8s.d.ts.map +1 -1
  114. package/dest/spartan/utils/k8s.js +6 -0
  115. package/dest/spartan/utils/nodes.d.ts +4 -5
  116. package/dest/spartan/utils/nodes.d.ts.map +1 -1
  117. package/dest/spartan/utils/nodes.js +9 -9
  118. package/dest/spartan/utils/pod_logs.d.ts +25 -0
  119. package/dest/spartan/utils/pod_logs.d.ts.map +1 -0
  120. package/dest/spartan/utils/pod_logs.js +74 -0
  121. package/dest/spartan/utils/scripts.d.ts +18 -4
  122. package/dest/spartan/utils/scripts.d.ts.map +1 -1
  123. package/dest/spartan/utils/scripts.js +19 -4
  124. package/dest/test-wallet/test_wallet.d.ts +76 -0
  125. package/dest/test-wallet/test_wallet.d.ts.map +1 -0
  126. package/dest/test-wallet/test_wallet.js +213 -0
  127. package/dest/test-wallet/utils.d.ts +41 -0
  128. package/dest/test-wallet/utils.d.ts.map +1 -0
  129. package/dest/test-wallet/utils.js +71 -0
  130. package/dest/test-wallet/wallet_worker_script.d.ts +2 -0
  131. package/dest/test-wallet/wallet_worker_script.d.ts.map +1 -0
  132. package/dest/test-wallet/wallet_worker_script.js +48 -0
  133. package/dest/test-wallet/worker_wallet.d.ts +52 -0
  134. package/dest/test-wallet/worker_wallet.d.ts.map +1 -0
  135. package/dest/test-wallet/worker_wallet.js +151 -0
  136. package/dest/test-wallet/worker_wallet_schema.d.ts +274 -0
  137. package/dest/test-wallet/worker_wallet_schema.d.ts.map +1 -0
  138. package/dest/test-wallet/worker_wallet_schema.js +10 -0
  139. package/package.json +45 -43
  140. package/src/bench/client_flows/client_flows_benchmark.ts +30 -17
  141. package/src/bench/client_flows/config.ts +9 -1
  142. package/src/bench/utils.ts +8 -3
  143. package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +28 -15
  144. package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +7 -8
  145. package/src/e2e_deploy_contract/deploy_test.ts +3 -3
  146. package/src/e2e_epochs/epochs_test.ts +83 -61
  147. package/src/e2e_fees/bridging_race.notest.ts +1 -1
  148. package/src/e2e_fees/fees_test.ts +20 -28
  149. package/src/e2e_nested_contract/nested_contract_test.ts +7 -5
  150. package/src/e2e_p2p/inactivity_slash_test.ts +5 -5
  151. package/src/e2e_p2p/p2p_network.ts +36 -10
  152. package/src/e2e_p2p/reqresp/utils.ts +61 -12
  153. package/src/e2e_p2p/shared.ts +58 -3
  154. package/src/e2e_storage_proof/fixtures/storage_proof.json +915 -0
  155. package/src/e2e_storage_proof/fixtures/storage_proof_fetcher.ts +190 -0
  156. package/src/e2e_storage_proof/fixtures/storage_proof_fixture.ts +173 -0
  157. package/src/e2e_token_contract/token_contract_test.ts +26 -9
  158. package/src/fixtures/authwit_proxy.ts +50 -0
  159. package/src/fixtures/dumps/epoch_proof_result.json +1 -1
  160. package/src/fixtures/e2e_prover_test.ts +42 -54
  161. package/src/fixtures/elu_monitor.ts +126 -0
  162. package/src/fixtures/fixtures.ts +10 -0
  163. package/src/fixtures/get_bb_config.ts +7 -6
  164. package/src/fixtures/ha_setup.ts +186 -0
  165. package/src/fixtures/index.ts +1 -0
  166. package/src/fixtures/setup.ts +106 -217
  167. package/src/fixtures/setup_p2p_test.ts +25 -24
  168. package/src/fixtures/token_utils.ts +3 -3
  169. package/src/guides/up_quick_start.sh +3 -3
  170. package/src/shared/cross_chain_test_harness.ts +13 -9
  171. package/src/shared/gas_portal_test_harness.ts +1 -1
  172. package/src/shared/index.ts +1 -0
  173. package/src/shared/jest_setup.ts +51 -1
  174. package/src/shared/mock_state_view.ts +188 -0
  175. package/src/shared/submit-transactions.ts +3 -2
  176. package/src/shared/uniswap_l1_l2.ts +38 -33
  177. package/src/simulators/lending_simulator.ts +8 -4
  178. package/src/simulators/token_simulator.ts +6 -30
  179. package/src/spartan/setup_test_wallets.ts +148 -13
  180. package/src/spartan/tx_metrics.ts +1 -1
  181. package/src/spartan/utils/bot.ts +4 -1
  182. package/src/spartan/utils/config.ts +3 -0
  183. package/src/spartan/utils/index.ts +8 -1
  184. package/src/spartan/utils/k8s.ts +8 -0
  185. package/src/spartan/utils/nodes.ts +15 -10
  186. package/src/spartan/utils/pod_logs.ts +99 -0
  187. package/src/spartan/utils/scripts.ts +43 -7
  188. package/src/test-wallet/test_wallet.ts +301 -0
  189. package/src/test-wallet/utils.ts +112 -0
  190. package/src/test-wallet/wallet_worker_script.ts +60 -0
  191. package/src/test-wallet/worker_wallet.ts +213 -0
  192. package/src/test-wallet/worker_wallet_schema.ts +13 -0
@@ -1,7 +1,7 @@
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';
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,
@@ -13,10 +13,9 @@ import {
13
13
  import { publishContractClass, publishInstance } from '@aztec/aztec.js/deployment';
14
14
  import { Fr } from '@aztec/aztec.js/fields';
15
15
  import { type Logger, createLogger } from '@aztec/aztec.js/log';
16
- import { type AztecNode, createAztecNodeClient, waitForNode } from '@aztec/aztec.js/node';
16
+ import type { AztecNode } from '@aztec/aztec.js/node';
17
17
  import type { Wallet } from '@aztec/aztec.js/wallet';
18
18
  import { AnvilTestWatcher, CheatCodes } from '@aztec/aztec/testing';
19
- import { createBlobClientWithFileStores } from '@aztec/blob-client/client';
20
19
  import { SPONSORED_FPC_SALT } from '@aztec/constants';
21
20
  import { isAnvilTestChain } from '@aztec/ethereum/chain';
22
21
  import { createExtendedL1Client } from '@aztec/ethereum/client';
@@ -30,13 +29,9 @@ import {
30
29
  type ZKPassportArgs,
31
30
  deployAztecL1Contracts,
32
31
  } from '@aztec/ethereum/deploy-aztec-l1-contracts';
33
- import {
34
- DelayedTxUtils,
35
- EthCheatCodes,
36
- EthCheatCodesWithState,
37
- createDelayedL1TxUtilsFromViemWallet,
38
- startAnvil,
39
- } from '@aztec/ethereum/test';
32
+ import type { Delayer } from '@aztec/ethereum/l1-tx-utils';
33
+ import { EthCheatCodes, EthCheatCodesWithState, startAnvil } from '@aztec/ethereum/test';
34
+ import type { Anvil } from '@aztec/ethereum/test';
40
35
  import { BlockNumber, EpochNumber } from '@aztec/foundation/branded-types';
41
36
  import { SecretValue } from '@aztec/foundation/config';
42
37
  import { randomBytes } from '@aztec/foundation/crypto/random';
@@ -45,20 +40,17 @@ import { withLoggerBindings } from '@aztec/foundation/log/server';
45
40
  import { retryUntil } from '@aztec/foundation/retry';
46
41
  import { sleep } from '@aztec/foundation/sleep';
47
42
  import { DateProvider, TestDateProvider } from '@aztec/foundation/timer';
48
- import type { DataStoreConfig } from '@aztec/kv-store/config';
49
43
  import { SponsoredFPCContract } from '@aztec/noir-contracts.js/SponsoredFPC';
50
44
  import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
51
45
  import type { P2PClientDeps } from '@aztec/p2p';
52
46
  import { MockGossipSubNetwork, getMockPubSubP2PServiceFactory } from '@aztec/p2p/test-helpers';
53
47
  import { protocolContractsHash } from '@aztec/protocol-contracts';
54
- import { type ProverNode, type ProverNodeConfig, type ProverNodeDeps, createProverNode } from '@aztec/prover-node';
48
+ import type { ProverNodeConfig } from '@aztec/prover-node';
55
49
  import { type PXEConfig, getPXEConfig } from '@aztec/pxe/server';
56
50
  import type { SequencerClient } from '@aztec/sequencer-client';
57
- import type { TestSequencerClient } from '@aztec/sequencer-client/test';
58
51
  import { type ContractInstanceWithAddress, getContractInstanceFromInstantiationParams } from '@aztec/stdlib/contract';
59
52
  import type { AztecNodeAdmin } from '@aztec/stdlib/interfaces/client';
60
53
  import { tryStop } from '@aztec/stdlib/interfaces/server';
61
- import type { P2PClientType } from '@aztec/stdlib/p2p';
62
54
  import type { PublicDataTreeLeaf } from '@aztec/stdlib/trees';
63
55
  import {
64
56
  type TelemetryClient,
@@ -67,10 +59,9 @@ import {
67
59
  initTelemetryClient,
68
60
  } from '@aztec/telemetry-client';
69
61
  import { BenchmarkTelemetryClient } from '@aztec/telemetry-client/bench';
70
- import { TestWallet, deployFundedSchnorrAccounts } from '@aztec/test-wallet/server';
62
+ import { deployFundedSchnorrAccounts } from '@aztec/wallets/testing';
71
63
  import { getGenesisValues } from '@aztec/world-state/testing';
72
64
 
73
- import type { Anvil } from '@viem/anvil';
74
65
  import fs from 'fs/promises';
75
66
  import { tmpdir } from 'os';
76
67
  import path from 'path';
@@ -84,6 +75,7 @@ import {
84
75
  } from 'viem/accounts';
85
76
  import { type Chain, foundry } from 'viem/chains';
86
77
 
78
+ import { TestWallet } from '../test-wallet/test_wallet.js';
87
79
  import { MNEMONIC, TEST_MAX_PENDING_TX_POOL_COUNT, TEST_PEER_CHECK_INTERVAL_MS } from './fixtures.js';
88
80
  import { getACVMConfig } from './get_acvm_config.js';
89
81
  import { getBBConfig } from './get_bb_config.js';
@@ -92,9 +84,6 @@ import { getEndToEndTestTelemetryClient } from './with_telemetry_utils.js';
92
84
 
93
85
  export { startAnvil };
94
86
 
95
- const { AZTEC_NODE_URL = '' } = process.env;
96
- const getAztecUrl = () => AZTEC_NODE_URL;
97
-
98
87
  let telemetry: TelemetryClient | undefined = undefined;
99
88
  async function getTelemetryClient(partialConfig: Partial<TelemetryClientConfig> & { benchmark?: boolean } = {}) {
100
89
  if (!telemetry) {
@@ -197,6 +186,11 @@ export type SetupOptions = {
197
186
  anvilAccounts?: number;
198
187
  /** Port to start anvil (defaults to 8545) */
199
188
  anvilPort?: number;
189
+ /**
190
+ * Number of slots per epoch for Anvil's finality simulation.
191
+ * Anvil reports `finalized = latest - slotsInAnEpoch * 2`.
192
+ */
193
+ anvilSlotsInAnEpoch?: number;
200
194
  /** Key to use for publishing L1 contracts */
201
195
  l1PublisherKey?: SecretValue<`0x${string}`>;
202
196
  /** ZkPassport configuration (domain, scope, mock verifier) */
@@ -217,13 +211,13 @@ export type EndToEndContext = {
217
211
  anvil: Anvil | undefined;
218
212
  /** The Aztec Node service or client a connected to it. */
219
213
  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) */
214
+ /** The Aztec Node as a service. */
215
+ aztecNodeService: AztecNodeService;
216
+ /** Client to the Aztec Node admin interface. */
217
+ aztecNodeAdmin: AztecNodeAdmin;
218
+ /** The aztec node running the prover node subsystem (only set if startProverNode is true). */
219
+ proverNode: AztecNodeService | undefined;
220
+ /** A client to the sequencer service. */
227
221
  sequencer: SequencerClient | undefined;
228
222
  /** Return values from deployAztecL1Contracts function. */
229
223
  deployL1ContractsValues: DeployAztecL1ContractsReturnType;
@@ -243,14 +237,18 @@ export type EndToEndContext = {
243
237
  cheatCodes: CheatCodes;
244
238
  /** The cheat codes for L1 */
245
239
  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;
240
+ /** The anvil test watcher. */
241
+ watcher: AnvilTestWatcher;
242
+ /** Allows tweaking current system time, used by the epoch cache only. */
243
+ dateProvider: TestDateProvider;
250
244
  /** Telemetry client */
251
- telemetryClient: TelemetryClient | undefined;
245
+ telemetryClient: TelemetryClient;
252
246
  /** Mock gossip sub network used for gossipping messages (only if mockGossipSubNetwork was set to true in opts) */
253
247
  mockGossipSubNetwork: MockGossipSubNetwork | undefined;
248
+ /** Delayer for sequencer L1 txs (only when enableDelayer is true). */
249
+ sequencerDelayer: Delayer | undefined;
250
+ /** Delayer for prover node L1 txs (only when enableDelayer and startProverNode are true). */
251
+ proverDelayer: Delayer | undefined;
254
252
  /** Prefilled public data used for setting up nodes. */
255
253
  prefilledPublicData: PublicDataTreeLeaf[] | undefined;
256
254
  /** ACVM config (only set if running locally). */
@@ -258,87 +256,11 @@ export type EndToEndContext = {
258
256
  /** BB config (only set if running locally). */
259
257
  bbConfig: Awaited<ReturnType<typeof getBBConfig>>;
260
258
  /** Directory to cleanup on teardown. */
261
- directoryToCleanup: string | undefined;
259
+ directoryToCleanup: string;
262
260
  /** Function to stop the started services. */
263
261
  teardown: () => Promise<void>;
264
262
  };
265
263
 
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
264
  /**
343
265
  * Sets up the environment for the end-to-end tests.
344
266
  * @param numberOfAccounts - The number of new accounts to be created once the PXE is initiated.
@@ -366,8 +288,12 @@ export async function setup(
366
288
  config.realProofs = !!opts.realProofs;
367
289
  // Only enforce the time table if requested
368
290
  config.enforceTimeTable = !!opts.enforceTimeTable;
291
+ // Enable the tx delayer for tests (default config has it disabled, so we force-enable it here)
292
+ config.enableDelayer = true;
369
293
  config.listenAddress = '127.0.0.1';
370
294
 
295
+ config.minTxPoolAgeMs = opts.minTxPoolAgeMs ?? 0;
296
+
371
297
  const logger = getLogger();
372
298
 
373
299
  // Create a temp directory for any services that need it and cleanup later
@@ -377,20 +303,18 @@ export async function setup(
377
303
  config.dataDirectory = directoryToCleanup;
378
304
  }
379
305
 
306
+ const dateProvider = new TestDateProvider();
307
+
380
308
  if (!config.l1RpcUrls?.length) {
381
309
  if (!isAnvilTestChain(chain.id)) {
382
310
  throw new Error(`No ETHEREUM_HOSTS set but non anvil chain requested`);
383
311
  }
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
312
  const res = await startAnvil({
391
313
  l1BlockTime: opts.ethereumSlotDuration,
392
314
  accounts: opts.anvilAccounts,
393
315
  port: opts.anvilPort ?? (process.env.ANVIL_PORT ? parseInt(process.env.ANVIL_PORT) : undefined),
316
+ slotsInAnEpoch: opts.anvilSlotsInAnEpoch,
317
+ dateProvider,
394
318
  });
395
319
  anvil = res.anvil;
396
320
  config.l1RpcUrls = [res.rpcUrl];
@@ -402,8 +326,6 @@ export async function setup(
402
326
  logger.info(`Logging metrics to ${filename}`);
403
327
  setupMetricsLogger(filename);
404
328
  }
405
-
406
- const dateProvider = new TestDateProvider();
407
329
  const ethCheatCodes = new EthCheatCodesWithState(config.l1RpcUrls, dateProvider);
408
330
 
409
331
  if (opts.stateLoad) {
@@ -421,11 +343,11 @@ export async function setup(
421
343
  publisherPrivKeyHex = opts.l1PublisherKey.getValue();
422
344
  publisherHdAccount = privateKeyToAccount(publisherPrivKeyHex);
423
345
  } else if (
424
- config.publisherPrivateKeys &&
425
- config.publisherPrivateKeys.length > 0 &&
426
- config.publisherPrivateKeys[0].getValue() != NULL_KEY
346
+ config.sequencerPublisherPrivateKeys &&
347
+ config.sequencerPublisherPrivateKeys.length > 0 &&
348
+ config.sequencerPublisherPrivateKeys[0].getValue() != NULL_KEY
427
349
  ) {
428
- publisherPrivKeyHex = config.publisherPrivateKeys[0].getValue();
350
+ publisherPrivKeyHex = config.sequencerPublisherPrivateKeys[0].getValue();
429
351
  publisherHdAccount = privateKeyToAccount(publisherPrivKeyHex);
430
352
  } else if (!MNEMONIC) {
431
353
  throw new Error(`Mnemonic not provided and no publisher private key`);
@@ -434,18 +356,13 @@ export async function setup(
434
356
  const publisherPrivKeyRaw = publisherHdAccount.getHdKey().privateKey;
435
357
  const publisherPrivKey = publisherPrivKeyRaw === null ? null : Buffer.from(publisherPrivKeyRaw);
436
358
  publisherPrivKeyHex = `0x${publisherPrivKey!.toString('hex')}` as const;
437
- config.publisherPrivateKeys = [new SecretValue(publisherPrivKeyHex)];
359
+ config.sequencerPublisherPrivateKeys = [new SecretValue(publisherPrivKeyHex)];
438
360
  }
439
361
 
440
362
  if (config.coinbase === undefined) {
441
363
  config.coinbase = EthAddress.fromString(publisherHdAccount.address);
442
364
  }
443
365
 
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
366
  // Determine which addresses to fund in genesis
450
367
  const initialFundedAccounts =
451
368
  opts.initialFundedAccounts ??
@@ -502,7 +419,13 @@ export async function setup(
502
419
  if (enableAutomine) {
503
420
  await ethCheatCodes.setAutomine(false);
504
421
  await ethCheatCodes.setIntervalMining(config.ethereumSlotDuration);
505
- dateProvider.setTime((await ethCheatCodes.timestamp()) * 1000);
422
+ }
423
+
424
+ // In compose mode (no local anvil), sync dateProvider to L1 time since it may have drifted
425
+ // ahead of system time due to the local-network watcher warping time forward on each filled slot.
426
+ // When running with a local anvil, the dateProvider is kept in sync via the stdout listener.
427
+ if (!anvil) {
428
+ dateProvider.setTime((await ethCheatCodes.lastBlockTimestamp()) * 1000);
506
429
  }
507
430
 
508
431
  if (opts.l2StartTime) {
@@ -541,7 +464,7 @@ export async function setup(
541
464
  }
542
465
 
543
466
  let mockGossipSubNetwork: MockGossipSubNetwork | undefined;
544
- let p2pClientDeps: P2PClientDeps<P2PClientType.Full> | undefined = undefined;
467
+ let p2pClientDeps: P2PClientDeps | undefined = undefined;
545
468
 
546
469
  if (opts.mockGossipSubNetwork) {
547
470
  mockGossipSubNetwork = new MockGossipSubNetwork();
@@ -581,31 +504,33 @@ export async function setup(
581
504
  );
582
505
  const sequencerClient = aztecNodeService.getSequencer();
583
506
 
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;
507
+ let proverNode: AztecNodeService | undefined = undefined;
590
508
  if (opts.startProverNode) {
591
509
  logger.verbose('Creating and syncing a simulated prover node...');
592
510
  const proverNodePrivateKey = getPrivateKeyFromIndex(2);
593
511
  const proverNodePrivateKeyHex: Hex = `0x${proverNodePrivateKey!.toString('hex')}`;
594
512
  const proverNodeDataDirectory = path.join(directoryToCleanup, randomBytes(8).toString('hex'));
595
- const proverNodeConfig = {
596
- ...config.proverNodeConfig,
597
- dataDirectory: proverNodeDataDirectory,
598
- p2pEnabled: false,
513
+
514
+ const p2pClientDeps: Partial<P2PClientDeps> = {
515
+ p2pServiceFactory: mockGossipSubNetwork && getMockPubSubP2PServiceFactory(mockGossipSubNetwork!),
516
+ rpcTxProviders: [aztecNodeService],
599
517
  };
600
- proverNode = await createAndSyncProverNode(
518
+
519
+ ({ proverNode } = await createAndSyncProverNode(
601
520
  proverNodePrivateKeyHex,
602
521
  config,
603
- proverNodeConfig,
604
- aztecNodeService,
605
- prefilledPublicData,
606
- );
522
+ {
523
+ ...config.proverNodeConfig,
524
+ dataDirectory: proverNodeDataDirectory,
525
+ },
526
+ { dateProvider, p2pClientDeps, telemetry: telemetryClient },
527
+ { prefilledPublicData },
528
+ ));
607
529
  }
608
530
 
531
+ const sequencerDelayer = sequencerClient?.getDelayer();
532
+ const proverDelayer = proverNode?.getProverNode()?.getDelayer();
533
+
609
534
  logger.verbose('Creating a pxe...');
610
535
  const pxeConfig = { ...getPXEConfig(), ...pxeOpts };
611
536
  pxeConfig.dataDirectory = path.join(directoryToCleanup, randomBytes(8).toString('hex'));
@@ -683,7 +608,7 @@ export async function setup(
683
608
  logger.error(`Error during e2e test teardown`, err);
684
609
  } finally {
685
610
  try {
686
- await telemetryClient?.stop();
611
+ await telemetryClient.stop();
687
612
  } catch (err) {
688
613
  logger.error(`Error during telemetry client stop`, err);
689
614
  }
@@ -706,6 +631,8 @@ export async function setup(
706
631
  mockGossipSubNetwork,
707
632
  prefilledPublicData,
708
633
  proverNode,
634
+ sequencerDelayer,
635
+ proverDelayer,
709
636
  sequencer: sequencerClient,
710
637
  teardown,
711
638
  telemetryClient,
@@ -789,93 +716,55 @@ export async function waitForProvenChain(node: AztecNode, targetBlock?: BlockNum
789
716
  );
790
717
  }
791
718
 
719
+ /**
720
+ * Creates an AztecNodeService with the prover node enabled as a subsystem.
721
+ * Returns both the aztec node service (for lifecycle management) and the prover node (for test internals access).
722
+ */
792
723
  export function createAndSyncProverNode(
793
724
  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
- ) {
725
+ baseConfig: AztecNodeConfig,
726
+ configOverrides: Pick<AztecNodeConfig, 'dataDirectory'>,
727
+ deps: {
728
+ telemetry?: TelemetryClient;
729
+ dateProvider: DateProvider;
730
+ p2pClientDeps?: P2PClientDeps;
731
+ },
732
+ options: { prefilledPublicData: PublicDataTreeLeaf[]; dontStart?: boolean },
733
+ ): Promise<{ proverNode: AztecNodeService }> {
800
734
  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,
735
+ const proverNode = await AztecNodeService.createAndSync(
736
+ {
737
+ ...baseConfig,
738
+ ...configOverrides,
739
+ p2pPort: 0,
740
+ enableProverNode: true,
741
+ disableValidator: true,
742
+ proverPublisherPrivateKeys: [new SecretValue(proverNodePrivateKey)],
743
+ },
744
+ deps,
745
+ { ...options, dontStartProverNode: options.dontStart },
840
746
  );
841
747
 
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();
748
+ if (!proverNode.getProverNode()) {
749
+ throw new Error('Prover node subsystem was not created despite enableProverNode being set');
850
750
  }
851
- return proverNode;
852
- });
853
- }
854
751
 
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
-
863
- const log = createLogger(logName);
864
- const l1TxUtils = createDelayedL1TxUtilsFromViemWallet(l1Client, log, dateProvider, aztecNodeConfig);
865
- l1TxUtils.enableDelayer(aztecNodeConfig.ethereumSlotDuration);
866
- return l1TxUtils;
752
+ getLogger().info(`Created and synced prover node`);
753
+ return { proverNode };
754
+ });
867
755
  }
868
756
 
869
757
  export type BalancesFn = ReturnType<typeof getBalancesFn>;
870
758
  export function getBalancesFn(
871
759
  symbol: string,
872
760
  method: ContractMethod,
873
- from: AztecAddress,
874
761
  logger: any,
875
762
  ): (...addresses: (AztecAddress | { address: AztecAddress })[]) => Promise<bigint[]> {
876
763
  const balances = async (...addressLikes: (AztecAddress | { address: AztecAddress })[]) => {
877
764
  const addresses = addressLikes.map(addressLike => ('address' in addressLike ? addressLike.address : addressLike));
878
- const b = await Promise.all(addresses.map(address => method(address).simulate({ from })));
765
+ const b = await Promise.all(
766
+ addresses.map(async address => (await method(address).simulate({ from: address })).result),
767
+ );
879
768
  const debugString = `${symbol} balances: ${addresses.map((address, i) => `${address}: ${b[i]}`).join(', ')}`;
880
769
  logger.verbose(debugString);
881
770
  return b;
@@ -961,7 +850,7 @@ export const deployAccounts =
961
850
  );
962
851
  const deployMethod = await accountManager.getDeployMethod();
963
852
  await deployMethod.send({
964
- from: AztecAddress.ZERO,
853
+ from: NO_FROM,
965
854
  skipClassPublication: i !== 0, // Publish the contract class at most once.
966
855
  });
967
856
  }
@@ -993,7 +882,7 @@ export async function publicDeployAccounts(
993
882
 
994
883
  const batch = new BatchCall(wallet, calls);
995
884
 
996
- const txReceipt = await batch.send({ from: accountsToDeploy[0] });
885
+ const { receipt: txReceipt } = await batch.send({ from: accountsToDeploy[0] });
997
886
  if (waitUntilProven) {
998
887
  if (!node) {
999
888
  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';
@@ -83,9 +82,17 @@ export async function createNodes(
83
82
  return nodes;
84
83
  }
85
84
 
86
- /** Creates a P2P enabled instance of Aztec Node Service with a validator */
85
+ /** Extended config type for createNode with test-specific overrides. */
86
+ export type CreateNodeConfig = AztecNodeConfig & {
87
+ /** Whether to skip starting the sequencer. */
88
+ dontStartSequencer?: boolean;
89
+ /** Override the private key (instead of deriving from addressIndex). */
90
+ validatorPrivateKey?: `0x${string}`;
91
+ };
92
+
93
+ /** Creates a P2P enabled instance of Aztec Node Service with a validator. */
87
94
  export async function createNode(
88
- config: AztecNodeConfig & { dontStartSequencer?: boolean },
95
+ config: CreateNodeConfig,
89
96
  dateProvider: DateProvider,
90
97
  tcpPort: number,
91
98
  bootstrapNode: string | undefined,
@@ -123,7 +130,7 @@ export async function createNonValidatorNode(
123
130
  ...p2pConfig,
124
131
  disableValidator: true,
125
132
  validatorPrivateKeys: undefined,
126
- publisherPrivateKeys: [],
133
+ sequencerPublisherPrivateKeys: [],
127
134
  };
128
135
  const telemetry = await getEndToEndTestTelemetryClient(metricsPort);
129
136
  return await AztecNodeService.createAndSync(config, { telemetry, dateProvider }, { prefilledPublicData });
@@ -135,31 +142,24 @@ export async function createProverNode(
135
142
  tcpPort: number,
136
143
  bootstrapNode: string | undefined,
137
144
  addressIndex: number,
138
- proverNodeDeps: ProverNodeDeps & Required<Pick<ProverNodeDeps, 'dateProvider'>>,
145
+ deps: { dateProvider: DateProvider },
139
146
  prefilledPublicData?: PublicDataTreeLeaf[],
140
147
  dataDirectory?: string,
141
148
  metricsPort?: number,
142
- ) {
149
+ ): Promise<{ proverNode: AztecNodeService }> {
143
150
  const actorIndex = proverCounter++;
144
151
  return await withLoggerBindings({ actor: `prover-${actorIndex}` }, async () => {
145
152
  const proverNodePrivateKey = getPrivateKeyFromIndex(ATTESTER_PRIVATE_KEYS_START_INDEX + addressIndex)!;
146
153
  const telemetry = await getEndToEndTestTelemetryClient(metricsPort);
147
154
 
148
- const proverConfig: Partial<ProverNodeConfig> = await createP2PConfig(
149
- config,
150
- bootstrapNode,
151
- tcpPort,
152
- dataDirectory,
153
- );
155
+ const p2pConfig = await createP2PConfig(config, bootstrapNode, tcpPort, dataDirectory);
154
156
 
155
- const aztecNodeRpcTxProvider = undefined;
156
157
  return await createAndSyncProverNode(
157
158
  bufferToHex(proverNodePrivateKey),
158
- config,
159
- { ...proverConfig, dataDirectory },
160
- aztecNodeRpcTxProvider,
161
- prefilledPublicData,
162
- { ...proverNodeDeps, telemetry },
159
+ { ...config, ...p2pConfig },
160
+ { dataDirectory },
161
+ { ...deps, telemetry },
162
+ { prefilledPublicData: prefilledPublicData ?? [] },
163
163
  );
164
164
  });
165
165
  }
@@ -187,26 +187,27 @@ export async function createP2PConfig(
187
187
  }
188
188
 
189
189
  export async function createValidatorConfig(
190
- config: AztecNodeConfig,
190
+ config: CreateNodeConfig,
191
191
  bootstrapNodeEnr?: string,
192
192
  port?: number,
193
193
  addressIndex: number | number[] = 1,
194
194
  dataDirectory?: string,
195
195
  ) {
196
196
  const addressIndices = Array.isArray(addressIndex) ? addressIndex : [addressIndex];
197
- if (addressIndices.length === 0) {
197
+ if (addressIndices.length === 0 && !config.validatorPrivateKey) {
198
198
  throw new Error('At least one address index must be provided to create a validator config');
199
199
  }
200
200
 
201
- const attesterPrivateKeys = addressIndices.map(index =>
202
- bufferToHex(getPrivateKeyFromIndex(ATTESTER_PRIVATE_KEYS_START_INDEX + index)!),
203
- );
201
+ // Use override private key if provided, otherwise derive from address indices
202
+ const attesterPrivateKeys = config.validatorPrivateKey
203
+ ? [config.validatorPrivateKey]
204
+ : addressIndices.map(index => bufferToHex(getPrivateKeyFromIndex(ATTESTER_PRIVATE_KEYS_START_INDEX + index)!));
204
205
  const p2pConfig = await createP2PConfig(config, bootstrapNodeEnr, port, dataDirectory);
205
206
  const nodeConfig: AztecNodeConfig = {
206
207
  ...config,
207
208
  ...p2pConfig,
208
209
  validatorPrivateKeys: new SecretValue(attesterPrivateKeys),
209
- publisherPrivateKeys: [new SecretValue(attesterPrivateKeys[0])],
210
+ sequencerPublisherPrivateKeys: [new SecretValue(attesterPrivateKeys[0])],
210
211
  };
211
212
 
212
213
  return nodeConfig;