@aztec/end-to-end 0.0.0-test.1 → 0.0.1-commit.017a351

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 (316) hide show
  1. package/README.md +27 -0
  2. package/dest/bench/client_flows/benchmark.d.ts +76 -0
  3. package/dest/bench/client_flows/benchmark.d.ts.map +1 -0
  4. package/dest/bench/client_flows/benchmark.js +298 -0
  5. package/dest/bench/client_flows/client_flows_benchmark.d.ts +79 -0
  6. package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -0
  7. package/dest/bench/client_flows/client_flows_benchmark.js +318 -0
  8. package/dest/bench/client_flows/config.d.ts +14 -0
  9. package/dest/bench/client_flows/config.d.ts.map +1 -0
  10. package/dest/bench/client_flows/config.js +124 -0
  11. package/dest/bench/client_flows/data_extractor.d.ts +2 -0
  12. package/dest/bench/client_flows/data_extractor.d.ts.map +1 -0
  13. package/dest/bench/client_flows/data_extractor.js +79 -0
  14. package/dest/bench/utils.d.ts +16 -41
  15. package/dest/bench/utils.d.ts.map +1 -1
  16. package/dest/bench/utils.js +46 -72
  17. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +30 -20
  18. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts.map +1 -1
  19. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.js +137 -106
  20. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +44 -33
  21. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts.map +1 -1
  22. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.js +136 -103
  23. package/dest/e2e_deploy_contract/deploy_test.d.ts +20 -11
  24. package/dest/e2e_deploy_contract/deploy_test.d.ts.map +1 -1
  25. package/dest/e2e_deploy_contract/deploy_test.js +28 -28
  26. package/dest/e2e_epochs/epochs_test.d.ts +98 -24
  27. package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
  28. package/dest/e2e_epochs/epochs_test.js +366 -61
  29. package/dest/e2e_fees/bridging_race.notest.d.ts +2 -0
  30. package/dest/e2e_fees/bridging_race.notest.d.ts.map +1 -0
  31. package/dest/e2e_fees/bridging_race.notest.js +61 -0
  32. package/dest/e2e_fees/fees_test.d.ts +42 -24
  33. package/dest/e2e_fees/fees_test.d.ts.map +1 -1
  34. package/dest/e2e_fees/fees_test.js +194 -182
  35. package/dest/e2e_l1_publisher/write_json.d.ts +11 -0
  36. package/dest/e2e_l1_publisher/write_json.d.ts.map +1 -0
  37. package/dest/e2e_l1_publisher/write_json.js +56 -0
  38. package/dest/e2e_multi_validator/utils.d.ts +12 -0
  39. package/dest/e2e_multi_validator/utils.d.ts.map +1 -0
  40. package/dest/e2e_multi_validator/utils.js +214 -0
  41. package/dest/e2e_nested_contract/nested_contract_test.d.ts +16 -16
  42. package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +1 -1
  43. package/dest/e2e_nested_contract/nested_contract_test.js +38 -43
  44. package/dest/e2e_p2p/inactivity_slash_test.d.ts +31 -0
  45. package/dest/e2e_p2p/inactivity_slash_test.d.ts.map +1 -0
  46. package/dest/e2e_p2p/inactivity_slash_test.js +137 -0
  47. package/dest/e2e_p2p/p2p_network.d.ts +287 -31
  48. package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
  49. package/dest/e2e_p2p/p2p_network.js +281 -183
  50. package/dest/e2e_p2p/reqresp/utils.d.ts +22 -0
  51. package/dest/e2e_p2p/reqresp/utils.d.ts.map +1 -0
  52. package/dest/e2e_p2p/reqresp/utils.js +206 -0
  53. package/dest/e2e_p2p/shared.d.ts +73 -8
  54. package/dest/e2e_p2p/shared.d.ts.map +1 -1
  55. package/dest/e2e_p2p/shared.js +205 -27
  56. package/dest/e2e_storage_proof/fixtures/storage_proof_fetcher.d.ts +2 -0
  57. package/dest/e2e_storage_proof/fixtures/storage_proof_fetcher.d.ts.map +1 -0
  58. package/dest/e2e_storage_proof/fixtures/storage_proof_fetcher.js +184 -0
  59. package/dest/e2e_storage_proof/fixtures/storage_proof_fixture.d.ts +18 -0
  60. package/dest/e2e_storage_proof/fixtures/storage_proof_fixture.d.ts.map +1 -0
  61. package/dest/e2e_storage_proof/fixtures/storage_proof_fixture.js +120 -0
  62. package/dest/e2e_token_contract/token_contract_test.d.ts +30 -15
  63. package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -1
  64. package/dest/e2e_token_contract/token_contract_test.js +110 -76
  65. package/dest/fixtures/authwit_proxy.d.ts +15 -0
  66. package/dest/fixtures/authwit_proxy.d.ts.map +1 -0
  67. package/dest/fixtures/authwit_proxy.js +34 -0
  68. package/dest/fixtures/e2e_prover_test.d.ts +56 -0
  69. package/dest/fixtures/e2e_prover_test.d.ts.map +1 -0
  70. package/dest/fixtures/e2e_prover_test.js +267 -0
  71. package/dest/fixtures/elu_monitor.d.ts +21 -0
  72. package/dest/fixtures/elu_monitor.d.ts.map +1 -0
  73. package/dest/fixtures/elu_monitor.js +102 -0
  74. package/dest/fixtures/fixtures.d.ts +79 -8
  75. package/dest/fixtures/fixtures.d.ts.map +1 -1
  76. package/dest/fixtures/fixtures.js +76 -5
  77. package/dest/fixtures/get_acvm_config.d.ts +2 -2
  78. package/dest/fixtures/get_acvm_config.d.ts.map +1 -1
  79. package/dest/fixtures/get_acvm_config.js +3 -15
  80. package/dest/fixtures/get_bb_config.d.ts +2 -2
  81. package/dest/fixtures/get_bb_config.d.ts.map +1 -1
  82. package/dest/fixtures/get_bb_config.js +10 -17
  83. package/dest/fixtures/ha_setup.d.ts +71 -0
  84. package/dest/fixtures/ha_setup.d.ts.map +1 -0
  85. package/dest/fixtures/ha_setup.js +116 -0
  86. package/dest/fixtures/index.d.ts +2 -1
  87. package/dest/fixtures/index.d.ts.map +1 -1
  88. package/dest/fixtures/index.js +1 -0
  89. package/dest/fixtures/l1_to_l2_messaging.d.ts +11 -7
  90. package/dest/fixtures/l1_to_l2_messaging.d.ts.map +1 -1
  91. package/dest/fixtures/l1_to_l2_messaging.js +45 -19
  92. package/dest/fixtures/logging.d.ts +1 -1
  93. package/dest/fixtures/schnorr_hardcoded_account_contract.d.ts +25 -0
  94. package/dest/fixtures/schnorr_hardcoded_account_contract.d.ts.map +1 -0
  95. package/dest/fixtures/schnorr_hardcoded_account_contract.js +37 -0
  96. package/dest/fixtures/setup.d.ts +272 -0
  97. package/dest/fixtures/setup.d.ts.map +1 -0
  98. package/dest/fixtures/setup.js +735 -0
  99. package/dest/fixtures/setup_p2p_test.d.ts +28 -16
  100. package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
  101. package/dest/fixtures/setup_p2p_test.js +103 -32
  102. package/dest/fixtures/token_utils.d.ts +10 -4
  103. package/dest/fixtures/token_utils.d.ts.map +1 -1
  104. package/dest/fixtures/token_utils.js +30 -13
  105. package/dest/fixtures/utils.d.ts +5 -153
  106. package/dest/fixtures/utils.d.ts.map +1 -1
  107. package/dest/fixtures/utils.js +4 -552
  108. package/dest/fixtures/web3signer.d.ts +5 -0
  109. package/dest/fixtures/web3signer.d.ts.map +1 -0
  110. package/dest/fixtures/web3signer.js +53 -0
  111. package/dest/fixtures/with_telemetry_utils.d.ts +2 -2
  112. package/dest/fixtures/with_telemetry_utils.d.ts.map +1 -1
  113. package/dest/fixtures/with_telemetry_utils.js +2 -2
  114. package/dest/forward-compatibility/wallet_rpc_client.d.ts +7 -0
  115. package/dest/forward-compatibility/wallet_rpc_client.d.ts.map +1 -0
  116. package/dest/forward-compatibility/wallet_rpc_client.js +15 -0
  117. package/dest/forward-compatibility/wallet_service.d.ts +3 -0
  118. package/dest/forward-compatibility/wallet_service.d.ts.map +1 -0
  119. package/dest/forward-compatibility/wallet_service.js +109 -0
  120. package/dest/index.d.ts +1 -1
  121. package/dest/install_legacy_contracts.d.cts +10 -0
  122. package/dest/install_legacy_contracts.d.cts.map +1 -0
  123. package/dest/legacy-jest-resolver.d.cts +3 -0
  124. package/dest/legacy-jest-resolver.d.cts.map +1 -0
  125. package/dest/quality_of_service/grafana_client.d.ts +41 -0
  126. package/dest/quality_of_service/grafana_client.d.ts.map +1 -0
  127. package/dest/quality_of_service/{alert_checker.js → grafana_client.js} +1 -1
  128. package/dest/quality_of_service/prometheus_client.d.ts +38 -0
  129. package/dest/quality_of_service/prometheus_client.d.ts.map +1 -0
  130. package/dest/quality_of_service/prometheus_client.js +67 -0
  131. package/dest/shared/cross_chain_test_harness.d.ts +46 -27
  132. package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
  133. package/dest/shared/cross_chain_test_harness.js +113 -55
  134. package/dest/shared/gas_portal_test_harness.d.ts +39 -28
  135. package/dest/shared/gas_portal_test_harness.d.ts.map +1 -1
  136. package/dest/shared/gas_portal_test_harness.js +64 -34
  137. package/dest/shared/index.d.ts +3 -2
  138. package/dest/shared/index.d.ts.map +1 -1
  139. package/dest/shared/index.js +1 -0
  140. package/dest/shared/jest_setup.d.ts +1 -1
  141. package/dest/shared/jest_setup.js +42 -2
  142. package/dest/shared/mock_state_view.d.ts +86 -0
  143. package/dest/shared/mock_state_view.d.ts.map +1 -0
  144. package/dest/shared/mock_state_view.js +186 -0
  145. package/dest/shared/submit-transactions.d.ts +6 -4
  146. package/dest/shared/submit-transactions.d.ts.map +1 -1
  147. package/dest/shared/submit-transactions.js +15 -16
  148. package/dest/shared/uniswap_l1_l2.d.ts +3 -25
  149. package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
  150. package/dest/shared/uniswap_l1_l2.js +202 -135
  151. package/dest/shared/wait_for_l1_to_l2_message.d.ts +13 -0
  152. package/dest/shared/wait_for_l1_to_l2_message.d.ts.map +1 -0
  153. package/dest/shared/wait_for_l1_to_l2_message.js +10 -0
  154. package/dest/simulators/index.d.ts +1 -1
  155. package/dest/simulators/lending_simulator.d.ts +16 -9
  156. package/dest/simulators/lending_simulator.d.ts.map +1 -1
  157. package/dest/simulators/lending_simulator.js +38 -27
  158. package/dest/simulators/token_simulator.d.ts +6 -3
  159. package/dest/simulators/token_simulator.d.ts.map +1 -1
  160. package/dest/simulators/token_simulator.js +12 -30
  161. package/dest/spartan/setup_test_wallets.d.ts +36 -11
  162. package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
  163. package/dest/spartan/setup_test_wallets.js +301 -63
  164. package/dest/spartan/tx_metrics.d.ts +102 -0
  165. package/dest/spartan/tx_metrics.d.ts.map +1 -0
  166. package/dest/spartan/tx_metrics.js +475 -0
  167. package/dest/spartan/utils/bot.d.ts +28 -0
  168. package/dest/spartan/utils/bot.d.ts.map +1 -0
  169. package/dest/spartan/utils/bot.js +142 -0
  170. package/dest/spartan/utils/chaos.d.ts +79 -0
  171. package/dest/spartan/utils/chaos.d.ts.map +1 -0
  172. package/dest/spartan/utils/chaos.js +142 -0
  173. package/dest/spartan/utils/clients.d.ts +39 -0
  174. package/dest/spartan/utils/clients.d.ts.map +1 -0
  175. package/dest/spartan/utils/clients.js +90 -0
  176. package/dest/spartan/utils/config.d.ts +19 -0
  177. package/dest/spartan/utils/config.d.ts.map +1 -0
  178. package/dest/spartan/utils/config.js +23 -0
  179. package/dest/spartan/utils/health.d.ts +63 -0
  180. package/dest/spartan/utils/health.d.ts.map +1 -0
  181. package/dest/spartan/utils/health.js +202 -0
  182. package/dest/spartan/utils/helm.d.ts +15 -0
  183. package/dest/spartan/utils/helm.d.ts.map +1 -0
  184. package/dest/spartan/utils/helm.js +47 -0
  185. package/dest/spartan/utils/index.d.ts +11 -0
  186. package/dest/spartan/utils/index.d.ts.map +1 -0
  187. package/dest/spartan/utils/index.js +22 -0
  188. package/dest/spartan/utils/k8s.d.ts +128 -0
  189. package/dest/spartan/utils/k8s.d.ts.map +1 -0
  190. package/dest/spartan/utils/k8s.js +381 -0
  191. package/dest/spartan/utils/nodes.d.ts +40 -0
  192. package/dest/spartan/utils/nodes.d.ts.map +1 -0
  193. package/dest/spartan/utils/nodes.js +461 -0
  194. package/dest/spartan/utils/pod_logs.d.ts +25 -0
  195. package/dest/spartan/utils/pod_logs.d.ts.map +1 -0
  196. package/dest/spartan/utils/pod_logs.js +74 -0
  197. package/dest/spartan/utils/scripts.d.ts +30 -0
  198. package/dest/spartan/utils/scripts.d.ts.map +1 -0
  199. package/dest/spartan/utils/scripts.js +81 -0
  200. package/dest/spartan/utils.d.ts +2 -415
  201. package/dest/spartan/utils.d.ts.map +1 -1
  202. package/dest/spartan/utils.js +1 -445
  203. package/dest/test-wallet/test_wallet.d.ts +85 -0
  204. package/dest/test-wallet/test_wallet.d.ts.map +1 -0
  205. package/dest/test-wallet/test_wallet.js +273 -0
  206. package/dest/test-wallet/utils.d.ts +41 -0
  207. package/dest/test-wallet/utils.d.ts.map +1 -0
  208. package/dest/test-wallet/utils.js +66 -0
  209. package/dest/test-wallet/wallet_worker_script.d.ts +2 -0
  210. package/dest/test-wallet/wallet_worker_script.d.ts.map +1 -0
  211. package/dest/test-wallet/wallet_worker_script.js +53 -0
  212. package/dest/test-wallet/worker_wallet.d.ts +53 -0
  213. package/dest/test-wallet/worker_wallet.d.ts.map +1 -0
  214. package/dest/test-wallet/worker_wallet.js +155 -0
  215. package/dest/test-wallet/worker_wallet_schema.d.ts +160 -0
  216. package/dest/test-wallet/worker_wallet_schema.d.ts.map +1 -0
  217. package/dest/test-wallet/worker_wallet_schema.js +22 -0
  218. package/package.json +79 -64
  219. package/src/bench/client_flows/benchmark.ts +382 -0
  220. package/src/bench/client_flows/client_flows_benchmark.ts +399 -0
  221. package/src/bench/client_flows/config.ts +69 -0
  222. package/src/bench/client_flows/data_extractor.ts +89 -0
  223. package/src/bench/utils.ts +49 -87
  224. package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +164 -172
  225. package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +194 -183
  226. package/src/e2e_deploy_contract/deploy_test.ts +42 -49
  227. package/src/e2e_epochs/epochs_test.ts +451 -93
  228. package/src/e2e_fees/bridging_race.notest.ts +74 -0
  229. package/src/e2e_fees/fees_test.ts +249 -262
  230. package/src/e2e_l1_publisher/write_json.ts +77 -0
  231. package/src/e2e_multi_validator/utils.ts +258 -0
  232. package/src/e2e_nested_contract/nested_contract_test.ts +51 -60
  233. package/src/e2e_p2p/inactivity_slash_test.ts +180 -0
  234. package/src/e2e_p2p/p2p_network.ts +391 -240
  235. package/src/e2e_p2p/reqresp/utils.ts +274 -0
  236. package/src/e2e_p2p/shared.ts +304 -39
  237. package/src/e2e_storage_proof/fixtures/storage_proof.json +915 -0
  238. package/src/e2e_storage_proof/fixtures/storage_proof_fetcher.ts +190 -0
  239. package/src/e2e_storage_proof/fixtures/storage_proof_fixture.ts +173 -0
  240. package/src/e2e_token_contract/token_contract_test.ts +140 -124
  241. package/src/fixtures/authwit_proxy.ts +54 -0
  242. package/src/fixtures/dumps/epoch_proof_result.json +1 -1
  243. package/src/fixtures/e2e_prover_test.ts +329 -0
  244. package/src/fixtures/elu_monitor.ts +126 -0
  245. package/src/fixtures/fixtures.ts +98 -7
  246. package/src/fixtures/get_acvm_config.ts +4 -12
  247. package/src/fixtures/get_bb_config.ts +19 -13
  248. package/src/fixtures/ha_setup.ts +188 -0
  249. package/src/fixtures/index.ts +1 -0
  250. package/src/fixtures/l1_to_l2_messaging.ts +56 -24
  251. package/src/fixtures/schnorr_hardcoded_account_contract.ts +49 -0
  252. package/src/fixtures/setup.ts +1056 -0
  253. package/src/fixtures/setup_p2p_test.ts +142 -54
  254. package/src/fixtures/token_utils.ts +34 -16
  255. package/src/fixtures/utils.ts +29 -820
  256. package/src/fixtures/web3signer.ts +63 -0
  257. package/src/fixtures/with_telemetry_utils.ts +2 -2
  258. package/src/forward-compatibility/wallet_rpc_client.ts +14 -0
  259. package/src/forward-compatibility/wallet_service.ts +104 -0
  260. package/src/guides/up_quick_start.sh +9 -19
  261. package/src/install_legacy_contracts.cjs +75 -0
  262. package/src/legacy-jest-resolver.cjs +112 -0
  263. package/src/quality_of_service/{alert_checker.ts → grafana_client.ts} +2 -2
  264. package/src/quality_of_service/prometheus_client.ts +113 -0
  265. package/src/shared/cross_chain_test_harness.ts +116 -90
  266. package/src/shared/gas_portal_test_harness.ts +75 -56
  267. package/src/shared/index.ts +2 -1
  268. package/src/shared/jest_setup.ts +52 -2
  269. package/src/shared/mock_state_view.ts +188 -0
  270. package/src/shared/submit-transactions.ts +19 -20
  271. package/src/shared/uniswap_l1_l2.ts +259 -234
  272. package/src/shared/wait_for_l1_to_l2_message.ts +23 -0
  273. package/src/simulators/lending_simulator.ts +43 -26
  274. package/src/simulators/token_simulator.ts +18 -34
  275. package/src/spartan/DEVELOP.md +128 -0
  276. package/src/spartan/setup_test_wallets.ts +420 -96
  277. package/src/spartan/tx_metrics.ts +434 -0
  278. package/src/spartan/utils/bot.ts +188 -0
  279. package/src/spartan/utils/chaos.ts +253 -0
  280. package/src/spartan/utils/clients.ts +100 -0
  281. package/src/spartan/utils/config.ts +29 -0
  282. package/src/spartan/utils/health.ts +255 -0
  283. package/src/spartan/utils/helm.ts +84 -0
  284. package/src/spartan/utils/index.ts +71 -0
  285. package/src/spartan/utils/k8s.ts +535 -0
  286. package/src/spartan/utils/nodes.ts +543 -0
  287. package/src/spartan/utils/pod_logs.ts +99 -0
  288. package/src/spartan/utils/scripts.ts +99 -0
  289. package/src/spartan/utils.ts +1 -582
  290. package/src/test-wallet/test_wallet.ts +376 -0
  291. package/src/test-wallet/utils.ts +108 -0
  292. package/src/test-wallet/wallet_worker_script.ts +63 -0
  293. package/src/test-wallet/worker_wallet.ts +218 -0
  294. package/src/test-wallet/worker_wallet_schema.ts +13 -0
  295. package/dest/e2e_prover/e2e_prover_test.d.ts +0 -56
  296. package/dest/e2e_prover/e2e_prover_test.d.ts.map +0 -1
  297. package/dest/e2e_prover/e2e_prover_test.js +0 -291
  298. package/dest/fixtures/setup_l1_contracts.d.ts +0 -6
  299. package/dest/fixtures/setup_l1_contracts.d.ts.map +0 -1
  300. package/dest/fixtures/setup_l1_contracts.js +0 -17
  301. package/dest/fixtures/snapshot_manager.d.ts +0 -87
  302. package/dest/fixtures/snapshot_manager.d.ts.map +0 -1
  303. package/dest/fixtures/snapshot_manager.js +0 -479
  304. package/dest/quality_of_service/alert_checker.d.ts +0 -41
  305. package/dest/quality_of_service/alert_checker.d.ts.map +0 -1
  306. package/dest/sample-dapp/connect.js +0 -12
  307. package/dest/sample-dapp/contracts.js +0 -10
  308. package/dest/sample-dapp/deploy.js +0 -35
  309. package/dest/sample-dapp/index.js +0 -98
  310. package/src/e2e_prover/e2e_prover_test.ts +0 -418
  311. package/src/fixtures/setup_l1_contracts.ts +0 -27
  312. package/src/fixtures/snapshot_manager.ts +0 -617
  313. package/src/sample-dapp/connect.mjs +0 -16
  314. package/src/sample-dapp/contracts.mjs +0 -14
  315. package/src/sample-dapp/deploy.mjs +0 -40
  316. package/src/sample-dapp/index.mjs +0 -128
@@ -1,30 +1,32 @@
1
- import {
2
- type AccountWallet,
3
- AztecAddress,
4
- type AztecNode,
5
- type CheatCodes,
6
- EthAddress,
7
- Fr,
8
- type Logger,
9
- type PXE,
10
- computeAuthWitMessageHash,
11
- generateClaimSecret,
12
- } from '@aztec/aztec.js';
13
- import {
14
- type DeployL1ContractsReturnType,
15
- type ViemPublicClient,
16
- type ViemWalletClient,
17
- deployL1Contract,
18
- extractEvent,
19
- } from '@aztec/ethereum';
20
- import { sha256ToField } from '@aztec/foundation/crypto';
21
- import { InboxAbi, RollupAbi, UniswapPortalAbi, UniswapPortalBytecode } from '@aztec/l1-artifacts';
1
+ import { AztecAddress, EthAddress } from '@aztec/aztec.js/addresses';
2
+ import { computeAuthWitMessageHash } from '@aztec/aztec.js/authorization';
3
+ import { waitForProven } from '@aztec/aztec.js/contracts';
4
+ import { generateClaimSecret } from '@aztec/aztec.js/ethereum';
5
+ import { Fr } from '@aztec/aztec.js/fields';
6
+ import type { Logger } from '@aztec/aztec.js/log';
7
+ import type { AztecNode } from '@aztec/aztec.js/node';
8
+ import { CheatCodes } from '@aztec/aztec/testing';
9
+ import { RollupContract } from '@aztec/ethereum/contracts';
10
+ import type { DeployAztecL1ContractsReturnType } from '@aztec/ethereum/deploy-aztec-l1-contracts';
11
+ import { deployL1Contract } from '@aztec/ethereum/deploy-l1-contract';
12
+ import type { ExtendedViemWalletClient } from '@aztec/ethereum/types';
13
+ import { extractEvent } from '@aztec/ethereum/utils';
14
+ import { EpochNumber } from '@aztec/foundation/branded-types';
15
+ import { sha256ToField } from '@aztec/foundation/crypto/sha256';
16
+ import { retryUntil } from '@aztec/foundation/retry';
17
+ import { InboxAbi, UniswapPortalAbi, UniswapPortalBytecode } from '@aztec/l1-artifacts';
22
18
  import { UniswapContract } from '@aztec/noir-contracts.js/Uniswap';
19
+ import { computeL2ToL1MessageHash } from '@aztec/stdlib/hash';
23
20
 
24
21
  import { jest } from '@jest/globals';
25
22
  import { type GetContractReturnType, getContract, parseEther, toFunctionSelector } from 'viem';
26
23
 
27
- import { ensureAccountsPubliclyDeployed } from '../fixtures/utils.js';
24
+ import {
25
+ type EndToEndContext,
26
+ ensureAccountContractsPublished,
27
+ ensureAuthRegistryPublished,
28
+ } from '../fixtures/utils.js';
29
+ import type { TestWallet } from '../test-wallet/test_wallet.js';
28
30
  import { CrossChainTestHarness } from './cross_chain_test_harness.js';
29
31
 
30
32
  // PSA: This tests works on forked mainnet. There is a dump of the data in `dumpedState` such that we
@@ -34,38 +36,13 @@ import { CrossChainTestHarness } from './cross_chain_test_harness.js';
34
36
  // anvil --fork-url https://mainnet.infura.io/v3/9928b52099854248b3a096be07a6b23c --fork-block-number 17514288 --chain-id 31337
35
37
  // For CI, this is configured in `run_tests.sh` and `docker-compose-images.yml`
36
38
 
37
- // docs:start:uniswap_l1_l2_test_setup_const
38
- const TIMEOUT = 360_000;
39
-
40
- /** Objects to be returned by the uniswap setup function */
41
- export type UniswapSetupContext = {
42
- /** Aztec Node instance */
43
- aztecNode: AztecNode;
44
- /** The Private eXecution Environment (PXE). */
45
- pxe: PXE;
46
- /** Logger instance named as the current test. */
47
- logger: Logger;
48
- /** Viem Public client instance. */
49
- publicClient: ViemPublicClient;
50
- /** Viem Wallet Client instance. */
51
- walletClient: ViemWalletClient;
52
- /** The owner wallet. */
53
- ownerWallet: AccountWallet;
54
- /** The sponsor wallet. */
55
- sponsorWallet: AccountWallet;
56
- /** */
57
- deployL1ContractsValues: DeployL1ContractsReturnType;
58
- /** Cheat codes instance. */
59
- cheatCodes: CheatCodes;
60
- };
61
- // docs:end:uniswap_l1_l2_test_setup_const
39
+ const TIMEOUT = 15 * 60 * 1000;
62
40
 
63
41
  export const uniswapL1L2TestSuite = (
64
- setup: () => Promise<UniswapSetupContext>,
42
+ setup: () => Promise<EndToEndContext>,
65
43
  cleanup: () => Promise<void>,
66
44
  expectedForkBlockNumber = 17514288,
67
45
  ) => {
68
- // docs:start:uniswap_l1_l2_test_beforeAll
69
46
  describe('uniswap_trade_on_l1_from_l2', () => {
70
47
  jest.setTimeout(TIMEOUT);
71
48
 
@@ -73,25 +50,22 @@ export const uniswapL1L2TestSuite = (
73
50
  const DAI_ADDRESS: EthAddress = EthAddress.fromString('0x6B175474E89094C44Da98b954EedeAC495271d0F');
74
51
 
75
52
  let aztecNode: AztecNode;
76
- let pxe: PXE;
77
53
  let logger: Logger;
78
54
 
79
- let walletClient: ViemWalletClient;
80
- let publicClient: ViemPublicClient;
55
+ let l1Client: ExtendedViemWalletClient;
81
56
 
82
- let ownerWallet: AccountWallet;
57
+ let wallet: TestWallet;
83
58
  let ownerAddress: AztecAddress;
84
59
  let ownerEthAddress: EthAddress;
85
60
  // does transactions on behalf of owner on Aztec:
86
- let sponsorWallet: AccountWallet;
87
- // let sponsorAddress: AztecAddress;
61
+ let sponsorAddress: AztecAddress;
88
62
 
89
63
  let daiCrossChainHarness: CrossChainTestHarness;
90
64
  let wethCrossChainHarness: CrossChainTestHarness;
91
65
 
92
- let deployL1ContractsValues: DeployL1ContractsReturnType;
93
- let rollup: GetContractReturnType<typeof RollupAbi, ViemWalletClient>;
94
- let uniswapPortal: GetContractReturnType<typeof UniswapPortalAbi, ViemWalletClient>;
66
+ let deployL1ContractsValues: DeployAztecL1ContractsReturnType;
67
+ let rollup: RollupContract;
68
+ let uniswapPortal: GetContractReturnType<typeof UniswapPortalAbi, ExtendedViemWalletClient>;
95
69
  let uniswapPortalAddress: EthAddress;
96
70
  let uniswapL2Contract: UniswapContract;
97
71
 
@@ -100,43 +74,42 @@ export const uniswapL1L2TestSuite = (
100
74
  const minimumOutputAmount = 0n;
101
75
 
102
76
  let cheatCodes: CheatCodes;
103
-
77
+ let version: number;
104
78
  beforeAll(async () => {
79
+ const t = await setup();
105
80
  ({
106
81
  aztecNode,
107
- pxe,
108
82
  logger,
109
- publicClient,
110
- walletClient,
111
- ownerWallet,
112
- sponsorWallet,
113
83
  deployL1ContractsValues,
114
84
  cheatCodes,
115
- } = await setup());
85
+ wallet,
86
+ accounts: [ownerAddress, sponsorAddress],
87
+ } = t);
88
+
89
+ l1Client = deployL1ContractsValues.l1Client;
116
90
 
117
- if (Number(await publicClient.getBlockNumber()) < expectedForkBlockNumber) {
91
+ t.watcher.setIsMarkingAsProven(false);
92
+
93
+ if (Number(await l1Client.getBlockNumber()) < expectedForkBlockNumber) {
118
94
  throw new Error('This test must be run on a fork of mainnet with the expected fork block');
119
95
  }
120
96
 
121
- rollup = getContract({
122
- address: deployL1ContractsValues.l1ContractAddresses.rollupAddress.toString(),
123
- abi: RollupAbi,
124
- client: deployL1ContractsValues.walletClient,
125
- });
126
-
127
- ownerAddress = ownerWallet.getAddress();
128
- // sponsorAddress = sponsorWallet.getAddress();
129
- ownerEthAddress = EthAddress.fromString((await walletClient.getAddresses())[0]);
97
+ rollup = new RollupContract(
98
+ deployL1ContractsValues.l1Client,
99
+ deployL1ContractsValues.l1ContractAddresses.rollupAddress,
100
+ );
101
+ version = Number(await rollup.getVersion());
102
+ ownerEthAddress = EthAddress.fromString((await l1Client.getAddresses())[0]);
130
103
 
131
- await ensureAccountsPubliclyDeployed(ownerWallet, [ownerWallet, sponsorWallet]);
104
+ await ensureAccountContractsPublished(wallet, [ownerAddress, sponsorAddress]);
105
+ await ensureAuthRegistryPublished(wallet, ownerAddress);
132
106
 
133
107
  logger.info('Deploying DAI Portal, initializing and deploying l2 contract...');
134
108
  daiCrossChainHarness = await CrossChainTestHarness.new(
135
109
  aztecNode,
136
- pxe,
137
- publicClient,
138
- walletClient,
139
- ownerWallet,
110
+ deployL1ContractsValues.l1Client,
111
+ wallet,
112
+ ownerAddress,
140
113
  logger,
141
114
  DAI_ADDRESS,
142
115
  );
@@ -144,31 +117,29 @@ export const uniswapL1L2TestSuite = (
144
117
  logger.info('Deploying WETH Portal, initializing and deploying l2 contract...');
145
118
  wethCrossChainHarness = await CrossChainTestHarness.new(
146
119
  aztecNode,
147
- pxe,
148
- publicClient,
149
- walletClient,
150
- ownerWallet,
120
+ l1Client,
121
+ wallet,
122
+ ownerAddress,
151
123
  logger,
152
124
  WETH9_ADDRESS,
153
125
  );
154
126
 
155
127
  logger.info('Deploy Uniswap portal on L1 and L2...');
156
- uniswapPortalAddress = await deployL1Contract(
157
- walletClient,
158
- publicClient,
159
- UniswapPortalAbi,
160
- UniswapPortalBytecode,
161
- ).then(({ address }) => address);
128
+ uniswapPortalAddress = await deployL1Contract(l1Client, UniswapPortalAbi, UniswapPortalBytecode).then(
129
+ ({ address }) => address,
130
+ );
162
131
 
163
132
  uniswapPortal = getContract({
164
133
  address: uniswapPortalAddress.toString(),
165
134
  abi: UniswapPortalAbi,
166
- client: walletClient,
135
+ client: l1Client,
167
136
  });
168
137
  // deploy l2 uniswap contract and attach to portal
169
- uniswapL2Contract = await UniswapContract.deploy(ownerWallet, uniswapPortalAddress).send().deployed();
138
+ ({ contract: uniswapL2Contract } = await UniswapContract.deploy(wallet, uniswapPortalAddress).send({
139
+ from: ownerAddress,
140
+ }));
170
141
 
171
- const registryAddress = (await pxe.getNodeInfo()).l1ContractAddresses.registryAddress;
142
+ const registryAddress = (await aztecNode.getNodeInfo()).l1ContractAddresses.registryAddress;
172
143
 
173
144
  await uniswapPortal.write.initialize(
174
145
  [registryAddress.toString(), uniswapL2Contract.address.toString()],
@@ -177,19 +148,17 @@ export const uniswapL1L2TestSuite = (
177
148
 
178
149
  // Give me some WETH so I can deposit to L2 and do the swap...
179
150
  logger.info('Getting some weth');
180
- const hash = await walletClient.sendTransaction({ to: WETH9_ADDRESS.toString(), value: parseEther('1000') });
181
- await publicClient.waitForTransactionReceipt({ hash });
151
+ const hash = await l1Client.sendTransaction({ to: WETH9_ADDRESS.toString(), value: parseEther('1000') });
152
+ await l1Client.waitForTransactionReceipt({ hash });
182
153
 
183
154
  const wethBalance = await wethCrossChainHarness.getL1BalanceOf(ownerEthAddress);
184
155
  expect(wethBalance).toBe(parseEther('1000'));
185
156
  });
186
- // docs:end:uniswap_l1_l2_test_beforeAll
187
157
 
188
158
  afterAll(async () => {
189
159
  await cleanup();
190
160
  });
191
161
 
192
- // docs:start:uniswap_private
193
162
  it('should uniswap trade on L1 from L2 funds privately (swaps WETH -> DAI)', async () => {
194
163
  const wethL1BeforeBalance = await wethCrossChainHarness.getL1BalanceOf(ownerEthAddress);
195
164
 
@@ -218,7 +187,7 @@ export const uniswapL1L2TestSuite = (
218
187
  // 3. Owner gives uniswap approval to transfer the funds to public to self on its behalf
219
188
  logger.info('Approving uniswap to transfer funds to public to self on my behalf');
220
189
  const nonceForWETHTransferToPublicApproval = new Fr(1n);
221
- await ownerWallet.createAuthWit({
190
+ const transferToPublicAuhtwit = await wallet.createAuthWit(ownerAddress, {
222
191
  caller: uniswapL2Contract.address,
223
192
  action: wethCrossChainHarness.l2Token.methods.transfer_to_public(
224
193
  ownerAddress,
@@ -232,7 +201,7 @@ export const uniswapL1L2TestSuite = (
232
201
  logger.info('Withdrawing weth to L1 and sending message to swap to dai');
233
202
  const [secretForDepositingSwappedDai, secretHashForDepositingSwappedDai] = await generateClaimSecret();
234
203
 
235
- const l2UniswapInteractionReceipt = await uniswapL2Contract.methods
204
+ const { receipt: l2UniswapInteractionReceipt } = await uniswapL2Contract.methods
236
205
  .swap_private(
237
206
  wethCrossChainHarness.l2Token.address,
238
207
  wethCrossChainHarness.l2Bridge.address,
@@ -244,8 +213,7 @@ export const uniswapL1L2TestSuite = (
244
213
  secretHashForDepositingSwappedDai,
245
214
  ownerEthAddress,
246
215
  )
247
- .send()
248
- .wait();
216
+ .send({ from: ownerAddress, authWitnesses: [transferToPublicAuhtwit] });
249
217
 
250
218
  const swapPrivateFunction = 'swap_private(address,uint256,uint24,address,uint256,bytes32,address)';
251
219
  const swapPrivateContent = sha256ToField([
@@ -259,13 +227,13 @@ export const uniswapL1L2TestSuite = (
259
227
  ownerEthAddress.toBuffer32(),
260
228
  ]);
261
229
 
262
- const swapPrivateLeaf = sha256ToField([
263
- uniswapL2Contract.address,
264
- new Fr(1), // aztec version
265
- EthAddress.fromString(uniswapPortal.address).toBuffer32(),
266
- new Fr(publicClient.chain.id), // chain id
267
- swapPrivateContent,
268
- ]);
230
+ const swapPrivateLeaf = computeL2ToL1MessageHash({
231
+ l2Sender: uniswapL2Contract.address,
232
+ l1Recipient: EthAddress.fromString(uniswapPortal.address),
233
+ content: swapPrivateContent,
234
+ rollupVersion: new Fr(version),
235
+ chainId: new Fr(l1Client.chain.id),
236
+ });
269
237
 
270
238
  const withdrawContent = sha256ToField([
271
239
  Buffer.from(toFunctionSelector('withdraw(address,uint256,address)').substring(2), 'hex'),
@@ -274,39 +242,56 @@ export const uniswapL1L2TestSuite = (
274
242
  uniswapPortalAddress.toBuffer32(),
275
243
  ]);
276
244
 
277
- const withdrawLeaf = sha256ToField([
278
- wethCrossChainHarness.l2Bridge.address,
279
- new Fr(1), // aztec version
280
- wethCrossChainHarness.tokenPortalAddress.toBuffer32(),
281
- new Fr(publicClient.chain.id), // chain id
282
- withdrawContent,
283
- ]);
245
+ const withdrawLeaf = computeL2ToL1MessageHash({
246
+ l2Sender: wethCrossChainHarness.l2Bridge.address,
247
+ l1Recipient: wethCrossChainHarness.tokenPortalAddress,
248
+ content: withdrawContent,
249
+ rollupVersion: new Fr(version),
250
+ chainId: new Fr(l1Client.chain.id),
251
+ });
284
252
 
285
253
  // ensure that user's funds were burnt
286
254
  await wethCrossChainHarness.expectPrivateBalanceOnL2(ownerAddress, wethL2BalanceBeforeSwap - wethAmountToBridge);
287
255
  // ensure that uniswap contract didn't eat the funds.
288
256
  await wethCrossChainHarness.expectPublicBalanceOnL2(uniswapL2Contract.address, 0n);
289
257
 
290
- // Since the outbox is only consumable when the block is proven, we need to set the block to be proven
291
- await cheatCodes.rollup.markAsProven(await rollup.read.getPendingBlockNumber());
258
+ // Since the outbox is only consumable when the epoch is proven, we need to advance to the next epoch
259
+ // before we can ask the witness helper for a covering root.
260
+ const minedReceipt = await aztecNode.getTxReceipt(l2UniswapInteractionReceipt.txHash);
261
+ if (minedReceipt.epochNumber === undefined) {
262
+ throw new Error('L2 Uniswap interaction tx is not yet in an epoch');
263
+ }
264
+ await cheatCodes.rollup.advanceToEpoch(EpochNumber(minedReceipt.epochNumber + 1));
265
+ await waitForProven(aztecNode, l2UniswapInteractionReceipt, { provenTimeout: 300 });
292
266
 
293
267
  // 5. Consume L2 to L1 message by calling uniswapPortal.swap_private()
294
268
  logger.info('Execute withdraw and swap on the uniswapPortal!');
295
269
  const daiL1BalanceOfPortalBeforeSwap = await daiCrossChainHarness.getL1BalanceOf(
296
270
  daiCrossChainHarness.tokenPortalAddress,
297
271
  );
298
-
299
- const [swapPrivateL2MessageIndex, swapPrivateSiblingPath] = await aztecNode.getL2ToL1MessageMembershipWitness(
300
- l2UniswapInteractionReceipt.blockNumber!,
301
- swapPrivateLeaf,
272
+ const swapResult = await retryUntil(
273
+ () => aztecNode.getL2ToL1MembershipWitness(minedReceipt.txHash, swapPrivateLeaf),
274
+ 'swap private l2 to l1 witness',
275
+ 60,
276
+ 1,
302
277
  );
303
- const [withdrawL2MessageIndex, withdrawSiblingPath] = await aztecNode.getL2ToL1MessageMembershipWitness(
304
- l2UniswapInteractionReceipt.blockNumber!,
305
- withdrawLeaf,
278
+ const { epochNumber: epoch, numCheckpointsInEpoch } = swapResult;
279
+ const withdrawResult = await retryUntil(
280
+ () => aztecNode.getL2ToL1MembershipWitness(minedReceipt.txHash, withdrawLeaf),
281
+ 'withdraw l2 to l1 witness',
282
+ 60,
283
+ 1,
306
284
  );
307
285
 
286
+ const swapPrivateL2MessageIndex = swapResult.leafIndex;
287
+ const swapPrivateSiblingPath = swapResult.siblingPath;
288
+
289
+ const withdrawL2MessageIndex = withdrawResult.leafIndex;
290
+ const withdrawSiblingPath = withdrawResult.siblingPath;
291
+
308
292
  const withdrawMessageMetadata = {
309
- _l2BlockNumber: BigInt(l2UniswapInteractionReceipt.blockNumber!),
293
+ _epoch: BigInt(epoch),
294
+ _numCheckpointsInEpoch: BigInt(withdrawResult.numCheckpointsInEpoch),
310
295
  _leafIndex: BigInt(withdrawL2MessageIndex),
311
296
  _path: withdrawSiblingPath
312
297
  .toBufferArray()
@@ -314,7 +299,8 @@ export const uniswapL1L2TestSuite = (
314
299
  };
315
300
 
316
301
  const swapPrivateMessageMetadata = {
317
- _l2BlockNumber: BigInt(l2UniswapInteractionReceipt.blockNumber!),
302
+ _epoch: BigInt(epoch),
303
+ _numCheckpointsInEpoch: BigInt(numCheckpointsInEpoch),
318
304
  _leafIndex: BigInt(swapPrivateL2MessageIndex),
319
305
  _path: swapPrivateSiblingPath
320
306
  .toBufferArray()
@@ -333,7 +319,7 @@ export const uniswapL1L2TestSuite = (
333
319
  ] as const;
334
320
 
335
321
  // this should also insert a message into the inbox.
336
- const txReceipt = await daiCrossChainHarness.publicClient.waitForTransactionReceipt({
322
+ const txReceipt = await daiCrossChainHarness.l1Client.waitForTransactionReceipt({
337
323
  hash: await uniswapPortal.write.swapPrivate(swapArgs),
338
324
  });
339
325
 
@@ -372,10 +358,8 @@ export const uniswapL1L2TestSuite = (
372
358
  logger.info('WETH balance after swap : ', wethL2BalanceAfterSwap.toString());
373
359
  logger.info('DAI balance after swap : ', daiL2BalanceAfterSwap.toString());
374
360
  });
375
- // docs:end:uniswap_private
376
361
 
377
362
  // TODO(#7463): reenable look into this failure https://github.com/AztecProtocol/aztec-packages/actions/runs/9912612912/job/27388320150?pr=7462
378
- // // docs:start:uniswap_public
379
363
  // it('should uniswap trade on L1 from L2 funds publicly (swaps WETH -> DAI)', async () => {
380
364
  // const wethL1BeforeBalance = await wethCrossChainHarness.getL1BalanceOf(ownerEthAddress);
381
365
 
@@ -461,10 +445,10 @@ export const uniswapL1L2TestSuite = (
461
445
  // ownerEthAddress,
462
446
  // nonceForSwap,
463
447
  // );
464
- // await ownerWallet.setPublicAuthWit({ caller: sponsorAddress, action }, true).send().wait();
448
+ // await ownerWallet.setPublicAuthWit({ caller: sponsorAddress, action }, true).send();
465
449
 
466
450
  // // 4.2 Call swap_public from user2 on behalf of owner
467
- // const uniswapL2Interaction = await action.send().wait();
451
+ // const uniswapL2Interaction = await action.send();
468
452
 
469
453
  // const swapPublicContent = sha256ToField([
470
454
  // Buffer.from(
@@ -525,7 +509,7 @@ export const uniswapL1L2TestSuite = (
525
509
  // );
526
510
 
527
511
  // const withdrawMessageMetadata = {
528
- // _l2BlockNumber: BigInt(uniswapL2Interaction.blockNumber!),
512
+ // _epoch: epoch,
529
513
  // _leafIndex: BigInt(withdrawL2MessageIndex),
530
514
  // _path: withdrawSiblingPath
531
515
  // .toBufferArray()
@@ -533,7 +517,7 @@ export const uniswapL1L2TestSuite = (
533
517
  // };
534
518
 
535
519
  // const swapPrivateMessageMetadata = {
536
- // _l2BlockNumber: BigInt(uniswapL2Interaction.blockNumber!),
520
+ // _epoch: epoch,
537
521
  // _leafIndex: BigInt(swapPrivateL2MessageIndex),
538
522
  // _path: swapPrivateSiblingPath
539
523
  // .toBufferArray()
@@ -608,7 +592,6 @@ export const uniswapL1L2TestSuite = (
608
592
  // logger.info('WETH balance after swap : ', wethL2BalanceAfterSwap.toString());
609
593
  // logger.info('DAI balance after swap : ', daiL2BalanceAfterSwap.toString());
610
594
  // });
611
- // // docs:end:uniswap_public
612
595
 
613
596
  // Edge cases for the private flow:
614
597
  // note - tests for uniswapPortal.sol and minting asset on L2 are covered in other tests.
@@ -620,14 +603,16 @@ export const uniswapL1L2TestSuite = (
620
603
  const expectedMessageHash = await computeAuthWitMessageHash(
621
604
  {
622
605
  caller: uniswapL2Contract.address,
623
- action: wethCrossChainHarness.l2Token.methods.transfer_to_public(
624
- ownerAddress,
625
- uniswapL2Contract.address,
626
- wethAmountToBridge,
627
- nonceForWETHTransferToPublicApproval,
628
- ),
606
+ call: await wethCrossChainHarness.l2Token.methods
607
+ .transfer_to_public(
608
+ ownerAddress,
609
+ uniswapL2Contract.address,
610
+ wethAmountToBridge,
611
+ nonceForWETHTransferToPublicApproval,
612
+ )
613
+ .getFunctionCall(),
629
614
  },
630
- { chainId: ownerWallet.getChainId(), version: ownerWallet.getVersion() },
615
+ await wallet.getChainInfo(),
631
616
  );
632
617
 
633
618
  await expect(
@@ -643,7 +628,7 @@ export const uniswapL1L2TestSuite = (
643
628
  Fr.random(),
644
629
  ownerEthAddress,
645
630
  )
646
- .prove(),
631
+ .simulate({ from: ownerAddress }),
647
632
  ).rejects.toThrow(`Unknown auth witness for message hash ${expectedMessageHash.toString()}`);
648
633
  });
649
634
 
@@ -655,7 +640,7 @@ export const uniswapL1L2TestSuite = (
655
640
  // 2. owner gives uniswap approval to transfer the funds to public:
656
641
  logger.info('Approving uniswap to transfer funds to public to self on my behalf');
657
642
  const nonceForWETHTransferToPublicApproval = new Fr(3n);
658
- await ownerWallet.createAuthWit({
643
+ const transferToPublicAuthwith = await wallet.createAuthWit(ownerAddress, {
659
644
  caller: uniswapL2Contract.address,
660
645
  action: wethCrossChainHarness.l2Token.methods.transfer_to_public(
661
646
  ownerAddress,
@@ -680,7 +665,7 @@ export const uniswapL1L2TestSuite = (
680
665
  Fr.random(),
681
666
  ownerEthAddress,
682
667
  )
683
- .prove(),
668
+ .send({ from: ownerAddress, authWitnesses: [transferToPublicAuthwith] }),
684
669
  ).rejects.toThrow('Assertion failed: input_asset address is not the same as seen in the bridge contract');
685
670
  });
686
671
 
@@ -692,7 +677,8 @@ export const uniswapL1L2TestSuite = (
692
677
 
693
678
  // 2. Give approval to uniswap to transfer funds to itself
694
679
  const nonceForWETHTransferApproval = new Fr(2n);
695
- const validateActionInteraction = await ownerWallet.setPublicAuthWit(
680
+ const validateActionInteraction = await wallet.setPublicAuthWit(
681
+ ownerAddress,
696
682
  {
697
683
  caller: uniswapL2Contract.address,
698
684
  action: wethCrossChainHarness.l2Token.methods.transfer_in_public(
@@ -704,7 +690,7 @@ export const uniswapL1L2TestSuite = (
704
690
  },
705
691
  true,
706
692
  );
707
- await validateActionInteraction.send().wait();
693
+ await validateActionInteraction.send();
708
694
 
709
695
  // No approval to call `swap` but should work even without it:
710
696
  const [_, secretHashForDepositingSwappedDai] = await generateClaimSecret();
@@ -723,8 +709,7 @@ export const uniswapL1L2TestSuite = (
723
709
  ownerEthAddress,
724
710
  Fr.ZERO, // nonce for swap -> doesn't matter
725
711
  )
726
- .send()
727
- .wait();
712
+ .send({ from: ownerAddress });
728
713
  // check weth balance of owner on L2 (we first bridged `wethAmountToBridge` into L2 and now withdrew it!)
729
714
  await wethCrossChainHarness.expectPublicBalanceOnL2(ownerAddress, 0n);
730
715
  });
@@ -736,32 +721,35 @@ export const uniswapL1L2TestSuite = (
736
721
  const nonceForWETHTransferApproval = new Fr(3n);
737
722
  const nonceForSwap = new Fr(3n);
738
723
  const secretHashForDepositingSwappedDai = new Fr(4n);
739
- const action = uniswapL2Contract
740
- .withWallet(sponsorWallet)
741
- .methods.swap_public(
742
- ownerAddress,
743
- wethCrossChainHarness.l2Bridge.address,
744
- wethAmountToBridge,
745
- daiCrossChainHarness.l2Bridge.address,
746
- nonceForWETHTransferApproval,
747
- uniswapFeeTier,
748
- minimumOutputAmount,
749
- ownerAddress,
750
- secretHashForDepositingSwappedDai,
751
- ownerEthAddress,
752
- nonceForSwap,
753
- );
754
- const validateActionInteraction = await ownerWallet.setPublicAuthWit({ caller: approvedUser, action }, true);
755
- await validateActionInteraction.send().wait();
724
+ const action = uniswapL2Contract.methods.swap_public(
725
+ ownerAddress,
726
+ wethCrossChainHarness.l2Bridge.address,
727
+ wethAmountToBridge,
728
+ daiCrossChainHarness.l2Bridge.address,
729
+ nonceForWETHTransferApproval,
730
+ uniswapFeeTier,
731
+ minimumOutputAmount,
732
+ ownerAddress,
733
+ secretHashForDepositingSwappedDai,
734
+ ownerEthAddress,
735
+ nonceForSwap,
736
+ );
737
+ const validateActionInteraction = await wallet.setPublicAuthWit(
738
+ ownerAddress,
739
+ { caller: approvedUser, action },
740
+ true,
741
+ );
742
+ await validateActionInteraction.send();
756
743
 
757
- await expect(action.simulate()).rejects.toThrow(/unauthorized/);
744
+ await expect(action.simulate({ from: sponsorAddress })).rejects.toThrow(/unauthorized/);
758
745
  });
759
746
 
760
747
  it("uniswap can't pull funds without transfer approval", async () => {
761
748
  // swap should fail since no transfer approval to uniswap:
762
749
  const nonceForWETHTransferApproval = new Fr(4n);
763
750
 
764
- const validateActionInteraction = await ownerWallet.setPublicAuthWit(
751
+ const validateActionInteraction = await wallet.setPublicAuthWit(
752
+ ownerAddress,
765
753
  {
766
754
  caller: uniswapL2Contract.address,
767
755
  action: wethCrossChainHarness.l2Token.methods.transfer_in_public(
@@ -773,7 +761,7 @@ export const uniswapL1L2TestSuite = (
773
761
  },
774
762
  true,
775
763
  );
776
- await validateActionInteraction.send().wait();
764
+ await validateActionInteraction.send();
777
765
 
778
766
  await expect(
779
767
  uniswapL2Contract.methods
@@ -790,7 +778,7 @@ export const uniswapL1L2TestSuite = (
790
778
  ownerEthAddress,
791
779
  Fr.ZERO,
792
780
  )
793
- .simulate(),
781
+ .simulate({ from: ownerAddress }),
794
782
  ).rejects.toThrow(/unauthorized/);
795
783
  });
796
784
 
@@ -803,7 +791,7 @@ export const uniswapL1L2TestSuite = (
803
791
  // Owner gives uniswap approval to transfer the funds to public to self on its behalf
804
792
  logger.info('Approving uniswap to transfer the funds to public to self on my behalf');
805
793
  const nonceForWETHTransferToPublicApproval = new Fr(4n);
806
- await ownerWallet.createAuthWit({
794
+ const transferToPublicAuhtwit = await wallet.createAuthWit(ownerAddress, {
807
795
  caller: uniswapL2Contract.address,
808
796
  action: wethCrossChainHarness.l2Token.methods.transfer_to_public(
809
797
  ownerAddress,
@@ -818,7 +806,7 @@ export const uniswapL1L2TestSuite = (
818
806
  logger.info('Withdrawing weth to L1 and sending message to swap to dai');
819
807
 
820
808
  const [, secretHashForDepositingSwappedDai] = await generateClaimSecret();
821
- const withdrawReceipt = await uniswapL2Contract.methods
809
+ const { receipt: withdrawReceipt } = await uniswapL2Contract.methods
822
810
  .swap_private(
823
811
  wethCrossChainHarness.l2Token.address,
824
812
  wethCrossChainHarness.l2Bridge.address,
@@ -830,8 +818,7 @@ export const uniswapL1L2TestSuite = (
830
818
  secretHashForDepositingSwappedDai,
831
819
  ownerEthAddress,
832
820
  )
833
- .send()
834
- .wait();
821
+ .send({ from: ownerAddress, authWitnesses: [transferToPublicAuhtwit] });
835
822
 
836
823
  const swapPrivateContent = sha256ToField([
837
824
  Buffer.from(
@@ -847,13 +834,13 @@ export const uniswapL1L2TestSuite = (
847
834
  ownerEthAddress.toBuffer32(),
848
835
  ]);
849
836
 
850
- const swapPrivateLeaf = sha256ToField([
851
- uniswapL2Contract.address,
852
- new Fr(1), // aztec version
853
- EthAddress.fromString(uniswapPortal.address).toBuffer32(),
854
- new Fr(publicClient.chain.id), // chain id
855
- swapPrivateContent,
856
- ]);
837
+ const swapPrivateLeaf = computeL2ToL1MessageHash({
838
+ l2Sender: uniswapL2Contract.address,
839
+ l1Recipient: EthAddress.fromString(uniswapPortal.address),
840
+ content: swapPrivateContent,
841
+ rollupVersion: new Fr(version),
842
+ chainId: new Fr(l1Client.chain.id),
843
+ });
857
844
 
858
845
  const withdrawContent = sha256ToField([
859
846
  Buffer.from(toFunctionSelector('withdraw(address,uint256,address)').substring(2), 'hex'),
@@ -862,25 +849,49 @@ export const uniswapL1L2TestSuite = (
862
849
  uniswapPortalAddress.toBuffer32(),
863
850
  ]);
864
851
 
865
- const withdrawLeaf = sha256ToField([
866
- wethCrossChainHarness.l2Bridge.address,
867
- new Fr(1), // aztec version
868
- wethCrossChainHarness.tokenPortalAddress.toBuffer32(),
869
- new Fr(publicClient.chain.id), // chain id
870
- withdrawContent,
871
- ]);
852
+ const withdrawLeaf = computeL2ToL1MessageHash({
853
+ l2Sender: wethCrossChainHarness.l2Bridge.address,
854
+ l1Recipient: wethCrossChainHarness.tokenPortalAddress,
855
+ content: withdrawContent,
856
+ rollupVersion: new Fr(version),
857
+ chainId: new Fr(l1Client.chain.id),
858
+ });
859
+
860
+ // ensure that user's funds were burnt
861
+ await wethCrossChainHarness.expectPrivateBalanceOnL2(ownerAddress, wethL2BalanceBeforeSwap - wethAmountToBridge);
872
862
 
873
- const [swapPrivateL2MessageIndex, swapPrivateSiblingPath] = await aztecNode.getL2ToL1MessageMembershipWitness(
874
- withdrawReceipt.blockNumber!,
875
- swapPrivateLeaf,
863
+ // Since the outbox is only consumable when the epoch is proven, we need to advance to the next epoch
864
+ // before we can ask the witness helper for a covering root.
865
+ const minedReceipt = await aztecNode.getTxReceipt(withdrawReceipt.txHash);
866
+ if (minedReceipt.epochNumber === undefined) {
867
+ throw new Error('Withdraw tx is not yet in an epoch');
868
+ }
869
+ await cheatCodes.rollup.advanceToEpoch(EpochNumber(minedReceipt.epochNumber + 1));
870
+ await waitForProven(aztecNode, withdrawReceipt, { provenTimeout: 300 });
871
+
872
+ const swapResult = await retryUntil(
873
+ () => aztecNode.getL2ToL1MembershipWitness(minedReceipt.txHash, swapPrivateLeaf),
874
+ 'swap private l2 to l1 witness',
875
+ 60,
876
+ 1,
876
877
  );
877
- const [withdrawL2MessageIndex, withdrawSiblingPath] = await aztecNode.getL2ToL1MessageMembershipWitness(
878
- withdrawReceipt.blockNumber!,
879
- withdrawLeaf,
878
+ const { epochNumber: epoch, numCheckpointsInEpoch } = swapResult;
879
+ const withdrawResult = await retryUntil(
880
+ () => aztecNode.getL2ToL1MembershipWitness(minedReceipt.txHash, withdrawLeaf),
881
+ 'withdraw l2 to l1 witness',
882
+ 60,
883
+ 1,
880
884
  );
881
885
 
886
+ const swapPrivateL2MessageIndex = swapResult.leafIndex;
887
+ const swapPrivateSiblingPath = swapResult.siblingPath;
888
+
889
+ const withdrawL2MessageIndex = withdrawResult.leafIndex;
890
+ const withdrawSiblingPath = withdrawResult.siblingPath;
891
+
882
892
  const withdrawMessageMetadata = {
883
- _l2BlockNumber: BigInt(withdrawReceipt.blockNumber!),
893
+ _epoch: BigInt(epoch),
894
+ _numCheckpointsInEpoch: BigInt(withdrawResult.numCheckpointsInEpoch),
884
895
  _leafIndex: BigInt(withdrawL2MessageIndex),
885
896
  _path: withdrawSiblingPath
886
897
  .toBufferArray()
@@ -888,19 +899,14 @@ export const uniswapL1L2TestSuite = (
888
899
  };
889
900
 
890
901
  const swapPrivateMessageMetadata = {
891
- _l2BlockNumber: BigInt(withdrawReceipt.blockNumber!),
902
+ _epoch: BigInt(epoch),
903
+ _numCheckpointsInEpoch: BigInt(numCheckpointsInEpoch),
892
904
  _leafIndex: BigInt(swapPrivateL2MessageIndex),
893
905
  _path: swapPrivateSiblingPath
894
906
  .toBufferArray()
895
907
  .map((buf: Buffer) => `0x${buf.toString('hex')}`) as readonly `0x${string}`[],
896
908
  };
897
909
 
898
- // ensure that user's funds were burnt
899
- await wethCrossChainHarness.expectPrivateBalanceOnL2(ownerAddress, wethL2BalanceBeforeSwap - wethAmountToBridge);
900
-
901
- // Since the outbox is only consumable when the block is proven, we need to set the block to be proven
902
- await cheatCodes.rollup.markAsProven(await rollup.read.getPendingBlockNumber());
903
-
904
910
  // On L1 call swap_public!
905
911
  logger.info('call swap_public on L1');
906
912
  const swapArgs = [
@@ -927,7 +933,8 @@ export const uniswapL1L2TestSuite = (
927
933
 
928
934
  // Owner gives uniswap approval to transfer funds on its behalf
929
935
  const nonceForWETHTransferApproval = new Fr(5n);
930
- const validateActionInteraction = await ownerWallet.setPublicAuthWit(
936
+ const validateActionInteraction = await wallet.setPublicAuthWit(
937
+ ownerAddress,
931
938
  {
932
939
  caller: uniswapL2Contract.address,
933
940
  action: wethCrossChainHarness.l2Token.methods.transfer_in_public(
@@ -939,11 +946,11 @@ export const uniswapL1L2TestSuite = (
939
946
  },
940
947
  true,
941
948
  );
942
- await validateActionInteraction.send().wait();
949
+ await validateActionInteraction.send();
943
950
 
944
951
  // Call swap_public on L2
945
952
  const secretHashForDepositingSwappedDai = Fr.random();
946
- const withdrawReceipt = await uniswapL2Contract.methods
953
+ const { receipt: withdrawReceipt } = await uniswapL2Contract.methods
947
954
  .swap_public(
948
955
  ownerAddress,
949
956
  wethCrossChainHarness.l2Bridge.address,
@@ -957,8 +964,7 @@ export const uniswapL1L2TestSuite = (
957
964
  ownerEthAddress,
958
965
  Fr.ZERO,
959
966
  )
960
- .send()
961
- .wait();
967
+ .send({ from: ownerAddress });
962
968
 
963
969
  const swapPublicContent = sha256ToField([
964
970
  Buffer.from(
@@ -977,13 +983,13 @@ export const uniswapL1L2TestSuite = (
977
983
  ownerEthAddress.toBuffer32(),
978
984
  ]);
979
985
 
980
- const swapPublicLeaf = sha256ToField([
981
- uniswapL2Contract.address,
982
- new Fr(1), // aztec version
983
- EthAddress.fromString(uniswapPortal.address).toBuffer32(),
984
- new Fr(publicClient.chain.id), // chain id
985
- swapPublicContent,
986
- ]);
986
+ const swapPublicLeaf = computeL2ToL1MessageHash({
987
+ l2Sender: uniswapL2Contract.address,
988
+ l1Recipient: EthAddress.fromString(uniswapPortal.address),
989
+ content: swapPublicContent,
990
+ rollupVersion: new Fr(version),
991
+ chainId: new Fr(l1Client.chain.id),
992
+ });
987
993
 
988
994
  const withdrawContent = sha256ToField([
989
995
  Buffer.from(toFunctionSelector('withdraw(address,uint256,address)').substring(2), 'hex'),
@@ -992,25 +998,49 @@ export const uniswapL1L2TestSuite = (
992
998
  uniswapPortalAddress.toBuffer32(),
993
999
  ]);
994
1000
 
995
- const withdrawLeaf = sha256ToField([
996
- wethCrossChainHarness.l2Bridge.address,
997
- new Fr(1), // aztec version
998
- wethCrossChainHarness.tokenPortalAddress.toBuffer32(),
999
- new Fr(publicClient.chain.id), // chain id
1000
- withdrawContent,
1001
- ]);
1001
+ const withdrawLeaf = computeL2ToL1MessageHash({
1002
+ l2Sender: wethCrossChainHarness.l2Bridge.address,
1003
+ l1Recipient: wethCrossChainHarness.tokenPortalAddress,
1004
+ content: withdrawContent,
1005
+ rollupVersion: new Fr(version),
1006
+ chainId: new Fr(l1Client.chain.id),
1007
+ });
1002
1008
 
1003
- const [swapPublicL2MessageIndex, swapPublicSiblingPath] = await aztecNode.getL2ToL1MessageMembershipWitness(
1004
- withdrawReceipt.blockNumber!,
1005
- swapPublicLeaf,
1009
+ // check weth balance of owner on L2 (we first bridged `wethAmountToBridge` into L2 and now withdrew it!)
1010
+ await wethCrossChainHarness.expectPublicBalanceOnL2(ownerAddress, 0n);
1011
+
1012
+ // Since the outbox is only consumable when the epoch is proven, we need to advance to the next epoch
1013
+ // before we can ask the witness helper for a covering root.
1014
+ const minedReceipt = await aztecNode.getTxReceipt(withdrawReceipt.txHash);
1015
+ if (minedReceipt.epochNumber === undefined) {
1016
+ throw new Error('Withdraw tx is not yet in an epoch');
1017
+ }
1018
+ await cheatCodes.rollup.advanceToEpoch(EpochNumber(minedReceipt.epochNumber + 1));
1019
+ await waitForProven(aztecNode, withdrawReceipt, { provenTimeout: 300 });
1020
+
1021
+ const swapResult = await retryUntil(
1022
+ () => aztecNode.getL2ToL1MembershipWitness(minedReceipt.txHash, swapPublicLeaf),
1023
+ 'swap public l2 to l1 witness',
1024
+ 60,
1025
+ 1,
1006
1026
  );
1007
- const [withdrawL2MessageIndex, withdrawSiblingPath] = await aztecNode.getL2ToL1MessageMembershipWitness(
1008
- withdrawReceipt.blockNumber!,
1009
- withdrawLeaf,
1027
+ const { epochNumber: epoch, numCheckpointsInEpoch } = swapResult;
1028
+ const withdrawResult = await retryUntil(
1029
+ () => aztecNode.getL2ToL1MembershipWitness(minedReceipt.txHash, withdrawLeaf),
1030
+ 'withdraw l2 to l1 witness',
1031
+ 60,
1032
+ 1,
1010
1033
  );
1011
1034
 
1035
+ const swapPublicL2MessageIndex = swapResult.leafIndex;
1036
+ const swapPublicSiblingPath = swapResult.siblingPath;
1037
+
1038
+ const withdrawL2MessageIndex = withdrawResult.leafIndex;
1039
+ const withdrawSiblingPath = withdrawResult.siblingPath;
1040
+
1012
1041
  const withdrawMessageMetadata = {
1013
- _l2BlockNumber: BigInt(withdrawReceipt.blockNumber!),
1042
+ _epoch: BigInt(epoch),
1043
+ _numCheckpointsInEpoch: BigInt(withdrawResult.numCheckpointsInEpoch),
1014
1044
  _leafIndex: BigInt(withdrawL2MessageIndex),
1015
1045
  _path: withdrawSiblingPath
1016
1046
  .toBufferArray()
@@ -1018,19 +1048,14 @@ export const uniswapL1L2TestSuite = (
1018
1048
  };
1019
1049
 
1020
1050
  const swapPublicMessageMetadata = {
1021
- _l2BlockNumber: BigInt(withdrawReceipt.blockNumber!),
1051
+ _epoch: BigInt(epoch),
1052
+ _numCheckpointsInEpoch: BigInt(numCheckpointsInEpoch),
1022
1053
  _leafIndex: BigInt(swapPublicL2MessageIndex),
1023
1054
  _path: swapPublicSiblingPath
1024
1055
  .toBufferArray()
1025
1056
  .map((buf: Buffer) => `0x${buf.toString('hex')}`) as readonly `0x${string}`[],
1026
1057
  };
1027
1058
 
1028
- // check weth balance of owner on L2 (we first bridged `wethAmountToBridge` into L2 and now withdrew it!)
1029
- await wethCrossChainHarness.expectPublicBalanceOnL2(ownerAddress, 0n);
1030
-
1031
- // Since the outbox is only consumable when the block is proven, we need to set the block to be proven
1032
- await cheatCodes.rollup.markAsProven(await rollup.read.getPendingBlockNumber());
1033
-
1034
1059
  // Call swap_private on L1
1035
1060
  logger.info('Execute withdraw and swap on the uniswapPortal!');
1036
1061