@aztec/aztec-node 0.0.1-commit.343b43af6 → 0.0.1-commit.350e0a4d

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