@aztec/end-to-end 0.0.0-test.0 → 0.0.1-fake-c83136db25

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 (166) hide show
  1. package/dest/bench/client_flows/benchmark.d.ts +61 -0
  2. package/dest/bench/client_flows/benchmark.d.ts.map +1 -0
  3. package/dest/bench/client_flows/benchmark.js +261 -0
  4. package/dest/bench/client_flows/client_flows_benchmark.d.ts +73 -0
  5. package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -0
  6. package/dest/bench/client_flows/client_flows_benchmark.js +311 -0
  7. package/dest/bench/client_flows/config.d.ts +14 -0
  8. package/dest/bench/client_flows/config.d.ts.map +1 -0
  9. package/dest/bench/client_flows/config.js +106 -0
  10. package/dest/bench/client_flows/data_extractor.d.ts +2 -0
  11. package/dest/bench/client_flows/data_extractor.d.ts.map +1 -0
  12. package/dest/bench/client_flows/data_extractor.js +99 -0
  13. package/dest/bench/utils.d.ts +10 -36
  14. package/dest/bench/utils.d.ts.map +1 -1
  15. package/dest/bench/utils.js +26 -66
  16. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +20 -12
  17. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts.map +1 -1
  18. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.js +85 -57
  19. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +18 -24
  20. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts.map +1 -1
  21. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.js +48 -69
  22. package/dest/e2e_deploy_contract/deploy_test.d.ts +14 -6
  23. package/dest/e2e_deploy_contract/deploy_test.d.ts.map +1 -1
  24. package/dest/e2e_deploy_contract/deploy_test.js +13 -19
  25. package/dest/e2e_epochs/epochs_test.d.ts +58 -17
  26. package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
  27. package/dest/e2e_epochs/epochs_test.js +224 -43
  28. package/dest/e2e_fees/bridging_race.notest.d.ts +2 -0
  29. package/dest/e2e_fees/bridging_race.notest.d.ts.map +1 -0
  30. package/dest/e2e_fees/bridging_race.notest.js +63 -0
  31. package/dest/e2e_fees/fees_test.d.ts +20 -9
  32. package/dest/e2e_fees/fees_test.d.ts.map +1 -1
  33. package/dest/e2e_fees/fees_test.js +98 -107
  34. package/dest/e2e_l1_publisher/write_json.d.ts +10 -0
  35. package/dest/e2e_l1_publisher/write_json.d.ts.map +1 -0
  36. package/dest/e2e_l1_publisher/write_json.js +57 -0
  37. package/dest/e2e_multi_validator/utils.d.ts +12 -0
  38. package/dest/e2e_multi_validator/utils.d.ts.map +1 -0
  39. package/dest/e2e_multi_validator/utils.js +214 -0
  40. package/dest/e2e_nested_contract/nested_contract_test.d.ts +9 -6
  41. package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +1 -1
  42. package/dest/e2e_nested_contract/nested_contract_test.js +22 -19
  43. package/dest/e2e_p2p/inactivity_slash_test.d.ts +31 -0
  44. package/dest/e2e_p2p/inactivity_slash_test.d.ts.map +1 -0
  45. package/dest/e2e_p2p/inactivity_slash_test.js +135 -0
  46. package/dest/e2e_p2p/p2p_network.d.ts +69 -22
  47. package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
  48. package/dest/e2e_p2p/p2p_network.js +180 -129
  49. package/dest/e2e_p2p/shared.d.ts +41 -5
  50. package/dest/e2e_p2p/shared.d.ts.map +1 -1
  51. package/dest/e2e_p2p/shared.js +163 -19
  52. package/dest/e2e_token_contract/token_contract_test.d.ts +11 -5
  53. package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -1
  54. package/dest/e2e_token_contract/token_contract_test.js +50 -26
  55. package/dest/{e2e_prover → fixtures}/e2e_prover_test.d.ts +14 -9
  56. package/dest/fixtures/e2e_prover_test.d.ts.map +1 -0
  57. package/dest/{e2e_prover → fixtures}/e2e_prover_test.js +95 -100
  58. package/dest/fixtures/fixtures.d.ts +5 -6
  59. package/dest/fixtures/fixtures.d.ts.map +1 -1
  60. package/dest/fixtures/fixtures.js +4 -3
  61. package/dest/fixtures/get_acvm_config.d.ts +1 -1
  62. package/dest/fixtures/get_acvm_config.d.ts.map +1 -1
  63. package/dest/fixtures/get_acvm_config.js +2 -14
  64. package/dest/fixtures/get_bb_config.d.ts +1 -1
  65. package/dest/fixtures/get_bb_config.d.ts.map +1 -1
  66. package/dest/fixtures/get_bb_config.js +10 -17
  67. package/dest/fixtures/l1_to_l2_messaging.d.ts +8 -5
  68. package/dest/fixtures/l1_to_l2_messaging.d.ts.map +1 -1
  69. package/dest/fixtures/l1_to_l2_messaging.js +44 -18
  70. package/dest/fixtures/setup_l1_contracts.d.ts +3 -3
  71. package/dest/fixtures/setup_l1_contracts.d.ts.map +1 -1
  72. package/dest/fixtures/setup_l1_contracts.js +4 -4
  73. package/dest/fixtures/setup_p2p_test.d.ts +14 -13
  74. package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
  75. package/dest/fixtures/setup_p2p_test.js +73 -21
  76. package/dest/fixtures/snapshot_manager.d.ts +15 -7
  77. package/dest/fixtures/snapshot_manager.d.ts.map +1 -1
  78. package/dest/fixtures/snapshot_manager.js +147 -121
  79. package/dest/fixtures/token_utils.d.ts +6 -3
  80. package/dest/fixtures/token_utils.d.ts.map +1 -1
  81. package/dest/fixtures/token_utils.js +23 -10
  82. package/dest/fixtures/utils.d.ts +76 -37
  83. package/dest/fixtures/utils.d.ts.map +1 -1
  84. package/dest/fixtures/utils.js +464 -368
  85. package/dest/fixtures/web3signer.d.ts +5 -0
  86. package/dest/fixtures/web3signer.d.ts.map +1 -0
  87. package/dest/fixtures/web3signer.js +53 -0
  88. package/dest/quality_of_service/alert_checker.d.ts +1 -1
  89. package/dest/quality_of_service/alert_checker.d.ts.map +1 -1
  90. package/dest/shared/cross_chain_test_harness.d.ts +41 -25
  91. package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
  92. package/dest/shared/cross_chain_test_harness.js +104 -50
  93. package/dest/shared/gas_portal_test_harness.d.ts +32 -24
  94. package/dest/shared/gas_portal_test_harness.d.ts.map +1 -1
  95. package/dest/shared/gas_portal_test_harness.js +50 -29
  96. package/dest/shared/jest_setup.js +1 -1
  97. package/dest/shared/submit-transactions.d.ts +5 -3
  98. package/dest/shared/submit-transactions.d.ts.map +1 -1
  99. package/dest/shared/submit-transactions.js +8 -7
  100. package/dest/shared/uniswap_l1_l2.d.ts +13 -11
  101. package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
  102. package/dest/shared/uniswap_l1_l2.js +138 -108
  103. package/dest/simulators/lending_simulator.d.ts +6 -6
  104. package/dest/simulators/lending_simulator.d.ts.map +1 -1
  105. package/dest/simulators/lending_simulator.js +13 -16
  106. package/dest/simulators/token_simulator.d.ts +5 -2
  107. package/dest/simulators/token_simulator.d.ts.map +1 -1
  108. package/dest/simulators/token_simulator.js +16 -13
  109. package/dest/spartan/setup_test_wallets.d.ts +23 -10
  110. package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
  111. package/dest/spartan/setup_test_wallets.js +167 -58
  112. package/dest/spartan/utils.d.ts +100 -303
  113. package/dest/spartan/utils.d.ts.map +1 -1
  114. package/dest/spartan/utils.js +407 -130
  115. package/package.json +61 -56
  116. package/src/bench/client_flows/benchmark.ts +341 -0
  117. package/src/bench/client_flows/client_flows_benchmark.ts +402 -0
  118. package/src/bench/client_flows/config.ts +61 -0
  119. package/src/bench/client_flows/data_extractor.ts +111 -0
  120. package/src/bench/utils.ts +22 -76
  121. package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +80 -77
  122. package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +63 -105
  123. package/src/e2e_deploy_contract/deploy_test.ts +23 -38
  124. package/src/e2e_epochs/epochs_test.ts +274 -54
  125. package/src/e2e_fees/bridging_race.notest.ts +80 -0
  126. package/src/e2e_fees/fees_test.ts +137 -136
  127. package/src/e2e_l1_publisher/write_json.ts +76 -0
  128. package/src/e2e_multi_validator/utils.ts +258 -0
  129. package/src/e2e_nested_contract/nested_contract_test.ts +27 -18
  130. package/src/e2e_p2p/inactivity_slash_test.ts +178 -0
  131. package/src/e2e_p2p/p2p_network.ts +272 -166
  132. package/src/e2e_p2p/shared.ts +244 -29
  133. package/src/e2e_token_contract/token_contract_test.ts +43 -39
  134. package/src/fixtures/dumps/epoch_proof_result.json +1 -1
  135. package/src/{e2e_prover → fixtures}/e2e_prover_test.ts +101 -145
  136. package/src/fixtures/fixtures.ts +4 -3
  137. package/src/fixtures/get_acvm_config.ts +3 -11
  138. package/src/fixtures/get_bb_config.ts +18 -13
  139. package/src/fixtures/l1_to_l2_messaging.ts +53 -23
  140. package/src/fixtures/setup_l1_contracts.ts +6 -7
  141. package/src/fixtures/setup_p2p_test.ts +112 -38
  142. package/src/fixtures/snapshot_manager.ts +187 -139
  143. package/src/fixtures/token_utils.ts +29 -12
  144. package/src/fixtures/utils.ts +552 -425
  145. package/src/fixtures/web3signer.ts +63 -0
  146. package/src/guides/up_quick_start.sh +6 -14
  147. package/src/quality_of_service/alert_checker.ts +1 -1
  148. package/src/shared/cross_chain_test_harness.ts +108 -79
  149. package/src/shared/gas_portal_test_harness.ts +58 -49
  150. package/src/shared/jest_setup.ts +1 -1
  151. package/src/shared/submit-transactions.ts +12 -8
  152. package/src/shared/uniswap_l1_l2.ts +173 -176
  153. package/src/simulators/lending_simulator.ts +12 -15
  154. package/src/simulators/token_simulator.ts +21 -13
  155. package/src/spartan/DEVELOP.md +121 -0
  156. package/src/spartan/setup_test_wallets.ts +215 -93
  157. package/src/spartan/utils.ts +458 -130
  158. package/dest/e2e_prover/e2e_prover_test.d.ts.map +0 -1
  159. package/dest/sample-dapp/connect.js +0 -12
  160. package/dest/sample-dapp/contracts.js +0 -10
  161. package/dest/sample-dapp/deploy.js +0 -35
  162. package/dest/sample-dapp/index.js +0 -98
  163. package/src/sample-dapp/connect.mjs +0 -16
  164. package/src/sample-dapp/contracts.mjs +0 -14
  165. package/src/sample-dapp/deploy.mjs +0 -40
  166. package/src/sample-dapp/index.mjs +0 -128
@@ -1,63 +1,64 @@
1
1
  import { SchnorrAccountContractArtifact } from '@aztec/accounts/schnorr';
2
- import {
3
- type InitialAccountData,
4
- deployFundedSchnorrAccounts,
5
- generateSchnorrAccounts,
6
- getDeployedTestAccounts,
7
- getDeployedTestAccountsWallets,
8
- } from '@aztec/accounts/testing';
2
+ import { type InitialAccountData, generateSchnorrAccounts, getInitialTestAccountsData } from '@aztec/accounts/testing';
9
3
  import { type Archiver, createArchiver } from '@aztec/archiver';
10
4
  import { type AztecNodeConfig, AztecNodeService, getConfigEnvVars } from '@aztec/aztec-node';
11
- import {
12
- type AccountWalletWithSecretKey,
13
- AnvilTestWatcher,
14
- type AztecAddress,
15
- type AztecNode,
16
- BatchCall,
17
- CheatCodes,
18
- type ContractMethod,
19
- type DeployL1ContractsReturnType,
20
- FeeJuicePaymentMethod,
21
- type Logger,
22
- type PXE,
23
- SignerlessWallet,
24
- type Wallet,
25
- createAztecNodeClient,
26
- createLogger,
27
- createPXEClient,
28
- deployL1Contracts,
29
- makeFetch,
30
- waitForPXE,
31
- } from '@aztec/aztec.js';
32
- import { deployInstance, registerContractClass } from '@aztec/aztec.js/deployment';
33
- import type { BBNativePrivateKernelProver } from '@aztec/bb-prover';
5
+ import { AztecAddress } from '@aztec/aztec.js/addresses';
6
+ import { BatchCall, type ContractMethod } from '@aztec/aztec.js/contracts';
7
+ import { publishContractClass, publishInstance } from '@aztec/aztec.js/deployment';
8
+ import { type Logger, createLogger } from '@aztec/aztec.js/log';
9
+ import { type AztecNode, createAztecNodeClient, waitForNode } from '@aztec/aztec.js/node';
10
+ import type { Wallet } from '@aztec/aztec.js/wallet';
11
+ import { AnvilTestWatcher, CheatCodes } from '@aztec/aztec/testing';
34
12
  import { createBlobSinkClient } from '@aztec/blob-sink/client';
35
13
  import { type BlobSinkServer, createBlobSinkServer } from '@aztec/blob-sink/server';
36
- import { FEE_JUICE_INITIAL_MINT, GENESIS_ARCHIVE_ROOT, GENESIS_BLOCK_HASH } from '@aztec/constants';
14
+ import { GENESIS_ARCHIVE_ROOT, SPONSORED_FPC_SALT } from '@aztec/constants';
37
15
  import {
38
16
  type DeployL1ContractsArgs,
39
- ForwarderContract,
17
+ type DeployL1ContractsReturnType,
18
+ FeeAssetArtifact,
40
19
  NULL_KEY,
41
- createL1Clients,
20
+ type Operator,
21
+ RollupContract,
22
+ createExtendedL1Client,
23
+ deployL1Contracts,
24
+ deployMulticall3,
42
25
  getL1ContractsConfigEnvVars,
43
26
  isAnvilTestChain,
44
- l1Artifacts,
45
27
  } from '@aztec/ethereum';
46
- import { DelayedTxUtils, EthCheatCodesWithState, startAnvil } from '@aztec/ethereum/test';
28
+ import {
29
+ DelayedTxUtils,
30
+ EthCheatCodes,
31
+ EthCheatCodesWithState,
32
+ createDelayedL1TxUtilsFromViemWallet,
33
+ startAnvil,
34
+ } from '@aztec/ethereum/test';
35
+ import { SecretValue } from '@aztec/foundation/config';
47
36
  import { randomBytes } from '@aztec/foundation/crypto';
48
37
  import { EthAddress } from '@aztec/foundation/eth-address';
49
38
  import { Fr } from '@aztec/foundation/fields';
39
+ import { tryRmDir } from '@aztec/foundation/fs';
40
+ import { withLogNameSuffix } from '@aztec/foundation/log';
50
41
  import { retryUntil } from '@aztec/foundation/retry';
51
- import { TestDateProvider } from '@aztec/foundation/timer';
52
- import { FeeJuiceContract } from '@aztec/noir-contracts.js/FeeJuice';
42
+ import { sleep } from '@aztec/foundation/sleep';
43
+ import { DateProvider, TestDateProvider } from '@aztec/foundation/timer';
44
+ import type { DataStoreConfig } from '@aztec/kv-store/config';
45
+ import { SponsoredFPCContract } from '@aztec/noir-contracts.js/SponsoredFPC';
53
46
  import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
54
- import { ProtocolContractAddress, protocolContractTreeRoot } from '@aztec/protocol-contracts';
55
- import { type ProverNode, type ProverNodeConfig, createProverNode } from '@aztec/prover-node';
56
- import { type PXEService, type PXEServiceConfig, createPXEService, getPXEServiceConfig } from '@aztec/pxe/server';
47
+ import type { P2PClientDeps } from '@aztec/p2p';
48
+ import { MockGossipSubNetwork, getMockPubSubP2PServiceFactory } from '@aztec/p2p/test-helpers';
49
+ import { protocolContractsHash } from '@aztec/protocol-contracts';
50
+ import { type ProverNode, type ProverNodeConfig, type ProverNodeDeps, createProverNode } from '@aztec/prover-node';
51
+ import { type PXEConfig, getPXEConfig } from '@aztec/pxe/server';
57
52
  import type { SequencerClient } from '@aztec/sequencer-client';
58
53
  import type { TestSequencerClient } from '@aztec/sequencer-client/test';
59
- import { getContractClassFromArtifact } from '@aztec/stdlib/contract';
60
- import { Gas } from '@aztec/stdlib/gas';
54
+ import {
55
+ type ContractInstanceWithAddress,
56
+ getContractClassFromArtifact,
57
+ getContractInstanceFromInstantiationParams,
58
+ } from '@aztec/stdlib/contract';
59
+ import type { AztecNodeAdmin } from '@aztec/stdlib/interfaces/client';
60
+ import { tryStop } from '@aztec/stdlib/interfaces/server';
61
+ import type { P2PClientType } from '@aztec/stdlib/p2p';
61
62
  import type { PublicDataTreeLeaf } from '@aztec/stdlib/trees';
62
63
  import {
63
64
  type TelemetryClient,
@@ -66,6 +67,7 @@ import {
66
67
  initTelemetryClient,
67
68
  } from '@aztec/telemetry-client';
68
69
  import { BenchmarkTelemetryClient } from '@aztec/telemetry-client/bench';
70
+ import { TestWallet, deployFundedSchnorrAccounts } from '@aztec/test-wallet/server';
69
71
  import { getGenesisValues } from '@aztec/world-state/testing';
70
72
 
71
73
  import type { Anvil } from '@viem/anvil';
@@ -73,9 +75,8 @@ import fs from 'fs/promises';
73
75
  import getPort from 'get-port';
74
76
  import { tmpdir } from 'os';
75
77
  import * as path from 'path';
76
- import { inspect } from 'util';
77
78
  import { type Chain, type HDAccount, type Hex, type PrivateKeyAccount, getContract } from 'viem';
78
- import { mnemonicToAccount, privateKeyToAccount } from 'viem/accounts';
79
+ import { generatePrivateKey, mnemonicToAccount, privateKeyToAccount } from 'viem/accounts';
79
80
  import { foundry } from 'viem/chains';
80
81
 
81
82
  import { MNEMONIC, TEST_PEER_CHECK_INTERVAL_MS } from './fixtures.js';
@@ -86,8 +87,8 @@ import { isMetricsLoggingRequested, setupMetricsLogger } from './logging.js';
86
87
  export { deployAndInitializeTokenAndBridgeContracts } from '../shared/cross_chain_test_harness.js';
87
88
  export { startAnvil };
88
89
 
89
- const { PXE_URL = '' } = process.env;
90
- const getAztecUrl = () => PXE_URL;
90
+ const { AZTEC_NODE_URL = '' } = process.env;
91
+ const getAztecUrl = () => AZTEC_NODE_URL;
91
92
 
92
93
  let telemetry: TelemetryClient | undefined = undefined;
93
94
  function getTelemetryClient(partialConfig: Partial<TelemetryClientConfig> & { benchmark?: boolean } = {}) {
@@ -117,14 +118,13 @@ export const setupL1Contracts = async (
117
118
  chain: Chain = foundry,
118
119
  ) => {
119
120
  const l1Data = await deployL1Contracts(l1RpcUrls, account, chain, logger, {
120
- l2FeeJuiceAddress: ProtocolContractAddress.FeeJuice.toField(),
121
121
  vkTreeRoot: getVKTreeRoot(),
122
- protocolContractTreeRoot,
122
+ protocolContractsHash,
123
123
  genesisArchiveRoot: args.genesisArchiveRoot ?? new Fr(GENESIS_ARCHIVE_ROOT),
124
- genesisBlockHash: args.genesisBlockHash ?? new Fr(GENESIS_BLOCK_HASH),
125
124
  salt: args.salt,
126
125
  initialValidators: args.initialValidators,
127
126
  ...getL1ContractsConfigEnvVars(),
127
+ realVerifier: false,
128
128
  ...args,
129
129
  });
130
130
 
@@ -132,26 +132,23 @@ export const setupL1Contracts = async (
132
132
  };
133
133
 
134
134
  /**
135
- * Sets up Private eXecution Environment (PXE).
135
+ * Sets up Private eXecution Environment (PXE) and returns the corresponding test wallet.
136
136
  * @param aztecNode - An instance of Aztec Node.
137
- * @param opts - Partial configuration for the PXE service.
138
- * @param firstPrivKey - The private key of the first account to be created.
137
+ * @param opts - Partial configuration for the PXE.
139
138
  * @param logger - The logger to be used.
140
139
  * @param useLogSuffix - Whether to add a randomly generated suffix to the PXE debug logs.
141
- * @param proofCreator - An optional proof creator to use
142
- * @returns Private eXecution Environment (PXE), accounts, wallets and logger.
140
+ * @returns A test wallet, logger and teardown function.
143
141
  */
144
- export async function setupPXEService(
142
+ export async function setupPXEAndGetWallet(
145
143
  aztecNode: AztecNode,
146
- opts: Partial<PXEServiceConfig> = {},
144
+ opts: Partial<PXEConfig> = {},
147
145
  logger = getLogger(),
148
146
  useLogSuffix = false,
149
- proofCreator?: BBNativePrivateKernelProver,
150
147
  ): Promise<{
151
148
  /**
152
- * The PXE instance.
149
+ * The wallet instance.
153
150
  */
154
- pxe: PXEService;
151
+ wallet: TestWallet;
155
152
  /**
156
153
  * Logger instance named as the current test.
157
154
  */
@@ -161,28 +158,24 @@ export async function setupPXEService(
161
158
  */
162
159
  teardown: () => Promise<void>;
163
160
  }> {
164
- const pxeServiceConfig = { ...getPXEServiceConfig(), ...opts };
161
+ const PXEConfig = { ...getPXEConfig(), ...opts };
162
+ // For tests we only want proving enabled if specifically requested
163
+ PXEConfig.proverEnabled = !!opts.proverEnabled;
165
164
 
166
165
  // If no data directory provided, create a temp directory and clean up afterwards
167
- const configuredDataDirectory = pxeServiceConfig.dataDirectory;
166
+ const configuredDataDirectory = PXEConfig.dataDirectory;
168
167
  if (!configuredDataDirectory) {
169
- pxeServiceConfig.dataDirectory = path.join(tmpdir(), randomBytes(8).toString('hex'));
168
+ PXEConfig.dataDirectory = path.join(tmpdir(), randomBytes(8).toString('hex'));
170
169
  }
171
170
 
172
- const pxe = await createPXEService(aztecNode, pxeServiceConfig, useLogSuffix, proofCreator);
171
+ const teardown = configuredDataDirectory ? () => Promise.resolve() : () => tryRmDir(PXEConfig.dataDirectory!);
173
172
 
174
- const teardown = async () => {
175
- if (!configuredDataDirectory) {
176
- try {
177
- await fs.rm(pxeServiceConfig.dataDirectory!, { recursive: true, force: true, maxRetries: 3 });
178
- } catch (err) {
179
- logger.warn(`Failed to delete tmp PXE data directory ${pxeServiceConfig.dataDirectory}: ${err}`);
180
- }
181
- }
182
- };
173
+ const wallet = await TestWallet.create(aztecNode, PXEConfig, {
174
+ useLogSuffix,
175
+ });
183
176
 
184
177
  return {
185
- pxe,
178
+ wallet,
186
179
  logger,
187
180
  teardown,
188
181
  };
@@ -202,52 +195,58 @@ async function setupWithRemoteEnvironment(
202
195
  config: AztecNodeConfig,
203
196
  logger: Logger,
204
197
  numberOfAccounts: number,
205
- ) {
198
+ ): Promise<EndToEndContext> {
206
199
  // we are setting up against a remote environment, l1 contracts are already deployed
207
200
  const aztecNodeUrl = getAztecUrl();
208
201
  logger.verbose(`Creating Aztec Node client to remote host ${aztecNodeUrl}`);
209
202
  const aztecNode = createAztecNodeClient(aztecNodeUrl);
210
- logger.verbose(`Creating PXE client to remote host ${PXE_URL}`);
211
- const pxeClient = createPXEClient(PXE_URL, {}, makeFetch([1, 2, 3], true));
212
- await waitForPXE(pxeClient, logger);
213
- logger.verbose('JSON RPC client connected to PXE');
214
- logger.verbose(`Retrieving contract addresses from ${PXE_URL}`);
215
- const l1Contracts = (await pxeClient.getNodeInfo()).l1ContractAddresses;
203
+ await waitForNode(aztecNode, logger);
204
+ logger.verbose('JSON RPC client connected to Aztec Node');
205
+ logger.verbose(`Retrieving contract addresses from ${aztecNodeUrl}`);
206
+ const { l1ContractAddresses, rollupVersion } = await aztecNode.getNodeInfo();
216
207
 
217
- const { walletClient, publicClient } = createL1Clients(config.l1RpcUrls, account, foundry);
208
+ const l1Client = createExtendedL1Client(config.l1RpcUrls, account, foundry);
218
209
 
219
210
  const deployL1ContractsValues: DeployL1ContractsReturnType = {
220
- l1ContractAddresses: l1Contracts,
221
- walletClient,
222
- publicClient,
211
+ l1ContractAddresses,
212
+ l1Client,
213
+ rollupVersion,
223
214
  };
224
- const cheatCodes = await CheatCodes.create(config.l1RpcUrls, pxeClient!);
215
+ const ethCheatCodes = new EthCheatCodes(config.l1RpcUrls, new DateProvider());
216
+ const wallet = await TestWallet.create(aztecNode);
217
+ const cheatCodes = await CheatCodes.create(config.l1RpcUrls, aztecNode, new DateProvider());
225
218
  const teardown = () => Promise.resolve();
226
219
 
227
- await setupCanonicalFeeJuice(pxeClient);
228
-
229
- logger.verbose('Constructing available wallets from already registered accounts...');
230
- const initialFundedAccounts = await getDeployedTestAccounts(pxeClient);
231
- const wallets = await getDeployedTestAccountsWallets(pxeClient);
220
+ logger.verbose('Populating wallet from already registered accounts...');
221
+ const initialFundedAccounts = await getInitialTestAccountsData();
232
222
 
233
- if (wallets.length < numberOfAccounts) {
234
- throw new Error(`Required ${numberOfAccounts} accounts. Found ${wallets.length}.`);
223
+ if (initialFundedAccounts.length < numberOfAccounts) {
224
+ throw new Error(`Required ${numberOfAccounts} accounts. Found ${initialFundedAccounts.length}.`);
235
225
  // Deploy new accounts if there's a test that requires more funded accounts in the remote environment.
236
226
  }
237
227
 
228
+ const testAccounts = await Promise.all(
229
+ initialFundedAccounts.slice(0, numberOfAccounts).map(async account => {
230
+ const accountManager = await wallet.createSchnorrAccount(account.secret, account.salt, account.signingKey);
231
+ return accountManager.address;
232
+ }),
233
+ );
234
+
238
235
  return {
239
236
  aztecNode,
237
+ aztecNodeAdmin: undefined,
240
238
  sequencer: undefined,
241
239
  proverNode: undefined,
242
- pxe: pxeClient,
243
240
  deployL1ContractsValues,
244
- accounts: await pxeClient!.getRegisteredAccounts(),
245
241
  config,
246
242
  initialFundedAccounts,
247
- wallet: wallets[0],
248
- wallets: wallets.slice(0, numberOfAccounts),
243
+ wallet,
244
+ accounts: testAccounts,
249
245
  logger,
250
246
  cheatCodes,
247
+ ethCheatCodes,
248
+ prefilledPublicData: undefined,
249
+ mockGossipSubNetwork: undefined,
251
250
  watcher: undefined,
252
251
  dateProvider: undefined,
253
252
  blobSink: undefined,
@@ -275,7 +274,7 @@ export type SetupOptions = {
275
274
  /** Salt to use in L1 contract deployment */
276
275
  salt?: number;
277
276
  /** An initial set of validators */
278
- initialValidators?: EthAddress[];
277
+ initialValidators?: (Operator & { privateKey: `0x${string}` })[];
279
278
  /** Anvil Start time */
280
279
  l1StartTime?: number;
281
280
  /** The anvil time where we should at the earliest be seeing L2 blocks */
@@ -288,32 +287,48 @@ export type SetupOptions = {
288
287
  telemetryConfig?: Partial<TelemetryClientConfig> & { benchmark?: boolean };
289
288
  /** Public data that will be inserted in the tree in genesis */
290
289
  genesisPublicData?: PublicDataTreeLeaf[];
290
+ /** Specific config for the prover node, if set. */
291
+ proverNodeConfig?: Partial<ProverNodeConfig>;
292
+ /** Whether to use a mock gossip sub network for p2p clients. */
293
+ mockGossipSubNetwork?: boolean;
294
+ /** Whether to disable the anvil test watcher (can still be manually started) */
295
+ disableAnvilTestWatcher?: boolean;
296
+ /** Whether to enable anvil automine during deployment of L1 contracts (consider defaulting this to true). */
297
+ automineL1Setup?: boolean;
298
+ /** How many accounts to seed and unlock in anvil. */
299
+ anvilAccounts?: number;
300
+ /** Port to start anvil (defaults to 8545) */
301
+ anvilPort?: number;
302
+ /** Key to use for publishing L1 contracts */
303
+ l1PublisherKey?: SecretValue<`0x${string}`>;
291
304
  } & Partial<AztecNodeConfig>;
292
305
 
293
306
  /** Context for an end-to-end test as returned by the `setup` function */
294
307
  export type EndToEndContext = {
295
308
  /** The Aztec Node service or client a connected to it. */
296
309
  aztecNode: AztecNode;
310
+ /** Client to the Aztec Node admin interface (undefined if connected to remote environment) */
311
+ aztecNodeAdmin?: AztecNodeAdmin;
297
312
  /** The prover node service (only set if startProverNode is true) */
298
313
  proverNode: ProverNode | undefined;
299
314
  /** A client to the sequencer service (undefined if connected to remote environment) */
300
315
  sequencer: SequencerClient | undefined;
301
- /** The Private eXecution Environment (PXE). */
302
- pxe: PXE;
303
316
  /** Return values from deployL1Contracts function. */
304
317
  deployL1ContractsValues: DeployL1ContractsReturnType;
305
318
  /** The Aztec Node configuration. */
306
319
  config: AztecNodeConfig;
307
320
  /** The data for the initial funded accounts. */
308
321
  initialFundedAccounts: InitialAccountData[];
309
- /** The first wallet to be used. */
310
- wallet: AccountWalletWithSecretKey;
322
+ /** The wallet to be used. */
323
+ wallet: TestWallet;
311
324
  /** The wallets to be used. */
312
- wallets: AccountWalletWithSecretKey[];
325
+ accounts: AztecAddress[];
313
326
  /** Logger instance named as the current test. */
314
327
  logger: Logger;
315
328
  /** The cheat codes. */
316
329
  cheatCodes: CheatCodes;
330
+ /** The cheat codes for L1 */
331
+ ethCheatCodes: EthCheatCodes;
317
332
  /** The anvil test watcher (undefined if connected to remote environment) */
318
333
  watcher: AnvilTestWatcher | undefined;
319
334
  /** Allows tweaking current system time, used by the epoch cache only (undefined if connected to remote environment) */
@@ -322,6 +337,10 @@ export type EndToEndContext = {
322
337
  blobSink: BlobSinkServer | undefined;
323
338
  /** Telemetry client */
324
339
  telemetryClient: TelemetryClient | undefined;
340
+ /** Mock gossip sub network used for gossipping messages (only if mockGossipSubNetwork was set to true in opts) */
341
+ mockGossipSubNetwork: MockGossipSubNetwork | undefined;
342
+ /** Prefilled public data used for setting up nodes. */
343
+ prefilledPublicData: PublicDataTreeLeaf[] | undefined;
325
344
  /** Function to stop the started services. */
326
345
  teardown: () => Promise<void>;
327
346
  };
@@ -334,267 +353,370 @@ export type EndToEndContext = {
334
353
  */
335
354
  export async function setup(
336
355
  numberOfAccounts = 1,
337
- opts: SetupOptions = {
338
- customForwarderContractAddress: EthAddress.ZERO,
339
- },
340
- pxeOpts: Partial<PXEServiceConfig> = {},
356
+ opts: SetupOptions = {},
357
+ pxeOpts: Partial<PXEConfig> = {},
341
358
  chain: Chain = foundry,
342
359
  ): Promise<EndToEndContext> {
343
- const config = { ...getConfigEnvVars(), ...opts };
344
- config.peerCheckIntervalMS = TEST_PEER_CHECK_INTERVAL_MS;
345
-
346
- const logger = getLogger();
347
-
348
- // Create a temp directory for any services that need it and cleanup later
349
- const directoryToCleanup = path.join(tmpdir(), randomBytes(8).toString('hex'));
350
- await fs.mkdir(directoryToCleanup, { recursive: true });
351
- if (!config.dataDirectory) {
352
- config.dataDirectory = directoryToCleanup;
353
- }
354
-
355
360
  let anvil: Anvil | undefined;
356
-
357
- if (!config.l1RpcUrls?.length) {
358
- if (!isAnvilTestChain(chain.id)) {
359
- throw new Error(`No ETHEREUM_HOSTS set but non anvil chain requested`);
361
+ try {
362
+ opts.aztecTargetCommitteeSize ??= 0;
363
+ opts.slasherFlavor ??= 'none';
364
+
365
+ const config: AztecNodeConfig & SetupOptions = { ...getConfigEnvVars(), ...opts };
366
+ // use initialValidators for the node config
367
+ config.validatorPrivateKeys = new SecretValue(opts.initialValidators?.map(v => v.privateKey) ?? []);
368
+
369
+ config.peerCheckIntervalMS = TEST_PEER_CHECK_INTERVAL_MS;
370
+ // For tests we only want proving enabled if specifically requested
371
+ config.realProofs = !!opts.realProofs;
372
+ // Only enforce the time table if requested
373
+ config.enforceTimeTable = !!opts.enforceTimeTable;
374
+
375
+ const logger = getLogger();
376
+
377
+ // Create a temp directory for any services that need it and cleanup later
378
+ const directoryToCleanup = path.join(tmpdir(), randomBytes(8).toString('hex'));
379
+ await fs.mkdir(directoryToCleanup, { recursive: true });
380
+ if (!config.dataDirectory) {
381
+ config.dataDirectory = directoryToCleanup;
360
382
  }
361
- if (PXE_URL) {
362
- throw new Error(
363
- `PXE_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`,
364
- );
383
+
384
+ if (!config.l1RpcUrls?.length) {
385
+ if (!isAnvilTestChain(chain.id)) {
386
+ throw new Error(`No ETHEREUM_HOSTS set but non anvil chain requested`);
387
+ }
388
+ if (AZTEC_NODE_URL) {
389
+ throw new Error(
390
+ `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`,
391
+ );
392
+ }
393
+
394
+ const res = await startAnvil({
395
+ l1BlockTime: opts.ethereumSlotDuration,
396
+ accounts: opts.anvilAccounts,
397
+ port: opts.anvilPort,
398
+ });
399
+ anvil = res.anvil;
400
+ config.l1RpcUrls = [res.rpcUrl];
365
401
  }
366
402
 
367
- const res = await startAnvil({ l1BlockTime: opts.ethereumSlotDuration });
368
- anvil = res.anvil;
369
- config.l1RpcUrls = [res.rpcUrl];
370
- }
403
+ // Enable logging metrics to a local file named after the test suite
404
+ if (isMetricsLoggingRequested()) {
405
+ const filename = path.join('log', getJobName() + '.jsonl');
406
+ logger.info(`Logging metrics to ${filename}`);
407
+ setupMetricsLogger(filename);
408
+ }
371
409
 
372
- // Enable logging metrics to a local file named after the test suite
373
- if (isMetricsLoggingRequested()) {
374
- const filename = path.join('log', getJobName() + '.jsonl');
375
- logger.info(`Logging metrics to ${filename}`);
376
- setupMetricsLogger(filename);
377
- }
410
+ const dateProvider = new TestDateProvider();
411
+ const ethCheatCodes = new EthCheatCodesWithState(config.l1RpcUrls, dateProvider);
378
412
 
379
- const ethCheatCodes = new EthCheatCodesWithState(config.l1RpcUrls);
413
+ if (opts.stateLoad) {
414
+ await ethCheatCodes.loadChainState(opts.stateLoad);
415
+ }
380
416
 
381
- if (opts.stateLoad) {
382
- await ethCheatCodes.loadChainState(opts.stateLoad);
383
- }
417
+ if (opts.l1StartTime) {
418
+ await ethCheatCodes.warp(opts.l1StartTime, { resetBlockInterval: true });
419
+ }
384
420
 
385
- if (opts.l1StartTime) {
386
- await ethCheatCodes.warp(opts.l1StartTime);
387
- }
421
+ let publisherPrivKey = undefined;
422
+ let publisherHdAccount = undefined;
423
+
424
+ if (opts.l1PublisherKey && opts.l1PublisherKey.getValue() && opts.l1PublisherKey.getValue() != NULL_KEY) {
425
+ publisherHdAccount = privateKeyToAccount(opts.l1PublisherKey.getValue());
426
+ } else if (
427
+ config.publisherPrivateKeys &&
428
+ config.publisherPrivateKeys.length > 0 &&
429
+ config.publisherPrivateKeys[0].getValue() != NULL_KEY
430
+ ) {
431
+ publisherHdAccount = privateKeyToAccount(config.publisherPrivateKeys[0].getValue());
432
+ } else if (!MNEMONIC) {
433
+ throw new Error(`Mnemonic not provided and no publisher private key`);
434
+ } else {
435
+ publisherHdAccount = mnemonicToAccount(MNEMONIC, { addressIndex: 0 });
436
+ const publisherPrivKeyRaw = publisherHdAccount.getHdKey().privateKey;
437
+ publisherPrivKey = publisherPrivKeyRaw === null ? null : Buffer.from(publisherPrivKeyRaw);
438
+ config.publisherPrivateKeys = [new SecretValue(`0x${publisherPrivKey!.toString('hex')}` as const)];
439
+ }
388
440
 
389
- let publisherPrivKey = undefined;
390
- let publisherHdAccount = undefined;
391
-
392
- if (config.publisherPrivateKey && config.publisherPrivateKey != NULL_KEY) {
393
- publisherHdAccount = privateKeyToAccount(config.publisherPrivateKey);
394
- } else if (!MNEMONIC) {
395
- throw new Error(`Mnemonic not provided and no publisher private key`);
396
- } else {
397
- publisherHdAccount = mnemonicToAccount(MNEMONIC, { addressIndex: 0 });
398
- const publisherPrivKeyRaw = publisherHdAccount.getHdKey().privateKey;
399
- publisherPrivKey = publisherPrivKeyRaw === null ? null : Buffer.from(publisherPrivKeyRaw);
400
- config.publisherPrivateKey = `0x${publisherPrivKey!.toString('hex')}`;
401
- }
441
+ config.coinbase = EthAddress.fromString(publisherHdAccount.address);
402
442
 
403
- // Made as separate values such that keys can change, but for test they will be the same.
404
- config.validatorPrivateKey = config.publisherPrivateKey;
443
+ if (AZTEC_NODE_URL) {
444
+ // we are setting up against a remote environment, l1 contracts are assumed to already be deployed
445
+ return await setupWithRemoteEnvironment(publisherHdAccount!, config, logger, numberOfAccounts);
446
+ }
405
447
 
406
- if (PXE_URL) {
407
- // we are setting up against a remote environment, l1 contracts are assumed to already be deployed
408
- return await setupWithRemoteEnvironment(publisherHdAccount!, config, logger, numberOfAccounts);
409
- }
448
+ const initialFundedAccounts =
449
+ opts.initialFundedAccounts ??
450
+ (await generateSchnorrAccounts(opts.numberOfInitialFundedAccounts ?? numberOfAccounts));
451
+ const { genesisArchiveRoot, prefilledPublicData, fundingNeeded } = await getGenesisValues(
452
+ initialFundedAccounts.map(a => a.address),
453
+ opts.initialAccountFeeJuice,
454
+ opts.genesisPublicData,
455
+ );
410
456
 
411
- // Blob sink service - blobs get posted here and served from here
412
- const blobSinkPort = await getPort();
413
- const blobSink = await createBlobSinkServer({ port: blobSinkPort });
414
- await blobSink.start();
415
- config.blobSinkUrl = `http://localhost:${blobSinkPort}`;
416
-
417
- const initialFundedAccounts =
418
- opts.initialFundedAccounts ??
419
- (await generateSchnorrAccounts(opts.numberOfInitialFundedAccounts ?? numberOfAccounts));
420
- const { genesisBlockHash, genesisArchiveRoot, prefilledPublicData } = await getGenesisValues(
421
- initialFundedAccounts.map(a => a.address),
422
- opts.initialAccountFeeJuice,
423
- opts.genesisPublicData,
424
- );
457
+ const wasAutomining = await ethCheatCodes.isAutoMining();
458
+ const enableAutomine = opts.automineL1Setup && !wasAutomining && isAnvilTestChain(chain.id);
459
+ if (enableAutomine) {
460
+ await ethCheatCodes.setAutomine(true);
461
+ }
425
462
 
426
- const deployL1ContractsValues =
427
- opts.deployL1ContractsValues ??
428
- (await setupL1Contracts(
429
- config.l1RpcUrls,
430
- publisherHdAccount!,
431
- logger,
432
- { ...opts, genesisArchiveRoot, genesisBlockHash },
433
- chain,
434
- ));
463
+ const l1Client = createExtendedL1Client(config.l1RpcUrls, publisherHdAccount!, chain);
464
+ await deployMulticall3(l1Client, logger);
465
+
466
+ const deployL1ContractsValues =
467
+ opts.deployL1ContractsValues ??
468
+ (await setupL1Contracts(
469
+ config.l1RpcUrls,
470
+ publisherHdAccount!,
471
+ logger,
472
+ {
473
+ ...opts,
474
+ genesisArchiveRoot,
475
+ feeJuicePortalInitialBalance: fundingNeeded,
476
+ initialValidators: opts.initialValidators,
477
+ },
478
+ chain,
479
+ ));
480
+
481
+ config.l1Contracts = deployL1ContractsValues.l1ContractAddresses;
482
+ config.rollupVersion = deployL1ContractsValues.rollupVersion;
483
+
484
+ if (opts.fundRewardDistributor) {
485
+ // Mints block rewards for 10000 blocks to the rewardDistributor contract
486
+
487
+ const rollup = new RollupContract(
488
+ deployL1ContractsValues.l1Client,
489
+ deployL1ContractsValues.l1ContractAddresses.rollupAddress,
490
+ );
435
491
 
436
- config.l1Contracts = deployL1ContractsValues.l1ContractAddresses;
492
+ const blockReward = await rollup.getBlockReward();
493
+ const mintAmount = 10_000n * (blockReward as bigint);
437
494
 
438
- if (opts.fundRewardDistributor) {
439
- // Mints block rewards for 10000 blocks to the rewardDistributor contract
495
+ const feeJuice = getContract({
496
+ address: deployL1ContractsValues.l1ContractAddresses.feeJuiceAddress.toString(),
497
+ abi: FeeAssetArtifact.contractAbi,
498
+ client: deployL1ContractsValues.l1Client,
499
+ });
440
500
 
441
- const rewardDistributor = getContract({
442
- address: deployL1ContractsValues.l1ContractAddresses.rewardDistributorAddress.toString(),
443
- abi: l1Artifacts.rewardDistributor.contractAbi,
444
- client: deployL1ContractsValues.publicClient,
445
- });
501
+ const rewardDistributorMintTxHash = await feeJuice.write.mint(
502
+ [deployL1ContractsValues.l1ContractAddresses.rewardDistributorAddress.toString(), mintAmount],
503
+ {} as any,
504
+ );
505
+ await deployL1ContractsValues.l1Client.waitForTransactionReceipt({ hash: rewardDistributorMintTxHash });
506
+ logger.info(`Funding rewardDistributor in ${rewardDistributorMintTxHash}`);
507
+ }
446
508
 
447
- const blockReward = await rewardDistributor.read.BLOCK_REWARD();
448
- const mintAmount = 10_000n * (blockReward as bigint);
509
+ if (enableAutomine) {
510
+ await ethCheatCodes.setAutomine(false);
511
+ await ethCheatCodes.setIntervalMining(config.ethereumSlotDuration);
512
+ dateProvider.setTime((await ethCheatCodes.timestamp()) * 1000);
513
+ }
449
514
 
450
- const feeJuice = getContract({
451
- address: deployL1ContractsValues.l1ContractAddresses.feeJuiceAddress.toString(),
452
- abi: l1Artifacts.feeAsset.contractAbi,
453
- client: deployL1ContractsValues.walletClient,
454
- });
515
+ if (opts.l2StartTime) {
516
+ // This should only be used in synching test or when you need to have a stable
517
+ // timestamp for the first l2 block.
518
+ await ethCheatCodes.warp(opts.l2StartTime, { resetBlockInterval: true });
519
+ }
455
520
 
456
- const rewardDistributorMintTxHash = await feeJuice.write.mint([rewardDistributor.address, mintAmount], {} as any);
457
- await deployL1ContractsValues.publicClient.waitForTransactionReceipt({ hash: rewardDistributorMintTxHash });
458
- logger.info(`Funding rewardDistributor in ${rewardDistributorMintTxHash}`);
459
- }
521
+ const watcher = new AnvilTestWatcher(
522
+ new EthCheatCodesWithState(config.l1RpcUrls, dateProvider),
523
+ deployL1ContractsValues.l1ContractAddresses.rollupAddress,
524
+ deployL1ContractsValues.l1Client,
525
+ dateProvider,
526
+ );
527
+ if (!opts.disableAnvilTestWatcher) {
528
+ await watcher.start();
529
+ }
460
530
 
461
- if (opts.l2StartTime) {
462
- // This should only be used in synching test or when you need to have a stable
463
- // timestamp for the first l2 block.
464
- await ethCheatCodes.warp(opts.l2StartTime);
465
- }
531
+ const telemetry = getTelemetryClient(opts.telemetryConfig);
532
+
533
+ // Blob sink service - blobs get posted here and served from here
534
+ const blobSinkPort = await getPort();
535
+ const blobSink = await createBlobSinkServer(
536
+ {
537
+ l1ChainId: config.l1ChainId,
538
+ l1RpcUrls: config.l1RpcUrls,
539
+ l1Contracts: config.l1Contracts,
540
+ port: blobSinkPort,
541
+ dataDirectory: config.dataDirectory,
542
+ dataStoreMapSizeKb: config.dataStoreMapSizeKb,
543
+ },
544
+ telemetry,
545
+ );
546
+ await blobSink.start();
547
+ config.blobSinkUrl = `http://localhost:${blobSinkPort}`;
466
548
 
467
- const dateProvider = new TestDateProvider();
549
+ logger.verbose('Creating and synching an aztec node', config);
468
550
 
469
- const watcher = new AnvilTestWatcher(
470
- new EthCheatCodesWithState(config.l1RpcUrls),
471
- deployL1ContractsValues.l1ContractAddresses.rollupAddress,
472
- deployL1ContractsValues.publicClient,
473
- dateProvider,
474
- );
551
+ const acvmConfig = await getACVMConfig(logger);
552
+ if (acvmConfig) {
553
+ config.acvmWorkingDirectory = acvmConfig.acvmWorkingDirectory;
554
+ config.acvmBinaryPath = acvmConfig.acvmBinaryPath;
555
+ }
475
556
 
476
- await watcher.start();
557
+ const bbConfig = await getBBConfig(logger);
558
+ if (bbConfig) {
559
+ config.bbBinaryPath = bbConfig.bbBinaryPath;
560
+ config.bbWorkingDirectory = bbConfig.bbWorkingDirectory;
561
+ }
477
562
 
478
- logger.verbose('Creating and synching an aztec node...');
563
+ const blobSinkClient = createBlobSinkClient(config, { logger: createLogger('node:blob-sink:client') });
479
564
 
480
- const acvmConfig = await getACVMConfig(logger);
481
- if (acvmConfig) {
482
- config.acvmWorkingDirectory = acvmConfig.acvmWorkingDirectory;
483
- config.acvmBinaryPath = acvmConfig.acvmBinaryPath;
484
- }
565
+ let mockGossipSubNetwork: MockGossipSubNetwork | undefined;
566
+ let p2pClientDeps: P2PClientDeps<P2PClientType.Full> | undefined = undefined;
485
567
 
486
- const bbConfig = await getBBConfig(logger);
487
- if (bbConfig) {
488
- config.bbBinaryPath = bbConfig.bbBinaryPath;
489
- config.bbWorkingDirectory = bbConfig.bbWorkingDirectory;
490
- }
491
- config.l1PublishRetryIntervalMS = 100;
568
+ if (opts.mockGossipSubNetwork) {
569
+ mockGossipSubNetwork = new MockGossipSubNetwork();
570
+ p2pClientDeps = { p2pServiceFactory: getMockPubSubP2PServiceFactory(mockGossipSubNetwork) };
571
+ }
492
572
 
493
- const telemetry = getTelemetryClient(opts.telemetryConfig);
573
+ // Transactions built against the genesis state must be included in block 1, otherwise they are dropped.
574
+ // To avoid test failures from dropped transactions, we ensure progression beyond genesis before proceeding.
575
+ // For account deployments, we set minTxsPerBlock=1 and deploy accounts sequentially for guaranteed success.
576
+ // If no accounts need deployment, we await an empty block to confirm network progression. After either path
577
+ // completes, we restore the original minTxsPerBlock setting. The deployment and waiting for empty block is
578
+ // handled by the if-else branches on line 632.
579
+ // For more details on why the tx would be dropped see `validate_include_by_timestamp` function in
580
+ // `noir-projects/noir-protocol-circuits/crates/rollup-lib/src/base/components/validation_requests.nr`.
581
+ //
582
+ // Note: If the following seems too convoluted or if it starts making problems, we could drop the "progressing
583
+ // past genesis via an account contract deployment" optimization and just call flush() on the sequencer and wait
584
+ // for an empty block to be mined. This would simplify it all quite a bit but the setup would be slower for tests
585
+ // deploying accounts.
586
+ const originalMinTxsPerBlock = config.minTxsPerBlock;
587
+ if (originalMinTxsPerBlock === undefined) {
588
+ throw new Error('minTxsPerBlock is undefined in e2e test setup');
589
+ }
590
+ config.minTxsPerBlock = numberOfAccounts === 0 ? 0 : 1;
494
591
 
495
- const blobSinkClient = createBlobSinkClient(config);
496
- const aztecNode = await AztecNodeService.createAndSync(
497
- config,
498
- {
499
- dateProvider,
500
- blobSinkClient,
501
- },
502
- { prefilledPublicData },
503
- );
504
- const sequencer = aztecNode.getSequencer();
592
+ config.p2pEnabled = opts.mockGossipSubNetwork || config.p2pEnabled;
593
+ config.p2pIp = opts.p2pIp ?? config.p2pIp ?? '127.0.0.1';
505
594
 
506
- if (sequencer) {
507
- const publisher = (sequencer as TestSequencerClient).sequencer.publisher;
508
- publisher.l1TxUtils = DelayedTxUtils.fromL1TxUtils(publisher.l1TxUtils, config.ethereumSlotDuration);
509
- }
595
+ if (!config.disableValidator) {
596
+ if ((config.validatorPrivateKeys?.getValue().length ?? 0) === 0) {
597
+ config.validatorPrivateKeys = new SecretValue([generatePrivateKey()]);
598
+ }
599
+ }
510
600
 
511
- let proverNode: ProverNode | undefined = undefined;
512
- if (opts.startProverNode) {
513
- logger.verbose('Creating and syncing a simulated prover node...');
514
- const proverNodePrivateKey = getPrivateKeyFromIndex(2);
515
- const proverNodePrivateKeyHex: Hex = `0x${proverNodePrivateKey!.toString('hex')}`;
516
- proverNode = await createAndSyncProverNode(
517
- proverNodePrivateKeyHex,
518
- config,
519
- aztecNode,
520
- path.join(directoryToCleanup, randomBytes(8).toString('hex')),
601
+ const aztecNode = await AztecNodeService.createAndSync(
602
+ config, // REFACTOR: createAndSync mutates this config
603
+ { dateProvider, blobSinkClient, telemetry, p2pClientDeps, logger: createLogger('node:MAIN-aztec-node') },
604
+ { prefilledPublicData },
521
605
  );
522
- }
523
-
524
- logger.verbose('Creating a pxe...');
525
- const { pxe, teardown: pxeTeardown } = await setupPXEService(aztecNode!, pxeOpts, logger);
606
+ const sequencerClient = aztecNode.getSequencer();
526
607
 
527
- if (!config.skipProtocolContracts) {
528
- logger.verbose('Setting up Fee Juice...');
529
- await setupCanonicalFeeJuice(pxe);
530
- }
608
+ if (sequencerClient) {
609
+ const publisher = (sequencerClient as TestSequencerClient).sequencer.publisher;
610
+ publisher.l1TxUtils = DelayedTxUtils.fromL1TxUtils(publisher.l1TxUtils, config.ethereumSlotDuration, l1Client);
611
+ }
531
612
 
532
- const accountManagers = await deployFundedSchnorrAccounts(pxe, initialFundedAccounts.slice(0, numberOfAccounts));
533
- const wallets = await Promise.all(accountManagers.map(account => account.getWallet()));
534
- if (initialFundedAccounts.length < numberOfAccounts) {
535
- // TODO: Create (numberOfAccounts - initialFundedAccounts.length) wallets without funds.
536
- throw new Error(
537
- `Unable to deploy ${numberOfAccounts} accounts. Only ${initialFundedAccounts.length} accounts were funded.`,
538
- );
539
- }
613
+ let proverNode: ProverNode | undefined = undefined;
614
+ if (opts.startProverNode) {
615
+ logger.verbose('Creating and syncing a simulated prover node...');
616
+ const proverNodePrivateKey = getPrivateKeyFromIndex(2);
617
+ const proverNodePrivateKeyHex: Hex = `0x${proverNodePrivateKey!.toString('hex')}`;
618
+ const proverNodeDataDirectory = path.join(directoryToCleanup, randomBytes(8).toString('hex'));
619
+ const proverNodeConfig = { ...config.proverNodeConfig, dataDirectory: proverNodeDataDirectory };
620
+ proverNode = await createAndSyncProverNode(
621
+ proverNodePrivateKeyHex,
622
+ config,
623
+ proverNodeConfig,
624
+ aztecNode,
625
+ prefilledPublicData,
626
+ );
627
+ }
540
628
 
541
- const cheatCodes = await CheatCodes.create(config.l1RpcUrls, pxe!);
629
+ logger.verbose('Creating a pxe...');
630
+ const { wallet, teardown: pxeTeardown } = await setupPXEAndGetWallet(aztecNode!, pxeOpts, logger);
542
631
 
543
- const teardown = async () => {
544
- await pxeTeardown();
632
+ const cheatCodes = await CheatCodes.create(config.l1RpcUrls, aztecNode, dateProvider);
545
633
 
546
- if (aztecNode instanceof AztecNodeService) {
547
- await aztecNode?.stop();
634
+ if (
635
+ (opts.aztecTargetCommitteeSize && opts.aztecTargetCommitteeSize > 0) ||
636
+ (opts.initialValidators && opts.initialValidators.length > 0)
637
+ ) {
638
+ // We need to advance such that the committee is set up.
639
+ await cheatCodes.rollup.advanceToEpoch((await cheatCodes.rollup.getEpoch()) + BigInt(config.lagInEpochs + 1));
640
+ await cheatCodes.rollup.setupEpoch();
641
+ await cheatCodes.rollup.debugRollup();
548
642
  }
549
-
550
- if (proverNode) {
551
- await proverNode.stop();
643
+ let accounts: AztecAddress[] = [];
644
+ // Below we continue with what we described in the long comment on line 571.
645
+ if (numberOfAccounts === 0) {
646
+ logger.info('No accounts are being deployed, waiting for an empty block 1 to be mined');
647
+ while ((await aztecNode.getBlockNumber()) === 0) {
648
+ await sleep(2000);
649
+ }
650
+ } else {
651
+ logger.info(
652
+ `${numberOfAccounts} accounts are being deployed. Reliably progressing past genesis by setting minTxsPerBlock to 1 and waiting for the accounts to be deployed`,
653
+ );
654
+ const accountsData = initialFundedAccounts.slice(0, numberOfAccounts);
655
+ const accountManagers = await deployFundedSchnorrAccounts(wallet, aztecNode, accountsData);
656
+ accounts = accountManagers.map(accountManager => accountManager.address);
552
657
  }
553
658
 
554
- if (acvmConfig?.cleanup) {
555
- // remove the temp directory created for the acvm
556
- logger.verbose(`Cleaning up ACVM state`);
557
- await acvmConfig.cleanup();
558
- }
659
+ // Now we restore the original minTxsPerBlock setting.
660
+ sequencerClient!.getSequencer().updateConfig({ minTxsPerBlock: originalMinTxsPerBlock });
559
661
 
560
- if (bbConfig?.cleanup) {
561
- // remove the temp directory created for the acvm
562
- logger.verbose(`Cleaning up BB state`);
563
- await bbConfig.cleanup();
662
+ if (initialFundedAccounts.length < numberOfAccounts) {
663
+ // TODO: Create (numberOfAccounts - initialFundedAccounts.length) wallets without funds.
664
+ throw new Error(
665
+ `Unable to deploy ${numberOfAccounts} accounts. Only ${initialFundedAccounts.length} accounts were funded.`,
666
+ );
564
667
  }
565
668
 
566
- await anvil?.stop().catch(err => getLogger().error(err));
567
- await watcher.stop();
568
- await blobSink?.stop();
569
-
570
- if (directoryToCleanup) {
669
+ const teardown = async () => {
571
670
  try {
572
- logger.verbose(`Cleaning up data directory at ${directoryToCleanup}`);
573
- await fs.rm(directoryToCleanup, { recursive: true, force: true, maxRetries: 3 });
671
+ await pxeTeardown();
672
+
673
+ await tryStop(aztecNode, logger);
674
+ await tryStop(proverNode, logger);
675
+
676
+ if (acvmConfig?.cleanup) {
677
+ await acvmConfig.cleanup();
678
+ }
679
+
680
+ if (bbConfig?.cleanup) {
681
+ await bbConfig.cleanup();
682
+ }
683
+
684
+ await tryStop(watcher, logger);
685
+ await tryStop(anvil, logger);
686
+
687
+ await tryStop(blobSink, logger);
688
+ await tryRmDir(directoryToCleanup, logger);
574
689
  } catch (err) {
575
- logger.warn(`Failed to delete data directory at ${directoryToCleanup}: ${err}`);
690
+ logger.error(`Error during e2e test teardown`, err);
576
691
  }
577
- }
578
- };
692
+ };
579
693
 
580
- return {
581
- aztecNode,
582
- blobSink,
583
- cheatCodes,
584
- config,
585
- dateProvider,
586
- deployL1ContractsValues,
587
- initialFundedAccounts,
588
- logger,
589
- proverNode,
590
- pxe,
591
- sequencer,
592
- teardown,
593
- telemetryClient: telemetry,
594
- wallet: wallets[0],
595
- wallets,
596
- watcher,
597
- };
694
+ return {
695
+ aztecNode,
696
+ aztecNodeAdmin: aztecNode,
697
+ blobSink,
698
+ cheatCodes,
699
+ ethCheatCodes,
700
+ config,
701
+ dateProvider,
702
+ deployL1ContractsValues,
703
+ initialFundedAccounts,
704
+ logger,
705
+ mockGossipSubNetwork,
706
+ prefilledPublicData,
707
+ proverNode,
708
+ sequencer: sequencerClient,
709
+ teardown,
710
+ telemetryClient: telemetry,
711
+ wallet,
712
+ accounts,
713
+ watcher,
714
+ };
715
+ } catch (err) {
716
+ // TODO: Just hoisted anvil for now to ensure cleanup. Prob need to hoist the rest.
717
+ await anvil?.stop();
718
+ throw err;
719
+ }
598
720
  }
599
721
 
600
722
  /**
@@ -604,16 +726,14 @@ export async function setup(
604
726
  * @param accountsToDeploy - Which accounts to publicly deploy.
605
727
  */
606
728
 
607
- // docs:start:public_deploy_accounts
608
- export async function ensureAccountsPubliclyDeployed(sender: Wallet, accountsToDeploy: Wallet[]) {
729
+ export async function ensureAccountContractsPublished(wallet: Wallet, accountsToDeploy: AztecAddress[]) {
609
730
  // We have to check whether the accounts are already deployed. This can happen if the test runs against
610
731
  // the sandbox and the test accounts exist
611
732
  const accountsAndAddresses = await Promise.all(
612
- accountsToDeploy.map(async account => {
613
- const address = account.getAddress();
733
+ accountsToDeploy.map(async address => {
614
734
  return {
615
735
  address,
616
- deployed: (await sender.getContractMetadata(address)).isContractPubliclyDeployed,
736
+ deployed: (await wallet.getContractMetadata(address)).isContractPublished,
617
737
  };
618
738
  }),
619
739
  );
@@ -621,33 +741,18 @@ export async function ensureAccountsPubliclyDeployed(sender: Wallet, accountsToD
621
741
  await Promise.all(
622
742
  accountsAndAddresses
623
743
  .filter(({ deployed }) => !deployed)
624
- .map(({ address }) => sender.getContractMetadata(address)),
744
+ .map(({ address }) => wallet.getContractMetadata(address)),
625
745
  )
626
746
  ).map(contractMetadata => contractMetadata.contractInstance);
627
747
  const contractClass = await getContractClassFromArtifact(SchnorrAccountContractArtifact);
628
- if (!(await sender.getContractClassMetadata(contractClass.id, true)).isContractClassPubliclyRegistered) {
629
- await (await registerContractClass(sender, SchnorrAccountContractArtifact)).send().wait();
748
+ if (!(await wallet.getContractClassMetadata(contractClass.id, true)).isContractClassPubliclyRegistered) {
749
+ await (await publishContractClass(wallet, SchnorrAccountContractArtifact))
750
+ .send({ from: accountsToDeploy[0] })
751
+ .wait();
630
752
  }
631
- const requests = await Promise.all(
632
- instances.map(async instance => (await deployInstance(sender, instance!)).request()),
633
- );
634
- const batch = new BatchCall(sender, [...requests]);
635
- await batch.send().wait();
636
- }
637
- // docs:end:public_deploy_accounts
638
-
639
- /**
640
- * Sets the timestamp of the next block.
641
- * @param rpcUrl - rpc url of the blockchain instance to connect to
642
- * @param timestamp - the timestamp for the next block
643
- */
644
- export async function setNextBlockTimestamp(rpcUrl: string, timestamp: number) {
645
- const params = `[${timestamp}]`;
646
- await fetch(rpcUrl, {
647
- body: `{"jsonrpc":"2.0", "method": "evm_setNextBlockTimestamp", "params": ${params}, "id": 1}`,
648
- method: 'POST',
649
- headers: { 'Content-Type': 'application/json' },
650
- });
753
+ const requests = await Promise.all(instances.map(async instance => await publishInstance(wallet, instance!)));
754
+ const batch = new BatchCall(wallet, requests);
755
+ await batch.send({ from: accountsToDeploy[0] }).wait();
651
756
  }
652
757
 
653
758
  /** Returns the job name for the current test. */
@@ -672,11 +777,12 @@ export type BalancesFn = ReturnType<typeof getBalancesFn>;
672
777
  export function getBalancesFn(
673
778
  symbol: string,
674
779
  method: ContractMethod,
780
+ from: AztecAddress,
675
781
  logger: any,
676
782
  ): (...addresses: (AztecAddress | { address: AztecAddress })[]) => Promise<bigint[]> {
677
783
  const balances = async (...addressLikes: (AztecAddress | { address: AztecAddress })[]) => {
678
784
  const addresses = addressLikes.map(addressLike => ('address' in addressLike ? addressLike.address : addressLike));
679
- const b = await Promise.all(addresses.map(address => method(address).simulate()));
785
+ const b = await Promise.all(addresses.map(address => method(address).simulate({ from })));
680
786
  const debugString = `${symbol} balances: ${addresses.map((address, i) => `${address}: ${b[i]}`).join(', ')}`;
681
787
  logger.verbose(debugString);
682
788
  return b;
@@ -712,24 +818,47 @@ export async function expectMappingDelta<K, V extends number | bigint>(
712
818
  }
713
819
 
714
820
  /**
715
- * Deploy the protocol contracts to a running instance.
821
+ * Computes the address of the "canonical" SponsoredFPCContract. This is not a protocol contract
822
+ * but by conventions its address is computed with a salt of 0.
823
+ * @returns The address of the sponsored FPC contract
716
824
  */
717
- export async function setupCanonicalFeeJuice(pxe: PXE) {
718
- // "deploy" the Fee Juice as it contains public functions
719
- const feeJuicePortalAddress = (await pxe.getNodeInfo()).l1ContractAddresses.feeJuicePortalAddress;
720
- const wallet = new SignerlessWallet(pxe);
721
- const feeJuice = await FeeJuiceContract.at(ProtocolContractAddress.FeeJuice, wallet);
825
+ export function getSponsoredFPCInstance(): Promise<ContractInstanceWithAddress> {
826
+ return Promise.resolve(
827
+ getContractInstanceFromInstantiationParams(SponsoredFPCContract.artifact, {
828
+ salt: new Fr(SPONSORED_FPC_SALT),
829
+ }),
830
+ );
831
+ }
722
832
 
723
- try {
724
- const paymentMethod = new FeeJuicePaymentMethod(ProtocolContractAddress.FeeJuice);
725
- await feeJuice.methods
726
- .initialize(feeJuicePortalAddress, FEE_JUICE_INITIAL_MINT)
727
- .send({ fee: { paymentMethod, gasSettings: { teardownGasLimits: Gas.empty() } } })
728
- .wait();
729
- getLogger().info(`Fee Juice successfully setup. Portal address: ${feeJuicePortalAddress}`);
730
- } catch (error) {
731
- getLogger().warn(`Fee Juice might have already been setup. Got error: ${inspect(error)}.`);
732
- }
833
+ /**
834
+ * Computes the address of the "canonical" SponsoredFPCContract. This is not a protocol contract
835
+ * but by conventions its address is computed with a salt of 0.
836
+ * @returns The address of the sponsored FPC contract
837
+ */
838
+ export async function getSponsoredFPCAddress() {
839
+ const sponsoredFPCInstance = await getSponsoredFPCInstance();
840
+ return sponsoredFPCInstance.address;
841
+ }
842
+
843
+ /**
844
+ * Deploy a sponsored FPC contract to a running instance.
845
+ */
846
+ export async function setupSponsoredFPC(wallet: Wallet) {
847
+ const instance = await getContractInstanceFromInstantiationParams(SponsoredFPCContract.artifact, {
848
+ salt: new Fr(SPONSORED_FPC_SALT),
849
+ });
850
+
851
+ await wallet.registerContract({ instance, artifact: SponsoredFPCContract.artifact });
852
+ getLogger().info(`SponsoredFPC: ${instance.address}`);
853
+ return instance;
854
+ }
855
+
856
+ /**
857
+ * Registers the SponsoredFPC in this PXE instance
858
+ * @param wallet - The wallet
859
+ */
860
+ export async function registerSponsoredFPC(wallet: Wallet): Promise<void> {
861
+ await wallet.registerContract({ instance: await getSponsoredFPCInstance(), artifact: SponsoredFPCContract.artifact });
733
862
  }
734
863
 
735
864
  export async function waitForProvenChain(node: AztecNode, targetBlock?: number, timeoutSec = 60, intervalSec = 1) {
@@ -743,81 +872,79 @@ export async function waitForProvenChain(node: AztecNode, targetBlock?: number,
743
872
  );
744
873
  }
745
874
 
746
- export async function createAndSyncProverNode(
875
+ export function createAndSyncProverNode(
747
876
  proverNodePrivateKey: `0x${string}`,
748
877
  aztecNodeConfig: AztecNodeConfig,
749
- aztecNode: AztecNode,
750
- dataDirectory: string,
878
+ proverNodeConfig: Partial<ProverNodeConfig> & Pick<DataStoreConfig, 'dataDirectory'> & { dontStart?: boolean },
879
+ aztecNode: AztecNode | undefined,
751
880
  prefilledPublicData: PublicDataTreeLeaf[] = [],
881
+ proverNodeDeps: ProverNodeDeps = {},
752
882
  ) {
753
- // Disable stopping the aztec node as the prover coordination test will kill it otherwise
754
- // This is only required when stopping the prover node for testing
755
- const aztecNodeWithoutStop = {
756
- getTxByHash: aztecNode.getTxByHash.bind(aztecNode),
757
- getTxsByHash: aztecNode.getTxsByHash.bind(aztecNode),
758
- stop: () => Promise.resolve(),
759
- };
883
+ return withLogNameSuffix('prover-node', async () => {
884
+ // Disable stopping the aztec node as the prover coordination test will kill it otherwise
885
+ // This is only required when stopping the prover node for testing
886
+ const aztecNodeTxProvider = aztecNode && {
887
+ getTxByHash: aztecNode.getTxByHash.bind(aztecNode),
888
+ getTxsByHash: aztecNode.getTxsByHash.bind(aztecNode),
889
+ stop: () => Promise.resolve(),
890
+ };
891
+
892
+ const blobSinkClient = createBlobSinkClient(aztecNodeConfig);
893
+
894
+ // Creating temp store and archiver for simulated prover node
895
+ const archiverConfig = { ...aztecNodeConfig, dataDirectory: proverNodeConfig.dataDirectory };
896
+ const archiver = await createArchiver(archiverConfig, { blobSinkClient }, { blockUntilSync: true });
897
+
898
+ // Prover node config is for simulated proofs
899
+ const proverConfig: ProverNodeConfig = {
900
+ ...aztecNodeConfig,
901
+ txCollectionNodeRpcUrls: [],
902
+ realProofs: false,
903
+ proverAgentCount: 2,
904
+ publisherPrivateKeys: [new SecretValue(proverNodePrivateKey)],
905
+ proverNodeMaxPendingJobs: 10,
906
+ proverNodeMaxParallelBlocksPerEpoch: 32,
907
+ proverNodePollingIntervalMs: 200,
908
+ txGatheringIntervalMs: 1000,
909
+ txGatheringBatchSize: 10,
910
+ txGatheringMaxParallelRequestsPerNode: 10,
911
+ txGatheringTimeoutMs: 24_000,
912
+ proverNodeFailedEpochStore: undefined,
913
+ proverId: EthAddress.fromNumber(1),
914
+ proverNodeEpochProvingDelayMs: undefined,
915
+ ...proverNodeConfig,
916
+ };
917
+
918
+ const l1TxUtils = createDelayedL1TxUtils(
919
+ aztecNodeConfig,
920
+ proverNodePrivateKey,
921
+ 'prover-node',
922
+ proverNodeDeps.dateProvider,
923
+ );
760
924
 
761
- const blobSinkClient = createBlobSinkClient(aztecNodeConfig);
762
- // Creating temp store and archiver for simulated prover node
763
- const archiverConfig = { ...aztecNodeConfig, dataDirectory };
764
- const archiver = await createArchiver(archiverConfig, blobSinkClient, {
765
- blockUntilSync: true,
925
+ const proverNode = await createProverNode(
926
+ proverConfig,
927
+ { ...proverNodeDeps, aztecNodeTxProvider, archiver: archiver as Archiver, l1TxUtils },
928
+ { prefilledPublicData },
929
+ );
930
+ getLogger().info(`Created and synced prover node`, { publisherAddress: l1TxUtils.client.account!.address });
931
+ if (!proverNodeConfig.dontStart) {
932
+ await proverNode.start();
933
+ }
934
+ return proverNode;
766
935
  });
767
-
768
- // Prover node config is for simulated proofs
769
- const proverConfig: ProverNodeConfig = {
770
- ...aztecNodeConfig,
771
- proverCoordinationNodeUrl: undefined,
772
- dataDirectory: undefined,
773
- realProofs: false,
774
- proverAgentCount: 2,
775
- publisherPrivateKey: proverNodePrivateKey,
776
- proverNodeMaxPendingJobs: 10,
777
- proverNodeMaxParallelBlocksPerEpoch: 32,
778
- proverNodePollingIntervalMs: 200,
779
- txGatheringTimeoutMs: 60000,
780
- txGatheringIntervalMs: 1000,
781
- txGatheringMaxParallelRequests: 100,
782
- };
783
-
784
- const l1TxUtils = createDelayedL1TxUtils(aztecNodeConfig, proverNodePrivateKey, 'prover-node');
785
-
786
- const proverNode = await createProverNode(
787
- proverConfig,
788
- {
789
- aztecNodeTxProvider: aztecNodeWithoutStop,
790
- archiver: archiver as Archiver,
791
- l1TxUtils,
792
- },
793
- { prefilledPublicData },
794
- );
795
- getLogger().info(`Created and synced prover node`, { publisherAddress: l1TxUtils.walletClient.account.address });
796
- proverNode.start();
797
- return proverNode;
798
936
  }
799
937
 
800
- function createDelayedL1TxUtils(aztecNodeConfig: AztecNodeConfig, privateKey: `0x${string}`, logName: string) {
801
- const { publicClient, walletClient } = createL1Clients(aztecNodeConfig.l1RpcUrls, privateKey, foundry);
938
+ function createDelayedL1TxUtils(
939
+ aztecNodeConfig: AztecNodeConfig,
940
+ privateKey: `0x${string}`,
941
+ logName: string,
942
+ dateProvider?: DateProvider,
943
+ ) {
944
+ const l1Client = createExtendedL1Client(aztecNodeConfig.l1RpcUrls, privateKey, foundry);
802
945
 
803
946
  const log = createLogger(logName);
804
- const l1TxUtils = new DelayedTxUtils(publicClient, walletClient, log, aztecNodeConfig);
947
+ const l1TxUtils = createDelayedL1TxUtilsFromViemWallet(l1Client, log, dateProvider, aztecNodeConfig);
805
948
  l1TxUtils.enableDelayer(aztecNodeConfig.ethereumSlotDuration);
806
949
  return l1TxUtils;
807
950
  }
808
-
809
- export async function createForwarderContract(
810
- aztecNodeConfig: AztecNodeConfig,
811
- privateKey: `0x${string}`,
812
- rollupAddress: Hex,
813
- ) {
814
- const { walletClient, publicClient } = createL1Clients(aztecNodeConfig.l1RpcUrls, privateKey, foundry);
815
- const forwarderContract = await ForwarderContract.create(
816
- walletClient.account.address,
817
- walletClient,
818
- publicClient,
819
- createLogger('forwarder'),
820
- rollupAddress,
821
- );
822
- return forwarderContract;
823
- }