@aztec/end-to-end 0.0.0-test.1 → 0.0.1-commit.1142ef1

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