@aztec/end-to-end 0.0.1-commit.a072138 → 0.0.1-commit.a4600f49

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 (344) 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/automine/contracts/fixtures/storage_proof_fetcher.js +184 -0
  8. package/dest/automine/contracts/fixtures/storage_proof_fixture.d.ts +18 -0
  9. package/dest/automine/contracts/fixtures/storage_proof_fixture.d.ts.map +1 -0
  10. package/dest/automine/contracts/fixtures/storage_proof_fixture.js +120 -0
  11. package/dest/automine/delivery/onchain_delivery_harness.d.ts +17 -0
  12. package/dest/automine/delivery/onchain_delivery_harness.d.ts.map +1 -0
  13. package/dest/automine/delivery/onchain_delivery_harness.js +123 -0
  14. package/dest/automine/token/blacklist_token_contract_test.d.ts +49 -0
  15. package/dest/automine/token/blacklist_token_contract_test.d.ts.map +1 -0
  16. package/dest/{e2e_blacklist_token_contract → automine/token}/blacklist_token_contract_test.js +45 -48
  17. package/dest/automine/token/token_contract_test.d.ts +40 -0
  18. package/dest/automine/token/token_contract_test.d.ts.map +1 -0
  19. package/dest/{e2e_token_contract → automine/token}/token_contract_test.js +43 -48
  20. package/dest/automine/token/token_test_helpers.d.ts +73 -0
  21. package/dest/automine/token/token_test_helpers.d.ts.map +1 -0
  22. package/dest/automine/token/token_test_helpers.js +97 -0
  23. package/dest/bench/client_flows/benchmark.d.ts +15 -1
  24. package/dest/bench/client_flows/benchmark.d.ts.map +1 -1
  25. package/dest/bench/client_flows/benchmark.js +19 -0
  26. package/dest/bench/client_flows/client_flows_benchmark.d.ts +6 -6
  27. package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -1
  28. package/dest/bench/client_flows/client_flows_benchmark.js +63 -54
  29. package/dest/bench/client_flows/config.d.ts +2 -2
  30. package/dest/bench/client_flows/config.d.ts.map +1 -1
  31. package/dest/bench/client_flows/config.js +18 -0
  32. package/dest/bench/client_flows/data_extractor.js +1 -0
  33. package/dest/bench/utils.d.ts +3 -3
  34. package/dest/bench/utils.d.ts.map +1 -1
  35. package/dest/bench/utils.js +102 -8
  36. package/dest/composed/ha/ha_full_setup.d.ts +77 -0
  37. package/dest/composed/ha/ha_full_setup.d.ts.map +1 -0
  38. package/dest/composed/ha/ha_full_setup.js +383 -0
  39. package/dest/composed/web3signer/multi_validator_keystore_utils.d.ts +12 -0
  40. package/dest/composed/web3signer/multi_validator_keystore_utils.d.ts.map +1 -0
  41. package/dest/fixtures/authwit_proxy.d.ts +15 -0
  42. package/dest/fixtures/authwit_proxy.d.ts.map +1 -0
  43. package/dest/fixtures/authwit_proxy.js +34 -0
  44. package/dest/fixtures/e2e_prover_test.d.ts +18 -14
  45. package/dest/fixtures/e2e_prover_test.d.ts.map +1 -1
  46. package/dest/fixtures/e2e_prover_test.js +82 -74
  47. package/dest/fixtures/elu_monitor.d.ts +21 -0
  48. package/dest/fixtures/elu_monitor.d.ts.map +1 -0
  49. package/dest/fixtures/elu_monitor.js +102 -0
  50. package/dest/fixtures/fixtures.d.ts +82 -1
  51. package/dest/fixtures/fixtures.d.ts.map +1 -1
  52. package/dest/fixtures/fixtures.js +84 -0
  53. package/dest/fixtures/get_bb_config.d.ts +1 -1
  54. package/dest/fixtures/get_bb_config.d.ts.map +1 -1
  55. package/dest/fixtures/get_bb_config.js +5 -5
  56. package/dest/fixtures/ha_setup.d.ts +71 -0
  57. package/dest/fixtures/ha_setup.d.ts.map +1 -0
  58. package/dest/fixtures/ha_setup.js +119 -0
  59. package/dest/fixtures/index.d.ts +3 -1
  60. package/dest/fixtures/index.d.ts.map +1 -1
  61. package/dest/fixtures/index.js +2 -0
  62. package/dest/fixtures/schnorr_hardcoded_account_contract.d.ts +25 -0
  63. package/dest/fixtures/schnorr_hardcoded_account_contract.d.ts.map +1 -0
  64. package/dest/fixtures/schnorr_hardcoded_account_contract.js +37 -0
  65. package/dest/fixtures/setup.d.ts +111 -60
  66. package/dest/fixtures/setup.d.ts.map +1 -1
  67. package/dest/fixtures/setup.js +320 -327
  68. package/dest/fixtures/setup_p2p_test.d.ts +22 -10
  69. package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
  70. package/dest/fixtures/setup_p2p_test.js +26 -20
  71. package/dest/fixtures/timing.d.ts +42 -0
  72. package/dest/fixtures/timing.d.ts.map +1 -0
  73. package/dest/fixtures/timing.js +72 -0
  74. package/dest/fixtures/token_utils.d.ts +22 -4
  75. package/dest/fixtures/token_utils.d.ts.map +1 -1
  76. package/dest/fixtures/token_utils.js +26 -8
  77. package/dest/fixtures/utils.d.ts +2 -2
  78. package/dest/fixtures/utils.d.ts.map +1 -1
  79. package/dest/fixtures/utils.js +1 -1
  80. package/dest/fixtures/wait_helpers.d.ts +135 -0
  81. package/dest/fixtures/wait_helpers.d.ts.map +1 -0
  82. package/dest/fixtures/wait_helpers.js +154 -0
  83. package/dest/forward-compatibility/wallet_rpc_client.d.ts +7 -0
  84. package/dest/forward-compatibility/wallet_rpc_client.d.ts.map +1 -0
  85. package/dest/forward-compatibility/wallet_rpc_client.js +15 -0
  86. package/dest/forward-compatibility/wallet_service.d.ts +3 -0
  87. package/dest/forward-compatibility/wallet_service.d.ts.map +1 -0
  88. package/dest/forward-compatibility/wallet_service.js +109 -0
  89. package/dest/install_legacy_contracts.d.cts +10 -0
  90. package/dest/install_legacy_contracts.d.cts.map +1 -0
  91. package/dest/legacy-jest-resolver.d.cts +3 -0
  92. package/dest/legacy-jest-resolver.d.cts.map +1 -0
  93. package/dest/multi-node/block-production/setup.d.ts +97 -0
  94. package/dest/multi-node/block-production/setup.d.ts.map +1 -0
  95. package/dest/multi-node/block-production/setup.js +158 -0
  96. package/dest/multi-node/governance/setup.d.ts +67 -0
  97. package/dest/multi-node/governance/setup.d.ts.map +1 -0
  98. package/dest/multi-node/governance/setup.js +126 -0
  99. package/dest/multi-node/multi_node_test_context.d.ts +212 -0
  100. package/dest/multi-node/multi_node_test_context.d.ts.map +1 -0
  101. package/dest/multi-node/multi_node_test_context.js +347 -0
  102. package/dest/multi-node/slashing/inactivity_setup.d.ts +27 -0
  103. package/dest/multi-node/slashing/inactivity_setup.d.ts.map +1 -0
  104. package/dest/multi-node/slashing/inactivity_setup.js +111 -0
  105. package/dest/multi-node/slashing/setup.d.ts +167 -0
  106. package/dest/multi-node/slashing/setup.d.ts.map +1 -0
  107. package/dest/multi-node/slashing/setup.js +275 -0
  108. package/dest/{e2e_p2p → p2p}/p2p_network.d.ts +22 -12
  109. package/dest/p2p/p2p_network.d.ts.map +1 -0
  110. package/dest/{e2e_p2p → p2p}/p2p_network.js +97 -37
  111. package/dest/p2p/reqresp/utils.d.ts +19 -0
  112. package/dest/p2p/reqresp/utils.d.ts.map +1 -0
  113. package/dest/{e2e_p2p → p2p}/reqresp/utils.js +67 -27
  114. package/dest/p2p/shared.d.ts +72 -0
  115. package/dest/p2p/shared.d.ts.map +1 -0
  116. package/dest/p2p/shared.js +212 -0
  117. package/dest/shared/cross_chain_test_harness.d.ts +6 -4
  118. package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
  119. package/dest/shared/cross_chain_test_harness.js +36 -31
  120. package/dest/shared/gas_portal_test_harness.d.ts +8 -5
  121. package/dest/shared/gas_portal_test_harness.d.ts.map +1 -1
  122. package/dest/shared/gas_portal_test_harness.js +26 -14
  123. package/dest/shared/index.d.ts +2 -1
  124. package/dest/shared/index.d.ts.map +1 -1
  125. package/dest/shared/index.js +1 -0
  126. package/dest/shared/jest_setup.js +41 -1
  127. package/dest/shared/mock_state_view.d.ts +86 -0
  128. package/dest/shared/mock_state_view.d.ts.map +1 -0
  129. package/dest/shared/mock_state_view.js +186 -0
  130. package/dest/shared/submit-transactions.d.ts +2 -2
  131. package/dest/shared/submit-transactions.d.ts.map +1 -1
  132. package/dest/shared/submit-transactions.js +12 -5
  133. package/dest/shared/timing_env.d.js +5 -0
  134. package/dest/shared/timing_env.js +365 -0
  135. package/dest/shared/uniswap_l1_l2.d.ts +1 -1
  136. package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
  137. package/dest/shared/uniswap_l1_l2.js +56 -44
  138. package/dest/shared/wait_for_l1_to_l2_message.d.ts +13 -0
  139. package/dest/shared/wait_for_l1_to_l2_message.d.ts.map +1 -0
  140. package/dest/shared/wait_for_l1_to_l2_message.js +10 -0
  141. package/dest/simulators/lending_simulator.d.ts +10 -3
  142. package/dest/simulators/lending_simulator.d.ts.map +1 -1
  143. package/dest/simulators/lending_simulator.js +27 -15
  144. package/dest/simulators/token_simulator.d.ts +1 -1
  145. package/dest/simulators/token_simulator.d.ts.map +1 -1
  146. package/dest/simulators/token_simulator.js +3 -24
  147. package/dest/single-node/cross-chain/cross_chain_messaging_test.d.ts +75 -0
  148. package/dest/single-node/cross-chain/cross_chain_messaging_test.d.ts.map +1 -0
  149. package/dest/single-node/cross-chain/cross_chain_messaging_test.js +209 -0
  150. package/dest/single-node/cross-chain/message_test_helpers.d.ts +38 -0
  151. package/dest/single-node/cross-chain/message_test_helpers.d.ts.map +1 -0
  152. package/dest/single-node/cross-chain/message_test_helpers.js +70 -0
  153. package/dest/{e2e_fees → single-node/fees}/bridging_race.notest.d.ts +1 -1
  154. package/dest/single-node/fees/bridging_race.notest.d.ts.map +1 -0
  155. package/dest/{e2e_fees → single-node/fees}/bridging_race.notest.js +17 -4
  156. package/dest/single-node/fees/fees_test.d.ts +93 -0
  157. package/dest/single-node/fees/fees_test.d.ts.map +1 -0
  158. package/dest/{e2e_fees → single-node/fees}/fees_test.js +94 -68
  159. package/dest/single-node/l1-reorgs/setup.d.ts +42 -0
  160. package/dest/single-node/l1-reorgs/setup.d.ts.map +1 -0
  161. package/dest/single-node/l1-reorgs/setup.js +57 -0
  162. package/dest/single-node/partial-proofs/setup.d.ts +5 -0
  163. package/dest/single-node/partial-proofs/setup.d.ts.map +1 -0
  164. package/dest/single-node/partial-proofs/setup.js +5 -0
  165. package/dest/single-node/proving/setup.d.ts +5 -0
  166. package/dest/single-node/proving/setup.d.ts.map +1 -0
  167. package/dest/single-node/proving/setup.js +5 -0
  168. package/dest/single-node/recovery/setup.d.ts +5 -0
  169. package/dest/single-node/recovery/setup.d.ts.map +1 -0
  170. package/dest/single-node/recovery/setup.js +5 -0
  171. package/dest/single-node/setup.d.ts +49 -0
  172. package/dest/single-node/setup.d.ts.map +1 -0
  173. package/dest/single-node/setup.js +56 -0
  174. package/dest/single-node/single_node_test_context.d.ts +360 -0
  175. package/dest/single-node/single_node_test_context.d.ts.map +1 -0
  176. package/dest/single-node/single_node_test_context.js +833 -0
  177. package/dest/spartan/setup_test_wallets.d.ts +12 -3
  178. package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
  179. package/dest/spartan/setup_test_wallets.js +118 -41
  180. package/dest/spartan/tx_metrics.d.ts +27 -4
  181. package/dest/spartan/tx_metrics.d.ts.map +1 -1
  182. package/dest/spartan/tx_metrics.js +106 -21
  183. package/dest/spartan/utils/bot.d.ts +3 -2
  184. package/dest/spartan/utils/bot.d.ts.map +1 -1
  185. package/dest/spartan/utils/bot.js +2 -1
  186. package/dest/spartan/utils/config.d.ts +11 -28
  187. package/dest/spartan/utils/config.d.ts.map +1 -1
  188. package/dest/spartan/utils/config.js +4 -1
  189. package/dest/spartan/utils/index.d.ts +5 -3
  190. package/dest/spartan/utils/index.d.ts.map +1 -1
  191. package/dest/spartan/utils/index.js +5 -1
  192. package/dest/spartan/utils/k8s.d.ts +3 -1
  193. package/dest/spartan/utils/k8s.d.ts.map +1 -1
  194. package/dest/spartan/utils/k8s.js +6 -0
  195. package/dest/spartan/utils/nodes.d.ts +4 -5
  196. package/dest/spartan/utils/nodes.d.ts.map +1 -1
  197. package/dest/spartan/utils/nodes.js +11 -11
  198. package/dest/spartan/utils/pod_logs.d.ts +25 -0
  199. package/dest/spartan/utils/pod_logs.d.ts.map +1 -0
  200. package/dest/spartan/utils/pod_logs.js +74 -0
  201. package/dest/spartan/utils/scripts.d.ts +18 -4
  202. package/dest/spartan/utils/scripts.d.ts.map +1 -1
  203. package/dest/spartan/utils/scripts.js +19 -4
  204. package/dest/test-wallet/test_wallet.d.ts +105 -0
  205. package/dest/test-wallet/test_wallet.d.ts.map +1 -0
  206. package/dest/test-wallet/test_wallet.js +323 -0
  207. package/dest/test-wallet/utils.d.ts +76 -0
  208. package/dest/test-wallet/utils.d.ts.map +1 -0
  209. package/dest/test-wallet/utils.js +126 -0
  210. package/dest/test-wallet/wallet_worker_script.d.ts +2 -0
  211. package/dest/test-wallet/wallet_worker_script.d.ts.map +1 -0
  212. package/dest/test-wallet/wallet_worker_script.js +56 -0
  213. package/dest/test-wallet/worker_wallet.d.ts +53 -0
  214. package/dest/test-wallet/worker_wallet.d.ts.map +1 -0
  215. package/dest/test-wallet/worker_wallet.js +155 -0
  216. package/dest/test-wallet/worker_wallet_schema.d.ts +4 -0
  217. package/dest/test-wallet/worker_wallet_schema.d.ts.map +1 -0
  218. package/dest/test-wallet/worker_wallet_schema.js +22 -0
  219. package/package.json +53 -46
  220. package/src/automine/README.md +60 -0
  221. package/src/automine/automine_test_context.ts +153 -0
  222. package/src/automine/contracts/fixtures/storage_proof.json +915 -0
  223. package/src/automine/contracts/fixtures/storage_proof_fetcher.ts +190 -0
  224. package/src/automine/contracts/fixtures/storage_proof_fixture.ts +173 -0
  225. package/src/automine/delivery/onchain_delivery_harness.ts +177 -0
  226. package/src/{e2e_blacklist_token_contract → automine/token}/blacklist_token_contract_test.ts +51 -61
  227. package/src/{e2e_token_contract → automine/token}/token_contract_test.ts +50 -56
  228. package/src/automine/token/token_test_helpers.ts +138 -0
  229. package/src/bench/client_flows/benchmark.ts +21 -0
  230. package/src/bench/client_flows/client_flows_benchmark.ts +104 -70
  231. package/src/bench/client_flows/config.ts +9 -1
  232. package/src/bench/client_flows/data_extractor.ts +1 -0
  233. package/src/bench/utils.ts +117 -8
  234. package/src/composed/ha/ha_full_setup.ts +466 -0
  235. package/src/fixtures/authwit_proxy.ts +54 -0
  236. package/src/fixtures/dumps/epoch_proof_result.json +1 -1
  237. package/src/fixtures/e2e_prover_test.ts +94 -95
  238. package/src/fixtures/elu_monitor.ts +126 -0
  239. package/src/fixtures/fixtures.ts +108 -0
  240. package/src/fixtures/get_bb_config.ts +7 -6
  241. package/src/fixtures/ha_setup.ts +192 -0
  242. package/src/fixtures/index.ts +2 -0
  243. package/src/fixtures/schnorr_hardcoded_account_contract.ts +49 -0
  244. package/src/fixtures/setup.ts +412 -442
  245. package/src/fixtures/setup_p2p_test.ts +39 -34
  246. package/src/fixtures/timing.ts +97 -0
  247. package/src/fixtures/token_utils.ts +42 -7
  248. package/src/fixtures/utils.ts +2 -3
  249. package/src/fixtures/wait_helpers.ts +333 -0
  250. package/src/forward-compatibility/wallet_rpc_client.ts +14 -0
  251. package/src/forward-compatibility/wallet_service.ts +106 -0
  252. package/src/guides/up_quick_start.sh +7 -4
  253. package/src/infra/README.md +12 -0
  254. package/src/install_legacy_contracts.cjs +75 -0
  255. package/src/legacy-jest-resolver.cjs +112 -0
  256. package/src/multi-node/README.md +95 -0
  257. package/src/multi-node/block-production/setup.ts +272 -0
  258. package/src/multi-node/governance/setup.ts +172 -0
  259. package/src/multi-node/multi_node_test_context.ts +447 -0
  260. package/src/multi-node/slashing/inactivity_setup.ts +139 -0
  261. package/src/multi-node/slashing/setup.ts +433 -0
  262. package/src/p2p/README.md +78 -0
  263. package/src/{e2e_p2p → p2p}/p2p_network.ts +121 -52
  264. package/src/{e2e_p2p → p2p}/reqresp/utils.ts +86 -30
  265. package/src/p2p/shared.ts +329 -0
  266. package/src/shared/cross_chain_test_harness.ts +42 -17
  267. package/src/shared/gas_portal_test_harness.ts +33 -15
  268. package/src/shared/index.ts +1 -0
  269. package/src/shared/jest_setup.ts +51 -1
  270. package/src/shared/mock_state_view.ts +188 -0
  271. package/src/shared/submit-transactions.ts +15 -6
  272. package/src/shared/timing_env.d.mts +39 -0
  273. package/src/shared/timing_env.mjs +363 -0
  274. package/src/shared/uniswap_l1_l2.ts +98 -56
  275. package/src/shared/wait_for_l1_to_l2_message.ts +23 -0
  276. package/src/simulators/lending_simulator.ts +33 -15
  277. package/src/simulators/token_simulator.ts +6 -30
  278. package/src/single-node/README.md +60 -0
  279. package/src/single-node/cross-chain/cross_chain_messaging_test.ts +302 -0
  280. package/src/single-node/cross-chain/message_test_helpers.ts +125 -0
  281. package/src/{e2e_fees → single-node/fees}/bridging_race.notest.ts +19 -5
  282. package/src/{e2e_fees → single-node/fees}/fees_test.ts +118 -89
  283. package/src/single-node/l1-reorgs/setup.ts +93 -0
  284. package/src/single-node/partial-proofs/setup.ts +8 -0
  285. package/src/single-node/proving/setup.ts +15 -0
  286. package/src/single-node/recovery/setup.ts +8 -0
  287. package/src/single-node/setup.ts +63 -0
  288. package/src/single-node/single_node_test_context.ts +1041 -0
  289. package/src/spartan/setup_test_wallets.ts +156 -36
  290. package/src/spartan/tx_metrics.ts +108 -24
  291. package/src/spartan/utils/bot.ts +4 -1
  292. package/src/spartan/utils/config.ts +3 -0
  293. package/src/spartan/utils/index.ts +8 -1
  294. package/src/spartan/utils/k8s.ts +8 -0
  295. package/src/spartan/utils/nodes.ts +17 -12
  296. package/src/spartan/utils/pod_logs.ts +99 -0
  297. package/src/spartan/utils/scripts.ts +43 -7
  298. package/src/test-wallet/test_wallet.ts +429 -0
  299. package/src/test-wallet/utils.ts +205 -0
  300. package/src/test-wallet/wallet_worker_script.ts +66 -0
  301. package/src/test-wallet/worker_wallet.ts +214 -0
  302. package/src/test-wallet/worker_wallet_schema.ts +14 -0
  303. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +0 -53
  304. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts.map +0 -1
  305. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +0 -47
  306. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts.map +0 -1
  307. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.js +0 -128
  308. package/dest/e2e_deploy_contract/deploy_test.d.ts +0 -37
  309. package/dest/e2e_deploy_contract/deploy_test.d.ts.map +0 -1
  310. package/dest/e2e_deploy_contract/deploy_test.js +0 -50
  311. package/dest/e2e_epochs/epochs_test.d.ts +0 -100
  312. package/dest/e2e_epochs/epochs_test.d.ts.map +0 -1
  313. package/dest/e2e_epochs/epochs_test.js +0 -361
  314. package/dest/e2e_fees/bridging_race.notest.d.ts.map +0 -1
  315. package/dest/e2e_fees/fees_test.d.ts +0 -88
  316. package/dest/e2e_fees/fees_test.d.ts.map +0 -1
  317. package/dest/e2e_l1_publisher/write_json.d.ts +0 -11
  318. package/dest/e2e_l1_publisher/write_json.d.ts.map +0 -1
  319. package/dest/e2e_l1_publisher/write_json.js +0 -56
  320. package/dest/e2e_multi_validator/utils.d.ts +0 -12
  321. package/dest/e2e_multi_validator/utils.d.ts.map +0 -1
  322. package/dest/e2e_nested_contract/nested_contract_test.d.ts +0 -26
  323. package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +0 -1
  324. package/dest/e2e_nested_contract/nested_contract_test.js +0 -56
  325. package/dest/e2e_p2p/inactivity_slash_test.d.ts +0 -31
  326. package/dest/e2e_p2p/inactivity_slash_test.d.ts.map +0 -1
  327. package/dest/e2e_p2p/inactivity_slash_test.js +0 -136
  328. package/dest/e2e_p2p/p2p_network.d.ts.map +0 -1
  329. package/dest/e2e_p2p/reqresp/utils.d.ts +0 -22
  330. package/dest/e2e_p2p/reqresp/utils.d.ts.map +0 -1
  331. package/dest/e2e_p2p/shared.d.ts +0 -46
  332. package/dest/e2e_p2p/shared.d.ts.map +0 -1
  333. package/dest/e2e_p2p/shared.js +0 -177
  334. package/dest/e2e_token_contract/token_contract_test.d.ts +0 -42
  335. package/dest/e2e_token_contract/token_contract_test.d.ts.map +0 -1
  336. package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +0 -194
  337. package/src/e2e_deploy_contract/deploy_test.ts +0 -85
  338. package/src/e2e_epochs/epochs_test.ts +0 -477
  339. package/src/e2e_l1_publisher/write_json.ts +0 -77
  340. package/src/e2e_nested_contract/nested_contract_test.ts +0 -73
  341. package/src/e2e_p2p/inactivity_slash_test.ts +0 -179
  342. package/src/e2e_p2p/shared.ts +0 -288
  343. /package/dest/{e2e_multi_validator/utils.js → composed/web3signer/multi_validator_keystore_utils.js} +0 -0
  344. /package/src/{e2e_multi_validator/utils.ts → composed/web3signer/multi_validator_keystore_utils.ts} +0 -0
@@ -0,0 +1,363 @@
1
+ import { appendFileSync, writeFileSync } from 'node:fs';
2
+ import { basename } from 'node:path';
3
+
4
+ import CustomEnvironment from '../../../foundation/src/jest/env.mjs';
5
+
6
+ // Per-test e2e timing environment. Gated entirely on the TEST_TIMING_FILE env var: when unset, this
7
+ // behaves exactly like the base CustomEnvironment (it only delegates). When set, it records, per test
8
+ // worker process, the time spent in jest before/after hooks and the test body, and folds in the named
9
+ // spans recorded via the `testSpan()` wrapper (fixtures/timing.ts) through a collector shared on
10
+ // `this.global`.
11
+ //
12
+ // Output is one JSONL file per worker process (the env runs once per worker). Each line carries a
13
+ // `type` discriminator and is one of:
14
+ // - `type: 'test'` (`name` set): beforeEach hooks, the it() body, afterEach hooks for one test; or
15
+ // - `type: 'suite'` (`name: null`): the suite-scoped beforeAll/afterAll hooks for the whole file.
16
+ //
17
+ // Each line also gains a `spans` map: per `category:label` tag the test/suite touched, the collector
18
+ // records `{ count, totalMs, busyMs, maxMs }`. `busyMs` is the duration of the union of the spans'
19
+ // `[start, end)` intervals on the shared `performance.now()` clock, so concurrent spans (Promise.all
20
+ // fan-out) do not inflate it the way `totalMs` does. The legacy `setupFnMs`/`teardownFnMs` fields are
21
+ // kept for back-compat, derived from the `setup:env`/`teardown:env` spans.
22
+ //
23
+ // When `TEST_TIMING_SPANS=1`, the collector additionally retains every raw span occurrence and emits
24
+ // one `type:"span"` line per occurrence (owner, name, ms) for deep dives, at the cost of a larger file.
25
+ export default class TimingEnvironment extends CustomEnvironment {
26
+ constructor(config, context) {
27
+ super(config, context);
28
+
29
+ this.timingFile = process.env.TEST_TIMING_FILE;
30
+ if (!this.timingFile) {
31
+ return;
32
+ }
33
+
34
+ this.suite = basename(context?.testPath ?? config?.testPath ?? 'unknown').replace(/\.test\.[cm]?[jt]s$/, '');
35
+ this.meta = {
36
+ commit: process.env.COMMIT_HASH ?? null,
37
+ branch: process.env.TARGET_BRANCH ?? process.env.REF_NAME ?? null,
38
+ runId: process.env.RUN_ID ?? null,
39
+ };
40
+
41
+ // Opt-in per-occurrence emission for deep dives (off by default keeps the JSONL one line per test).
42
+ this.emitSpanLines = process.env.TEST_TIMING_SPANS === '1';
43
+
44
+ // Shared collector. The instrumented helpers (running in the sandbox realm) read
45
+ // `globalThis.__e2eTimings`; this env (host realm) reads `this.global.__e2eTimings` — they are the
46
+ // same object. `current` is the full name of the test currently running (null during
47
+ // beforeAll/afterAll), used to attribute each span to a test or to the suite-scoped line. `spans`
48
+ // accumulates every recorded span until flush. The `start`/`end` timestamps come from the sandbox
49
+ // realm's `performance.now()`; Node's perf clock is process-wide (one monotonic origin across all
50
+ // realms), so merging the intervals here for `busyMs` is valid.
51
+ this.collector = { current: null, spans: [] };
52
+ this.global.__e2eTimings = this.collector;
53
+
54
+ // Records to flush as JSONL on teardown. One per test plus one suite-scoped record.
55
+ this.records = [];
56
+ this.recordsByName = new Map();
57
+ // The suite-scoped record (beforeAll/afterAll); bodyMs/totalMs are computed at flush time.
58
+ this.suiteRecord = { name: null, status: 'passed', beforeHooksMs: 0, afterHooksMs: 0 };
59
+ // Start times keyed by hook type (beforeAll/beforeEach/afterAll/afterEach).
60
+ this.hookStarts = {};
61
+ this.testStarts = new Map();
62
+ // Guards against double-flushing (we flush on both the teardown event and the teardown method).
63
+ this.flushed = false;
64
+ // Raw per-occurrence spans retained only when TEST_TIMING_SPANS=1, emitted as `type:"span"` lines.
65
+ this.rawSpans = [];
66
+ }
67
+
68
+ // Flush on the teardown method too: the jest lifecycle always calls this, whereas the 'teardown'
69
+ // event is not reliably delivered when a test run is interrupted. Whichever fires first wins.
70
+ async teardown() {
71
+ this.finalizeAndFlush();
72
+ await super.teardown();
73
+ }
74
+
75
+ async handleTestEvent(event, state) {
76
+ // Run the base env first so its unhandledRejection patching for after-hooks stays intact.
77
+ await super.handleTestEvent(event, state);
78
+
79
+ if (!this.timingFile) {
80
+ return;
81
+ }
82
+
83
+ const now = Date.now();
84
+ switch (event.name) {
85
+ case 'hook_start': {
86
+ this.hookStarts[event.hook.type] = now;
87
+ break;
88
+ }
89
+ case 'hook_success':
90
+ case 'hook_failure': {
91
+ const start = this.hookStarts[event.hook.type];
92
+ if (start === undefined) {
93
+ break;
94
+ }
95
+ delete this.hookStarts[event.hook.type];
96
+ const ms = now - start;
97
+ if (event.hook.type === 'beforeEach') {
98
+ this.addToCurrent('beforeHooksMs', ms);
99
+ } else if (event.hook.type === 'afterEach') {
100
+ this.addToCurrent('afterHooksMs', ms);
101
+ } else if (event.hook.type === 'beforeAll') {
102
+ this.suiteRecord.beforeHooksMs += ms;
103
+ } else if (event.hook.type === 'afterAll') {
104
+ this.suiteRecord.afterHooksMs += ms;
105
+ }
106
+ break;
107
+ }
108
+ case 'test_start': {
109
+ const name = this.fullTestName(event.test);
110
+ const record = {
111
+ type: 'test',
112
+ name,
113
+ status: 'passed',
114
+ setupFnMs: 0,
115
+ beforeHooksMs: 0,
116
+ bodyMs: 0,
117
+ teardownFnMs: 0,
118
+ afterHooksMs: 0,
119
+ totalMs: 0,
120
+ startedAt: new Date(now).toISOString(),
121
+ };
122
+ this.records.push(record);
123
+ this.recordsByName.set(name, record);
124
+ this.testStarts.set(name, now);
125
+ this.collector.current = name;
126
+ break;
127
+ }
128
+ case 'test_fn_start': {
129
+ this.testStarts.set(`fn:${this.fullTestName(event.test)}`, now);
130
+ break;
131
+ }
132
+ case 'test_fn_success':
133
+ case 'test_fn_failure': {
134
+ const name = this.fullTestName(event.test);
135
+ const start = this.testStarts.get(`fn:${name}`);
136
+ const record = this.recordsByName.get(name);
137
+ if (record && start !== undefined) {
138
+ record.bodyMs = now - start;
139
+ }
140
+ if (record && event.name === 'test_fn_failure') {
141
+ record.status = 'failed';
142
+ }
143
+ break;
144
+ }
145
+ case 'test_done': {
146
+ const name = this.fullTestName(event.test);
147
+ const record = this.recordsByName.get(name);
148
+ const start = this.testStarts.get(name);
149
+ if (record && start !== undefined) {
150
+ record.totalMs = now - start;
151
+ }
152
+ if (record && event.test?.errors?.length) {
153
+ record.status = 'failed';
154
+ }
155
+ this.collector.current = null;
156
+ break;
157
+ }
158
+ case 'teardown': {
159
+ this.finalizeAndFlush();
160
+ break;
161
+ }
162
+ default:
163
+ break;
164
+ }
165
+ }
166
+
167
+ /** The record for the test currently running, if any. */
168
+ currentRecord() {
169
+ return this.collector.current ? this.recordsByName.get(this.collector.current) : undefined;
170
+ }
171
+
172
+ /** Adds `ms` to a hook bucket on the current per-test record, or the suite record during beforeAll/afterAll. */
173
+ addToCurrent(field, ms) {
174
+ const record = this.currentRecord();
175
+ if (record) {
176
+ record[field] += ms;
177
+ }
178
+ }
179
+
180
+ /** Builds the full test name by walking up the describe blocks, matching jest's currentTestName. */
181
+ fullTestName(test) {
182
+ if (!test) {
183
+ return null;
184
+ }
185
+ const parts = [];
186
+ let node = test;
187
+ while (node && node.name && node.name !== 'ROOT_DESCRIBE_BLOCK') {
188
+ parts.unshift(node.name);
189
+ node = node.parent;
190
+ }
191
+ return parts.join(' ');
192
+ }
193
+
194
+ /** Folds the collected spans into the per-test / suite records via {@link foldSpansInto}, then drains the collector. */
195
+ foldSpans() {
196
+ const rawSpans = foldSpansInto(this.collector.spans, {
197
+ recordsByName: this.recordsByName,
198
+ suiteRecord: this.suiteRecord,
199
+ emitSpanLines: this.emitSpanLines,
200
+ });
201
+ this.rawSpans.push(...rawSpans);
202
+ this.collector.spans = [];
203
+ }
204
+
205
+ /** Folds spans into records, finalizes the suite-scoped record, and writes all JSONL. */
206
+ finalizeAndFlush() {
207
+ if (this.flushed || !this.timingFile) {
208
+ return;
209
+ }
210
+ this.flushed = true;
211
+ this.foldSpans();
212
+
213
+ const lines = [];
214
+ for (const record of this.records) {
215
+ lines.push(this.toLine({ ...record }));
216
+ }
217
+ lines.push(
218
+ this.toLine({
219
+ type: 'suite',
220
+ name: null,
221
+ status: 'passed',
222
+ setupFnMs: this.suiteRecord.setupFnMs ?? 0,
223
+ beforeHooksMs: this.suiteRecord.beforeHooksMs,
224
+ teardownFnMs: this.suiteRecord.teardownFnMs ?? 0,
225
+ afterHooksMs: this.suiteRecord.afterHooksMs,
226
+ totalMs: this.suiteRecord.beforeHooksMs + this.suiteRecord.afterHooksMs,
227
+ spans: this.suiteRecord.spans,
228
+ }),
229
+ );
230
+ for (const raw of this.rawSpans) {
231
+ lines.push(this.toLine({ type: 'span', name: raw.owner, span: raw.name, ms: raw.ms }));
232
+ }
233
+
234
+ const payload = lines.join('\n') + '\n';
235
+ try {
236
+ // One file per worker process, but a worker may run several suites: append so we keep them all.
237
+ appendFileSync(this.timingFile, payload);
238
+ } catch {
239
+ try {
240
+ writeFileSync(this.timingFile, payload);
241
+ } catch {
242
+ // Timing is best-effort; never fail a test because we couldn't write the file.
243
+ }
244
+ }
245
+ }
246
+
247
+ /** Flattens metadata onto a record and serializes to a single JSON line, rounding all Ms fields. */
248
+ toLine(record) {
249
+ const obj = { suite: this.suite, ...record, ...this.meta };
250
+ for (const key of Object.keys(obj)) {
251
+ if (key.endsWith('Ms') && typeof obj[key] === 'number') {
252
+ obj[key] = Math.round(obj[key]);
253
+ }
254
+ }
255
+ // Round the nested span aggregates' Ms fields too (totalMs/busyMs/maxMs per tag).
256
+ if (obj.spans && typeof obj.spans === 'object') {
257
+ for (const agg of Object.values(obj.spans)) {
258
+ for (const key of Object.keys(agg)) {
259
+ if (key.endsWith('Ms') && typeof agg[key] === 'number') {
260
+ agg[key] = Math.round(agg[key]);
261
+ }
262
+ }
263
+ }
264
+ }
265
+ return JSON.stringify(obj);
266
+ }
267
+ }
268
+
269
+ /**
270
+ * Aggregates a list of `{ start, end }` spans of one tag into `{ count, totalMs, busyMs, maxMs }`.
271
+ * `totalMs` is the naive sum of per-occurrence durations (correct for serial repeats); `busyMs` is
272
+ * the duration of the union of the `[start, end)` intervals (concurrency-correct — N concurrent
273
+ * spans collapse to their wall-clock span instead of summing to ~N×); `maxMs` is the longest single
274
+ * occurrence. All durations are on the shared process-wide `performance.now()` clock. Does not mutate
275
+ * the input array.
276
+ */
277
+ export function aggregateSpans(spans) {
278
+ let totalMs = 0;
279
+ let maxMs = 0;
280
+ for (const span of spans) {
281
+ const ms = span.end - span.start;
282
+ totalMs += ms;
283
+ if (ms > maxMs) {
284
+ maxMs = ms;
285
+ }
286
+ }
287
+ // busyMs: sort by start and merge overlapping intervals, summing the merged lengths.
288
+ const sorted = [...spans].sort((a, b) => a.start - b.start);
289
+ let busyMs = 0;
290
+ let mergeStart = null;
291
+ let mergeEnd = null;
292
+ for (const span of sorted) {
293
+ if (mergeStart === null) {
294
+ mergeStart = span.start;
295
+ mergeEnd = span.end;
296
+ } else if (span.start <= mergeEnd) {
297
+ if (span.end > mergeEnd) {
298
+ mergeEnd = span.end;
299
+ }
300
+ } else {
301
+ busyMs += mergeEnd - mergeStart;
302
+ mergeStart = span.start;
303
+ mergeEnd = span.end;
304
+ }
305
+ }
306
+ if (mergeStart !== null) {
307
+ busyMs += mergeEnd - mergeStart;
308
+ }
309
+ return { count: spans.length, totalMs, busyMs, maxMs };
310
+ }
311
+
312
+ /**
313
+ * Groups `spans` by owner, then by tag, and attaches a `spans` map of aggregates to the matching
314
+ * per-test record (looked up in `recordsByName`) or, for `null`-owner spans, to `suiteRecord`. Also
315
+ * derives the back-compat `setupFnMs` / `teardownFnMs` fields from the `setup:env:<mode>` /
316
+ * `teardown:env` aggregates (additive over any pre-existing value). Spans whose owner matches no
317
+ * record (e.g. the pinned `other:mempool-feeder` owner) are dropped. Returns the raw per-occurrence
318
+ * list (`{ owner, name, ms }`), which is empty unless `emitSpanLines` is set.
319
+ */
320
+ export function foldSpansInto(spans, { recordsByName, suiteRecord, emitSpanLines = false }) {
321
+ const rawSpans = [];
322
+ // Group by owner (null owner → suite record), then by tag.
323
+ const byOwner = new Map();
324
+ for (const span of spans) {
325
+ const owner = span.owner ?? null;
326
+ let byName = byOwner.get(owner);
327
+ if (!byName) {
328
+ byName = new Map();
329
+ byOwner.set(owner, byName);
330
+ }
331
+ let list = byName.get(span.name);
332
+ if (!list) {
333
+ list = [];
334
+ byName.set(span.name, list);
335
+ }
336
+ list.push(span);
337
+ if (emitSpanLines) {
338
+ rawSpans.push({ owner, name: span.name, ms: span.end - span.start });
339
+ }
340
+ }
341
+
342
+ for (const [owner, byName] of byOwner) {
343
+ const record = owner === null ? suiteRecord : recordsByName.get(owner);
344
+ if (!record) {
345
+ continue;
346
+ }
347
+ const aggregates = {};
348
+ for (const [name, list] of byName) {
349
+ aggregates[name] = aggregateSpans(list);
350
+ }
351
+ record.spans = aggregates;
352
+ // Back-compat: the legacy fn-span buckets are derived from the top-level env setup/teardown tags.
353
+ // The top-level setup is tagged `setup:env:<proverMode>` (the mode is a closed set, distinct from
354
+ // the `:anvil`/`:l1-deploy`/... sub-phase tags), so sum those three exact tags.
355
+ const setupFnMs =
356
+ (aggregates['setup:env:none']?.totalMs ?? 0) +
357
+ (aggregates['setup:env:fake']?.totalMs ?? 0) +
358
+ (aggregates['setup:env:real']?.totalMs ?? 0);
359
+ record.setupFnMs = setupFnMs + (record.setupFnMs ?? 0);
360
+ record.teardownFnMs = (aggregates['teardown:env']?.totalMs ?? 0) + (record.teardownFnMs ?? 0);
361
+ }
362
+ return rawSpans;
363
+ }
@@ -11,18 +11,18 @@ import type { DeployAztecL1ContractsReturnType } from '@aztec/ethereum/deploy-az
11
11
  import { deployL1Contract } from '@aztec/ethereum/deploy-l1-contract';
12
12
  import type { ExtendedViemWalletClient } from '@aztec/ethereum/types';
13
13
  import { extractEvent } from '@aztec/ethereum/utils';
14
- import { CheckpointNumber, EpochNumber } from '@aztec/foundation/branded-types';
14
+ import { EpochNumber } from '@aztec/foundation/branded-types';
15
15
  import { sha256ToField } from '@aztec/foundation/crypto/sha256';
16
+ import { retryUntil } from '@aztec/foundation/retry';
16
17
  import { InboxAbi, UniswapPortalAbi, UniswapPortalBytecode } from '@aztec/l1-artifacts';
17
18
  import { UniswapContract } from '@aztec/noir-contracts.js/Uniswap';
18
19
  import { computeL2ToL1MessageHash } from '@aztec/stdlib/hash';
19
- import { computeL2ToL1MembershipWitness } from '@aztec/stdlib/messaging';
20
- import type { TestWallet } from '@aztec/test-wallet/server';
21
20
 
22
21
  import { jest } from '@jest/globals';
23
22
  import { type GetContractReturnType, getContract, parseEther, toFunctionSelector } from 'viem';
24
23
 
25
- import { type EndToEndContext, ensureAccountContractsPublished } from '../fixtures/utils.js';
24
+ import { type EndToEndContext, ensureAuthRegistryPublished } from '../fixtures/utils.js';
25
+ import type { TestWallet } from '../test-wallet/test_wallet.js';
26
26
  import { CrossChainTestHarness } from './cross_chain_test_harness.js';
27
27
 
28
28
  // PSA: This tests works on forked mainnet. There is a dump of the data in `dumpedState` such that we
@@ -32,7 +32,7 @@ import { CrossChainTestHarness } from './cross_chain_test_harness.js';
32
32
  // anvil --fork-url https://mainnet.infura.io/v3/9928b52099854248b3a096be07a6b23c --fork-block-number 17514288 --chain-id 31337
33
33
  // For CI, this is configured in `run_tests.sh` and `docker-compose-images.yml`
34
34
 
35
- const TIMEOUT = 360_000;
35
+ const TIMEOUT = 15 * 60 * 1000;
36
36
 
37
37
  export const uniswapL1L2TestSuite = (
38
38
  setup: () => Promise<EndToEndContext>,
@@ -84,8 +84,6 @@ export const uniswapL1L2TestSuite = (
84
84
 
85
85
  l1Client = deployL1ContractsValues.l1Client;
86
86
 
87
- t.watcher?.setIsMarkingAsProven(false);
88
-
89
87
  if (Number(await l1Client.getBlockNumber()) < expectedForkBlockNumber) {
90
88
  throw new Error('This test must be run on a fork of mainnet with the expected fork block');
91
89
  }
@@ -97,7 +95,7 @@ export const uniswapL1L2TestSuite = (
97
95
  version = Number(await rollup.getVersion());
98
96
  ownerEthAddress = EthAddress.fromString((await l1Client.getAddresses())[0]);
99
97
 
100
- await ensureAccountContractsPublished(wallet, [ownerAddress, sponsorAddress]);
98
+ await ensureAuthRegistryPublished(wallet, ownerAddress);
101
99
 
102
100
  logger.info('Deploying DAI Portal, initializing and deploying l2 contract...');
103
101
  daiCrossChainHarness = await CrossChainTestHarness.new(
@@ -130,7 +128,9 @@ export const uniswapL1L2TestSuite = (
130
128
  client: l1Client,
131
129
  });
132
130
  // deploy l2 uniswap contract and attach to portal
133
- uniswapL2Contract = await UniswapContract.deploy(wallet, uniswapPortalAddress).send({ from: ownerAddress });
131
+ ({ contract: uniswapL2Contract } = await UniswapContract.deploy(wallet, uniswapPortalAddress).send({
132
+ from: ownerAddress,
133
+ }));
134
134
 
135
135
  const registryAddress = (await aztecNode.getNodeInfo()).l1ContractAddresses.registryAddress;
136
136
 
@@ -152,7 +152,6 @@ export const uniswapL1L2TestSuite = (
152
152
  await cleanup();
153
153
  });
154
154
 
155
- // docs:start:uniswap_private
156
155
  it('should uniswap trade on L1 from L2 funds privately (swaps WETH -> DAI)', async () => {
157
156
  const wethL1BeforeBalance = await wethCrossChainHarness.getL1BalanceOf(ownerEthAddress);
158
157
 
@@ -195,7 +194,7 @@ export const uniswapL1L2TestSuite = (
195
194
  logger.info('Withdrawing weth to L1 and sending message to swap to dai');
196
195
  const [secretForDepositingSwappedDai, secretHashForDepositingSwappedDai] = await generateClaimSecret();
197
196
 
198
- const l2UniswapInteractionReceipt = await uniswapL2Contract.methods
197
+ const { receipt: l2UniswapInteractionReceipt } = await uniswapL2Contract.methods
199
198
  .swap_private(
200
199
  wethCrossChainHarness.l2Token.address,
201
200
  wethCrossChainHarness.l2Bridge.address,
@@ -249,10 +248,13 @@ export const uniswapL1L2TestSuite = (
249
248
  // ensure that uniswap contract didn't eat the funds.
250
249
  await wethCrossChainHarness.expectPublicBalanceOnL2(uniswapL2Contract.address, 0n);
251
250
 
252
- // Since the outbox is only consumable when the epoch is proven, we need to advance to the next epoch.
253
- const checkpointNumber = CheckpointNumber.fromBlockNumber(l2UniswapInteractionReceipt.blockNumber!);
254
- const epoch = await rollup.getEpochNumberForCheckpoint(checkpointNumber);
255
- await cheatCodes.rollup.advanceToEpoch(EpochNumber(epoch + 1));
251
+ // Since the outbox is only consumable when the epoch is proven, we need to advance to the next epoch
252
+ // before we can ask the witness helper for a covering root.
253
+ const minedReceipt = await aztecNode.getTxReceipt(l2UniswapInteractionReceipt.txHash);
254
+ if (minedReceipt.epochNumber === undefined) {
255
+ throw new Error('L2 Uniswap interaction tx is not yet in an epoch');
256
+ }
257
+ await cheatCodes.rollup.advanceToEpoch(EpochNumber(minedReceipt.epochNumber + 1));
256
258
  await waitForProven(aztecNode, l2UniswapInteractionReceipt, { provenTimeout: 300 });
257
259
 
258
260
  // 5. Consume L2 to L1 message by calling uniswapPortal.swap_private()
@@ -260,17 +262,29 @@ export const uniswapL1L2TestSuite = (
260
262
  const daiL1BalanceOfPortalBeforeSwap = await daiCrossChainHarness.getL1BalanceOf(
261
263
  daiCrossChainHarness.tokenPortalAddress,
262
264
  );
263
- const swapResult = await computeL2ToL1MembershipWitness(aztecNode, epoch, swapPrivateLeaf);
264
- const withdrawResult = await computeL2ToL1MembershipWitness(aztecNode, epoch, withdrawLeaf);
265
+ const swapResult = await retryUntil(
266
+ () => aztecNode.getL2ToL1MembershipWitness(minedReceipt.txHash, swapPrivateLeaf),
267
+ 'swap private l2 to l1 witness',
268
+ 60,
269
+ 1,
270
+ );
271
+ const { epochNumber: epoch, numCheckpointsInEpoch } = swapResult;
272
+ const withdrawResult = await retryUntil(
273
+ () => aztecNode.getL2ToL1MembershipWitness(minedReceipt.txHash, withdrawLeaf),
274
+ 'withdraw l2 to l1 witness',
275
+ 60,
276
+ 1,
277
+ );
265
278
 
266
- const swapPrivateL2MessageIndex = swapResult!.leafIndex;
267
- const swapPrivateSiblingPath = swapResult!.siblingPath;
279
+ const swapPrivateL2MessageIndex = swapResult.leafIndex;
280
+ const swapPrivateSiblingPath = swapResult.siblingPath;
268
281
 
269
- const withdrawL2MessageIndex = withdrawResult!.leafIndex;
270
- const withdrawSiblingPath = withdrawResult!.siblingPath;
282
+ const withdrawL2MessageIndex = withdrawResult.leafIndex;
283
+ const withdrawSiblingPath = withdrawResult.siblingPath;
271
284
 
272
285
  const withdrawMessageMetadata = {
273
286
  _epoch: BigInt(epoch),
287
+ _numCheckpointsInEpoch: BigInt(withdrawResult.numCheckpointsInEpoch),
274
288
  _leafIndex: BigInt(withdrawL2MessageIndex),
275
289
  _path: withdrawSiblingPath
276
290
  .toBufferArray()
@@ -279,6 +293,7 @@ export const uniswapL1L2TestSuite = (
279
293
 
280
294
  const swapPrivateMessageMetadata = {
281
295
  _epoch: BigInt(epoch),
296
+ _numCheckpointsInEpoch: BigInt(numCheckpointsInEpoch),
282
297
  _leafIndex: BigInt(swapPrivateL2MessageIndex),
283
298
  _path: swapPrivateSiblingPath
284
299
  .toBufferArray()
@@ -336,10 +351,8 @@ export const uniswapL1L2TestSuite = (
336
351
  logger.info('WETH balance after swap : ', wethL2BalanceAfterSwap.toString());
337
352
  logger.info('DAI balance after swap : ', daiL2BalanceAfterSwap.toString());
338
353
  });
339
- // docs:end:uniswap_private
340
354
 
341
355
  // TODO(#7463): reenable look into this failure https://github.com/AztecProtocol/aztec-packages/actions/runs/9912612912/job/27388320150?pr=7462
342
- // // docs:start:uniswap_public
343
356
  // it('should uniswap trade on L1 from L2 funds publicly (swaps WETH -> DAI)', async () => {
344
357
  // const wethL1BeforeBalance = await wethCrossChainHarness.getL1BalanceOf(ownerEthAddress);
345
358
 
@@ -572,7 +585,6 @@ export const uniswapL1L2TestSuite = (
572
585
  // logger.info('WETH balance after swap : ', wethL2BalanceAfterSwap.toString());
573
586
  // logger.info('DAI balance after swap : ', daiL2BalanceAfterSwap.toString());
574
587
  // });
575
- // // docs:end:uniswap_public
576
588
 
577
589
  // Edge cases for the private flow:
578
590
  // note - tests for uniswapPortal.sol and minting asset on L2 are covered in other tests.
@@ -787,7 +799,7 @@ export const uniswapL1L2TestSuite = (
787
799
  logger.info('Withdrawing weth to L1 and sending message to swap to dai');
788
800
 
789
801
  const [, secretHashForDepositingSwappedDai] = await generateClaimSecret();
790
- const withdrawReceipt = await uniswapL2Contract.methods
802
+ const { receipt: withdrawReceipt } = await uniswapL2Contract.methods
791
803
  .swap_private(
792
804
  wethCrossChainHarness.l2Token.address,
793
805
  wethCrossChainHarness.l2Bridge.address,
@@ -838,20 +850,41 @@ export const uniswapL1L2TestSuite = (
838
850
  chainId: new Fr(l1Client.chain.id),
839
851
  });
840
852
 
841
- const epoch = await rollup.getEpochNumberForCheckpoint(
842
- CheckpointNumber.fromBlockNumber(withdrawReceipt.blockNumber!),
853
+ // ensure that user's funds were burnt
854
+ await wethCrossChainHarness.expectPrivateBalanceOnL2(ownerAddress, wethL2BalanceBeforeSwap - wethAmountToBridge);
855
+
856
+ // Since the outbox is only consumable when the epoch is proven, we need to advance to the next epoch
857
+ // before we can ask the witness helper for a covering root.
858
+ const minedReceipt = await aztecNode.getTxReceipt(withdrawReceipt.txHash);
859
+ if (minedReceipt.epochNumber === undefined) {
860
+ throw new Error('Withdraw tx is not yet in an epoch');
861
+ }
862
+ await cheatCodes.rollup.advanceToEpoch(EpochNumber(minedReceipt.epochNumber + 1));
863
+ await waitForProven(aztecNode, withdrawReceipt, { provenTimeout: 300 });
864
+
865
+ const swapResult = await retryUntil(
866
+ () => aztecNode.getL2ToL1MembershipWitness(minedReceipt.txHash, swapPrivateLeaf),
867
+ 'swap private l2 to l1 witness',
868
+ 60,
869
+ 1,
870
+ );
871
+ const { epochNumber: epoch, numCheckpointsInEpoch } = swapResult;
872
+ const withdrawResult = await retryUntil(
873
+ () => aztecNode.getL2ToL1MembershipWitness(minedReceipt.txHash, withdrawLeaf),
874
+ 'withdraw l2 to l1 witness',
875
+ 60,
876
+ 1,
843
877
  );
844
- const swapResult = await computeL2ToL1MembershipWitness(aztecNode, epoch, swapPrivateLeaf);
845
- const withdrawResult = await computeL2ToL1MembershipWitness(aztecNode, epoch, withdrawLeaf);
846
878
 
847
- const swapPrivateL2MessageIndex = swapResult!.leafIndex;
848
- const swapPrivateSiblingPath = swapResult!.siblingPath;
879
+ const swapPrivateL2MessageIndex = swapResult.leafIndex;
880
+ const swapPrivateSiblingPath = swapResult.siblingPath;
849
881
 
850
- const withdrawL2MessageIndex = withdrawResult!.leafIndex;
851
- const withdrawSiblingPath = withdrawResult!.siblingPath;
882
+ const withdrawL2MessageIndex = withdrawResult.leafIndex;
883
+ const withdrawSiblingPath = withdrawResult.siblingPath;
852
884
 
853
885
  const withdrawMessageMetadata = {
854
886
  _epoch: BigInt(epoch),
887
+ _numCheckpointsInEpoch: BigInt(withdrawResult.numCheckpointsInEpoch),
855
888
  _leafIndex: BigInt(withdrawL2MessageIndex),
856
889
  _path: withdrawSiblingPath
857
890
  .toBufferArray()
@@ -860,19 +893,13 @@ export const uniswapL1L2TestSuite = (
860
893
 
861
894
  const swapPrivateMessageMetadata = {
862
895
  _epoch: BigInt(epoch),
896
+ _numCheckpointsInEpoch: BigInt(numCheckpointsInEpoch),
863
897
  _leafIndex: BigInt(swapPrivateL2MessageIndex),
864
898
  _path: swapPrivateSiblingPath
865
899
  .toBufferArray()
866
900
  .map((buf: Buffer) => `0x${buf.toString('hex')}`) as readonly `0x${string}`[],
867
901
  };
868
902
 
869
- // ensure that user's funds were burnt
870
- await wethCrossChainHarness.expectPrivateBalanceOnL2(ownerAddress, wethL2BalanceBeforeSwap - wethAmountToBridge);
871
-
872
- // Since the outbox is only consumable when the epoch is proven, we need to advance to the next epoch.
873
- await cheatCodes.rollup.advanceToEpoch(EpochNumber(epoch + 1));
874
- await waitForProven(aztecNode, withdrawReceipt, { provenTimeout: 300 });
875
-
876
903
  // On L1 call swap_public!
877
904
  logger.info('call swap_public on L1');
878
905
  const swapArgs = [
@@ -916,7 +943,7 @@ export const uniswapL1L2TestSuite = (
916
943
 
917
944
  // Call swap_public on L2
918
945
  const secretHashForDepositingSwappedDai = Fr.random();
919
- const withdrawReceipt = await uniswapL2Contract.methods
946
+ const { receipt: withdrawReceipt } = await uniswapL2Contract.methods
920
947
  .swap_public(
921
948
  ownerAddress,
922
949
  wethCrossChainHarness.l2Bridge.address,
@@ -972,20 +999,41 @@ export const uniswapL1L2TestSuite = (
972
999
  chainId: new Fr(l1Client.chain.id),
973
1000
  });
974
1001
 
975
- const epoch = await rollup.getEpochNumberForCheckpoint(
976
- CheckpointNumber.fromBlockNumber(withdrawReceipt.blockNumber!),
1002
+ // check weth balance of owner on L2 (we first bridged `wethAmountToBridge` into L2 and now withdrew it!)
1003
+ await wethCrossChainHarness.expectPublicBalanceOnL2(ownerAddress, 0n);
1004
+
1005
+ // Since the outbox is only consumable when the epoch is proven, we need to advance to the next epoch
1006
+ // before we can ask the witness helper for a covering root.
1007
+ const minedReceipt = await aztecNode.getTxReceipt(withdrawReceipt.txHash);
1008
+ if (minedReceipt.epochNumber === undefined) {
1009
+ throw new Error('Withdraw tx is not yet in an epoch');
1010
+ }
1011
+ await cheatCodes.rollup.advanceToEpoch(EpochNumber(minedReceipt.epochNumber + 1));
1012
+ await waitForProven(aztecNode, withdrawReceipt, { provenTimeout: 300 });
1013
+
1014
+ const swapResult = await retryUntil(
1015
+ () => aztecNode.getL2ToL1MembershipWitness(minedReceipt.txHash, swapPublicLeaf),
1016
+ 'swap public l2 to l1 witness',
1017
+ 60,
1018
+ 1,
1019
+ );
1020
+ const { epochNumber: epoch, numCheckpointsInEpoch } = swapResult;
1021
+ const withdrawResult = await retryUntil(
1022
+ () => aztecNode.getL2ToL1MembershipWitness(minedReceipt.txHash, withdrawLeaf),
1023
+ 'withdraw l2 to l1 witness',
1024
+ 60,
1025
+ 1,
977
1026
  );
978
- const swapResult = await computeL2ToL1MembershipWitness(aztecNode, epoch, swapPublicLeaf);
979
- const withdrawResult = await computeL2ToL1MembershipWitness(aztecNode, epoch, withdrawLeaf);
980
1027
 
981
- const swapPublicL2MessageIndex = swapResult!.leafIndex;
982
- const swapPublicSiblingPath = swapResult!.siblingPath;
1028
+ const swapPublicL2MessageIndex = swapResult.leafIndex;
1029
+ const swapPublicSiblingPath = swapResult.siblingPath;
983
1030
 
984
- const withdrawL2MessageIndex = withdrawResult!.leafIndex;
985
- const withdrawSiblingPath = withdrawResult!.siblingPath;
1031
+ const withdrawL2MessageIndex = withdrawResult.leafIndex;
1032
+ const withdrawSiblingPath = withdrawResult.siblingPath;
986
1033
 
987
1034
  const withdrawMessageMetadata = {
988
1035
  _epoch: BigInt(epoch),
1036
+ _numCheckpointsInEpoch: BigInt(withdrawResult.numCheckpointsInEpoch),
989
1037
  _leafIndex: BigInt(withdrawL2MessageIndex),
990
1038
  _path: withdrawSiblingPath
991
1039
  .toBufferArray()
@@ -994,19 +1042,13 @@ export const uniswapL1L2TestSuite = (
994
1042
 
995
1043
  const swapPublicMessageMetadata = {
996
1044
  _epoch: BigInt(epoch),
1045
+ _numCheckpointsInEpoch: BigInt(numCheckpointsInEpoch),
997
1046
  _leafIndex: BigInt(swapPublicL2MessageIndex),
998
1047
  _path: swapPublicSiblingPath
999
1048
  .toBufferArray()
1000
1049
  .map((buf: Buffer) => `0x${buf.toString('hex')}`) as readonly `0x${string}`[],
1001
1050
  };
1002
1051
 
1003
- // check weth balance of owner on L2 (we first bridged `wethAmountToBridge` into L2 and now withdrew it!)
1004
- await wethCrossChainHarness.expectPublicBalanceOnL2(ownerAddress, 0n);
1005
-
1006
- // Since the outbox is only consumable when the epoch is proven, we need to advance to the next epoch.
1007
- await cheatCodes.rollup.advanceToEpoch(EpochNumber(epoch + 1));
1008
- await waitForProven(aztecNode, withdrawReceipt, { provenTimeout: 300 });
1009
-
1010
1052
  // Call swap_private on L1
1011
1053
  logger.info('Execute withdraw and swap on the uniswapPortal!');
1012
1054