@aztec/end-to-end 0.0.1-commit.b6e433891 → 0.0.1-commit.b8a057fa

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 (298) 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/{e2e_storage_proof → automine/contracts}/fixtures/storage_proof_fixture.d.ts +1 -1
  8. package/dest/automine/contracts/fixtures/storage_proof_fixture.d.ts.map +1 -0
  9. package/dest/automine/delivery/onchain_delivery_harness.d.ts +17 -0
  10. package/dest/automine/delivery/onchain_delivery_harness.d.ts.map +1 -0
  11. package/dest/automine/delivery/onchain_delivery_harness.js +123 -0
  12. package/dest/automine/token/blacklist_token_contract_test.d.ts +49 -0
  13. package/dest/automine/token/blacklist_token_contract_test.d.ts.map +1 -0
  14. package/dest/{e2e_blacklist_token_contract → automine/token}/blacklist_token_contract_test.js +23 -36
  15. package/dest/automine/token/token_contract_test.d.ts +40 -0
  16. package/dest/automine/token/token_contract_test.d.ts.map +1 -0
  17. package/dest/{e2e_token_contract → automine/token}/token_contract_test.js +24 -39
  18. package/dest/automine/token/token_test_helpers.d.ts +73 -0
  19. package/dest/automine/token/token_test_helpers.d.ts.map +1 -0
  20. package/dest/automine/token/token_test_helpers.js +97 -0
  21. package/dest/bench/client_flows/benchmark.d.ts +15 -1
  22. package/dest/bench/client_flows/benchmark.d.ts.map +1 -1
  23. package/dest/bench/client_flows/benchmark.js +19 -0
  24. package/dest/bench/client_flows/client_flows_benchmark.d.ts +5 -5
  25. package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -1
  26. package/dest/bench/client_flows/client_flows_benchmark.js +53 -52
  27. package/dest/bench/client_flows/data_extractor.js +1 -0
  28. package/dest/bench/utils.d.ts +3 -3
  29. package/dest/bench/utils.d.ts.map +1 -1
  30. package/dest/bench/utils.js +97 -6
  31. package/dest/composed/ha/ha_full_setup.d.ts +77 -0
  32. package/dest/composed/ha/ha_full_setup.d.ts.map +1 -0
  33. package/dest/composed/ha/ha_full_setup.js +383 -0
  34. package/dest/composed/web3signer/multi_validator_keystore_utils.d.ts +12 -0
  35. package/dest/composed/web3signer/multi_validator_keystore_utils.d.ts.map +1 -0
  36. package/dest/fixtures/authwit_proxy.d.ts +1 -1
  37. package/dest/fixtures/authwit_proxy.d.ts.map +1 -1
  38. package/dest/fixtures/authwit_proxy.js +4 -0
  39. package/dest/fixtures/e2e_prover_test.d.ts +15 -11
  40. package/dest/fixtures/e2e_prover_test.d.ts.map +1 -1
  41. package/dest/fixtures/e2e_prover_test.js +55 -40
  42. package/dest/fixtures/fixtures.d.ts +78 -1
  43. package/dest/fixtures/fixtures.d.ts.map +1 -1
  44. package/dest/fixtures/fixtures.js +78 -0
  45. package/dest/fixtures/get_bb_config.d.ts +1 -1
  46. package/dest/fixtures/get_bb_config.d.ts.map +1 -1
  47. package/dest/fixtures/get_bb_config.js +5 -5
  48. package/dest/fixtures/ha_setup.d.ts +4 -4
  49. package/dest/fixtures/ha_setup.d.ts.map +1 -1
  50. package/dest/fixtures/ha_setup.js +5 -2
  51. package/dest/fixtures/index.d.ts +2 -1
  52. package/dest/fixtures/index.d.ts.map +1 -1
  53. package/dest/fixtures/index.js +1 -0
  54. package/dest/fixtures/schnorr_hardcoded_account_contract.d.ts +25 -0
  55. package/dest/fixtures/schnorr_hardcoded_account_contract.d.ts.map +1 -0
  56. package/dest/fixtures/schnorr_hardcoded_account_contract.js +37 -0
  57. package/dest/fixtures/setup.d.ts +71 -41
  58. package/dest/fixtures/setup.d.ts.map +1 -1
  59. package/dest/fixtures/setup.js +283 -201
  60. package/dest/fixtures/setup_p2p_test.d.ts +10 -6
  61. package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
  62. package/dest/fixtures/setup_p2p_test.js +11 -11
  63. package/dest/fixtures/timing.d.ts +42 -0
  64. package/dest/fixtures/timing.d.ts.map +1 -0
  65. package/dest/fixtures/timing.js +72 -0
  66. package/dest/fixtures/token_utils.d.ts +22 -4
  67. package/dest/fixtures/token_utils.d.ts.map +1 -1
  68. package/dest/fixtures/token_utils.js +23 -6
  69. package/dest/fixtures/utils.d.ts +2 -2
  70. package/dest/fixtures/utils.d.ts.map +1 -1
  71. package/dest/fixtures/utils.js +1 -1
  72. package/dest/fixtures/wait_helpers.d.ts +135 -0
  73. package/dest/fixtures/wait_helpers.d.ts.map +1 -0
  74. package/dest/fixtures/wait_helpers.js +154 -0
  75. package/dest/forward-compatibility/wallet_rpc_client.d.ts +7 -0
  76. package/dest/forward-compatibility/wallet_rpc_client.d.ts.map +1 -0
  77. package/dest/forward-compatibility/wallet_rpc_client.js +15 -0
  78. package/dest/forward-compatibility/wallet_service.d.ts +3 -0
  79. package/dest/forward-compatibility/wallet_service.d.ts.map +1 -0
  80. package/dest/forward-compatibility/wallet_service.js +109 -0
  81. package/dest/install_legacy_contracts.d.cts +10 -0
  82. package/dest/install_legacy_contracts.d.cts.map +1 -0
  83. package/dest/legacy-jest-resolver.d.cts +3 -0
  84. package/dest/legacy-jest-resolver.d.cts.map +1 -0
  85. package/dest/multi-node/block-production/setup.d.ts +97 -0
  86. package/dest/multi-node/block-production/setup.d.ts.map +1 -0
  87. package/dest/multi-node/block-production/setup.js +158 -0
  88. package/dest/multi-node/governance/setup.d.ts +67 -0
  89. package/dest/multi-node/governance/setup.d.ts.map +1 -0
  90. package/dest/multi-node/governance/setup.js +126 -0
  91. package/dest/multi-node/multi_node_test_context.d.ts +212 -0
  92. package/dest/multi-node/multi_node_test_context.d.ts.map +1 -0
  93. package/dest/multi-node/multi_node_test_context.js +347 -0
  94. package/dest/multi-node/slashing/inactivity_setup.d.ts +27 -0
  95. package/dest/multi-node/slashing/inactivity_setup.d.ts.map +1 -0
  96. package/dest/multi-node/slashing/inactivity_setup.js +111 -0
  97. package/dest/multi-node/slashing/setup.d.ts +167 -0
  98. package/dest/multi-node/slashing/setup.d.ts.map +1 -0
  99. package/dest/multi-node/slashing/setup.js +275 -0
  100. package/dest/{e2e_p2p → p2p}/p2p_network.d.ts +19 -10
  101. package/dest/p2p/p2p_network.d.ts.map +1 -0
  102. package/dest/{e2e_p2p → p2p}/p2p_network.js +81 -38
  103. package/dest/p2p/reqresp/utils.d.ts +19 -0
  104. package/dest/p2p/reqresp/utils.d.ts.map +1 -0
  105. package/dest/{e2e_p2p → p2p}/reqresp/utils.js +32 -29
  106. package/dest/p2p/shared.d.ts +72 -0
  107. package/dest/p2p/shared.d.ts.map +1 -0
  108. package/dest/p2p/shared.js +212 -0
  109. package/dest/shared/cross_chain_test_harness.d.ts +6 -4
  110. package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
  111. package/dest/shared/cross_chain_test_harness.js +25 -20
  112. package/dest/shared/gas_portal_test_harness.d.ts +8 -5
  113. package/dest/shared/gas_portal_test_harness.d.ts.map +1 -1
  114. package/dest/shared/gas_portal_test_harness.js +24 -12
  115. package/dest/shared/submit-transactions.d.ts +1 -1
  116. package/dest/shared/submit-transactions.d.ts.map +1 -1
  117. package/dest/shared/submit-transactions.js +12 -5
  118. package/dest/shared/timing_env.d.js +5 -0
  119. package/dest/shared/timing_env.js +365 -0
  120. package/dest/shared/uniswap_l1_l2.d.ts +1 -1
  121. package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
  122. package/dest/shared/uniswap_l1_l2.js +50 -37
  123. package/dest/shared/wait_for_l1_to_l2_message.d.ts +13 -0
  124. package/dest/shared/wait_for_l1_to_l2_message.d.ts.map +1 -0
  125. package/dest/shared/wait_for_l1_to_l2_message.js +10 -0
  126. package/dest/simulators/lending_simulator.d.ts +10 -3
  127. package/dest/simulators/lending_simulator.d.ts.map +1 -1
  128. package/dest/simulators/lending_simulator.js +25 -13
  129. package/dest/single-node/cross-chain/cross_chain_messaging_test.d.ts +75 -0
  130. package/dest/single-node/cross-chain/cross_chain_messaging_test.d.ts.map +1 -0
  131. package/dest/single-node/cross-chain/cross_chain_messaging_test.js +209 -0
  132. package/dest/single-node/cross-chain/message_test_helpers.d.ts +38 -0
  133. package/dest/single-node/cross-chain/message_test_helpers.d.ts.map +1 -0
  134. package/dest/single-node/cross-chain/message_test_helpers.js +70 -0
  135. package/dest/{e2e_fees → single-node/fees}/bridging_race.notest.d.ts +1 -1
  136. package/dest/single-node/fees/bridging_race.notest.d.ts.map +1 -0
  137. package/dest/{e2e_fees → single-node/fees}/bridging_race.notest.js +17 -4
  138. package/dest/single-node/fees/fees_test.d.ts +93 -0
  139. package/dest/single-node/fees/fees_test.d.ts.map +1 -0
  140. package/dest/{e2e_fees → single-node/fees}/fees_test.js +78 -59
  141. package/dest/single-node/l1-reorgs/setup.d.ts +42 -0
  142. package/dest/single-node/l1-reorgs/setup.d.ts.map +1 -0
  143. package/dest/single-node/l1-reorgs/setup.js +57 -0
  144. package/dest/single-node/partial-proofs/setup.d.ts +5 -0
  145. package/dest/single-node/partial-proofs/setup.d.ts.map +1 -0
  146. package/dest/single-node/partial-proofs/setup.js +5 -0
  147. package/dest/single-node/proving/setup.d.ts +5 -0
  148. package/dest/single-node/proving/setup.d.ts.map +1 -0
  149. package/dest/single-node/proving/setup.js +5 -0
  150. package/dest/single-node/recovery/setup.d.ts +5 -0
  151. package/dest/single-node/recovery/setup.d.ts.map +1 -0
  152. package/dest/single-node/recovery/setup.js +5 -0
  153. package/dest/single-node/setup.d.ts +49 -0
  154. package/dest/single-node/setup.d.ts.map +1 -0
  155. package/dest/single-node/setup.js +56 -0
  156. package/dest/single-node/single_node_test_context.d.ts +360 -0
  157. package/dest/single-node/single_node_test_context.d.ts.map +1 -0
  158. package/dest/single-node/single_node_test_context.js +833 -0
  159. package/dest/spartan/setup_test_wallets.d.ts +1 -1
  160. package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
  161. package/dest/spartan/setup_test_wallets.js +83 -49
  162. package/dest/spartan/tx_metrics.d.ts +27 -4
  163. package/dest/spartan/tx_metrics.d.ts.map +1 -1
  164. package/dest/spartan/tx_metrics.js +105 -20
  165. package/dest/spartan/utils/config.d.ts +9 -35
  166. package/dest/spartan/utils/config.d.ts.map +1 -1
  167. package/dest/spartan/utils/nodes.js +2 -2
  168. package/dest/test-wallet/test_wallet.d.ts +38 -9
  169. package/dest/test-wallet/test_wallet.d.ts.map +1 -1
  170. package/dest/test-wallet/test_wallet.js +186 -77
  171. package/dest/test-wallet/utils.d.ts +38 -3
  172. package/dest/test-wallet/utils.d.ts.map +1 -1
  173. package/dest/test-wallet/utils.js +65 -10
  174. package/dest/test-wallet/wallet_worker_script.js +10 -2
  175. package/dest/test-wallet/worker_wallet.d.ts +7 -6
  176. package/dest/test-wallet/worker_wallet.d.ts.map +1 -1
  177. package/dest/test-wallet/worker_wallet.js +6 -2
  178. package/dest/test-wallet/worker_wallet_schema.d.ts +3 -273
  179. package/dest/test-wallet/worker_wallet_schema.d.ts.map +1 -1
  180. package/dest/test-wallet/worker_wallet_schema.js +14 -2
  181. package/package.json +47 -42
  182. package/src/automine/README.md +60 -0
  183. package/src/automine/automine_test_context.ts +153 -0
  184. package/src/automine/delivery/onchain_delivery_harness.ts +177 -0
  185. package/src/{e2e_blacklist_token_contract → automine/token}/blacklist_token_contract_test.ts +24 -47
  186. package/src/{e2e_token_contract → automine/token}/token_contract_test.ts +25 -48
  187. package/src/automine/token/token_test_helpers.ts +138 -0
  188. package/src/bench/client_flows/benchmark.ts +21 -0
  189. package/src/bench/client_flows/client_flows_benchmark.ts +103 -73
  190. package/src/bench/client_flows/data_extractor.ts +1 -0
  191. package/src/bench/utils.ts +110 -6
  192. package/src/composed/ha/ha_full_setup.ts +466 -0
  193. package/src/fixtures/authwit_proxy.ts +4 -0
  194. package/src/fixtures/e2e_prover_test.ts +66 -63
  195. package/src/fixtures/fixtures.ts +98 -0
  196. package/src/fixtures/get_bb_config.ts +7 -6
  197. package/src/fixtures/ha_setup.ts +11 -5
  198. package/src/fixtures/index.ts +1 -0
  199. package/src/fixtures/schnorr_hardcoded_account_contract.ts +49 -0
  200. package/src/fixtures/setup.ts +342 -258
  201. package/src/fixtures/setup_p2p_test.ts +15 -11
  202. package/src/fixtures/timing.ts +97 -0
  203. package/src/fixtures/token_utils.ts +40 -8
  204. package/src/fixtures/utils.ts +2 -3
  205. package/src/fixtures/wait_helpers.ts +333 -0
  206. package/src/forward-compatibility/wallet_rpc_client.ts +14 -0
  207. package/src/forward-compatibility/wallet_service.ts +106 -0
  208. package/src/guides/up_quick_start.sh +5 -2
  209. package/src/infra/README.md +12 -0
  210. package/src/install_legacy_contracts.cjs +75 -0
  211. package/src/legacy-jest-resolver.cjs +112 -0
  212. package/src/multi-node/README.md +95 -0
  213. package/src/multi-node/block-production/setup.ts +272 -0
  214. package/src/multi-node/governance/setup.ts +172 -0
  215. package/src/multi-node/multi_node_test_context.ts +447 -0
  216. package/src/multi-node/slashing/inactivity_setup.ts +139 -0
  217. package/src/multi-node/slashing/setup.ts +433 -0
  218. package/src/p2p/README.md +78 -0
  219. package/src/{e2e_p2p → p2p}/p2p_network.ts +92 -49
  220. package/src/{e2e_p2p → p2p}/reqresp/utils.ts +35 -28
  221. package/src/p2p/shared.ts +329 -0
  222. package/src/shared/cross_chain_test_harness.ts +35 -14
  223. package/src/shared/gas_portal_test_harness.ts +32 -14
  224. package/src/shared/submit-transactions.ts +13 -5
  225. package/src/shared/timing_env.d.mts +39 -0
  226. package/src/shared/timing_env.mjs +363 -0
  227. package/src/shared/uniswap_l1_l2.ts +80 -43
  228. package/src/shared/wait_for_l1_to_l2_message.ts +23 -0
  229. package/src/simulators/lending_simulator.ts +29 -13
  230. package/src/single-node/README.md +60 -0
  231. package/src/single-node/cross-chain/cross_chain_messaging_test.ts +302 -0
  232. package/src/single-node/cross-chain/message_test_helpers.ts +125 -0
  233. package/src/{e2e_fees → single-node/fees}/bridging_race.notest.ts +19 -5
  234. package/src/{e2e_fees → single-node/fees}/fees_test.ts +103 -66
  235. package/src/single-node/l1-reorgs/setup.ts +93 -0
  236. package/src/single-node/partial-proofs/setup.ts +8 -0
  237. package/src/single-node/proving/setup.ts +15 -0
  238. package/src/single-node/recovery/setup.ts +8 -0
  239. package/src/single-node/setup.ts +63 -0
  240. package/src/single-node/single_node_test_context.ts +1041 -0
  241. package/src/spartan/setup_test_wallets.ts +79 -44
  242. package/src/spartan/tx_metrics.ts +107 -23
  243. package/src/spartan/utils/nodes.ts +2 -2
  244. package/src/test-wallet/test_wallet.ts +213 -78
  245. package/src/test-wallet/utils.ts +104 -11
  246. package/src/test-wallet/wallet_worker_script.ts +8 -2
  247. package/src/test-wallet/worker_wallet.ts +12 -11
  248. package/src/test-wallet/worker_wallet_schema.ts +4 -3
  249. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +0 -55
  250. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts.map +0 -1
  251. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +0 -47
  252. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts.map +0 -1
  253. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.js +0 -129
  254. package/dest/e2e_deploy_contract/deploy_test.d.ts +0 -37
  255. package/dest/e2e_deploy_contract/deploy_test.d.ts.map +0 -1
  256. package/dest/e2e_deploy_contract/deploy_test.js +0 -50
  257. package/dest/e2e_epochs/epochs_test.d.ts +0 -104
  258. package/dest/e2e_epochs/epochs_test.d.ts.map +0 -1
  259. package/dest/e2e_epochs/epochs_test.js +0 -389
  260. package/dest/e2e_fees/bridging_race.notest.d.ts.map +0 -1
  261. package/dest/e2e_fees/fees_test.d.ts +0 -88
  262. package/dest/e2e_fees/fees_test.d.ts.map +0 -1
  263. package/dest/e2e_l1_publisher/write_json.d.ts +0 -11
  264. package/dest/e2e_l1_publisher/write_json.d.ts.map +0 -1
  265. package/dest/e2e_l1_publisher/write_json.js +0 -56
  266. package/dest/e2e_multi_validator/utils.d.ts +0 -12
  267. package/dest/e2e_multi_validator/utils.d.ts.map +0 -1
  268. package/dest/e2e_nested_contract/nested_contract_test.d.ts +0 -26
  269. package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +0 -1
  270. package/dest/e2e_nested_contract/nested_contract_test.js +0 -54
  271. package/dest/e2e_p2p/inactivity_slash_test.d.ts +0 -31
  272. package/dest/e2e_p2p/inactivity_slash_test.d.ts.map +0 -1
  273. package/dest/e2e_p2p/inactivity_slash_test.js +0 -136
  274. package/dest/e2e_p2p/p2p_network.d.ts.map +0 -1
  275. package/dest/e2e_p2p/reqresp/utils.d.ts +0 -22
  276. package/dest/e2e_p2p/reqresp/utils.d.ts.map +0 -1
  277. package/dest/e2e_p2p/shared.d.ts +0 -66
  278. package/dest/e2e_p2p/shared.d.ts.map +0 -1
  279. package/dest/e2e_p2p/shared.js +0 -212
  280. package/dest/e2e_storage_proof/fixtures/storage_proof_fetcher.d.ts +0 -2
  281. package/dest/e2e_storage_proof/fixtures/storage_proof_fetcher.d.ts.map +0 -1
  282. package/dest/e2e_storage_proof/fixtures/storage_proof_fixture.d.ts.map +0 -1
  283. package/dest/e2e_token_contract/token_contract_test.d.ts +0 -44
  284. package/dest/e2e_token_contract/token_contract_test.d.ts.map +0 -1
  285. package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +0 -193
  286. package/src/e2e_deploy_contract/deploy_test.ts +0 -85
  287. package/src/e2e_epochs/epochs_test.ts +0 -499
  288. package/src/e2e_l1_publisher/write_json.ts +0 -77
  289. package/src/e2e_nested_contract/nested_contract_test.ts +0 -75
  290. package/src/e2e_p2p/inactivity_slash_test.ts +0 -179
  291. package/src/e2e_p2p/shared.ts +0 -343
  292. /package/dest/{e2e_storage_proof → automine/contracts}/fixtures/storage_proof_fetcher.js +0 -0
  293. /package/dest/{e2e_storage_proof → automine/contracts}/fixtures/storage_proof_fixture.js +0 -0
  294. /package/dest/{e2e_multi_validator/utils.js → composed/web3signer/multi_validator_keystore_utils.js} +0 -0
  295. /package/src/{e2e_storage_proof → automine/contracts}/fixtures/storage_proof.json +0 -0
  296. /package/src/{e2e_storage_proof → automine/contracts}/fixtures/storage_proof_fetcher.ts +0 -0
  297. /package/src/{e2e_storage_proof → automine/contracts}/fixtures/storage_proof_fixture.ts +0 -0
  298. /package/src/{e2e_multi_validator/utils.ts → composed/web3signer/multi_validator_keystore_utils.ts} +0 -0
@@ -1,7 +1,9 @@
1
1
  import { EcdsaKAccountContract, EcdsaRAccountContract } from '@aztec/accounts/ecdsa';
2
- import { SchnorrAccountContract } from '@aztec/accounts/schnorr';
3
- import { StubAccountContractArtifact, createStubAccount } from '@aztec/accounts/stub';
4
- import { type Account, type AccountContract, SignerlessAccount } from '@aztec/aztec.js/account';
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';
5
7
  import {
6
8
  type CallIntent,
7
9
  type ContractFunctionInteractionCallIntent,
@@ -11,23 +13,35 @@ import {
11
13
  isContractFunctionInteractionCallIntent,
12
14
  lookupValidity,
13
15
  } from '@aztec/aztec.js/authorization';
16
+ import { ContractFunctionInteraction } from '@aztec/aztec.js/contracts';
14
17
  import type { AztecNode } from '@aztec/aztec.js/node';
15
18
  import { AccountManager, type SendOptions } from '@aztec/aztec.js/wallet';
19
+ import { TxSimulationResultWithAppOffset } from '@aztec/aztec.js/wallet';
16
20
  import type { DefaultAccountEntrypointOptions } from '@aztec/entrypoints/account';
21
+ import { DefaultEntrypoint } from '@aztec/entrypoints/default';
17
22
  import { Fq, Fr } from '@aztec/foundation/curves/bn254';
18
23
  import { GrumpkinScalar } from '@aztec/foundation/curves/grumpkin';
19
24
  import type { NotesFilter } from '@aztec/pxe/client/lazy';
20
25
  import { type PXEConfig, getPXEConfig } from '@aztec/pxe/config';
21
- import { PXE, type PXECreationOptions, createPXE } from '@aztec/pxe/server';
26
+ import { PXE, type PXECreationOptions, type TaggingSecretSource, createPXE } from '@aztec/pxe/server';
22
27
  import { AuthWitness } from '@aztec/stdlib/auth-witness';
23
28
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
24
- import { getContractInstanceFromInstantiationParams } from '@aztec/stdlib/contract';
29
+ import { getContractClassFromArtifact } from '@aztec/stdlib/contract';
25
30
  import { deriveSigningKey } from '@aztec/stdlib/keys';
26
31
  import type { NoteDao } from '@aztec/stdlib/note';
27
- import type { BlockHeader, SimulationOverrides, TxHash, TxReceipt, TxSimulationResult } from '@aztec/stdlib/tx';
32
+ import {
33
+ type BlockHeader,
34
+ type ContractOverrides,
35
+ SimulationOverrides,
36
+ type TxExecutionRequest,
37
+ type TxHash,
38
+ type TxReceipt,
39
+ } from '@aztec/stdlib/tx';
28
40
  import { ExecutionPayload, mergeExecutionPayloads } from '@aztec/stdlib/tx';
29
41
  import { BaseWallet, type SimulateViaEntrypointOptions } from '@aztec/wallet-sdk/base-wallet';
42
+ import type { AccountType } from '@aztec/wallets/embedded';
30
43
 
44
+ import { DEFAULT_MIN_FEE_PADDING } from '../fixtures/fixtures.js';
31
45
  import { AztecNodeProxy, ProvenTx } from './utils.js';
32
46
 
33
47
  /**
@@ -36,6 +50,7 @@ import { AztecNodeProxy, ProvenTx } from './utils.js';
36
50
  export interface AccountData {
37
51
  secret: Fr;
38
52
  salt: Fr;
53
+ type?: AccountType;
39
54
  contract: AccountContract;
40
55
  }
41
56
 
@@ -44,12 +59,29 @@ export interface AccountData {
44
59
  * utilities
45
60
  * It is intended to be used in e2e tests.
46
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
+
47
69
  export class TestWallet extends BaseWallet {
48
70
  constructor(
49
71
  pxe: PXE,
50
72
  private readonly nodeRef: AztecNodeProxy,
51
73
  ) {
52
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;
53
85
  }
54
86
 
55
87
  static async create(
@@ -63,7 +95,9 @@ export class TestWallet extends BaseWallet {
63
95
  ...overridePXEConfig,
64
96
  });
65
97
  const pxe = await createPXE(nodeRef, pxeConfig, options);
66
- return new TestWallet(pxe, nodeRef);
98
+ const wallet = new TestWallet(pxe, nodeRef);
99
+ await wallet.initStubClasses();
100
+ return wallet;
67
101
  }
68
102
 
69
103
  /**
@@ -76,53 +110,108 @@ export class TestWallet extends BaseWallet {
76
110
 
77
111
  createSchnorrAccount(secret: Fr, salt: Fr, signingKey?: Fq): Promise<AccountManager> {
78
112
  signingKey = signingKey ?? deriveSigningKey(secret);
79
- const accountData = {
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({
80
119
  secret,
81
120
  salt,
82
- contract: new SchnorrAccountContract(signingKey),
83
- };
84
- return this.createAccount(accountData);
121
+ type: 'schnorr_initializerless',
122
+ contract: new SchnorrInitializerlessAccountContract(signingKey),
123
+ });
85
124
  }
86
125
 
87
126
  createECDSARAccount(secret: Fr, salt: Fr, signingKey: Buffer): Promise<AccountManager> {
88
- const accountData = {
127
+ return this.createAccount({
89
128
  secret,
90
129
  salt,
130
+ type: 'ecdsasecp256r1',
91
131
  contract: new EcdsaRAccountContract(signingKey),
92
- };
93
- return this.createAccount(accountData);
132
+ });
94
133
  }
95
134
 
96
135
  createECDSAKAccount(secret: Fr, salt: Fr, signingKey: Buffer): Promise<AccountManager> {
97
- const accountData = {
136
+ return this.createAccount({
98
137
  secret,
99
138
  salt,
139
+ type: 'ecdsasecp256k1',
100
140
  contract: new EcdsaKAccountContract(signingKey),
101
- };
102
- return this.createAccount(accountData);
141
+ });
103
142
  }
104
143
 
105
- async getFakeAccountDataFor(address: AztecAddress) {
106
- const originalAccount = await this.getAccountFromAddress(address);
107
- if (originalAccount instanceof SignerlessAccount) {
108
- throw new Error(`Cannot create fake account data for SignerlessAccount at address: ${address}`);
109
- }
110
- const originalAddress = (originalAccount as Account).getCompleteAddress();
111
- const contractInstance = await this.pxe.getContractInstance(originalAddress.address);
112
- if (!contractInstance) {
113
- throw new Error(`No contract instance found for address: ${originalAddress.address}`);
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
+ };
114
198
  }
115
- const stubAccount = createStubAccount(originalAddress);
116
- const instance = await getContractInstanceFromInstantiationParams(StubAccountContractArtifact, {
117
- salt: Fr.random(),
118
- });
119
- return {
120
- account: stubAccount,
121
- instance,
122
- artifact: StubAccountContractArtifact,
123
- };
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);
124
214
  }
125
- protected accounts: Map<string, Account> = new Map();
126
215
 
127
216
  /**
128
217
  * Controls how the test wallet simulates transactions:
@@ -137,41 +226,54 @@ export class TestWallet extends BaseWallet {
137
226
  }
138
227
 
139
228
  setMinFeePadding(value?: number) {
140
- this.minFeePadding = value ?? 0.5;
229
+ this.minFeePadding = value ?? DEFAULT_MIN_FEE_PADDING;
141
230
  }
142
231
 
143
232
  protected getAccountFromAddress(address: AztecAddress): Promise<Account> {
144
- let account: Account | undefined;
145
- if (address.equals(AztecAddress.ZERO)) {
146
- account = new SignerlessAccount();
147
- } else {
148
- account = this.accounts.get(address?.toString() ?? '');
149
- }
233
+ const entry = this.accounts.get(address?.toString() ?? '');
150
234
 
151
- if (!account) {
235
+ if (!entry) {
152
236
  throw new Error(`Account not found in wallet for address: ${address}`);
153
237
  }
154
238
 
155
- return Promise.resolve(account);
239
+ return Promise.resolve(entry.account);
156
240
  }
157
241
 
158
242
  getAccounts() {
159
- return Promise.resolve(Array.from(this.accounts.values()).map(acc => ({ alias: '', item: acc.getAddress() })));
243
+ return Promise.resolve(
244
+ Array.from(this.accounts.values()).map(entry => ({ alias: '', item: entry.account.getAddress() })),
245
+ );
160
246
  }
161
247
 
162
248
  async createAccount(accountData?: AccountData): Promise<AccountManager> {
163
249
  const secret = accountData?.secret ?? Fr.random();
164
250
  const salt = accountData?.salt ?? Fr.random();
251
+ const type = accountData?.type ?? 'schnorr';
165
252
  const contract = accountData?.contract ?? new SchnorrAccountContract(GrumpkinScalar.random());
166
253
 
167
- const accountManager = await AccountManager.create(this, secret, contract, salt);
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 });
168
259
 
169
260
  const instance = accountManager.getInstance();
170
261
  const artifact = await contract.getContractArtifact();
171
262
 
172
263
  await this.registerContract(instance, artifact, secret);
173
264
 
174
- this.accounts.set(accountManager.address.toString(), await accountManager.getAccount());
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
+ }
175
277
 
176
278
  return accountManager;
177
279
  }
@@ -217,53 +319,77 @@ export class TestWallet extends BaseWallet {
217
319
  protected override async simulateViaEntrypoint(
218
320
  executionPayload: ExecutionPayload,
219
321
  opts: SimulateViaEntrypointOptions,
220
- ): Promise<TxSimulationResult> {
221
- const { from, feeOptions, scopes, skipTxValidation, skipFeeEnforcement } = opts;
322
+ ): Promise<TxSimulationResultWithAppOffset> {
323
+ const { from, feeOptions, additionalScopes, skipTxValidation, skipFeeEnforcement, sendMessagesAs } = opts;
324
+ const scopes = this.scopesFrom(from, additionalScopes);
222
325
  const skipKernels = this.simulationMode !== 'full';
223
- const useOverride = this.simulationMode === 'kernelless-override' && !from.equals(AztecAddress.ZERO);
224
-
225
- let overrides: SimulationOverrides | undefined;
226
- let fromAccount: Account;
227
- if (useOverride) {
228
- const { account, instance, artifact } = await this.getFakeAccountDataFor(from);
229
- fromAccount = account;
230
- overrides = {
231
- contracts: { [from.toString()]: { instance, artifact } },
232
- };
233
- } else {
234
- fromAccount = await this.getAccountFromAddress(from);
235
- }
326
+ const useOverride = this.simulationMode === 'kernelless-override';
236
327
 
237
328
  const feeExecutionPayload = await feeOptions.walletFeePaymentMethod?.getExecutionPayload();
238
- const executionOptions: DefaultAccountEntrypointOptions = {
239
- txNonce: Fr.random(),
240
- cancellable: this.cancellableTransactions,
241
- feePaymentMethodOptions: feeOptions.accountFeePaymentMethodOptions,
242
- };
243
329
  const finalExecutionPayload = feeExecutionPayload
244
330
  ? mergeExecutionPayloads([feeExecutionPayload, executionPayload])
245
331
  : executionPayload;
246
332
  const chainInfo = await this.getChainInfo();
247
- const txRequest = await fromAccount.createTxExecutionRequest(
248
- finalExecutionPayload,
249
- feeOptions.gasSettings,
250
- chainInfo,
251
- executionOptions,
252
- );
253
- return this.pxe.simulateTx(txRequest, {
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, {
254
370
  simulatePublic: true,
255
371
  skipKernels,
256
372
  skipFeeEnforcement,
257
373
  skipTxValidation,
258
374
  overrides,
259
375
  scopes,
376
+ senderForTags: this.senderForTagsFrom(from, sendMessagesAs),
260
377
  });
378
+ const appCallOffset = await this.computeAppCallOffset(from, feeOptions);
379
+ return TxSimulationResultWithAppOffset.fromResultAndOffset(result, appCallOffset);
261
380
  }
262
381
 
263
382
  async proveTx(exec: ExecutionPayload, opts: Omit<SendOptions, 'wait'>): Promise<ProvenTx> {
264
- const fee = await this.completeFeeOptions(opts.from, exec.feePayer, opts.fee?.gasSettings);
383
+ const fee = await this.completeFeeOptions({
384
+ from: opts.from,
385
+ feePayer: exec.feePayer,
386
+ gasSettings: opts.fee?.gasSettings,
387
+ });
265
388
  const txRequest = await this.createTxExecutionRequestFromPayloadAndFee(exec, opts.from, fee);
266
- const txProvingResult = await this.pxe.proveTx(txRequest, this.scopesFrom(opts.from, opts.additionalScopes));
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
+ });
267
393
  return new ProvenTx(
268
394
  this.aztecNode,
269
395
  await txProvingResult.toTx(),
@@ -285,7 +411,16 @@ export class TestWallet extends BaseWallet {
285
411
  }
286
412
 
287
413
  sync(): Promise<void> {
288
- return this.pxe.debug.sync();
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);
289
424
  }
290
425
 
291
426
  stop(): Promise<void> {
@@ -1,4 +1,6 @@
1
+ import type { AztecAddress } from '@aztec/aztec.js/addresses';
1
2
  import {
3
+ BatchCall,
2
4
  ContractFunctionInteraction,
3
5
  DeployMethod,
4
6
  type DeployOptions,
@@ -9,11 +11,15 @@ import {
9
11
  toSendOptions,
10
12
  } from '@aztec/aztec.js/contracts';
11
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';
12
17
  import { SimulationError } from '@aztec/stdlib/errors';
13
18
  import { type OffchainEffect, type ProvingStats, Tx, TxHash, type TxReceipt } from '@aztec/stdlib/tx';
14
19
 
15
20
  import { inspect } from 'util';
16
21
 
22
+ import { testSpan, withTestSpanOwner } from '../fixtures/timing.js';
17
23
  import type { TestWallet } from './test_wallet.js';
18
24
 
19
25
  export type ProvenTxSendOpts = {
@@ -34,7 +40,11 @@ export class ProvenTx extends Tx {
34
40
 
35
41
  send(options?: Omit<ProvenTxSendOpts, 'wait'>): Promise<TxReceipt>;
36
42
  send<W extends ProvenTxSendOpts['wait']>(options: ProvenTxSendOpts & { wait: W }): Promise<ProvenTxSendReturn<W>>;
37
- async send(options?: ProvenTxSendOpts): Promise<TxHash | TxReceipt> {
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> {
38
48
  const txHash = this.getTxHash();
39
49
  await this.node.sendTx(this).catch(err => {
40
50
  throw this.contextualizeError(err, inspect(this));
@@ -60,18 +70,101 @@ export class ProvenTx extends Tx {
60
70
  }
61
71
  }
62
72
 
63
- export async function proveInteraction(
73
+ export function proveInteraction(
64
74
  wallet: TestWallet,
65
- interaction: ContractFunctionInteraction | DeployMethod,
75
+ interaction: ContractFunctionInteraction | DeployMethod | BatchCall,
66
76
  options: SendInteractionOptions | DeployOptions,
67
- ) {
68
- let execPayload;
69
- if (interaction instanceof DeployMethod) {
70
- execPayload = await interaction.request(interaction.convertDeployOptionsToRequestOptions(options));
71
- } else {
72
- execPayload = await interaction.request(options);
73
- }
74
- return wallet.proveTx(execPayload, toSendOptions(options));
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
+ };
75
168
  }
76
169
 
77
170
  /**
@@ -1,9 +1,11 @@
1
+ import { DefaultWaitOpts } from '@aztec/aztec.js/contracts';
1
2
  import { createAztecNodeClient } from '@aztec/aztec.js/node';
2
3
  import type { SendOptions } from '@aztec/aztec.js/wallet';
4
+ import { BackendType, BarretenbergSync } from '@aztec/bb.js';
3
5
  import { jsonStringify } from '@aztec/foundation/json-rpc';
4
6
  import { createLogger } from '@aztec/foundation/log';
5
7
  import type { ApiSchema, Fr } from '@aztec/foundation/schemas';
6
- import { parseWithOptionals, schemaHasMethod } from '@aztec/foundation/schemas';
8
+ import { getSchemaParameters, parseWithOptionals, schemaHasMethod } from '@aztec/foundation/schemas';
7
9
  import { NodeListener, TransportServer } from '@aztec/foundation/transport';
8
10
  import { ExecutionPayload, Tx } from '@aztec/stdlib/tx';
9
11
 
@@ -19,7 +21,11 @@ try {
19
21
 
20
22
  logger.info('Initializing worker wallet', { nodeUrl });
21
23
  const node = createAztecNodeClient(nodeUrl);
24
+ // Worker sync bb use is limited to crypto and proof serialization helpers.
25
+ await BarretenbergSync.initSingleton({ backend: BackendType.Wasm });
22
26
  const wallet = await TestWallet.create(node, pxeConfig);
27
+ // Worker wallets are only used by spartan tests against remote JSON-RPC nodes: keep the 1s poll cadence.
28
+ wallet.setDefaultWaitInterval(DefaultWaitOpts.interval);
23
29
  logger.info('Worker wallet initialized');
24
30
 
25
31
  const customMethods = {
@@ -46,7 +52,7 @@ try {
46
52
  throw new Error(`Unknown method: ${msg.fn}`);
47
53
  }
48
54
  const jsonParams = JSON.parse(msg.args) as unknown[];
49
- const args: any[] = await parseWithOptionals(jsonParams, schema[msg.fn].parameters());
55
+ const args: any[] = await parseWithOptionals(jsonParams, getSchemaParameters(schema[msg.fn]));
50
56
  // we have to erase the fn type in order to be able to spread ...args
51
57
  const handler: ((...args: any[]) => Promise<any>) | undefined =
52
58
  msg.fn in customMethods ? customMethods[msg.fn as keyof typeof customMethods] : undefined;
@@ -13,6 +13,7 @@ import type {
13
13
  ProfileOptions,
14
14
  SendOptions,
15
15
  SimulateOptions,
16
+ TxSimulationResultWithAppOffset,
16
17
  Wallet,
17
18
  WalletCapabilities,
18
19
  } from '@aztec/aztec.js/wallet';
@@ -21,15 +22,15 @@ import type { Fr } from '@aztec/foundation/curves/bn254';
21
22
  import { jsonStringify } from '@aztec/foundation/json-rpc';
22
23
  import { createLogger } from '@aztec/foundation/log';
23
24
  import { promiseWithResolvers } from '@aztec/foundation/promise';
24
- import type { ApiSchema } from '@aztec/foundation/schemas';
25
+ import { type ApiSchema, getSchemaReturnType } from '@aztec/foundation/schemas';
25
26
  import { sleep } from '@aztec/foundation/sleep';
26
27
  import { NodeConnector, TransportClient } from '@aztec/foundation/transport';
27
28
  import type { PXEConfig } from '@aztec/pxe/config';
28
29
  import type { ContractArtifact, EventMetadataDefinition, FunctionCall } from '@aztec/stdlib/abi';
29
30
  import type { AuthWitness } from '@aztec/stdlib/auth-witness';
30
31
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
31
- import type { ContractInstanceWithAddress } from '@aztec/stdlib/contract';
32
- import type { ExecutionPayload, TxProfileResult, TxSimulationResult, UtilityExecutionResult } from '@aztec/stdlib/tx';
32
+ import type { ContractInstancePreimage } from '@aztec/stdlib/contract';
33
+ import type { ExecutionPayload, TxProfileResult, UtilityExecutionResult } from '@aztec/stdlib/tx';
33
34
  import { Tx } from '@aztec/stdlib/tx';
34
35
 
35
36
  import { Worker } from 'worker_threads';
@@ -70,7 +71,7 @@ export class WorkerWallet implements Wallet {
70
71
  env: {
71
72
  ...parentEnv,
72
73
  ...(process.stderr.isTTY || process.env.FORCE_COLOR ? { FORCE_COLOR: '1' } : {}),
73
- LOG_LEVEL: process.env.WORKER_LOG_LEVEL ?? 'warn',
74
+ LOG_LEVEL: process.env.WORKER_LOG_LEVEL ?? 'info',
74
75
  },
75
76
  });
76
77
 
@@ -123,7 +124,7 @@ export class WorkerWallet implements Wallet {
123
124
  private async call(fn: string, ...args: any[]): Promise<any> {
124
125
  const resultJson = await this.callRaw(fn, ...args);
125
126
  const methodSchema = (WorkerWalletSchema as ApiSchema)[fn];
126
- return methodSchema.returnType().parseAsync(JSON.parse(resultJson));
127
+ return getSchemaReturnType(methodSchema).parseAsync(JSON.parse(resultJson));
127
128
  }
128
129
 
129
130
  getChainInfo(): Promise<ChainInfo> {
@@ -157,15 +158,15 @@ export class WorkerWallet implements Wallet {
157
158
  return this.call('getAccounts');
158
159
  }
159
160
 
160
- registerContract(
161
- instance: ContractInstanceWithAddress,
162
- artifact?: ContractArtifact,
163
- secretKey?: Fr,
164
- ): Promise<ContractInstanceWithAddress> {
161
+ registerContract(instance: ContractInstancePreimage, artifact?: ContractArtifact, secretKey?: Fr): Promise<void> {
165
162
  return this.call('registerContract', instance, artifact, secretKey);
166
163
  }
167
164
 
168
- simulateTx(exec: ExecutionPayload, opts: SimulateOptions): Promise<TxSimulationResult> {
165
+ registerContractClass(artifact: ContractArtifact): Promise<void> {
166
+ return this.call('registerContractClass', artifact);
167
+ }
168
+
169
+ simulateTx(exec: ExecutionPayload, opts: SimulateOptions): Promise<TxSimulationResultWithAppOffset> {
169
170
  return this.call('simulateTx', exec, opts);
170
171
  }
171
172