@aztec/end-to-end 5.0.0-rc.2 → 5.0.0

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 (246) 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 +17 -24
  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 -28
  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 +1 -1
  28. package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -1
  29. package/dest/bench/client_flows/client_flows_benchmark.js +16 -4
  30. package/dest/bench/utils.d.ts +1 -1
  31. package/dest/composed/ha/ha_full_setup.d.ts +77 -0
  32. package/dest/composed/ha/ha_full_setup.d.ts.map +1 -0
  33. package/dest/composed/ha/ha_full_setup.js +383 -0
  34. package/dest/composed/web3signer/multi_validator_keystore_utils.d.ts +12 -0
  35. package/dest/composed/web3signer/multi_validator_keystore_utils.d.ts.map +1 -0
  36. package/dest/fixtures/e2e_prover_test.d.ts +10 -7
  37. package/dest/fixtures/e2e_prover_test.d.ts.map +1 -1
  38. package/dest/fixtures/e2e_prover_test.js +30 -11
  39. package/dest/fixtures/fixtures.d.ts +7 -5
  40. package/dest/fixtures/fixtures.d.ts.map +1 -1
  41. package/dest/fixtures/fixtures.js +6 -4
  42. package/dest/fixtures/ha_setup.d.ts +3 -3
  43. package/dest/fixtures/ha_setup.d.ts.map +1 -1
  44. package/dest/fixtures/ha_setup.js +4 -1
  45. package/dest/fixtures/index.d.ts +2 -1
  46. package/dest/fixtures/index.d.ts.map +1 -1
  47. package/dest/fixtures/index.js +1 -0
  48. package/dest/fixtures/setup.d.ts +32 -8
  49. package/dest/fixtures/setup.d.ts.map +1 -1
  50. package/dest/fixtures/setup.js +165 -160
  51. package/dest/fixtures/standard_contracts_genesis.d.ts +16 -0
  52. package/dest/fixtures/standard_contracts_genesis.d.ts.map +1 -0
  53. package/dest/fixtures/standard_contracts_genesis.js +25 -0
  54. package/dest/fixtures/timing.d.ts +42 -0
  55. package/dest/fixtures/timing.d.ts.map +1 -0
  56. package/dest/fixtures/timing.js +72 -0
  57. package/dest/fixtures/wait_helpers.d.ts +135 -0
  58. package/dest/fixtures/wait_helpers.d.ts.map +1 -0
  59. package/dest/fixtures/wait_helpers.js +154 -0
  60. package/dest/forward-compatibility/wallet_service.js +1 -1
  61. package/dest/multi-node/block-production/setup.d.ts +97 -0
  62. package/dest/multi-node/block-production/setup.d.ts.map +1 -0
  63. package/dest/multi-node/block-production/setup.js +158 -0
  64. package/dest/multi-node/governance/setup.d.ts +67 -0
  65. package/dest/multi-node/governance/setup.d.ts.map +1 -0
  66. package/dest/multi-node/governance/setup.js +126 -0
  67. package/dest/multi-node/multi_node_test_context.d.ts +212 -0
  68. package/dest/multi-node/multi_node_test_context.d.ts.map +1 -0
  69. package/dest/multi-node/multi_node_test_context.js +347 -0
  70. package/dest/multi-node/slashing/inactivity_setup.d.ts +27 -0
  71. package/dest/multi-node/slashing/inactivity_setup.d.ts.map +1 -0
  72. package/dest/multi-node/slashing/inactivity_setup.js +111 -0
  73. package/dest/multi-node/slashing/setup.d.ts +167 -0
  74. package/dest/multi-node/slashing/setup.d.ts.map +1 -0
  75. package/dest/multi-node/slashing/setup.js +275 -0
  76. package/dest/{e2e_p2p → p2p}/p2p_network.d.ts +9 -1
  77. package/dest/p2p/p2p_network.d.ts.map +1 -0
  78. package/dest/{e2e_p2p → p2p}/p2p_network.js +26 -1
  79. package/dest/p2p/reqresp/utils.d.ts +19 -0
  80. package/dest/p2p/reqresp/utils.d.ts.map +1 -0
  81. package/dest/{e2e_p2p → p2p}/reqresp/utils.js +4 -15
  82. package/dest/p2p/shared.d.ts +72 -0
  83. package/dest/p2p/shared.d.ts.map +1 -0
  84. package/dest/p2p/shared.js +212 -0
  85. package/dest/shared/cross_chain_test_harness.d.ts +3 -3
  86. package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
  87. package/dest/shared/cross_chain_test_harness.js +24 -16
  88. package/dest/shared/gas_portal_test_harness.d.ts +1 -1
  89. package/dest/shared/gas_portal_test_harness.d.ts.map +1 -1
  90. package/dest/shared/gas_portal_test_harness.js +8 -5
  91. package/dest/shared/submit-transactions.d.ts +1 -1
  92. package/dest/shared/submit-transactions.d.ts.map +1 -1
  93. package/dest/shared/submit-transactions.js +12 -5
  94. package/dest/shared/timing_env.d.js +5 -0
  95. package/dest/shared/timing_env.js +158 -47
  96. package/dest/shared/wait_for_l1_to_l2_message.js +1 -1
  97. package/dest/single-node/cross-chain/cross_chain_messaging_test.d.ts +75 -0
  98. package/dest/single-node/cross-chain/cross_chain_messaging_test.d.ts.map +1 -0
  99. package/dest/{e2e_cross_chain_messaging → single-node/cross-chain}/cross_chain_messaging_test.js +74 -26
  100. package/dest/single-node/cross-chain/message_test_helpers.d.ts +38 -0
  101. package/dest/single-node/cross-chain/message_test_helpers.d.ts.map +1 -0
  102. package/dest/single-node/cross-chain/message_test_helpers.js +70 -0
  103. package/dest/{e2e_fees → single-node/fees}/bridging_race.notest.d.ts +1 -1
  104. package/dest/single-node/fees/bridging_race.notest.d.ts.map +1 -0
  105. package/dest/{e2e_fees → single-node/fees}/bridging_race.notest.js +9 -6
  106. package/dest/single-node/fees/fees_test.d.ts +95 -0
  107. package/dest/single-node/fees/fees_test.d.ts.map +1 -0
  108. package/dest/{e2e_fees → single-node/fees}/fees_test.js +121 -45
  109. package/dest/single-node/l1-reorgs/setup.d.ts +42 -0
  110. package/dest/single-node/l1-reorgs/setup.d.ts.map +1 -0
  111. package/dest/single-node/l1-reorgs/setup.js +57 -0
  112. package/dest/single-node/partial-proofs/setup.d.ts +5 -0
  113. package/dest/single-node/partial-proofs/setup.d.ts.map +1 -0
  114. package/dest/single-node/partial-proofs/setup.js +5 -0
  115. package/dest/single-node/proving/setup.d.ts +5 -0
  116. package/dest/single-node/proving/setup.d.ts.map +1 -0
  117. package/dest/single-node/proving/setup.js +5 -0
  118. package/dest/single-node/recovery/setup.d.ts +5 -0
  119. package/dest/single-node/recovery/setup.d.ts.map +1 -0
  120. package/dest/single-node/recovery/setup.js +5 -0
  121. package/dest/single-node/setup.d.ts +49 -0
  122. package/dest/single-node/setup.d.ts.map +1 -0
  123. package/dest/single-node/setup.js +56 -0
  124. package/dest/single-node/single_node_test_context.d.ts +373 -0
  125. package/dest/single-node/single_node_test_context.d.ts.map +1 -0
  126. package/dest/single-node/single_node_test_context.js +845 -0
  127. package/dest/spartan/setup_test_wallets.d.ts +1 -1
  128. package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
  129. package/dest/spartan/setup_test_wallets.js +13 -7
  130. package/dest/spartan/tx_metrics.d.ts +10 -1
  131. package/dest/spartan/tx_metrics.d.ts.map +1 -1
  132. package/dest/spartan/tx_metrics.js +32 -0
  133. package/dest/test-wallet/test_wallet.d.ts +23 -4
  134. package/dest/test-wallet/test_wallet.d.ts.map +1 -1
  135. package/dest/test-wallet/test_wallet.js +20 -4
  136. package/dest/test-wallet/utils.d.ts +36 -1
  137. package/dest/test-wallet/utils.d.ts.map +1 -1
  138. package/dest/test-wallet/utils.js +64 -4
  139. package/dest/test-wallet/wallet_worker_script.js +5 -2
  140. package/dest/test-wallet/worker_wallet.d.ts +5 -5
  141. package/dest/test-wallet/worker_wallet.d.ts.map +1 -1
  142. package/dest/test-wallet/worker_wallet.js +2 -2
  143. package/dest/test-wallet/worker_wallet_schema.js +2 -1
  144. package/package.json +40 -40
  145. package/src/automine/README.md +60 -0
  146. package/src/automine/automine_test_context.ts +153 -0
  147. package/src/automine/delivery/interactive_handshake_responder.ts +125 -0
  148. package/src/automine/delivery/onchain_delivery_harness.ts +213 -0
  149. package/src/{e2e_blacklist_token_contract → automine/token}/blacklist_token_contract_test.ts +19 -39
  150. package/src/{e2e_token_contract → automine/token}/token_contract_test.ts +24 -43
  151. package/src/automine/token/token_test_helpers.ts +138 -0
  152. package/src/bench/client_flows/benchmark.ts +3 -1
  153. package/src/bench/client_flows/client_flows_benchmark.ts +17 -4
  154. package/src/composed/ha/ha_full_setup.ts +466 -0
  155. package/src/fixtures/e2e_prover_test.ts +36 -20
  156. package/src/fixtures/fixtures.ts +6 -4
  157. package/src/fixtures/ha_setup.ts +7 -3
  158. package/src/fixtures/index.ts +1 -0
  159. package/src/fixtures/setup.ts +202 -161
  160. package/src/fixtures/standard_contracts_genesis.ts +28 -0
  161. package/src/fixtures/timing.ts +97 -0
  162. package/src/fixtures/wait_helpers.ts +333 -0
  163. package/src/forward-compatibility/wallet_service.ts +2 -2
  164. package/src/infra/README.md +12 -0
  165. package/src/multi-node/README.md +96 -0
  166. package/src/multi-node/block-production/setup.ts +272 -0
  167. package/src/multi-node/governance/setup.ts +172 -0
  168. package/src/multi-node/multi_node_test_context.ts +447 -0
  169. package/src/multi-node/slashing/inactivity_setup.ts +139 -0
  170. package/src/multi-node/slashing/setup.ts +433 -0
  171. package/src/p2p/README.md +78 -0
  172. package/src/{e2e_p2p → p2p}/p2p_network.ts +26 -0
  173. package/src/{e2e_p2p → p2p}/reqresp/utils.ts +5 -14
  174. package/src/p2p/shared.ts +329 -0
  175. package/src/shared/cross_chain_test_harness.ts +22 -13
  176. package/src/shared/gas_portal_test_harness.ts +13 -5
  177. package/src/shared/submit-transactions.ts +13 -5
  178. package/src/shared/timing_env.d.mts +39 -0
  179. package/src/shared/timing_env.mjs +152 -48
  180. package/src/shared/wait_for_l1_to_l2_message.ts +1 -1
  181. package/src/single-node/README.md +66 -0
  182. package/src/{e2e_cross_chain_messaging → single-node/cross-chain}/cross_chain_messaging_test.ts +100 -38
  183. package/src/single-node/cross-chain/message_test_helpers.ts +125 -0
  184. package/src/{e2e_fees → single-node/fees}/bridging_race.notest.ts +11 -7
  185. package/src/{e2e_fees → single-node/fees}/fees_test.ts +132 -47
  186. package/src/single-node/l1-reorgs/setup.ts +93 -0
  187. package/src/single-node/partial-proofs/setup.ts +8 -0
  188. package/src/single-node/proving/setup.ts +15 -0
  189. package/src/single-node/recovery/setup.ts +8 -0
  190. package/src/single-node/setup.ts +63 -0
  191. package/src/single-node/single_node_test_context.ts +1054 -0
  192. package/src/spartan/setup_test_wallets.ts +19 -7
  193. package/src/spartan/tx_metrics.ts +26 -0
  194. package/src/test-wallet/test_wallet.ts +28 -6
  195. package/src/test-wallet/utils.ts +102 -5
  196. package/src/test-wallet/wallet_worker_script.ts +6 -3
  197. package/src/test-wallet/worker_wallet.ts +5 -9
  198. package/src/test-wallet/worker_wallet_schema.ts +1 -1
  199. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +0 -56
  200. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts.map +0 -1
  201. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +0 -59
  202. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts.map +0 -1
  203. package/dest/e2e_deploy_contract/deploy_test.d.ts +0 -36
  204. package/dest/e2e_deploy_contract/deploy_test.d.ts.map +0 -1
  205. package/dest/e2e_deploy_contract/deploy_test.js +0 -42
  206. package/dest/e2e_epochs/epochs_test.d.ts +0 -137
  207. package/dest/e2e_epochs/epochs_test.d.ts.map +0 -1
  208. package/dest/e2e_epochs/epochs_test.js +0 -485
  209. package/dest/e2e_fees/bridging_race.notest.d.ts.map +0 -1
  210. package/dest/e2e_fees/fees_test.d.ts +0 -89
  211. package/dest/e2e_fees/fees_test.d.ts.map +0 -1
  212. package/dest/e2e_l1_publisher/write_json.d.ts +0 -11
  213. package/dest/e2e_l1_publisher/write_json.d.ts.map +0 -1
  214. package/dest/e2e_l1_publisher/write_json.js +0 -57
  215. package/dest/e2e_multi_validator/utils.d.ts +0 -12
  216. package/dest/e2e_multi_validator/utils.d.ts.map +0 -1
  217. package/dest/e2e_nested_contract/nested_contract_test.d.ts +0 -22
  218. package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +0 -1
  219. package/dest/e2e_nested_contract/nested_contract_test.js +0 -40
  220. package/dest/e2e_p2p/inactivity_slash_test.d.ts +0 -31
  221. package/dest/e2e_p2p/inactivity_slash_test.d.ts.map +0 -1
  222. package/dest/e2e_p2p/inactivity_slash_test.js +0 -138
  223. package/dest/e2e_p2p/p2p_network.d.ts.map +0 -1
  224. package/dest/e2e_p2p/reqresp/utils.d.ts +0 -22
  225. package/dest/e2e_p2p/reqresp/utils.d.ts.map +0 -1
  226. package/dest/e2e_p2p/shared.d.ts +0 -100
  227. package/dest/e2e_p2p/shared.d.ts.map +0 -1
  228. package/dest/e2e_p2p/shared.js +0 -257
  229. package/dest/e2e_storage_proof/fixtures/storage_proof_fetcher.d.ts +0 -2
  230. package/dest/e2e_storage_proof/fixtures/storage_proof_fetcher.d.ts.map +0 -1
  231. package/dest/e2e_storage_proof/fixtures/storage_proof_fixture.d.ts.map +0 -1
  232. package/dest/e2e_token_contract/token_contract_test.d.ts +0 -44
  233. package/dest/e2e_token_contract/token_contract_test.d.ts.map +0 -1
  234. package/src/e2e_deploy_contract/deploy_test.ts +0 -73
  235. package/src/e2e_epochs/epochs_test.ts +0 -596
  236. package/src/e2e_l1_publisher/write_json.ts +0 -78
  237. package/src/e2e_nested_contract/nested_contract_test.ts +0 -51
  238. package/src/e2e_p2p/inactivity_slash_test.ts +0 -181
  239. package/src/e2e_p2p/shared.ts +0 -391
  240. /package/dest/{e2e_storage_proof → automine/contracts}/fixtures/storage_proof_fetcher.js +0 -0
  241. /package/dest/{e2e_storage_proof → automine/contracts}/fixtures/storage_proof_fixture.js +0 -0
  242. /package/dest/{e2e_multi_validator/utils.js → composed/web3signer/multi_validator_keystore_utils.js} +0 -0
  243. /package/src/{e2e_storage_proof → automine/contracts}/fixtures/storage_proof.json +0 -0
  244. /package/src/{e2e_storage_proof → automine/contracts}/fixtures/storage_proof_fetcher.ts +0 -0
  245. /package/src/{e2e_storage_proof → automine/contracts}/fixtures/storage_proof_fixture.ts +0 -0
  246. /package/src/{e2e_multi_validator/utils.ts → composed/web3signer/multi_validator_keystore_utils.ts} +0 -0
@@ -22,15 +22,15 @@ import {
22
22
  deployAztecL1Contracts,
23
23
  } from '@aztec/ethereum/deploy-aztec-l1-contracts';
24
24
  import type { Delayer } from '@aztec/ethereum/l1-tx-utils';
25
- import { EthCheatCodes, EthCheatCodesWithState, startAnvil } from '@aztec/ethereum/test';
25
+ import { EthCheatCodes, EthCheatCodesWithState, startAnvil, warmBlobKzg } from '@aztec/ethereum/test';
26
26
  import type { Anvil } from '@aztec/ethereum/test';
27
+ import type { ExtendedViemWalletClient } from '@aztec/ethereum/types';
27
28
  import { BlockNumber, EpochNumber } from '@aztec/foundation/branded-types';
28
29
  import { SecretValue } from '@aztec/foundation/config';
29
30
  import { randomBytes } from '@aztec/foundation/crypto/random';
30
31
  import { tryRmDir } from '@aztec/foundation/fs';
31
32
  import { withLoggerBindings } from '@aztec/foundation/log/server';
32
33
  import { retryUntil } from '@aztec/foundation/retry';
33
- import { sleep } from '@aztec/foundation/sleep';
34
34
  import { DateProvider, TestDateProvider } from '@aztec/foundation/timer';
35
35
  import { SponsoredFPCContract } from '@aztec/noir-contracts.js/SponsoredFPC';
36
36
  import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
@@ -77,6 +77,8 @@ import { MNEMONIC, TEST_MAX_PENDING_TX_POOL_COUNT, TEST_PEER_CHECK_INTERVAL_MS }
77
77
  import { getACVMConfig } from './get_acvm_config.js';
78
78
  import { getBBConfig } from './get_bb_config.js';
79
79
  import { isMetricsLoggingRequested, setupMetricsLogger } from './logging.js';
80
+ import { getStandardContractGenesisNullifiers } from './standard_contracts_genesis.js';
81
+ import { testSpan } from './timing.js';
80
82
  import { getEndToEndTestTelemetryClient } from './with_telemetry_utils.js';
81
83
 
82
84
  export { startAnvil };
@@ -152,7 +154,7 @@ export async function setupPXEAndGetWallet(
152
154
  }
153
155
 
154
156
  /** Options for the e2e tests setup */
155
- export type SetupOptions = {
157
+ export type SetupOptions<TDeployExtraL1ContractsReturnType = unknown> = {
156
158
  /** State load */
157
159
  stateLoad?: string;
158
160
  /** Whether to enable metrics collection, if undefined, metrics collection is disabled */
@@ -184,8 +186,26 @@ export type SetupOptions = {
184
186
  mockGossipSubNetwork?: boolean;
185
187
  /** Whether to add simulated latency to the mock gossipsub network (in ms) */
186
188
  mockGossipSubNetworkLatency?: number;
187
- /** 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
+ */
188
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>;
189
209
  /** How many accounts to seed and unlock in anvil. */
190
210
  anvilAccounts?: number;
191
211
  /** Port to start anvil (defaults to 8545) */
@@ -202,10 +222,13 @@ export type SetupOptions = {
202
222
  /** Whether to fund the sponsored FPC in genesis (defaults to false). */
203
223
  fundSponsoredFPC?: boolean;
204
224
  /**
205
- * Whether to advance the chain past genesis by mining an empty block during setup (defaults to true).
206
- * Set to false for tests that must observe the chain at genesis (block 0).
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`.
207
230
  */
208
- advancePastGenesis?: boolean;
231
+ computeExtraGenesisFundedAddresses?: (defaultAccounts: InitialAccountData[]) => Promise<AztecAddress[]>;
209
232
  /** L1 contracts deployment arguments. */
210
233
  l1ContractsArgs?: Partial<DeployAztecL1ContractsArgs>;
211
234
  /** Wallet minimum fee padding multiplier */
@@ -221,7 +244,7 @@ export type SetupOptions = {
221
244
  } & Partial<AztecNodeConfig>;
222
245
 
223
246
  /** Context for an end-to-end test as returned by the `setup` function */
224
- export type EndToEndContext = {
247
+ export type EndToEndContext<TDeployExtraL1ContractsReturnType = unknown> = {
225
248
  /** The Anvil instance (only set if anvil was started locally). */
226
249
  anvil: Anvil | undefined;
227
250
  /** The Aztec Node service or client a connected to it. */
@@ -264,6 +287,8 @@ export type EndToEndContext = {
264
287
  proverDelayer: Delayer | undefined;
265
288
  /** Genesis data used for setting up nodes. */
266
289
  genesis: GenesisData | undefined;
290
+ /** Resolved value of the `deployExtraL1Contracts` setup hook, if one was provided. */
291
+ extraL1DeployResult: TDeployExtraL1ContractsReturnType;
267
292
  /** ACVM config (only set if running locally). */
268
293
  acvmConfig: Awaited<ReturnType<typeof getACVMConfig>>;
269
294
  /** BB config (only set if running locally). */
@@ -300,48 +325,49 @@ function assertContractArtifactsVersion() {
300
325
  }
301
326
  }
302
327
 
303
- /**
304
- * Records a function-level timing span into the shared collector installed by the e2e timing
305
- * environment. No-op unless TEST_TIMING_FILE is set (the env only installs the collector then). The
306
- * span is tagged with the name of the currently running test so the env can attribute it to the
307
- * right line; `null` during beforeAll/afterAll lands it on the suite-scoped line.
308
- */
309
- function recordFnSpan(kind: 'setup' | 'teardown', ms: number) {
310
- const collector = (globalThis as { __e2eTimings?: { current: string | null; fnSpans: unknown[] } }).__e2eTimings;
311
- collector?.fnSpans.push({ name: collector.current, kind, ms });
312
- }
313
-
314
328
  /**
315
329
  * Sets up the environment for the end-to-end tests.
316
330
  * @param numberOfAccounts - The number of new accounts to be created once the PXE is initiated.
317
331
  * @param opts - Options to pass to the node initialization and to the setup script.
318
332
  * @param pxeOpts - Options to pass to the PXE initialization.
319
333
  */
320
- export async function setup(
334
+ export function setup<TDeployExtraL1ContractsReturnType = unknown>(
321
335
  numberOfAccounts = 1,
322
- opts: SetupOptions = {},
336
+ opts: SetupOptions<TDeployExtraL1ContractsReturnType> = {},
323
337
  pxeOpts: Partial<PXEConfig> = {},
324
338
  chain: Chain = foundry,
325
- ): Promise<EndToEndContext> {
326
- const setupStart = performance.now();
327
- try {
328
- return await setupInner(numberOfAccounts, opts, pxeOpts, chain);
329
- } finally {
330
- recordFnSpan('setup', performance.now() - setupStart);
331
- }
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
+ });
332
352
  }
333
353
 
334
- async function setupInner(
354
+ async function setupInner<TDeployExtraL1ContractsReturnType = unknown>(
335
355
  numberOfAccounts: number,
336
- opts: SetupOptions,
356
+ opts: SetupOptions<TDeployExtraL1ContractsReturnType>,
337
357
  pxeOpts: Partial<PXEConfig>,
338
358
  chain: Chain,
339
- ): Promise<EndToEndContext> {
359
+ ): Promise<EndToEndContext<TDeployExtraL1ContractsReturnType>> {
340
360
  assertContractArtifactsVersion();
361
+ const logger = getLogger();
341
362
  let anvil: Anvil | undefined;
342
363
  try {
343
364
  opts.aztecTargetCommitteeSize ??= 0;
344
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');
345
371
 
346
372
  const config: AztecNodeConfig & SetupOptions = { ...getConfigEnvVars(), ...opts };
347
373
  // use initialValidators for the node config
@@ -357,8 +383,6 @@ async function setupInner(
357
383
 
358
384
  config.minTxPoolAgeMs = opts.minTxPoolAgeMs ?? 0;
359
385
 
360
- const logger = getLogger();
361
-
362
386
  // Create a temp directory for any services that need it and cleanup later
363
387
  const directoryToCleanup = path.join(tmpdir(), randomBytes(8).toString('hex'));
364
388
  await fs.mkdir(directoryToCleanup, { recursive: true });
@@ -372,16 +396,19 @@ async function setupInner(
372
396
  if (!isAnvilTestChain(chain.id)) {
373
397
  throw new Error(`No ETHEREUM_HOSTS set but non anvil chain requested`);
374
398
  }
375
- const res = await startAnvil({
376
- l1BlockTime: opts.ethereumSlotDuration,
377
- accounts: opts.anvilAccounts,
378
- port: opts.anvilPort ?? (process.env.ANVIL_PORT ? parseInt(process.env.ANVIL_PORT) : undefined),
379
- slotsInAnEpoch: opts.anvilSlotsInAnEpoch,
380
- dateProvider,
381
- });
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
+ );
382
408
  anvil = res.anvil;
383
409
  config.l1RpcUrls = [res.rpcUrl];
384
410
  }
411
+ logger.trace('Started anvil and L1 RPC client');
385
412
 
386
413
  // Enable logging metrics to a local file named after the test suite
387
414
  if (isMetricsLoggingRequested()) {
@@ -398,6 +425,7 @@ async function setupInner(
398
425
  if (opts.l1StartTime) {
399
426
  await ethCheatCodes.warp(opts.l1StartTime, { resetBlockInterval: true });
400
427
  }
428
+ logger.trace('Initialized L1 cheat codes and applied state/time overrides');
401
429
 
402
430
  let publisherPrivKeyHex: `0x${string}` | undefined = undefined;
403
431
  let publisherHdAccount: HDAccount | PrivateKeyAccount | undefined = undefined;
@@ -425,6 +453,7 @@ async function setupInner(
425
453
  if (config.coinbase === undefined) {
426
454
  config.coinbase = EthAddress.fromString(publisherHdAccount.address);
427
455
  }
456
+ logger.trace('Resolved L1 publisher account');
428
457
 
429
458
  // The accounts setup creates itself: `numberOfAccounts` initializerless accounts, generated here and
430
459
  // funded at genesis so they are immediately usable.
@@ -439,13 +468,29 @@ async function setupInner(
439
468
  addressesToFund.push(sponsoredFPCAddress);
440
469
  }
441
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
+
442
485
  const genesisTimestamp = BigInt(Math.floor(Date.now() / 1000));
443
486
  const { genesisArchiveRoot, genesis, fundingNeeded } = await getGenesisValues(
444
487
  addressesToFund,
445
488
  opts.initialAccountFeeJuice,
446
489
  opts.genesisPublicData,
447
490
  genesisTimestamp,
491
+ standardContractNullifiers,
448
492
  );
493
+ logger.trace('Computed genesis values');
449
494
 
450
495
  const wasAutomining = await ethCheatCodes.isAutoMining();
451
496
  const enableAutomine = opts.automineL1Setup && !wasAutomining && isAnvilTestChain(chain.id);
@@ -455,18 +500,21 @@ async function setupInner(
455
500
 
456
501
  const l1Client = createExtendedL1Client(config.l1RpcUrls, publisherHdAccount!, chain);
457
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
+
458
508
  // Deploy Multicall3 if running locally
459
509
  await deployMulticall3(l1Client, logger);
460
510
 
461
511
  // Force viem to refresh its nonce cache to avoid "nonce too low" errors in subsequent transactions
462
512
  // This is necessary because deployMulticall3 sends multiple transactions and viem may cache a stale nonce
463
513
  await l1Client.getTransactionCount({ address: l1Client.account.address });
514
+ logger.trace('Deployed Multicall3');
464
515
 
465
- const deployL1ContractsValues: DeployAztecL1ContractsReturnType = await deployAztecL1Contracts(
466
- config.l1RpcUrls[0],
467
- publisherPrivKeyHex!,
468
- chain.id,
469
- {
516
+ const deployL1ContractsValues: DeployAztecL1ContractsReturnType = await testSpan('setup:env:l1-deploy', () =>
517
+ deployAztecL1Contracts(config.l1RpcUrls[0], publisherPrivKeyHex!, chain.id, {
470
518
  ...getL1ContractsConfigEnvVars(),
471
519
  ...opts,
472
520
  ...opts.l1ContractsArgs,
@@ -476,7 +524,7 @@ async function setupInner(
476
524
  initialValidators: opts.initialValidators,
477
525
  feeJuicePortalInitialBalance: fundingNeeded,
478
526
  realVerifier: false,
479
- },
527
+ }),
480
528
  );
481
529
 
482
530
  Object.assign(config, deployL1ContractsValues.l1ContractAddresses);
@@ -500,9 +548,23 @@ async function setupInner(
500
548
  }
501
549
  }
502
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
+
503
566
  if (enableAutomine) {
504
- await ethCheatCodes.setAutomine(false);
505
- await ethCheatCodes.setIntervalMining(config.ethereumSlotDuration);
567
+ await ethCheatCodes.startIntervalMiningWithFreshBlock(config.ethereumSlotDuration);
506
568
  }
507
569
 
508
570
  // In compose mode (no local anvil), sync dateProvider to L1 time since it may have drifted
@@ -515,27 +577,34 @@ async function setupInner(
515
577
  if (opts.l2StartTime) {
516
578
  await ethCheatCodes.warp(opts.l2StartTime, { resetBlockInterval: true });
517
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');
518
594
 
519
- // Use metricsPort-based telemetry if provided, otherwise use the regular telemetry client
520
- const telemetryClient = opts.metricsPort
521
- ? await getEndToEndTestTelemetryClient(opts.metricsPort)
522
- : await getTelemetryClient(opts.telemetryConfig);
523
-
524
- await setupSharedBlobStorage(config);
525
-
526
- logger.verbose('Creating and synching an aztec node', config);
527
-
528
- const acvmConfig = await getACVMConfig(logger);
529
595
  if (acvmConfig) {
530
596
  config.acvmWorkingDirectory = acvmConfig.acvmWorkingDirectory;
531
597
  config.acvmBinaryPath = acvmConfig.acvmBinaryPath;
532
598
  }
599
+ logger.trace('Resolved ACVM config');
533
600
 
534
- const bbConfig = await getBBConfig(logger);
535
601
  if (bbConfig) {
536
602
  config.bbBinaryPath = bbConfig.bbBinaryPath;
537
603
  config.bbWorkingDirectory = bbConfig.bbWorkingDirectory;
538
604
  }
605
+ logger.trace('Resolved Barretenberg config');
606
+
607
+ logger.verbose('Creating and synching an aztec node', config);
539
608
 
540
609
  let mockGossipSubNetwork: MockGossipSubNetwork | undefined;
541
610
  let p2pClientDeps: P2PClientDeps | undefined = undefined;
@@ -545,27 +614,6 @@ async function setupInner(
545
614
  p2pClientDeps = { p2pServiceFactory: getMockPubSubP2PServiceFactory(mockGossipSubNetwork) };
546
615
  }
547
616
 
548
- // Transactions built against the genesis state must be included in block 1, otherwise they are dropped.
549
- // To avoid test failures from dropped transactions, we ensure progression beyond genesis before proceeding.
550
- const originalMinTxsPerBlock = config.minTxsPerBlock;
551
- if (originalMinTxsPerBlock === undefined) {
552
- throw new Error('minTxsPerBlock is undefined in e2e test setup');
553
- }
554
- const originalBuildCheckpointIfEmpty = config.buildCheckpointIfEmpty ?? false;
555
-
556
- // Allow an empty checkpoint so the empty block can be built; leave untouched when not advancing.
557
- const advancePastGenesis = (opts.advancePastGenesis ?? true) && !opts.skipInitialSequencer;
558
- config.minTxsPerBlock = advancePastGenesis ? 0 : originalMinTxsPerBlock;
559
- // Pipelining is always on: the proposer builds during slot N-1 for slot N. A tx submitted at slot N
560
- // start arrives after that build, so forcing minTxsPerBlock=1 would stall the chain on alternating
561
- // slots -- hence empty checkpoints are allowed (minTxsPerBlock=0) while advancing past genesis.
562
- // Automine is unaffected: its runBuild clamps mempool builds to Math.max(minTxsPerBlock ?? 1, 1) and
563
- // still requires minValidTxs: 1.
564
- const shouldTemporarilyBuildEmptyCheckpoints = advancePastGenesis && config.useAutomineSequencer !== true;
565
- if (shouldTemporarilyBuildEmptyCheckpoints) {
566
- config.buildCheckpointIfEmpty = true;
567
- }
568
-
569
617
  config.p2pEnabled = opts.mockGossipSubNetwork || config.p2pEnabled;
570
618
  config.p2pIp = opts.p2pIp ?? config.p2pIp ?? '127.0.0.1';
571
619
 
@@ -585,15 +633,19 @@ async function setupInner(
585
633
  ...(opts.mockGossipSubNetwork ? {} : { p2pEnabled: false, bootstrapNodes: [] as string[] }),
586
634
  }
587
635
  : config;
588
-
589
- const aztecNodeService = await withLoggerBindings({ actor: 'node-0' }, () =>
590
- createAztecNodeService(
591
- initialNodeConfig,
592
- { dateProvider, telemetry: telemetryClient, p2pClientDeps },
593
- { 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
+ ),
594
645
  ),
595
646
  );
596
647
  const sequencerClient = aztecNodeService.getSequencer();
648
+ logger.trace('Created and synced aztec node');
597
649
 
598
650
  let proverNode: AztecNodeService | undefined = undefined;
599
651
  if (opts.startProverNode) {
@@ -607,16 +659,19 @@ async function setupInner(
607
659
  rpcTxProviders: [aztecNodeService],
608
660
  };
609
661
 
610
- ({ proverNode } = await createAndSyncProverNode(
611
- proverNodePrivateKeyHex,
612
- config,
613
- {
614
- ...config.proverNodeConfig,
615
- dataDirectory: proverNodeDataDirectory,
616
- },
617
- { dateProvider, p2pClientDeps, telemetry: telemetryClient },
618
- { 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
+ ),
619
673
  ));
674
+ logger.trace('Created prover node');
620
675
  }
621
676
 
622
677
  const sequencerDelayer = sequencerClient?.getDelayer();
@@ -627,18 +682,22 @@ async function setupInner(
627
682
  pxeConfig.dataDirectory = path.join(directoryToCleanup, randomBytes(8).toString('hex'));
628
683
  // For tests we only want proving enabled if specifically requested
629
684
  pxeConfig.proverEnabled = !!pxeOpts.proverEnabled;
630
- const wallet = await TestWallet.create(aztecNodeService, pxeConfig, {
631
- loggerActorLabel: 'pxe-0',
632
- // In-process node implements the debug API, so register public function signatures for named traces.
633
- nodeDebug: aztecNodeService,
634
- ...opts.pxeCreationOptions,
635
- });
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
+ );
636
693
 
637
694
  if (opts.walletMinFeePadding !== undefined) {
638
695
  wallet.setMinFeePadding(opts.walletMinFeePadding);
639
696
  }
697
+ logger.trace('Created PXE and test wallet');
640
698
 
641
699
  const cheatCodes = await CheatCodes.create(config.l1RpcUrls, aztecNodeService, dateProvider);
700
+ logger.trace('Created cheat codes');
642
701
 
643
702
  if (
644
703
  (opts.aztecTargetCommitteeSize && opts.aztecTargetCommitteeSize > 0) ||
@@ -652,6 +711,7 @@ async function setupInner(
652
711
  );
653
712
  await cheatCodes.rollup.setupEpoch();
654
713
  await cheatCodes.rollup.debugRollup();
714
+ logger.trace('Advanced chain to set up validator committee');
655
715
  }
656
716
 
657
717
  let accounts: AztecAddress[] = [];
@@ -660,66 +720,39 @@ async function setupInner(
660
720
  // + a simulated store call) with no on-chain tx, independent of the sequencer.
661
721
  if (numberOfAccounts > 0) {
662
722
  logger.info(`Creating ${numberOfAccounts} initializerless test accounts`);
663
- await createFundedInitializerlessAccounts(wallet, defaultAccounts);
723
+ await testSpan('wallet:create', () => createFundedInitializerlessAccounts(wallet, defaultAccounts));
664
724
  accounts = defaultAccounts.map(a => a.address);
665
725
  }
726
+ logger.trace('Created funded test accounts');
666
727
 
667
- // Advancing past genesis needs a running sequencer to build the empty block; advancePastGenesis is
668
- // already false when skipInitialSequencer is set.
669
- if (advancePastGenesis) {
670
- logger.info('Mining an empty block to progress past genesis');
671
- const automine = aztecNodeService.getAutomineSequencer();
672
- if (automine) {
673
- await automine.buildEmptyBlock();
674
- }
675
- while ((await aztecNodeService.getBlockNumber()) === 0) {
676
- await sleep(2000);
677
- }
678
- } else if (opts.skipInitialSequencer) {
679
- logger.info('Sequencer not started on initial node, skipping block progression');
680
- }
681
-
682
- // Now we restore the original minTxsPerBlock setting if we changed it.
683
- if (sequencerClient) {
684
- const sequencer = sequencerClient.getSequencer();
685
- if (config.minTxsPerBlock !== originalMinTxsPerBlock) {
686
- sequencer.updateConfig({ minTxsPerBlock: originalMinTxsPerBlock });
687
- }
688
- if (shouldTemporarilyBuildEmptyCheckpoints) {
689
- sequencer.updateConfig({ buildCheckpointIfEmpty: originalBuildCheckpointIfEmpty });
690
- config.buildCheckpointIfEmpty = originalBuildCheckpointIfEmpty;
691
- }
692
- }
693
-
694
- const teardown = async () => {
695
- const teardownStart = performance.now();
696
- try {
697
- await tryStop(wallet, logger);
698
- await tryStop(aztecNodeService, logger);
699
- await tryStop(proverNode, logger);
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);
700
734
 
701
- if (acvmConfig?.cleanup) {
702
- await acvmConfig.cleanup();
703
- }
735
+ if (acvmConfig?.cleanup) {
736
+ await acvmConfig.cleanup();
737
+ }
704
738
 
705
- if (bbConfig?.cleanup) {
706
- await bbConfig.cleanup();
707
- }
739
+ if (bbConfig?.cleanup) {
740
+ await bbConfig.cleanup();
741
+ }
708
742
 
709
- await tryStop(anvil, logger);
743
+ await tryStop(anvil, logger);
710
744
 
711
- await tryRmDir(directoryToCleanup, logger);
712
- } catch (err) {
713
- logger.error(`Error during e2e test teardown`, err);
714
- } finally {
715
- try {
716
- await telemetryClient.stop();
745
+ await tryRmDir(directoryToCleanup, logger);
717
746
  } catch (err) {
718
- 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
+ }
719
754
  }
720
- recordFnSpan('teardown', performance.now() - teardownStart);
721
- }
722
- };
755
+ });
723
756
 
724
757
  return {
725
758
  anvil,
@@ -736,6 +769,7 @@ async function setupInner(
736
769
  logger,
737
770
  mockGossipSubNetwork,
738
771
  genesis,
772
+ extraL1DeployResult,
739
773
  proverNode,
740
774
  sequencerDelayer,
741
775
  proverDelayer,
@@ -810,7 +844,12 @@ export async function registerSponsoredFPC(wallet: Wallet): Promise<void> {
810
844
  await wallet.registerContract(await getSponsoredFPCInstance(), SponsoredFPCContract.artifact);
811
845
  }
812
846
 
813
- 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
+ ) {
814
853
  targetBlock ??= await node.getBlockNumber();
815
854
 
816
855
  await retryUntil(
@@ -912,14 +951,16 @@ export async function expectMappingDelta<K, V extends number | bigint>(
912
951
  * surface as generic "Assertion failed:" and tests that match on the real message fail).
913
952
  */
914
953
  export async function ensureAuthRegistryPublished(wallet: Wallet, from: AztecAddress) {
915
- const { instance, contractClass } = await getStandardAuthRegistry();
916
- if (!(await wallet.getContractClassMetadata(contractClass.id)).isContractClassPubliclyRegistered) {
917
- await (await publishContractClass(wallet, AuthRegistryArtifact)).send({ from });
918
- }
919
- if (!(await wallet.getContractMetadata(instance.address)).isContractPublished) {
920
- await publishInstance(wallet, instance).send({ from });
921
- }
922
- await wallet.registerContract(instance, AuthRegistryArtifact);
954
+ await testSpan('setup:auth-registry', async () => {
955
+ const { instance, contractClass } = await getStandardAuthRegistry();
956
+ if (!(await wallet.getContractClassMetadata(contractClass.id)).isContractClassPubliclyRegistered) {
957
+ await (await publishContractClass(wallet, AuthRegistryArtifact)).send({ from });
958
+ }
959
+ if (!(await wallet.getContractMetadata(instance.address)).isContractPublished) {
960
+ await publishInstance(wallet, instance).send({ from });
961
+ }
962
+ await wallet.registerContract(instance, AuthRegistryArtifact);
963
+ });
923
964
  }
924
965
 
925
966
  /**
@@ -0,0 +1,28 @@
1
+ import type { Fr } from '@aztec/foundation/curves/bn254';
2
+ import { ProtocolContractAddress } from '@aztec/protocol-contracts';
3
+ import { getPublishableStandardContracts } from '@aztec/standard-contracts';
4
+ import { siloNullifier } from '@aztec/stdlib/hash';
5
+
6
+ /**
7
+ * Computes the genesis nullifiers that pre-publish the standard contracts (AuthRegistry, PublicChecks,
8
+ * HandshakeRegistry) in e2e environments, mirroring the nullifiers their on-chain publish txs would emit. Per contract:
9
+ * - `siloNullifier(ContractClassRegistry, classId)` — the class-registration nullifier that `ContractClassRegistry.publish` pushes.
10
+ * - `siloNullifier(ContractInstanceRegistry, instanceAddress)` — the instance-deployment nullifier that
11
+ * `ContractInstanceRegistry.publish_for_public_execution` pushes, using the contract's real derived address (standard
12
+ * contracts are deployed at artifact-derived addresses, not magic protocol addresses).
13
+ *
14
+ * Seed these into the genesis nullifier tree (as the 5th `getGenesisValues` arg) alongside the archiver's
15
+ * `testPreloadStandardContracts` preload: the store preload makes the `ensure*Published` guards short-circuit, and these
16
+ * nullifiers make the AVM's deployment-nullifier check pass when the contracts are called. Every e2e node genesis that
17
+ * feeds an L1 `genesisArchiveRoot` must seed the same set, or the world-state root diverges from the deployed rollup.
18
+ */
19
+ export async function getStandardContractGenesisNullifiers(): Promise<Fr[]> {
20
+ const classRegistry = ProtocolContractAddress.ContractClassRegistry;
21
+ const instanceRegistry = ProtocolContractAddress.ContractInstanceRegistry;
22
+ const nullifiers: Fr[] = [];
23
+ for (const { contractClass, address } of await getPublishableStandardContracts()) {
24
+ nullifiers.push(await siloNullifier(classRegistry, contractClass.id));
25
+ nullifiers.push(await siloNullifier(instanceRegistry, address.toField()));
26
+ }
27
+ return nullifiers;
28
+ }