@aztec/end-to-end 0.0.1-commit.24de95ac → 0.0.1-commit.2606882

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 (299) hide show
  1. package/README.md +27 -0
  2. package/dest/bench/client_flows/benchmark.d.ts +17 -2
  3. package/dest/bench/client_flows/benchmark.d.ts.map +1 -1
  4. package/dest/bench/client_flows/benchmark.js +38 -1
  5. package/dest/bench/client_flows/client_flows_benchmark.d.ts +23 -17
  6. package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -1
  7. package/dest/bench/client_flows/client_flows_benchmark.js +143 -136
  8. package/dest/bench/client_flows/config.d.ts +2 -2
  9. package/dest/bench/client_flows/config.d.ts.map +1 -1
  10. package/dest/bench/client_flows/config.js +18 -0
  11. package/dest/bench/client_flows/data_extractor.d.ts +1 -1
  12. package/dest/bench/client_flows/data_extractor.js +7 -27
  13. package/dest/bench/utils.d.ts +8 -7
  14. package/dest/bench/utils.d.ts.map +1 -1
  15. package/dest/bench/utils.js +33 -19
  16. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +12 -10
  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 +120 -117
  19. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +33 -16
  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 +124 -70
  22. package/dest/e2e_deploy_contract/deploy_test.d.ts +7 -6
  23. package/dest/e2e_deploy_contract/deploy_test.d.ts.map +1 -1
  24. package/dest/e2e_deploy_contract/deploy_test.js +20 -14
  25. package/dest/e2e_epochs/epochs_test.d.ts +49 -16
  26. package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
  27. package/dest/e2e_epochs/epochs_test.js +188 -64
  28. package/dest/e2e_fees/bridging_race.notest.d.ts +1 -1
  29. package/dest/e2e_fees/bridging_race.notest.js +5 -7
  30. package/dest/e2e_fees/fees_test.d.ts +25 -18
  31. package/dest/e2e_fees/fees_test.d.ts.map +1 -1
  32. package/dest/e2e_fees/fees_test.js +162 -141
  33. package/dest/e2e_l1_publisher/write_json.d.ts +4 -3
  34. package/dest/e2e_l1_publisher/write_json.d.ts.map +1 -1
  35. package/dest/e2e_l1_publisher/write_json.js +18 -19
  36. package/dest/e2e_multi_validator/utils.d.ts +1 -1
  37. package/dest/e2e_multi_validator/utils.js +1 -1
  38. package/dest/e2e_nested_contract/nested_contract_test.d.ts +7 -10
  39. package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +1 -1
  40. package/dest/e2e_nested_contract/nested_contract_test.js +32 -40
  41. package/dest/e2e_p2p/inactivity_slash_test.d.ts +3 -3
  42. package/dest/e2e_p2p/inactivity_slash_test.d.ts.map +1 -1
  43. package/dest/e2e_p2p/inactivity_slash_test.js +11 -9
  44. package/dest/e2e_p2p/p2p_network.d.ts +237 -28
  45. package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
  46. package/dest/e2e_p2p/p2p_network.js +176 -129
  47. package/dest/e2e_p2p/reqresp/utils.d.ts +22 -0
  48. package/dest/e2e_p2p/reqresp/utils.d.ts.map +1 -0
  49. package/dest/e2e_p2p/reqresp/utils.js +206 -0
  50. package/dest/e2e_p2p/shared.d.ts +44 -15
  51. package/dest/e2e_p2p/shared.d.ts.map +1 -1
  52. package/dest/e2e_p2p/shared.js +102 -68
  53. package/dest/e2e_storage_proof/fixtures/storage_proof_fetcher.d.ts +2 -0
  54. package/dest/e2e_storage_proof/fixtures/storage_proof_fetcher.d.ts.map +1 -0
  55. package/dest/e2e_storage_proof/fixtures/storage_proof_fetcher.js +184 -0
  56. package/dest/e2e_storage_proof/fixtures/storage_proof_fixture.d.ts +18 -0
  57. package/dest/e2e_storage_proof/fixtures/storage_proof_fixture.d.ts.map +1 -0
  58. package/dest/e2e_storage_proof/fixtures/storage_proof_fixture.js +120 -0
  59. package/dest/e2e_token_contract/token_contract_test.d.ts +20 -11
  60. package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -1
  61. package/dest/e2e_token_contract/token_contract_test.js +103 -93
  62. package/dest/fixtures/authwit_proxy.d.ts +15 -0
  63. package/dest/fixtures/authwit_proxy.d.ts.map +1 -0
  64. package/dest/fixtures/authwit_proxy.js +34 -0
  65. package/dest/fixtures/e2e_prover_test.d.ts +19 -24
  66. package/dest/fixtures/e2e_prover_test.d.ts.map +1 -1
  67. package/dest/fixtures/e2e_prover_test.js +126 -145
  68. package/dest/fixtures/elu_monitor.d.ts +21 -0
  69. package/dest/fixtures/elu_monitor.d.ts.map +1 -0
  70. package/dest/fixtures/elu_monitor.js +102 -0
  71. package/dest/fixtures/fixtures.d.ts +75 -3
  72. package/dest/fixtures/fixtures.d.ts.map +1 -1
  73. package/dest/fixtures/fixtures.js +73 -3
  74. package/dest/fixtures/get_acvm_config.d.ts +1 -1
  75. package/dest/fixtures/get_acvm_config.js +1 -1
  76. package/dest/fixtures/get_bb_config.d.ts +1 -1
  77. package/dest/fixtures/get_bb_config.d.ts.map +1 -1
  78. package/dest/fixtures/get_bb_config.js +5 -5
  79. package/dest/fixtures/ha_setup.d.ts +71 -0
  80. package/dest/fixtures/ha_setup.d.ts.map +1 -0
  81. package/dest/fixtures/ha_setup.js +116 -0
  82. package/dest/fixtures/index.d.ts +2 -1
  83. package/dest/fixtures/index.d.ts.map +1 -1
  84. package/dest/fixtures/index.js +1 -0
  85. package/dest/fixtures/l1_to_l2_messaging.d.ts +4 -3
  86. package/dest/fixtures/l1_to_l2_messaging.d.ts.map +1 -1
  87. package/dest/fixtures/l1_to_l2_messaging.js +2 -2
  88. package/dest/fixtures/logging.d.ts +1 -1
  89. package/dest/fixtures/schnorr_hardcoded_account_contract.d.ts +25 -0
  90. package/dest/fixtures/schnorr_hardcoded_account_contract.d.ts.map +1 -0
  91. package/dest/fixtures/schnorr_hardcoded_account_contract.js +37 -0
  92. package/dest/fixtures/setup.d.ts +272 -0
  93. package/dest/fixtures/setup.d.ts.map +1 -0
  94. package/dest/fixtures/setup.js +735 -0
  95. package/dest/fixtures/setup_p2p_test.d.ts +22 -11
  96. package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
  97. package/dest/fixtures/setup_p2p_test.js +57 -38
  98. package/dest/fixtures/token_utils.d.ts +6 -3
  99. package/dest/fixtures/token_utils.d.ts.map +1 -1
  100. package/dest/fixtures/token_utils.js +13 -9
  101. package/dest/fixtures/utils.d.ts +5 -192
  102. package/dest/fixtures/utils.d.ts.map +1 -1
  103. package/dest/fixtures/utils.js +4 -648
  104. package/dest/fixtures/web3signer.d.ts +1 -1
  105. package/dest/fixtures/web3signer.js +1 -1
  106. package/dest/fixtures/with_telemetry_utils.d.ts +2 -2
  107. package/dest/fixtures/with_telemetry_utils.d.ts.map +1 -1
  108. package/dest/fixtures/with_telemetry_utils.js +2 -2
  109. package/dest/forward-compatibility/wallet_rpc_client.d.ts +7 -0
  110. package/dest/forward-compatibility/wallet_rpc_client.d.ts.map +1 -0
  111. package/dest/forward-compatibility/wallet_rpc_client.js +15 -0
  112. package/dest/forward-compatibility/wallet_service.d.ts +3 -0
  113. package/dest/forward-compatibility/wallet_service.d.ts.map +1 -0
  114. package/dest/forward-compatibility/wallet_service.js +109 -0
  115. package/dest/index.d.ts +1 -1
  116. package/dest/install_legacy_contracts.d.cts +10 -0
  117. package/dest/install_legacy_contracts.d.cts.map +1 -0
  118. package/dest/legacy-jest-resolver.d.cts +3 -0
  119. package/dest/legacy-jest-resolver.d.cts.map +1 -0
  120. package/dest/quality_of_service/grafana_client.d.ts +41 -0
  121. package/dest/quality_of_service/grafana_client.d.ts.map +1 -0
  122. package/dest/quality_of_service/{alert_checker.js → grafana_client.js} +1 -1
  123. package/dest/quality_of_service/prometheus_client.d.ts +38 -0
  124. package/dest/quality_of_service/prometheus_client.d.ts.map +1 -0
  125. package/dest/quality_of_service/prometheus_client.js +67 -0
  126. package/dest/shared/cross_chain_test_harness.d.ts +9 -6
  127. package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
  128. package/dest/shared/cross_chain_test_harness.js +34 -30
  129. package/dest/shared/gas_portal_test_harness.d.ts +9 -6
  130. package/dest/shared/gas_portal_test_harness.d.ts.map +1 -1
  131. package/dest/shared/gas_portal_test_harness.js +21 -12
  132. package/dest/shared/index.d.ts +3 -2
  133. package/dest/shared/index.d.ts.map +1 -1
  134. package/dest/shared/index.js +1 -0
  135. package/dest/shared/jest_setup.d.ts +1 -1
  136. package/dest/shared/jest_setup.js +41 -1
  137. package/dest/shared/mock_state_view.d.ts +86 -0
  138. package/dest/shared/mock_state_view.d.ts.map +1 -0
  139. package/dest/shared/mock_state_view.js +186 -0
  140. package/dest/shared/submit-transactions.d.ts +4 -4
  141. package/dest/shared/submit-transactions.d.ts.map +1 -1
  142. package/dest/shared/submit-transactions.js +9 -11
  143. package/dest/shared/uniswap_l1_l2.d.ts +3 -27
  144. package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
  145. package/dest/shared/uniswap_l1_l2.js +87 -50
  146. package/dest/shared/wait_for_l1_to_l2_message.d.ts +13 -0
  147. package/dest/shared/wait_for_l1_to_l2_message.d.ts.map +1 -0
  148. package/dest/shared/wait_for_l1_to_l2_message.js +10 -0
  149. package/dest/simulators/index.d.ts +1 -1
  150. package/dest/simulators/lending_simulator.d.ts +11 -4
  151. package/dest/simulators/lending_simulator.d.ts.map +1 -1
  152. package/dest/simulators/lending_simulator.js +32 -18
  153. package/dest/simulators/token_simulator.d.ts +1 -1
  154. package/dest/simulators/token_simulator.d.ts.map +1 -1
  155. package/dest/simulators/token_simulator.js +3 -24
  156. package/dest/spartan/setup_test_wallets.d.ts +18 -6
  157. package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
  158. package/dest/spartan/setup_test_wallets.js +159 -30
  159. package/dest/spartan/tx_metrics.d.ts +102 -0
  160. package/dest/spartan/tx_metrics.d.ts.map +1 -0
  161. package/dest/spartan/tx_metrics.js +475 -0
  162. package/dest/spartan/utils/bot.d.ts +28 -0
  163. package/dest/spartan/utils/bot.d.ts.map +1 -0
  164. package/dest/spartan/utils/bot.js +142 -0
  165. package/dest/spartan/utils/chaos.d.ts +79 -0
  166. package/dest/spartan/utils/chaos.d.ts.map +1 -0
  167. package/dest/spartan/utils/chaos.js +142 -0
  168. package/dest/spartan/utils/clients.d.ts +39 -0
  169. package/dest/spartan/utils/clients.d.ts.map +1 -0
  170. package/dest/spartan/utils/clients.js +90 -0
  171. package/dest/spartan/utils/config.d.ts +19 -0
  172. package/dest/spartan/utils/config.d.ts.map +1 -0
  173. package/dest/spartan/utils/config.js +23 -0
  174. package/dest/spartan/utils/health.d.ts +63 -0
  175. package/dest/spartan/utils/health.d.ts.map +1 -0
  176. package/dest/spartan/utils/health.js +202 -0
  177. package/dest/spartan/utils/helm.d.ts +15 -0
  178. package/dest/spartan/utils/helm.d.ts.map +1 -0
  179. package/dest/spartan/utils/helm.js +47 -0
  180. package/dest/spartan/utils/index.d.ts +11 -0
  181. package/dest/spartan/utils/index.d.ts.map +1 -0
  182. package/dest/spartan/utils/index.js +22 -0
  183. package/dest/spartan/utils/k8s.d.ts +128 -0
  184. package/dest/spartan/utils/k8s.d.ts.map +1 -0
  185. package/dest/spartan/utils/k8s.js +381 -0
  186. package/dest/spartan/utils/nodes.d.ts +40 -0
  187. package/dest/spartan/utils/nodes.d.ts.map +1 -0
  188. package/dest/spartan/utils/nodes.js +461 -0
  189. package/dest/spartan/utils/pod_logs.d.ts +25 -0
  190. package/dest/spartan/utils/pod_logs.d.ts.map +1 -0
  191. package/dest/spartan/utils/pod_logs.js +74 -0
  192. package/dest/spartan/utils/scripts.d.ts +30 -0
  193. package/dest/spartan/utils/scripts.d.ts.map +1 -0
  194. package/dest/spartan/utils/scripts.js +81 -0
  195. package/dest/spartan/utils.d.ts +2 -218
  196. package/dest/spartan/utils.d.ts.map +1 -1
  197. package/dest/spartan/utils.js +1 -749
  198. package/dest/test-wallet/test_wallet.d.ts +85 -0
  199. package/dest/test-wallet/test_wallet.d.ts.map +1 -0
  200. package/dest/test-wallet/test_wallet.js +273 -0
  201. package/dest/test-wallet/utils.d.ts +41 -0
  202. package/dest/test-wallet/utils.d.ts.map +1 -0
  203. package/dest/test-wallet/utils.js +66 -0
  204. package/dest/test-wallet/wallet_worker_script.d.ts +2 -0
  205. package/dest/test-wallet/wallet_worker_script.d.ts.map +1 -0
  206. package/dest/test-wallet/wallet_worker_script.js +53 -0
  207. package/dest/test-wallet/worker_wallet.d.ts +53 -0
  208. package/dest/test-wallet/worker_wallet.d.ts.map +1 -0
  209. package/dest/test-wallet/worker_wallet.js +155 -0
  210. package/dest/test-wallet/worker_wallet_schema.d.ts +160 -0
  211. package/dest/test-wallet/worker_wallet_schema.d.ts.map +1 -0
  212. package/dest/test-wallet/worker_wallet_schema.js +22 -0
  213. package/package.json +56 -46
  214. package/src/bench/client_flows/benchmark.ts +43 -2
  215. package/src/bench/client_flows/client_flows_benchmark.ts +203 -206
  216. package/src/bench/client_flows/config.ts +9 -1
  217. package/src/bench/client_flows/data_extractor.ts +6 -28
  218. package/src/bench/utils.ts +38 -22
  219. package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +141 -152
  220. package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +180 -127
  221. package/src/e2e_deploy_contract/deploy_test.ts +25 -17
  222. package/src/e2e_epochs/epochs_test.ts +254 -116
  223. package/src/e2e_fees/bridging_race.notest.ts +6 -12
  224. package/src/e2e_fees/fees_test.ts +215 -229
  225. package/src/e2e_l1_publisher/write_json.ts +20 -19
  226. package/src/e2e_multi_validator/utils.ts +1 -1
  227. package/src/e2e_nested_contract/nested_contract_test.ts +38 -56
  228. package/src/e2e_p2p/inactivity_slash_test.ts +12 -10
  229. package/src/e2e_p2p/p2p_network.ts +246 -201
  230. package/src/e2e_p2p/reqresp/utils.ts +274 -0
  231. package/src/e2e_p2p/shared.ts +132 -82
  232. package/src/e2e_storage_proof/fixtures/storage_proof.json +915 -0
  233. package/src/e2e_storage_proof/fixtures/storage_proof_fetcher.ts +190 -0
  234. package/src/e2e_storage_proof/fixtures/storage_proof_fixture.ts +173 -0
  235. package/src/e2e_token_contract/token_contract_test.ts +129 -117
  236. package/src/fixtures/authwit_proxy.ts +54 -0
  237. package/src/fixtures/dumps/epoch_proof_result.json +1 -1
  238. package/src/fixtures/e2e_prover_test.ts +154 -199
  239. package/src/fixtures/elu_monitor.ts +126 -0
  240. package/src/fixtures/fixtures.ts +95 -5
  241. package/src/fixtures/get_acvm_config.ts +1 -1
  242. package/src/fixtures/get_bb_config.ts +7 -6
  243. package/src/fixtures/ha_setup.ts +188 -0
  244. package/src/fixtures/index.ts +1 -0
  245. package/src/fixtures/l1_to_l2_messaging.ts +4 -2
  246. package/src/fixtures/schnorr_hardcoded_account_contract.ts +49 -0
  247. package/src/fixtures/setup.ts +1056 -0
  248. package/src/fixtures/setup_p2p_test.ts +70 -56
  249. package/src/fixtures/token_utils.ts +9 -8
  250. package/src/fixtures/utils.ts +29 -947
  251. package/src/fixtures/web3signer.ts +1 -1
  252. package/src/fixtures/with_telemetry_utils.ts +2 -2
  253. package/src/forward-compatibility/wallet_rpc_client.ts +14 -0
  254. package/src/forward-compatibility/wallet_service.ts +104 -0
  255. package/src/guides/up_quick_start.sh +4 -6
  256. package/src/install_legacy_contracts.cjs +75 -0
  257. package/src/legacy-jest-resolver.cjs +112 -0
  258. package/src/quality_of_service/{alert_checker.ts → grafana_client.ts} +1 -1
  259. package/src/quality_of_service/prometheus_client.ts +113 -0
  260. package/src/shared/cross_chain_test_harness.ts +37 -40
  261. package/src/shared/gas_portal_test_harness.ts +24 -14
  262. package/src/shared/index.ts +2 -1
  263. package/src/shared/jest_setup.ts +51 -1
  264. package/src/shared/mock_state_view.ts +188 -0
  265. package/src/shared/submit-transactions.ts +11 -16
  266. package/src/shared/uniswap_l1_l2.ts +142 -114
  267. package/src/shared/wait_for_l1_to_l2_message.ts +23 -0
  268. package/src/simulators/lending_simulator.ts +39 -19
  269. package/src/simulators/token_simulator.ts +6 -30
  270. package/src/spartan/DEVELOP.md +7 -0
  271. package/src/spartan/setup_test_wallets.ts +234 -32
  272. package/src/spartan/tx_metrics.ts +434 -0
  273. package/src/spartan/utils/bot.ts +188 -0
  274. package/src/spartan/utils/chaos.ts +253 -0
  275. package/src/spartan/utils/clients.ts +100 -0
  276. package/src/spartan/utils/config.ts +29 -0
  277. package/src/spartan/utils/health.ts +255 -0
  278. package/src/spartan/utils/helm.ts +84 -0
  279. package/src/spartan/utils/index.ts +71 -0
  280. package/src/spartan/utils/k8s.ts +535 -0
  281. package/src/spartan/utils/nodes.ts +543 -0
  282. package/src/spartan/utils/pod_logs.ts +99 -0
  283. package/src/spartan/utils/scripts.ts +99 -0
  284. package/src/spartan/utils.ts +1 -942
  285. package/src/test-wallet/test_wallet.ts +376 -0
  286. package/src/test-wallet/utils.ts +108 -0
  287. package/src/test-wallet/wallet_worker_script.ts +63 -0
  288. package/src/test-wallet/worker_wallet.ts +218 -0
  289. package/src/test-wallet/worker_wallet_schema.ts +13 -0
  290. package/dest/fixtures/setup_l1_contracts.d.ts +0 -6
  291. package/dest/fixtures/setup_l1_contracts.d.ts.map +0 -1
  292. package/dest/fixtures/setup_l1_contracts.js +0 -17
  293. package/dest/fixtures/snapshot_manager.d.ts +0 -95
  294. package/dest/fixtures/snapshot_manager.d.ts.map +0 -1
  295. package/dest/fixtures/snapshot_manager.js +0 -505
  296. package/dest/quality_of_service/alert_checker.d.ts +0 -41
  297. package/dest/quality_of_service/alert_checker.d.ts.map +0 -1
  298. package/src/fixtures/setup_l1_contracts.ts +0 -26
  299. package/src/fixtures/snapshot_manager.ts +0 -665
@@ -1,28 +1,32 @@
1
1
  import { AztecAddress, EthAddress } from '@aztec/aztec.js/addresses';
2
2
  import { computeAuthWitMessageHash } from '@aztec/aztec.js/authorization';
3
+ import { waitForProven } from '@aztec/aztec.js/contracts';
3
4
  import { generateClaimSecret } from '@aztec/aztec.js/ethereum';
4
5
  import { Fr } from '@aztec/aztec.js/fields';
5
6
  import type { Logger } from '@aztec/aztec.js/log';
6
7
  import type { AztecNode } from '@aztec/aztec.js/node';
7
8
  import { CheatCodes } from '@aztec/aztec/testing';
8
- import {
9
- type DeployL1ContractsReturnType,
10
- type ExtendedViemWalletClient,
11
- RollupContract,
12
- deployL1Contract,
13
- extractEvent,
14
- } from '@aztec/ethereum';
15
- import { sha256ToField } from '@aztec/foundation/crypto';
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';
16
17
  import { InboxAbi, UniswapPortalAbi, UniswapPortalBytecode } from '@aztec/l1-artifacts';
17
18
  import { UniswapContract } from '@aztec/noir-contracts.js/Uniswap';
18
19
  import { computeL2ToL1MessageHash } from '@aztec/stdlib/hash';
19
- import { computeL2ToL1MembershipWitness } from '@aztec/stdlib/messaging';
20
- import type { TestWallet } from '@aztec/test-wallet/server';
21
20
 
22
21
  import { jest } from '@jest/globals';
23
22
  import { type GetContractReturnType, getContract, parseEther, toFunctionSelector } from 'viem';
24
23
 
25
- import { ensureAccountContractsPublished } 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';
26
30
  import { CrossChainTestHarness } from './cross_chain_test_harness.js';
27
31
 
28
32
  // PSA: This tests works on forked mainnet. There is a dump of the data in `dumpedState` such that we
@@ -32,30 +36,10 @@ import { CrossChainTestHarness } from './cross_chain_test_harness.js';
32
36
  // anvil --fork-url https://mainnet.infura.io/v3/9928b52099854248b3a096be07a6b23c --fork-block-number 17514288 --chain-id 31337
33
37
  // For CI, this is configured in `run_tests.sh` and `docker-compose-images.yml`
34
38
 
35
- const TIMEOUT = 360_000;
36
-
37
- /** Objects to be returned by the uniswap setup function */
38
- export type UniswapSetupContext = {
39
- /** Aztec Node instance */
40
- aztecNode: AztecNode;
41
- /** Logger instance named as the current test. */
42
- logger: Logger;
43
- /** The L1 wallet client, extended with public actions. */
44
- l1Client: ExtendedViemWalletClient;
45
- /** The wallet. */
46
- wallet: TestWallet;
47
- /** The owner address. */
48
- ownerAddress: AztecAddress;
49
- /** The sponsor wallet. */
50
- sponsorAddress: AztecAddress;
51
- /** */
52
- deployL1ContractsValues: DeployL1ContractsReturnType;
53
- /** Cheat codes instance. */
54
- cheatCodes: CheatCodes;
55
- };
39
+ const TIMEOUT = 15 * 60 * 1000;
56
40
 
57
41
  export const uniswapL1L2TestSuite = (
58
- setup: () => Promise<UniswapSetupContext>,
42
+ setup: () => Promise<EndToEndContext>,
59
43
  cleanup: () => Promise<void>,
60
44
  expectedForkBlockNumber = 17514288,
61
45
  ) => {
@@ -79,7 +63,7 @@ export const uniswapL1L2TestSuite = (
79
63
  let daiCrossChainHarness: CrossChainTestHarness;
80
64
  let wethCrossChainHarness: CrossChainTestHarness;
81
65
 
82
- let deployL1ContractsValues: DeployL1ContractsReturnType;
66
+ let deployL1ContractsValues: DeployAztecL1ContractsReturnType;
83
67
  let rollup: RollupContract;
84
68
  let uniswapPortal: GetContractReturnType<typeof UniswapPortalAbi, ExtendedViemWalletClient>;
85
69
  let uniswapPortalAddress: EthAddress;
@@ -92,8 +76,19 @@ export const uniswapL1L2TestSuite = (
92
76
  let cheatCodes: CheatCodes;
93
77
  let version: number;
94
78
  beforeAll(async () => {
95
- ({ aztecNode, logger, l1Client, wallet, ownerAddress, sponsorAddress, deployL1ContractsValues, cheatCodes } =
96
- await setup());
79
+ const t = await setup();
80
+ ({
81
+ aztecNode,
82
+ logger,
83
+ deployL1ContractsValues,
84
+ cheatCodes,
85
+ wallet,
86
+ accounts: [ownerAddress, sponsorAddress],
87
+ } = t);
88
+
89
+ l1Client = deployL1ContractsValues.l1Client;
90
+
91
+ t.watcher.setIsMarkingAsProven(false);
97
92
 
98
93
  if (Number(await l1Client.getBlockNumber()) < expectedForkBlockNumber) {
99
94
  throw new Error('This test must be run on a fork of mainnet with the expected fork block');
@@ -107,6 +102,7 @@ export const uniswapL1L2TestSuite = (
107
102
  ownerEthAddress = EthAddress.fromString((await l1Client.getAddresses())[0]);
108
103
 
109
104
  await ensureAccountContractsPublished(wallet, [ownerAddress, sponsorAddress]);
105
+ await ensureAuthRegistryPublished(wallet, ownerAddress);
110
106
 
111
107
  logger.info('Deploying DAI Portal, initializing and deploying l2 contract...');
112
108
  daiCrossChainHarness = await CrossChainTestHarness.new(
@@ -139,9 +135,9 @@ export const uniswapL1L2TestSuite = (
139
135
  client: l1Client,
140
136
  });
141
137
  // deploy l2 uniswap contract and attach to portal
142
- uniswapL2Contract = await UniswapContract.deploy(wallet, uniswapPortalAddress)
143
- .send({ from: ownerAddress })
144
- .deployed();
138
+ ({ contract: uniswapL2Contract } = await UniswapContract.deploy(wallet, uniswapPortalAddress).send({
139
+ from: ownerAddress,
140
+ }));
145
141
 
146
142
  const registryAddress = (await aztecNode.getNodeInfo()).l1ContractAddresses.registryAddress;
147
143
 
@@ -163,7 +159,6 @@ export const uniswapL1L2TestSuite = (
163
159
  await cleanup();
164
160
  });
165
161
 
166
- // docs:start:uniswap_private
167
162
  it('should uniswap trade on L1 from L2 funds privately (swaps WETH -> DAI)', async () => {
168
163
  const wethL1BeforeBalance = await wethCrossChainHarness.getL1BalanceOf(ownerEthAddress);
169
164
 
@@ -206,7 +201,7 @@ export const uniswapL1L2TestSuite = (
206
201
  logger.info('Withdrawing weth to L1 and sending message to swap to dai');
207
202
  const [secretForDepositingSwappedDai, secretHashForDepositingSwappedDai] = await generateClaimSecret();
208
203
 
209
- const l2UniswapInteractionReceipt = await uniswapL2Contract.methods
204
+ const { receipt: l2UniswapInteractionReceipt } = await uniswapL2Contract.methods
210
205
  .swap_private(
211
206
  wethCrossChainHarness.l2Token.address,
212
207
  wethCrossChainHarness.l2Bridge.address,
@@ -218,8 +213,7 @@ export const uniswapL1L2TestSuite = (
218
213
  secretHashForDepositingSwappedDai,
219
214
  ownerEthAddress,
220
215
  )
221
- .send({ from: ownerAddress, authWitnesses: [transferToPublicAuhtwit] })
222
- .wait();
216
+ .send({ from: ownerAddress, authWitnesses: [transferToPublicAuhtwit] });
223
217
 
224
218
  const swapPrivateFunction = 'swap_private(address,uint256,uint24,address,uint256,bytes32,address)';
225
219
  const swapPrivateContent = sha256ToField([
@@ -261,33 +255,43 @@ export const uniswapL1L2TestSuite = (
261
255
  // ensure that uniswap contract didn't eat the funds.
262
256
  await wethCrossChainHarness.expectPublicBalanceOnL2(uniswapL2Contract.address, 0n);
263
257
 
264
- // Since the outbox is only consumable when the block is proven, we need to set the block to be proven
265
- await cheatCodes.rollup.markAsProven(await rollup.getBlockNumber());
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 });
266
266
 
267
267
  // 5. Consume L2 to L1 message by calling uniswapPortal.swap_private()
268
268
  logger.info('Execute withdraw and swap on the uniswapPortal!');
269
269
  const daiL1BalanceOfPortalBeforeSwap = await daiCrossChainHarness.getL1BalanceOf(
270
270
  daiCrossChainHarness.tokenPortalAddress,
271
271
  );
272
- const swapResult = await computeL2ToL1MembershipWitness(
273
- aztecNode,
274
- l2UniswapInteractionReceipt.blockNumber!,
275
- swapPrivateLeaf,
272
+ const swapResult = await retryUntil(
273
+ () => aztecNode.getL2ToL1MembershipWitness(minedReceipt.txHash, swapPrivateLeaf),
274
+ 'swap private l2 to l1 witness',
275
+ 60,
276
+ 1,
276
277
  );
277
- const withdrawResult = await computeL2ToL1MembershipWitness(
278
- aztecNode,
279
- l2UniswapInteractionReceipt.blockNumber!,
280
- 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,
281
284
  );
282
285
 
283
- const swapPrivateL2MessageIndex = swapResult!.leafIndex;
284
- const swapPrivateSiblingPath = swapResult!.siblingPath;
286
+ const swapPrivateL2MessageIndex = swapResult.leafIndex;
287
+ const swapPrivateSiblingPath = swapResult.siblingPath;
285
288
 
286
- const withdrawL2MessageIndex = withdrawResult!.leafIndex;
287
- const withdrawSiblingPath = withdrawResult!.siblingPath;
289
+ const withdrawL2MessageIndex = withdrawResult.leafIndex;
290
+ const withdrawSiblingPath = withdrawResult.siblingPath;
288
291
 
289
292
  const withdrawMessageMetadata = {
290
- _l2BlockNumber: BigInt(l2UniswapInteractionReceipt.blockNumber!),
293
+ _epoch: BigInt(epoch),
294
+ _numCheckpointsInEpoch: BigInt(withdrawResult.numCheckpointsInEpoch),
291
295
  _leafIndex: BigInt(withdrawL2MessageIndex),
292
296
  _path: withdrawSiblingPath
293
297
  .toBufferArray()
@@ -295,7 +299,8 @@ export const uniswapL1L2TestSuite = (
295
299
  };
296
300
 
297
301
  const swapPrivateMessageMetadata = {
298
- _l2BlockNumber: BigInt(l2UniswapInteractionReceipt.blockNumber!),
302
+ _epoch: BigInt(epoch),
303
+ _numCheckpointsInEpoch: BigInt(numCheckpointsInEpoch),
299
304
  _leafIndex: BigInt(swapPrivateL2MessageIndex),
300
305
  _path: swapPrivateSiblingPath
301
306
  .toBufferArray()
@@ -353,10 +358,8 @@ export const uniswapL1L2TestSuite = (
353
358
  logger.info('WETH balance after swap : ', wethL2BalanceAfterSwap.toString());
354
359
  logger.info('DAI balance after swap : ', daiL2BalanceAfterSwap.toString());
355
360
  });
356
- // docs:end:uniswap_private
357
361
 
358
362
  // TODO(#7463): reenable look into this failure https://github.com/AztecProtocol/aztec-packages/actions/runs/9912612912/job/27388320150?pr=7462
359
- // // docs:start:uniswap_public
360
363
  // it('should uniswap trade on L1 from L2 funds publicly (swaps WETH -> DAI)', async () => {
361
364
  // const wethL1BeforeBalance = await wethCrossChainHarness.getL1BalanceOf(ownerEthAddress);
362
365
 
@@ -442,10 +445,10 @@ export const uniswapL1L2TestSuite = (
442
445
  // ownerEthAddress,
443
446
  // nonceForSwap,
444
447
  // );
445
- // await ownerWallet.setPublicAuthWit({ caller: sponsorAddress, action }, true).send().wait();
448
+ // await ownerWallet.setPublicAuthWit({ caller: sponsorAddress, action }, true).send();
446
449
 
447
450
  // // 4.2 Call swap_public from user2 on behalf of owner
448
- // const uniswapL2Interaction = await action.send().wait();
451
+ // const uniswapL2Interaction = await action.send();
449
452
 
450
453
  // const swapPublicContent = sha256ToField([
451
454
  // Buffer.from(
@@ -506,7 +509,7 @@ export const uniswapL1L2TestSuite = (
506
509
  // );
507
510
 
508
511
  // const withdrawMessageMetadata = {
509
- // _l2BlockNumber: BigInt(uniswapL2Interaction.blockNumber!),
512
+ // _epoch: epoch,
510
513
  // _leafIndex: BigInt(withdrawL2MessageIndex),
511
514
  // _path: withdrawSiblingPath
512
515
  // .toBufferArray()
@@ -514,7 +517,7 @@ export const uniswapL1L2TestSuite = (
514
517
  // };
515
518
 
516
519
  // const swapPrivateMessageMetadata = {
517
- // _l2BlockNumber: BigInt(uniswapL2Interaction.blockNumber!),
520
+ // _epoch: epoch,
518
521
  // _leafIndex: BigInt(swapPrivateL2MessageIndex),
519
522
  // _path: swapPrivateSiblingPath
520
523
  // .toBufferArray()
@@ -589,7 +592,6 @@ export const uniswapL1L2TestSuite = (
589
592
  // logger.info('WETH balance after swap : ', wethL2BalanceAfterSwap.toString());
590
593
  // logger.info('DAI balance after swap : ', daiL2BalanceAfterSwap.toString());
591
594
  // });
592
- // // docs:end:uniswap_public
593
595
 
594
596
  // Edge cases for the private flow:
595
597
  // note - tests for uniswapPortal.sol and minting asset on L2 are covered in other tests.
@@ -663,8 +665,7 @@ export const uniswapL1L2TestSuite = (
663
665
  Fr.random(),
664
666
  ownerEthAddress,
665
667
  )
666
- .send({ from: ownerAddress, authWitnesses: [transferToPublicAuthwith] })
667
- .wait(),
668
+ .send({ from: ownerAddress, authWitnesses: [transferToPublicAuthwith] }),
668
669
  ).rejects.toThrow('Assertion failed: input_asset address is not the same as seen in the bridge contract');
669
670
  });
670
671
 
@@ -689,7 +690,7 @@ export const uniswapL1L2TestSuite = (
689
690
  },
690
691
  true,
691
692
  );
692
- await validateActionInteraction.send().wait();
693
+ await validateActionInteraction.send();
693
694
 
694
695
  // No approval to call `swap` but should work even without it:
695
696
  const [_, secretHashForDepositingSwappedDai] = await generateClaimSecret();
@@ -708,8 +709,7 @@ export const uniswapL1L2TestSuite = (
708
709
  ownerEthAddress,
709
710
  Fr.ZERO, // nonce for swap -> doesn't matter
710
711
  )
711
- .send({ from: ownerAddress })
712
- .wait();
712
+ .send({ from: ownerAddress });
713
713
  // check weth balance of owner on L2 (we first bridged `wethAmountToBridge` into L2 and now withdrew it!)
714
714
  await wethCrossChainHarness.expectPublicBalanceOnL2(ownerAddress, 0n);
715
715
  });
@@ -739,7 +739,7 @@ export const uniswapL1L2TestSuite = (
739
739
  { caller: approvedUser, action },
740
740
  true,
741
741
  );
742
- await validateActionInteraction.send().wait();
742
+ await validateActionInteraction.send();
743
743
 
744
744
  await expect(action.simulate({ from: sponsorAddress })).rejects.toThrow(/unauthorized/);
745
745
  });
@@ -761,7 +761,7 @@ export const uniswapL1L2TestSuite = (
761
761
  },
762
762
  true,
763
763
  );
764
- await validateActionInteraction.send().wait();
764
+ await validateActionInteraction.send();
765
765
 
766
766
  await expect(
767
767
  uniswapL2Contract.methods
@@ -806,7 +806,7 @@ export const uniswapL1L2TestSuite = (
806
806
  logger.info('Withdrawing weth to L1 and sending message to swap to dai');
807
807
 
808
808
  const [, secretHashForDepositingSwappedDai] = await generateClaimSecret();
809
- const withdrawReceipt = await uniswapL2Contract.methods
809
+ const { receipt: withdrawReceipt } = await uniswapL2Contract.methods
810
810
  .swap_private(
811
811
  wethCrossChainHarness.l2Token.address,
812
812
  wethCrossChainHarness.l2Bridge.address,
@@ -818,8 +818,7 @@ export const uniswapL1L2TestSuite = (
818
818
  secretHashForDepositingSwappedDai,
819
819
  ownerEthAddress,
820
820
  )
821
- .send({ from: ownerAddress, authWitnesses: [transferToPublicAuhtwit] })
822
- .wait();
821
+ .send({ from: ownerAddress, authWitnesses: [transferToPublicAuhtwit] });
823
822
 
824
823
  const swapPrivateContent = sha256ToField([
825
824
  Buffer.from(
@@ -858,21 +857,41 @@ export const uniswapL1L2TestSuite = (
858
857
  chainId: new Fr(l1Client.chain.id),
859
858
  });
860
859
 
861
- const swapResult = await computeL2ToL1MembershipWitness(aztecNode, withdrawReceipt.blockNumber!, swapPrivateLeaf);
862
- const withdrawResult = await computeL2ToL1MembershipWitness(
863
- aztecNode,
864
- withdrawReceipt.blockNumber!,
865
- withdrawLeaf,
860
+ // ensure that user's funds were burnt
861
+ await wethCrossChainHarness.expectPrivateBalanceOnL2(ownerAddress, wethL2BalanceBeforeSwap - wethAmountToBridge);
862
+
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,
877
+ );
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,
866
884
  );
867
885
 
868
- const swapPrivateL2MessageIndex = swapResult!.leafIndex;
869
- const swapPrivateSiblingPath = swapResult!.siblingPath;
886
+ const swapPrivateL2MessageIndex = swapResult.leafIndex;
887
+ const swapPrivateSiblingPath = swapResult.siblingPath;
870
888
 
871
- const withdrawL2MessageIndex = withdrawResult!.leafIndex;
872
- const withdrawSiblingPath = withdrawResult!.siblingPath;
889
+ const withdrawL2MessageIndex = withdrawResult.leafIndex;
890
+ const withdrawSiblingPath = withdrawResult.siblingPath;
873
891
 
874
892
  const withdrawMessageMetadata = {
875
- _l2BlockNumber: BigInt(withdrawReceipt.blockNumber!),
893
+ _epoch: BigInt(epoch),
894
+ _numCheckpointsInEpoch: BigInt(withdrawResult.numCheckpointsInEpoch),
876
895
  _leafIndex: BigInt(withdrawL2MessageIndex),
877
896
  _path: withdrawSiblingPath
878
897
  .toBufferArray()
@@ -880,19 +899,14 @@ export const uniswapL1L2TestSuite = (
880
899
  };
881
900
 
882
901
  const swapPrivateMessageMetadata = {
883
- _l2BlockNumber: BigInt(withdrawReceipt.blockNumber!),
902
+ _epoch: BigInt(epoch),
903
+ _numCheckpointsInEpoch: BigInt(numCheckpointsInEpoch),
884
904
  _leafIndex: BigInt(swapPrivateL2MessageIndex),
885
905
  _path: swapPrivateSiblingPath
886
906
  .toBufferArray()
887
907
  .map((buf: Buffer) => `0x${buf.toString('hex')}`) as readonly `0x${string}`[],
888
908
  };
889
909
 
890
- // ensure that user's funds were burnt
891
- await wethCrossChainHarness.expectPrivateBalanceOnL2(ownerAddress, wethL2BalanceBeforeSwap - wethAmountToBridge);
892
-
893
- // Since the outbox is only consumable when the block is proven, we need to set the block to be proven
894
- await cheatCodes.rollup.markAsProven(await rollup.getBlockNumber());
895
-
896
910
  // On L1 call swap_public!
897
911
  logger.info('call swap_public on L1');
898
912
  const swapArgs = [
@@ -932,11 +946,11 @@ export const uniswapL1L2TestSuite = (
932
946
  },
933
947
  true,
934
948
  );
935
- await validateActionInteraction.send().wait();
949
+ await validateActionInteraction.send();
936
950
 
937
951
  // Call swap_public on L2
938
952
  const secretHashForDepositingSwappedDai = Fr.random();
939
- const withdrawReceipt = await uniswapL2Contract.methods
953
+ const { receipt: withdrawReceipt } = await uniswapL2Contract.methods
940
954
  .swap_public(
941
955
  ownerAddress,
942
956
  wethCrossChainHarness.l2Bridge.address,
@@ -950,8 +964,7 @@ export const uniswapL1L2TestSuite = (
950
964
  ownerEthAddress,
951
965
  Fr.ZERO,
952
966
  )
953
- .send({ from: ownerAddress })
954
- .wait();
967
+ .send({ from: ownerAddress });
955
968
 
956
969
  const swapPublicContent = sha256ToField([
957
970
  Buffer.from(
@@ -993,21 +1006,41 @@ export const uniswapL1L2TestSuite = (
993
1006
  chainId: new Fr(l1Client.chain.id),
994
1007
  });
995
1008
 
996
- const swapResult = await computeL2ToL1MembershipWitness(aztecNode, withdrawReceipt.blockNumber!, swapPublicLeaf);
997
- const withdrawResult = await computeL2ToL1MembershipWitness(
998
- aztecNode,
999
- withdrawReceipt.blockNumber!,
1000
- withdrawLeaf,
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,
1026
+ );
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,
1001
1033
  );
1002
1034
 
1003
- const swapPublicL2MessageIndex = swapResult!.leafIndex;
1004
- const swapPublicSiblingPath = swapResult!.siblingPath;
1035
+ const swapPublicL2MessageIndex = swapResult.leafIndex;
1036
+ const swapPublicSiblingPath = swapResult.siblingPath;
1005
1037
 
1006
- const withdrawL2MessageIndex = withdrawResult!.leafIndex;
1007
- const withdrawSiblingPath = withdrawResult!.siblingPath;
1038
+ const withdrawL2MessageIndex = withdrawResult.leafIndex;
1039
+ const withdrawSiblingPath = withdrawResult.siblingPath;
1008
1040
 
1009
1041
  const withdrawMessageMetadata = {
1010
- _l2BlockNumber: BigInt(withdrawReceipt.blockNumber!),
1042
+ _epoch: BigInt(epoch),
1043
+ _numCheckpointsInEpoch: BigInt(withdrawResult.numCheckpointsInEpoch),
1011
1044
  _leafIndex: BigInt(withdrawL2MessageIndex),
1012
1045
  _path: withdrawSiblingPath
1013
1046
  .toBufferArray()
@@ -1015,19 +1048,14 @@ export const uniswapL1L2TestSuite = (
1015
1048
  };
1016
1049
 
1017
1050
  const swapPublicMessageMetadata = {
1018
- _l2BlockNumber: BigInt(withdrawReceipt.blockNumber!),
1051
+ _epoch: BigInt(epoch),
1052
+ _numCheckpointsInEpoch: BigInt(numCheckpointsInEpoch),
1019
1053
  _leafIndex: BigInt(swapPublicL2MessageIndex),
1020
1054
  _path: swapPublicSiblingPath
1021
1055
  .toBufferArray()
1022
1056
  .map((buf: Buffer) => `0x${buf.toString('hex')}`) as readonly `0x${string}`[],
1023
1057
  };
1024
1058
 
1025
- // check weth balance of owner on L2 (we first bridged `wethAmountToBridge` into L2 and now withdrew it!)
1026
- await wethCrossChainHarness.expectPublicBalanceOnL2(ownerAddress, 0n);
1027
-
1028
- // Since the outbox is only consumable when the block is proven, we need to set the block to be proven
1029
- await cheatCodes.rollup.markAsProven(await rollup.getBlockNumber());
1030
-
1031
1059
  // Call swap_private on L1
1032
1060
  logger.info('Execute withdraw and swap on the uniswapPortal!');
1033
1061
 
@@ -0,0 +1,23 @@
1
+ import type { Fr } from '@aztec/aztec.js/fields';
2
+ import type { AztecNode } from '@aztec/aztec.js/node';
3
+ import { retryUntil } from '@aztec/foundation/retry';
4
+
5
+ /**
6
+ * Waits until the archiver has seen the L1 to L2 message and indexed it. Unlike
7
+ * {@link waitForL1ToL2MessageReady} from `@aztec/aztec.js/messaging`, this does not
8
+ * require the L2 chain to have advanced to the message's checkpoint — it only confirms
9
+ * the message has been picked up from L1. Use this in tests that explicitly produce L2
10
+ * blocks afterwards to make the message consumable.
11
+ */
12
+ export function waitForL1ToL2MessageSeen(
13
+ node: Pick<AztecNode, 'getL1ToL2MessageCheckpoint'>,
14
+ l1ToL2MessageHash: Fr,
15
+ opts: { timeoutSeconds: number },
16
+ ) {
17
+ return retryUntil(
18
+ async () => (await node.getL1ToL2MessageCheckpoint(l1ToL2MessageHash)) !== undefined,
19
+ `L1 to L2 message ${l1ToL2MessageHash.toString()} seen`,
20
+ opts.timeoutSeconds,
21
+ 1,
22
+ );
23
+ }
@@ -2,10 +2,12 @@
2
2
  import { AztecAddress } from '@aztec/aztec.js/addresses';
3
3
  import { Fr } from '@aztec/aztec.js/fields';
4
4
  import { CheatCodes } from '@aztec/aztec/testing';
5
- import type { RollupContract } from '@aztec/ethereum';
6
- import { pedersenHash } from '@aztec/foundation/crypto';
5
+ import type { RollupContract } from '@aztec/ethereum/contracts';
6
+ import { SlotNumber } from '@aztec/foundation/branded-types';
7
+ import { poseidon2Hash } from '@aztec/foundation/crypto/poseidon';
7
8
  import type { TestDateProvider } from '@aztec/foundation/timer';
8
9
  import type { LendingContract } from '@aztec/noir-contracts.js/Lending';
10
+ import type { AztecNode, AztecNodeDebug } from '@aztec/stdlib/interfaces/client';
9
11
 
10
12
  import type { TokenSimulator } from './token_simulator.js';
11
13
 
@@ -28,7 +30,7 @@ export class LendingAccount {
28
30
  * @returns Key in public space
29
31
  */
30
32
  public key() {
31
- return pedersenHash([this.address, this.secret]);
33
+ return poseidon2Hash([this.address, this.secret]);
32
34
  }
33
35
  }
34
36
 
@@ -91,29 +93,45 @@ export class LendingSimulator {
91
93
  public stableCoin: TokenSimulator,
92
94
  ) {}
93
95
 
94
- async prepare() {
96
+ prepare() {
95
97
  this.accumulator = BASE;
96
- const slot = await this.rollup.getSlotAt(BigInt(await this.cc.eth.timestamp()) + BigInt(this.ethereumSlotDuration));
97
- this.time = Number(await this.rollup.getTimestampForSlot(slot));
98
+ this.time = 0;
98
99
  }
99
100
 
100
- async progressSlots(diff: number, dateProvider?: TestDateProvider) {
101
+ /**
102
+ * Advances the simulator's accumulator and clock to match a block timestamp observed on chain.
103
+ * Call this BEFORE applying any accumulator-sensitive mutation (borrow/repay) so the mutation
104
+ * sees the same accumulator as the contract did during execution.
105
+ */
106
+ observeBlockTimestamp(ts: number) {
107
+ const diff = ts - this.time;
108
+ if (diff > 0) {
109
+ this.accumulator = muldivDown(this.accumulator, computeMultiplier(this.rate, BigInt(diff)), BASE);
110
+ }
111
+ this.time = ts;
112
+ }
113
+
114
+ async progressSlots(diff: number, _dateProvider?: TestDateProvider, node?: AztecNode & AztecNodeDebug) {
101
115
  if (diff <= 1) {
102
116
  return;
103
117
  }
104
118
 
105
- const slot = await this.rollup.getSlotAt(BigInt(await this.cc.eth.timestamp()));
106
- const ts = Number(await this.rollup.getTimestampForSlot(slot + BigInt(diff)));
107
- const timeDiff = ts - this.time;
108
- this.time = ts;
119
+ const slot = await this.rollup.getSlotAt(BigInt(await this.cc.eth.lastBlockTimestamp()));
120
+ const targetSlot = SlotNumber(slot + diff);
121
+ const ts = Number(await this.rollup.getTimestampForSlot(targetSlot));
109
122
 
110
- // Mine ethereum blocks such that the next block will be in a new slot
111
- await this.cc.eth.warp(this.time - this.ethereumSlotDuration);
112
- if (dateProvider) {
113
- dateProvider.setTime(this.time * 1000);
123
+ // Queue-aware warp under AutomineSequencer: atomic warp + mineBlock that advances L2 time to the
124
+ // target slot. The cheat code routes through the AutomineSequencer queue when one is installed,
125
+ // and otherwise falls back to a manual warp + mineBlock loop.
126
+ if (node) {
127
+ await this.cc.warpL2TimeAtLeastTo(node, ts);
128
+ } else {
129
+ await this.cc.eth.warp(ts - this.ethereumSlotDuration);
114
130
  }
115
- await this.cc.rollup.markAsProven(await this.rollup.getBlockNumber());
116
- this.accumulator = muldivDown(this.accumulator, computeMultiplier(this.rate, BigInt(timeDiff)), BASE);
131
+
132
+ // Mark the latest checkpoint as proven so the rollup does not reorg pending checkpoints when
133
+ // time jumps far enough forward to cross an unproven epoch boundary.
134
+ await this.cc.rollup.markAsProven(await this.rollup.getCheckpointNumber());
117
135
  }
118
136
 
119
137
  depositPrivate(from: AztecAddress, onBehalfOf: Fr, amount: bigint) {
@@ -184,14 +202,16 @@ export class LendingSimulator {
184
202
 
185
203
  expect(this.borrowed).toEqual(this.stableCoin.totalSupply - this.mintedOutside);
186
204
 
187
- const asset = await this.lendingContract.methods.get_asset(0).simulate({ from: this.account.address });
205
+ const { result: asset } = await this.lendingContract.methods.get_asset(0).simulate({ from: this.account.address });
188
206
 
189
207
  const interestAccumulator = asset['interest_accumulator'];
190
208
  expect(interestAccumulator).toEqual(this.accumulator);
191
209
  expect(asset['last_updated_ts']).toEqual(BigInt(this.time));
192
210
 
193
211
  for (const key of [this.account.address, AztecAddress.fromField(await this.account.key())]) {
194
- const privatePos = await this.lendingContract.methods.get_position(key).simulate({ from: this.account.address });
212
+ const { result: privatePos } = await this.lendingContract.methods
213
+ .get_position(key)
214
+ .simulate({ from: this.account.address });
195
215
  expect(new Fr(privatePos['collateral'])).toEqual(this.collateral[key.toString()] ?? Fr.ZERO);
196
216
  expect(new Fr(privatePos['static_debt'])).toEqual(this.staticDebt[key.toString()] ?? Fr.ZERO);
197
217
  expect(privatePos['debt']).toEqual(