@aztec/aztec-node 0.0.1-commit.96dac018d → 0.0.1-commit.9a89641

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