@aztec/end-to-end 0.0.1-commit.4d3c002 → 0.0.1-commit.4d9804df

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 (298) hide show
  1. package/README.md +217 -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 +45 -29
  30. package/dest/bench/client_flows/data_extractor.js +1 -0
  31. package/dest/bench/utils.d.ts +3 -3
  32. package/dest/bench/utils.d.ts.map +1 -1
  33. package/dest/bench/utils.js +97 -6
  34. package/dest/composed/ha/ha_full_setup.d.ts +77 -0
  35. package/dest/composed/ha/ha_full_setup.d.ts.map +1 -0
  36. package/dest/composed/ha/ha_full_setup.js +383 -0
  37. package/dest/composed/web3signer/multi_validator_keystore_utils.d.ts +12 -0
  38. package/dest/composed/web3signer/multi_validator_keystore_utils.d.ts.map +1 -0
  39. package/dest/fixtures/authwit_proxy.d.ts +1 -1
  40. package/dest/fixtures/authwit_proxy.d.ts.map +1 -1
  41. package/dest/fixtures/authwit_proxy.js +4 -0
  42. package/dest/fixtures/e2e_prover_test.d.ts +12 -9
  43. package/dest/fixtures/e2e_prover_test.d.ts.map +1 -1
  44. package/dest/fixtures/e2e_prover_test.js +50 -30
  45. package/dest/fixtures/fixtures.d.ts +79 -1
  46. package/dest/fixtures/fixtures.d.ts.map +1 -1
  47. package/dest/fixtures/fixtures.js +80 -0
  48. package/dest/fixtures/ha_setup.d.ts +4 -4
  49. package/dest/fixtures/ha_setup.d.ts.map +1 -1
  50. package/dest/fixtures/ha_setup.js +5 -2
  51. package/dest/fixtures/index.d.ts +2 -1
  52. package/dest/fixtures/index.d.ts.map +1 -1
  53. package/dest/fixtures/index.js +1 -0
  54. package/dest/fixtures/schnorr_hardcoded_account_contract.d.ts +25 -0
  55. package/dest/fixtures/schnorr_hardcoded_account_contract.d.ts.map +1 -0
  56. package/dest/fixtures/schnorr_hardcoded_account_contract.js +37 -0
  57. package/dest/fixtures/setup.d.ts +71 -41
  58. package/dest/fixtures/setup.d.ts.map +1 -1
  59. package/dest/fixtures/setup.js +277 -198
  60. package/dest/fixtures/setup_p2p_test.d.ts +10 -6
  61. package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
  62. package/dest/fixtures/setup_p2p_test.js +11 -11
  63. package/dest/fixtures/timing.d.ts +42 -0
  64. package/dest/fixtures/timing.d.ts.map +1 -0
  65. package/dest/fixtures/timing.js +72 -0
  66. package/dest/fixtures/token_utils.d.ts +22 -4
  67. package/dest/fixtures/token_utils.d.ts.map +1 -1
  68. package/dest/fixtures/token_utils.js +21 -1
  69. package/dest/fixtures/utils.d.ts +2 -2
  70. package/dest/fixtures/utils.d.ts.map +1 -1
  71. package/dest/fixtures/utils.js +1 -1
  72. package/dest/fixtures/wait_helpers.d.ts +135 -0
  73. package/dest/fixtures/wait_helpers.d.ts.map +1 -0
  74. package/dest/fixtures/wait_helpers.js +154 -0
  75. package/dest/forward-compatibility/wallet_rpc_client.d.ts +7 -0
  76. package/dest/forward-compatibility/wallet_rpc_client.d.ts.map +1 -0
  77. package/dest/forward-compatibility/wallet_rpc_client.js +15 -0
  78. package/dest/forward-compatibility/wallet_service.d.ts +3 -0
  79. package/dest/forward-compatibility/wallet_service.d.ts.map +1 -0
  80. package/dest/forward-compatibility/wallet_service.js +109 -0
  81. package/dest/install_legacy_contracts.d.cts +10 -0
  82. package/dest/install_legacy_contracts.d.cts.map +1 -0
  83. package/dest/legacy-jest-resolver.d.cts +3 -0
  84. package/dest/legacy-jest-resolver.d.cts.map +1 -0
  85. package/dest/multi-node/block-production/setup.d.ts +97 -0
  86. package/dest/multi-node/block-production/setup.d.ts.map +1 -0
  87. package/dest/multi-node/block-production/setup.js +158 -0
  88. package/dest/multi-node/governance/setup.d.ts +67 -0
  89. package/dest/multi-node/governance/setup.d.ts.map +1 -0
  90. package/dest/multi-node/governance/setup.js +126 -0
  91. package/dest/multi-node/multi_node_test_context.d.ts +212 -0
  92. package/dest/multi-node/multi_node_test_context.d.ts.map +1 -0
  93. package/dest/multi-node/multi_node_test_context.js +347 -0
  94. package/dest/multi-node/slashing/inactivity_setup.d.ts +27 -0
  95. package/dest/multi-node/slashing/inactivity_setup.d.ts.map +1 -0
  96. package/dest/multi-node/slashing/inactivity_setup.js +111 -0
  97. package/dest/multi-node/slashing/setup.d.ts +167 -0
  98. package/dest/multi-node/slashing/setup.d.ts.map +1 -0
  99. package/dest/multi-node/slashing/setup.js +275 -0
  100. package/dest/{e2e_p2p → p2p}/p2p_network.d.ts +19 -10
  101. package/dest/p2p/p2p_network.d.ts.map +1 -0
  102. package/dest/{e2e_p2p → p2p}/p2p_network.js +81 -38
  103. package/dest/p2p/reqresp/utils.d.ts +19 -0
  104. package/dest/p2p/reqresp/utils.d.ts.map +1 -0
  105. package/dest/{e2e_p2p → p2p}/reqresp/utils.js +32 -29
  106. package/dest/p2p/shared.d.ts +72 -0
  107. package/dest/p2p/shared.d.ts.map +1 -0
  108. package/dest/p2p/shared.js +212 -0
  109. package/dest/shared/cross_chain_test_harness.d.ts +6 -4
  110. package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
  111. package/dest/shared/cross_chain_test_harness.js +25 -20
  112. package/dest/shared/gas_portal_test_harness.d.ts +8 -5
  113. package/dest/shared/gas_portal_test_harness.d.ts.map +1 -1
  114. package/dest/shared/gas_portal_test_harness.js +24 -12
  115. package/dest/shared/submit-transactions.d.ts +1 -1
  116. package/dest/shared/submit-transactions.d.ts.map +1 -1
  117. package/dest/shared/submit-transactions.js +12 -5
  118. package/dest/shared/timing_env.d.js +5 -0
  119. package/dest/shared/timing_env.js +365 -0
  120. package/dest/shared/uniswap_l1_l2.d.ts +1 -1
  121. package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
  122. package/dest/shared/uniswap_l1_l2.js +50 -37
  123. package/dest/shared/wait_for_l1_to_l2_message.d.ts +13 -0
  124. package/dest/shared/wait_for_l1_to_l2_message.d.ts.map +1 -0
  125. package/dest/shared/wait_for_l1_to_l2_message.js +10 -0
  126. package/dest/simulators/lending_simulator.d.ts +10 -3
  127. package/dest/simulators/lending_simulator.d.ts.map +1 -1
  128. package/dest/simulators/lending_simulator.js +24 -12
  129. package/dest/single-node/cross-chain/cross_chain_messaging_test.d.ts +75 -0
  130. package/dest/single-node/cross-chain/cross_chain_messaging_test.d.ts.map +1 -0
  131. package/dest/single-node/cross-chain/cross_chain_messaging_test.js +209 -0
  132. package/dest/single-node/cross-chain/message_test_helpers.d.ts +38 -0
  133. package/dest/single-node/cross-chain/message_test_helpers.d.ts.map +1 -0
  134. package/dest/single-node/cross-chain/message_test_helpers.js +70 -0
  135. package/dest/{e2e_fees → single-node/fees}/bridging_race.notest.d.ts +1 -1
  136. package/dest/single-node/fees/bridging_race.notest.d.ts.map +1 -0
  137. package/dest/{e2e_fees → single-node/fees}/bridging_race.notest.js +17 -4
  138. package/dest/single-node/fees/fees_test.d.ts +93 -0
  139. package/dest/single-node/fees/fees_test.d.ts.map +1 -0
  140. package/dest/{e2e_fees → single-node/fees}/fees_test.js +78 -59
  141. package/dest/single-node/l1-reorgs/setup.d.ts +42 -0
  142. package/dest/single-node/l1-reorgs/setup.d.ts.map +1 -0
  143. package/dest/single-node/l1-reorgs/setup.js +57 -0
  144. package/dest/single-node/partial-proofs/setup.d.ts +5 -0
  145. package/dest/single-node/partial-proofs/setup.d.ts.map +1 -0
  146. package/dest/single-node/partial-proofs/setup.js +5 -0
  147. package/dest/single-node/proving/setup.d.ts +5 -0
  148. package/dest/single-node/proving/setup.d.ts.map +1 -0
  149. package/dest/single-node/proving/setup.js +5 -0
  150. package/dest/single-node/recovery/setup.d.ts +5 -0
  151. package/dest/single-node/recovery/setup.d.ts.map +1 -0
  152. package/dest/single-node/recovery/setup.js +5 -0
  153. package/dest/single-node/setup.d.ts +49 -0
  154. package/dest/single-node/setup.d.ts.map +1 -0
  155. package/dest/single-node/setup.js +56 -0
  156. package/dest/single-node/single_node_test_context.d.ts +360 -0
  157. package/dest/single-node/single_node_test_context.d.ts.map +1 -0
  158. package/dest/single-node/single_node_test_context.js +833 -0
  159. package/dest/spartan/setup_test_wallets.d.ts +1 -1
  160. package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
  161. package/dest/spartan/setup_test_wallets.js +28 -12
  162. package/dest/spartan/tx_metrics.d.ts +27 -4
  163. package/dest/spartan/tx_metrics.d.ts.map +1 -1
  164. package/dest/spartan/tx_metrics.js +105 -20
  165. package/dest/spartan/utils/config.d.ts +9 -35
  166. package/dest/spartan/utils/config.d.ts.map +1 -1
  167. package/dest/spartan/utils/nodes.js +2 -2
  168. package/dest/test-wallet/test_wallet.d.ts +39 -10
  169. package/dest/test-wallet/test_wallet.d.ts.map +1 -1
  170. package/dest/test-wallet/test_wallet.js +166 -59
  171. package/dest/test-wallet/utils.d.ts +38 -3
  172. package/dest/test-wallet/utils.d.ts.map +1 -1
  173. package/dest/test-wallet/utils.js +65 -10
  174. package/dest/test-wallet/wallet_worker_script.js +12 -4
  175. package/dest/test-wallet/worker_wallet.d.ts +9 -8
  176. package/dest/test-wallet/worker_wallet.d.ts.map +1 -1
  177. package/dest/test-wallet/worker_wallet.js +10 -4
  178. package/dest/test-wallet/worker_wallet_schema.d.ts +3 -273
  179. package/dest/test-wallet/worker_wallet_schema.d.ts.map +1 -1
  180. package/dest/test-wallet/worker_wallet_schema.js +15 -2
  181. package/package.json +47 -42
  182. package/src/automine/README.md +60 -0
  183. package/src/automine/automine_test_context.ts +153 -0
  184. package/src/automine/delivery/interactive_handshake_responder.ts +125 -0
  185. package/src/automine/delivery/onchain_delivery_harness.ts +213 -0
  186. package/src/{e2e_blacklist_token_contract → automine/token}/blacklist_token_contract_test.ts +24 -47
  187. package/src/{e2e_token_contract → automine/token}/token_contract_test.ts +25 -48
  188. package/src/automine/token/token_test_helpers.ts +138 -0
  189. package/src/bench/client_flows/benchmark.ts +21 -0
  190. package/src/bench/client_flows/client_flows_benchmark.ts +77 -56
  191. package/src/bench/client_flows/data_extractor.ts +1 -0
  192. package/src/bench/utils.ts +110 -6
  193. package/src/composed/ha/ha_full_setup.ts +466 -0
  194. package/src/fixtures/authwit_proxy.ts +4 -0
  195. package/src/fixtures/e2e_prover_test.ts +64 -48
  196. package/src/fixtures/fixtures.ts +100 -0
  197. package/src/fixtures/ha_setup.ts +11 -5
  198. package/src/fixtures/index.ts +1 -0
  199. package/src/fixtures/schnorr_hardcoded_account_contract.ts +49 -0
  200. package/src/fixtures/setup.ts +336 -255
  201. package/src/fixtures/setup_p2p_test.ts +15 -11
  202. package/src/fixtures/timing.ts +97 -0
  203. package/src/fixtures/token_utils.ts +39 -4
  204. package/src/fixtures/utils.ts +2 -3
  205. package/src/fixtures/wait_helpers.ts +333 -0
  206. package/src/forward-compatibility/wallet_rpc_client.ts +14 -0
  207. package/src/forward-compatibility/wallet_service.ts +106 -0
  208. package/src/guides/up_quick_start.sh +5 -2
  209. package/src/infra/README.md +12 -0
  210. package/src/install_legacy_contracts.cjs +75 -0
  211. package/src/legacy-jest-resolver.cjs +112 -0
  212. package/src/multi-node/README.md +95 -0
  213. package/src/multi-node/block-production/setup.ts +272 -0
  214. package/src/multi-node/governance/setup.ts +172 -0
  215. package/src/multi-node/multi_node_test_context.ts +447 -0
  216. package/src/multi-node/slashing/inactivity_setup.ts +139 -0
  217. package/src/multi-node/slashing/setup.ts +433 -0
  218. package/src/p2p/README.md +78 -0
  219. package/src/{e2e_p2p → p2p}/p2p_network.ts +92 -49
  220. package/src/{e2e_p2p → p2p}/reqresp/utils.ts +35 -28
  221. package/src/p2p/shared.ts +329 -0
  222. package/src/shared/cross_chain_test_harness.ts +35 -14
  223. package/src/shared/gas_portal_test_harness.ts +32 -14
  224. package/src/shared/submit-transactions.ts +13 -5
  225. package/src/shared/timing_env.d.mts +39 -0
  226. package/src/shared/timing_env.mjs +363 -0
  227. package/src/shared/uniswap_l1_l2.ts +80 -43
  228. package/src/shared/wait_for_l1_to_l2_message.ts +23 -0
  229. package/src/simulators/lending_simulator.ts +28 -14
  230. package/src/single-node/README.md +60 -0
  231. package/src/single-node/cross-chain/cross_chain_messaging_test.ts +302 -0
  232. package/src/single-node/cross-chain/message_test_helpers.ts +125 -0
  233. package/src/{e2e_fees → single-node/fees}/bridging_race.notest.ts +19 -5
  234. package/src/{e2e_fees → single-node/fees}/fees_test.ts +103 -66
  235. package/src/single-node/l1-reorgs/setup.ts +93 -0
  236. package/src/single-node/partial-proofs/setup.ts +8 -0
  237. package/src/single-node/proving/setup.ts +15 -0
  238. package/src/single-node/recovery/setup.ts +8 -0
  239. package/src/single-node/setup.ts +63 -0
  240. package/src/single-node/single_node_test_context.ts +1041 -0
  241. package/src/spartan/setup_test_wallets.ts +30 -13
  242. package/src/spartan/tx_metrics.ts +107 -23
  243. package/src/spartan/utils/nodes.ts +2 -2
  244. package/src/test-wallet/test_wallet.ts +185 -60
  245. package/src/test-wallet/utils.ts +104 -11
  246. package/src/test-wallet/wallet_worker_script.ts +11 -5
  247. package/src/test-wallet/worker_wallet.ts +19 -16
  248. package/src/test-wallet/worker_wallet_schema.ts +4 -3
  249. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +0 -55
  250. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts.map +0 -1
  251. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +0 -47
  252. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts.map +0 -1
  253. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.js +0 -129
  254. package/dest/e2e_deploy_contract/deploy_test.d.ts +0 -37
  255. package/dest/e2e_deploy_contract/deploy_test.d.ts.map +0 -1
  256. package/dest/e2e_deploy_contract/deploy_test.js +0 -50
  257. package/dest/e2e_epochs/epochs_test.d.ts +0 -104
  258. package/dest/e2e_epochs/epochs_test.d.ts.map +0 -1
  259. package/dest/e2e_epochs/epochs_test.js +0 -389
  260. package/dest/e2e_fees/bridging_race.notest.d.ts.map +0 -1
  261. package/dest/e2e_fees/fees_test.d.ts +0 -88
  262. package/dest/e2e_fees/fees_test.d.ts.map +0 -1
  263. package/dest/e2e_l1_publisher/write_json.d.ts +0 -11
  264. package/dest/e2e_l1_publisher/write_json.d.ts.map +0 -1
  265. package/dest/e2e_l1_publisher/write_json.js +0 -56
  266. package/dest/e2e_multi_validator/utils.d.ts +0 -12
  267. package/dest/e2e_multi_validator/utils.d.ts.map +0 -1
  268. package/dest/e2e_nested_contract/nested_contract_test.d.ts +0 -26
  269. package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +0 -1
  270. package/dest/e2e_nested_contract/nested_contract_test.js +0 -54
  271. package/dest/e2e_p2p/inactivity_slash_test.d.ts +0 -31
  272. package/dest/e2e_p2p/inactivity_slash_test.d.ts.map +0 -1
  273. package/dest/e2e_p2p/inactivity_slash_test.js +0 -136
  274. package/dest/e2e_p2p/p2p_network.d.ts.map +0 -1
  275. package/dest/e2e_p2p/reqresp/utils.d.ts +0 -22
  276. package/dest/e2e_p2p/reqresp/utils.d.ts.map +0 -1
  277. package/dest/e2e_p2p/shared.d.ts +0 -66
  278. package/dest/e2e_p2p/shared.d.ts.map +0 -1
  279. package/dest/e2e_p2p/shared.js +0 -212
  280. package/dest/e2e_storage_proof/fixtures/storage_proof_fetcher.d.ts +0 -2
  281. package/dest/e2e_storage_proof/fixtures/storage_proof_fetcher.d.ts.map +0 -1
  282. package/dest/e2e_storage_proof/fixtures/storage_proof_fixture.d.ts.map +0 -1
  283. package/dest/e2e_token_contract/token_contract_test.d.ts +0 -44
  284. package/dest/e2e_token_contract/token_contract_test.d.ts.map +0 -1
  285. package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +0 -193
  286. package/src/e2e_deploy_contract/deploy_test.ts +0 -85
  287. package/src/e2e_epochs/epochs_test.ts +0 -499
  288. package/src/e2e_l1_publisher/write_json.ts +0 -77
  289. package/src/e2e_nested_contract/nested_contract_test.ts +0 -75
  290. package/src/e2e_p2p/inactivity_slash_test.ts +0 -179
  291. package/src/e2e_p2p/shared.ts +0 -343
  292. /package/dest/{e2e_storage_proof → automine/contracts}/fixtures/storage_proof_fetcher.js +0 -0
  293. /package/dest/{e2e_storage_proof → automine/contracts}/fixtures/storage_proof_fixture.js +0 -0
  294. /package/dest/{e2e_multi_validator/utils.js → composed/web3signer/multi_validator_keystore_utils.js} +0 -0
  295. /package/src/{e2e_storage_proof → automine/contracts}/fixtures/storage_proof.json +0 -0
  296. /package/src/{e2e_storage_proof → automine/contracts}/fixtures/storage_proof_fetcher.ts +0 -0
  297. /package/src/{e2e_storage_proof → automine/contracts}/fixtures/storage_proof_fixture.ts +0 -0
  298. /package/src/{e2e_multi_validator/utils.ts → composed/web3signer/multi_validator_keystore_utils.ts} +0 -0
@@ -1,13 +1,10 @@
1
- import { SchnorrAccountContractArtifact } from '@aztec/accounts/schnorr';
2
1
  import { generateSchnorrAccounts } from '@aztec/accounts/testing';
3
- import { AztecNodeService, getConfigEnvVars } from '@aztec/aztec-node';
4
- import { NO_FROM } from '@aztec/aztec.js/account';
2
+ import { createAztecNodeService, getConfigEnvVars } from '@aztec/aztec-node';
5
3
  import { EthAddress } from '@aztec/aztec.js/addresses';
6
- import { BatchCall, getContractClassFromArtifact, waitForProven } from '@aztec/aztec.js/contracts';
7
4
  import { publishContractClass, publishInstance } from '@aztec/aztec.js/deployment';
8
5
  import { Fr } from '@aztec/aztec.js/fields';
9
6
  import { createLogger } from '@aztec/aztec.js/log';
10
- import { AnvilTestWatcher, CheatCodes } from '@aztec/aztec/testing';
7
+ import { CheatCodes } from '@aztec/aztec/testing';
11
8
  import { SPONSORED_FPC_SALT } from '@aztec/constants';
12
9
  import { isAnvilTestChain } from '@aztec/ethereum/chain';
13
10
  import { createExtendedL1Client } from '@aztec/ethereum/client';
@@ -15,25 +12,28 @@ import { getL1ContractsConfigEnvVars } from '@aztec/ethereum/config';
15
12
  import { NULL_KEY } from '@aztec/ethereum/constants';
16
13
  import { deployMulticall3 } from '@aztec/ethereum/contracts';
17
14
  import { deployAztecL1Contracts } from '@aztec/ethereum/deploy-aztec-l1-contracts';
18
- import { EthCheatCodesWithState, startAnvil } from '@aztec/ethereum/test';
15
+ import { EthCheatCodesWithState, startAnvil, warmBlobKzg } from '@aztec/ethereum/test';
19
16
  import { EpochNumber } from '@aztec/foundation/branded-types';
20
17
  import { SecretValue } from '@aztec/foundation/config';
21
18
  import { randomBytes } from '@aztec/foundation/crypto/random';
22
19
  import { tryRmDir } from '@aztec/foundation/fs';
23
20
  import { withLoggerBindings } from '@aztec/foundation/log/server';
24
21
  import { retryUntil } from '@aztec/foundation/retry';
25
- import { sleep } from '@aztec/foundation/sleep';
26
22
  import { TestDateProvider } from '@aztec/foundation/timer';
27
23
  import { SponsoredFPCContract } from '@aztec/noir-contracts.js/SponsoredFPC';
28
24
  import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
29
25
  import { MockGossipSubNetwork, getMockPubSubP2PServiceFactory } from '@aztec/p2p/test-helpers';
30
26
  import { protocolContractsHash } from '@aztec/protocol-contracts';
31
27
  import { getPXEConfig } from '@aztec/pxe/server';
28
+ import { AuthRegistryArtifact, getStandardAuthRegistry } from '@aztec/standard-contracts/auth-registry';
29
+ import { HandshakeRegistryArtifact, getStandardHandshakeRegistry } from '@aztec/standard-contracts/handshake-registry';
30
+ import { PublicChecksArtifact, getStandardPublicChecks } from '@aztec/standard-contracts/public-checks';
31
+ import { ARTIFACT_VERSION_BEFORE_INJECTION } from '@aztec/stdlib/abi';
32
32
  import { getContractInstanceFromInstantiationParams } from '@aztec/stdlib/contract';
33
33
  import { tryStop } from '@aztec/stdlib/interfaces/server';
34
34
  import { getConfigEnvVars as getTelemetryConfig, initTelemetryClient } from '@aztec/telemetry-client';
35
35
  import { BenchmarkTelemetryClient } from '@aztec/telemetry-client/bench';
36
- import { deployFundedSchnorrAccounts } from '@aztec/wallets/testing';
36
+ import { createFundedInitializerlessAccounts } from '@aztec/wallets/testing';
37
37
  import { getGenesisValues } from '@aztec/world-state/testing';
38
38
  import fs from 'fs/promises';
39
39
  import { tmpdir } from 'os';
@@ -45,6 +45,7 @@ import { MNEMONIC, TEST_MAX_PENDING_TX_POOL_COUNT, TEST_PEER_CHECK_INTERVAL_MS }
45
45
  import { getACVMConfig } from './get_acvm_config.js';
46
46
  import { getBBConfig } from './get_bb_config.js';
47
47
  import { isMetricsLoggingRequested, setupMetricsLogger } from './logging.js';
48
+ import { testSpan } from './timing.js';
48
49
  import { getEndToEndTestTelemetryClient } from './with_telemetry_utils.js';
49
50
  export { startAnvil };
50
51
  let telemetry = undefined;
@@ -80,11 +81,13 @@ export const getPrivateKeyFromIndex = (index)=>{
80
81
  /**
81
82
  * Sets up Private eXecution Environment (PXE) and returns the corresponding test wallet.
82
83
  * @param aztecNode - An instance of Aztec Node.
84
+ * @param nodeDebug - The node's debug API, used to register public function signatures for named traces; pass
85
+ * `undefined` when the node does not expose it.
83
86
  * @param opts - Partial configuration for the PXE.
84
87
  * @param logger - The logger to be used.
85
88
  * @param actor - Actor label to include in log output (e.g., 'pxe-test').
86
89
  * @returns A test wallet, logger and teardown function.
87
- */ export async function setupPXEAndGetWallet(aztecNode, opts = {}, logger = getLogger(), actor) {
90
+ */ export async function setupPXEAndGetWallet(aztecNode, nodeDebug, opts = {}, logger = getLogger(), actor) {
88
91
  const PXEConfig = {
89
92
  ...getPXEConfig(),
90
93
  ...opts
@@ -98,7 +101,8 @@ export const getPrivateKeyFromIndex = (index)=>{
98
101
  }
99
102
  const teardown = configuredDataDirectory ? ()=>Promise.resolve() : ()=>tryRmDir(PXEConfig.dataDirectory);
100
103
  const wallet = await TestWallet.create(aztecNode, PXEConfig, {
101
- loggerActorLabel: actor
104
+ loggerActorLabel: actor,
105
+ nodeDebug
102
106
  });
103
107
  return {
104
108
  wallet,
@@ -106,16 +110,56 @@ export const getPrivateKeyFromIndex = (index)=>{
106
110
  teardown
107
111
  };
108
112
  }
113
+ /**
114
+ * When CONTRACT_ARTIFACTS_VERSION is set (backwards compatibility testing), asserts that the loaded artifact's
115
+ * aztecVersion matches the expected version. This is a sanity check verifying that the legacy artifact resolver
116
+ * actually swapped in the correct version.
117
+ */ function assertContractArtifactsVersion() {
118
+ const expected = process.env.CONTRACT_ARTIFACTS_VERSION;
119
+ if (!expected) {
120
+ return;
121
+ }
122
+ const { aztecVersion } = SponsoredFPCContract.artifact;
123
+ // TODO(F-557): Remove this bypass once pre-version artifacts are no longer tested.
124
+ if (aztecVersion === ARTIFACT_VERSION_BEFORE_INJECTION) {
125
+ createLogger('e2e:setup').info(`Skipping artifact version check: artifact predates version injection (CONTRACT_ARTIFACTS_VERSION=${expected})`);
126
+ return;
127
+ }
128
+ if (aztecVersion !== expected) {
129
+ throw new Error(`Artifact version mismatch: expected ${expected} but got ${aztecVersion}. ` + `The legacy artifact resolver may not have swapped in the correct version.`);
130
+ }
131
+ }
109
132
  /**
110
133
  * Sets up the environment for the end-to-end tests.
111
134
  * @param numberOfAccounts - The number of new accounts to be created once the PXE is initiated.
112
135
  * @param opts - Options to pass to the node initialization and to the setup script.
113
136
  * @param pxeOpts - Options to pass to the PXE initialization.
114
- */ export async function setup(numberOfAccounts = 1, opts = {}, pxeOpts = {}, chain = foundry) {
137
+ */ export function setup(numberOfAccounts = 1, opts = {}, pxeOpts = {}, chain = foundry) {
138
+ // Tag the top-level env spin-up with the prover mode (none → fake → real), the largest config-driven
139
+ // swing in setup cost, so the three factories are comparable on the span leaderboard. The internals
140
+ // (anvil / l1-deploy / sequencer-start / pxe / wallet:create) decompose this further.
141
+ const proverMode = opts.realProofs ? 'real' : opts.startProverNode ? 'fake' : 'none';
142
+ return testSpan(`setup:env:${proverMode}`, async ()=>{
143
+ const ctx = await setupInner(numberOfAccounts, opts, pxeOpts, chain);
144
+ if (process.env.EXIT_E2E_AFTER_SETUP) {
145
+ ctx.logger.info('EXIT_E2E_AFTER_SETUP is set; aborting before the test body runs');
146
+ throw new Error('EXIT_E2E_AFTER_SETUP');
147
+ }
148
+ return ctx;
149
+ });
150
+ }
151
+ async function setupInner(numberOfAccounts, opts, pxeOpts, chain) {
152
+ assertContractArtifactsVersion();
153
+ const logger = getLogger();
115
154
  let anvil;
116
155
  try {
117
156
  opts.aztecTargetCommitteeSize ??= 0;
118
- opts.slasherFlavor ??= 'none';
157
+ opts.slasherEnabled ??= false;
158
+ // Mine the L1 setup txs (Multicall3 + rollup contract deployment) immediately instead of
159
+ // waiting on anvil's block interval — this is the dominant cost of e2e setup. Suites that
160
+ // assert on genesis-relative L1 timing can opt out by passing `automineL1Setup: false`.
161
+ opts.automineL1Setup ??= true;
162
+ logger.trace('Starting e2e test setup');
119
163
  const config = {
120
164
  ...getConfigEnvVars(),
121
165
  ...opts
@@ -126,13 +170,10 @@ export const getPrivateKeyFromIndex = (index)=>{
126
170
  config.maxPendingTxCount = opts.maxPendingTxCount ?? TEST_MAX_PENDING_TX_POOL_COUNT;
127
171
  // For tests we only want proving enabled if specifically requested
128
172
  config.realProofs = !!opts.realProofs;
129
- // Only enforce the time table if requested
130
- config.enforceTimeTable = !!opts.enforceTimeTable;
131
173
  // Enable the tx delayer for tests (default config has it disabled, so we force-enable it here)
132
174
  config.enableDelayer = true;
133
175
  config.listenAddress = '127.0.0.1';
134
176
  config.minTxPoolAgeMs = opts.minTxPoolAgeMs ?? 0;
135
- const logger = getLogger();
136
177
  // Create a temp directory for any services that need it and cleanup later
137
178
  const directoryToCleanup = path.join(tmpdir(), randomBytes(8).toString('hex'));
138
179
  await fs.mkdir(directoryToCleanup, {
@@ -146,18 +187,19 @@ export const getPrivateKeyFromIndex = (index)=>{
146
187
  if (!isAnvilTestChain(chain.id)) {
147
188
  throw new Error(`No ETHEREUM_HOSTS set but non anvil chain requested`);
148
189
  }
149
- const res = await startAnvil({
150
- l1BlockTime: opts.ethereumSlotDuration,
151
- accounts: opts.anvilAccounts,
152
- port: opts.anvilPort ?? (process.env.ANVIL_PORT ? parseInt(process.env.ANVIL_PORT) : undefined),
153
- slotsInAnEpoch: opts.anvilSlotsInAnEpoch,
154
- dateProvider
155
- });
190
+ const res = await testSpan('setup:env:anvil', ()=>startAnvil({
191
+ l1BlockTime: opts.ethereumSlotDuration,
192
+ accounts: opts.anvilAccounts,
193
+ port: opts.anvilPort ?? (process.env.ANVIL_PORT ? parseInt(process.env.ANVIL_PORT) : undefined),
194
+ slotsInAnEpoch: opts.anvilSlotsInAnEpoch,
195
+ dateProvider
196
+ }));
156
197
  anvil = res.anvil;
157
198
  config.l1RpcUrls = [
158
199
  res.rpcUrl
159
200
  ];
160
201
  }
202
+ logger.trace('Started anvil and L1 RPC client');
161
203
  // Enable logging metrics to a local file named after the test suite
162
204
  if (isMetricsLoggingRequested()) {
163
205
  const filename = path.join('log', getJobName() + '.jsonl');
@@ -173,6 +215,7 @@ export const getPrivateKeyFromIndex = (index)=>{
173
215
  resetBlockInterval: true
174
216
  });
175
217
  }
218
+ logger.trace('Initialized L1 cheat codes and applied state/time overrides');
176
219
  let publisherPrivKeyHex = undefined;
177
220
  let publisherHdAccount = undefined;
178
221
  if (opts.l1PublisherKey && opts.l1PublisherKey.getValue() && opts.l1PublisherKey.getValue() != NULL_KEY) {
@@ -197,21 +240,35 @@ export const getPrivateKeyFromIndex = (index)=>{
197
240
  if (config.coinbase === undefined) {
198
241
  config.coinbase = EthAddress.fromString(publisherHdAccount.address);
199
242
  }
200
- // Determine which addresses to fund in genesis
201
- const initialFundedAccounts = opts.initialFundedAccounts ?? await generateSchnorrAccounts(opts.numberOfInitialFundedAccounts ?? Math.max(numberOfAccounts, 10));
202
- const addressesToFund = initialFundedAccounts.map((a)=>a.address);
243
+ logger.trace('Resolved L1 publisher account');
244
+ // The accounts setup creates itself: `numberOfAccounts` initializerless accounts, generated here and
245
+ // funded at genesis so they are immediately usable.
246
+ const defaultAccounts = await generateSchnorrAccounts(numberOfAccounts);
247
+ // Extra accounts the test wants funded at genesis but will create/deploy itself.
248
+ const additionallyFundedAccounts = opts.additionallyFundedAccounts ?? [];
249
+ const addressesToFund = [
250
+ ...defaultAccounts,
251
+ ...additionallyFundedAccounts
252
+ ].map((a)=>a.address);
203
253
  // Optionally fund the sponsored FPC
204
254
  if (opts.fundSponsoredFPC) {
205
255
  const sponsoredFPCAddress = await getSponsoredFPCAddress();
206
256
  addressesToFund.push(sponsoredFPCAddress);
207
257
  }
208
- const { genesisArchiveRoot, prefilledPublicData, fundingNeeded } = await getGenesisValues(addressesToFund, opts.initialAccountFeeJuice, opts.genesisPublicData);
258
+ logger.trace('Generated test accounts to fund at genesis');
259
+ const genesisTimestamp = BigInt(Math.floor(Date.now() / 1000));
260
+ const { genesisArchiveRoot, genesis, fundingNeeded } = await getGenesisValues(addressesToFund, opts.initialAccountFeeJuice, opts.genesisPublicData, genesisTimestamp);
261
+ logger.trace('Computed genesis values');
209
262
  const wasAutomining = await ethCheatCodes.isAutoMining();
210
263
  const enableAutomine = opts.automineL1Setup && !wasAutomining && isAnvilTestChain(chain.id);
211
264
  if (enableAutomine) {
212
265
  await ethCheatCodes.setAutomine(true);
213
266
  }
214
267
  const l1Client = createExtendedL1Client(config.l1RpcUrls, publisherHdAccount, chain);
268
+ // Warm both KZG trusted setups (ours + anvil's) in parallel
269
+ if (anvil && isAnvilTestChain(chain.id)) {
270
+ await warmBlobKzg(l1Client, logger);
271
+ }
215
272
  // Deploy Multicall3 if running locally
216
273
  await deployMulticall3(l1Client, logger);
217
274
  // Force viem to refresh its nonce cache to avoid "nonce too low" errors in subsequent transactions
@@ -219,26 +276,59 @@ export const getPrivateKeyFromIndex = (index)=>{
219
276
  await l1Client.getTransactionCount({
220
277
  address: l1Client.account.address
221
278
  });
222
- const deployL1ContractsValues = await deployAztecL1Contracts(config.l1RpcUrls[0], publisherPrivKeyHex, chain.id, {
223
- ...getL1ContractsConfigEnvVars(),
224
- ...opts,
225
- ...opts.l1ContractsArgs,
226
- vkTreeRoot: getVKTreeRoot(),
227
- protocolContractsHash,
228
- genesisArchiveRoot,
229
- initialValidators: opts.initialValidators,
230
- feeJuicePortalInitialBalance: fundingNeeded,
231
- realVerifier: false
232
- });
233
- config.l1Contracts = deployL1ContractsValues.l1ContractAddresses;
279
+ logger.trace('Deployed Multicall3');
280
+ const deployL1ContractsValues = await testSpan('setup:env:l1-deploy', ()=>deployAztecL1Contracts(config.l1RpcUrls[0], publisherPrivKeyHex, chain.id, {
281
+ ...getL1ContractsConfigEnvVars(),
282
+ ...opts,
283
+ ...opts.l1ContractsArgs,
284
+ vkTreeRoot: getVKTreeRoot(),
285
+ protocolContractsHash,
286
+ genesisArchiveRoot,
287
+ initialValidators: opts.initialValidators,
288
+ feeJuicePortalInitialBalance: fundingNeeded,
289
+ realVerifier: false
290
+ }));
291
+ Object.assign(config, deployL1ContractsValues.l1ContractAddresses);
234
292
  config.rollupVersion = deployL1ContractsValues.rollupVersion;
293
+ // Propagate L1-contracts-config overrides back to the node config so the archiver's
294
+ // `l1Constants` (and any other node-side consumer) agrees with what was actually deployed.
295
+ // Without this, a per-test override like `aztecEpochDuration: 4` lands on the rollup contract
296
+ // but the node config keeps the default (32), so `archiver.isEpochComplete(0)` computes
297
+ // `endSlot=31` and `EpochTestSettler`/`EpochMonitor` never fires — letting the
298
+ // `aztecProofSubmissionEpochs` window expire mid-test and prune the pending chain.
299
+ // Skip undefined values: callers (e.g. `P2PNetworkTest`) sometimes build `l1ContractsArgs`
300
+ // by spreading a partial `AztecNodeConfig`, which leaves unset fields (notably `dataDirectory`)
301
+ // as `undefined`. A blind Object.assign would then clobber the temp `dataDirectory` set earlier
302
+ // in this function and crash `setupSharedBlobStorage`.
303
+ if (opts.l1ContractsArgs) {
304
+ for (const [key, value] of Object.entries(opts.l1ContractsArgs)){
305
+ if (value !== undefined) {
306
+ config[key] = value;
307
+ }
308
+ }
309
+ }
310
+ // Deploy any test-specific L1 contracts while automine is still on and before the node starts,
311
+ // so they mine instantly rather than paying the L1 block interval once the sequencer is live.
312
+ let extraL1DeployResult = undefined;
313
+ if (opts.deployExtraL1Contracts) {
314
+ logger.trace('Running deployExtraL1Contracts hook');
315
+ extraL1DeployResult = await opts.deployExtraL1Contracts({
316
+ l1Client,
317
+ deployL1ContractsValues,
318
+ logger
319
+ });
320
+ // The hook reused `l1Client` to send deploy txs, so refresh viem's nonce cache to avoid a
321
+ // stale cached nonce for later transactions on the publisher account.
322
+ await l1Client.getTransactionCount({
323
+ address: l1Client.account.address
324
+ });
325
+ }
235
326
  if (enableAutomine) {
236
- await ethCheatCodes.setAutomine(false);
237
- await ethCheatCodes.setIntervalMining(config.ethereumSlotDuration);
327
+ await ethCheatCodes.startIntervalMiningWithFreshBlock(config.ethereumSlotDuration);
238
328
  }
239
329
  // In compose mode (no local anvil), sync dateProvider to L1 time since it may have drifted
240
- // ahead of system time due to the local-network watcher warping time forward on each filled slot.
241
- // When running with a local anvil, the dateProvider is kept in sync via the stdout listener.
330
+ // ahead of system time. When running with a local anvil, the dateProvider is kept in sync via
331
+ // the stdout listener.
242
332
  if (!anvil) {
243
333
  dateProvider.setTime(await ethCheatCodes.lastBlockTimestamp() * 1000);
244
334
  }
@@ -247,45 +337,38 @@ export const getPrivateKeyFromIndex = (index)=>{
247
337
  resetBlockInterval: true
248
338
  });
249
339
  }
250
- const watcher = new AnvilTestWatcher(new EthCheatCodesWithState(config.l1RpcUrls, dateProvider), deployL1ContractsValues.l1ContractAddresses.rollupAddress, deployL1ContractsValues.l1Client, dateProvider);
251
- if (!opts.disableAnvilTestWatcher) {
252
- await watcher.start();
253
- }
254
- // Use metricsPort-based telemetry if provided, otherwise use the regular telemetry client
255
- const telemetryClient = opts.metricsPort ? await getEndToEndTestTelemetryClient(opts.metricsPort) : await getTelemetryClient(opts.telemetryConfig);
256
- await setupSharedBlobStorage(config);
257
- logger.verbose('Creating and synching an aztec node', config);
258
- const acvmConfig = await getACVMConfig(logger);
340
+ logger.trace('Deployed L1 rollup contracts');
341
+ // These boot steps are independent and write disjoint config keys, so run them concurrently:
342
+ // telemetry returns a client (no config write), shared blob storage writes blobFileStore* keys,
343
+ // and the ACVM/BB config resolvers write their own acvm*/bb* keys.
344
+ const [telemetryClient, , acvmConfig, bbConfig] = await Promise.all([
345
+ // Use metricsPort-based telemetry if provided, otherwise use the regular telemetry client
346
+ opts.metricsPort ? getEndToEndTestTelemetryClient(opts.metricsPort) : getTelemetryClient(opts.telemetryConfig),
347
+ setupSharedBlobStorage(config),
348
+ getACVMConfig(logger),
349
+ getBBConfig(logger)
350
+ ]);
351
+ logger.trace('Created telemetry client');
352
+ logger.trace('Set up shared blob storage');
259
353
  if (acvmConfig) {
260
354
  config.acvmWorkingDirectory = acvmConfig.acvmWorkingDirectory;
261
355
  config.acvmBinaryPath = acvmConfig.acvmBinaryPath;
262
356
  }
263
- const bbConfig = await getBBConfig(logger);
357
+ logger.trace('Resolved ACVM config');
264
358
  if (bbConfig) {
265
359
  config.bbBinaryPath = bbConfig.bbBinaryPath;
266
360
  config.bbWorkingDirectory = bbConfig.bbWorkingDirectory;
267
361
  }
362
+ logger.trace('Resolved Barretenberg config');
363
+ logger.verbose('Creating and synching an aztec node', config);
268
364
  let mockGossipSubNetwork;
269
365
  let p2pClientDeps = undefined;
270
366
  if (opts.mockGossipSubNetwork) {
271
- mockGossipSubNetwork = new MockGossipSubNetwork();
367
+ mockGossipSubNetwork = new MockGossipSubNetwork(opts.mockGossipSubNetworkLatency);
272
368
  p2pClientDeps = {
273
369
  p2pServiceFactory: getMockPubSubP2PServiceFactory(mockGossipSubNetwork)
274
370
  };
275
371
  }
276
- // Transactions built against the genesis state must be included in block 1, otherwise they are dropped.
277
- // To avoid test failures from dropped transactions, we ensure progression beyond genesis before proceeding.
278
- // For account deployments, we set minTxsPerBlock=1 and deploy accounts sequentially for guaranteed success.
279
- // If no accounts need deployment, we await an empty block to confirm network progression.
280
- const originalMinTxsPerBlock = config.minTxsPerBlock;
281
- if (originalMinTxsPerBlock === undefined) {
282
- throw new Error('minTxsPerBlock is undefined in e2e test setup');
283
- }
284
- // Only set minTxsPerBlock=1 if we're going to deploy accounts and need reliable block inclusion
285
- const shouldDeployAccounts = numberOfAccounts > 0 && !opts.skipAccountDeployment;
286
- // Only set minTxsPerBlock=0 if we need an empty block (no accounts at all, not skipped deployment)
287
- const needsEmptyBlock = numberOfAccounts === 0 && !opts.skipAccountDeployment;
288
- config.minTxsPerBlock = shouldDeployAccounts ? 1 : needsEmptyBlock ? 0 : originalMinTxsPerBlock;
289
372
  config.p2pEnabled = opts.mockGossipSubNetwork || config.p2pEnabled;
290
373
  config.p2pIp = opts.p2pIp ?? config.p2pIp ?? '127.0.0.1';
291
374
  if (!config.disableValidator) {
@@ -295,16 +378,30 @@ export const getPrivateKeyFromIndex = (index)=>{
295
378
  ]);
296
379
  }
297
380
  }
298
- const aztecNodeService = await withLoggerBindings({
299
- actor: 'node-0'
300
- }, ()=>AztecNodeService.createAndSync(config, {
301
- dateProvider,
302
- telemetry: telemetryClient,
303
- p2pClientDeps
304
- }, {
305
- prefilledPublicData
306
- }));
381
+ // When skipInitialSequencer is set, the initial node is a lightweight RPC-only node.
382
+ // We apply these overrides to a copy so they don't leak into the returned config.
383
+ // Keep P2P enabled if mockGossipSubNetwork is used (needed for tx propagation to validators).
384
+ const initialNodeConfig = opts.skipInitialSequencer ? {
385
+ ...config,
386
+ disableValidator: true,
387
+ ...opts.mockGossipSubNetwork ? {} : {
388
+ p2pEnabled: false,
389
+ bootstrapNodes: []
390
+ }
391
+ } : config;
392
+ logger.trace('Prepared aztec node config');
393
+ const aztecNodeService = await testSpan('setup:env:sequencer-start', ()=>withLoggerBindings({
394
+ actor: 'node-0'
395
+ }, ()=>createAztecNodeService(initialNodeConfig, {
396
+ dateProvider,
397
+ telemetry: telemetryClient,
398
+ p2pClientDeps
399
+ }, {
400
+ genesis,
401
+ dontStartSequencer: opts.skipInitialSequencer
402
+ })));
307
403
  const sequencerClient = aztecNodeService.getSequencer();
404
+ logger.trace('Created and synced aztec node');
308
405
  let proverNode = undefined;
309
406
  if (opts.startProverNode) {
310
407
  logger.verbose('Creating and syncing a simulated prover node...');
@@ -317,16 +414,17 @@ export const getPrivateKeyFromIndex = (index)=>{
317
414
  aztecNodeService
318
415
  ]
319
416
  };
320
- ({ proverNode } = await createAndSyncProverNode(proverNodePrivateKeyHex, config, {
321
- ...config.proverNodeConfig,
322
- dataDirectory: proverNodeDataDirectory
323
- }, {
324
- dateProvider,
325
- p2pClientDeps,
326
- telemetry: telemetryClient
327
- }, {
328
- prefilledPublicData
329
- }));
417
+ ({ proverNode } = await testSpan('setup:env:prover-node', ()=>createAndSyncProverNode(proverNodePrivateKeyHex, config, {
418
+ ...config.proverNodeConfig,
419
+ dataDirectory: proverNodeDataDirectory
420
+ }, {
421
+ dateProvider,
422
+ p2pClientDeps,
423
+ telemetry: telemetryClient
424
+ }, {
425
+ genesis
426
+ })));
427
+ logger.trace('Created prover node');
330
428
  }
331
429
  const sequencerDelayer = sequencerClient?.getDelayer();
332
430
  const proverDelayer = proverNode?.getProverNode()?.getDelayer();
@@ -338,65 +436,57 @@ export const getPrivateKeyFromIndex = (index)=>{
338
436
  pxeConfig.dataDirectory = path.join(directoryToCleanup, randomBytes(8).toString('hex'));
339
437
  // For tests we only want proving enabled if specifically requested
340
438
  pxeConfig.proverEnabled = !!pxeOpts.proverEnabled;
341
- const wallet = await TestWallet.create(aztecNodeService, pxeConfig, {
342
- loggerActorLabel: 'pxe-0'
343
- });
439
+ const wallet = await testSpan('setup:env:pxe', ()=>TestWallet.create(aztecNodeService, pxeConfig, {
440
+ loggerActorLabel: 'pxe-0',
441
+ // In-process node implements the debug API, so register public function signatures for named traces.
442
+ nodeDebug: aztecNodeService,
443
+ ...opts.pxeCreationOptions
444
+ }));
344
445
  if (opts.walletMinFeePadding !== undefined) {
345
446
  wallet.setMinFeePadding(opts.walletMinFeePadding);
346
447
  }
448
+ logger.trace('Created PXE and test wallet');
347
449
  const cheatCodes = await CheatCodes.create(config.l1RpcUrls, aztecNodeService, dateProvider);
450
+ logger.trace('Created cheat codes');
348
451
  if (opts.aztecTargetCommitteeSize && opts.aztecTargetCommitteeSize > 0 || opts.initialValidators && opts.initialValidators.length > 0) {
349
452
  // We need to advance such that the committee is set up.
350
453
  await cheatCodes.rollup.advanceToEpoch(EpochNumber.fromBigInt(BigInt(await cheatCodes.rollup.getEpoch()) + BigInt(config.lagInEpochsForValidatorSet + 1)));
351
454
  await cheatCodes.rollup.setupEpoch();
352
455
  await cheatCodes.rollup.debugRollup();
456
+ logger.trace('Advanced chain to set up validator committee');
353
457
  }
354
458
  let accounts = [];
355
- if (shouldDeployAccounts) {
356
- logger.info(`${numberOfAccounts} accounts are being deployed. Reliably progressing past genesis by setting minTxsPerBlock to 1 and waiting for the accounts to be deployed`);
357
- const accountsData = initialFundedAccounts.slice(0, numberOfAccounts);
358
- const accountManagers = await deployFundedSchnorrAccounts(wallet, accountsData);
359
- accounts = accountManagers.map((accountManager)=>accountManager.address);
360
- } else if (needsEmptyBlock) {
361
- logger.info('No accounts are being deployed, waiting for an empty block 1 to be mined');
362
- while(await aztecNodeService.getBlockNumber() === 0){
363
- await sleep(2000);
364
- }
365
- }
366
- // If skipAccountDeployment is true, we don't deploy or wait - tests will handle account deployment later
367
- // Now we restore the original minTxsPerBlock setting if we changed it.
368
- if (sequencerClient && config.minTxsPerBlock !== originalMinTxsPerBlock) {
369
- sequencerClient.getSequencer().updateConfig({
370
- minTxsPerBlock: originalMinTxsPerBlock
371
- });
459
+ // Create the default accounts. They are initializerless, so this is a PXE-side operation (registration
460
+ // + a simulated store call) with no on-chain tx, independent of the sequencer.
461
+ if (numberOfAccounts > 0) {
462
+ logger.info(`Creating ${numberOfAccounts} initializerless test accounts`);
463
+ await testSpan('wallet:create', ()=>createFundedInitializerlessAccounts(wallet, defaultAccounts));
464
+ accounts = defaultAccounts.map((a)=>a.address);
372
465
  }
373
- if (initialFundedAccounts.length < numberOfAccounts) {
374
- throw new Error(`Unable to deploy ${numberOfAccounts} accounts. Only ${initialFundedAccounts.length} accounts were funded.`);
375
- }
376
- const teardown = async ()=>{
377
- try {
378
- await tryStop(wallet, logger);
379
- await tryStop(aztecNodeService, logger);
380
- await tryStop(proverNode, logger);
381
- if (acvmConfig?.cleanup) {
382
- await acvmConfig.cleanup();
383
- }
384
- if (bbConfig?.cleanup) {
385
- await bbConfig.cleanup();
386
- }
387
- await tryStop(watcher, logger);
388
- await tryStop(anvil, logger);
389
- await tryRmDir(directoryToCleanup, logger);
390
- } catch (err) {
391
- logger.error(`Error during e2e test teardown`, err);
392
- } finally{
466
+ logger.trace('Created funded test accounts');
467
+ const teardown = ()=>testSpan('teardown:env', async ()=>{
393
468
  try {
394
- await telemetryClient.stop();
469
+ await tryStop(wallet, logger);
470
+ await tryStop(aztecNodeService, logger);
471
+ await tryStop(proverNode, logger);
472
+ if (acvmConfig?.cleanup) {
473
+ await acvmConfig.cleanup();
474
+ }
475
+ if (bbConfig?.cleanup) {
476
+ await bbConfig.cleanup();
477
+ }
478
+ await tryStop(anvil, logger);
479
+ await tryRmDir(directoryToCleanup, logger);
395
480
  } catch (err) {
396
- logger.error(`Error during telemetry client stop`, err);
481
+ logger.error(`Error during e2e test teardown`, err);
482
+ } finally{
483
+ try {
484
+ await telemetryClient.stop();
485
+ } catch (err) {
486
+ logger.error(`Error during telemetry client stop`, err);
487
+ }
397
488
  }
398
- }
399
- };
489
+ });
400
490
  return {
401
491
  anvil,
402
492
  aztecNode: aztecNodeService,
@@ -408,10 +498,11 @@ export const getPrivateKeyFromIndex = (index)=>{
408
498
  aztecNodeConfig: config,
409
499
  dateProvider,
410
500
  deployL1ContractsValues,
411
- initialFundedAccounts,
501
+ additionallyFundedAccounts,
412
502
  logger,
413
503
  mockGossipSubNetwork,
414
- prefilledPublicData,
504
+ genesis,
505
+ extraL1DeployResult,
415
506
  proverNode,
416
507
  sequencerDelayer,
417
508
  proverDelayer,
@@ -420,7 +511,6 @@ export const getPrivateKeyFromIndex = (index)=>{
420
511
  telemetryClient,
421
512
  wallet,
422
513
  accounts,
423
- watcher,
424
514
  acvmConfig,
425
515
  bbConfig,
426
516
  directoryToCleanup
@@ -471,9 +561,9 @@ export const getPrivateKeyFromIndex = (index)=>{
471
561
  */ export async function registerSponsoredFPC(wallet) {
472
562
  await wallet.registerContract(await getSponsoredFPCInstance(), SponsoredFPCContract.artifact);
473
563
  }
474
- export async function waitForProvenChain(node, targetBlock, timeoutSec = 60, intervalSec = 1) {
564
+ export async function waitForProvenChain(node, targetBlock, timeoutSec = 60, intervalSec = 0.25) {
475
565
  targetBlock ??= await node.getBlockNumber();
476
- await retryUntil(async ()=>await node.getProvenBlockNumber() >= targetBlock, 'proven chain status', timeoutSec, intervalSec);
566
+ await retryUntil(async ()=>await node.getBlockNumber('proven') >= targetBlock, 'proven chain status', timeoutSec, intervalSec);
477
567
  }
478
568
  /**
479
569
  * Creates an AztecNodeService with the prover node enabled as a subsystem.
@@ -482,7 +572,7 @@ export async function waitForProvenChain(node, targetBlock, timeoutSec = 60, int
482
572
  return withLoggerBindings({
483
573
  actor: 'prover-0'
484
574
  }, async ()=>{
485
- const proverNode = await AztecNodeService.createAndSync({
575
+ const proverNode = await createAztecNodeService({
486
576
  ...baseConfig,
487
577
  ...configOverrides,
488
578
  p2pPort: 0,
@@ -492,7 +582,7 @@ export async function waitForProvenChain(node, targetBlock, timeoutSec = 60, int
492
582
  new SecretValue(proverNodePrivateKey)
493
583
  ]
494
584
  }, deps, {
495
- ...options,
585
+ genesis: options.genesis,
496
586
  dontStartProverNode: options.dontStart
497
587
  });
498
588
  if (!proverNode.getProverNode()) {
@@ -528,74 +618,63 @@ export async function expectMappingDelta(initialValues, fn, inputs, expectedDiff
528
618
  expect(diffs).toEqual(expectedDiffs);
529
619
  }
530
620
  /**
531
- * Registers the contract class used for test accounts and publicly deploys the instances requested.
532
- * Use this when you need to make a public call to an account contract, such as for requesting a public authwit.
533
- */ export async function ensureAccountContractsPublished(wallet, accountsToDeploy) {
534
- const accountsAndAddresses = await Promise.all(accountsToDeploy.map(async (address)=>{
535
- return {
536
- address,
537
- deployed: (await wallet.getContractMetadata(address)).isContractPublished
538
- };
539
- }));
540
- const instances = (await Promise.all(accountsAndAddresses.filter(({ deployed })=>!deployed).map(({ address })=>wallet.getContractMetadata(address)))).map((contractMetadata)=>contractMetadata.instance);
541
- const contractClass = await getContractClassFromArtifact(SchnorrAccountContractArtifact);
621
+ * Registers the auth_registry contract class and publishes its standard instance if not already
622
+ * present, and registers the artifact with PXE. Publishing is required before exercising the public
623
+ * authwit path (which relies on the AVM's deployment-nullifier check); the PXE-side registration is
624
+ * required so revert messages from AuthRegistry calls can be enriched (otherwise assertion strings
625
+ * surface as generic "Assertion failed:" and tests that match on the real message fail).
626
+ */ export async function ensureAuthRegistryPublished(wallet, from) {
627
+ await testSpan('setup:auth-registry', async ()=>{
628
+ const { instance, contractClass } = await getStandardAuthRegistry();
629
+ if (!(await wallet.getContractClassMetadata(contractClass.id)).isContractClassPubliclyRegistered) {
630
+ await (await publishContractClass(wallet, AuthRegistryArtifact)).send({
631
+ from
632
+ });
633
+ }
634
+ if (!(await wallet.getContractMetadata(instance.address)).isContractPublished) {
635
+ await publishInstance(wallet, instance).send({
636
+ from
637
+ });
638
+ }
639
+ await wallet.registerContract(instance, AuthRegistryArtifact);
640
+ });
641
+ }
642
+ /**
643
+ * Registers the public_checks contract class and publishes its standard instance if not already
644
+ * present, and registers the artifact with PXE. Required for any contract that calls
645
+ * `privately_check_timestamp` / `privately_check_block_number` (which dispatch into the
646
+ * deployed PublicChecks contract via an enqueued public call).
647
+ */ export async function ensurePublicChecksPublished(wallet, from) {
648
+ const { instance, contractClass } = await getStandardPublicChecks();
542
649
  if (!(await wallet.getContractClassMetadata(contractClass.id)).isContractClassPubliclyRegistered) {
543
- await (await publishContractClass(wallet, SchnorrAccountContractArtifact)).send({
544
- from: accountsToDeploy[0]
650
+ await (await publishContractClass(wallet, PublicChecksArtifact)).send({
651
+ from
545
652
  });
546
653
  }
547
- const requests = instances.map((instance)=>publishInstance(wallet, instance));
548
- const batch = new BatchCall(wallet, requests);
549
- await batch.send({
550
- from: accountsToDeploy[0]
551
- });
654
+ if (!(await wallet.getContractMetadata(instance.address)).isContractPublished) {
655
+ await publishInstance(wallet, instance).send({
656
+ from
657
+ });
658
+ }
659
+ await wallet.registerContract(instance, PublicChecksArtifact);
552
660
  }
553
661
  /**
554
- * Helper function to deploy accounts.
555
- * Returns deployed account data that can be used by tests.
556
- */ export const deployAccounts = (numberOfAccounts, logger)=>async ({ wallet, initialFundedAccounts })=>{
557
- if (initialFundedAccounts.length < numberOfAccounts) {
558
- throw new Error(`Cannot deploy more than ${initialFundedAccounts.length} initial accounts.`);
559
- }
560
- logger.verbose('Deploying accounts funded with fee juice...');
561
- const deployedAccounts = initialFundedAccounts.slice(0, numberOfAccounts);
562
- // Serial due to https://github.com/AztecProtocol/aztec-packages/issues/12045
563
- for(let i = 0; i < deployedAccounts.length; i++){
564
- const accountManager = await wallet.createSchnorrAccount(deployedAccounts[i].secret, deployedAccounts[i].salt, deployedAccounts[i].signingKey);
565
- const deployMethod = await accountManager.getDeployMethod();
566
- await deployMethod.send({
567
- from: NO_FROM,
568
- skipClassPublication: i !== 0
569
- });
570
- }
571
- return {
572
- deployedAccounts
573
- };
574
- };
575
- /**
576
- * Registers the contract class used for test accounts and publicly deploys the instances requested.
577
- * Use this when you need to make a public call to an account contract, such as for requesting a public authwit.
578
- */ export async function publicDeployAccounts(wallet, accountsToDeploy, waitUntilProven = false, node) {
579
- const instances = (await Promise.all(accountsToDeploy.map((account)=>wallet.getContractMetadata(account)))).map((metadata)=>metadata.instance);
580
- const contractClass = await getContractClassFromArtifact(SchnorrAccountContractArtifact);
581
- const alreadyRegistered = (await wallet.getContractClassMetadata(contractClass.id)).isContractClassPubliclyRegistered;
582
- const calls = await Promise.all([
583
- ...!alreadyRegistered ? [
584
- publishContractClass(wallet, SchnorrAccountContractArtifact)
585
- ] : [],
586
- ...instances.map((instance)=>publishInstance(wallet, instance))
587
- ]);
588
- const batch = new BatchCall(wallet, calls);
589
- const { receipt: txReceipt } = await batch.send({
590
- from: accountsToDeploy[0]
591
- });
592
- if (waitUntilProven) {
593
- if (!node) {
594
- throw new Error('Need to provide an AztecNode to wait for proven.');
595
- } else {
596
- await waitForProven(node, txReceipt);
597
- }
662
+ * Registers the handshake_registry contract class and publishes its standard instance if not
663
+ * already present, and registers the artifact with PXE. Required for constrained-delivery flows
664
+ * that call into the HandshakeRegistry at its well-known address.
665
+ */ export async function ensureHandshakeRegistryPublished(wallet, from) {
666
+ const { instance, contractClass } = await getStandardHandshakeRegistry();
667
+ if (!(await wallet.getContractClassMetadata(contractClass.id)).isContractClassPubliclyRegistered) {
668
+ await (await publishContractClass(wallet, HandshakeRegistryArtifact)).send({
669
+ from
670
+ });
671
+ }
672
+ if (!(await wallet.getContractMetadata(instance.address)).isContractPublished) {
673
+ await publishInstance(wallet, instance).send({
674
+ from
675
+ });
598
676
  }
677
+ await wallet.registerContract(instance, HandshakeRegistryArtifact);
599
678
  }
600
679
  /**
601
680
  * Destroys the current context.