@aztec/end-to-end 0.0.1-commit.993d240 → 0.0.1-commit.9a89641

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 (282) hide show
  1. package/README.md +215 -27
  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/interactive_handshake_responder.d.ts +48 -0
  10. package/dest/automine/delivery/interactive_handshake_responder.d.ts.map +1 -0
  11. package/dest/automine/delivery/interactive_handshake_responder.js +76 -0
  12. package/dest/automine/delivery/onchain_delivery_harness.d.ts +19 -0
  13. package/dest/automine/delivery/onchain_delivery_harness.d.ts.map +1 -0
  14. package/dest/automine/delivery/onchain_delivery_harness.js +141 -0
  15. package/dest/automine/token/blacklist_token_contract_test.d.ts +49 -0
  16. package/dest/automine/token/blacklist_token_contract_test.d.ts.map +1 -0
  17. package/dest/{e2e_blacklist_token_contract → automine/token}/blacklist_token_contract_test.js +18 -40
  18. package/dest/automine/token/token_contract_test.d.ts +40 -0
  19. package/dest/automine/token/token_contract_test.d.ts.map +1 -0
  20. package/dest/{e2e_token_contract → automine/token}/token_contract_test.js +22 -39
  21. package/dest/automine/token/token_test_helpers.d.ts +73 -0
  22. package/dest/automine/token/token_test_helpers.d.ts.map +1 -0
  23. package/dest/automine/token/token_test_helpers.js +97 -0
  24. package/dest/bench/client_flows/benchmark.d.ts +1 -1
  25. package/dest/bench/client_flows/benchmark.d.ts.map +1 -1
  26. package/dest/bench/client_flows/benchmark.js +3 -1
  27. package/dest/bench/client_flows/client_flows_benchmark.d.ts +5 -5
  28. package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -1
  29. package/dest/bench/client_flows/client_flows_benchmark.js +34 -25
  30. package/dest/bench/client_flows/data_extractor.js +1 -0
  31. package/dest/bench/utils.d.ts +3 -3
  32. package/dest/bench/utils.d.ts.map +1 -1
  33. package/dest/bench/utils.js +95 -6
  34. package/dest/composed/ha/ha_full_setup.d.ts +77 -0
  35. package/dest/composed/ha/ha_full_setup.d.ts.map +1 -0
  36. package/dest/composed/ha/ha_full_setup.js +383 -0
  37. package/dest/composed/web3signer/multi_validator_keystore_utils.d.ts +12 -0
  38. package/dest/composed/web3signer/multi_validator_keystore_utils.d.ts.map +1 -0
  39. package/dest/fixtures/e2e_prover_test.d.ts +12 -9
  40. package/dest/fixtures/e2e_prover_test.d.ts.map +1 -1
  41. package/dest/fixtures/e2e_prover_test.js +48 -28
  42. package/dest/fixtures/fixtures.d.ts +20 -14
  43. package/dest/fixtures/fixtures.d.ts.map +1 -1
  44. package/dest/fixtures/fixtures.js +27 -15
  45. package/dest/fixtures/get_acvm_config.d.ts +1 -1
  46. package/dest/fixtures/get_acvm_config.d.ts.map +1 -1
  47. package/dest/fixtures/get_acvm_config.js +2 -2
  48. package/dest/fixtures/get_bb_config.d.ts +1 -1
  49. package/dest/fixtures/get_bb_config.d.ts.map +1 -1
  50. package/dest/fixtures/get_bb_config.js +2 -2
  51. package/dest/fixtures/ha_setup.d.ts +3 -3
  52. package/dest/fixtures/ha_setup.d.ts.map +1 -1
  53. package/dest/fixtures/ha_setup.js +4 -1
  54. package/dest/fixtures/index.d.ts +2 -1
  55. package/dest/fixtures/index.d.ts.map +1 -1
  56. package/dest/fixtures/index.js +1 -0
  57. package/dest/fixtures/setup.d.ts +52 -40
  58. package/dest/fixtures/setup.d.ts.map +1 -1
  59. package/dest/fixtures/setup.js +207 -221
  60. package/dest/fixtures/setup_p2p_test.d.ts +1 -1
  61. package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
  62. package/dest/fixtures/setup_p2p_test.js +3 -3
  63. package/dest/fixtures/standard_contracts_genesis.d.ts +16 -0
  64. package/dest/fixtures/standard_contracts_genesis.d.ts.map +1 -0
  65. package/dest/fixtures/standard_contracts_genesis.js +25 -0
  66. package/dest/fixtures/timing.d.ts +42 -0
  67. package/dest/fixtures/timing.d.ts.map +1 -0
  68. package/dest/fixtures/timing.js +72 -0
  69. package/dest/fixtures/token_utils.d.ts +22 -4
  70. package/dest/fixtures/token_utils.d.ts.map +1 -1
  71. package/dest/fixtures/token_utils.js +21 -1
  72. package/dest/fixtures/utils.d.ts +2 -2
  73. package/dest/fixtures/utils.d.ts.map +1 -1
  74. package/dest/fixtures/utils.js +1 -1
  75. package/dest/fixtures/wait_helpers.d.ts +135 -0
  76. package/dest/fixtures/wait_helpers.d.ts.map +1 -0
  77. package/dest/fixtures/wait_helpers.js +154 -0
  78. package/dest/forward-compatibility/wallet_service.js +3 -3
  79. package/dest/multi-node/block-production/setup.d.ts +97 -0
  80. package/dest/multi-node/block-production/setup.d.ts.map +1 -0
  81. package/dest/multi-node/block-production/setup.js +158 -0
  82. package/dest/multi-node/governance/setup.d.ts +67 -0
  83. package/dest/multi-node/governance/setup.d.ts.map +1 -0
  84. package/dest/multi-node/governance/setup.js +126 -0
  85. package/dest/multi-node/multi_node_test_context.d.ts +212 -0
  86. package/dest/multi-node/multi_node_test_context.d.ts.map +1 -0
  87. package/dest/multi-node/multi_node_test_context.js +347 -0
  88. package/dest/multi-node/slashing/inactivity_setup.d.ts +27 -0
  89. package/dest/multi-node/slashing/inactivity_setup.d.ts.map +1 -0
  90. package/dest/multi-node/slashing/inactivity_setup.js +111 -0
  91. package/dest/multi-node/slashing/setup.d.ts +167 -0
  92. package/dest/multi-node/slashing/setup.d.ts.map +1 -0
  93. package/dest/multi-node/slashing/setup.js +275 -0
  94. package/dest/{e2e_p2p → p2p}/p2p_network.d.ts +10 -2
  95. package/dest/p2p/p2p_network.d.ts.map +1 -0
  96. package/dest/{e2e_p2p → p2p}/p2p_network.js +41 -16
  97. package/dest/p2p/reqresp/utils.d.ts +19 -0
  98. package/dest/p2p/reqresp/utils.d.ts.map +1 -0
  99. package/dest/{e2e_p2p → p2p}/reqresp/utils.js +6 -19
  100. package/dest/p2p/shared.d.ts +72 -0
  101. package/dest/p2p/shared.d.ts.map +1 -0
  102. package/dest/p2p/shared.js +212 -0
  103. package/dest/shared/cross_chain_test_harness.d.ts +3 -3
  104. package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
  105. package/dest/shared/cross_chain_test_harness.js +24 -16
  106. package/dest/shared/gas_portal_test_harness.d.ts +2 -2
  107. package/dest/shared/gas_portal_test_harness.d.ts.map +1 -1
  108. package/dest/shared/gas_portal_test_harness.js +10 -8
  109. package/dest/shared/submit-transactions.d.ts +1 -1
  110. package/dest/shared/submit-transactions.d.ts.map +1 -1
  111. package/dest/shared/submit-transactions.js +12 -5
  112. package/dest/shared/timing_env.d.js +5 -0
  113. package/dest/shared/timing_env.js +365 -0
  114. package/dest/shared/uniswap_l1_l2.d.ts +1 -1
  115. package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
  116. package/dest/shared/uniswap_l1_l2.js +8 -19
  117. package/dest/shared/wait_for_l1_to_l2_message.js +1 -1
  118. package/dest/simulators/lending_simulator.js +1 -1
  119. package/dest/single-node/cross-chain/cross_chain_messaging_test.d.ts +75 -0
  120. package/dest/single-node/cross-chain/cross_chain_messaging_test.d.ts.map +1 -0
  121. package/dest/single-node/cross-chain/cross_chain_messaging_test.js +209 -0
  122. package/dest/single-node/cross-chain/message_test_helpers.d.ts +38 -0
  123. package/dest/single-node/cross-chain/message_test_helpers.d.ts.map +1 -0
  124. package/dest/single-node/cross-chain/message_test_helpers.js +70 -0
  125. package/dest/{e2e_fees → single-node/fees}/bridging_race.notest.d.ts +1 -1
  126. package/dest/single-node/fees/bridging_race.notest.d.ts.map +1 -0
  127. package/dest/{e2e_fees → single-node/fees}/bridging_race.notest.js +17 -4
  128. package/dest/single-node/fees/fees_test.d.ts +95 -0
  129. package/dest/single-node/fees/fees_test.d.ts.map +1 -0
  130. package/dest/{e2e_fees → single-node/fees}/fees_test.js +129 -66
  131. package/dest/single-node/l1-reorgs/setup.d.ts +42 -0
  132. package/dest/single-node/l1-reorgs/setup.d.ts.map +1 -0
  133. package/dest/single-node/l1-reorgs/setup.js +57 -0
  134. package/dest/single-node/partial-proofs/setup.d.ts +5 -0
  135. package/dest/single-node/partial-proofs/setup.d.ts.map +1 -0
  136. package/dest/single-node/partial-proofs/setup.js +5 -0
  137. package/dest/single-node/proving/setup.d.ts +5 -0
  138. package/dest/single-node/proving/setup.d.ts.map +1 -0
  139. package/dest/single-node/proving/setup.js +5 -0
  140. package/dest/single-node/recovery/setup.d.ts +5 -0
  141. package/dest/single-node/recovery/setup.d.ts.map +1 -0
  142. package/dest/single-node/recovery/setup.js +5 -0
  143. package/dest/single-node/setup.d.ts +49 -0
  144. package/dest/single-node/setup.d.ts.map +1 -0
  145. package/dest/single-node/setup.js +56 -0
  146. package/dest/single-node/single_node_test_context.d.ts +374 -0
  147. package/dest/single-node/single_node_test_context.d.ts.map +1 -0
  148. package/dest/single-node/single_node_test_context.js +847 -0
  149. package/dest/spartan/setup_test_wallets.d.ts +1 -1
  150. package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
  151. package/dest/spartan/setup_test_wallets.js +24 -10
  152. package/dest/spartan/tx_metrics.d.ts +10 -1
  153. package/dest/spartan/tx_metrics.d.ts.map +1 -1
  154. package/dest/spartan/tx_metrics.js +32 -0
  155. package/dest/test-wallet/test_wallet.d.ts +23 -3
  156. package/dest/test-wallet/test_wallet.d.ts.map +1 -1
  157. package/dest/test-wallet/test_wallet.js +56 -9
  158. package/dest/test-wallet/utils.d.ts +36 -1
  159. package/dest/test-wallet/utils.d.ts.map +1 -1
  160. package/dest/test-wallet/utils.js +64 -4
  161. package/dest/test-wallet/wallet_worker_script.js +10 -2
  162. package/dest/test-wallet/worker_wallet.d.ts +5 -5
  163. package/dest/test-wallet/worker_wallet.d.ts.map +1 -1
  164. package/dest/test-wallet/worker_wallet.js +6 -4
  165. package/dest/test-wallet/worker_wallet_schema.d.ts +3 -159
  166. package/dest/test-wallet/worker_wallet_schema.d.ts.map +1 -1
  167. package/dest/test-wallet/worker_wallet_schema.js +2 -1
  168. package/package.json +41 -41
  169. package/src/automine/README.md +60 -0
  170. package/src/automine/automine_test_context.ts +153 -0
  171. package/src/automine/delivery/interactive_handshake_responder.ts +125 -0
  172. package/src/automine/delivery/onchain_delivery_harness.ts +213 -0
  173. package/src/{e2e_blacklist_token_contract → automine/token}/blacklist_token_contract_test.ts +20 -57
  174. package/src/{e2e_token_contract → automine/token}/token_contract_test.ts +24 -57
  175. package/src/automine/token/token_test_helpers.ts +138 -0
  176. package/src/bench/client_flows/benchmark.ts +3 -1
  177. package/src/bench/client_flows/client_flows_benchmark.ts +48 -32
  178. package/src/bench/client_flows/data_extractor.ts +1 -0
  179. package/src/bench/utils.ts +109 -6
  180. package/src/composed/ha/ha_full_setup.ts +466 -0
  181. package/src/fixtures/e2e_prover_test.ts +60 -47
  182. package/src/fixtures/fixtures.ts +29 -15
  183. package/src/fixtures/get_acvm_config.ts +2 -8
  184. package/src/fixtures/get_bb_config.ts +1 -2
  185. package/src/fixtures/ha_setup.ts +7 -3
  186. package/src/fixtures/index.ts +1 -0
  187. package/src/fixtures/setup.ts +255 -281
  188. package/src/fixtures/setup_p2p_test.ts +3 -3
  189. package/src/fixtures/standard_contracts_genesis.ts +28 -0
  190. package/src/fixtures/timing.ts +97 -0
  191. package/src/fixtures/token_utils.ts +39 -4
  192. package/src/fixtures/utils.ts +0 -3
  193. package/src/fixtures/wait_helpers.ts +333 -0
  194. package/src/forward-compatibility/wallet_service.ts +6 -4
  195. package/src/guides/up_quick_start.sh +5 -0
  196. package/src/infra/README.md +12 -0
  197. package/src/multi-node/README.md +96 -0
  198. package/src/multi-node/block-production/setup.ts +272 -0
  199. package/src/multi-node/governance/setup.ts +172 -0
  200. package/src/multi-node/multi_node_test_context.ts +447 -0
  201. package/src/multi-node/slashing/inactivity_setup.ts +139 -0
  202. package/src/multi-node/slashing/setup.ts +433 -0
  203. package/src/p2p/README.md +78 -0
  204. package/src/{e2e_p2p → p2p}/p2p_network.ts +40 -13
  205. package/src/{e2e_p2p → p2p}/reqresp/utils.ts +7 -18
  206. package/src/p2p/shared.ts +329 -0
  207. package/src/shared/cross_chain_test_harness.ts +22 -13
  208. package/src/shared/gas_portal_test_harness.ts +15 -8
  209. package/src/shared/submit-transactions.ts +13 -5
  210. package/src/shared/timing_env.d.mts +39 -0
  211. package/src/shared/timing_env.mjs +363 -0
  212. package/src/shared/uniswap_l1_l2.ts +38 -21
  213. package/src/shared/wait_for_l1_to_l2_message.ts +1 -1
  214. package/src/simulators/lending_simulator.ts +1 -1
  215. package/src/single-node/README.md +66 -0
  216. package/src/single-node/cross-chain/cross_chain_messaging_test.ts +302 -0
  217. package/src/single-node/cross-chain/message_test_helpers.ts +125 -0
  218. package/src/{e2e_fees → single-node/fees}/bridging_race.notest.ts +19 -5
  219. package/src/{e2e_fees → single-node/fees}/fees_test.ts +146 -76
  220. package/src/single-node/l1-reorgs/setup.ts +93 -0
  221. package/src/single-node/partial-proofs/setup.ts +8 -0
  222. package/src/single-node/proving/setup.ts +15 -0
  223. package/src/single-node/recovery/setup.ts +8 -0
  224. package/src/single-node/setup.ts +63 -0
  225. package/src/single-node/single_node_test_context.ts +1058 -0
  226. package/src/spartan/setup_test_wallets.ts +28 -10
  227. package/src/spartan/tx_metrics.ts +26 -0
  228. package/src/test-wallet/test_wallet.ts +60 -10
  229. package/src/test-wallet/utils.ts +102 -5
  230. package/src/test-wallet/wallet_worker_script.ts +9 -3
  231. package/src/test-wallet/worker_wallet.ts +11 -13
  232. package/src/test-wallet/worker_wallet_schema.ts +3 -2
  233. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +0 -56
  234. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts.map +0 -1
  235. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +0 -58
  236. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts.map +0 -1
  237. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.js +0 -161
  238. package/dest/e2e_deploy_contract/deploy_test.d.ts +0 -37
  239. package/dest/e2e_deploy_contract/deploy_test.d.ts.map +0 -1
  240. package/dest/e2e_deploy_contract/deploy_test.js +0 -51
  241. package/dest/e2e_epochs/epochs_test.d.ts +0 -125
  242. package/dest/e2e_epochs/epochs_test.d.ts.map +0 -1
  243. package/dest/e2e_epochs/epochs_test.js +0 -460
  244. package/dest/e2e_fees/bridging_race.notest.d.ts.map +0 -1
  245. package/dest/e2e_fees/fees_test.d.ts +0 -91
  246. package/dest/e2e_fees/fees_test.d.ts.map +0 -1
  247. package/dest/e2e_l1_publisher/write_json.d.ts +0 -11
  248. package/dest/e2e_l1_publisher/write_json.d.ts.map +0 -1
  249. package/dest/e2e_l1_publisher/write_json.js +0 -56
  250. package/dest/e2e_multi_validator/utils.d.ts +0 -12
  251. package/dest/e2e_multi_validator/utils.d.ts.map +0 -1
  252. package/dest/e2e_nested_contract/nested_contract_test.d.ts +0 -26
  253. package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +0 -1
  254. package/dest/e2e_nested_contract/nested_contract_test.js +0 -55
  255. package/dest/e2e_p2p/inactivity_slash_test.d.ts +0 -31
  256. package/dest/e2e_p2p/inactivity_slash_test.d.ts.map +0 -1
  257. package/dest/e2e_p2p/inactivity_slash_test.js +0 -138
  258. package/dest/e2e_p2p/p2p_network.d.ts.map +0 -1
  259. package/dest/e2e_p2p/reqresp/utils.d.ts +0 -22
  260. package/dest/e2e_p2p/reqresp/utils.d.ts.map +0 -1
  261. package/dest/e2e_p2p/shared.d.ts +0 -64
  262. package/dest/e2e_p2p/shared.d.ts.map +0 -1
  263. package/dest/e2e_p2p/shared.js +0 -204
  264. package/dest/e2e_storage_proof/fixtures/storage_proof_fetcher.d.ts +0 -2
  265. package/dest/e2e_storage_proof/fixtures/storage_proof_fetcher.d.ts.map +0 -1
  266. package/dest/e2e_storage_proof/fixtures/storage_proof_fixture.d.ts.map +0 -1
  267. package/dest/e2e_token_contract/token_contract_test.d.ts +0 -44
  268. package/dest/e2e_token_contract/token_contract_test.d.ts.map +0 -1
  269. package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +0 -231
  270. package/src/e2e_deploy_contract/deploy_test.ts +0 -86
  271. package/src/e2e_epochs/epochs_test.ts +0 -575
  272. package/src/e2e_l1_publisher/write_json.ts +0 -77
  273. package/src/e2e_nested_contract/nested_contract_test.ts +0 -77
  274. package/src/e2e_p2p/inactivity_slash_test.ts +0 -181
  275. package/src/e2e_p2p/shared.ts +0 -318
  276. /package/dest/{e2e_storage_proof → automine/contracts}/fixtures/storage_proof_fetcher.js +0 -0
  277. /package/dest/{e2e_storage_proof → automine/contracts}/fixtures/storage_proof_fixture.js +0 -0
  278. /package/dest/{e2e_multi_validator/utils.js → composed/web3signer/multi_validator_keystore_utils.js} +0 -0
  279. /package/src/{e2e_storage_proof → automine/contracts}/fixtures/storage_proof.json +0 -0
  280. /package/src/{e2e_storage_proof → automine/contracts}/fixtures/storage_proof_fetcher.ts +0 -0
  281. /package/src/{e2e_storage_proof → automine/contracts}/fixtures/storage_proof_fixture.ts +0 -0
  282. /package/src/{e2e_multi_validator/utils.ts → composed/web3signer/multi_validator_keystore_utils.ts} +0 -0
@@ -1,23 +1,13 @@
1
- import { SchnorrAccountContractArtifact } from '@aztec/accounts/schnorr';
2
1
  import { type InitialAccountData, generateSchnorrAccounts } from '@aztec/accounts/testing';
3
- import { type AztecNodeConfig, AztecNodeService, getConfigEnvVars } from '@aztec/aztec-node';
4
- import { NO_FROM } from '@aztec/aztec.js/account';
2
+ import { type AztecNodeConfig, AztecNodeService, createAztecNodeService, getConfigEnvVars } from '@aztec/aztec-node';
5
3
  import { AztecAddress, EthAddress } from '@aztec/aztec.js/addresses';
6
- import {
7
- BatchCall,
8
- type ContractFunctionInteraction,
9
- type ContractMethod,
10
- type DeployOptions,
11
- type InteractionWaitOptions,
12
- getContractClassFromArtifact,
13
- waitForProven,
14
- } from '@aztec/aztec.js/contracts';
4
+ import type { ContractMethod } from '@aztec/aztec.js/contracts';
15
5
  import { publishContractClass, publishInstance } from '@aztec/aztec.js/deployment';
16
6
  import { Fr } from '@aztec/aztec.js/fields';
17
7
  import { type Logger, createLogger } from '@aztec/aztec.js/log';
18
8
  import type { AztecNode } from '@aztec/aztec.js/node';
19
9
  import type { Wallet } from '@aztec/aztec.js/wallet';
20
- import { AnvilTestWatcher, type AnvilTestWatcherOpts, CheatCodes } from '@aztec/aztec/testing';
10
+ import { CheatCodes } from '@aztec/aztec/testing';
21
11
  import { SPONSORED_FPC_SALT } from '@aztec/constants';
22
12
  import { isAnvilTestChain } from '@aztec/ethereum/chain';
23
13
  import { createExtendedL1Client } from '@aztec/ethereum/client';
@@ -32,25 +22,26 @@ import {
32
22
  deployAztecL1Contracts,
33
23
  } from '@aztec/ethereum/deploy-aztec-l1-contracts';
34
24
  import type { Delayer } from '@aztec/ethereum/l1-tx-utils';
35
- import { EthCheatCodes, EthCheatCodesWithState, startAnvil } from '@aztec/ethereum/test';
25
+ import { EthCheatCodes, EthCheatCodesWithState, startAnvil, warmBlobKzg } from '@aztec/ethereum/test';
36
26
  import type { Anvil } from '@aztec/ethereum/test';
27
+ import type { ExtendedViemWalletClient } from '@aztec/ethereum/types';
37
28
  import { BlockNumber, EpochNumber } from '@aztec/foundation/branded-types';
38
29
  import { SecretValue } from '@aztec/foundation/config';
39
30
  import { randomBytes } from '@aztec/foundation/crypto/random';
40
31
  import { tryRmDir } from '@aztec/foundation/fs';
41
32
  import { withLoggerBindings } from '@aztec/foundation/log/server';
42
33
  import { retryUntil } from '@aztec/foundation/retry';
43
- import { sleep } from '@aztec/foundation/sleep';
44
34
  import { DateProvider, TestDateProvider } from '@aztec/foundation/timer';
45
35
  import { SponsoredFPCContract } from '@aztec/noir-contracts.js/SponsoredFPC';
46
36
  import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
47
37
  import type { P2PClientDeps } from '@aztec/p2p';
48
38
  import { MockGossipSubNetwork, getMockPubSubP2PServiceFactory } from '@aztec/p2p/test-helpers';
49
39
  import { protocolContractsHash } from '@aztec/protocol-contracts';
50
- import type { ProverNodeConfig } from '@aztec/prover-node';
40
+ import type { ProverNodeConfig, ProverNodeDeps } from '@aztec/prover-node';
51
41
  import { type PXEConfig, type PXECreationOptions, getPXEConfig } from '@aztec/pxe/server';
52
42
  import type { SequencerClient } from '@aztec/sequencer-client';
53
43
  import { AuthRegistryArtifact, getStandardAuthRegistry } from '@aztec/standard-contracts/auth-registry';
44
+ import { HandshakeRegistryArtifact, getStandardHandshakeRegistry } from '@aztec/standard-contracts/handshake-registry';
54
45
  import { PublicChecksArtifact, getStandardPublicChecks } from '@aztec/standard-contracts/public-checks';
55
46
  import { ARTIFACT_VERSION_BEFORE_INJECTION } from '@aztec/stdlib/abi';
56
47
  import { type ContractInstanceWithAddress, getContractInstanceFromInstantiationParams } from '@aztec/stdlib/contract';
@@ -65,7 +56,7 @@ import {
65
56
  initTelemetryClient,
66
57
  } from '@aztec/telemetry-client';
67
58
  import { BenchmarkTelemetryClient } from '@aztec/telemetry-client/bench';
68
- import { deployFundedSchnorrAccounts } from '@aztec/wallets/testing';
59
+ import { createFundedInitializerlessAccounts } from '@aztec/wallets/testing';
69
60
  import { getGenesisValues } from '@aztec/world-state/testing';
70
61
 
71
62
  import fs from 'fs/promises';
@@ -86,6 +77,8 @@ import { MNEMONIC, TEST_MAX_PENDING_TX_POOL_COUNT, TEST_PEER_CHECK_INTERVAL_MS }
86
77
  import { getACVMConfig } from './get_acvm_config.js';
87
78
  import { getBBConfig } from './get_bb_config.js';
88
79
  import { isMetricsLoggingRequested, setupMetricsLogger } from './logging.js';
80
+ import { getStandardContractGenesisNullifiers } from './standard_contracts_genesis.js';
81
+ import { testSpan } from './timing.js';
89
82
  import { getEndToEndTestTelemetryClient } from './with_telemetry_utils.js';
90
83
 
91
84
  export { startAnvil };
@@ -118,6 +111,8 @@ export async function setupSharedBlobStorage(config: { dataDirectory?: string }
118
111
  /**
119
112
  * Sets up Private eXecution Environment (PXE) and returns the corresponding test wallet.
120
113
  * @param aztecNode - An instance of Aztec Node.
114
+ * @param nodeDebug - The node's debug API, used to register public function signatures for named traces; pass
115
+ * `undefined` when the node does not expose it.
121
116
  * @param opts - Partial configuration for the PXE.
122
117
  * @param logger - The logger to be used.
123
118
  * @param actor - Actor label to include in log output (e.g., 'pxe-test').
@@ -125,6 +120,7 @@ export async function setupSharedBlobStorage(config: { dataDirectory?: string }
125
120
  */
126
121
  export async function setupPXEAndGetWallet(
127
122
  aztecNode: AztecNode,
123
+ nodeDebug: AztecNodeDebug | undefined,
128
124
  opts: Partial<PXEConfig> = {},
129
125
  logger = getLogger(),
130
126
  actor?: string,
@@ -145,7 +141,10 @@ export async function setupPXEAndGetWallet(
145
141
 
146
142
  const teardown = configuredDataDirectory ? () => Promise.resolve() : () => tryRmDir(PXEConfig.dataDirectory!);
147
143
 
148
- const wallet = await TestWallet.create(aztecNode, PXEConfig, { loggerActorLabel: actor });
144
+ const wallet = await TestWallet.create(aztecNode, PXEConfig, {
145
+ loggerActorLabel: actor,
146
+ nodeDebug,
147
+ });
149
148
 
150
149
  return {
151
150
  wallet,
@@ -155,7 +154,7 @@ export async function setupPXEAndGetWallet(
155
154
  }
156
155
 
157
156
  /** Options for the e2e tests setup */
158
- export type SetupOptions = {
157
+ export type SetupOptions<TDeployExtraL1ContractsReturnType = unknown> = {
159
158
  /** State load */
160
159
  stateLoad?: string;
161
160
  /** Whether to enable metrics collection, if undefined, metrics collection is disabled */
@@ -164,10 +163,11 @@ export type SetupOptions = {
164
163
  deployL1ContractsValues?: DeployAztecL1ContractsReturnType;
165
164
  /** Initial fee juice for default accounts */
166
165
  initialAccountFeeJuice?: Fr;
167
- /** Number of initial accounts funded with fee juice */
168
- numberOfInitialFundedAccounts?: number;
169
- /** Data of the initial funded accounts */
170
- initialFundedAccounts?: InitialAccountData[];
166
+ /**
167
+ * Extra accounts to fund at genesis beyond the `numberOfAccounts` initializerless accounts that setup
168
+ * creates. Setup funds these but does NOT create or deploy them — the test creates/deploys them itself
169
+ */
170
+ additionallyFundedAccounts?: InitialAccountData[];
171
171
  /** An initial set of validators */
172
172
  initialValidators?: (Operator & { privateKey: `0x${string}` })[];
173
173
  /** Anvil Start time */
@@ -186,11 +186,26 @@ export type SetupOptions = {
186
186
  mockGossipSubNetwork?: boolean;
187
187
  /** Whether to add simulated latency to the mock gossipsub network (in ms) */
188
188
  mockGossipSubNetworkLatency?: number;
189
- /** Whether to disable the anvil test watcher (can still be manually started) */
190
- disableAnvilTestWatcher?: boolean;
191
- anvilTestWatcherOpts?: AnvilTestWatcherOpts;
192
- /** Whether to enable anvil automine during deployment of L1 contracts (consider defaulting this to true). */
189
+ /**
190
+ * Whether to mine the L1 setup txs (Multicall3 + rollup contract deployment) under anvil automine
191
+ * instead of waiting on the block interval. Defaults to `true` (set in `setupInner`); only suites
192
+ * that assert on genesis-relative L1 timing need to opt out with `false`.
193
+ */
193
194
  automineL1Setup?: boolean;
195
+ /**
196
+ * Hook invoked after the Aztec L1 rollup contracts are deployed but BEFORE the node/sequencer
197
+ * start, while anvil automine is still enabled (when `automineL1Setup` is true, the default).
198
+ * Deploy extra L1 contracts a test needs here (e.g. a cross-chain token portal + ERC20) so they
199
+ * mine instantly under automine instead of paying the L1 block interval once the node is running
200
+ * (and racing the live sequencer/archiver). The resolved value is exposed on the returned context
201
+ * as `extraL1DeployResult`. The hook receives setup's L1 deployer client (the same one used to
202
+ * deploy Multicall3).
203
+ */
204
+ deployExtraL1Contracts?: (deps: {
205
+ l1Client: ExtendedViemWalletClient;
206
+ deployL1ContractsValues: DeployAztecL1ContractsReturnType;
207
+ logger: Logger;
208
+ }) => Promise<TDeployExtraL1ContractsReturnType>;
194
209
  /** How many accounts to seed and unlock in anvil. */
195
210
  anvilAccounts?: number;
196
211
  /** Port to start anvil (defaults to 8545) */
@@ -206,8 +221,14 @@ export type SetupOptions = {
206
221
  zkPassportArgs?: ZKPassportArgs;
207
222
  /** Whether to fund the sponsored FPC in genesis (defaults to false). */
208
223
  fundSponsoredFPC?: boolean;
209
- /** Whether to skip deploying accounts during setup (legacy behavior for tests using deployAccounts helper). */
210
- skipAccountDeployment?: boolean;
224
+ /**
225
+ * Compute extra addresses to fund at genesis from the accounts setup just generated (passed as the
226
+ * argument). Runs after the default accounts are created and before genesis values are computed, so a
227
+ * test can genesis-fund a contract whose address derives from a default account (e.g. an FPC whose
228
+ * admin is the first account) instead of bridging fee juice to it during setup. Each returned address
229
+ * is funded with the same fee juice as an initial account and included in the L1 portal `fundingNeeded`.
230
+ */
231
+ computeExtraGenesisFundedAddresses?: (defaultAccounts: InitialAccountData[]) => Promise<AztecAddress[]>;
211
232
  /** L1 contracts deployment arguments. */
212
233
  l1ContractsArgs?: Partial<DeployAztecL1ContractsArgs>;
213
234
  /** Wallet minimum fee padding multiplier */
@@ -223,7 +244,7 @@ export type SetupOptions = {
223
244
  } & Partial<AztecNodeConfig>;
224
245
 
225
246
  /** Context for an end-to-end test as returned by the `setup` function */
226
- export type EndToEndContext = {
247
+ export type EndToEndContext<TDeployExtraL1ContractsReturnType = unknown> = {
227
248
  /** The Anvil instance (only set if anvil was started locally). */
228
249
  anvil: Anvil | undefined;
229
250
  /** The Aztec Node service or client a connected to it. */
@@ -242,8 +263,8 @@ export type EndToEndContext = {
242
263
  config: AztecNodeConfig;
243
264
  /** The Aztec Node configuration (alias for config for backward compatibility). */
244
265
  aztecNodeConfig: AztecNodeConfig;
245
- /** The data for the initial funded accounts. */
246
- initialFundedAccounts: InitialAccountData[];
266
+ /** Data for the extra accounts funded at genesis but not created by setup (the test creates/deploys them). */
267
+ additionallyFundedAccounts: InitialAccountData[];
247
268
  /** The wallet to be used. */
248
269
  wallet: TestWallet;
249
270
  /** The wallets to be used. */
@@ -254,8 +275,6 @@ export type EndToEndContext = {
254
275
  cheatCodes: CheatCodes;
255
276
  /** The cheat codes for L1 */
256
277
  ethCheatCodes: EthCheatCodes;
257
- /** The anvil test watcher. */
258
- watcher: AnvilTestWatcher;
259
278
  /** Allows tweaking current system time, used by the epoch cache only. */
260
279
  dateProvider: TestDateProvider;
261
280
  /** Telemetry client */
@@ -268,6 +287,8 @@ export type EndToEndContext = {
268
287
  proverDelayer: Delayer | undefined;
269
288
  /** Genesis data used for setting up nodes. */
270
289
  genesis: GenesisData | undefined;
290
+ /** Resolved value of the `deployExtraL1Contracts` setup hook, if one was provided. */
291
+ extraL1DeployResult: TDeployExtraL1ContractsReturnType;
271
292
  /** ACVM config (only set if running locally). */
272
293
  acvmConfig: Awaited<ReturnType<typeof getACVMConfig>>;
273
294
  /** BB config (only set if running locally). */
@@ -310,17 +331,43 @@ function assertContractArtifactsVersion() {
310
331
  * @param opts - Options to pass to the node initialization and to the setup script.
311
332
  * @param pxeOpts - Options to pass to the PXE initialization.
312
333
  */
313
- export async function setup(
334
+ export function setup<TDeployExtraL1ContractsReturnType = unknown>(
314
335
  numberOfAccounts = 1,
315
- opts: SetupOptions = {},
336
+ opts: SetupOptions<TDeployExtraL1ContractsReturnType> = {},
316
337
  pxeOpts: Partial<PXEConfig> = {},
317
338
  chain: Chain = foundry,
318
- ): Promise<EndToEndContext> {
339
+ ): Promise<EndToEndContext<TDeployExtraL1ContractsReturnType>> {
340
+ // Tag the top-level env spin-up with the prover mode (none → fake → real), the largest config-driven
341
+ // swing in setup cost, so the three factories are comparable on the span leaderboard. The internals
342
+ // (anvil / l1-deploy / sequencer-start / pxe / wallet:create) decompose this further.
343
+ const proverMode = opts.realProofs ? 'real' : opts.startProverNode ? 'fake' : 'none';
344
+ return testSpan(`setup:env:${proverMode}`, async () => {
345
+ const ctx = await setupInner(numberOfAccounts, opts, pxeOpts, chain);
346
+ if (process.env.EXIT_E2E_AFTER_SETUP) {
347
+ ctx.logger.info('EXIT_E2E_AFTER_SETUP is set; aborting before the test body runs');
348
+ throw new Error('EXIT_E2E_AFTER_SETUP');
349
+ }
350
+ return ctx;
351
+ });
352
+ }
353
+
354
+ async function setupInner<TDeployExtraL1ContractsReturnType = unknown>(
355
+ numberOfAccounts: number,
356
+ opts: SetupOptions<TDeployExtraL1ContractsReturnType>,
357
+ pxeOpts: Partial<PXEConfig>,
358
+ chain: Chain,
359
+ ): Promise<EndToEndContext<TDeployExtraL1ContractsReturnType>> {
319
360
  assertContractArtifactsVersion();
361
+ const logger = getLogger();
320
362
  let anvil: Anvil | undefined;
321
363
  try {
322
364
  opts.aztecTargetCommitteeSize ??= 0;
323
365
  opts.slasherEnabled ??= false;
366
+ // Mine the L1 setup txs (Multicall3 + rollup contract deployment) immediately instead of
367
+ // waiting on anvil's block interval — this is the dominant cost of e2e setup. Suites that
368
+ // assert on genesis-relative L1 timing can opt out by passing `automineL1Setup: false`.
369
+ opts.automineL1Setup ??= true;
370
+ logger.trace('Starting e2e test setup');
324
371
 
325
372
  const config: AztecNodeConfig & SetupOptions = { ...getConfigEnvVars(), ...opts };
326
373
  // use initialValidators for the node config
@@ -330,16 +377,12 @@ export async function setup(
330
377
  config.maxPendingTxCount = opts.maxPendingTxCount ?? TEST_MAX_PENDING_TX_POOL_COUNT;
331
378
  // For tests we only want proving enabled if specifically requested
332
379
  config.realProofs = !!opts.realProofs;
333
- // Only enforce the time table if requested
334
- config.enforceTimeTable = !!opts.enforceTimeTable;
335
380
  // Enable the tx delayer for tests (default config has it disabled, so we force-enable it here)
336
381
  config.enableDelayer = true;
337
382
  config.listenAddress = '127.0.0.1';
338
383
 
339
384
  config.minTxPoolAgeMs = opts.minTxPoolAgeMs ?? 0;
340
385
 
341
- const logger = getLogger();
342
-
343
386
  // Create a temp directory for any services that need it and cleanup later
344
387
  const directoryToCleanup = path.join(tmpdir(), randomBytes(8).toString('hex'));
345
388
  await fs.mkdir(directoryToCleanup, { recursive: true });
@@ -353,16 +396,19 @@ export async function setup(
353
396
  if (!isAnvilTestChain(chain.id)) {
354
397
  throw new Error(`No ETHEREUM_HOSTS set but non anvil chain requested`);
355
398
  }
356
- const res = await startAnvil({
357
- l1BlockTime: opts.ethereumSlotDuration,
358
- accounts: opts.anvilAccounts,
359
- port: opts.anvilPort ?? (process.env.ANVIL_PORT ? parseInt(process.env.ANVIL_PORT) : undefined),
360
- slotsInAnEpoch: opts.anvilSlotsInAnEpoch,
361
- dateProvider,
362
- });
399
+ const res = await testSpan('setup:env:anvil', () =>
400
+ startAnvil({
401
+ l1BlockTime: opts.ethereumSlotDuration,
402
+ accounts: opts.anvilAccounts,
403
+ port: opts.anvilPort ?? (process.env.ANVIL_PORT ? parseInt(process.env.ANVIL_PORT) : undefined),
404
+ slotsInAnEpoch: opts.anvilSlotsInAnEpoch,
405
+ dateProvider,
406
+ }),
407
+ );
363
408
  anvil = res.anvil;
364
409
  config.l1RpcUrls = [res.rpcUrl];
365
410
  }
411
+ logger.trace('Started anvil and L1 RPC client');
366
412
 
367
413
  // Enable logging metrics to a local file named after the test suite
368
414
  if (isMetricsLoggingRequested()) {
@@ -379,6 +425,7 @@ export async function setup(
379
425
  if (opts.l1StartTime) {
380
426
  await ethCheatCodes.warp(opts.l1StartTime, { resetBlockInterval: true });
381
427
  }
428
+ logger.trace('Initialized L1 cheat codes and applied state/time overrides');
382
429
 
383
430
  let publisherPrivKeyHex: `0x${string}` | undefined = undefined;
384
431
  let publisherHdAccount: HDAccount | PrivateKeyAccount | undefined = undefined;
@@ -406,12 +453,14 @@ export async function setup(
406
453
  if (config.coinbase === undefined) {
407
454
  config.coinbase = EthAddress.fromString(publisherHdAccount.address);
408
455
  }
456
+ logger.trace('Resolved L1 publisher account');
409
457
 
410
- // Determine which addresses to fund in genesis
411
- const initialFundedAccounts =
412
- opts.initialFundedAccounts ??
413
- (await generateSchnorrAccounts(opts.numberOfInitialFundedAccounts ?? Math.max(numberOfAccounts, 10)));
414
- const addressesToFund = initialFundedAccounts.map(a => a.address);
458
+ // The accounts setup creates itself: `numberOfAccounts` initializerless accounts, generated here and
459
+ // funded at genesis so they are immediately usable.
460
+ const defaultAccounts = await generateSchnorrAccounts(numberOfAccounts);
461
+ // Extra accounts the test wants funded at genesis but will create/deploy itself.
462
+ const additionallyFundedAccounts = opts.additionallyFundedAccounts ?? [];
463
+ const addressesToFund = [...defaultAccounts, ...additionallyFundedAccounts].map(a => a.address);
415
464
 
416
465
  // Optionally fund the sponsored FPC
417
466
  if (opts.fundSponsoredFPC) {
@@ -419,13 +468,29 @@ export async function setup(
419
468
  addressesToFund.push(sponsoredFPCAddress);
420
469
  }
421
470
 
471
+ // Fund any extra addresses whose value depends on the just-generated accounts (e.g. an FPC admin'd
472
+ // by a default account), so a test can genesis-fund them instead of bridging fee juice during setup.
473
+ if (opts.computeExtraGenesisFundedAddresses) {
474
+ addressesToFund.push(...(await opts.computeExtraGenesisFundedAddresses(defaultAccounts)));
475
+ }
476
+ logger.trace('Generated test accounts to fund at genesis');
477
+
478
+ // Preload the standard contracts (AuthRegistry, PublicChecks, HandshakeRegistry) so their `ensure*Published` setup
479
+ // helpers short-circuit their publish txs. The archiver flag seeds the bytecode/instance into every spawned node's
480
+ // contract store; the genesis nullifiers make the AVM's deployment-nullifier check pass when they are called. Both
481
+ // must go together (flag alone would recreate the publish-collision bug), so the flag lives here beside the seeding.
482
+ config.testPreloadStandardContracts = true;
483
+ const standardContractNullifiers = await getStandardContractGenesisNullifiers();
484
+
422
485
  const genesisTimestamp = BigInt(Math.floor(Date.now() / 1000));
423
486
  const { genesisArchiveRoot, genesis, fundingNeeded } = await getGenesisValues(
424
487
  addressesToFund,
425
488
  opts.initialAccountFeeJuice,
426
489
  opts.genesisPublicData,
427
490
  genesisTimestamp,
491
+ standardContractNullifiers,
428
492
  );
493
+ logger.trace('Computed genesis values');
429
494
 
430
495
  const wasAutomining = await ethCheatCodes.isAutoMining();
431
496
  const enableAutomine = opts.automineL1Setup && !wasAutomining && isAnvilTestChain(chain.id);
@@ -435,18 +500,21 @@ export async function setup(
435
500
 
436
501
  const l1Client = createExtendedL1Client(config.l1RpcUrls, publisherHdAccount!, chain);
437
502
 
503
+ // Warm both KZG trusted setups (ours + anvil's) in parallel
504
+ if (anvil && isAnvilTestChain(chain.id)) {
505
+ await warmBlobKzg(l1Client, logger);
506
+ }
507
+
438
508
  // Deploy Multicall3 if running locally
439
509
  await deployMulticall3(l1Client, logger);
440
510
 
441
511
  // Force viem to refresh its nonce cache to avoid "nonce too low" errors in subsequent transactions
442
512
  // This is necessary because deployMulticall3 sends multiple transactions and viem may cache a stale nonce
443
513
  await l1Client.getTransactionCount({ address: l1Client.account.address });
514
+ logger.trace('Deployed Multicall3');
444
515
 
445
- const deployL1ContractsValues: DeployAztecL1ContractsReturnType = await deployAztecL1Contracts(
446
- config.l1RpcUrls[0],
447
- publisherPrivKeyHex!,
448
- chain.id,
449
- {
516
+ const deployL1ContractsValues: DeployAztecL1ContractsReturnType = await testSpan('setup:env:l1-deploy', () =>
517
+ deployAztecL1Contracts(config.l1RpcUrls[0], publisherPrivKeyHex!, chain.id, {
450
518
  ...getL1ContractsConfigEnvVars(),
451
519
  ...opts,
452
520
  ...opts.l1ContractsArgs,
@@ -456,7 +524,7 @@ export async function setup(
456
524
  initialValidators: opts.initialValidators,
457
525
  feeJuicePortalInitialBalance: fundingNeeded,
458
526
  realVerifier: false,
459
- },
527
+ }),
460
528
  );
461
529
 
462
530
  Object.assign(config, deployL1ContractsValues.l1ContractAddresses);
@@ -480,14 +548,28 @@ export async function setup(
480
548
  }
481
549
  }
482
550
 
551
+ // Deploy any test-specific L1 contracts while automine is still on and before the node starts,
552
+ // so they mine instantly rather than paying the L1 block interval once the sequencer is live.
553
+ let extraL1DeployResult: TDeployExtraL1ContractsReturnType = undefined as TDeployExtraL1ContractsReturnType;
554
+ if (opts.deployExtraL1Contracts) {
555
+ logger.trace('Running deployExtraL1Contracts hook');
556
+ extraL1DeployResult = await opts.deployExtraL1Contracts({
557
+ l1Client,
558
+ deployL1ContractsValues,
559
+ logger,
560
+ });
561
+ // The hook reused `l1Client` to send deploy txs, so refresh viem's nonce cache to avoid a
562
+ // stale cached nonce for later transactions on the publisher account.
563
+ await l1Client.getTransactionCount({ address: l1Client.account.address });
564
+ }
565
+
483
566
  if (enableAutomine) {
484
- await ethCheatCodes.setAutomine(false);
485
- await ethCheatCodes.setIntervalMining(config.ethereumSlotDuration);
567
+ await ethCheatCodes.startIntervalMiningWithFreshBlock(config.ethereumSlotDuration);
486
568
  }
487
569
 
488
570
  // In compose mode (no local anvil), sync dateProvider to L1 time since it may have drifted
489
- // ahead of system time due to the local-network watcher warping time forward on each filled slot.
490
- // When running with a local anvil, the dateProvider is kept in sync via the stdout listener.
571
+ // ahead of system time. When running with a local anvil, the dateProvider is kept in sync via
572
+ // the stdout listener.
491
573
  if (!anvil) {
492
574
  dateProvider.setTime((await ethCheatCodes.lastBlockTimestamp()) * 1000);
493
575
  }
@@ -495,38 +577,34 @@ export async function setup(
495
577
  if (opts.l2StartTime) {
496
578
  await ethCheatCodes.warp(opts.l2StartTime, { resetBlockInterval: true });
497
579
  }
580
+ logger.trace('Deployed L1 rollup contracts');
581
+
582
+ // These boot steps are independent and write disjoint config keys, so run them concurrently:
583
+ // telemetry returns a client (no config write), shared blob storage writes blobFileStore* keys,
584
+ // and the ACVM/BB config resolvers write their own acvm*/bb* keys.
585
+ const [telemetryClient, , acvmConfig, bbConfig] = await Promise.all([
586
+ // Use metricsPort-based telemetry if provided, otherwise use the regular telemetry client
587
+ opts.metricsPort ? getEndToEndTestTelemetryClient(opts.metricsPort) : getTelemetryClient(opts.telemetryConfig),
588
+ setupSharedBlobStorage(config),
589
+ getACVMConfig(logger),
590
+ getBBConfig(logger),
591
+ ]);
592
+ logger.trace('Created telemetry client');
593
+ logger.trace('Set up shared blob storage');
498
594
 
499
- const watcher = new AnvilTestWatcher(
500
- new EthCheatCodesWithState(config.l1RpcUrls, dateProvider),
501
- deployL1ContractsValues.l1ContractAddresses.rollupAddress,
502
- deployL1ContractsValues.l1Client,
503
- dateProvider,
504
- opts.anvilTestWatcherOpts,
505
- );
506
- if (!opts.disableAnvilTestWatcher) {
507
- await watcher.start();
508
- }
509
-
510
- // Use metricsPort-based telemetry if provided, otherwise use the regular telemetry client
511
- const telemetryClient = opts.metricsPort
512
- ? await getEndToEndTestTelemetryClient(opts.metricsPort)
513
- : await getTelemetryClient(opts.telemetryConfig);
514
-
515
- await setupSharedBlobStorage(config);
516
-
517
- logger.verbose('Creating and synching an aztec node', config);
518
-
519
- const acvmConfig = await getACVMConfig(logger);
520
595
  if (acvmConfig) {
521
596
  config.acvmWorkingDirectory = acvmConfig.acvmWorkingDirectory;
522
597
  config.acvmBinaryPath = acvmConfig.acvmBinaryPath;
523
598
  }
599
+ logger.trace('Resolved ACVM config');
524
600
 
525
- const bbConfig = await getBBConfig(logger);
526
601
  if (bbConfig) {
527
602
  config.bbBinaryPath = bbConfig.bbBinaryPath;
528
603
  config.bbWorkingDirectory = bbConfig.bbWorkingDirectory;
529
604
  }
605
+ logger.trace('Resolved Barretenberg config');
606
+
607
+ logger.verbose('Creating and synching an aztec node', config);
530
608
 
531
609
  let mockGossipSubNetwork: MockGossipSubNetwork | undefined;
532
610
  let p2pClientDeps: P2PClientDeps | undefined = undefined;
@@ -536,25 +614,6 @@ export async function setup(
536
614
  p2pClientDeps = { p2pServiceFactory: getMockPubSubP2PServiceFactory(mockGossipSubNetwork) };
537
615
  }
538
616
 
539
- // Transactions built against the genesis state must be included in block 1, otherwise they are dropped.
540
- // To avoid test failures from dropped transactions, we ensure progression beyond genesis before proceeding.
541
- // For account deployments, we set minTxsPerBlock=1 and deploy accounts sequentially for guaranteed success.
542
- // If no accounts need deployment, we await an empty block to confirm network progression.
543
- const originalMinTxsPerBlock = config.minTxsPerBlock;
544
- if (originalMinTxsPerBlock === undefined) {
545
- throw new Error('minTxsPerBlock is undefined in e2e test setup');
546
- }
547
-
548
- // Only set minTxsPerBlock=1 if we're going to deploy accounts and need reliable block inclusion
549
- const shouldDeployAccounts = numberOfAccounts > 0 && !opts.skipAccountDeployment;
550
- // Only set minTxsPerBlock=0 if we need an empty block (no accounts at all, not skipped deployment)
551
- const needsEmptyBlock = numberOfAccounts === 0 && !opts.skipAccountDeployment;
552
- // Under proposer pipelining the sequencer builds during slot N-1 for slot N. A tx submitted at
553
- // slot N start is too late -- it arrives after the build. Forcing minTxsPerBlock=1 then stalls
554
- // the chain on alternating slots, so allow empty checkpoints under pipelining.
555
- const accountsDeployMinTxs = config.enableProposerPipelining ? 0 : 1;
556
- config.minTxsPerBlock = shouldDeployAccounts ? accountsDeployMinTxs : needsEmptyBlock ? 0 : originalMinTxsPerBlock;
557
-
558
617
  config.p2pEnabled = opts.mockGossipSubNetwork || config.p2pEnabled;
559
618
  config.p2pIp = opts.p2pIp ?? config.p2pIp ?? '127.0.0.1';
560
619
 
@@ -574,15 +633,19 @@ export async function setup(
574
633
  ...(opts.mockGossipSubNetwork ? {} : { p2pEnabled: false, bootstrapNodes: [] as string[] }),
575
634
  }
576
635
  : config;
577
-
578
- const aztecNodeService = await withLoggerBindings({ actor: 'node-0' }, () =>
579
- AztecNodeService.createAndSync(
580
- initialNodeConfig,
581
- { dateProvider, telemetry: telemetryClient, p2pClientDeps },
582
- { genesis, dontStartSequencer: opts.skipInitialSequencer },
636
+ logger.trace('Prepared aztec node config');
637
+
638
+ const aztecNodeService = await testSpan('setup:env:sequencer-start', () =>
639
+ withLoggerBindings({ actor: 'node-0' }, () =>
640
+ createAztecNodeService(
641
+ initialNodeConfig,
642
+ { dateProvider, telemetry: telemetryClient, p2pClientDeps },
643
+ { genesis, dontStartSequencer: opts.skipInitialSequencer },
644
+ ),
583
645
  ),
584
646
  );
585
647
  const sequencerClient = aztecNodeService.getSequencer();
648
+ logger.trace('Created and synced aztec node');
586
649
 
587
650
  let proverNode: AztecNodeService | undefined = undefined;
588
651
  if (opts.startProverNode) {
@@ -596,16 +659,19 @@ export async function setup(
596
659
  rpcTxProviders: [aztecNodeService],
597
660
  };
598
661
 
599
- ({ proverNode } = await createAndSyncProverNode(
600
- proverNodePrivateKeyHex,
601
- config,
602
- {
603
- ...config.proverNodeConfig,
604
- dataDirectory: proverNodeDataDirectory,
605
- },
606
- { dateProvider, p2pClientDeps, telemetry: telemetryClient },
607
- { genesis },
662
+ ({ proverNode } = await testSpan('setup:env:prover-node', () =>
663
+ createAndSyncProverNode(
664
+ proverNodePrivateKeyHex,
665
+ config,
666
+ {
667
+ ...config.proverNodeConfig,
668
+ dataDirectory: proverNodeDataDirectory,
669
+ },
670
+ { dateProvider, p2pClientDeps, telemetry: telemetryClient },
671
+ { genesis },
672
+ ),
608
673
  ));
674
+ logger.trace('Created prover node');
609
675
  }
610
676
 
611
677
  const sequencerDelayer = sequencerClient?.getDelayer();
@@ -616,21 +682,22 @@ export async function setup(
616
682
  pxeConfig.dataDirectory = path.join(directoryToCleanup, randomBytes(8).toString('hex'));
617
683
  // For tests we only want proving enabled if specifically requested
618
684
  pxeConfig.proverEnabled = !!pxeOpts.proverEnabled;
619
- const wallet = await TestWallet.create(aztecNodeService, pxeConfig, {
620
- loggerActorLabel: 'pxe-0',
621
- ...opts.pxeCreationOptions,
622
- });
685
+ const wallet = await testSpan('setup:env:pxe', () =>
686
+ TestWallet.create(aztecNodeService, pxeConfig, {
687
+ loggerActorLabel: 'pxe-0',
688
+ // In-process node implements the debug API, so register public function signatures for named traces.
689
+ nodeDebug: aztecNodeService,
690
+ ...opts.pxeCreationOptions,
691
+ }),
692
+ );
623
693
 
624
694
  if (opts.walletMinFeePadding !== undefined) {
625
695
  wallet.setMinFeePadding(opts.walletMinFeePadding);
626
696
  }
697
+ logger.trace('Created PXE and test wallet');
627
698
 
628
- const cheatCodes = await CheatCodes.create(
629
- config.l1RpcUrls,
630
- aztecNodeService,
631
- dateProvider,
632
- aztecNodeService.getAutomineSequencer(),
633
- );
699
+ const cheatCodes = await CheatCodes.create(config.l1RpcUrls, aztecNodeService, dateProvider);
700
+ logger.trace('Created cheat codes');
634
701
 
635
702
  if (
636
703
  (opts.aztecTargetCommitteeSize && opts.aztecTargetCommitteeSize > 0) ||
@@ -644,71 +711,48 @@ export async function setup(
644
711
  );
645
712
  await cheatCodes.rollup.setupEpoch();
646
713
  await cheatCodes.rollup.debugRollup();
714
+ logger.trace('Advanced chain to set up validator committee');
647
715
  }
648
716
 
649
717
  let accounts: AztecAddress[] = [];
650
718
 
651
- if (opts.skipInitialSequencer) {
652
- logger.info('Sequencer not started on initial node, skipping block progression');
653
- } else if (shouldDeployAccounts) {
654
- logger.info(
655
- `${numberOfAccounts} accounts are being deployed. Reliably progressing past genesis by setting minTxsPerBlock to 1 and waiting for the accounts to be deployed`,
656
- );
657
- const accountsData = initialFundedAccounts.slice(0, numberOfAccounts);
658
- const accountManagers = await deployFundedSchnorrAccounts(wallet, accountsData);
659
- accounts = accountManagers.map(accountManager => accountManager.address);
660
- } else if (needsEmptyBlock) {
661
- logger.info('No accounts are being deployed, waiting for an empty block 1 to be mined');
662
- // AutomineSequencer only builds on tx arrival; explicitly request an empty block.
663
- const automine = aztecNodeService.getAutomineSequencer();
664
- if (automine) {
665
- await automine.buildEmptyBlock();
666
- }
667
- while ((await aztecNodeService.getBlockNumber()) === 0) {
668
- await sleep(2000);
669
- }
670
- }
671
- // If skipAccountDeployment is true, we don't deploy or wait - tests will handle account deployment later
672
-
673
- // Now we restore the original minTxsPerBlock setting if we changed it.
674
- if (sequencerClient && config.minTxsPerBlock !== originalMinTxsPerBlock) {
675
- sequencerClient.getSequencer().updateConfig({ minTxsPerBlock: originalMinTxsPerBlock });
719
+ // Create the default accounts. They are initializerless, so this is a PXE-side operation (registration
720
+ // + a simulated store call) with no on-chain tx, independent of the sequencer.
721
+ if (numberOfAccounts > 0) {
722
+ logger.info(`Creating ${numberOfAccounts} initializerless test accounts`);
723
+ await testSpan('wallet:create', () => createFundedInitializerlessAccounts(wallet, defaultAccounts));
724
+ accounts = defaultAccounts.map(a => a.address);
676
725
  }
726
+ logger.trace('Created funded test accounts');
677
727
 
678
- if (initialFundedAccounts.length < numberOfAccounts) {
679
- throw new Error(
680
- `Unable to deploy ${numberOfAccounts} accounts. Only ${initialFundedAccounts.length} accounts were funded.`,
681
- );
682
- }
728
+ const teardown = () =>
729
+ testSpan('teardown:env', async () => {
730
+ try {
731
+ await tryStop(wallet, logger);
732
+ await tryStop(aztecNodeService, logger);
733
+ await tryStop(proverNode, logger);
683
734
 
684
- const teardown = async () => {
685
- try {
686
- await tryStop(wallet, logger);
687
- await tryStop(aztecNodeService, logger);
688
- await tryStop(proverNode, logger);
735
+ if (acvmConfig?.cleanup) {
736
+ await acvmConfig.cleanup();
737
+ }
689
738
 
690
- if (acvmConfig?.cleanup) {
691
- await acvmConfig.cleanup();
692
- }
739
+ if (bbConfig?.cleanup) {
740
+ await bbConfig.cleanup();
741
+ }
693
742
 
694
- if (bbConfig?.cleanup) {
695
- await bbConfig.cleanup();
696
- }
697
-
698
- await tryStop(watcher, logger);
699
- await tryStop(anvil, logger);
743
+ await tryStop(anvil, logger);
700
744
 
701
- await tryRmDir(directoryToCleanup, logger);
702
- } catch (err) {
703
- logger.error(`Error during e2e test teardown`, err);
704
- } finally {
705
- try {
706
- await telemetryClient.stop();
745
+ await tryRmDir(directoryToCleanup, logger);
707
746
  } catch (err) {
708
- logger.error(`Error during telemetry client stop`, err);
747
+ logger.error(`Error during e2e test teardown`, err);
748
+ } finally {
749
+ try {
750
+ await telemetryClient.stop();
751
+ } catch (err) {
752
+ logger.error(`Error during telemetry client stop`, err);
753
+ }
709
754
  }
710
- }
711
- };
755
+ });
712
756
 
713
757
  return {
714
758
  anvil,
@@ -721,10 +765,11 @@ export async function setup(
721
765
  aztecNodeConfig: config,
722
766
  dateProvider,
723
767
  deployL1ContractsValues,
724
- initialFundedAccounts,
768
+ additionallyFundedAccounts,
725
769
  logger,
726
770
  mockGossipSubNetwork,
727
771
  genesis,
772
+ extraL1DeployResult,
728
773
  proverNode,
729
774
  sequencerDelayer,
730
775
  proverDelayer,
@@ -733,7 +778,6 @@ export async function setup(
733
778
  telemetryClient,
734
779
  wallet,
735
780
  accounts,
736
- watcher,
737
781
  acvmConfig,
738
782
  bbConfig,
739
783
  directoryToCleanup,
@@ -800,7 +844,12 @@ export async function registerSponsoredFPC(wallet: Wallet): Promise<void> {
800
844
  await wallet.registerContract(await getSponsoredFPCInstance(), SponsoredFPCContract.artifact);
801
845
  }
802
846
 
803
- export async function waitForProvenChain(node: AztecNode, targetBlock?: BlockNumber, timeoutSec = 60, intervalSec = 1) {
847
+ export async function waitForProvenChain(
848
+ node: AztecNode,
849
+ targetBlock?: BlockNumber,
850
+ timeoutSec = 60,
851
+ intervalSec = 0.25,
852
+ ) {
804
853
  targetBlock ??= await node.getBlockNumber();
805
854
 
806
855
  await retryUntil(
@@ -823,11 +872,12 @@ export function createAndSyncProverNode(
823
872
  telemetry?: TelemetryClient;
824
873
  dateProvider: DateProvider;
825
874
  p2pClientDeps?: P2PClientDeps;
875
+ proverNodeDeps?: Partial<ProverNodeDeps>;
826
876
  },
827
877
  options: { genesis?: GenesisData; dontStart?: boolean },
828
878
  ): Promise<{ proverNode: AztecNodeService }> {
829
879
  return withLoggerBindings({ actor: 'prover-0' }, async () => {
830
- const proverNode = await AztecNodeService.createAndSync(
880
+ const proverNode = await createAztecNodeService(
831
881
  {
832
882
  ...baseConfig,
833
883
  ...configOverrides,
@@ -902,14 +952,16 @@ export async function expectMappingDelta<K, V extends number | bigint>(
902
952
  * surface as generic "Assertion failed:" and tests that match on the real message fail).
903
953
  */
904
954
  export async function ensureAuthRegistryPublished(wallet: Wallet, from: AztecAddress) {
905
- const { instance, contractClass } = await getStandardAuthRegistry();
906
- if (!(await wallet.getContractClassMetadata(contractClass.id)).isContractClassPubliclyRegistered) {
907
- await (await publishContractClass(wallet, AuthRegistryArtifact)).send({ from });
908
- }
909
- if (!(await wallet.getContractMetadata(instance.address)).isContractPublished) {
910
- await publishInstance(wallet, instance).send({ from });
911
- }
912
- await wallet.registerContract(instance, AuthRegistryArtifact);
955
+ await testSpan('setup:auth-registry', async () => {
956
+ const { instance, contractClass } = await getStandardAuthRegistry();
957
+ if (!(await wallet.getContractClassMetadata(contractClass.id)).isContractClassPubliclyRegistered) {
958
+ await (await publishContractClass(wallet, AuthRegistryArtifact)).send({ from });
959
+ }
960
+ if (!(await wallet.getContractMetadata(instance.address)).isContractPublished) {
961
+ await publishInstance(wallet, instance).send({ from });
962
+ }
963
+ await wallet.registerContract(instance, AuthRegistryArtifact);
964
+ });
913
965
  }
914
966
 
915
967
  /**
@@ -930,97 +982,19 @@ export async function ensurePublicChecksPublished(wallet: Wallet, from: AztecAdd
930
982
  }
931
983
 
932
984
  /**
933
- * Registers the contract class used for test accounts and publicly deploys the instances requested.
934
- * Use this when you need to make a public call to an account contract, such as for requesting a public authwit.
985
+ * Registers the handshake_registry contract class and publishes its standard instance if not
986
+ * already present, and registers the artifact with PXE. Required for constrained-delivery flows
987
+ * that call into the HandshakeRegistry at its well-known address.
935
988
  */
936
- export async function ensureAccountContractsPublished(wallet: Wallet, accountsToDeploy: AztecAddress[]) {
937
- const accountsAndAddresses = await Promise.all(
938
- accountsToDeploy.map(async address => {
939
- return {
940
- address,
941
- deployed: (await wallet.getContractMetadata(address)).isContractPublished,
942
- };
943
- }),
944
- );
945
- const instances = (
946
- await Promise.all(
947
- accountsAndAddresses
948
- .filter(({ deployed }) => !deployed)
949
- .map(({ address }) => wallet.getContractMetadata(address)),
950
- )
951
- ).map(contractMetadata => contractMetadata.instance);
952
- const contractClass = await getContractClassFromArtifact(SchnorrAccountContractArtifact);
989
+ export async function ensureHandshakeRegistryPublished(wallet: Wallet, from: AztecAddress) {
990
+ const { instance, contractClass } = await getStandardHandshakeRegistry();
953
991
  if (!(await wallet.getContractClassMetadata(contractClass.id)).isContractClassPubliclyRegistered) {
954
- await (await publishContractClass(wallet, SchnorrAccountContractArtifact)).send({ from: accountsToDeploy[0] });
992
+ await (await publishContractClass(wallet, HandshakeRegistryArtifact)).send({ from });
955
993
  }
956
- const requests = instances.map(instance => publishInstance(wallet, instance!));
957
- const batch = new BatchCall(wallet, requests);
958
- await batch.send({ from: accountsToDeploy[0] });
959
- }
960
-
961
- /**
962
- * Helper function to deploy accounts.
963
- * Returns deployed account data that can be used by tests.
964
- */
965
- export const deployAccounts =
966
- (numberOfAccounts: number, logger: Logger, deployOptions?: Partial<DeployOptions<InteractionWaitOptions>>) =>
967
- async ({ wallet, initialFundedAccounts }: { wallet: TestWallet; initialFundedAccounts: InitialAccountData[] }) => {
968
- if (initialFundedAccounts.length < numberOfAccounts) {
969
- throw new Error(`Cannot deploy more than ${initialFundedAccounts.length} initial accounts.`);
970
- }
971
-
972
- logger.verbose('Deploying accounts funded with fee juice...');
973
- const deployedAccounts = initialFundedAccounts.slice(0, numberOfAccounts);
974
- // Serial due to https://github.com/AztecProtocol/aztec-packages/issues/12045
975
- for (let i = 0; i < deployedAccounts.length; i++) {
976
- const accountManager = await wallet.createSchnorrAccount(
977
- deployedAccounts[i].secret,
978
- deployedAccounts[i].salt,
979
- deployedAccounts[i].signingKey,
980
- );
981
- const deployMethod = await accountManager.getDeployMethod();
982
- await deployMethod.send({
983
- from: NO_FROM,
984
- skipClassPublication: i !== 0, // Publish the contract class at most once.
985
- ...deployOptions,
986
- });
987
- }
988
-
989
- return { deployedAccounts };
990
- };
991
-
992
- /**
993
- * Registers the contract class used for test accounts and publicly deploys the instances requested.
994
- * Use this when you need to make a public call to an account contract, such as for requesting a public authwit.
995
- */
996
- export async function publicDeployAccounts(
997
- wallet: Wallet,
998
- accountsToDeploy: AztecAddress[],
999
- waitUntilProven = false,
1000
- node?: AztecNode,
1001
- ) {
1002
- const instances = (await Promise.all(accountsToDeploy.map(account => wallet.getContractMetadata(account)))).map(
1003
- metadata => metadata.instance,
1004
- );
1005
-
1006
- const contractClass = await getContractClassFromArtifact(SchnorrAccountContractArtifact);
1007
- const alreadyRegistered = (await wallet.getContractClassMetadata(contractClass.id)).isContractClassPubliclyRegistered;
1008
-
1009
- const calls: ContractFunctionInteraction[] = await Promise.all([
1010
- ...(!alreadyRegistered ? [publishContractClass(wallet, SchnorrAccountContractArtifact)] : []),
1011
- ...instances.map(instance => publishInstance(wallet, instance!)),
1012
- ]);
1013
-
1014
- const batch = new BatchCall(wallet, calls);
1015
-
1016
- const { receipt: txReceipt } = await batch.send({ from: accountsToDeploy[0] });
1017
- if (waitUntilProven) {
1018
- if (!node) {
1019
- throw new Error('Need to provide an AztecNode to wait for proven.');
1020
- } else {
1021
- await waitForProven(node, txReceipt);
1022
- }
994
+ if (!(await wallet.getContractMetadata(instance.address)).isContractPublished) {
995
+ await publishInstance(wallet, instance).send({ from });
1023
996
  }
997
+ await wallet.registerContract(instance, HandshakeRegistryArtifact);
1024
998
  }
1025
999
 
1026
1000
  /**