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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (316) hide show
  1. package/README.md +27 -0
  2. package/dest/bench/client_flows/benchmark.d.ts +76 -0
  3. package/dest/bench/client_flows/benchmark.d.ts.map +1 -0
  4. package/dest/bench/client_flows/benchmark.js +298 -0
  5. package/dest/bench/client_flows/client_flows_benchmark.d.ts +79 -0
  6. package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -0
  7. package/dest/bench/client_flows/client_flows_benchmark.js +318 -0
  8. package/dest/bench/client_flows/config.d.ts +14 -0
  9. package/dest/bench/client_flows/config.d.ts.map +1 -0
  10. package/dest/bench/client_flows/config.js +124 -0
  11. package/dest/bench/client_flows/data_extractor.d.ts +2 -0
  12. package/dest/bench/client_flows/data_extractor.d.ts.map +1 -0
  13. package/dest/bench/client_flows/data_extractor.js +79 -0
  14. package/dest/bench/utils.d.ts +16 -41
  15. package/dest/bench/utils.d.ts.map +1 -1
  16. package/dest/bench/utils.js +46 -72
  17. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +30 -20
  18. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts.map +1 -1
  19. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.js +137 -106
  20. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +44 -33
  21. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts.map +1 -1
  22. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.js +136 -103
  23. package/dest/e2e_deploy_contract/deploy_test.d.ts +20 -11
  24. package/dest/e2e_deploy_contract/deploy_test.d.ts.map +1 -1
  25. package/dest/e2e_deploy_contract/deploy_test.js +28 -28
  26. package/dest/e2e_epochs/epochs_test.d.ts +98 -24
  27. package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
  28. package/dest/e2e_epochs/epochs_test.js +366 -61
  29. package/dest/e2e_fees/bridging_race.notest.d.ts +2 -0
  30. package/dest/e2e_fees/bridging_race.notest.d.ts.map +1 -0
  31. package/dest/e2e_fees/bridging_race.notest.js +61 -0
  32. package/dest/e2e_fees/fees_test.d.ts +42 -24
  33. package/dest/e2e_fees/fees_test.d.ts.map +1 -1
  34. package/dest/e2e_fees/fees_test.js +194 -182
  35. package/dest/e2e_l1_publisher/write_json.d.ts +11 -0
  36. package/dest/e2e_l1_publisher/write_json.d.ts.map +1 -0
  37. package/dest/e2e_l1_publisher/write_json.js +56 -0
  38. package/dest/e2e_multi_validator/utils.d.ts +12 -0
  39. package/dest/e2e_multi_validator/utils.d.ts.map +1 -0
  40. package/dest/e2e_multi_validator/utils.js +214 -0
  41. package/dest/e2e_nested_contract/nested_contract_test.d.ts +16 -16
  42. package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +1 -1
  43. package/dest/e2e_nested_contract/nested_contract_test.js +38 -43
  44. package/dest/e2e_p2p/inactivity_slash_test.d.ts +31 -0
  45. package/dest/e2e_p2p/inactivity_slash_test.d.ts.map +1 -0
  46. package/dest/e2e_p2p/inactivity_slash_test.js +137 -0
  47. package/dest/e2e_p2p/p2p_network.d.ts +287 -31
  48. package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
  49. package/dest/e2e_p2p/p2p_network.js +281 -183
  50. package/dest/e2e_p2p/reqresp/utils.d.ts +22 -0
  51. package/dest/e2e_p2p/reqresp/utils.d.ts.map +1 -0
  52. package/dest/e2e_p2p/reqresp/utils.js +206 -0
  53. package/dest/e2e_p2p/shared.d.ts +73 -8
  54. package/dest/e2e_p2p/shared.d.ts.map +1 -1
  55. package/dest/e2e_p2p/shared.js +205 -27
  56. package/dest/e2e_storage_proof/fixtures/storage_proof_fetcher.d.ts +2 -0
  57. package/dest/e2e_storage_proof/fixtures/storage_proof_fetcher.d.ts.map +1 -0
  58. package/dest/e2e_storage_proof/fixtures/storage_proof_fetcher.js +184 -0
  59. package/dest/e2e_storage_proof/fixtures/storage_proof_fixture.d.ts +18 -0
  60. package/dest/e2e_storage_proof/fixtures/storage_proof_fixture.d.ts.map +1 -0
  61. package/dest/e2e_storage_proof/fixtures/storage_proof_fixture.js +120 -0
  62. package/dest/e2e_token_contract/token_contract_test.d.ts +30 -15
  63. package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -1
  64. package/dest/e2e_token_contract/token_contract_test.js +110 -76
  65. package/dest/fixtures/authwit_proxy.d.ts +15 -0
  66. package/dest/fixtures/authwit_proxy.d.ts.map +1 -0
  67. package/dest/fixtures/authwit_proxy.js +34 -0
  68. package/dest/fixtures/e2e_prover_test.d.ts +56 -0
  69. package/dest/fixtures/e2e_prover_test.d.ts.map +1 -0
  70. package/dest/fixtures/e2e_prover_test.js +267 -0
  71. package/dest/fixtures/elu_monitor.d.ts +21 -0
  72. package/dest/fixtures/elu_monitor.d.ts.map +1 -0
  73. package/dest/fixtures/elu_monitor.js +102 -0
  74. package/dest/fixtures/fixtures.d.ts +79 -8
  75. package/dest/fixtures/fixtures.d.ts.map +1 -1
  76. package/dest/fixtures/fixtures.js +76 -5
  77. package/dest/fixtures/get_acvm_config.d.ts +2 -2
  78. package/dest/fixtures/get_acvm_config.d.ts.map +1 -1
  79. package/dest/fixtures/get_acvm_config.js +3 -15
  80. package/dest/fixtures/get_bb_config.d.ts +2 -2
  81. package/dest/fixtures/get_bb_config.d.ts.map +1 -1
  82. package/dest/fixtures/get_bb_config.js +10 -17
  83. package/dest/fixtures/ha_setup.d.ts +71 -0
  84. package/dest/fixtures/ha_setup.d.ts.map +1 -0
  85. package/dest/fixtures/ha_setup.js +116 -0
  86. package/dest/fixtures/index.d.ts +2 -1
  87. package/dest/fixtures/index.d.ts.map +1 -1
  88. package/dest/fixtures/index.js +1 -0
  89. package/dest/fixtures/l1_to_l2_messaging.d.ts +11 -7
  90. package/dest/fixtures/l1_to_l2_messaging.d.ts.map +1 -1
  91. package/dest/fixtures/l1_to_l2_messaging.js +45 -19
  92. package/dest/fixtures/logging.d.ts +1 -1
  93. package/dest/fixtures/schnorr_hardcoded_account_contract.d.ts +25 -0
  94. package/dest/fixtures/schnorr_hardcoded_account_contract.d.ts.map +1 -0
  95. package/dest/fixtures/schnorr_hardcoded_account_contract.js +37 -0
  96. package/dest/fixtures/setup.d.ts +272 -0
  97. package/dest/fixtures/setup.d.ts.map +1 -0
  98. package/dest/fixtures/setup.js +735 -0
  99. package/dest/fixtures/setup_p2p_test.d.ts +28 -16
  100. package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
  101. package/dest/fixtures/setup_p2p_test.js +103 -32
  102. package/dest/fixtures/token_utils.d.ts +10 -4
  103. package/dest/fixtures/token_utils.d.ts.map +1 -1
  104. package/dest/fixtures/token_utils.js +30 -13
  105. package/dest/fixtures/utils.d.ts +5 -153
  106. package/dest/fixtures/utils.d.ts.map +1 -1
  107. package/dest/fixtures/utils.js +4 -552
  108. package/dest/fixtures/web3signer.d.ts +5 -0
  109. package/dest/fixtures/web3signer.d.ts.map +1 -0
  110. package/dest/fixtures/web3signer.js +53 -0
  111. package/dest/fixtures/with_telemetry_utils.d.ts +2 -2
  112. package/dest/fixtures/with_telemetry_utils.d.ts.map +1 -1
  113. package/dest/fixtures/with_telemetry_utils.js +2 -2
  114. package/dest/forward-compatibility/wallet_rpc_client.d.ts +7 -0
  115. package/dest/forward-compatibility/wallet_rpc_client.d.ts.map +1 -0
  116. package/dest/forward-compatibility/wallet_rpc_client.js +15 -0
  117. package/dest/forward-compatibility/wallet_service.d.ts +3 -0
  118. package/dest/forward-compatibility/wallet_service.d.ts.map +1 -0
  119. package/dest/forward-compatibility/wallet_service.js +109 -0
  120. package/dest/index.d.ts +1 -1
  121. package/dest/install_legacy_contracts.d.cts +10 -0
  122. package/dest/install_legacy_contracts.d.cts.map +1 -0
  123. package/dest/legacy-jest-resolver.d.cts +3 -0
  124. package/dest/legacy-jest-resolver.d.cts.map +1 -0
  125. package/dest/quality_of_service/grafana_client.d.ts +41 -0
  126. package/dest/quality_of_service/grafana_client.d.ts.map +1 -0
  127. package/dest/quality_of_service/{alert_checker.js → grafana_client.js} +1 -1
  128. package/dest/quality_of_service/prometheus_client.d.ts +38 -0
  129. package/dest/quality_of_service/prometheus_client.d.ts.map +1 -0
  130. package/dest/quality_of_service/prometheus_client.js +67 -0
  131. package/dest/shared/cross_chain_test_harness.d.ts +46 -27
  132. package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
  133. package/dest/shared/cross_chain_test_harness.js +113 -55
  134. package/dest/shared/gas_portal_test_harness.d.ts +39 -28
  135. package/dest/shared/gas_portal_test_harness.d.ts.map +1 -1
  136. package/dest/shared/gas_portal_test_harness.js +64 -34
  137. package/dest/shared/index.d.ts +3 -2
  138. package/dest/shared/index.d.ts.map +1 -1
  139. package/dest/shared/index.js +1 -0
  140. package/dest/shared/jest_setup.d.ts +1 -1
  141. package/dest/shared/jest_setup.js +42 -2
  142. package/dest/shared/mock_state_view.d.ts +86 -0
  143. package/dest/shared/mock_state_view.d.ts.map +1 -0
  144. package/dest/shared/mock_state_view.js +186 -0
  145. package/dest/shared/submit-transactions.d.ts +6 -4
  146. package/dest/shared/submit-transactions.d.ts.map +1 -1
  147. package/dest/shared/submit-transactions.js +15 -16
  148. package/dest/shared/uniswap_l1_l2.d.ts +3 -25
  149. package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
  150. package/dest/shared/uniswap_l1_l2.js +202 -135
  151. package/dest/shared/wait_for_l1_to_l2_message.d.ts +13 -0
  152. package/dest/shared/wait_for_l1_to_l2_message.d.ts.map +1 -0
  153. package/dest/shared/wait_for_l1_to_l2_message.js +10 -0
  154. package/dest/simulators/index.d.ts +1 -1
  155. package/dest/simulators/lending_simulator.d.ts +16 -9
  156. package/dest/simulators/lending_simulator.d.ts.map +1 -1
  157. package/dest/simulators/lending_simulator.js +38 -27
  158. package/dest/simulators/token_simulator.d.ts +6 -3
  159. package/dest/simulators/token_simulator.d.ts.map +1 -1
  160. package/dest/simulators/token_simulator.js +12 -30
  161. package/dest/spartan/setup_test_wallets.d.ts +36 -11
  162. package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
  163. package/dest/spartan/setup_test_wallets.js +301 -63
  164. package/dest/spartan/tx_metrics.d.ts +102 -0
  165. package/dest/spartan/tx_metrics.d.ts.map +1 -0
  166. package/dest/spartan/tx_metrics.js +475 -0
  167. package/dest/spartan/utils/bot.d.ts +28 -0
  168. package/dest/spartan/utils/bot.d.ts.map +1 -0
  169. package/dest/spartan/utils/bot.js +142 -0
  170. package/dest/spartan/utils/chaos.d.ts +79 -0
  171. package/dest/spartan/utils/chaos.d.ts.map +1 -0
  172. package/dest/spartan/utils/chaos.js +142 -0
  173. package/dest/spartan/utils/clients.d.ts +39 -0
  174. package/dest/spartan/utils/clients.d.ts.map +1 -0
  175. package/dest/spartan/utils/clients.js +90 -0
  176. package/dest/spartan/utils/config.d.ts +19 -0
  177. package/dest/spartan/utils/config.d.ts.map +1 -0
  178. package/dest/spartan/utils/config.js +23 -0
  179. package/dest/spartan/utils/health.d.ts +63 -0
  180. package/dest/spartan/utils/health.d.ts.map +1 -0
  181. package/dest/spartan/utils/health.js +202 -0
  182. package/dest/spartan/utils/helm.d.ts +15 -0
  183. package/dest/spartan/utils/helm.d.ts.map +1 -0
  184. package/dest/spartan/utils/helm.js +47 -0
  185. package/dest/spartan/utils/index.d.ts +11 -0
  186. package/dest/spartan/utils/index.d.ts.map +1 -0
  187. package/dest/spartan/utils/index.js +22 -0
  188. package/dest/spartan/utils/k8s.d.ts +128 -0
  189. package/dest/spartan/utils/k8s.d.ts.map +1 -0
  190. package/dest/spartan/utils/k8s.js +381 -0
  191. package/dest/spartan/utils/nodes.d.ts +40 -0
  192. package/dest/spartan/utils/nodes.d.ts.map +1 -0
  193. package/dest/spartan/utils/nodes.js +461 -0
  194. package/dest/spartan/utils/pod_logs.d.ts +25 -0
  195. package/dest/spartan/utils/pod_logs.d.ts.map +1 -0
  196. package/dest/spartan/utils/pod_logs.js +74 -0
  197. package/dest/spartan/utils/scripts.d.ts +30 -0
  198. package/dest/spartan/utils/scripts.d.ts.map +1 -0
  199. package/dest/spartan/utils/scripts.js +81 -0
  200. package/dest/spartan/utils.d.ts +2 -415
  201. package/dest/spartan/utils.d.ts.map +1 -1
  202. package/dest/spartan/utils.js +1 -445
  203. package/dest/test-wallet/test_wallet.d.ts +85 -0
  204. package/dest/test-wallet/test_wallet.d.ts.map +1 -0
  205. package/dest/test-wallet/test_wallet.js +273 -0
  206. package/dest/test-wallet/utils.d.ts +41 -0
  207. package/dest/test-wallet/utils.d.ts.map +1 -0
  208. package/dest/test-wallet/utils.js +66 -0
  209. package/dest/test-wallet/wallet_worker_script.d.ts +2 -0
  210. package/dest/test-wallet/wallet_worker_script.d.ts.map +1 -0
  211. package/dest/test-wallet/wallet_worker_script.js +53 -0
  212. package/dest/test-wallet/worker_wallet.d.ts +53 -0
  213. package/dest/test-wallet/worker_wallet.d.ts.map +1 -0
  214. package/dest/test-wallet/worker_wallet.js +155 -0
  215. package/dest/test-wallet/worker_wallet_schema.d.ts +160 -0
  216. package/dest/test-wallet/worker_wallet_schema.d.ts.map +1 -0
  217. package/dest/test-wallet/worker_wallet_schema.js +22 -0
  218. package/package.json +79 -64
  219. package/src/bench/client_flows/benchmark.ts +382 -0
  220. package/src/bench/client_flows/client_flows_benchmark.ts +399 -0
  221. package/src/bench/client_flows/config.ts +69 -0
  222. package/src/bench/client_flows/data_extractor.ts +89 -0
  223. package/src/bench/utils.ts +49 -87
  224. package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +164 -172
  225. package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +194 -183
  226. package/src/e2e_deploy_contract/deploy_test.ts +42 -49
  227. package/src/e2e_epochs/epochs_test.ts +451 -93
  228. package/src/e2e_fees/bridging_race.notest.ts +74 -0
  229. package/src/e2e_fees/fees_test.ts +249 -262
  230. package/src/e2e_l1_publisher/write_json.ts +77 -0
  231. package/src/e2e_multi_validator/utils.ts +258 -0
  232. package/src/e2e_nested_contract/nested_contract_test.ts +51 -60
  233. package/src/e2e_p2p/inactivity_slash_test.ts +180 -0
  234. package/src/e2e_p2p/p2p_network.ts +391 -240
  235. package/src/e2e_p2p/reqresp/utils.ts +274 -0
  236. package/src/e2e_p2p/shared.ts +304 -39
  237. package/src/e2e_storage_proof/fixtures/storage_proof.json +915 -0
  238. package/src/e2e_storage_proof/fixtures/storage_proof_fetcher.ts +190 -0
  239. package/src/e2e_storage_proof/fixtures/storage_proof_fixture.ts +173 -0
  240. package/src/e2e_token_contract/token_contract_test.ts +140 -124
  241. package/src/fixtures/authwit_proxy.ts +54 -0
  242. package/src/fixtures/dumps/epoch_proof_result.json +1 -1
  243. package/src/fixtures/e2e_prover_test.ts +329 -0
  244. package/src/fixtures/elu_monitor.ts +126 -0
  245. package/src/fixtures/fixtures.ts +98 -7
  246. package/src/fixtures/get_acvm_config.ts +4 -12
  247. package/src/fixtures/get_bb_config.ts +19 -13
  248. package/src/fixtures/ha_setup.ts +188 -0
  249. package/src/fixtures/index.ts +1 -0
  250. package/src/fixtures/l1_to_l2_messaging.ts +56 -24
  251. package/src/fixtures/schnorr_hardcoded_account_contract.ts +49 -0
  252. package/src/fixtures/setup.ts +1056 -0
  253. package/src/fixtures/setup_p2p_test.ts +142 -54
  254. package/src/fixtures/token_utils.ts +34 -16
  255. package/src/fixtures/utils.ts +29 -820
  256. package/src/fixtures/web3signer.ts +63 -0
  257. package/src/fixtures/with_telemetry_utils.ts +2 -2
  258. package/src/forward-compatibility/wallet_rpc_client.ts +14 -0
  259. package/src/forward-compatibility/wallet_service.ts +104 -0
  260. package/src/guides/up_quick_start.sh +9 -19
  261. package/src/install_legacy_contracts.cjs +75 -0
  262. package/src/legacy-jest-resolver.cjs +112 -0
  263. package/src/quality_of_service/{alert_checker.ts → grafana_client.ts} +2 -2
  264. package/src/quality_of_service/prometheus_client.ts +113 -0
  265. package/src/shared/cross_chain_test_harness.ts +116 -90
  266. package/src/shared/gas_portal_test_harness.ts +75 -56
  267. package/src/shared/index.ts +2 -1
  268. package/src/shared/jest_setup.ts +52 -2
  269. package/src/shared/mock_state_view.ts +188 -0
  270. package/src/shared/submit-transactions.ts +19 -20
  271. package/src/shared/uniswap_l1_l2.ts +259 -234
  272. package/src/shared/wait_for_l1_to_l2_message.ts +23 -0
  273. package/src/simulators/lending_simulator.ts +43 -26
  274. package/src/simulators/token_simulator.ts +18 -34
  275. package/src/spartan/DEVELOP.md +128 -0
  276. package/src/spartan/setup_test_wallets.ts +420 -96
  277. package/src/spartan/tx_metrics.ts +434 -0
  278. package/src/spartan/utils/bot.ts +188 -0
  279. package/src/spartan/utils/chaos.ts +253 -0
  280. package/src/spartan/utils/clients.ts +100 -0
  281. package/src/spartan/utils/config.ts +29 -0
  282. package/src/spartan/utils/health.ts +255 -0
  283. package/src/spartan/utils/helm.ts +84 -0
  284. package/src/spartan/utils/index.ts +71 -0
  285. package/src/spartan/utils/k8s.ts +535 -0
  286. package/src/spartan/utils/nodes.ts +543 -0
  287. package/src/spartan/utils/pod_logs.ts +99 -0
  288. package/src/spartan/utils/scripts.ts +99 -0
  289. package/src/spartan/utils.ts +1 -582
  290. package/src/test-wallet/test_wallet.ts +376 -0
  291. package/src/test-wallet/utils.ts +108 -0
  292. package/src/test-wallet/wallet_worker_script.ts +63 -0
  293. package/src/test-wallet/worker_wallet.ts +218 -0
  294. package/src/test-wallet/worker_wallet_schema.ts +13 -0
  295. package/dest/e2e_prover/e2e_prover_test.d.ts +0 -56
  296. package/dest/e2e_prover/e2e_prover_test.d.ts.map +0 -1
  297. package/dest/e2e_prover/e2e_prover_test.js +0 -291
  298. package/dest/fixtures/setup_l1_contracts.d.ts +0 -6
  299. package/dest/fixtures/setup_l1_contracts.d.ts.map +0 -1
  300. package/dest/fixtures/setup_l1_contracts.js +0 -17
  301. package/dest/fixtures/snapshot_manager.d.ts +0 -87
  302. package/dest/fixtures/snapshot_manager.d.ts.map +0 -1
  303. package/dest/fixtures/snapshot_manager.js +0 -479
  304. package/dest/quality_of_service/alert_checker.d.ts +0 -41
  305. package/dest/quality_of_service/alert_checker.d.ts.map +0 -1
  306. package/dest/sample-dapp/connect.js +0 -12
  307. package/dest/sample-dapp/contracts.js +0 -10
  308. package/dest/sample-dapp/deploy.js +0 -35
  309. package/dest/sample-dapp/index.js +0 -98
  310. package/src/e2e_prover/e2e_prover_test.ts +0 -418
  311. package/src/fixtures/setup_l1_contracts.ts +0 -27
  312. package/src/fixtures/snapshot_manager.ts +0 -617
  313. package/src/sample-dapp/connect.mjs +0 -16
  314. package/src/sample-dapp/contracts.mjs +0 -14
  315. package/src/sample-dapp/deploy.mjs +0 -40
  316. package/src/sample-dapp/index.mjs +0 -128
@@ -1,24 +1,23 @@
1
- // docs:start:cross_chain_test_harness
1
+ import type { AztecAddress } from '@aztec/aztec.js/addresses';
2
+ import { EthAddress } from '@aztec/aztec.js/addresses';
3
+ import { AuthWitness } from '@aztec/aztec.js/authorization';
2
4
  import {
3
- type AccountWallet,
4
- type AztecAddress,
5
- type AztecNode,
6
- EthAddress,
7
- type FieldsOf,
8
- Fr,
9
5
  type L1TokenManager,
10
6
  L1TokenPortalManager,
11
7
  type L2AmountClaim,
12
8
  type L2AmountClaimWithRecipient,
13
- type Logger,
14
- type PXE,
15
- type SiblingPath,
16
- type TxReceipt,
17
- type Wallet,
18
- deployL1Contract,
19
- retryUntil,
20
- } from '@aztec/aztec.js';
21
- import type { L1ContractAddresses, ViemPublicClient, ViemWalletClient } from '@aztec/ethereum';
9
+ } from '@aztec/aztec.js/ethereum';
10
+ import { Fr } from '@aztec/aztec.js/fields';
11
+ import type { Logger } from '@aztec/aztec.js/log';
12
+ import type { AztecNode } from '@aztec/aztec.js/node';
13
+ import type { SiblingPath } from '@aztec/aztec.js/trees';
14
+ import type { TxReceipt } from '@aztec/aztec.js/tx';
15
+ import type { Wallet } from '@aztec/aztec.js/wallet';
16
+ import { OutboxContract } from '@aztec/ethereum/contracts';
17
+ import { deployL1Contract } from '@aztec/ethereum/deploy-l1-contract';
18
+ import type { L1ContractAddresses } from '@aztec/ethereum/l1-contract-addresses';
19
+ import type { ExtendedViemWalletClient } from '@aztec/ethereum/types';
20
+ import { EpochNumber } from '@aztec/foundation/branded-types';
22
21
  import { TestERC20Abi, TokenPortalAbi, TokenPortalBytecode } from '@aztec/l1-artifacts';
23
22
  import { TokenContract } from '@aztec/noir-contracts.js/Token';
24
23
  import { TokenBridgeContract } from '@aztec/noir-contracts.js/TokenBridge';
@@ -26,8 +25,8 @@ import { TokenBridgeContract } from '@aztec/noir-contracts.js/TokenBridge';
26
25
  import { type Hex, getContract } from 'viem';
27
26
 
28
27
  import { mintTokensToPrivate } from '../fixtures/token_utils.js';
28
+ import { waitForL1ToL2MessageSeen } from './wait_for_l1_to_l2_message.js';
29
29
 
30
- // docs:start:deployAndInitializeTokenAndBridgeContracts
31
30
  /**
32
31
  * Deploy L1 token and portal, initialize portal, deploy a non native l2 token contract, its L2 bridge contract and attach is to the portal.
33
32
  * @param wallet - the wallet instance
@@ -40,8 +39,7 @@ import { mintTokensToPrivate } from '../fixtures/token_utils.js';
40
39
  */
41
40
  export async function deployAndInitializeTokenAndBridgeContracts(
42
41
  wallet: Wallet,
43
- walletClient: ViemWalletClient,
44
- publicClient: ViemPublicClient,
42
+ l1Client: ExtendedViemWalletClient,
45
43
  rollupRegistryAddress: EthAddress,
46
44
  owner: AztecAddress,
47
45
  underlyingERC20Address: EthAddress,
@@ -68,35 +66,34 @@ export async function deployAndInitializeTokenAndBridgeContracts(
68
66
  underlyingERC20: any;
69
67
  }> {
70
68
  // deploy the token portal
71
- const { address: tokenPortalAddress } = await deployL1Contract(
72
- walletClient,
73
- publicClient,
74
- TokenPortalAbi,
75
- TokenPortalBytecode,
76
- );
69
+ const { address: tokenPortalAddress } = await deployL1Contract(l1Client, TokenPortalAbi, TokenPortalBytecode);
77
70
  const tokenPortal = getContract({
78
71
  address: tokenPortalAddress.toString(),
79
72
  abi: TokenPortalAbi,
80
- client: walletClient,
73
+ client: l1Client,
81
74
  });
82
75
 
83
76
  // deploy l2 token
84
- const token = await TokenContract.deploy(wallet, owner, 'TokenName', 'TokenSymbol', 18).send().deployed();
77
+ const { contract: token } = await TokenContract.deploy(wallet, owner, 'TokenName', 'TokenSymbol', 18).send({
78
+ from: owner,
79
+ });
85
80
 
86
81
  // deploy l2 token bridge and attach to the portal
87
- const bridge = await TokenBridgeContract.deploy(wallet, token.address, tokenPortalAddress).send().deployed();
82
+ const { contract: bridge } = await TokenBridgeContract.deploy(wallet, token.address, tokenPortalAddress).send({
83
+ from: owner,
84
+ });
88
85
 
89
- if ((await token.methods.get_admin().simulate()) !== owner.toBigInt()) {
86
+ if ((await token.methods.get_admin().simulate({ from: owner })).result !== owner.toBigInt()) {
90
87
  throw new Error(`Token admin is not ${owner}`);
91
88
  }
92
89
 
93
- if (!(await bridge.methods.get_config().simulate()).token.equals(token.address)) {
90
+ if (!(await bridge.methods.get_config().simulate({ from: owner })).result.token.equals(token.address)) {
94
91
  throw new Error(`Bridge token is not ${token.address}`);
95
92
  }
96
93
 
97
94
  // make the bridge a minter on the token:
98
- await token.methods.set_minter(bridge.address, true).send().wait();
99
- if ((await token.methods.is_minter(bridge.address).simulate()) === 1n) {
95
+ await token.methods.set_minter(bridge.address, true).send({ from: owner });
96
+ if ((await token.methods.is_minter(bridge.address).simulate({ from: owner })).result === 1n) {
100
97
  throw new Error(`Bridge is not a minter`);
101
98
  }
102
99
 
@@ -109,12 +106,22 @@ export async function deployAndInitializeTokenAndBridgeContracts(
109
106
  const underlyingERC20 = getContract({
110
107
  address: underlyingERC20Address.toString(),
111
108
  abi: TestERC20Abi,
112
- client: walletClient,
109
+ client: l1Client,
113
110
  });
114
111
 
115
112
  return { token, bridge, tokenPortalAddress, tokenPortal, underlyingERC20 };
116
113
  }
117
- // docs:end:deployAndInitializeTokenAndBridgeContracts
114
+
115
+ export type CrossChainContext = {
116
+ l2Token: AztecAddress;
117
+ l2Bridge: AztecAddress;
118
+ tokenPortal: EthAddress;
119
+ underlying: EthAddress;
120
+ ethAccount: EthAddress;
121
+ ownerAddress: AztecAddress;
122
+ inbox: EthAddress;
123
+ outbox: EthAddress;
124
+ };
118
125
 
119
126
  /**
120
127
  * A Class for testing cross chain interactions, contains common interactions
@@ -123,54 +130,48 @@ export async function deployAndInitializeTokenAndBridgeContracts(
123
130
  export class CrossChainTestHarness {
124
131
  static async new(
125
132
  aztecNode: AztecNode,
126
- pxeService: PXE,
127
- publicClient: ViemPublicClient,
128
- walletClient: ViemWalletClient,
129
- wallet: AccountWallet,
133
+ l1Client: ExtendedViemWalletClient,
134
+ wallet: Wallet,
135
+ ownerAddress: AztecAddress,
130
136
  logger: Logger,
131
137
  underlyingERC20Address: EthAddress,
132
138
  ): Promise<CrossChainTestHarness> {
133
- const ethAccount = EthAddress.fromString((await walletClient.getAddresses())[0]);
134
- const l1ContractAddresses = (await pxeService.getNodeInfo()).l1ContractAddresses;
139
+ const ethAccount = EthAddress.fromString((await l1Client.getAddresses())[0]);
140
+ const l1ContractAddresses = (await aztecNode.getNodeInfo()).l1ContractAddresses;
135
141
 
136
142
  // Deploy and initialize all required contracts
137
143
  logger.info('Deploying and initializing token, portal and its bridge...');
138
144
  const { token, bridge, tokenPortalAddress, underlyingERC20 } = await deployAndInitializeTokenAndBridgeContracts(
139
145
  wallet,
140
- walletClient,
141
- publicClient,
146
+ l1Client,
142
147
  l1ContractAddresses.registryAddress,
143
- wallet.getAddress(),
148
+ ownerAddress,
144
149
  underlyingERC20Address,
145
150
  );
146
151
  logger.info('Deployed and initialized token, portal and its bridge.');
147
152
 
148
153
  return new CrossChainTestHarness(
149
154
  aztecNode,
150
- pxeService,
151
155
  logger,
152
156
  token,
153
157
  bridge,
154
158
  ethAccount,
155
159
  tokenPortalAddress,
156
160
  underlyingERC20.address,
157
- publicClient,
158
- walletClient,
161
+ l1Client,
159
162
  l1ContractAddresses,
160
163
  wallet,
164
+ ownerAddress,
161
165
  );
162
166
  }
163
167
 
164
168
  private readonly l1TokenManager: L1TokenManager;
165
169
  private readonly l1TokenPortalManager: L1TokenPortalManager;
166
-
167
- public readonly ownerAddress: AztecAddress;
170
+ public readonly outboxContract: OutboxContract;
168
171
 
169
172
  constructor(
170
173
  /** Aztec node instance. */
171
174
  public aztecNode: AztecNode,
172
- /** Private eXecution Environment (PXE). */
173
- public pxeService: PXE,
174
175
  /** Logger. */
175
176
  public logger: Logger,
176
177
 
@@ -186,32 +187,40 @@ export class CrossChainTestHarness {
186
187
  public tokenPortalAddress: EthAddress,
187
188
  /** Underlying token for portal tests. */
188
189
  public underlyingERC20Address: EthAddress,
189
- /** Viem Public client instance. */
190
- public publicClient: ViemPublicClient,
191
- /** Viem Wallet Client instance. */
192
- public walletClient: ViemWalletClient,
190
+ /** Viem Extended client instance. */
191
+ public l1Client: ExtendedViemWalletClient,
193
192
 
194
193
  /** Deployment addresses for all L1 contracts */
195
194
  public readonly l1ContractAddresses: L1ContractAddresses,
196
195
 
197
- /** Wallet of the owner. */
198
- public readonly ownerWallet: AccountWallet,
196
+ /** Wallet to simulate and send txs from. */
197
+ public readonly wallet: Wallet,
198
+
199
+ /** Owner of the l2 token and bridge */
200
+ public readonly ownerAddress: AztecAddress,
199
201
  ) {
200
202
  this.l1TokenPortalManager = new L1TokenPortalManager(
201
203
  this.tokenPortalAddress,
202
204
  this.underlyingERC20Address,
205
+ this.l1ContractAddresses.feeAssetHandlerAddress,
203
206
  this.l1ContractAddresses.outboxAddress,
204
- this.publicClient,
205
- this.walletClient,
207
+ this.l1Client,
206
208
  this.logger,
207
209
  );
208
210
  this.l1TokenManager = this.l1TokenPortalManager.getTokenManager();
209
- this.ownerAddress = this.ownerWallet.getAddress();
211
+ this.outboxContract = new OutboxContract(this.l1Client, this.l1ContractAddresses.outboxAddress);
210
212
  }
211
213
 
212
214
  async mintTokensOnL1(amount: bigint) {
213
- await this.l1TokenManager.mint(amount, this.ethAccount.toString());
214
- expect(await this.l1TokenManager.getL1TokenBalance(this.ethAccount.toString())).toEqual(amount);
215
+ const contract = getContract({
216
+ abi: TestERC20Abi,
217
+ address: this.l1TokenManager.tokenAddress.toString(),
218
+ client: this.l1Client,
219
+ });
220
+ const balanceBefore = await this.l1TokenManager.getL1TokenBalance(this.ethAccount.toString());
221
+ const hash = await contract.write.mint([this.ethAccount.toString(), amount]);
222
+ await this.l1Client.waitForTransactionReceipt({ hash });
223
+ expect(await this.l1TokenManager.getL1TokenBalance(this.ethAccount.toString())).toEqual(balanceBefore + amount);
215
224
  }
216
225
 
217
226
  getL1BalanceOf(address: EthAddress) {
@@ -228,16 +237,18 @@ export class CrossChainTestHarness {
228
237
 
229
238
  async mintTokensPublicOnL2(amount: bigint) {
230
239
  this.logger.info('Minting tokens on L2 publicly');
231
- await this.l2Token.methods.mint_to_public(this.ownerAddress, amount).send().wait();
240
+ await this.l2Token.methods.mint_to_public(this.ownerAddress, amount).send({ from: this.ownerAddress });
232
241
  }
233
242
 
234
243
  async mintTokensPrivateOnL2(amount: bigint) {
235
- await mintTokensToPrivate(this.l2Token, this.ownerWallet, this.ownerAddress, amount);
244
+ await mintTokensToPrivate(this.l2Token, this.ownerAddress, this.ownerAddress, amount);
236
245
  }
237
246
 
238
247
  async sendL2PublicTransfer(transferAmount: bigint, receiverAddress: AztecAddress) {
239
248
  // send a transfer tx to force through rollup with the message included
240
- await this.l2Token.methods.transfer_in_public(this.ownerAddress, receiverAddress, transferAmount, 0).send().wait();
249
+ await this.l2Token.methods
250
+ .transfer_in_public(this.ownerAddress, receiverAddress, transferAmount, 0)
251
+ .send({ from: this.ownerAddress });
241
252
  }
242
253
 
243
254
  async consumeMessageOnAztecAndMintPrivately(
@@ -247,8 +258,7 @@ export class CrossChainTestHarness {
247
258
  const { recipient, claimAmount, claimSecret: secretForL2MessageConsumption, messageLeafIndex } = claim;
248
259
  await this.l2Bridge.methods
249
260
  .claim_private(recipient, claimAmount, secretForL2MessageConsumption, messageLeafIndex)
250
- .send()
251
- .wait();
261
+ .send({ from: this.ownerAddress });
252
262
  }
253
263
 
254
264
  async consumeMessageOnAztecAndMintPublicly(
@@ -258,30 +268,31 @@ export class CrossChainTestHarness {
258
268
  const { claimAmount, claimSecret, messageLeafIndex } = claim;
259
269
  await this.l2Bridge.methods
260
270
  .claim_public(this.ownerAddress, claimAmount, claimSecret, messageLeafIndex)
261
- .send()
262
- .wait();
271
+ .send({ from: this.ownerAddress });
263
272
  }
264
273
 
265
- async withdrawPrivateFromAztecToL1(withdrawAmount: bigint, nonce: Fr = Fr.ZERO): Promise<FieldsOf<TxReceipt>> {
266
- const withdrawReceipt = await this.l2Bridge.methods
267
- .exit_to_l1_private(this.l2Token.address, this.ethAccount, withdrawAmount, EthAddress.ZERO, nonce)
268
- .send()
269
- .wait();
274
+ async withdrawPrivateFromAztecToL1(
275
+ withdrawAmount: bigint,
276
+ authwitNonce: Fr = Fr.ZERO,
277
+ authWitness: AuthWitness,
278
+ ): Promise<TxReceipt> {
279
+ const { receipt: withdrawReceipt } = await this.l2Bridge.methods
280
+ .exit_to_l1_private(this.l2Token.address, this.ethAccount, withdrawAmount, EthAddress.ZERO, authwitNonce)
281
+ .send({ authWitnesses: [authWitness], from: this.ownerAddress });
270
282
 
271
283
  return withdrawReceipt;
272
284
  }
273
285
 
274
- async withdrawPublicFromAztecToL1(withdrawAmount: bigint, nonce: Fr = Fr.ZERO): Promise<FieldsOf<TxReceipt>> {
275
- const withdrawReceipt = await this.l2Bridge.methods
276
- .exit_to_l1_public(this.ethAccount, withdrawAmount, EthAddress.ZERO, nonce)
277
- .send()
278
- .wait();
286
+ async withdrawPublicFromAztecToL1(withdrawAmount: bigint, authwitNonce: Fr = Fr.ZERO): Promise<TxReceipt> {
287
+ const { receipt: withdrawReceipt } = await this.l2Bridge.methods
288
+ .exit_to_l1_public(this.ethAccount, withdrawAmount, EthAddress.ZERO, authwitNonce)
289
+ .send({ from: this.ownerAddress });
279
290
 
280
291
  return withdrawReceipt;
281
292
  }
282
293
 
283
294
  async getL2PrivateBalanceOf(owner: AztecAddress) {
284
- return await this.l2Token.methods.balance_of_private(owner).simulate({ from: owner });
295
+ return (await this.l2Token.methods.balance_of_private(owner).simulate({ from: owner })).result;
285
296
  }
286
297
 
287
298
  async expectPrivateBalanceOnL2(owner: AztecAddress, expectedBalance: bigint) {
@@ -291,7 +302,7 @@ export class CrossChainTestHarness {
291
302
  }
292
303
 
293
304
  async getL2PublicBalanceOf(owner: AztecAddress) {
294
- return await this.l2Token.methods.balance_of_public(owner).simulate();
305
+ return (await this.l2Token.methods.balance_of_public(owner).simulate({ from: this.ownerAddress })).result;
295
306
  }
296
307
 
297
308
  async expectPublicBalanceOnL2(owner: AztecAddress, expectedBalance: bigint) {
@@ -299,8 +310,8 @@ export class CrossChainTestHarness {
299
310
  expect(balance).toBe(expectedBalance);
300
311
  }
301
312
 
302
- getL2ToL1MessageLeaf(withdrawAmount: bigint, callerOnL1: EthAddress = EthAddress.ZERO): Fr {
303
- return this.l1TokenPortalManager.getL2ToL1MessageLeaf(
313
+ async getL2ToL1MessageLeaf(withdrawAmount: bigint, callerOnL1: EthAddress = EthAddress.ZERO): Promise<Fr> {
314
+ return await this.l1TokenPortalManager.getL2ToL1MessageLeaf(
304
315
  withdrawAmount,
305
316
  this.ethAccount,
306
317
  this.l2Bridge.address,
@@ -310,14 +321,16 @@ export class CrossChainTestHarness {
310
321
 
311
322
  withdrawFundsFromBridgeOnL1(
312
323
  amount: bigint,
313
- blockNumber: number | bigint,
324
+ epochNumber: EpochNumber,
325
+ numCheckpointsInEpoch: number,
314
326
  messageIndex: bigint,
315
327
  siblingPath: SiblingPath<number>,
316
328
  ) {
317
329
  return this.l1TokenPortalManager.withdrawFunds(
318
330
  amount,
319
331
  this.ethAccount,
320
- BigInt(blockNumber),
332
+ epochNumber,
333
+ numCheckpointsInEpoch,
321
334
  messageIndex,
322
335
  siblingPath,
323
336
  );
@@ -325,12 +338,14 @@ export class CrossChainTestHarness {
325
338
 
326
339
  async transferToPrivateOnL2(shieldAmount: bigint) {
327
340
  this.logger.info('Transferring to private on L2');
328
- await this.l2Token.methods.transfer_to_private(this.ownerAddress, shieldAmount).send().wait();
341
+ await this.l2Token.methods.transfer_to_private(this.ownerAddress, shieldAmount).send({ from: this.ownerAddress });
329
342
  }
330
343
 
331
- async transferToPublicOnL2(amount: bigint, nonce = Fr.ZERO) {
344
+ async transferToPublicOnL2(amount: bigint, authwitNonce = Fr.ZERO) {
332
345
  this.logger.info('Transferring tokens to public');
333
- await this.l2Token.methods.transfer_to_public(this.ownerAddress, this.ownerAddress, amount, nonce).send().wait();
346
+ await this.l2Token.methods
347
+ .transfer_to_public(this.ownerAddress, this.ownerAddress, amount, authwitNonce)
348
+ .send({ from: this.ownerAddress });
334
349
  }
335
350
 
336
351
  /**
@@ -342,11 +357,22 @@ export class CrossChainTestHarness {
342
357
  */
343
358
  async makeMessageConsumable(msgHash: Fr | Hex) {
344
359
  const frMsgHash = typeof msgHash === 'string' ? Fr.fromHexString(msgHash) : msgHash;
345
- // We poll isL1ToL2MessageSynced endpoint until the message is available
346
- await retryUntil(async () => await this.aztecNode.isL1ToL2MessageSynced(frMsgHash), 'message sync', 10);
360
+ await waitForL1ToL2MessageSeen(this.aztecNode, frMsgHash, { timeoutSeconds: 10 });
347
361
 
348
362
  await this.mintTokensPublicOnL2(0n);
349
363
  await this.mintTokensPublicOnL2(0n);
350
364
  }
365
+
366
+ toCrossChainContext(): CrossChainContext {
367
+ return {
368
+ l2Token: this.l2Token.address,
369
+ l2Bridge: this.l2Bridge.address,
370
+ tokenPortal: this.tokenPortalAddress,
371
+ underlying: this.underlyingERC20Address,
372
+ ethAccount: this.ethAccount,
373
+ ownerAddress: this.ownerAddress,
374
+ inbox: this.l1ContractAddresses.inboxAddress,
375
+ outbox: this.l1ContractAddresses.outboxAddress,
376
+ };
377
+ }
351
378
  }
352
- // docs:end:cross_chain_test_harness
@@ -1,33 +1,32 @@
1
- import {
2
- type AztecAddress,
3
- type AztecNode,
4
- EthAddress,
5
- Fr,
6
- L1FeeJuicePortalManager,
7
- type L1TokenManager,
8
- type L2AmountClaim,
9
- type Logger,
10
- type PXE,
11
- type Wallet,
12
- retryUntil,
13
- } from '@aztec/aztec.js';
14
- import type { ViemPublicClient, ViemWalletClient } from '@aztec/ethereum';
1
+ import { AztecAddress, EthAddress } from '@aztec/aztec.js/addresses';
2
+ import { L1FeeJuicePortalManager, type L1TokenManager, type L2AmountClaim } from '@aztec/aztec.js/ethereum';
3
+ import { Fr } from '@aztec/aztec.js/fields';
4
+ import type { Logger } from '@aztec/aztec.js/log';
5
+ import type { AztecNode } from '@aztec/aztec.js/node';
6
+ import type { Wallet } from '@aztec/aztec.js/wallet';
7
+ import type { ExtendedViemWalletClient } from '@aztec/ethereum/types';
8
+ import { retryUntil } from '@aztec/foundation/retry';
15
9
  import { FeeJuiceContract } from '@aztec/noir-contracts.js/FeeJuice';
16
10
  import { ProtocolContractAddress } from '@aztec/protocol-contracts';
11
+ import type { AztecNodeAdmin, AztecNodeDebug } from '@aztec/stdlib/interfaces/client';
12
+
13
+ import { waitForL1ToL2MessageSeen } from './wait_for_l1_to_l2_message.js';
14
+
15
+ /** Aztec node that may expose the debug mining API in local e2e setups. */
16
+ type MiningAztecNode = AztecNode & Partial<AztecNodeDebug>;
17
17
 
18
18
  export interface IGasBridgingTestHarness {
19
19
  getL1FeeJuiceBalance(address: EthAddress): Promise<bigint>;
20
- prepareTokensOnL1(bridgeAmount: bigint, owner: AztecAddress): Promise<L2AmountClaim>;
21
- bridgeFromL1ToL2(bridgeAmount: bigint, owner: AztecAddress): Promise<void>;
20
+ prepareTokensOnL1(owner: AztecAddress): Promise<L2AmountClaim>;
21
+ bridgeFromL1ToL2(owner: AztecAddress, claimer: AztecAddress): Promise<void>;
22
22
  feeJuice: FeeJuiceContract;
23
23
  l1FeeJuiceAddress: EthAddress;
24
24
  }
25
25
 
26
26
  export interface FeeJuicePortalTestingHarnessFactoryConfig {
27
- aztecNode: AztecNode;
28
- pxeService: PXE;
29
- publicClient: ViemPublicClient;
30
- walletClient: ViemWalletClient;
27
+ aztecNode: MiningAztecNode;
28
+ aztecNodeAdmin?: AztecNodeAdmin;
29
+ l1Client: ExtendedViemWalletClient;
31
30
  wallet: Wallet;
32
31
  logger: Logger;
33
32
  mockL1?: boolean;
@@ -37,10 +36,10 @@ export class FeeJuicePortalTestingHarnessFactory {
37
36
  private constructor(private config: FeeJuicePortalTestingHarnessFactoryConfig) {}
38
37
 
39
38
  private async createReal() {
40
- const { aztecNode, pxeService, publicClient, walletClient, wallet, logger } = this.config;
39
+ const { aztecNode, aztecNodeAdmin, l1Client, wallet, logger } = this.config;
41
40
 
42
- const ethAccount = EthAddress.fromString((await walletClient.getAddresses())[0]);
43
- const l1ContractAddresses = (await pxeService.getNodeInfo()).l1ContractAddresses;
41
+ const ethAccount = EthAddress.fromString((await l1Client.getAddresses())[0]);
42
+ const l1ContractAddresses = (await aztecNode.getNodeInfo()).l1ContractAddresses;
44
43
 
45
44
  const feeJuiceAddress = l1ContractAddresses.feeJuiceAddress;
46
45
  const feeJuicePortalAddress = l1ContractAddresses.feeJuicePortalAddress;
@@ -49,18 +48,19 @@ export class FeeJuicePortalTestingHarnessFactory {
49
48
  throw new Error('Fee Juice portal not deployed on L1');
50
49
  }
51
50
 
52
- const gasL2 = await FeeJuiceContract.at(ProtocolContractAddress.FeeJuice, wallet);
51
+ const gasL2 = FeeJuiceContract.at(ProtocolContractAddress.FeeJuice, wallet);
53
52
 
54
53
  return new GasBridgingTestHarness(
55
54
  aztecNode,
56
- pxeService,
55
+ aztecNodeAdmin,
56
+ wallet,
57
57
  logger,
58
58
  gasL2,
59
59
  ethAccount,
60
60
  feeJuicePortalAddress,
61
61
  feeJuiceAddress,
62
- publicClient,
63
- walletClient,
62
+ l1ContractAddresses.feeAssetHandlerAddress!,
63
+ l1Client,
64
64
  );
65
65
  }
66
66
 
@@ -80,9 +80,11 @@ export class GasBridgingTestHarness implements IGasBridgingTestHarness {
80
80
 
81
81
  constructor(
82
82
  /** Aztec node */
83
- public aztecNode: AztecNode,
84
- /** Private eXecution Environment (PXE). */
85
- public pxeService: PXE,
83
+ public aztecNode: MiningAztecNode,
84
+ /** Aztec node admin interface */
85
+ public aztecNodeAdmin: AztecNodeAdmin | undefined,
86
+ /** Wallet. */
87
+ public wallet: Wallet,
86
88
  /** Logger. */
87
89
  public logger: Logger,
88
90
 
@@ -96,44 +98,45 @@ export class GasBridgingTestHarness implements IGasBridgingTestHarness {
96
98
  public feeJuicePortalAddress: EthAddress,
97
99
  /** Underlying token for portal tests. */
98
100
  public l1FeeJuiceAddress: EthAddress,
99
- /** Viem Public client instance. */
100
- public publicClient: ViemPublicClient,
101
- /** Viem Wallet Client instance. */
102
- public walletClient: ViemWalletClient,
101
+ /** Fee asset handler address. */
102
+ public feeAssetHandlerAddress: EthAddress,
103
+ /** Viem Extended client instance. */
104
+ public l1Client: ExtendedViemWalletClient,
103
105
  ) {
104
106
  this.feeJuicePortalManager = new L1FeeJuicePortalManager(
105
107
  this.feeJuicePortalAddress,
106
108
  this.l1FeeJuiceAddress,
107
- this.publicClient,
108
- this.walletClient,
109
+ this.feeAssetHandlerAddress,
110
+ this.l1Client,
109
111
  this.logger,
110
112
  );
111
113
 
112
114
  this.l1TokenManager = this.feeJuicePortalManager.getTokenManager();
113
115
  }
114
116
 
115
- async mintTokensOnL1(amount: bigint, to: EthAddress = this.ethAccount) {
116
- const balanceBefore = await this.l1TokenManager.getL1TokenBalance(to.toString());
117
- await this.l1TokenManager.mint(amount, to.toString());
118
- expect(await this.l1TokenManager.getL1TokenBalance(to.toString())).toEqual(balanceBefore + amount);
117
+ async mintTokensOnL1(to: EthAddress = this.ethAccount) {
118
+ // const balanceBefore = await this.l1TokenManager.getL1TokenBalance(to.toString());
119
+ await this.l1TokenManager.mint(to.toString());
120
+
121
+ // expect(await this.l1TokenManager.getL1TokenBalance(to.toString())).toEqual(balanceBefore + amount);
119
122
  }
120
123
 
121
124
  async getL1FeeJuiceBalance(address: EthAddress) {
122
125
  return await this.l1TokenManager.getL1TokenBalance(address.toString());
123
126
  }
124
127
 
125
- sendTokensToPortalPublic(bridgeAmount: bigint, l2Address: AztecAddress, mint = false) {
126
- return this.feeJuicePortalManager.bridgeTokensPublic(l2Address, bridgeAmount, mint);
128
+ sendTokensToPortalPublic(bridgeAmount: bigint, l2Address: AztecAddress) {
129
+ return this.feeJuicePortalManager.bridgeTokensPublic(l2Address, bridgeAmount, false);
127
130
  }
128
131
 
129
- async consumeMessageOnAztecAndClaimPrivately(owner: AztecAddress, claim: L2AmountClaim) {
132
+ async consumeMessageOnAztecAndClaimPrivately(owner: AztecAddress, claimer: AztecAddress, claim: L2AmountClaim) {
130
133
  this.logger.info('Consuming messages on L2 Privately');
131
134
  const { claimAmount, claimSecret, messageLeafIndex } = claim;
132
- await this.feeJuice.methods.claim(owner, claimAmount, claimSecret, messageLeafIndex).send().wait();
135
+ await this.feeJuice.methods.claim(owner, claimAmount, claimSecret, messageLeafIndex).send({ from: claimer });
133
136
  }
134
137
 
135
138
  async getL2PublicBalanceOf(owner: AztecAddress) {
136
- return await this.feeJuice.methods.balance_of_public(owner).simulate();
139
+ return (await this.feeJuice.methods.balance_of_public(owner).simulate({ from: owner })).result;
137
140
  }
138
141
 
139
142
  async expectPublicBalanceOnL2(owner: AztecAddress, expectedBalance: bigint) {
@@ -141,11 +144,12 @@ export class GasBridgingTestHarness implements IGasBridgingTestHarness {
141
144
  expect(balance).toBe(expectedBalance);
142
145
  }
143
146
 
144
- async prepareTokensOnL1(bridgeAmount: bigint, owner: AztecAddress) {
145
- const claim = await this.sendTokensToPortalPublic(bridgeAmount, owner, true);
147
+ async prepareTokensOnL1(owner: AztecAddress) {
148
+ const bridgeAmount = await this.l1TokenManager.getMintAmount();
149
+ await this.mintTokensOnL1();
150
+ const claim = await this.sendTokensToPortalPublic(bridgeAmount, owner);
146
151
 
147
- const isSynced = async () => await this.aztecNode.isL1ToL2MessageSynced(Fr.fromHexString(claim.messageHash));
148
- await retryUntil(isSynced, `message ${claim.messageHash} sync`, 24, 1);
152
+ await waitForL1ToL2MessageSeen(this.aztecNode, Fr.fromHexString(claim.messageHash), { timeoutSeconds: 24 });
149
153
 
150
154
  // Progress by 2 L2 blocks so that the l1ToL2Message added above will be available to use on L2.
151
155
  await this.advanceL2Block();
@@ -154,19 +158,34 @@ export class GasBridgingTestHarness implements IGasBridgingTestHarness {
154
158
  return claim;
155
159
  }
156
160
 
157
- async bridgeFromL1ToL2(bridgeAmount: bigint, owner: AztecAddress) {
161
+ async bridgeFromL1ToL2(owner: AztecAddress, claimer: AztecAddress) {
158
162
  // Prepare the tokens on the L1 side
159
- const claim = await this.prepareTokensOnL1(bridgeAmount, owner);
163
+ const claim = await this.prepareTokensOnL1(owner);
160
164
 
161
165
  // Consume L1 -> L2 message and claim tokens privately on L2
162
- await this.consumeMessageOnAztecAndClaimPrivately(owner, claim);
163
- await this.expectPublicBalanceOnL2(owner, bridgeAmount);
166
+ await this.consumeMessageOnAztecAndClaimPrivately(owner, claimer, claim);
164
167
  }
165
168
 
166
169
  private async advanceL2Block() {
170
+ if (this.aztecNode.mineBlock) {
171
+ await this.aztecNode.mineBlock();
172
+ return;
173
+ }
174
+
167
175
  const initialBlockNumber = await this.aztecNode.getBlockNumber();
168
- await this.aztecNode.flushTxs();
169
- await retryUntil(async () => (await this.aztecNode.getBlockNumber()) >= initialBlockNumber + 1);
176
+
177
+ let minTxsPerBlock = undefined;
178
+ if (this.aztecNodeAdmin) {
179
+ ({ minTxsPerBlock } = await this.aztecNodeAdmin.getConfig());
180
+ await this.aztecNodeAdmin.setConfig({ minTxsPerBlock: 0 }); // Set to 0 to ensure we can advance the block
181
+ }
182
+
183
+ try {
184
+ await retryUntil(async () => (await this.aztecNode.getBlockNumber()) >= initialBlockNumber + 1);
185
+ } finally {
186
+ if (this.aztecNodeAdmin && minTxsPerBlock !== undefined) {
187
+ await this.aztecNodeAdmin.setConfig({ minTxsPerBlock });
188
+ }
189
+ }
170
190
  }
171
191
  }
172
- // docs:end:cross_chain_test_harness
@@ -1 +1,2 @@
1
- export { uniswapL1L2TestSuite, type UniswapSetupContext } from './uniswap_l1_l2.js';
1
+ export { uniswapL1L2TestSuite } from './uniswap_l1_l2.js';
2
+ export { MockStateView, diffInBps } from './mock_state_view.js';