@aztec/aztec-node 0.0.1-commit.f504929 → 0.0.1-commit.f5a9928

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 (71) hide show
  1. package/dest/aztec-node/block_response_helpers.d.ts +25 -0
  2. package/dest/aztec-node/block_response_helpers.d.ts.map +1 -0
  3. package/dest/aztec-node/block_response_helpers.js +112 -0
  4. package/dest/aztec-node/config.d.ts +17 -5
  5. package/dest/aztec-node/config.d.ts.map +1 -1
  6. package/dest/aztec-node/config.js +16 -6
  7. package/dest/aztec-node/node_public_calls_simulator.d.ts +90 -0
  8. package/dest/aztec-node/node_public_calls_simulator.d.ts.map +1 -0
  9. package/dest/aztec-node/node_public_calls_simulator.js +346 -0
  10. package/dest/aztec-node/public_data_overrides.d.ts +13 -0
  11. package/dest/aztec-node/public_data_overrides.d.ts.map +1 -0
  12. package/dest/aztec-node/public_data_overrides.js +21 -0
  13. package/dest/aztec-node/register_node_rpc_handlers.d.ts +11 -0
  14. package/dest/aztec-node/register_node_rpc_handlers.d.ts.map +1 -0
  15. package/dest/aztec-node/register_node_rpc_handlers.js +48 -0
  16. package/dest/aztec-node/server.d.ts +131 -139
  17. package/dest/aztec-node/server.d.ts.map +1 -1
  18. package/dest/aztec-node/server.js +405 -793
  19. package/dest/bin/index.js +31 -15
  20. package/dest/factory.d.ts +33 -0
  21. package/dest/factory.d.ts.map +1 -0
  22. package/dest/factory.js +523 -0
  23. package/dest/index.d.ts +3 -1
  24. package/dest/index.d.ts.map +1 -1
  25. package/dest/index.js +2 -0
  26. package/dest/modules/block_parameter.d.ts +25 -0
  27. package/dest/modules/block_parameter.d.ts.map +1 -0
  28. package/dest/modules/block_parameter.js +100 -0
  29. package/dest/modules/node_block_provider.d.ts +19 -0
  30. package/dest/modules/node_block_provider.d.ts.map +1 -0
  31. package/dest/modules/node_block_provider.js +112 -0
  32. package/dest/modules/node_tx_receipt.d.ts +24 -0
  33. package/dest/modules/node_tx_receipt.d.ts.map +1 -0
  34. package/dest/modules/node_tx_receipt.js +70 -0
  35. package/dest/modules/node_world_state_queries.d.ts +65 -0
  36. package/dest/modules/node_world_state_queries.d.ts.map +1 -0
  37. package/dest/modules/node_world_state_queries.js +272 -0
  38. package/dest/sentinel/config.d.ts +3 -2
  39. package/dest/sentinel/config.d.ts.map +1 -1
  40. package/dest/sentinel/config.js +15 -5
  41. package/dest/sentinel/factory.d.ts +6 -4
  42. package/dest/sentinel/factory.d.ts.map +1 -1
  43. package/dest/sentinel/factory.js +12 -5
  44. package/dest/sentinel/sentinel.d.ts +145 -21
  45. package/dest/sentinel/sentinel.d.ts.map +1 -1
  46. package/dest/sentinel/sentinel.js +230 -108
  47. package/dest/sentinel/store.d.ts +8 -8
  48. package/dest/sentinel/store.d.ts.map +1 -1
  49. package/dest/sentinel/store.js +25 -17
  50. package/dest/test/index.d.ts +3 -3
  51. package/dest/test/index.d.ts.map +1 -1
  52. package/package.json +28 -27
  53. package/src/aztec-node/block_response_helpers.ts +161 -0
  54. package/src/aztec-node/config.ts +31 -8
  55. package/src/aztec-node/node_public_calls_simulator.ts +383 -0
  56. package/src/aztec-node/public_data_overrides.ts +35 -0
  57. package/src/aztec-node/register_node_rpc_handlers.ts +41 -0
  58. package/src/aztec-node/server.ts +526 -1028
  59. package/src/bin/index.ts +39 -16
  60. package/src/factory.ts +688 -0
  61. package/src/index.ts +2 -0
  62. package/src/modules/block_parameter.ts +93 -0
  63. package/src/modules/node_block_provider.ts +149 -0
  64. package/src/modules/node_tx_receipt.ts +115 -0
  65. package/src/modules/node_world_state_queries.ts +374 -0
  66. package/src/sentinel/README.md +103 -0
  67. package/src/sentinel/config.ts +18 -6
  68. package/src/sentinel/factory.ts +22 -7
  69. package/src/sentinel/sentinel.ts +280 -133
  70. package/src/sentinel/store.ts +26 -18
  71. package/src/test/index.ts +2 -2
@@ -1,55 +1,49 @@
1
- import { Archiver, createArchiver } from '@aztec/archiver';
2
- import { BBCircuitVerifier, QueuedIVCVerifier, TestCircuitVerifier } from '@aztec/bb-prover';
3
- import { type BlobClientInterface, createBlobClientWithFileStores } from '@aztec/blob-client/client';
4
- import { Blob } from '@aztec/blob-lib';
1
+ import { Archiver } from '@aztec/archiver';
2
+ import { BBCircuitVerifier, BatchChonkVerifier, QueuedIVCVerifier } from '@aztec/bb-prover';
3
+ import { TestCircuitVerifier } from '@aztec/bb-prover/test';
4
+ import type { BlobClientInterface } from '@aztec/blob-client/client';
5
5
  import { ARCHIVE_HEIGHT, type L1_TO_L2_MSG_TREE_HEIGHT, type NOTE_HASH_TREE_HEIGHT } from '@aztec/constants';
6
- import { EpochCache, type EpochCacheInterface } from '@aztec/epoch-cache';
7
- import { createEthereumChain } from '@aztec/ethereum/chain';
8
- import { getPublicClient } from '@aztec/ethereum/client';
9
- import { RegistryContract, RollupContract } from '@aztec/ethereum/contracts';
10
- import type { L1ContractAddresses } from '@aztec/ethereum/l1-contract-addresses';
11
- import { BlockNumber, CheckpointNumber, EpochNumber, SlotNumber } from '@aztec/foundation/branded-types';
6
+ import type { EpochCacheInterface } from '@aztec/epoch-cache';
7
+ import { RollupContract } from '@aztec/ethereum/contracts';
8
+ import { type L1ContractAddresses, pickL1ContractAddresses } from '@aztec/ethereum/l1-contract-addresses';
9
+ import {
10
+ BlockNumber,
11
+ CheckpointNumber,
12
+ type CheckpointProposalHash,
13
+ EpochNumber,
14
+ SlotNumber,
15
+ } from '@aztec/foundation/branded-types';
12
16
  import { compactArray, pick, unique } from '@aztec/foundation/collection';
13
17
  import { Fr } from '@aztec/foundation/curves/bn254';
14
18
  import { EthAddress } from '@aztec/foundation/eth-address';
19
+ import { first } from '@aztec/foundation/iterable';
15
20
  import { BadRequestError } from '@aztec/foundation/json-rpc';
16
21
  import { type Logger, createLogger } from '@aztec/foundation/log';
22
+ import { retryUntil } from '@aztec/foundation/retry';
17
23
  import { count } from '@aztec/foundation/string';
18
- import { DateProvider, Timer } from '@aztec/foundation/timer';
24
+ import { Timer } from '@aztec/foundation/timer';
19
25
  import { MembershipWitness, SiblingPath } from '@aztec/foundation/trees';
20
- import { type KeyStore, KeystoreManager, loadKeystores, mergeKeystores } from '@aztec/node-keystore';
21
- import { trySnapshotSync, uploadSnapshot } from '@aztec/node-lib/actions';
22
- import { createForwarderL1TxUtilsFromSigners, createL1TxUtilsFromSigners } from '@aztec/node-lib/factories';
23
- import {
24
- type P2P,
25
- type P2PClientDeps,
26
- createP2PClient,
27
- createTxValidatorForAcceptingTxsOverRPC,
28
- getDefaultAllowedSetupFunctions,
29
- } from '@aztec/p2p';
26
+ import { KeystoreManager, loadKeystores, mergeKeystores } from '@aztec/node-keystore';
27
+ import { uploadSnapshot } from '@aztec/node-lib/actions';
28
+ import { type P2P, createTxValidatorForAcceptingTxsOverRPC, getDefaultAllowedSetupFunctions } from '@aztec/p2p';
30
29
  import { ProtocolContractAddress } from '@aztec/protocol-contracts';
31
- import { type ProverNode, type ProverNodeDeps, createProverNode } from '@aztec/prover-node';
32
- import { createKeyStoreForProver } from '@aztec/prover-node/config';
33
- import { GlobalVariableBuilder, SequencerClient, type SequencerPublisher } from '@aztec/sequencer-client';
34
- import { PublicProcessorFactory } from '@aztec/simulator/server';
35
- import {
36
- AttestationsBlockWatcher,
37
- EpochPruneWatcher,
38
- type SlasherClientInterface,
39
- type Watcher,
40
- createSlasher,
41
- } from '@aztec/slasher';
42
- import { CollectionLimitsConfig, PublicSimulatorConfig } from '@aztec/stdlib/avm';
30
+ import type { ProverNode } from '@aztec/prover-node';
31
+ import { SequencerClient } from '@aztec/sequencer-client';
32
+ import { AutomineSequencer } from '@aztec/sequencer-client/automine';
33
+ import type { SlasherClientInterface } from '@aztec/slasher';
34
+ import { STANDARD_MULTI_CALL_ENTRYPOINT_ADDRESS } from '@aztec/standard-contracts/multi-call-entrypoint';
43
35
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
44
36
  import {
45
37
  type BlockData,
46
38
  BlockHash,
47
39
  type BlockParameter,
40
+ type CheckpointsQuery,
48
41
  type DataInBlock,
49
- L2Block,
50
42
  type L2BlockSource,
43
+ type L2BlockTag,
44
+ type L2Tips,
45
+ inspectBlockParameter,
51
46
  } from '@aztec/stdlib/block';
52
- import type { PublishedCheckpoint } from '@aztec/stdlib/checkpoint';
53
47
  import type {
54
48
  ContractClassPublic,
55
49
  ContractDataSource,
@@ -57,16 +51,25 @@ import type {
57
51
  NodeInfo,
58
52
  ProtocolContractAddresses,
59
53
  } from '@aztec/stdlib/contract';
60
- import { GasFees } from '@aztec/stdlib/gas';
61
- import { computePublicDataTreeLeafSlot } from '@aztec/stdlib/hash';
62
- import {
63
- type AztecNode,
64
- type AztecNodeAdmin,
65
- type AztecNodeAdminConfig,
66
- AztecNodeAdminConfigSchema,
67
- type GetContractClassLogsResponse,
68
- type GetPublicLogsResponse,
54
+ import type { L1RollupConstants } from '@aztec/stdlib/epoch-helpers';
55
+ import { GasFees, type ManaUsageEstimate, getNetworkTxGasLimits } from '@aztec/stdlib/gas';
56
+ import type {
57
+ AztecNode,
58
+ AztecNodeAdmin,
59
+ AztecNodeAdminConfig,
60
+ AztecNodeDebug,
61
+ BlockIncludeOptions,
62
+ BlockResponse,
63
+ BlocksIncludeOptions,
64
+ CheckpointIncludeOptions,
65
+ CheckpointParameter,
66
+ CheckpointResponse,
67
+ CheckpointTag,
68
+ GetTxByHashOptions,
69
+ PeerInfo,
70
+ ProposalsForSlot,
69
71
  } from '@aztec/stdlib/interfaces/client';
72
+ import { AztecNodeAdminConfigSchema } from '@aztec/stdlib/interfaces/client';
70
73
  import {
71
74
  type AllowedElement,
72
75
  type ClientProtocolCircuitVerifier,
@@ -76,24 +79,24 @@ import {
76
79
  type WorldStateSynchronizer,
77
80
  tryStop,
78
81
  } from '@aztec/stdlib/interfaces/server';
79
- import type { DebugLogStore, LogFilter, SiloedTag, Tag, TxScopedL2Log } from '@aztec/stdlib/logs';
80
- import { InMemoryDebugLogStore, NullDebugLogStore } from '@aztec/stdlib/logs';
81
- import { InboxLeaf, type L1ToL2MessageSource } from '@aztec/stdlib/messaging';
82
- import type { Offense, SlashPayloadRound } from '@aztec/stdlib/slashing';
83
- import type { NullifierLeafPreimage, PublicDataTreeLeaf, PublicDataTreeLeafPreimage } from '@aztec/stdlib/trees';
82
+ import type { DebugLogStore, LogResult, PrivateLogsQuery, PublicLogsQuery } from '@aztec/stdlib/logs';
83
+ import { NullDebugLogStore } from '@aztec/stdlib/logs';
84
+ import type { L1ToL2MessageSource, L2ToL1MembershipWitness } from '@aztec/stdlib/messaging';
85
+ import type { CheckpointAttestation } from '@aztec/stdlib/p2p';
86
+ import type { Offense } from '@aztec/stdlib/slashing';
84
87
  import { MerkleTreeId, NullifierMembershipWitness, PublicDataWitness } from '@aztec/stdlib/trees';
85
88
  import {
86
- type BlockHeader,
89
+ type FeeProvider,
90
+ type GetTxReceiptOptions,
87
91
  type GlobalVariableBuilder as GlobalVariableBuilderInterface,
88
92
  type IndexedTxEffect,
89
93
  PublicSimulationOutput,
94
+ type SimulationOverrides,
90
95
  Tx,
91
96
  type TxHash,
92
- TxReceipt,
93
- TxStatus,
97
+ type TxReceipt,
94
98
  type TxValidationResult,
95
99
  } from '@aztec/stdlib/tx';
96
- import { getPackageVersion } from '@aztec/stdlib/update-checker';
97
100
  import type { SingleValidatorStats, ValidatorsStats } from '@aztec/stdlib/validators';
98
101
  import {
99
102
  Attributes,
@@ -103,478 +106,258 @@ import {
103
106
  getTelemetryClient,
104
107
  trackSpan,
105
108
  } from '@aztec/telemetry-client';
106
- import {
107
- FullNodeCheckpointsBuilder as CheckpointsBuilder,
108
- FullNodeCheckpointsBuilder,
109
- NodeKeystoreAdapter,
110
- ValidatorClient,
111
- createBlockProposalHandler,
112
- createValidatorClient,
113
- } from '@aztec/validator-client';
114
- import { createWorldStateSynchronizer } from '@aztec/world-state';
115
-
116
- import { createPublicClient, fallback, http } from 'viem';
117
-
118
- import { createSentinel } from '../sentinel/factory.js';
109
+ import { NodeKeystoreAdapter, ValidatorClient } from '@aztec/validator-client';
110
+
111
+ import { NodeBlockProvider } from '../modules/node_block_provider.js';
112
+ import { NodeTxReceiptBuilder } from '../modules/node_tx_receipt.js';
113
+ import { NodeWorldStateQueries } from '../modules/node_world_state_queries.js';
119
114
  import { Sentinel } from '../sentinel/sentinel.js';
120
- import { type AztecNodeConfig, createKeyStoreForValidator } from './config.js';
115
+ import type { AztecNodeConfig } from './config.js';
121
116
  import { NodeMetrics } from './node_metrics.js';
117
+ import { NodePublicCallsSimulator } from './node_public_calls_simulator.js';
118
+
119
+ /**
120
+ * Fully-constructed collaborators and settings an {@link AztecNodeService} owns. Built by `createAztecNodeService`
121
+ * (see `factory.ts`); passed as a single object so call sites name each dependency instead of relying on
122
+ * positional order.
123
+ */
124
+ export interface AztecNodeServiceDeps {
125
+ config: AztecNodeConfig;
126
+ p2pClient: P2P;
127
+ blockSource: L2BlockSource & Partial<Service>;
128
+ logsSource: L2LogsSource;
129
+ contractDataSource: ContractDataSource;
130
+ l1ToL2MessageSource: L1ToL2MessageSource;
131
+ worldStateSynchronizer: WorldStateSynchronizer;
132
+ sequencer: SequencerClient | undefined;
133
+ proverNode: ProverNode | undefined;
134
+ slasherClient: SlasherClientInterface | undefined;
135
+ validatorsSentinel: Sentinel | undefined;
136
+ stopStartedWatchers: () => Promise<void>;
137
+ l1ChainId: number;
138
+ version: number;
139
+ globalVariableBuilder: GlobalVariableBuilderInterface;
140
+ rollupContract: RollupContract | undefined;
141
+ feeProvider: FeeProvider;
142
+ epochCache: EpochCacheInterface;
143
+ packageVersion: string;
144
+ peerProofVerifier: ClientProtocolCircuitVerifier;
145
+ rpcProofVerifier: ClientProtocolCircuitVerifier;
146
+ telemetry?: TelemetryClient;
147
+ log?: Logger;
148
+ blobClient?: BlobClientInterface;
149
+ validatorClient?: ValidatorClient;
150
+ keyStoreManager?: KeystoreManager;
151
+ debugLogStore?: DebugLogStore;
152
+ automineSequencer?: AutomineSequencer;
153
+ }
122
154
 
123
155
  /**
124
156
  * The aztec node.
125
157
  */
126
- export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
158
+ export class AztecNodeService implements AztecNode, AztecNodeAdmin, AztecNodeDebug, Traceable {
127
159
  private metrics: NodeMetrics;
128
- private initialHeaderHashPromise: Promise<BlockHash> | undefined = undefined;
129
-
130
160
  // Prevent two snapshot operations to happen simultaneously
131
161
  private isUploadingSnapshot = false;
162
+ // Saved minTxsPerBlock used by `pauseSequencer` to restore production-sequencer config on resume.
163
+ private sequencerPausedMinTxsPerBlock: number | undefined;
164
+ private readonly nodePublicCallsSimulator: NodePublicCallsSimulator;
165
+ private readonly worldStateQueries: NodeWorldStateQueries;
166
+ private readonly blockProvider: NodeBlockProvider;
167
+ private readonly txReceiptBuilder: NodeTxReceiptBuilder;
132
168
 
133
169
  public readonly tracer: Tracer;
134
170
 
135
- constructor(
136
- protected config: AztecNodeConfig,
137
- protected readonly p2pClient: P2P,
138
- protected readonly blockSource: L2BlockSource & Partial<Service>,
139
- protected readonly logsSource: L2LogsSource,
140
- protected readonly contractDataSource: ContractDataSource,
141
- protected readonly l1ToL2MessageSource: L1ToL2MessageSource,
142
- protected readonly worldStateSynchronizer: WorldStateSynchronizer,
143
- protected readonly sequencer: SequencerClient | undefined,
144
- protected readonly proverNode: ProverNode | undefined,
145
- protected readonly slasherClient: SlasherClientInterface | undefined,
146
- protected readonly validatorsSentinel: Sentinel | undefined,
147
- protected readonly epochPruneWatcher: EpochPruneWatcher | undefined,
148
- protected readonly l1ChainId: number,
149
- protected readonly version: number,
150
- protected readonly globalVariableBuilder: GlobalVariableBuilderInterface,
151
- protected readonly epochCache: EpochCacheInterface,
152
- protected readonly packageVersion: string,
153
- private proofVerifier: ClientProtocolCircuitVerifier,
154
- private telemetry: TelemetryClient = getTelemetryClient(),
155
- private log = createLogger('node'),
156
- private blobClient?: BlobClientInterface,
157
- private validatorClient?: ValidatorClient,
158
- private keyStoreManager?: KeystoreManager,
159
- private debugLogStore: DebugLogStore = new NullDebugLogStore(),
160
- ) {
161
- this.metrics = new NodeMetrics(telemetry, 'AztecNodeService');
162
- this.tracer = telemetry.getTracer('AztecNodeService');
171
+ protected config: AztecNodeConfig;
172
+ protected readonly p2pClient: P2P;
173
+ protected readonly blockSource: L2BlockSource & Partial<Service>;
174
+ protected readonly logsSource: L2LogsSource;
175
+ protected readonly contractDataSource: ContractDataSource;
176
+ protected readonly l1ToL2MessageSource: L1ToL2MessageSource;
177
+ protected readonly worldStateSynchronizer: WorldStateSynchronizer;
178
+ protected readonly sequencer: SequencerClient | undefined;
179
+ protected readonly proverNode: ProverNode | undefined;
180
+ protected readonly slasherClient: SlasherClientInterface | undefined;
181
+ protected readonly validatorsSentinel: Sentinel | undefined;
182
+ private readonly stopStartedWatchers: () => Promise<void>;
183
+ protected readonly l1ChainId: number;
184
+ protected readonly version: number;
185
+ protected readonly globalVariableBuilder: GlobalVariableBuilderInterface;
186
+ protected readonly rollupContract: RollupContract | undefined;
187
+ protected readonly feeProvider: FeeProvider;
188
+ protected readonly epochCache: EpochCacheInterface;
189
+ protected readonly packageVersion: string;
190
+ private peerProofVerifier: ClientProtocolCircuitVerifier;
191
+ private rpcProofVerifier: ClientProtocolCircuitVerifier;
192
+ private telemetry: TelemetryClient;
193
+ private log: Logger;
194
+ private blobClient?: BlobClientInterface;
195
+ private validatorClient?: ValidatorClient;
196
+ private keyStoreManager?: KeystoreManager;
197
+ private debugLogStore: DebugLogStore;
198
+ private readonly automineSequencer?: AutomineSequencer;
199
+
200
+ constructor(deps: AztecNodeServiceDeps) {
201
+ this.config = deps.config;
202
+ this.p2pClient = deps.p2pClient;
203
+ this.blockSource = deps.blockSource;
204
+ this.logsSource = deps.logsSource;
205
+ this.contractDataSource = deps.contractDataSource;
206
+ this.l1ToL2MessageSource = deps.l1ToL2MessageSource;
207
+ this.worldStateSynchronizer = deps.worldStateSynchronizer;
208
+ this.sequencer = deps.sequencer;
209
+ this.proverNode = deps.proverNode;
210
+ this.slasherClient = deps.slasherClient;
211
+ this.validatorsSentinel = deps.validatorsSentinel;
212
+ this.stopStartedWatchers = deps.stopStartedWatchers;
213
+ this.l1ChainId = deps.l1ChainId;
214
+ this.version = deps.version;
215
+ this.globalVariableBuilder = deps.globalVariableBuilder;
216
+ this.rollupContract = deps.rollupContract;
217
+ this.feeProvider = deps.feeProvider;
218
+ this.epochCache = deps.epochCache;
219
+ this.packageVersion = deps.packageVersion;
220
+ this.peerProofVerifier = deps.peerProofVerifier;
221
+ this.rpcProofVerifier = deps.rpcProofVerifier;
222
+ this.telemetry = deps.telemetry ?? getTelemetryClient();
223
+ this.log = deps.log ?? createLogger('node');
224
+ this.blobClient = deps.blobClient;
225
+ this.validatorClient = deps.validatorClient;
226
+ this.keyStoreManager = deps.keyStoreManager;
227
+ this.debugLogStore = deps.debugLogStore ?? new NullDebugLogStore();
228
+ this.automineSequencer = deps.automineSequencer;
229
+
230
+ this.metrics = new NodeMetrics(this.telemetry, 'AztecNodeService');
231
+ this.tracer = this.telemetry.getTracer('AztecNodeService');
232
+
233
+ // The node never represents a proposer's payout addresses, so the simulator zeroes coinbase and
234
+ // fee recipient. The signature context only needs chain id + rollup address (see signature_utils).
235
+ this.nodePublicCallsSimulator = new NodePublicCallsSimulator({
236
+ blockSource: this.blockSource,
237
+ worldStateSynchronizer: this.worldStateSynchronizer,
238
+ l1ToL2MessageSource: this.l1ToL2MessageSource,
239
+ contractDataSource: this.contractDataSource,
240
+ globalVariableBuilder: this.globalVariableBuilder,
241
+ rollupContract: this.rollupContract,
242
+ epochCache: this.epochCache,
243
+ signatureContext: { chainId: this.l1ChainId, rollupAddress: this.config.rollupAddress },
244
+ config: this.config,
245
+ telemetry: this.telemetry,
246
+ log: this.log.createChild('public-calls-simulator'),
247
+ });
248
+
249
+ this.worldStateQueries = new NodeWorldStateQueries({
250
+ worldStateSynchronizer: this.worldStateSynchronizer,
251
+ blockSource: this.blockSource,
252
+ l1ToL2MessageSource: this.l1ToL2MessageSource,
253
+ log: this.log.createChild('world-state-queries'),
254
+ });
255
+
256
+ this.blockProvider = new NodeBlockProvider(this.blockSource);
257
+
258
+ this.txReceiptBuilder = new NodeTxReceiptBuilder({
259
+ p2pClient: this.p2pClient,
260
+ blockSource: this.blockSource,
261
+ debugLogStore: this.debugLogStore,
262
+ });
163
263
 
164
264
  this.log.info(`Aztec Node version: ${this.packageVersion}`);
165
- this.log.info(`Aztec Node started on chain 0x${l1ChainId.toString(16)}`, config.l1Contracts);
265
+ this.log.info(`Aztec Node started on chain 0x${this.l1ChainId.toString(16)}`, pickL1ContractAddresses(this.config));
166
266
 
167
- // A defensive check that protects us against introducing a bug in the complex `createAndSync` function. We must
267
+ // A defensive check that protects us against introducing a bug in the complex node creation flow. We must
168
268
  // never have debugLogStore enabled when not in test mode because then we would be accumulating debug logs in
169
269
  // memory which could be a DoS vector on the sequencer (since no fees are paid for debug logs).
170
- if (debugLogStore.isEnabled && config.realProofs) {
270
+ if (this.debugLogStore.isEnabled && this.config.realProofs) {
171
271
  throw new Error('debugLogStore should never be enabled when realProofs are set');
172
272
  }
173
273
  }
174
274
 
275
+ /** @internal Exposed for testing — returns the RPC proof verifier. */
276
+ public getProofVerifier(): ClientProtocolCircuitVerifier {
277
+ return this.rpcProofVerifier;
278
+ }
279
+
175
280
  public async getWorldStateSyncStatus(): Promise<WorldStateSyncStatus> {
176
281
  const status = await this.worldStateSynchronizer.status();
177
282
  return status.syncSummary;
178
283
  }
179
284
 
180
- public getL2Tips() {
285
+ public getChainTips(): Promise<L2Tips> {
181
286
  return this.blockSource.getL2Tips();
182
287
  }
183
288
 
184
- /**
185
- * initializes the Aztec Node, wait for component to sync.
186
- * @param config - The configuration to be used by the aztec node.
187
- * @returns - A fully synced Aztec Node for use in development/testing.
188
- */
189
- public static async createAndSync(
190
- inputConfig: AztecNodeConfig,
191
- deps: {
192
- telemetry?: TelemetryClient;
193
- logger?: Logger;
194
- publisher?: SequencerPublisher;
195
- dateProvider?: DateProvider;
196
- p2pClientDeps?: P2PClientDeps;
197
- proverNodeDeps?: Partial<ProverNodeDeps>;
198
- } = {},
199
- options: {
200
- prefilledPublicData?: PublicDataTreeLeaf[];
201
- dontStartSequencer?: boolean;
202
- dontStartProverNode?: boolean;
203
- } = {},
204
- ): Promise<AztecNodeService> {
205
- const config = { ...inputConfig }; // Copy the config so we dont mutate the input object
206
- const log = deps.logger ?? createLogger('node');
207
- const packageVersion = getPackageVersion() ?? '';
208
- const telemetry = deps.telemetry ?? getTelemetryClient();
209
- const dateProvider = deps.dateProvider ?? new DateProvider();
210
- const ethereumChain = createEthereumChain(config.l1RpcUrls, config.l1ChainId);
211
-
212
- // Build a key store from file if given or from environment otherwise.
213
- // We keep the raw KeyStore available so we can merge with prover keys if enableProverNode is set.
214
- let keyStoreManager: KeystoreManager | undefined;
215
- const keyStoreProvided = config.keyStoreDirectory !== undefined && config.keyStoreDirectory.length > 0;
216
- if (keyStoreProvided) {
217
- const keyStores = loadKeystores(config.keyStoreDirectory!);
218
- keyStoreManager = new KeystoreManager(mergeKeystores(keyStores));
219
- } else {
220
- const rawKeyStores: KeyStore[] = [];
221
- const validatorKeyStore = createKeyStoreForValidator(config);
222
- if (validatorKeyStore) {
223
- rawKeyStores.push(validatorKeyStore);
224
- }
225
- if (config.enableProverNode) {
226
- const proverKeyStore = createKeyStoreForProver(config);
227
- if (proverKeyStore) {
228
- rawKeyStores.push(proverKeyStore);
229
- }
230
- }
231
- if (rawKeyStores.length > 0) {
232
- keyStoreManager = new KeystoreManager(
233
- rawKeyStores.length === 1 ? rawKeyStores[0] : mergeKeystores(rawKeyStores),
234
- );
235
- }
236
- }
237
-
238
- await keyStoreManager?.validateSigners();
239
-
240
- // If we are a validator, verify our configuration before doing too much more.
241
- if (!config.disableValidator) {
242
- if (keyStoreManager === undefined) {
243
- throw new Error('Failed to create key store, a requirement for running a validator');
244
- }
245
- if (!keyStoreProvided && process.env.NODE_ENV !== 'test') {
246
- log.warn("Keystore created from env: it's recommended to use a file-based key store for production");
247
- }
248
- ValidatorClient.validateKeyStoreConfiguration(keyStoreManager, log);
249
- }
250
-
251
- // validate that the actual chain id matches that specified in configuration
252
- if (config.l1ChainId !== ethereumChain.chainInfo.id) {
253
- throw new Error(
254
- `RPC URL configured for chain id ${ethereumChain.chainInfo.id} but expected id ${config.l1ChainId}`,
255
- );
256
- }
257
-
258
- const publicClient = createPublicClient({
259
- chain: ethereumChain.chainInfo,
260
- transport: fallback(config.l1RpcUrls.map((url: string) => http(url, { batch: false }))),
261
- pollingInterval: config.viemPollingIntervalMS,
262
- });
263
-
264
- const l1ContractsAddresses = await RegistryContract.collectAddresses(
265
- publicClient,
266
- config.l1Contracts.registryAddress,
267
- config.rollupVersion ?? 'canonical',
268
- );
269
-
270
- // Overwrite the passed in vars.
271
- config.l1Contracts = { ...config.l1Contracts, ...l1ContractsAddresses };
272
-
273
- const rollupContract = new RollupContract(publicClient, config.l1Contracts.rollupAddress.toString());
274
- const [l1GenesisTime, slotDuration, rollupVersionFromRollup] = await Promise.all([
275
- rollupContract.getL1GenesisTime(),
276
- rollupContract.getSlotDuration(),
277
- rollupContract.getVersion(),
278
- ] as const);
279
-
280
- config.rollupVersion ??= Number(rollupVersionFromRollup);
281
-
282
- if (config.rollupVersion !== Number(rollupVersionFromRollup)) {
283
- log.warn(
284
- `Registry looked up and returned a rollup with version (${config.rollupVersion}), but this does not match with version detected from the rollup directly: (${rollupVersionFromRollup}).`,
285
- );
286
- }
287
-
288
- const blobClient = await createBlobClientWithFileStores(config, log.createChild('blob-client'));
289
-
290
- // attempt snapshot sync if possible
291
- await trySnapshotSync(config, log);
292
-
293
- const epochCache = await EpochCache.create(config.l1Contracts.rollupAddress, config, { dateProvider });
294
-
295
- const archiver = await createArchiver(
296
- config,
297
- { blobClient, epochCache, telemetry, dateProvider },
298
- { blockUntilSync: !config.skipArchiverInitialSync },
299
- );
300
-
301
- // now create the merkle trees and the world state synchronizer
302
- const worldStateSynchronizer = await createWorldStateSynchronizer(
303
- config,
304
- archiver,
305
- options.prefilledPublicData,
306
- telemetry,
307
- );
308
- const circuitVerifier =
309
- config.realProofs || config.debugForceTxProofVerification
310
- ? await BBCircuitVerifier.new(config)
311
- : new TestCircuitVerifier(config.proverTestVerificationDelayMs);
312
-
313
- let debugLogStore: DebugLogStore;
314
- if (!config.realProofs) {
315
- log.warn(`Aztec node is accepting fake proofs`);
316
-
317
- debugLogStore = new InMemoryDebugLogStore();
318
- log.info(
319
- 'Aztec node started in test mode (realProofs set to false) hence debug logs from public functions will be collected and served',
320
- );
321
- } else {
322
- debugLogStore = new NullDebugLogStore();
323
- }
324
-
325
- const proofVerifier = new QueuedIVCVerifier(config, circuitVerifier);
326
-
327
- const proverOnly = config.enableProverNode && config.disableValidator;
328
- if (proverOnly) {
329
- log.info('Starting in prover-only mode: skipping validator, sequencer, sentinel, and slasher subsystems');
330
- }
331
-
332
- // create the tx pool and the p2p client, which will need the l2 block source
333
- const p2pClient = await createP2PClient(
334
- config,
335
- archiver,
336
- proofVerifier,
337
- worldStateSynchronizer,
338
- epochCache,
339
- packageVersion,
340
- dateProvider,
341
- telemetry,
342
- deps.p2pClientDeps,
343
- );
344
-
345
- // We'll accumulate sentinel watchers here
346
- const watchers: Watcher[] = [];
347
-
348
- // Create FullNodeCheckpointsBuilder for block proposal handling and tx validation
349
- const validatorCheckpointsBuilder = new FullNodeCheckpointsBuilder(
350
- { ...config, l1GenesisTime, slotDuration: Number(slotDuration) },
351
- worldStateSynchronizer,
352
- archiver,
353
- dateProvider,
354
- telemetry,
355
- );
356
-
357
- let validatorClient: ValidatorClient | undefined;
358
-
359
- if (!proverOnly) {
360
- // Create validator client if required
361
- validatorClient = await createValidatorClient(config, {
362
- checkpointsBuilder: validatorCheckpointsBuilder,
363
- worldState: worldStateSynchronizer,
364
- p2pClient,
365
- telemetry,
366
- dateProvider,
367
- epochCache,
368
- blockSource: archiver,
369
- l1ToL2MessageSource: archiver,
370
- keyStoreManager,
371
- blobClient,
372
- });
373
-
374
- // If we have a validator client, register it as a source of offenses for the slasher,
375
- // and have it register callbacks on the p2p client *before* we start it, otherwise messages
376
- // like attestations or auths will fail.
377
- if (validatorClient) {
378
- watchers.push(validatorClient);
379
- if (!options.dontStartSequencer) {
380
- await validatorClient.registerHandlers();
381
- }
382
- }
383
-
384
- // If there's no validator client but alwaysReexecuteBlockProposals is enabled,
385
- // create a BlockProposalHandler to reexecute block proposals for monitoring
386
- if (!validatorClient && config.alwaysReexecuteBlockProposals) {
387
- log.info('Setting up block proposal reexecution for monitoring');
388
- createBlockProposalHandler(config, {
389
- checkpointsBuilder: validatorCheckpointsBuilder,
390
- worldState: worldStateSynchronizer,
391
- epochCache,
392
- blockSource: archiver,
393
- l1ToL2MessageSource: archiver,
394
- p2pClient,
395
- dateProvider,
396
- telemetry,
397
- }).registerForReexecution(p2pClient);
398
- }
399
- }
400
-
401
- // Start world state and wait for it to sync to the archiver.
402
- await worldStateSynchronizer.start();
403
-
404
- // Start p2p. Note that it depends on world state to be running.
405
- await p2pClient.start();
406
-
407
- let validatorsSentinel: Awaited<ReturnType<typeof createSentinel>> | undefined;
408
- let epochPruneWatcher: EpochPruneWatcher | undefined;
409
- let attestationsBlockWatcher: AttestationsBlockWatcher | undefined;
410
-
411
- if (!proverOnly) {
412
- validatorsSentinel = await createSentinel(epochCache, archiver, p2pClient, config);
413
- if (validatorsSentinel && config.slashInactivityPenalty > 0n) {
414
- watchers.push(validatorsSentinel);
415
- }
289
+ public getL1Constants(): Promise<L1RollupConstants> {
290
+ return this.blockSource.getL1Constants();
291
+ }
416
292
 
417
- if (config.slashPrunePenalty > 0n || config.slashDataWithholdingPenalty > 0n) {
418
- epochPruneWatcher = new EpochPruneWatcher(
419
- archiver,
420
- archiver,
421
- epochCache,
422
- p2pClient.getTxProvider(),
423
- validatorCheckpointsBuilder,
424
- config,
425
- );
426
- watchers.push(epochPruneWatcher);
427
- }
293
+ public getSyncedL2SlotNumber() {
294
+ return this.blockSource.getSyncedL2SlotNumber();
295
+ }
428
296
 
429
- // We assume we want to slash for invalid attestations unless all max penalties are set to 0
430
- if (config.slashProposeInvalidAttestationsPenalty > 0n || config.slashAttestDescendantOfInvalidPenalty > 0n) {
431
- attestationsBlockWatcher = new AttestationsBlockWatcher(archiver, epochCache, config);
432
- watchers.push(attestationsBlockWatcher);
433
- }
434
- }
297
+ public getSyncedL2EpochNumber() {
298
+ return this.blockSource.getSyncedL2EpochNumber();
299
+ }
435
300
 
436
- // Start p2p-related services once the archiver has completed sync
437
- void archiver
438
- .waitForInitialSync()
439
- .then(async () => {
440
- await p2pClient.start();
441
- await validatorsSentinel?.start();
442
- await epochPruneWatcher?.start();
443
- await attestationsBlockWatcher?.start();
444
- log.info(`All p2p services started`);
445
- })
446
- .catch(err => log.error('Failed to start p2p services after archiver sync', err));
447
-
448
- // Validator enabled, create/start relevant service
449
- let sequencer: SequencerClient | undefined;
450
- let slasherClient: SlasherClientInterface | undefined;
451
- if (!config.disableValidator && validatorClient) {
452
- // We create a slasher only if we have a sequencer, since all slashing actions go through the sequencer publisher
453
- // as they are executed when the node is selected as proposer.
454
- const validatorAddresses = keyStoreManager
455
- ? NodeKeystoreAdapter.fromKeyStoreManager(keyStoreManager).getAddresses()
456
- : [];
457
-
458
- slasherClient = await createSlasher(
459
- config,
460
- config.l1Contracts,
461
- getPublicClient(config),
462
- watchers,
463
- dateProvider,
464
- epochCache,
465
- validatorAddresses,
466
- undefined, // logger
467
- );
468
- await slasherClient.start();
469
-
470
- const l1TxUtils = config.sequencerPublisherForwarderAddress
471
- ? await createForwarderL1TxUtilsFromSigners(
472
- publicClient,
473
- keyStoreManager!.createAllValidatorPublisherSigners(),
474
- config.sequencerPublisherForwarderAddress,
475
- { ...config, scope: 'sequencer' },
476
- { telemetry, logger: log.createChild('l1-tx-utils'), dateProvider, kzg: Blob.getViemKzgInstance() },
477
- )
478
- : await createL1TxUtilsFromSigners(
479
- publicClient,
480
- keyStoreManager!.createAllValidatorPublisherSigners(),
481
- { ...config, scope: 'sequencer' },
482
- { telemetry, logger: log.createChild('l1-tx-utils'), dateProvider, kzg: Blob.getViemKzgInstance() },
483
- );
301
+ public getSyncedL1Timestamp() {
302
+ return this.blockSource.getL1Timestamp();
303
+ }
484
304
 
485
- // Create and start the sequencer client
486
- const checkpointsBuilder = new CheckpointsBuilder(
487
- { ...config, l1GenesisTime, slotDuration: Number(slotDuration) },
488
- worldStateSynchronizer,
489
- archiver,
490
- dateProvider,
491
- telemetry,
492
- debugLogStore,
493
- );
305
+ public getCheckpointsData(query: CheckpointsQuery) {
306
+ return this.blockSource.getCheckpointsData(query);
307
+ }
494
308
 
495
- sequencer = await SequencerClient.new(config, {
496
- ...deps,
497
- epochCache,
498
- l1TxUtils,
499
- validatorClient,
500
- p2pClient,
501
- worldStateSynchronizer,
502
- slasherClient,
503
- checkpointsBuilder,
504
- l2BlockSource: archiver,
505
- l1ToL2MessageSource: archiver,
506
- telemetry,
507
- dateProvider,
508
- blobClient,
509
- nodeKeyStore: keyStoreManager!,
510
- });
309
+ public async getBlockNumber(tip?: L2BlockTag): Promise<BlockNumber> {
310
+ if (tip === undefined || tip === 'proposed') {
311
+ return this.blockSource.getBlockNumber();
511
312
  }
512
-
513
- if (!options.dontStartSequencer && sequencer) {
514
- await sequencer.start();
515
- log.verbose(`Sequencer started`);
516
- } else if (sequencer) {
517
- log.warn(`Sequencer created but not started`);
313
+ return (await this.blockSource.getBlockNumber({ tag: tip })) ?? BlockNumber.ZERO;
314
+ }
315
+
316
+ public async getCheckpointNumber(tip?: CheckpointTag): Promise<CheckpointNumber> {
317
+ const tips = await this.blockSource.getL2Tips();
318
+ switch (tip) {
319
+ case undefined:
320
+ case 'checkpointed':
321
+ return tips.checkpointed.checkpoint.number;
322
+ case 'proven':
323
+ return tips.proven.checkpoint.number;
324
+ case 'finalized':
325
+ return tips.finalized.checkpoint.number;
518
326
  }
327
+ }
519
328
 
520
- // Create prover node subsystem if enabled
521
- let proverNode: ProverNode | undefined;
522
- if (config.enableProverNode) {
523
- proverNode = await createProverNode(config, {
524
- ...deps.proverNodeDeps,
525
- telemetry,
526
- dateProvider,
527
- archiver,
528
- worldStateSynchronizer,
529
- p2pClient,
530
- epochCache,
531
- blobClient,
532
- keyStoreManager,
533
- });
329
+ public getBlock<Opts extends BlockIncludeOptions = {}>(
330
+ param: BlockParameter,
331
+ options: Opts = {} as Opts,
332
+ ): Promise<BlockResponse<Opts> | undefined> {
333
+ return this.blockProvider.getBlock(param, options);
334
+ }
534
335
 
535
- if (!options.dontStartProverNode) {
536
- await proverNode.start();
537
- log.info(`Prover node subsystem started`);
538
- } else {
539
- log.info(`Prover node subsystem created but not started`);
540
- }
541
- }
336
+ public getBlockData(param: BlockParameter): Promise<BlockData | undefined> {
337
+ return this.blockProvider.getBlockData(param);
338
+ }
542
339
 
543
- const globalVariableBuilder = new GlobalVariableBuilder({
544
- ...config,
545
- rollupVersion: BigInt(config.rollupVersion),
546
- l1GenesisTime,
547
- slotDuration: Number(slotDuration),
548
- });
340
+ public getBlocks<Opts extends BlocksIncludeOptions = {}>(
341
+ from: BlockNumber,
342
+ limit: number,
343
+ options: Opts = {} as Opts,
344
+ ): Promise<BlockResponse<Opts>[]> {
345
+ return this.blockProvider.getBlocks(from, limit, options);
346
+ }
549
347
 
550
- const node = new AztecNodeService(
551
- config,
552
- p2pClient,
553
- archiver,
554
- archiver,
555
- archiver,
556
- archiver,
557
- worldStateSynchronizer,
558
- sequencer,
559
- proverNode,
560
- slasherClient,
561
- validatorsSentinel,
562
- epochPruneWatcher,
563
- ethereumChain.chainInfo.id,
564
- config.rollupVersion,
565
- globalVariableBuilder,
566
- epochCache,
567
- packageVersion,
568
- proofVerifier,
569
- telemetry,
570
- log,
571
- blobClient,
572
- validatorClient,
573
- keyStoreManager,
574
- debugLogStore,
575
- );
348
+ public getCheckpoint<Opts extends CheckpointIncludeOptions = {}>(
349
+ param: CheckpointParameter,
350
+ options: Opts = {} as Opts,
351
+ ): Promise<CheckpointResponse<Opts> | undefined> {
352
+ return this.blockProvider.getCheckpoint(param, options);
353
+ }
576
354
 
577
- return node;
355
+ public getCheckpoints<Opts extends CheckpointIncludeOptions = {}>(
356
+ from: CheckpointNumber,
357
+ limit: number,
358
+ options: Opts = {} as Opts,
359
+ ): Promise<CheckpointResponse<Opts>[]> {
360
+ return this.blockProvider.getCheckpoints(from, limit, options);
578
361
  }
579
362
 
580
363
  /**
@@ -585,6 +368,11 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
585
368
  return this.sequencer;
586
369
  }
587
370
 
371
+ /** Test-only: returns the AutomineSequencer when wired via `useAutomineSequencer`. */
372
+ public getAutomineSequencer(): AutomineSequencer | undefined {
373
+ return this.automineSequencer;
374
+ }
375
+
588
376
  /** Returns the prover node subsystem, if enabled. */
589
377
  public getProverNode(): ProverNode | undefined {
590
378
  return this.proverNode;
@@ -607,7 +395,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
607
395
  * @returns - The currently deployed L1 contract addresses.
608
396
  */
609
397
  public getL1ContractAddresses(): Promise<L1ContractAddresses> {
610
- return Promise.resolve(this.config.l1Contracts);
398
+ return Promise.resolve(pickL1ContractAddresses(this.config));
611
399
  }
612
400
 
613
401
  public getEncodedEnr(): Promise<string | undefined> {
@@ -627,14 +415,22 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
627
415
  }
628
416
 
629
417
  public async getNodeInfo(): Promise<NodeInfo> {
630
- const [nodeVersion, rollupVersion, chainId, enr, contractAddresses, protocolContractAddresses] = await Promise.all([
631
- this.getNodeVersion(),
632
- this.getVersion(),
633
- this.getChainId(),
634
- this.getEncodedEnr(),
635
- this.getL1ContractAddresses(),
636
- this.getProtocolContractAddresses(),
637
- ]);
418
+ const [nodeVersion, rollupVersion, chainId, enr, contractAddresses, protocolContractAddresses, l1Constants] =
419
+ await Promise.all([
420
+ this.getNodeVersion(),
421
+ this.getVersion(),
422
+ this.getChainId(),
423
+ this.getEncodedEnr(),
424
+ this.getL1ContractAddresses(),
425
+ this.getProtocolContractAddresses(),
426
+ this.blockSource.getL1Constants(),
427
+ ]);
428
+
429
+ // Gas limits a single tx may declare on this network, derived from network-wide constants only (the
430
+ // timetable's blocks-per-checkpoint and the network-minimum per-block multipliers) — never this node's
431
+ // local caps or configured multipliers, which can make the node stricter at block-building time but
432
+ // cannot define what the network accepts for relay. Clients read txsLimits to set fallback gas limits.
433
+ const maxTxGas = getNetworkTxGasLimits(this.config, l1Constants);
638
434
 
639
435
  const nodeInfo: NodeInfo = {
640
436
  nodeVersion,
@@ -644,102 +440,24 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
644
440
  l1ContractAddresses: contractAddresses,
645
441
  protocolContractAddresses: protocolContractAddresses,
646
442
  realProofs: !!this.config.realProofs,
443
+ txsLimits: { gas: { daGas: maxTxGas.daGas, l2Gas: maxTxGas.l2Gas } },
647
444
  };
648
445
 
649
446
  return nodeInfo;
650
447
  }
651
448
 
652
- /**
653
- * Get a block specified by its block number, block hash, or 'latest'.
654
- * @param block - The block parameter (block number, block hash, or 'latest').
655
- * @returns The requested block.
656
- */
657
- public async getBlock(block: BlockParameter): Promise<L2Block | undefined> {
658
- if (BlockHash.isBlockHash(block)) {
659
- return this.getBlockByHash(block);
660
- }
661
- const blockNumber = block === 'latest' ? await this.getBlockNumber() : (block as BlockNumber);
662
- if (blockNumber === BlockNumber.ZERO) {
663
- return this.buildInitialBlock();
664
- }
665
- return await this.blockSource.getL2Block(blockNumber);
666
- }
667
-
668
- /**
669
- * Get a block specified by its hash.
670
- * @param blockHash - The block hash being requested.
671
- * @returns The requested block.
672
- */
673
- public async getBlockByHash(blockHash: BlockHash): Promise<L2Block | undefined> {
674
- const initialBlockHash = await this.#getInitialHeaderHash();
675
- if (blockHash.equals(initialBlockHash)) {
676
- return this.buildInitialBlock();
677
- }
678
- return await this.blockSource.getL2BlockByHash(blockHash);
679
- }
680
-
681
- private buildInitialBlock(): L2Block {
682
- const initialHeader = this.worldStateSynchronizer.getCommitted().getInitialHeader();
683
- return L2Block.empty(initialHeader);
684
- }
685
-
686
- /**
687
- * Get a block specified by its archive root.
688
- * @param archive - The archive root being requested.
689
- * @returns The requested block.
690
- */
691
- public async getBlockByArchive(archive: Fr): Promise<L2Block | undefined> {
692
- return await this.blockSource.getL2BlockByArchive(archive);
693
- }
694
-
695
- /**
696
- * Method to request blocks. Will attempt to return all requested blocks but will return only those available.
697
- * @param from - The start of the range of blocks to return.
698
- * @param limit - The maximum number of blocks to obtain.
699
- * @returns The blocks requested.
700
- */
701
- public async getBlocks(from: BlockNumber, limit: number): Promise<L2Block[]> {
702
- return (await this.blockSource.getBlocks(from, BlockNumber(limit))) ?? [];
703
- }
704
-
705
- public async getCheckpoints(from: CheckpointNumber, limit: number): Promise<PublishedCheckpoint[]> {
706
- return (await this.blockSource.getCheckpoints(from, limit)) ?? [];
707
- }
708
-
709
- public async getCheckpointedBlocks(from: BlockNumber, limit: number) {
710
- return (await this.blockSource.getCheckpointedBlocks(from, limit)) ?? [];
711
- }
712
-
713
- /**
714
- * Method to fetch the current min L2 fees.
715
- * @returns The current min L2 fees.
716
- */
717
449
  public async getCurrentMinFees(): Promise<GasFees> {
718
- return await this.globalVariableBuilder.getCurrentMinFees();
719
- }
720
-
721
- public async getMaxPriorityFees(): Promise<GasFees> {
722
- for await (const tx of this.p2pClient.iteratePendingTxs()) {
723
- return tx.getGasSettings().maxPriorityFeesPerGas;
724
- }
725
-
726
- return GasFees.from({ feePerDaGas: 0n, feePerL2Gas: 0n });
727
- }
728
-
729
- /**
730
- * Method to fetch the latest block number synchronized by the node.
731
- * @returns The block number.
732
- */
733
- public async getBlockNumber(): Promise<BlockNumber> {
734
- return await this.blockSource.getBlockNumber();
450
+ return await this.feeProvider.getCurrentMinFees();
735
451
  }
736
452
 
737
- public async getProvenBlockNumber(): Promise<BlockNumber> {
738
- return await this.blockSource.getProvenBlockNumber();
453
+ /** Returns predicted min fees for the current slot and next N slots. */
454
+ public async getPredictedMinFees(manaUsage?: ManaUsageEstimate): Promise<GasFees[]> {
455
+ return await this.feeProvider.getPredictedMinFees(manaUsage);
739
456
  }
740
457
 
741
- public async getCheckpointedBlockNumber(): Promise<BlockNumber> {
742
- return await this.blockSource.getCheckpointedL2BlockNumber();
458
+ public async getMaxPriorityFees(): Promise<GasFees> {
459
+ const tx = await first(this.p2pClient.iteratePendingTxs({ includeProof: false }));
460
+ return tx ? tx.getGasSettings().maxPriorityFeesPerGas : GasFees.from({ feePerDaGas: 0n, feePerL2Gas: 0n });
743
461
  }
744
462
 
745
463
  /**
@@ -770,65 +488,25 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
770
488
  return this.contractDataSource.getContractClass(id);
771
489
  }
772
490
 
773
- public getContract(address: AztecAddress): Promise<ContractInstanceWithAddress | undefined> {
774
- return this.contractDataSource.getContract(address);
775
- }
776
-
777
- public async getPrivateLogsByTags(
778
- tags: SiloedTag[],
779
- page?: number,
780
- referenceBlock?: BlockHash,
781
- ): Promise<TxScopedL2Log[][]> {
782
- if (referenceBlock) {
783
- const initialBlockHash = await this.#getInitialHeaderHash();
784
- if (!referenceBlock.equals(initialBlockHash)) {
785
- const header = await this.blockSource.getBlockHeaderByHash(referenceBlock);
786
- if (!header) {
787
- throw new Error(
788
- `Block ${referenceBlock.toString()} not found in the node. This might indicate a reorg has occurred.`,
789
- );
790
- }
791
- }
792
- }
793
- return this.logsSource.getPrivateLogsByTags(tags, page);
794
- }
795
-
796
- public async getPublicLogsByTagsFromContract(
797
- contractAddress: AztecAddress,
798
- tags: Tag[],
799
- page?: number,
800
- referenceBlock?: BlockHash,
801
- ): Promise<TxScopedL2Log[][]> {
802
- if (referenceBlock) {
803
- const initialBlockHash = await this.#getInitialHeaderHash();
804
- if (!referenceBlock.equals(initialBlockHash)) {
805
- const header = await this.blockSource.getBlockHeaderByHash(referenceBlock);
806
- if (!header) {
807
- throw new Error(
808
- `Block ${referenceBlock.toString()} not found in the node. This might indicate a reorg has occurred.`,
809
- );
810
- }
811
- }
491
+ public async getContract(
492
+ address: AztecAddress,
493
+ referenceBlock: BlockParameter = 'latest',
494
+ ): Promise<ContractInstanceWithAddress | undefined> {
495
+ const blockData = await this.getBlockData(referenceBlock);
496
+ if (!blockData) {
497
+ throw new Error(
498
+ `Reference block ${inspectBlockParameter(referenceBlock)} not found when querying contract ${address}. If the node API has been queried with an anchor block hash, possibly a reorg has occurred.`,
499
+ );
812
500
  }
813
- return this.logsSource.getPublicLogsByTagsFromContract(contractAddress, tags, page);
501
+ return this.contractDataSource.getContract(address, blockData.header.globalVariables.timestamp);
814
502
  }
815
503
 
816
- /**
817
- * Gets public logs based on the provided filter.
818
- * @param filter - The filter to apply to the logs.
819
- * @returns The requested logs.
820
- */
821
- getPublicLogs(filter: LogFilter): Promise<GetPublicLogsResponse> {
822
- return this.logsSource.getPublicLogs(filter);
504
+ public getPrivateLogsByTags(query: PrivateLogsQuery): Promise<LogResult[][]> {
505
+ return this.logsSource.getPrivateLogsByTags(query);
823
506
  }
824
507
 
825
- /**
826
- * Gets contract class logs based on the provided filter.
827
- * @param filter - The filter to apply to the logs.
828
- * @returns The requested logs.
829
- */
830
- getContractClassLogs(filter: LogFilter): Promise<GetContractClassLogsResponse> {
831
- return this.logsSource.getContractClassLogs(filter);
508
+ public getPublicLogsByTags(query: PublicLogsQuery): Promise<LogResult[][]> {
509
+ return this.logsSource.getPublicLogsByTags(query);
832
510
  }
833
511
 
834
512
  /**
@@ -843,6 +521,13 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
843
521
  const timer = new Timer();
844
522
  const txHash = tx.getTxHash().toString();
845
523
 
524
+ const connectivity = await this.p2pClient.getP2PConnectivity();
525
+ if (connectivity.enabled && connectivity.connectedPeers === 0) {
526
+ this.metrics.receivedTx(timer.ms(), false);
527
+ this.log.warn(`Rejecting tx ${txHash}: node has no connected peers`, { txHash });
528
+ throw new Error('Cannot accept tx: node has no connected peers to propagate it');
529
+ }
530
+
846
531
  const valid = await this.isValidTx(tx);
847
532
  if (valid.result !== 'valid') {
848
533
  const reason = valid.reason.join(', ');
@@ -851,37 +536,23 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
851
536
  throw new Error(`Invalid tx: ${reason}`);
852
537
  }
853
538
 
854
- await this.p2pClient!.sendTx(tx);
539
+ try {
540
+ await this.p2pClient!.sendTx(tx);
541
+ } catch (err) {
542
+ this.metrics.receivedTx(timer.ms(), false);
543
+ this.log.warn(`Mempool rejected tx ${txHash}: ${(err as Error).message}`, { txHash });
544
+ throw err;
545
+ }
855
546
  const duration = timer.ms();
856
547
  this.metrics.receivedTx(duration, true);
857
548
  this.log.info(`Received tx ${txHash} in ${duration}ms`, { txHash });
858
549
  }
859
550
 
860
- public async getTxReceipt(txHash: TxHash): Promise<TxReceipt> {
861
- // Check the tx pool status first. If the tx is known to the pool (pending or mined), we'll use that
862
- // as a fallback if we don't find a settled receipt in the archiver.
863
- const txPoolStatus = await this.p2pClient.getTxStatus(txHash);
864
- const isKnownToPool = txPoolStatus === 'pending' || txPoolStatus === 'mined';
865
-
866
- // Then get the actual tx from the archiver, which tracks every tx in a mined block.
867
- const settledTxReceipt = await this.blockSource.getSettledTxReceipt(txHash);
868
-
869
- let receipt: TxReceipt;
870
- if (settledTxReceipt) {
871
- receipt = settledTxReceipt;
872
- } else if (isKnownToPool) {
873
- // If the tx is in the pool but not in the archiver, it's pending.
874
- // This handles race conditions between archiver and p2p, where the archiver
875
- // has pruned the block in which a tx was mined, but p2p has not caught up yet.
876
- receipt = new TxReceipt(txHash, TxStatus.PENDING, undefined, undefined);
877
- } else {
878
- // Otherwise, if we don't know the tx, we consider it dropped.
879
- receipt = new TxReceipt(txHash, TxStatus.DROPPED, undefined, 'Tx dropped by P2P node');
880
- }
881
-
882
- this.debugLogStore.decorateReceiptWithLogs(txHash.toString(), receipt);
883
-
884
- return receipt;
551
+ public getTxReceipt<TGetTxReceiptOptions extends GetTxReceiptOptions = {}>(
552
+ txHash: TxHash,
553
+ options?: TGetTxReceiptOptions,
554
+ ): Promise<TxReceipt<TGetTxReceiptOptions>> {
555
+ return this.txReceiptBuilder.getTxReceipt(txHash, options);
885
556
  }
886
557
 
887
558
  public getTxEffect(txHash: TxHash): Promise<IndexedTxEffect | undefined> {
@@ -893,11 +564,11 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
893
564
  */
894
565
  public async stop() {
895
566
  this.log.info(`Stopping Aztec Node`);
896
- await tryStop(this.validatorsSentinel);
897
- await tryStop(this.epochPruneWatcher);
567
+ await this.stopStartedWatchers();
898
568
  await tryStop(this.slasherClient);
899
- await tryStop(this.proofVerifier);
569
+ await Promise.all([tryStop(this.peerProofVerifier), tryStop(this.rpcProofVerifier)]);
900
570
  await tryStop(this.sequencer);
571
+ await tryStop(this.automineSequencer);
901
572
  await tryStop(this.proverNode);
902
573
  await tryStop(this.p2pClient);
903
574
  await tryStop(this.worldStateSynchronizer);
@@ -921,379 +592,146 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
921
592
  * @param after - The last known pending tx. Used for pagination
922
593
  * @returns - The pending txs.
923
594
  */
924
- public getPendingTxs(limit?: number, after?: TxHash): Promise<Tx[]> {
925
- return this.p2pClient!.getPendingTxs(limit, after);
595
+ public getPendingTxs(limit?: number, after?: TxHash, options?: GetTxByHashOptions): Promise<Tx[]> {
596
+ return this.p2pClient!.getPendingTxs(limit, after, options);
926
597
  }
927
598
 
928
599
  public getPendingTxCount(): Promise<number> {
929
600
  return this.p2pClient!.getPendingTxCount();
930
601
  }
931
602
 
603
+ public getPeers(includePending?: boolean): Promise<PeerInfo[]> {
604
+ return this.p2pClient!.getPeers(includePending);
605
+ }
606
+
607
+ public getCheckpointAttestationsForSlot(
608
+ slot: SlotNumber,
609
+ proposalPayloadHash?: CheckpointProposalHash,
610
+ ): Promise<CheckpointAttestation[]> {
611
+ return this.p2pClient!.getCheckpointAttestationsForSlot(slot, proposalPayloadHash);
612
+ }
613
+
614
+ public getProposalsForSlot(slot: SlotNumber): Promise<ProposalsForSlot> {
615
+ return this.p2pClient!.getProposalsForSlot(slot);
616
+ }
617
+
932
618
  /**
933
- * Method to retrieve a single tx from the mempool or unfinalized chain.
619
+ * Method to retrieve a single tx from the mempool or unfinalized chain. The tx's proof is only loaded and returned
620
+ * when `includeProof` is set.
934
621
  * @param txHash - The transaction hash to return.
622
+ * @param options - Options for the returned tx (eg whether to include its proof).
935
623
  * @returns - The tx if it exists.
936
624
  */
937
- public getTxByHash(txHash: TxHash): Promise<Tx | undefined> {
938
- return Promise.resolve(this.p2pClient!.getTxByHashFromPool(txHash));
625
+ public getTxByHash(txHash: TxHash, options?: GetTxByHashOptions): Promise<Tx | undefined> {
626
+ return this.p2pClient!.getTxByHashFromPool(txHash, { includeProof: !!options?.includeProof });
939
627
  }
940
628
 
941
629
  /**
942
- * Method to retrieve txs from the mempool or unfinalized chain.
630
+ * Method to retrieve txs from the mempool or unfinalized chain. The txs' proofs are only loaded and returned when
631
+ * `includeProof` is set.
943
632
  * @param txHash - The transaction hash to return.
633
+ * @param options - Options for the returned txs (eg whether to include their proofs).
944
634
  * @returns - The txs if it exists.
945
635
  */
946
- public async getTxsByHash(txHashes: TxHash[]): Promise<Tx[]> {
947
- return compactArray(await Promise.all(txHashes.map(txHash => this.getTxByHash(txHash))));
636
+ public async getTxsByHash(txHashes: TxHash[], options?: GetTxByHashOptions): Promise<Tx[]> {
637
+ const txs = await this.p2pClient!.getTxsByHashFromPool(txHashes, { includeProof: !!options?.includeProof });
638
+ return compactArray(txs);
948
639
  }
949
640
 
950
- public async findLeavesIndexes(
641
+ public findLeavesIndexes(
951
642
  referenceBlock: BlockParameter,
952
643
  treeId: MerkleTreeId,
953
644
  leafValues: Fr[],
954
645
  ): Promise<(DataInBlock<bigint> | undefined)[]> {
955
- const committedDb = await this.#getWorldState(referenceBlock);
956
- const maybeIndices = await committedDb.findLeafIndices(
957
- treeId,
958
- leafValues.map(x => x.toBuffer()),
959
- );
960
- // We filter out undefined values
961
- const indices = maybeIndices.filter(x => x !== undefined) as bigint[];
962
-
963
- // Now we find the block numbers for the indices
964
- const blockNumbers = await committedDb.getBlockNumbersForLeafIndices(treeId, indices);
965
-
966
- // If any of the block numbers are undefined, we throw an error.
967
- for (let i = 0; i < indices.length; i++) {
968
- if (blockNumbers[i] === undefined) {
969
- throw new Error(`Block number is undefined for leaf index ${indices[i]} in tree ${MerkleTreeId[treeId]}`);
970
- }
971
- }
972
-
973
- // Get unique block numbers in order to optimize num calls to getLeafValue function.
974
- const uniqueBlockNumbers = [...new Set(blockNumbers.filter(x => x !== undefined))];
975
-
976
- // Now we obtain the block hashes from the archive tree by calling await `committedDb.getLeafValue(treeId, index)`
977
- // (note that block number corresponds to the leaf index in the archive tree).
978
- const blockHashes = await Promise.all(
979
- uniqueBlockNumbers.map(blockNumber => {
980
- return committedDb.getLeafValue(MerkleTreeId.ARCHIVE, BigInt(blockNumber));
981
- }),
982
- );
983
-
984
- // If any of the block hashes are undefined, we throw an error.
985
- for (let i = 0; i < uniqueBlockNumbers.length; i++) {
986
- if (blockHashes[i] === undefined) {
987
- throw new Error(`Block hash is undefined for block number ${uniqueBlockNumbers[i]}`);
988
- }
989
- }
990
-
991
- // Create DataInBlock objects by combining indices, blockNumbers and blockHashes and return them.
992
- return maybeIndices.map((index, i) => {
993
- if (index === undefined) {
994
- return undefined;
995
- }
996
- const blockNumber = blockNumbers[i];
997
- if (blockNumber === undefined) {
998
- return undefined;
999
- }
1000
- const blockHashIndex = uniqueBlockNumbers.indexOf(blockNumber);
1001
- const blockHash = blockHashes[blockHashIndex];
1002
- if (!blockHash) {
1003
- return undefined;
1004
- }
1005
- return {
1006
- l2BlockNumber: BlockNumber(Number(blockNumber)),
1007
- l2BlockHash: new BlockHash(blockHash),
1008
- data: index,
1009
- };
1010
- });
646
+ return this.worldStateQueries.findLeavesIndexes(referenceBlock, treeId, leafValues);
1011
647
  }
1012
648
 
1013
- public async getBlockHashMembershipWitness(
649
+ public getBlockHashMembershipWitness(
1014
650
  referenceBlock: BlockParameter,
1015
651
  blockHash: BlockHash,
1016
652
  ): Promise<MembershipWitness<typeof ARCHIVE_HEIGHT> | undefined> {
1017
- const committedDb = await this.#getWorldState(referenceBlock);
1018
- const [pathAndIndex] = await committedDb.findSiblingPaths<MerkleTreeId.ARCHIVE>(MerkleTreeId.ARCHIVE, [blockHash]);
1019
- return pathAndIndex === undefined
1020
- ? undefined
1021
- : MembershipWitness.fromSiblingPath(pathAndIndex.index, pathAndIndex.path);
653
+ return this.worldStateQueries.getBlockHashMembershipWitness(referenceBlock, blockHash);
1022
654
  }
1023
655
 
1024
- public async getNoteHashMembershipWitness(
656
+ public getNoteHashMembershipWitness(
1025
657
  referenceBlock: BlockParameter,
1026
658
  noteHash: Fr,
1027
659
  ): Promise<MembershipWitness<typeof NOTE_HASH_TREE_HEIGHT> | undefined> {
1028
- const committedDb = await this.#getWorldState(referenceBlock);
1029
- const [pathAndIndex] = await committedDb.findSiblingPaths<MerkleTreeId.NOTE_HASH_TREE>(
1030
- MerkleTreeId.NOTE_HASH_TREE,
1031
- [noteHash],
1032
- );
1033
- return pathAndIndex === undefined
1034
- ? undefined
1035
- : MembershipWitness.fromSiblingPath(pathAndIndex.index, pathAndIndex.path);
660
+ return this.worldStateQueries.getNoteHashMembershipWitness(referenceBlock, noteHash);
1036
661
  }
1037
662
 
1038
- public async getL1ToL2MessageMembershipWitness(
663
+ public getL1ToL2MessageMembershipWitness(
1039
664
  referenceBlock: BlockParameter,
1040
665
  l1ToL2Message: Fr,
1041
666
  ): Promise<[bigint, SiblingPath<typeof L1_TO_L2_MSG_TREE_HEIGHT>] | undefined> {
1042
- const db = await this.#getWorldState(referenceBlock);
1043
- const [witness] = await db.findSiblingPaths(MerkleTreeId.L1_TO_L2_MESSAGE_TREE, [l1ToL2Message]);
1044
- if (!witness) {
1045
- return undefined;
1046
- }
1047
-
1048
- // REFACTOR: Return a MembershipWitness object
1049
- return [witness.index, witness.path];
667
+ return this.worldStateQueries.getL1ToL2MessageMembershipWitness(referenceBlock, l1ToL2Message);
1050
668
  }
1051
669
 
1052
- public async getL1ToL2MessageBlock(l1ToL2Message: Fr): Promise<BlockNumber | undefined> {
1053
- const messageIndex = await this.l1ToL2MessageSource.getL1ToL2MessageIndex(l1ToL2Message);
1054
- return messageIndex
1055
- ? BlockNumber.fromCheckpointNumber(InboxLeaf.checkpointNumberFromIndex(messageIndex))
1056
- : undefined;
670
+ public getL1ToL2MessageCheckpoint(l1ToL2Message: Fr): Promise<CheckpointNumber | undefined> {
671
+ return this.worldStateQueries.getL1ToL2MessageCheckpoint(l1ToL2Message);
1057
672
  }
1058
673
 
1059
674
  /**
1060
- * Returns whether an L1 to L2 message is synced by archiver and if it's ready to be included in a block.
1061
- * @param l1ToL2Message - The L1 to L2 message to check.
1062
- * @returns Whether the message is synced and ready to be included in a block.
675
+ * Returns all the L2 to L1 messages in an epoch.
676
+ *
677
+ * @deprecated Use {@link getL2ToL1MembershipWitness} to get an L2-to-L1 message witness directly.
678
+ *
679
+ * @param epoch - The epoch at which to get the data.
680
+ * @returns The L2 to L1 messages (empty array if the epoch is not found).
1063
681
  */
1064
- public async isL1ToL2MessageSynced(l1ToL2Message: Fr): Promise<boolean> {
1065
- const messageIndex = await this.l1ToL2MessageSource.getL1ToL2MessageIndex(l1ToL2Message);
1066
- return messageIndex !== undefined;
682
+ public getL2ToL1Messages(epoch: EpochNumber): Promise<Fr[][][][]> {
683
+ return this.worldStateQueries.getL2ToL1Messages(epoch);
1067
684
  }
1068
685
 
1069
686
  /**
1070
- * Returns all the L2 to L1 messages in an epoch.
1071
- * @param epoch - The epoch at which to get the data.
1072
- * @returns The L2 to L1 messages (empty array if the epoch is not found).
687
+ * Returns the L2-to-L1 membership witness for a message in `txHash`. Passthrough to the
688
+ * archiver's locally-cached resolver — see {@link Archiver.getL2ToL1MembershipWitness}.
1073
689
  */
1074
- public async getL2ToL1Messages(epoch: EpochNumber): Promise<Fr[][][][]> {
1075
- // Assumes `getCheckpointedBlocksForEpoch` returns blocks in ascending order of block number.
1076
- const checkpointedBlocks = await this.blockSource.getCheckpointedBlocksForEpoch(epoch);
1077
- const blocksInCheckpoints: L2Block[][] = [];
1078
- let previousSlotNumber = SlotNumber.ZERO;
1079
- let checkpointIndex = -1;
1080
- for (const checkpointedBlock of checkpointedBlocks) {
1081
- const block = checkpointedBlock.block;
1082
- const slotNumber = block.header.globalVariables.slotNumber;
1083
- if (slotNumber !== previousSlotNumber) {
1084
- checkpointIndex++;
1085
- blocksInCheckpoints.push([]);
1086
- previousSlotNumber = slotNumber;
1087
- }
1088
- blocksInCheckpoints[checkpointIndex].push(block);
1089
- }
1090
- return blocksInCheckpoints.map(blocks =>
1091
- blocks.map(block => block.body.txEffects.map(txEffect => txEffect.l2ToL1Msgs)),
1092
- );
690
+ public getL2ToL1MembershipWitness(
691
+ txHash: TxHash,
692
+ message: Fr,
693
+ messageIndexInTx?: number,
694
+ ): Promise<L2ToL1MembershipWitness | undefined> {
695
+ return this.worldStateQueries.getL2ToL1MembershipWitness(txHash, message, messageIndexInTx);
1093
696
  }
1094
697
 
1095
- public async getNullifierMembershipWitness(
698
+ public getNullifierMembershipWitness(
1096
699
  referenceBlock: BlockParameter,
1097
700
  nullifier: Fr,
1098
701
  ): Promise<NullifierMembershipWitness | undefined> {
1099
- const db = await this.#getWorldState(referenceBlock);
1100
- const [witness] = await db.findSiblingPaths(MerkleTreeId.NULLIFIER_TREE, [nullifier.toBuffer()]);
1101
- if (!witness) {
1102
- return undefined;
1103
- }
1104
-
1105
- const { index, path } = witness;
1106
- const leafPreimage = await db.getLeafPreimage(MerkleTreeId.NULLIFIER_TREE, index);
1107
- if (!leafPreimage) {
1108
- return undefined;
1109
- }
1110
-
1111
- return new NullifierMembershipWitness(index, leafPreimage as NullifierLeafPreimage, path);
702
+ return this.worldStateQueries.getNullifierMembershipWitness(referenceBlock, nullifier);
1112
703
  }
1113
704
 
1114
- /**
1115
- * Returns a low nullifier membership witness for a given nullifier at a given block.
1116
- * @param referenceBlock - The block parameter (block number, block hash, or 'latest') at which to get the data
1117
- * (which contains the root of the nullifier tree in which we are searching for the nullifier).
1118
- * @param nullifier - Nullifier we try to find the low nullifier witness for.
1119
- * @returns The low nullifier membership witness (if found).
1120
- * @remarks Low nullifier witness can be used to perform a nullifier non-inclusion proof by leveraging the "linked
1121
- * list structure" of leaves and proving that a lower nullifier is pointing to a bigger next value than the nullifier
1122
- * we are trying to prove non-inclusion for.
1123
- *
1124
- * Note: This function returns the membership witness of the nullifier itself and not the low nullifier when
1125
- * the nullifier already exists in the tree. This is because the `getPreviousValueIndex` function returns the
1126
- * index of the nullifier itself when it already exists in the tree.
1127
- * TODO: This is a confusing behavior and we should eventually address that.
1128
- */
1129
- public async getLowNullifierMembershipWitness(
705
+ public getLowNullifierMembershipWitness(
1130
706
  referenceBlock: BlockParameter,
1131
707
  nullifier: Fr,
1132
708
  ): Promise<NullifierMembershipWitness | undefined> {
1133
- const committedDb = await this.#getWorldState(referenceBlock);
1134
- const findResult = await committedDb.getPreviousValueIndex(MerkleTreeId.NULLIFIER_TREE, nullifier.toBigInt());
1135
- if (!findResult) {
1136
- return undefined;
1137
- }
1138
- const { index, alreadyPresent } = findResult;
1139
- if (alreadyPresent) {
1140
- this.log.warn(`Nullifier ${nullifier.toBigInt()} already exists in the tree`);
1141
- }
1142
- const preimageData = (await committedDb.getLeafPreimage(MerkleTreeId.NULLIFIER_TREE, index))!;
1143
-
1144
- const siblingPath = await committedDb.getSiblingPath(MerkleTreeId.NULLIFIER_TREE, BigInt(index));
1145
- return new NullifierMembershipWitness(BigInt(index), preimageData as NullifierLeafPreimage, siblingPath);
709
+ return this.worldStateQueries.getLowNullifierMembershipWitness(referenceBlock, nullifier);
1146
710
  }
1147
711
 
1148
- async getPublicDataWitness(referenceBlock: BlockParameter, leafSlot: Fr): Promise<PublicDataWitness | undefined> {
1149
- const committedDb = await this.#getWorldState(referenceBlock);
1150
- const lowLeafResult = await committedDb.getPreviousValueIndex(MerkleTreeId.PUBLIC_DATA_TREE, leafSlot.toBigInt());
1151
- if (!lowLeafResult) {
1152
- return undefined;
1153
- } else {
1154
- const preimage = (await committedDb.getLeafPreimage(
1155
- MerkleTreeId.PUBLIC_DATA_TREE,
1156
- lowLeafResult.index,
1157
- )) as PublicDataTreeLeafPreimage;
1158
- const path = await committedDb.getSiblingPath(MerkleTreeId.PUBLIC_DATA_TREE, lowLeafResult.index);
1159
- return new PublicDataWitness(lowLeafResult.index, preimage, path);
1160
- }
1161
- }
1162
-
1163
- public async getPublicStorageAt(referenceBlock: BlockParameter, contract: AztecAddress, slot: Fr): Promise<Fr> {
1164
- const committedDb = await this.#getWorldState(referenceBlock);
1165
- const leafSlot = await computePublicDataTreeLeafSlot(contract, slot);
1166
-
1167
- const lowLeafResult = await committedDb.getPreviousValueIndex(MerkleTreeId.PUBLIC_DATA_TREE, leafSlot.toBigInt());
1168
- if (!lowLeafResult || !lowLeafResult.alreadyPresent) {
1169
- return Fr.ZERO;
1170
- }
1171
- const preimage = (await committedDb.getLeafPreimage(
1172
- MerkleTreeId.PUBLIC_DATA_TREE,
1173
- lowLeafResult.index,
1174
- )) as PublicDataTreeLeafPreimage;
1175
- return preimage.leaf.value;
1176
- }
1177
-
1178
- public async getBlockHeader(block: BlockParameter = 'latest'): Promise<BlockHeader | undefined> {
1179
- if (BlockHash.isBlockHash(block)) {
1180
- const initialBlockHash = await this.#getInitialHeaderHash();
1181
- if (block.equals(initialBlockHash)) {
1182
- // Block source doesn't handle initial header so we need to handle the case separately.
1183
- return this.worldStateSynchronizer.getCommitted().getInitialHeader();
1184
- }
1185
- return this.blockSource.getBlockHeaderByHash(block);
1186
- } else {
1187
- // Block source doesn't handle initial header so we need to handle the case separately.
1188
- const blockNumber = block === 'latest' ? await this.getBlockNumber() : (block as BlockNumber);
1189
- if (blockNumber === BlockNumber.ZERO) {
1190
- return this.worldStateSynchronizer.getCommitted().getInitialHeader();
1191
- }
1192
- return this.blockSource.getBlockHeader(block);
1193
- }
712
+ public getPublicDataWitness(referenceBlock: BlockParameter, leafSlot: Fr): Promise<PublicDataWitness | undefined> {
713
+ return this.worldStateQueries.getPublicDataWitness(referenceBlock, leafSlot);
1194
714
  }
1195
715
 
1196
- /**
1197
- * Get a block header specified by its archive root.
1198
- * @param archive - The archive root being requested.
1199
- * @returns The requested block header.
1200
- */
1201
- public async getBlockHeaderByArchive(archive: Fr): Promise<BlockHeader | undefined> {
1202
- return await this.blockSource.getBlockHeaderByArchive(archive);
1203
- }
1204
-
1205
- public getBlockData(number: BlockNumber): Promise<BlockData | undefined> {
1206
- return this.blockSource.getBlockData(number);
1207
- }
1208
-
1209
- public getBlockDataByArchive(archive: Fr): Promise<BlockData | undefined> {
1210
- return this.blockSource.getBlockDataByArchive(archive);
716
+ public getPublicStorageAt(referenceBlock: BlockParameter, contract: AztecAddress, slot: Fr): Promise<Fr> {
717
+ return this.worldStateQueries.getPublicStorageAt(referenceBlock, contract, slot);
1211
718
  }
1212
719
 
1213
720
  /**
1214
721
  * Simulates the public part of a transaction with the current state.
1215
722
  * @param tx - The transaction to simulate.
723
+ * @param skipFeeEnforcement - If true, fee enforcement is skipped.
724
+ * @param overrides - Optional pre-simulation overrides applied to the ephemeral fork and contract DB.
1216
725
  **/
1217
726
  @trackSpan('AztecNodeService.simulatePublicCalls', (tx: Tx) => ({
1218
727
  [Attributes.TX_HASH]: tx.getTxHash().toString(),
1219
728
  }))
1220
- public async simulatePublicCalls(tx: Tx, skipFeeEnforcement = false): Promise<PublicSimulationOutput> {
1221
- // Check total gas limit for simulation
1222
- const gasSettings = tx.data.constants.txContext.gasSettings;
1223
- const txGasLimit = gasSettings.gasLimits.l2Gas;
1224
- const teardownGasLimit = gasSettings.teardownGasLimits.l2Gas;
1225
- if (txGasLimit + teardownGasLimit > this.config.rpcSimulatePublicMaxGasLimit) {
1226
- throw new BadRequestError(
1227
- `Transaction total gas limit ${
1228
- txGasLimit + teardownGasLimit
1229
- } (${txGasLimit} + ${teardownGasLimit}) exceeds maximum gas limit ${
1230
- this.config.rpcSimulatePublicMaxGasLimit
1231
- } for simulation`,
1232
- );
1233
- }
1234
-
1235
- const txHash = tx.getTxHash();
1236
- const latestBlockNumber = await this.blockSource.getBlockNumber();
1237
- const blockNumber = BlockNumber.add(latestBlockNumber, 1);
1238
-
1239
- // If sequencer is not initialized, we just set these values to zero for simulation.
1240
- const coinbase = EthAddress.ZERO;
1241
- const feeRecipient = AztecAddress.ZERO;
1242
-
1243
- const newGlobalVariables = await this.globalVariableBuilder.buildGlobalVariables(
1244
- blockNumber,
1245
- coinbase,
1246
- feeRecipient,
1247
- );
1248
- const publicProcessorFactory = new PublicProcessorFactory(
1249
- this.contractDataSource,
1250
- new DateProvider(),
1251
- this.telemetry,
1252
- this.log.getBindings(),
1253
- );
1254
-
1255
- this.log.verbose(`Simulating public calls for tx ${txHash}`, {
1256
- globalVariables: newGlobalVariables.toInspect(),
1257
- txHash,
1258
- blockNumber,
1259
- });
1260
-
1261
- // Ensure world-state has caught up with the latest block we loaded from the archiver
1262
- await this.worldStateSynchronizer.syncImmediate(latestBlockNumber);
1263
- const merkleTreeFork = await this.worldStateSynchronizer.fork();
1264
- try {
1265
- const config = PublicSimulatorConfig.from({
1266
- skipFeeEnforcement,
1267
- collectDebugLogs: true,
1268
- collectHints: false,
1269
- collectCallMetadata: true,
1270
- collectStatistics: false,
1271
- collectionLimits: CollectionLimitsConfig.from({
1272
- maxDebugLogMemoryReads: this.config.rpcSimulatePublicMaxDebugLogMemoryReads,
1273
- }),
1274
- });
1275
- const processor = publicProcessorFactory.create(merkleTreeFork, newGlobalVariables, config);
1276
-
1277
- // REFACTOR: Consider merging ProcessReturnValues into ProcessedTx
1278
- const [processedTxs, failedTxs, _usedTxs, returns, _blobFields, debugLogs] = await processor.process([tx]);
1279
- // REFACTOR: Consider returning the error rather than throwing
1280
- if (failedTxs.length) {
1281
- this.log.warn(`Simulated tx ${txHash} fails: ${failedTxs[0].error}`, { txHash });
1282
- throw failedTxs[0].error;
1283
- }
1284
-
1285
- const [processedTx] = processedTxs;
1286
- return new PublicSimulationOutput(
1287
- processedTx.revertReason,
1288
- processedTx.globalVariables,
1289
- processedTx.txEffect,
1290
- returns,
1291
- processedTx.gasUsed,
1292
- debugLogs,
1293
- );
1294
- } finally {
1295
- await merkleTreeFork.close();
1296
- }
729
+ public simulatePublicCalls(
730
+ tx: Tx,
731
+ skipFeeEnforcement = false,
732
+ overrides?: SimulationOverrides,
733
+ ): Promise<PublicSimulationOutput> {
734
+ return this.nodePublicCallsSimulator.simulate(tx, skipFeeEnforcement, overrides);
1297
735
  }
1298
736
 
1299
737
  public async isValidTx(
@@ -1301,11 +739,15 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
1301
739
  { isSimulation, skipFeeEnforcement }: { isSimulation?: boolean; skipFeeEnforcement?: boolean } = {},
1302
740
  ): Promise<TxValidationResult> {
1303
741
  const db = this.worldStateSynchronizer.getCommitted();
1304
- const verifier = isSimulation ? undefined : this.proofVerifier;
742
+ const verifier = isSimulation ? undefined : this.rpcProofVerifier;
1305
743
 
1306
744
  // We accept transactions if they are not expired by the next slot (checked based on the ExpirationTimestamp field)
1307
745
  const { ts: nextSlotTimestamp } = this.epochCache.getEpochAndSlotInNextL1Slot();
1308
746
  const blockNumber = BlockNumber((await this.blockSource.getBlockNumber()) + 1);
747
+ const l1Constants = await this.blockSource.getL1Constants();
748
+ // Enforce the same network admission limit the node advertises in getNodeInfo (network-wide, not this
749
+ // node's local caps), so a tx the wallet sized against txsLimits is not rejected here.
750
+ const networkTxGasLimits = getNetworkTxGasLimits(this.config, l1Constants);
1309
751
  const validator = createTxValidatorForAcceptingTxsOverRPC(
1310
752
  db,
1311
753
  this.contractDataSource,
@@ -1321,7 +763,10 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
1321
763
  ],
1322
764
  gasFees: await this.getCurrentMinFees(),
1323
765
  skipFeeEnforcement,
766
+ isSimulation,
1324
767
  txsPermitted: !this.config.disableTransactions,
768
+ maxTxL2Gas: networkTxGasLimits.l2Gas,
769
+ maxTxDAGas: networkTxGasLimits.daGas,
1325
770
  },
1326
771
  this.log.getBindings(),
1327
772
  );
@@ -1337,7 +782,18 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
1337
782
 
1338
783
  public async setConfig(config: Partial<AztecNodeAdminConfig>): Promise<void> {
1339
784
  const newConfig = { ...this.config, ...config };
1340
- this.sequencer?.updateConfig(config);
785
+ // If the sequencer is currently paused via pauseSequencer(), record the caller's desired
786
+ // minTxsPerBlock as the restore value (so resumeSequencer applies it) and keep the freeze
787
+ // (MAX_SAFE_INTEGER) applied to the underlying sequencer. Without this guard, forwarding
788
+ // the new minTxsPerBlock to the sequencer would silently unpause block production while
789
+ // pauseSequencer() still considers it paused.
790
+ const sequencerUpdate = { ...config };
791
+ if (this.sequencerPausedMinTxsPerBlock !== undefined && sequencerUpdate.minTxsPerBlock !== undefined) {
792
+ this.sequencerPausedMinTxsPerBlock = sequencerUpdate.minTxsPerBlock;
793
+ delete sequencerUpdate.minTxsPerBlock;
794
+ }
795
+ this.sequencer?.updateConfig(sequencerUpdate);
796
+ this.automineSequencer?.updateConfig(sequencerUpdate);
1341
797
  this.slasherClient?.updateConfig(config);
1342
798
  this.validatorsSentinel?.updateConfig(config);
1343
799
  await this.p2pClient.updateP2PConfig(config);
@@ -1346,7 +802,15 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
1346
802
  archiver.updateConfig(config);
1347
803
  }
1348
804
  if (newConfig.realProofs !== this.config.realProofs) {
1349
- this.proofVerifier = config.realProofs ? await BBCircuitVerifier.new(newConfig) : new TestCircuitVerifier();
805
+ await Promise.all([tryStop(this.peerProofVerifier), tryStop(this.rpcProofVerifier)]);
806
+ if (newConfig.realProofs) {
807
+ this.peerProofVerifier = await BatchChonkVerifier.new(newConfig, newConfig.bbChonkVerifyMaxBatch, 'peer');
808
+ const rpcVerifier = await BBCircuitVerifier.new(newConfig);
809
+ this.rpcProofVerifier = new QueuedIVCVerifier(rpcVerifier, newConfig.numConcurrentIVCVerifiers);
810
+ } else {
811
+ this.peerProofVerifier = new TestCircuitVerifier();
812
+ this.rpcProofVerifier = new TestCircuitVerifier();
813
+ }
1350
814
  }
1351
815
 
1352
816
  this.config = newConfig;
@@ -1357,7 +821,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
1357
821
  classRegistry: ProtocolContractAddress.ContractClassRegistry,
1358
822
  feeJuice: ProtocolContractAddress.FeeJuice,
1359
823
  instanceRegistry: ProtocolContractAddress.ContractInstanceRegistry,
1360
- multiCallEntrypoint: ProtocolContractAddress.MultiCallEntrypoint,
824
+ multiCallEntrypoint: STANDARD_MULTI_CALL_ENTRYPOINT_ADDRESS,
1361
825
  });
1362
826
  }
1363
827
 
@@ -1421,7 +885,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
1421
885
  return Promise.resolve();
1422
886
  }
1423
887
 
1424
- public async rollbackTo(targetBlock: BlockNumber, force?: boolean): Promise<void> {
888
+ public async rollbackTo(targetBlock: BlockNumber, force?: boolean, resumeSync = true): Promise<void> {
1425
889
  const archiver = this.blockSource as Archiver;
1426
890
  if (!('rollbackTo' in archiver)) {
1427
891
  throw new Error('Archiver implementation does not support rollbacks.');
@@ -1451,9 +915,13 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
1451
915
  this.log.error(`Error during rollback`, err);
1452
916
  throw err;
1453
917
  } finally {
1454
- this.log.info(`Resuming world state and archiver sync.`);
1455
- this.worldStateSynchronizer.resumeSync();
1456
- archiver.resume();
918
+ if (resumeSync) {
919
+ this.log.info(`Resuming world state and archiver sync.`);
920
+ this.worldStateSynchronizer.resumeSync();
921
+ archiver.resume();
922
+ } else {
923
+ this.log.info(`Sync left paused after rollback (resumeSync=false).`);
924
+ }
1457
925
  }
1458
926
  }
1459
927
 
@@ -1470,11 +938,39 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
1470
938
  return Promise.resolve();
1471
939
  }
1472
940
 
1473
- public getSlashPayloads(): Promise<SlashPayloadRound[]> {
1474
- if (!this.slasherClient) {
1475
- throw new Error(`Slasher client not enabled`);
941
+ public pauseSequencer(): Promise<void> {
942
+ if (this.automineSequencer) {
943
+ this.automineSequencer.pause();
944
+ return Promise.resolve();
945
+ }
946
+ if (this.sequencer) {
947
+ if (this.sequencerPausedMinTxsPerBlock === undefined) {
948
+ this.sequencerPausedMinTxsPerBlock = this.sequencer.getSequencer().getConfig().minTxsPerBlock ?? 0;
949
+ this.sequencer.updateConfig({ minTxsPerBlock: Number.MAX_SAFE_INTEGER });
950
+ this.log.info(`Sequencer paused (minTxsPerBlock set to MAX_SAFE_INTEGER)`, {
951
+ previousMinTxsPerBlock: this.sequencerPausedMinTxsPerBlock,
952
+ });
953
+ }
954
+ return Promise.resolve();
1476
955
  }
1477
- return this.slasherClient.getSlashPayloads();
956
+ throw new BadRequestError('Cannot pause sequencer: no sequencer is running');
957
+ }
958
+
959
+ public resumeSequencer(): Promise<void> {
960
+ if (this.automineSequencer) {
961
+ this.automineSequencer.resume();
962
+ return Promise.resolve();
963
+ }
964
+ if (this.sequencer) {
965
+ if (this.sequencerPausedMinTxsPerBlock !== undefined) {
966
+ const restored = this.sequencerPausedMinTxsPerBlock;
967
+ this.sequencerPausedMinTxsPerBlock = undefined;
968
+ this.sequencer.updateConfig({ minTxsPerBlock: restored });
969
+ this.log.info(`Sequencer resumed (minTxsPerBlock restored)`, { minTxsPerBlock: restored });
970
+ }
971
+ return Promise.resolve();
972
+ }
973
+ throw new BadRequestError('Cannot resume sequencer: no sequencer is running');
1478
974
  }
1479
975
 
1480
976
  public getSlashOffenses(round: bigint | 'all' | 'current'): Promise<Offense[]> {
@@ -1482,7 +978,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
1482
978
  throw new Error(`Slasher client not enabled`);
1483
979
  }
1484
980
  if (round === 'all') {
1485
- return this.slasherClient.getPendingOffenses();
981
+ return this.slasherClient.getOffenses();
1486
982
  } else {
1487
983
  return this.slasherClient.gatherOffensesForRound(round === 'current' ? undefined : BigInt(round));
1488
984
  }
@@ -1576,69 +1072,71 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
1576
1072
  this.log.info('Keystore reloaded: coinbase, feeRecipient, and attester keys updated');
1577
1073
  }
1578
1074
 
1579
- #getInitialHeaderHash(): Promise<BlockHash> {
1580
- if (!this.initialHeaderHashPromise) {
1581
- this.initialHeaderHashPromise = this.worldStateSynchronizer.getCommitted().getInitialHeader().hash();
1075
+ public async mineBlock(): Promise<void> {
1076
+ if (this.automineSequencer) {
1077
+ await this.automineSequencer.buildEmptyBlock();
1078
+ return;
1582
1079
  }
1583
- return this.initialHeaderHashPromise;
1584
- }
1585
-
1586
- /**
1587
- * Returns an instance of MerkleTreeOperations having first ensured the world state is fully synched
1588
- * @param block - The block parameter (block number, block hash, or 'latest') at which to get the data.
1589
- * @returns An instance of a committed MerkleTreeOperations
1590
- */
1591
- async #getWorldState(block: BlockParameter) {
1592
- let blockSyncedTo: BlockNumber = BlockNumber.ZERO;
1593
- try {
1594
- // Attempt to sync the world state if necessary
1595
- blockSyncedTo = await this.#syncWorldState();
1596
- } catch (err) {
1597
- this.log.error(`Error getting world state: ${err}`);
1080
+ if (!this.sequencer) {
1081
+ throw new BadRequestError('Cannot mine block: no sequencer is running');
1598
1082
  }
1599
1083
 
1600
- if (block === 'latest') {
1601
- this.log.debug(`Using committed db for block 'latest', world state synced upto ${blockSyncedTo}`);
1602
- return this.worldStateSynchronizer.getCommitted();
1603
- }
1084
+ const currentBlockNumber = await this.getBlockNumber();
1604
1085
 
1605
- if (BlockHash.isBlockHash(block)) {
1606
- const initialBlockHash = await this.#getInitialHeaderHash();
1607
- if (block.equals(initialBlockHash)) {
1608
- // Block source doesn't handle initial header so we need to handle the case separately.
1609
- return this.worldStateSynchronizer.getSnapshot(BlockNumber.ZERO);
1610
- }
1086
+ // Use slot duration + 50% buffer as the timeout so this works on running networks too
1087
+ const { slotDuration } = await this.blockSource.getL1Constants();
1088
+ const timeoutSeconds = Math.ceil(slotDuration * 1.5);
1611
1089
 
1612
- const header = await this.blockSource.getBlockHeaderByHash(block);
1613
- if (!header) {
1614
- throw new Error(
1615
- `Block hash ${block.toString()} not found when querying world state. If the node API has been queried with anchor block hash possibly a reorg has occurred.`,
1616
- );
1617
- }
1618
- const blockNumber = header.getBlockNumber();
1619
- this.log.debug(`Using snapshot for block ${blockNumber}, world state synced upto ${blockSyncedTo}`);
1620
- return this.worldStateSynchronizer.getSnapshot(blockNumber);
1090
+ // Temporarily set minTxsPerBlock to 0 so the sequencer produces a block even with no txs
1091
+ const originalMinTxsPerBlock = this.sequencer.getSequencer().getConfig().minTxsPerBlock;
1092
+ this.sequencer.updateConfig({ minTxsPerBlock: 0 });
1093
+
1094
+ try {
1095
+ // Trigger the sequencer to produce a block immediately
1096
+ void this.sequencer.trigger();
1097
+
1098
+ // Wait for the new L2 block to appear
1099
+ await retryUntil(
1100
+ async () => {
1101
+ const newBlockNumber = await this.getBlockNumber();
1102
+ return newBlockNumber > currentBlockNumber ? true : undefined;
1103
+ },
1104
+ 'mineBlock',
1105
+ timeoutSeconds,
1106
+ 0.1,
1107
+ );
1108
+ } finally {
1109
+ this.sequencer.updateConfig({ minTxsPerBlock: originalMinTxsPerBlock });
1621
1110
  }
1111
+ }
1622
1112
 
1623
- // Block number provided
1624
- {
1625
- const blockNumber = block as BlockNumber;
1113
+ public async prove(upToCheckpoint?: CheckpointNumber): Promise<CheckpointNumber> {
1114
+ if (!this.automineSequencer) {
1115
+ throw new BadRequestError('Cannot prove checkpoint: no automine sequencer is running');
1116
+ }
1117
+ return await this.automineSequencer.prove(upToCheckpoint);
1118
+ }
1626
1119
 
1627
- if (blockNumber > blockSyncedTo) {
1628
- throw new Error(`Queried block ${block} not yet synced by the node (node is synced upto ${blockSyncedTo}).`);
1629
- }
1120
+ public async warpL2TimeAtLeastTo(targetTimestamp: number): Promise<void> {
1121
+ if (!this.automineSequencer) {
1122
+ throw new BadRequestError('Cannot warp L2 time: no automine sequencer is running');
1123
+ }
1124
+ await this.automineSequencer.warpTo(targetTimestamp);
1125
+ }
1630
1126
 
1631
- this.log.debug(`Using snapshot for block ${blockNumber}, world state synced upto ${blockSyncedTo}`);
1632
- return this.worldStateSynchronizer.getSnapshot(blockNumber);
1127
+ public async warpL2TimeAtLeastBy(duration: number): Promise<void> {
1128
+ if (!this.automineSequencer) {
1129
+ throw new BadRequestError('Cannot warp L2 time: no automine sequencer is running');
1633
1130
  }
1131
+ await this.automineSequencer.warpBy(duration);
1634
1132
  }
1635
1133
 
1636
1134
  /**
1637
- * Ensure we fully sync the world state
1638
- * @returns A promise that fulfils once the world state is synced
1135
+ * Returns a committed world-state view at `block`, driving sync first. Delegates to
1136
+ * {@link NodeWorldStateQueries.getWorldState}; kept as a protected method so subclasses and tests can
1137
+ * exercise the node's block-resolution and reorg-aware sync behavior.
1639
1138
  */
1640
- async #syncWorldState(): Promise<BlockNumber> {
1641
- const blockSourceHeight = await this.blockSource.getBlockNumber();
1642
- return await this.worldStateSynchronizer.syncImmediate(blockSourceHeight);
1139
+ protected getWorldState(block: BlockParameter) {
1140
+ return this.worldStateQueries.getWorldState(block);
1643
1141
  }
1644
1142
  }