@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
@@ -0,0 +1,365 @@
1
+ import { appendFileSync, writeFileSync } from 'node:fs';
2
+ import { basename } from 'node:path';
3
+ import CustomEnvironment from '../../../foundation/src/jest/env.mjs';
4
+ // Per-test e2e timing environment. Gated entirely on the TEST_TIMING_FILE env var: when unset, this
5
+ // behaves exactly like the base CustomEnvironment (it only delegates). When set, it records, per test
6
+ // worker process, the time spent in jest before/after hooks and the test body, and folds in the named
7
+ // spans recorded via the `testSpan()` wrapper (fixtures/timing.ts) through a collector shared on
8
+ // `this.global`.
9
+ //
10
+ // Output is one JSONL file per worker process (the env runs once per worker). Each line carries a
11
+ // `type` discriminator and is one of:
12
+ // - `type: 'test'` (`name` set): beforeEach hooks, the it() body, afterEach hooks for one test; or
13
+ // - `type: 'suite'` (`name: null`): the suite-scoped beforeAll/afterAll hooks for the whole file.
14
+ //
15
+ // Each line also gains a `spans` map: per `category:label` tag the test/suite touched, the collector
16
+ // records `{ count, totalMs, busyMs, maxMs }`. `busyMs` is the duration of the union of the spans'
17
+ // `[start, end)` intervals on the shared `performance.now()` clock, so concurrent spans (Promise.all
18
+ // fan-out) do not inflate it the way `totalMs` does. The legacy `setupFnMs`/`teardownFnMs` fields are
19
+ // kept for back-compat, derived from the `setup:env`/`teardown:env` spans.
20
+ //
21
+ // When `TEST_TIMING_SPANS=1`, the collector additionally retains every raw span occurrence and emits
22
+ // one `type:"span"` line per occurrence (owner, name, ms) for deep dives, at the cost of a larger file.
23
+ export default class TimingEnvironment extends CustomEnvironment {
24
+ constructor(config, context){
25
+ super(config, context);
26
+ this.timingFile = process.env.TEST_TIMING_FILE;
27
+ if (!this.timingFile) {
28
+ return;
29
+ }
30
+ this.suite = basename(context?.testPath ?? config?.testPath ?? 'unknown').replace(/\.test\.[cm]?[jt]s$/, '');
31
+ this.meta = {
32
+ commit: process.env.COMMIT_HASH ?? null,
33
+ branch: process.env.TARGET_BRANCH ?? process.env.REF_NAME ?? null,
34
+ runId: process.env.RUN_ID ?? null
35
+ };
36
+ // Opt-in per-occurrence emission for deep dives (off by default keeps the JSONL one line per test).
37
+ this.emitSpanLines = process.env.TEST_TIMING_SPANS === '1';
38
+ // Shared collector. The instrumented helpers (running in the sandbox realm) read
39
+ // `globalThis.__e2eTimings`; this env (host realm) reads `this.global.__e2eTimings` — they are the
40
+ // same object. `current` is the full name of the test currently running (null during
41
+ // beforeAll/afterAll), used to attribute each span to a test or to the suite-scoped line. `spans`
42
+ // accumulates every recorded span until flush. The `start`/`end` timestamps come from the sandbox
43
+ // realm's `performance.now()`; Node's perf clock is process-wide (one monotonic origin across all
44
+ // realms), so merging the intervals here for `busyMs` is valid.
45
+ this.collector = {
46
+ current: null,
47
+ spans: []
48
+ };
49
+ this.global.__e2eTimings = this.collector;
50
+ // Records to flush as JSONL on teardown. One per test plus one suite-scoped record.
51
+ this.records = [];
52
+ this.recordsByName = new Map();
53
+ // The suite-scoped record (beforeAll/afterAll); bodyMs/totalMs are computed at flush time.
54
+ this.suiteRecord = {
55
+ name: null,
56
+ status: 'passed',
57
+ beforeHooksMs: 0,
58
+ afterHooksMs: 0
59
+ };
60
+ // Start times keyed by hook type (beforeAll/beforeEach/afterAll/afterEach).
61
+ this.hookStarts = {};
62
+ this.testStarts = new Map();
63
+ // Guards against double-flushing (we flush on both the teardown event and the teardown method).
64
+ this.flushed = false;
65
+ // Raw per-occurrence spans retained only when TEST_TIMING_SPANS=1, emitted as `type:"span"` lines.
66
+ this.rawSpans = [];
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
+ async handleTestEvent(event, state) {
75
+ // Run the base env first so its unhandledRejection patching for after-hooks stays intact.
76
+ await super.handleTestEvent(event, state);
77
+ if (!this.timingFile) {
78
+ return;
79
+ }
80
+ const now = Date.now();
81
+ switch(event.name){
82
+ case 'hook_start':
83
+ {
84
+ this.hookStarts[event.hook.type] = now;
85
+ break;
86
+ }
87
+ case 'hook_success':
88
+ case 'hook_failure':
89
+ {
90
+ const start = this.hookStarts[event.hook.type];
91
+ if (start === undefined) {
92
+ break;
93
+ }
94
+ delete this.hookStarts[event.hook.type];
95
+ const ms = now - start;
96
+ if (event.hook.type === 'beforeEach') {
97
+ this.addToCurrent('beforeHooksMs', ms);
98
+ } else if (event.hook.type === 'afterEach') {
99
+ this.addToCurrent('afterHooksMs', ms);
100
+ } else if (event.hook.type === 'beforeAll') {
101
+ this.suiteRecord.beforeHooksMs += ms;
102
+ } else if (event.hook.type === 'afterAll') {
103
+ this.suiteRecord.afterHooksMs += ms;
104
+ }
105
+ break;
106
+ }
107
+ case 'test_start':
108
+ {
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
+ {
130
+ this.testStarts.set(`fn:${this.fullTestName(event.test)}`, now);
131
+ break;
132
+ }
133
+ case 'test_fn_success':
134
+ case 'test_fn_failure':
135
+ {
136
+ const name = this.fullTestName(event.test);
137
+ const start = this.testStarts.get(`fn:${name}`);
138
+ const record = this.recordsByName.get(name);
139
+ if (record && start !== undefined) {
140
+ record.bodyMs = now - start;
141
+ }
142
+ if (record && event.name === 'test_fn_failure') {
143
+ record.status = 'failed';
144
+ }
145
+ break;
146
+ }
147
+ case 'test_done':
148
+ {
149
+ const name = this.fullTestName(event.test);
150
+ const record = this.recordsByName.get(name);
151
+ const start = this.testStarts.get(name);
152
+ if (record && start !== undefined) {
153
+ record.totalMs = now - start;
154
+ }
155
+ if (record && event.test?.errors?.length) {
156
+ record.status = 'failed';
157
+ }
158
+ this.collector.current = null;
159
+ break;
160
+ }
161
+ case 'teardown':
162
+ {
163
+ this.finalizeAndFlush();
164
+ break;
165
+ }
166
+ default:
167
+ break;
168
+ }
169
+ }
170
+ /** The record for the test currently running, if any. */ currentRecord() {
171
+ return this.collector.current ? this.recordsByName.get(this.collector.current) : undefined;
172
+ }
173
+ /** Adds `ms` to a hook bucket on the current per-test record, or the suite record during beforeAll/afterAll. */ addToCurrent(field, ms) {
174
+ const record = this.currentRecord();
175
+ if (record) {
176
+ record[field] += ms;
177
+ }
178
+ }
179
+ /** Builds the full test name by walking up the describe blocks, matching jest's currentTestName. */ fullTestName(test) {
180
+ if (!test) {
181
+ return null;
182
+ }
183
+ const parts = [];
184
+ let node = test;
185
+ while(node && node.name && node.name !== 'ROOT_DESCRIBE_BLOCK'){
186
+ parts.unshift(node.name);
187
+ node = node.parent;
188
+ }
189
+ return parts.join(' ');
190
+ }
191
+ /** Folds the collected spans into the per-test / suite records via {@link foldSpansInto}, then drains the collector. */ foldSpans() {
192
+ const rawSpans = foldSpansInto(this.collector.spans, {
193
+ recordsByName: this.recordsByName,
194
+ suiteRecord: this.suiteRecord,
195
+ emitSpanLines: this.emitSpanLines
196
+ });
197
+ this.rawSpans.push(...rawSpans);
198
+ this.collector.spans = [];
199
+ }
200
+ /** Folds spans into records, finalizes the suite-scoped record, and writes all JSONL. */ finalizeAndFlush() {
201
+ if (this.flushed || !this.timingFile) {
202
+ return;
203
+ }
204
+ this.flushed = true;
205
+ this.foldSpans();
206
+ const lines = [];
207
+ for (const record of this.records){
208
+ lines.push(this.toLine({
209
+ ...record
210
+ }));
211
+ }
212
+ lines.push(this.toLine({
213
+ type: 'suite',
214
+ name: null,
215
+ status: 'passed',
216
+ setupFnMs: this.suiteRecord.setupFnMs ?? 0,
217
+ beforeHooksMs: this.suiteRecord.beforeHooksMs,
218
+ teardownFnMs: this.suiteRecord.teardownFnMs ?? 0,
219
+ afterHooksMs: this.suiteRecord.afterHooksMs,
220
+ totalMs: this.suiteRecord.beforeHooksMs + this.suiteRecord.afterHooksMs,
221
+ spans: this.suiteRecord.spans
222
+ }));
223
+ for (const raw of this.rawSpans){
224
+ lines.push(this.toLine({
225
+ type: 'span',
226
+ name: raw.owner,
227
+ span: raw.name,
228
+ ms: raw.ms
229
+ }));
230
+ }
231
+ const payload = lines.join('\n') + '\n';
232
+ try {
233
+ // One file per worker process, but a worker may run several suites: append so we keep them all.
234
+ appendFileSync(this.timingFile, payload);
235
+ } catch {
236
+ try {
237
+ writeFileSync(this.timingFile, payload);
238
+ } catch {
239
+ // Timing is best-effort; never fail a test because we couldn't write the file.
240
+ }
241
+ }
242
+ }
243
+ /** Flattens metadata onto a record and serializes to a single JSON line, rounding all Ms fields. */ toLine(record) {
244
+ const obj = {
245
+ suite: this.suite,
246
+ ...record,
247
+ ...this.meta
248
+ };
249
+ for (const key of Object.keys(obj)){
250
+ if (key.endsWith('Ms') && typeof obj[key] === 'number') {
251
+ obj[key] = Math.round(obj[key]);
252
+ }
253
+ }
254
+ // Round the nested span aggregates' Ms fields too (totalMs/busyMs/maxMs per tag).
255
+ if (obj.spans && typeof obj.spans === 'object') {
256
+ for (const agg of Object.values(obj.spans)){
257
+ for (const key of Object.keys(agg)){
258
+ if (key.endsWith('Ms') && typeof agg[key] === 'number') {
259
+ agg[key] = Math.round(agg[key]);
260
+ }
261
+ }
262
+ }
263
+ }
264
+ return JSON.stringify(obj);
265
+ }
266
+ }
267
+ /**
268
+ * Aggregates a list of `{ start, end }` spans of one tag into `{ count, totalMs, busyMs, maxMs }`.
269
+ * `totalMs` is the naive sum of per-occurrence durations (correct for serial repeats); `busyMs` is
270
+ * the duration of the union of the `[start, end)` intervals (concurrency-correct — N concurrent
271
+ * spans collapse to their wall-clock span instead of summing to ~N×); `maxMs` is the longest single
272
+ * occurrence. All durations are on the shared process-wide `performance.now()` clock. Does not mutate
273
+ * the input array.
274
+ */ export function aggregateSpans(spans) {
275
+ let totalMs = 0;
276
+ let maxMs = 0;
277
+ for (const span of spans){
278
+ const ms = span.end - span.start;
279
+ totalMs += ms;
280
+ if (ms > maxMs) {
281
+ maxMs = ms;
282
+ }
283
+ }
284
+ // busyMs: sort by start and merge overlapping intervals, summing the merged lengths.
285
+ const sorted = [
286
+ ...spans
287
+ ].sort((a, b)=>a.start - b.start);
288
+ let busyMs = 0;
289
+ let mergeStart = null;
290
+ let mergeEnd = null;
291
+ for (const span of sorted){
292
+ if (mergeStart === null) {
293
+ mergeStart = span.start;
294
+ mergeEnd = span.end;
295
+ } else if (span.start <= mergeEnd) {
296
+ if (span.end > mergeEnd) {
297
+ mergeEnd = span.end;
298
+ }
299
+ } else {
300
+ busyMs += mergeEnd - mergeStart;
301
+ mergeStart = span.start;
302
+ mergeEnd = span.end;
303
+ }
304
+ }
305
+ if (mergeStart !== null) {
306
+ busyMs += mergeEnd - mergeStart;
307
+ }
308
+ return {
309
+ count: spans.length,
310
+ totalMs,
311
+ busyMs,
312
+ maxMs
313
+ };
314
+ }
315
+ /**
316
+ * Groups `spans` by owner, then by tag, and attaches a `spans` map of aggregates to the matching
317
+ * per-test record (looked up in `recordsByName`) or, for `null`-owner spans, to `suiteRecord`. Also
318
+ * derives the back-compat `setupFnMs` / `teardownFnMs` fields from the `setup:env:<mode>` /
319
+ * `teardown:env` aggregates (additive over any pre-existing value). Spans whose owner matches no
320
+ * record (e.g. the pinned `other:mempool-feeder` owner) are dropped. Returns the raw per-occurrence
321
+ * list (`{ owner, name, ms }`), which is empty unless `emitSpanLines` is set.
322
+ */ export function foldSpansInto(spans, { recordsByName, suiteRecord, emitSpanLines = false }) {
323
+ const rawSpans = [];
324
+ // Group by owner (null owner → suite record), then by tag.
325
+ const byOwner = new Map();
326
+ for (const span of spans){
327
+ const owner = span.owner ?? null;
328
+ let byName = byOwner.get(owner);
329
+ if (!byName) {
330
+ byName = new Map();
331
+ byOwner.set(owner, byName);
332
+ }
333
+ let list = byName.get(span.name);
334
+ if (!list) {
335
+ list = [];
336
+ byName.set(span.name, list);
337
+ }
338
+ list.push(span);
339
+ if (emitSpanLines) {
340
+ rawSpans.push({
341
+ owner,
342
+ name: span.name,
343
+ ms: span.end - span.start
344
+ });
345
+ }
346
+ }
347
+ for (const [owner, byName] of byOwner){
348
+ const record = owner === null ? suiteRecord : recordsByName.get(owner);
349
+ if (!record) {
350
+ continue;
351
+ }
352
+ const aggregates = {};
353
+ for (const [name, list] of byName){
354
+ aggregates[name] = aggregateSpans(list);
355
+ }
356
+ record.spans = aggregates;
357
+ // Back-compat: the legacy fn-span buckets are derived from the top-level env setup/teardown tags.
358
+ // The top-level setup is tagged `setup:env:<proverMode>` (the mode is a closed set, distinct from
359
+ // the `:anvil`/`:l1-deploy`/... sub-phase tags), so sum those three exact tags.
360
+ const setupFnMs = (aggregates['setup:env:none']?.totalMs ?? 0) + (aggregates['setup:env:fake']?.totalMs ?? 0) + (aggregates['setup:env:real']?.totalMs ?? 0);
361
+ record.setupFnMs = setupFnMs + (record.setupFnMs ?? 0);
362
+ record.teardownFnMs = (aggregates['teardown:env']?.totalMs ?? 0) + (record.teardownFnMs ?? 0);
363
+ }
364
+ return rawSpans;
365
+ }
@@ -1,3 +1,3 @@
1
1
  import { type EndToEndContext } from '../fixtures/utils.js';
2
2
  export declare const uniswapL1L2TestSuite: (setup: () => Promise<EndToEndContext>, cleanup: () => Promise<void>, expectedForkBlockNumber?: number) => void;
3
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidW5pc3dhcF9sMV9sMi5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3NoYXJlZC91bmlzd2FwX2wxX2wyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQXVCQSxPQUFPLEVBQUUsS0FBSyxlQUFlLEVBQW1DLE1BQU0sc0JBQXNCLENBQUM7QUFhN0YsZUFBTyxNQUFNLG9CQUFvQixpSEFnK0JoQyxDQUFDIn0=
3
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidW5pc3dhcF9sMV9sMi5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3NoYXJlZC91bmlzd2FwX2wxX2wyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQXVCQSxPQUFPLEVBQUUsS0FBSyxlQUFlLEVBQStCLE1BQU0sc0JBQXNCLENBQUM7QUFhekYsZUFBTyxNQUFNLG9CQUFvQixpSEE0Z0NoQyxDQUFDIn0=
@@ -1 +1 @@
1
- {"version":3,"file":"uniswap_l1_l2.d.ts","sourceRoot":"","sources":["../../src/shared/uniswap_l1_l2.ts"],"names":[],"mappings":"AAuBA,OAAO,EAAE,KAAK,eAAe,EAAmC,MAAM,sBAAsB,CAAC;AAa7F,eAAO,MAAM,oBAAoB,iHAg+BhC,CAAC"}
1
+ {"version":3,"file":"uniswap_l1_l2.d.ts","sourceRoot":"","sources":["../../src/shared/uniswap_l1_l2.ts"],"names":[],"mappings":"AAuBA,OAAO,EAAE,KAAK,eAAe,EAA+B,MAAM,sBAAsB,CAAC;AAazF,eAAO,MAAM,oBAAoB,iHA4gChC,CAAC"}
@@ -8,13 +8,13 @@ import { deployL1Contract } from '@aztec/ethereum/deploy-l1-contract';
8
8
  import { extractEvent } from '@aztec/ethereum/utils';
9
9
  import { EpochNumber } from '@aztec/foundation/branded-types';
10
10
  import { sha256ToField } from '@aztec/foundation/crypto/sha256';
11
+ import { retryUntil } from '@aztec/foundation/retry';
11
12
  import { InboxAbi, UniswapPortalAbi, UniswapPortalBytecode } from '@aztec/l1-artifacts';
12
13
  import { UniswapContract } from '@aztec/noir-contracts.js/Uniswap';
13
14
  import { computeL2ToL1MessageHash } from '@aztec/stdlib/hash';
14
- import { computeL2ToL1MembershipWitness } from '@aztec/stdlib/messaging';
15
15
  import { jest } from '@jest/globals';
16
16
  import { getContract, parseEther, toFunctionSelector } from 'viem';
17
- import { ensureAccountContractsPublished } from '../fixtures/utils.js';
17
+ import { ensureAuthRegistryPublished } from '../fixtures/utils.js';
18
18
  import { CrossChainTestHarness } from './cross_chain_test_harness.js';
19
19
  // PSA: This tests works on forked mainnet. There is a dump of the data in `dumpedState` such that we
20
20
  // don't need to burn through RPC requests.
@@ -22,7 +22,7 @@ import { CrossChainTestHarness } from './cross_chain_test_harness.js';
22
22
  // To start an actual fork, use the command:
23
23
  // anvil --fork-url https://mainnet.infura.io/v3/9928b52099854248b3a096be07a6b23c --fork-block-number 17514288 --chain-id 31337
24
24
  // For CI, this is configured in `run_tests.sh` and `docker-compose-images.yml`
25
- const TIMEOUT = 360_000;
25
+ const TIMEOUT = 15 * 60 * 1000;
26
26
  export const uniswapL1L2TestSuite = (setup, cleanup, expectedForkBlockNumber = 17514288)=>{
27
27
  describe('uniswap_trade_on_l1_from_l2', ()=>{
28
28
  jest.setTimeout(TIMEOUT);
@@ -52,17 +52,13 @@ export const uniswapL1L2TestSuite = (setup, cleanup, expectedForkBlockNumber = 1
52
52
  const t = await setup();
53
53
  ({ aztecNode, logger, deployL1ContractsValues, cheatCodes, wallet, accounts: [ownerAddress, sponsorAddress] } = t);
54
54
  l1Client = deployL1ContractsValues.l1Client;
55
- t.watcher.setIsMarkingAsProven(false);
56
55
  if (Number(await l1Client.getBlockNumber()) < expectedForkBlockNumber) {
57
56
  throw new Error('This test must be run on a fork of mainnet with the expected fork block');
58
57
  }
59
58
  rollup = new RollupContract(deployL1ContractsValues.l1Client, deployL1ContractsValues.l1ContractAddresses.rollupAddress);
60
59
  version = Number(await rollup.getVersion());
61
60
  ownerEthAddress = EthAddress.fromString((await l1Client.getAddresses())[0]);
62
- await ensureAccountContractsPublished(wallet, [
63
- ownerAddress,
64
- sponsorAddress
65
- ]);
61
+ await ensureAuthRegistryPublished(wallet, ownerAddress);
66
62
  logger.info('Deploying DAI Portal, initializing and deploying l2 contract...');
67
63
  daiCrossChainHarness = await CrossChainTestHarness.new(aztecNode, deployL1ContractsValues.l1Client, wallet, ownerAddress, logger, DAI_ADDRESS);
68
64
  logger.info('Deploying WETH Portal, initializing and deploying l2 contract...');
@@ -75,9 +71,9 @@ export const uniswapL1L2TestSuite = (setup, cleanup, expectedForkBlockNumber = 1
75
71
  client: l1Client
76
72
  });
77
73
  // deploy l2 uniswap contract and attach to portal
78
- uniswapL2Contract = await UniswapContract.deploy(wallet, uniswapPortalAddress).send({
74
+ ({ contract: uniswapL2Contract } = await UniswapContract.deploy(wallet, uniswapPortalAddress).send({
79
75
  from: ownerAddress
80
- });
76
+ }));
81
77
  const registryAddress = (await aztecNode.getNodeInfo()).l1ContractAddresses.registryAddress;
82
78
  await uniswapPortal.write.initialize([
83
79
  registryAddress.toString(),
@@ -98,7 +94,6 @@ export const uniswapL1L2TestSuite = (setup, cleanup, expectedForkBlockNumber = 1
98
94
  afterAll(async ()=>{
99
95
  await cleanup();
100
96
  });
101
- // docs:start:uniswap_private
102
97
  it('should uniswap trade on L1 from L2 funds privately (swaps WETH -> DAI)', async ()=>{
103
98
  const wethL1BeforeBalance = await wethCrossChainHarness.getL1BalanceOf(ownerEthAddress);
104
99
  // 1. Approve and deposit weth to the portal and move to L2
@@ -124,7 +119,7 @@ export const uniswapL1L2TestSuite = (setup, cleanup, expectedForkBlockNumber = 1
124
119
  // 4. Swap on L1 - sends L2 to L1 message to withdraw WETH to L1 and another message to swap assets.
125
120
  logger.info('Withdrawing weth to L1 and sending message to swap to dai');
126
121
  const [secretForDepositingSwappedDai, secretHashForDepositingSwappedDai] = await generateClaimSecret();
127
- const l2UniswapInteractionReceipt = await uniswapL2Contract.methods.swap_private(wethCrossChainHarness.l2Token.address, wethCrossChainHarness.l2Bridge.address, wethAmountToBridge, daiCrossChainHarness.l2Bridge.address, nonceForWETHTransferToPublicApproval, uniswapFeeTier, minimumOutputAmount, secretHashForDepositingSwappedDai, ownerEthAddress).send({
122
+ const { receipt: l2UniswapInteractionReceipt } = await uniswapL2Contract.methods.swap_private(wethCrossChainHarness.l2Token.address, wethCrossChainHarness.l2Bridge.address, wethAmountToBridge, daiCrossChainHarness.l2Bridge.address, nonceForWETHTransferToPublicApproval, uniswapFeeTier, minimumOutputAmount, secretHashForDepositingSwappedDai, ownerEthAddress).send({
128
123
  from: ownerAddress,
129
124
  authWitnesses: [
130
125
  transferToPublicAuhtwit
@@ -165,29 +160,35 @@ export const uniswapL1L2TestSuite = (setup, cleanup, expectedForkBlockNumber = 1
165
160
  await wethCrossChainHarness.expectPrivateBalanceOnL2(ownerAddress, wethL2BalanceBeforeSwap - wethAmountToBridge);
166
161
  // ensure that uniswap contract didn't eat the funds.
167
162
  await wethCrossChainHarness.expectPublicBalanceOnL2(uniswapL2Contract.address, 0n);
168
- // Since the outbox is only consumable when the epoch is proven, we need to advance to the next epoch.
169
- const block = await aztecNode.getBlock(l2UniswapInteractionReceipt.blockNumber);
170
- const epoch = await rollup.getEpochNumberForCheckpoint(block.checkpointNumber);
171
- await cheatCodes.rollup.advanceToEpoch(EpochNumber(epoch + 1));
163
+ // Since the outbox is only consumable when the epoch is proven, we need to advance to the next epoch
164
+ // before we can ask the witness helper for a covering root.
165
+ const minedReceipt = await aztecNode.getTxReceipt(l2UniswapInteractionReceipt.txHash);
166
+ if (minedReceipt.epochNumber === undefined) {
167
+ throw new Error('L2 Uniswap interaction tx is not yet in an epoch');
168
+ }
169
+ await cheatCodes.rollup.advanceToEpoch(EpochNumber(minedReceipt.epochNumber + 1));
172
170
  await waitForProven(aztecNode, l2UniswapInteractionReceipt, {
173
171
  provenTimeout: 300
174
172
  });
175
173
  // 5. Consume L2 to L1 message by calling uniswapPortal.swap_private()
176
174
  logger.info('Execute withdraw and swap on the uniswapPortal!');
177
175
  const daiL1BalanceOfPortalBeforeSwap = await daiCrossChainHarness.getL1BalanceOf(daiCrossChainHarness.tokenPortalAddress);
178
- const swapResult = await computeL2ToL1MembershipWitness(aztecNode, epoch, swapPrivateLeaf);
179
- const withdrawResult = await computeL2ToL1MembershipWitness(aztecNode, epoch, withdrawLeaf);
176
+ const swapResult = await retryUntil(()=>aztecNode.getL2ToL1MembershipWitness(minedReceipt.txHash, swapPrivateLeaf), 'swap private l2 to l1 witness', 60, 1);
177
+ const { epochNumber: epoch, numCheckpointsInEpoch } = swapResult;
178
+ const withdrawResult = await retryUntil(()=>aztecNode.getL2ToL1MembershipWitness(minedReceipt.txHash, withdrawLeaf), 'withdraw l2 to l1 witness', 60, 1);
180
179
  const swapPrivateL2MessageIndex = swapResult.leafIndex;
181
180
  const swapPrivateSiblingPath = swapResult.siblingPath;
182
181
  const withdrawL2MessageIndex = withdrawResult.leafIndex;
183
182
  const withdrawSiblingPath = withdrawResult.siblingPath;
184
183
  const withdrawMessageMetadata = {
185
184
  _epoch: BigInt(epoch),
185
+ _numCheckpointsInEpoch: BigInt(withdrawResult.numCheckpointsInEpoch),
186
186
  _leafIndex: BigInt(withdrawL2MessageIndex),
187
187
  _path: withdrawSiblingPath.toBufferArray().map((buf)=>`0x${buf.toString('hex')}`)
188
188
  };
189
189
  const swapPrivateMessageMetadata = {
190
190
  _epoch: BigInt(epoch),
191
+ _numCheckpointsInEpoch: BigInt(numCheckpointsInEpoch),
191
192
  _leafIndex: BigInt(swapPrivateL2MessageIndex),
192
193
  _path: swapPrivateSiblingPath.toBufferArray().map((buf)=>`0x${buf.toString('hex')}`)
193
194
  };
@@ -236,9 +237,7 @@ export const uniswapL1L2TestSuite = (setup, cleanup, expectedForkBlockNumber = 1
236
237
  logger.info('WETH balance after swap : ', wethL2BalanceAfterSwap.toString());
237
238
  logger.info('DAI balance after swap : ', daiL2BalanceAfterSwap.toString());
238
239
  });
239
- // docs:end:uniswap_private
240
240
  // TODO(#7463): reenable look into this failure https://github.com/AztecProtocol/aztec-packages/actions/runs/9912612912/job/27388320150?pr=7462
241
- // // docs:start:uniswap_public
242
241
  // it('should uniswap trade on L1 from L2 funds publicly (swaps WETH -> DAI)', async () => {
243
242
  // const wethL1BeforeBalance = await wethCrossChainHarness.getL1BalanceOf(ownerEthAddress);
244
243
  // // 1. Approve and deposit weth to the portal and move to L2
@@ -441,7 +440,6 @@ export const uniswapL1L2TestSuite = (setup, cleanup, expectedForkBlockNumber = 1
441
440
  // logger.info('WETH balance after swap : ', wethL2BalanceAfterSwap.toString());
442
441
  // logger.info('DAI balance after swap : ', daiL2BalanceAfterSwap.toString());
443
442
  // });
444
- // // docs:end:uniswap_public
445
443
  // Edge cases for the private flow:
446
444
  // note - tests for uniswapPortal.sol and minting asset on L2 are covered in other tests.
447
445
  it('swap_private reverts without transfer to public approval', async ()=>{
@@ -538,7 +536,7 @@ export const uniswapL1L2TestSuite = (setup, cleanup, expectedForkBlockNumber = 1
538
536
  // Swap
539
537
  logger.info('Withdrawing weth to L1 and sending message to swap to dai');
540
538
  const [, secretHashForDepositingSwappedDai] = await generateClaimSecret();
541
- const withdrawReceipt = await uniswapL2Contract.methods.swap_private(wethCrossChainHarness.l2Token.address, wethCrossChainHarness.l2Bridge.address, wethAmountToBridge, daiCrossChainHarness.l2Bridge.address, nonceForWETHTransferToPublicApproval, uniswapFeeTier, minimumOutputAmount, secretHashForDepositingSwappedDai, ownerEthAddress).send({
539
+ const { receipt: withdrawReceipt } = await uniswapL2Contract.methods.swap_private(wethCrossChainHarness.l2Token.address, wethCrossChainHarness.l2Bridge.address, wethAmountToBridge, daiCrossChainHarness.l2Bridge.address, nonceForWETHTransferToPublicApproval, uniswapFeeTier, minimumOutputAmount, secretHashForDepositingSwappedDai, ownerEthAddress).send({
542
540
  from: ownerAddress,
543
541
  authWitnesses: [
544
542
  transferToPublicAuhtwit
@@ -574,31 +572,37 @@ export const uniswapL1L2TestSuite = (setup, cleanup, expectedForkBlockNumber = 1
574
572
  rollupVersion: new Fr(version),
575
573
  chainId: new Fr(l1Client.chain.id)
576
574
  });
577
- const block = await aztecNode.getBlock(withdrawReceipt.blockNumber);
578
- const epoch = await rollup.getEpochNumberForCheckpoint(block.checkpointNumber);
579
- const swapResult = await computeL2ToL1MembershipWitness(aztecNode, epoch, swapPrivateLeaf);
580
- const withdrawResult = await computeL2ToL1MembershipWitness(aztecNode, epoch, withdrawLeaf);
575
+ // ensure that user's funds were burnt
576
+ await wethCrossChainHarness.expectPrivateBalanceOnL2(ownerAddress, wethL2BalanceBeforeSwap - wethAmountToBridge);
577
+ // Since the outbox is only consumable when the epoch is proven, we need to advance to the next epoch
578
+ // before we can ask the witness helper for a covering root.
579
+ const minedReceipt = await aztecNode.getTxReceipt(withdrawReceipt.txHash);
580
+ if (minedReceipt.epochNumber === undefined) {
581
+ throw new Error('Withdraw tx is not yet in an epoch');
582
+ }
583
+ await cheatCodes.rollup.advanceToEpoch(EpochNumber(minedReceipt.epochNumber + 1));
584
+ await waitForProven(aztecNode, withdrawReceipt, {
585
+ provenTimeout: 300
586
+ });
587
+ const swapResult = await retryUntil(()=>aztecNode.getL2ToL1MembershipWitness(minedReceipt.txHash, swapPrivateLeaf), 'swap private l2 to l1 witness', 60, 1);
588
+ const { epochNumber: epoch, numCheckpointsInEpoch } = swapResult;
589
+ const withdrawResult = await retryUntil(()=>aztecNode.getL2ToL1MembershipWitness(minedReceipt.txHash, withdrawLeaf), 'withdraw l2 to l1 witness', 60, 1);
581
590
  const swapPrivateL2MessageIndex = swapResult.leafIndex;
582
591
  const swapPrivateSiblingPath = swapResult.siblingPath;
583
592
  const withdrawL2MessageIndex = withdrawResult.leafIndex;
584
593
  const withdrawSiblingPath = withdrawResult.siblingPath;
585
594
  const withdrawMessageMetadata = {
586
595
  _epoch: BigInt(epoch),
596
+ _numCheckpointsInEpoch: BigInt(withdrawResult.numCheckpointsInEpoch),
587
597
  _leafIndex: BigInt(withdrawL2MessageIndex),
588
598
  _path: withdrawSiblingPath.toBufferArray().map((buf)=>`0x${buf.toString('hex')}`)
589
599
  };
590
600
  const swapPrivateMessageMetadata = {
591
601
  _epoch: BigInt(epoch),
602
+ _numCheckpointsInEpoch: BigInt(numCheckpointsInEpoch),
592
603
  _leafIndex: BigInt(swapPrivateL2MessageIndex),
593
604
  _path: swapPrivateSiblingPath.toBufferArray().map((buf)=>`0x${buf.toString('hex')}`)
594
605
  };
595
- // ensure that user's funds were burnt
596
- await wethCrossChainHarness.expectPrivateBalanceOnL2(ownerAddress, wethL2BalanceBeforeSwap - wethAmountToBridge);
597
- // Since the outbox is only consumable when the epoch is proven, we need to advance to the next epoch.
598
- await cheatCodes.rollup.advanceToEpoch(EpochNumber(epoch + 1));
599
- await waitForProven(aztecNode, withdrawReceipt, {
600
- provenTimeout: 300
601
- });
602
606
  // On L1 call swap_public!
603
607
  logger.info('call swap_public on L1');
604
608
  const swapArgs = [
@@ -631,7 +635,7 @@ export const uniswapL1L2TestSuite = (setup, cleanup, expectedForkBlockNumber = 1
631
635
  await validateActionInteraction.send();
632
636
  // Call swap_public on L2
633
637
  const secretHashForDepositingSwappedDai = Fr.random();
634
- const withdrawReceipt = await uniswapL2Contract.methods.swap_public(ownerAddress, wethCrossChainHarness.l2Bridge.address, wethAmountToBridge, daiCrossChainHarness.l2Bridge.address, nonceForWETHTransferApproval, uniswapFeeTier, minimumOutputAmount, ownerAddress, secretHashForDepositingSwappedDai, ownerEthAddress, Fr.ZERO).send({
638
+ const { receipt: withdrawReceipt } = await uniswapL2Contract.methods.swap_public(ownerAddress, wethCrossChainHarness.l2Bridge.address, wethAmountToBridge, daiCrossChainHarness.l2Bridge.address, nonceForWETHTransferApproval, uniswapFeeTier, minimumOutputAmount, ownerAddress, secretHashForDepositingSwappedDai, ownerEthAddress, Fr.ZERO).send({
635
639
  from: ownerAddress
636
640
  });
637
641
  const swapPublicContent = sha256ToField([
@@ -665,31 +669,37 @@ export const uniswapL1L2TestSuite = (setup, cleanup, expectedForkBlockNumber = 1
665
669
  rollupVersion: new Fr(version),
666
670
  chainId: new Fr(l1Client.chain.id)
667
671
  });
668
- const block = await aztecNode.getBlock(withdrawReceipt.blockNumber);
669
- const epoch = await rollup.getEpochNumberForCheckpoint(block.checkpointNumber);
670
- const swapResult = await computeL2ToL1MembershipWitness(aztecNode, epoch, swapPublicLeaf);
671
- const withdrawResult = await computeL2ToL1MembershipWitness(aztecNode, epoch, withdrawLeaf);
672
+ // check weth balance of owner on L2 (we first bridged `wethAmountToBridge` into L2 and now withdrew it!)
673
+ await wethCrossChainHarness.expectPublicBalanceOnL2(ownerAddress, 0n);
674
+ // Since the outbox is only consumable when the epoch is proven, we need to advance to the next epoch
675
+ // before we can ask the witness helper for a covering root.
676
+ const minedReceipt = await aztecNode.getTxReceipt(withdrawReceipt.txHash);
677
+ if (minedReceipt.epochNumber === undefined) {
678
+ throw new Error('Withdraw tx is not yet in an epoch');
679
+ }
680
+ await cheatCodes.rollup.advanceToEpoch(EpochNumber(minedReceipt.epochNumber + 1));
681
+ await waitForProven(aztecNode, withdrawReceipt, {
682
+ provenTimeout: 300
683
+ });
684
+ const swapResult = await retryUntil(()=>aztecNode.getL2ToL1MembershipWitness(minedReceipt.txHash, swapPublicLeaf), 'swap public l2 to l1 witness', 60, 1);
685
+ const { epochNumber: epoch, numCheckpointsInEpoch } = swapResult;
686
+ const withdrawResult = await retryUntil(()=>aztecNode.getL2ToL1MembershipWitness(minedReceipt.txHash, withdrawLeaf), 'withdraw l2 to l1 witness', 60, 1);
672
687
  const swapPublicL2MessageIndex = swapResult.leafIndex;
673
688
  const swapPublicSiblingPath = swapResult.siblingPath;
674
689
  const withdrawL2MessageIndex = withdrawResult.leafIndex;
675
690
  const withdrawSiblingPath = withdrawResult.siblingPath;
676
691
  const withdrawMessageMetadata = {
677
692
  _epoch: BigInt(epoch),
693
+ _numCheckpointsInEpoch: BigInt(withdrawResult.numCheckpointsInEpoch),
678
694
  _leafIndex: BigInt(withdrawL2MessageIndex),
679
695
  _path: withdrawSiblingPath.toBufferArray().map((buf)=>`0x${buf.toString('hex')}`)
680
696
  };
681
697
  const swapPublicMessageMetadata = {
682
698
  _epoch: BigInt(epoch),
699
+ _numCheckpointsInEpoch: BigInt(numCheckpointsInEpoch),
683
700
  _leafIndex: BigInt(swapPublicL2MessageIndex),
684
701
  _path: swapPublicSiblingPath.toBufferArray().map((buf)=>`0x${buf.toString('hex')}`)
685
702
  };
686
- // check weth balance of owner on L2 (we first bridged `wethAmountToBridge` into L2 and now withdrew it!)
687
- await wethCrossChainHarness.expectPublicBalanceOnL2(ownerAddress, 0n);
688
- // Since the outbox is only consumable when the epoch is proven, we need to advance to the next epoch.
689
- await cheatCodes.rollup.advanceToEpoch(EpochNumber(epoch + 1));
690
- await waitForProven(aztecNode, withdrawReceipt, {
691
- provenTimeout: 300
692
- });
693
703
  // Call swap_private on L1
694
704
  logger.info('Execute withdraw and swap on the uniswapPortal!');
695
705
  const swapArgs = [
@@ -0,0 +1,13 @@
1
+ import type { Fr } from '@aztec/aztec.js/fields';
2
+ import type { AztecNode } from '@aztec/aztec.js/node';
3
+ /**
4
+ * Waits until the archiver has seen the L1 to L2 message and indexed it. Unlike
5
+ * {@link waitForL1ToL2MessageReady} from `@aztec/aztec.js/messaging`, this does not
6
+ * require the L2 chain to have advanced to the message's checkpoint — it only confirms
7
+ * the message has been picked up from L1. Use this in tests that explicitly produce L2
8
+ * blocks afterwards to make the message consumable.
9
+ */
10
+ export declare function waitForL1ToL2MessageSeen(node: Pick<AztecNode, 'getL1ToL2MessageCheckpoint'>, l1ToL2MessageHash: Fr, opts: {
11
+ timeoutSeconds: number;
12
+ }): Promise<boolean>;
13
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoid2FpdF9mb3JfbDFfdG9fbDJfbWVzc2FnZS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3NoYXJlZC93YWl0X2Zvcl9sMV90b19sMl9tZXNzYWdlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxFQUFFLEVBQUUsRUFBRSxNQUFNLHdCQUF3QixDQUFDO0FBQ2pELE9BQU8sS0FBSyxFQUFFLFNBQVMsRUFBRSxNQUFNLHNCQUFzQixDQUFDO0FBR3REOzs7Ozs7R0FNRztBQUNILHdCQUFnQix3QkFBd0IsQ0FDdEMsSUFBSSxFQUFFLElBQUksQ0FBQyxTQUFTLEVBQUUsNEJBQTRCLENBQUMsRUFDbkQsaUJBQWlCLEVBQUUsRUFBRSxFQUNyQixJQUFJLEVBQUU7SUFBRSxjQUFjLEVBQUUsTUFBTSxDQUFBO0NBQUUsb0JBUWpDIn0=
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wait_for_l1_to_l2_message.d.ts","sourceRoot":"","sources":["../../src/shared/wait_for_l1_to_l2_message.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAGtD;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CACtC,IAAI,EAAE,IAAI,CAAC,SAAS,EAAE,4BAA4B,CAAC,EACnD,iBAAiB,EAAE,EAAE,EACrB,IAAI,EAAE;IAAE,cAAc,EAAE,MAAM,CAAA;CAAE,oBAQjC"}
@@ -0,0 +1,10 @@
1
+ import { retryUntil } from '@aztec/foundation/retry';
2
+ /**
3
+ * Waits until the archiver has seen the L1 to L2 message and indexed it. Unlike
4
+ * {@link waitForL1ToL2MessageReady} from `@aztec/aztec.js/messaging`, this does not
5
+ * require the L2 chain to have advanced to the message's checkpoint — it only confirms
6
+ * the message has been picked up from L1. Use this in tests that explicitly produce L2
7
+ * blocks afterwards to make the message consumable.
8
+ */ export function waitForL1ToL2MessageSeen(node, l1ToL2MessageHash, opts) {
9
+ return retryUntil(async ()=>await node.getL1ToL2MessageCheckpoint(l1ToL2MessageHash) !== undefined, `L1 to L2 message ${l1ToL2MessageHash.toString()} seen`, opts.timeoutSeconds, 0.25);
10
+ }