@aztec/end-to-end 0.0.1-commit.4d79d1f2d → 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 (343) 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 +39 -52
  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 +37 -52
  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 +62 -53
  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 +102 -8
  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 +15 -0
  40. package/dest/fixtures/authwit_proxy.d.ts.map +1 -0
  41. package/dest/fixtures/authwit_proxy.js +34 -0
  42. package/dest/fixtures/e2e_prover_test.d.ts +17 -13
  43. package/dest/fixtures/e2e_prover_test.d.ts.map +1 -1
  44. package/dest/fixtures/e2e_prover_test.js +82 -74
  45. package/dest/fixtures/elu_monitor.d.ts +21 -0
  46. package/dest/fixtures/elu_monitor.d.ts.map +1 -0
  47. package/dest/fixtures/elu_monitor.js +102 -0
  48. package/dest/fixtures/fixtures.d.ts +83 -1
  49. package/dest/fixtures/fixtures.d.ts.map +1 -1
  50. package/dest/fixtures/fixtures.js +86 -0
  51. package/dest/fixtures/get_bb_config.d.ts +1 -1
  52. package/dest/fixtures/get_bb_config.d.ts.map +1 -1
  53. package/dest/fixtures/get_bb_config.js +5 -5
  54. package/dest/fixtures/ha_setup.d.ts +4 -4
  55. package/dest/fixtures/ha_setup.d.ts.map +1 -1
  56. package/dest/fixtures/ha_setup.js +8 -3
  57. package/dest/fixtures/index.d.ts +2 -1
  58. package/dest/fixtures/index.d.ts.map +1 -1
  59. package/dest/fixtures/index.js +1 -0
  60. package/dest/fixtures/schnorr_hardcoded_account_contract.d.ts +25 -0
  61. package/dest/fixtures/schnorr_hardcoded_account_contract.d.ts.map +1 -0
  62. package/dest/fixtures/schnorr_hardcoded_account_contract.js +37 -0
  63. package/dest/fixtures/setup.d.ts +99 -48
  64. package/dest/fixtures/setup.d.ts.map +1 -1
  65. package/dest/fixtures/setup.js +319 -262
  66. package/dest/fixtures/setup_p2p_test.d.ts +14 -7
  67. package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
  68. package/dest/fixtures/setup_p2p_test.js +21 -18
  69. package/dest/fixtures/timing.d.ts +42 -0
  70. package/dest/fixtures/timing.d.ts.map +1 -0
  71. package/dest/fixtures/timing.js +72 -0
  72. package/dest/fixtures/token_utils.d.ts +22 -4
  73. package/dest/fixtures/token_utils.d.ts.map +1 -1
  74. package/dest/fixtures/token_utils.js +26 -8
  75. package/dest/fixtures/utils.d.ts +2 -2
  76. package/dest/fixtures/utils.d.ts.map +1 -1
  77. package/dest/fixtures/utils.js +1 -1
  78. package/dest/fixtures/wait_helpers.d.ts +135 -0
  79. package/dest/fixtures/wait_helpers.d.ts.map +1 -0
  80. package/dest/fixtures/wait_helpers.js +154 -0
  81. package/dest/forward-compatibility/wallet_rpc_client.d.ts +7 -0
  82. package/dest/forward-compatibility/wallet_rpc_client.d.ts.map +1 -0
  83. package/dest/forward-compatibility/wallet_rpc_client.js +15 -0
  84. package/dest/forward-compatibility/wallet_service.d.ts +3 -0
  85. package/dest/forward-compatibility/wallet_service.d.ts.map +1 -0
  86. package/dest/forward-compatibility/wallet_service.js +109 -0
  87. package/dest/install_legacy_contracts.d.cts +10 -0
  88. package/dest/install_legacy_contracts.d.cts.map +1 -0
  89. package/dest/legacy-jest-resolver.d.cts +3 -0
  90. package/dest/legacy-jest-resolver.d.cts.map +1 -0
  91. package/dest/multi-node/block-production/setup.d.ts +97 -0
  92. package/dest/multi-node/block-production/setup.d.ts.map +1 -0
  93. package/dest/multi-node/block-production/setup.js +158 -0
  94. package/dest/multi-node/governance/setup.d.ts +67 -0
  95. package/dest/multi-node/governance/setup.d.ts.map +1 -0
  96. package/dest/multi-node/governance/setup.js +126 -0
  97. package/dest/multi-node/multi_node_test_context.d.ts +212 -0
  98. package/dest/multi-node/multi_node_test_context.d.ts.map +1 -0
  99. package/dest/multi-node/multi_node_test_context.js +347 -0
  100. package/dest/multi-node/slashing/inactivity_setup.d.ts +27 -0
  101. package/dest/multi-node/slashing/inactivity_setup.d.ts.map +1 -0
  102. package/dest/multi-node/slashing/inactivity_setup.js +111 -0
  103. package/dest/multi-node/slashing/setup.d.ts +167 -0
  104. package/dest/multi-node/slashing/setup.d.ts.map +1 -0
  105. package/dest/multi-node/slashing/setup.js +275 -0
  106. package/dest/{e2e_p2p → p2p}/p2p_network.d.ts +21 -11
  107. package/dest/p2p/p2p_network.d.ts.map +1 -0
  108. package/dest/{e2e_p2p → p2p}/p2p_network.js +97 -37
  109. package/dest/p2p/reqresp/utils.d.ts +19 -0
  110. package/dest/p2p/reqresp/utils.d.ts.map +1 -0
  111. package/dest/{e2e_p2p → p2p}/reqresp/utils.js +67 -27
  112. package/dest/p2p/shared.d.ts +72 -0
  113. package/dest/p2p/shared.d.ts.map +1 -0
  114. package/dest/p2p/shared.js +212 -0
  115. package/dest/shared/cross_chain_test_harness.d.ts +6 -4
  116. package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
  117. package/dest/shared/cross_chain_test_harness.js +36 -31
  118. package/dest/shared/gas_portal_test_harness.d.ts +8 -5
  119. package/dest/shared/gas_portal_test_harness.d.ts.map +1 -1
  120. package/dest/shared/gas_portal_test_harness.js +26 -14
  121. package/dest/shared/index.d.ts +2 -1
  122. package/dest/shared/index.d.ts.map +1 -1
  123. package/dest/shared/index.js +1 -0
  124. package/dest/shared/jest_setup.js +41 -1
  125. package/dest/shared/mock_state_view.d.ts +86 -0
  126. package/dest/shared/mock_state_view.d.ts.map +1 -0
  127. package/dest/shared/mock_state_view.js +186 -0
  128. package/dest/shared/submit-transactions.d.ts +1 -1
  129. package/dest/shared/submit-transactions.d.ts.map +1 -1
  130. package/dest/shared/submit-transactions.js +12 -5
  131. package/dest/shared/timing_env.d.js +5 -0
  132. package/dest/shared/timing_env.js +365 -0
  133. package/dest/shared/uniswap_l1_l2.d.ts +1 -1
  134. package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
  135. package/dest/shared/uniswap_l1_l2.js +55 -45
  136. package/dest/shared/wait_for_l1_to_l2_message.d.ts +13 -0
  137. package/dest/shared/wait_for_l1_to_l2_message.d.ts.map +1 -0
  138. package/dest/shared/wait_for_l1_to_l2_message.js +10 -0
  139. package/dest/simulators/lending_simulator.d.ts +10 -3
  140. package/dest/simulators/lending_simulator.d.ts.map +1 -1
  141. package/dest/simulators/lending_simulator.js +27 -15
  142. package/dest/simulators/token_simulator.d.ts +1 -1
  143. package/dest/simulators/token_simulator.d.ts.map +1 -1
  144. package/dest/simulators/token_simulator.js +2 -2
  145. package/dest/single-node/cross-chain/cross_chain_messaging_test.d.ts +75 -0
  146. package/dest/single-node/cross-chain/cross_chain_messaging_test.d.ts.map +1 -0
  147. package/dest/single-node/cross-chain/cross_chain_messaging_test.js +209 -0
  148. package/dest/single-node/cross-chain/message_test_helpers.d.ts +38 -0
  149. package/dest/single-node/cross-chain/message_test_helpers.d.ts.map +1 -0
  150. package/dest/single-node/cross-chain/message_test_helpers.js +70 -0
  151. package/dest/{e2e_fees → single-node/fees}/bridging_race.notest.d.ts +1 -1
  152. package/dest/single-node/fees/bridging_race.notest.d.ts.map +1 -0
  153. package/dest/{e2e_fees → single-node/fees}/bridging_race.notest.js +17 -4
  154. package/dest/single-node/fees/fees_test.d.ts +93 -0
  155. package/dest/single-node/fees/fees_test.d.ts.map +1 -0
  156. package/dest/{e2e_fees → single-node/fees}/fees_test.js +89 -63
  157. package/dest/single-node/l1-reorgs/setup.d.ts +42 -0
  158. package/dest/single-node/l1-reorgs/setup.d.ts.map +1 -0
  159. package/dest/single-node/l1-reorgs/setup.js +57 -0
  160. package/dest/single-node/partial-proofs/setup.d.ts +5 -0
  161. package/dest/single-node/partial-proofs/setup.d.ts.map +1 -0
  162. package/dest/single-node/partial-proofs/setup.js +5 -0
  163. package/dest/single-node/proving/setup.d.ts +5 -0
  164. package/dest/single-node/proving/setup.d.ts.map +1 -0
  165. package/dest/single-node/proving/setup.js +5 -0
  166. package/dest/single-node/recovery/setup.d.ts +5 -0
  167. package/dest/single-node/recovery/setup.d.ts.map +1 -0
  168. package/dest/single-node/recovery/setup.js +5 -0
  169. package/dest/single-node/setup.d.ts +49 -0
  170. package/dest/single-node/setup.d.ts.map +1 -0
  171. package/dest/single-node/setup.js +56 -0
  172. package/dest/single-node/single_node_test_context.d.ts +360 -0
  173. package/dest/single-node/single_node_test_context.d.ts.map +1 -0
  174. package/dest/single-node/single_node_test_context.js +833 -0
  175. package/dest/spartan/setup_test_wallets.d.ts +11 -2
  176. package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
  177. package/dest/spartan/setup_test_wallets.js +121 -46
  178. package/dest/spartan/tx_metrics.d.ts +27 -4
  179. package/dest/spartan/tx_metrics.d.ts.map +1 -1
  180. package/dest/spartan/tx_metrics.js +106 -21
  181. package/dest/spartan/utils/bot.d.ts +3 -2
  182. package/dest/spartan/utils/bot.d.ts.map +1 -1
  183. package/dest/spartan/utils/bot.js +2 -1
  184. package/dest/spartan/utils/config.d.ts +10 -30
  185. package/dest/spartan/utils/config.d.ts.map +1 -1
  186. package/dest/spartan/utils/config.js +3 -1
  187. package/dest/spartan/utils/index.d.ts +4 -2
  188. package/dest/spartan/utils/index.d.ts.map +1 -1
  189. package/dest/spartan/utils/index.js +5 -1
  190. package/dest/spartan/utils/k8s.d.ts +3 -1
  191. package/dest/spartan/utils/k8s.d.ts.map +1 -1
  192. package/dest/spartan/utils/k8s.js +6 -0
  193. package/dest/spartan/utils/nodes.d.ts +4 -5
  194. package/dest/spartan/utils/nodes.d.ts.map +1 -1
  195. package/dest/spartan/utils/nodes.js +11 -11
  196. package/dest/spartan/utils/pod_logs.d.ts +25 -0
  197. package/dest/spartan/utils/pod_logs.d.ts.map +1 -0
  198. package/dest/spartan/utils/pod_logs.js +74 -0
  199. package/dest/test-wallet/test_wallet.d.ts +48 -25
  200. package/dest/test-wallet/test_wallet.d.ts.map +1 -1
  201. package/dest/test-wallet/test_wallet.js +197 -91
  202. package/dest/test-wallet/utils.d.ts +38 -3
  203. package/dest/test-wallet/utils.d.ts.map +1 -1
  204. package/dest/test-wallet/utils.js +65 -10
  205. package/dest/test-wallet/wallet_worker_script.d.ts +2 -0
  206. package/dest/test-wallet/wallet_worker_script.d.ts.map +1 -0
  207. package/dest/test-wallet/wallet_worker_script.js +56 -0
  208. package/dest/test-wallet/worker_wallet.d.ts +53 -0
  209. package/dest/test-wallet/worker_wallet.d.ts.map +1 -0
  210. package/dest/test-wallet/worker_wallet.js +157 -0
  211. package/dest/test-wallet/worker_wallet_schema.d.ts +4 -0
  212. package/dest/test-wallet/worker_wallet_schema.d.ts.map +1 -0
  213. package/dest/test-wallet/worker_wallet_schema.js +23 -0
  214. package/package.json +50 -47
  215. package/src/automine/README.md +60 -0
  216. package/src/automine/automine_test_context.ts +153 -0
  217. package/src/automine/delivery/interactive_handshake_responder.ts +125 -0
  218. package/src/automine/delivery/onchain_delivery_harness.ts +213 -0
  219. package/src/{e2e_blacklist_token_contract → automine/token}/blacklist_token_contract_test.ts +44 -63
  220. package/src/{e2e_token_contract → automine/token}/token_contract_test.ts +43 -58
  221. package/src/automine/token/token_test_helpers.ts +138 -0
  222. package/src/bench/client_flows/benchmark.ts +21 -0
  223. package/src/bench/client_flows/client_flows_benchmark.ts +102 -64
  224. package/src/bench/client_flows/data_extractor.ts +1 -0
  225. package/src/bench/utils.ts +116 -7
  226. package/src/composed/ha/ha_full_setup.ts +466 -0
  227. package/src/fixtures/authwit_proxy.ts +54 -0
  228. package/src/fixtures/dumps/epoch_proof_result.json +1 -1
  229. package/src/fixtures/e2e_prover_test.ts +97 -93
  230. package/src/fixtures/elu_monitor.ts +126 -0
  231. package/src/fixtures/fixtures.ts +110 -0
  232. package/src/fixtures/get_bb_config.ts +7 -6
  233. package/src/fixtures/ha_setup.ts +14 -6
  234. package/src/fixtures/index.ts +1 -0
  235. package/src/fixtures/schnorr_hardcoded_account_contract.ts +49 -0
  236. package/src/fixtures/setup.ts +406 -351
  237. package/src/fixtures/setup_p2p_test.ts +23 -27
  238. package/src/fixtures/timing.ts +97 -0
  239. package/src/fixtures/token_utils.ts +42 -7
  240. package/src/fixtures/utils.ts +2 -3
  241. package/src/fixtures/wait_helpers.ts +333 -0
  242. package/src/forward-compatibility/wallet_rpc_client.ts +14 -0
  243. package/src/forward-compatibility/wallet_service.ts +106 -0
  244. package/src/guides/up_quick_start.sh +5 -2
  245. package/src/infra/README.md +12 -0
  246. package/src/install_legacy_contracts.cjs +75 -0
  247. package/src/legacy-jest-resolver.cjs +112 -0
  248. package/src/multi-node/README.md +95 -0
  249. package/src/multi-node/block-production/setup.ts +272 -0
  250. package/src/multi-node/governance/setup.ts +172 -0
  251. package/src/multi-node/multi_node_test_context.ts +447 -0
  252. package/src/multi-node/slashing/inactivity_setup.ts +139 -0
  253. package/src/multi-node/slashing/setup.ts +433 -0
  254. package/src/p2p/README.md +78 -0
  255. package/src/{e2e_p2p → p2p}/p2p_network.ts +116 -47
  256. package/src/{e2e_p2p → p2p}/reqresp/utils.ts +82 -26
  257. package/src/p2p/shared.ts +329 -0
  258. package/src/shared/cross_chain_test_harness.ts +42 -17
  259. package/src/shared/gas_portal_test_harness.ts +33 -15
  260. package/src/shared/index.ts +1 -0
  261. package/src/shared/jest_setup.ts +51 -1
  262. package/src/shared/mock_state_view.ts +188 -0
  263. package/src/shared/submit-transactions.ts +13 -5
  264. package/src/shared/timing_env.d.mts +39 -0
  265. package/src/shared/timing_env.mjs +363 -0
  266. package/src/shared/uniswap_l1_l2.ts +98 -54
  267. package/src/shared/wait_for_l1_to_l2_message.ts +23 -0
  268. package/src/simulators/lending_simulator.ts +33 -15
  269. package/src/simulators/token_simulator.ts +6 -2
  270. package/src/single-node/README.md +60 -0
  271. package/src/single-node/cross-chain/cross_chain_messaging_test.ts +302 -0
  272. package/src/single-node/cross-chain/message_test_helpers.ts +125 -0
  273. package/src/{e2e_fees → single-node/fees}/bridging_race.notest.ts +19 -5
  274. package/src/{e2e_fees → single-node/fees}/fees_test.ts +114 -70
  275. package/src/single-node/l1-reorgs/setup.ts +93 -0
  276. package/src/single-node/partial-proofs/setup.ts +8 -0
  277. package/src/single-node/proving/setup.ts +15 -0
  278. package/src/single-node/recovery/setup.ts +8 -0
  279. package/src/single-node/setup.ts +63 -0
  280. package/src/single-node/single_node_test_context.ts +1041 -0
  281. package/src/spartan/setup_test_wallets.ts +165 -41
  282. package/src/spartan/tx_metrics.ts +108 -24
  283. package/src/spartan/utils/bot.ts +4 -1
  284. package/src/spartan/utils/config.ts +2 -0
  285. package/src/spartan/utils/index.ts +7 -0
  286. package/src/spartan/utils/k8s.ts +8 -0
  287. package/src/spartan/utils/nodes.ts +17 -12
  288. package/src/spartan/utils/pod_logs.ts +99 -0
  289. package/src/test-wallet/test_wallet.ts +228 -107
  290. package/src/test-wallet/utils.ts +104 -11
  291. package/src/test-wallet/wallet_worker_script.ts +66 -0
  292. package/src/test-wallet/worker_wallet.ts +216 -0
  293. package/src/test-wallet/worker_wallet_schema.ts +14 -0
  294. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +0 -55
  295. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts.map +0 -1
  296. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +0 -47
  297. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts.map +0 -1
  298. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.js +0 -129
  299. package/dest/e2e_deploy_contract/deploy_test.d.ts +0 -37
  300. package/dest/e2e_deploy_contract/deploy_test.d.ts.map +0 -1
  301. package/dest/e2e_deploy_contract/deploy_test.js +0 -50
  302. package/dest/e2e_epochs/epochs_test.d.ts +0 -100
  303. package/dest/e2e_epochs/epochs_test.d.ts.map +0 -1
  304. package/dest/e2e_epochs/epochs_test.js +0 -367
  305. package/dest/e2e_fees/bridging_race.notest.d.ts.map +0 -1
  306. package/dest/e2e_fees/fees_test.d.ts +0 -88
  307. package/dest/e2e_fees/fees_test.d.ts.map +0 -1
  308. package/dest/e2e_l1_publisher/write_json.d.ts +0 -11
  309. package/dest/e2e_l1_publisher/write_json.d.ts.map +0 -1
  310. package/dest/e2e_l1_publisher/write_json.js +0 -56
  311. package/dest/e2e_multi_validator/utils.d.ts +0 -12
  312. package/dest/e2e_multi_validator/utils.d.ts.map +0 -1
  313. package/dest/e2e_nested_contract/nested_contract_test.d.ts +0 -26
  314. package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +0 -1
  315. package/dest/e2e_nested_contract/nested_contract_test.js +0 -56
  316. package/dest/e2e_p2p/inactivity_slash_test.d.ts +0 -31
  317. package/dest/e2e_p2p/inactivity_slash_test.d.ts.map +0 -1
  318. package/dest/e2e_p2p/inactivity_slash_test.js +0 -136
  319. package/dest/e2e_p2p/p2p_network.d.ts.map +0 -1
  320. package/dest/e2e_p2p/reqresp/utils.d.ts +0 -22
  321. package/dest/e2e_p2p/reqresp/utils.d.ts.map +0 -1
  322. package/dest/e2e_p2p/shared.d.ts +0 -46
  323. package/dest/e2e_p2p/shared.d.ts.map +0 -1
  324. package/dest/e2e_p2p/shared.js +0 -181
  325. package/dest/e2e_storage_proof/fixtures/storage_proof_fetcher.d.ts +0 -2
  326. package/dest/e2e_storage_proof/fixtures/storage_proof_fetcher.d.ts.map +0 -1
  327. package/dest/e2e_storage_proof/fixtures/storage_proof_fixture.d.ts.map +0 -1
  328. package/dest/e2e_token_contract/token_contract_test.d.ts +0 -44
  329. package/dest/e2e_token_contract/token_contract_test.d.ts.map +0 -1
  330. package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +0 -193
  331. package/src/e2e_deploy_contract/deploy_test.ts +0 -85
  332. package/src/e2e_epochs/epochs_test.ts +0 -487
  333. package/src/e2e_l1_publisher/write_json.ts +0 -77
  334. package/src/e2e_nested_contract/nested_contract_test.ts +0 -73
  335. package/src/e2e_p2p/inactivity_slash_test.ts +0 -179
  336. package/src/e2e_p2p/shared.ts +0 -290
  337. /package/dest/{e2e_storage_proof → automine/contracts}/fixtures/storage_proof_fetcher.js +0 -0
  338. /package/dest/{e2e_storage_proof → automine/contracts}/fixtures/storage_proof_fixture.js +0 -0
  339. /package/dest/{e2e_multi_validator/utils.js → composed/web3signer/multi_validator_keystore_utils.js} +0 -0
  340. /package/src/{e2e_storage_proof → automine/contracts}/fixtures/storage_proof.json +0 -0
  341. /package/src/{e2e_storage_proof → automine/contracts}/fixtures/storage_proof_fetcher.ts +0 -0
  342. /package/src/{e2e_storage_proof → automine/contracts}/fixtures/storage_proof_fixture.ts +0 -0
  343. /package/src/{e2e_multi_validator/utils.ts → composed/web3signer/multi_validator_keystore_utils.ts} +0 -0
@@ -1,14 +1,13 @@
1
1
  /**
2
2
  * Test fixtures and utilities to set up and run a test using multiple validators
3
3
  */
4
- import { type AztecNodeConfig, AztecNodeService } from '@aztec/aztec-node';
4
+ import { type AztecNodeConfig, AztecNodeService, createAztecNodeService } from '@aztec/aztec-node';
5
5
  import { range } from '@aztec/foundation/array';
6
6
  import { SecretValue } from '@aztec/foundation/config';
7
7
  import { withLoggerBindings } from '@aztec/foundation/log/server';
8
8
  import { bufferToHex } from '@aztec/foundation/string';
9
9
  import type { DateProvider } from '@aztec/foundation/timer';
10
- import type { ProverNodeConfig, ProverNodeDeps } from '@aztec/prover-node';
11
- import type { PublicDataTreeLeaf } from '@aztec/stdlib/trees';
10
+ import type { GenesisData } from '@aztec/stdlib/world-state';
12
11
 
13
12
  import getPort from 'get-port';
14
13
 
@@ -41,7 +40,7 @@ export async function createNodes(
41
40
  bootstrapNodeEnr: string,
42
41
  numNodes: number,
43
42
  bootNodePort: number,
44
- prefilledPublicData?: PublicDataTreeLeaf[],
43
+ genesis?: GenesisData,
45
44
  dataDirectory?: string,
46
45
  metricsPort?: number,
47
46
  indexOffset = 0,
@@ -66,7 +65,7 @@ export async function createNodes(
66
65
  port,
67
66
  bootstrapNodeEnr,
68
67
  validatorIndices,
69
- prefilledPublicData,
68
+ genesis,
70
69
  dataDir,
71
70
  metricsPort,
72
71
  );
@@ -89,6 +88,10 @@ export type CreateNodeConfig = AztecNodeConfig & {
89
88
  dontStartSequencer?: boolean;
90
89
  /** Override the private key (instead of deriving from addressIndex). */
91
90
  validatorPrivateKey?: `0x${string}`;
91
+ /** Corrupt only the block proposal at this indexWithinCheckpoint (testing only). */
92
+ invalidBlockProposalIndexWithinCheckpoint?: number;
93
+ /** Accept proposal gossip regardless of slot timing (testing only). */
94
+ skipProposalSlotValidation?: boolean;
92
95
  };
93
96
 
94
97
  /** Creates a P2P enabled instance of Aztec Node Service with a validator. */
@@ -98,7 +101,7 @@ export async function createNode(
98
101
  tcpPort: number,
99
102
  bootstrapNode: string | undefined,
100
103
  addressIndex: number | number[],
101
- prefilledPublicData?: PublicDataTreeLeaf[],
104
+ genesis?: GenesisData,
102
105
  dataDirectory?: string,
103
106
  metricsPort?: number,
104
107
  ) {
@@ -106,10 +109,10 @@ export async function createNode(
106
109
  return await withLoggerBindings({ actor: `validator-${actorIndex}` }, async () => {
107
110
  const validatorConfig = await createValidatorConfig(config, bootstrapNode, tcpPort, addressIndex, dataDirectory);
108
111
  const telemetry = await getEndToEndTestTelemetryClient(metricsPort);
109
- return await AztecNodeService.createAndSync(
112
+ return await createAztecNodeService(
110
113
  validatorConfig,
111
114
  { telemetry, dateProvider },
112
- { prefilledPublicData, dontStartSequencer: config.dontStartSequencer },
115
+ { genesis, dontStartSequencer: config.dontStartSequencer },
113
116
  );
114
117
  });
115
118
  }
@@ -120,7 +123,7 @@ export async function createNonValidatorNode(
120
123
  dateProvider: DateProvider,
121
124
  tcpPort: number,
122
125
  bootstrapNode: string | undefined,
123
- prefilledPublicData?: PublicDataTreeLeaf[],
126
+ genesis?: GenesisData,
124
127
  dataDirectory?: string,
125
128
  metricsPort?: number,
126
129
  ) {
@@ -131,10 +134,10 @@ export async function createNonValidatorNode(
131
134
  ...p2pConfig,
132
135
  disableValidator: true,
133
136
  validatorPrivateKeys: undefined,
134
- publisherPrivateKeys: [],
137
+ sequencerPublisherPrivateKeys: [],
135
138
  };
136
139
  const telemetry = await getEndToEndTestTelemetryClient(metricsPort);
137
- return await AztecNodeService.createAndSync(config, { telemetry, dateProvider }, { prefilledPublicData });
140
+ return await createAztecNodeService(config, { telemetry, dateProvider }, { genesis });
138
141
  });
139
142
  }
140
143
 
@@ -143,31 +146,24 @@ export async function createProverNode(
143
146
  tcpPort: number,
144
147
  bootstrapNode: string | undefined,
145
148
  addressIndex: number,
146
- proverNodeDeps: ProverNodeDeps & Required<Pick<ProverNodeDeps, 'dateProvider'>>,
147
- prefilledPublicData?: PublicDataTreeLeaf[],
149
+ deps: { dateProvider: DateProvider },
150
+ genesis?: GenesisData,
148
151
  dataDirectory?: string,
149
152
  metricsPort?: number,
150
- ) {
153
+ ): Promise<{ proverNode: AztecNodeService }> {
151
154
  const actorIndex = proverCounter++;
152
155
  return await withLoggerBindings({ actor: `prover-${actorIndex}` }, async () => {
153
156
  const proverNodePrivateKey = getPrivateKeyFromIndex(ATTESTER_PRIVATE_KEYS_START_INDEX + addressIndex)!;
154
157
  const telemetry = await getEndToEndTestTelemetryClient(metricsPort);
155
158
 
156
- const proverConfig: Partial<ProverNodeConfig> = await createP2PConfig(
157
- config,
158
- bootstrapNode,
159
- tcpPort,
160
- dataDirectory,
161
- );
159
+ const p2pConfig = await createP2PConfig(config, bootstrapNode, tcpPort, dataDirectory);
162
160
 
163
- const aztecNodeRpcTxProvider = undefined;
164
161
  return await createAndSyncProverNode(
165
162
  bufferToHex(proverNodePrivateKey),
166
- config,
167
- { ...proverConfig, dataDirectory },
168
- aztecNodeRpcTxProvider,
169
- prefilledPublicData,
170
- { ...proverNodeDeps, telemetry },
163
+ { ...config, ...p2pConfig },
164
+ { dataDirectory },
165
+ { ...deps, telemetry },
166
+ { genesis },
171
167
  );
172
168
  });
173
169
  }
@@ -215,7 +211,7 @@ export async function createValidatorConfig(
215
211
  ...config,
216
212
  ...p2pConfig,
217
213
  validatorPrivateKeys: new SecretValue(attesterPrivateKeys),
218
- publisherPrivateKeys: [new SecretValue(attesterPrivateKeys[0])],
214
+ sequencerPublisherPrivateKeys: [new SecretValue(attesterPrivateKeys[0])],
219
215
  };
220
216
 
221
217
  return nodeConfig;
@@ -0,0 +1,97 @@
1
+ /**
2
+ * E2e span instrumentation. Wrapping a shared test helper in {@link testSpan} / {@link testSpanSync}
3
+ * records how long it ran, attributed to the test (or suite) that was executing, so a full CI run can
4
+ * be aggregated into a ranked list of where the suite spends wall-clock (setup, protocol waits, client
5
+ * proving, warp scans, ...). See the A-1178 timing environment in `shared/timing_env.mjs`.
6
+ *
7
+ * Everything here is gated on the collector installed by that environment, which only exists when
8
+ * `TEST_TIMING_FILE` is set. When it is unset, {@link testSpan} calls `fn()` directly with no extra work
9
+ * and no clock reads — instrumentation is exactly zero-cost and cannot change a test's behavior or
10
+ * timing.
11
+ */
12
+ import { AsyncLocalStorage } from 'node:async_hooks';
13
+
14
+ /**
15
+ * Async-context owner override. A span normally attributes itself to the running test
16
+ * (`collector.current`), but a background producer (e.g. the mempool feeder) runs interleaved with
17
+ * arbitrary tests, so its spans would smear across whichever test happened to be current when each
18
+ * round fired. Running such work inside {@link withTestSpanOwner} pins every span in that async call
19
+ * tree to a fixed owner instead — isolated by async context from concurrent test-body spans.
20
+ */
21
+ const ownerOverride = new AsyncLocalStorage<string | null>();
22
+
23
+ /**
24
+ * Runs `fn` with every {@link testSpan} inside its async call tree attributed to `owner` instead of the
25
+ * currently running test. Use a non-test sentinel owner (e.g. `other:mempool-feeder`) to keep a
26
+ * background producer's spans out of the per-test view.
27
+ */
28
+ export function withTestSpanOwner<T>(owner: string, fn: () => Promise<T>): Promise<T> {
29
+ return ownerOverride.run(owner, fn);
30
+ }
31
+
32
+ /** One recorded span occurrence on the process-wide `performance.now()` clock. */
33
+ export type TimingSpan = {
34
+ /** Full name of the test running when the span started, or `null` if inside a beforeAll/afterAll hook. */
35
+ owner: string | null;
36
+ /** Stable `category:label` tag, aggregated across occurrences (e.g. `wait:checkpoint`, `setup:node`). */
37
+ name: string;
38
+ /** `performance.now()` at span start. */
39
+ start: number;
40
+ /** `performance.now()` at span end. */
41
+ end: number;
42
+ };
43
+
44
+ /**
45
+ * The collector shared by the timing environment on `globalThis.__e2eTimings`. `current` is the full
46
+ * name of the test currently running (`null` during beforeAll/afterAll); the environment sets it. The
47
+ * `spans` array accumulates every recorded span until the environment folds it into the per-test /
48
+ * per-suite JSONL line at flush.
49
+ */
50
+ export type SpanCollector = {
51
+ /** Full name of the running test, or `null` during a beforeAll/afterAll hook. */
52
+ current: string | null;
53
+ /** All recorded spans, drained by the timing environment at flush time. */
54
+ spans: TimingSpan[];
55
+ };
56
+
57
+ function getCollector(): SpanCollector | undefined {
58
+ return (globalThis as { __e2eTimings?: SpanCollector }).__e2eTimings;
59
+ }
60
+
61
+ /**
62
+ * Times `fn` and records a span tagged `name`, attributed to the test (or suite) running when it
63
+ * started. The span is recorded even when `fn` throws. Pure passthrough: when no collector is
64
+ * installed (i.e. `TEST_TIMING_FILE` is unset) this calls `fn()` directly with zero overhead.
65
+ *
66
+ * Use stable `category:label` tags and prefer wrapping at the leaf wait/setup/tx level — labels are
67
+ * forever aggregation keys, and leaf-level tagging keeps spans additive. See `SPEEDUP_FOLLOWUPS` and
68
+ * the A-1179 design doc for the tag taxonomy.
69
+ */
70
+ export async function testSpan<T>(name: string, fn: () => Promise<T>): Promise<T> {
71
+ const collector = getCollector();
72
+ if (!collector) {
73
+ return fn();
74
+ }
75
+ const owner = ownerOverride.getStore() ?? collector.current;
76
+ const start = performance.now();
77
+ try {
78
+ return await fn();
79
+ } finally {
80
+ collector.spans.push({ owner, name, start, end: performance.now() });
81
+ }
82
+ }
83
+
84
+ /** Synchronous variant of {@link testSpan} for non-async helpers. Same zero-cost guarantee when unset. */
85
+ export function testSpanSync<T>(name: string, fn: () => T): T {
86
+ const collector = getCollector();
87
+ if (!collector) {
88
+ return fn();
89
+ }
90
+ const owner = ownerOverride.getStore() ?? collector.current;
91
+ const start = performance.now();
92
+ try {
93
+ return fn();
94
+ } finally {
95
+ collector.spans.push({ owner, name, start, end: performance.now() });
96
+ }
97
+ }
@@ -3,12 +3,46 @@ import { BatchCall } from '@aztec/aztec.js/contracts';
3
3
  import type { Logger } from '@aztec/aztec.js/log';
4
4
  import type { Wallet } from '@aztec/aztec.js/wallet';
5
5
  import { TokenContract } from '@aztec/noir-contracts.js/Token';
6
+ import { TestTokenContract } from '@aztec/noir-test-contracts.js/TestToken';
7
+
8
+ /**
9
+ * Either token flavour. Canonical `TokenContract` uses constrained message delivery (production / docs
10
+ * source of truth); `TestTokenContract` is its codegen'd unconstrained-delivery sibling, used by tests
11
+ * where a token is just a unit-of-account vehicle. The two share an identical ABI, so helpers that only
12
+ * read balances or mint accept either.
13
+ */
14
+ export type AnyTokenContract = TokenContract | TestTokenContract;
6
15
 
7
16
  export async function deployToken(wallet: Wallet, admin: AztecAddress, initialAdminBalance: bigint, logger: Logger) {
8
17
  logger.info(`Deploying Token contract...`);
9
18
  const { contract, instance } = await TokenContract.deploy(wallet, admin, 'TokenName', 'TokenSymbol', 18).send({
10
19
  from: admin,
11
- wait: { returnReceipt: true },
20
+ });
21
+
22
+ if (initialAdminBalance > 0n) {
23
+ await mintTokensToPrivate(contract, admin, admin, initialAdminBalance);
24
+ }
25
+
26
+ logger.info('L2 contract deployed');
27
+
28
+ return { contract, instance };
29
+ }
30
+
31
+ /**
32
+ * Deploys the unconstrained-delivery `TestTokenContract`. Use this in tests where the token is a
33
+ * unit-of-account vehicle rather than the subject, so they don't pay constrained delivery's first-send
34
+ * handshake cost (which distorts step/log counts that benches assert on). Use {@link deployToken} when a
35
+ * test exercises canonical Token semantics or note discovery.
36
+ */
37
+ export async function deployTestToken(
38
+ wallet: Wallet,
39
+ admin: AztecAddress,
40
+ initialAdminBalance: bigint,
41
+ logger: Logger,
42
+ ) {
43
+ logger.info(`Deploying TestToken contract...`);
44
+ const { contract, instance } = await TestTokenContract.deploy(wallet, admin, 'TokenName', 'TokenSymbol', 18).send({
45
+ from: admin,
12
46
  });
13
47
 
14
48
  if (initialAdminBalance > 0n) {
@@ -21,24 +55,25 @@ export async function deployToken(wallet: Wallet, admin: AztecAddress, initialAd
21
55
  }
22
56
 
23
57
  export async function mintTokensToPrivate(
24
- token: TokenContract,
58
+ token: AnyTokenContract,
25
59
  minter: AztecAddress,
26
60
  recipient: AztecAddress,
27
61
  amount: bigint,
62
+ additionalScopes?: AztecAddress[],
28
63
  ) {
29
- await token.methods.mint_to_private(recipient, amount).send({ from: minter });
64
+ await token.methods.mint_to_private(recipient, amount).send({ from: minter, additionalScopes });
30
65
  }
31
66
 
32
67
  export async function expectTokenBalance(
33
68
  wallet: Wallet,
34
- token: TokenContract,
69
+ token: AnyTokenContract,
35
70
  owner: AztecAddress,
36
71
  expectedBalance: bigint,
37
72
  logger: Logger,
38
73
  ) {
39
74
  // Then check the balance
40
- const contractWithWallet = TokenContract.at(token.address, wallet);
41
- const balance = await contractWithWallet.methods.balance_of_private(owner).simulate({ from: owner });
75
+ const contractWithWallet = token.withWallet(wallet);
76
+ const { result: balance } = await contractWithWallet.methods.balance_of_private(owner).simulate({ from: owner });
42
77
  logger.info(`Account ${owner} balance: ${balance}`);
43
78
  expect(balance).toBe(expectedBalance);
44
79
  }
@@ -47,7 +82,7 @@ export async function mintNotes(
47
82
  wallet: Wallet,
48
83
  minter: AztecAddress,
49
84
  recipient: AztecAddress,
50
- asset: TokenContract,
85
+ asset: AnyTokenContract,
51
86
  noteAmounts: bigint[],
52
87
  ): Promise<bigint> {
53
88
  // We can only mint 5 notes at a time, since that's the maximum number of calls our entrypoints allow
@@ -7,8 +7,8 @@ export {
7
7
  type EndToEndContext,
8
8
  type SetupOptions,
9
9
  createAndSyncProverNode,
10
- deployAccounts,
11
- ensureAccountContractsPublished,
10
+ ensureAuthRegistryPublished,
11
+ ensurePublicChecksPublished,
12
12
  expectMapping,
13
13
  expectMappingDelta,
14
14
  getBalancesFn,
@@ -16,7 +16,6 @@ export {
16
16
  getPrivateKeyFromIndex,
17
17
  getSponsoredFPCAddress,
18
18
  getSponsoredFPCInstance,
19
- publicDeployAccounts,
20
19
  registerSponsoredFPC,
21
20
  setup,
22
21
  setupPXEAndGetWallet,
@@ -0,0 +1,333 @@
1
+ import type { WaitOpts } from '@aztec/aztec.js/contracts';
2
+ import type { Fr } from '@aztec/aztec.js/fields';
3
+ import { waitForTx } from '@aztec/aztec.js/node';
4
+ import { INITIAL_L2_BLOCK_NUM } from '@aztec/aztec.js/protocol';
5
+ import type { BlockNumber, CheckpointNumber, SlotNumber } from '@aztec/foundation/branded-types';
6
+ import { promiseWithResolvers } from '@aztec/foundation/promise';
7
+ import { retryUntil } from '@aztec/foundation/retry';
8
+ import type { Sequencer, SequencerEvents, SequencerState } from '@aztec/sequencer-client';
9
+ import type { L2BlockTag } from '@aztec/stdlib/block';
10
+ import type { AztecNode, CheckpointTag } from '@aztec/stdlib/interfaces/client';
11
+ import type { L2ToL1MembershipWitness } from '@aztec/stdlib/messaging';
12
+ import type { TxHash, TxReceipt, TxStatus } from '@aztec/stdlib/tx';
13
+
14
+ import { testSpan } from './timing.js';
15
+
16
+ /** Options for the block-number polling helpers. */
17
+ export type WaitForBlockOpts = {
18
+ /** Which chain tip to read; defaults to 'proposed'. */
19
+ tag?: L2BlockTag;
20
+ /** How the node's block number must relate to `target`; defaults to `(actual, target) => actual >= target`. */
21
+ compare?: (actual: number, target: number) => boolean;
22
+ /** Seconds before the poll rejects; defaults to 60. */
23
+ timeout?: number;
24
+ /** Seconds between polls; defaults to 0.25. */
25
+ interval?: number;
26
+ };
27
+
28
+ /**
29
+ * Polls `node.getBlockNumber(tag)` until `opts.compare(actual, target)` holds (default `>=`). Replaces
30
+ * the ad-hoc `retryUntil(() => node.getBlockNumber(tag) <op> target)` polls scattered across the suite,
31
+ * where the node may sync forward or prune backward — the caller passes the comparator for whichever it
32
+ * expects.
33
+ * @returns The block number once the comparison holds.
34
+ */
35
+ export function waitForBlockNumber(node: AztecNode, target: number, opts: WaitForBlockOpts = {}): Promise<BlockNumber> {
36
+ const tag = opts.tag ?? 'proposed';
37
+ const compare = opts.compare ?? ((actual, target) => actual >= target);
38
+ return testSpan(`wait:${tag}`, () =>
39
+ // Wrap the matched value: retryUntil treats any falsy return as "keep polling", so a legitimate
40
+ // match of block 0 (e.g. a freshly-pruned tip) would otherwise loop until timeout.
41
+ retryUntil(
42
+ async () => {
43
+ const blockNumber = await node.getBlockNumber(tag);
44
+ return compare(blockNumber, target) ? { blockNumber } : undefined;
45
+ },
46
+ `block ${tag} ${compare} ${target}`,
47
+ opts.timeout ?? 60,
48
+ opts.interval ?? 0.25,
49
+ ).then(({ blockNumber }) => blockNumber),
50
+ );
51
+ }
52
+
53
+ /** Convenience for {@link waitForBlockNumber} on the proven tip. */
54
+ export function waitForProvenBlock(
55
+ node: AztecNode,
56
+ target: number,
57
+ opts: Omit<WaitForBlockOpts, 'tag'> = {},
58
+ ): Promise<BlockNumber> {
59
+ return waitForBlockNumber(node, target, { ...opts, tag: 'proven' });
60
+ }
61
+
62
+ /** Compares the node's checkpoint number against the target; defaults to `>=`. */
63
+ export type CheckpointComparator = (actual: number, target: number) => boolean;
64
+
65
+ /** Options for {@link waitForNodeCheckpoint}. */
66
+ export type WaitForCheckpointOpts = {
67
+ /** Which checkpoint tip to read; defaults to 'checkpointed'. */
68
+ tag?: CheckpointTag;
69
+ /** How the node's checkpoint number must relate to `target`; defaults to `(actual, target) => actual >= target`. */
70
+ compare?: CheckpointComparator;
71
+ /** Seconds before the poll rejects; defaults to 30. */
72
+ timeout?: number;
73
+ /** Seconds between polls; defaults to 0.5. */
74
+ interval?: number;
75
+ };
76
+
77
+ /**
78
+ * Polls a single node's checkpoint number until `opts.compare(actual, target)` holds. Replaces the
79
+ * `retryUntil(() => node.getChainTips().then(tips => tips.<tag>.checkpoint.number <op> target))` polls
80
+ * duplicated across the reorg/proving tests, where the node may sync forward, prune backward, or land
81
+ * exactly on a value — the caller passes the comparator lambda for whichever it expects.
82
+ * @returns The node's checkpoint number once the comparison holds.
83
+ */
84
+ export function waitForNodeCheckpoint(
85
+ node: AztecNode,
86
+ target: number,
87
+ opts: WaitForCheckpointOpts = {},
88
+ ): Promise<CheckpointNumber> {
89
+ const tag = opts.tag ?? 'checkpointed';
90
+ const compare = opts.compare ?? ((actual, target) => actual >= target);
91
+ return testSpan(tag === 'proven' ? 'wait:proven-checkpoint' : 'wait:checkpoint', () =>
92
+ // Wrap the matched value: retryUntil treats any falsy return as "keep polling", so a legitimate
93
+ // match of checkpoint 0 (e.g. proven === 0 or checkpointed <= 1 after a prune) would otherwise
94
+ // loop until timeout instead of resolving.
95
+ retryUntil(
96
+ async () => {
97
+ const checkpointNumber = await node.getCheckpointNumber(tag);
98
+ return compare(checkpointNumber, target) ? { checkpointNumber } : undefined;
99
+ },
100
+ `node checkpoint ${tag} ${compare} ${target}`,
101
+ opts.timeout ?? 30,
102
+ opts.interval ?? 0.5,
103
+ ).then(({ checkpointNumber }) => checkpointNumber),
104
+ );
105
+ }
106
+
107
+ /** Convenience for {@link waitForNodeCheckpoint} on the proven tip. */
108
+ export function waitForNodeProvenCheckpoint(
109
+ node: AztecNode,
110
+ target: number,
111
+ opts: Omit<WaitForCheckpointOpts, 'tag'> = {},
112
+ ): Promise<CheckpointNumber> {
113
+ return waitForNodeCheckpoint(node, target, { ...opts, tag: 'proven' });
114
+ }
115
+
116
+ /**
117
+ * Waits for all of `txHashes` to reach the desired status on `node`. The plural form of
118
+ * {@link waitForTx}; resolves with the receipts in input order.
119
+ */
120
+ export function waitForTxs(node: AztecNode, txHashes: TxHash[], opts?: WaitOpts): Promise<TxReceipt[]> {
121
+ const optsWithInterval = { ...opts, interval: opts?.interval ?? 0.25 };
122
+ return testSpan('wait:tx-mined', () =>
123
+ Promise.all(txHashes.map(txHash => waitForTx(node, txHash, optsWithInterval))),
124
+ );
125
+ }
126
+
127
+ /** Options for {@link waitForBlocksAtSlots}. */
128
+ export type WaitForBlocksAtSlotsOpts = {
129
+ /** Block number to start scanning from; defaults to the initial L2 block. */
130
+ from?: BlockNumber;
131
+ /** How many blocks to fetch per poll; defaults to 10. */
132
+ limit?: number;
133
+ /** Seconds before the poll rejects; defaults to 20. */
134
+ timeout?: number;
135
+ /** Seconds between polls; defaults to 0.25. */
136
+ interval?: number;
137
+ };
138
+
139
+ /**
140
+ * Polls `node.getBlocks` until every slot in `slots` is present among the fetched blocks' slot
141
+ * numbers. Replaces the hand-rolled `retryUntil` over `getBlocks(...).map(getSlot)` membership check.
142
+ */
143
+ export async function waitForBlocksAtSlots(
144
+ node: AztecNode,
145
+ slots: SlotNumber[],
146
+ opts: WaitForBlocksAtSlotsOpts = {},
147
+ ): Promise<void> {
148
+ const from = opts.from ?? INITIAL_L2_BLOCK_NUM;
149
+ const limit = opts.limit ?? 10;
150
+ await testSpan('wait:block', () =>
151
+ retryUntil(
152
+ async () => {
153
+ const blocks = await node.getBlocks(from, limit);
154
+ const foundSlots = blocks.map(block => block.header.getSlot());
155
+ return slots.every(slot => foundSlots.includes(slot)) || undefined;
156
+ },
157
+ `blocks at slots ${slots.join(', ')}`,
158
+ opts.timeout ?? 20,
159
+ opts.interval ?? 0.25,
160
+ ),
161
+ );
162
+ }
163
+
164
+ /**
165
+ * Polls `node.getL2ToL1MembershipWitness(txHash, message)` until a witness is available, resolving
166
+ * with it. Wraps the `retryUntil` the cross-chain tests hand-roll while waiting for an L2-to-L1
167
+ * message's membership witness to become provable.
168
+ */
169
+ export function waitForL2ToL1Witness(
170
+ node: AztecNode,
171
+ txHash: TxHash,
172
+ message: Fr,
173
+ opts: { timeout?: number; interval?: number } = {},
174
+ ): Promise<L2ToL1MembershipWitness> {
175
+ return testSpan('wait:l2-to-l1-witness', () =>
176
+ retryUntil(
177
+ () => node.getL2ToL1MembershipWitness(txHash, message),
178
+ `L2-to-L1 membership witness for ${txHash.toString()}`,
179
+ opts.timeout ?? 30,
180
+ opts.interval ?? 0.25,
181
+ ),
182
+ );
183
+ }
184
+
185
+ /** Options for the tx-receipt polling helpers. */
186
+ export type WaitForTxReceiptOpts = {
187
+ /** Seconds before the poll rejects; defaults to 30. */
188
+ timeout?: number;
189
+ /** Seconds between polls; defaults to 0.25. */
190
+ interval?: number;
191
+ };
192
+
193
+ /**
194
+ * Polls `node.getTxReceipt(txHash)` until `predicate(receipt)` holds, resolving with the receipt.
195
+ * Wraps the `retryUntil` that the block-building reorg tests hand-roll while waiting for a tx to
196
+ * transition between statuses (pruned, re-included, ...).
197
+ * @returns The receipt once the predicate holds.
198
+ */
199
+ export function waitForTxReceipt(
200
+ node: AztecNode,
201
+ txHash: TxHash,
202
+ predicate: (receipt: TxReceipt) => boolean,
203
+ opts: WaitForTxReceiptOpts = {},
204
+ ): Promise<TxReceipt> {
205
+ return testSpan('wait:tx-mined', () =>
206
+ retryUntil(
207
+ async () => {
208
+ const receipt = await node.getTxReceipt(txHash);
209
+ return predicate(receipt) ? { receipt } : undefined;
210
+ },
211
+ `tx receipt for ${txHash.toString()}`,
212
+ opts.timeout ?? 30,
213
+ opts.interval ?? 0.25,
214
+ ).then(({ receipt }) => receipt),
215
+ );
216
+ }
217
+
218
+ /** Polls until `node.getTxReceipt(txHash).status === status`. Thin wrapper over {@link waitForTxReceipt}. */
219
+ export function waitForTxStatus(
220
+ node: AztecNode,
221
+ txHash: TxHash,
222
+ status: TxStatus,
223
+ opts: WaitForTxReceiptOpts = {},
224
+ ): Promise<TxReceipt> {
225
+ return waitForTxReceipt(node, txHash, receipt => receipt.status === status, opts);
226
+ }
227
+
228
+ /** Compares the node's pending-tx count against the target; defaults to `>=`. */
229
+ export type PendingTxCountComparator = (actual: number, target: number) => boolean;
230
+
231
+ /** Options for {@link waitForPendingTxCount}. */
232
+ export type WaitForPendingTxCountOpts = {
233
+ /** How the node's pending-tx count must relate to `target`; defaults to `(actual, target) => actual >= target`. */
234
+ compare?: PendingTxCountComparator;
235
+ /** Seconds before the poll rejects; defaults to 30. */
236
+ timeout?: number;
237
+ /** Seconds between polls; defaults to 0.25. */
238
+ interval?: number;
239
+ };
240
+
241
+ /**
242
+ * Polls `node.getPendingTxCount()` until `opts.compare(actual, target)` holds (default `>=`).
243
+ * Replaces the hand-rolled mempool-size poll in the slashing tests.
244
+ * @returns The pending-tx count once the comparison holds.
245
+ */
246
+ export function waitForPendingTxCount(
247
+ node: AztecNode,
248
+ target: number,
249
+ opts: WaitForPendingTxCountOpts = {},
250
+ ): Promise<number> {
251
+ const compare = opts.compare ?? ((actual, target) => actual >= target);
252
+ return testSpan('wait:pending-tx', () =>
253
+ // Wrap the matched value: retryUntil treats any falsy return as "keep polling", so a legitimate
254
+ // match of 0 pending txs would otherwise loop until timeout instead of resolving.
255
+ retryUntil(
256
+ async () => {
257
+ const count = await node.getPendingTxCount();
258
+ return compare(count, target) ? { count } : undefined;
259
+ },
260
+ `pending tx count ${compare} ${target}`,
261
+ opts.timeout ?? 30,
262
+ opts.interval ?? 0.25,
263
+ ).then(({ count }) => count),
264
+ );
265
+ }
266
+
267
+ /** Options for {@link waitForSequencerState}. */
268
+ export type WaitForSequencerStateOpts = {
269
+ /** Milliseconds before the wait rejects; defaults to 30000. */
270
+ timeout?: number;
271
+ /**
272
+ * Action to run after subscribing to the sequencer but before awaiting the transition. Subscribing
273
+ * first guarantees the state change the action triggers is not missed between the action and the
274
+ * listener attaching.
275
+ */
276
+ after?: () => unknown;
277
+ };
278
+
279
+ /**
280
+ * Resolves once `sequencer` reaches `state`. Subscribes to the `state-changed` event first, then (if
281
+ * `opts.after` is given) runs the action, then resolves immediately if the sequencer is already at
282
+ * `state`, otherwise waits for the transition. The listener is cleaned up on both resolve and timeout.
283
+ * Replaces the hand-rolled `state-changed` on/off subscriptions duplicated across the fee, cross-chain,
284
+ * and keystore-reload tests.
285
+ */
286
+ export function waitForSequencerState(
287
+ sequencer: Sequencer,
288
+ state: SequencerState,
289
+ opts: WaitForSequencerStateOpts = {},
290
+ ): Promise<void> {
291
+ return testSpan('wait:sequencer-state', () => waitForSequencerStateInner(sequencer, state, opts));
292
+ }
293
+
294
+ async function waitForSequencerStateInner(
295
+ sequencer: Sequencer,
296
+ state: SequencerState,
297
+ opts: WaitForSequencerStateOpts,
298
+ ): Promise<void> {
299
+ const timeout = opts.timeout ?? 30000;
300
+ const { promise, resolve, reject } = promiseWithResolvers<void>();
301
+
302
+ let settled = false;
303
+ const handler = (args: Parameters<SequencerEvents['state-changed']>[0]) => {
304
+ if (args.newState === state) {
305
+ finish(resolve);
306
+ }
307
+ };
308
+ const timer = setTimeout(
309
+ () => finish(() => reject(new Error(`Timeout waiting for sequencer ${state} state`))),
310
+ timeout,
311
+ );
312
+ function finish(complete: () => void) {
313
+ if (settled) {
314
+ return;
315
+ }
316
+ settled = true;
317
+ clearTimeout(timer);
318
+ sequencer.off('state-changed', handler);
319
+ complete();
320
+ }
321
+
322
+ sequencer.on('state-changed', handler);
323
+ try {
324
+ await opts.after?.();
325
+ if (sequencer.status().state === state) {
326
+ finish(resolve);
327
+ }
328
+ await promise;
329
+ } catch (err) {
330
+ finish(() => {});
331
+ throw err;
332
+ }
333
+ }
@@ -0,0 +1,14 @@
1
+ import type { Wallet } from '@aztec/aztec.js/wallet';
2
+ import { WalletSchema } from '@aztec/aztec.js/wallet';
3
+ import { createSafeJsonRpcClient, makeFetch } from '@aztec/foundation/json-rpc/client';
4
+
5
+ /**
6
+ * Creates a JSON-RPC client that connects to a remote wallet service.
7
+ * The returned object implements the {@link Wallet} interface, proxying all calls over HTTP to the specified URL.
8
+ */
9
+ export function createWalletClient(url: string): Wallet {
10
+ return createSafeJsonRpcClient<Wallet>(url, WalletSchema, {
11
+ namespaceMethods: 'wallet',
12
+ fetch: makeFetch([1, 2, 3], false),
13
+ });
14
+ }