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

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 (344) 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/onchain_delivery_harness.d.ts +17 -0
  12. package/dest/automine/delivery/onchain_delivery_harness.d.ts.map +1 -0
  13. package/dest/automine/delivery/onchain_delivery_harness.js +123 -0
  14. package/dest/automine/token/blacklist_token_contract_test.d.ts +49 -0
  15. package/dest/automine/token/blacklist_token_contract_test.d.ts.map +1 -0
  16. package/dest/{e2e_blacklist_token_contract → automine/token}/blacklist_token_contract_test.js +45 -48
  17. package/dest/automine/token/token_contract_test.d.ts +40 -0
  18. package/dest/automine/token/token_contract_test.d.ts.map +1 -0
  19. package/dest/{e2e_token_contract → automine/token}/token_contract_test.js +43 -48
  20. package/dest/automine/token/token_test_helpers.d.ts +73 -0
  21. package/dest/automine/token/token_test_helpers.d.ts.map +1 -0
  22. package/dest/automine/token/token_test_helpers.js +97 -0
  23. package/dest/bench/client_flows/benchmark.d.ts +15 -1
  24. package/dest/bench/client_flows/benchmark.d.ts.map +1 -1
  25. package/dest/bench/client_flows/benchmark.js +19 -0
  26. package/dest/bench/client_flows/client_flows_benchmark.d.ts +6 -6
  27. package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -1
  28. package/dest/bench/client_flows/client_flows_benchmark.js +63 -54
  29. package/dest/bench/client_flows/config.d.ts +2 -2
  30. package/dest/bench/client_flows/config.d.ts.map +1 -1
  31. package/dest/bench/client_flows/config.js +18 -0
  32. package/dest/bench/client_flows/data_extractor.js +1 -0
  33. package/dest/bench/utils.d.ts +3 -3
  34. package/dest/bench/utils.d.ts.map +1 -1
  35. package/dest/bench/utils.js +102 -8
  36. package/dest/composed/ha/ha_full_setup.d.ts +77 -0
  37. package/dest/composed/ha/ha_full_setup.d.ts.map +1 -0
  38. package/dest/composed/ha/ha_full_setup.js +383 -0
  39. package/dest/composed/web3signer/multi_validator_keystore_utils.d.ts +12 -0
  40. package/dest/composed/web3signer/multi_validator_keystore_utils.d.ts.map +1 -0
  41. package/dest/fixtures/authwit_proxy.d.ts +15 -0
  42. package/dest/fixtures/authwit_proxy.d.ts.map +1 -0
  43. package/dest/fixtures/authwit_proxy.js +34 -0
  44. package/dest/fixtures/e2e_prover_test.d.ts +18 -14
  45. package/dest/fixtures/e2e_prover_test.d.ts.map +1 -1
  46. package/dest/fixtures/e2e_prover_test.js +82 -74
  47. package/dest/fixtures/elu_monitor.d.ts +21 -0
  48. package/dest/fixtures/elu_monitor.d.ts.map +1 -0
  49. package/dest/fixtures/elu_monitor.js +102 -0
  50. package/dest/fixtures/fixtures.d.ts +82 -1
  51. package/dest/fixtures/fixtures.d.ts.map +1 -1
  52. package/dest/fixtures/fixtures.js +84 -0
  53. package/dest/fixtures/get_bb_config.d.ts +1 -1
  54. package/dest/fixtures/get_bb_config.d.ts.map +1 -1
  55. package/dest/fixtures/get_bb_config.js +5 -5
  56. package/dest/fixtures/ha_setup.d.ts +71 -0
  57. package/dest/fixtures/ha_setup.d.ts.map +1 -0
  58. package/dest/fixtures/ha_setup.js +119 -0
  59. package/dest/fixtures/index.d.ts +3 -1
  60. package/dest/fixtures/index.d.ts.map +1 -1
  61. package/dest/fixtures/index.js +2 -0
  62. package/dest/fixtures/schnorr_hardcoded_account_contract.d.ts +25 -0
  63. package/dest/fixtures/schnorr_hardcoded_account_contract.d.ts.map +1 -0
  64. package/dest/fixtures/schnorr_hardcoded_account_contract.js +37 -0
  65. package/dest/fixtures/setup.d.ts +111 -60
  66. package/dest/fixtures/setup.d.ts.map +1 -1
  67. package/dest/fixtures/setup.js +320 -327
  68. package/dest/fixtures/setup_p2p_test.d.ts +22 -10
  69. package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
  70. package/dest/fixtures/setup_p2p_test.js +26 -20
  71. package/dest/fixtures/timing.d.ts +42 -0
  72. package/dest/fixtures/timing.d.ts.map +1 -0
  73. package/dest/fixtures/timing.js +72 -0
  74. package/dest/fixtures/token_utils.d.ts +22 -4
  75. package/dest/fixtures/token_utils.d.ts.map +1 -1
  76. package/dest/fixtures/token_utils.js +26 -8
  77. package/dest/fixtures/utils.d.ts +2 -2
  78. package/dest/fixtures/utils.d.ts.map +1 -1
  79. package/dest/fixtures/utils.js +1 -1
  80. package/dest/fixtures/wait_helpers.d.ts +135 -0
  81. package/dest/fixtures/wait_helpers.d.ts.map +1 -0
  82. package/dest/fixtures/wait_helpers.js +154 -0
  83. package/dest/forward-compatibility/wallet_rpc_client.d.ts +7 -0
  84. package/dest/forward-compatibility/wallet_rpc_client.d.ts.map +1 -0
  85. package/dest/forward-compatibility/wallet_rpc_client.js +15 -0
  86. package/dest/forward-compatibility/wallet_service.d.ts +3 -0
  87. package/dest/forward-compatibility/wallet_service.d.ts.map +1 -0
  88. package/dest/forward-compatibility/wallet_service.js +109 -0
  89. package/dest/install_legacy_contracts.d.cts +10 -0
  90. package/dest/install_legacy_contracts.d.cts.map +1 -0
  91. package/dest/legacy-jest-resolver.d.cts +3 -0
  92. package/dest/legacy-jest-resolver.d.cts.map +1 -0
  93. package/dest/multi-node/block-production/setup.d.ts +97 -0
  94. package/dest/multi-node/block-production/setup.d.ts.map +1 -0
  95. package/dest/multi-node/block-production/setup.js +158 -0
  96. package/dest/multi-node/governance/setup.d.ts +67 -0
  97. package/dest/multi-node/governance/setup.d.ts.map +1 -0
  98. package/dest/multi-node/governance/setup.js +126 -0
  99. package/dest/multi-node/multi_node_test_context.d.ts +212 -0
  100. package/dest/multi-node/multi_node_test_context.d.ts.map +1 -0
  101. package/dest/multi-node/multi_node_test_context.js +347 -0
  102. package/dest/multi-node/slashing/inactivity_setup.d.ts +27 -0
  103. package/dest/multi-node/slashing/inactivity_setup.d.ts.map +1 -0
  104. package/dest/multi-node/slashing/inactivity_setup.js +111 -0
  105. package/dest/multi-node/slashing/setup.d.ts +167 -0
  106. package/dest/multi-node/slashing/setup.d.ts.map +1 -0
  107. package/dest/multi-node/slashing/setup.js +275 -0
  108. package/dest/{e2e_p2p → p2p}/p2p_network.d.ts +22 -12
  109. package/dest/p2p/p2p_network.d.ts.map +1 -0
  110. package/dest/{e2e_p2p → p2p}/p2p_network.js +97 -37
  111. package/dest/p2p/reqresp/utils.d.ts +19 -0
  112. package/dest/p2p/reqresp/utils.d.ts.map +1 -0
  113. package/dest/{e2e_p2p → p2p}/reqresp/utils.js +67 -27
  114. package/dest/p2p/shared.d.ts +72 -0
  115. package/dest/p2p/shared.d.ts.map +1 -0
  116. package/dest/p2p/shared.js +212 -0
  117. package/dest/shared/cross_chain_test_harness.d.ts +6 -4
  118. package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
  119. package/dest/shared/cross_chain_test_harness.js +36 -31
  120. package/dest/shared/gas_portal_test_harness.d.ts +8 -5
  121. package/dest/shared/gas_portal_test_harness.d.ts.map +1 -1
  122. package/dest/shared/gas_portal_test_harness.js +26 -14
  123. package/dest/shared/index.d.ts +2 -1
  124. package/dest/shared/index.d.ts.map +1 -1
  125. package/dest/shared/index.js +1 -0
  126. package/dest/shared/jest_setup.js +41 -1
  127. package/dest/shared/mock_state_view.d.ts +86 -0
  128. package/dest/shared/mock_state_view.d.ts.map +1 -0
  129. package/dest/shared/mock_state_view.js +186 -0
  130. package/dest/shared/submit-transactions.d.ts +2 -2
  131. package/dest/shared/submit-transactions.d.ts.map +1 -1
  132. package/dest/shared/submit-transactions.js +12 -5
  133. package/dest/shared/timing_env.d.js +5 -0
  134. package/dest/shared/timing_env.js +365 -0
  135. package/dest/shared/uniswap_l1_l2.d.ts +1 -1
  136. package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
  137. package/dest/shared/uniswap_l1_l2.js +56 -44
  138. package/dest/shared/wait_for_l1_to_l2_message.d.ts +13 -0
  139. package/dest/shared/wait_for_l1_to_l2_message.d.ts.map +1 -0
  140. package/dest/shared/wait_for_l1_to_l2_message.js +10 -0
  141. package/dest/simulators/lending_simulator.d.ts +10 -3
  142. package/dest/simulators/lending_simulator.d.ts.map +1 -1
  143. package/dest/simulators/lending_simulator.js +27 -15
  144. package/dest/simulators/token_simulator.d.ts +1 -1
  145. package/dest/simulators/token_simulator.d.ts.map +1 -1
  146. package/dest/simulators/token_simulator.js +3 -24
  147. package/dest/single-node/cross-chain/cross_chain_messaging_test.d.ts +75 -0
  148. package/dest/single-node/cross-chain/cross_chain_messaging_test.d.ts.map +1 -0
  149. package/dest/single-node/cross-chain/cross_chain_messaging_test.js +209 -0
  150. package/dest/single-node/cross-chain/message_test_helpers.d.ts +38 -0
  151. package/dest/single-node/cross-chain/message_test_helpers.d.ts.map +1 -0
  152. package/dest/single-node/cross-chain/message_test_helpers.js +70 -0
  153. package/dest/{e2e_fees → single-node/fees}/bridging_race.notest.d.ts +1 -1
  154. package/dest/single-node/fees/bridging_race.notest.d.ts.map +1 -0
  155. package/dest/{e2e_fees → single-node/fees}/bridging_race.notest.js +17 -4
  156. package/dest/single-node/fees/fees_test.d.ts +93 -0
  157. package/dest/single-node/fees/fees_test.d.ts.map +1 -0
  158. package/dest/{e2e_fees → single-node/fees}/fees_test.js +94 -68
  159. package/dest/single-node/l1-reorgs/setup.d.ts +42 -0
  160. package/dest/single-node/l1-reorgs/setup.d.ts.map +1 -0
  161. package/dest/single-node/l1-reorgs/setup.js +57 -0
  162. package/dest/single-node/partial-proofs/setup.d.ts +5 -0
  163. package/dest/single-node/partial-proofs/setup.d.ts.map +1 -0
  164. package/dest/single-node/partial-proofs/setup.js +5 -0
  165. package/dest/single-node/proving/setup.d.ts +5 -0
  166. package/dest/single-node/proving/setup.d.ts.map +1 -0
  167. package/dest/single-node/proving/setup.js +5 -0
  168. package/dest/single-node/recovery/setup.d.ts +5 -0
  169. package/dest/single-node/recovery/setup.d.ts.map +1 -0
  170. package/dest/single-node/recovery/setup.js +5 -0
  171. package/dest/single-node/setup.d.ts +49 -0
  172. package/dest/single-node/setup.d.ts.map +1 -0
  173. package/dest/single-node/setup.js +56 -0
  174. package/dest/single-node/single_node_test_context.d.ts +360 -0
  175. package/dest/single-node/single_node_test_context.d.ts.map +1 -0
  176. package/dest/single-node/single_node_test_context.js +833 -0
  177. package/dest/spartan/setup_test_wallets.d.ts +12 -3
  178. package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
  179. package/dest/spartan/setup_test_wallets.js +118 -41
  180. package/dest/spartan/tx_metrics.d.ts +27 -4
  181. package/dest/spartan/tx_metrics.d.ts.map +1 -1
  182. package/dest/spartan/tx_metrics.js +106 -21
  183. package/dest/spartan/utils/bot.d.ts +3 -2
  184. package/dest/spartan/utils/bot.d.ts.map +1 -1
  185. package/dest/spartan/utils/bot.js +2 -1
  186. package/dest/spartan/utils/config.d.ts +11 -28
  187. package/dest/spartan/utils/config.d.ts.map +1 -1
  188. package/dest/spartan/utils/config.js +4 -1
  189. package/dest/spartan/utils/index.d.ts +5 -3
  190. package/dest/spartan/utils/index.d.ts.map +1 -1
  191. package/dest/spartan/utils/index.js +5 -1
  192. package/dest/spartan/utils/k8s.d.ts +3 -1
  193. package/dest/spartan/utils/k8s.d.ts.map +1 -1
  194. package/dest/spartan/utils/k8s.js +6 -0
  195. package/dest/spartan/utils/nodes.d.ts +4 -5
  196. package/dest/spartan/utils/nodes.d.ts.map +1 -1
  197. package/dest/spartan/utils/nodes.js +11 -11
  198. package/dest/spartan/utils/pod_logs.d.ts +25 -0
  199. package/dest/spartan/utils/pod_logs.d.ts.map +1 -0
  200. package/dest/spartan/utils/pod_logs.js +74 -0
  201. package/dest/spartan/utils/scripts.d.ts +18 -4
  202. package/dest/spartan/utils/scripts.d.ts.map +1 -1
  203. package/dest/spartan/utils/scripts.js +19 -4
  204. package/dest/test-wallet/test_wallet.d.ts +105 -0
  205. package/dest/test-wallet/test_wallet.d.ts.map +1 -0
  206. package/dest/test-wallet/test_wallet.js +323 -0
  207. package/dest/test-wallet/utils.d.ts +76 -0
  208. package/dest/test-wallet/utils.d.ts.map +1 -0
  209. package/dest/test-wallet/utils.js +126 -0
  210. package/dest/test-wallet/wallet_worker_script.d.ts +2 -0
  211. package/dest/test-wallet/wallet_worker_script.d.ts.map +1 -0
  212. package/dest/test-wallet/wallet_worker_script.js +56 -0
  213. package/dest/test-wallet/worker_wallet.d.ts +53 -0
  214. package/dest/test-wallet/worker_wallet.d.ts.map +1 -0
  215. package/dest/test-wallet/worker_wallet.js +155 -0
  216. package/dest/test-wallet/worker_wallet_schema.d.ts +4 -0
  217. package/dest/test-wallet/worker_wallet_schema.d.ts.map +1 -0
  218. package/dest/test-wallet/worker_wallet_schema.js +22 -0
  219. package/package.json +53 -46
  220. package/src/automine/README.md +60 -0
  221. package/src/automine/automine_test_context.ts +153 -0
  222. package/src/automine/contracts/fixtures/storage_proof.json +915 -0
  223. package/src/automine/contracts/fixtures/storage_proof_fetcher.ts +190 -0
  224. package/src/automine/contracts/fixtures/storage_proof_fixture.ts +173 -0
  225. package/src/automine/delivery/onchain_delivery_harness.ts +177 -0
  226. package/src/{e2e_blacklist_token_contract → automine/token}/blacklist_token_contract_test.ts +51 -61
  227. package/src/{e2e_token_contract → automine/token}/token_contract_test.ts +50 -56
  228. package/src/automine/token/token_test_helpers.ts +138 -0
  229. package/src/bench/client_flows/benchmark.ts +21 -0
  230. package/src/bench/client_flows/client_flows_benchmark.ts +104 -70
  231. package/src/bench/client_flows/config.ts +9 -1
  232. package/src/bench/client_flows/data_extractor.ts +1 -0
  233. package/src/bench/utils.ts +117 -8
  234. package/src/composed/ha/ha_full_setup.ts +466 -0
  235. package/src/fixtures/authwit_proxy.ts +54 -0
  236. package/src/fixtures/dumps/epoch_proof_result.json +1 -1
  237. package/src/fixtures/e2e_prover_test.ts +94 -95
  238. package/src/fixtures/elu_monitor.ts +126 -0
  239. package/src/fixtures/fixtures.ts +108 -0
  240. package/src/fixtures/get_bb_config.ts +7 -6
  241. package/src/fixtures/ha_setup.ts +192 -0
  242. package/src/fixtures/index.ts +2 -0
  243. package/src/fixtures/schnorr_hardcoded_account_contract.ts +49 -0
  244. package/src/fixtures/setup.ts +412 -442
  245. package/src/fixtures/setup_p2p_test.ts +39 -34
  246. package/src/fixtures/timing.ts +97 -0
  247. package/src/fixtures/token_utils.ts +42 -7
  248. package/src/fixtures/utils.ts +2 -3
  249. package/src/fixtures/wait_helpers.ts +333 -0
  250. package/src/forward-compatibility/wallet_rpc_client.ts +14 -0
  251. package/src/forward-compatibility/wallet_service.ts +106 -0
  252. package/src/guides/up_quick_start.sh +7 -4
  253. package/src/infra/README.md +12 -0
  254. package/src/install_legacy_contracts.cjs +75 -0
  255. package/src/legacy-jest-resolver.cjs +112 -0
  256. package/src/multi-node/README.md +95 -0
  257. package/src/multi-node/block-production/setup.ts +272 -0
  258. package/src/multi-node/governance/setup.ts +172 -0
  259. package/src/multi-node/multi_node_test_context.ts +447 -0
  260. package/src/multi-node/slashing/inactivity_setup.ts +139 -0
  261. package/src/multi-node/slashing/setup.ts +433 -0
  262. package/src/p2p/README.md +78 -0
  263. package/src/{e2e_p2p → p2p}/p2p_network.ts +121 -52
  264. package/src/{e2e_p2p → p2p}/reqresp/utils.ts +86 -30
  265. package/src/p2p/shared.ts +329 -0
  266. package/src/shared/cross_chain_test_harness.ts +42 -17
  267. package/src/shared/gas_portal_test_harness.ts +33 -15
  268. package/src/shared/index.ts +1 -0
  269. package/src/shared/jest_setup.ts +51 -1
  270. package/src/shared/mock_state_view.ts +188 -0
  271. package/src/shared/submit-transactions.ts +15 -6
  272. package/src/shared/timing_env.d.mts +39 -0
  273. package/src/shared/timing_env.mjs +363 -0
  274. package/src/shared/uniswap_l1_l2.ts +98 -56
  275. package/src/shared/wait_for_l1_to_l2_message.ts +23 -0
  276. package/src/simulators/lending_simulator.ts +33 -15
  277. package/src/simulators/token_simulator.ts +6 -30
  278. package/src/single-node/README.md +60 -0
  279. package/src/single-node/cross-chain/cross_chain_messaging_test.ts +302 -0
  280. package/src/single-node/cross-chain/message_test_helpers.ts +125 -0
  281. package/src/{e2e_fees → single-node/fees}/bridging_race.notest.ts +19 -5
  282. package/src/{e2e_fees → single-node/fees}/fees_test.ts +118 -89
  283. package/src/single-node/l1-reorgs/setup.ts +93 -0
  284. package/src/single-node/partial-proofs/setup.ts +8 -0
  285. package/src/single-node/proving/setup.ts +15 -0
  286. package/src/single-node/recovery/setup.ts +8 -0
  287. package/src/single-node/setup.ts +63 -0
  288. package/src/single-node/single_node_test_context.ts +1041 -0
  289. package/src/spartan/setup_test_wallets.ts +156 -36
  290. package/src/spartan/tx_metrics.ts +108 -24
  291. package/src/spartan/utils/bot.ts +4 -1
  292. package/src/spartan/utils/config.ts +3 -0
  293. package/src/spartan/utils/index.ts +8 -1
  294. package/src/spartan/utils/k8s.ts +8 -0
  295. package/src/spartan/utils/nodes.ts +17 -12
  296. package/src/spartan/utils/pod_logs.ts +99 -0
  297. package/src/spartan/utils/scripts.ts +43 -7
  298. package/src/test-wallet/test_wallet.ts +429 -0
  299. package/src/test-wallet/utils.ts +205 -0
  300. package/src/test-wallet/wallet_worker_script.ts +66 -0
  301. package/src/test-wallet/worker_wallet.ts +214 -0
  302. package/src/test-wallet/worker_wallet_schema.ts +14 -0
  303. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +0 -53
  304. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts.map +0 -1
  305. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +0 -47
  306. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts.map +0 -1
  307. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.js +0 -128
  308. package/dest/e2e_deploy_contract/deploy_test.d.ts +0 -37
  309. package/dest/e2e_deploy_contract/deploy_test.d.ts.map +0 -1
  310. package/dest/e2e_deploy_contract/deploy_test.js +0 -50
  311. package/dest/e2e_epochs/epochs_test.d.ts +0 -100
  312. package/dest/e2e_epochs/epochs_test.d.ts.map +0 -1
  313. package/dest/e2e_epochs/epochs_test.js +0 -361
  314. package/dest/e2e_fees/bridging_race.notest.d.ts.map +0 -1
  315. package/dest/e2e_fees/fees_test.d.ts +0 -88
  316. package/dest/e2e_fees/fees_test.d.ts.map +0 -1
  317. package/dest/e2e_l1_publisher/write_json.d.ts +0 -11
  318. package/dest/e2e_l1_publisher/write_json.d.ts.map +0 -1
  319. package/dest/e2e_l1_publisher/write_json.js +0 -56
  320. package/dest/e2e_multi_validator/utils.d.ts +0 -12
  321. package/dest/e2e_multi_validator/utils.d.ts.map +0 -1
  322. package/dest/e2e_nested_contract/nested_contract_test.d.ts +0 -26
  323. package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +0 -1
  324. package/dest/e2e_nested_contract/nested_contract_test.js +0 -56
  325. package/dest/e2e_p2p/inactivity_slash_test.d.ts +0 -31
  326. package/dest/e2e_p2p/inactivity_slash_test.d.ts.map +0 -1
  327. package/dest/e2e_p2p/inactivity_slash_test.js +0 -136
  328. package/dest/e2e_p2p/p2p_network.d.ts.map +0 -1
  329. package/dest/e2e_p2p/reqresp/utils.d.ts +0 -22
  330. package/dest/e2e_p2p/reqresp/utils.d.ts.map +0 -1
  331. package/dest/e2e_p2p/shared.d.ts +0 -46
  332. package/dest/e2e_p2p/shared.d.ts.map +0 -1
  333. package/dest/e2e_p2p/shared.js +0 -177
  334. package/dest/e2e_token_contract/token_contract_test.d.ts +0 -42
  335. package/dest/e2e_token_contract/token_contract_test.d.ts.map +0 -1
  336. package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +0 -194
  337. package/src/e2e_deploy_contract/deploy_test.ts +0 -85
  338. package/src/e2e_epochs/epochs_test.ts +0 -477
  339. package/src/e2e_l1_publisher/write_json.ts +0 -77
  340. package/src/e2e_nested_contract/nested_contract_test.ts +0 -73
  341. package/src/e2e_p2p/inactivity_slash_test.ts +0 -179
  342. package/src/e2e_p2p/shared.ts +0 -288
  343. /package/dest/{e2e_multi_validator/utils.js → composed/web3signer/multi_validator_keystore_utils.js} +0 -0
  344. /package/src/{e2e_multi_validator/utils.ts → composed/web3signer/multi_validator_keystore_utils.ts} +0 -0
@@ -0,0 +1,429 @@
1
+ import { EcdsaKAccountContract, EcdsaRAccountContract } from '@aztec/accounts/ecdsa';
2
+ import { StubEcdsaAccountContractArtifact, createStubEcdsaAccount } from '@aztec/accounts/ecdsa/stub';
3
+ import { SchnorrAccountContract, SchnorrInitializerlessAccountContract } from '@aztec/accounts/schnorr';
4
+ import { StubSchnorrAccountContractArtifact, createStubSchnorrAccount } from '@aztec/accounts/schnorr/stub';
5
+ import { type Account, type AccountContract, NO_FROM } from '@aztec/aztec.js/account';
6
+ import type { CompleteAddress } from '@aztec/aztec.js/addresses';
7
+ import {
8
+ type CallIntent,
9
+ type ContractFunctionInteractionCallIntent,
10
+ type IntentInnerHash,
11
+ SetPublicAuthwitContractInteraction,
12
+ computeInnerAuthWitHashFromAction,
13
+ isContractFunctionInteractionCallIntent,
14
+ lookupValidity,
15
+ } from '@aztec/aztec.js/authorization';
16
+ import { ContractFunctionInteraction } from '@aztec/aztec.js/contracts';
17
+ import type { AztecNode } from '@aztec/aztec.js/node';
18
+ import { AccountManager, type SendOptions } from '@aztec/aztec.js/wallet';
19
+ import { TxSimulationResultWithAppOffset } from '@aztec/aztec.js/wallet';
20
+ import type { DefaultAccountEntrypointOptions } from '@aztec/entrypoints/account';
21
+ import { DefaultEntrypoint } from '@aztec/entrypoints/default';
22
+ import { Fq, Fr } from '@aztec/foundation/curves/bn254';
23
+ import { GrumpkinScalar } from '@aztec/foundation/curves/grumpkin';
24
+ import type { NotesFilter } from '@aztec/pxe/client/lazy';
25
+ import { type PXEConfig, getPXEConfig } from '@aztec/pxe/config';
26
+ import { PXE, type PXECreationOptions, type TaggingSecretSource, createPXE } from '@aztec/pxe/server';
27
+ import { AuthWitness } from '@aztec/stdlib/auth-witness';
28
+ import { AztecAddress } from '@aztec/stdlib/aztec-address';
29
+ import { getContractClassFromArtifact } from '@aztec/stdlib/contract';
30
+ import { deriveSigningKey } from '@aztec/stdlib/keys';
31
+ import type { NoteDao } from '@aztec/stdlib/note';
32
+ import {
33
+ type BlockHeader,
34
+ type ContractOverrides,
35
+ SimulationOverrides,
36
+ type TxExecutionRequest,
37
+ type TxHash,
38
+ type TxReceipt,
39
+ } from '@aztec/stdlib/tx';
40
+ import { ExecutionPayload, mergeExecutionPayloads } from '@aztec/stdlib/tx';
41
+ import { BaseWallet, type SimulateViaEntrypointOptions } from '@aztec/wallet-sdk/base-wallet';
42
+ import type { AccountType } from '@aztec/wallets/embedded';
43
+
44
+ import { DEFAULT_MIN_FEE_PADDING } from '../fixtures/fixtures.js';
45
+ import { AztecNodeProxy, ProvenTx } from './utils.js';
46
+
47
+ /**
48
+ * Data for generating an account.
49
+ */
50
+ export interface AccountData {
51
+ secret: Fr;
52
+ salt: Fr;
53
+ type?: AccountType;
54
+ contract: AccountContract;
55
+ }
56
+
57
+ /**
58
+ * Wallet implementation that stores accounts in memory and provides extra debugging
59
+ * utilities
60
+ * It is intended to be used in e2e tests.
61
+ */
62
+ /**
63
+ * Poll interval (in seconds) for in-process TestWallet tx waits. In-process nodes reach CHECKPOINTED synchronously
64
+ * under automine and cheaply otherwise, so a sub-second cadence removes almost-pure dead time from every send().wait().
65
+ * Spartan tests run against remote JSON-RPC nodes and restore the 1s default via setDefaultWaitInterval.
66
+ */
67
+ export const IN_PROCESS_WAIT_INTERVAL_SECONDS = 0.25;
68
+
69
+ export class TestWallet extends BaseWallet {
70
+ constructor(
71
+ pxe: PXE,
72
+ private readonly nodeRef: AztecNodeProxy,
73
+ ) {
74
+ super(pxe, nodeRef);
75
+ this.minFeePadding = DEFAULT_MIN_FEE_PADDING;
76
+ this.defaultWaitInterval = IN_PROCESS_WAIT_INTERVAL_SECONDS;
77
+ }
78
+
79
+ /**
80
+ * Overrides the poll interval (in seconds) used when a send().wait() caller does not specify one. Pass `undefined`
81
+ * to fall back to the DefaultWaitOpts cadence. Spartan tests set this to 1 so they do not hammer remote nodes.
82
+ */
83
+ setDefaultWaitInterval(interval?: number): void {
84
+ this.defaultWaitInterval = interval;
85
+ }
86
+
87
+ static async create(
88
+ node: AztecNode,
89
+ overridePXEConfig?: Partial<PXEConfig>,
90
+ options: PXECreationOptions = { loggers: {} },
91
+ ): Promise<TestWallet> {
92
+ const nodeRef = new AztecNodeProxy(node);
93
+ const pxeConfig = Object.assign(getPXEConfig(), {
94
+ proverEnabled: overridePXEConfig?.proverEnabled ?? false,
95
+ ...overridePXEConfig,
96
+ });
97
+ const pxe = await createPXE(nodeRef, pxeConfig, options);
98
+ const wallet = new TestWallet(pxe, nodeRef);
99
+ await wallet.initStubClasses();
100
+ return wallet;
101
+ }
102
+
103
+ /**
104
+ * Updates the underlying node that this wallet and its PXE communicate with.
105
+ * @param node - The new AztecNode to forward all calls to.
106
+ */
107
+ updateNode(node: AztecNode): void {
108
+ this.nodeRef.updateTargetNode(node);
109
+ }
110
+
111
+ createSchnorrAccount(secret: Fr, salt: Fr, signingKey?: Fq): Promise<AccountManager> {
112
+ signingKey = signingKey ?? deriveSigningKey(secret);
113
+ return this.createAccount({ secret, salt, type: 'schnorr', contract: new SchnorrAccountContract(signingKey) });
114
+ }
115
+
116
+ createSchnorrInitializerlessAccount(secret: Fr, salt: Fr, signingKey?: Fq): Promise<AccountManager> {
117
+ signingKey = signingKey ?? deriveSigningKey(secret);
118
+ return this.createAccount({
119
+ secret,
120
+ salt,
121
+ type: 'schnorr_initializerless',
122
+ contract: new SchnorrInitializerlessAccountContract(signingKey),
123
+ });
124
+ }
125
+
126
+ createECDSARAccount(secret: Fr, salt: Fr, signingKey: Buffer): Promise<AccountManager> {
127
+ return this.createAccount({
128
+ secret,
129
+ salt,
130
+ type: 'ecdsasecp256r1',
131
+ contract: new EcdsaRAccountContract(signingKey),
132
+ });
133
+ }
134
+
135
+ createECDSAKAccount(secret: Fr, salt: Fr, signingKey: Buffer): Promise<AccountManager> {
136
+ return this.createAccount({
137
+ secret,
138
+ salt,
139
+ type: 'ecdsasecp256k1',
140
+ contract: new EcdsaKAccountContract(signingKey),
141
+ });
142
+ }
143
+
144
+ // Stub class ids, populated on wallet startup
145
+ // to avoid redundant work per simulation
146
+ private stubClassIds = new Map<AccountType, Fr>();
147
+
148
+ /**
149
+ * Hashes and registers the stub class for every supported account type with PXE, populating
150
+ * stubClassIds. Called on wallet initialization.
151
+ */
152
+ private async initStubClasses(): Promise<void> {
153
+ const { id: schnorrClassId } = await getContractClassFromArtifact(StubSchnorrAccountContractArtifact);
154
+ await this.pxe.registerContractClass(StubSchnorrAccountContractArtifact);
155
+
156
+ // ecdsa stubs share the same class id
157
+ const { id: ecdsaClassId } = await getContractClassFromArtifact(StubEcdsaAccountContractArtifact);
158
+ await this.pxe.registerContractClass(StubEcdsaAccountContractArtifact);
159
+
160
+ this.stubClassIds.set('schnorr', schnorrClassId);
161
+ // Initializerless accounts share the schnorr stub class for kernelless simulation.
162
+ this.stubClassIds.set('schnorr_initializerless', schnorrClassId);
163
+ this.stubClassIds.set('ecdsasecp256k1', ecdsaClassId);
164
+ this.stubClassIds.set('ecdsasecp256r1', ecdsaClassId);
165
+ }
166
+
167
+ /**
168
+ * Builds contract overrides for all provided addresses by replacing their account contracts with stub implementations.
169
+ */
170
+ protected async buildAccountOverrides(addresses: AztecAddress[]): Promise<ContractOverrides> {
171
+ const accounts = await this.getAccounts();
172
+ const contracts: ContractOverrides = {};
173
+
174
+ const filtered = accounts.filter(acc => addresses.some(addr => addr.equals(acc.item)));
175
+
176
+ for (const account of filtered) {
177
+ const address = account.item;
178
+ const originalAccount = await this.getAccountFromAddress(address);
179
+ const completeAddress = originalAccount.getCompleteAddress();
180
+ const contractInstance = await this.pxe.getContractInstance(completeAddress.address);
181
+ if (!contractInstance) {
182
+ throw new Error(
183
+ `No contract instance found for address: ${completeAddress.address} during account override building. This is a bug!`,
184
+ );
185
+ }
186
+
187
+ const type = this.getTypeFor(address);
188
+ const stubClassId = this.stubClassIds.get(type);
189
+ if (!stubClassId) {
190
+ throw new Error(
191
+ `Stub class for account type '${type}' was not registered at wallet init. This is a bug — initStubClasses should cover every supported AccountType.`,
192
+ );
193
+ }
194
+
195
+ contracts[address.toString()] = {
196
+ instance: { ...contractInstance, currentContractClassId: stubClassId },
197
+ };
198
+ }
199
+
200
+ return contracts;
201
+ }
202
+
203
+ protected accounts: Map<string, { account: Account; type: AccountType }> = new Map();
204
+
205
+ private getTypeFor(address: AztecAddress): AccountType {
206
+ return this.accounts.get(address.toString())?.type ?? 'schnorr';
207
+ }
208
+
209
+ private getStubAccountFor(address: AztecAddress, completeAddress: CompleteAddress) {
210
+ const type = this.getTypeFor(address);
211
+ return type === 'schnorr' || type === 'schnorr_initializerless'
212
+ ? createStubSchnorrAccount(completeAddress)
213
+ : createStubEcdsaAccount(completeAddress);
214
+ }
215
+
216
+ /**
217
+ * Controls how the test wallet simulates transactions:
218
+ * - `kernelless`: Skips kernel circuits but uses the real account contract. Default.
219
+ * - `kernelless-override`: Skips kernels and replaces the account with a stub that doesn't do authwit validation.
220
+ * - `full`: Uses real kernel circuits and real account contracts. Slow!
221
+ */
222
+ private simulationMode: 'kernelless' | 'kernelless-override' | 'full' = 'kernelless';
223
+
224
+ setSimulationMode(mode: 'kernelless' | 'kernelless-override' | 'full') {
225
+ this.simulationMode = mode;
226
+ }
227
+
228
+ setMinFeePadding(value?: number) {
229
+ this.minFeePadding = value ?? DEFAULT_MIN_FEE_PADDING;
230
+ }
231
+
232
+ protected getAccountFromAddress(address: AztecAddress): Promise<Account> {
233
+ const entry = this.accounts.get(address?.toString() ?? '');
234
+
235
+ if (!entry) {
236
+ throw new Error(`Account not found in wallet for address: ${address}`);
237
+ }
238
+
239
+ return Promise.resolve(entry.account);
240
+ }
241
+
242
+ getAccounts() {
243
+ return Promise.resolve(
244
+ Array.from(this.accounts.values()).map(entry => ({ alias: '', item: entry.account.getAddress() })),
245
+ );
246
+ }
247
+
248
+ async createAccount(accountData?: AccountData): Promise<AccountManager> {
249
+ const secret = accountData?.secret ?? Fr.random();
250
+ const salt = accountData?.salt ?? Fr.random();
251
+ const type = accountData?.type ?? 'schnorr';
252
+ const contract = accountData?.contract ?? new SchnorrAccountContract(GrumpkinScalar.random());
253
+
254
+ // Initializerless accounts have no deployment tx: the address commits to the signing public key
255
+ // (via the contract's immutablesHash, resolved by AccountManager.create) and the constructor's
256
+ // storage writes are materialized locally via a simulated "store" call below.
257
+ // Mirrors EmbeddedWallet.createAccountInternal.
258
+ const accountManager = await AccountManager.create(this, secret, contract, { salt });
259
+
260
+ const instance = accountManager.getInstance();
261
+ const artifact = await contract.getContractArtifact();
262
+
263
+ await this.registerContract(instance, artifact, secret);
264
+
265
+ const address = accountManager.address.toString();
266
+ this.accounts.set(address, { account: await accountManager.getAccount(), type });
267
+
268
+ if (contract instanceof SchnorrInitializerlessAccountContract) {
269
+ const constructorAbi = artifact.functions.find(f => f.name === 'constructor');
270
+ if (!constructorAbi) {
271
+ throw new Error('Could not create SchnorrInitializerlessAccount: constructor ABI not found');
272
+ }
273
+ const { x, y } = await contract.getSigningPublicKey();
274
+ const storeCall = new ContractFunctionInteraction(this, instance.address, constructorAbi, [x, y]);
275
+ await storeCall.simulate({ from: instance.address });
276
+ }
277
+
278
+ return accountManager;
279
+ }
280
+
281
+ lookupValidity(
282
+ onBehalfOf: AztecAddress,
283
+ intent: IntentInnerHash | CallIntent | ContractFunctionInteractionCallIntent,
284
+ witness: AuthWitness,
285
+ ): Promise<{
286
+ isValidInPrivate: boolean;
287
+ isValidInPublic: boolean;
288
+ }> {
289
+ return lookupValidity(this, onBehalfOf, intent, witness);
290
+ }
291
+
292
+ public setPublicAuthWit(
293
+ from: AztecAddress,
294
+ messageHashOrIntent: Fr | IntentInnerHash | CallIntent | ContractFunctionInteractionCallIntent,
295
+ authorized: boolean,
296
+ ): Promise<SetPublicAuthwitContractInteraction> {
297
+ return SetPublicAuthwitContractInteraction.create(this, from, messageHashOrIntent, authorized);
298
+ }
299
+
300
+ public override async createAuthWit(
301
+ from: AztecAddress,
302
+ intent: IntentInnerHash | CallIntent | ContractFunctionInteractionCallIntent,
303
+ ): Promise<AuthWitness> {
304
+ const account = await this.getAccountFromAddress(from);
305
+ const chainInfo = await this.getChainInfo();
306
+ let intentInnerHash: IntentInnerHash;
307
+ if ('caller' in intent) {
308
+ const call = isContractFunctionInteractionCallIntent(intent)
309
+ ? await intent.action.getFunctionCall()
310
+ : intent.call;
311
+ const innerHash = await computeInnerAuthWitHashFromAction(intent.caller, call);
312
+ intentInnerHash = { innerHash, consumer: call.to };
313
+ } else {
314
+ intentInnerHash = intent;
315
+ }
316
+ return account.createAuthWit(intentInnerHash, chainInfo);
317
+ }
318
+
319
+ protected override async simulateViaEntrypoint(
320
+ executionPayload: ExecutionPayload,
321
+ opts: SimulateViaEntrypointOptions,
322
+ ): Promise<TxSimulationResultWithAppOffset> {
323
+ const { from, feeOptions, additionalScopes, skipTxValidation, skipFeeEnforcement, sendMessagesAs } = opts;
324
+ const scopes = this.scopesFrom(from, additionalScopes);
325
+ const skipKernels = this.simulationMode !== 'full';
326
+ const useOverride = this.simulationMode === 'kernelless-override';
327
+
328
+ const feeExecutionPayload = await feeOptions.walletFeePaymentMethod?.getExecutionPayload();
329
+ const finalExecutionPayload = feeExecutionPayload
330
+ ? mergeExecutionPayloads([feeExecutionPayload, executionPayload])
331
+ : executionPayload;
332
+ const chainInfo = await this.getChainInfo();
333
+
334
+ let overrides = opts.overrides;
335
+ let txRequest: TxExecutionRequest;
336
+ if (useOverride) {
337
+ const accountOverrides = await this.buildAccountOverrides(scopes);
338
+ overrides = new SimulationOverrides({
339
+ publicStorage: overrides?.publicStorage,
340
+ contracts: { ...overrides?.contracts, ...accountOverrides },
341
+ });
342
+ }
343
+
344
+ if (from === NO_FROM) {
345
+ const entrypoint = new DefaultEntrypoint();
346
+ txRequest = await entrypoint.createTxExecutionRequest(finalExecutionPayload, feeOptions.gasSettings, chainInfo);
347
+ } else {
348
+ let fromAccount: Account;
349
+ if (useOverride) {
350
+ const originalAccount = await this.getAccountFromAddress(from);
351
+ fromAccount = this.getStubAccountFor(from, originalAccount.getCompleteAddress());
352
+ } else {
353
+ fromAccount = await this.getAccountFromAddress(from);
354
+ }
355
+ const executionOptions: DefaultAccountEntrypointOptions = {
356
+ txNonce: Fr.random(),
357
+ cancellable: this.cancellableTransactions,
358
+ // If from is an address, feeOptions include the way the account contract should handle the fee payment
359
+ feePaymentMethodOptions: feeOptions.accountFeePaymentMethodOptions!,
360
+ };
361
+ txRequest = await fromAccount.createTxExecutionRequest(
362
+ finalExecutionPayload,
363
+ feeOptions.gasSettings,
364
+ chainInfo,
365
+ executionOptions,
366
+ );
367
+ }
368
+
369
+ const result = await this.pxe.simulateTx(txRequest, {
370
+ simulatePublic: true,
371
+ skipKernels,
372
+ skipFeeEnforcement,
373
+ skipTxValidation,
374
+ overrides,
375
+ scopes,
376
+ senderForTags: this.senderForTagsFrom(from, sendMessagesAs),
377
+ });
378
+ const appCallOffset = await this.computeAppCallOffset(from, feeOptions);
379
+ return TxSimulationResultWithAppOffset.fromResultAndOffset(result, appCallOffset);
380
+ }
381
+
382
+ async proveTx(exec: ExecutionPayload, opts: Omit<SendOptions, 'wait'>): Promise<ProvenTx> {
383
+ const fee = await this.completeFeeOptions({
384
+ from: opts.from,
385
+ feePayer: exec.feePayer,
386
+ gasSettings: opts.fee?.gasSettings,
387
+ });
388
+ const txRequest = await this.createTxExecutionRequestFromPayloadAndFee(exec, opts.from, fee);
389
+ const txProvingResult = await this.pxe.proveTx(txRequest, {
390
+ scopes: this.scopesFrom(opts.from, opts.additionalScopes),
391
+ senderForTags: this.senderForTagsFrom(opts.from, opts.sendMessagesAs),
392
+ });
393
+ return new ProvenTx(
394
+ this.aztecNode,
395
+ await txProvingResult.toTx(),
396
+ txProvingResult.getOffchainEffects(),
397
+ txProvingResult.stats,
398
+ );
399
+ }
400
+
401
+ getTxReceipt(txHash: TxHash): Promise<TxReceipt> {
402
+ return this.aztecNode.getTxReceipt(txHash);
403
+ }
404
+
405
+ getNotes(filter: NotesFilter): Promise<NoteDao[]> {
406
+ return this.pxe.debug.getNotes(filter);
407
+ }
408
+
409
+ getSyncedBlockHeader(): Promise<BlockHeader> {
410
+ return this.pxe.getSyncedBlockHeader();
411
+ }
412
+
413
+ sync(): Promise<void> {
414
+ return this.pxe.sync();
415
+ }
416
+
417
+ /**
418
+ * Registers a non-sender tagging-secret source (e.g. a raw out-of-band shared secret) so this PXE discovers messages
419
+ * tagged with it. Test-only surface over {@link PXE.registerTaggingSecretSource}, which the base `Wallet` does not
420
+ * expose. The `address-derived` (sender) variant is excluded: use {@link Wallet.registerSender} for that.
421
+ */
422
+ registerTaggingSecretSource(source: Exclude<TaggingSecretSource, { kind: 'address-derived' }>): Promise<void> {
423
+ return this.pxe.registerTaggingSecretSource(source);
424
+ }
425
+
426
+ stop(): Promise<void> {
427
+ return this.pxe.stop();
428
+ }
429
+ }
@@ -0,0 +1,205 @@
1
+ import type { AztecAddress } from '@aztec/aztec.js/addresses';
2
+ import {
3
+ BatchCall,
4
+ ContractFunctionInteraction,
5
+ DeployMethod,
6
+ type DeployOptions,
7
+ NO_WAIT,
8
+ type NoWait,
9
+ type SendInteractionOptions,
10
+ type WaitOpts,
11
+ toSendOptions,
12
+ } from '@aztec/aztec.js/contracts';
13
+ import { type AztecNode, waitForTx } from '@aztec/aztec.js/node';
14
+ import { timesAsync } from '@aztec/foundation/collection';
15
+ import type { Logger } from '@aztec/foundation/log';
16
+ import { sleep } from '@aztec/foundation/sleep';
17
+ import { SimulationError } from '@aztec/stdlib/errors';
18
+ import { type OffchainEffect, type ProvingStats, Tx, TxHash, type TxReceipt } from '@aztec/stdlib/tx';
19
+
20
+ import { inspect } from 'util';
21
+
22
+ import { testSpan, withTestSpanOwner } from '../fixtures/timing.js';
23
+ import type { TestWallet } from './test_wallet.js';
24
+
25
+ export type ProvenTxSendOpts = {
26
+ wait?: NoWait | WaitOpts;
27
+ };
28
+
29
+ export type ProvenTxSendReturn<T extends NoWait | WaitOpts | undefined> = T extends NoWait ? TxHash : TxReceipt;
30
+
31
+ export class ProvenTx extends Tx {
32
+ constructor(
33
+ private node: AztecNode,
34
+ tx: Tx,
35
+ public offchainEffects: OffchainEffect[],
36
+ public stats?: ProvingStats,
37
+ ) {
38
+ super(tx.getTxHash(), tx.data, tx.chonkProof, tx.contractClassLogFields, tx.publicFunctionCalldata);
39
+ }
40
+
41
+ send(options?: Omit<ProvenTxSendOpts, 'wait'>): Promise<TxReceipt>;
42
+ send<W extends ProvenTxSendOpts['wait']>(options: ProvenTxSendOpts & { wait: W }): Promise<ProvenTxSendReturn<W>>;
43
+ send(options?: ProvenTxSendOpts): Promise<TxHash | TxReceipt> {
44
+ return testSpan('tx:send', () => this.sendInner(options));
45
+ }
46
+
47
+ private async sendInner(options?: ProvenTxSendOpts): Promise<TxHash | TxReceipt> {
48
+ const txHash = this.getTxHash();
49
+ await this.node.sendTx(this).catch(err => {
50
+ throw this.contextualizeError(err, inspect(this));
51
+ });
52
+
53
+ if (options?.wait === NO_WAIT) {
54
+ return txHash;
55
+ }
56
+
57
+ const waitOpts = typeof options?.wait === 'object' ? options.wait : undefined;
58
+ return await waitForTx(this.node, txHash, waitOpts);
59
+ }
60
+
61
+ private contextualizeError(err: Error, ...context: string[]): Error {
62
+ let contextStr = '';
63
+ if (context.length > 0) {
64
+ contextStr = `\nContext:\n${context.join('\n')}`;
65
+ }
66
+ if (err instanceof SimulationError) {
67
+ err.setAztecContext(contextStr);
68
+ }
69
+ return err;
70
+ }
71
+ }
72
+
73
+ export function proveInteraction(
74
+ wallet: TestWallet,
75
+ interaction: ContractFunctionInteraction | DeployMethod | BatchCall,
76
+ options: SendInteractionOptions | DeployOptions,
77
+ ): Promise<ProvenTx> {
78
+ return testSpan('tx:prove', async () => {
79
+ const execPayload = await interaction.request(options);
80
+ return wallet.proveTx(execPayload, toSendOptions(options));
81
+ });
82
+ }
83
+
84
+ /** Builds an interaction for index `i` of a batch. */
85
+ export type MakeBatchCall = (i: number) => ContractFunctionInteraction | DeployMethod | BatchCall;
86
+
87
+ /**
88
+ * Pre-proves `count` interactions built by `makeCall(i)` against `wallet`, all with the same
89
+ * `options`. Returns the proven txs so the caller can send them individually (e.g. with sleeps
90
+ * between sends, or anchored to intermediate tips). For the common "send the whole batch at once"
91
+ * case use {@link proveAndSendTxs}.
92
+ */
93
+ export function proveTxs(
94
+ wallet: TestWallet,
95
+ count: number,
96
+ makeCall: MakeBatchCall,
97
+ options: SendInteractionOptions | DeployOptions,
98
+ ): Promise<ProvenTx[]> {
99
+ return timesAsync(count, i => proveInteraction(wallet, makeCall(i), options));
100
+ }
101
+
102
+ /**
103
+ * Pre-proves `count` interactions built by `makeCall(i)` and sends each one with `NO_WAIT`, all at
104
+ * once. Returns the tx hashes in batch order. Pairs with `waitForTxs` for the "send N, wait for N"
105
+ * arc. Use {@link proveTxs} instead when the sends need bespoke sequencing.
106
+ */
107
+ export async function proveAndSendTxs(
108
+ wallet: TestWallet,
109
+ count: number,
110
+ makeCall: MakeBatchCall,
111
+ options: SendInteractionOptions | DeployOptions,
112
+ ): Promise<TxHash[]> {
113
+ const txs = await proveTxs(wallet, count, makeCall, options);
114
+ return Promise.all(txs.map(tx => tx.send({ wait: NO_WAIT })));
115
+ }
116
+
117
+ /** Options for {@link startMempoolFeeder}. */
118
+ export type MempoolFeederOpts = {
119
+ /** The account the txs are sent from. */
120
+ from: AztecAddress;
121
+ /** Keep the pending-tx count at or above this threshold; defaults to 3. */
122
+ minPending?: number;
123
+ /** Milliseconds between top-up polls; defaults to 1000. */
124
+ intervalMs?: number;
125
+ /** Logger for verbose top-up traces. */
126
+ logger?: Logger;
127
+ };
128
+
129
+ /**
130
+ * Starts a background loop that keeps `node`'s mempool topped up: whenever the pending-tx count drops
131
+ * below `opts.minPending`, it proves and sends one interaction built by `makeCall()` (NO_WAIT). Errors
132
+ * are swallowed and retried. Returns an {@link AsyncDisposable}; disposing stops the loop and awaits it.
133
+ */
134
+ export function startMempoolFeeder(
135
+ wallet: TestWallet,
136
+ node: AztecNode,
137
+ makeCall: () => ContractFunctionInteraction | DeployMethod | BatchCall,
138
+ opts: MempoolFeederOpts,
139
+ ): AsyncDisposable {
140
+ const minPending = opts.minPending ?? 3;
141
+ const intervalMs = opts.intervalMs ?? 1000;
142
+ let stopped = false;
143
+
144
+ // Pin the feeder's prove/send spans to a fixed non-test owner. It runs interleaved with arbitrary
145
+ // tests, so without this its tx:prove/tx:send spans would smear onto whichever test was current
146
+ // when each round fired; the pinned owner matches no test/suite record, excluding them cleanly.
147
+ const loop = withTestSpanOwner('other:mempool-feeder', async () => {
148
+ while (!stopped) {
149
+ try {
150
+ const pendingCount = await node.getPendingTxCount();
151
+ if (pendingCount < minPending) {
152
+ await proveAndSendTxs(wallet, 1, makeCall, { from: opts.from });
153
+ opts.logger?.verbose(`Topped up mempool (was ${pendingCount})`);
154
+ }
155
+ } catch (err) {
156
+ opts.logger?.verbose(`Mempool top-up error (will retry): ${err}`);
157
+ }
158
+ await sleep(intervalMs);
159
+ }
160
+ });
161
+
162
+ return {
163
+ async [Symbol.asyncDispose]() {
164
+ stopped = true;
165
+ await loop;
166
+ },
167
+ };
168
+ }
169
+
170
+ /**
171
+ * Extends AztecNode via declaration merging so instances can be used wherever AztecNode is expected.
172
+ * The actual method forwarding is handled by a Proxy in the class constructor.
173
+ */
174
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging
175
+ export interface AztecNodeProxy extends AztecNode {}
176
+
177
+ /**
178
+ * Mutable wrapper around an AztecNode that forwards all calls to the current target.
179
+ * Allows swapping the underlying node at runtime via updateTargetNode, which is useful
180
+ * for tests that need to redirect a wallet from one node to another without recreating it.
181
+ */
182
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging
183
+ export class AztecNodeProxy {
184
+ constructor(private target: AztecNode) {
185
+ return new Proxy(this, {
186
+ get: (obj, prop, receiver) => {
187
+ // Own properties and methods (updateTargetNode, target) are served directly.
188
+ if (Reflect.has(obj, prop)) {
189
+ return Reflect.get(obj, prop, receiver);
190
+ }
191
+ // Everything else is forwarded to the current target node.
192
+ const val = (obj.target as unknown as Record<string | symbol, unknown>)[prop];
193
+ return typeof val === 'function' ? val.bind(obj.target) : val;
194
+ },
195
+ });
196
+ }
197
+
198
+ /**
199
+ * Updates the underlying node that this reference points to.
200
+ * @param node - The new node to forward calls to.
201
+ */
202
+ updateTargetNode(node: AztecNode): void {
203
+ this.target = node;
204
+ }
205
+ }