@aztec/end-to-end 0.0.1-commit.b9865e97 → 0.0.1-commit.be03c316

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