@aztec/end-to-end 0.0.1-commit.b655e406 → 0.0.1-commit.d1f2d6c

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 (209) 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 +21 -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 +129 -119
  7. package/dest/bench/client_flows/config.d.ts +1 -1
  8. package/dest/bench/client_flows/data_extractor.d.ts +1 -1
  9. package/dest/bench/client_flows/data_extractor.js +7 -27
  10. package/dest/bench/utils.d.ts +8 -7
  11. package/dest/bench/utils.d.ts.map +1 -1
  12. package/dest/bench/utils.js +27 -18
  13. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +6 -7
  14. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts.map +1 -1
  15. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.js +96 -112
  16. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +19 -13
  17. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts.map +1 -1
  18. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.js +91 -70
  19. package/dest/e2e_deploy_contract/deploy_test.d.ts +5 -4
  20. package/dest/e2e_deploy_contract/deploy_test.d.ts.map +1 -1
  21. package/dest/e2e_deploy_contract/deploy_test.js +18 -13
  22. package/dest/e2e_epochs/epochs_test.d.ts +11 -9
  23. package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
  24. package/dest/e2e_epochs/epochs_test.js +22 -16
  25. package/dest/e2e_fees/bridging_race.notest.d.ts +1 -1
  26. package/dest/e2e_fees/bridging_race.notest.js +5 -7
  27. package/dest/e2e_fees/fees_test.d.ts +20 -16
  28. package/dest/e2e_fees/fees_test.d.ts.map +1 -1
  29. package/dest/e2e_fees/fees_test.js +127 -139
  30. package/dest/e2e_l1_publisher/write_json.d.ts +2 -2
  31. package/dest/e2e_l1_publisher/write_json.d.ts.map +1 -1
  32. package/dest/e2e_l1_publisher/write_json.js +23 -18
  33. package/dest/e2e_multi_validator/utils.d.ts +1 -1
  34. package/dest/e2e_multi_validator/utils.js +1 -1
  35. package/dest/e2e_nested_contract/nested_contract_test.d.ts +6 -9
  36. package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +1 -1
  37. package/dest/e2e_nested_contract/nested_contract_test.js +31 -38
  38. package/dest/e2e_p2p/inactivity_slash_test.d.ts +3 -3
  39. package/dest/e2e_p2p/inactivity_slash_test.d.ts.map +1 -1
  40. package/dest/e2e_p2p/inactivity_slash_test.js +7 -6
  41. package/dest/e2e_p2p/p2p_network.d.ts +225 -18
  42. package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
  43. package/dest/e2e_p2p/p2p_network.js +119 -109
  44. package/dest/e2e_p2p/shared.d.ts +11 -11
  45. package/dest/e2e_p2p/shared.d.ts.map +1 -1
  46. package/dest/e2e_p2p/shared.js +13 -19
  47. package/dest/e2e_token_contract/token_contract_test.d.ts +16 -9
  48. package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -1
  49. package/dest/e2e_token_contract/token_contract_test.js +89 -91
  50. package/dest/fixtures/e2e_prover_test.d.ts +12 -18
  51. package/dest/fixtures/e2e_prover_test.d.ts.map +1 -1
  52. package/dest/fixtures/e2e_prover_test.js +100 -108
  53. package/dest/fixtures/fixtures.d.ts +2 -3
  54. package/dest/fixtures/fixtures.d.ts.map +1 -1
  55. package/dest/fixtures/fixtures.js +2 -3
  56. package/dest/fixtures/get_acvm_config.d.ts +1 -1
  57. package/dest/fixtures/get_acvm_config.js +1 -1
  58. package/dest/fixtures/get_bb_config.d.ts +1 -1
  59. package/dest/fixtures/get_bb_config.d.ts.map +1 -1
  60. package/dest/fixtures/index.d.ts +1 -1
  61. package/dest/fixtures/l1_to_l2_messaging.d.ts +4 -3
  62. package/dest/fixtures/l1_to_l2_messaging.d.ts.map +1 -1
  63. package/dest/fixtures/l1_to_l2_messaging.js +2 -2
  64. package/dest/fixtures/logging.d.ts +1 -1
  65. package/dest/fixtures/setup.d.ts +216 -0
  66. package/dest/fixtures/setup.d.ts.map +1 -0
  67. package/dest/fixtures/setup.js +684 -0
  68. package/dest/fixtures/setup_p2p_test.d.ts +4 -4
  69. package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
  70. package/dest/fixtures/setup_p2p_test.js +18 -10
  71. package/dest/fixtures/token_utils.d.ts +5 -2
  72. package/dest/fixtures/token_utils.d.ts.map +1 -1
  73. package/dest/fixtures/token_utils.js +13 -7
  74. package/dest/fixtures/utils.d.ts +5 -192
  75. package/dest/fixtures/utils.d.ts.map +1 -1
  76. package/dest/fixtures/utils.js +4 -648
  77. package/dest/fixtures/web3signer.d.ts +1 -1
  78. package/dest/fixtures/web3signer.js +1 -1
  79. package/dest/fixtures/with_telemetry_utils.d.ts +2 -2
  80. package/dest/fixtures/with_telemetry_utils.d.ts.map +1 -1
  81. package/dest/fixtures/with_telemetry_utils.js +2 -2
  82. package/dest/index.d.ts +1 -1
  83. package/dest/quality_of_service/grafana_client.d.ts +41 -0
  84. package/dest/quality_of_service/grafana_client.d.ts.map +1 -0
  85. package/dest/quality_of_service/{alert_checker.js → grafana_client.js} +1 -1
  86. package/dest/quality_of_service/prometheus_client.d.ts +38 -0
  87. package/dest/quality_of_service/prometheus_client.d.ts.map +1 -0
  88. package/dest/quality_of_service/prometheus_client.js +67 -0
  89. package/dest/shared/cross_chain_test_harness.d.ts +7 -6
  90. package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
  91. package/dest/shared/cross_chain_test_harness.js +14 -14
  92. package/dest/shared/gas_portal_test_harness.d.ts +2 -2
  93. package/dest/shared/gas_portal_test_harness.d.ts.map +1 -1
  94. package/dest/shared/gas_portal_test_harness.js +2 -2
  95. package/dest/shared/index.d.ts +2 -2
  96. package/dest/shared/index.d.ts.map +1 -1
  97. package/dest/shared/jest_setup.d.ts +1 -1
  98. package/dest/shared/submit-transactions.d.ts +3 -3
  99. package/dest/shared/submit-transactions.d.ts.map +1 -1
  100. package/dest/shared/submit-transactions.js +9 -11
  101. package/dest/shared/uniswap_l1_l2.d.ts +3 -27
  102. package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
  103. package/dest/shared/uniswap_l1_l2.js +55 -35
  104. package/dest/simulators/index.d.ts +1 -1
  105. package/dest/simulators/lending_simulator.d.ts +2 -2
  106. package/dest/simulators/lending_simulator.d.ts.map +1 -1
  107. package/dest/simulators/lending_simulator.js +6 -4
  108. package/dest/simulators/token_simulator.d.ts +1 -1
  109. package/dest/simulators/token_simulator.d.ts.map +1 -1
  110. package/dest/spartan/setup_test_wallets.d.ts +8 -5
  111. package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
  112. package/dest/spartan/setup_test_wallets.js +85 -23
  113. package/dest/spartan/tx_metrics.d.ts +54 -0
  114. package/dest/spartan/tx_metrics.d.ts.map +1 -0
  115. package/dest/spartan/tx_metrics.js +272 -0
  116. package/dest/spartan/utils/bot.d.ts +27 -0
  117. package/dest/spartan/utils/bot.d.ts.map +1 -0
  118. package/dest/spartan/utils/bot.js +141 -0
  119. package/dest/spartan/utils/chaos.d.ts +79 -0
  120. package/dest/spartan/utils/chaos.d.ts.map +1 -0
  121. package/dest/spartan/utils/chaos.js +142 -0
  122. package/dest/spartan/utils/clients.d.ts +39 -0
  123. package/dest/spartan/utils/clients.d.ts.map +1 -0
  124. package/dest/spartan/utils/clients.js +90 -0
  125. package/dest/spartan/utils/config.d.ts +36 -0
  126. package/dest/spartan/utils/config.d.ts.map +1 -0
  127. package/dest/spartan/utils/config.js +20 -0
  128. package/dest/spartan/utils/health.d.ts +63 -0
  129. package/dest/spartan/utils/health.d.ts.map +1 -0
  130. package/dest/spartan/utils/health.js +202 -0
  131. package/dest/spartan/utils/helm.d.ts +15 -0
  132. package/dest/spartan/utils/helm.d.ts.map +1 -0
  133. package/dest/spartan/utils/helm.js +47 -0
  134. package/dest/spartan/utils/index.d.ts +9 -0
  135. package/dest/spartan/utils/index.d.ts.map +1 -0
  136. package/dest/spartan/utils/index.js +18 -0
  137. package/dest/spartan/utils/k8s.d.ts +98 -0
  138. package/dest/spartan/utils/k8s.d.ts.map +1 -0
  139. package/dest/spartan/utils/k8s.js +257 -0
  140. package/dest/spartan/utils/nodes.d.ts +31 -0
  141. package/dest/spartan/utils/nodes.d.ts.map +1 -0
  142. package/dest/spartan/utils/nodes.js +290 -0
  143. package/dest/spartan/utils/scripts.d.ts +16 -0
  144. package/dest/spartan/utils/scripts.d.ts.map +1 -0
  145. package/dest/spartan/utils/scripts.js +66 -0
  146. package/dest/spartan/utils.d.ts +2 -218
  147. package/dest/spartan/utils.d.ts.map +1 -1
  148. package/dest/spartan/utils.js +1 -749
  149. package/package.json +43 -40
  150. package/src/bench/client_flows/benchmark.ts +24 -2
  151. package/src/bench/client_flows/client_flows_benchmark.ts +152 -170
  152. package/src/bench/client_flows/data_extractor.ts +6 -28
  153. package/src/bench/utils.ts +30 -20
  154. package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +104 -142
  155. package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +140 -124
  156. package/src/e2e_deploy_contract/deploy_test.ts +22 -15
  157. package/src/e2e_epochs/epochs_test.ts +67 -48
  158. package/src/e2e_fees/bridging_race.notest.ts +5 -11
  159. package/src/e2e_fees/fees_test.ts +180 -219
  160. package/src/e2e_l1_publisher/write_json.ts +25 -19
  161. package/src/e2e_multi_validator/utils.ts +1 -1
  162. package/src/e2e_nested_contract/nested_contract_test.ts +33 -55
  163. package/src/e2e_p2p/inactivity_slash_test.ts +10 -9
  164. package/src/e2e_p2p/p2p_network.ts +180 -180
  165. package/src/e2e_p2p/shared.ts +25 -27
  166. package/src/e2e_token_contract/token_contract_test.ts +103 -118
  167. package/src/fixtures/e2e_prover_test.ts +111 -149
  168. package/src/fixtures/fixtures.ts +2 -5
  169. package/src/fixtures/get_acvm_config.ts +1 -1
  170. package/src/fixtures/l1_to_l2_messaging.ts +4 -2
  171. package/src/fixtures/setup.ts +1006 -0
  172. package/src/fixtures/setup_p2p_test.ts +23 -9
  173. package/src/fixtures/token_utils.ts +8 -7
  174. package/src/fixtures/utils.ts +27 -947
  175. package/src/fixtures/web3signer.ts +1 -1
  176. package/src/fixtures/with_telemetry_utils.ts +2 -2
  177. package/src/guides/up_quick_start.sh +1 -1
  178. package/src/quality_of_service/{alert_checker.ts → grafana_client.ts} +1 -1
  179. package/src/quality_of_service/prometheus_client.ts +113 -0
  180. package/src/shared/cross_chain_test_harness.ts +19 -36
  181. package/src/shared/gas_portal_test_harness.ts +3 -3
  182. package/src/shared/index.ts +1 -1
  183. package/src/shared/submit-transactions.ts +9 -15
  184. package/src/shared/uniswap_l1_l2.ts +65 -86
  185. package/src/simulators/lending_simulator.ts +7 -5
  186. package/src/spartan/DEVELOP.md +7 -0
  187. package/src/spartan/setup_test_wallets.ts +119 -28
  188. package/src/spartan/tx_metrics.ts +250 -0
  189. package/src/spartan/utils/bot.ts +185 -0
  190. package/src/spartan/utils/chaos.ts +253 -0
  191. package/src/spartan/utils/clients.ts +100 -0
  192. package/src/spartan/utils/config.ts +26 -0
  193. package/src/spartan/utils/health.ts +255 -0
  194. package/src/spartan/utils/helm.ts +84 -0
  195. package/src/spartan/utils/index.ts +62 -0
  196. package/src/spartan/utils/k8s.ts +375 -0
  197. package/src/spartan/utils/nodes.ts +323 -0
  198. package/src/spartan/utils/scripts.ts +63 -0
  199. package/src/spartan/utils.ts +1 -942
  200. package/dest/fixtures/setup_l1_contracts.d.ts +0 -6
  201. package/dest/fixtures/setup_l1_contracts.d.ts.map +0 -1
  202. package/dest/fixtures/setup_l1_contracts.js +0 -17
  203. package/dest/fixtures/snapshot_manager.d.ts +0 -95
  204. package/dest/fixtures/snapshot_manager.d.ts.map +0 -1
  205. package/dest/fixtures/snapshot_manager.js +0 -505
  206. package/dest/quality_of_service/alert_checker.d.ts +0 -41
  207. package/dest/quality_of_service/alert_checker.d.ts.map +0 -1
  208. package/src/fixtures/setup_l1_contracts.ts +0 -26
  209. package/src/fixtures/snapshot_manager.ts +0 -665
@@ -1,6 +0,0 @@
1
- import type { Logger } from '@aztec/aztec.js/log';
2
- import { type DeployL1ContractsArgs, type L1ContractsConfig } from '@aztec/ethereum';
3
- import type { HDAccount, PrivateKeyAccount } from 'viem';
4
- export { deployAndInitializeTokenAndBridgeContracts } from '../shared/cross_chain_test_harness.js';
5
- export declare const setupL1Contracts: (l1RpcUrl: string, account: HDAccount | PrivateKeyAccount, logger: Logger, args: Pick<DeployL1ContractsArgs, "genesisArchiveRoot" | "initialValidators"> & L1ContractsConfig) => Promise<import("@aztec/ethereum").DeployL1ContractsReturnType>;
6
- //# sourceMappingURL=setup_l1_contracts.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"setup_l1_contracts.d.ts","sourceRoot":"","sources":["../../src/fixtures/setup_l1_contracts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,KAAK,qBAAqB,EAAE,KAAK,iBAAiB,EAAqB,MAAM,iBAAiB,CAAC;AAIxG,OAAO,KAAK,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;AAGzD,OAAO,EAAE,0CAA0C,EAAE,MAAM,uCAAuC,CAAC;AAEnG,eAAO,MAAM,gBAAgB,GAC3B,UAAU,MAAM,EAChB,SAAS,SAAS,GAAG,iBAAiB,EACtC,QAAQ,MAAM,EACd,MAAM,IAAI,CAAC,qBAAqB,EAAE,oBAAoB,GAAG,mBAAmB,CAAC,GAAG,iBAAiB,mEAWlG,CAAC"}
@@ -1,17 +0,0 @@
1
- import { deployL1Contracts } from '@aztec/ethereum';
2
- import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
3
- import { protocolContractsHash } from '@aztec/protocol-contracts';
4
- import { foundry } from 'viem/chains';
5
- export { deployAndInitializeTokenAndBridgeContracts } from '../shared/cross_chain_test_harness.js';
6
- export const setupL1Contracts = async (l1RpcUrl, account, logger, args)=>{
7
- const l1Data = await deployL1Contracts([
8
- l1RpcUrl
9
- ], account, foundry, logger, {
10
- vkTreeRoot: getVKTreeRoot(),
11
- protocolContractsHash,
12
- salt: undefined,
13
- realVerifier: false,
14
- ...args
15
- });
16
- return l1Data;
17
- };
@@ -1,95 +0,0 @@
1
- import { type InitialAccountData } from '@aztec/accounts/testing';
2
- import { type AztecNodeConfig, AztecNodeService } from '@aztec/aztec-node';
3
- import { AztecAddress } from '@aztec/aztec.js/addresses';
4
- import type { Logger } from '@aztec/aztec.js/log';
5
- import type { AztecNode } from '@aztec/aztec.js/node';
6
- import type { Wallet } from '@aztec/aztec.js/wallet';
7
- import { AnvilTestWatcher, CheatCodes } from '@aztec/aztec/testing';
8
- import { type BlobSinkServer } from '@aztec/blob-sink/server';
9
- import { type DeployL1ContractsArgs, type DeployL1ContractsReturnType } from '@aztec/ethereum';
10
- import { TestDateProvider } from '@aztec/foundation/timer';
11
- import type { ProverNode } from '@aztec/prover-node';
12
- import type { SequencerClient } from '@aztec/sequencer-client';
13
- import { TestWallet } from '@aztec/test-wallet/server';
14
- import type { Anvil } from '@viem/anvil';
15
- import { type SetupOptions } from './utils.js';
16
- export type SubsystemsContext = {
17
- anvil: Anvil;
18
- acvmConfig: any;
19
- bbConfig: any;
20
- aztecNode: AztecNodeService;
21
- aztecNodeConfig: AztecNodeConfig;
22
- wallet: TestWallet;
23
- deployL1ContractsValues: DeployL1ContractsReturnType;
24
- proverNode?: ProverNode;
25
- watcher: AnvilTestWatcher;
26
- cheatCodes: CheatCodes;
27
- sequencer: SequencerClient;
28
- dateProvider: TestDateProvider;
29
- blobSink: BlobSinkServer;
30
- initialFundedAccounts: InitialAccountData[];
31
- directoryToCleanup?: string;
32
- };
33
- export declare function createSnapshotManager(testName: string, dataPath?: string, config?: Partial<SetupOptions>, deployL1ContractsArgs?: Partial<DeployL1ContractsArgs>): SnapshotManager | MockSnapshotManager;
34
- export interface ISnapshotManager {
35
- snapshot<T>(name: string, apply: (context: SubsystemsContext) => Promise<T>, restore?: (snapshotData: T, context: SubsystemsContext) => Promise<void>): Promise<void>;
36
- setup(): Promise<SubsystemsContext>;
37
- teardown(): Promise<void>;
38
- }
39
- /** Snapshot manager that does not perform snapshotting, it just applies transition and restoration functions as it receives them. */
40
- declare class MockSnapshotManager implements ISnapshotManager {
41
- private config;
42
- private deployL1ContractsArgs;
43
- private context?;
44
- private logger;
45
- constructor(testName: string, config?: Partial<AztecNodeConfig>, deployL1ContractsArgs?: Partial<DeployL1ContractsArgs>);
46
- snapshot<T>(name: string, apply: (context: SubsystemsContext) => Promise<T>, restore?: (snapshotData: T, context: SubsystemsContext) => Promise<void>): Promise<void>;
47
- setup(): Promise<SubsystemsContext>;
48
- teardown(): Promise<void>;
49
- }
50
- /**
51
- * Snapshot engine for local e2e tests. Read more:
52
- * https://github.com/AztecProtocol/aztec-packages/pull/5526
53
- */
54
- declare class SnapshotManager implements ISnapshotManager {
55
- private dataPath;
56
- private config;
57
- private deployL1ContractsArgs;
58
- private snapshotStack;
59
- private context?;
60
- private livePath;
61
- private logger;
62
- constructor(testName: string, dataPath: string, config?: Partial<SetupOptions>, deployL1ContractsArgs?: Partial<DeployL1ContractsArgs>);
63
- snapshot<T>(name: string, apply: (context: SubsystemsContext) => Promise<T>, restore?: (snapshotData: T, context: SubsystemsContext) => Promise<void>): Promise<void>;
64
- /**
65
- * Creates and returns the subsystem context based on the current snapshot stack.
66
- * If the subsystem context already exists, just return it.
67
- * If you want to be sure to get a clean snapshot, be sure to call teardown() before calling setup().
68
- */
69
- setup(): Promise<SubsystemsContext>;
70
- /**
71
- * Destroys the current subsystem context.
72
- */
73
- teardown(): Promise<void>;
74
- }
75
- /**
76
- * Snapshot 'apply' helper function to add accounts.
77
- * The 'restore' function is not provided, as it must be a closure within the test context to capture the results.
78
- */
79
- export declare const deployAccounts: (numberOfAccounts: number, logger: Logger) => ({ wallet, initialFundedAccounts }: {
80
- wallet: TestWallet;
81
- initialFundedAccounts: InitialAccountData[];
82
- }) => Promise<{
83
- deployedAccounts: InitialAccountData[];
84
- }>;
85
- /**
86
- * Registers the contract class used for test accounts and publicly deploys the instances requested.
87
- * Use this when you need to make a public call to an account contract, such as for requesting a public authwit.
88
- * @param sender - Wallet to send the deployment tx.
89
- * @param accountsToDeploy - Which accounts to publicly deploy.
90
- * @param waitUntilProven - Whether to wait for the tx to be proven.
91
- * @param node - AztecNode used to wait for proven tx.
92
- */
93
- export declare function publicDeployAccounts(wallet: Wallet, accountsToDeploy: AztecAddress[], waitUntilProven?: boolean, node?: AztecNode): Promise<void>;
94
- export {};
95
- //# sourceMappingURL=snapshot_manager.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"snapshot_manager.d.ts","sourceRoot":"","sources":["../../src/fixtures/snapshot_manager.ts"],"names":[],"mappings":"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"}
@@ -1,505 +0,0 @@
1
- import { SchnorrAccountContractArtifact } from '@aztec/accounts/schnorr';
2
- import { generateSchnorrAccounts } from '@aztec/accounts/testing';
3
- import { AztecNodeService, getConfigEnvVars } from '@aztec/aztec-node';
4
- import { AztecAddress, EthAddress } from '@aztec/aztec.js/addresses';
5
- import { getContractClassFromArtifact } from '@aztec/aztec.js/contracts';
6
- import { BatchCall, waitForProven } from '@aztec/aztec.js/contracts';
7
- import { publishContractClass, publishInstance } from '@aztec/aztec.js/deployment';
8
- import { AnvilTestWatcher, CheatCodes } from '@aztec/aztec/testing';
9
- import { createBlobSinkServer } from '@aztec/blob-sink/server';
10
- import { createExtendedL1Client, deployMulticall3, getL1ContractsConfigEnvVars } from '@aztec/ethereum';
11
- import { EthCheatCodesWithState, startAnvil } from '@aztec/ethereum/test';
12
- import { asyncMap } from '@aztec/foundation/async-map';
13
- import { SecretValue } from '@aztec/foundation/config';
14
- import { randomBytes } from '@aztec/foundation/crypto';
15
- import { tryRmDir } from '@aztec/foundation/fs';
16
- import { createLogger } from '@aztec/foundation/log';
17
- import { resolver, reviver } from '@aztec/foundation/serialize';
18
- import { TestDateProvider } from '@aztec/foundation/timer';
19
- import { getPXEConfig } from '@aztec/pxe/server';
20
- import { tryStop } from '@aztec/stdlib/interfaces/server';
21
- import { getConfigEnvVars as getTelemetryConfig, initTelemetryClient } from '@aztec/telemetry-client';
22
- import { TestWallet } from '@aztec/test-wallet/server';
23
- import { getGenesisValues } from '@aztec/world-state/testing';
24
- import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'fs';
25
- import { copySync, removeSync } from 'fs-extra/esm';
26
- import fs from 'fs/promises';
27
- import getPort from 'get-port';
28
- import { tmpdir } from 'os';
29
- import path, { join } from 'path';
30
- import { mnemonicToAccount } from 'viem/accounts';
31
- import { foundry } from 'viem/chains';
32
- import { MNEMONIC, TEST_MAX_TX_POOL_SIZE, TEST_PEER_CHECK_INTERVAL_MS } from './fixtures.js';
33
- import { getACVMConfig } from './get_acvm_config.js';
34
- import { getBBConfig } from './get_bb_config.js';
35
- import { setupL1Contracts } from './setup_l1_contracts.js';
36
- import { createAndSyncProverNode, getLogger, getPrivateKeyFromIndex, getSponsoredFPCAddress } from './utils.js';
37
- import { getEndToEndTestTelemetryClient } from './with_telemetry_utils.js';
38
- export function createSnapshotManager(testName, dataPath, config = {}, deployL1ContractsArgs = {
39
- initialValidators: []
40
- }) {
41
- return dataPath ? new SnapshotManager(testName, dataPath, config, deployL1ContractsArgs) : new MockSnapshotManager(testName, config, deployL1ContractsArgs);
42
- }
43
- /** Snapshot manager that does not perform snapshotting, it just applies transition and restoration functions as it receives them. */ class MockSnapshotManager {
44
- config;
45
- deployL1ContractsArgs;
46
- context;
47
- logger;
48
- constructor(testName, config = {}, deployL1ContractsArgs = {}){
49
- this.config = config;
50
- this.deployL1ContractsArgs = deployL1ContractsArgs;
51
- this.logger = createLogger(`e2e:snapshot_manager:${testName}`);
52
- this.logger.warn(`No data path given, will not persist any snapshots.`);
53
- }
54
- async snapshot(name, apply, restore = ()=>Promise.resolve()) {
55
- // We are running in disabled mode. Just apply the state.
56
- const context = await this.setup();
57
- this.logger.verbose(`Applying state transition for ${name}...`);
58
- const snapshotData = await apply(context);
59
- this.logger.verbose(`State transition for ${name} complete.`);
60
- // Execute the restoration function.
61
- await restore(snapshotData, context);
62
- return;
63
- }
64
- async setup() {
65
- if (!this.context) {
66
- this.context = await setupFromFresh(undefined, this.logger, this.config, this.deployL1ContractsArgs);
67
- }
68
- return this.context;
69
- }
70
- async teardown() {
71
- await teardown(this.context);
72
- this.context = undefined;
73
- }
74
- }
75
- /**
76
- * Snapshot engine for local e2e tests. Read more:
77
- * https://github.com/AztecProtocol/aztec-packages/pull/5526
78
- */ class SnapshotManager {
79
- dataPath;
80
- config;
81
- deployL1ContractsArgs;
82
- snapshotStack;
83
- context;
84
- livePath;
85
- logger;
86
- constructor(testName, dataPath, config = {}, deployL1ContractsArgs = {}){
87
- this.dataPath = dataPath;
88
- this.config = config;
89
- this.deployL1ContractsArgs = deployL1ContractsArgs;
90
- this.snapshotStack = [];
91
- this.livePath = join(this.dataPath, 'live', testName);
92
- this.logger = createLogger(`e2e:snapshot_manager:${testName}`);
93
- }
94
- async snapshot(name, apply, restore = ()=>Promise.resolve()) {
95
- const snapshotPath = join(this.dataPath, 'snapshots', ...this.snapshotStack.map((e)=>e.name), name, 'snapshot');
96
- if (existsSync(snapshotPath)) {
97
- // Snapshot exists. Record entry on stack but do nothing else as we're probably still descending the tree.
98
- // It's the tests responsibility to call setup() before a test to ensure subsystems get created.
99
- this.logger.verbose(`Snapshot exists at ${snapshotPath}. Continuing...`);
100
- this.snapshotStack.push({
101
- name,
102
- apply,
103
- restore,
104
- snapshotPath
105
- });
106
- return;
107
- }
108
- // Snapshot didn't exist at snapshotPath, and by definition none of the child snapshots can exist.
109
- // If we have no subsystem context yet, create it from the top of the snapshot stack (if it exists).
110
- const context = await this.setup();
111
- this.snapshotStack.push({
112
- name,
113
- apply,
114
- restore,
115
- snapshotPath
116
- });
117
- // Apply current state transition.
118
- this.logger.verbose(`Applying state transition for ${name}...`);
119
- const snapshotData = await apply(context);
120
- this.logger.verbose(`State transition for ${name} complete.`);
121
- // Execute the restoration function.
122
- await restore(snapshotData, context);
123
- // Save the snapshot data.
124
- const ethCheatCodes = new EthCheatCodesWithState(context.aztecNodeConfig.l1RpcUrls, context.dateProvider);
125
- const anvilStateFile = `${this.livePath}/anvil.dat`;
126
- await ethCheatCodes.dumpChainState(anvilStateFile);
127
- writeFileSync(`${this.livePath}/${name}.json`, JSON.stringify(snapshotData || {}, resolver));
128
- // Copy everything to snapshot path.
129
- // We want it to be atomic, in case multiple processes are racing to create the snapshot.
130
- this.logger.verbose(`Saving snapshot to ${snapshotPath}...`);
131
- if (mkdirSync(snapshotPath, {
132
- recursive: true
133
- })) {
134
- copySync(this.livePath, snapshotPath);
135
- this.logger.verbose(`Snapshot copied to ${snapshotPath}.`);
136
- } else {
137
- this.logger.verbose(`Snapshot already exists at ${snapshotPath}. Discarding our version.`);
138
- await this.teardown();
139
- }
140
- }
141
- /**
142
- * Creates and returns the subsystem context based on the current snapshot stack.
143
- * If the subsystem context already exists, just return it.
144
- * If you want to be sure to get a clean snapshot, be sure to call teardown() before calling setup().
145
- */ async setup() {
146
- // We have no subsystem context yet.
147
- // If one exists on the snapshot stack, create one from that snapshot.
148
- // Otherwise create a fresh one.
149
- if (!this.context) {
150
- removeSync(this.livePath);
151
- mkdirSync(this.livePath, {
152
- recursive: true
153
- });
154
- const previousSnapshotPath = this.snapshotStack[this.snapshotStack.length - 1]?.snapshotPath;
155
- if (previousSnapshotPath) {
156
- this.logger.verbose(`Copying snapshot from ${previousSnapshotPath} to ${this.livePath}...`);
157
- copySync(previousSnapshotPath, this.livePath);
158
- this.context = await setupFromState(this.livePath, this.logger);
159
- // Execute each of the previous snapshots restoration functions in turn.
160
- await asyncMap(this.snapshotStack, async (e)=>{
161
- const snapshotData = JSON.parse(readFileSync(`${e.snapshotPath}/${e.name}.json`, 'utf-8'), reviver);
162
- this.logger.verbose(`Executing restoration function for ${e.name}...`);
163
- await e.restore(snapshotData, this.context);
164
- this.logger.verbose(`Restoration of ${e.name} complete.`);
165
- });
166
- } else {
167
- this.context = await setupFromFresh(this.livePath, this.logger, this.config, this.deployL1ContractsArgs);
168
- }
169
- }
170
- return this.context;
171
- }
172
- /**
173
- * Destroys the current subsystem context.
174
- */ async teardown() {
175
- await teardown(this.context);
176
- this.context = undefined;
177
- removeSync(this.livePath);
178
- }
179
- }
180
- /**
181
- * Destroys the current subsystem context.
182
- */ async function teardown(context) {
183
- if (!context) {
184
- return;
185
- }
186
- const logger = getLogger();
187
- try {
188
- logger.info('Tearing down subsystems');
189
- await tryStop(context.proverNode);
190
- await tryStop(context.aztecNode);
191
- await context.acvmConfig?.cleanup();
192
- await context.bbConfig?.cleanup();
193
- await tryStop(context.anvil);
194
- await tryStop(context.watcher);
195
- await tryStop(context.blobSink);
196
- await tryRmDir(context.directoryToCleanup, logger);
197
- } catch (err) {
198
- logger.error('Error during teardown', err);
199
- }
200
- }
201
- /**
202
- * Initializes a fresh set of subsystems.
203
- * If given a statePath, the state will be written to the path.
204
- * If there is no statePath, in-memory and temporary state locations will be used.
205
- */ async function setupFromFresh(statePath, logger, { numberOfInitialFundedAccounts = 10, ...opts } = {}, deployL1ContractsArgs = {
206
- initialValidators: []
207
- }) {
208
- logger.verbose(`Initializing state...`);
209
- const blobSinkPort = await getPort();
210
- // Default to no slashing
211
- opts.slasherFlavor ??= 'none';
212
- deployL1ContractsArgs.slasherFlavor ??= opts.slasherFlavor;
213
- // Fetch the AztecNode config.
214
- // TODO: For some reason this is currently the union of a bunch of subsystems. That needs fixing.
215
- const aztecNodeConfig = {
216
- ...getConfigEnvVars(),
217
- ...opts
218
- };
219
- aztecNodeConfig.peerCheckIntervalMS = TEST_PEER_CHECK_INTERVAL_MS;
220
- aztecNodeConfig.maxTxPoolSize = opts.maxTxPoolSize ?? TEST_MAX_TX_POOL_SIZE;
221
- // Only enable proving if specifically requested.
222
- aztecNodeConfig.realProofs = !!opts.realProofs;
223
- // Only enforce the time table if requested
224
- aztecNodeConfig.enforceTimeTable = !!opts.enforceTimeTable;
225
- // Only set the target committee size if it is explicitly set
226
- aztecNodeConfig.aztecTargetCommitteeSize = opts.aztecTargetCommitteeSize ?? 0;
227
- aztecNodeConfig.listenAddress = '127.0.0.1';
228
- deployL1ContractsArgs.aztecTargetCommitteeSize ??= aztecNodeConfig.aztecTargetCommitteeSize;
229
- // Create a temp directory for all ephemeral state and cleanup afterwards
230
- const directoryToCleanup = path.join(tmpdir(), randomBytes(8).toString('hex'));
231
- await fs.mkdir(directoryToCleanup, {
232
- recursive: true
233
- });
234
- if (statePath === undefined) {
235
- aztecNodeConfig.dataDirectory = directoryToCleanup;
236
- } else {
237
- aztecNodeConfig.dataDirectory = statePath;
238
- }
239
- aztecNodeConfig.blobSinkUrl = `http://127.0.0.1:${blobSinkPort}`;
240
- const hdAccount = mnemonicToAccount(MNEMONIC, {
241
- addressIndex: 0
242
- });
243
- const publisherPrivKeyRaw = hdAccount.getHdKey().privateKey;
244
- const publisherPrivKey = publisherPrivKeyRaw === null ? null : Buffer.from(publisherPrivKeyRaw);
245
- const l1Client = createExtendedL1Client([
246
- aztecNodeConfig.l1RpcUrls[0]
247
- ], hdAccount, foundry);
248
- const validatorPrivKey = getPrivateKeyFromIndex(0);
249
- const proverNodePrivateKey = getPrivateKeyFromIndex(0);
250
- aztecNodeConfig.publisherPrivateKeys = [
251
- new SecretValue(`0x${publisherPrivKey.toString('hex')}`)
252
- ];
253
- aztecNodeConfig.validatorPrivateKeys = new SecretValue([
254
- `0x${validatorPrivKey.toString('hex')}`
255
- ]);
256
- aztecNodeConfig.coinbase = opts.coinbase ?? EthAddress.fromString(`${hdAccount.address}`);
257
- logger.info(`Setting up environment with config`, aztecNodeConfig);
258
- // Start anvil. We go via a wrapper script to ensure if the parent dies, anvil dies.
259
- logger.verbose('Starting anvil...');
260
- const res = await startAnvil({
261
- l1BlockTime: opts.ethereumSlotDuration
262
- });
263
- const anvil = res.anvil;
264
- aztecNodeConfig.l1RpcUrls = [
265
- res.rpcUrl
266
- ];
267
- const dateProvider = new TestDateProvider();
268
- const ethCheatCodes = new EthCheatCodesWithState(aztecNodeConfig.l1RpcUrls, dateProvider);
269
- // Deploy our L1 contracts.
270
- logger.verbose('Deploying L1 contracts...');
271
- if (opts.l1StartTime) {
272
- await ethCheatCodes.warp(opts.l1StartTime, {
273
- resetBlockInterval: true
274
- });
275
- }
276
- const initialFundedAccounts = await generateSchnorrAccounts(numberOfInitialFundedAccounts);
277
- const sponsoredFPCAddress = await getSponsoredFPCAddress();
278
- const { genesisArchiveRoot, prefilledPublicData, fundingNeeded } = await getGenesisValues(initialFundedAccounts.map((a)=>a.address).concat(sponsoredFPCAddress), opts.initialAccountFeeJuice);
279
- await deployMulticall3(l1Client, logger);
280
- const deployL1ContractsValues = await setupL1Contracts(aztecNodeConfig.l1RpcUrls[0], hdAccount, logger, {
281
- ...getL1ContractsConfigEnvVars(),
282
- genesisArchiveRoot,
283
- feeJuicePortalInitialBalance: fundingNeeded,
284
- salt: opts.salt,
285
- ...deployL1ContractsArgs,
286
- initialValidators: opts.initialValidators
287
- });
288
- aztecNodeConfig.l1Contracts = deployL1ContractsValues.l1ContractAddresses;
289
- aztecNodeConfig.rollupVersion = deployL1ContractsValues.rollupVersion;
290
- const watcher = new AnvilTestWatcher(new EthCheatCodesWithState(aztecNodeConfig.l1RpcUrls, dateProvider), deployL1ContractsValues.l1ContractAddresses.rollupAddress, deployL1ContractsValues.l1Client, dateProvider);
291
- await watcher.start();
292
- const acvmConfig = await getACVMConfig(logger);
293
- if (acvmConfig) {
294
- aztecNodeConfig.acvmWorkingDirectory = acvmConfig.acvmWorkingDirectory;
295
- aztecNodeConfig.acvmBinaryPath = acvmConfig.acvmBinaryPath;
296
- }
297
- const bbConfig = await getBBConfig(logger);
298
- if (bbConfig) {
299
- aztecNodeConfig.bbBinaryPath = bbConfig.bbBinaryPath;
300
- aztecNodeConfig.bbWorkingDirectory = bbConfig.bbWorkingDirectory;
301
- }
302
- const telemetry = getEndToEndTestTelemetryClient(opts.metricsPort);
303
- // Setup blob sink service
304
- const blobSink = await createBlobSinkServer({
305
- l1ChainId: aztecNodeConfig.l1ChainId,
306
- l1RpcUrls: aztecNodeConfig.l1RpcUrls,
307
- l1Contracts: aztecNodeConfig.l1Contracts,
308
- port: blobSinkPort,
309
- dataDirectory: aztecNodeConfig.dataDirectory,
310
- dataStoreMapSizeKb: aztecNodeConfig.dataStoreMapSizeKb
311
- }, telemetry);
312
- await blobSink.start();
313
- logger.info('Creating and synching an aztec node...');
314
- const aztecNode = await AztecNodeService.createAndSync(aztecNodeConfig, {
315
- telemetry,
316
- dateProvider
317
- }, {
318
- prefilledPublicData
319
- });
320
- let proverNode = undefined;
321
- if (opts.startProverNode) {
322
- logger.verbose('Creating and syncing a simulated prover node with p2p disabled...');
323
- proverNode = await createAndSyncProverNode(`0x${proverNodePrivateKey.toString('hex')}`, aztecNodeConfig, {
324
- ...aztecNodeConfig.proverNodeConfig,
325
- dataDirectory: path.join(directoryToCleanup, randomBytes(8).toString('hex')),
326
- p2pEnabled: false
327
- }, aztecNode, prefilledPublicData);
328
- }
329
- logger.verbose('Creating pxe...');
330
- const pxeConfig = getPXEConfig();
331
- pxeConfig.dataDirectory = statePath ?? path.join(directoryToCleanup, randomBytes(8).toString('hex'));
332
- // Only enable proving if specifically requested.
333
- pxeConfig.proverEnabled = !!opts.realProofs;
334
- const wallet = await TestWallet.create(aztecNode, pxeConfig);
335
- const cheatCodes = await CheatCodes.create(aztecNodeConfig.l1RpcUrls, aztecNode, dateProvider);
336
- if (statePath) {
337
- writeFileSync(`${statePath}/aztec_node_config.json`, JSON.stringify(aztecNodeConfig, resolver));
338
- writeFileSync(`${statePath}/accounts.json`, JSON.stringify(initialFundedAccounts, resolver));
339
- }
340
- return {
341
- aztecNodeConfig,
342
- anvil,
343
- aztecNode,
344
- wallet,
345
- sequencer: aztecNode.getSequencer(),
346
- acvmConfig,
347
- bbConfig,
348
- deployL1ContractsValues,
349
- proverNode,
350
- watcher,
351
- cheatCodes,
352
- dateProvider,
353
- blobSink,
354
- initialFundedAccounts,
355
- directoryToCleanup
356
- };
357
- }
358
- /**
359
- * Given a statePath, setup the system starting from that state.
360
- */ async function setupFromState(statePath, logger) {
361
- logger.verbose(`Initializing with saved state at ${statePath}...`);
362
- const directoryToCleanup = path.join(tmpdir(), randomBytes(8).toString('hex'));
363
- await fs.mkdir(directoryToCleanup, {
364
- recursive: true
365
- });
366
- // Run the blob sink on a random port
367
- const blobSinkPort = await getPort();
368
- // TODO: For some reason this is currently the union of a bunch of subsystems. That needs fixing.
369
- const aztecNodeConfig = JSON.parse(readFileSync(`${statePath}/aztec_node_config.json`, 'utf-8'), reviver);
370
- aztecNodeConfig.dataDirectory = statePath;
371
- aztecNodeConfig.blobSinkUrl = `http://127.0.0.1:${blobSinkPort}`;
372
- aztecNodeConfig.listenAddress = '127.0.0.1';
373
- const initialFundedAccounts = JSON.parse(readFileSync(`${statePath}/accounts.json`, 'utf-8'), reviver) || [];
374
- const { prefilledPublicData } = await getGenesisValues(initialFundedAccounts.map((a)=>a.address));
375
- // Start anvil. We go via a wrapper script to ensure if the parent dies, anvil dies.
376
- const { anvil, rpcUrl } = await startAnvil();
377
- aztecNodeConfig.l1RpcUrls = [
378
- rpcUrl
379
- ];
380
- // Load anvil state.
381
- const anvilStateFile = `${statePath}/anvil.dat`;
382
- const dateProvider = new TestDateProvider();
383
- const ethCheatCodes = new EthCheatCodesWithState(aztecNodeConfig.l1RpcUrls, dateProvider);
384
- await ethCheatCodes.loadChainState(anvilStateFile);
385
- // TODO: Encapsulate this in a NativeAcvm impl.
386
- const acvmConfig = await getACVMConfig(logger);
387
- if (acvmConfig) {
388
- aztecNodeConfig.acvmWorkingDirectory = acvmConfig.acvmWorkingDirectory;
389
- aztecNodeConfig.acvmBinaryPath = acvmConfig.acvmBinaryPath;
390
- }
391
- const bbConfig = await getBBConfig(logger);
392
- if (bbConfig) {
393
- aztecNodeConfig.bbBinaryPath = bbConfig.bbBinaryPath;
394
- aztecNodeConfig.bbWorkingDirectory = bbConfig.bbWorkingDirectory;
395
- }
396
- logger.verbose('Creating ETH clients...');
397
- const l1Client = createExtendedL1Client(aztecNodeConfig.l1RpcUrls, mnemonicToAccount(MNEMONIC));
398
- const watcher = new AnvilTestWatcher(ethCheatCodes, aztecNodeConfig.l1Contracts.rollupAddress, l1Client, dateProvider);
399
- await watcher.start();
400
- const telemetry = initTelemetryClient(getTelemetryConfig());
401
- const blobSink = await createBlobSinkServer({
402
- l1ChainId: aztecNodeConfig.l1ChainId,
403
- l1RpcUrls: aztecNodeConfig.l1RpcUrls,
404
- l1Contracts: aztecNodeConfig.l1Contracts,
405
- port: blobSinkPort,
406
- dataDirectory: statePath,
407
- dataStoreMapSizeKb: aztecNodeConfig.dataStoreMapSizeKb
408
- }, telemetry);
409
- await blobSink.start();
410
- logger.verbose('Creating aztec node...');
411
- const aztecNode = await AztecNodeService.createAndSync(aztecNodeConfig, {
412
- telemetry,
413
- dateProvider
414
- }, {
415
- prefilledPublicData
416
- });
417
- let proverNode = undefined;
418
- if (aztecNodeConfig.startProverNode) {
419
- logger.verbose('Creating and syncing a simulated prover node...');
420
- const proverNodePrivateKey = getPrivateKeyFromIndex(2);
421
- const proverNodePrivateKeyHex = `0x${proverNodePrivateKey.toString('hex')}`;
422
- proverNode = await createAndSyncProverNode(proverNodePrivateKeyHex, aztecNodeConfig, {
423
- ...aztecNodeConfig.proverNodeConfig,
424
- dataDirectory: path.join(directoryToCleanup, randomBytes(8).toString('hex')),
425
- p2pEnabled: false
426
- }, aztecNode, prefilledPublicData);
427
- }
428
- logger.verbose('Creating pxe...');
429
- const pxeConfig = getPXEConfig();
430
- pxeConfig.dataDirectory = statePath;
431
- const wallet = await TestWallet.create(aztecNode, pxeConfig);
432
- const cheatCodes = await CheatCodes.create(aztecNodeConfig.l1RpcUrls, aztecNode, dateProvider);
433
- return {
434
- aztecNodeConfig,
435
- anvil,
436
- aztecNode,
437
- wallet,
438
- sequencer: aztecNode.getSequencer(),
439
- acvmConfig,
440
- bbConfig,
441
- proverNode,
442
- deployL1ContractsValues: {
443
- l1Client,
444
- l1ContractAddresses: aztecNodeConfig.l1Contracts,
445
- rollupVersion: aztecNodeConfig.rollupVersion
446
- },
447
- watcher,
448
- cheatCodes,
449
- dateProvider,
450
- blobSink,
451
- initialFundedAccounts,
452
- directoryToCleanup
453
- };
454
- }
455
- /**
456
- * Snapshot 'apply' helper function to add accounts.
457
- * The 'restore' function is not provided, as it must be a closure within the test context to capture the results.
458
- */ export const deployAccounts = (numberOfAccounts, logger)=>async ({ wallet, initialFundedAccounts })=>{
459
- if (initialFundedAccounts.length < numberOfAccounts) {
460
- throw new Error(`Cannot deploy more than ${initialFundedAccounts.length} initial accounts.`);
461
- }
462
- logger.verbose('Deploying accounts funded with fee juice...');
463
- const deployedAccounts = initialFundedAccounts.slice(0, numberOfAccounts);
464
- // Serial due to https://github.com/AztecProtocol/aztec-packages/issues/12045
465
- for(let i = 0; i < deployedAccounts.length; i++){
466
- const accountManager = await wallet.createSchnorrAccount(deployedAccounts[i].secret, deployedAccounts[i].salt, deployedAccounts[i].signingKey);
467
- const deployMethod = await accountManager.getDeployMethod();
468
- await deployMethod.send({
469
- from: AztecAddress.ZERO,
470
- skipClassPublication: i !== 0
471
- }).wait();
472
- }
473
- return {
474
- deployedAccounts
475
- };
476
- };
477
- /**
478
- * Registers the contract class used for test accounts and publicly deploys the instances requested.
479
- * Use this when you need to make a public call to an account contract, such as for requesting a public authwit.
480
- * @param sender - Wallet to send the deployment tx.
481
- * @param accountsToDeploy - Which accounts to publicly deploy.
482
- * @param waitUntilProven - Whether to wait for the tx to be proven.
483
- * @param node - AztecNode used to wait for proven tx.
484
- */ export async function publicDeployAccounts(wallet, accountsToDeploy, waitUntilProven = false, node) {
485
- const instances = (await Promise.all(accountsToDeploy.map((account)=>wallet.getContractMetadata(account)))).map((metadata)=>metadata.contractInstance);
486
- const contractClass = await getContractClassFromArtifact(SchnorrAccountContractArtifact);
487
- const alreadyRegistered = (await wallet.getContractClassMetadata(contractClass.id)).isContractClassPubliclyRegistered;
488
- const calls = await Promise.all([
489
- ...!alreadyRegistered ? [
490
- publishContractClass(wallet, SchnorrAccountContractArtifact)
491
- ] : [],
492
- ...instances.map((instance)=>publishInstance(wallet, instance))
493
- ]);
494
- const batch = new BatchCall(wallet, calls);
495
- const txReceipt = await batch.send({
496
- from: accountsToDeploy[0]
497
- }).wait();
498
- if (waitUntilProven) {
499
- if (!node) {
500
- throw new Error('Need to provide an AztecNode to wait for proven.');
501
- } else {
502
- await waitForProven(node, txReceipt);
503
- }
504
- }
505
- }