@aztec/end-to-end 0.0.1-commit.a072138 → 0.0.1-commit.a5db02d

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 (352) hide show
  1. package/README.md +229 -14
  2. package/dest/automine/automine_test_context.d.ts +85 -0
  3. package/dest/automine/automine_test_context.d.ts.map +1 -0
  4. package/dest/automine/automine_test_context.js +98 -0
  5. package/dest/automine/contracts/fixtures/storage_proof_fetcher.d.ts +2 -0
  6. package/dest/automine/contracts/fixtures/storage_proof_fetcher.d.ts.map +1 -0
  7. package/dest/automine/contracts/fixtures/storage_proof_fetcher.js +184 -0
  8. package/dest/automine/contracts/fixtures/storage_proof_fixture.d.ts +18 -0
  9. package/dest/automine/contracts/fixtures/storage_proof_fixture.d.ts.map +1 -0
  10. package/dest/automine/contracts/fixtures/storage_proof_fixture.js +120 -0
  11. package/dest/automine/delivery/interactive_handshake_responder.d.ts +48 -0
  12. package/dest/automine/delivery/interactive_handshake_responder.d.ts.map +1 -0
  13. package/dest/automine/delivery/interactive_handshake_responder.js +76 -0
  14. package/dest/automine/delivery/onchain_delivery_harness.d.ts +19 -0
  15. package/dest/automine/delivery/onchain_delivery_harness.d.ts.map +1 -0
  16. package/dest/automine/delivery/onchain_delivery_harness.js +141 -0
  17. package/dest/automine/token/blacklist_token_contract_test.d.ts +49 -0
  18. package/dest/automine/token/blacklist_token_contract_test.d.ts.map +1 -0
  19. package/dest/{e2e_blacklist_token_contract → automine/token}/blacklist_token_contract_test.js +45 -48
  20. package/dest/automine/token/token_contract_test.d.ts +40 -0
  21. package/dest/automine/token/token_contract_test.d.ts.map +1 -0
  22. package/dest/{e2e_token_contract → automine/token}/token_contract_test.js +43 -48
  23. package/dest/automine/token/token_test_helpers.d.ts +73 -0
  24. package/dest/automine/token/token_test_helpers.d.ts.map +1 -0
  25. package/dest/automine/token/token_test_helpers.js +97 -0
  26. package/dest/bench/client_flows/benchmark.d.ts +15 -1
  27. package/dest/bench/client_flows/benchmark.d.ts.map +1 -1
  28. package/dest/bench/client_flows/benchmark.js +19 -0
  29. package/dest/bench/client_flows/client_flows_benchmark.d.ts +6 -6
  30. package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -1
  31. package/dest/bench/client_flows/client_flows_benchmark.js +65 -56
  32. package/dest/bench/client_flows/config.d.ts +2 -2
  33. package/dest/bench/client_flows/config.d.ts.map +1 -1
  34. package/dest/bench/client_flows/config.js +18 -0
  35. package/dest/bench/utils.d.ts +3 -3
  36. package/dest/bench/utils.d.ts.map +1 -1
  37. package/dest/bench/utils.js +102 -8
  38. package/dest/composed/ha/ha_full_setup.d.ts +77 -0
  39. package/dest/composed/ha/ha_full_setup.d.ts.map +1 -0
  40. package/dest/composed/ha/ha_full_setup.js +383 -0
  41. package/dest/composed/web3signer/multi_validator_keystore_utils.d.ts +12 -0
  42. package/dest/composed/web3signer/multi_validator_keystore_utils.d.ts.map +1 -0
  43. package/dest/fixtures/authwit_proxy.d.ts +15 -0
  44. package/dest/fixtures/authwit_proxy.d.ts.map +1 -0
  45. package/dest/fixtures/authwit_proxy.js +34 -0
  46. package/dest/fixtures/e2e_prover_test.d.ts +18 -14
  47. package/dest/fixtures/e2e_prover_test.d.ts.map +1 -1
  48. package/dest/fixtures/e2e_prover_test.js +83 -74
  49. package/dest/fixtures/elu_monitor.d.ts +21 -0
  50. package/dest/fixtures/elu_monitor.d.ts.map +1 -0
  51. package/dest/fixtures/elu_monitor.js +102 -0
  52. package/dest/fixtures/fixtures.d.ts +83 -1
  53. package/dest/fixtures/fixtures.d.ts.map +1 -1
  54. package/dest/fixtures/fixtures.js +86 -0
  55. package/dest/fixtures/get_bb_config.d.ts +1 -1
  56. package/dest/fixtures/get_bb_config.d.ts.map +1 -1
  57. package/dest/fixtures/get_bb_config.js +5 -5
  58. package/dest/fixtures/ha_setup.d.ts +71 -0
  59. package/dest/fixtures/ha_setup.d.ts.map +1 -0
  60. package/dest/fixtures/ha_setup.js +119 -0
  61. package/dest/fixtures/index.d.ts +3 -1
  62. package/dest/fixtures/index.d.ts.map +1 -1
  63. package/dest/fixtures/index.js +2 -0
  64. package/dest/fixtures/schnorr_hardcoded_account_contract.d.ts +25 -0
  65. package/dest/fixtures/schnorr_hardcoded_account_contract.d.ts.map +1 -0
  66. package/dest/fixtures/schnorr_hardcoded_account_contract.js +37 -0
  67. package/dest/fixtures/setup.d.ts +120 -60
  68. package/dest/fixtures/setup.d.ts.map +1 -1
  69. package/dest/fixtures/setup.js +332 -327
  70. package/dest/fixtures/setup_p2p_test.d.ts +22 -10
  71. package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
  72. package/dest/fixtures/setup_p2p_test.js +26 -20
  73. package/dest/fixtures/standard_contracts_genesis.d.ts +16 -0
  74. package/dest/fixtures/standard_contracts_genesis.d.ts.map +1 -0
  75. package/dest/fixtures/standard_contracts_genesis.js +25 -0
  76. package/dest/fixtures/timing.d.ts +42 -0
  77. package/dest/fixtures/timing.d.ts.map +1 -0
  78. package/dest/fixtures/timing.js +72 -0
  79. package/dest/fixtures/token_utils.d.ts +22 -4
  80. package/dest/fixtures/token_utils.d.ts.map +1 -1
  81. package/dest/fixtures/token_utils.js +26 -8
  82. package/dest/fixtures/utils.d.ts +2 -2
  83. package/dest/fixtures/utils.d.ts.map +1 -1
  84. package/dest/fixtures/utils.js +1 -1
  85. package/dest/fixtures/wait_helpers.d.ts +135 -0
  86. package/dest/fixtures/wait_helpers.d.ts.map +1 -0
  87. package/dest/fixtures/wait_helpers.js +154 -0
  88. package/dest/forward-compatibility/wallet_rpc_client.d.ts +7 -0
  89. package/dest/forward-compatibility/wallet_rpc_client.d.ts.map +1 -0
  90. package/dest/forward-compatibility/wallet_rpc_client.js +15 -0
  91. package/dest/forward-compatibility/wallet_service.d.ts +3 -0
  92. package/dest/forward-compatibility/wallet_service.d.ts.map +1 -0
  93. package/dest/forward-compatibility/wallet_service.js +109 -0
  94. package/dest/install_legacy_contracts.d.cts +10 -0
  95. package/dest/install_legacy_contracts.d.cts.map +1 -0
  96. package/dest/legacy-jest-resolver.d.cts +3 -0
  97. package/dest/legacy-jest-resolver.d.cts.map +1 -0
  98. package/dest/multi-node/block-production/setup.d.ts +97 -0
  99. package/dest/multi-node/block-production/setup.d.ts.map +1 -0
  100. package/dest/multi-node/block-production/setup.js +158 -0
  101. package/dest/multi-node/governance/setup.d.ts +67 -0
  102. package/dest/multi-node/governance/setup.d.ts.map +1 -0
  103. package/dest/multi-node/governance/setup.js +126 -0
  104. package/dest/multi-node/multi_node_test_context.d.ts +212 -0
  105. package/dest/multi-node/multi_node_test_context.d.ts.map +1 -0
  106. package/dest/multi-node/multi_node_test_context.js +347 -0
  107. package/dest/multi-node/slashing/inactivity_setup.d.ts +27 -0
  108. package/dest/multi-node/slashing/inactivity_setup.d.ts.map +1 -0
  109. package/dest/multi-node/slashing/inactivity_setup.js +111 -0
  110. package/dest/multi-node/slashing/setup.d.ts +167 -0
  111. package/dest/multi-node/slashing/setup.d.ts.map +1 -0
  112. package/dest/multi-node/slashing/setup.js +275 -0
  113. package/dest/{e2e_p2p → p2p}/p2p_network.d.ts +22 -12
  114. package/dest/p2p/p2p_network.d.ts.map +1 -0
  115. package/dest/{e2e_p2p → p2p}/p2p_network.js +98 -37
  116. package/dest/p2p/reqresp/utils.d.ts +19 -0
  117. package/dest/p2p/reqresp/utils.d.ts.map +1 -0
  118. package/dest/{e2e_p2p → p2p}/reqresp/utils.js +67 -27
  119. package/dest/p2p/shared.d.ts +72 -0
  120. package/dest/p2p/shared.d.ts.map +1 -0
  121. package/dest/p2p/shared.js +212 -0
  122. package/dest/shared/cross_chain_test_harness.d.ts +6 -4
  123. package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
  124. package/dest/shared/cross_chain_test_harness.js +44 -32
  125. package/dest/shared/gas_portal_test_harness.d.ts +8 -5
  126. package/dest/shared/gas_portal_test_harness.d.ts.map +1 -1
  127. package/dest/shared/gas_portal_test_harness.js +26 -14
  128. package/dest/shared/index.d.ts +2 -1
  129. package/dest/shared/index.d.ts.map +1 -1
  130. package/dest/shared/index.js +1 -0
  131. package/dest/shared/jest_setup.js +41 -1
  132. package/dest/shared/mock_state_view.d.ts +86 -0
  133. package/dest/shared/mock_state_view.d.ts.map +1 -0
  134. package/dest/shared/mock_state_view.js +186 -0
  135. package/dest/shared/submit-transactions.d.ts +2 -2
  136. package/dest/shared/submit-transactions.d.ts.map +1 -1
  137. package/dest/shared/submit-transactions.js +12 -5
  138. package/dest/shared/timing_env.d.js +5 -0
  139. package/dest/shared/timing_env.js +365 -0
  140. package/dest/shared/uniswap_l1_l2.d.ts +1 -1
  141. package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
  142. package/dest/shared/uniswap_l1_l2.js +56 -44
  143. package/dest/shared/wait_for_l1_to_l2_message.d.ts +13 -0
  144. package/dest/shared/wait_for_l1_to_l2_message.d.ts.map +1 -0
  145. package/dest/shared/wait_for_l1_to_l2_message.js +10 -0
  146. package/dest/simulators/lending_simulator.d.ts +10 -3
  147. package/dest/simulators/lending_simulator.d.ts.map +1 -1
  148. package/dest/simulators/lending_simulator.js +27 -15
  149. package/dest/simulators/token_simulator.d.ts +1 -1
  150. package/dest/simulators/token_simulator.d.ts.map +1 -1
  151. package/dest/simulators/token_simulator.js +3 -24
  152. package/dest/single-node/cross-chain/cross_chain_messaging_test.d.ts +75 -0
  153. package/dest/single-node/cross-chain/cross_chain_messaging_test.d.ts.map +1 -0
  154. package/dest/single-node/cross-chain/cross_chain_messaging_test.js +209 -0
  155. package/dest/single-node/cross-chain/message_test_helpers.d.ts +38 -0
  156. package/dest/single-node/cross-chain/message_test_helpers.d.ts.map +1 -0
  157. package/dest/single-node/cross-chain/message_test_helpers.js +70 -0
  158. package/dest/{e2e_fees → single-node/fees}/bridging_race.notest.d.ts +1 -1
  159. package/dest/single-node/fees/bridging_race.notest.d.ts.map +1 -0
  160. package/dest/{e2e_fees → single-node/fees}/bridging_race.notest.js +17 -4
  161. package/dest/single-node/fees/fees_test.d.ts +95 -0
  162. package/dest/single-node/fees/fees_test.d.ts.map +1 -0
  163. package/dest/single-node/fees/fees_test.js +347 -0
  164. package/dest/single-node/l1-reorgs/setup.d.ts +42 -0
  165. package/dest/single-node/l1-reorgs/setup.d.ts.map +1 -0
  166. package/dest/single-node/l1-reorgs/setup.js +57 -0
  167. package/dest/single-node/partial-proofs/setup.d.ts +5 -0
  168. package/dest/single-node/partial-proofs/setup.d.ts.map +1 -0
  169. package/dest/single-node/partial-proofs/setup.js +5 -0
  170. package/dest/single-node/proving/setup.d.ts +5 -0
  171. package/dest/single-node/proving/setup.d.ts.map +1 -0
  172. package/dest/single-node/proving/setup.js +5 -0
  173. package/dest/single-node/recovery/setup.d.ts +5 -0
  174. package/dest/single-node/recovery/setup.d.ts.map +1 -0
  175. package/dest/single-node/recovery/setup.js +5 -0
  176. package/dest/single-node/setup.d.ts +49 -0
  177. package/dest/single-node/setup.d.ts.map +1 -0
  178. package/dest/single-node/setup.js +56 -0
  179. package/dest/single-node/single_node_test_context.d.ts +374 -0
  180. package/dest/single-node/single_node_test_context.d.ts.map +1 -0
  181. package/dest/single-node/single_node_test_context.js +847 -0
  182. package/dest/spartan/setup_test_wallets.d.ts +12 -3
  183. package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
  184. package/dest/spartan/setup_test_wallets.js +124 -47
  185. package/dest/spartan/tx_metrics.d.ts +27 -4
  186. package/dest/spartan/tx_metrics.d.ts.map +1 -1
  187. package/dest/spartan/tx_metrics.js +106 -21
  188. package/dest/spartan/utils/bot.d.ts +3 -2
  189. package/dest/spartan/utils/bot.d.ts.map +1 -1
  190. package/dest/spartan/utils/bot.js +2 -1
  191. package/dest/spartan/utils/config.d.ts +11 -28
  192. package/dest/spartan/utils/config.d.ts.map +1 -1
  193. package/dest/spartan/utils/config.js +4 -1
  194. package/dest/spartan/utils/index.d.ts +5 -3
  195. package/dest/spartan/utils/index.d.ts.map +1 -1
  196. package/dest/spartan/utils/index.js +5 -1
  197. package/dest/spartan/utils/k8s.d.ts +3 -1
  198. package/dest/spartan/utils/k8s.d.ts.map +1 -1
  199. package/dest/spartan/utils/k8s.js +6 -0
  200. package/dest/spartan/utils/nodes.d.ts +4 -5
  201. package/dest/spartan/utils/nodes.d.ts.map +1 -1
  202. package/dest/spartan/utils/nodes.js +11 -11
  203. package/dest/spartan/utils/pod_logs.d.ts +25 -0
  204. package/dest/spartan/utils/pod_logs.d.ts.map +1 -0
  205. package/dest/spartan/utils/pod_logs.js +74 -0
  206. package/dest/spartan/utils/scripts.d.ts +18 -4
  207. package/dest/spartan/utils/scripts.d.ts.map +1 -1
  208. package/dest/spartan/utils/scripts.js +19 -4
  209. package/dest/test-wallet/test_wallet.d.ts +105 -0
  210. package/dest/test-wallet/test_wallet.d.ts.map +1 -0
  211. package/dest/test-wallet/test_wallet.js +320 -0
  212. package/dest/test-wallet/utils.d.ts +76 -0
  213. package/dest/test-wallet/utils.d.ts.map +1 -0
  214. package/dest/test-wallet/utils.js +126 -0
  215. package/dest/test-wallet/wallet_worker_script.d.ts +2 -0
  216. package/dest/test-wallet/wallet_worker_script.d.ts.map +1 -0
  217. package/dest/test-wallet/wallet_worker_script.js +56 -0
  218. package/dest/test-wallet/worker_wallet.d.ts +53 -0
  219. package/dest/test-wallet/worker_wallet.d.ts.map +1 -0
  220. package/dest/test-wallet/worker_wallet.js +155 -0
  221. package/dest/test-wallet/worker_wallet_schema.d.ts +4 -0
  222. package/dest/test-wallet/worker_wallet_schema.d.ts.map +1 -0
  223. package/dest/test-wallet/worker_wallet_schema.js +23 -0
  224. package/package.json +53 -46
  225. package/src/automine/README.md +60 -0
  226. package/src/automine/automine_test_context.ts +153 -0
  227. package/src/automine/contracts/fixtures/storage_proof.json +915 -0
  228. package/src/automine/contracts/fixtures/storage_proof_fetcher.ts +190 -0
  229. package/src/automine/contracts/fixtures/storage_proof_fixture.ts +173 -0
  230. package/src/automine/delivery/interactive_handshake_responder.ts +125 -0
  231. package/src/automine/delivery/onchain_delivery_harness.ts +213 -0
  232. package/src/{e2e_blacklist_token_contract → automine/token}/blacklist_token_contract_test.ts +51 -61
  233. package/src/{e2e_token_contract → automine/token}/token_contract_test.ts +50 -56
  234. package/src/automine/token/token_test_helpers.ts +138 -0
  235. package/src/bench/client_flows/benchmark.ts +21 -0
  236. package/src/bench/client_flows/client_flows_benchmark.ts +106 -72
  237. package/src/bench/client_flows/config.ts +9 -1
  238. package/src/bench/utils.ts +117 -8
  239. package/src/composed/ha/ha_full_setup.ts +466 -0
  240. package/src/fixtures/authwit_proxy.ts +54 -0
  241. package/src/fixtures/dumps/epoch_proof_result.json +1 -1
  242. package/src/fixtures/e2e_prover_test.ts +101 -95
  243. package/src/fixtures/elu_monitor.ts +126 -0
  244. package/src/fixtures/fixtures.ts +110 -0
  245. package/src/fixtures/get_bb_config.ts +7 -6
  246. package/src/fixtures/ha_setup.ts +192 -0
  247. package/src/fixtures/index.ts +2 -0
  248. package/src/fixtures/schnorr_hardcoded_account_contract.ts +49 -0
  249. package/src/fixtures/setup.ts +436 -442
  250. package/src/fixtures/setup_p2p_test.ts +39 -34
  251. package/src/fixtures/standard_contracts_genesis.ts +28 -0
  252. package/src/fixtures/timing.ts +97 -0
  253. package/src/fixtures/token_utils.ts +42 -7
  254. package/src/fixtures/utils.ts +2 -3
  255. package/src/fixtures/wait_helpers.ts +333 -0
  256. package/src/forward-compatibility/wallet_rpc_client.ts +14 -0
  257. package/src/forward-compatibility/wallet_service.ts +106 -0
  258. package/src/guides/up_quick_start.sh +7 -4
  259. package/src/infra/README.md +12 -0
  260. package/src/install_legacy_contracts.cjs +75 -0
  261. package/src/legacy-jest-resolver.cjs +112 -0
  262. package/src/multi-node/README.md +96 -0
  263. package/src/multi-node/block-production/setup.ts +272 -0
  264. package/src/multi-node/governance/setup.ts +172 -0
  265. package/src/multi-node/multi_node_test_context.ts +447 -0
  266. package/src/multi-node/slashing/inactivity_setup.ts +139 -0
  267. package/src/multi-node/slashing/setup.ts +433 -0
  268. package/src/p2p/README.md +78 -0
  269. package/src/{e2e_p2p → p2p}/p2p_network.ts +124 -53
  270. package/src/{e2e_p2p → p2p}/reqresp/utils.ts +86 -30
  271. package/src/p2p/shared.ts +329 -0
  272. package/src/shared/cross_chain_test_harness.ts +44 -21
  273. package/src/shared/gas_portal_test_harness.ts +33 -15
  274. package/src/shared/index.ts +1 -0
  275. package/src/shared/jest_setup.ts +51 -1
  276. package/src/shared/mock_state_view.ts +188 -0
  277. package/src/shared/submit-transactions.ts +15 -6
  278. package/src/shared/timing_env.d.mts +39 -0
  279. package/src/shared/timing_env.mjs +363 -0
  280. package/src/shared/uniswap_l1_l2.ts +98 -56
  281. package/src/shared/wait_for_l1_to_l2_message.ts +23 -0
  282. package/src/simulators/lending_simulator.ts +33 -15
  283. package/src/simulators/token_simulator.ts +6 -30
  284. package/src/single-node/README.md +66 -0
  285. package/src/single-node/cross-chain/cross_chain_messaging_test.ts +302 -0
  286. package/src/single-node/cross-chain/message_test_helpers.ts +125 -0
  287. package/src/{e2e_fees → single-node/fees}/bridging_race.notest.ts +19 -5
  288. package/src/single-node/fees/fees_test.ts +437 -0
  289. package/src/single-node/l1-reorgs/setup.ts +93 -0
  290. package/src/single-node/partial-proofs/setup.ts +8 -0
  291. package/src/single-node/proving/setup.ts +15 -0
  292. package/src/single-node/recovery/setup.ts +8 -0
  293. package/src/single-node/setup.ts +63 -0
  294. package/src/single-node/single_node_test_context.ts +1058 -0
  295. package/src/spartan/setup_test_wallets.ts +168 -42
  296. package/src/spartan/tx_metrics.ts +108 -24
  297. package/src/spartan/utils/bot.ts +4 -1
  298. package/src/spartan/utils/config.ts +3 -0
  299. package/src/spartan/utils/index.ts +8 -1
  300. package/src/spartan/utils/k8s.ts +8 -0
  301. package/src/spartan/utils/nodes.ts +17 -12
  302. package/src/spartan/utils/pod_logs.ts +99 -0
  303. package/src/spartan/utils/scripts.ts +43 -7
  304. package/src/test-wallet/test_wallet.ts +426 -0
  305. package/src/test-wallet/utils.ts +205 -0
  306. package/src/test-wallet/wallet_worker_script.ts +66 -0
  307. package/src/test-wallet/worker_wallet.ts +214 -0
  308. package/src/test-wallet/worker_wallet_schema.ts +14 -0
  309. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +0 -53
  310. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts.map +0 -1
  311. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +0 -47
  312. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts.map +0 -1
  313. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.js +0 -128
  314. package/dest/e2e_deploy_contract/deploy_test.d.ts +0 -37
  315. package/dest/e2e_deploy_contract/deploy_test.d.ts.map +0 -1
  316. package/dest/e2e_deploy_contract/deploy_test.js +0 -50
  317. package/dest/e2e_epochs/epochs_test.d.ts +0 -100
  318. package/dest/e2e_epochs/epochs_test.d.ts.map +0 -1
  319. package/dest/e2e_epochs/epochs_test.js +0 -361
  320. package/dest/e2e_fees/bridging_race.notest.d.ts.map +0 -1
  321. package/dest/e2e_fees/fees_test.d.ts +0 -88
  322. package/dest/e2e_fees/fees_test.d.ts.map +0 -1
  323. package/dest/e2e_fees/fees_test.js +0 -248
  324. package/dest/e2e_l1_publisher/write_json.d.ts +0 -11
  325. package/dest/e2e_l1_publisher/write_json.d.ts.map +0 -1
  326. package/dest/e2e_l1_publisher/write_json.js +0 -56
  327. package/dest/e2e_multi_validator/utils.d.ts +0 -12
  328. package/dest/e2e_multi_validator/utils.d.ts.map +0 -1
  329. package/dest/e2e_nested_contract/nested_contract_test.d.ts +0 -26
  330. package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +0 -1
  331. package/dest/e2e_nested_contract/nested_contract_test.js +0 -56
  332. package/dest/e2e_p2p/inactivity_slash_test.d.ts +0 -31
  333. package/dest/e2e_p2p/inactivity_slash_test.d.ts.map +0 -1
  334. package/dest/e2e_p2p/inactivity_slash_test.js +0 -136
  335. package/dest/e2e_p2p/p2p_network.d.ts.map +0 -1
  336. package/dest/e2e_p2p/reqresp/utils.d.ts +0 -22
  337. package/dest/e2e_p2p/reqresp/utils.d.ts.map +0 -1
  338. package/dest/e2e_p2p/shared.d.ts +0 -46
  339. package/dest/e2e_p2p/shared.d.ts.map +0 -1
  340. package/dest/e2e_p2p/shared.js +0 -177
  341. package/dest/e2e_token_contract/token_contract_test.d.ts +0 -42
  342. package/dest/e2e_token_contract/token_contract_test.d.ts.map +0 -1
  343. package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +0 -194
  344. package/src/e2e_deploy_contract/deploy_test.ts +0 -85
  345. package/src/e2e_epochs/epochs_test.ts +0 -477
  346. package/src/e2e_fees/fees_test.ts +0 -339
  347. package/src/e2e_l1_publisher/write_json.ts +0 -77
  348. package/src/e2e_nested_contract/nested_contract_test.ts +0 -73
  349. package/src/e2e_p2p/inactivity_slash_test.ts +0 -179
  350. package/src/e2e_p2p/shared.ts +0 -288
  351. /package/dest/{e2e_multi_validator/utils.js → composed/web3signer/multi_validator_keystore_utils.js} +0 -0
  352. /package/src/{e2e_multi_validator/utils.ts → composed/web3signer/multi_validator_keystore_utils.ts} +0 -0
package/README.md CHANGED
@@ -1,26 +1,241 @@
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 a private then private 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/default_node.test.ts
18
24
  ```
19
- yarn test:integration
25
+
26
+ Each run spawns anvil on port 8545, so two tests can only run side by side if each gets its own
27
+ `ANVIL_PORT` (p2p tests additionally bind fixed p2p ports and can never run concurrently — see
28
+ [`src/p2p/README.md`](src/p2p/README.md)). To shake flakiness out of a test,
29
+ `scripts/deflaker.sh yarn test:e2e <file>` reruns it up to 100 times and stops at the first failure
30
+ (output lands in `scripts/deflaker.log`).
31
+
32
+ Compose-based tests (those under `src/composed/`) need a running local network — see
33
+ [Compose / HA / web3signer tests](#compose--ha--web3signer-tests).
34
+
35
+ ## Test categories
36
+
37
+ Tests are grouped by **node topology** — the shape of the network a test needs. The top-level folder is
38
+ the category; the second level names the behavior under test. Each category owns a base class that builds
39
+ its environment, so a test file only describes the scenario, not the wiring.
40
+
41
+ | Category | Topology | A test belongs here when… | README |
42
+ |---|---|---|---|
43
+ | [`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 |
44
+ | [`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 |
45
+ | [`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 |
46
+ | [`p2p/`](src/p2p/README.md) | Real libp2p transport between nodes. | the networking transport itself is under test (gossip, rediscovery, req/resp). | yes |
47
+ | [`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 |
48
+
49
+ A handful of tests live **outside** this package, next to the code they test — see
50
+ [Tests that live elsewhere](#tests-that-live-elsewhere). Other non-category test groups (`composed/`,
51
+ `guides/`, `bench/`) are described in the reference section.
52
+
53
+ ## Where does my test go?
54
+
55
+ 1. **Does it need real networking transport?** → `p2p/`.
56
+ 2. **Does it need a validator committee (consensus/slashing/governance)?** → `multi-node/`.
57
+ 3. **Does it assert on the production sequencer, proving, reorgs, fees, or cross-chain flows?** →
58
+ `single-node/`.
59
+ 4. **Is it pure contract/protocol behavior that's happy with one-block-per-tx?** → `automine/` (the
60
+ default home for most contract tests).
61
+ 5. **Is it really a unit/integration test of one package with no Aztec node?** → it probably belongs in
62
+ that package, not here (see [Tests that live elsewhere](#tests-that-live-elsewhere)).
63
+
64
+ When in doubt, prefer `automine/` for contract behavior and `single-node/` for anything that watches the
65
+ chain advance.
66
+
67
+ ---
68
+
69
+ ## Reference for agents
70
+
71
+ This section is the detailed contract for adding, moving, and wiring tests. It assumes you've read the
72
+ overview above.
73
+
74
+ ### Category base classes
75
+
76
+ Each category centralizes its environment in a base class. The hierarchy:
77
+
78
+ - `single-node/single_node_test_context.ts` → **`SingleNodeTestContext`**. Owns the environment
79
+ (in-process anvil + L1 deploy), node spawning (`createNonValidatorNode`, `createProverNode`), the
80
+ `ChainMonitor`, and the epoch/checkpoint/proof-window/reorg waiters.
81
+ - `multi-node/multi_node_test_context.ts` → **`MultiNodeTestContext extends SingleNodeTestContext`**.
82
+ Adds the N-validator topology over a mock-gossip bus, inheriting the base environment and waiters.
83
+ - `automine/automine_test_context.ts` → **`AutomineTestContext`**. A sibling of `SingleNodeTestContext`
84
+ (both wrap `fixtures/setup.ts:setup()`), but fixes the automine topology and makes `AUTOMINE_E2E_OPTS`
85
+ the default. Exposes `markProvenAndWarp`, `registerContract`, `applyManualParentChild`.
86
+ - `p2p/p2p_network.ts` → **`P2PNetworkTest`**. Real libp2p; node creation goes through
87
+ `fixtures/setup_p2p_test.ts`.
88
+ - `infra/` has no shared base — its tests target a network selected by `L1_CHAIN_ID` (local anvil in CI,
89
+ a public testnet with credentials).
90
+
91
+ All of the above ultimately wrap `fixtures/setup.ts:setup(numberOfAccounts, opts)`, the single entry point
92
+ that deploys L1 contracts, starts the node(s), and provisions a PXE and accounts.
93
+
94
+ ### Setup factories
95
+
96
+ Categories expose thin factories over their base's static `setup`, named by what the test wants, so a test
97
+ calls the factory instead of spreading option presets:
98
+
99
+ - `single-node/setup.ts`: `setupWithProver` (fake in-process prover — the single-node default) and
100
+ `setupBlockProducer` (no prover; raises `aztecProofSubmissionEpochs` to `NO_REORG_SUBMISSION_EPOCHS`
101
+ (1024) so unproven blocks aren't pruned, and points the PXE at `syncChainTip: 'proposed'`).
102
+ - `automine` tests call `AutomineTestContext.setup({ numberOfAccounts })` directly.
103
+
104
+ ### The harness pattern (domain setup on top of a category)
105
+
106
+ A test suite with bespoke domain setup does **not** fork `setup()`. It subclasses the category base and
107
+ overrides a `protected hydrateFromContext(context)` split out of `setup`, so it reuses the base's
108
+ rollup/epoch-cache/chain-monitor/waiter/teardown machinery while adding its own domain state. Examples:
109
+
110
+ - `single-node/prover/` → `FullProverTest` (real Barretenberg env) extends `SingleNodeTestContext`.
111
+ - `single-node/fees/` → `FeesTest`; `single-node/cross-chain/` → `CrossChainMessagingTest`.
112
+ - `automine/token/` → `TokenContractTest` and `BlacklistTokenContractTest` extend `AutomineTestContext`
113
+ and run their `TokenSimulator`/snapshot setup after `super.setup()`.
114
+
115
+ When two suites share behavior: if their public APIs are nearly identical, use inheritance; if behavior
116
+ overlaps but APIs differ, compose. Don't duplicate a category's environment wiring.
117
+
118
+ ### The `.parallel` suffix
119
+
120
+ CI splits each `it` in a `.parallel.test.ts` file into its own docker job, running it in isolation via
121
+ `jest --testNamePattern` (the names come from `extract_test_names` in `bootstrap.sh`, which matches
122
+ `it`/`test` at **any** nesting depth, not just top level). When an `it` runs alone its enclosing
123
+ `beforeAll`/`beforeEach` hooks still run, but sibling `it`s do not. Rules:
124
+
125
+ - The `.parallel` suffix is for files whose `it`s are **independent**: every `it` must pass when run
126
+ entirely on its own. That holds only when all shared state is built in `beforeAll`/`beforeEach` and no
127
+ `it` reads or asserts on state produced by a sibling `it`.
128
+ - A file with sequential or stateful `it`s (progressive mutation across `it`s, a describe-scope variable
129
+ assigned in one `it` and read in another, a note/token created in an earlier `it` and used later) stays
130
+ a plain `.test.ts` **even if it has many top-level `it`s** — it runs as one ordered job. Adding
131
+ `.parallel` to such a file breaks CI, because each `it` then runs without its predecessors.
132
+ - A file with a single top-level `it` is a plain `.test.ts`.
133
+ - `it`/`test` names in a `.parallel` file must avoid regex/shell-special characters —
134
+ `"` `(` `)` `[` `]` `{` `}` `$` `\` and backtick. The split passes each name to
135
+ `run_test.sh ... "<name>"` as a shell-quoted `--testNamePattern` regex: an embedded `"` closes the
136
+ quote early and hard-fails the job, while regex metacharacters (`(` `)` `[` `]` `+` `*` `?` `|` `{` `}`)
137
+ silently match zero tests so the shard runs nothing and passes green — a coverage gap that hides the
138
+ test. Plain `.test.ts` files run as one job and are unaffected, so any name is fine there.
139
+ (`.` `!` `#` `-` `:` `,` are safe in `.parallel` names.)
140
+ - Each file has exactly one top-level `describe`, named to match its path
141
+ (e.g. `describe('automine/token/transfer', …)`).
142
+
143
+ ### CI test discovery — `bootstrap.sh`
144
+
145
+ `end-to-end/bootstrap.sh` enumerates tests in two arrays, and a test must resolve through the relevant one
146
+ or it **won't run in CI**:
147
+
148
+ - `test_cmds` — the standard run. Covers each category with a recursive glob (e.g.
149
+ `src/automine/!(simulation)/**/*.test.ts`, `src/multi-node/**/*.test.ts`), so a new file or sub-folder
150
+ inside an existing category is picked up automatically; only a new top-level category needs its own glob
151
+ line. Tests with bespoke handling sit outside the globs: the `single-node/prover/` lanes at the top of
152
+ the function (real proofs and custom resources under `CI_FULL`, `FAKE_PROOFS=1` otherwise) and
153
+ `avm_simulator` (below).
154
+ - `compat_test_cmds` — the forward/legacy-compat run (a subset). This one enumerates **single-level leaf
155
+ globs** (e.g. `src/automine/token/*.test.ts`), so a new sub-folder whose tests should run against legacy
156
+ contract artifacts needs its own line here.
157
+
158
+ Bespoke handling to be aware of:
159
+
160
+ - **`avm_simulator`** (`automine/simulation/avm_simulator.test.ts`) has a dedicated line in `test_cmds`
161
+ that sets `DUMP_AVM_INPUTS_TO_DIR` (feeds the downstream `avm_check_circuit` job) and is therefore
162
+ excluded from the generic `simulation/` glob there (`!(avm_simulator)`). In `compat_test_cmds` it runs
163
+ as a regular test (no dump line), so it is **not** excluded there.
164
+ - **`kernelless_simulation`** is excluded from `compat_test_cmds` only.
165
+
166
+ After editing the arrays, confirm every `*.test.ts` resolves through exactly one line (no duplicate, no
167
+ omission — anything excluded via `!(...)` must be matched by its dedicated line). Per-test bash `TIMEOUT`
168
+ overrides live in the `case` block in `test_cmds` and must stay in sync with the test's `jest.setTimeout`.
169
+
170
+ ### Flaky tests — `.test_patterns.yml`
171
+
172
+ Flaky/owner entries live in `.test_patterns.yml` at the **git root** (not in this package), keyed on the
173
+ test path. A bare entry flags the test as flaky whenever it fails; add `error_regex` to flag only on a
174
+ matching message; `skip: true` disables it. Blanket regex entries (e.g. `src/automine/.*\.test\.ts`) are
175
+ depth-agnostic and survive folder renames; path-specific entries must be updated when a file moves.
176
+
177
+ ### Compose / HA / web3signer tests
178
+
179
+ `src/composed/` tests run against a **running local network** rather than an in-process stack, via
180
+ `scripts/run_test.sh` in different modes:
181
+
182
+ - `src/composed/*.test.ts` → `compose` mode (e.g. `e2e_persistence`, `uniswap_trade_on_l1_from_l2`,
183
+ `e2e_cheat_codes` — the compose variant, distinct from the relocated unit-style one).
184
+ - `src/composed/web3signer/*.test.ts` → `web3signer` mode (remote-signer scenarios).
185
+ - `src/composed/ha/*.test.ts` → `ha` mode (high-availability multi-process scenarios).
186
+ - `src/guides/*.test.ts` → tutorial/guide flows; `src/bench/` → benchmarks (see `bench_cmds`).
187
+
188
+ Run one compose test locally with `yarn test:compose <name>` (anvil + the test runner are spawned for
189
+ you), or `docker-compose up` for separate containers.
190
+
191
+ ### Tests that live elsewhere
192
+
193
+ Tests with **no Aztec node** that exercise one package belong in that package, not here:
194
+
195
+ - L1 cheat-code behavior (`EthCheatCodes`/`RollupCheatCodes` against raw anvil) → `@aztec/ethereum`
196
+ (`ethereum/src/test/eth_cheat_codes.test.ts`).
197
+ - The `SequencerPublisher` integration test (anvil + L1 deploy, no node) → `@aztec/sequencer-client`
198
+ (`sequencer-client/src/publisher/`).
199
+
200
+ These run in their own package's test lane (both packages already run anvil-backed integration tests).
201
+
202
+ ### Support directories (not test categories)
203
+
204
+ - `fixtures/` — the shared `setup()`, option presets (`fixtures.ts`), the named node-level waiters
205
+ (`wait_helpers.ts`), the span instrumentation (`timing.ts` — `testSpan`, zero-cost unless
206
+ `TEST_TIMING_FILE` is set), `l1_to_l2_messaging`, and common utils.
207
+ - `shared/` — shared test bodies, the `CrossChainTestHarness`, and `timing_env.mjs`, a **custom jest
208
+ `testEnvironment`** referenced from this package's `package.json`. `yarn prepare` / the package-json
209
+ check will try to revert it to the default — don't let it.
210
+ - `simulators/` — in-TS reference models (`TokenSimulator`, `LendingSimulator`) used to assert contract
211
+ behavior.
212
+ - `test-wallet/`, `bench/`, `spartan/`, `quality_of_service/`, `forward-compatibility/` — helpers,
213
+ benchmarks, and network/ops tests outside the topology categories.
214
+
215
+ ### Running tests against legacy contract artifacts
216
+
217
+ To verify that contracts deployed from a previous release still work against the current stack, set
218
+ `CONTRACT_ARTIFACTS_VERSION` to a published version of `@aztec/noir-contracts.js` /
219
+ `@aztec/noir-test-contracts.js`:
220
+
221
+ ```bash
222
+ CONTRACT_ARTIFACTS_VERSION=4.1.3 yarn test:e2e src/automine/token/access_control.parallel.test.ts
20
223
  ```
21
224
 
22
- which will spawn the two processes.
225
+ Only the JSON artifact files (`.../artifacts/*.json`) are redirected. The TypeScript wrapper classes
226
+ (e.g. `TokenContract`) continue to load from the current workspace and use the current `@aztec/aztec.js` —
227
+ so this exercises whether a deployed contract's ABI / bytecode / notes still work through the *new* client,
228
+ not whether the legacy wrapper code still imports cleanly.
23
229
 
24
- You can also run this by `docker-compose up` which will spawn 2 different containers for Anvil and the test runner.
230
+ The first run downloads the pinned packages into `.legacy-contracts/<version>/node_modules/` (cached across
231
+ runs). A startup banner and a per-redirect line are printed to stderr so you can confirm the legacy
232
+ artifacts were actually loaded:
233
+
234
+ ```
235
+ [legacy-contracts][jest] CONTRACT_ARTIFACTS_VERSION=4.1.3
236
+ [legacy-contracts][jest] redirecting @aztec/noir-contracts.js/artifacts/*.json -> .legacy-contracts/4.1.3/...
237
+ [legacy-contracts][jest] redirected token_contract-Token.json -> /abs/.../.legacy-contracts/4.1.3/.../token_contract-Token.json
238
+ ```
25
239
 
26
- You can run a single test by running `yarn test:compose <test_name>`.
240
+ When `CONTRACT_ARTIFACTS_VERSION` is unset the test run is byte-identical to the default behaviour. The
241
+ 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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXV0b21pbmVfdGVzdF9jb250ZXh0LmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvYXV0b21pbmUvYXV0b21pbmVfdGVzdF9jb250ZXh0LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxFQUFFLGdCQUFnQixFQUFFLE1BQU0scUJBQXFCLENBQUM7QUFDNUQsT0FBTyxLQUFLLEVBQ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gG;IACnF,sBAAsB,IAAI,OAAO,CAAC,IAAI,CAAC,CAQnD;CACF;AAED,MAAM,MAAM,wBAAwB,GAAG,UAAU,CAAC,oBAAoB,CAAC,SAAS,CAAC,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);