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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (293) hide show
  1. package/dest/bench/client_flows/benchmark.d.ts +62 -0
  2. package/dest/bench/client_flows/benchmark.d.ts.map +1 -0
  3. package/dest/bench/client_flows/benchmark.js +281 -0
  4. package/dest/bench/client_flows/client_flows_benchmark.d.ts +79 -0
  5. package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -0
  6. package/dest/bench/client_flows/client_flows_benchmark.js +329 -0
  7. package/dest/bench/client_flows/config.d.ts +14 -0
  8. package/dest/bench/client_flows/config.d.ts.map +1 -0
  9. package/dest/bench/client_flows/config.js +124 -0
  10. package/dest/bench/client_flows/data_extractor.d.ts +2 -0
  11. package/dest/bench/client_flows/data_extractor.d.ts.map +1 -0
  12. package/dest/bench/client_flows/data_extractor.js +79 -0
  13. package/dest/bench/utils.d.ts +16 -41
  14. package/dest/bench/utils.d.ts.map +1 -1
  15. package/dest/bench/utils.js +44 -72
  16. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +28 -19
  17. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts.map +1 -1
  18. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.js +125 -103
  19. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +32 -32
  20. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts.map +1 -1
  21. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.js +105 -104
  22. package/dest/e2e_deploy_contract/deploy_test.d.ts +19 -10
  23. package/dest/e2e_deploy_contract/deploy_test.d.ts.map +1 -1
  24. package/dest/e2e_deploy_contract/deploy_test.js +26 -27
  25. package/dest/e2e_epochs/epochs_test.d.ts +75 -24
  26. package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
  27. package/dest/e2e_epochs/epochs_test.js +290 -58
  28. package/dest/e2e_fees/bridging_race.notest.d.ts +2 -0
  29. package/dest/e2e_fees/bridging_race.notest.d.ts.map +1 -0
  30. package/dest/e2e_fees/bridging_race.notest.js +61 -0
  31. package/dest/e2e_fees/fees_test.d.ts +38 -23
  32. package/dest/e2e_fees/fees_test.d.ts.map +1 -1
  33. package/dest/e2e_fees/fees_test.js +169 -183
  34. package/dest/e2e_l1_publisher/write_json.d.ts +11 -0
  35. package/dest/e2e_l1_publisher/write_json.d.ts.map +1 -0
  36. package/dest/e2e_l1_publisher/write_json.js +56 -0
  37. package/dest/e2e_multi_validator/utils.d.ts +12 -0
  38. package/dest/e2e_multi_validator/utils.d.ts.map +1 -0
  39. package/dest/e2e_multi_validator/utils.js +214 -0
  40. package/dest/e2e_nested_contract/nested_contract_test.d.ts +15 -15
  41. package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +1 -1
  42. package/dest/e2e_nested_contract/nested_contract_test.js +36 -42
  43. package/dest/e2e_p2p/inactivity_slash_test.d.ts +31 -0
  44. package/dest/e2e_p2p/inactivity_slash_test.d.ts.map +1 -0
  45. package/dest/e2e_p2p/inactivity_slash_test.js +136 -0
  46. package/dest/e2e_p2p/p2p_network.d.ts +282 -27
  47. package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
  48. package/dest/e2e_p2p/p2p_network.js +255 -176
  49. package/dest/e2e_p2p/reqresp/utils.d.ts +22 -0
  50. package/dest/e2e_p2p/reqresp/utils.d.ts.map +1 -0
  51. package/dest/e2e_p2p/reqresp/utils.js +190 -0
  52. package/dest/e2e_p2p/shared.d.ts +64 -8
  53. package/dest/e2e_p2p/shared.d.ts.map +1 -1
  54. package/dest/e2e_p2p/shared.js +200 -27
  55. package/dest/e2e_storage_proof/fixtures/storage_proof_fetcher.d.ts +2 -0
  56. package/dest/e2e_storage_proof/fixtures/storage_proof_fetcher.d.ts.map +1 -0
  57. package/dest/e2e_storage_proof/fixtures/storage_proof_fetcher.js +184 -0
  58. package/dest/e2e_storage_proof/fixtures/storage_proof_fixture.d.ts +18 -0
  59. package/dest/e2e_storage_proof/fixtures/storage_proof_fixture.d.ts.map +1 -0
  60. package/dest/e2e_storage_proof/fixtures/storage_proof_fixture.js +120 -0
  61. package/dest/e2e_token_contract/token_contract_test.d.ts +29 -14
  62. package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -1
  63. package/dest/e2e_token_contract/token_contract_test.js +107 -75
  64. package/dest/fixtures/authwit_proxy.d.ts +15 -0
  65. package/dest/fixtures/authwit_proxy.d.ts.map +1 -0
  66. package/dest/fixtures/authwit_proxy.js +30 -0
  67. package/dest/fixtures/e2e_prover_test.d.ts +55 -0
  68. package/dest/fixtures/e2e_prover_test.d.ts.map +1 -0
  69. package/dest/fixtures/e2e_prover_test.js +271 -0
  70. package/dest/fixtures/elu_monitor.d.ts +21 -0
  71. package/dest/fixtures/elu_monitor.d.ts.map +1 -0
  72. package/dest/fixtures/elu_monitor.js +102 -0
  73. package/dest/fixtures/fixtures.d.ts +10 -8
  74. package/dest/fixtures/fixtures.d.ts.map +1 -1
  75. package/dest/fixtures/fixtures.js +11 -5
  76. package/dest/fixtures/get_acvm_config.d.ts +2 -2
  77. package/dest/fixtures/get_acvm_config.d.ts.map +1 -1
  78. package/dest/fixtures/get_acvm_config.js +3 -15
  79. package/dest/fixtures/get_bb_config.d.ts +2 -2
  80. package/dest/fixtures/get_bb_config.d.ts.map +1 -1
  81. package/dest/fixtures/get_bb_config.js +10 -17
  82. package/dest/fixtures/ha_setup.d.ts +71 -0
  83. package/dest/fixtures/ha_setup.d.ts.map +1 -0
  84. package/dest/fixtures/ha_setup.js +116 -0
  85. package/dest/fixtures/index.d.ts +2 -1
  86. package/dest/fixtures/index.d.ts.map +1 -1
  87. package/dest/fixtures/index.js +1 -0
  88. package/dest/fixtures/l1_to_l2_messaging.d.ts +11 -7
  89. package/dest/fixtures/l1_to_l2_messaging.d.ts.map +1 -1
  90. package/dest/fixtures/l1_to_l2_messaging.js +45 -19
  91. package/dest/fixtures/logging.d.ts +1 -1
  92. package/dest/fixtures/setup.d.ts +239 -0
  93. package/dest/fixtures/setup.d.ts.map +1 -0
  94. package/dest/fixtures/setup.js +606 -0
  95. package/dest/fixtures/setup_p2p_test.d.ts +23 -15
  96. package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
  97. package/dest/fixtures/setup_p2p_test.js +102 -31
  98. package/dest/fixtures/token_utils.d.ts +10 -4
  99. package/dest/fixtures/token_utils.d.ts.map +1 -1
  100. package/dest/fixtures/token_utils.js +33 -13
  101. package/dest/fixtures/utils.d.ts +5 -153
  102. package/dest/fixtures/utils.d.ts.map +1 -1
  103. package/dest/fixtures/utils.js +4 -552
  104. package/dest/fixtures/web3signer.d.ts +5 -0
  105. package/dest/fixtures/web3signer.d.ts.map +1 -0
  106. package/dest/fixtures/web3signer.js +53 -0
  107. package/dest/fixtures/with_telemetry_utils.d.ts +2 -2
  108. package/dest/fixtures/with_telemetry_utils.d.ts.map +1 -1
  109. package/dest/fixtures/with_telemetry_utils.js +2 -2
  110. package/dest/index.d.ts +1 -1
  111. package/dest/quality_of_service/grafana_client.d.ts +41 -0
  112. package/dest/quality_of_service/grafana_client.d.ts.map +1 -0
  113. package/dest/quality_of_service/{alert_checker.js → grafana_client.js} +1 -1
  114. package/dest/quality_of_service/prometheus_client.d.ts +38 -0
  115. package/dest/quality_of_service/prometheus_client.d.ts.map +1 -0
  116. package/dest/quality_of_service/prometheus_client.js +67 -0
  117. package/dest/shared/cross_chain_test_harness.d.ts +44 -27
  118. package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
  119. package/dest/shared/cross_chain_test_harness.js +107 -53
  120. package/dest/shared/gas_portal_test_harness.d.ts +33 -25
  121. package/dest/shared/gas_portal_test_harness.d.ts.map +1 -1
  122. package/dest/shared/gas_portal_test_harness.js +51 -30
  123. package/dest/shared/index.d.ts +3 -2
  124. package/dest/shared/index.d.ts.map +1 -1
  125. package/dest/shared/index.js +1 -0
  126. package/dest/shared/jest_setup.d.ts +1 -1
  127. package/dest/shared/jest_setup.js +42 -2
  128. package/dest/shared/mock_state_view.d.ts +86 -0
  129. package/dest/shared/mock_state_view.d.ts.map +1 -0
  130. package/dest/shared/mock_state_view.js +186 -0
  131. package/dest/shared/submit-transactions.d.ts +6 -4
  132. package/dest/shared/submit-transactions.d.ts.map +1 -1
  133. package/dest/shared/submit-transactions.js +15 -16
  134. package/dest/shared/uniswap_l1_l2.d.ts +3 -25
  135. package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
  136. package/dest/shared/uniswap_l1_l2.js +175 -126
  137. package/dest/simulators/index.d.ts +1 -1
  138. package/dest/simulators/lending_simulator.d.ts +7 -7
  139. package/dest/simulators/lending_simulator.d.ts.map +1 -1
  140. package/dest/simulators/lending_simulator.js +17 -18
  141. package/dest/simulators/token_simulator.d.ts +6 -3
  142. package/dest/simulators/token_simulator.d.ts.map +1 -1
  143. package/dest/simulators/token_simulator.js +12 -30
  144. package/dest/spartan/setup_test_wallets.d.ts +36 -11
  145. package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
  146. package/dest/spartan/setup_test_wallets.js +276 -62
  147. package/dest/spartan/tx_metrics.d.ts +88 -0
  148. package/dest/spartan/tx_metrics.d.ts.map +1 -0
  149. package/dest/spartan/tx_metrics.js +422 -0
  150. package/dest/spartan/utils/bot.d.ts +28 -0
  151. package/dest/spartan/utils/bot.d.ts.map +1 -0
  152. package/dest/spartan/utils/bot.js +142 -0
  153. package/dest/spartan/utils/chaos.d.ts +79 -0
  154. package/dest/spartan/utils/chaos.d.ts.map +1 -0
  155. package/dest/spartan/utils/chaos.js +142 -0
  156. package/dest/spartan/utils/clients.d.ts +39 -0
  157. package/dest/spartan/utils/clients.d.ts.map +1 -0
  158. package/dest/spartan/utils/clients.js +90 -0
  159. package/dest/spartan/utils/config.d.ts +45 -0
  160. package/dest/spartan/utils/config.d.ts.map +1 -0
  161. package/dest/spartan/utils/config.js +23 -0
  162. package/dest/spartan/utils/health.d.ts +63 -0
  163. package/dest/spartan/utils/health.d.ts.map +1 -0
  164. package/dest/spartan/utils/health.js +202 -0
  165. package/dest/spartan/utils/helm.d.ts +15 -0
  166. package/dest/spartan/utils/helm.d.ts.map +1 -0
  167. package/dest/spartan/utils/helm.js +47 -0
  168. package/dest/spartan/utils/index.d.ts +11 -0
  169. package/dest/spartan/utils/index.d.ts.map +1 -0
  170. package/dest/spartan/utils/index.js +22 -0
  171. package/dest/spartan/utils/k8s.d.ts +128 -0
  172. package/dest/spartan/utils/k8s.d.ts.map +1 -0
  173. package/dest/spartan/utils/k8s.js +381 -0
  174. package/dest/spartan/utils/nodes.d.ts +40 -0
  175. package/dest/spartan/utils/nodes.d.ts.map +1 -0
  176. package/dest/spartan/utils/nodes.js +461 -0
  177. package/dest/spartan/utils/pod_logs.d.ts +25 -0
  178. package/dest/spartan/utils/pod_logs.d.ts.map +1 -0
  179. package/dest/spartan/utils/pod_logs.js +74 -0
  180. package/dest/spartan/utils/scripts.d.ts +30 -0
  181. package/dest/spartan/utils/scripts.d.ts.map +1 -0
  182. package/dest/spartan/utils/scripts.js +81 -0
  183. package/dest/spartan/utils.d.ts +2 -415
  184. package/dest/spartan/utils.d.ts.map +1 -1
  185. package/dest/spartan/utils.js +1 -445
  186. package/dest/test-wallet/test_wallet.d.ts +83 -0
  187. package/dest/test-wallet/test_wallet.d.ts.map +1 -0
  188. package/dest/test-wallet/test_wallet.js +214 -0
  189. package/dest/test-wallet/utils.d.ts +41 -0
  190. package/dest/test-wallet/utils.d.ts.map +1 -0
  191. package/dest/test-wallet/utils.js +71 -0
  192. package/dest/test-wallet/wallet_worker_script.d.ts +2 -0
  193. package/dest/test-wallet/wallet_worker_script.d.ts.map +1 -0
  194. package/dest/test-wallet/wallet_worker_script.js +48 -0
  195. package/dest/test-wallet/worker_wallet.d.ts +52 -0
  196. package/dest/test-wallet/worker_wallet.d.ts.map +1 -0
  197. package/dest/test-wallet/worker_wallet.js +151 -0
  198. package/dest/test-wallet/worker_wallet_schema.d.ts +274 -0
  199. package/dest/test-wallet/worker_wallet_schema.d.ts.map +1 -0
  200. package/dest/test-wallet/worker_wallet_schema.js +10 -0
  201. package/package.json +72 -62
  202. package/src/bench/client_flows/benchmark.ts +363 -0
  203. package/src/bench/client_flows/client_flows_benchmark.ts +388 -0
  204. package/src/bench/client_flows/config.ts +69 -0
  205. package/src/bench/client_flows/data_extractor.ts +89 -0
  206. package/src/bench/utils.ts +47 -86
  207. package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +149 -171
  208. package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +155 -182
  209. package/src/e2e_deploy_contract/deploy_test.ts +40 -48
  210. package/src/e2e_epochs/epochs_test.ts +364 -93
  211. package/src/e2e_fees/bridging_race.notest.ts +74 -0
  212. package/src/e2e_fees/fees_test.ts +213 -259
  213. package/src/e2e_l1_publisher/write_json.ts +77 -0
  214. package/src/e2e_multi_validator/utils.ts +258 -0
  215. package/src/e2e_nested_contract/nested_contract_test.ts +48 -59
  216. package/src/e2e_p2p/inactivity_slash_test.ts +179 -0
  217. package/src/e2e_p2p/p2p_network.ts +367 -234
  218. package/src/e2e_p2p/reqresp/utils.ts +256 -0
  219. package/src/e2e_p2p/shared.ts +315 -39
  220. package/src/e2e_storage_proof/fixtures/storage_proof.json +915 -0
  221. package/src/e2e_storage_proof/fixtures/storage_proof_fetcher.ts +190 -0
  222. package/src/e2e_storage_proof/fixtures/storage_proof_fixture.ts +173 -0
  223. package/src/e2e_token_contract/token_contract_test.ts +132 -126
  224. package/src/fixtures/authwit_proxy.ts +50 -0
  225. package/src/fixtures/dumps/epoch_proof_result.json +1 -1
  226. package/src/fixtures/e2e_prover_test.ts +332 -0
  227. package/src/fixtures/elu_monitor.ts +126 -0
  228. package/src/fixtures/fixtures.ts +15 -7
  229. package/src/fixtures/get_acvm_config.ts +4 -12
  230. package/src/fixtures/get_bb_config.ts +18 -13
  231. package/src/fixtures/ha_setup.ts +186 -0
  232. package/src/fixtures/index.ts +1 -0
  233. package/src/fixtures/l1_to_l2_messaging.ts +56 -24
  234. package/src/fixtures/setup.ts +903 -0
  235. package/src/fixtures/setup_p2p_test.ts +134 -50
  236. package/src/fixtures/token_utils.ts +37 -16
  237. package/src/fixtures/utils.ts +27 -820
  238. package/src/fixtures/web3signer.ts +63 -0
  239. package/src/fixtures/with_telemetry_utils.ts +2 -2
  240. package/src/guides/up_quick_start.sh +9 -17
  241. package/src/quality_of_service/{alert_checker.ts → grafana_client.ts} +2 -2
  242. package/src/quality_of_service/prometheus_client.ts +113 -0
  243. package/src/shared/cross_chain_test_harness.ts +110 -94
  244. package/src/shared/gas_portal_test_harness.ts +59 -50
  245. package/src/shared/index.ts +2 -1
  246. package/src/shared/jest_setup.ts +52 -2
  247. package/src/shared/mock_state_view.ts +188 -0
  248. package/src/shared/submit-transactions.ts +19 -20
  249. package/src/shared/uniswap_l1_l2.ts +207 -226
  250. package/src/simulators/lending_simulator.ts +18 -17
  251. package/src/simulators/token_simulator.ts +18 -34
  252. package/src/spartan/DEVELOP.md +128 -0
  253. package/src/spartan/setup_test_wallets.ts +393 -95
  254. package/src/spartan/tx_metrics.ts +376 -0
  255. package/src/spartan/utils/bot.ts +188 -0
  256. package/src/spartan/utils/chaos.ts +253 -0
  257. package/src/spartan/utils/clients.ts +100 -0
  258. package/src/spartan/utils/config.ts +29 -0
  259. package/src/spartan/utils/health.ts +255 -0
  260. package/src/spartan/utils/helm.ts +84 -0
  261. package/src/spartan/utils/index.ts +71 -0
  262. package/src/spartan/utils/k8s.ts +535 -0
  263. package/src/spartan/utils/nodes.ts +543 -0
  264. package/src/spartan/utils/pod_logs.ts +99 -0
  265. package/src/spartan/utils/scripts.ts +99 -0
  266. package/src/spartan/utils.ts +1 -582
  267. package/src/test-wallet/test_wallet.ts +306 -0
  268. package/src/test-wallet/utils.ts +112 -0
  269. package/src/test-wallet/wallet_worker_script.ts +60 -0
  270. package/src/test-wallet/worker_wallet.ts +213 -0
  271. package/src/test-wallet/worker_wallet_schema.ts +13 -0
  272. package/dest/e2e_prover/e2e_prover_test.d.ts +0 -56
  273. package/dest/e2e_prover/e2e_prover_test.d.ts.map +0 -1
  274. package/dest/e2e_prover/e2e_prover_test.js +0 -291
  275. package/dest/fixtures/setup_l1_contracts.d.ts +0 -6
  276. package/dest/fixtures/setup_l1_contracts.d.ts.map +0 -1
  277. package/dest/fixtures/setup_l1_contracts.js +0 -17
  278. package/dest/fixtures/snapshot_manager.d.ts +0 -87
  279. package/dest/fixtures/snapshot_manager.d.ts.map +0 -1
  280. package/dest/fixtures/snapshot_manager.js +0 -479
  281. package/dest/quality_of_service/alert_checker.d.ts +0 -41
  282. package/dest/quality_of_service/alert_checker.d.ts.map +0 -1
  283. package/dest/sample-dapp/connect.js +0 -12
  284. package/dest/sample-dapp/contracts.js +0 -10
  285. package/dest/sample-dapp/deploy.js +0 -35
  286. package/dest/sample-dapp/index.js +0 -98
  287. package/src/e2e_prover/e2e_prover_test.ts +0 -418
  288. package/src/fixtures/setup_l1_contracts.ts +0 -27
  289. package/src/fixtures/snapshot_manager.ts +0 -617
  290. package/src/sample-dapp/connect.mjs +0 -16
  291. package/src/sample-dapp/contracts.mjs +0 -14
  292. package/src/sample-dapp/deploy.mjs +0 -40
  293. package/src/sample-dapp/index.mjs +0 -128
@@ -1,71 +1,63 @@
1
- import { getSchnorrWallet } from '@aztec/accounts/schnorr';
2
- import {
3
- type AccountWallet,
4
- type AztecAddress,
5
- type AztecNode,
6
- ChainMonitor,
7
- CheatCodes,
8
- type Logger,
9
- type PXE,
10
- createLogger,
11
- sleep,
12
- } from '@aztec/aztec.js';
13
- import { FEE_FUNDING_FOR_TESTER_ACCOUNT } from '@aztec/constants';
14
- import { type DeployL1ContractsArgs, RollupContract, createL1Clients } from '@aztec/ethereum';
1
+ import type { AztecAddress } from '@aztec/aztec.js/addresses';
2
+ import { type Logger, createLogger } from '@aztec/aztec.js/log';
3
+ import type { AztecNode } from '@aztec/aztec.js/node';
4
+ import { CheatCodes, getTokenAllowedSetupFunctions } from '@aztec/aztec/testing';
5
+ import { createExtendedL1Client } from '@aztec/ethereum/client';
6
+ import { RollupContract } from '@aztec/ethereum/contracts';
7
+ import type { DeployAztecL1ContractsArgs } from '@aztec/ethereum/deploy-aztec-l1-contracts';
8
+ import { ChainMonitor } from '@aztec/ethereum/test';
9
+ import { BlockNumber } from '@aztec/foundation/branded-types';
15
10
  import { EthAddress } from '@aztec/foundation/eth-address';
16
- import { RollupAbi, TestERC20Abi } from '@aztec/l1-artifacts';
11
+ import { sleep } from '@aztec/foundation/sleep';
12
+ import { TestERC20Abi } from '@aztec/l1-artifacts';
17
13
  import { AppSubscriptionContract } from '@aztec/noir-contracts.js/AppSubscription';
18
- import { CounterContract } from '@aztec/noir-contracts.js/Counter';
19
14
  import { FPCContract } from '@aztec/noir-contracts.js/FPC';
20
15
  import { FeeJuiceContract } from '@aztec/noir-contracts.js/FeeJuice';
16
+ import { SponsoredFPCContract } from '@aztec/noir-contracts.js/SponsoredFPC';
21
17
  import { TokenContract as BananaCoin } from '@aztec/noir-contracts.js/Token';
18
+ import { CounterContract } from '@aztec/noir-test-contracts.js/Counter';
22
19
  import { ProtocolContractAddress } from '@aztec/protocol-contracts';
23
20
  import { getCanonicalFeeJuice } from '@aztec/protocol-contracts/fee-juice';
24
- import { computePartialAddress } from '@aztec/stdlib/contract';
25
21
  import { GasSettings } from '@aztec/stdlib/gas';
22
+ import type { AztecNodeAdmin } from '@aztec/stdlib/interfaces/client';
26
23
 
27
24
  import { getContract } from 'viem';
28
25
 
29
26
  import { MNEMONIC } from '../fixtures/fixtures.js';
30
27
  import {
31
- type ISnapshotManager,
32
- type SubsystemsContext,
33
- createSnapshotManager,
28
+ type EndToEndContext,
29
+ type SetupOptions,
34
30
  deployAccounts,
35
- } from '../fixtures/snapshot_manager.js';
31
+ publicDeployAccounts,
32
+ setup,
33
+ teardown,
34
+ } from '../fixtures/setup.js';
36
35
  import { mintTokensToPrivate } from '../fixtures/token_utils.js';
37
- import {
38
- type BalancesFn,
39
- type SetupOptions,
40
- ensureAccountsPubliclyDeployed,
41
- getBalancesFn,
42
- setupCanonicalFeeJuice,
43
- } from '../fixtures/utils.js';
36
+ import { type BalancesFn, getBalancesFn, setupSponsoredFPC } from '../fixtures/utils.js';
44
37
  import { FeeJuicePortalTestingHarnessFactory, type GasBridgingTestHarness } from '../shared/gas_portal_test_harness.js';
45
-
46
- const { E2E_DATA_PATH: dataPath } = process.env;
38
+ import { TestWallet } from '../test-wallet/test_wallet.js';
47
39
 
48
40
  /**
49
- * Test fixture for testing fees. Provides the following snapshots:
41
+ * Test fixture for testing fees. Provides the following setup steps:
50
42
  * InitialAccounts: Initializes 3 Schnorr account contracts.
51
43
  * PublicDeployAccounts: Deploys the accounts publicly.
52
44
  * DeployFeeJuice: Deploys the Fee Juice contract.
53
45
  * FPCSetup: Deploys BananaCoin and FPC contracts, and bridges gas from L1.
46
+ * SponsoredFPCSetup: Deploys Sponsored FPC contract, and bridges gas from L1.
54
47
  * FundAlice: Mints private and public bananas to Alice.
55
48
  * SetupSubscription: Deploys a counter contract and a subscription contract, and mints Fee Juice to the subscription contract.
56
49
  */
57
50
  export class FeesTest {
58
- private snapshotManager: ISnapshotManager;
59
- private wallets: AccountWallet[] = [];
51
+ private accounts: AztecAddress[] = [];
52
+ public context!: EndToEndContext;
60
53
 
61
54
  public logger: Logger;
62
- public pxe!: PXE;
63
55
  public aztecNode!: AztecNode;
56
+ public aztecNodeAdmin!: AztecNodeAdmin;
64
57
  public cheatCodes!: CheatCodes;
65
58
 
66
- public aliceWallet!: AccountWallet;
59
+ public wallet!: TestWallet;
67
60
  public aliceAddress!: AztecAddress;
68
- public bobWallet!: AccountWallet;
69
61
  public bobAddress!: AztecAddress;
70
62
  public sequencerAddress!: AztecAddress;
71
63
  public coinbase!: EthAddress;
@@ -74,14 +66,16 @@ export class FeesTest {
74
66
 
75
67
  public gasSettings!: GasSettings;
76
68
 
69
+ public rollupContract!: RollupContract;
70
+
77
71
  public feeJuiceContract!: FeeJuiceContract;
78
72
  public bananaCoin!: BananaCoin;
79
73
  public bananaFPC!: FPCContract;
74
+ public sponsoredFPC!: SponsoredFPCContract;
80
75
  public counterContract!: CounterContract;
81
76
  public subscriptionContract!: AppSubscriptionContract;
82
77
  public feeJuiceBridgeTestHarness!: GasBridgingTestHarness;
83
78
 
84
- public context!: SubsystemsContext;
85
79
  public chainMonitor!: ChainMonitor;
86
80
 
87
81
  public getCoinbaseBalance!: () => Promise<bigint>;
@@ -89,7 +83,7 @@ export class FeesTest {
89
83
  public getGasBalanceFn!: BalancesFn;
90
84
  public getBananaPublicBalanceFn!: BalancesFn;
91
85
  public getBananaPrivateBalanceFn!: BalancesFn;
92
- public getProverFee!: (blockNumber: number) => Promise<bigint>;
86
+ public getProverFee!: (blockNumber: BlockNumber) => Promise<bigint>;
93
87
 
94
88
  public readonly ALICE_INITIAL_BANANAS = BigInt(1e22);
95
89
  public readonly SUBSCRIPTION_AMOUNT = BigInt(1e19);
@@ -98,33 +92,40 @@ export class FeesTest {
98
92
  constructor(
99
93
  testName: string,
100
94
  private numberOfAccounts = 3,
101
- setupOptions: Partial<SetupOptions & DeployL1ContractsArgs> = {},
95
+ private setupOptions: Partial<SetupOptions & DeployAztecL1ContractsArgs> = {},
102
96
  ) {
103
97
  if (!numberOfAccounts) {
104
98
  throw new Error('There must be at least 1 initial account.');
105
99
  }
100
+ setupOptions.coinbase ??= EthAddress.random();
101
+ this.coinbase = setupOptions.coinbase!;
106
102
  this.logger = createLogger(`e2e:e2e_fees:${testName}`);
107
- this.snapshotManager = createSnapshotManager(
108
- `e2e_fees/${testName}-${numberOfAccounts}`,
109
- dataPath,
110
- { startProverNode: true, ...setupOptions },
111
- { ...setupOptions },
112
- );
113
103
  }
114
104
 
115
105
  async setup() {
116
- const context = await this.snapshotManager.setup();
117
- await context.aztecNode.setConfig({ feeRecipient: this.sequencerAddress, coinbase: this.coinbase });
118
-
119
- const rollupContract = RollupContract.getFromConfig(context.aztecNodeConfig);
120
- this.chainMonitor = new ChainMonitor(rollupContract, this.logger, 200).start();
106
+ this.logger.verbose('Setting up fresh context...');
107
+ // Token allowlist entries are test-only: FPC-based fee payment with custom tokens won't work on mainnet alpha.
108
+ const tokenAllowList = await getTokenAllowedSetupFunctions();
109
+ this.context = await setup(0, {
110
+ startProverNode: true,
111
+ ...this.setupOptions,
112
+ fundSponsoredFPC: true,
113
+ skipAccountDeployment: true,
114
+ l1ContractsArgs: { ...this.setupOptions },
115
+ txPublicSetupAllowListExtend: [...(this.setupOptions.txPublicSetupAllowListExtend ?? []), ...tokenAllowList],
116
+ });
117
+
118
+ this.rollupContract = RollupContract.getFromConfig(this.context.config);
119
+ this.chainMonitor = new ChainMonitor(this.rollupContract, this.context.dateProvider, this.logger, 200).start();
120
+
121
+ await this.applyBaseSetup();
121
122
 
122
123
  return this;
123
124
  }
124
125
 
125
126
  async teardown() {
126
- this.chainMonitor.stop();
127
- await this.snapshotManager.teardown();
127
+ await this.chainMonitor.stop();
128
+ await teardown(this.context);
128
129
  }
129
130
 
130
131
  setIsMarkingAsProven(b: boolean) {
@@ -138,240 +139,193 @@ export class FeesTest {
138
139
  }
139
140
  }
140
141
 
141
- async mintAndBridgeFeeJuice(address: AztecAddress, amount: bigint) {
142
- const claim = await this.feeJuiceBridgeTestHarness.prepareTokensOnL1(amount, address);
142
+ async getBlockRewards() {
143
+ const blockReward = await this.rollupContract.getCheckpointReward();
144
+ const rewardConfig = await this.rollupContract.getRewardConfig();
145
+
146
+ const balance = await this.feeJuiceBridgeTestHarness.getL1FeeJuiceBalance(rewardConfig.rewardDistributor);
147
+
148
+ const toDistribute = balance > blockReward ? blockReward : balance;
149
+ const sequencerBlockRewards = (toDistribute * BigInt(rewardConfig.sequencerBps)) / 10000n;
150
+ const proverBlockRewards = toDistribute - sequencerBlockRewards;
151
+
152
+ return { sequencerBlockRewards, proverBlockRewards };
153
+ }
154
+
155
+ async mintAndBridgeFeeJuice(minter: AztecAddress, recipient: AztecAddress) {
156
+ const claim = await this.feeJuiceBridgeTestHarness.prepareTokensOnL1(recipient);
143
157
  const { claimSecret: secret, messageLeafIndex: index } = claim;
144
- await this.feeJuiceContract.methods.claim(address, amount, secret, index).send().wait();
158
+ await this.feeJuiceContract.methods.claim(recipient, claim.claimAmount, secret, index).send({ from: minter });
145
159
  }
146
160
 
147
161
  /** Alice mints bananaCoin tokens privately to the target address and redeems them. */
148
162
  async mintPrivateBananas(amount: bigint, address: AztecAddress) {
149
- const balanceBefore = await this.bananaCoin.methods.balance_of_private(address).simulate();
163
+ const { result: balanceBefore } = await this.bananaCoin.methods
164
+ .balance_of_private(address)
165
+ .simulate({ from: address });
150
166
 
151
- await mintTokensToPrivate(this.bananaCoin, this.aliceWallet, address, amount);
167
+ await mintTokensToPrivate(this.bananaCoin, this.aliceAddress, address, amount);
152
168
 
153
- const balanceAfter = await this.bananaCoin.methods.balance_of_private(address).simulate();
169
+ const { result: balanceAfter } = await this.bananaCoin.methods
170
+ .balance_of_private(address)
171
+ .simulate({ from: address });
154
172
  expect(balanceAfter).toEqual(balanceBefore + amount);
155
173
  }
156
174
 
157
- public async applyBaseSnapshots() {
158
- await this.applyInitialAccountsSnapshot();
159
- await this.applyPublicDeployAccountsSnapshot();
160
- await this.applySetupFeeJuiceSnapshot();
161
- await this.applyDeployBananaTokenSnapshot();
175
+ public async applyBaseSetup() {
176
+ await this.applyInitialAccounts();
177
+ await this.applyPublicDeployAccounts();
178
+ await this.applySetupFeeJuice();
179
+ await this.applyDeployBananaToken();
162
180
  }
163
181
 
164
- async applyInitialAccountsSnapshot() {
165
- await this.snapshotManager.snapshot(
166
- 'initial_accounts',
167
- deployAccounts(this.numberOfAccounts, this.logger),
168
- async ({ deployedAccounts }, { pxe, aztecNode, aztecNodeConfig }) => {
169
- this.pxe = pxe;
170
- this.aztecNode = aztecNode;
171
- this.gasSettings = GasSettings.default({ maxFeesPerGas: (await this.aztecNode.getCurrentBaseFees()).mul(2) });
172
- this.cheatCodes = await CheatCodes.create(aztecNodeConfig.l1RpcUrls, pxe);
173
- this.wallets = await Promise.all(deployedAccounts.map(a => getSchnorrWallet(pxe, a.address, a.signingKey)));
174
- this.wallets.forEach((w, i) => this.logger.verbose(`Wallet ${i} address: ${w.getAddress()}`));
175
- [this.aliceWallet, this.bobWallet] = this.wallets.slice(0, 2);
176
- [this.aliceAddress, this.bobAddress, this.sequencerAddress] = this.wallets.map(w => w.getAddress());
177
-
178
- // We set Alice as the FPC admin to avoid the need for deployment of another account.
179
- this.fpcAdmin = this.aliceAddress;
180
-
181
- const canonicalFeeJuice = await getCanonicalFeeJuice();
182
- this.feeJuiceContract = await FeeJuiceContract.at(canonicalFeeJuice.address, this.aliceWallet);
183
- if (this.numberOfAccounts > 1) {
184
- const bobInstance = (await this.bobWallet.getContractMetadata(this.bobAddress)).contractInstance;
185
- await this.aliceWallet.registerAccount(deployedAccounts[1].secret, await computePartialAddress(bobInstance!));
186
- }
187
- this.coinbase = EthAddress.random();
188
-
189
- const { publicClient, walletClient } = createL1Clients(aztecNodeConfig.l1RpcUrls, MNEMONIC);
190
- this.feeJuiceBridgeTestHarness = await FeeJuicePortalTestingHarnessFactory.create({
191
- aztecNode: aztecNode,
192
- pxeService: pxe,
193
- publicClient: publicClient,
194
- walletClient: walletClient,
195
- wallet: this.aliceWallet,
196
- logger: this.logger,
197
- });
198
- },
199
- );
182
+ async applyInitialAccounts() {
183
+ this.logger.info('Applying initial accounts setup');
184
+
185
+ const { deployedAccounts } = await deployAccounts(
186
+ this.numberOfAccounts,
187
+ this.logger,
188
+ )({
189
+ wallet: this.context.wallet,
190
+ initialFundedAccounts: this.context.initialFundedAccounts,
191
+ });
192
+
193
+ this.wallet = this.context.wallet;
194
+ this.aztecNode = this.context.aztecNodeService;
195
+ this.aztecNodeAdmin = this.context.aztecNodeService;
196
+ this.gasSettings = GasSettings.default({ maxFeesPerGas: (await this.aztecNode.getCurrentMinFees()).mul(2) });
197
+ this.cheatCodes = this.context.cheatCodes;
198
+ this.accounts = deployedAccounts.map(a => a.address);
199
+ this.accounts.forEach((a, i) => this.logger.verbose(`Account ${i} address: ${a}`));
200
+ [this.aliceAddress, this.bobAddress, this.sequencerAddress] = this.accounts.slice(0, 3);
201
+
202
+ // We set Alice as the FPC admin to avoid the need for deployment of another account.
203
+ this.fpcAdmin = this.aliceAddress;
204
+
205
+ const canonicalFeeJuice = await getCanonicalFeeJuice();
206
+ this.feeJuiceContract = FeeJuiceContract.at(canonicalFeeJuice.address, this.wallet);
200
207
  }
201
208
 
202
- async applyPublicDeployAccountsSnapshot() {
203
- await this.snapshotManager.snapshot('public_deploy_accounts', () =>
204
- ensureAccountsPubliclyDeployed(this.aliceWallet, this.wallets),
205
- );
209
+ async applyPublicDeployAccounts() {
210
+ this.logger.info('Applying public deploy accounts setup');
211
+ await publicDeployAccounts(this.wallet, this.accounts);
206
212
  }
207
213
 
208
- async applySetupFeeJuiceSnapshot() {
209
- await this.snapshotManager.snapshot(
210
- 'setup_fee_juice',
211
- async context => {
212
- await setupCanonicalFeeJuice(context.pxe);
213
- },
214
- async (_data, context) => {
215
- this.context = context;
216
-
217
- this.feeJuiceContract = await FeeJuiceContract.at(ProtocolContractAddress.FeeJuice, this.aliceWallet);
218
-
219
- this.getGasBalanceFn = getBalancesFn('⛽', this.feeJuiceContract.methods.balance_of_public, this.logger);
220
-
221
- const { publicClient, walletClient } = createL1Clients(context.aztecNodeConfig.l1RpcUrls, MNEMONIC);
222
- this.feeJuiceBridgeTestHarness = await FeeJuicePortalTestingHarnessFactory.create({
223
- aztecNode: context.aztecNode,
224
- pxeService: context.pxe,
225
- publicClient: publicClient,
226
- walletClient: walletClient,
227
- wallet: this.aliceWallet,
228
- logger: this.logger,
229
- });
230
- },
231
- );
214
+ async applySetupFeeJuice() {
215
+ this.logger.info('Applying fee juice setup');
216
+
217
+ this.feeJuiceContract = FeeJuiceContract.at(ProtocolContractAddress.FeeJuice, this.wallet);
218
+
219
+ this.getGasBalanceFn = getBalancesFn('⛽', this.feeJuiceContract.methods.balance_of_public, this.logger);
220
+
221
+ this.feeJuiceBridgeTestHarness = await FeeJuicePortalTestingHarnessFactory.create({
222
+ aztecNode: this.context.aztecNodeService,
223
+ aztecNodeAdmin: this.context.aztecNodeService,
224
+ l1Client: this.context.deployL1ContractsValues.l1Client,
225
+ wallet: this.wallet,
226
+ logger: this.logger,
227
+ });
232
228
  }
233
229
 
234
- async applyDeployBananaTokenSnapshot() {
235
- await this.snapshotManager.snapshot(
236
- 'deploy_banana_token',
237
- async () => {
238
- const bananaCoin = await BananaCoin.deploy(this.aliceWallet, this.aliceAddress, 'BC', 'BC', 18n)
239
- .send()
240
- .deployed();
241
- this.logger.info(`BananaCoin deployed at ${bananaCoin.address}`);
242
- return { bananaCoinAddress: bananaCoin.address };
243
- },
244
- async ({ bananaCoinAddress }) => {
245
- this.bananaCoin = await BananaCoin.at(bananaCoinAddress, this.aliceWallet);
246
- },
230
+ async applyDeployBananaToken() {
231
+ this.logger.info('Applying deploy banana token setup');
232
+
233
+ const { contract: bananaCoin } = await BananaCoin.deploy(this.wallet, this.aliceAddress, 'BC', 'BC', 18n).send({
234
+ from: this.aliceAddress,
235
+ });
236
+ this.logger.info(`BananaCoin deployed at ${bananaCoin.address}`);
237
+
238
+ this.bananaCoin = bananaCoin;
239
+ this.getBananaPublicBalanceFn = getBalancesFn('🍌.public', this.bananaCoin.methods.balance_of_public, this.logger);
240
+ this.getBananaPrivateBalanceFn = getBalancesFn(
241
+ '🍌.private',
242
+ this.bananaCoin.methods.balance_of_private,
243
+ this.logger,
247
244
  );
248
245
  }
249
246
 
250
- public async applyFPCSetupSnapshot() {
251
- await this.snapshotManager.snapshot(
252
- 'fpc_setup',
253
- async context => {
254
- const feeJuiceContract = this.feeJuiceBridgeTestHarness.feeJuice;
255
- expect((await context.pxe.getContractMetadata(feeJuiceContract.address)).isContractPubliclyDeployed).toBe(true);
256
-
257
- const bananaCoin = this.bananaCoin;
258
- const bananaFPC = await FPCContract.deploy(this.aliceWallet, bananaCoin.address, this.fpcAdmin)
259
- .send()
260
- .deployed();
261
-
262
- this.logger.info(`BananaPay deployed at ${bananaFPC.address}`);
263
-
264
- await this.feeJuiceBridgeTestHarness.bridgeFromL1ToL2(FEE_FUNDING_FOR_TESTER_ACCOUNT, bananaFPC.address);
265
-
266
- return {
267
- bananaFPCAddress: bananaFPC.address,
268
- feeJuiceAddress: feeJuiceContract.address,
269
- l1FeeJuiceAddress: this.feeJuiceBridgeTestHarness.l1FeeJuiceAddress,
270
- rollupAddress: context.deployL1ContractsValues.l1ContractAddresses.rollupAddress,
271
- };
272
- },
273
- async (data, context) => {
274
- const bananaFPC = await FPCContract.at(data.bananaFPCAddress, this.aliceWallet);
275
- this.bananaFPC = bananaFPC;
276
-
277
- const logger = this.logger;
278
- this.getBananaPublicBalanceFn = getBalancesFn('🍌.public', this.bananaCoin.methods.balance_of_public, logger);
279
- this.getBananaPrivateBalanceFn = getBalancesFn(
280
- '🍌.private',
281
- this.bananaCoin.methods.balance_of_private,
282
- logger,
283
- );
284
-
285
- this.getCoinbaseBalance = async () => {
286
- const { walletClient } = createL1Clients(context.aztecNodeConfig.l1RpcUrls, MNEMONIC);
287
- const gasL1 = getContract({
288
- address: data.l1FeeJuiceAddress.toString(),
289
- abi: TestERC20Abi,
290
- client: walletClient,
291
- });
292
- return await gasL1.read.balanceOf([this.coinbase.toString()]);
293
- };
294
-
295
- this.getCoinbaseSequencerRewards = async () => {
296
- const { walletClient } = createL1Clients(context.aztecNodeConfig.l1RpcUrls, MNEMONIC);
297
- const rollup = getContract({
298
- address: data.rollupAddress.toString(),
299
- abi: RollupAbi,
300
- client: walletClient,
301
- });
302
-
303
- return await rollup.read.getSequencerRewards([this.coinbase.toString()]);
304
- };
305
-
306
- this.getProverFee = async (blockNumber: number) => {
307
- const { walletClient } = createL1Clients(context.aztecNodeConfig.l1RpcUrls, MNEMONIC);
308
- const rollup = getContract({
309
- address: data.rollupAddress.toString(),
310
- abi: RollupAbi,
311
- client: walletClient,
312
- });
313
-
314
- const provingCostPerMana = await rollup.read.getProvingCostPerManaInFeeAsset();
315
-
316
- const block = await this.pxe.getBlock(blockNumber);
317
- const mana = block!.header.totalManaUsed.toBigInt();
318
- return mana * provingCostPerMana;
319
- };
320
- },
321
- );
247
+ public async applyFPCSetup() {
248
+ this.logger.info('Applying FPC setup');
249
+
250
+ const feeJuiceContract = this.feeJuiceBridgeTestHarness.feeJuice;
251
+ expect((await this.wallet.getContractMetadata(feeJuiceContract.address)).isContractPublished).toBe(true);
252
+
253
+ const bananaCoin = this.bananaCoin;
254
+ const { contract: bananaFPC } = await FPCContract.deploy(this.wallet, bananaCoin.address, this.fpcAdmin).send({
255
+ from: this.aliceAddress,
256
+ });
257
+
258
+ this.logger.info(`BananaPay deployed at ${bananaFPC.address}`);
259
+
260
+ await this.feeJuiceBridgeTestHarness.bridgeFromL1ToL2(bananaFPC.address, this.aliceAddress);
261
+
262
+ this.bananaFPC = bananaFPC;
263
+
264
+ const l1FeeJuiceAddress = this.feeJuiceBridgeTestHarness.l1FeeJuiceAddress;
265
+
266
+ this.getCoinbaseBalance = async () => {
267
+ const l1Client = createExtendedL1Client(this.context.config.l1RpcUrls, MNEMONIC);
268
+ const gasL1 = getContract({
269
+ address: l1FeeJuiceAddress.toString(),
270
+ abi: TestERC20Abi,
271
+ client: l1Client,
272
+ });
273
+ return await gasL1.read.balanceOf([this.coinbase.toString()]);
274
+ };
275
+
276
+ this.getCoinbaseSequencerRewards = async () => {
277
+ return await this.rollupContract.getSequencerRewards(this.coinbase);
278
+ };
279
+
280
+ this.getProverFee = async (blockNumber: BlockNumber) => {
281
+ const block = await this.aztecNode.getBlock(blockNumber);
282
+
283
+ // @todo @lherskind As we deal with #13601
284
+ // Right now the value is from `FeeLib.sol`
285
+ const L1_GAS_PER_EPOCH_VERIFIED = 3600000n;
286
+
287
+ // We round up
288
+ const mulDiv = (a: bigint, b: bigint, c: bigint) => (a * b) / c + ((a * b) % c > 0n ? 1n : 0n);
289
+
290
+ const { baseFee } = await this.rollupContract.getL1FeesAt(block!.header.globalVariables.timestamp);
291
+ const proverCost =
292
+ mulDiv(
293
+ mulDiv(L1_GAS_PER_EPOCH_VERIFIED, baseFee, BigInt(await this.rollupContract.getEpochDuration())),
294
+ 1n,
295
+ await this.rollupContract.getManaTarget(),
296
+ ) + (await this.rollupContract.getProvingCostPerMana());
297
+
298
+ const price = await this.rollupContract.getEthPerFeeAsset();
299
+
300
+ const mana = block!.header.totalManaUsed.toBigInt();
301
+ return mulDiv(mana * proverCost, 10n ** 12n, price);
302
+ };
303
+ }
304
+
305
+ public async applySponsoredFPCSetup() {
306
+ this.logger.info('Applying sponsored FPC setup');
307
+
308
+ const feeJuiceContract = this.feeJuiceBridgeTestHarness.feeJuice;
309
+ expect((await this.wallet.getContractMetadata(feeJuiceContract.address)).isContractPublished).toBe(true);
310
+
311
+ const sponsoredFPCInstance = await setupSponsoredFPC(this.wallet);
312
+ this.logger.info(`SponsoredFPC at ${sponsoredFPCInstance.address}`);
313
+
314
+ this.sponsoredFPC = SponsoredFPCContract.at(sponsoredFPCInstance.address, this.wallet);
322
315
  }
323
316
 
324
317
  public async applyFundAliceWithBananas() {
325
- await this.snapshotManager.snapshot(
326
- 'fund_alice',
327
- async () => {
328
- await this.mintPrivateBananas(this.ALICE_INITIAL_BANANAS, this.aliceAddress);
329
- await this.bananaCoin.methods.mint_to_public(this.aliceAddress, this.ALICE_INITIAL_BANANAS).send().wait();
330
- },
331
- () => Promise.resolve(),
332
- );
318
+ this.logger.info('Applying fund Alice with bananas setup');
319
+
320
+ await this.mintPrivateBananas(this.ALICE_INITIAL_BANANAS, this.aliceAddress);
321
+ await this.bananaCoin.methods
322
+ .mint_to_public(this.aliceAddress, this.ALICE_INITIAL_BANANAS)
323
+ .send({ from: this.aliceAddress });
333
324
  }
334
325
 
335
326
  public async applyFundAliceWithPrivateBananas() {
336
- await this.snapshotManager.snapshot(
337
- 'fund_alice_with_private_bananas',
338
- async () => {
339
- await this.mintPrivateBananas(this.ALICE_INITIAL_BANANAS, this.aliceAddress);
340
- },
341
- () => Promise.resolve(),
342
- );
343
- }
327
+ this.logger.info('Applying fund Alice with private bananas setup');
344
328
 
345
- public async applySetupSubscription() {
346
- await this.snapshotManager.snapshot(
347
- 'setup_subscription',
348
- async () => {
349
- const counterContract = await CounterContract.deploy(this.bobWallet, 0, this.bobAddress).send().deployed();
350
-
351
- // Deploy subscription contract, that allows subscriptions for SUBSCRIPTION_AMOUNT of bananas
352
- const subscriptionContract = await AppSubscriptionContract.deploy(
353
- this.bobWallet,
354
- counterContract.address,
355
- this.bobAddress,
356
- this.bananaCoin.address,
357
- this.SUBSCRIPTION_AMOUNT,
358
- this.APP_SPONSORED_TX_GAS_LIMIT,
359
- )
360
- .send()
361
- .deployed();
362
-
363
- // Mint some Fee Juice to the subscription contract
364
- // Could also use bridgeFromL1ToL2 from the harness, but this is more direct
365
- await this.mintAndBridgeFeeJuice(subscriptionContract.address, FEE_FUNDING_FOR_TESTER_ACCOUNT);
366
- return {
367
- counterContractAddress: counterContract.address,
368
- subscriptionContractAddress: subscriptionContract.address,
369
- };
370
- },
371
- async ({ counterContractAddress, subscriptionContractAddress }) => {
372
- this.counterContract = await CounterContract.at(counterContractAddress, this.bobWallet);
373
- this.subscriptionContract = await AppSubscriptionContract.at(subscriptionContractAddress, this.bobWallet);
374
- },
375
- );
329
+ await this.mintPrivateBananas(this.ALICE_INITIAL_BANANAS, this.aliceAddress);
376
330
  }
377
331
  }
@@ -0,0 +1,77 @@
1
+ import { AztecAddress } from '@aztec/aztec.js/addresses';
2
+ import { Fr } from '@aztec/aztec.js/fields';
3
+ import { BatchedBlob, Blob, getEthBlobEvaluationInputs, getPrefixedEthBlobCommitments } from '@aztec/blob-lib';
4
+ import { EthAddress } from '@aztec/foundation/eth-address';
5
+ import { L2Block } from '@aztec/stdlib/block';
6
+ import { CheckpointHeader } from '@aztec/stdlib/rollup';
7
+
8
+ import { writeFile } from 'fs/promises';
9
+
10
+ const AZTEC_GENERATE_TEST_DATA = !!process.env.AZTEC_GENERATE_TEST_DATA;
11
+
12
+ /**
13
+ * Creates a json object that can be used to test the solidity contract.
14
+ * The json object must be put into
15
+ */
16
+ export async function writeJson(
17
+ fileName: string,
18
+ checkpointHeader: CheckpointHeader,
19
+ block: L2Block,
20
+ l1ToL2Content: Fr[],
21
+ blobs: Blob[],
22
+ batchedBlob: BatchedBlob,
23
+ recipientAddress: AztecAddress,
24
+ deployerAddress: `0x${string}`,
25
+ ): Promise<void> {
26
+ if (!AZTEC_GENERATE_TEST_DATA) {
27
+ return;
28
+ }
29
+ // Path relative to the package.json in the end-to-end folder
30
+ const path = `../../l1-contracts/test/fixtures/${fileName}.json`;
31
+
32
+ const asHex = (value: Fr | Buffer | EthAddress | AztecAddress, size = 64) => {
33
+ const buffer = Buffer.isBuffer(value) ? value : value.toBuffer();
34
+ return `0x${buffer.toString('hex').padStart(size, '0')}`;
35
+ };
36
+
37
+ const jsonObject = {
38
+ populate: {
39
+ l1ToL2Content: l1ToL2Content.map(value => asHex(value)),
40
+ recipient: asHex(recipientAddress.toField()),
41
+ sender: deployerAddress,
42
+ },
43
+ messages: {
44
+ l2ToL1Messages: block.body.txEffects.flatMap(txEffect => txEffect.l2ToL1Msgs).map(value => asHex(value)),
45
+ },
46
+ checkpoint: {
47
+ // The json formatting in forge is a bit brittle, so we convert Fr to a number in the few values below.
48
+ // This should not be a problem for testing as long as the values are not larger than u32.
49
+ archive: asHex(block.archive.root),
50
+ blobCommitments: getPrefixedEthBlobCommitments(blobs),
51
+ batchedBlobInputs: getEthBlobEvaluationInputs(batchedBlob),
52
+ checkpointNumber: block.number,
53
+ body: `0x${block.body.toBuffer().toString('hex')}`,
54
+ header: {
55
+ lastArchiveRoot: asHex(checkpointHeader.lastArchiveRoot),
56
+ blockHeadersHash: asHex(checkpointHeader.blockHeadersHash),
57
+ blobsHash: asHex(checkpointHeader.blobsHash),
58
+ inHash: asHex(checkpointHeader.inHash),
59
+ outHash: asHex(checkpointHeader.epochOutHash),
60
+ slotNumber: Number(checkpointHeader.slotNumber),
61
+ timestamp: Number(checkpointHeader.timestamp),
62
+ coinbase: asHex(checkpointHeader.coinbase, 40),
63
+ feeRecipient: asHex(checkpointHeader.feeRecipient),
64
+ gasFees: {
65
+ feePerDaGas: Number(checkpointHeader.gasFees.feePerDaGas),
66
+ feePerL2Gas: Number(checkpointHeader.gasFees.feePerL2Gas),
67
+ },
68
+ totalManaUsed: checkpointHeader.totalManaUsed.toNumber(),
69
+ },
70
+ headerHash: asHex(checkpointHeader.hash()),
71
+ numTxs: block.body.txEffects.length,
72
+ },
73
+ };
74
+
75
+ const output = JSON.stringify(jsonObject, null, 2);
76
+ await writeFile(path, output, 'utf8');
77
+ }