@aztec/end-to-end 0.0.1-commit.2ed92850 → 0.0.1-commit.2f68f620

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 (234) hide show
  1. package/README.md +27 -0
  2. package/dest/bench/client_flows/benchmark.d.ts +15 -1
  3. package/dest/bench/client_flows/benchmark.d.ts.map +1 -1
  4. package/dest/bench/client_flows/benchmark.js +17 -0
  5. package/dest/bench/client_flows/client_flows_benchmark.d.ts +3 -3
  6. package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -1
  7. package/dest/bench/client_flows/client_flows_benchmark.js +36 -39
  8. package/dest/bench/client_flows/config.d.ts +2 -2
  9. package/dest/bench/client_flows/config.d.ts.map +1 -1
  10. package/dest/bench/client_flows/config.js +18 -0
  11. package/dest/bench/utils.d.ts +1 -1
  12. package/dest/bench/utils.d.ts.map +1 -1
  13. package/dest/bench/utils.js +8 -3
  14. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +8 -5
  15. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts.map +1 -1
  16. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.js +36 -17
  17. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +16 -5
  18. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts.map +1 -1
  19. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.js +42 -9
  20. package/dest/e2e_deploy_contract/deploy_test.d.ts +4 -4
  21. package/dest/e2e_deploy_contract/deploy_test.d.ts.map +1 -1
  22. package/dest/e2e_deploy_contract/deploy_test.js +2 -1
  23. package/dest/e2e_epochs/epochs_test.d.ts +39 -8
  24. package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
  25. package/dest/e2e_epochs/epochs_test.js +170 -52
  26. package/dest/e2e_fees/fees_test.d.ts +6 -3
  27. package/dest/e2e_fees/fees_test.d.ts.map +1 -1
  28. package/dest/e2e_fees/fees_test.js +50 -17
  29. package/dest/e2e_l1_publisher/write_json.d.ts +3 -2
  30. package/dest/e2e_l1_publisher/write_json.d.ts.map +1 -1
  31. package/dest/e2e_l1_publisher/write_json.js +1 -7
  32. package/dest/e2e_nested_contract/nested_contract_test.d.ts +3 -3
  33. package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +1 -1
  34. package/dest/e2e_nested_contract/nested_contract_test.js +6 -7
  35. package/dest/e2e_p2p/inactivity_slash_test.d.ts +1 -1
  36. package/dest/e2e_p2p/inactivity_slash_test.d.ts.map +1 -1
  37. package/dest/e2e_p2p/inactivity_slash_test.js +4 -3
  38. package/dest/e2e_p2p/p2p_network.d.ts +14 -12
  39. package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
  40. package/dest/e2e_p2p/p2p_network.js +70 -34
  41. package/dest/e2e_p2p/reqresp/utils.d.ts +22 -0
  42. package/dest/e2e_p2p/reqresp/utils.d.ts.map +1 -0
  43. package/dest/e2e_p2p/reqresp/utils.js +206 -0
  44. package/dest/e2e_p2p/shared.d.ts +37 -8
  45. package/dest/e2e_p2p/shared.d.ts.map +1 -1
  46. package/dest/e2e_p2p/shared.js +93 -53
  47. package/dest/e2e_storage_proof/fixtures/storage_proof_fetcher.d.ts +2 -0
  48. package/dest/e2e_storage_proof/fixtures/storage_proof_fetcher.d.ts.map +1 -0
  49. package/dest/e2e_storage_proof/fixtures/storage_proof_fetcher.js +184 -0
  50. package/dest/e2e_storage_proof/fixtures/storage_proof_fixture.d.ts +18 -0
  51. package/dest/e2e_storage_proof/fixtures/storage_proof_fixture.d.ts.map +1 -0
  52. package/dest/e2e_storage_proof/fixtures/storage_proof_fixture.js +120 -0
  53. package/dest/e2e_token_contract/token_contract_test.d.ts +6 -4
  54. package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -1
  55. package/dest/e2e_token_contract/token_contract_test.js +23 -11
  56. package/dest/fixtures/authwit_proxy.d.ts +15 -0
  57. package/dest/fixtures/authwit_proxy.d.ts.map +1 -0
  58. package/dest/fixtures/authwit_proxy.js +34 -0
  59. package/dest/fixtures/e2e_prover_test.d.ts +9 -8
  60. package/dest/fixtures/e2e_prover_test.d.ts.map +1 -1
  61. package/dest/fixtures/e2e_prover_test.js +40 -51
  62. package/dest/fixtures/elu_monitor.d.ts +21 -0
  63. package/dest/fixtures/elu_monitor.d.ts.map +1 -0
  64. package/dest/fixtures/elu_monitor.js +102 -0
  65. package/dest/fixtures/fixtures.d.ts +74 -1
  66. package/dest/fixtures/fixtures.d.ts.map +1 -1
  67. package/dest/fixtures/fixtures.js +71 -0
  68. package/dest/fixtures/get_bb_config.d.ts +1 -1
  69. package/dest/fixtures/get_bb_config.d.ts.map +1 -1
  70. package/dest/fixtures/get_bb_config.js +5 -5
  71. package/dest/fixtures/ha_setup.d.ts +71 -0
  72. package/dest/fixtures/ha_setup.d.ts.map +1 -0
  73. package/dest/fixtures/ha_setup.js +116 -0
  74. package/dest/fixtures/index.d.ts +2 -1
  75. package/dest/fixtures/index.d.ts.map +1 -1
  76. package/dest/fixtures/index.js +1 -0
  77. package/dest/fixtures/schnorr_hardcoded_account_contract.d.ts +25 -0
  78. package/dest/fixtures/schnorr_hardcoded_account_contract.d.ts.map +1 -0
  79. package/dest/fixtures/schnorr_hardcoded_account_contract.js +37 -0
  80. package/dest/fixtures/setup.d.ts +88 -34
  81. package/dest/fixtures/setup.d.ts.map +1 -1
  82. package/dest/fixtures/setup.js +225 -180
  83. package/dest/fixtures/setup_p2p_test.d.ts +22 -11
  84. package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
  85. package/dest/fixtures/setup_p2p_test.js +43 -32
  86. package/dest/fixtures/token_utils.d.ts +2 -2
  87. package/dest/fixtures/token_utils.d.ts.map +1 -1
  88. package/dest/fixtures/token_utils.js +5 -7
  89. package/dest/fixtures/utils.d.ts +2 -2
  90. package/dest/fixtures/utils.d.ts.map +1 -1
  91. package/dest/fixtures/utils.js +1 -1
  92. package/dest/forward-compatibility/wallet_rpc_client.d.ts +7 -0
  93. package/dest/forward-compatibility/wallet_rpc_client.d.ts.map +1 -0
  94. package/dest/forward-compatibility/wallet_rpc_client.js +15 -0
  95. package/dest/forward-compatibility/wallet_service.d.ts +3 -0
  96. package/dest/forward-compatibility/wallet_service.d.ts.map +1 -0
  97. package/dest/forward-compatibility/wallet_service.js +109 -0
  98. package/dest/install_legacy_contracts.d.cts +10 -0
  99. package/dest/install_legacy_contracts.d.cts.map +1 -0
  100. package/dest/legacy-jest-resolver.d.cts +3 -0
  101. package/dest/legacy-jest-resolver.d.cts.map +1 -0
  102. package/dest/shared/cross_chain_test_harness.d.ts +4 -2
  103. package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
  104. package/dest/shared/cross_chain_test_harness.js +22 -18
  105. package/dest/shared/gas_portal_test_harness.d.ts +8 -5
  106. package/dest/shared/gas_portal_test_harness.d.ts.map +1 -1
  107. package/dest/shared/gas_portal_test_harness.js +19 -10
  108. package/dest/shared/index.d.ts +2 -1
  109. package/dest/shared/index.d.ts.map +1 -1
  110. package/dest/shared/index.js +1 -0
  111. package/dest/shared/jest_setup.js +41 -1
  112. package/dest/shared/mock_state_view.d.ts +86 -0
  113. package/dest/shared/mock_state_view.d.ts.map +1 -0
  114. package/dest/shared/mock_state_view.js +186 -0
  115. package/dest/shared/submit-transactions.d.ts +2 -2
  116. package/dest/shared/submit-transactions.d.ts.map +1 -1
  117. package/dest/shared/submit-transactions.js +1 -1
  118. package/dest/shared/uniswap_l1_l2.d.ts +1 -1
  119. package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
  120. package/dest/shared/uniswap_l1_l2.js +57 -40
  121. package/dest/shared/wait_for_l1_to_l2_message.d.ts +13 -0
  122. package/dest/shared/wait_for_l1_to_l2_message.d.ts.map +1 -0
  123. package/dest/shared/wait_for_l1_to_l2_message.js +10 -0
  124. package/dest/simulators/lending_simulator.d.ts +10 -3
  125. package/dest/simulators/lending_simulator.d.ts.map +1 -1
  126. package/dest/simulators/lending_simulator.js +26 -14
  127. package/dest/simulators/token_simulator.d.ts +1 -1
  128. package/dest/simulators/token_simulator.d.ts.map +1 -1
  129. package/dest/simulators/token_simulator.js +3 -24
  130. package/dest/spartan/setup_test_wallets.d.ts +12 -3
  131. package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
  132. package/dest/spartan/setup_test_wallets.js +108 -41
  133. package/dest/spartan/tx_metrics.d.ts +52 -4
  134. package/dest/spartan/tx_metrics.d.ts.map +1 -1
  135. package/dest/spartan/tx_metrics.js +224 -21
  136. package/dest/spartan/utils/bot.d.ts +3 -2
  137. package/dest/spartan/utils/bot.d.ts.map +1 -1
  138. package/dest/spartan/utils/bot.js +2 -1
  139. package/dest/spartan/utils/config.d.ts +11 -28
  140. package/dest/spartan/utils/config.d.ts.map +1 -1
  141. package/dest/spartan/utils/config.js +4 -1
  142. package/dest/spartan/utils/index.d.ts +6 -4
  143. package/dest/spartan/utils/index.d.ts.map +1 -1
  144. package/dest/spartan/utils/index.js +6 -2
  145. package/dest/spartan/utils/k8s.d.ts +31 -1
  146. package/dest/spartan/utils/k8s.d.ts.map +1 -1
  147. package/dest/spartan/utils/k8s.js +124 -0
  148. package/dest/spartan/utils/nodes.d.ts +14 -5
  149. package/dest/spartan/utils/nodes.d.ts.map +1 -1
  150. package/dest/spartan/utils/nodes.js +204 -33
  151. package/dest/spartan/utils/pod_logs.d.ts +25 -0
  152. package/dest/spartan/utils/pod_logs.d.ts.map +1 -0
  153. package/dest/spartan/utils/pod_logs.js +74 -0
  154. package/dest/spartan/utils/scripts.d.ts +18 -4
  155. package/dest/spartan/utils/scripts.d.ts.map +1 -1
  156. package/dest/spartan/utils/scripts.js +19 -4
  157. package/dest/test-wallet/test_wallet.d.ts +85 -0
  158. package/dest/test-wallet/test_wallet.d.ts.map +1 -0
  159. package/dest/test-wallet/test_wallet.js +273 -0
  160. package/dest/test-wallet/utils.d.ts +41 -0
  161. package/dest/test-wallet/utils.d.ts.map +1 -0
  162. package/dest/test-wallet/utils.js +66 -0
  163. package/dest/test-wallet/wallet_worker_script.d.ts +2 -0
  164. package/dest/test-wallet/wallet_worker_script.d.ts.map +1 -0
  165. package/dest/test-wallet/wallet_worker_script.js +53 -0
  166. package/dest/test-wallet/worker_wallet.d.ts +53 -0
  167. package/dest/test-wallet/worker_wallet.d.ts.map +1 -0
  168. package/dest/test-wallet/worker_wallet.js +155 -0
  169. package/dest/test-wallet/worker_wallet_schema.d.ts +160 -0
  170. package/dest/test-wallet/worker_wallet_schema.d.ts.map +1 -0
  171. package/dest/test-wallet/worker_wallet_schema.js +22 -0
  172. package/package.json +52 -45
  173. package/src/bench/client_flows/benchmark.ts +19 -0
  174. package/src/bench/client_flows/client_flows_benchmark.ts +64 -49
  175. package/src/bench/client_flows/config.ts +9 -1
  176. package/src/bench/utils.ts +10 -4
  177. package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +52 -25
  178. package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +56 -19
  179. package/src/e2e_deploy_contract/deploy_test.ts +6 -5
  180. package/src/e2e_epochs/epochs_test.ts +196 -77
  181. package/src/e2e_fees/bridging_race.notest.ts +1 -1
  182. package/src/e2e_fees/fees_test.ts +57 -32
  183. package/src/e2e_l1_publisher/write_json.ts +1 -6
  184. package/src/e2e_nested_contract/nested_contract_test.ts +10 -6
  185. package/src/e2e_p2p/inactivity_slash_test.ts +8 -7
  186. package/src/e2e_p2p/p2p_network.ts +93 -49
  187. package/src/e2e_p2p/reqresp/utils.ts +274 -0
  188. package/src/e2e_p2p/shared.ts +117 -65
  189. package/src/e2e_storage_proof/fixtures/storage_proof.json +915 -0
  190. package/src/e2e_storage_proof/fixtures/storage_proof_fetcher.ts +190 -0
  191. package/src/e2e_storage_proof/fixtures/storage_proof_fixture.ts +173 -0
  192. package/src/e2e_token_contract/token_contract_test.ts +38 -11
  193. package/src/fixtures/authwit_proxy.ts +54 -0
  194. package/src/fixtures/dumps/epoch_proof_result.json +1 -1
  195. package/src/fixtures/e2e_prover_test.ts +50 -57
  196. package/src/fixtures/elu_monitor.ts +126 -0
  197. package/src/fixtures/fixtures.ts +93 -0
  198. package/src/fixtures/get_bb_config.ts +7 -6
  199. package/src/fixtures/ha_setup.ts +188 -0
  200. package/src/fixtures/index.ts +1 -0
  201. package/src/fixtures/schnorr_hardcoded_account_contract.ts +49 -0
  202. package/src/fixtures/setup.ts +282 -243
  203. package/src/fixtures/setup_p2p_test.ts +52 -52
  204. package/src/fixtures/token_utils.ts +3 -3
  205. package/src/fixtures/utils.ts +2 -0
  206. package/src/forward-compatibility/wallet_rpc_client.ts +14 -0
  207. package/src/forward-compatibility/wallet_service.ts +104 -0
  208. package/src/guides/up_quick_start.sh +3 -5
  209. package/src/install_legacy_contracts.cjs +75 -0
  210. package/src/legacy-jest-resolver.cjs +112 -0
  211. package/src/shared/cross_chain_test_harness.ts +27 -13
  212. package/src/shared/gas_portal_test_harness.ts +21 -11
  213. package/src/shared/index.ts +1 -0
  214. package/src/shared/jest_setup.ts +51 -1
  215. package/src/shared/mock_state_view.ts +188 -0
  216. package/src/shared/submit-transactions.ts +3 -2
  217. package/src/shared/uniswap_l1_l2.ts +103 -54
  218. package/src/shared/wait_for_l1_to_l2_message.ts +23 -0
  219. package/src/simulators/lending_simulator.ts +32 -14
  220. package/src/simulators/token_simulator.ts +6 -30
  221. package/src/spartan/setup_test_wallets.ts +146 -35
  222. package/src/spartan/tx_metrics.ts +208 -24
  223. package/src/spartan/utils/bot.ts +4 -1
  224. package/src/spartan/utils/config.ts +3 -0
  225. package/src/spartan/utils/index.ts +10 -1
  226. package/src/spartan/utils/k8s.ts +160 -0
  227. package/src/spartan/utils/nodes.ts +251 -31
  228. package/src/spartan/utils/pod_logs.ts +99 -0
  229. package/src/spartan/utils/scripts.ts +43 -7
  230. package/src/test-wallet/test_wallet.ts +376 -0
  231. package/src/test-wallet/utils.ts +108 -0
  232. package/src/test-wallet/wallet_worker_script.ts +63 -0
  233. package/src/test-wallet/worker_wallet.ts +218 -0
  234. package/src/test-wallet/worker_wallet_schema.ts +13 -0
@@ -1,4 +1,7 @@
1
+ import type { InitialAccountData } from '@aztec/accounts/testing';
2
+ import type { Archiver } from '@aztec/archiver';
1
3
  import { type AztecNodeConfig, AztecNodeService } from '@aztec/aztec-node';
4
+ import { getAccountContractAddress } from '@aztec/aztec.js/account';
2
5
  import { getTimestampRangeForEpoch } from '@aztec/aztec.js/block';
3
6
  import { getContractInstanceFromInstantiationParams } from '@aztec/aztec.js/contracts';
4
7
  import { Fr } from '@aztec/aztec.js/fields';
@@ -9,33 +12,34 @@ import { EpochCache } from '@aztec/epoch-cache';
9
12
  import { createExtendedL1Client } from '@aztec/ethereum/client';
10
13
  import { DefaultL1ContractsConfig } from '@aztec/ethereum/config';
11
14
  import { RollupContract } from '@aztec/ethereum/contracts';
12
- import { ChainMonitor, DelayedTxUtils, type Delayer, waitUntilL1Timestamp, withDelayer } from '@aztec/ethereum/test';
15
+ import { Delayer, createDelayer, waitUntilL1Timestamp, wrapClientWithDelayer } from '@aztec/ethereum/l1-tx-utils';
16
+ import { ChainMonitor } from '@aztec/ethereum/test';
13
17
  import type { ExtendedViemWalletClient } from '@aztec/ethereum/types';
14
18
  import { BlockNumber, CheckpointNumber, EpochNumber } from '@aztec/foundation/branded-types';
15
19
  import { SecretValue } from '@aztec/foundation/config';
16
20
  import { randomBytes } from '@aztec/foundation/crypto/random';
17
- import { withLogNameSuffix } from '@aztec/foundation/log';
21
+ import { withLoggerBindings } from '@aztec/foundation/log/server';
18
22
  import { retryUntil } from '@aztec/foundation/retry';
19
23
  import { sleep } from '@aztec/foundation/sleep';
20
24
  import { SpamContract } from '@aztec/noir-test-contracts.js/Spam';
25
+ import { TestContract } from '@aztec/noir-test-contracts.js/Test';
21
26
  import { getMockPubSubP2PServiceFactory } from '@aztec/p2p/test-helpers';
22
- import { ProverNode, type ProverNodeConfig, ProverNodePublisher } from '@aztec/prover-node';
23
- import type { TestProverNode } from '@aztec/prover-node/test';
24
- import {
25
- type SequencerClient,
26
- type SequencerEvents,
27
- type SequencerPublisher,
28
- SequencerState,
29
- } from '@aztec/sequencer-client';
30
- import type { TestSequencerClient } from '@aztec/sequencer-client/test';
27
+ import type { ProverNodeConfig } from '@aztec/prover-node';
28
+ import type { PXEConfig } from '@aztec/pxe/config';
29
+ import { type SequencerClient, type SequencerEvents, SequencerState } from '@aztec/sequencer-client';
31
30
  import { type BlockParameter, EthAddress } from '@aztec/stdlib/block';
32
31
  import { type L1RollupConstants, getProofSubmissionDeadlineTimestamp } from '@aztec/stdlib/epoch-helpers';
33
32
  import { tryStop } from '@aztec/stdlib/interfaces/server';
33
+ import type { SlashingProtectionDatabase } from '@aztec/validator-ha-signer/types';
34
34
 
35
35
  import { join } from 'path';
36
36
  import type { Hex } from 'viem';
37
37
  import { privateKeyToAccount } from 'viem/accounts';
38
38
 
39
+ import {
40
+ SCHNORR_HARDCODED_PRIVATE_KEY,
41
+ SchnorrHardcodedKeyAccountContract,
42
+ } from '../fixtures/schnorr_hardcoded_account_contract.js';
39
43
  import {
40
44
  type EndToEndContext,
41
45
  type SetupOptions,
@@ -43,13 +47,25 @@ import {
43
47
  getPrivateKeyFromIndex,
44
48
  setup,
45
49
  } from '../fixtures/utils.js';
50
+ import type { TestWallet } from '../test-wallet/test_wallet.js';
46
51
 
47
- export const WORLD_STATE_BLOCK_HISTORY = 2;
52
+ export const WORLD_STATE_CHECKPOINT_HISTORY = 2;
48
53
  export const WORLD_STATE_BLOCK_CHECK_INTERVAL = 50;
49
54
  export const ARCHIVER_POLL_INTERVAL = 50;
50
55
  export const DEFAULT_L1_BLOCK_TIME = process.env.CI ? 12 : 8;
51
56
 
52
- export type EpochsTestOpts = Partial<SetupOptions> & { numberOfAccounts?: number };
57
+ export type EpochsTestOpts = Partial<SetupOptions> & {
58
+ numberOfAccounts?: number;
59
+ pxeOpts?: Partial<PXEConfig>;
60
+ aztecSlotDurationInL1Slots?: number;
61
+ /** Skip creating/registering the hardcoded account during setup (for tests that handle accounts themselves). */
62
+ skipHardcodedAccount?: boolean;
63
+ /**
64
+ * Force the hardcoded-account fast-path even when an initial sequencer is running. Useful for
65
+ * tests with tight per-block gas budgets that can't fit a full account-deploy tx.
66
+ */
67
+ useHardcodedAccount?: boolean;
68
+ };
53
69
 
54
70
  export type TrackedSequencerEvent = {
55
71
  [K in keyof SequencerEvents]: Parameters<SequencerEvents[K]>[0] & {
@@ -75,7 +91,7 @@ export class EpochsTestContext {
75
91
  public proverDelayer!: Delayer;
76
92
  public sequencerDelayer!: Delayer;
77
93
 
78
- public proverNodes: ProverNode[] = [];
94
+ public proverNodes: AztecNodeService[] = [];
79
95
  public nodes: AztecNodeService[] = [];
80
96
 
81
97
  public epochDuration!: number;
@@ -94,7 +110,7 @@ export class EpochsTestContext {
94
110
  ? parseInt(process.env.L1_BLOCK_TIME)
95
111
  : DEFAULT_L1_BLOCK_TIME;
96
112
  const ethereumSlotDuration = opts.ethereumSlotDuration ?? envEthereumSlotDuration;
97
- const aztecSlotDuration = opts.aztecSlotDuration ?? ethereumSlotDuration * 2;
113
+ const aztecSlotDuration = opts.aztecSlotDuration ?? (opts.aztecSlotDurationInL1Slots ?? 2) * ethereumSlotDuration;
98
114
  const aztecEpochDuration = opts.aztecEpochDuration ?? 6;
99
115
  const aztecProofSubmissionEpochs = opts.aztecProofSubmissionEpochs ?? 1;
100
116
  const l1PublishingTime = opts.l1PublishingTime ?? 1;
@@ -119,10 +135,20 @@ export class EpochsTestContext {
119
135
  this.L1_BLOCK_TIME_IN_S = ethereumSlotDuration;
120
136
  this.L2_SLOT_DURATION_IN_S = aztecSlotDuration;
121
137
 
138
+ // Auto-create a hardcoded account funded via genesis when:
139
+ // - skipInitialSequencer is set (no sequencer to deploy on-chain), or
140
+ // - useHardcodedAccount is explicitly requested (e.g. tight per-block gas budgets that
141
+ // can't fit a full account-deploy tx).
142
+ const useHardcodedAccount = (opts.skipInitialSequencer || opts.useHardcodedAccount) && !opts.skipHardcodedAccount;
143
+ let hardcodedAccountData: InitialAccountData | undefined;
144
+ if (useHardcodedAccount) {
145
+ hardcodedAccountData = await EpochsTestContext.getHardcodedAccountData(Fr.random(), Fr.random());
146
+ }
147
+
122
148
  // Set up system without any account nor protocol contracts
123
149
  // and with faster block times and shorter epochs.
124
150
  const context = await setup(
125
- opts.numberOfAccounts ?? 0,
151
+ useHardcodedAccount ? 0 : (opts.numberOfAccounts ?? 0),
126
152
  {
127
153
  automineL1Setup: true,
128
154
  checkIntervalMs: 50,
@@ -137,21 +163,25 @@ export class EpochsTestContext {
137
163
  realProofs: false,
138
164
  startProverNode: true,
139
165
  proverTestDelayMs: opts.proverTestDelayMs ?? 0,
140
- // We use numeric incremental prover ids for simplicity, but we can switch to
141
- // using the prover's eth address if the proverId is used for something in the rollup contract
142
- // Use numeric EthAddress for deterministic prover id
143
166
  proverId: EthAddress.fromNumber(1),
144
- worldStateBlockHistory: WORLD_STATE_BLOCK_HISTORY,
167
+ worldStateCheckpointHistory: WORLD_STATE_CHECKPOINT_HISTORY,
145
168
  exitDelaySeconds: DefaultL1ContractsConfig.exitDelaySeconds,
146
- slasherFlavor: 'none',
169
+ slasherEnabled: false,
147
170
  l1PublishingTime,
148
171
  ...opts,
172
+ ...(hardcodedAccountData ? { initialFundedAccounts: [hardcodedAccountData], numberOfAccounts: 0 } : {}),
149
173
  },
150
- // Use checkpointed chain tip for PXE to avoid issues with blocks being dropped due to pruned anchor blocks.
151
- { syncChainTip: 'checkpointed' },
174
+ // Use checkpointed chain tip for PXE by default to avoid issues with blocks being dropped due to pruned anchor blocks.
175
+ // Can be overridden via opts.pxeOpts.
176
+ { syncChainTip: 'checkpointed', ...opts.pxeOpts },
152
177
  );
153
178
 
154
179
  this.context = context;
180
+
181
+ // Register the hardcoded account in PXE (local only, no on-chain deployment needed).
182
+ if (hardcodedAccountData) {
183
+ await this.registerHardcodedAccount(hardcodedAccountData);
184
+ }
155
185
  this.proverNodes = context.proverNode ? [context.proverNode] : [];
156
186
  this.nodes = context.aztecNode ? [context.aztecNode as AztecNodeService] : [];
157
187
  this.logger = context.logger;
@@ -162,17 +192,8 @@ export class EpochsTestContext {
162
192
  // Loop that tracks L1 and L2 block numbers and logs whenever there's a new one.
163
193
  this.monitor = new ChainMonitor(this.rollup, context.dateProvider, this.logger).start();
164
194
 
165
- // This is hideous.
166
- // We ought to have a definite reference to the l1TxUtils that we're using in both places, provided by the test context.
167
- this.proverDelayer = context.proverNode
168
- ? (((context.proverNode as TestProverNode).publisher as ProverNodePublisher).l1TxUtils as DelayedTxUtils).delayer!
169
- : undefined!;
170
- this.sequencerDelayer = context.sequencer
171
- ? (
172
- ((context.sequencer as TestSequencerClient).sequencer.publisher as SequencerPublisher)
173
- .l1TxUtils as DelayedTxUtils
174
- ).delayer!
175
- : undefined!;
195
+ this.proverDelayer = context.proverDelayer!;
196
+ this.sequencerDelayer = context.sequencerDelayer!;
176
197
 
177
198
  if ((context.proverNode && !this.proverDelayer) || (context.sequencer && !this.sequencerDelayer)) {
178
199
  throw new Error(`Could not find prover or sequencer delayer`);
@@ -187,6 +208,8 @@ export class EpochsTestContext {
187
208
  l1GenesisTime: await this.rollup.getL1GenesisTime(),
188
209
  ethereumSlotDuration,
189
210
  proofSubmissionEpochs: Number(await this.rollup.getProofSubmissionEpochs()),
211
+ targetCommitteeSize: await this.rollup.getTargetCommitteeSize(),
212
+ rollupManaLimit: Number(await this.rollup.getManaLimit()),
190
213
  };
191
214
 
192
215
  this.logger.info(
@@ -201,23 +224,64 @@ export class EpochsTestContext {
201
224
  await this.context.teardown();
202
225
  }
203
226
 
227
+ /**
228
+ * Computes InitialAccountData for a SchnorrHardcodedKeyAccountContract.
229
+ * This contract has a hardcoded signing key and no initializer, so it can be used without
230
+ * on-chain deployment. Pass the returned data in `initialFundedAccounts` so the address
231
+ * gets funded with fee juice in genesis.
232
+ */
233
+ public static async getHardcodedAccountData(secret: Fr, salt: Fr): Promise<InitialAccountData> {
234
+ const contract = new SchnorrHardcodedKeyAccountContract();
235
+ const address = await getAccountContractAddress(contract, secret, salt);
236
+ const signingKey = SCHNORR_HARDCODED_PRIVATE_KEY;
237
+ return { secret, salt, signingKey, address };
238
+ }
239
+
240
+ /**
241
+ * Registers a SchnorrHardcodedKeyAccountContract in PXE. The account must have been funded
242
+ * at genesis (via getHardcodedAccountData). No on-chain deployment or block mining needed.
243
+ */
244
+ public async registerHardcodedAccount(accountData: InitialAccountData) {
245
+ const contract = new SchnorrHardcodedKeyAccountContract();
246
+ const wallet = this.context.wallet;
247
+ const accountManager = await (wallet as TestWallet).createAccount({
248
+ secret: accountData.secret,
249
+ salt: accountData.salt,
250
+ contract,
251
+ });
252
+ this.context.accounts = [accountManager.address];
253
+ return accountManager.address;
254
+ }
255
+
204
256
  public async createProverNode(opts: { dontStart?: boolean } & Partial<ProverNodeConfig> = {}) {
205
257
  this.logger.warn('Creating and syncing a simulated prover node...');
206
258
  const proverNodePrivateKey = this.getNextPrivateKey();
207
- const suffix = (this.proverNodes.length + 1).toString();
208
- const proverNode = await withLogNameSuffix(suffix, () =>
259
+ const proverIndex = this.proverNodes.length + 1;
260
+ const { mockGossipSubNetwork } = this.context;
261
+ const { proverNode } = await withLoggerBindings({ actor: `prover-${proverIndex}` }, () =>
209
262
  createAndSyncProverNode(
210
263
  proverNodePrivateKey,
211
- { ...this.context.config },
212
264
  {
213
- dataDirectory: join(this.context.config.dataDirectory!, randomBytes(8).toString('hex')),
214
- proverId: EthAddress.fromNumber(parseInt(suffix, 10)),
265
+ ...this.context.config,
266
+ p2pEnabled: this.context.config.p2pEnabled || mockGossipSubNetwork !== undefined,
267
+ proverId: EthAddress.fromNumber(proverIndex),
215
268
  dontStart: opts.dontStart,
216
269
  ...opts,
217
270
  },
218
- this.context.aztecNode,
219
- this.context.prefilledPublicData ?? [],
220
- { dateProvider: this.context.dateProvider },
271
+ {
272
+ dataDirectory: join(this.context.config.dataDirectory!, randomBytes(8).toString('hex')),
273
+ },
274
+ {
275
+ dateProvider: this.context.dateProvider,
276
+ p2pClientDeps: {
277
+ p2pServiceFactory: mockGossipSubNetwork ? getMockPubSubP2PServiceFactory(mockGossipSubNetwork) : undefined,
278
+ rpcTxProviders: [this.context.aztecNode],
279
+ },
280
+ },
281
+ {
282
+ genesis: this.context.genesis,
283
+ dontStart: opts.dontStart,
284
+ },
221
285
  ),
222
286
  );
223
287
  this.proverNodes.push(proverNode);
@@ -231,26 +295,34 @@ export class EpochsTestContext {
231
295
 
232
296
  public createValidatorNode(
233
297
  privateKeys: `0x${string}`[],
234
- opts: Partial<AztecNodeConfig> & { txDelayerMaxInclusionTimeIntoSlot?: number; dontStartSequencer?: boolean } = {},
298
+ opts: Partial<AztecNodeConfig> & {
299
+ dontStartSequencer?: boolean;
300
+ slashingProtectionDb?: SlashingProtectionDatabase;
301
+ } = {},
235
302
  ) {
236
303
  this.logger.warn('Creating and syncing a validator node...');
237
304
  return this.createNode({ ...opts, disableValidator: false, validatorPrivateKeys: new SecretValue(privateKeys) });
238
305
  }
239
306
 
240
307
  private async createNode(
241
- opts: Partial<AztecNodeConfig> & { txDelayerMaxInclusionTimeIntoSlot?: number; dontStartSequencer?: boolean } = {},
308
+ opts: Partial<AztecNodeConfig> & {
309
+ dontStartSequencer?: boolean;
310
+ slashingProtectionDb?: SlashingProtectionDatabase;
311
+ } = {},
242
312
  ) {
243
- const suffix = (this.nodes.length + 1).toString();
313
+ const nodeIndex = this.nodes.length + 1;
314
+ const actorPrefix = opts.disableValidator ? 'node' : 'validator';
244
315
  const { mockGossipSubNetwork } = this.context;
245
316
  const resolvedConfig = { ...this.context.config, ...opts };
246
317
  const p2pEnabled = resolvedConfig.p2pEnabled || mockGossipSubNetwork !== undefined;
247
318
  const p2pIp = resolvedConfig.p2pIp ?? (p2pEnabled ? '127.0.0.1' : undefined);
248
- const node = await withLogNameSuffix(suffix, () =>
319
+ const node = await withLoggerBindings({ actor: `${actorPrefix}-${nodeIndex}` }, () =>
249
320
  AztecNodeService.createAndSync(
250
321
  {
251
322
  ...resolvedConfig,
252
323
  dataDirectory: join(this.context.config.dataDirectory!, randomBytes(8).toString('hex')),
253
324
  validatorPrivateKeys: opts.validatorPrivateKeys ?? new SecretValue([]),
325
+ nodeId: resolvedConfig.nodeId || `${actorPrefix}-${nodeIndex}`,
254
326
  p2pEnabled,
255
327
  p2pIp,
256
328
  },
@@ -259,34 +331,15 @@ export class EpochsTestContext {
259
331
  p2pClientDeps: {
260
332
  p2pServiceFactory: mockGossipSubNetwork ? getMockPubSubP2PServiceFactory(mockGossipSubNetwork) : undefined,
261
333
  },
334
+ slashingProtectionDb: opts.slashingProtectionDb,
262
335
  },
263
336
  {
264
- prefilledPublicData: this.context.prefilledPublicData,
337
+ genesis: this.context.genesis,
265
338
  ...opts,
266
339
  },
267
340
  ),
268
341
  );
269
342
 
270
- // REFACTOR: We're getting too much into the internals of the sequencer here.
271
- // We should have a single method for constructing an aztec node that returns a TestAztecNodeService
272
- // which directly exposes the delayer and sets any test config.
273
- if (opts.txDelayerMaxInclusionTimeIntoSlot !== undefined) {
274
- this.logger.info(
275
- `Setting tx delayer max inclusion time into slot to ${opts.txDelayerMaxInclusionTimeIntoSlot} seconds`,
276
- );
277
- // Here we reach into the sequencer and hook in a tx delayer. The problem is that the sequencer's l1 utils only uses a public client, not a wallet.
278
- // The delayer needs a wallet (a client that can sign), so we have to create one here.
279
- const l1Client = createExtendedL1Client(
280
- resolvedConfig.l1RpcUrls!,
281
- resolvedConfig.publisherPrivateKeys![0]!.getValue(),
282
- );
283
- const sequencer = node.getSequencer() as TestSequencerClient;
284
- const publisher = sequencer.sequencer.publisher;
285
- const delayed = DelayedTxUtils.fromL1TxUtils(publisher.l1TxUtils, this.L1_BLOCK_TIME_IN_S, l1Client);
286
- delayed.delayer!.setMaxInclusionTimeIntoSlot(opts.txDelayerMaxInclusionTimeIntoSlot);
287
- publisher.l1TxUtils = delayed;
288
- }
289
-
290
343
  this.nodes.push(node);
291
344
  return node;
292
345
  }
@@ -338,7 +391,10 @@ export class EpochsTestContext {
338
391
  this.logger.info(`Waiting until last slot of submission window for epoch ${epochNumber} at ${date}`, {
339
392
  oneSlotBefore,
340
393
  });
341
- await waitUntilL1Timestamp(this.l1Client, oneSlotBefore);
394
+ // Use a timeout that accounts for the full proof submission window
395
+ const proofSubmissionWindowDuration =
396
+ this.constants.proofSubmissionEpochs * this.epochDuration * this.L2_SLOT_DURATION_IN_S;
397
+ await waitUntilL1Timestamp(this.l1Client, oneSlotBefore, undefined, proofSubmissionWindowDuration * 2);
342
398
  }
343
399
 
344
400
  /** Waits for the aztec node to sync to the target block number. */
@@ -349,7 +405,7 @@ export class EpochsTestContext {
349
405
  await sleep(waitTime);
350
406
  const [syncState, tips] = await Promise.all([
351
407
  this.context.aztecNode.getWorldStateSyncStatus(),
352
- await this.context.aztecNode.getL2Tips(),
408
+ await this.context.aztecNode.getChainTips(),
353
409
  ]);
354
410
  this.logger.info(`Wait for node synch ${blockNumber} ${type}`, { blockNumber, type, syncState, tips });
355
411
  if (type === 'proven') {
@@ -375,17 +431,28 @@ export class EpochsTestContext {
375
431
  return SpamContract.at(instance.address, wallet);
376
432
  }
377
433
 
434
+ /** Registers the TestContract on the given wallet. */
435
+ public async registerTestContract(wallet: Wallet, salt = Fr.ZERO) {
436
+ const instance = await getContractInstanceFromInstantiationParams(TestContract.artifact, {
437
+ constructorArgs: [],
438
+ constructorArtifact: undefined,
439
+ salt,
440
+ publicKeys: undefined,
441
+ deployer: undefined,
442
+ });
443
+ await wallet.registerContract(instance, TestContract.artifact);
444
+ return TestContract.at(instance.address, wallet);
445
+ }
446
+
378
447
  /** Creates an L1 client using a fresh account with funds from anvil, with a tx delayer already set up. */
379
448
  public async createL1Client() {
380
- const { client, delayer } = withDelayer(
381
- createExtendedL1Client(
382
- [...this.l1Client.chain.rpcUrls.default.http],
383
- privateKeyToAccount(this.getNextPrivateKey()),
384
- this.l1Client.chain,
385
- ),
386
- this.context.dateProvider!,
387
- { ethereumSlotDuration: this.L1_BLOCK_TIME_IN_S },
449
+ const rawClient = createExtendedL1Client(
450
+ [...this.l1Client.chain.rpcUrls.default.http],
451
+ privateKeyToAccount(this.getNextPrivateKey()),
452
+ this.l1Client.chain,
388
453
  );
454
+ const delayer = createDelayer(this.context.dateProvider, { ethereumSlotDuration: this.L1_BLOCK_TIME_IN_S }, {});
455
+ const client = wrapClientWithDelayer(rawClient, delayer);
389
456
  expect(await client.getBalance({ address: client.account.address })).toBeGreaterThan(0n);
390
457
  return { client, delayer };
391
458
  }
@@ -402,9 +469,42 @@ export class EpochsTestContext {
402
469
  expect(result).toBe(expectedSuccess);
403
470
  }
404
471
 
472
+ /** Verifies at least one checkpoint has the target number of blocks (for MBPS validation). */
473
+ public async assertMultipleBlocksPerSlot(targetBlockCount: number) {
474
+ const archiver = (this.context.aztecNode as AztecNodeService).getBlockSource() as Archiver;
475
+ const checkpoints = await archiver.getCheckpoints({ from: CheckpointNumber(1), limit: 50 });
476
+
477
+ this.logger.warn(`Retrieved ${checkpoints.length} checkpoints from archiver`, {
478
+ checkpoints: checkpoints.map(pc => pc.checkpoint.getStats()),
479
+ });
480
+
481
+ let expectedBlockNumber = checkpoints[0].checkpoint.blocks[0].number;
482
+ let targetFound = false;
483
+
484
+ for (const checkpoint of checkpoints) {
485
+ const blockCount = checkpoint.checkpoint.blocks.length;
486
+ targetFound = targetFound || blockCount >= targetBlockCount;
487
+
488
+ this.logger.verbose(`Checkpoint ${checkpoint.checkpoint.number} has ${blockCount} blocks`, {
489
+ checkpoint: checkpoint.checkpoint.getStats(),
490
+ });
491
+
492
+ for (let i = 0; i < blockCount; i++) {
493
+ const block = checkpoint.checkpoint.blocks[i];
494
+ expect(block.indexWithinCheckpoint).toBe(i);
495
+ expect(block.checkpointNumber).toBe(checkpoint.checkpoint.number);
496
+ expect(block.number).toBe(expectedBlockNumber);
497
+ expectedBlockNumber++;
498
+ }
499
+ }
500
+
501
+ expect(targetFound).toBe(true);
502
+ }
503
+
405
504
  public watchSequencerEvents(
406
505
  sequencers: SequencerClient[],
407
506
  getMetadata: (i: number) => Record<string, any> = () => ({}),
507
+ additionalFailEventKeys: (keyof SequencerEvents)[] = [],
408
508
  ) {
409
509
  const stateChanges: TrackedSequencerEvent[] = [];
410
510
  const failEvents: TrackedSequencerEvent[] = [];
@@ -415,6 +515,11 @@ export class EpochsTestContext {
415
515
  'block-build-failed',
416
516
  'checkpoint-publish-failed',
417
517
  'proposer-rollup-check-failed',
518
+ 'checkpoint-error',
519
+ 'checkpoint-publish-failed',
520
+ 'header-validation-failed',
521
+ 'pipelined-checkpoint-discarded',
522
+ ...additionalFailEventKeys,
418
523
  ];
419
524
 
420
525
  const makeEvent = (
@@ -444,6 +549,13 @@ export class EpochsTestContext {
444
549
  });
445
550
  failEventsKeys.forEach(eventName => {
446
551
  sequencer.getSequencer().on(eventName, (args: Parameters<SequencerEvents[typeof eventName]>[0]) => {
552
+ // Skip benign block-build-failed events where the builder rejected the block because it
553
+ // could not collect enough valid txs. This is the same "not enough txs" case as
554
+ // block-tx-count-check-failed (which is already excluded above), just detected after we
555
+ // started processing txs rather than before.
556
+ if (eventName === 'block-build-failed' && (args as { reason?: string }).reason === 'Insufficient valid txs') {
557
+ return;
558
+ }
447
559
  const evt = makeEvent(i, eventName, args);
448
560
  failEvents.push(evt);
449
561
  this.logger.error(`Failed event ${eventName} from sequencer ${sequencerIndex}`, undefined, evt);
@@ -453,4 +565,11 @@ export class EpochsTestContext {
453
565
 
454
566
  return { failEvents, stateChanges };
455
567
  }
568
+
569
+ public assertNoFailuresFromSequencers(failEvents: TrackedSequencerEvent[]) {
570
+ if (failEvents.length > 0) {
571
+ this.logger.error(`Failed events from sequencers`, failEvents);
572
+ }
573
+ expect(failEvents).toEqual([]);
574
+ }
456
575
  }
@@ -4,11 +4,11 @@ import type { Logger } from '@aztec/aztec.js/log';
4
4
  import { Fq } from '@aztec/foundation/curves/bn254';
5
5
  import { sleep } from '@aztec/foundation/sleep';
6
6
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
7
- import type { TestWallet } from '@aztec/test-wallet/server';
8
7
 
9
8
  import { jest } from '@jest/globals';
10
9
  import type { Hex } from 'viem';
11
10
 
11
+ import type { TestWallet } from '../test-wallet/test_wallet.js';
12
12
  import { FeesTest } from './fees_test.js';
13
13
 
14
14
  jest.setTimeout(300_000);