@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
package/README.md CHANGED
@@ -1,26 +1,229 @@
1
- # End to End
1
+ # End-to-end tests
2
2
 
3
- This package includes end-to-end tests that cover Aztec's main milestones.
4
- These can be run locally either by starting anvil on a different terminal.
3
+ This package holds Aztec's end-to-end (e2e) tests: full-stack scenarios that spin up an Aztec node (or
4
+ several), a PXE, and an L1 (anvil) and exercise the system the way a real deployment would. It is the
5
+ integration layer above the per-package unit tests.
5
6
 
6
- ```
7
- anvil -p 8545 --host 0.0.0.0 --chain-id 31337
8
- ```
7
+ > **Two audiences.** The top of this document is a quick orientation for humans. The
8
+ > [Reference for agents](#reference-for-agents) section at the bottom is the detailed, exhaustive
9
+ > version — read that when you are placing, moving, or wiring up a test.
9
10
 
10
- and then running
11
+ ## Quick start
11
12
 
12
- ```
13
- yarn test
13
+ Run a single test (spawns its own in-process anvil):
14
+
15
+ ```bash
16
+ yarn test:e2e src/automine/token/access_control.parallel.test.ts
17
+ yarn test:e2e src/single-node/block-building/block_building.test.ts -t 'rejects double spend'
14
18
  ```
15
19
 
16
- Or by running
20
+ Turn up logging with `LOG_LEVEL` (`verbose` is the useful default; `debug:sequencer,archiver` scopes it):
17
21
 
22
+ ```bash
23
+ LOG_LEVEL=verbose yarn test:e2e src/single-node/proving/empty_blocks.test.ts
18
24
  ```
19
- yarn test:integration
25
+
26
+ Compose-based tests (those under `src/composed/`) need a running local network — see
27
+ [Compose / HA / web3signer tests](#compose--ha--web3signer-tests).
28
+
29
+ ## Test categories
30
+
31
+ Tests are grouped by **node topology** — the shape of the network a test needs. The top-level folder is
32
+ the category; the second level names the behavior under test. Each category owns a base class that builds
33
+ its environment, so a test file only describes the scenario, not the wiring.
34
+
35
+ | Category | Topology | A test belongs here when… | README |
36
+ |---|---|---|---|
37
+ | [`automine/`](src/automine/README.md) | One node, deterministic `AutomineSequencer` — one block per tx, no committee/prover/validator. Fast. | it exercises contract or protocol behavior that doesn't depend on real block-building or consensus (transfers, nested calls, note discovery, tx semantics). | yes |
38
+ | [`single-node/`](src/single-node/README.md) | One node, production sequencer (interval block production), optional prover. | it asserts on sequencer, proving, partial-proof, L1-reorg, recovery, fee, or cross-chain behavior on a single sequencer. | yes |
39
+ | [`multi-node/`](src/multi-node/README.md) | N validators on an in-memory mock-gossip bus. | it needs a committee: consensus, attestations, slashing, governance, or multi-validator block production. | yes |
40
+ | `p2p/` | Real libp2p transport between nodes. | the networking transport itself is under test (gossip, rediscovery, req/resp). | — |
41
+ | [`infra/`](src/infra/README.md) | Targets a deployed/external network (local anvil or a public testnet). | its concern is deployment or network targeting, not a specific protocol behavior. | yes |
42
+
43
+ A handful of tests live **outside** this package, next to the code they test — see
44
+ [Tests that live elsewhere](#tests-that-live-elsewhere). Other non-category test groups (`composed/`,
45
+ `guides/`, `bench/`) are described in the reference section.
46
+
47
+ ## Where does my test go?
48
+
49
+ 1. **Does it need real networking transport?** → `p2p/`.
50
+ 2. **Does it need a validator committee (consensus/slashing/governance)?** → `multi-node/`.
51
+ 3. **Does it assert on the production sequencer, proving, reorgs, fees, or cross-chain flows?** →
52
+ `single-node/`.
53
+ 4. **Is it pure contract/protocol behavior that's happy with one-block-per-tx?** → `automine/` (the
54
+ default home for most contract tests).
55
+ 5. **Is it really a unit/integration test of one package with no Aztec node?** → it probably belongs in
56
+ that package, not here (see [Tests that live elsewhere](#tests-that-live-elsewhere)).
57
+
58
+ When in doubt, prefer `automine/` for contract behavior and `single-node/` for anything that watches the
59
+ chain advance.
60
+
61
+ ---
62
+
63
+ ## Reference for agents
64
+
65
+ This section is the detailed contract for adding, moving, and wiring tests. It assumes you've read the
66
+ overview above.
67
+
68
+ ### Category base classes
69
+
70
+ Each category centralizes its environment in a base class. The hierarchy:
71
+
72
+ - `single-node/single_node_test_context.ts` → **`SingleNodeTestContext`**. Owns the environment
73
+ (in-process anvil + L1 deploy), node spawning (`createNonValidatorNode`, `createProverNode`), the
74
+ `ChainMonitor`, and the epoch/checkpoint/proof-window/reorg waiters.
75
+ - `multi-node/multi_node_test_context.ts` → **`MultiNodeTestContext extends SingleNodeTestContext`**.
76
+ Adds the N-validator topology over a mock-gossip bus, inheriting the base environment and waiters.
77
+ - `automine/automine_test_context.ts` → **`AutomineTestContext`**. A sibling of `SingleNodeTestContext`
78
+ (both wrap `fixtures/setup.ts:setup()`), but fixes the automine topology and makes `AUTOMINE_E2E_OPTS`
79
+ the default. Exposes `markProvenAndWarp`, `registerContract`, `applyManualParentChild`.
80
+ - `p2p/p2p_network.ts` → **`P2PNetworkTest`**. Real libp2p; node creation goes through
81
+ `setup_p2p_test.ts`.
82
+ - `infra/` has no shared base — its tests target a network selected by `L1_CHAIN_ID` (local anvil in CI,
83
+ a public testnet with credentials).
84
+
85
+ All of the above ultimately wrap `fixtures/setup.ts:setup(numberOfAccounts, opts)`, the single entry point
86
+ that deploys L1 contracts, starts the node(s), and provisions a PXE and accounts.
87
+
88
+ ### Setup factories
89
+
90
+ Categories expose thin factories over their base's static `setup`, named by what the test wants, so a test
91
+ calls the factory instead of spreading option presets:
92
+
93
+ - `single-node/setup.ts`: `setupWithProver` (fake in-process prover — the single-node default) and
94
+ `setupBlockProducer` (no prover; raises `aztecProofSubmissionEpochs` to `1024` so unproven blocks
95
+ aren't pruned, and points the PXE at `syncChainTip: 'proposed'`).
96
+ - `automine` tests call `AutomineTestContext.setup({ numberOfAccounts })` directly.
97
+
98
+ ### The harness pattern (domain setup on top of a category)
99
+
100
+ A test suite with bespoke domain setup does **not** fork `setup()`. It subclasses the category base and
101
+ overrides a `protected hydrateFromContext(context)` split out of `setup`, so it reuses the base's
102
+ rollup/epoch-cache/chain-monitor/waiter/teardown machinery while adding its own domain state. Examples:
103
+
104
+ - `single-node/prover/` → `FullProverTest` (real Barretenberg env) extends `SingleNodeTestContext`.
105
+ - `single-node/fees/` → `FeesTest`; `single-node/cross-chain/` → `CrossChainMessagingTest`.
106
+ - `automine/token/` → `TokenContractTest` and `BlacklistTokenContractTest` extend `AutomineTestContext`
107
+ and run their `TokenSimulator`/snapshot setup after `super.setup()`.
108
+
109
+ When two suites share behavior: if their public APIs are nearly identical, use inheritance; if behavior
110
+ overlaps but APIs differ, compose. Don't duplicate a category's environment wiring.
111
+
112
+ ### The `.parallel` suffix
113
+
114
+ CI splits each `it` in a `.parallel.test.ts` file into its own docker job, running it in isolation via
115
+ `jest --testNamePattern` (the names come from `extract_test_names` in `bootstrap.sh`, which matches
116
+ `it`/`test` at **any** nesting depth, not just top level). When an `it` runs alone its enclosing
117
+ `beforeAll`/`beforeEach` hooks still run, but sibling `it`s do not. Rules:
118
+
119
+ - The `.parallel` suffix is for files whose `it`s are **independent**: every `it` must pass when run
120
+ entirely on its own. That holds only when all shared state is built in `beforeAll`/`beforeEach` and no
121
+ `it` reads or asserts on state produced by a sibling `it`.
122
+ - A file with sequential or stateful `it`s (progressive mutation across `it`s, a describe-scope variable
123
+ assigned in one `it` and read in another, a note/token created in an earlier `it` and used later) stays
124
+ a plain `.test.ts` **even if it has many top-level `it`s** — it runs as one ordered job. Adding
125
+ `.parallel` to such a file breaks CI, because each `it` then runs without its predecessors.
126
+ - A file with a single top-level `it` is a plain `.test.ts`.
127
+ - `it`/`test` names in a `.parallel` file must avoid regex/shell-special characters —
128
+ `"` `(` `)` `[` `]` `{` `}` `$` `\` and backtick. The split passes each name to
129
+ `run_test.sh ... "<name>"` as a shell-quoted `--testNamePattern` regex: an embedded `"` closes the
130
+ quote early and hard-fails the job, while regex metacharacters (`(` `)` `[` `]` `+` `*` `?` `|` `{` `}`)
131
+ silently match zero tests so the shard runs nothing and passes green — a coverage gap that hides the
132
+ test. Plain `.test.ts` files run as one job and are unaffected, so any name is fine there.
133
+ (`.` `!` `#` `-` `:` `,` are safe in `.parallel` names.)
134
+ - Each file has exactly one top-level `describe`, named to match its path
135
+ (e.g. `describe('automine/token/transfer', …)`).
136
+
137
+ ### CI test discovery — `bootstrap.sh`
138
+
139
+ `end-to-end/bootstrap.sh` enumerates tests in two arrays, and a test must appear in the relevant one or it
140
+ **won't run in CI**:
141
+
142
+ - `test_cmds` (~line 37) — the standard run.
143
+ - `compat_test_cmds` (~line 290) — the forward/legacy-compat run (a subset).
144
+
145
+ Each leaf folder needs its own single-level glob line (e.g. `src/automine/token/*.test.ts`) in each array;
146
+ globs are not recursive, so every sub-folder is listed explicitly. Folders that organize by behavior get
147
+ one line per leaf. Bespoke handling to be aware of:
148
+
149
+ - **`avm_simulator`** (`automine/simulation/avm_simulator.test.ts`) has a dedicated line in `test_cmds`
150
+ that sets `DUMP_AVM_INPUTS_TO_DIR` (feeds the downstream `avm_check_circuit` job) and is therefore
151
+ excluded from the generic `simulation/` glob there (`!(avm_simulator)`). In `compat_test_cmds` it runs
152
+ as a regular test (no dump line), so it is **not** excluded there.
153
+ - **`kernelless_simulation`** is excluded from `compat_test_cmds` only.
154
+
155
+ After editing the arrays, confirm every `*.test.ts` resolves through exactly one line (no duplicate, no
156
+ omission). Per-test bash `TIMEOUT` overrides live in the `case` block in `test_cmds` and must stay in sync
157
+ with the test's `jest.setTimeout`.
158
+
159
+ ### Flaky tests — `.test_patterns.yml`
160
+
161
+ Flaky/owner entries live in `.test_patterns.yml` at the **git root** (not in this package), keyed on the
162
+ test path. A bare entry flags the test as flaky whenever it fails; add `error_regex` to flag only on a
163
+ matching message; `skip: true` disables it. Blanket regex entries (e.g. `src/automine/.*\.test\.ts`) are
164
+ depth-agnostic and survive folder renames; path-specific entries must be updated when a file moves.
165
+
166
+ ### Compose / HA / web3signer tests
167
+
168
+ `src/composed/` tests run against a **running local network** rather than an in-process stack, via
169
+ `scripts/run_test.sh` in different modes:
170
+
171
+ - `src/composed/*.test.ts` → `compose` mode (e.g. `e2e_persistence`, `uniswap_trade_on_l1_from_l2`,
172
+ `e2e_cheat_codes` — the compose variant, distinct from the relocated unit-style one).
173
+ - `src/composed/web3signer/*.test.ts` → `web3signer` mode (remote-signer scenarios).
174
+ - `src/composed/ha/*.test.ts` → `ha` mode (high-availability multi-process scenarios).
175
+ - `src/guides/*.test.ts` → tutorial/guide flows; `src/bench/` → benchmarks (see `bench_cmds`).
176
+
177
+ Run one compose test locally with `yarn test:compose <name>` (anvil + the test runner are spawned for
178
+ you), or `docker-compose up` for separate containers.
179
+
180
+ ### Tests that live elsewhere
181
+
182
+ Tests with **no Aztec node** that exercise one package belong in that package, not here:
183
+
184
+ - L1 cheat-code behavior (`EthCheatCodes`/`RollupCheatCodes` against raw anvil) → `@aztec/ethereum`
185
+ (`ethereum/src/test/eth_cheat_codes.test.ts`).
186
+ - The `SequencerPublisher` integration test (anvil + L1 deploy, no node) → `@aztec/sequencer-client`
187
+ (`sequencer-client/src/publisher/`).
188
+
189
+ These run in their own package's test lane (both packages already run anvil-backed integration tests).
190
+
191
+ ### Support directories (not test categories)
192
+
193
+ - `fixtures/` — the shared `setup()`, option presets (`fixtures.ts`), `CrossChainTestHarness`,
194
+ `l1_to_l2_messaging`, and common utils.
195
+ - `shared/` — shared test bodies and `timing_env.mjs`, a **custom jest `testEnvironment`** referenced from
196
+ this package's `package.json`. `yarn prepare` / the package-json check will try to revert it to the
197
+ default — don't let it.
198
+ - `simulators/` — in-TS reference models (`TokenSimulator`, `LendingSimulator`) used to assert contract
199
+ behavior.
200
+ - `test-wallet/`, `bench/`, `spartan/`, `quality_of_service/`, `forward-compatibility/` — helpers,
201
+ benchmarks, and network/ops tests outside the topology categories.
202
+
203
+ ### Running tests against legacy contract artifacts
204
+
205
+ To verify that contracts deployed from a previous release still work against the current stack, set
206
+ `CONTRACT_ARTIFACTS_VERSION` to a published version of `@aztec/noir-contracts.js` /
207
+ `@aztec/noir-test-contracts.js`:
208
+
209
+ ```bash
210
+ CONTRACT_ARTIFACTS_VERSION=4.1.3 yarn test:e2e src/automine/token/access_control.parallel.test.ts
20
211
  ```
21
212
 
22
- which will spawn the two processes.
213
+ Only the JSON artifact files (`.../artifacts/*.json`) are redirected. The TypeScript wrapper classes
214
+ (e.g. `TokenContract`) continue to load from the current workspace and use the current `@aztec/aztec.js` —
215
+ so this exercises whether a deployed contract's ABI / bytecode / notes still work through the *new* client,
216
+ not whether the legacy wrapper code still imports cleanly.
23
217
 
24
- You can also run this by `docker-compose up` which will spawn 2 different containers for Anvil and the test runner.
218
+ The first run downloads the pinned packages into `.legacy-contracts/<version>/node_modules/` (cached across
219
+ runs). A startup banner and a per-redirect line are printed to stderr so you can confirm the legacy
220
+ artifacts were actually loaded:
221
+
222
+ ```
223
+ [legacy-contracts][jest] CONTRACT_ARTIFACTS_VERSION=4.1.3
224
+ [legacy-contracts][jest] redirecting @aztec/noir-contracts.js/artifacts/*.json -> .legacy-contracts/4.1.3/...
225
+ [legacy-contracts][jest] redirected token_contract-Token.json -> /abs/.../.legacy-contracts/4.1.3/.../token_contract-Token.json
226
+ ```
25
227
 
26
- You can run a single test by running `yarn test:compose <test_name>`.
228
+ When `CONTRACT_ARTIFACTS_VERSION` is unset the test run is byte-identical to the default behaviour. The
229
+ cache is populated automatically on first use.
@@ -0,0 +1,85 @@
1
+ import type { ContractArtifact } from '@aztec/aztec.js/abi';
2
+ import type { AztecAddress } from '@aztec/aztec.js/addresses';
3
+ import { type ContractBase } from '@aztec/aztec.js/contracts';
4
+ import { Fr } from '@aztec/aztec.js/fields';
5
+ import type { PublicKeys } from '@aztec/aztec.js/keys';
6
+ import type { Logger } from '@aztec/aztec.js/log';
7
+ import type { AztecNode } from '@aztec/aztec.js/node';
8
+ import type { Wallet } from '@aztec/aztec.js/wallet';
9
+ import type { CheatCodes } from '@aztec/aztec/testing';
10
+ import { ChildContract } from '@aztec/noir-test-contracts.js/Child';
11
+ import { ParentContract } from '@aztec/noir-test-contracts.js/Parent';
12
+ import type { StatefulTestContract } from '@aztec/noir-test-contracts.js/StatefulTest';
13
+ import type { PXEConfig } from '@aztec/pxe/config';
14
+ import type { SequencerClient } from '@aztec/sequencer-client';
15
+ import type { AztecNodeAdmin, AztecNodeDebug } from '@aztec/stdlib/interfaces/client';
16
+ import { type EndToEndContext, type SetupOptions } from '../fixtures/setup.js';
17
+ import type { TestWallet } from '../test-wallet/test_wallet.js';
18
+ export type AutomineTestOpts = Partial<SetupOptions> & {
19
+ /** Number of accounts to create and deploy during setup. */
20
+ numberOfAccounts?: number;
21
+ /** Options forwarded to PXE creation. */
22
+ pxeOpts?: Partial<PXEConfig>;
23
+ };
24
+ /**
25
+ * Base class for the automine-sequencer test topology: a single in-process node running the
26
+ * deterministic {@link AUTOMINE_E2E_OPTS} preset (one block per submitted tx, synchronous L1 publish,
27
+ * no committee, no prover, no validator client). Owns the environment (in-proc anvil in automine mode
28
+ * plus the L1 deploy) and exposes the handles every automine test uses (`wallet`, `aztecNode`,
29
+ * `cheatCodes`, `sequencer`, `accounts`, `logger`).
30
+ *
31
+ * The sibling of {@link SingleNodeTestContext}: both wrap the same underlying `fixtures/setup.ts:setup()`
32
+ * but fix opposite sequencer topologies. Making {@link AUTOMINE_E2E_OPTS} the base default removes the
33
+ * per-test-file spread every automine test would otherwise repeat.
34
+ *
35
+ * Domain harnesses (the token simulators) compose on top by extending this base and overriding
36
+ * {@link setup} to run their domain steps after `super.setup()`.
37
+ */
38
+ export declare class AutomineTestContext {
39
+ context: EndToEndContext;
40
+ logger: Logger;
41
+ wallet: TestWallet;
42
+ aztecNode: AztecNode & AztecNodeDebug;
43
+ aztecNodeAdmin: AztecNodeAdmin;
44
+ cheatCodes: CheatCodes;
45
+ sequencer: SequencerClient;
46
+ accounts: AztecAddress[];
47
+ defaultAccountAddress: AztecAddress;
48
+ parentContract: ParentContract;
49
+ childContract: ChildContract;
50
+ static setup<T extends AutomineTestContext>(this: new () => T, opts?: AutomineTestOpts): Promise<T>;
51
+ setup(opts?: AutomineTestOpts): Promise<void>;
52
+ /**
53
+ * Populates the context-derived handles from an already-built {@link EndToEndContext}. Split out of
54
+ * {@link setup} so domain harnesses that build the environment with their own bespoke `setup(...)`
55
+ * opts can still reuse the shared handle wiring.
56
+ */
57
+ protected hydrateFromContext(context: EndToEndContext): Promise<void>;
58
+ teardown(): Promise<void>;
59
+ /**
60
+ * Marks the current pending checkpoints as proven, then warps the L2 clock forward by `seconds`.
61
+ *
62
+ * Under {@link AUTOMINE_E2E_OPTS} a long warp crosses many epochs with no proofs being submitted, so
63
+ * without a prior `markAsProven()` the rollup contract's pruning window resets the chain tip to genesis
64
+ * and the warp's own empty-checkpoint propose fails with `Rollup__InvalidArchive`. Marking proven before
65
+ * warping keeps the pending chain alive. Composes the existing `cheatCodes.rollup.markAsProven` and
66
+ * `warpL2TimeAtLeastBy` with that required ordering.
67
+ */
68
+ markProvenAndWarp(seconds: number | bigint): Promise<void>;
69
+ /** Computes and registers a contract instance in the wallet without deploying it on-chain. */
70
+ registerContract<T extends ContractBase>(wallet: Wallet, contractArtifact: ContractArtifactClass<T>, opts?: {
71
+ salt?: Fr;
72
+ publicKeys?: PublicKeys;
73
+ initArgs?: any[];
74
+ constructorName?: string;
75
+ deployer?: AztecAddress;
76
+ }): Promise<T>;
77
+ /** Deploys a Parent and a Child contract from the default account for the nested-call tests. */
78
+ applyManualParentChild(): Promise<void>;
79
+ }
80
+ export type StatefulContractCtorArgs = Parameters<StatefulTestContract['methods']['constructor']>;
81
+ export type ContractArtifactClass<T extends ContractBase> = {
82
+ at(address: AztecAddress, wallet: Wallet): T;
83
+ artifact: ContractArtifact;
84
+ };
85
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXV0b21pbmVfdGVzdF9jb250ZXh0LmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvYXV0b21pbmUvYXV0b21pbmVfdGVzdF9jb250ZXh0LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxFQUFFLGdCQUFnQixFQUFFLE1BQU0scUJBQXFCLENBQUM7QUFDNUQsT0FBTyxLQUFLLEVBQUUsWUFBWSxFQUFFLE1BQU0sMkJBQTJCLENBQUM7QUFDOUQsT0FBTyxFQUFFLEtBQUssWUFBWSxFQUE4QyxNQUFNLDJCQUEyQixDQUFDO0FBQ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AC,CAAC,aAAa,CAAC,CAAC,CAAC;AAElG,MAAM,MAAM,qBAAqB,CAAC,CAAC,SAAS,YAAY,IAAI;IAC1D,EAAE,CAAC,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,GAAG,CAAC,CAAC;IAC7C,QAAQ,EAAE,gBAAgB,CAAC;CAC5B,CAAC"}
@@ -0,0 +1,98 @@
1
+ import { getContractInstanceFromInstantiationParams } from '@aztec/aztec.js/contracts';
2
+ import { Fr } from '@aztec/aztec.js/fields';
3
+ import { ChildContract } from '@aztec/noir-test-contracts.js/Child';
4
+ import { ParentContract } from '@aztec/noir-test-contracts.js/Parent';
5
+ import { AUTOMINE_E2E_OPTS } from '../fixtures/fixtures.js';
6
+ import { setup, teardown } from '../fixtures/setup.js';
7
+ /**
8
+ * Base class for the automine-sequencer test topology: a single in-process node running the
9
+ * deterministic {@link AUTOMINE_E2E_OPTS} preset (one block per submitted tx, synchronous L1 publish,
10
+ * no committee, no prover, no validator client). Owns the environment (in-proc anvil in automine mode
11
+ * plus the L1 deploy) and exposes the handles every automine test uses (`wallet`, `aztecNode`,
12
+ * `cheatCodes`, `sequencer`, `accounts`, `logger`).
13
+ *
14
+ * The sibling of {@link SingleNodeTestContext}: both wrap the same underlying `fixtures/setup.ts:setup()`
15
+ * but fix opposite sequencer topologies. Making {@link AUTOMINE_E2E_OPTS} the base default removes the
16
+ * per-test-file spread every automine test would otherwise repeat.
17
+ *
18
+ * Domain harnesses (the token simulators) compose on top by extending this base and overriding
19
+ * {@link setup} to run their domain steps after `super.setup()`.
20
+ */ export class AutomineTestContext {
21
+ context;
22
+ logger;
23
+ wallet;
24
+ aztecNode;
25
+ aztecNodeAdmin;
26
+ cheatCodes;
27
+ sequencer;
28
+ accounts;
29
+ defaultAccountAddress;
30
+ parentContract;
31
+ childContract;
32
+ static async setup(opts = {}) {
33
+ const test = new this();
34
+ await test.setup(opts);
35
+ return test;
36
+ }
37
+ async setup(opts = {}) {
38
+ const { numberOfAccounts = 1, pxeOpts, ...setupOpts } = opts;
39
+ const context = await setup(numberOfAccounts, {
40
+ ...AUTOMINE_E2E_OPTS,
41
+ fundSponsoredFPC: true,
42
+ ...setupOpts
43
+ }, pxeOpts);
44
+ await this.hydrateFromContext(context);
45
+ }
46
+ /**
47
+ * Populates the context-derived handles from an already-built {@link EndToEndContext}. Split out of
48
+ * {@link setup} so domain harnesses that build the environment with their own bespoke `setup(...)`
49
+ * opts can still reuse the shared handle wiring.
50
+ */ hydrateFromContext(context) {
51
+ this.context = context;
52
+ this.logger = context.logger;
53
+ this.wallet = context.wallet;
54
+ this.aztecNode = context.aztecNodeService;
55
+ this.aztecNodeAdmin = context.aztecNodeService;
56
+ this.cheatCodes = context.cheatCodes;
57
+ this.sequencer = context.sequencer;
58
+ this.accounts = context.accounts;
59
+ this.defaultAccountAddress = context.accounts[0];
60
+ return Promise.resolve();
61
+ }
62
+ async teardown() {
63
+ await teardown(this.context);
64
+ }
65
+ /**
66
+ * Marks the current pending checkpoints as proven, then warps the L2 clock forward by `seconds`.
67
+ *
68
+ * Under {@link AUTOMINE_E2E_OPTS} a long warp crosses many epochs with no proofs being submitted, so
69
+ * without a prior `markAsProven()` the rollup contract's pruning window resets the chain tip to genesis
70
+ * and the warp's own empty-checkpoint propose fails with `Rollup__InvalidArchive`. Marking proven before
71
+ * warping keeps the pending chain alive. Composes the existing `cheatCodes.rollup.markAsProven` and
72
+ * `warpL2TimeAtLeastBy` with that required ordering.
73
+ */ async markProvenAndWarp(seconds) {
74
+ await this.cheatCodes.rollup.markAsProven();
75
+ await this.cheatCodes.warpL2TimeAtLeastBy(this.aztecNode, seconds);
76
+ }
77
+ /** Computes and registers a contract instance in the wallet without deploying it on-chain. */ async registerContract(wallet, contractArtifact, opts = {}) {
78
+ const { salt, publicKeys, initArgs, constructorName, deployer } = opts;
79
+ const instance = await getContractInstanceFromInstantiationParams(contractArtifact.artifact, {
80
+ constructorArgs: initArgs ?? [],
81
+ constructorArtifact: constructorName,
82
+ salt: salt ?? Fr.random(),
83
+ publicKeys,
84
+ deployer
85
+ });
86
+ await wallet.registerContract(instance, contractArtifact.artifact);
87
+ return contractArtifact.at(instance.address, wallet);
88
+ }
89
+ /** Deploys a Parent and a Child contract from the default account for the nested-call tests. */ async applyManualParentChild() {
90
+ this.logger.info('Deploying parent and child contracts');
91
+ ({ contract: this.parentContract } = await ParentContract.deploy(this.wallet).send({
92
+ from: this.defaultAccountAddress
93
+ }));
94
+ ({ contract: this.childContract } = await ChildContract.deploy(this.wallet).send({
95
+ from: this.defaultAccountAddress
96
+ }));
97
+ }
98
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3RvcmFnZV9wcm9vZl9mZXRjaGVyLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9zcmMvYXV0b21pbmUvY29udHJhY3RzL2ZpeHR1cmVzL3N0b3JhZ2VfcHJvb2ZfZmV0Y2hlci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiIn0=
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storage_proof_fetcher.d.ts","sourceRoot":"","sources":["../../../../src/automine/contracts/fixtures/storage_proof_fetcher.ts"],"names":[],"mappings":""}
@@ -0,0 +1,184 @@
1
+ /**
2
+ * Fetches a ERC20 balance storage proof from the Ethereum mainnet and saves it to a Prover.toml compatible JSON.
3
+ * The JSON can be converted to toml for use with nargo, or used directly as a JSON file when used in
4
+ * Aztec contracts. This script is not using any Aztec library code, so it's easily portable.
5
+ */ import fs from 'fs';
6
+ import { dirname, join } from 'path';
7
+ import { fileURLToPath } from 'url';
8
+ import { createPublicClient, encodeAbiParameters, fromRlp, hexToBytes, http, keccak256 } from 'viem';
9
+ import { mainnet } from 'viem/chains';
10
+ const __dirname = dirname(fileURLToPath(import.meta.url));
11
+ const RPC_URL = process.env.RPC_URL;
12
+ const ERC20_CONTRACT = process.env.ERC20_CONTRACT || '0xdAC17F958D2ee523a2206206994597C13D831ec7';
13
+ const HOLDER = process.env.HOLDER || '0x23878914EFE38d27C4D67Ab83ed1b93A74D4086a';
14
+ const SLOT = BigInt(process.env.SLOT || '2');
15
+ const BLOCK_TAG = process.env.BLOCK_NUMBER ? BigInt(process.env.BLOCK_NUMBER) : 'latest';
16
+ const MAX_ACCOUNT_PATH = 15;
17
+ const MAX_STORAGE_PATH = 10;
18
+ function padTo(arr, len) {
19
+ return [
20
+ ...arr,
21
+ ...Array(len - arr.length).fill(0)
22
+ ].slice(0, len);
23
+ }
24
+ function toBytes(hex) {
25
+ return Array.from(hexToBytes(hex));
26
+ }
27
+ function bytesToU64s(bytes) {
28
+ const paddedBytes = padTo(bytes, 32);
29
+ return Array.from({
30
+ length: 4
31
+ }, (_, i)=>{
32
+ let val = 0n;
33
+ for(let j = 0; j < 8; j++){
34
+ val += BigInt(paddedBytes[i * 8 + j]) << BigInt(j * 8);
35
+ }
36
+ return val.toString();
37
+ });
38
+ }
39
+ function toBytesAndLen(val) {
40
+ if (val === 0n || val === 0) {
41
+ return {
42
+ bytes: [
43
+ 0
44
+ ],
45
+ length: 0
46
+ };
47
+ }
48
+ let hex = val.toString(16);
49
+ if (hex.length % 2) {
50
+ hex = '0' + hex;
51
+ }
52
+ const bytes = toBytes(`0x${hex}`);
53
+ return {
54
+ bytes,
55
+ length: bytes.length
56
+ };
57
+ }
58
+ function parseNode(rlp) {
59
+ // Should be safe when working with branches and extensions without embedded children.
60
+ const decoded = fromRlp(rlp);
61
+ const node = {
62
+ rows: Array(16).fill(0).map(()=>Array(32).fill(0)),
63
+ row_exist: Array(16).fill(false),
64
+ node_type: 0
65
+ };
66
+ if (decoded.length === 17) {
67
+ for(let i = 0; i < 16; i++){
68
+ if (decoded[i] !== '0x') {
69
+ node.row_exist[i] = true;
70
+ node.rows[i] = padTo(toBytes(decoded[i]), 32);
71
+ }
72
+ }
73
+ } else if (decoded.length === 2) {
74
+ const keyBytes = toBytes(decoded[0]);
75
+ const prefix = keyBytes[0];
76
+ if (prefix >> 4 >= 2) {
77
+ throw new Error('Unsupported: leaf node in proof path');
78
+ }
79
+ node.node_type = 1;
80
+ // Extension header format expected by the noir code: check out storage_proof types.nr.
81
+ node.rows[0][0] = prefix >> 4;
82
+ node.rows[0][8] = prefix & 0x0f;
83
+ node.rows[0][16] = keyBytes.length - 1;
84
+ for(let i = 1; i < keyBytes.length && i < 32; i++){
85
+ node.rows[1][i - 1] = keyBytes[i];
86
+ }
87
+ node.rows[2] = padTo(toBytes(decoded[1]), 32);
88
+ node.row_exist[0] = node.row_exist[1] = node.row_exist[2] = true;
89
+ }
90
+ return node;
91
+ }
92
+ function parseProof(proof, maxLen) {
93
+ const nodes = proof.slice(0, -1).slice(0, maxLen).map(parseNode);
94
+ while(nodes.length < maxLen){
95
+ nodes.push({
96
+ rows: Array(16).fill(0).map(()=>Array(32).fill(0)),
97
+ row_exist: Array(16).fill(false),
98
+ node_type: 0
99
+ });
100
+ }
101
+ return nodes;
102
+ }
103
+ function nodeToLibFormat(node) {
104
+ return {
105
+ rows: node.rows.map(bytesToU64s),
106
+ row_exist: node.row_exist,
107
+ node_type: String(node.node_type)
108
+ };
109
+ }
110
+ async function main() {
111
+ if (!RPC_URL) {
112
+ throw new Error('RPC_URL is not set');
113
+ }
114
+ const storageKey = keccak256(encodeAbiParameters([
115
+ {
116
+ type: 'address'
117
+ },
118
+ {
119
+ type: 'uint256'
120
+ }
121
+ ], [
122
+ HOLDER,
123
+ SLOT
124
+ ]));
125
+ console.log(`Fetching storage proof for ${ERC20_CONTRACT}, holder ${HOLDER}, slot ${SLOT}`);
126
+ console.log(`Storage key: ${storageKey}`);
127
+ const client = createPublicClient({
128
+ chain: mainnet,
129
+ transport: http(RPC_URL)
130
+ });
131
+ const [blockNumber, proof, block] = await Promise.all([
132
+ client.getBlockNumber(),
133
+ client.getProof({
134
+ address: ERC20_CONTRACT,
135
+ storageKeys: [
136
+ storageKey
137
+ ],
138
+ blockNumber: BLOCK_TAG === 'latest' ? undefined : BLOCK_TAG
139
+ }),
140
+ client.getBlock({
141
+ blockNumber: BLOCK_TAG === 'latest' ? undefined : BLOCK_TAG
142
+ })
143
+ ]);
144
+ const storageProof = proof.storageProof[0];
145
+ console.log(`Block: ${blockNumber}, Account nodes: ${proof.accountProof.length}, Storage nodes: ${storageProof.proof.length}`);
146
+ console.log(`Value: ${storageProof.value}`);
147
+ // The -1 is because the last node in the proof is the leaf, which is excluded from path verification.
148
+ const accountPathLen = proof.accountProof.length - 1;
149
+ const storagePathLen = storageProof.proof.length - 1;
150
+ if (accountPathLen > MAX_ACCOUNT_PATH) {
151
+ throw new Error(`Account proof path length ${accountPathLen} exceeds MAX_ACCOUNT_PATH ${MAX_ACCOUNT_PATH}. Increase the limit.`);
152
+ }
153
+ if (storagePathLen > MAX_STORAGE_PATH) {
154
+ throw new Error(`Storage proof path length ${storagePathLen} exceeds MAX_STORAGE_PATH ${MAX_STORAGE_PATH}. Increase the limit.`);
155
+ }
156
+ const nonce = toBytesAndLen(proof.nonce);
157
+ const balance = toBytesAndLen(proof.balance);
158
+ const slotValue = toBytesAndLen(storageProof.value);
159
+ const data = {
160
+ account_nodes: parseProof(proof.accountProof, MAX_ACCOUNT_PATH).map(nodeToLibFormat),
161
+ account_node_length: String(accountPathLen),
162
+ storage_nodes: parseProof(storageProof.proof, MAX_STORAGE_PATH).map(nodeToLibFormat),
163
+ storage_node_length: String(storagePathLen),
164
+ account: {
165
+ nonce: padTo(nonce.bytes, 8).map(String),
166
+ nonce_length: String(nonce.length),
167
+ balance: padTo(balance.bytes, 32).map(String),
168
+ balance_length: String(balance.length),
169
+ address: toBytes(ERC20_CONTRACT).map(String),
170
+ storage_hash: bytesToU64s(toBytes(proof.storageHash)),
171
+ code_hash: bytesToU64s(toBytes(proof.codeHash))
172
+ },
173
+ slot: {
174
+ value: padTo(slotValue.bytes, 32).map(String),
175
+ value_length: String(slotValue.length)
176
+ },
177
+ slot_key: toBytes(storageKey).map(String),
178
+ root: bytesToU64s(toBytes(block.stateRoot)),
179
+ block_number: String(blockNumber)
180
+ };
181
+ fs.writeFileSync(join(__dirname, 'storage_proof.json'), JSON.stringify(data, null, 2));
182
+ console.log('storage_proof.json generated');
183
+ }
184
+ main().catch(console.error);
@@ -0,0 +1,18 @@
1
+ import type { AztecAddress } from '@aztec/aztec.js/addresses';
2
+ import { EthAddress } from '@aztec/foundation/eth-address';
3
+ import { Capsule } from '@aztec/stdlib/tx';
4
+ /** Parsed + typed fixture data ready for use as contract function arguments. */
5
+ export type StorageProofArgs = {
6
+ ethAddress: EthAddress;
7
+ slotKey: number[];
8
+ slotContents: {
9
+ value: number[];
10
+ value_length: number;
11
+ };
12
+ root: bigint[];
13
+ };
14
+ /** Loads the storage proof fixture from disk and returns the contract args. */
15
+ export declare function loadStorageProofArgs(): StorageProofArgs;
16
+ /** Builds all the capsules the StorageProofTest contract expects during private execution. */
17
+ export declare function buildStorageProofCapsules(contractAddress: AztecAddress): Promise<Capsule[]>;
18
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3RvcmFnZV9wcm9vZl9maXh0dXJlLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9zcmMvYXV0b21pbmUvY29udHJhY3RzL2ZpeHR1cmVzL3N0b3JhZ2VfcHJvb2ZfZml4dHVyZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxZQUFZLEVBQUUsTUFBTSwyQkFBMkIsQ0FBQztBQUc5RCxPQUFPLEVBQUUsVUFBVSxFQUFFLE1BQU0sK0JBQStCLENBQUM7QUFDM0QsT0FBTyxFQUFFLE9BQU8sRUFBRSxNQUFNLGtCQUFrQixDQUFDO0FBd0YzQyxnRkFBZ0Y7QUFDaEYsTUFBTSxNQUFNLGdCQUFnQixHQUFHO0lBQzdCLFVBQVUsRUFBRSxVQUFVLENBQUM7SUFDdkIsT0FBTyxFQUFFLE1BQU0sRUFBRSxDQUFDO0lBQ2xCLFlBQVksRUFBRTtRQUFFLEtBQUssRUFBRSxNQUFNLEVBQUUsQ0FBQztRQUFDLFlBQVksRUFBRSxNQUFNLENBQUE7S0FBRSxDQUFDO0lBQ3hELElBQUksRUFBRSxNQUFNLEVBQUUsQ0FBQztDQUNoQixDQUFDO0FBRUYsK0VBQStFO0FBQy9FLHdCQUFnQixvQkFBb0IsSUFBSSxnQkFBZ0IsQ0FhdkQ7QUFFRCw4RkFBOEY7QUFDOUYsd0JBQXNCLHlCQUF5QixDQUFDLGVBQWUsRUFBRSxZQUFZLEdBQUcsT0FBTyxDQUFDLE9BQU8sRUFBRSxDQUFDLENBdURqRyJ9
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storage_proof_fixture.d.ts","sourceRoot":"","sources":["../../../../src/automine/contracts/fixtures/storage_proof_fixture.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAG9D,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC3D,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAwF3C,gFAAgF;AAChF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,UAAU,EAAE,UAAU,CAAC;IACvB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,YAAY,EAAE;QAAE,KAAK,EAAE,MAAM,EAAE,CAAC;QAAC,YAAY,EAAE,MAAM,CAAA;KAAE,CAAC;IACxD,IAAI,EAAE,MAAM,EAAE,CAAC;CAChB,CAAC;AAEF,+EAA+E;AAC/E,wBAAgB,oBAAoB,IAAI,gBAAgB,CAavD;AAED,8FAA8F;AAC9F,wBAAsB,yBAAyB,CAAC,eAAe,EAAE,YAAY,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC,CAuDjG"}