@aztec/end-to-end 0.0.0-test.1 → 0.0.1-commit.001888fc

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 (293) hide show
  1. package/dest/bench/client_flows/benchmark.d.ts +62 -0
  2. package/dest/bench/client_flows/benchmark.d.ts.map +1 -0
  3. package/dest/bench/client_flows/benchmark.js +281 -0
  4. package/dest/bench/client_flows/client_flows_benchmark.d.ts +79 -0
  5. package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -0
  6. package/dest/bench/client_flows/client_flows_benchmark.js +329 -0
  7. package/dest/bench/client_flows/config.d.ts +14 -0
  8. package/dest/bench/client_flows/config.d.ts.map +1 -0
  9. package/dest/bench/client_flows/config.js +124 -0
  10. package/dest/bench/client_flows/data_extractor.d.ts +2 -0
  11. package/dest/bench/client_flows/data_extractor.d.ts.map +1 -0
  12. package/dest/bench/client_flows/data_extractor.js +79 -0
  13. package/dest/bench/utils.d.ts +16 -41
  14. package/dest/bench/utils.d.ts.map +1 -1
  15. package/dest/bench/utils.js +44 -72
  16. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +28 -19
  17. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts.map +1 -1
  18. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.js +125 -103
  19. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +32 -32
  20. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts.map +1 -1
  21. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.js +105 -104
  22. package/dest/e2e_deploy_contract/deploy_test.d.ts +19 -10
  23. package/dest/e2e_deploy_contract/deploy_test.d.ts.map +1 -1
  24. package/dest/e2e_deploy_contract/deploy_test.js +26 -27
  25. package/dest/e2e_epochs/epochs_test.d.ts +75 -24
  26. package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
  27. package/dest/e2e_epochs/epochs_test.js +290 -58
  28. package/dest/e2e_fees/bridging_race.notest.d.ts +2 -0
  29. package/dest/e2e_fees/bridging_race.notest.d.ts.map +1 -0
  30. package/dest/e2e_fees/bridging_race.notest.js +61 -0
  31. package/dest/e2e_fees/fees_test.d.ts +38 -23
  32. package/dest/e2e_fees/fees_test.d.ts.map +1 -1
  33. package/dest/e2e_fees/fees_test.js +169 -183
  34. package/dest/e2e_l1_publisher/write_json.d.ts +11 -0
  35. package/dest/e2e_l1_publisher/write_json.d.ts.map +1 -0
  36. package/dest/e2e_l1_publisher/write_json.js +56 -0
  37. package/dest/e2e_multi_validator/utils.d.ts +12 -0
  38. package/dest/e2e_multi_validator/utils.d.ts.map +1 -0
  39. package/dest/e2e_multi_validator/utils.js +214 -0
  40. package/dest/e2e_nested_contract/nested_contract_test.d.ts +15 -15
  41. package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +1 -1
  42. package/dest/e2e_nested_contract/nested_contract_test.js +36 -42
  43. package/dest/e2e_p2p/inactivity_slash_test.d.ts +31 -0
  44. package/dest/e2e_p2p/inactivity_slash_test.d.ts.map +1 -0
  45. package/dest/e2e_p2p/inactivity_slash_test.js +136 -0
  46. package/dest/e2e_p2p/p2p_network.d.ts +282 -27
  47. package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
  48. package/dest/e2e_p2p/p2p_network.js +255 -176
  49. package/dest/e2e_p2p/reqresp/utils.d.ts +22 -0
  50. package/dest/e2e_p2p/reqresp/utils.d.ts.map +1 -0
  51. package/dest/e2e_p2p/reqresp/utils.js +190 -0
  52. package/dest/e2e_p2p/shared.d.ts +64 -8
  53. package/dest/e2e_p2p/shared.d.ts.map +1 -1
  54. package/dest/e2e_p2p/shared.js +200 -27
  55. package/dest/e2e_storage_proof/fixtures/storage_proof_fetcher.d.ts +2 -0
  56. package/dest/e2e_storage_proof/fixtures/storage_proof_fetcher.d.ts.map +1 -0
  57. package/dest/e2e_storage_proof/fixtures/storage_proof_fetcher.js +184 -0
  58. package/dest/e2e_storage_proof/fixtures/storage_proof_fixture.d.ts +18 -0
  59. package/dest/e2e_storage_proof/fixtures/storage_proof_fixture.d.ts.map +1 -0
  60. package/dest/e2e_storage_proof/fixtures/storage_proof_fixture.js +120 -0
  61. package/dest/e2e_token_contract/token_contract_test.d.ts +29 -14
  62. package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -1
  63. package/dest/e2e_token_contract/token_contract_test.js +107 -75
  64. package/dest/fixtures/authwit_proxy.d.ts +15 -0
  65. package/dest/fixtures/authwit_proxy.d.ts.map +1 -0
  66. package/dest/fixtures/authwit_proxy.js +30 -0
  67. package/dest/fixtures/e2e_prover_test.d.ts +55 -0
  68. package/dest/fixtures/e2e_prover_test.d.ts.map +1 -0
  69. package/dest/fixtures/e2e_prover_test.js +271 -0
  70. package/dest/fixtures/elu_monitor.d.ts +21 -0
  71. package/dest/fixtures/elu_monitor.d.ts.map +1 -0
  72. package/dest/fixtures/elu_monitor.js +102 -0
  73. package/dest/fixtures/fixtures.d.ts +10 -8
  74. package/dest/fixtures/fixtures.d.ts.map +1 -1
  75. package/dest/fixtures/fixtures.js +11 -5
  76. package/dest/fixtures/get_acvm_config.d.ts +2 -2
  77. package/dest/fixtures/get_acvm_config.d.ts.map +1 -1
  78. package/dest/fixtures/get_acvm_config.js +3 -15
  79. package/dest/fixtures/get_bb_config.d.ts +2 -2
  80. package/dest/fixtures/get_bb_config.d.ts.map +1 -1
  81. package/dest/fixtures/get_bb_config.js +10 -17
  82. package/dest/fixtures/ha_setup.d.ts +71 -0
  83. package/dest/fixtures/ha_setup.d.ts.map +1 -0
  84. package/dest/fixtures/ha_setup.js +116 -0
  85. package/dest/fixtures/index.d.ts +2 -1
  86. package/dest/fixtures/index.d.ts.map +1 -1
  87. package/dest/fixtures/index.js +1 -0
  88. package/dest/fixtures/l1_to_l2_messaging.d.ts +11 -7
  89. package/dest/fixtures/l1_to_l2_messaging.d.ts.map +1 -1
  90. package/dest/fixtures/l1_to_l2_messaging.js +45 -19
  91. package/dest/fixtures/logging.d.ts +1 -1
  92. package/dest/fixtures/setup.d.ts +239 -0
  93. package/dest/fixtures/setup.d.ts.map +1 -0
  94. package/dest/fixtures/setup.js +606 -0
  95. package/dest/fixtures/setup_p2p_test.d.ts +23 -15
  96. package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
  97. package/dest/fixtures/setup_p2p_test.js +102 -31
  98. package/dest/fixtures/token_utils.d.ts +10 -4
  99. package/dest/fixtures/token_utils.d.ts.map +1 -1
  100. package/dest/fixtures/token_utils.js +33 -13
  101. package/dest/fixtures/utils.d.ts +5 -153
  102. package/dest/fixtures/utils.d.ts.map +1 -1
  103. package/dest/fixtures/utils.js +4 -552
  104. package/dest/fixtures/web3signer.d.ts +5 -0
  105. package/dest/fixtures/web3signer.d.ts.map +1 -0
  106. package/dest/fixtures/web3signer.js +53 -0
  107. package/dest/fixtures/with_telemetry_utils.d.ts +2 -2
  108. package/dest/fixtures/with_telemetry_utils.d.ts.map +1 -1
  109. package/dest/fixtures/with_telemetry_utils.js +2 -2
  110. package/dest/index.d.ts +1 -1
  111. package/dest/quality_of_service/grafana_client.d.ts +41 -0
  112. package/dest/quality_of_service/grafana_client.d.ts.map +1 -0
  113. package/dest/quality_of_service/{alert_checker.js → grafana_client.js} +1 -1
  114. package/dest/quality_of_service/prometheus_client.d.ts +38 -0
  115. package/dest/quality_of_service/prometheus_client.d.ts.map +1 -0
  116. package/dest/quality_of_service/prometheus_client.js +67 -0
  117. package/dest/shared/cross_chain_test_harness.d.ts +44 -27
  118. package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
  119. package/dest/shared/cross_chain_test_harness.js +107 -53
  120. package/dest/shared/gas_portal_test_harness.d.ts +33 -25
  121. package/dest/shared/gas_portal_test_harness.d.ts.map +1 -1
  122. package/dest/shared/gas_portal_test_harness.js +51 -30
  123. package/dest/shared/index.d.ts +3 -2
  124. package/dest/shared/index.d.ts.map +1 -1
  125. package/dest/shared/index.js +1 -0
  126. package/dest/shared/jest_setup.d.ts +1 -1
  127. package/dest/shared/jest_setup.js +42 -2
  128. package/dest/shared/mock_state_view.d.ts +86 -0
  129. package/dest/shared/mock_state_view.d.ts.map +1 -0
  130. package/dest/shared/mock_state_view.js +186 -0
  131. package/dest/shared/submit-transactions.d.ts +6 -4
  132. package/dest/shared/submit-transactions.d.ts.map +1 -1
  133. package/dest/shared/submit-transactions.js +15 -16
  134. package/dest/shared/uniswap_l1_l2.d.ts +3 -25
  135. package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
  136. package/dest/shared/uniswap_l1_l2.js +175 -126
  137. package/dest/simulators/index.d.ts +1 -1
  138. package/dest/simulators/lending_simulator.d.ts +7 -7
  139. package/dest/simulators/lending_simulator.d.ts.map +1 -1
  140. package/dest/simulators/lending_simulator.js +17 -18
  141. package/dest/simulators/token_simulator.d.ts +6 -3
  142. package/dest/simulators/token_simulator.d.ts.map +1 -1
  143. package/dest/simulators/token_simulator.js +12 -30
  144. package/dest/spartan/setup_test_wallets.d.ts +36 -11
  145. package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
  146. package/dest/spartan/setup_test_wallets.js +276 -62
  147. package/dest/spartan/tx_metrics.d.ts +88 -0
  148. package/dest/spartan/tx_metrics.d.ts.map +1 -0
  149. package/dest/spartan/tx_metrics.js +422 -0
  150. package/dest/spartan/utils/bot.d.ts +28 -0
  151. package/dest/spartan/utils/bot.d.ts.map +1 -0
  152. package/dest/spartan/utils/bot.js +142 -0
  153. package/dest/spartan/utils/chaos.d.ts +79 -0
  154. package/dest/spartan/utils/chaos.d.ts.map +1 -0
  155. package/dest/spartan/utils/chaos.js +142 -0
  156. package/dest/spartan/utils/clients.d.ts +39 -0
  157. package/dest/spartan/utils/clients.d.ts.map +1 -0
  158. package/dest/spartan/utils/clients.js +90 -0
  159. package/dest/spartan/utils/config.d.ts +45 -0
  160. package/dest/spartan/utils/config.d.ts.map +1 -0
  161. package/dest/spartan/utils/config.js +23 -0
  162. package/dest/spartan/utils/health.d.ts +63 -0
  163. package/dest/spartan/utils/health.d.ts.map +1 -0
  164. package/dest/spartan/utils/health.js +202 -0
  165. package/dest/spartan/utils/helm.d.ts +15 -0
  166. package/dest/spartan/utils/helm.d.ts.map +1 -0
  167. package/dest/spartan/utils/helm.js +47 -0
  168. package/dest/spartan/utils/index.d.ts +11 -0
  169. package/dest/spartan/utils/index.d.ts.map +1 -0
  170. package/dest/spartan/utils/index.js +22 -0
  171. package/dest/spartan/utils/k8s.d.ts +128 -0
  172. package/dest/spartan/utils/k8s.d.ts.map +1 -0
  173. package/dest/spartan/utils/k8s.js +381 -0
  174. package/dest/spartan/utils/nodes.d.ts +40 -0
  175. package/dest/spartan/utils/nodes.d.ts.map +1 -0
  176. package/dest/spartan/utils/nodes.js +461 -0
  177. package/dest/spartan/utils/pod_logs.d.ts +25 -0
  178. package/dest/spartan/utils/pod_logs.d.ts.map +1 -0
  179. package/dest/spartan/utils/pod_logs.js +74 -0
  180. package/dest/spartan/utils/scripts.d.ts +30 -0
  181. package/dest/spartan/utils/scripts.d.ts.map +1 -0
  182. package/dest/spartan/utils/scripts.js +81 -0
  183. package/dest/spartan/utils.d.ts +2 -415
  184. package/dest/spartan/utils.d.ts.map +1 -1
  185. package/dest/spartan/utils.js +1 -445
  186. package/dest/test-wallet/test_wallet.d.ts +83 -0
  187. package/dest/test-wallet/test_wallet.d.ts.map +1 -0
  188. package/dest/test-wallet/test_wallet.js +214 -0
  189. package/dest/test-wallet/utils.d.ts +41 -0
  190. package/dest/test-wallet/utils.d.ts.map +1 -0
  191. package/dest/test-wallet/utils.js +71 -0
  192. package/dest/test-wallet/wallet_worker_script.d.ts +2 -0
  193. package/dest/test-wallet/wallet_worker_script.d.ts.map +1 -0
  194. package/dest/test-wallet/wallet_worker_script.js +48 -0
  195. package/dest/test-wallet/worker_wallet.d.ts +52 -0
  196. package/dest/test-wallet/worker_wallet.d.ts.map +1 -0
  197. package/dest/test-wallet/worker_wallet.js +151 -0
  198. package/dest/test-wallet/worker_wallet_schema.d.ts +274 -0
  199. package/dest/test-wallet/worker_wallet_schema.d.ts.map +1 -0
  200. package/dest/test-wallet/worker_wallet_schema.js +10 -0
  201. package/package.json +72 -62
  202. package/src/bench/client_flows/benchmark.ts +363 -0
  203. package/src/bench/client_flows/client_flows_benchmark.ts +388 -0
  204. package/src/bench/client_flows/config.ts +69 -0
  205. package/src/bench/client_flows/data_extractor.ts +89 -0
  206. package/src/bench/utils.ts +47 -86
  207. package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +149 -171
  208. package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +155 -182
  209. package/src/e2e_deploy_contract/deploy_test.ts +40 -48
  210. package/src/e2e_epochs/epochs_test.ts +364 -93
  211. package/src/e2e_fees/bridging_race.notest.ts +74 -0
  212. package/src/e2e_fees/fees_test.ts +213 -259
  213. package/src/e2e_l1_publisher/write_json.ts +77 -0
  214. package/src/e2e_multi_validator/utils.ts +258 -0
  215. package/src/e2e_nested_contract/nested_contract_test.ts +48 -59
  216. package/src/e2e_p2p/inactivity_slash_test.ts +179 -0
  217. package/src/e2e_p2p/p2p_network.ts +367 -234
  218. package/src/e2e_p2p/reqresp/utils.ts +256 -0
  219. package/src/e2e_p2p/shared.ts +315 -39
  220. package/src/e2e_storage_proof/fixtures/storage_proof.json +915 -0
  221. package/src/e2e_storage_proof/fixtures/storage_proof_fetcher.ts +190 -0
  222. package/src/e2e_storage_proof/fixtures/storage_proof_fixture.ts +173 -0
  223. package/src/e2e_token_contract/token_contract_test.ts +132 -126
  224. package/src/fixtures/authwit_proxy.ts +50 -0
  225. package/src/fixtures/dumps/epoch_proof_result.json +1 -1
  226. package/src/fixtures/e2e_prover_test.ts +332 -0
  227. package/src/fixtures/elu_monitor.ts +126 -0
  228. package/src/fixtures/fixtures.ts +15 -7
  229. package/src/fixtures/get_acvm_config.ts +4 -12
  230. package/src/fixtures/get_bb_config.ts +18 -13
  231. package/src/fixtures/ha_setup.ts +186 -0
  232. package/src/fixtures/index.ts +1 -0
  233. package/src/fixtures/l1_to_l2_messaging.ts +56 -24
  234. package/src/fixtures/setup.ts +903 -0
  235. package/src/fixtures/setup_p2p_test.ts +134 -50
  236. package/src/fixtures/token_utils.ts +37 -16
  237. package/src/fixtures/utils.ts +27 -820
  238. package/src/fixtures/web3signer.ts +63 -0
  239. package/src/fixtures/with_telemetry_utils.ts +2 -2
  240. package/src/guides/up_quick_start.sh +9 -17
  241. package/src/quality_of_service/{alert_checker.ts → grafana_client.ts} +2 -2
  242. package/src/quality_of_service/prometheus_client.ts +113 -0
  243. package/src/shared/cross_chain_test_harness.ts +110 -94
  244. package/src/shared/gas_portal_test_harness.ts +59 -50
  245. package/src/shared/index.ts +2 -1
  246. package/src/shared/jest_setup.ts +52 -2
  247. package/src/shared/mock_state_view.ts +188 -0
  248. package/src/shared/submit-transactions.ts +19 -20
  249. package/src/shared/uniswap_l1_l2.ts +207 -226
  250. package/src/simulators/lending_simulator.ts +18 -17
  251. package/src/simulators/token_simulator.ts +18 -34
  252. package/src/spartan/DEVELOP.md +128 -0
  253. package/src/spartan/setup_test_wallets.ts +393 -95
  254. package/src/spartan/tx_metrics.ts +376 -0
  255. package/src/spartan/utils/bot.ts +188 -0
  256. package/src/spartan/utils/chaos.ts +253 -0
  257. package/src/spartan/utils/clients.ts +100 -0
  258. package/src/spartan/utils/config.ts +29 -0
  259. package/src/spartan/utils/health.ts +255 -0
  260. package/src/spartan/utils/helm.ts +84 -0
  261. package/src/spartan/utils/index.ts +71 -0
  262. package/src/spartan/utils/k8s.ts +535 -0
  263. package/src/spartan/utils/nodes.ts +543 -0
  264. package/src/spartan/utils/pod_logs.ts +99 -0
  265. package/src/spartan/utils/scripts.ts +99 -0
  266. package/src/spartan/utils.ts +1 -582
  267. package/src/test-wallet/test_wallet.ts +306 -0
  268. package/src/test-wallet/utils.ts +112 -0
  269. package/src/test-wallet/wallet_worker_script.ts +60 -0
  270. package/src/test-wallet/worker_wallet.ts +213 -0
  271. package/src/test-wallet/worker_wallet_schema.ts +13 -0
  272. package/dest/e2e_prover/e2e_prover_test.d.ts +0 -56
  273. package/dest/e2e_prover/e2e_prover_test.d.ts.map +0 -1
  274. package/dest/e2e_prover/e2e_prover_test.js +0 -291
  275. package/dest/fixtures/setup_l1_contracts.d.ts +0 -6
  276. package/dest/fixtures/setup_l1_contracts.d.ts.map +0 -1
  277. package/dest/fixtures/setup_l1_contracts.js +0 -17
  278. package/dest/fixtures/snapshot_manager.d.ts +0 -87
  279. package/dest/fixtures/snapshot_manager.d.ts.map +0 -1
  280. package/dest/fixtures/snapshot_manager.js +0 -479
  281. package/dest/quality_of_service/alert_checker.d.ts +0 -41
  282. package/dest/quality_of_service/alert_checker.d.ts.map +0 -1
  283. package/dest/sample-dapp/connect.js +0 -12
  284. package/dest/sample-dapp/contracts.js +0 -10
  285. package/dest/sample-dapp/deploy.js +0 -35
  286. package/dest/sample-dapp/index.js +0 -98
  287. package/src/e2e_prover/e2e_prover_test.ts +0 -418
  288. package/src/fixtures/setup_l1_contracts.ts +0 -27
  289. package/src/fixtures/snapshot_manager.ts +0 -617
  290. package/src/sample-dapp/connect.mjs +0 -16
  291. package/src/sample-dapp/contracts.mjs +0 -14
  292. package/src/sample-dapp/deploy.mjs +0 -40
  293. package/src/sample-dapp/index.mjs +0 -128
@@ -1,30 +1,28 @@
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 { InboxAbi, UniswapPortalAbi, UniswapPortalBytecode } from '@aztec/l1-artifacts';
22
17
  import { UniswapContract } from '@aztec/noir-contracts.js/Uniswap';
18
+ import { computeL2ToL1MessageHash } from '@aztec/stdlib/hash';
19
+ import { computeL2ToL1MembershipWitness } from '@aztec/stdlib/messaging';
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 { type EndToEndContext, ensureAccountContractsPublished } from '../fixtures/utils.js';
25
+ import type { TestWallet } from '../test-wallet/test_wallet.js';
28
26
  import { CrossChainTestHarness } from './cross_chain_test_harness.js';
29
27
 
30
28
  // PSA: This tests works on forked mainnet. There is a dump of the data in `dumpedState` such that we
@@ -34,38 +32,13 @@ import { CrossChainTestHarness } from './cross_chain_test_harness.js';
34
32
  // anvil --fork-url https://mainnet.infura.io/v3/9928b52099854248b3a096be07a6b23c --fork-block-number 17514288 --chain-id 31337
35
33
  // For CI, this is configured in `run_tests.sh` and `docker-compose-images.yml`
36
34
 
37
- // docs:start:uniswap_l1_l2_test_setup_const
38
35
  const TIMEOUT = 360_000;
39
36
 
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
62
-
63
37
  export const uniswapL1L2TestSuite = (
64
- setup: () => Promise<UniswapSetupContext>,
38
+ setup: () => Promise<EndToEndContext>,
65
39
  cleanup: () => Promise<void>,
66
40
  expectedForkBlockNumber = 17514288,
67
41
  ) => {
68
- // docs:start:uniswap_l1_l2_test_beforeAll
69
42
  describe('uniswap_trade_on_l1_from_l2', () => {
70
43
  jest.setTimeout(TIMEOUT);
71
44
 
@@ -73,25 +46,22 @@ export const uniswapL1L2TestSuite = (
73
46
  const DAI_ADDRESS: EthAddress = EthAddress.fromString('0x6B175474E89094C44Da98b954EedeAC495271d0F');
74
47
 
75
48
  let aztecNode: AztecNode;
76
- let pxe: PXE;
77
49
  let logger: Logger;
78
50
 
79
- let walletClient: ViemWalletClient;
80
- let publicClient: ViemPublicClient;
51
+ let l1Client: ExtendedViemWalletClient;
81
52
 
82
- let ownerWallet: AccountWallet;
53
+ let wallet: TestWallet;
83
54
  let ownerAddress: AztecAddress;
84
55
  let ownerEthAddress: EthAddress;
85
56
  // does transactions on behalf of owner on Aztec:
86
- let sponsorWallet: AccountWallet;
87
- // let sponsorAddress: AztecAddress;
57
+ let sponsorAddress: AztecAddress;
88
58
 
89
59
  let daiCrossChainHarness: CrossChainTestHarness;
90
60
  let wethCrossChainHarness: CrossChainTestHarness;
91
61
 
92
- let deployL1ContractsValues: DeployL1ContractsReturnType;
93
- let rollup: GetContractReturnType<typeof RollupAbi, ViemWalletClient>;
94
- let uniswapPortal: GetContractReturnType<typeof UniswapPortalAbi, ViemWalletClient>;
62
+ let deployL1ContractsValues: DeployAztecL1ContractsReturnType;
63
+ let rollup: RollupContract;
64
+ let uniswapPortal: GetContractReturnType<typeof UniswapPortalAbi, ExtendedViemWalletClient>;
95
65
  let uniswapPortalAddress: EthAddress;
96
66
  let uniswapL2Contract: UniswapContract;
97
67
 
@@ -100,43 +70,41 @@ export const uniswapL1L2TestSuite = (
100
70
  const minimumOutputAmount = 0n;
101
71
 
102
72
  let cheatCodes: CheatCodes;
103
-
73
+ let version: number;
104
74
  beforeAll(async () => {
75
+ const t = await setup();
105
76
  ({
106
77
  aztecNode,
107
- pxe,
108
78
  logger,
109
- publicClient,
110
- walletClient,
111
- ownerWallet,
112
- sponsorWallet,
113
79
  deployL1ContractsValues,
114
80
  cheatCodes,
115
- } = await setup());
81
+ wallet,
82
+ accounts: [ownerAddress, sponsorAddress],
83
+ } = t);
84
+
85
+ l1Client = deployL1ContractsValues.l1Client;
86
+
87
+ t.watcher.setIsMarkingAsProven(false);
116
88
 
117
- if (Number(await publicClient.getBlockNumber()) < expectedForkBlockNumber) {
89
+ if (Number(await l1Client.getBlockNumber()) < expectedForkBlockNumber) {
118
90
  throw new Error('This test must be run on a fork of mainnet with the expected fork block');
119
91
  }
120
92
 
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]);
93
+ rollup = new RollupContract(
94
+ deployL1ContractsValues.l1Client,
95
+ deployL1ContractsValues.l1ContractAddresses.rollupAddress,
96
+ );
97
+ version = Number(await rollup.getVersion());
98
+ ownerEthAddress = EthAddress.fromString((await l1Client.getAddresses())[0]);
130
99
 
131
- await ensureAccountsPubliclyDeployed(ownerWallet, [ownerWallet, sponsorWallet]);
100
+ await ensureAccountContractsPublished(wallet, [ownerAddress, sponsorAddress]);
132
101
 
133
102
  logger.info('Deploying DAI Portal, initializing and deploying l2 contract...');
134
103
  daiCrossChainHarness = await CrossChainTestHarness.new(
135
104
  aztecNode,
136
- pxe,
137
- publicClient,
138
- walletClient,
139
- ownerWallet,
105
+ deployL1ContractsValues.l1Client,
106
+ wallet,
107
+ ownerAddress,
140
108
  logger,
141
109
  DAI_ADDRESS,
142
110
  );
@@ -144,31 +112,29 @@ export const uniswapL1L2TestSuite = (
144
112
  logger.info('Deploying WETH Portal, initializing and deploying l2 contract...');
145
113
  wethCrossChainHarness = await CrossChainTestHarness.new(
146
114
  aztecNode,
147
- pxe,
148
- publicClient,
149
- walletClient,
150
- ownerWallet,
115
+ l1Client,
116
+ wallet,
117
+ ownerAddress,
151
118
  logger,
152
119
  WETH9_ADDRESS,
153
120
  );
154
121
 
155
122
  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);
123
+ uniswapPortalAddress = await deployL1Contract(l1Client, UniswapPortalAbi, UniswapPortalBytecode).then(
124
+ ({ address }) => address,
125
+ );
162
126
 
163
127
  uniswapPortal = getContract({
164
128
  address: uniswapPortalAddress.toString(),
165
129
  abi: UniswapPortalAbi,
166
- client: walletClient,
130
+ client: l1Client,
167
131
  });
168
132
  // deploy l2 uniswap contract and attach to portal
169
- uniswapL2Contract = await UniswapContract.deploy(ownerWallet, uniswapPortalAddress).send().deployed();
133
+ ({ contract: uniswapL2Contract } = await UniswapContract.deploy(wallet, uniswapPortalAddress).send({
134
+ from: ownerAddress,
135
+ }));
170
136
 
171
- const registryAddress = (await pxe.getNodeInfo()).l1ContractAddresses.registryAddress;
137
+ const registryAddress = (await aztecNode.getNodeInfo()).l1ContractAddresses.registryAddress;
172
138
 
173
139
  await uniswapPortal.write.initialize(
174
140
  [registryAddress.toString(), uniswapL2Contract.address.toString()],
@@ -177,13 +143,12 @@ export const uniswapL1L2TestSuite = (
177
143
 
178
144
  // Give me some WETH so I can deposit to L2 and do the swap...
179
145
  logger.info('Getting some weth');
180
- const hash = await walletClient.sendTransaction({ to: WETH9_ADDRESS.toString(), value: parseEther('1000') });
181
- await publicClient.waitForTransactionReceipt({ hash });
146
+ const hash = await l1Client.sendTransaction({ to: WETH9_ADDRESS.toString(), value: parseEther('1000') });
147
+ await l1Client.waitForTransactionReceipt({ hash });
182
148
 
183
149
  const wethBalance = await wethCrossChainHarness.getL1BalanceOf(ownerEthAddress);
184
150
  expect(wethBalance).toBe(parseEther('1000'));
185
151
  });
186
- // docs:end:uniswap_l1_l2_test_beforeAll
187
152
 
188
153
  afterAll(async () => {
189
154
  await cleanup();
@@ -218,7 +183,7 @@ export const uniswapL1L2TestSuite = (
218
183
  // 3. Owner gives uniswap approval to transfer the funds to public to self on its behalf
219
184
  logger.info('Approving uniswap to transfer funds to public to self on my behalf');
220
185
  const nonceForWETHTransferToPublicApproval = new Fr(1n);
221
- await ownerWallet.createAuthWit({
186
+ const transferToPublicAuhtwit = await wallet.createAuthWit(ownerAddress, {
222
187
  caller: uniswapL2Contract.address,
223
188
  action: wethCrossChainHarness.l2Token.methods.transfer_to_public(
224
189
  ownerAddress,
@@ -232,7 +197,7 @@ export const uniswapL1L2TestSuite = (
232
197
  logger.info('Withdrawing weth to L1 and sending message to swap to dai');
233
198
  const [secretForDepositingSwappedDai, secretHashForDepositingSwappedDai] = await generateClaimSecret();
234
199
 
235
- const l2UniswapInteractionReceipt = await uniswapL2Contract.methods
200
+ const { receipt: l2UniswapInteractionReceipt } = await uniswapL2Contract.methods
236
201
  .swap_private(
237
202
  wethCrossChainHarness.l2Token.address,
238
203
  wethCrossChainHarness.l2Bridge.address,
@@ -244,8 +209,7 @@ export const uniswapL1L2TestSuite = (
244
209
  secretHashForDepositingSwappedDai,
245
210
  ownerEthAddress,
246
211
  )
247
- .send()
248
- .wait();
212
+ .send({ from: ownerAddress, authWitnesses: [transferToPublicAuhtwit] });
249
213
 
250
214
  const swapPrivateFunction = 'swap_private(address,uint256,uint24,address,uint256,bytes32,address)';
251
215
  const swapPrivateContent = sha256ToField([
@@ -259,13 +223,13 @@ export const uniswapL1L2TestSuite = (
259
223
  ownerEthAddress.toBuffer32(),
260
224
  ]);
261
225
 
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
- ]);
226
+ const swapPrivateLeaf = computeL2ToL1MessageHash({
227
+ l2Sender: uniswapL2Contract.address,
228
+ l1Recipient: EthAddress.fromString(uniswapPortal.address),
229
+ content: swapPrivateContent,
230
+ rollupVersion: new Fr(version),
231
+ chainId: new Fr(l1Client.chain.id),
232
+ });
269
233
 
270
234
  const withdrawContent = sha256ToField([
271
235
  Buffer.from(toFunctionSelector('withdraw(address,uint256,address)').substring(2), 'hex'),
@@ -274,39 +238,48 @@ export const uniswapL1L2TestSuite = (
274
238
  uniswapPortalAddress.toBuffer32(),
275
239
  ]);
276
240
 
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
- ]);
241
+ const withdrawLeaf = computeL2ToL1MessageHash({
242
+ l2Sender: wethCrossChainHarness.l2Bridge.address,
243
+ l1Recipient: wethCrossChainHarness.tokenPortalAddress,
244
+ content: withdrawContent,
245
+ rollupVersion: new Fr(version),
246
+ chainId: new Fr(l1Client.chain.id),
247
+ });
284
248
 
285
249
  // ensure that user's funds were burnt
286
250
  await wethCrossChainHarness.expectPrivateBalanceOnL2(ownerAddress, wethL2BalanceBeforeSwap - wethAmountToBridge);
287
251
  // ensure that uniswap contract didn't eat the funds.
288
252
  await wethCrossChainHarness.expectPublicBalanceOnL2(uniswapL2Contract.address, 0n);
289
253
 
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());
254
+ // Since the outbox is only consumable when the epoch is proven, we need to advance to the next epoch.
255
+ const swapResult = (await computeL2ToL1MembershipWitness(
256
+ aztecNode,
257
+ swapPrivateLeaf,
258
+ l2UniswapInteractionReceipt.txHash,
259
+ ))!;
260
+ const { epochNumber: epoch } = swapResult;
261
+ await cheatCodes.rollup.advanceToEpoch(EpochNumber(epoch + 1));
262
+ await waitForProven(aztecNode, l2UniswapInteractionReceipt, { provenTimeout: 300 });
292
263
 
293
264
  // 5. Consume L2 to L1 message by calling uniswapPortal.swap_private()
294
265
  logger.info('Execute withdraw and swap on the uniswapPortal!');
295
266
  const daiL1BalanceOfPortalBeforeSwap = await daiCrossChainHarness.getL1BalanceOf(
296
267
  daiCrossChainHarness.tokenPortalAddress,
297
268
  );
298
-
299
- const [swapPrivateL2MessageIndex, swapPrivateSiblingPath] = await aztecNode.getL2ToL1MessageMembershipWitness(
300
- l2UniswapInteractionReceipt.blockNumber!,
301
- swapPrivateLeaf,
302
- );
303
- const [withdrawL2MessageIndex, withdrawSiblingPath] = await aztecNode.getL2ToL1MessageMembershipWitness(
304
- l2UniswapInteractionReceipt.blockNumber!,
269
+ const withdrawResult = (await computeL2ToL1MembershipWitness(
270
+ aztecNode,
305
271
  withdrawLeaf,
306
- );
272
+ l2UniswapInteractionReceipt.txHash,
273
+ ))!;
274
+
275
+ const swapPrivateL2MessageIndex = swapResult.leafIndex;
276
+ const swapPrivateSiblingPath = swapResult.siblingPath;
277
+
278
+ const withdrawL2MessageIndex = withdrawResult.leafIndex;
279
+ const withdrawSiblingPath = withdrawResult.siblingPath;
307
280
 
308
281
  const withdrawMessageMetadata = {
309
- _l2BlockNumber: BigInt(l2UniswapInteractionReceipt.blockNumber!),
282
+ _epoch: BigInt(epoch),
310
283
  _leafIndex: BigInt(withdrawL2MessageIndex),
311
284
  _path: withdrawSiblingPath
312
285
  .toBufferArray()
@@ -314,7 +287,7 @@ export const uniswapL1L2TestSuite = (
314
287
  };
315
288
 
316
289
  const swapPrivateMessageMetadata = {
317
- _l2BlockNumber: BigInt(l2UniswapInteractionReceipt.blockNumber!),
290
+ _epoch: BigInt(epoch),
318
291
  _leafIndex: BigInt(swapPrivateL2MessageIndex),
319
292
  _path: swapPrivateSiblingPath
320
293
  .toBufferArray()
@@ -333,7 +306,7 @@ export const uniswapL1L2TestSuite = (
333
306
  ] as const;
334
307
 
335
308
  // this should also insert a message into the inbox.
336
- const txReceipt = await daiCrossChainHarness.publicClient.waitForTransactionReceipt({
309
+ const txReceipt = await daiCrossChainHarness.l1Client.waitForTransactionReceipt({
337
310
  hash: await uniswapPortal.write.swapPrivate(swapArgs),
338
311
  });
339
312
 
@@ -461,10 +434,10 @@ export const uniswapL1L2TestSuite = (
461
434
  // ownerEthAddress,
462
435
  // nonceForSwap,
463
436
  // );
464
- // await ownerWallet.setPublicAuthWit({ caller: sponsorAddress, action }, true).send().wait();
437
+ // await ownerWallet.setPublicAuthWit({ caller: sponsorAddress, action }, true).send();
465
438
 
466
439
  // // 4.2 Call swap_public from user2 on behalf of owner
467
- // const uniswapL2Interaction = await action.send().wait();
440
+ // const uniswapL2Interaction = await action.send();
468
441
 
469
442
  // const swapPublicContent = sha256ToField([
470
443
  // Buffer.from(
@@ -525,7 +498,7 @@ export const uniswapL1L2TestSuite = (
525
498
  // );
526
499
 
527
500
  // const withdrawMessageMetadata = {
528
- // _l2BlockNumber: BigInt(uniswapL2Interaction.blockNumber!),
501
+ // _epoch: epoch,
529
502
  // _leafIndex: BigInt(withdrawL2MessageIndex),
530
503
  // _path: withdrawSiblingPath
531
504
  // .toBufferArray()
@@ -533,7 +506,7 @@ export const uniswapL1L2TestSuite = (
533
506
  // };
534
507
 
535
508
  // const swapPrivateMessageMetadata = {
536
- // _l2BlockNumber: BigInt(uniswapL2Interaction.blockNumber!),
509
+ // _epoch: epoch,
537
510
  // _leafIndex: BigInt(swapPrivateL2MessageIndex),
538
511
  // _path: swapPrivateSiblingPath
539
512
  // .toBufferArray()
@@ -620,14 +593,16 @@ export const uniswapL1L2TestSuite = (
620
593
  const expectedMessageHash = await computeAuthWitMessageHash(
621
594
  {
622
595
  caller: uniswapL2Contract.address,
623
- action: wethCrossChainHarness.l2Token.methods.transfer_to_public(
624
- ownerAddress,
625
- uniswapL2Contract.address,
626
- wethAmountToBridge,
627
- nonceForWETHTransferToPublicApproval,
628
- ),
596
+ call: await wethCrossChainHarness.l2Token.methods
597
+ .transfer_to_public(
598
+ ownerAddress,
599
+ uniswapL2Contract.address,
600
+ wethAmountToBridge,
601
+ nonceForWETHTransferToPublicApproval,
602
+ )
603
+ .getFunctionCall(),
629
604
  },
630
- { chainId: ownerWallet.getChainId(), version: ownerWallet.getVersion() },
605
+ await wallet.getChainInfo(),
631
606
  );
632
607
 
633
608
  await expect(
@@ -643,7 +618,7 @@ export const uniswapL1L2TestSuite = (
643
618
  Fr.random(),
644
619
  ownerEthAddress,
645
620
  )
646
- .prove(),
621
+ .simulate({ from: ownerAddress }),
647
622
  ).rejects.toThrow(`Unknown auth witness for message hash ${expectedMessageHash.toString()}`);
648
623
  });
649
624
 
@@ -655,7 +630,7 @@ export const uniswapL1L2TestSuite = (
655
630
  // 2. owner gives uniswap approval to transfer the funds to public:
656
631
  logger.info('Approving uniswap to transfer funds to public to self on my behalf');
657
632
  const nonceForWETHTransferToPublicApproval = new Fr(3n);
658
- await ownerWallet.createAuthWit({
633
+ const transferToPublicAuthwith = await wallet.createAuthWit(ownerAddress, {
659
634
  caller: uniswapL2Contract.address,
660
635
  action: wethCrossChainHarness.l2Token.methods.transfer_to_public(
661
636
  ownerAddress,
@@ -680,7 +655,7 @@ export const uniswapL1L2TestSuite = (
680
655
  Fr.random(),
681
656
  ownerEthAddress,
682
657
  )
683
- .prove(),
658
+ .send({ from: ownerAddress, authWitnesses: [transferToPublicAuthwith] }),
684
659
  ).rejects.toThrow('Assertion failed: input_asset address is not the same as seen in the bridge contract');
685
660
  });
686
661
 
@@ -692,7 +667,8 @@ export const uniswapL1L2TestSuite = (
692
667
 
693
668
  // 2. Give approval to uniswap to transfer funds to itself
694
669
  const nonceForWETHTransferApproval = new Fr(2n);
695
- const validateActionInteraction = await ownerWallet.setPublicAuthWit(
670
+ const validateActionInteraction = await wallet.setPublicAuthWit(
671
+ ownerAddress,
696
672
  {
697
673
  caller: uniswapL2Contract.address,
698
674
  action: wethCrossChainHarness.l2Token.methods.transfer_in_public(
@@ -704,7 +680,7 @@ export const uniswapL1L2TestSuite = (
704
680
  },
705
681
  true,
706
682
  );
707
- await validateActionInteraction.send().wait();
683
+ await validateActionInteraction.send();
708
684
 
709
685
  // No approval to call `swap` but should work even without it:
710
686
  const [_, secretHashForDepositingSwappedDai] = await generateClaimSecret();
@@ -723,8 +699,7 @@ export const uniswapL1L2TestSuite = (
723
699
  ownerEthAddress,
724
700
  Fr.ZERO, // nonce for swap -> doesn't matter
725
701
  )
726
- .send()
727
- .wait();
702
+ .send({ from: ownerAddress });
728
703
  // check weth balance of owner on L2 (we first bridged `wethAmountToBridge` into L2 and now withdrew it!)
729
704
  await wethCrossChainHarness.expectPublicBalanceOnL2(ownerAddress, 0n);
730
705
  });
@@ -736,32 +711,35 @@ export const uniswapL1L2TestSuite = (
736
711
  const nonceForWETHTransferApproval = new Fr(3n);
737
712
  const nonceForSwap = new Fr(3n);
738
713
  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();
714
+ const action = uniswapL2Contract.methods.swap_public(
715
+ ownerAddress,
716
+ wethCrossChainHarness.l2Bridge.address,
717
+ wethAmountToBridge,
718
+ daiCrossChainHarness.l2Bridge.address,
719
+ nonceForWETHTransferApproval,
720
+ uniswapFeeTier,
721
+ minimumOutputAmount,
722
+ ownerAddress,
723
+ secretHashForDepositingSwappedDai,
724
+ ownerEthAddress,
725
+ nonceForSwap,
726
+ );
727
+ const validateActionInteraction = await wallet.setPublicAuthWit(
728
+ ownerAddress,
729
+ { caller: approvedUser, action },
730
+ true,
731
+ );
732
+ await validateActionInteraction.send();
756
733
 
757
- await expect(action.simulate()).rejects.toThrow(/unauthorized/);
734
+ await expect(action.simulate({ from: sponsorAddress })).rejects.toThrow(/unauthorized/);
758
735
  });
759
736
 
760
737
  it("uniswap can't pull funds without transfer approval", async () => {
761
738
  // swap should fail since no transfer approval to uniswap:
762
739
  const nonceForWETHTransferApproval = new Fr(4n);
763
740
 
764
- const validateActionInteraction = await ownerWallet.setPublicAuthWit(
741
+ const validateActionInteraction = await wallet.setPublicAuthWit(
742
+ ownerAddress,
765
743
  {
766
744
  caller: uniswapL2Contract.address,
767
745
  action: wethCrossChainHarness.l2Token.methods.transfer_in_public(
@@ -773,7 +751,7 @@ export const uniswapL1L2TestSuite = (
773
751
  },
774
752
  true,
775
753
  );
776
- await validateActionInteraction.send().wait();
754
+ await validateActionInteraction.send();
777
755
 
778
756
  await expect(
779
757
  uniswapL2Contract.methods
@@ -790,7 +768,7 @@ export const uniswapL1L2TestSuite = (
790
768
  ownerEthAddress,
791
769
  Fr.ZERO,
792
770
  )
793
- .simulate(),
771
+ .simulate({ from: ownerAddress }),
794
772
  ).rejects.toThrow(/unauthorized/);
795
773
  });
796
774
 
@@ -803,7 +781,7 @@ export const uniswapL1L2TestSuite = (
803
781
  // Owner gives uniswap approval to transfer the funds to public to self on its behalf
804
782
  logger.info('Approving uniswap to transfer the funds to public to self on my behalf');
805
783
  const nonceForWETHTransferToPublicApproval = new Fr(4n);
806
- await ownerWallet.createAuthWit({
784
+ const transferToPublicAuhtwit = await wallet.createAuthWit(ownerAddress, {
807
785
  caller: uniswapL2Contract.address,
808
786
  action: wethCrossChainHarness.l2Token.methods.transfer_to_public(
809
787
  ownerAddress,
@@ -818,7 +796,7 @@ export const uniswapL1L2TestSuite = (
818
796
  logger.info('Withdrawing weth to L1 and sending message to swap to dai');
819
797
 
820
798
  const [, secretHashForDepositingSwappedDai] = await generateClaimSecret();
821
- const withdrawReceipt = await uniswapL2Contract.methods
799
+ const { receipt: withdrawReceipt } = await uniswapL2Contract.methods
822
800
  .swap_private(
823
801
  wethCrossChainHarness.l2Token.address,
824
802
  wethCrossChainHarness.l2Bridge.address,
@@ -830,8 +808,7 @@ export const uniswapL1L2TestSuite = (
830
808
  secretHashForDepositingSwappedDai,
831
809
  ownerEthAddress,
832
810
  )
833
- .send()
834
- .wait();
811
+ .send({ from: ownerAddress, authWitnesses: [transferToPublicAuhtwit] });
835
812
 
836
813
  const swapPrivateContent = sha256ToField([
837
814
  Buffer.from(
@@ -847,13 +824,13 @@ export const uniswapL1L2TestSuite = (
847
824
  ownerEthAddress.toBuffer32(),
848
825
  ]);
849
826
 
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
- ]);
827
+ const swapPrivateLeaf = computeL2ToL1MessageHash({
828
+ l2Sender: uniswapL2Contract.address,
829
+ l1Recipient: EthAddress.fromString(uniswapPortal.address),
830
+ content: swapPrivateContent,
831
+ rollupVersion: new Fr(version),
832
+ chainId: new Fr(l1Client.chain.id),
833
+ });
857
834
 
858
835
  const withdrawContent = sha256ToField([
859
836
  Buffer.from(toFunctionSelector('withdraw(address,uint256,address)').substring(2), 'hex'),
@@ -862,25 +839,26 @@ export const uniswapL1L2TestSuite = (
862
839
  uniswapPortalAddress.toBuffer32(),
863
840
  ]);
864
841
 
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
- ]);
842
+ const withdrawLeaf = computeL2ToL1MessageHash({
843
+ l2Sender: wethCrossChainHarness.l2Bridge.address,
844
+ l1Recipient: wethCrossChainHarness.tokenPortalAddress,
845
+ content: withdrawContent,
846
+ rollupVersion: new Fr(version),
847
+ chainId: new Fr(l1Client.chain.id),
848
+ });
872
849
 
873
- const [swapPrivateL2MessageIndex, swapPrivateSiblingPath] = await aztecNode.getL2ToL1MessageMembershipWitness(
874
- withdrawReceipt.blockNumber!,
875
- swapPrivateLeaf,
876
- );
877
- const [withdrawL2MessageIndex, withdrawSiblingPath] = await aztecNode.getL2ToL1MessageMembershipWitness(
878
- withdrawReceipt.blockNumber!,
879
- withdrawLeaf,
880
- );
850
+ const swapResult = (await computeL2ToL1MembershipWitness(aztecNode, swapPrivateLeaf, withdrawReceipt.txHash))!;
851
+ const { epochNumber: epoch } = swapResult;
852
+ const withdrawResult = (await computeL2ToL1MembershipWitness(aztecNode, withdrawLeaf, withdrawReceipt.txHash))!;
853
+
854
+ const swapPrivateL2MessageIndex = swapResult.leafIndex;
855
+ const swapPrivateSiblingPath = swapResult.siblingPath;
856
+
857
+ const withdrawL2MessageIndex = withdrawResult.leafIndex;
858
+ const withdrawSiblingPath = withdrawResult.siblingPath;
881
859
 
882
860
  const withdrawMessageMetadata = {
883
- _l2BlockNumber: BigInt(withdrawReceipt.blockNumber!),
861
+ _epoch: BigInt(epoch),
884
862
  _leafIndex: BigInt(withdrawL2MessageIndex),
885
863
  _path: withdrawSiblingPath
886
864
  .toBufferArray()
@@ -888,7 +866,7 @@ export const uniswapL1L2TestSuite = (
888
866
  };
889
867
 
890
868
  const swapPrivateMessageMetadata = {
891
- _l2BlockNumber: BigInt(withdrawReceipt.blockNumber!),
869
+ _epoch: BigInt(epoch),
892
870
  _leafIndex: BigInt(swapPrivateL2MessageIndex),
893
871
  _path: swapPrivateSiblingPath
894
872
  .toBufferArray()
@@ -898,8 +876,9 @@ export const uniswapL1L2TestSuite = (
898
876
  // ensure that user's funds were burnt
899
877
  await wethCrossChainHarness.expectPrivateBalanceOnL2(ownerAddress, wethL2BalanceBeforeSwap - wethAmountToBridge);
900
878
 
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());
879
+ // Since the outbox is only consumable when the epoch is proven, we need to advance to the next epoch.
880
+ await cheatCodes.rollup.advanceToEpoch(EpochNumber(epoch + 1));
881
+ await waitForProven(aztecNode, withdrawReceipt, { provenTimeout: 300 });
903
882
 
904
883
  // On L1 call swap_public!
905
884
  logger.info('call swap_public on L1');
@@ -927,7 +906,8 @@ export const uniswapL1L2TestSuite = (
927
906
 
928
907
  // Owner gives uniswap approval to transfer funds on its behalf
929
908
  const nonceForWETHTransferApproval = new Fr(5n);
930
- const validateActionInteraction = await ownerWallet.setPublicAuthWit(
909
+ const validateActionInteraction = await wallet.setPublicAuthWit(
910
+ ownerAddress,
931
911
  {
932
912
  caller: uniswapL2Contract.address,
933
913
  action: wethCrossChainHarness.l2Token.methods.transfer_in_public(
@@ -939,11 +919,11 @@ export const uniswapL1L2TestSuite = (
939
919
  },
940
920
  true,
941
921
  );
942
- await validateActionInteraction.send().wait();
922
+ await validateActionInteraction.send();
943
923
 
944
924
  // Call swap_public on L2
945
925
  const secretHashForDepositingSwappedDai = Fr.random();
946
- const withdrawReceipt = await uniswapL2Contract.methods
926
+ const { receipt: withdrawReceipt } = await uniswapL2Contract.methods
947
927
  .swap_public(
948
928
  ownerAddress,
949
929
  wethCrossChainHarness.l2Bridge.address,
@@ -957,8 +937,7 @@ export const uniswapL1L2TestSuite = (
957
937
  ownerEthAddress,
958
938
  Fr.ZERO,
959
939
  )
960
- .send()
961
- .wait();
940
+ .send({ from: ownerAddress });
962
941
 
963
942
  const swapPublicContent = sha256ToField([
964
943
  Buffer.from(
@@ -977,13 +956,13 @@ export const uniswapL1L2TestSuite = (
977
956
  ownerEthAddress.toBuffer32(),
978
957
  ]);
979
958
 
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
- ]);
959
+ const swapPublicLeaf = computeL2ToL1MessageHash({
960
+ l2Sender: uniswapL2Contract.address,
961
+ l1Recipient: EthAddress.fromString(uniswapPortal.address),
962
+ content: swapPublicContent,
963
+ rollupVersion: new Fr(version),
964
+ chainId: new Fr(l1Client.chain.id),
965
+ });
987
966
 
988
967
  const withdrawContent = sha256ToField([
989
968
  Buffer.from(toFunctionSelector('withdraw(address,uint256,address)').substring(2), 'hex'),
@@ -992,25 +971,26 @@ export const uniswapL1L2TestSuite = (
992
971
  uniswapPortalAddress.toBuffer32(),
993
972
  ]);
994
973
 
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
- ]);
974
+ const withdrawLeaf = computeL2ToL1MessageHash({
975
+ l2Sender: wethCrossChainHarness.l2Bridge.address,
976
+ l1Recipient: wethCrossChainHarness.tokenPortalAddress,
977
+ content: withdrawContent,
978
+ rollupVersion: new Fr(version),
979
+ chainId: new Fr(l1Client.chain.id),
980
+ });
1002
981
 
1003
- const [swapPublicL2MessageIndex, swapPublicSiblingPath] = await aztecNode.getL2ToL1MessageMembershipWitness(
1004
- withdrawReceipt.blockNumber!,
1005
- swapPublicLeaf,
1006
- );
1007
- const [withdrawL2MessageIndex, withdrawSiblingPath] = await aztecNode.getL2ToL1MessageMembershipWitness(
1008
- withdrawReceipt.blockNumber!,
1009
- withdrawLeaf,
1010
- );
982
+ const swapResult = (await computeL2ToL1MembershipWitness(aztecNode, swapPublicLeaf, withdrawReceipt.txHash))!;
983
+ const { epochNumber: epoch } = swapResult;
984
+ const withdrawResult = (await computeL2ToL1MembershipWitness(aztecNode, withdrawLeaf, withdrawReceipt.txHash))!;
985
+
986
+ const swapPublicL2MessageIndex = swapResult.leafIndex;
987
+ const swapPublicSiblingPath = swapResult.siblingPath;
988
+
989
+ const withdrawL2MessageIndex = withdrawResult.leafIndex;
990
+ const withdrawSiblingPath = withdrawResult.siblingPath;
1011
991
 
1012
992
  const withdrawMessageMetadata = {
1013
- _l2BlockNumber: BigInt(withdrawReceipt.blockNumber!),
993
+ _epoch: BigInt(epoch),
1014
994
  _leafIndex: BigInt(withdrawL2MessageIndex),
1015
995
  _path: withdrawSiblingPath
1016
996
  .toBufferArray()
@@ -1018,7 +998,7 @@ export const uniswapL1L2TestSuite = (
1018
998
  };
1019
999
 
1020
1000
  const swapPublicMessageMetadata = {
1021
- _l2BlockNumber: BigInt(withdrawReceipt.blockNumber!),
1001
+ _epoch: BigInt(epoch),
1022
1002
  _leafIndex: BigInt(swapPublicL2MessageIndex),
1023
1003
  _path: swapPublicSiblingPath
1024
1004
  .toBufferArray()
@@ -1028,8 +1008,9 @@ export const uniswapL1L2TestSuite = (
1028
1008
  // check weth balance of owner on L2 (we first bridged `wethAmountToBridge` into L2 and now withdrew it!)
1029
1009
  await wethCrossChainHarness.expectPublicBalanceOnL2(ownerAddress, 0n);
1030
1010
 
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());
1011
+ // Since the outbox is only consumable when the epoch is proven, we need to advance to the next epoch.
1012
+ await cheatCodes.rollup.advanceToEpoch(EpochNumber(epoch + 1));
1013
+ await waitForProven(aztecNode, withdrawReceipt, { provenTimeout: 300 });
1033
1014
 
1034
1015
  // Call swap_private on L1
1035
1016
  logger.info('Execute withdraw and swap on the uniswapPortal!');