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

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 (218) hide show
  1. package/dest/bench/client_flows/benchmark.d.ts +3 -2
  2. package/dest/bench/client_flows/benchmark.d.ts.map +1 -1
  3. package/dest/bench/client_flows/benchmark.js +21 -1
  4. package/dest/bench/client_flows/client_flows_benchmark.d.ts +14 -15
  5. package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -1
  6. package/dest/bench/client_flows/client_flows_benchmark.js +123 -136
  7. package/dest/bench/client_flows/config.d.ts +2 -2
  8. package/dest/bench/client_flows/config.d.ts.map +1 -1
  9. package/dest/bench/client_flows/config.js +18 -0
  10. package/dest/bench/client_flows/data_extractor.js +3 -1
  11. package/dest/bench/utils.d.ts +9 -8
  12. package/dest/bench/utils.d.ts.map +1 -1
  13. package/dest/bench/utils.js +27 -18
  14. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +6 -7
  15. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts.map +1 -1
  16. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.js +96 -112
  17. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +19 -13
  18. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts.map +1 -1
  19. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.js +92 -71
  20. package/dest/e2e_deploy_contract/deploy_test.d.ts +4 -3
  21. package/dest/e2e_deploy_contract/deploy_test.d.ts.map +1 -1
  22. package/dest/e2e_deploy_contract/deploy_test.js +18 -13
  23. package/dest/e2e_epochs/epochs_test.d.ts +9 -2
  24. package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
  25. package/dest/e2e_epochs/epochs_test.js +51 -21
  26. package/dest/e2e_fees/bridging_race.notest.js +4 -6
  27. package/dest/e2e_fees/fees_test.d.ts +18 -15
  28. package/dest/e2e_fees/fees_test.d.ts.map +1 -1
  29. package/dest/e2e_fees/fees_test.js +126 -141
  30. package/dest/e2e_l1_publisher/write_json.d.ts +4 -3
  31. package/dest/e2e_l1_publisher/write_json.d.ts.map +1 -1
  32. package/dest/e2e_l1_publisher/write_json.js +14 -16
  33. package/dest/e2e_multi_validator/utils.js +1 -1
  34. package/dest/e2e_nested_contract/nested_contract_test.d.ts +6 -9
  35. package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +1 -1
  36. package/dest/e2e_nested_contract/nested_contract_test.js +31 -39
  37. package/dest/e2e_p2p/inactivity_slash_test.d.ts +4 -4
  38. package/dest/e2e_p2p/inactivity_slash_test.d.ts.map +1 -1
  39. package/dest/e2e_p2p/inactivity_slash_test.js +6 -9
  40. package/dest/e2e_p2p/p2p_network.d.ts +13 -11
  41. package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
  42. package/dest/e2e_p2p/p2p_network.js +120 -111
  43. package/dest/e2e_p2p/reqresp/utils.d.ts +22 -0
  44. package/dest/e2e_p2p/reqresp/utils.d.ts.map +1 -0
  45. package/dest/e2e_p2p/reqresp/utils.js +153 -0
  46. package/dest/e2e_p2p/shared.d.ts +7 -7
  47. package/dest/e2e_p2p/shared.d.ts.map +1 -1
  48. package/dest/e2e_p2p/shared.js +16 -20
  49. package/dest/e2e_storage_proof/fixtures/storage_proof_fetcher.d.ts +2 -0
  50. package/dest/e2e_storage_proof/fixtures/storage_proof_fetcher.d.ts.map +1 -0
  51. package/dest/e2e_storage_proof/fixtures/storage_proof_fetcher.js +184 -0
  52. package/dest/e2e_storage_proof/fixtures/storage_proof_fixture.d.ts +18 -0
  53. package/dest/e2e_storage_proof/fixtures/storage_proof_fixture.d.ts.map +1 -0
  54. package/dest/e2e_storage_proof/fixtures/storage_proof_fixture.js +120 -0
  55. package/dest/e2e_token_contract/token_contract_test.d.ts +16 -9
  56. package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -1
  57. package/dest/e2e_token_contract/token_contract_test.js +89 -91
  58. package/dest/fixtures/e2e_prover_test.d.ts +10 -18
  59. package/dest/fixtures/e2e_prover_test.d.ts.map +1 -1
  60. package/dest/fixtures/e2e_prover_test.js +91 -103
  61. package/dest/fixtures/fixtures.d.ts +2 -3
  62. package/dest/fixtures/fixtures.d.ts.map +1 -1
  63. package/dest/fixtures/fixtures.js +1 -2
  64. package/dest/fixtures/get_acvm_config.js +1 -1
  65. package/dest/fixtures/ha_setup.d.ts +71 -0
  66. package/dest/fixtures/ha_setup.d.ts.map +1 -0
  67. package/dest/fixtures/ha_setup.js +114 -0
  68. package/dest/fixtures/index.d.ts +2 -1
  69. package/dest/fixtures/index.d.ts.map +1 -1
  70. package/dest/fixtures/index.js +1 -0
  71. package/dest/fixtures/l1_to_l2_messaging.d.ts +4 -3
  72. package/dest/fixtures/l1_to_l2_messaging.d.ts.map +1 -1
  73. package/dest/fixtures/l1_to_l2_messaging.js +2 -2
  74. package/dest/fixtures/setup.d.ts +218 -0
  75. package/dest/fixtures/setup.d.ts.map +1 -0
  76. package/dest/fixtures/setup.js +630 -0
  77. package/dest/fixtures/setup_p2p_test.d.ts +12 -8
  78. package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
  79. package/dest/fixtures/setup_p2p_test.js +32 -24
  80. package/dest/fixtures/token_utils.d.ts +1 -1
  81. package/dest/fixtures/token_utils.d.ts.map +1 -1
  82. package/dest/fixtures/token_utils.js +7 -4
  83. package/dest/fixtures/utils.d.ts +5 -638
  84. package/dest/fixtures/utils.d.ts.map +1 -1
  85. package/dest/fixtures/utils.js +4 -647
  86. package/dest/fixtures/web3signer.js +1 -1
  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/quality_of_service/grafana_client.d.ts +41 -0
  91. package/dest/quality_of_service/grafana_client.d.ts.map +1 -0
  92. package/dest/quality_of_service/{alert_checker.js → grafana_client.js} +1 -1
  93. package/dest/quality_of_service/prometheus_client.d.ts +38 -0
  94. package/dest/quality_of_service/prometheus_client.d.ts.map +1 -0
  95. package/dest/quality_of_service/prometheus_client.js +67 -0
  96. package/dest/shared/cross_chain_test_harness.d.ts +18 -7
  97. package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
  98. package/dest/shared/cross_chain_test_harness.js +14 -14
  99. package/dest/shared/gas_portal_test_harness.d.ts +12 -2
  100. package/dest/shared/gas_portal_test_harness.d.ts.map +1 -1
  101. package/dest/shared/gas_portal_test_harness.js +1 -1
  102. package/dest/shared/index.d.ts +2 -2
  103. package/dest/shared/index.d.ts.map +1 -1
  104. package/dest/shared/submit-transactions.d.ts +3 -3
  105. package/dest/shared/submit-transactions.d.ts.map +1 -1
  106. package/dest/shared/submit-transactions.js +9 -11
  107. package/dest/shared/uniswap_l1_l2.d.ts +3 -27
  108. package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
  109. package/dest/shared/uniswap_l1_l2.js +57 -35
  110. package/dest/simulators/lending_simulator.d.ts +6 -2
  111. package/dest/simulators/lending_simulator.d.ts.map +1 -1
  112. package/dest/simulators/lending_simulator.js +2 -2
  113. package/dest/spartan/setup_test_wallets.d.ts +4 -3
  114. package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
  115. package/dest/spartan/setup_test_wallets.js +63 -35
  116. package/dest/spartan/tx_metrics.d.ts +88 -0
  117. package/dest/spartan/tx_metrics.d.ts.map +1 -0
  118. package/dest/spartan/tx_metrics.js +422 -0
  119. package/dest/spartan/utils/bot.d.ts +27 -0
  120. package/dest/spartan/utils/bot.d.ts.map +1 -0
  121. package/dest/spartan/utils/bot.js +141 -0
  122. package/dest/spartan/utils/chaos.d.ts +79 -0
  123. package/dest/spartan/utils/chaos.d.ts.map +1 -0
  124. package/dest/spartan/utils/chaos.js +142 -0
  125. package/dest/spartan/utils/clients.d.ts +39 -0
  126. package/dest/spartan/utils/clients.d.ts.map +1 -0
  127. package/dest/spartan/utils/clients.js +90 -0
  128. package/dest/spartan/utils/config.d.ts +39 -0
  129. package/dest/spartan/utils/config.d.ts.map +1 -0
  130. package/dest/spartan/utils/config.js +21 -0
  131. package/dest/spartan/utils/health.d.ts +63 -0
  132. package/dest/spartan/utils/health.d.ts.map +1 -0
  133. package/dest/spartan/utils/health.js +202 -0
  134. package/dest/spartan/utils/helm.d.ts +15 -0
  135. package/dest/spartan/utils/helm.d.ts.map +1 -0
  136. package/dest/spartan/utils/helm.js +47 -0
  137. package/dest/spartan/utils/index.d.ts +9 -0
  138. package/dest/spartan/utils/index.d.ts.map +1 -0
  139. package/dest/spartan/utils/index.js +18 -0
  140. package/dest/spartan/utils/k8s.d.ts +126 -0
  141. package/dest/spartan/utils/k8s.d.ts.map +1 -0
  142. package/dest/spartan/utils/k8s.js +375 -0
  143. package/dest/spartan/utils/nodes.d.ts +41 -0
  144. package/dest/spartan/utils/nodes.d.ts.map +1 -0
  145. package/dest/spartan/utils/nodes.js +461 -0
  146. package/dest/spartan/utils/scripts.d.ts +30 -0
  147. package/dest/spartan/utils/scripts.d.ts.map +1 -0
  148. package/dest/spartan/utils/scripts.js +81 -0
  149. package/dest/spartan/utils.d.ts +2 -221
  150. package/dest/spartan/utils.d.ts.map +1 -1
  151. package/dest/spartan/utils.js +1 -782
  152. package/package.json +43 -39
  153. package/src/bench/client_flows/benchmark.ts +24 -2
  154. package/src/bench/client_flows/client_flows_benchmark.ts +145 -208
  155. package/src/bench/client_flows/config.ts +9 -1
  156. package/src/bench/client_flows/data_extractor.ts +1 -1
  157. package/src/bench/utils.ts +31 -21
  158. package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +104 -142
  159. package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +139 -125
  160. package/src/e2e_deploy_contract/deploy_test.ts +21 -14
  161. package/src/e2e_epochs/epochs_test.ts +96 -47
  162. package/src/e2e_fees/bridging_race.notest.ts +4 -10
  163. package/src/e2e_fees/fees_test.ts +176 -219
  164. package/src/e2e_l1_publisher/write_json.ts +16 -16
  165. package/src/e2e_multi_validator/utils.ts +1 -1
  166. package/src/e2e_nested_contract/nested_contract_test.ts +33 -56
  167. package/src/e2e_p2p/inactivity_slash_test.ts +7 -10
  168. package/src/e2e_p2p/p2p_network.ts +180 -183
  169. package/src/e2e_p2p/reqresp/utils.ts +207 -0
  170. package/src/e2e_p2p/shared.ts +32 -28
  171. package/src/e2e_storage_proof/fixtures/storage_proof.json +915 -0
  172. package/src/e2e_storage_proof/fixtures/storage_proof_fetcher.ts +190 -0
  173. package/src/e2e_storage_proof/fixtures/storage_proof_fixture.ts +173 -0
  174. package/src/e2e_token_contract/token_contract_test.ts +103 -118
  175. package/src/fixtures/dumps/epoch_proof_result.json +1 -1
  176. package/src/fixtures/e2e_prover_test.ts +103 -140
  177. package/src/fixtures/fixtures.ts +1 -3
  178. package/src/fixtures/get_acvm_config.ts +1 -1
  179. package/src/fixtures/ha_setup.ts +184 -0
  180. package/src/fixtures/index.ts +1 -0
  181. package/src/fixtures/l1_to_l2_messaging.ts +4 -2
  182. package/src/fixtures/setup.ts +932 -0
  183. package/src/fixtures/setup_p2p_test.ts +34 -30
  184. package/src/fixtures/token_utils.ts +6 -5
  185. package/src/fixtures/utils.ts +27 -966
  186. package/src/fixtures/web3signer.ts +1 -1
  187. package/src/fixtures/with_telemetry_utils.ts +2 -2
  188. package/src/quality_of_service/{alert_checker.ts → grafana_client.ts} +1 -1
  189. package/src/quality_of_service/prometheus_client.ts +113 -0
  190. package/src/shared/cross_chain_test_harness.ts +19 -37
  191. package/src/shared/gas_portal_test_harness.ts +2 -2
  192. package/src/shared/index.ts +1 -1
  193. package/src/shared/submit-transactions.ts +9 -15
  194. package/src/shared/uniswap_l1_l2.ts +65 -88
  195. package/src/simulators/lending_simulator.ts +3 -3
  196. package/src/spartan/setup_test_wallets.ts +81 -26
  197. package/src/spartan/tx_metrics.ts +376 -0
  198. package/src/spartan/utils/bot.ts +185 -0
  199. package/src/spartan/utils/chaos.ts +253 -0
  200. package/src/spartan/utils/clients.ts +100 -0
  201. package/src/spartan/utils/config.ts +27 -0
  202. package/src/spartan/utils/health.ts +255 -0
  203. package/src/spartan/utils/helm.ts +84 -0
  204. package/src/spartan/utils/index.ts +64 -0
  205. package/src/spartan/utils/k8s.ts +527 -0
  206. package/src/spartan/utils/nodes.ts +538 -0
  207. package/src/spartan/utils/scripts.ts +99 -0
  208. package/src/spartan/utils.ts +1 -983
  209. package/dest/fixtures/setup_l1_contracts.d.ts +0 -477
  210. package/dest/fixtures/setup_l1_contracts.d.ts.map +0 -1
  211. package/dest/fixtures/setup_l1_contracts.js +0 -17
  212. package/dest/fixtures/snapshot_manager.d.ts +0 -95
  213. package/dest/fixtures/snapshot_manager.d.ts.map +0 -1
  214. package/dest/fixtures/snapshot_manager.js +0 -505
  215. package/dest/quality_of_service/alert_checker.d.ts +0 -41
  216. package/dest/quality_of_service/alert_checker.d.ts.map +0 -1
  217. package/src/fixtures/setup_l1_contracts.ts +0 -26
  218. package/src/fixtures/snapshot_manager.ts +0 -665
@@ -0,0 +1,630 @@
1
+ import { SchnorrAccountContractArtifact } from '@aztec/accounts/schnorr';
2
+ import { generateSchnorrAccounts } from '@aztec/accounts/testing';
3
+ import { createArchiver } from '@aztec/archiver';
4
+ import { AztecNodeService, getConfigEnvVars } from '@aztec/aztec-node';
5
+ import { AztecAddress, EthAddress } from '@aztec/aztec.js/addresses';
6
+ import { BatchCall, getContractClassFromArtifact, waitForProven } from '@aztec/aztec.js/contracts';
7
+ import { publishContractClass, publishInstance } from '@aztec/aztec.js/deployment';
8
+ import { Fr } from '@aztec/aztec.js/fields';
9
+ import { createLogger } from '@aztec/aztec.js/log';
10
+ import { AnvilTestWatcher, CheatCodes } from '@aztec/aztec/testing';
11
+ import { createBlobClientWithFileStores } from '@aztec/blob-client/client';
12
+ import { SPONSORED_FPC_SALT } from '@aztec/constants';
13
+ import { isAnvilTestChain } from '@aztec/ethereum/chain';
14
+ import { createExtendedL1Client } from '@aztec/ethereum/client';
15
+ import { getL1ContractsConfigEnvVars } from '@aztec/ethereum/config';
16
+ import { NULL_KEY } from '@aztec/ethereum/constants';
17
+ import { deployMulticall3 } from '@aztec/ethereum/contracts';
18
+ import { deployAztecL1Contracts } from '@aztec/ethereum/deploy-aztec-l1-contracts';
19
+ import { DelayedTxUtils, EthCheatCodesWithState, createDelayedL1TxUtilsFromViemWallet, startAnvil } from '@aztec/ethereum/test';
20
+ import { EpochNumber } from '@aztec/foundation/branded-types';
21
+ import { SecretValue } from '@aztec/foundation/config';
22
+ import { randomBytes } from '@aztec/foundation/crypto/random';
23
+ import { tryRmDir } from '@aztec/foundation/fs';
24
+ import { withLoggerBindings } from '@aztec/foundation/log/server';
25
+ import { retryUntil } from '@aztec/foundation/retry';
26
+ import { sleep } from '@aztec/foundation/sleep';
27
+ import { TestDateProvider } from '@aztec/foundation/timer';
28
+ import { SponsoredFPCContract } from '@aztec/noir-contracts.js/SponsoredFPC';
29
+ import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
30
+ import { MockGossipSubNetwork, getMockPubSubP2PServiceFactory } from '@aztec/p2p/test-helpers';
31
+ import { protocolContractsHash } from '@aztec/protocol-contracts';
32
+ import { createProverNode } from '@aztec/prover-node';
33
+ import { getPXEConfig } from '@aztec/pxe/server';
34
+ import { getContractInstanceFromInstantiationParams } from '@aztec/stdlib/contract';
35
+ import { tryStop } from '@aztec/stdlib/interfaces/server';
36
+ import { getConfigEnvVars as getTelemetryConfig, initTelemetryClient } from '@aztec/telemetry-client';
37
+ import { BenchmarkTelemetryClient } from '@aztec/telemetry-client/bench';
38
+ import { TestWallet, deployFundedSchnorrAccounts } from '@aztec/test-wallet/server';
39
+ import { getGenesisValues } from '@aztec/world-state/testing';
40
+ import fs from 'fs/promises';
41
+ import { tmpdir } from 'os';
42
+ import path from 'path';
43
+ import { generatePrivateKey, mnemonicToAccount, privateKeyToAccount } from 'viem/accounts';
44
+ import { foundry } from 'viem/chains';
45
+ import { MNEMONIC, TEST_MAX_PENDING_TX_POOL_COUNT, TEST_PEER_CHECK_INTERVAL_MS } from './fixtures.js';
46
+ import { getACVMConfig } from './get_acvm_config.js';
47
+ import { getBBConfig } from './get_bb_config.js';
48
+ import { isMetricsLoggingRequested, setupMetricsLogger } from './logging.js';
49
+ import { getEndToEndTestTelemetryClient } from './with_telemetry_utils.js';
50
+ export { startAnvil };
51
+ let telemetry = undefined;
52
+ async function getTelemetryClient(partialConfig = {}) {
53
+ if (!telemetry) {
54
+ const config = {
55
+ ...getTelemetryConfig(),
56
+ ...partialConfig
57
+ };
58
+ telemetry = config.benchmark ? new BenchmarkTelemetryClient() : await initTelemetryClient(config);
59
+ }
60
+ return telemetry;
61
+ }
62
+ export const getPrivateKeyFromIndex = (index)=>{
63
+ const hdAccount = mnemonicToAccount(MNEMONIC, {
64
+ addressIndex: index
65
+ });
66
+ const privKeyRaw = hdAccount.getHdKey().privateKey;
67
+ return privKeyRaw === null ? null : Buffer.from(privKeyRaw);
68
+ };
69
+ /**
70
+ * Sets up shared blob storage using FileStore in the data directory.
71
+ */ export async function setupSharedBlobStorage(config) {
72
+ const sharedBlobPath = path.join(config.dataDirectory, 'shared-blobs');
73
+ await fs.mkdir(sharedBlobPath, {
74
+ recursive: true
75
+ });
76
+ config.blobFileStoreUrls = [
77
+ `file://${sharedBlobPath}`
78
+ ];
79
+ config.blobFileStoreUploadUrl = `file://${sharedBlobPath}`;
80
+ }
81
+ /**
82
+ * Sets up Private eXecution Environment (PXE) and returns the corresponding test wallet.
83
+ * @param aztecNode - An instance of Aztec Node.
84
+ * @param opts - Partial configuration for the PXE.
85
+ * @param logger - The logger to be used.
86
+ * @param actor - Actor label to include in log output (e.g., 'pxe-test').
87
+ * @returns A test wallet, logger and teardown function.
88
+ */ export async function setupPXEAndGetWallet(aztecNode, opts = {}, logger = getLogger(), actor) {
89
+ const PXEConfig = {
90
+ ...getPXEConfig(),
91
+ ...opts
92
+ };
93
+ // For tests we only want proving enabled if specifically requested
94
+ PXEConfig.proverEnabled = !!opts.proverEnabled;
95
+ // If no data directory provided, create a temp directory and clean up afterwards
96
+ const configuredDataDirectory = PXEConfig.dataDirectory;
97
+ if (!configuredDataDirectory) {
98
+ PXEConfig.dataDirectory = path.join(tmpdir(), randomBytes(8).toString('hex'));
99
+ }
100
+ const teardown = configuredDataDirectory ? ()=>Promise.resolve() : ()=>tryRmDir(PXEConfig.dataDirectory);
101
+ const wallet = await TestWallet.create(aztecNode, PXEConfig, {
102
+ loggerActorLabel: actor
103
+ });
104
+ return {
105
+ wallet,
106
+ logger,
107
+ teardown
108
+ };
109
+ }
110
+ /**
111
+ * Sets up the environment for the end-to-end tests.
112
+ * @param numberOfAccounts - The number of new accounts to be created once the PXE is initiated.
113
+ * @param opts - Options to pass to the node initialization and to the setup script.
114
+ * @param pxeOpts - Options to pass to the PXE initialization.
115
+ */ export async function setup(numberOfAccounts = 1, opts = {}, pxeOpts = {}, chain = foundry) {
116
+ let anvil;
117
+ try {
118
+ opts.aztecTargetCommitteeSize ??= 0;
119
+ opts.slasherFlavor ??= 'none';
120
+ const config = {
121
+ ...getConfigEnvVars(),
122
+ ...opts
123
+ };
124
+ // use initialValidators for the node config
125
+ config.validatorPrivateKeys = new SecretValue(opts.initialValidators?.map((v)=>v.privateKey) ?? []);
126
+ config.peerCheckIntervalMS = TEST_PEER_CHECK_INTERVAL_MS;
127
+ config.maxPendingTxCount = opts.maxPendingTxCount ?? TEST_MAX_PENDING_TX_POOL_COUNT;
128
+ // For tests we only want proving enabled if specifically requested
129
+ config.realProofs = !!opts.realProofs;
130
+ // Only enforce the time table if requested
131
+ config.enforceTimeTable = !!opts.enforceTimeTable;
132
+ config.listenAddress = '127.0.0.1';
133
+ const logger = getLogger();
134
+ // Create a temp directory for any services that need it and cleanup later
135
+ const directoryToCleanup = path.join(tmpdir(), randomBytes(8).toString('hex'));
136
+ await fs.mkdir(directoryToCleanup, {
137
+ recursive: true
138
+ });
139
+ if (!config.dataDirectory) {
140
+ config.dataDirectory = directoryToCleanup;
141
+ }
142
+ if (!config.l1RpcUrls?.length) {
143
+ if (!isAnvilTestChain(chain.id)) {
144
+ throw new Error(`No ETHEREUM_HOSTS set but non anvil chain requested`);
145
+ }
146
+ const res = await startAnvil({
147
+ l1BlockTime: opts.ethereumSlotDuration,
148
+ accounts: opts.anvilAccounts,
149
+ port: opts.anvilPort ?? (process.env.ANVIL_PORT ? parseInt(process.env.ANVIL_PORT) : undefined)
150
+ });
151
+ anvil = res.anvil;
152
+ config.l1RpcUrls = [
153
+ res.rpcUrl
154
+ ];
155
+ }
156
+ // Enable logging metrics to a local file named after the test suite
157
+ if (isMetricsLoggingRequested()) {
158
+ const filename = path.join('log', getJobName() + '.jsonl');
159
+ logger.info(`Logging metrics to ${filename}`);
160
+ setupMetricsLogger(filename);
161
+ }
162
+ const dateProvider = new TestDateProvider();
163
+ const ethCheatCodes = new EthCheatCodesWithState(config.l1RpcUrls, dateProvider);
164
+ if (opts.stateLoad) {
165
+ await ethCheatCodes.loadChainState(opts.stateLoad);
166
+ }
167
+ if (opts.l1StartTime) {
168
+ await ethCheatCodes.warp(opts.l1StartTime, {
169
+ resetBlockInterval: true
170
+ });
171
+ }
172
+ let publisherPrivKeyHex = undefined;
173
+ let publisherHdAccount = undefined;
174
+ if (opts.l1PublisherKey && opts.l1PublisherKey.getValue() && opts.l1PublisherKey.getValue() != NULL_KEY) {
175
+ publisherPrivKeyHex = opts.l1PublisherKey.getValue();
176
+ publisherHdAccount = privateKeyToAccount(publisherPrivKeyHex);
177
+ } else if (config.publisherPrivateKeys && config.publisherPrivateKeys.length > 0 && config.publisherPrivateKeys[0].getValue() != NULL_KEY) {
178
+ publisherPrivKeyHex = config.publisherPrivateKeys[0].getValue();
179
+ publisherHdAccount = privateKeyToAccount(publisherPrivKeyHex);
180
+ } else if (!MNEMONIC) {
181
+ throw new Error(`Mnemonic not provided and no publisher private key`);
182
+ } else {
183
+ publisherHdAccount = mnemonicToAccount(MNEMONIC, {
184
+ addressIndex: 0
185
+ });
186
+ const publisherPrivKeyRaw = publisherHdAccount.getHdKey().privateKey;
187
+ const publisherPrivKey = publisherPrivKeyRaw === null ? null : Buffer.from(publisherPrivKeyRaw);
188
+ publisherPrivKeyHex = `0x${publisherPrivKey.toString('hex')}`;
189
+ config.publisherPrivateKeys = [
190
+ new SecretValue(publisherPrivKeyHex)
191
+ ];
192
+ }
193
+ if (config.coinbase === undefined) {
194
+ config.coinbase = EthAddress.fromString(publisherHdAccount.address);
195
+ }
196
+ // Determine which addresses to fund in genesis
197
+ const initialFundedAccounts = opts.initialFundedAccounts ?? await generateSchnorrAccounts(opts.numberOfInitialFundedAccounts ?? Math.max(numberOfAccounts, 10));
198
+ const addressesToFund = initialFundedAccounts.map((a)=>a.address);
199
+ // Optionally fund the sponsored FPC
200
+ if (opts.fundSponsoredFPC) {
201
+ const sponsoredFPCAddress = await getSponsoredFPCAddress();
202
+ addressesToFund.push(sponsoredFPCAddress);
203
+ }
204
+ const { genesisArchiveRoot, prefilledPublicData, fundingNeeded } = await getGenesisValues(addressesToFund, opts.initialAccountFeeJuice, opts.genesisPublicData);
205
+ const wasAutomining = await ethCheatCodes.isAutoMining();
206
+ const enableAutomine = opts.automineL1Setup && !wasAutomining && isAnvilTestChain(chain.id);
207
+ if (enableAutomine) {
208
+ await ethCheatCodes.setAutomine(true);
209
+ }
210
+ const l1Client = createExtendedL1Client(config.l1RpcUrls, publisherHdAccount, chain);
211
+ // Deploy Multicall3 if running locally
212
+ await deployMulticall3(l1Client, logger);
213
+ // Force viem to refresh its nonce cache to avoid "nonce too low" errors in subsequent transactions
214
+ // This is necessary because deployMulticall3 sends multiple transactions and viem may cache a stale nonce
215
+ await l1Client.getTransactionCount({
216
+ address: l1Client.account.address
217
+ });
218
+ const deployL1ContractsValues = await deployAztecL1Contracts(config.l1RpcUrls[0], publisherPrivKeyHex, chain.id, {
219
+ ...getL1ContractsConfigEnvVars(),
220
+ ...opts,
221
+ ...opts.l1ContractsArgs,
222
+ vkTreeRoot: getVKTreeRoot(),
223
+ protocolContractsHash,
224
+ genesisArchiveRoot,
225
+ initialValidators: opts.initialValidators,
226
+ feeJuicePortalInitialBalance: fundingNeeded,
227
+ realVerifier: false
228
+ });
229
+ config.l1Contracts = deployL1ContractsValues.l1ContractAddresses;
230
+ config.rollupVersion = deployL1ContractsValues.rollupVersion;
231
+ if (enableAutomine) {
232
+ await ethCheatCodes.setAutomine(false);
233
+ await ethCheatCodes.setIntervalMining(config.ethereumSlotDuration);
234
+ dateProvider.setTime(await ethCheatCodes.timestamp() * 1000);
235
+ }
236
+ if (opts.l2StartTime) {
237
+ await ethCheatCodes.warp(opts.l2StartTime, {
238
+ resetBlockInterval: true
239
+ });
240
+ }
241
+ const watcher = new AnvilTestWatcher(new EthCheatCodesWithState(config.l1RpcUrls, dateProvider), deployL1ContractsValues.l1ContractAddresses.rollupAddress, deployL1ContractsValues.l1Client, dateProvider);
242
+ if (!opts.disableAnvilTestWatcher) {
243
+ await watcher.start();
244
+ }
245
+ // Use metricsPort-based telemetry if provided, otherwise use the regular telemetry client
246
+ const telemetryClient = opts.metricsPort ? await getEndToEndTestTelemetryClient(opts.metricsPort) : await getTelemetryClient(opts.telemetryConfig);
247
+ await setupSharedBlobStorage(config);
248
+ logger.verbose('Creating and synching an aztec node', config);
249
+ const acvmConfig = await getACVMConfig(logger);
250
+ if (acvmConfig) {
251
+ config.acvmWorkingDirectory = acvmConfig.acvmWorkingDirectory;
252
+ config.acvmBinaryPath = acvmConfig.acvmBinaryPath;
253
+ }
254
+ const bbConfig = await getBBConfig(logger);
255
+ if (bbConfig) {
256
+ config.bbBinaryPath = bbConfig.bbBinaryPath;
257
+ config.bbWorkingDirectory = bbConfig.bbWorkingDirectory;
258
+ }
259
+ let mockGossipSubNetwork;
260
+ let p2pClientDeps = undefined;
261
+ if (opts.mockGossipSubNetwork) {
262
+ mockGossipSubNetwork = new MockGossipSubNetwork();
263
+ p2pClientDeps = {
264
+ p2pServiceFactory: getMockPubSubP2PServiceFactory(mockGossipSubNetwork)
265
+ };
266
+ }
267
+ // Transactions built against the genesis state must be included in block 1, otherwise they are dropped.
268
+ // To avoid test failures from dropped transactions, we ensure progression beyond genesis before proceeding.
269
+ // For account deployments, we set minTxsPerBlock=1 and deploy accounts sequentially for guaranteed success.
270
+ // If no accounts need deployment, we await an empty block to confirm network progression.
271
+ const originalMinTxsPerBlock = config.minTxsPerBlock;
272
+ if (originalMinTxsPerBlock === undefined) {
273
+ throw new Error('minTxsPerBlock is undefined in e2e test setup');
274
+ }
275
+ // Only set minTxsPerBlock=1 if we're going to deploy accounts and need reliable block inclusion
276
+ const shouldDeployAccounts = numberOfAccounts > 0 && !opts.skipAccountDeployment;
277
+ // Only set minTxsPerBlock=0 if we need an empty block (no accounts at all, not skipped deployment)
278
+ const needsEmptyBlock = numberOfAccounts === 0 && !opts.skipAccountDeployment;
279
+ config.minTxsPerBlock = shouldDeployAccounts ? 1 : needsEmptyBlock ? 0 : originalMinTxsPerBlock;
280
+ config.p2pEnabled = opts.mockGossipSubNetwork || config.p2pEnabled;
281
+ config.p2pIp = opts.p2pIp ?? config.p2pIp ?? '127.0.0.1';
282
+ if (!config.disableValidator) {
283
+ if ((config.validatorPrivateKeys?.getValue().length ?? 0) === 0) {
284
+ config.validatorPrivateKeys = new SecretValue([
285
+ generatePrivateKey()
286
+ ]);
287
+ }
288
+ }
289
+ const aztecNodeService = await withLoggerBindings({
290
+ actor: 'node-0'
291
+ }, ()=>AztecNodeService.createAndSync(config, {
292
+ dateProvider,
293
+ telemetry: telemetryClient,
294
+ p2pClientDeps
295
+ }, {
296
+ prefilledPublicData
297
+ }));
298
+ const sequencerClient = aztecNodeService.getSequencer();
299
+ if (sequencerClient) {
300
+ const publisher = sequencerClient.sequencer.publisher;
301
+ publisher.l1TxUtils = DelayedTxUtils.fromL1TxUtils(publisher.l1TxUtils, config.ethereumSlotDuration, l1Client);
302
+ }
303
+ let proverNode = undefined;
304
+ if (opts.startProverNode) {
305
+ logger.verbose('Creating and syncing a simulated prover node...');
306
+ const proverNodePrivateKey = getPrivateKeyFromIndex(2);
307
+ const proverNodePrivateKeyHex = `0x${proverNodePrivateKey.toString('hex')}`;
308
+ const proverNodeDataDirectory = path.join(directoryToCleanup, randomBytes(8).toString('hex'));
309
+ const proverNodeConfig = {
310
+ ...config.proverNodeConfig,
311
+ dataDirectory: proverNodeDataDirectory,
312
+ p2pEnabled: !!mockGossipSubNetwork
313
+ };
314
+ proverNode = await createAndSyncProverNode(proverNodePrivateKeyHex, config, proverNodeConfig, aztecNodeService, prefilledPublicData, {
315
+ p2pClientDeps: mockGossipSubNetwork ? {
316
+ p2pServiceFactory: getMockPubSubP2PServiceFactory(mockGossipSubNetwork)
317
+ } : undefined
318
+ });
319
+ }
320
+ logger.verbose('Creating a pxe...');
321
+ const pxeConfig = {
322
+ ...getPXEConfig(),
323
+ ...pxeOpts
324
+ };
325
+ pxeConfig.dataDirectory = path.join(directoryToCleanup, randomBytes(8).toString('hex'));
326
+ // For tests we only want proving enabled if specifically requested
327
+ pxeConfig.proverEnabled = !!pxeOpts.proverEnabled;
328
+ const wallet = await TestWallet.create(aztecNodeService, pxeConfig, {
329
+ loggerActorLabel: 'pxe-0'
330
+ });
331
+ if (opts.walletMinFeePadding !== undefined) {
332
+ wallet.setMinFeePadding(opts.walletMinFeePadding);
333
+ }
334
+ const cheatCodes = await CheatCodes.create(config.l1RpcUrls, aztecNodeService, dateProvider);
335
+ if (opts.aztecTargetCommitteeSize && opts.aztecTargetCommitteeSize > 0 || opts.initialValidators && opts.initialValidators.length > 0) {
336
+ // We need to advance such that the committee is set up.
337
+ await cheatCodes.rollup.advanceToEpoch(EpochNumber.fromBigInt(BigInt(await cheatCodes.rollup.getEpoch()) + BigInt(config.lagInEpochsForValidatorSet + 1)));
338
+ await cheatCodes.rollup.setupEpoch();
339
+ await cheatCodes.rollup.debugRollup();
340
+ }
341
+ let accounts = [];
342
+ if (shouldDeployAccounts) {
343
+ logger.info(`${numberOfAccounts} accounts are being deployed. Reliably progressing past genesis by setting minTxsPerBlock to 1 and waiting for the accounts to be deployed`);
344
+ const accountsData = initialFundedAccounts.slice(0, numberOfAccounts);
345
+ const accountManagers = await deployFundedSchnorrAccounts(wallet, accountsData);
346
+ accounts = accountManagers.map((accountManager)=>accountManager.address);
347
+ } else if (needsEmptyBlock) {
348
+ logger.info('No accounts are being deployed, waiting for an empty block 1 to be mined');
349
+ while(await aztecNodeService.getBlockNumber() === 0){
350
+ await sleep(2000);
351
+ }
352
+ }
353
+ // If skipAccountDeployment is true, we don't deploy or wait - tests will handle account deployment later
354
+ // Now we restore the original minTxsPerBlock setting if we changed it.
355
+ if (sequencerClient && config.minTxsPerBlock !== originalMinTxsPerBlock) {
356
+ sequencerClient.getSequencer().updateConfig({
357
+ minTxsPerBlock: originalMinTxsPerBlock
358
+ });
359
+ }
360
+ if (initialFundedAccounts.length < numberOfAccounts) {
361
+ throw new Error(`Unable to deploy ${numberOfAccounts} accounts. Only ${initialFundedAccounts.length} accounts were funded.`);
362
+ }
363
+ const teardown = async ()=>{
364
+ try {
365
+ await tryStop(wallet, logger);
366
+ await tryStop(aztecNodeService, logger);
367
+ await tryStop(proverNode, logger);
368
+ if (acvmConfig?.cleanup) {
369
+ await acvmConfig.cleanup();
370
+ }
371
+ if (bbConfig?.cleanup) {
372
+ await bbConfig.cleanup();
373
+ }
374
+ await tryStop(watcher, logger);
375
+ await tryStop(anvil, logger);
376
+ await tryRmDir(directoryToCleanup, logger);
377
+ } catch (err) {
378
+ logger.error(`Error during e2e test teardown`, err);
379
+ } finally{
380
+ try {
381
+ await telemetryClient.stop();
382
+ } catch (err) {
383
+ logger.error(`Error during telemetry client stop`, err);
384
+ }
385
+ }
386
+ };
387
+ return {
388
+ anvil,
389
+ aztecNode: aztecNodeService,
390
+ aztecNodeService,
391
+ aztecNodeAdmin: aztecNodeService,
392
+ cheatCodes,
393
+ ethCheatCodes,
394
+ config,
395
+ aztecNodeConfig: config,
396
+ dateProvider,
397
+ deployL1ContractsValues,
398
+ initialFundedAccounts,
399
+ logger,
400
+ mockGossipSubNetwork,
401
+ prefilledPublicData,
402
+ proverNode,
403
+ sequencer: sequencerClient,
404
+ teardown,
405
+ telemetryClient,
406
+ wallet,
407
+ accounts,
408
+ watcher,
409
+ acvmConfig,
410
+ bbConfig,
411
+ directoryToCleanup
412
+ };
413
+ } catch (err) {
414
+ await anvil?.stop();
415
+ throw err;
416
+ }
417
+ }
418
+ /** Returns the job name for the current test. */ function getJobName() {
419
+ return process.env.JOB_NAME ?? expect.getState().currentTestName?.split(' ')[0].replaceAll('/', '_') ?? 'unknown';
420
+ }
421
+ /**
422
+ * Returns a logger instance for the current test.
423
+ */ export function getLogger() {
424
+ const describeBlockName = expect.getState().currentTestName?.split(' ')[0].replaceAll('/', ':');
425
+ if (!describeBlockName) {
426
+ const name = expect.getState().testPath?.split('/').pop()?.split('.')[0] ?? 'unknown';
427
+ return createLogger('e2e:' + name);
428
+ }
429
+ return createLogger('e2e:' + describeBlockName);
430
+ }
431
+ /**
432
+ * Computes the address of the "canonical" SponsoredFPCContract.
433
+ */ export function getSponsoredFPCInstance() {
434
+ return Promise.resolve(getContractInstanceFromInstantiationParams(SponsoredFPCContract.artifact, {
435
+ salt: new Fr(SPONSORED_FPC_SALT)
436
+ }));
437
+ }
438
+ /**
439
+ * Computes the address of the "canonical" SponsoredFPCContract.
440
+ */ export async function getSponsoredFPCAddress() {
441
+ const sponsoredFPCInstance = await getSponsoredFPCInstance();
442
+ return sponsoredFPCInstance.address;
443
+ }
444
+ /**
445
+ * Deploy a sponsored FPC contract to a running instance.
446
+ */ export async function setupSponsoredFPC(wallet) {
447
+ const instance = await getContractInstanceFromInstantiationParams(SponsoredFPCContract.artifact, {
448
+ salt: new Fr(SPONSORED_FPC_SALT)
449
+ });
450
+ await wallet.registerContract(instance, SponsoredFPCContract.artifact);
451
+ getLogger().info(`SponsoredFPC: ${instance.address}`);
452
+ return instance;
453
+ }
454
+ /**
455
+ * Registers the SponsoredFPC in this PXE instance.
456
+ */ export async function registerSponsoredFPC(wallet) {
457
+ await wallet.registerContract(await getSponsoredFPCInstance(), SponsoredFPCContract.artifact);
458
+ }
459
+ export async function waitForProvenChain(node, targetBlock, timeoutSec = 60, intervalSec = 1) {
460
+ targetBlock ??= await node.getBlockNumber();
461
+ await retryUntil(async ()=>await node.getProvenBlockNumber() >= targetBlock, 'proven chain status', timeoutSec, intervalSec);
462
+ }
463
+ export function createAndSyncProverNode(proverNodePrivateKey, aztecNodeConfig, proverNodeConfig, aztecNode, prefilledPublicData = [], proverNodeDeps = {}) {
464
+ return withLoggerBindings({
465
+ actor: 'prover-0'
466
+ }, async ()=>{
467
+ const aztecNodeTxProvider = aztecNode && {
468
+ getTxByHash: aztecNode.getTxByHash.bind(aztecNode),
469
+ getTxsByHash: aztecNode.getTxsByHash.bind(aztecNode),
470
+ stop: ()=>Promise.resolve()
471
+ };
472
+ const blobClient = await createBlobClientWithFileStores(aztecNodeConfig, createLogger('blob-client:prover-node'));
473
+ const archiverConfig = {
474
+ ...aztecNodeConfig,
475
+ dataDirectory: proverNodeConfig.dataDirectory
476
+ };
477
+ const archiver = await createArchiver(archiverConfig, {
478
+ blobClient,
479
+ dateProvider: proverNodeDeps.dateProvider
480
+ }, {
481
+ blockUntilSync: true
482
+ });
483
+ const proverConfig = {
484
+ ...aztecNodeConfig,
485
+ txCollectionNodeRpcUrls: [],
486
+ realProofs: false,
487
+ proverAgentCount: 2,
488
+ publisherPrivateKeys: [
489
+ new SecretValue(proverNodePrivateKey)
490
+ ],
491
+ proverNodeMaxPendingJobs: 10,
492
+ proverNodeMaxParallelBlocksPerEpoch: 32,
493
+ proverNodePollingIntervalMs: 200,
494
+ txGatheringIntervalMs: 1000,
495
+ txGatheringBatchSize: 10,
496
+ txGatheringMaxParallelRequestsPerNode: 10,
497
+ txGatheringTimeoutMs: 24_000,
498
+ proverNodeFailedEpochStore: undefined,
499
+ proverId: EthAddress.fromNumber(1),
500
+ proverNodeEpochProvingDelayMs: undefined,
501
+ ...proverNodeConfig
502
+ };
503
+ const l1TxUtils = createDelayedL1TxUtils(aztecNodeConfig, proverNodePrivateKey, 'prover-node', proverNodeDeps.dateProvider);
504
+ const proverNode = await createProverNode(proverConfig, {
505
+ ...proverNodeDeps,
506
+ aztecNodeTxProvider,
507
+ archiver: archiver,
508
+ l1TxUtils
509
+ }, {
510
+ prefilledPublicData
511
+ });
512
+ getLogger().info(`Created and synced prover node`, {
513
+ publisherAddress: l1TxUtils.client.account.address
514
+ });
515
+ if (!proverNodeConfig.dontStart) {
516
+ await proverNode.start();
517
+ }
518
+ return proverNode;
519
+ });
520
+ }
521
+ function createDelayedL1TxUtils(aztecNodeConfig, privateKey, logName, dateProvider) {
522
+ const l1Client = createExtendedL1Client(aztecNodeConfig.l1RpcUrls, privateKey, foundry);
523
+ const log = createLogger(logName);
524
+ const l1TxUtils = createDelayedL1TxUtilsFromViemWallet(l1Client, log, dateProvider, aztecNodeConfig);
525
+ l1TxUtils.enableDelayer(aztecNodeConfig.ethereumSlotDuration);
526
+ return l1TxUtils;
527
+ }
528
+ export function getBalancesFn(symbol, method, from, logger) {
529
+ const balances = async (...addressLikes)=>{
530
+ const addresses = addressLikes.map((addressLike)=>'address' in addressLike ? addressLike.address : addressLike);
531
+ const b = await Promise.all(addresses.map((address)=>method(address).simulate({
532
+ from
533
+ })));
534
+ const debugString = `${symbol} balances: ${addresses.map((address, i)=>`${address}: ${b[i]}`).join(', ')}`;
535
+ logger.verbose(debugString);
536
+ return b;
537
+ };
538
+ return balances;
539
+ }
540
+ export async function expectMapping(fn, inputs, expectedOutputs) {
541
+ expect(inputs.length).toBe(expectedOutputs.length);
542
+ const outputs = await fn(...inputs);
543
+ expect(outputs).toEqual(expectedOutputs);
544
+ }
545
+ export async function expectMappingDelta(initialValues, fn, inputs, expectedDiffs) {
546
+ expect(inputs.length).toBe(expectedDiffs.length);
547
+ const outputs = await fn(...inputs);
548
+ const diffs = outputs.map((output, i)=>output - initialValues[i]);
549
+ expect(diffs).toEqual(expectedDiffs);
550
+ }
551
+ /**
552
+ * Registers the contract class used for test accounts and publicly deploys the instances requested.
553
+ * Use this when you need to make a public call to an account contract, such as for requesting a public authwit.
554
+ */ export async function ensureAccountContractsPublished(wallet, accountsToDeploy) {
555
+ const accountsAndAddresses = await Promise.all(accountsToDeploy.map(async (address)=>{
556
+ return {
557
+ address,
558
+ deployed: (await wallet.getContractMetadata(address)).isContractPublished
559
+ };
560
+ }));
561
+ const instances = (await Promise.all(accountsAndAddresses.filter(({ deployed })=>!deployed).map(({ address })=>wallet.getContractMetadata(address)))).map((contractMetadata)=>contractMetadata.instance);
562
+ const contractClass = await getContractClassFromArtifact(SchnorrAccountContractArtifact);
563
+ if (!(await wallet.getContractClassMetadata(contractClass.id)).isContractClassPubliclyRegistered) {
564
+ await (await publishContractClass(wallet, SchnorrAccountContractArtifact)).send({
565
+ from: accountsToDeploy[0]
566
+ });
567
+ }
568
+ const requests = instances.map((instance)=>publishInstance(wallet, instance));
569
+ const batch = new BatchCall(wallet, requests);
570
+ await batch.send({
571
+ from: accountsToDeploy[0]
572
+ });
573
+ }
574
+ /**
575
+ * Helper function to deploy accounts.
576
+ * Returns deployed account data that can be used by tests.
577
+ */ export const deployAccounts = (numberOfAccounts, logger)=>async ({ wallet, initialFundedAccounts })=>{
578
+ if (initialFundedAccounts.length < numberOfAccounts) {
579
+ throw new Error(`Cannot deploy more than ${initialFundedAccounts.length} initial accounts.`);
580
+ }
581
+ logger.verbose('Deploying accounts funded with fee juice...');
582
+ const deployedAccounts = initialFundedAccounts.slice(0, numberOfAccounts);
583
+ // Serial due to https://github.com/AztecProtocol/aztec-packages/issues/12045
584
+ for(let i = 0; i < deployedAccounts.length; i++){
585
+ const accountManager = await wallet.createSchnorrAccount(deployedAccounts[i].secret, deployedAccounts[i].salt, deployedAccounts[i].signingKey);
586
+ const deployMethod = await accountManager.getDeployMethod();
587
+ await deployMethod.send({
588
+ from: AztecAddress.ZERO,
589
+ skipClassPublication: i !== 0
590
+ });
591
+ }
592
+ return {
593
+ deployedAccounts
594
+ };
595
+ };
596
+ /**
597
+ * Registers the contract class used for test accounts and publicly deploys the instances requested.
598
+ * Use this when you need to make a public call to an account contract, such as for requesting a public authwit.
599
+ */ export async function publicDeployAccounts(wallet, accountsToDeploy, waitUntilProven = false, node) {
600
+ const instances = (await Promise.all(accountsToDeploy.map((account)=>wallet.getContractMetadata(account)))).map((metadata)=>metadata.instance);
601
+ const contractClass = await getContractClassFromArtifact(SchnorrAccountContractArtifact);
602
+ const alreadyRegistered = (await wallet.getContractClassMetadata(contractClass.id)).isContractClassPubliclyRegistered;
603
+ const calls = await Promise.all([
604
+ ...!alreadyRegistered ? [
605
+ publishContractClass(wallet, SchnorrAccountContractArtifact)
606
+ ] : [],
607
+ ...instances.map((instance)=>publishInstance(wallet, instance))
608
+ ]);
609
+ const batch = new BatchCall(wallet, calls);
610
+ const txReceipt = await batch.send({
611
+ from: accountsToDeploy[0]
612
+ });
613
+ if (waitUntilProven) {
614
+ if (!node) {
615
+ throw new Error('Need to provide an AztecNode to wait for proven.');
616
+ } else {
617
+ await waitForProven(node, txReceipt);
618
+ }
619
+ }
620
+ }
621
+ /**
622
+ * Destroys the current context.
623
+ */ export async function teardown(context) {
624
+ if (!context) {
625
+ return;
626
+ }
627
+ await context.teardown();
628
+ }
629
+ // Re-export for backward compatibility
630
+ export { deployAndInitializeTokenAndBridgeContracts } from '../shared/cross_chain_test_harness.js';