@aztec/end-to-end 0.0.1-commit.d3ec352c → 0.0.1-commit.d58ff9d0

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 (404) hide show
  1. package/README.md +217 -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/automine/token/blacklist_token_contract_test.js +166 -0
  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/automine/token/token_contract_test.js +119 -0
  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 +17 -2
  27. package/dest/bench/client_flows/benchmark.d.ts.map +1 -1
  28. package/dest/bench/client_flows/benchmark.js +40 -1
  29. package/dest/bench/client_flows/client_flows_benchmark.d.ts +19 -20
  30. package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -1
  31. package/dest/bench/client_flows/client_flows_benchmark.js +155 -159
  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/client_flows/data_extractor.js +4 -1
  36. package/dest/bench/utils.d.ts +11 -10
  37. package/dest/bench/utils.d.ts.map +1 -1
  38. package/dest/bench/utils.js +126 -23
  39. package/dest/composed/ha/ha_full_setup.d.ts +77 -0
  40. package/dest/composed/ha/ha_full_setup.d.ts.map +1 -0
  41. package/dest/composed/ha/ha_full_setup.js +383 -0
  42. package/dest/composed/web3signer/multi_validator_keystore_utils.d.ts +12 -0
  43. package/dest/composed/web3signer/multi_validator_keystore_utils.d.ts.map +1 -0
  44. package/dest/{e2e_multi_validator/utils.js → composed/web3signer/multi_validator_keystore_utils.js} +1 -1
  45. package/dest/fixtures/authwit_proxy.d.ts +15 -0
  46. package/dest/fixtures/authwit_proxy.d.ts.map +1 -0
  47. package/dest/fixtures/authwit_proxy.js +34 -0
  48. package/dest/fixtures/e2e_prover_test.d.ts +25 -29
  49. package/dest/fixtures/e2e_prover_test.d.ts.map +1 -1
  50. package/dest/fixtures/e2e_prover_test.js +147 -151
  51. package/dest/fixtures/elu_monitor.d.ts +21 -0
  52. package/dest/fixtures/elu_monitor.d.ts.map +1 -0
  53. package/dest/fixtures/elu_monitor.js +102 -0
  54. package/dest/fixtures/fixtures.d.ts +84 -3
  55. package/dest/fixtures/fixtures.d.ts.map +1 -1
  56. package/dest/fixtures/fixtures.js +87 -2
  57. package/dest/fixtures/get_acvm_config.js +1 -1
  58. package/dest/fixtures/get_bb_config.d.ts +1 -1
  59. package/dest/fixtures/get_bb_config.d.ts.map +1 -1
  60. package/dest/fixtures/get_bb_config.js +5 -5
  61. package/dest/fixtures/ha_setup.d.ts +71 -0
  62. package/dest/fixtures/ha_setup.d.ts.map +1 -0
  63. package/dest/fixtures/ha_setup.js +119 -0
  64. package/dest/fixtures/index.d.ts +3 -1
  65. package/dest/fixtures/index.d.ts.map +1 -1
  66. package/dest/fixtures/index.js +2 -0
  67. package/dest/fixtures/l1_to_l2_messaging.d.ts +4 -3
  68. package/dest/fixtures/l1_to_l2_messaging.d.ts.map +1 -1
  69. package/dest/fixtures/l1_to_l2_messaging.js +2 -2
  70. package/dest/fixtures/schnorr_hardcoded_account_contract.d.ts +25 -0
  71. package/dest/fixtures/schnorr_hardcoded_account_contract.d.ts.map +1 -0
  72. package/dest/fixtures/schnorr_hardcoded_account_contract.js +37 -0
  73. package/dest/fixtures/setup.d.ts +269 -0
  74. package/dest/fixtures/setup.d.ts.map +1 -0
  75. package/dest/fixtures/setup.js +688 -0
  76. package/dest/fixtures/setup_p2p_test.d.ts +22 -11
  77. package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
  78. package/dest/fixtures/setup_p2p_test.js +49 -38
  79. package/dest/fixtures/timing.d.ts +42 -0
  80. package/dest/fixtures/timing.d.ts.map +1 -0
  81. package/dest/fixtures/timing.js +72 -0
  82. package/dest/fixtures/token_utils.d.ts +22 -4
  83. package/dest/fixtures/token_utils.d.ts.map +1 -1
  84. package/dest/fixtures/token_utils.js +28 -7
  85. package/dest/fixtures/utils.d.ts +5 -638
  86. package/dest/fixtures/utils.d.ts.map +1 -1
  87. package/dest/fixtures/utils.js +4 -647
  88. package/dest/fixtures/wait_helpers.d.ts +135 -0
  89. package/dest/fixtures/wait_helpers.d.ts.map +1 -0
  90. package/dest/fixtures/wait_helpers.js +154 -0
  91. package/dest/fixtures/web3signer.js +1 -1
  92. package/dest/fixtures/with_telemetry_utils.d.ts +2 -2
  93. package/dest/fixtures/with_telemetry_utils.d.ts.map +1 -1
  94. package/dest/fixtures/with_telemetry_utils.js +2 -2
  95. package/dest/forward-compatibility/wallet_rpc_client.d.ts +7 -0
  96. package/dest/forward-compatibility/wallet_rpc_client.d.ts.map +1 -0
  97. package/dest/forward-compatibility/wallet_rpc_client.js +15 -0
  98. package/dest/forward-compatibility/wallet_service.d.ts +3 -0
  99. package/dest/forward-compatibility/wallet_service.d.ts.map +1 -0
  100. package/dest/forward-compatibility/wallet_service.js +109 -0
  101. package/dest/install_legacy_contracts.d.cts +10 -0
  102. package/dest/install_legacy_contracts.d.cts.map +1 -0
  103. package/dest/legacy-jest-resolver.d.cts +3 -0
  104. package/dest/legacy-jest-resolver.d.cts.map +1 -0
  105. package/dest/multi-node/block-production/setup.d.ts +97 -0
  106. package/dest/multi-node/block-production/setup.d.ts.map +1 -0
  107. package/dest/multi-node/block-production/setup.js +158 -0
  108. package/dest/multi-node/governance/setup.d.ts +67 -0
  109. package/dest/multi-node/governance/setup.d.ts.map +1 -0
  110. package/dest/multi-node/governance/setup.js +126 -0
  111. package/dest/multi-node/multi_node_test_context.d.ts +212 -0
  112. package/dest/multi-node/multi_node_test_context.d.ts.map +1 -0
  113. package/dest/multi-node/multi_node_test_context.js +347 -0
  114. package/dest/multi-node/slashing/inactivity_setup.d.ts +27 -0
  115. package/dest/multi-node/slashing/inactivity_setup.d.ts.map +1 -0
  116. package/dest/multi-node/slashing/inactivity_setup.js +111 -0
  117. package/dest/multi-node/slashing/setup.d.ts +167 -0
  118. package/dest/multi-node/slashing/setup.d.ts.map +1 -0
  119. package/dest/multi-node/slashing/setup.js +275 -0
  120. package/dest/{e2e_p2p → p2p}/p2p_network.d.ts +33 -21
  121. package/dest/p2p/p2p_network.d.ts.map +1 -0
  122. package/dest/p2p/p2p_network.js +389 -0
  123. package/dest/p2p/reqresp/utils.d.ts +19 -0
  124. package/dest/p2p/reqresp/utils.d.ts.map +1 -0
  125. package/dest/p2p/reqresp/utils.js +193 -0
  126. package/dest/p2p/shared.d.ts +72 -0
  127. package/dest/p2p/shared.d.ts.map +1 -0
  128. package/dest/p2p/shared.js +212 -0
  129. package/dest/quality_of_service/grafana_client.d.ts +41 -0
  130. package/dest/quality_of_service/grafana_client.d.ts.map +1 -0
  131. package/dest/quality_of_service/{alert_checker.js → grafana_client.js} +1 -1
  132. package/dest/quality_of_service/prometheus_client.d.ts +38 -0
  133. package/dest/quality_of_service/prometheus_client.d.ts.map +1 -0
  134. package/dest/quality_of_service/prometheus_client.js +67 -0
  135. package/dest/shared/cross_chain_test_harness.d.ts +22 -9
  136. package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
  137. package/dest/shared/cross_chain_test_harness.js +45 -40
  138. package/dest/shared/gas_portal_test_harness.d.ts +19 -6
  139. package/dest/shared/gas_portal_test_harness.d.ts.map +1 -1
  140. package/dest/shared/gas_portal_test_harness.js +27 -15
  141. package/dest/shared/index.d.ts +3 -2
  142. package/dest/shared/index.d.ts.map +1 -1
  143. package/dest/shared/index.js +1 -0
  144. package/dest/shared/jest_setup.js +41 -1
  145. package/dest/shared/mock_state_view.d.ts +86 -0
  146. package/dest/shared/mock_state_view.d.ts.map +1 -0
  147. package/dest/shared/mock_state_view.js +186 -0
  148. package/dest/shared/submit-transactions.d.ts +4 -4
  149. package/dest/shared/submit-transactions.d.ts.map +1 -1
  150. package/dest/shared/submit-transactions.js +19 -14
  151. package/dest/shared/timing_env.d.js +5 -0
  152. package/dest/shared/timing_env.js +365 -0
  153. package/dest/shared/uniswap_l1_l2.d.ts +3 -27
  154. package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
  155. package/dest/shared/uniswap_l1_l2.js +86 -54
  156. package/dest/shared/wait_for_l1_to_l2_message.d.ts +13 -0
  157. package/dest/shared/wait_for_l1_to_l2_message.d.ts.map +1 -0
  158. package/dest/shared/wait_for_l1_to_l2_message.js +10 -0
  159. package/dest/simulators/lending_simulator.d.ts +15 -4
  160. package/dest/simulators/lending_simulator.d.ts.map +1 -1
  161. package/dest/simulators/lending_simulator.js +29 -17
  162. package/dest/simulators/token_simulator.d.ts +1 -1
  163. package/dest/simulators/token_simulator.d.ts.map +1 -1
  164. package/dest/simulators/token_simulator.js +3 -24
  165. package/dest/single-node/cross-chain/cross_chain_messaging_test.d.ts +75 -0
  166. package/dest/single-node/cross-chain/cross_chain_messaging_test.d.ts.map +1 -0
  167. package/dest/single-node/cross-chain/cross_chain_messaging_test.js +209 -0
  168. package/dest/single-node/cross-chain/message_test_helpers.d.ts +38 -0
  169. package/dest/single-node/cross-chain/message_test_helpers.d.ts.map +1 -0
  170. package/dest/single-node/cross-chain/message_test_helpers.js +70 -0
  171. package/dest/{e2e_fees → single-node/fees}/bridging_race.notest.d.ts +1 -1
  172. package/dest/single-node/fees/bridging_race.notest.d.ts.map +1 -0
  173. package/dest/{e2e_fees → single-node/fees}/bridging_race.notest.js +21 -10
  174. package/dest/single-node/fees/fees_test.d.ts +93 -0
  175. package/dest/single-node/fees/fees_test.d.ts.map +1 -0
  176. package/dest/single-node/fees/fees_test.js +274 -0
  177. package/dest/single-node/l1-reorgs/setup.d.ts +42 -0
  178. package/dest/single-node/l1-reorgs/setup.d.ts.map +1 -0
  179. package/dest/single-node/l1-reorgs/setup.js +57 -0
  180. package/dest/single-node/partial-proofs/setup.d.ts +5 -0
  181. package/dest/single-node/partial-proofs/setup.d.ts.map +1 -0
  182. package/dest/single-node/partial-proofs/setup.js +5 -0
  183. package/dest/single-node/proving/setup.d.ts +5 -0
  184. package/dest/single-node/proving/setup.d.ts.map +1 -0
  185. package/dest/single-node/proving/setup.js +5 -0
  186. package/dest/single-node/recovery/setup.d.ts +5 -0
  187. package/dest/single-node/recovery/setup.d.ts.map +1 -0
  188. package/dest/single-node/recovery/setup.js +5 -0
  189. package/dest/single-node/setup.d.ts +49 -0
  190. package/dest/single-node/setup.d.ts.map +1 -0
  191. package/dest/single-node/setup.js +56 -0
  192. package/dest/single-node/single_node_test_context.d.ts +360 -0
  193. package/dest/single-node/single_node_test_context.d.ts.map +1 -0
  194. package/dest/single-node/single_node_test_context.js +833 -0
  195. package/dest/spartan/setup_test_wallets.d.ts +15 -5
  196. package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
  197. package/dest/spartan/setup_test_wallets.js +155 -50
  198. package/dest/spartan/tx_metrics.d.ts +111 -0
  199. package/dest/spartan/tx_metrics.d.ts.map +1 -0
  200. package/dest/spartan/tx_metrics.js +507 -0
  201. package/dest/spartan/utils/bot.d.ts +28 -0
  202. package/dest/spartan/utils/bot.d.ts.map +1 -0
  203. package/dest/spartan/utils/bot.js +142 -0
  204. package/dest/spartan/utils/chaos.d.ts +79 -0
  205. package/dest/spartan/utils/chaos.d.ts.map +1 -0
  206. package/dest/spartan/utils/chaos.js +142 -0
  207. package/dest/spartan/utils/clients.d.ts +39 -0
  208. package/dest/spartan/utils/clients.d.ts.map +1 -0
  209. package/dest/spartan/utils/clients.js +90 -0
  210. package/dest/spartan/utils/config.d.ts +19 -0
  211. package/dest/spartan/utils/config.d.ts.map +1 -0
  212. package/dest/spartan/utils/config.js +23 -0
  213. package/dest/spartan/utils/health.d.ts +63 -0
  214. package/dest/spartan/utils/health.d.ts.map +1 -0
  215. package/dest/spartan/utils/health.js +202 -0
  216. package/dest/spartan/utils/helm.d.ts +15 -0
  217. package/dest/spartan/utils/helm.d.ts.map +1 -0
  218. package/dest/spartan/utils/helm.js +47 -0
  219. package/dest/spartan/utils/index.d.ts +11 -0
  220. package/dest/spartan/utils/index.d.ts.map +1 -0
  221. package/dest/spartan/utils/index.js +22 -0
  222. package/dest/spartan/utils/k8s.d.ts +128 -0
  223. package/dest/spartan/utils/k8s.d.ts.map +1 -0
  224. package/dest/spartan/utils/k8s.js +381 -0
  225. package/dest/spartan/utils/nodes.d.ts +40 -0
  226. package/dest/spartan/utils/nodes.d.ts.map +1 -0
  227. package/dest/spartan/utils/nodes.js +461 -0
  228. package/dest/spartan/utils/pod_logs.d.ts +25 -0
  229. package/dest/spartan/utils/pod_logs.d.ts.map +1 -0
  230. package/dest/spartan/utils/pod_logs.js +74 -0
  231. package/dest/spartan/utils/scripts.d.ts +30 -0
  232. package/dest/spartan/utils/scripts.d.ts.map +1 -0
  233. package/dest/spartan/utils/scripts.js +81 -0
  234. package/dest/spartan/utils.d.ts +2 -221
  235. package/dest/spartan/utils.d.ts.map +1 -1
  236. package/dest/spartan/utils.js +1 -782
  237. package/dest/test-wallet/test_wallet.d.ts +105 -0
  238. package/dest/test-wallet/test_wallet.d.ts.map +1 -0
  239. package/dest/test-wallet/test_wallet.js +320 -0
  240. package/dest/test-wallet/utils.d.ts +76 -0
  241. package/dest/test-wallet/utils.d.ts.map +1 -0
  242. package/dest/test-wallet/utils.js +126 -0
  243. package/dest/test-wallet/wallet_worker_script.d.ts +2 -0
  244. package/dest/test-wallet/wallet_worker_script.d.ts.map +1 -0
  245. package/dest/test-wallet/wallet_worker_script.js +56 -0
  246. package/dest/test-wallet/worker_wallet.d.ts +53 -0
  247. package/dest/test-wallet/worker_wallet.d.ts.map +1 -0
  248. package/dest/test-wallet/worker_wallet.js +157 -0
  249. package/dest/test-wallet/worker_wallet_schema.d.ts +4 -0
  250. package/dest/test-wallet/worker_wallet_schema.d.ts.map +1 -0
  251. package/dest/test-wallet/worker_wallet_schema.js +23 -0
  252. package/package.json +54 -46
  253. package/src/automine/README.md +60 -0
  254. package/src/automine/automine_test_context.ts +153 -0
  255. package/src/automine/contracts/fixtures/storage_proof.json +915 -0
  256. package/src/automine/contracts/fixtures/storage_proof_fetcher.ts +190 -0
  257. package/src/automine/contracts/fixtures/storage_proof_fixture.ts +173 -0
  258. package/src/automine/delivery/interactive_handshake_responder.ts +125 -0
  259. package/src/automine/delivery/onchain_delivery_harness.ts +213 -0
  260. package/src/automine/token/blacklist_token_contract_test.ts +208 -0
  261. package/src/automine/token/token_contract_test.ts +146 -0
  262. package/src/automine/token/token_test_helpers.ts +138 -0
  263. package/src/bench/client_flows/benchmark.ts +45 -2
  264. package/src/bench/client_flows/client_flows_benchmark.ts +222 -251
  265. package/src/bench/client_flows/config.ts +9 -1
  266. package/src/bench/client_flows/data_extractor.ts +2 -1
  267. package/src/bench/utils.ts +144 -25
  268. package/src/composed/ha/ha_full_setup.ts +466 -0
  269. package/src/{e2e_multi_validator/utils.ts → composed/web3signer/multi_validator_keystore_utils.ts} +1 -1
  270. package/src/fixtures/authwit_proxy.ts +54 -0
  271. package/src/fixtures/dumps/epoch_proof_result.json +1 -1
  272. package/src/fixtures/e2e_prover_test.ts +172 -205
  273. package/src/fixtures/elu_monitor.ts +126 -0
  274. package/src/fixtures/fixtures.ts +111 -3
  275. package/src/fixtures/get_acvm_config.ts +1 -1
  276. package/src/fixtures/get_bb_config.ts +7 -6
  277. package/src/fixtures/ha_setup.ts +192 -0
  278. package/src/fixtures/index.ts +2 -0
  279. package/src/fixtures/l1_to_l2_messaging.ts +4 -2
  280. package/src/fixtures/schnorr_hardcoded_account_contract.ts +49 -0
  281. package/src/fixtures/setup.ts +987 -0
  282. package/src/fixtures/setup_p2p_test.ts +57 -57
  283. package/src/fixtures/timing.ts +97 -0
  284. package/src/fixtures/token_utils.ts +46 -10
  285. package/src/fixtures/utils.ts +26 -966
  286. package/src/fixtures/wait_helpers.ts +333 -0
  287. package/src/fixtures/web3signer.ts +1 -1
  288. package/src/fixtures/with_telemetry_utils.ts +2 -2
  289. package/src/forward-compatibility/wallet_rpc_client.ts +14 -0
  290. package/src/forward-compatibility/wallet_service.ts +106 -0
  291. package/src/guides/up_quick_start.sh +7 -4
  292. package/src/infra/README.md +12 -0
  293. package/src/install_legacy_contracts.cjs +75 -0
  294. package/src/legacy-jest-resolver.cjs +112 -0
  295. package/src/multi-node/README.md +95 -0
  296. package/src/multi-node/block-production/setup.ts +272 -0
  297. package/src/multi-node/governance/setup.ts +172 -0
  298. package/src/multi-node/multi_node_test_context.ts +447 -0
  299. package/src/multi-node/slashing/inactivity_setup.ts +139 -0
  300. package/src/multi-node/slashing/setup.ts +433 -0
  301. package/src/p2p/README.md +78 -0
  302. package/src/p2p/p2p_network.ts +542 -0
  303. package/src/p2p/reqresp/utils.ts +263 -0
  304. package/src/p2p/shared.ts +329 -0
  305. package/src/quality_of_service/{alert_checker.ts → grafana_client.ts} +1 -1
  306. package/src/quality_of_service/prometheus_client.ts +113 -0
  307. package/src/shared/cross_chain_test_harness.ts +51 -44
  308. package/src/shared/gas_portal_test_harness.ts +35 -17
  309. package/src/shared/index.ts +2 -1
  310. package/src/shared/jest_setup.ts +51 -1
  311. package/src/shared/mock_state_view.ts +188 -0
  312. package/src/shared/submit-transactions.ts +22 -19
  313. package/src/shared/timing_env.d.mts +39 -0
  314. package/src/shared/timing_env.mjs +363 -0
  315. package/src/shared/uniswap_l1_l2.ts +136 -115
  316. package/src/shared/wait_for_l1_to_l2_message.ts +23 -0
  317. package/src/simulators/lending_simulator.ts +36 -18
  318. package/src/simulators/token_simulator.ts +6 -30
  319. package/src/single-node/README.md +60 -0
  320. package/src/single-node/cross-chain/cross_chain_messaging_test.ts +302 -0
  321. package/src/single-node/cross-chain/message_test_helpers.ts +125 -0
  322. package/src/{e2e_fees → single-node/fees}/bridging_race.notest.ts +23 -15
  323. package/src/single-node/fees/fees_test.ts +368 -0
  324. package/src/single-node/l1-reorgs/setup.ts +93 -0
  325. package/src/single-node/partial-proofs/setup.ts +8 -0
  326. package/src/single-node/proving/setup.ts +15 -0
  327. package/src/single-node/recovery/setup.ts +8 -0
  328. package/src/single-node/setup.ts +63 -0
  329. package/src/single-node/single_node_test_context.ts +1041 -0
  330. package/src/spartan/setup_test_wallets.ts +217 -36
  331. package/src/spartan/tx_metrics.ts +460 -0
  332. package/src/spartan/utils/bot.ts +188 -0
  333. package/src/spartan/utils/chaos.ts +253 -0
  334. package/src/spartan/utils/clients.ts +100 -0
  335. package/src/spartan/utils/config.ts +29 -0
  336. package/src/spartan/utils/health.ts +255 -0
  337. package/src/spartan/utils/helm.ts +84 -0
  338. package/src/spartan/utils/index.ts +71 -0
  339. package/src/spartan/utils/k8s.ts +535 -0
  340. package/src/spartan/utils/nodes.ts +543 -0
  341. package/src/spartan/utils/pod_logs.ts +99 -0
  342. package/src/spartan/utils/scripts.ts +99 -0
  343. package/src/spartan/utils.ts +1 -983
  344. package/src/test-wallet/test_wallet.ts +426 -0
  345. package/src/test-wallet/utils.ts +205 -0
  346. package/src/test-wallet/wallet_worker_script.ts +66 -0
  347. package/src/test-wallet/worker_wallet.ts +216 -0
  348. package/src/test-wallet/worker_wallet_schema.ts +14 -0
  349. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +0 -54
  350. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts.map +0 -1
  351. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.js +0 -185
  352. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +0 -41
  353. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts.map +0 -1
  354. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.js +0 -108
  355. package/dest/e2e_deploy_contract/deploy_test.d.ts +0 -36
  356. package/dest/e2e_deploy_contract/deploy_test.d.ts.map +0 -1
  357. package/dest/e2e_deploy_contract/deploy_test.js +0 -45
  358. package/dest/e2e_epochs/epochs_test.d.ts +0 -93
  359. package/dest/e2e_epochs/epochs_test.d.ts.map +0 -1
  360. package/dest/e2e_epochs/epochs_test.js +0 -337
  361. package/dest/e2e_fees/bridging_race.notest.d.ts.map +0 -1
  362. package/dest/e2e_fees/fees_test.d.ts +0 -85
  363. package/dest/e2e_fees/fees_test.d.ts.map +0 -1
  364. package/dest/e2e_fees/fees_test.js +0 -263
  365. package/dest/e2e_l1_publisher/write_json.d.ts +0 -10
  366. package/dest/e2e_l1_publisher/write_json.d.ts.map +0 -1
  367. package/dest/e2e_l1_publisher/write_json.js +0 -58
  368. package/dest/e2e_multi_validator/utils.d.ts +0 -12
  369. package/dest/e2e_multi_validator/utils.d.ts.map +0 -1
  370. package/dest/e2e_nested_contract/nested_contract_test.d.ts +0 -29
  371. package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +0 -1
  372. package/dest/e2e_nested_contract/nested_contract_test.js +0 -64
  373. package/dest/e2e_p2p/inactivity_slash_test.d.ts +0 -31
  374. package/dest/e2e_p2p/inactivity_slash_test.d.ts.map +0 -1
  375. package/dest/e2e_p2p/inactivity_slash_test.js +0 -139
  376. package/dest/e2e_p2p/p2p_network.d.ts.map +0 -1
  377. package/dest/e2e_p2p/p2p_network.js +0 -320
  378. package/dest/e2e_p2p/shared.d.ts +0 -46
  379. package/dest/e2e_p2p/shared.d.ts.map +0 -1
  380. package/dest/e2e_p2p/shared.js +0 -184
  381. package/dest/e2e_token_contract/token_contract_test.d.ts +0 -35
  382. package/dest/e2e_token_contract/token_contract_test.d.ts.map +0 -1
  383. package/dest/e2e_token_contract/token_contract_test.js +0 -126
  384. package/dest/fixtures/setup_l1_contracts.d.ts +0 -477
  385. package/dest/fixtures/setup_l1_contracts.d.ts.map +0 -1
  386. package/dest/fixtures/setup_l1_contracts.js +0 -17
  387. package/dest/fixtures/snapshot_manager.d.ts +0 -95
  388. package/dest/fixtures/snapshot_manager.d.ts.map +0 -1
  389. package/dest/fixtures/snapshot_manager.js +0 -505
  390. package/dest/quality_of_service/alert_checker.d.ts +0 -41
  391. package/dest/quality_of_service/alert_checker.d.ts.map +0 -1
  392. package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +0 -256
  393. package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +0 -179
  394. package/src/e2e_deploy_contract/deploy_test.ts +0 -78
  395. package/src/e2e_epochs/epochs_test.ts +0 -438
  396. package/src/e2e_fees/fees_test.ts +0 -382
  397. package/src/e2e_l1_publisher/write_json.ts +0 -77
  398. package/src/e2e_nested_contract/nested_contract_test.ts +0 -96
  399. package/src/e2e_p2p/inactivity_slash_test.ts +0 -182
  400. package/src/e2e_p2p/p2p_network.ts +0 -476
  401. package/src/e2e_p2p/shared.ts +0 -285
  402. package/src/e2e_token_contract/token_contract_test.ts +0 -167
  403. package/src/fixtures/setup_l1_contracts.ts +0 -26
  404. package/src/fixtures/snapshot_manager.ts +0 -665
@@ -0,0 +1,833 @@
1
+ import { createAztecNodeService } from '@aztec/aztec-node';
2
+ import { getAccountContractAddress } from '@aztec/aztec.js/account';
3
+ import { getTimestampRangeForEpoch } from '@aztec/aztec.js/block';
4
+ import { getContractInstanceFromInstantiationParams } from '@aztec/aztec.js/contracts';
5
+ import { Fr } from '@aztec/aztec.js/fields';
6
+ import { MerkleTreeId } from '@aztec/aztec.js/trees';
7
+ import { EpochCache } from '@aztec/epoch-cache';
8
+ import { createExtendedL1Client } from '@aztec/ethereum/client';
9
+ import { DefaultL1ContractsConfig } from '@aztec/ethereum/config';
10
+ import { RollupContract } from '@aztec/ethereum/contracts';
11
+ import { createDelayer, waitUntilL1Timestamp, wrapClientWithDelayer } from '@aztec/ethereum/l1-tx-utils';
12
+ import { ChainMonitor } from '@aztec/ethereum/test';
13
+ import { CheckpointNumber, EpochNumber } from '@aztec/foundation/branded-types';
14
+ import { SecretValue } from '@aztec/foundation/config';
15
+ import { randomBytes } from '@aztec/foundation/crypto/random';
16
+ import { withLoggerBindings } from '@aztec/foundation/log/server';
17
+ import { retryUntil } from '@aztec/foundation/retry';
18
+ import { sleep } from '@aztec/foundation/sleep';
19
+ import { executeTimeout } from '@aztec/foundation/timer';
20
+ import { SpamContract } from '@aztec/noir-test-contracts.js/Spam';
21
+ import { TestContract } from '@aztec/noir-test-contracts.js/Test';
22
+ import { getMockPubSubP2PServiceFactory } from '@aztec/p2p/test-helpers';
23
+ import { SequencerState } from '@aztec/sequencer-client';
24
+ import { EthAddress } from '@aztec/stdlib/block';
25
+ import { getProofSubmissionDeadlineTimestamp, getTimestampForSlot } from '@aztec/stdlib/epoch-helpers';
26
+ import { tryStop } from '@aztec/stdlib/interfaces/server';
27
+ import { join } from 'path';
28
+ import { privateKeyToAccount } from 'viem/accounts';
29
+ import { SCHNORR_HARDCODED_PRIVATE_KEY, SchnorrHardcodedKeyAccountContract } from '../fixtures/schnorr_hardcoded_account_contract.js';
30
+ import { testSpan } from '../fixtures/timing.js';
31
+ import { createAndSyncProverNode, getPrivateKeyFromIndex, setup } from '../fixtures/utils.js';
32
+ export const WORLD_STATE_CHECKPOINT_HISTORY = 2;
33
+ export const WORLD_STATE_BLOCK_CHECK_INTERVAL = 50;
34
+ export const ARCHIVER_POLL_INTERVAL = 50;
35
+ export const DEFAULT_L1_BLOCK_TIME = process.env.CI ? 12 : 8;
36
+ /**
37
+ * The 36s-slot reorg cadence shared by every reorg/prune/HA test, regardless of single-node vs
38
+ * multi-validator topology: a 36s L2 slot, 8s blocks, and a 4-slot epoch. The two concrete reorg
39
+ * profiles ({@link FAST_REORG_TIMING}, {@link MULTI_VALIDATOR_REORG_TIMING}) extend this with their topology's L1
40
+ * slot duration and any extra knobs. Kept timing-only — `maxSpeedUpAttempts`, `cancelTxOnTimeout`, and
41
+ * `aztecProofSubmissionEpochs` encode per-test scenario intent and stay explicit at the call site.
42
+ */ export const REORG_TIMING_BASE = {
43
+ aztecSlotDuration: 36,
44
+ blockDurationMs: 8000,
45
+ aztecEpochDuration: 4
46
+ };
47
+ /**
48
+ * Timing-only profile shared by the fast single-node L1-reorg tests (`proving/optimistic`'s reorg
49
+ * cases and `l1-reorgs/`). Extends {@link REORG_TIMING_BASE} with mainnet-style 32-slot anvil epochs
50
+ * and a 4s L1 slot. Note: `ethereumSlotDuration` stays at 4 here (not unified to
51
+ * {@link MULTI_VALIDATOR_REORG_TIMING}'s 6) — at eth=6 the proof-submission-window timing in the
52
+ * proof-removal/proof-restore reorg assertions in `l1-reorgs/blocks` starves and times out, so the 4s
53
+ * L1 slot is required for the single-node reorg path. Tests that need a different epoch length (e.g. 8
54
+ * for the "with replacement" case) override `aztecEpochDuration` after the spread.
55
+ */ export const FAST_REORG_TIMING = {
56
+ ...REORG_TIMING_BASE,
57
+ ethereumSlotDuration: 4,
58
+ anvilSlotsInAnEpoch: 32
59
+ };
60
+ /**
61
+ * Timing-only profile naming the 36s/6s reorg-and-prune cadence copied verbatim across the
62
+ * multi-validator recovery and high-availability tests (`recovery/proposal_failure_recovery`,
63
+ * `recovery/equivocation_recovery`, `high-availability/ha_sync`,
64
+ * `high-availability/ha_checkpoint_handoff`). The multi-validator analogue of
65
+ * {@link FAST_REORG_TIMING}, adding the 0.5s attestation-propagation budget those committee tests
66
+ * need. Timing-only: committee size, `aztecProofSubmissionEpochs`, and the slasher block stay
67
+ * per-test. Spread BEFORE per-test overrides so a test can still bump e.g. `aztecEpochDuration`.
68
+ */ export const MULTI_VALIDATOR_REORG_TIMING = {
69
+ ...REORG_TIMING_BASE,
70
+ ethereumSlotDuration: 6,
71
+ attestationPropagationTime: 0.5
72
+ };
73
+ /**
74
+ * Timing-only profile naming the 36s/12s multi-validator block-production cadence copied across
75
+ * `block-production/` (`simple`, `high_tps`, `first_slot`, and `proof_boundary`). Uses
76
+ * `aztecSlotDurationInL1Slots: 3` rather than an explicit `aztecSlotDuration: 36` so the L2 slot stays
77
+ * coupled to `ethereumSlotDuration` if a test overrides eth. Deliberately omits
78
+ * `attestationPropagationTime` (per-scenario: default 2, 0.5, or 1) — set it per test. Spread BEFORE
79
+ * per-test overrides.
80
+ */ export const MULTI_VALIDATOR_BLOCK_PRODUCTION_TIMING = {
81
+ ethereumSlotDuration: 12,
82
+ aztecSlotDurationInL1Slots: 3,
83
+ blockDurationMs: 6000
84
+ };
85
+ /**
86
+ * Timing-only profile naming the 72s wide-slot multiple-blocks-per-slot cadence copied across the
87
+ * block-production and recovery tests (`block-production/`'s `setupBlockProductionWithProver`, `block-production/blob_promotion`,
88
+ * `recovery/pipeline_prune`). A-914:
89
+ * pipelined multiple-blocks-per-slot needs this 72s/12s cadence (not the tighter 36s/4s), otherwise non-proposer nodes hit
90
+ * `CheckpointNumberNotSequentialError` when the pipelined proposer races ahead of L1 confirmation. The
91
+ * larger `perBlockAllocationMultiplier` lets each of the several blocks per slot fit non-trivial txs.
92
+ * Spread BEFORE per-test overrides (e.g. `mockGossipSubNetworkLatency`, `maxTxsPerCheckpoint`).
93
+ */ export const WIDE_SLOT_TIMING = {
94
+ ethereumSlotDuration: 12,
95
+ aztecSlotDuration: 72,
96
+ blockDurationMs: 5500,
97
+ aztecEpochDuration: 4,
98
+ perBlockAllocationMultiplier: 8,
99
+ aztecTargetCommitteeSize: 3
100
+ };
101
+ /**
102
+ * Base class for the prod-sequencer single-node test topology: one node running the production
103
+ * sequencer with fast block times and short epochs, an optional fake-proof prover node, and the
104
+ * environment it runs in (in-proc anvil + L1 deploy). Owns node spawning
105
+ * (`createNonValidatorNode` / `createProverNode` incl. the mock-gossip `p2pServiceFactory` wiring,
106
+ * which is harmless with a single node), the `ChainMonitor`, and the epoch / proof-window / reorg
107
+ * waiters and assertion helpers shared by every test in the category.
108
+ *
109
+ * {@link MultiNodeTestContext} extends this with the N-validator topology (validator-node spawning,
110
+ * committee/proposal/attestation convergence helpers). Single-node-topology tests use this base
111
+ * directly from the sibling `single-node/` category.
112
+ */ export class SingleNodeTestContext {
113
+ context;
114
+ l1Client;
115
+ rollup;
116
+ constants;
117
+ logger;
118
+ monitor;
119
+ epochCache;
120
+ proverDelayer;
121
+ sequencerDelayer;
122
+ proverNodes = [];
123
+ nodes = [];
124
+ epochDuration;
125
+ L1_BLOCK_TIME_IN_S;
126
+ L2_SLOT_DURATION_IN_S;
127
+ static async setup(opts = {}) {
128
+ const test = new this();
129
+ await test.setup(opts);
130
+ return test;
131
+ }
132
+ static getSlotDurations(opts = {}) {
133
+ const envEthereumSlotDuration = process.env.L1_BLOCK_TIME ? parseInt(process.env.L1_BLOCK_TIME) : DEFAULT_L1_BLOCK_TIME;
134
+ const ethereumSlotDuration = opts.ethereumSlotDuration ?? envEthereumSlotDuration;
135
+ const aztecSlotDuration = opts.aztecSlotDuration ?? (opts.aztecSlotDurationInL1Slots ?? 2) * ethereumSlotDuration;
136
+ const aztecEpochDuration = opts.aztecEpochDuration ?? 6;
137
+ const aztecProofSubmissionEpochs = opts.aztecProofSubmissionEpochs ?? 1;
138
+ return {
139
+ ethereumSlotDuration,
140
+ aztecSlotDuration,
141
+ aztecEpochDuration,
142
+ aztecProofSubmissionEpochs
143
+ };
144
+ }
145
+ async setup(opts = {}) {
146
+ const { ethereumSlotDuration, aztecSlotDuration, aztecEpochDuration, aztecProofSubmissionEpochs } = SingleNodeTestContext.getSlotDurations(opts);
147
+ // Auto-create a hardcoded account funded via genesis when:
148
+ // - skipInitialSequencer is set (no sequencer to deploy on-chain), or
149
+ // - useHardcodedAccount is explicitly requested (e.g. tight per-block gas budgets that
150
+ // can't fit a full account-deploy tx).
151
+ const useHardcodedAccount = (opts.skipInitialSequencer || opts.useHardcodedAccount) && !opts.skipHardcodedAccount;
152
+ let hardcodedAccountData;
153
+ if (useHardcodedAccount) {
154
+ hardcodedAccountData = await SingleNodeTestContext.getHardcodedAccountData(Fr.random(), Fr.random());
155
+ }
156
+ // Set up system without any account nor protocol contracts
157
+ // and with faster block times and shorter epochs.
158
+ const context = await setup(useHardcodedAccount ? 0 : opts.numberOfAccounts ?? 0, {
159
+ automineL1Setup: true,
160
+ checkIntervalMs: 50,
161
+ archiverPollingIntervalMS: ARCHIVER_POLL_INTERVAL,
162
+ worldStateBlockCheckIntervalMS: WORLD_STATE_BLOCK_CHECK_INTERVAL,
163
+ aztecEpochDuration,
164
+ aztecSlotDuration,
165
+ ethereumSlotDuration,
166
+ aztecProofSubmissionEpochs,
167
+ aztecTargetCommitteeSize: opts.initialValidators?.length ?? 0,
168
+ minTxsPerBlock: 0,
169
+ realProofs: false,
170
+ startProverNode: true,
171
+ proverTestDelayMs: opts.proverTestDelayMs ?? 0,
172
+ proverId: EthAddress.fromNumber(1),
173
+ worldStateCheckpointHistory: WORLD_STATE_CHECKPOINT_HISTORY,
174
+ exitDelaySeconds: DefaultL1ContractsConfig.exitDelaySeconds,
175
+ slasherEnabled: false,
176
+ // `inboxLag: 2` is the intended value when running with pipelining (the production config
177
+ // default of 1 is a separate bug). Set before `...opts` so tests can still override.
178
+ inboxLag: 2,
179
+ ...opts,
180
+ ...hardcodedAccountData ? {
181
+ additionallyFundedAccounts: [
182
+ hardcodedAccountData
183
+ ],
184
+ numberOfAccounts: 0
185
+ } : {}
186
+ }, // Use checkpointed chain tip for PXE by default to avoid issues with blocks being dropped due to pruned anchor blocks.
187
+ // Can be overridden via opts.pxeOpts.
188
+ {
189
+ syncChainTip: 'checkpointed',
190
+ ...opts.pxeOpts
191
+ });
192
+ // Register the hardcoded account in PXE (local only, no on-chain deployment needed).
193
+ if (hardcodedAccountData) {
194
+ this.context = context;
195
+ await this.registerHardcodedAccount(hardcodedAccountData);
196
+ }
197
+ await this.hydrateFromContext(context);
198
+ }
199
+ /**
200
+ * Populates the context-derived state (tracked nodes, L1 client, rollup, epoch cache, chain
201
+ * monitor, delayers, timing constants) from an already-built {@link EndToEndContext}. Split out of
202
+ * {@link setup} so prover-specific subclasses that build the environment with their own bespoke
203
+ * `setup(...)` opts (e.g. `FullProverTest`) can still reuse the base node/teardown machinery
204
+ * without inheriting the base's default node config. Slot/epoch durations are read from the
205
+ * resolved `context.config` so the recorded constants match whatever the environment was deployed
206
+ * with.
207
+ */ async hydrateFromContext(context) {
208
+ this.context = context;
209
+ const { ethereumSlotDuration, aztecSlotDuration, aztecEpochDuration } = context.config;
210
+ this.L1_BLOCK_TIME_IN_S = ethereumSlotDuration;
211
+ this.L2_SLOT_DURATION_IN_S = aztecSlotDuration;
212
+ this.proverNodes = context.proverNode ? [
213
+ context.proverNode
214
+ ] : [];
215
+ this.nodes = context.aztecNode ? [
216
+ context.aztecNode
217
+ ] : [];
218
+ this.logger = context.logger;
219
+ this.l1Client = context.deployL1ContractsValues.l1Client;
220
+ this.rollup = RollupContract.getFromConfig(context.config);
221
+ this.epochCache = await EpochCache.create(this.rollup, context.config, {
222
+ dateProvider: context.dateProvider
223
+ });
224
+ // Loop that tracks L1 and L2 block numbers and logs whenever there's a new one.
225
+ this.monitor = new ChainMonitor(this.rollup, context.dateProvider, this.logger).start();
226
+ this.proverDelayer = context.proverDelayer;
227
+ this.sequencerDelayer = context.sequencerDelayer;
228
+ if (context.proverNode && !this.proverDelayer || context.sequencer && !this.sequencerDelayer) {
229
+ throw new Error(`Could not find prover or sequencer delayer`);
230
+ }
231
+ // Constants used for time calculation
232
+ this.epochDuration = aztecEpochDuration;
233
+ this.constants = {
234
+ epochDuration: aztecEpochDuration,
235
+ slotDuration: aztecSlotDuration,
236
+ l1StartBlock: await this.rollup.getL1StartBlock(),
237
+ l1GenesisTime: await this.rollup.getL1GenesisTime(),
238
+ ethereumSlotDuration,
239
+ proofSubmissionEpochs: Number(await this.rollup.getProofSubmissionEpochs()),
240
+ targetCommitteeSize: await this.rollup.getTargetCommitteeSize(),
241
+ rollupManaLimit: Number(await this.rollup.getManaLimit())
242
+ };
243
+ this.logger.info(`L2 genesis at L1 block ${this.constants.l1StartBlock} (timestamp ${this.constants.l1GenesisTime})`);
244
+ }
245
+ async teardown() {
246
+ await this.monitor.stop();
247
+ await Promise.all(this.proverNodes.map((node)=>tryStop(node, this.logger)));
248
+ await Promise.all(this.nodes.map((node)=>tryStop(node, this.logger)));
249
+ await this.context.teardown();
250
+ }
251
+ /**
252
+ * Computes InitialAccountData for a SchnorrHardcodedKeyAccountContract.
253
+ * This contract has a hardcoded signing key and no initializer, so it can be used without
254
+ * on-chain deployment. Pass the returned data in `additionallyFundedAccounts` so the address
255
+ * gets funded with fee juice in genesis.
256
+ */ static async getHardcodedAccountData(secret, salt) {
257
+ const contract = new SchnorrHardcodedKeyAccountContract();
258
+ const address = await getAccountContractAddress(contract, secret, salt);
259
+ const signingKey = SCHNORR_HARDCODED_PRIVATE_KEY;
260
+ return {
261
+ secret,
262
+ salt,
263
+ signingKey,
264
+ address
265
+ };
266
+ }
267
+ /**
268
+ * Registers a SchnorrHardcodedKeyAccountContract in PXE. The account must have been funded
269
+ * at genesis (via getHardcodedAccountData). No on-chain deployment or block mining needed.
270
+ */ async registerHardcodedAccount(accountData) {
271
+ const contract = new SchnorrHardcodedKeyAccountContract();
272
+ const wallet = this.context.wallet;
273
+ const accountManager = await wallet.createAccount({
274
+ secret: accountData.secret,
275
+ salt: accountData.salt,
276
+ contract
277
+ });
278
+ this.context.accounts = [
279
+ accountManager.address
280
+ ];
281
+ return accountManager.address;
282
+ }
283
+ async createProverNode(opts = {}) {
284
+ this.logger.warn('Creating and syncing a simulated prover node...');
285
+ const proverNodePrivateKey = this.getNextPrivateKey();
286
+ const proverIndex = this.proverNodes.length + 1;
287
+ const { mockGossipSubNetwork } = this.context;
288
+ const { proverNode } = await testSpan('setup:node', ()=>withLoggerBindings({
289
+ actor: `prover-${proverIndex}`
290
+ }, ()=>createAndSyncProverNode(proverNodePrivateKey, {
291
+ ...this.context.config,
292
+ p2pEnabled: this.context.config.p2pEnabled || mockGossipSubNetwork !== undefined,
293
+ proverId: EthAddress.fromNumber(proverIndex),
294
+ dontStart: opts.dontStart,
295
+ ...opts
296
+ }, {
297
+ dataDirectory: join(this.context.config.dataDirectory, randomBytes(8).toString('hex'))
298
+ }, {
299
+ dateProvider: this.context.dateProvider,
300
+ p2pClientDeps: {
301
+ p2pServiceFactory: mockGossipSubNetwork ? getMockPubSubP2PServiceFactory(mockGossipSubNetwork) : undefined,
302
+ rpcTxProviders: [
303
+ this.context.aztecNode
304
+ ]
305
+ }
306
+ }, {
307
+ genesis: this.context.genesis,
308
+ dontStart: opts.dontStart
309
+ })));
310
+ this.proverNodes.push(proverNode);
311
+ return proverNode;
312
+ }
313
+ createNonValidatorNode(opts = {}) {
314
+ this.logger.warn('Creating and syncing a node without a validator...');
315
+ return this.createNode({
316
+ ...opts,
317
+ disableValidator: true
318
+ });
319
+ }
320
+ async createNode(opts = {}) {
321
+ const nodeIndex = this.nodes.length + 1;
322
+ const actorPrefix = opts.disableValidator ? 'node' : 'validator';
323
+ const { mockGossipSubNetwork } = this.context;
324
+ const resolvedConfig = {
325
+ ...this.context.config,
326
+ ...opts
327
+ };
328
+ const p2pEnabled = resolvedConfig.p2pEnabled || mockGossipSubNetwork !== undefined;
329
+ const p2pIp = resolvedConfig.p2pIp ?? (p2pEnabled ? '127.0.0.1' : undefined);
330
+ const node = await testSpan('setup:node', ()=>withLoggerBindings({
331
+ actor: `${actorPrefix}-${nodeIndex}`
332
+ }, ()=>createAztecNodeService({
333
+ ...resolvedConfig,
334
+ dataDirectory: join(this.context.config.dataDirectory, randomBytes(8).toString('hex')),
335
+ validatorPrivateKeys: opts.validatorPrivateKeys ?? new SecretValue([]),
336
+ nodeId: resolvedConfig.nodeId || `${actorPrefix}-${nodeIndex}`,
337
+ p2pEnabled,
338
+ p2pIp
339
+ }, {
340
+ dateProvider: this.context.dateProvider,
341
+ p2pClientDeps: {
342
+ p2pServiceFactory: mockGossipSubNetwork ? getMockPubSubP2PServiceFactory(mockGossipSubNetwork) : undefined
343
+ },
344
+ slashingProtectionDb: opts.slashingProtectionDb
345
+ }, {
346
+ genesis: this.context.genesis,
347
+ ...opts
348
+ })));
349
+ this.nodes.push(node);
350
+ return node;
351
+ }
352
+ getNextPrivateKey() {
353
+ const key = getPrivateKeyFromIndex(this.nodes.length + this.proverNodes.length + 1);
354
+ return `0x${key.toString('hex')}`;
355
+ }
356
+ /** Waits until the epoch begins (ie until the immediately previous L1 block is mined). */ async waitUntilEpochStarts(epoch) {
357
+ const [start] = getTimestampRangeForEpoch(EpochNumber(epoch), this.constants);
358
+ this.logger.info(`Waiting until L1 timestamp ${start} is reached as the start of epoch ${epoch}`);
359
+ // Cover at least two full epochs of wall time so callers issuing the wait mid-epoch
360
+ // still have headroom — the prior `30 * epochDuration` mixed units (slots vs seconds)
361
+ // and timed out at 120s for configs whose epoch wall time is 144s+.
362
+ await testSpan('wait:epoch', ()=>waitUntilL1Timestamp(this.l1Client, start - BigInt(this.L1_BLOCK_TIME_IN_S), undefined, 2 * this.epochDuration * this.L2_SLOT_DURATION_IN_S));
363
+ return start;
364
+ }
365
+ /**
366
+ * Waits until the next epoch boundary and returns that epoch's number. Anchors tests
367
+ * on a guaranteed-fresh epoch regardless of how much wall time `beforeEach` consumed —
368
+ * `waitUntilEpochStarts(1)` returns immediately when the chain has already advanced past
369
+ * slot 4, which under CI load can leave only seconds of the target epoch remaining.
370
+ *
371
+ * If the chain has more than two slots of headroom before the target boundary, warps
372
+ * the L1 clock to within two slots of the boundary instead of waiting in wall-clock.
373
+ * The two-slot tail is intentional — it lets the sequencer/builder settle so the first
374
+ * checkpoint of the target epoch lands correctly.
375
+ */ async waitUntilNextEpochStarts() {
376
+ const { epoch } = this.epochCache.getEpochAndSlotNow();
377
+ const target = EpochNumber(Number(epoch) + 1);
378
+ const [targetTs] = getTimestampRangeForEpoch(target, this.constants);
379
+ const safeTs = targetTs - BigInt(2 * this.L2_SLOT_DURATION_IN_S);
380
+ const currentTs = BigInt(await this.context.cheatCodes.eth.lastBlockTimestamp());
381
+ if (currentTs < safeTs) {
382
+ this.logger.info(`Warping L1 from ${currentTs} to ${safeTs} (2 slots before epoch ${target})`);
383
+ await this.context.cheatCodes.eth.warp(Number(safeTs), {
384
+ resetBlockInterval: true
385
+ });
386
+ }
387
+ await this.waitUntilEpochStarts(Number(target));
388
+ return target;
389
+ }
390
+ /**
391
+ * Warps the L1 clock to within `leadSlots` slots of the start of `epoch`, then waits for that boundary in
392
+ * wall-clock, skipping the dead stretch where the chain just advances one L1 block per slot until an epoch
393
+ * ends. Anything the post-warp assertions depend on must already be produced before calling this — warping
394
+ * the tail away does not change what gets proven, and the shared `TestDateProvider` moves the
395
+ * prover/node/sequencer clocks together so the epoch finalizes right after the warp. The `leadSlots` tail
396
+ * (default 2) is left in real time so the sequencer can publish the epoch's final checkpoint before the
397
+ * boundary, and so any post-warp sampler observes an in-epoch slot rather than the epoch's last slot.
398
+ * Forward-only, so a no-op when already within `leadSlots` of the boundary.
399
+ */ async warpToEpochStart(epoch, opts = {}) {
400
+ const leadSlots = opts.leadSlots ?? 2;
401
+ const [targetTs] = getTimestampRangeForEpoch(EpochNumber(epoch), this.constants);
402
+ const safeTs = targetTs - BigInt(leadSlots * this.L2_SLOT_DURATION_IN_S);
403
+ const currentTs = BigInt(await this.context.cheatCodes.eth.lastBlockTimestamp());
404
+ if (currentTs < safeTs) {
405
+ this.logger.info(`Warping L1 from ${currentTs} to ${safeTs} (${leadSlots} slots before epoch ${epoch})`);
406
+ await this.context.cheatCodes.eth.warp(Number(safeTs), {
407
+ resetBlockInterval: true
408
+ });
409
+ }
410
+ return this.waitUntilEpochStarts(epoch);
411
+ }
412
+ /**
413
+ * Most of a proof-submission window is dead wall-clock time, so warp the L1 clock forward to `leadSlots`
414
+ * (default 2) L2 slots before the window's last slot. A subsequent
415
+ * {@link waitUntilLastSlotOfProofSubmissionWindow} then only sleeps out the few remaining real slots,
416
+ * leaving enough real time for any in-flight proving, pruning, and recovery to happen organically. Only
417
+ * warps forward, so it is a no-op when the chain is already within `leadSlots`+1 slots of the window end.
418
+ */ async warpNearSubmissionWindowEnd(epoch, opts = {}) {
419
+ const leadSlots = opts.leadSlots ?? 2;
420
+ const { slotDuration } = this.constants;
421
+ const deadline = getProofSubmissionDeadlineTimestamp(EpochNumber(epoch), this.constants);
422
+ // Mirror waitUntilLastSlotOfProofSubmissionWindow's target (one slot before the deadline).
423
+ const lastSlotTs = deadline - BigInt(slotDuration);
424
+ const target = lastSlotTs - BigInt(leadSlots * slotDuration);
425
+ const currentTs = BigInt(await this.context.cheatCodes.eth.lastBlockTimestamp());
426
+ if (currentTs < target) {
427
+ this.logger.warn(`Warping L1 to ${leadSlots} slots before end of epoch ${epoch} submission window`, {
428
+ currentTs,
429
+ target,
430
+ epoch
431
+ });
432
+ await this.context.cheatCodes.eth.warp(Number(target), {
433
+ resetBlockInterval: true
434
+ });
435
+ }
436
+ }
437
+ /** Waits until the given checkpoint number is mined. */ async waitUntilCheckpointNumber(target, timeout = 120) {
438
+ await testSpan('wait:checkpoint', ()=>retryUntil(()=>Promise.resolve(target <= this.monitor.checkpointNumber), `Wait until checkpoint ${target}`, timeout, 0.1));
439
+ }
440
+ /** Waits until the given checkpoint number is marked as proven. */ async waitUntilProvenCheckpointNumber(target, timeout = 120) {
441
+ await testSpan('wait:proven-checkpoint', ()=>retryUntil(()=>Promise.resolve(target <= this.monitor.provenCheckpointNumber), `Wait proven checkpoint ${target}`, timeout, 0.1));
442
+ return this.monitor.provenCheckpointNumber;
443
+ }
444
+ /** Waits until the last slot of the proof submission window for a given epoch. */ async waitUntilLastSlotOfProofSubmissionWindow(epochNumber) {
445
+ const deadline = getProofSubmissionDeadlineTimestamp(EpochNumber.fromBigInt(BigInt(epochNumber)), this.constants);
446
+ const oneSlotBefore = deadline - BigInt(this.constants.slotDuration);
447
+ const date = new Date(Number(oneSlotBefore) * 1000);
448
+ this.logger.info(`Waiting until last slot of submission window for epoch ${epochNumber} at ${date}`, {
449
+ oneSlotBefore
450
+ });
451
+ // Use a timeout that accounts for the full proof submission window
452
+ const proofSubmissionWindowDuration = this.constants.proofSubmissionEpochs * this.epochDuration * this.L2_SLOT_DURATION_IN_S;
453
+ await testSpan('wait:proof-window', ()=>waitUntilL1Timestamp(this.l1Client, oneSlotBefore, undefined, proofSubmissionWindowDuration * 2));
454
+ }
455
+ /**
456
+ * Timestamp one L1 block before L2 `slot` begins — the instant a pipelined proposer starts
457
+ * building for that slot. `opts.lead` overrides the default one-L1-block lead (e.g. when a test
458
+ * needs an extra block-duration margin to guarantee sub-slot 1 is reachable).
459
+ */ buildWindowTimestampForSlot(slot, opts = {}) {
460
+ const lead = opts.lead ?? this.L1_BLOCK_TIME_IN_S;
461
+ return getTimestampForSlot(slot, this.constants) - BigInt(lead);
462
+ }
463
+ /**
464
+ * Warps the L1 clock to the build window of `slot` (one L1 block before the slot begins) with
465
+ * `resetBlockInterval`, so a pipelined proposer engages cleanly when its sequencer starts.
466
+ * @returns The slot warped to.
467
+ */ async warpToBuildWindowForSlot(slot) {
468
+ const target = this.buildWindowTimestampForSlot(slot);
469
+ this.logger.info(`Warping L1 to build window of slot ${slot}`, {
470
+ slot,
471
+ target
472
+ });
473
+ await this.context.cheatCodes.eth.warp(Number(target), {
474
+ resetBlockInterval: true
475
+ });
476
+ return slot;
477
+ }
478
+ /**
479
+ * Waits (in wall-clock, without warping) until the L1 clock reaches the build window of `slot`.
480
+ * For production-sequencer tests that can't warp. `opts.lead` extends the lead beyond the default
481
+ * one L1 block; `opts.timeout` bounds the wait (defaults to three L2 slots).
482
+ * @returns The slot waited for.
483
+ */ async waitForBuildWindowForSlot(slot, opts = {}) {
484
+ const target = this.buildWindowTimestampForSlot(slot, {
485
+ lead: opts.lead
486
+ });
487
+ const timeout = opts.timeout ?? this.L2_SLOT_DURATION_IN_S * 3;
488
+ this.logger.info(`Waiting until L1 reaches build window of slot ${slot}`, {
489
+ slot,
490
+ target
491
+ });
492
+ await testSpan('wait:slot', ()=>waitUntilL1Timestamp(this.l1Client, target, undefined, timeout));
493
+ return slot;
494
+ }
495
+ /** Waits for the aztec node to sync to the target block number. */ async waitForNodeToSync(blockNumber, type) {
496
+ const waitTime = ARCHIVER_POLL_INTERVAL + WORLD_STATE_BLOCK_CHECK_INTERVAL;
497
+ await testSpan('wait:node-sync', async ()=>{
498
+ let synched = false;
499
+ while(!synched){
500
+ await sleep(waitTime);
501
+ const [syncState, tips] = await Promise.all([
502
+ this.context.aztecNode.getWorldStateSyncStatus(),
503
+ await this.context.aztecNode.getChainTips()
504
+ ]);
505
+ this.logger.info(`Wait for node synch ${blockNumber} ${type}`, {
506
+ blockNumber,
507
+ type,
508
+ syncState,
509
+ tips
510
+ });
511
+ if (type === 'proven') {
512
+ synched = tips.proven.block.number >= blockNumber && syncState.latestBlockNumber >= blockNumber;
513
+ } else if (type === 'finalized') {
514
+ synched = syncState.finalizedBlockNumber >= blockNumber;
515
+ } else {
516
+ synched = syncState.oldestHistoricBlockNumber >= blockNumber;
517
+ }
518
+ }
519
+ });
520
+ }
521
+ /**
522
+ * Waits until every prover node has submitted a proof for `epoch` (of length `epochLength`
523
+ * checkpoints) on L1. Polls `rollup.getHasSubmittedProof` for each prover registered in
524
+ * {@link proverNodes}.
525
+ */ async waitForAllProversToSubmit(epoch, epochLength, opts = {}) {
526
+ const proverIds = this.proverNodes.map((node)=>node.getProverNode().getProverId());
527
+ await testSpan('wait:proof-submitted', ()=>retryUntil(async ()=>{
528
+ const haveSubmitted = await Promise.all(proverIds.map((proverId)=>this.rollup.getHasSubmittedProof(epoch, epochLength, proverId)));
529
+ this.logger.info(`Proof submissions: ${haveSubmitted.join(', ')}`);
530
+ return haveSubmitted.every((submitted)=>submitted);
531
+ }, 'Provers have submitted proofs', opts.timeout ?? 120));
532
+ }
533
+ /** Registers the SpamContract on the given wallet. */ async registerSpamContract(wallet, salt = Fr.ZERO) {
534
+ const instance = await getContractInstanceFromInstantiationParams(SpamContract.artifact, {
535
+ constructorArgs: [],
536
+ constructorArtifact: undefined,
537
+ salt,
538
+ publicKeys: undefined,
539
+ deployer: undefined
540
+ });
541
+ await wallet.registerContract(instance, SpamContract.artifact);
542
+ return SpamContract.at(instance.address, wallet);
543
+ }
544
+ /** Registers the TestContract on the given wallet. */ async registerTestContract(wallet, salt = Fr.ZERO) {
545
+ const instance = await getContractInstanceFromInstantiationParams(TestContract.artifact, {
546
+ constructorArgs: [],
547
+ constructorArtifact: undefined,
548
+ salt,
549
+ publicKeys: undefined,
550
+ deployer: undefined
551
+ });
552
+ await wallet.registerContract(instance, TestContract.artifact);
553
+ return TestContract.at(instance.address, wallet);
554
+ }
555
+ /** Creates an L1 client using a fresh account with funds from anvil, with a tx delayer already set up. */ async createL1Client() {
556
+ const rawClient = createExtendedL1Client([
557
+ ...this.l1Client.chain.rpcUrls.default.http
558
+ ], privateKeyToAccount(this.getNextPrivateKey()), this.l1Client.chain);
559
+ const delayer = createDelayer(this.context.dateProvider, {
560
+ ethereumSlotDuration: this.L1_BLOCK_TIME_IN_S
561
+ }, {});
562
+ const client = wrapClientWithDelayer(rawClient, delayer);
563
+ expect(await client.getBalance({
564
+ address: client.account.address
565
+ })).toBeGreaterThan(0n);
566
+ return {
567
+ client,
568
+ delayer
569
+ };
570
+ }
571
+ /** Verifies whether the given block number is found on the aztec node. */ async verifyHistoricBlock(blockNumber, expectedSuccess) {
572
+ // We use `findLeavesIndexes` here, but could use any function that queries the world-state
573
+ // at a particular block, so we know whether that historic block is available or has been
574
+ // pruned. Note that `getBlock` would not work here, since it only hits the archiver.
575
+ const result = await this.context.aztecNode.findLeavesIndexes(blockNumber, MerkleTreeId.NULLIFIER_TREE, [
576
+ Fr.ZERO
577
+ ]).then((_)=>true).catch((_)=>false);
578
+ expect(result).toBe(expectedSuccess);
579
+ }
580
+ /**
581
+ * Verifies that at least one checkpoint has `targetBlockCount` blocks and that block numbering is
582
+ * contiguous within every checkpoint (MBPS validation).
583
+ *
584
+ * Two optional wait modes (both poll before reading checkpoints):
585
+ * - `opts.wait`: waits until some checkpoint reaches `targetBlockCount` blocks (the proposed-tip
586
+ * MBPS setup case), and
587
+ * - `opts.targetBlock`: waits until the archiver's checkpointed tip reaches that block number
588
+ * (the pipeline-prune recovery case).
589
+ *
590
+ * Reads from `opts.archiver` when given (e.g. a specific validator node's block source); otherwise
591
+ * from the initial node's archiver.
592
+ * @returns The number of the first checkpoint with at least `targetBlockCount` blocks.
593
+ */ async assertMultipleBlocksPerSlot(targetBlockCount, opts = {}) {
594
+ const archiver = opts.archiver ?? this.context.aztecNode.getBlockSource();
595
+ const waitTimeout = opts.timeout ?? this.L2_SLOT_DURATION_IN_S * 3;
596
+ if (opts.targetBlock !== undefined) {
597
+ const targetBlock = opts.targetBlock;
598
+ await retryUntil(async ()=>{
599
+ const checkpointed = await archiver.getBlockNumber({
600
+ tag: 'checkpointed'
601
+ });
602
+ return checkpointed !== undefined && checkpointed >= targetBlock;
603
+ }, `archiver checkpointed block ${targetBlock}`, 10, 0.1);
604
+ }
605
+ if (opts.wait) {
606
+ await retryUntil(async ()=>{
607
+ const found = await archiver.getCheckpoints({
608
+ from: CheckpointNumber(1),
609
+ limit: 50
610
+ });
611
+ return found.some((pc)=>pc.checkpoint.blocks.length >= targetBlockCount) || undefined;
612
+ }, `checkpoint with at least ${targetBlockCount} blocks`, waitTimeout, 0.5);
613
+ }
614
+ const checkpoints = await archiver.getCheckpoints({
615
+ from: CheckpointNumber(1),
616
+ limit: 50
617
+ });
618
+ this.logger.warn(`Retrieved ${checkpoints.length} checkpoints from archiver`, {
619
+ checkpoints: checkpoints.map((pc)=>pc.checkpoint.getStats())
620
+ });
621
+ let expectedBlockNumber = checkpoints[0].checkpoint.blocks[0].number;
622
+ let multiBlockCheckpointNumber;
623
+ for (const checkpoint of checkpoints){
624
+ const blockCount = checkpoint.checkpoint.blocks.length;
625
+ if (blockCount >= targetBlockCount && multiBlockCheckpointNumber === undefined) {
626
+ multiBlockCheckpointNumber = checkpoint.checkpoint.number;
627
+ }
628
+ this.logger.verbose(`Checkpoint ${checkpoint.checkpoint.number} has ${blockCount} blocks`, {
629
+ checkpoint: checkpoint.checkpoint.getStats()
630
+ });
631
+ for(let i = 0; i < blockCount; i++){
632
+ const block = checkpoint.checkpoint.blocks[i];
633
+ expect(block.indexWithinCheckpoint).toBe(i);
634
+ expect(block.checkpointNumber).toBe(checkpoint.checkpoint.number);
635
+ expect(block.number).toBe(expectedBlockNumber);
636
+ expectedBlockNumber++;
637
+ }
638
+ }
639
+ expect(multiBlockCheckpointNumber).toBeDefined();
640
+ return multiBlockCheckpointNumber;
641
+ }
642
+ /**
643
+ * Asserts pipelining by comparing the build slot (from block-proposed events) against the
644
+ * submission slot (from block headers). With pipelining, the block is built in slot N but its
645
+ * header carries submission slot N+1. Also checks each block's coinbase matches the expected
646
+ * proposer for its submission slot. Reads checkpoints from `archiver` (typically a validator
647
+ * node's block source).
648
+ */ async assertProposerPipelining(archiver, blockProposedEvents, logger) {
649
+ const checkpoints = await archiver.getCheckpoints({
650
+ from: CheckpointNumber(1),
651
+ limit: 50
652
+ });
653
+ const allBlocks = checkpoints.flatMap((pc)=>pc.checkpoint.blocks);
654
+ logger.warn(`assertProposerPipelining: ${allBlocks.length} blocks, ${blockProposedEvents.length} events`, {
655
+ blockNumbers: allBlocks.map((b)=>b.number),
656
+ eventBlockNumbers: blockProposedEvents.map((e)=>e.blockNumber)
657
+ });
658
+ let foundPipelining = false;
659
+ for (const block of allBlocks){
660
+ const headerSlot = block.header.globalVariables.slotNumber; // submission slot (N+1)
661
+ const coinbase = block.header.globalVariables.coinbase;
662
+ // Find the block-proposed event for this block (use Number() for safe comparison)
663
+ const event = blockProposedEvents.find((e)=>Number(e.blockNumber) === Number(block.number));
664
+ // if there is no event, then it was probably block number one - which was proposed in setup
665
+ if (!event) {
666
+ continue;
667
+ }
668
+ const buildSlot = event.buildSlot; // build slot (N)
669
+ // Verify the pipelining offset: block built in slot N, submitted in slot N+1
670
+ expect(Number(headerSlot)).toBe(Number(buildSlot) + 1);
671
+ foundPipelining = true;
672
+ // Verify coinbase matches the expected proposer for the submission slot
673
+ const expectedProposer = await this.rollup.getProposerAt(getTimestampForSlot(headerSlot, this.constants));
674
+ expect(coinbase).toEqual(expectedProposer);
675
+ logger.warn(`Block ${block.number}: buildSlot=${buildSlot}, submissionSlot=${headerSlot}, coinbase=${coinbase}`, {
676
+ blockNumber: block.number,
677
+ buildSlot,
678
+ headerSlot,
679
+ coinbase: coinbase.toString(),
680
+ expectedProposer: expectedProposer.toString()
681
+ });
682
+ }
683
+ expect(foundPipelining).toBe(true);
684
+ logger.warn(`Pipelining assertion passed for ${allBlocks.length} blocks`);
685
+ }
686
+ watchSequencerEvents(sequencers, getMetadata = ()=>({}), additionalFailEventKeys = []) {
687
+ const stateChanges = [];
688
+ const failEvents = [];
689
+ // Note we do not include the 'block-tx-count-check-failed' event here, since it is fine if we dont build
690
+ // due to lack of txs available.
691
+ const failEventsKeys = [
692
+ 'block-build-failed',
693
+ 'checkpoint-publish-failed',
694
+ 'proposer-rollup-check-failed',
695
+ 'checkpoint-error',
696
+ 'checkpoint-publish-failed',
697
+ 'header-validation-failed',
698
+ 'pipelined-checkpoint-discarded',
699
+ ...additionalFailEventKeys
700
+ ];
701
+ const makeEvent = (i, eventName, args)=>({
702
+ ...args,
703
+ type: eventName,
704
+ sequencerIndex: i + 2,
705
+ ...getMetadata(i)
706
+ });
707
+ sequencers.forEach((sequencer, i)=>{
708
+ const sequencerIndex = i + 2;
709
+ sequencer.getSequencer().on('state-changed', (args)=>{
710
+ const noisyStates = [
711
+ SequencerState.IDLE,
712
+ SequencerState.PROPOSER_CHECK,
713
+ SequencerState.SYNCHRONIZING
714
+ ];
715
+ if (!noisyStates.includes(args.newState)) {
716
+ const evt = makeEvent(i, 'state-changed', args);
717
+ stateChanges.push(evt);
718
+ this.logger.verbose(`Sequencer ${sequencerIndex} transitioned from state ${args.oldState} to state ${args.newState}`, evt);
719
+ }
720
+ });
721
+ failEventsKeys.forEach((eventName)=>{
722
+ sequencer.getSequencer().on(eventName, (args)=>{
723
+ // Skip benign block-build-failed events where the builder rejected the block because it
724
+ // could not collect enough valid txs. This is the same "not enough txs" case as
725
+ // block-tx-count-check-failed (which is already excluded above), just detected after we
726
+ // started processing txs rather than before.
727
+ if (eventName === 'block-build-failed' && args.reason === 'Insufficient valid txs') {
728
+ return;
729
+ }
730
+ const evt = makeEvent(i, eventName, args);
731
+ failEvents.push(evt);
732
+ this.logger.error(`Failed event ${eventName} from sequencer ${sequencerIndex}`, undefined, evt);
733
+ });
734
+ });
735
+ });
736
+ return {
737
+ failEvents,
738
+ stateChanges
739
+ };
740
+ }
741
+ /**
742
+ * Resolves with the event args the first time `sequencer` emits `event` with args matching
743
+ * `match`. Rejects after `opts.timeout` ms (default 60s). Wraps the
744
+ * `executeTimeout(signal => new Promise(...))` one-shot subscription boilerplate, cleaning up
745
+ * the listener on both the resolve and the abort paths.
746
+ */ waitForSequencerEvent(sequencer, event, match = ()=>true, opts = {}) {
747
+ const timeout = opts.timeout ?? 60_000;
748
+ return testSpan('wait:sequencer-state', ()=>executeTimeout((signal)=>new Promise((resolve)=>{
749
+ const listener = (args)=>{
750
+ if (match(args)) {
751
+ sequencer.off(event, listener);
752
+ resolve(args);
753
+ }
754
+ };
755
+ signal.addEventListener('abort', ()=>sequencer.off(event, listener), {
756
+ once: true
757
+ });
758
+ sequencer.on(event, listener);
759
+ }), timeout, `wait for sequencer event ${String(event)}`));
760
+ }
761
+ /** Returns the {@link SequencerClient} of each given node, throwing if any node has no sequencer. */ getSequencers(nodes) {
762
+ return nodes.map((node)=>{
763
+ const sequencer = node.getSequencer();
764
+ if (!sequencer) {
765
+ throw new Error('Node has no sequencer');
766
+ }
767
+ return sequencer;
768
+ });
769
+ }
770
+ /** Starts the sequencer on each given node in parallel. */ async startSequencers(nodes) {
771
+ await Promise.all(this.getSequencers(nodes).map((sequencer)=>sequencer.start()));
772
+ }
773
+ /**
774
+ * Resolves once `sequencer` is in `state`, returning immediately if it is already there. Use to
775
+ * flush in-flight work (e.g. wait for `IDLE` so pending L1 publishes have been issued) before
776
+ * sampling chain state. Builds on {@link waitForSequencerEvent} for the not-yet-there path.
777
+ */ async waitForSequencerState(sequencer, state, opts = {}) {
778
+ if (sequencer.status().state === state) {
779
+ return;
780
+ }
781
+ await this.waitForSequencerEvent(sequencer, 'state-changed', (args)=>args.newState === state, opts);
782
+ }
783
+ assertNoFailuresFromSequencers(failEvents) {
784
+ if (failEvents.length > 0) {
785
+ this.logger.error(`Failed events from sequencers`, failEvents);
786
+ }
787
+ expect(failEvents).toEqual([]);
788
+ }
789
+ /**
790
+ * Warps the L1 clock to `target` with every given node's sequencer paused, then resumes them
791
+ * (pass `restart: false` to leave them paused, e.g. until some clock-driven effect is confirmed).
792
+ *
793
+ * Warping the shared date provider under live sequencers interrupts whatever iteration is mid-build,
794
+ * producing spurious `block-build-failed` / `checkpoint-error` events and dropped checkpoints. The
795
+ * sequencers are therefore paused first: the poll loop halts and the in-flight iteration, its pending L1
796
+ * submission, and any pending fallback vote all finish untouched before the warp, so nothing fires with a
797
+ * stale slot afterwards. Pausing leaves the validator clients (and their slashing-protection stores) and
798
+ * publishers running, so a later {@link SequencerClient.start} cleanly resumes; archivers, provers, and
799
+ * the chain monitor keep running throughout, so clock-driven effects of the warp (e.g. an orphan-block
800
+ * prune) still fire.
801
+ *
802
+ * The warp is performed here (rather than via a caller-supplied callback) so it happens only after the
803
+ * pause has drained. Draining can take several slots, so a `target` computed before the pause may already
804
+ * lie in the past by the time the sequencers are down. The warp is therefore skipped when the L1 clock has
805
+ * already reached or passed `target` — `evm_setNextBlockTimestamp` rejects a non-advancing timestamp, so
806
+ * warping there would throw "timestamp in the past".
807
+ */ async warpWithSequencersPaused(nodes, cheatCodes, target, opts = {}) {
808
+ const sequencers = this.getSequencers(nodes);
809
+ await testSpan('warp:sequencers-paused', async ()=>{
810
+ this.logger.warn(`Pausing ${sequencers.length} sequencers before warp`);
811
+ await Promise.all(sequencers.map((sequencer)=>sequencer.pause()));
812
+ const currentTs = BigInt(await cheatCodes.eth.lastBlockTimestamp());
813
+ if (currentTs < target) {
814
+ this.logger.warn(`Warping L1 to ${target} with all sequencers paused`, {
815
+ currentTs,
816
+ target
817
+ });
818
+ await cheatCodes.eth.warp(Number(target), {
819
+ resetBlockInterval: true
820
+ });
821
+ } else {
822
+ this.logger.verbose(`Skipping warp: L1 clock ${currentTs} already at or past target ${target}`, {
823
+ currentTs,
824
+ target
825
+ });
826
+ }
827
+ if (opts.restart ?? true) {
828
+ this.logger.warn(`Resuming ${sequencers.length} sequencers after warp`);
829
+ await Promise.all(sequencers.map((sequencer)=>sequencer.start()));
830
+ }
831
+ });
832
+ }
833
+ }