@aztec/end-to-end 0.0.0-test.1 → 0.0.1-commit.03f7ef2

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