@aztec/end-to-end 0.0.1-commit.3fd054f6 → 0.0.1-commit.431c48d

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 (309) hide show
  1. package/README.md +229 -14
  2. package/dest/automine/automine_test_context.d.ts +85 -0
  3. package/dest/automine/automine_test_context.d.ts.map +1 -0
  4. package/dest/automine/automine_test_context.js +98 -0
  5. package/dest/automine/contracts/fixtures/storage_proof_fetcher.d.ts +2 -0
  6. package/dest/automine/contracts/fixtures/storage_proof_fetcher.d.ts.map +1 -0
  7. package/dest/{e2e_storage_proof → automine/contracts}/fixtures/storage_proof_fixture.d.ts +1 -1
  8. package/dest/automine/contracts/fixtures/storage_proof_fixture.d.ts.map +1 -0
  9. package/dest/automine/delivery/interactive_handshake_responder.d.ts +48 -0
  10. package/dest/automine/delivery/interactive_handshake_responder.d.ts.map +1 -0
  11. package/dest/automine/delivery/interactive_handshake_responder.js +76 -0
  12. package/dest/automine/delivery/onchain_delivery_harness.d.ts +19 -0
  13. package/dest/automine/delivery/onchain_delivery_harness.d.ts.map +1 -0
  14. package/dest/automine/delivery/onchain_delivery_harness.js +141 -0
  15. package/dest/automine/token/blacklist_token_contract_test.d.ts +49 -0
  16. package/dest/automine/token/blacklist_token_contract_test.d.ts.map +1 -0
  17. package/dest/{e2e_blacklist_token_contract → automine/token}/blacklist_token_contract_test.js +23 -36
  18. package/dest/automine/token/token_contract_test.d.ts +40 -0
  19. package/dest/automine/token/token_contract_test.d.ts.map +1 -0
  20. package/dest/{e2e_token_contract → automine/token}/token_contract_test.js +24 -39
  21. package/dest/automine/token/token_test_helpers.d.ts +73 -0
  22. package/dest/automine/token/token_test_helpers.d.ts.map +1 -0
  23. package/dest/automine/token/token_test_helpers.js +97 -0
  24. package/dest/bench/client_flows/benchmark.d.ts +15 -1
  25. package/dest/bench/client_flows/benchmark.d.ts.map +1 -1
  26. package/dest/bench/client_flows/benchmark.js +19 -0
  27. package/dest/bench/client_flows/client_flows_benchmark.d.ts +5 -5
  28. package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -1
  29. package/dest/bench/client_flows/client_flows_benchmark.js +55 -54
  30. package/dest/bench/utils.d.ts +3 -3
  31. package/dest/bench/utils.d.ts.map +1 -1
  32. package/dest/bench/utils.js +97 -6
  33. package/dest/composed/ha/ha_full_setup.d.ts +77 -0
  34. package/dest/composed/ha/ha_full_setup.d.ts.map +1 -0
  35. package/dest/composed/ha/ha_full_setup.js +383 -0
  36. package/dest/composed/web3signer/multi_validator_keystore_utils.d.ts +12 -0
  37. package/dest/composed/web3signer/multi_validator_keystore_utils.d.ts.map +1 -0
  38. package/dest/fixtures/authwit_proxy.d.ts +1 -1
  39. package/dest/fixtures/authwit_proxy.d.ts.map +1 -1
  40. package/dest/fixtures/authwit_proxy.js +4 -0
  41. package/dest/fixtures/e2e_prover_test.d.ts +12 -9
  42. package/dest/fixtures/e2e_prover_test.d.ts.map +1 -1
  43. package/dest/fixtures/e2e_prover_test.js +53 -35
  44. package/dest/fixtures/fixtures.d.ts +79 -1
  45. package/dest/fixtures/fixtures.d.ts.map +1 -1
  46. package/dest/fixtures/fixtures.js +80 -0
  47. package/dest/fixtures/ha_setup.d.ts +4 -4
  48. package/dest/fixtures/ha_setup.d.ts.map +1 -1
  49. package/dest/fixtures/ha_setup.js +5 -2
  50. package/dest/fixtures/index.d.ts +2 -1
  51. package/dest/fixtures/index.d.ts.map +1 -1
  52. package/dest/fixtures/index.js +1 -0
  53. package/dest/fixtures/schnorr_hardcoded_account_contract.d.ts +25 -0
  54. package/dest/fixtures/schnorr_hardcoded_account_contract.d.ts.map +1 -0
  55. package/dest/fixtures/schnorr_hardcoded_account_contract.js +37 -0
  56. package/dest/fixtures/setup.d.ts +81 -42
  57. package/dest/fixtures/setup.d.ts.map +1 -1
  58. package/dest/fixtures/setup.js +290 -198
  59. package/dest/fixtures/setup_p2p_test.d.ts +10 -6
  60. package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
  61. package/dest/fixtures/setup_p2p_test.js +11 -11
  62. package/dest/fixtures/standard_contracts_genesis.d.ts +16 -0
  63. package/dest/fixtures/standard_contracts_genesis.d.ts.map +1 -0
  64. package/dest/fixtures/standard_contracts_genesis.js +25 -0
  65. package/dest/fixtures/timing.d.ts +42 -0
  66. package/dest/fixtures/timing.d.ts.map +1 -0
  67. package/dest/fixtures/timing.js +72 -0
  68. package/dest/fixtures/token_utils.d.ts +22 -4
  69. package/dest/fixtures/token_utils.d.ts.map +1 -1
  70. package/dest/fixtures/token_utils.js +23 -6
  71. package/dest/fixtures/utils.d.ts +2 -2
  72. package/dest/fixtures/utils.d.ts.map +1 -1
  73. package/dest/fixtures/utils.js +1 -1
  74. package/dest/fixtures/wait_helpers.d.ts +135 -0
  75. package/dest/fixtures/wait_helpers.d.ts.map +1 -0
  76. package/dest/fixtures/wait_helpers.js +154 -0
  77. package/dest/forward-compatibility/wallet_rpc_client.d.ts +7 -0
  78. package/dest/forward-compatibility/wallet_rpc_client.d.ts.map +1 -0
  79. package/dest/forward-compatibility/wallet_rpc_client.js +15 -0
  80. package/dest/forward-compatibility/wallet_service.d.ts +3 -0
  81. package/dest/forward-compatibility/wallet_service.d.ts.map +1 -0
  82. package/dest/forward-compatibility/wallet_service.js +109 -0
  83. package/dest/install_legacy_contracts.d.cts +13 -0
  84. package/dest/install_legacy_contracts.d.cts.map +1 -0
  85. package/dest/legacy-jest-resolver.d.cts +3 -0
  86. package/dest/legacy-jest-resolver.d.cts.map +1 -0
  87. package/dest/multi-node/block-production/setup.d.ts +97 -0
  88. package/dest/multi-node/block-production/setup.d.ts.map +1 -0
  89. package/dest/multi-node/block-production/setup.js +158 -0
  90. package/dest/multi-node/governance/setup.d.ts +67 -0
  91. package/dest/multi-node/governance/setup.d.ts.map +1 -0
  92. package/dest/multi-node/governance/setup.js +126 -0
  93. package/dest/multi-node/multi_node_test_context.d.ts +212 -0
  94. package/dest/multi-node/multi_node_test_context.d.ts.map +1 -0
  95. package/dest/multi-node/multi_node_test_context.js +347 -0
  96. package/dest/multi-node/slashing/inactivity_setup.d.ts +27 -0
  97. package/dest/multi-node/slashing/inactivity_setup.d.ts.map +1 -0
  98. package/dest/multi-node/slashing/inactivity_setup.js +111 -0
  99. package/dest/multi-node/slashing/setup.d.ts +167 -0
  100. package/dest/multi-node/slashing/setup.d.ts.map +1 -0
  101. package/dest/multi-node/slashing/setup.js +275 -0
  102. package/dest/{e2e_p2p → p2p}/p2p_network.d.ts +19 -10
  103. package/dest/p2p/p2p_network.d.ts.map +1 -0
  104. package/dest/{e2e_p2p → p2p}/p2p_network.js +82 -38
  105. package/dest/p2p/reqresp/utils.d.ts +19 -0
  106. package/dest/p2p/reqresp/utils.d.ts.map +1 -0
  107. package/dest/{e2e_p2p → p2p}/reqresp/utils.js +32 -29
  108. package/dest/p2p/shared.d.ts +72 -0
  109. package/dest/p2p/shared.d.ts.map +1 -0
  110. package/dest/p2p/shared.js +212 -0
  111. package/dest/shared/cross_chain_test_harness.d.ts +6 -4
  112. package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
  113. package/dest/shared/cross_chain_test_harness.js +33 -21
  114. package/dest/shared/gas_portal_test_harness.d.ts +8 -5
  115. package/dest/shared/gas_portal_test_harness.d.ts.map +1 -1
  116. package/dest/shared/gas_portal_test_harness.js +24 -12
  117. package/dest/shared/submit-transactions.d.ts +1 -1
  118. package/dest/shared/submit-transactions.d.ts.map +1 -1
  119. package/dest/shared/submit-transactions.js +12 -5
  120. package/dest/shared/timing_env.d.js +5 -0
  121. package/dest/shared/timing_env.js +365 -0
  122. package/dest/shared/uniswap_l1_l2.d.ts +1 -1
  123. package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
  124. package/dest/shared/uniswap_l1_l2.js +50 -37
  125. package/dest/shared/wait_for_l1_to_l2_message.d.ts +13 -0
  126. package/dest/shared/wait_for_l1_to_l2_message.d.ts.map +1 -0
  127. package/dest/shared/wait_for_l1_to_l2_message.js +10 -0
  128. package/dest/simulators/lending_simulator.d.ts +10 -3
  129. package/dest/simulators/lending_simulator.d.ts.map +1 -1
  130. package/dest/simulators/lending_simulator.js +24 -12
  131. package/dest/single-node/cross-chain/cross_chain_messaging_test.d.ts +75 -0
  132. package/dest/single-node/cross-chain/cross_chain_messaging_test.d.ts.map +1 -0
  133. package/dest/single-node/cross-chain/cross_chain_messaging_test.js +209 -0
  134. package/dest/single-node/cross-chain/message_test_helpers.d.ts +38 -0
  135. package/dest/single-node/cross-chain/message_test_helpers.d.ts.map +1 -0
  136. package/dest/single-node/cross-chain/message_test_helpers.js +70 -0
  137. package/dest/{e2e_fees → single-node/fees}/bridging_race.notest.d.ts +1 -1
  138. package/dest/single-node/fees/bridging_race.notest.d.ts.map +1 -0
  139. package/dest/{e2e_fees → single-node/fees}/bridging_race.notest.js +17 -4
  140. package/dest/single-node/fees/fees_test.d.ts +95 -0
  141. package/dest/single-node/fees/fees_test.d.ts.map +1 -0
  142. package/dest/single-node/fees/fees_test.js +347 -0
  143. package/dest/single-node/l1-reorgs/setup.d.ts +42 -0
  144. package/dest/single-node/l1-reorgs/setup.d.ts.map +1 -0
  145. package/dest/single-node/l1-reorgs/setup.js +57 -0
  146. package/dest/single-node/partial-proofs/setup.d.ts +5 -0
  147. package/dest/single-node/partial-proofs/setup.d.ts.map +1 -0
  148. package/dest/single-node/partial-proofs/setup.js +5 -0
  149. package/dest/single-node/proving/setup.d.ts +5 -0
  150. package/dest/single-node/proving/setup.d.ts.map +1 -0
  151. package/dest/single-node/proving/setup.js +5 -0
  152. package/dest/single-node/recovery/setup.d.ts +5 -0
  153. package/dest/single-node/recovery/setup.d.ts.map +1 -0
  154. package/dest/single-node/recovery/setup.js +5 -0
  155. package/dest/single-node/setup.d.ts +49 -0
  156. package/dest/single-node/setup.d.ts.map +1 -0
  157. package/dest/single-node/setup.js +56 -0
  158. package/dest/single-node/single_node_test_context.d.ts +374 -0
  159. package/dest/single-node/single_node_test_context.d.ts.map +1 -0
  160. package/dest/single-node/single_node_test_context.js +847 -0
  161. package/dest/spartan/setup_test_wallets.d.ts +1 -1
  162. package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
  163. package/dest/spartan/setup_test_wallets.js +89 -55
  164. package/dest/spartan/tx_metrics.d.ts +27 -4
  165. package/dest/spartan/tx_metrics.d.ts.map +1 -1
  166. package/dest/spartan/tx_metrics.js +105 -20
  167. package/dest/spartan/utils/config.d.ts +9 -35
  168. package/dest/spartan/utils/config.d.ts.map +1 -1
  169. package/dest/spartan/utils/gossip_metrics.d.ts +9 -0
  170. package/dest/spartan/utils/gossip_metrics.d.ts.map +1 -0
  171. package/dest/spartan/utils/gossip_metrics.js +77 -0
  172. package/dest/spartan/utils/index.d.ts +2 -1
  173. package/dest/spartan/utils/index.d.ts.map +1 -1
  174. package/dest/spartan/utils/index.js +2 -0
  175. package/dest/spartan/utils/nodes.js +2 -2
  176. package/dest/test-wallet/test_wallet.d.ts +39 -10
  177. package/dest/test-wallet/test_wallet.d.ts.map +1 -1
  178. package/dest/test-wallet/test_wallet.js +185 -79
  179. package/dest/test-wallet/utils.d.ts +38 -3
  180. package/dest/test-wallet/utils.d.ts.map +1 -1
  181. package/dest/test-wallet/utils.js +65 -10
  182. package/dest/test-wallet/wallet_worker_script.js +12 -4
  183. package/dest/test-wallet/worker_wallet.d.ts +9 -8
  184. package/dest/test-wallet/worker_wallet.d.ts.map +1 -1
  185. package/dest/test-wallet/worker_wallet.js +10 -4
  186. package/dest/test-wallet/worker_wallet_schema.d.ts +3 -273
  187. package/dest/test-wallet/worker_wallet_schema.d.ts.map +1 -1
  188. package/dest/test-wallet/worker_wallet_schema.js +15 -2
  189. package/package.json +48 -43
  190. package/src/automine/README.md +60 -0
  191. package/src/automine/automine_test_context.ts +153 -0
  192. package/src/automine/delivery/interactive_handshake_responder.ts +125 -0
  193. package/src/automine/delivery/onchain_delivery_harness.ts +213 -0
  194. package/src/{e2e_blacklist_token_contract → automine/token}/blacklist_token_contract_test.ts +24 -47
  195. package/src/{e2e_token_contract → automine/token}/token_contract_test.ts +25 -48
  196. package/src/automine/token/token_test_helpers.ts +138 -0
  197. package/src/bench/client_flows/benchmark.ts +21 -0
  198. package/src/bench/client_flows/client_flows_benchmark.ts +105 -75
  199. package/src/bench/utils.ts +110 -6
  200. package/src/composed/ha/ha_full_setup.ts +466 -0
  201. package/src/fixtures/authwit_proxy.ts +4 -0
  202. package/src/fixtures/e2e_prover_test.ts +68 -52
  203. package/src/fixtures/fixtures.ts +100 -0
  204. package/src/fixtures/ha_setup.ts +11 -5
  205. package/src/fixtures/index.ts +1 -0
  206. package/src/fixtures/schnorr_hardcoded_account_contract.ts +49 -0
  207. package/src/fixtures/setup.ts +361 -255
  208. package/src/fixtures/setup_p2p_test.ts +15 -11
  209. package/src/fixtures/standard_contracts_genesis.ts +28 -0
  210. package/src/fixtures/timing.ts +97 -0
  211. package/src/fixtures/token_utils.ts +40 -8
  212. package/src/fixtures/utils.ts +2 -3
  213. package/src/fixtures/wait_helpers.ts +333 -0
  214. package/src/forward-compatibility/wallet_rpc_client.ts +14 -0
  215. package/src/forward-compatibility/wallet_service.ts +106 -0
  216. package/src/guides/up_quick_start.sh +5 -2
  217. package/src/infra/README.md +12 -0
  218. package/src/install_legacy_contracts.cjs +81 -0
  219. package/src/legacy-jest-resolver.cjs +98 -0
  220. package/src/multi-node/README.md +96 -0
  221. package/src/multi-node/block-production/setup.ts +272 -0
  222. package/src/multi-node/governance/setup.ts +172 -0
  223. package/src/multi-node/multi_node_test_context.ts +447 -0
  224. package/src/multi-node/slashing/inactivity_setup.ts +139 -0
  225. package/src/multi-node/slashing/setup.ts +433 -0
  226. package/src/p2p/README.md +78 -0
  227. package/src/{e2e_p2p → p2p}/p2p_network.ts +95 -50
  228. package/src/{e2e_p2p → p2p}/reqresp/utils.ts +35 -28
  229. package/src/p2p/shared.ts +329 -0
  230. package/src/shared/cross_chain_test_harness.ts +36 -17
  231. package/src/shared/gas_portal_test_harness.ts +32 -14
  232. package/src/shared/submit-transactions.ts +13 -5
  233. package/src/shared/timing_env.d.mts +39 -0
  234. package/src/shared/timing_env.mjs +363 -0
  235. package/src/shared/uniswap_l1_l2.ts +80 -43
  236. package/src/shared/wait_for_l1_to_l2_message.ts +23 -0
  237. package/src/simulators/lending_simulator.ts +28 -14
  238. package/src/single-node/README.md +66 -0
  239. package/src/single-node/cross-chain/cross_chain_messaging_test.ts +302 -0
  240. package/src/single-node/cross-chain/message_test_helpers.ts +125 -0
  241. package/src/{e2e_fees → single-node/fees}/bridging_race.notest.ts +19 -5
  242. package/src/{e2e_fees → single-node/fees}/fees_test.ts +176 -70
  243. package/src/single-node/l1-reorgs/setup.ts +93 -0
  244. package/src/single-node/partial-proofs/setup.ts +8 -0
  245. package/src/single-node/proving/setup.ts +15 -0
  246. package/src/single-node/recovery/setup.ts +8 -0
  247. package/src/single-node/setup.ts +63 -0
  248. package/src/single-node/single_node_test_context.ts +1058 -0
  249. package/src/spartan/setup_test_wallets.ts +91 -50
  250. package/src/spartan/tx_metrics.ts +107 -23
  251. package/src/spartan/utils/gossip_metrics.ts +108 -0
  252. package/src/spartan/utils/index.ts +3 -0
  253. package/src/spartan/utils/nodes.ts +2 -2
  254. package/src/test-wallet/test_wallet.ts +213 -81
  255. package/src/test-wallet/utils.ts +104 -11
  256. package/src/test-wallet/wallet_worker_script.ts +11 -5
  257. package/src/test-wallet/worker_wallet.ts +19 -16
  258. package/src/test-wallet/worker_wallet_schema.ts +4 -3
  259. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +0 -55
  260. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts.map +0 -1
  261. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +0 -47
  262. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts.map +0 -1
  263. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.js +0 -129
  264. package/dest/e2e_deploy_contract/deploy_test.d.ts +0 -37
  265. package/dest/e2e_deploy_contract/deploy_test.d.ts.map +0 -1
  266. package/dest/e2e_deploy_contract/deploy_test.js +0 -50
  267. package/dest/e2e_epochs/epochs_test.d.ts +0 -104
  268. package/dest/e2e_epochs/epochs_test.d.ts.map +0 -1
  269. package/dest/e2e_epochs/epochs_test.js +0 -389
  270. package/dest/e2e_fees/bridging_race.notest.d.ts.map +0 -1
  271. package/dest/e2e_fees/fees_test.d.ts +0 -88
  272. package/dest/e2e_fees/fees_test.d.ts.map +0 -1
  273. package/dest/e2e_fees/fees_test.js +0 -255
  274. package/dest/e2e_l1_publisher/write_json.d.ts +0 -11
  275. package/dest/e2e_l1_publisher/write_json.d.ts.map +0 -1
  276. package/dest/e2e_l1_publisher/write_json.js +0 -56
  277. package/dest/e2e_multi_validator/utils.d.ts +0 -12
  278. package/dest/e2e_multi_validator/utils.d.ts.map +0 -1
  279. package/dest/e2e_nested_contract/nested_contract_test.d.ts +0 -26
  280. package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +0 -1
  281. package/dest/e2e_nested_contract/nested_contract_test.js +0 -54
  282. package/dest/e2e_p2p/inactivity_slash_test.d.ts +0 -31
  283. package/dest/e2e_p2p/inactivity_slash_test.d.ts.map +0 -1
  284. package/dest/e2e_p2p/inactivity_slash_test.js +0 -136
  285. package/dest/e2e_p2p/p2p_network.d.ts.map +0 -1
  286. package/dest/e2e_p2p/reqresp/utils.d.ts +0 -22
  287. package/dest/e2e_p2p/reqresp/utils.d.ts.map +0 -1
  288. package/dest/e2e_p2p/shared.d.ts +0 -66
  289. package/dest/e2e_p2p/shared.d.ts.map +0 -1
  290. package/dest/e2e_p2p/shared.js +0 -212
  291. package/dest/e2e_storage_proof/fixtures/storage_proof_fetcher.d.ts +0 -2
  292. package/dest/e2e_storage_proof/fixtures/storage_proof_fetcher.d.ts.map +0 -1
  293. package/dest/e2e_storage_proof/fixtures/storage_proof_fixture.d.ts.map +0 -1
  294. package/dest/e2e_token_contract/token_contract_test.d.ts +0 -44
  295. package/dest/e2e_token_contract/token_contract_test.d.ts.map +0 -1
  296. package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +0 -193
  297. package/src/e2e_deploy_contract/deploy_test.ts +0 -85
  298. package/src/e2e_epochs/epochs_test.ts +0 -499
  299. package/src/e2e_l1_publisher/write_json.ts +0 -77
  300. package/src/e2e_nested_contract/nested_contract_test.ts +0 -75
  301. package/src/e2e_p2p/inactivity_slash_test.ts +0 -179
  302. package/src/e2e_p2p/shared.ts +0 -343
  303. /package/dest/{e2e_storage_proof → automine/contracts}/fixtures/storage_proof_fetcher.js +0 -0
  304. /package/dest/{e2e_storage_proof → automine/contracts}/fixtures/storage_proof_fixture.js +0 -0
  305. /package/dest/{e2e_multi_validator/utils.js → composed/web3signer/multi_validator_keystore_utils.js} +0 -0
  306. /package/src/{e2e_storage_proof → automine/contracts}/fixtures/storage_proof.json +0 -0
  307. /package/src/{e2e_storage_proof → automine/contracts}/fixtures/storage_proof_fetcher.ts +0 -0
  308. /package/src/{e2e_storage_proof → automine/contracts}/fixtures/storage_proof_fixture.ts +0 -0
  309. /package/src/{e2e_multi_validator/utils.ts → composed/web3signer/multi_validator_keystore_utils.ts} +0 -0
@@ -1,20 +1,13 @@
1
- import { SchnorrAccountContractArtifact } from '@aztec/accounts/schnorr';
2
1
  import { type InitialAccountData, generateSchnorrAccounts } from '@aztec/accounts/testing';
3
- import { type AztecNodeConfig, AztecNodeService, getConfigEnvVars } from '@aztec/aztec-node';
2
+ import { type AztecNodeConfig, AztecNodeService, createAztecNodeService, getConfigEnvVars } from '@aztec/aztec-node';
4
3
  import { AztecAddress, EthAddress } from '@aztec/aztec.js/addresses';
5
- import {
6
- BatchCall,
7
- type ContractFunctionInteraction,
8
- type ContractMethod,
9
- getContractClassFromArtifact,
10
- waitForProven,
11
- } from '@aztec/aztec.js/contracts';
4
+ import type { ContractMethod } from '@aztec/aztec.js/contracts';
12
5
  import { publishContractClass, publishInstance } from '@aztec/aztec.js/deployment';
13
6
  import { Fr } from '@aztec/aztec.js/fields';
14
7
  import { type Logger, createLogger } from '@aztec/aztec.js/log';
15
8
  import type { AztecNode } from '@aztec/aztec.js/node';
16
9
  import type { Wallet } from '@aztec/aztec.js/wallet';
17
- import { AnvilTestWatcher, CheatCodes } from '@aztec/aztec/testing';
10
+ import { CheatCodes } from '@aztec/aztec/testing';
18
11
  import { SPONSORED_FPC_SALT } from '@aztec/constants';
19
12
  import { isAnvilTestChain } from '@aztec/ethereum/chain';
20
13
  import { createExtendedL1Client } from '@aztec/ethereum/client';
@@ -29,28 +22,33 @@ import {
29
22
  deployAztecL1Contracts,
30
23
  } from '@aztec/ethereum/deploy-aztec-l1-contracts';
31
24
  import type { Delayer } from '@aztec/ethereum/l1-tx-utils';
32
- import { EthCheatCodes, EthCheatCodesWithState, startAnvil } from '@aztec/ethereum/test';
25
+ import { EthCheatCodes, EthCheatCodesWithState, startAnvil, warmBlobKzg } from '@aztec/ethereum/test';
33
26
  import type { Anvil } from '@aztec/ethereum/test';
27
+ import type { ExtendedViemWalletClient } from '@aztec/ethereum/types';
34
28
  import { BlockNumber, EpochNumber } from '@aztec/foundation/branded-types';
35
29
  import { SecretValue } from '@aztec/foundation/config';
36
30
  import { randomBytes } from '@aztec/foundation/crypto/random';
37
31
  import { tryRmDir } from '@aztec/foundation/fs';
38
32
  import { withLoggerBindings } from '@aztec/foundation/log/server';
39
33
  import { retryUntil } from '@aztec/foundation/retry';
40
- import { sleep } from '@aztec/foundation/sleep';
41
34
  import { DateProvider, TestDateProvider } from '@aztec/foundation/timer';
42
35
  import { SponsoredFPCContract } from '@aztec/noir-contracts.js/SponsoredFPC';
43
36
  import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
44
37
  import type { P2PClientDeps } from '@aztec/p2p';
45
38
  import { MockGossipSubNetwork, getMockPubSubP2PServiceFactory } from '@aztec/p2p/test-helpers';
46
39
  import { protocolContractsHash } from '@aztec/protocol-contracts';
47
- import type { ProverNodeConfig } from '@aztec/prover-node';
48
- import { type PXEConfig, getPXEConfig } from '@aztec/pxe/server';
40
+ import type { ProverNodeConfig, ProverNodeDeps } from '@aztec/prover-node';
41
+ import { type PXEConfig, type PXECreationOptions, getPXEConfig } from '@aztec/pxe/server';
49
42
  import type { SequencerClient } from '@aztec/sequencer-client';
43
+ import { AuthRegistryArtifact, getStandardAuthRegistry } from '@aztec/standard-contracts/auth-registry';
44
+ import { HandshakeRegistryArtifact, getStandardHandshakeRegistry } from '@aztec/standard-contracts/handshake-registry';
45
+ import { PublicChecksArtifact, getStandardPublicChecks } from '@aztec/standard-contracts/public-checks';
46
+ import { ARTIFACT_VERSION_BEFORE_INJECTION } from '@aztec/stdlib/abi';
50
47
  import { type ContractInstanceWithAddress, getContractInstanceFromInstantiationParams } from '@aztec/stdlib/contract';
51
- import type { AztecNodeAdmin } from '@aztec/stdlib/interfaces/client';
48
+ import type { AztecNodeAdmin, AztecNodeDebug } from '@aztec/stdlib/interfaces/client';
52
49
  import { tryStop } from '@aztec/stdlib/interfaces/server';
53
50
  import type { PublicDataTreeLeaf } from '@aztec/stdlib/trees';
51
+ import type { GenesisData } from '@aztec/stdlib/world-state';
54
52
  import {
55
53
  type TelemetryClient,
56
54
  type TelemetryClientConfig,
@@ -58,7 +56,7 @@ import {
58
56
  initTelemetryClient,
59
57
  } from '@aztec/telemetry-client';
60
58
  import { BenchmarkTelemetryClient } from '@aztec/telemetry-client/bench';
61
- import { deployFundedSchnorrAccounts } from '@aztec/wallets/testing';
59
+ import { createFundedInitializerlessAccounts } from '@aztec/wallets/testing';
62
60
  import { getGenesisValues } from '@aztec/world-state/testing';
63
61
 
64
62
  import fs from 'fs/promises';
@@ -79,6 +77,8 @@ import { MNEMONIC, TEST_MAX_PENDING_TX_POOL_COUNT, TEST_PEER_CHECK_INTERVAL_MS }
79
77
  import { getACVMConfig } from './get_acvm_config.js';
80
78
  import { getBBConfig } from './get_bb_config.js';
81
79
  import { isMetricsLoggingRequested, setupMetricsLogger } from './logging.js';
80
+ import { getStandardContractGenesisNullifiers } from './standard_contracts_genesis.js';
81
+ import { testSpan } from './timing.js';
82
82
  import { getEndToEndTestTelemetryClient } from './with_telemetry_utils.js';
83
83
 
84
84
  export { startAnvil };
@@ -111,6 +111,8 @@ export async function setupSharedBlobStorage(config: { dataDirectory?: string }
111
111
  /**
112
112
  * Sets up Private eXecution Environment (PXE) and returns the corresponding test wallet.
113
113
  * @param aztecNode - An instance of Aztec Node.
114
+ * @param nodeDebug - The node's debug API, used to register public function signatures for named traces; pass
115
+ * `undefined` when the node does not expose it.
114
116
  * @param opts - Partial configuration for the PXE.
115
117
  * @param logger - The logger to be used.
116
118
  * @param actor - Actor label to include in log output (e.g., 'pxe-test').
@@ -118,6 +120,7 @@ export async function setupSharedBlobStorage(config: { dataDirectory?: string }
118
120
  */
119
121
  export async function setupPXEAndGetWallet(
120
122
  aztecNode: AztecNode,
123
+ nodeDebug: AztecNodeDebug | undefined,
121
124
  opts: Partial<PXEConfig> = {},
122
125
  logger = getLogger(),
123
126
  actor?: string,
@@ -138,7 +141,10 @@ export async function setupPXEAndGetWallet(
138
141
 
139
142
  const teardown = configuredDataDirectory ? () => Promise.resolve() : () => tryRmDir(PXEConfig.dataDirectory!);
140
143
 
141
- const wallet = await TestWallet.create(aztecNode, PXEConfig, { loggerActorLabel: actor });
144
+ const wallet = await TestWallet.create(aztecNode, PXEConfig, {
145
+ loggerActorLabel: actor,
146
+ nodeDebug,
147
+ });
142
148
 
143
149
  return {
144
150
  wallet,
@@ -148,7 +154,7 @@ export async function setupPXEAndGetWallet(
148
154
  }
149
155
 
150
156
  /** Options for the e2e tests setup */
151
- export type SetupOptions = {
157
+ export type SetupOptions<TDeployExtraL1ContractsReturnType = unknown> = {
152
158
  /** State load */
153
159
  stateLoad?: string;
154
160
  /** Whether to enable metrics collection, if undefined, metrics collection is disabled */
@@ -157,10 +163,11 @@ export type SetupOptions = {
157
163
  deployL1ContractsValues?: DeployAztecL1ContractsReturnType;
158
164
  /** Initial fee juice for default accounts */
159
165
  initialAccountFeeJuice?: Fr;
160
- /** Number of initial accounts funded with fee juice */
161
- numberOfInitialFundedAccounts?: number;
162
- /** Data of the initial funded accounts */
163
- initialFundedAccounts?: InitialAccountData[];
166
+ /**
167
+ * Extra accounts to fund at genesis beyond the `numberOfAccounts` initializerless accounts that setup
168
+ * creates. Setup funds these but does NOT create or deploy them — the test creates/deploys them itself
169
+ */
170
+ additionallyFundedAccounts?: InitialAccountData[];
164
171
  /** An initial set of validators */
165
172
  initialValidators?: (Operator & { privateKey: `0x${string}` })[];
166
173
  /** Anvil Start time */
@@ -177,10 +184,28 @@ export type SetupOptions = {
177
184
  proverNodeConfig?: Partial<ProverNodeConfig>;
178
185
  /** Whether to use a mock gossip sub network for p2p clients. */
179
186
  mockGossipSubNetwork?: boolean;
180
- /** Whether to disable the anvil test watcher (can still be manually started) */
181
- disableAnvilTestWatcher?: boolean;
182
- /** Whether to enable anvil automine during deployment of L1 contracts (consider defaulting this to true). */
187
+ /** Whether to add simulated latency to the mock gossipsub network (in ms) */
188
+ mockGossipSubNetworkLatency?: number;
189
+ /**
190
+ * Whether to mine the L1 setup txs (Multicall3 + rollup contract deployment) under anvil automine
191
+ * instead of waiting on the block interval. Defaults to `true` (set in `setupInner`); only suites
192
+ * that assert on genesis-relative L1 timing need to opt out with `false`.
193
+ */
183
194
  automineL1Setup?: boolean;
195
+ /**
196
+ * Hook invoked after the Aztec L1 rollup contracts are deployed but BEFORE the node/sequencer
197
+ * start, while anvil automine is still enabled (when `automineL1Setup` is true, the default).
198
+ * Deploy extra L1 contracts a test needs here (e.g. a cross-chain token portal + ERC20) so they
199
+ * mine instantly under automine instead of paying the L1 block interval once the node is running
200
+ * (and racing the live sequencer/archiver). The resolved value is exposed on the returned context
201
+ * as `extraL1DeployResult`. The hook receives setup's L1 deployer client (the same one used to
202
+ * deploy Multicall3).
203
+ */
204
+ deployExtraL1Contracts?: (deps: {
205
+ l1Client: ExtendedViemWalletClient;
206
+ deployL1ContractsValues: DeployAztecL1ContractsReturnType;
207
+ logger: Logger;
208
+ }) => Promise<TDeployExtraL1ContractsReturnType>;
184
209
  /** How many accounts to seed and unlock in anvil. */
185
210
  anvilAccounts?: number;
186
211
  /** Port to start anvil (defaults to 8545) */
@@ -196,20 +221,34 @@ export type SetupOptions = {
196
221
  zkPassportArgs?: ZKPassportArgs;
197
222
  /** Whether to fund the sponsored FPC in genesis (defaults to false). */
198
223
  fundSponsoredFPC?: boolean;
199
- /** Whether to skip deploying accounts during setup (legacy behavior for tests using deployAccounts helper). */
200
- skipAccountDeployment?: boolean;
224
+ /**
225
+ * Compute extra addresses to fund at genesis from the accounts setup just generated (passed as the
226
+ * argument). Runs after the default accounts are created and before genesis values are computed, so a
227
+ * test can genesis-fund a contract whose address derives from a default account (e.g. an FPC whose
228
+ * admin is the first account) instead of bridging fee juice to it during setup. Each returned address
229
+ * is funded with the same fee juice as an initial account and included in the L1 portal `fundingNeeded`.
230
+ */
231
+ computeExtraGenesisFundedAddresses?: (defaultAccounts: InitialAccountData[]) => Promise<AztecAddress[]>;
201
232
  /** L1 contracts deployment arguments. */
202
233
  l1ContractsArgs?: Partial<DeployAztecL1ContractsArgs>;
203
- /** Wallet minimum fee padding multiplier (defaults to 0.5, which is 50% padding). */
234
+ /** Wallet minimum fee padding multiplier */
204
235
  walletMinFeePadding?: number;
236
+ /** Whether the initial node should be a lightweight RPC-only node (no sequencer, no validator).
237
+ * Use for tests that create their own validator nodes and don't need the initial sequencer. */
238
+ skipInitialSequencer?: boolean;
239
+ /** Whether to swap the production Sequencer for the minimal AutomineSequencer.
240
+ * Use only for single-sequencer non-block-building tests. See AUTOMINE_E2E_OPTS in `fixtures.ts`. */
241
+ useAutomineSequencer?: boolean;
242
+ /** Options forwarded to PXE creation (e.g. execution hooks). */
243
+ pxeCreationOptions?: PXECreationOptions;
205
244
  } & Partial<AztecNodeConfig>;
206
245
 
207
246
  /** Context for an end-to-end test as returned by the `setup` function */
208
- export type EndToEndContext = {
247
+ export type EndToEndContext<TDeployExtraL1ContractsReturnType = unknown> = {
209
248
  /** The Anvil instance (only set if anvil was started locally). */
210
249
  anvil: Anvil | undefined;
211
250
  /** The Aztec Node service or client a connected to it. */
212
- aztecNode: AztecNode;
251
+ aztecNode: AztecNode & AztecNodeDebug;
213
252
  /** The Aztec Node as a service. */
214
253
  aztecNodeService: AztecNodeService;
215
254
  /** Client to the Aztec Node admin interface. */
@@ -224,8 +263,8 @@ export type EndToEndContext = {
224
263
  config: AztecNodeConfig;
225
264
  /** The Aztec Node configuration (alias for config for backward compatibility). */
226
265
  aztecNodeConfig: AztecNodeConfig;
227
- /** The data for the initial funded accounts. */
228
- initialFundedAccounts: InitialAccountData[];
266
+ /** Data for the extra accounts funded at genesis but not created by setup (the test creates/deploys them). */
267
+ additionallyFundedAccounts: InitialAccountData[];
229
268
  /** The wallet to be used. */
230
269
  wallet: TestWallet;
231
270
  /** The wallets to be used. */
@@ -236,8 +275,6 @@ export type EndToEndContext = {
236
275
  cheatCodes: CheatCodes;
237
276
  /** The cheat codes for L1 */
238
277
  ethCheatCodes: EthCheatCodes;
239
- /** The anvil test watcher. */
240
- watcher: AnvilTestWatcher;
241
278
  /** Allows tweaking current system time, used by the epoch cache only. */
242
279
  dateProvider: TestDateProvider;
243
280
  /** Telemetry client */
@@ -248,8 +285,10 @@ export type EndToEndContext = {
248
285
  sequencerDelayer: Delayer | undefined;
249
286
  /** Delayer for prover node L1 txs (only when enableDelayer and startProverNode are true). */
250
287
  proverDelayer: Delayer | undefined;
251
- /** Prefilled public data used for setting up nodes. */
252
- prefilledPublicData: PublicDataTreeLeaf[] | undefined;
288
+ /** Genesis data used for setting up nodes. */
289
+ genesis: GenesisData | undefined;
290
+ /** Resolved value of the `deployExtraL1Contracts` setup hook, if one was provided. */
291
+ extraL1DeployResult: TDeployExtraL1ContractsReturnType;
253
292
  /** ACVM config (only set if running locally). */
254
293
  acvmConfig: Awaited<ReturnType<typeof getACVMConfig>>;
255
294
  /** BB config (only set if running locally). */
@@ -260,22 +299,75 @@ export type EndToEndContext = {
260
299
  teardown: () => Promise<void>;
261
300
  };
262
301
 
302
+ /**
303
+ * When CONTRACT_ARTIFACTS_VERSION is set (backwards compatibility testing), asserts that the loaded artifact's
304
+ * aztecVersion matches the expected version. This is a sanity check verifying that the legacy artifact resolver
305
+ * actually swapped in the correct version.
306
+ */
307
+ function assertContractArtifactsVersion() {
308
+ const expected = process.env.CONTRACT_ARTIFACTS_VERSION;
309
+ if (!expected) {
310
+ return;
311
+ }
312
+ const { aztecVersion } = SponsoredFPCContract.artifact;
313
+ // TODO(F-557): Remove this bypass once pre-version artifacts are no longer tested.
314
+ if (aztecVersion === ARTIFACT_VERSION_BEFORE_INJECTION) {
315
+ createLogger('e2e:setup').info(
316
+ `Skipping artifact version check: artifact predates version injection (CONTRACT_ARTIFACTS_VERSION=${expected})`,
317
+ );
318
+ return;
319
+ }
320
+ if (aztecVersion !== expected) {
321
+ throw new Error(
322
+ `Artifact version mismatch: expected ${expected} but got ${aztecVersion}. ` +
323
+ `The legacy artifact resolver may not have swapped in the correct version.`,
324
+ );
325
+ }
326
+ }
327
+
263
328
  /**
264
329
  * Sets up the environment for the end-to-end tests.
265
330
  * @param numberOfAccounts - The number of new accounts to be created once the PXE is initiated.
266
331
  * @param opts - Options to pass to the node initialization and to the setup script.
267
332
  * @param pxeOpts - Options to pass to the PXE initialization.
268
333
  */
269
- export async function setup(
334
+ export function setup<TDeployExtraL1ContractsReturnType = unknown>(
270
335
  numberOfAccounts = 1,
271
- opts: SetupOptions = {},
336
+ opts: SetupOptions<TDeployExtraL1ContractsReturnType> = {},
272
337
  pxeOpts: Partial<PXEConfig> = {},
273
338
  chain: Chain = foundry,
274
- ): Promise<EndToEndContext> {
339
+ ): Promise<EndToEndContext<TDeployExtraL1ContractsReturnType>> {
340
+ // Tag the top-level env spin-up with the prover mode (none → fake → real), the largest config-driven
341
+ // swing in setup cost, so the three factories are comparable on the span leaderboard. The internals
342
+ // (anvil / l1-deploy / sequencer-start / pxe / wallet:create) decompose this further.
343
+ const proverMode = opts.realProofs ? 'real' : opts.startProverNode ? 'fake' : 'none';
344
+ return testSpan(`setup:env:${proverMode}`, async () => {
345
+ const ctx = await setupInner(numberOfAccounts, opts, pxeOpts, chain);
346
+ if (process.env.EXIT_E2E_AFTER_SETUP) {
347
+ ctx.logger.info('EXIT_E2E_AFTER_SETUP is set; aborting before the test body runs');
348
+ throw new Error('EXIT_E2E_AFTER_SETUP');
349
+ }
350
+ return ctx;
351
+ });
352
+ }
353
+
354
+ async function setupInner<TDeployExtraL1ContractsReturnType = unknown>(
355
+ numberOfAccounts: number,
356
+ opts: SetupOptions<TDeployExtraL1ContractsReturnType>,
357
+ pxeOpts: Partial<PXEConfig>,
358
+ chain: Chain,
359
+ ): Promise<EndToEndContext<TDeployExtraL1ContractsReturnType>> {
360
+ assertContractArtifactsVersion();
361
+ const logger = getLogger();
275
362
  let anvil: Anvil | undefined;
276
363
  try {
277
364
  opts.aztecTargetCommitteeSize ??= 0;
278
- opts.slasherFlavor ??= 'none';
365
+ opts.slasherEnabled ??= false;
366
+ // Mine the L1 setup txs (Multicall3 + rollup contract deployment) immediately instead of
367
+ // waiting on anvil's block interval — this is the dominant cost of e2e setup. Suites that
368
+ // assert on genesis-relative L1 timing can opt out by passing `automineL1Setup: false`.
369
+ opts.automineL1Setup ??= true;
370
+ logger.trace('Starting e2e test setup');
279
371
 
280
372
  const config: AztecNodeConfig & SetupOptions = { ...getConfigEnvVars(), ...opts };
281
373
  // use initialValidators for the node config
@@ -285,16 +377,12 @@ export async function setup(
285
377
  config.maxPendingTxCount = opts.maxPendingTxCount ?? TEST_MAX_PENDING_TX_POOL_COUNT;
286
378
  // For tests we only want proving enabled if specifically requested
287
379
  config.realProofs = !!opts.realProofs;
288
- // Only enforce the time table if requested
289
- config.enforceTimeTable = !!opts.enforceTimeTable;
290
380
  // Enable the tx delayer for tests (default config has it disabled, so we force-enable it here)
291
381
  config.enableDelayer = true;
292
382
  config.listenAddress = '127.0.0.1';
293
383
 
294
384
  config.minTxPoolAgeMs = opts.minTxPoolAgeMs ?? 0;
295
385
 
296
- const logger = getLogger();
297
-
298
386
  // Create a temp directory for any services that need it and cleanup later
299
387
  const directoryToCleanup = path.join(tmpdir(), randomBytes(8).toString('hex'));
300
388
  await fs.mkdir(directoryToCleanup, { recursive: true });
@@ -308,16 +396,19 @@ export async function setup(
308
396
  if (!isAnvilTestChain(chain.id)) {
309
397
  throw new Error(`No ETHEREUM_HOSTS set but non anvil chain requested`);
310
398
  }
311
- const res = await startAnvil({
312
- l1BlockTime: opts.ethereumSlotDuration,
313
- accounts: opts.anvilAccounts,
314
- port: opts.anvilPort ?? (process.env.ANVIL_PORT ? parseInt(process.env.ANVIL_PORT) : undefined),
315
- slotsInAnEpoch: opts.anvilSlotsInAnEpoch,
316
- dateProvider,
317
- });
399
+ const res = await testSpan('setup:env:anvil', () =>
400
+ startAnvil({
401
+ l1BlockTime: opts.ethereumSlotDuration,
402
+ accounts: opts.anvilAccounts,
403
+ port: opts.anvilPort ?? (process.env.ANVIL_PORT ? parseInt(process.env.ANVIL_PORT) : undefined),
404
+ slotsInAnEpoch: opts.anvilSlotsInAnEpoch,
405
+ dateProvider,
406
+ }),
407
+ );
318
408
  anvil = res.anvil;
319
409
  config.l1RpcUrls = [res.rpcUrl];
320
410
  }
411
+ logger.trace('Started anvil and L1 RPC client');
321
412
 
322
413
  // Enable logging metrics to a local file named after the test suite
323
414
  if (isMetricsLoggingRequested()) {
@@ -334,6 +425,7 @@ export async function setup(
334
425
  if (opts.l1StartTime) {
335
426
  await ethCheatCodes.warp(opts.l1StartTime, { resetBlockInterval: true });
336
427
  }
428
+ logger.trace('Initialized L1 cheat codes and applied state/time overrides');
337
429
 
338
430
  let publisherPrivKeyHex: `0x${string}` | undefined = undefined;
339
431
  let publisherHdAccount: HDAccount | PrivateKeyAccount | undefined = undefined;
@@ -361,12 +453,14 @@ export async function setup(
361
453
  if (config.coinbase === undefined) {
362
454
  config.coinbase = EthAddress.fromString(publisherHdAccount.address);
363
455
  }
456
+ logger.trace('Resolved L1 publisher account');
364
457
 
365
- // Determine which addresses to fund in genesis
366
- const initialFundedAccounts =
367
- opts.initialFundedAccounts ??
368
- (await generateSchnorrAccounts(opts.numberOfInitialFundedAccounts ?? Math.max(numberOfAccounts, 10)));
369
- const addressesToFund = initialFundedAccounts.map(a => a.address);
458
+ // The accounts setup creates itself: `numberOfAccounts` initializerless accounts, generated here and
459
+ // funded at genesis so they are immediately usable.
460
+ const defaultAccounts = await generateSchnorrAccounts(numberOfAccounts);
461
+ // Extra accounts the test wants funded at genesis but will create/deploy itself.
462
+ const additionallyFundedAccounts = opts.additionallyFundedAccounts ?? [];
463
+ const addressesToFund = [...defaultAccounts, ...additionallyFundedAccounts].map(a => a.address);
370
464
 
371
465
  // Optionally fund the sponsored FPC
372
466
  if (opts.fundSponsoredFPC) {
@@ -374,11 +468,29 @@ export async function setup(
374
468
  addressesToFund.push(sponsoredFPCAddress);
375
469
  }
376
470
 
377
- const { genesisArchiveRoot, prefilledPublicData, fundingNeeded } = await getGenesisValues(
471
+ // Fund any extra addresses whose value depends on the just-generated accounts (e.g. an FPC admin'd
472
+ // by a default account), so a test can genesis-fund them instead of bridging fee juice during setup.
473
+ if (opts.computeExtraGenesisFundedAddresses) {
474
+ addressesToFund.push(...(await opts.computeExtraGenesisFundedAddresses(defaultAccounts)));
475
+ }
476
+ logger.trace('Generated test accounts to fund at genesis');
477
+
478
+ // Preload the standard contracts (AuthRegistry, PublicChecks, HandshakeRegistry) so their `ensure*Published` setup
479
+ // helpers short-circuit their publish txs. The archiver flag seeds the bytecode/instance into every spawned node's
480
+ // contract store; the genesis nullifiers make the AVM's deployment-nullifier check pass when they are called. Both
481
+ // must go together (flag alone would recreate the publish-collision bug), so the flag lives here beside the seeding.
482
+ config.testPreloadStandardContracts = true;
483
+ const standardContractNullifiers = await getStandardContractGenesisNullifiers();
484
+
485
+ const genesisTimestamp = BigInt(Math.floor(Date.now() / 1000));
486
+ const { genesisArchiveRoot, genesis, fundingNeeded } = await getGenesisValues(
378
487
  addressesToFund,
379
488
  opts.initialAccountFeeJuice,
380
489
  opts.genesisPublicData,
490
+ genesisTimestamp,
491
+ standardContractNullifiers,
381
492
  );
493
+ logger.trace('Computed genesis values');
382
494
 
383
495
  const wasAutomining = await ethCheatCodes.isAutoMining();
384
496
  const enableAutomine = opts.automineL1Setup && !wasAutomining && isAnvilTestChain(chain.id);
@@ -388,18 +500,21 @@ export async function setup(
388
500
 
389
501
  const l1Client = createExtendedL1Client(config.l1RpcUrls, publisherHdAccount!, chain);
390
502
 
503
+ // Warm both KZG trusted setups (ours + anvil's) in parallel
504
+ if (anvil && isAnvilTestChain(chain.id)) {
505
+ await warmBlobKzg(l1Client, logger);
506
+ }
507
+
391
508
  // Deploy Multicall3 if running locally
392
509
  await deployMulticall3(l1Client, logger);
393
510
 
394
511
  // Force viem to refresh its nonce cache to avoid "nonce too low" errors in subsequent transactions
395
512
  // This is necessary because deployMulticall3 sends multiple transactions and viem may cache a stale nonce
396
513
  await l1Client.getTransactionCount({ address: l1Client.account.address });
514
+ logger.trace('Deployed Multicall3');
397
515
 
398
- const deployL1ContractsValues: DeployAztecL1ContractsReturnType = await deployAztecL1Contracts(
399
- config.l1RpcUrls[0],
400
- publisherPrivKeyHex!,
401
- chain.id,
402
- {
516
+ const deployL1ContractsValues: DeployAztecL1ContractsReturnType = await testSpan('setup:env:l1-deploy', () =>
517
+ deployAztecL1Contracts(config.l1RpcUrls[0], publisherPrivKeyHex!, chain.id, {
403
518
  ...getL1ContractsConfigEnvVars(),
404
519
  ...opts,
405
520
  ...opts.l1ContractsArgs,
@@ -409,20 +524,52 @@ export async function setup(
409
524
  initialValidators: opts.initialValidators,
410
525
  feeJuicePortalInitialBalance: fundingNeeded,
411
526
  realVerifier: false,
412
- },
527
+ }),
413
528
  );
414
529
 
415
- config.l1Contracts = deployL1ContractsValues.l1ContractAddresses;
530
+ Object.assign(config, deployL1ContractsValues.l1ContractAddresses);
416
531
  config.rollupVersion = deployL1ContractsValues.rollupVersion;
417
532
 
533
+ // Propagate L1-contracts-config overrides back to the node config so the archiver's
534
+ // `l1Constants` (and any other node-side consumer) agrees with what was actually deployed.
535
+ // Without this, a per-test override like `aztecEpochDuration: 4` lands on the rollup contract
536
+ // but the node config keeps the default (32), so `archiver.isEpochComplete(0)` computes
537
+ // `endSlot=31` and `EpochTestSettler`/`EpochMonitor` never fires — letting the
538
+ // `aztecProofSubmissionEpochs` window expire mid-test and prune the pending chain.
539
+ // Skip undefined values: callers (e.g. `P2PNetworkTest`) sometimes build `l1ContractsArgs`
540
+ // by spreading a partial `AztecNodeConfig`, which leaves unset fields (notably `dataDirectory`)
541
+ // as `undefined`. A blind Object.assign would then clobber the temp `dataDirectory` set earlier
542
+ // in this function and crash `setupSharedBlobStorage`.
543
+ if (opts.l1ContractsArgs) {
544
+ for (const [key, value] of Object.entries(opts.l1ContractsArgs)) {
545
+ if (value !== undefined) {
546
+ (config as unknown as Record<string, unknown>)[key] = value;
547
+ }
548
+ }
549
+ }
550
+
551
+ // Deploy any test-specific L1 contracts while automine is still on and before the node starts,
552
+ // so they mine instantly rather than paying the L1 block interval once the sequencer is live.
553
+ let extraL1DeployResult: TDeployExtraL1ContractsReturnType = undefined as TDeployExtraL1ContractsReturnType;
554
+ if (opts.deployExtraL1Contracts) {
555
+ logger.trace('Running deployExtraL1Contracts hook');
556
+ extraL1DeployResult = await opts.deployExtraL1Contracts({
557
+ l1Client,
558
+ deployL1ContractsValues,
559
+ logger,
560
+ });
561
+ // The hook reused `l1Client` to send deploy txs, so refresh viem's nonce cache to avoid a
562
+ // stale cached nonce for later transactions on the publisher account.
563
+ await l1Client.getTransactionCount({ address: l1Client.account.address });
564
+ }
565
+
418
566
  if (enableAutomine) {
419
- await ethCheatCodes.setAutomine(false);
420
- await ethCheatCodes.setIntervalMining(config.ethereumSlotDuration);
567
+ await ethCheatCodes.startIntervalMiningWithFreshBlock(config.ethereumSlotDuration);
421
568
  }
422
569
 
423
570
  // In compose mode (no local anvil), sync dateProvider to L1 time since it may have drifted
424
- // ahead of system time due to the local-network watcher warping time forward on each filled slot.
425
- // When running with a local anvil, the dateProvider is kept in sync via the stdout listener.
571
+ // ahead of system time. When running with a local anvil, the dateProvider is kept in sync via
572
+ // the stdout listener.
426
573
  if (!anvil) {
427
574
  dateProvider.setTime((await ethCheatCodes.lastBlockTimestamp()) * 1000);
428
575
  }
@@ -430,61 +577,43 @@ export async function setup(
430
577
  if (opts.l2StartTime) {
431
578
  await ethCheatCodes.warp(opts.l2StartTime, { resetBlockInterval: true });
432
579
  }
580
+ logger.trace('Deployed L1 rollup contracts');
581
+
582
+ // These boot steps are independent and write disjoint config keys, so run them concurrently:
583
+ // telemetry returns a client (no config write), shared blob storage writes blobFileStore* keys,
584
+ // and the ACVM/BB config resolvers write their own acvm*/bb* keys.
585
+ const [telemetryClient, , acvmConfig, bbConfig] = await Promise.all([
586
+ // Use metricsPort-based telemetry if provided, otherwise use the regular telemetry client
587
+ opts.metricsPort ? getEndToEndTestTelemetryClient(opts.metricsPort) : getTelemetryClient(opts.telemetryConfig),
588
+ setupSharedBlobStorage(config),
589
+ getACVMConfig(logger),
590
+ getBBConfig(logger),
591
+ ]);
592
+ logger.trace('Created telemetry client');
593
+ logger.trace('Set up shared blob storage');
433
594
 
434
- const watcher = new AnvilTestWatcher(
435
- new EthCheatCodesWithState(config.l1RpcUrls, dateProvider),
436
- deployL1ContractsValues.l1ContractAddresses.rollupAddress,
437
- deployL1ContractsValues.l1Client,
438
- dateProvider,
439
- );
440
- if (!opts.disableAnvilTestWatcher) {
441
- await watcher.start();
442
- }
443
-
444
- // Use metricsPort-based telemetry if provided, otherwise use the regular telemetry client
445
- const telemetryClient = opts.metricsPort
446
- ? await getEndToEndTestTelemetryClient(opts.metricsPort)
447
- : await getTelemetryClient(opts.telemetryConfig);
448
-
449
- await setupSharedBlobStorage(config);
450
-
451
- logger.verbose('Creating and synching an aztec node', config);
452
-
453
- const acvmConfig = await getACVMConfig(logger);
454
595
  if (acvmConfig) {
455
596
  config.acvmWorkingDirectory = acvmConfig.acvmWorkingDirectory;
456
597
  config.acvmBinaryPath = acvmConfig.acvmBinaryPath;
457
598
  }
599
+ logger.trace('Resolved ACVM config');
458
600
 
459
- const bbConfig = await getBBConfig(logger);
460
601
  if (bbConfig) {
461
602
  config.bbBinaryPath = bbConfig.bbBinaryPath;
462
603
  config.bbWorkingDirectory = bbConfig.bbWorkingDirectory;
463
604
  }
605
+ logger.trace('Resolved Barretenberg config');
606
+
607
+ logger.verbose('Creating and synching an aztec node', config);
464
608
 
465
609
  let mockGossipSubNetwork: MockGossipSubNetwork | undefined;
466
610
  let p2pClientDeps: P2PClientDeps | undefined = undefined;
467
611
 
468
612
  if (opts.mockGossipSubNetwork) {
469
- mockGossipSubNetwork = new MockGossipSubNetwork();
613
+ mockGossipSubNetwork = new MockGossipSubNetwork(opts.mockGossipSubNetworkLatency);
470
614
  p2pClientDeps = { p2pServiceFactory: getMockPubSubP2PServiceFactory(mockGossipSubNetwork) };
471
615
  }
472
616
 
473
- // Transactions built against the genesis state must be included in block 1, otherwise they are dropped.
474
- // To avoid test failures from dropped transactions, we ensure progression beyond genesis before proceeding.
475
- // For account deployments, we set minTxsPerBlock=1 and deploy accounts sequentially for guaranteed success.
476
- // If no accounts need deployment, we await an empty block to confirm network progression.
477
- const originalMinTxsPerBlock = config.minTxsPerBlock;
478
- if (originalMinTxsPerBlock === undefined) {
479
- throw new Error('minTxsPerBlock is undefined in e2e test setup');
480
- }
481
-
482
- // Only set minTxsPerBlock=1 if we're going to deploy accounts and need reliable block inclusion
483
- const shouldDeployAccounts = numberOfAccounts > 0 && !opts.skipAccountDeployment;
484
- // Only set minTxsPerBlock=0 if we need an empty block (no accounts at all, not skipped deployment)
485
- const needsEmptyBlock = numberOfAccounts === 0 && !opts.skipAccountDeployment;
486
- config.minTxsPerBlock = shouldDeployAccounts ? 1 : needsEmptyBlock ? 0 : originalMinTxsPerBlock;
487
-
488
617
  config.p2pEnabled = opts.mockGossipSubNetwork || config.p2pEnabled;
489
618
  config.p2pIp = opts.p2pIp ?? config.p2pIp ?? '127.0.0.1';
490
619
 
@@ -494,14 +623,29 @@ export async function setup(
494
623
  }
495
624
  }
496
625
 
497
- const aztecNodeService = await withLoggerBindings({ actor: 'node-0' }, () =>
498
- AztecNodeService.createAndSync(
499
- config,
500
- { dateProvider, telemetry: telemetryClient, p2pClientDeps },
501
- { prefilledPublicData },
626
+ // When skipInitialSequencer is set, the initial node is a lightweight RPC-only node.
627
+ // We apply these overrides to a copy so they don't leak into the returned config.
628
+ // Keep P2P enabled if mockGossipSubNetwork is used (needed for tx propagation to validators).
629
+ const initialNodeConfig = opts.skipInitialSequencer
630
+ ? {
631
+ ...config,
632
+ disableValidator: true,
633
+ ...(opts.mockGossipSubNetwork ? {} : { p2pEnabled: false, bootstrapNodes: [] as string[] }),
634
+ }
635
+ : config;
636
+ logger.trace('Prepared aztec node config');
637
+
638
+ const aztecNodeService = await testSpan('setup:env:sequencer-start', () =>
639
+ withLoggerBindings({ actor: 'node-0' }, () =>
640
+ createAztecNodeService(
641
+ initialNodeConfig,
642
+ { dateProvider, telemetry: telemetryClient, p2pClientDeps },
643
+ { genesis, dontStartSequencer: opts.skipInitialSequencer },
644
+ ),
502
645
  ),
503
646
  );
504
647
  const sequencerClient = aztecNodeService.getSequencer();
648
+ logger.trace('Created and synced aztec node');
505
649
 
506
650
  let proverNode: AztecNodeService | undefined = undefined;
507
651
  if (opts.startProverNode) {
@@ -515,16 +659,19 @@ export async function setup(
515
659
  rpcTxProviders: [aztecNodeService],
516
660
  };
517
661
 
518
- ({ proverNode } = await createAndSyncProverNode(
519
- proverNodePrivateKeyHex,
520
- config,
521
- {
522
- ...config.proverNodeConfig,
523
- dataDirectory: proverNodeDataDirectory,
524
- },
525
- { dateProvider, p2pClientDeps, telemetry: telemetryClient },
526
- { prefilledPublicData },
662
+ ({ proverNode } = await testSpan('setup:env:prover-node', () =>
663
+ createAndSyncProverNode(
664
+ proverNodePrivateKeyHex,
665
+ config,
666
+ {
667
+ ...config.proverNodeConfig,
668
+ dataDirectory: proverNodeDataDirectory,
669
+ },
670
+ { dateProvider, p2pClientDeps, telemetry: telemetryClient },
671
+ { genesis },
672
+ ),
527
673
  ));
674
+ logger.trace('Created prover node');
528
675
  }
529
676
 
530
677
  const sequencerDelayer = sequencerClient?.getDelayer();
@@ -535,13 +682,22 @@ export async function setup(
535
682
  pxeConfig.dataDirectory = path.join(directoryToCleanup, randomBytes(8).toString('hex'));
536
683
  // For tests we only want proving enabled if specifically requested
537
684
  pxeConfig.proverEnabled = !!pxeOpts.proverEnabled;
538
- const wallet = await TestWallet.create(aztecNodeService, pxeConfig, { loggerActorLabel: 'pxe-0' });
685
+ const wallet = await testSpan('setup:env:pxe', () =>
686
+ TestWallet.create(aztecNodeService, pxeConfig, {
687
+ loggerActorLabel: 'pxe-0',
688
+ // In-process node implements the debug API, so register public function signatures for named traces.
689
+ nodeDebug: aztecNodeService,
690
+ ...opts.pxeCreationOptions,
691
+ }),
692
+ );
539
693
 
540
694
  if (opts.walletMinFeePadding !== undefined) {
541
695
  wallet.setMinFeePadding(opts.walletMinFeePadding);
542
696
  }
697
+ logger.trace('Created PXE and test wallet');
543
698
 
544
699
  const cheatCodes = await CheatCodes.create(config.l1RpcUrls, aztecNodeService, dateProvider);
700
+ logger.trace('Created cheat codes');
545
701
 
546
702
  if (
547
703
  (opts.aztecTargetCommitteeSize && opts.aztecTargetCommitteeSize > 0) ||
@@ -555,64 +711,48 @@ export async function setup(
555
711
  );
556
712
  await cheatCodes.rollup.setupEpoch();
557
713
  await cheatCodes.rollup.debugRollup();
714
+ logger.trace('Advanced chain to set up validator committee');
558
715
  }
559
716
 
560
717
  let accounts: AztecAddress[] = [];
561
718
 
562
- if (shouldDeployAccounts) {
563
- logger.info(
564
- `${numberOfAccounts} accounts are being deployed. Reliably progressing past genesis by setting minTxsPerBlock to 1 and waiting for the accounts to be deployed`,
565
- );
566
- const accountsData = initialFundedAccounts.slice(0, numberOfAccounts);
567
- const accountManagers = await deployFundedSchnorrAccounts(wallet, accountsData);
568
- accounts = accountManagers.map(accountManager => accountManager.address);
569
- } else if (needsEmptyBlock) {
570
- logger.info('No accounts are being deployed, waiting for an empty block 1 to be mined');
571
- while ((await aztecNodeService.getBlockNumber()) === 0) {
572
- await sleep(2000);
573
- }
574
- }
575
- // If skipAccountDeployment is true, we don't deploy or wait - tests will handle account deployment later
576
-
577
- // Now we restore the original minTxsPerBlock setting if we changed it.
578
- if (sequencerClient && config.minTxsPerBlock !== originalMinTxsPerBlock) {
579
- sequencerClient.getSequencer().updateConfig({ minTxsPerBlock: originalMinTxsPerBlock });
580
- }
581
-
582
- if (initialFundedAccounts.length < numberOfAccounts) {
583
- throw new Error(
584
- `Unable to deploy ${numberOfAccounts} accounts. Only ${initialFundedAccounts.length} accounts were funded.`,
585
- );
719
+ // Create the default accounts. They are initializerless, so this is a PXE-side operation (registration
720
+ // + a simulated store call) with no on-chain tx, independent of the sequencer.
721
+ if (numberOfAccounts > 0) {
722
+ logger.info(`Creating ${numberOfAccounts} initializerless test accounts`);
723
+ await testSpan('wallet:create', () => createFundedInitializerlessAccounts(wallet, defaultAccounts));
724
+ accounts = defaultAccounts.map(a => a.address);
586
725
  }
726
+ logger.trace('Created funded test accounts');
587
727
 
588
- const teardown = async () => {
589
- try {
590
- await tryStop(wallet, logger);
591
- await tryStop(aztecNodeService, logger);
592
- await tryStop(proverNode, logger);
728
+ const teardown = () =>
729
+ testSpan('teardown:env', async () => {
730
+ try {
731
+ await tryStop(wallet, logger);
732
+ await tryStop(aztecNodeService, logger);
733
+ await tryStop(proverNode, logger);
593
734
 
594
- if (acvmConfig?.cleanup) {
595
- await acvmConfig.cleanup();
596
- }
735
+ if (acvmConfig?.cleanup) {
736
+ await acvmConfig.cleanup();
737
+ }
597
738
 
598
- if (bbConfig?.cleanup) {
599
- await bbConfig.cleanup();
600
- }
739
+ if (bbConfig?.cleanup) {
740
+ await bbConfig.cleanup();
741
+ }
601
742
 
602
- await tryStop(watcher, logger);
603
- await tryStop(anvil, logger);
743
+ await tryStop(anvil, logger);
604
744
 
605
- await tryRmDir(directoryToCleanup, logger);
606
- } catch (err) {
607
- logger.error(`Error during e2e test teardown`, err);
608
- } finally {
609
- try {
610
- await telemetryClient.stop();
745
+ await tryRmDir(directoryToCleanup, logger);
611
746
  } catch (err) {
612
- logger.error(`Error during telemetry client stop`, err);
747
+ logger.error(`Error during e2e test teardown`, err);
748
+ } finally {
749
+ try {
750
+ await telemetryClient.stop();
751
+ } catch (err) {
752
+ logger.error(`Error during telemetry client stop`, err);
753
+ }
613
754
  }
614
- }
615
- };
755
+ });
616
756
 
617
757
  return {
618
758
  anvil,
@@ -625,10 +765,11 @@ export async function setup(
625
765
  aztecNodeConfig: config,
626
766
  dateProvider,
627
767
  deployL1ContractsValues,
628
- initialFundedAccounts,
768
+ additionallyFundedAccounts,
629
769
  logger,
630
770
  mockGossipSubNetwork,
631
- prefilledPublicData,
771
+ genesis,
772
+ extraL1DeployResult,
632
773
  proverNode,
633
774
  sequencerDelayer,
634
775
  proverDelayer,
@@ -637,7 +778,6 @@ export async function setup(
637
778
  telemetryClient,
638
779
  wallet,
639
780
  accounts,
640
- watcher,
641
781
  acvmConfig,
642
782
  bbConfig,
643
783
  directoryToCleanup,
@@ -704,11 +844,16 @@ export async function registerSponsoredFPC(wallet: Wallet): Promise<void> {
704
844
  await wallet.registerContract(await getSponsoredFPCInstance(), SponsoredFPCContract.artifact);
705
845
  }
706
846
 
707
- export async function waitForProvenChain(node: AztecNode, targetBlock?: BlockNumber, timeoutSec = 60, intervalSec = 1) {
847
+ export async function waitForProvenChain(
848
+ node: AztecNode,
849
+ targetBlock?: BlockNumber,
850
+ timeoutSec = 60,
851
+ intervalSec = 0.25,
852
+ ) {
708
853
  targetBlock ??= await node.getBlockNumber();
709
854
 
710
855
  await retryUntil(
711
- async () => (await node.getProvenBlockNumber()) >= targetBlock,
856
+ async () => (await node.getBlockNumber('proven')) >= targetBlock,
712
857
  'proven chain status',
713
858
  timeoutSec,
714
859
  intervalSec,
@@ -727,11 +872,12 @@ export function createAndSyncProverNode(
727
872
  telemetry?: TelemetryClient;
728
873
  dateProvider: DateProvider;
729
874
  p2pClientDeps?: P2PClientDeps;
875
+ proverNodeDeps?: Partial<ProverNodeDeps>;
730
876
  },
731
- options: { prefilledPublicData: PublicDataTreeLeaf[]; dontStart?: boolean },
877
+ options: { genesis?: GenesisData; dontStart?: boolean },
732
878
  ): Promise<{ proverNode: AztecNodeService }> {
733
879
  return withLoggerBindings({ actor: 'prover-0' }, async () => {
734
- const proverNode = await AztecNodeService.createAndSync(
880
+ const proverNode = await createAztecNodeService(
735
881
  {
736
882
  ...baseConfig,
737
883
  ...configOverrides,
@@ -741,7 +887,7 @@ export function createAndSyncProverNode(
741
887
  proverPublisherPrivateKeys: [new SecretValue(proverNodePrivateKey)],
742
888
  },
743
889
  deps,
744
- { ...options, dontStartProverNode: options.dontStart },
890
+ { genesis: options.genesis, dontStartProverNode: options.dontStart },
745
891
  );
746
892
 
747
893
  if (!proverNode.getProverNode()) {
@@ -799,96 +945,56 @@ export async function expectMappingDelta<K, V extends number | bigint>(
799
945
  }
800
946
 
801
947
  /**
802
- * Registers the contract class used for test accounts and publicly deploys the instances requested.
803
- * Use this when you need to make a public call to an account contract, such as for requesting a public authwit.
948
+ * Registers the auth_registry contract class and publishes its standard instance if not already
949
+ * present, and registers the artifact with PXE. Publishing is required before exercising the public
950
+ * authwit path (which relies on the AVM's deployment-nullifier check); the PXE-side registration is
951
+ * required so revert messages from AuthRegistry calls can be enriched (otherwise assertion strings
952
+ * surface as generic "Assertion failed:" and tests that match on the real message fail).
804
953
  */
805
- export async function ensureAccountContractsPublished(wallet: Wallet, accountsToDeploy: AztecAddress[]) {
806
- const accountsAndAddresses = await Promise.all(
807
- accountsToDeploy.map(async address => {
808
- return {
809
- address,
810
- deployed: (await wallet.getContractMetadata(address)).isContractPublished,
811
- };
812
- }),
813
- );
814
- const instances = (
815
- await Promise.all(
816
- accountsAndAddresses
817
- .filter(({ deployed }) => !deployed)
818
- .map(({ address }) => wallet.getContractMetadata(address)),
819
- )
820
- ).map(contractMetadata => contractMetadata.instance);
821
- const contractClass = await getContractClassFromArtifact(SchnorrAccountContractArtifact);
822
- if (!(await wallet.getContractClassMetadata(contractClass.id)).isContractClassPubliclyRegistered) {
823
- await (await publishContractClass(wallet, SchnorrAccountContractArtifact)).send({ from: accountsToDeploy[0] });
824
- }
825
- const requests = instances.map(instance => publishInstance(wallet, instance!));
826
- const batch = new BatchCall(wallet, requests);
827
- await batch.send({ from: accountsToDeploy[0] });
954
+ export async function ensureAuthRegistryPublished(wallet: Wallet, from: AztecAddress) {
955
+ await testSpan('setup:auth-registry', async () => {
956
+ const { instance, contractClass } = await getStandardAuthRegistry();
957
+ if (!(await wallet.getContractClassMetadata(contractClass.id)).isContractClassPubliclyRegistered) {
958
+ await (await publishContractClass(wallet, AuthRegistryArtifact)).send({ from });
959
+ }
960
+ if (!(await wallet.getContractMetadata(instance.address)).isContractPublished) {
961
+ await publishInstance(wallet, instance).send({ from });
962
+ }
963
+ await wallet.registerContract(instance, AuthRegistryArtifact);
964
+ });
828
965
  }
829
966
 
830
967
  /**
831
- * Helper function to deploy accounts.
832
- * Returns deployed account data that can be used by tests.
968
+ * Registers the public_checks contract class and publishes its standard instance if not already
969
+ * present, and registers the artifact with PXE. Required for any contract that calls
970
+ * `privately_check_timestamp` / `privately_check_block_number` (which dispatch into the
971
+ * deployed PublicChecks contract via an enqueued public call).
833
972
  */
834
- export const deployAccounts =
835
- (numberOfAccounts: number, logger: Logger) =>
836
- async ({ wallet, initialFundedAccounts }: { wallet: TestWallet; initialFundedAccounts: InitialAccountData[] }) => {
837
- if (initialFundedAccounts.length < numberOfAccounts) {
838
- throw new Error(`Cannot deploy more than ${initialFundedAccounts.length} initial accounts.`);
839
- }
840
-
841
- logger.verbose('Deploying accounts funded with fee juice...');
842
- const deployedAccounts = initialFundedAccounts.slice(0, numberOfAccounts);
843
- // Serial due to https://github.com/AztecProtocol/aztec-packages/issues/12045
844
- for (let i = 0; i < deployedAccounts.length; i++) {
845
- const accountManager = await wallet.createSchnorrAccount(
846
- deployedAccounts[i].secret,
847
- deployedAccounts[i].salt,
848
- deployedAccounts[i].signingKey,
849
- );
850
- const deployMethod = await accountManager.getDeployMethod();
851
- await deployMethod.send({
852
- from: AztecAddress.ZERO,
853
- skipClassPublication: i !== 0, // Publish the contract class at most once.
854
- });
855
- }
856
-
857
- return { deployedAccounts };
858
- };
973
+ export async function ensurePublicChecksPublished(wallet: Wallet, from: AztecAddress) {
974
+ const { instance, contractClass } = await getStandardPublicChecks();
975
+ if (!(await wallet.getContractClassMetadata(contractClass.id)).isContractClassPubliclyRegistered) {
976
+ await (await publishContractClass(wallet, PublicChecksArtifact)).send({ from });
977
+ }
978
+ if (!(await wallet.getContractMetadata(instance.address)).isContractPublished) {
979
+ await publishInstance(wallet, instance).send({ from });
980
+ }
981
+ await wallet.registerContract(instance, PublicChecksArtifact);
982
+ }
859
983
 
860
984
  /**
861
- * Registers the contract class used for test accounts and publicly deploys the instances requested.
862
- * Use this when you need to make a public call to an account contract, such as for requesting a public authwit.
985
+ * Registers the handshake_registry contract class and publishes its standard instance if not
986
+ * already present, and registers the artifact with PXE. Required for constrained-delivery flows
987
+ * that call into the HandshakeRegistry at its well-known address.
863
988
  */
864
- export async function publicDeployAccounts(
865
- wallet: Wallet,
866
- accountsToDeploy: AztecAddress[],
867
- waitUntilProven = false,
868
- node?: AztecNode,
869
- ) {
870
- const instances = (await Promise.all(accountsToDeploy.map(account => wallet.getContractMetadata(account)))).map(
871
- metadata => metadata.instance,
872
- );
873
-
874
- const contractClass = await getContractClassFromArtifact(SchnorrAccountContractArtifact);
875
- const alreadyRegistered = (await wallet.getContractClassMetadata(contractClass.id)).isContractClassPubliclyRegistered;
876
-
877
- const calls: ContractFunctionInteraction[] = await Promise.all([
878
- ...(!alreadyRegistered ? [publishContractClass(wallet, SchnorrAccountContractArtifact)] : []),
879
- ...instances.map(instance => publishInstance(wallet, instance!)),
880
- ]);
881
-
882
- const batch = new BatchCall(wallet, calls);
883
-
884
- const { receipt: txReceipt } = await batch.send({ from: accountsToDeploy[0] });
885
- if (waitUntilProven) {
886
- if (!node) {
887
- throw new Error('Need to provide an AztecNode to wait for proven.');
888
- } else {
889
- await waitForProven(node, txReceipt);
890
- }
989
+ export async function ensureHandshakeRegistryPublished(wallet: Wallet, from: AztecAddress) {
990
+ const { instance, contractClass } = await getStandardHandshakeRegistry();
991
+ if (!(await wallet.getContractClassMetadata(contractClass.id)).isContractClassPubliclyRegistered) {
992
+ await (await publishContractClass(wallet, HandshakeRegistryArtifact)).send({ from });
993
+ }
994
+ if (!(await wallet.getContractMetadata(instance.address)).isContractPublished) {
995
+ await publishInstance(wallet, instance).send({ from });
891
996
  }
997
+ await wallet.registerContract(instance, HandshakeRegistryArtifact);
892
998
  }
893
999
 
894
1000
  /**