@aztec/end-to-end 0.0.1-commit.2ed92850 → 0.0.1-commit.3100065

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 (350) hide show
  1. package/README.md +229 -14
  2. package/dest/automine/automine_test_context.d.ts +85 -0
  3. package/dest/automine/automine_test_context.d.ts.map +1 -0
  4. package/dest/automine/automine_test_context.js +98 -0
  5. package/dest/automine/contracts/fixtures/storage_proof_fetcher.d.ts +2 -0
  6. package/dest/automine/contracts/fixtures/storage_proof_fetcher.d.ts.map +1 -0
  7. package/dest/automine/contracts/fixtures/storage_proof_fetcher.js +184 -0
  8. package/dest/automine/contracts/fixtures/storage_proof_fixture.d.ts +18 -0
  9. package/dest/automine/contracts/fixtures/storage_proof_fixture.d.ts.map +1 -0
  10. package/dest/automine/contracts/fixtures/storage_proof_fixture.js +120 -0
  11. package/dest/automine/delivery/interactive_handshake_responder.d.ts +48 -0
  12. package/dest/automine/delivery/interactive_handshake_responder.d.ts.map +1 -0
  13. package/dest/automine/delivery/interactive_handshake_responder.js +76 -0
  14. package/dest/automine/delivery/onchain_delivery_harness.d.ts +19 -0
  15. package/dest/automine/delivery/onchain_delivery_harness.d.ts.map +1 -0
  16. package/dest/automine/delivery/onchain_delivery_harness.js +141 -0
  17. package/dest/automine/token/blacklist_token_contract_test.d.ts +49 -0
  18. package/dest/automine/token/blacklist_token_contract_test.d.ts.map +1 -0
  19. package/dest/{e2e_blacklist_token_contract → automine/token}/blacklist_token_contract_test.js +45 -48
  20. package/dest/automine/token/token_contract_test.d.ts +40 -0
  21. package/dest/automine/token/token_contract_test.d.ts.map +1 -0
  22. package/dest/{e2e_token_contract → automine/token}/token_contract_test.js +43 -48
  23. package/dest/automine/token/token_test_helpers.d.ts +73 -0
  24. package/dest/automine/token/token_test_helpers.d.ts.map +1 -0
  25. package/dest/automine/token/token_test_helpers.js +97 -0
  26. package/dest/bench/client_flows/benchmark.d.ts +15 -1
  27. package/dest/bench/client_flows/benchmark.d.ts.map +1 -1
  28. package/dest/bench/client_flows/benchmark.js +19 -0
  29. package/dest/bench/client_flows/client_flows_benchmark.d.ts +6 -6
  30. package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -1
  31. package/dest/bench/client_flows/client_flows_benchmark.js +65 -56
  32. package/dest/bench/client_flows/config.d.ts +2 -2
  33. package/dest/bench/client_flows/config.d.ts.map +1 -1
  34. package/dest/bench/client_flows/config.js +18 -0
  35. package/dest/bench/utils.d.ts +3 -3
  36. package/dest/bench/utils.d.ts.map +1 -1
  37. package/dest/bench/utils.js +102 -8
  38. package/dest/composed/ha/ha_full_setup.d.ts +77 -0
  39. package/dest/composed/ha/ha_full_setup.d.ts.map +1 -0
  40. package/dest/composed/ha/ha_full_setup.js +383 -0
  41. package/dest/composed/web3signer/multi_validator_keystore_utils.d.ts +12 -0
  42. package/dest/composed/web3signer/multi_validator_keystore_utils.d.ts.map +1 -0
  43. package/dest/fixtures/authwit_proxy.d.ts +15 -0
  44. package/dest/fixtures/authwit_proxy.d.ts.map +1 -0
  45. package/dest/fixtures/authwit_proxy.js +34 -0
  46. package/dest/fixtures/e2e_prover_test.d.ts +18 -14
  47. package/dest/fixtures/e2e_prover_test.d.ts.map +1 -1
  48. package/dest/fixtures/e2e_prover_test.js +84 -75
  49. package/dest/fixtures/elu_monitor.d.ts +21 -0
  50. package/dest/fixtures/elu_monitor.d.ts.map +1 -0
  51. package/dest/fixtures/elu_monitor.js +102 -0
  52. package/dest/fixtures/fixtures.d.ts +82 -1
  53. package/dest/fixtures/fixtures.d.ts.map +1 -1
  54. package/dest/fixtures/fixtures.js +84 -0
  55. package/dest/fixtures/get_bb_config.d.ts +1 -1
  56. package/dest/fixtures/get_bb_config.d.ts.map +1 -1
  57. package/dest/fixtures/get_bb_config.js +5 -5
  58. package/dest/fixtures/ha_setup.d.ts +71 -0
  59. package/dest/fixtures/ha_setup.d.ts.map +1 -0
  60. package/dest/fixtures/ha_setup.js +119 -0
  61. package/dest/fixtures/index.d.ts +3 -1
  62. package/dest/fixtures/index.d.ts.map +1 -1
  63. package/dest/fixtures/index.js +2 -0
  64. package/dest/fixtures/schnorr_hardcoded_account_contract.d.ts +25 -0
  65. package/dest/fixtures/schnorr_hardcoded_account_contract.d.ts.map +1 -0
  66. package/dest/fixtures/schnorr_hardcoded_account_contract.js +37 -0
  67. package/dest/fixtures/setup.d.ts +120 -61
  68. package/dest/fixtures/setup.d.ts.map +1 -1
  69. package/dest/fixtures/setup.js +337 -327
  70. package/dest/fixtures/setup_p2p_test.d.ts +22 -11
  71. package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
  72. package/dest/fixtures/setup_p2p_test.js +46 -35
  73. package/dest/fixtures/standard_contracts_genesis.d.ts +16 -0
  74. package/dest/fixtures/standard_contracts_genesis.d.ts.map +1 -0
  75. package/dest/fixtures/standard_contracts_genesis.js +25 -0
  76. package/dest/fixtures/timing.d.ts +42 -0
  77. package/dest/fixtures/timing.d.ts.map +1 -0
  78. package/dest/fixtures/timing.js +72 -0
  79. package/dest/fixtures/token_utils.d.ts +22 -4
  80. package/dest/fixtures/token_utils.d.ts.map +1 -1
  81. package/dest/fixtures/token_utils.js +26 -8
  82. package/dest/fixtures/utils.d.ts +2 -2
  83. package/dest/fixtures/utils.d.ts.map +1 -1
  84. package/dest/fixtures/utils.js +1 -1
  85. package/dest/fixtures/wait_helpers.d.ts +135 -0
  86. package/dest/fixtures/wait_helpers.d.ts.map +1 -0
  87. package/dest/fixtures/wait_helpers.js +154 -0
  88. package/dest/forward-compatibility/wallet_rpc_client.d.ts +7 -0
  89. package/dest/forward-compatibility/wallet_rpc_client.d.ts.map +1 -0
  90. package/dest/forward-compatibility/wallet_rpc_client.js +15 -0
  91. package/dest/forward-compatibility/wallet_service.d.ts +3 -0
  92. package/dest/forward-compatibility/wallet_service.d.ts.map +1 -0
  93. package/dest/forward-compatibility/wallet_service.js +109 -0
  94. package/dest/install_legacy_contracts.d.cts +10 -0
  95. package/dest/install_legacy_contracts.d.cts.map +1 -0
  96. package/dest/legacy-jest-resolver.d.cts +3 -0
  97. package/dest/legacy-jest-resolver.d.cts.map +1 -0
  98. package/dest/multi-node/block-production/setup.d.ts +97 -0
  99. package/dest/multi-node/block-production/setup.d.ts.map +1 -0
  100. package/dest/multi-node/block-production/setup.js +158 -0
  101. package/dest/multi-node/governance/setup.d.ts +67 -0
  102. package/dest/multi-node/governance/setup.d.ts.map +1 -0
  103. package/dest/multi-node/governance/setup.js +126 -0
  104. package/dest/multi-node/multi_node_test_context.d.ts +212 -0
  105. package/dest/multi-node/multi_node_test_context.d.ts.map +1 -0
  106. package/dest/multi-node/multi_node_test_context.js +347 -0
  107. package/dest/multi-node/slashing/inactivity_setup.d.ts +27 -0
  108. package/dest/multi-node/slashing/inactivity_setup.d.ts.map +1 -0
  109. package/dest/multi-node/slashing/inactivity_setup.js +111 -0
  110. package/dest/multi-node/slashing/setup.d.ts +167 -0
  111. package/dest/multi-node/slashing/setup.d.ts.map +1 -0
  112. package/dest/multi-node/slashing/setup.js +275 -0
  113. package/dest/{e2e_p2p → p2p}/p2p_network.d.ts +22 -12
  114. package/dest/p2p/p2p_network.d.ts.map +1 -0
  115. package/dest/{e2e_p2p → p2p}/p2p_network.js +98 -37
  116. package/dest/p2p/reqresp/utils.d.ts +19 -0
  117. package/dest/p2p/reqresp/utils.d.ts.map +1 -0
  118. package/dest/p2p/reqresp/utils.js +193 -0
  119. package/dest/p2p/shared.d.ts +72 -0
  120. package/dest/p2p/shared.d.ts.map +1 -0
  121. package/dest/p2p/shared.js +212 -0
  122. package/dest/shared/cross_chain_test_harness.d.ts +6 -4
  123. package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
  124. package/dest/shared/cross_chain_test_harness.js +44 -32
  125. package/dest/shared/gas_portal_test_harness.d.ts +8 -5
  126. package/dest/shared/gas_portal_test_harness.d.ts.map +1 -1
  127. package/dest/shared/gas_portal_test_harness.js +26 -14
  128. package/dest/shared/index.d.ts +2 -1
  129. package/dest/shared/index.d.ts.map +1 -1
  130. package/dest/shared/index.js +1 -0
  131. package/dest/shared/jest_setup.js +41 -1
  132. package/dest/shared/mock_state_view.d.ts +86 -0
  133. package/dest/shared/mock_state_view.d.ts.map +1 -0
  134. package/dest/shared/mock_state_view.js +186 -0
  135. package/dest/shared/submit-transactions.d.ts +2 -2
  136. package/dest/shared/submit-transactions.d.ts.map +1 -1
  137. package/dest/shared/submit-transactions.js +12 -5
  138. package/dest/shared/timing_env.d.js +5 -0
  139. package/dest/shared/timing_env.js +365 -0
  140. package/dest/shared/uniswap_l1_l2.d.ts +1 -1
  141. package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
  142. package/dest/shared/uniswap_l1_l2.js +56 -44
  143. package/dest/shared/wait_for_l1_to_l2_message.d.ts +13 -0
  144. package/dest/shared/wait_for_l1_to_l2_message.d.ts.map +1 -0
  145. package/dest/shared/wait_for_l1_to_l2_message.js +10 -0
  146. package/dest/simulators/lending_simulator.d.ts +10 -3
  147. package/dest/simulators/lending_simulator.d.ts.map +1 -1
  148. package/dest/simulators/lending_simulator.js +27 -15
  149. package/dest/simulators/token_simulator.d.ts +1 -1
  150. package/dest/simulators/token_simulator.d.ts.map +1 -1
  151. package/dest/simulators/token_simulator.js +3 -24
  152. package/dest/single-node/cross-chain/cross_chain_messaging_test.d.ts +75 -0
  153. package/dest/single-node/cross-chain/cross_chain_messaging_test.d.ts.map +1 -0
  154. package/dest/single-node/cross-chain/cross_chain_messaging_test.js +209 -0
  155. package/dest/single-node/cross-chain/message_test_helpers.d.ts +38 -0
  156. package/dest/single-node/cross-chain/message_test_helpers.d.ts.map +1 -0
  157. package/dest/single-node/cross-chain/message_test_helpers.js +70 -0
  158. package/dest/{e2e_fees → single-node/fees}/bridging_race.notest.d.ts +1 -1
  159. package/dest/single-node/fees/bridging_race.notest.d.ts.map +1 -0
  160. package/dest/{e2e_fees → single-node/fees}/bridging_race.notest.js +17 -4
  161. package/dest/single-node/fees/fees_test.d.ts +95 -0
  162. package/dest/single-node/fees/fees_test.d.ts.map +1 -0
  163. package/dest/single-node/fees/fees_test.js +347 -0
  164. package/dest/single-node/l1-reorgs/setup.d.ts +42 -0
  165. package/dest/single-node/l1-reorgs/setup.d.ts.map +1 -0
  166. package/dest/single-node/l1-reorgs/setup.js +57 -0
  167. package/dest/single-node/partial-proofs/setup.d.ts +5 -0
  168. package/dest/single-node/partial-proofs/setup.d.ts.map +1 -0
  169. package/dest/single-node/partial-proofs/setup.js +5 -0
  170. package/dest/single-node/proving/setup.d.ts +5 -0
  171. package/dest/single-node/proving/setup.d.ts.map +1 -0
  172. package/dest/single-node/proving/setup.js +5 -0
  173. package/dest/single-node/recovery/setup.d.ts +5 -0
  174. package/dest/single-node/recovery/setup.d.ts.map +1 -0
  175. package/dest/single-node/recovery/setup.js +5 -0
  176. package/dest/single-node/setup.d.ts +49 -0
  177. package/dest/single-node/setup.d.ts.map +1 -0
  178. package/dest/single-node/setup.js +56 -0
  179. package/dest/single-node/single_node_test_context.d.ts +373 -0
  180. package/dest/single-node/single_node_test_context.d.ts.map +1 -0
  181. package/dest/single-node/single_node_test_context.js +845 -0
  182. package/dest/spartan/setup_test_wallets.d.ts +12 -3
  183. package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
  184. package/dest/spartan/setup_test_wallets.js +124 -47
  185. package/dest/spartan/tx_metrics.d.ts +61 -4
  186. package/dest/spartan/tx_metrics.d.ts.map +1 -1
  187. package/dest/spartan/tx_metrics.js +256 -21
  188. package/dest/spartan/utils/bot.d.ts +3 -2
  189. package/dest/spartan/utils/bot.d.ts.map +1 -1
  190. package/dest/spartan/utils/bot.js +2 -1
  191. package/dest/spartan/utils/config.d.ts +11 -28
  192. package/dest/spartan/utils/config.d.ts.map +1 -1
  193. package/dest/spartan/utils/config.js +4 -1
  194. package/dest/spartan/utils/index.d.ts +6 -4
  195. package/dest/spartan/utils/index.d.ts.map +1 -1
  196. package/dest/spartan/utils/index.js +6 -2
  197. package/dest/spartan/utils/k8s.d.ts +31 -1
  198. package/dest/spartan/utils/k8s.d.ts.map +1 -1
  199. package/dest/spartan/utils/k8s.js +124 -0
  200. package/dest/spartan/utils/nodes.d.ts +14 -5
  201. package/dest/spartan/utils/nodes.d.ts.map +1 -1
  202. package/dest/spartan/utils/nodes.js +204 -33
  203. package/dest/spartan/utils/pod_logs.d.ts +25 -0
  204. package/dest/spartan/utils/pod_logs.d.ts.map +1 -0
  205. package/dest/spartan/utils/pod_logs.js +74 -0
  206. package/dest/spartan/utils/scripts.d.ts +18 -4
  207. package/dest/spartan/utils/scripts.d.ts.map +1 -1
  208. package/dest/spartan/utils/scripts.js +19 -4
  209. package/dest/test-wallet/test_wallet.d.ts +105 -0
  210. package/dest/test-wallet/test_wallet.d.ts.map +1 -0
  211. package/dest/test-wallet/test_wallet.js +320 -0
  212. package/dest/test-wallet/utils.d.ts +76 -0
  213. package/dest/test-wallet/utils.d.ts.map +1 -0
  214. package/dest/test-wallet/utils.js +126 -0
  215. package/dest/test-wallet/wallet_worker_script.d.ts +2 -0
  216. package/dest/test-wallet/wallet_worker_script.d.ts.map +1 -0
  217. package/dest/test-wallet/wallet_worker_script.js +56 -0
  218. package/dest/test-wallet/worker_wallet.d.ts +53 -0
  219. package/dest/test-wallet/worker_wallet.d.ts.map +1 -0
  220. package/dest/test-wallet/worker_wallet.js +155 -0
  221. package/dest/test-wallet/worker_wallet_schema.d.ts +4 -0
  222. package/dest/test-wallet/worker_wallet_schema.d.ts.map +1 -0
  223. package/dest/test-wallet/worker_wallet_schema.js +23 -0
  224. package/package.json +53 -46
  225. package/src/automine/README.md +60 -0
  226. package/src/automine/automine_test_context.ts +153 -0
  227. package/src/automine/contracts/fixtures/storage_proof.json +915 -0
  228. package/src/automine/contracts/fixtures/storage_proof_fetcher.ts +190 -0
  229. package/src/automine/contracts/fixtures/storage_proof_fixture.ts +173 -0
  230. package/src/automine/delivery/interactive_handshake_responder.ts +125 -0
  231. package/src/automine/delivery/onchain_delivery_harness.ts +213 -0
  232. package/src/{e2e_blacklist_token_contract → automine/token}/blacklist_token_contract_test.ts +51 -61
  233. package/src/{e2e_token_contract → automine/token}/token_contract_test.ts +50 -56
  234. package/src/automine/token/token_test_helpers.ts +138 -0
  235. package/src/bench/client_flows/benchmark.ts +21 -0
  236. package/src/bench/client_flows/client_flows_benchmark.ts +106 -72
  237. package/src/bench/client_flows/config.ts +9 -1
  238. package/src/bench/utils.ts +117 -8
  239. package/src/composed/ha/ha_full_setup.ts +466 -0
  240. package/src/fixtures/authwit_proxy.ts +54 -0
  241. package/src/fixtures/dumps/epoch_proof_result.json +1 -1
  242. package/src/fixtures/e2e_prover_test.ts +102 -96
  243. package/src/fixtures/elu_monitor.ts +126 -0
  244. package/src/fixtures/fixtures.ts +108 -0
  245. package/src/fixtures/get_bb_config.ts +7 -6
  246. package/src/fixtures/ha_setup.ts +192 -0
  247. package/src/fixtures/index.ts +2 -0
  248. package/src/fixtures/schnorr_hardcoded_account_contract.ts +49 -0
  249. package/src/fixtures/setup.ts +438 -445
  250. package/src/fixtures/setup_p2p_test.ts +54 -54
  251. package/src/fixtures/standard_contracts_genesis.ts +28 -0
  252. package/src/fixtures/timing.ts +97 -0
  253. package/src/fixtures/token_utils.ts +42 -7
  254. package/src/fixtures/utils.ts +2 -3
  255. package/src/fixtures/wait_helpers.ts +333 -0
  256. package/src/forward-compatibility/wallet_rpc_client.ts +14 -0
  257. package/src/forward-compatibility/wallet_service.ts +106 -0
  258. package/src/guides/up_quick_start.sh +7 -4
  259. package/src/infra/README.md +12 -0
  260. package/src/install_legacy_contracts.cjs +75 -0
  261. package/src/legacy-jest-resolver.cjs +112 -0
  262. package/src/multi-node/README.md +96 -0
  263. package/src/multi-node/block-production/setup.ts +272 -0
  264. package/src/multi-node/governance/setup.ts +172 -0
  265. package/src/multi-node/multi_node_test_context.ts +447 -0
  266. package/src/multi-node/slashing/inactivity_setup.ts +139 -0
  267. package/src/multi-node/slashing/setup.ts +433 -0
  268. package/src/p2p/README.md +78 -0
  269. package/src/{e2e_p2p → p2p}/p2p_network.ts +124 -53
  270. package/src/p2p/reqresp/utils.ts +263 -0
  271. package/src/p2p/shared.ts +329 -0
  272. package/src/shared/cross_chain_test_harness.ts +44 -21
  273. package/src/shared/gas_portal_test_harness.ts +33 -15
  274. package/src/shared/index.ts +1 -0
  275. package/src/shared/jest_setup.ts +51 -1
  276. package/src/shared/mock_state_view.ts +188 -0
  277. package/src/shared/submit-transactions.ts +15 -6
  278. package/src/shared/timing_env.d.mts +39 -0
  279. package/src/shared/timing_env.mjs +363 -0
  280. package/src/shared/uniswap_l1_l2.ts +98 -56
  281. package/src/shared/wait_for_l1_to_l2_message.ts +23 -0
  282. package/src/simulators/lending_simulator.ts +33 -15
  283. package/src/simulators/token_simulator.ts +6 -30
  284. package/src/single-node/README.md +66 -0
  285. package/src/single-node/cross-chain/cross_chain_messaging_test.ts +302 -0
  286. package/src/single-node/cross-chain/message_test_helpers.ts +125 -0
  287. package/src/{e2e_fees → single-node/fees}/bridging_race.notest.ts +19 -5
  288. package/src/single-node/fees/fees_test.ts +437 -0
  289. package/src/single-node/l1-reorgs/setup.ts +93 -0
  290. package/src/single-node/partial-proofs/setup.ts +8 -0
  291. package/src/single-node/proving/setup.ts +15 -0
  292. package/src/single-node/recovery/setup.ts +8 -0
  293. package/src/single-node/setup.ts +63 -0
  294. package/src/single-node/single_node_test_context.ts +1054 -0
  295. package/src/spartan/setup_test_wallets.ts +168 -42
  296. package/src/spartan/tx_metrics.ts +234 -24
  297. package/src/spartan/utils/bot.ts +4 -1
  298. package/src/spartan/utils/config.ts +3 -0
  299. package/src/spartan/utils/index.ts +10 -1
  300. package/src/spartan/utils/k8s.ts +160 -0
  301. package/src/spartan/utils/nodes.ts +251 -31
  302. package/src/spartan/utils/pod_logs.ts +99 -0
  303. package/src/spartan/utils/scripts.ts +43 -7
  304. package/src/test-wallet/test_wallet.ts +426 -0
  305. package/src/test-wallet/utils.ts +205 -0
  306. package/src/test-wallet/wallet_worker_script.ts +66 -0
  307. package/src/test-wallet/worker_wallet.ts +214 -0
  308. package/src/test-wallet/worker_wallet_schema.ts +14 -0
  309. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +0 -53
  310. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts.map +0 -1
  311. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +0 -47
  312. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts.map +0 -1
  313. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.js +0 -128
  314. package/dest/e2e_deploy_contract/deploy_test.d.ts +0 -37
  315. package/dest/e2e_deploy_contract/deploy_test.d.ts.map +0 -1
  316. package/dest/e2e_deploy_contract/deploy_test.js +0 -50
  317. package/dest/e2e_epochs/epochs_test.d.ts +0 -94
  318. package/dest/e2e_epochs/epochs_test.d.ts.map +0 -1
  319. package/dest/e2e_epochs/epochs_test.js +0 -342
  320. package/dest/e2e_fees/bridging_race.notest.d.ts.map +0 -1
  321. package/dest/e2e_fees/fees_test.d.ts +0 -88
  322. package/dest/e2e_fees/fees_test.d.ts.map +0 -1
  323. package/dest/e2e_fees/fees_test.js +0 -248
  324. package/dest/e2e_l1_publisher/write_json.d.ts +0 -10
  325. package/dest/e2e_l1_publisher/write_json.d.ts.map +0 -1
  326. package/dest/e2e_l1_publisher/write_json.js +0 -62
  327. package/dest/e2e_multi_validator/utils.d.ts +0 -12
  328. package/dest/e2e_multi_validator/utils.d.ts.map +0 -1
  329. package/dest/e2e_nested_contract/nested_contract_test.d.ts +0 -26
  330. package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +0 -1
  331. package/dest/e2e_nested_contract/nested_contract_test.js +0 -56
  332. package/dest/e2e_p2p/inactivity_slash_test.d.ts +0 -31
  333. package/dest/e2e_p2p/inactivity_slash_test.d.ts.map +0 -1
  334. package/dest/e2e_p2p/inactivity_slash_test.js +0 -136
  335. package/dest/e2e_p2p/p2p_network.d.ts.map +0 -1
  336. package/dest/e2e_p2p/shared.d.ts +0 -46
  337. package/dest/e2e_p2p/shared.d.ts.map +0 -1
  338. package/dest/e2e_p2p/shared.js +0 -177
  339. package/dest/e2e_token_contract/token_contract_test.d.ts +0 -42
  340. package/dest/e2e_token_contract/token_contract_test.d.ts.map +0 -1
  341. package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +0 -194
  342. package/src/e2e_deploy_contract/deploy_test.ts +0 -85
  343. package/src/e2e_epochs/epochs_test.ts +0 -456
  344. package/src/e2e_fees/fees_test.ts +0 -339
  345. package/src/e2e_l1_publisher/write_json.ts +0 -82
  346. package/src/e2e_nested_contract/nested_contract_test.ts +0 -73
  347. package/src/e2e_p2p/inactivity_slash_test.ts +0 -179
  348. package/src/e2e_p2p/shared.ts +0 -280
  349. /package/dest/{e2e_multi_validator/utils.js → composed/web3signer/multi_validator_keystore_utils.js} +0 -0
  350. /package/src/{e2e_multi_validator/utils.ts → composed/web3signer/multi_validator_keystore_utils.ts} +0 -0
@@ -4,18 +4,22 @@ import type { Logger } from '@aztec/aztec.js/log';
4
4
  import { Fq } from '@aztec/foundation/curves/bn254';
5
5
  import { sleep } from '@aztec/foundation/sleep';
6
6
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
7
- import type { TestWallet } from '@aztec/test-wallet/server';
8
7
 
9
8
  import { jest } from '@jest/globals';
10
9
  import type { Hex } from 'viem';
11
10
 
11
+ import type { TestWallet } from '../../test-wallet/test_wallet.js';
12
12
  import { FeesTest } from './fees_test.js';
13
13
 
14
14
  jest.setTimeout(300_000);
15
15
 
16
16
  // Regression for https://github.com/AztecProtocol/aztec-packages/issues/12366
17
17
  // Similar to e2e_fees/account_init but with no automine
18
- describe('e2e_fees bridging_race', () => {
18
+ // Disabled (.notest.ts): this regression was covered by fixes applied at each "wait for two blocks"
19
+ // site in the codebase; keeping the file as reference for the original race scenario. Uses FeesTest
20
+ // with prod sequencer (ethSlot=4s, aztecSlot=8s, inboxLag default, minTxsPerBlock=0) and
21
+ // GasBridgingTestHarness for L1↔L2 fee-juice bridging. Single account, fake in-proc prover node.
22
+ describe('single-node/fees/bridging_race', () => {
19
23
  const ETHEREUM_SLOT_DURATION = 4;
20
24
  const AZTEC_SLOT_DURATION = ETHEREUM_SLOT_DURATION * 2;
21
25
 
@@ -50,6 +54,18 @@ describe('e2e_fees bridging_race', () => {
50
54
  bobsAddress = bobsAccountManager.address;
51
55
  });
52
56
 
57
+ // Sleeps until 500ms before the current L2 slot ends, so the subsequent bridge lands right at the slot
58
+ // boundary (this is what reproduces the "message not in state" race the test guards against).
59
+ const sleepUntilNearSlotEnd = async () => {
60
+ const sleepTime = (Number(t.monitor.checkpointTimestamp) + AZTEC_SLOT_DURATION) * 1000 - Date.now() - 500;
61
+ logger.info(`Sleeping for ${sleepTime}ms until near end of L2 slot before sending L1 fee juice to L2 inbox`);
62
+ await sleep(sleepTime);
63
+ };
64
+
65
+ // Reproduces a timing race where an L1→L2 fee-juice bridge message lands just before the end of an
66
+ // L2 slot, causing the archiver to miss it. The fix was to wait for the archiver to see the message
67
+ // before waiting for the required two-block confirmation. The sleep injected into approve() simulates
68
+ // the near-slot-boundary timing.
53
69
  it('Alice bridges funds to Bob', async () => {
54
70
  // Tweak the token manager so the bridging happens immediately before the end of the current L2 slot
55
71
  // This caused the message to be "not in state" when tried to be used
@@ -57,9 +73,7 @@ describe('e2e_fees bridging_race', () => {
57
73
  const origApprove = l1TokenManager.approve.bind(l1TokenManager);
58
74
  l1TokenManager.approve = async (amount: bigint, address: Hex, addressName = '') => {
59
75
  await origApprove(amount, address, addressName);
60
- const sleepTime = (Number(t.chainMonitor.checkpointTimestamp) + AZTEC_SLOT_DURATION) * 1000 - Date.now() - 500;
61
- logger.info(`Sleeping for ${sleepTime}ms until near end of L2 slot before sending L1 fee juice to L2 inbox`);
62
- await sleep(sleepTime);
76
+ await sleepUntilNearSlotEnd();
63
77
  };
64
78
 
65
79
  // Waiting for the archiver to sync the message _before_ waiting for the mandatory 2 L2 blocks to pass fixed it
@@ -0,0 +1,437 @@
1
+ import type { AztecAddress } from '@aztec/aztec.js/addresses';
2
+ import { BatchCall } from '@aztec/aztec.js/contracts';
3
+ import { Fr } from '@aztec/aztec.js/fields';
4
+ import { createLogger } from '@aztec/aztec.js/log';
5
+ import type { AztecNode } from '@aztec/aztec.js/node';
6
+ import { CheatCodes, getTokenAllowedSetupFunctions } from '@aztec/aztec/testing';
7
+ import { createExtendedL1Client } from '@aztec/ethereum/client';
8
+ import type { RollupContract } from '@aztec/ethereum/contracts';
9
+ import type { DeployAztecL1ContractsArgs } from '@aztec/ethereum/deploy-aztec-l1-contracts';
10
+ import { BlockNumber } from '@aztec/foundation/branded-types';
11
+ import { EthAddress } from '@aztec/foundation/eth-address';
12
+ import { sleep } from '@aztec/foundation/sleep';
13
+ import { TestERC20Abi } from '@aztec/l1-artifacts';
14
+ import { AppSubscriptionContract } from '@aztec/noir-contracts.js/AppSubscription';
15
+ import { FPCContract } from '@aztec/noir-contracts.js/FPC';
16
+ import { FeeJuiceContract } from '@aztec/noir-contracts.js/FeeJuice';
17
+ import { SponsoredFPCContract } from '@aztec/noir-contracts.js/SponsoredFPC';
18
+ import { TokenContract as BananaCoin } from '@aztec/noir-contracts.js/Token';
19
+ import { CounterContract } from '@aztec/noir-test-contracts.js/Counter';
20
+ import { ProtocolContractAddress } from '@aztec/protocol-contracts';
21
+ import { getCanonicalFeeJuice } from '@aztec/protocol-contracts/fee-juice';
22
+ import { getContractInstanceFromInstantiationParams } from '@aztec/stdlib/contract';
23
+ import { Gas, GasSettings } from '@aztec/stdlib/gas';
24
+ import type { AztecNodeAdmin } from '@aztec/stdlib/interfaces/client';
25
+
26
+ import { getContract } from 'viem';
27
+
28
+ import { L1_DIRECT_WRITE_ACCOUNT_INDEX, MNEMONIC, getPaddedMaxFeesPerGas } from '../../fixtures/fixtures.js';
29
+ import { type SetupOptions, ensureAuthRegistryPublished, setup } from '../../fixtures/setup.js';
30
+ import { testSpan } from '../../fixtures/timing.js';
31
+ import { mintTokensToPrivate } from '../../fixtures/token_utils.js';
32
+ import { type BalancesFn, getBalancesFn, setupSponsoredFPC } from '../../fixtures/utils.js';
33
+ import {
34
+ FeeJuicePortalTestingHarnessFactory,
35
+ type GasBridgingTestHarness,
36
+ } from '../../shared/gas_portal_test_harness.js';
37
+ import { TestWallet } from '../../test-wallet/test_wallet.js';
38
+ import { SingleNodeTestContext, type SingleNodeTestOpts } from '../single_node_test_context.js';
39
+
40
+ // Fixed deploy salts so BananaCoin and its BananaFPC land at deterministic addresses given the FPC
41
+ // admin. This lets the BananaFPC's fee-juice balance be seeded at genesis (see `FeesTest.setup`)
42
+ // instead of bridged from L1 during setup — the address must be known before genesis is computed.
43
+ const BANANA_COIN_SALT = new Fr(0xba4a4a);
44
+ const BANANA_FPC_SALT = new Fr(0xfacade);
45
+
46
+ const BANANA_COIN_CONSTRUCTOR_ARGS = ['BC', 'BC', 18n] as const;
47
+
48
+ /**
49
+ * Computes the deterministic BananaCoin and BananaFPC instances for the given admin/deployer, matching
50
+ * what {@link FeesTest.applyDeployBananaToken} and {@link FeesTest.applyFPCSetup} deploy with the fixed
51
+ * salts above. Used both to seed the BananaFPC's fee juice at genesis and to assert the deployed
52
+ * addresses match the seeded one.
53
+ */
54
+ async function computeBananaContractAddresses(admin: AztecAddress) {
55
+ const bananaCoin = await getContractInstanceFromInstantiationParams(BananaCoin.artifact, {
56
+ salt: BANANA_COIN_SALT,
57
+ constructorArgs: [admin, ...BANANA_COIN_CONSTRUCTOR_ARGS],
58
+ deployer: admin,
59
+ });
60
+ const bananaFPC = await getContractInstanceFromInstantiationParams(FPCContract.artifact, {
61
+ salt: BANANA_FPC_SALT,
62
+ constructorArgs: [bananaCoin.address, admin],
63
+ deployer: admin,
64
+ });
65
+ return { bananaCoinAddress: bananaCoin.address, bananaFPCAddress: bananaFPC.address };
66
+ }
67
+
68
+ /**
69
+ * Test fixture for testing fees. Provides the following setup steps:
70
+ * InitialAccounts: Initializes 3 Schnorr account contracts.
71
+ * PublicDeployAccounts: Deploys the accounts publicly.
72
+ * DeployFeeJuice: Deploys the Fee Juice contract.
73
+ * FPCSetup: Deploys BananaCoin and FPC contracts; the FPC's fee juice is seeded at genesis.
74
+ * SponsoredFPCSetup: Registers the Sponsored FPC contract, whose fee juice is seeded at genesis.
75
+ * FundAlice: Mints private and public bananas to Alice.
76
+ * SetupSubscription: Deploys a counter contract and a subscription contract, and mints Fee Juice to the subscription contract.
77
+ *
78
+ * The fee-domain harness over the single-node topology: extends {@link SingleNodeTestContext} so it
79
+ * reuses the base node tracking / chain monitor / teardown machinery, but builds its environment with
80
+ * the bespoke fee opts below (prover node, sponsored-FPC funding, token allowlist) rather than the
81
+ * base's default node config, and layers the fee-domain setup (FPC, fee juice, banana token) on top.
82
+ */
83
+ export class FeesTest extends SingleNodeTestContext {
84
+ private accounts: AztecAddress[] = [];
85
+
86
+ public aztecNode!: AztecNode;
87
+ public aztecNodeAdmin!: AztecNodeAdmin;
88
+ public cheatCodes!: CheatCodes;
89
+
90
+ public wallet!: TestWallet;
91
+ public aliceAddress!: AztecAddress;
92
+ public bobAddress!: AztecAddress;
93
+ public sequencerAddress!: AztecAddress;
94
+ public coinbase!: EthAddress;
95
+
96
+ public fpcAdmin!: AztecAddress;
97
+
98
+ public gasSettings!: GasSettings;
99
+
100
+ /** The base's {@link SingleNodeTestContext.rollup}, exposed under the fee suite's historical name. */
101
+ public rollupContract!: RollupContract;
102
+
103
+ public feeJuiceContract!: FeeJuiceContract;
104
+ public bananaCoin!: BananaCoin;
105
+ public bananaFPC!: FPCContract;
106
+ public sponsoredFPC!: SponsoredFPCContract;
107
+ public counterContract!: CounterContract;
108
+ public subscriptionContract!: AppSubscriptionContract;
109
+ public feeJuiceBridgeTestHarness!: GasBridgingTestHarness;
110
+
111
+ public getCoinbaseBalance!: () => Promise<bigint>;
112
+ public getCoinbaseSequencerRewards!: () => Promise<bigint>;
113
+ public getGasBalanceFn!: BalancesFn;
114
+ public getBananaPublicBalanceFn!: BalancesFn;
115
+ public getBananaPrivateBalanceFn!: BalancesFn;
116
+ public getProverFee!: (blockNumber: BlockNumber) => Promise<bigint>;
117
+ public getCommittedProverFee!: (blockNumber: BlockNumber) => Promise<bigint>;
118
+ public getCommittedBurn!: (blockNumber: BlockNumber) => Promise<bigint>;
119
+
120
+ public readonly ALICE_INITIAL_BANANAS = BigInt(1e22);
121
+ public readonly SUBSCRIPTION_AMOUNT = BigInt(1e19);
122
+ public readonly APP_SPONSORED_TX_GAS_LIMIT = BigInt(10e9);
123
+
124
+ private testName: string;
125
+
126
+ constructor(
127
+ testName: string,
128
+ private numberOfAccounts = 3,
129
+ private setupOptions: Partial<SetupOptions & DeployAztecL1ContractsArgs> = {},
130
+ ) {
131
+ super();
132
+ if (!numberOfAccounts) {
133
+ throw new Error('There must be at least 1 initial account.');
134
+ }
135
+ setupOptions.coinbase ??= EthAddress.random();
136
+ this.coinbase = setupOptions.coinbase!;
137
+ this.testName = testName;
138
+ this.logger = createLogger(`e2e:e2e_fees:${testName}`);
139
+ }
140
+
141
+ override async setup(opts: SingleNodeTestOpts = {}) {
142
+ this.logger.verbose('Setting up fresh context...');
143
+ // Token allowlist entries are test-only: FPC-based fee payment with custom tokens won't work on mainnet alpha.
144
+ const tokenAllowList = await getTokenAllowedSetupFunctions();
145
+ const context = await setup(this.numberOfAccounts, {
146
+ startProverNode: true,
147
+ ...this.setupOptions,
148
+ ...opts,
149
+ fundSponsoredFPC: true,
150
+ // Seed the BananaFPC's fee juice at genesis instead of bridging it from L1 in applyFPCSetup. The
151
+ // FPC admin is the first account, so its address is deterministic once the accounts are generated.
152
+ computeExtraGenesisFundedAddresses: async defaultAccounts => [
153
+ (await computeBananaContractAddresses(defaultAccounts[0].address)).bananaFPCAddress,
154
+ ],
155
+ l1ContractsArgs: { ...this.setupOptions },
156
+ txPublicSetupAllowListExtend: [...(this.setupOptions.txPublicSetupAllowListExtend ?? []), ...tokenAllowList],
157
+ });
158
+
159
+ // Reuse the base context machinery (rollup, epoch cache, chain monitor, node tracking, teardown)
160
+ // over the environment built above. Restore the FeesTest-named logger afterwards, since
161
+ // hydrateFromContext repoints `this.logger` at the context logger.
162
+ await this.hydrateFromContext(context);
163
+ this.logger = createLogger(`e2e:e2e_fees:${this.testName}`);
164
+ this.rollupContract = this.rollup;
165
+
166
+ await this.applyBaseSetup();
167
+ }
168
+
169
+ async catchUpProvenChain() {
170
+ await testSpan('wait:proven-checkpoint', async () => {
171
+ const bn = await this.aztecNode.getBlockNumber();
172
+ while ((await this.aztecNode.getBlockNumber('proven')) < bn) {
173
+ await sleep(1000);
174
+ }
175
+ });
176
+ }
177
+
178
+ /** Warps L1 to the next epoch boundary so the current epoch closes and can be proven. */
179
+ async advanceToNextEpoch() {
180
+ await testSpan('warp:proven-checkpoint-epoch', () => this.cheatCodes.rollup.advanceToNextEpoch());
181
+ }
182
+
183
+ /** Advances to the next epoch and waits for the proven chain to catch up, so all prior fees are paid out. */
184
+ async waitForEpochProven() {
185
+ await this.advanceToNextEpoch();
186
+ await this.catchUpProvenChain();
187
+ }
188
+
189
+ async getBlockRewards() {
190
+ const blockReward = await this.rollupContract.getCheckpointReward();
191
+ const rewardConfig = await this.rollupContract.getRewardConfig();
192
+
193
+ const balance = await this.feeJuiceBridgeTestHarness.getL1FeeJuiceBalance(rewardConfig.rewardDistributor);
194
+
195
+ const toDistribute = balance > blockReward ? blockReward : balance;
196
+ const sequencerBlockRewards = (toDistribute * BigInt(rewardConfig.sequencerBps)) / 10000n;
197
+ const proverBlockRewards = toDistribute - sequencerBlockRewards;
198
+
199
+ return { sequencerBlockRewards, proverBlockRewards };
200
+ }
201
+
202
+ async mintAndBridgeFeeJuice(minter: AztecAddress, recipient: AztecAddress) {
203
+ const claim = await this.feeJuiceBridgeTestHarness.prepareTokensOnL1(recipient);
204
+ const { claimSecret: secret, messageLeafIndex: index } = claim;
205
+ await testSpan('setup:bridge', () =>
206
+ this.feeJuiceContract.methods.claim(recipient, claim.claimAmount, secret, index).send({ from: minter }),
207
+ );
208
+ }
209
+
210
+ /** Alice mints bananaCoin tokens privately to the target address and redeems them. */
211
+ async mintPrivateBananas(amount: bigint, address: AztecAddress) {
212
+ const { result: balanceBefore } = await this.bananaCoin.methods
213
+ .balance_of_private(address)
214
+ .simulate({ from: address });
215
+
216
+ await testSpan('tx:mint', () => mintTokensToPrivate(this.bananaCoin, this.aliceAddress, address, amount));
217
+
218
+ const { result: balanceAfter } = await this.bananaCoin.methods
219
+ .balance_of_private(address)
220
+ .simulate({ from: address });
221
+ expect(balanceAfter).toEqual(balanceBefore + amount);
222
+ }
223
+
224
+ public async applyBaseSetup() {
225
+ await this.applyInitialAccounts();
226
+ await this.applyEnsureAuthRegistryPublished();
227
+ await this.applySetupFeeJuice();
228
+ await this.applyDeployBananaToken();
229
+ }
230
+
231
+ async applyEnsureAuthRegistryPublished() {
232
+ this.logger.info('Ensuring AuthRegistry published');
233
+ await ensureAuthRegistryPublished(this.wallet, this.aliceAddress);
234
+ }
235
+
236
+ async applyInitialAccounts() {
237
+ this.logger.info('Applying initial accounts setup');
238
+
239
+ this.wallet = this.context.wallet;
240
+ this.aztecNode = this.context.aztecNodeService;
241
+ this.aztecNodeAdmin = this.context.aztecNodeService;
242
+ this.gasSettings = GasSettings.fallback({
243
+ gasLimits: Gas.from((await this.aztecNode.getNodeInfo()).txsLimits.gas),
244
+ maxFeesPerGas: await getPaddedMaxFeesPerGas(this.aztecNode),
245
+ });
246
+ this.cheatCodes = this.context.cheatCodes;
247
+ this.accounts = this.context.accounts;
248
+ this.accounts.forEach((a, i) => this.logger.verbose(`Account ${i} address: ${a}`));
249
+ [this.aliceAddress, this.bobAddress, this.sequencerAddress] = this.accounts.slice(0, 3);
250
+
251
+ // We set Alice as the FPC admin to avoid the need for deployment of another account.
252
+ this.fpcAdmin = this.aliceAddress;
253
+
254
+ const canonicalFeeJuice = await getCanonicalFeeJuice();
255
+ this.feeJuiceContract = FeeJuiceContract.at(canonicalFeeJuice.address, this.wallet);
256
+ }
257
+
258
+ async applySetupFeeJuice() {
259
+ this.logger.info('Applying fee juice setup');
260
+
261
+ this.feeJuiceContract = FeeJuiceContract.at(ProtocolContractAddress.FeeJuice, this.wallet);
262
+
263
+ this.getGasBalanceFn = getBalancesFn('⛽', this.feeJuiceContract.methods.balance_of_public, this.logger);
264
+
265
+ this.feeJuiceBridgeTestHarness = await FeeJuicePortalTestingHarnessFactory.create({
266
+ aztecNode: this.context.aztecNodeService,
267
+ aztecNodeAdmin: this.context.aztecNodeService,
268
+ // Bridge from a dedicated L1 account so its direct writes don't race the sequencer publisher's
269
+ // txs on the deployer account (see L1_DIRECT_WRITE_ACCOUNT_INDEX).
270
+ l1Client: createExtendedL1Client(
271
+ this.context.config.l1RpcUrls,
272
+ MNEMONIC,
273
+ undefined,
274
+ undefined,
275
+ L1_DIRECT_WRITE_ACCOUNT_INDEX,
276
+ ),
277
+ wallet: this.wallet,
278
+ logger: this.logger,
279
+ });
280
+ }
281
+
282
+ async applyDeployBananaToken() {
283
+ this.logger.info('Applying deploy banana token setup');
284
+
285
+ const { contract: bananaCoin } = await testSpan('deploy:token', () =>
286
+ BananaCoin.deploy(this.wallet, this.aliceAddress, ...BANANA_COIN_CONSTRUCTOR_ARGS, {
287
+ salt: BANANA_COIN_SALT,
288
+ deployer: this.aliceAddress,
289
+ }).send({
290
+ from: this.aliceAddress,
291
+ }),
292
+ );
293
+ this.logger.info(`BananaCoin deployed at ${bananaCoin.address}`);
294
+
295
+ this.bananaCoin = bananaCoin;
296
+ this.getBananaPublicBalanceFn = getBalancesFn('🍌.public', this.bananaCoin.methods.balance_of_public, this.logger);
297
+ this.getBananaPrivateBalanceFn = getBalancesFn(
298
+ '🍌.private',
299
+ this.bananaCoin.methods.balance_of_private,
300
+ this.logger,
301
+ );
302
+ }
303
+
304
+ public async applyFPCSetup() {
305
+ this.logger.info('Applying FPC setup');
306
+
307
+ const feeJuiceContract = this.feeJuiceBridgeTestHarness.feeJuice;
308
+ expect((await this.wallet.getContractMetadata(feeJuiceContract.address)).isContractPublished).toBe(true);
309
+
310
+ const bananaCoin = this.bananaCoin;
311
+ const { contract: bananaFPC } = await testSpan('deploy:fpc', () =>
312
+ FPCContract.deploy(this.wallet, bananaCoin.address, this.fpcAdmin, {
313
+ salt: BANANA_FPC_SALT,
314
+ deployer: this.aliceAddress,
315
+ }).send({
316
+ from: this.aliceAddress,
317
+ }),
318
+ );
319
+
320
+ this.logger.info(`BananaPay deployed at ${bananaFPC.address}`);
321
+
322
+ // The BananaFPC's fee juice is seeded at genesis (see FeesTest.setup) rather than bridged here.
323
+ // Assert the deploy landed at the seeded address so a params drift surfaces as a clear error rather
324
+ // than a downstream "insufficient fee payer balance".
325
+ const { bananaFPCAddress } = await computeBananaContractAddresses(this.aliceAddress);
326
+ if (!bananaFPC.address.equals(bananaFPCAddress)) {
327
+ throw new Error(
328
+ `Deployed BananaFPC address ${bananaFPC.address} does not match the genesis-funded address ` +
329
+ `${bananaFPCAddress}; the deterministic deploy params drifted from the genesis funding computation.`,
330
+ );
331
+ }
332
+
333
+ this.bananaFPC = bananaFPC;
334
+
335
+ const l1FeeJuiceAddress = this.feeJuiceBridgeTestHarness.l1FeeJuiceAddress;
336
+
337
+ this.getCoinbaseBalance = async () => {
338
+ const l1Client = createExtendedL1Client(this.context.config.l1RpcUrls, MNEMONIC);
339
+ const gasL1 = getContract({
340
+ address: l1FeeJuiceAddress.toString(),
341
+ abi: TestERC20Abi,
342
+ client: l1Client,
343
+ });
344
+ return await gasL1.read.balanceOf([this.coinbase.toString()]);
345
+ };
346
+
347
+ this.getCoinbaseSequencerRewards = async () => {
348
+ return await this.rollupContract.getSequencerRewards(this.coinbase);
349
+ };
350
+
351
+ this.getProverFee = async (blockNumber: BlockNumber) => {
352
+ const block = await this.aztecNode.getBlock(blockNumber);
353
+
354
+ // @todo @lherskind As we deal with #13601
355
+ // Right now the value is from `FeeLib.sol`
356
+ const L1_GAS_PER_EPOCH_VERIFIED = 3600000n;
357
+
358
+ // We round up
359
+ const mulDiv = (a: bigint, b: bigint, c: bigint) => (a * b) / c + ((a * b) % c > 0n ? 1n : 0n);
360
+
361
+ const { baseFee } = await this.rollupContract.getL1FeesAt(block!.header.globalVariables.timestamp);
362
+ const proverCost =
363
+ mulDiv(
364
+ mulDiv(L1_GAS_PER_EPOCH_VERIFIED, baseFee, BigInt(await this.rollupContract.getEpochDuration())),
365
+ 1n,
366
+ await this.rollupContract.getManaTarget(),
367
+ ) + (await this.rollupContract.getProvingCostPerMana());
368
+
369
+ const price = await this.rollupContract.getEthPerFeeAsset();
370
+
371
+ const mana = block!.header.totalManaUsed.toBigInt();
372
+ return mulDiv(mana * proverCost, 10n ** 12n, price);
373
+ };
374
+
375
+ /**
376
+ * Reads the prover fee that the rollup actually committed for the block's checkpoint, which is what
377
+ * RewardLib uses to pay prover rewards. Unlike `getProverFee`, this does not re-derive the value
378
+ * from current L1 fees or current eth-per-fee-asset price, so it is robust to pipelined fee-asset-price
379
+ * drift between propose-time and reward-payout-time.
380
+ */
381
+ this.getCommittedProverFee = async (blockNumber: BlockNumber) => {
382
+ const block = await this.aztecNode.getBlock(blockNumber);
383
+ const feeHeader = await this.rollupContract.getFeeHeader(BigInt(block!.checkpointNumber));
384
+ return feeHeader.manaUsed * feeHeader.proverCost;
385
+ };
386
+
387
+ // RewardLib computes sequencerFee = checkpointFee - burn - proverFee where burn = manaUsed * congestionCost.
388
+ // The fixture's typical case keeps congestionCost at zero, but reading it explicitly avoids latent bugs
389
+ // when test load changes excess mana.
390
+ this.getCommittedBurn = async (blockNumber: BlockNumber) => {
391
+ const block = await this.aztecNode.getBlock(blockNumber);
392
+ const feeHeader = await this.rollupContract.getFeeHeader(BigInt(block!.checkpointNumber));
393
+ return feeHeader.manaUsed * feeHeader.congestionCost;
394
+ };
395
+ }
396
+
397
+ public async applySponsoredFPCSetup() {
398
+ this.logger.info('Applying sponsored FPC setup');
399
+
400
+ const feeJuiceContract = this.feeJuiceBridgeTestHarness.feeJuice;
401
+ expect((await this.wallet.getContractMetadata(feeJuiceContract.address)).isContractPublished).toBe(true);
402
+
403
+ const sponsoredFPCInstance = await setupSponsoredFPC(this.wallet);
404
+ this.logger.info(`SponsoredFPC at ${sponsoredFPCInstance.address}`);
405
+
406
+ this.sponsoredFPC = SponsoredFPCContract.at(sponsoredFPCInstance.address, this.wallet);
407
+ }
408
+
409
+ public async applyFundAliceWithBananas() {
410
+ this.logger.info('Applying fund Alice with bananas setup');
411
+
412
+ // Both mints are alice sends on BananaCoin touching disjoint balances, so they ride a single
413
+ // BatchCall tx (one proof, one slot) rather than two concurrent txs. The PXE serializes proving,
414
+ // so two concurrent sends would still be proven back-to-back and land in consecutive slots.
415
+ const { result: privateBalanceBefore } = await this.bananaCoin.methods
416
+ .balance_of_private(this.aliceAddress)
417
+ .simulate({ from: this.aliceAddress });
418
+
419
+ await testSpan('tx:mint', () =>
420
+ new BatchCall(this.wallet, [
421
+ this.bananaCoin.methods.mint_to_private(this.aliceAddress, this.ALICE_INITIAL_BANANAS),
422
+ this.bananaCoin.methods.mint_to_public(this.aliceAddress, this.ALICE_INITIAL_BANANAS),
423
+ ]).send({ from: this.aliceAddress }),
424
+ );
425
+
426
+ const { result: privateBalanceAfter } = await this.bananaCoin.methods
427
+ .balance_of_private(this.aliceAddress)
428
+ .simulate({ from: this.aliceAddress });
429
+ expect(privateBalanceAfter).toEqual(privateBalanceBefore + this.ALICE_INITIAL_BANANAS);
430
+ }
431
+
432
+ public async applyFundAliceWithPrivateBananas() {
433
+ this.logger.info('Applying fund Alice with private bananas setup');
434
+
435
+ await this.mintPrivateBananas(this.ALICE_INITIAL_BANANAS, this.aliceAddress);
436
+ }
437
+ }
@@ -0,0 +1,93 @@
1
+ import type { Archiver } from '@aztec/archiver';
2
+ import type { AztecNodeService } from '@aztec/aztec-node';
3
+ import type { AztecAddress } from '@aztec/aztec.js/addresses';
4
+ import { Fr } from '@aztec/aztec.js/fields';
5
+ import type { Logger } from '@aztec/aztec.js/log';
6
+ import type { AztecNode } from '@aztec/aztec.js/node';
7
+ import type { Delayer } from '@aztec/ethereum/l1-tx-utils';
8
+ import type { ChainMonitor } from '@aztec/ethereum/test';
9
+ import type { TestContract } from '@aztec/noir-test-contracts.js/Test';
10
+ import type { TxHash } from '@aztec/stdlib/tx';
11
+
12
+ import { jest } from '@jest/globals';
13
+
14
+ import type { EndToEndContext } from '../../fixtures/utils.js';
15
+ import { proveAndSendTxs } from '../../test-wallet/utils.js';
16
+ import { setupWithProver } from '../setup.js';
17
+ import { FAST_REORG_TIMING, SingleNodeTestContext } from '../single_node_test_context.js';
18
+
19
+ jest.setTimeout(1000 * 60 * 20);
20
+
21
+ /** Number of txs to send at the start of each reorg test to trigger multi-block checkpoints. */
22
+ export const TX_COUNT = 8;
23
+
24
+ /**
25
+ * The single-node + prover-node fixture shared by the L1-reorg suites (`blocks`, `messages`). Stands
26
+ * up a {@link SingleNodeTestContext} on the {@link FAST_REORG_TIMING} cadence (ethSlot=4s,
27
+ * aztecSlot=24s, block=5s, epoch=4, 32 slots/epoch) with L1 speed-ups disabled so prover/sequencer txs
28
+ * can be held back and reorged, registers a {@link TestContract}, and exposes the per-test handles plus
29
+ * a `sendTransactions` helper that pre-proves and fires `count` lightweight txs to drive multi-block
30
+ * checkpoints. Reorgs themselves are driven by `EthCheatCodes.reorg`/`reorgWithReplacement` at the call
31
+ * site. The returned object's fields are populated when `setup()` resolves; create it in `beforeEach`.
32
+ */
33
+ export class L1ReorgsTest {
34
+ public test!: SingleNodeTestContext;
35
+ public context!: EndToEndContext;
36
+ public logger!: Logger;
37
+ public node!: AztecNode;
38
+ public archiver!: Archiver;
39
+ public monitor!: ChainMonitor;
40
+ public proverDelayer!: Delayer;
41
+ public sequencerDelayer!: Delayer;
42
+ public contract!: TestContract;
43
+ public from!: AztecAddress;
44
+
45
+ public L1_BLOCK_TIME_IN_S!: number;
46
+ public L2_SLOT_DURATION_IN_S!: number;
47
+
48
+ public async setup(): Promise<void> {
49
+ this.test = await setupWithProver({
50
+ ...FAST_REORG_TIMING, // ethSlot=4s, aztecSlot=24s, block=5s, epoch=4, 32 slots/epoch (mainnet)
51
+ numberOfAccounts: 1,
52
+ maxSpeedUpAttempts: 0, // Do not speed up l1 txs, we dont want them to land
53
+ cancelTxOnTimeout: false,
54
+ minTxsPerBlock: 0,
55
+ maxTxsPerBlock: 1,
56
+ aztecProofSubmissionEpochs: 1,
57
+ // Pipelining + multi-blocks-per-slot: 5s blocks fit ~3 blocks per 24s slot, and TX_COUNT=8
58
+ // ensures multiple checkpoints have multiple blocks
59
+ });
60
+ ({
61
+ proverDelayer: this.proverDelayer,
62
+ sequencerDelayer: this.sequencerDelayer,
63
+ context: this.context,
64
+ logger: this.logger,
65
+ monitor: this.monitor,
66
+ L1_BLOCK_TIME_IN_S: this.L1_BLOCK_TIME_IN_S,
67
+ L2_SLOT_DURATION_IN_S: this.L2_SLOT_DURATION_IN_S,
68
+ } = this.test);
69
+ this.node = this.context.aztecNode;
70
+ this.archiver = (this.node as AztecNodeService).getBlockSource() as Archiver;
71
+ this.from = this.context.accounts[0];
72
+ this.contract = await this.test.registerTestContract(this.context.wallet);
73
+ }
74
+
75
+ public teardown(): Promise<void> {
76
+ return this.test.teardown();
77
+ }
78
+
79
+ /** Pre-proves and sends `count` txs to generate L2 activity for multi-block checkpoints. */
80
+ public async sendTransactions(count: number, offset = 0): Promise<TxHash[]> {
81
+ this.logger.warn(`Pre-proving ${count} transactions`);
82
+ const txHashes = await proveAndSendTxs(
83
+ this.context.wallet,
84
+ count,
85
+ i => this.contract.methods.emit_nullifier(new Fr(offset + i + 1)),
86
+ { from: this.from },
87
+ );
88
+ this.logger.warn(`Sent ${txHashes.length} transactions`);
89
+ return txHashes;
90
+ }
91
+ }
92
+
93
+ export { jest };
@@ -0,0 +1,8 @@
1
+ import { jest } from '@jest/globals';
2
+
3
+ import { NO_REORG_SUBMISSION_EPOCHS, PROVING_SLOT_TIMING, setupWithProver } from '../setup.js';
4
+ import { SingleNodeTestContext } from '../single_node_test_context.js';
5
+
6
+ jest.setTimeout(1000 * 60 * 10);
7
+
8
+ export { jest, setupWithProver, SingleNodeTestContext, NO_REORG_SUBMISSION_EPOCHS, PROVING_SLOT_TIMING };
@@ -0,0 +1,15 @@
1
+ import { jest } from '@jest/globals';
2
+
3
+ import { NO_REORG_SUBMISSION_EPOCHS, PROVING_SLOT_TIMING, setupWithProver } from '../setup.js';
4
+ import { SingleNodeTestContext, WORLD_STATE_CHECKPOINT_HISTORY } from '../single_node_test_context.js';
5
+
6
+ jest.setTimeout(1000 * 60 * 15);
7
+
8
+ export {
9
+ jest,
10
+ setupWithProver,
11
+ SingleNodeTestContext,
12
+ WORLD_STATE_CHECKPOINT_HISTORY,
13
+ NO_REORG_SUBMISSION_EPOCHS,
14
+ PROVING_SLOT_TIMING,
15
+ };
@@ -0,0 +1,8 @@
1
+ import { jest } from '@jest/globals';
2
+
3
+ import { NO_REORG_SUBMISSION_EPOCHS, PROVING_SLOT_TIMING, setupWithProver } from '../setup.js';
4
+ import { SingleNodeTestContext } from '../single_node_test_context.js';
5
+
6
+ jest.setTimeout(1000 * 60 * 10);
7
+
8
+ export { jest, setupWithProver, SingleNodeTestContext, NO_REORG_SUBMISSION_EPOCHS, PROVING_SLOT_TIMING };