@aztec/aztec-node 0.0.1-commit.993d240 → 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 (52) hide show
  1. package/dest/aztec-node/config.d.ts +10 -1
  2. package/dest/aztec-node/config.d.ts.map +1 -1
  3. package/dest/aztec-node/config.js +10 -0
  4. package/dest/aztec-node/node_public_calls_simulator.d.ts +97 -0
  5. package/dest/aztec-node/node_public_calls_simulator.d.ts.map +1 -0
  6. package/dest/aztec-node/node_public_calls_simulator.js +351 -0
  7. package/dest/aztec-node/register_node_rpc_handlers.d.ts +10 -0
  8. package/dest/aztec-node/register_node_rpc_handlers.d.ts.map +1 -0
  9. package/dest/aztec-node/register_node_rpc_handlers.js +31 -0
  10. package/dest/aztec-node/server.d.ts +102 -66
  11. package/dest/aztec-node/server.d.ts.map +1 -1
  12. package/dest/aztec-node/server.js +237 -1095
  13. package/dest/bin/index.js +15 -10
  14. package/dest/factory.d.ts +33 -0
  15. package/dest/factory.d.ts.map +1 -0
  16. package/dest/factory.js +531 -0
  17. package/dest/index.d.ts +3 -1
  18. package/dest/index.d.ts.map +1 -1
  19. package/dest/index.js +2 -0
  20. package/dest/modules/block_parameter.d.ts +25 -0
  21. package/dest/modules/block_parameter.d.ts.map +1 -0
  22. package/dest/modules/block_parameter.js +100 -0
  23. package/dest/modules/node_block_provider.d.ts +19 -0
  24. package/dest/modules/node_block_provider.d.ts.map +1 -0
  25. package/dest/modules/node_block_provider.js +112 -0
  26. package/dest/modules/node_tx_receipt.d.ts +24 -0
  27. package/dest/modules/node_tx_receipt.d.ts.map +1 -0
  28. package/dest/modules/node_tx_receipt.js +70 -0
  29. package/dest/modules/node_world_state_queries.d.ts +65 -0
  30. package/dest/modules/node_world_state_queries.d.ts.map +1 -0
  31. package/dest/modules/node_world_state_queries.js +272 -0
  32. package/dest/sentinel/factory.d.ts +3 -3
  33. package/dest/sentinel/factory.d.ts.map +1 -1
  34. package/dest/sentinel/factory.js +8 -1
  35. package/dest/sentinel/sentinel.d.ts +21 -21
  36. package/dest/sentinel/sentinel.d.ts.map +1 -1
  37. package/dest/sentinel/sentinel.js +27 -47
  38. package/package.json +28 -27
  39. package/src/aztec-node/config.ts +19 -0
  40. package/src/aztec-node/node_public_calls_simulator.ts +394 -0
  41. package/src/aztec-node/register_node_rpc_handlers.ts +29 -0
  42. package/src/aztec-node/server.ts +339 -1260
  43. package/src/bin/index.ts +19 -12
  44. package/src/factory.ts +697 -0
  45. package/src/index.ts +2 -0
  46. package/src/modules/block_parameter.ts +93 -0
  47. package/src/modules/node_block_provider.ts +149 -0
  48. package/src/modules/node_tx_receipt.ts +115 -0
  49. package/src/modules/node_world_state_queries.ts +374 -0
  50. package/src/sentinel/README.md +3 -3
  51. package/src/sentinel/factory.ts +15 -3
  52. package/src/sentinel/sentinel.ts +34 -72
@@ -1,79 +1,49 @@
1
- import { Archiver, L1ToL2MessagesNotReadyError, createArchiver } from '@aztec/archiver';
1
+ import { Archiver } from '@aztec/archiver';
2
2
  import { BBCircuitVerifier, BatchChonkVerifier, QueuedIVCVerifier } from '@aztec/bb-prover';
3
3
  import { TestCircuitVerifier } from '@aztec/bb-prover/test';
4
- import { type BlobClientInterface, createBlobClientWithFileStores } from '@aztec/blob-client/client';
5
- import { Blob } from '@aztec/blob-lib';
4
+ import type { BlobClientInterface } from '@aztec/blob-client/client';
6
5
  import { ARCHIVE_HEIGHT, type L1_TO_L2_MSG_TREE_HEIGHT, type NOTE_HASH_TREE_HEIGHT } from '@aztec/constants';
7
- import { EpochCache, type EpochCacheInterface } from '@aztec/epoch-cache';
8
- import { createEthereumChain } from '@aztec/ethereum/chain';
9
- import { getPublicClient, makeL1HttpTransport } from '@aztec/ethereum/client';
10
- import { RegistryContract, RollupContract } from '@aztec/ethereum/contracts';
6
+ import type { EpochCacheInterface } from '@aztec/epoch-cache';
7
+ import { RollupContract } from '@aztec/ethereum/contracts';
11
8
  import { type L1ContractAddresses, pickL1ContractAddresses } from '@aztec/ethereum/l1-contract-addresses';
12
- import type { L1TxUtils } from '@aztec/ethereum/l1-tx-utils';
13
- import { BlockNumber, CheckpointNumber, EpochNumber, SlotNumber } from '@aztec/foundation/branded-types';
14
- import { chunkBy, compactArray, pick, unique } from '@aztec/foundation/collection';
9
+ import {
10
+ BlockNumber,
11
+ CheckpointNumber,
12
+ type CheckpointProposalHash,
13
+ EpochNumber,
14
+ SlotNumber,
15
+ } from '@aztec/foundation/branded-types';
16
+ import { compactArray, pick, unique } from '@aztec/foundation/collection';
15
17
  import { Fr } from '@aztec/foundation/curves/bn254';
16
18
  import { EthAddress } from '@aztec/foundation/eth-address';
17
19
  import { BadRequestError } from '@aztec/foundation/json-rpc';
18
20
  import { type Logger, createLogger } from '@aztec/foundation/log';
19
21
  import { retryUntil } from '@aztec/foundation/retry';
20
22
  import { count } from '@aztec/foundation/string';
21
- import { DateProvider, Timer } from '@aztec/foundation/timer';
23
+ import { Timer } from '@aztec/foundation/timer';
22
24
  import { MembershipWitness, SiblingPath } from '@aztec/foundation/trees';
23
- import { isErrorClass } from '@aztec/foundation/types';
24
- import { type KeyStore, KeystoreManager, loadKeystores, mergeKeystores } from '@aztec/node-keystore';
25
- import { trySnapshotSync, uploadSnapshot } from '@aztec/node-lib/actions';
26
- import { createForwarderL1TxUtilsFromSigners, createL1TxUtilsFromSigners } from '@aztec/node-lib/factories';
27
- import {
28
- type P2P,
29
- type P2PClientDeps,
30
- createP2PClient,
31
- createTxValidatorForAcceptingTxsOverRPC,
32
- getDefaultAllowedSetupFunctions,
33
- } 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';
34
28
  import { ProtocolContractAddress } from '@aztec/protocol-contracts';
35
- import { type ProverNode, type ProverNodeDeps, createProverNode } from '@aztec/prover-node';
36
- import { createKeyStoreForProver } from '@aztec/prover-node/config';
37
- import {
38
- AutomineSequencer,
39
- FeeProviderImpl,
40
- GlobalVariableBuilder,
41
- SequencerClient,
42
- type SequencerPublisher,
43
- createAutomineSequencer,
44
- } from '@aztec/sequencer-client';
45
- import { PublicContractsDB, PublicProcessorFactory } from '@aztec/simulator/server';
46
- import {
47
- AttestationsBlockWatcher,
48
- AttestedInvalidProposalWatcher,
49
- BroadcastedInvalidCheckpointProposalWatcher,
50
- CheckpointEquivocationWatcher,
51
- DataWithholdingWatcher,
52
- type SlasherClientInterface,
53
- type Watcher,
54
- createSlasher,
55
- } from '@aztec/slasher';
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';
56
34
  import { STANDARD_MULTI_CALL_ENTRYPOINT_ADDRESS } from '@aztec/standard-contracts/multi-call-entrypoint';
57
- import { CollectionLimitsConfig, PublicSimulatorConfig } from '@aztec/stdlib/avm';
58
35
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
59
36
  import {
60
37
  type BlockData,
61
38
  BlockHash,
62
39
  type BlockParameter,
63
- BlockTag,
64
40
  type CheckpointsQuery,
65
- type CommitteeAttestation,
66
41
  type DataInBlock,
67
42
  type L2BlockSource,
68
- type NormalizedBlockParameter,
43
+ type L2BlockTag,
44
+ type L2Tips,
69
45
  inspectBlockParameter,
70
46
  } from '@aztec/stdlib/block';
71
- import {
72
- type CheckpointData,
73
- CheckpointReexecutionTracker,
74
- L1PublishedData,
75
- type PublishedCheckpoint,
76
- } from '@aztec/stdlib/checkpoint';
77
47
  import type {
78
48
  ContractClassPublic,
79
49
  ContractDataSource,
@@ -81,8 +51,8 @@ import type {
81
51
  NodeInfo,
82
52
  ProtocolContractAddresses,
83
53
  } from '@aztec/stdlib/contract';
84
- import { GasFees, type ManaUsageEstimate } from '@aztec/stdlib/gas';
85
- import { computePublicDataTreeLeafSlot } from '@aztec/stdlib/hash';
54
+ import type { L1RollupConstants } from '@aztec/stdlib/epoch-helpers';
55
+ import { GasFees, type ManaUsageEstimate, getNetworkTxGasLimits } from '@aztec/stdlib/gas';
86
56
  import type {
87
57
  AztecNode,
88
58
  AztecNodeAdmin,
@@ -91,11 +61,13 @@ import type {
91
61
  BlockIncludeOptions,
92
62
  BlockResponse,
93
63
  BlocksIncludeOptions,
94
- ChainTip,
95
- ChainTips,
96
64
  CheckpointIncludeOptions,
97
65
  CheckpointParameter,
98
66
  CheckpointResponse,
67
+ CheckpointTag,
68
+ GetTxByHashOptions,
69
+ PeerInfo,
70
+ ProposalsForSlot,
99
71
  } from '@aztec/stdlib/interfaces/client';
100
72
  import { AztecNodeAdminConfigSchema } from '@aztec/stdlib/interfaces/client';
101
73
  import {
@@ -108,27 +80,24 @@ import {
108
80
  tryStop,
109
81
  } from '@aztec/stdlib/interfaces/server';
110
82
  import type { DebugLogStore, LogResult, PrivateLogsQuery, PublicLogsQuery } from '@aztec/stdlib/logs';
111
- import { InMemoryDebugLogStore, NullDebugLogStore } from '@aztec/stdlib/logs';
112
- import { InboxLeaf, type L1ToL2MessageSource, appendL1ToL2MessagesToTree } from '@aztec/stdlib/messaging';
83
+ import { NullDebugLogStore } from '@aztec/stdlib/logs';
84
+ import type { L1ToL2MessageSource, L2ToL1MembershipWitness } from '@aztec/stdlib/messaging';
85
+ import type { CheckpointAttestation } from '@aztec/stdlib/p2p';
113
86
  import type { Offense } from '@aztec/stdlib/slashing';
114
- import { MIN_EXECUTION_TIME } from '@aztec/stdlib/timetable';
115
- import type { NullifierLeafPreimage, PublicDataTreeLeafPreimage } from '@aztec/stdlib/trees';
116
87
  import { MerkleTreeId, NullifierMembershipWitness, PublicDataWitness } from '@aztec/stdlib/trees';
117
88
  import {
118
89
  type FeeProvider,
90
+ type GetTxReceiptOptions,
119
91
  type GlobalVariableBuilder as GlobalVariableBuilderInterface,
120
92
  type IndexedTxEffect,
121
93
  PublicSimulationOutput,
122
94
  type SimulationOverrides,
123
95
  Tx,
124
96
  type TxHash,
125
- TxReceipt,
126
- TxStatus,
97
+ type TxReceipt,
127
98
  type TxValidationResult,
128
99
  } from '@aztec/stdlib/tx';
129
- import { getPackageVersion } from '@aztec/stdlib/update-checker';
130
100
  import type { SingleValidatorStats, ValidatorsStats } from '@aztec/stdlib/validators';
131
- import type { GenesisData } from '@aztec/stdlib/world-state';
132
101
  import {
133
102
  Attributes,
134
103
  type TelemetryClient,
@@ -137,31 +106,55 @@ import {
137
106
  getTelemetryClient,
138
107
  trackSpan,
139
108
  } from '@aztec/telemetry-client';
140
- import {
141
- FullNodeCheckpointsBuilder as CheckpointsBuilder,
142
- FullNodeCheckpointsBuilder,
143
- NodeKeystoreAdapter,
144
- ValidatorClient,
145
- createProposalHandler,
146
- createValidatorClient,
147
- } from '@aztec/validator-client';
148
- import type { SlashingProtectionDatabase } from '@aztec/validator-ha-signer/types';
149
- import { createWorldState, createWorldStateSynchronizer } from '@aztec/world-state';
150
-
151
- import { createPublicClient } from 'viem';
152
-
153
- 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';
154
114
  import { Sentinel } from '../sentinel/sentinel.js';
155
- import {
156
- blockResponseFromBlockData,
157
- blockResponseFromL2Block,
158
- checkpointResponseFromCheckpointData,
159
- checkpointResponseFromPublishedCheckpoint,
160
- projectProposedToCheckpointResponse,
161
- } from './block_response_helpers.js';
162
- import { type AztecNodeConfig, createKeyStoreForValidator } from './config.js';
115
+ import type { AztecNodeConfig } from './config.js';
163
116
  import { NodeMetrics } from './node_metrics.js';
164
- import { applyPublicDataOverrides } from './public_data_overrides.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
+ }
165
158
 
166
159
  /**
167
160
  * The aztec node.
@@ -172,48 +165,116 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, AztecNodeDeb
172
165
  private isUploadingSnapshot = false;
173
166
  // Saved minTxsPerBlock used by `pauseSequencer` to restore production-sequencer config on resume.
174
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;
175
172
 
176
173
  public readonly tracer: Tracer;
177
174
 
178
- constructor(
179
- protected config: AztecNodeConfig,
180
- protected readonly p2pClient: P2P,
181
- protected readonly blockSource: L2BlockSource & Partial<Service>,
182
- protected readonly logsSource: L2LogsSource,
183
- protected readonly contractDataSource: ContractDataSource,
184
- protected readonly l1ToL2MessageSource: L1ToL2MessageSource,
185
- protected readonly worldStateSynchronizer: WorldStateSynchronizer,
186
- protected readonly sequencer: SequencerClient | undefined,
187
- protected readonly proverNode: ProverNode | undefined,
188
- protected readonly slasherClient: SlasherClientInterface | undefined,
189
- protected readonly validatorsSentinel: Sentinel | undefined,
190
- private readonly stopStartedWatchers: () => Promise<void>,
191
- protected readonly l1ChainId: number,
192
- protected readonly version: number,
193
- protected readonly globalVariableBuilder: GlobalVariableBuilderInterface,
194
- protected readonly feeProvider: FeeProvider,
195
- protected readonly epochCache: EpochCacheInterface,
196
- protected readonly packageVersion: string,
197
- private peerProofVerifier: ClientProtocolCircuitVerifier,
198
- private rpcProofVerifier: ClientProtocolCircuitVerifier,
199
- private telemetry: TelemetryClient = getTelemetryClient(),
200
- private log = createLogger('node'),
201
- private blobClient?: BlobClientInterface,
202
- private validatorClient?: ValidatorClient,
203
- private keyStoreManager?: KeystoreManager,
204
- private debugLogStore: DebugLogStore = new NullDebugLogStore(),
205
- private readonly automineSequencer?: AutomineSequencer,
206
- ) {
207
- this.metrics = new NodeMetrics(telemetry, 'AztecNodeService');
208
- 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
+ });
209
270
 
210
271
  this.log.info(`Aztec Node version: ${this.packageVersion}`);
211
- this.log.info(`Aztec Node started on chain 0x${l1ChainId.toString(16)}`, pickL1ContractAddresses(config));
272
+ this.log.info(`Aztec Node started on chain 0x${this.l1ChainId.toString(16)}`, pickL1ContractAddresses(this.config));
212
273
 
213
- // 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
214
275
  // never have debugLogStore enabled when not in test mode because then we would be accumulating debug logs in
215
276
  // memory which could be a DoS vector on the sequencer (since no fees are paid for debug logs).
216
- if (debugLogStore.isEnabled && config.realProofs) {
277
+ if (this.debugLogStore.isEnabled && this.config.realProofs) {
217
278
  throw new Error('debugLogStore should never be enabled when realProofs are set');
218
279
  }
219
280
  }
@@ -228,30 +289,43 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, AztecNodeDeb
228
289
  return status.syncSummary;
229
290
  }
230
291
 
231
- public async getChainTips(): Promise<ChainTips> {
232
- const { proposed, checkpointed, proven, finalized } = await this.blockSource.getL2Tips();
233
- return { proposed, checkpointed, proven, finalized };
292
+ public getChainTips(): Promise<L2Tips> {
293
+ return this.blockSource.getL2Tips();
294
+ }
295
+
296
+ public getL1Constants(): Promise<L1RollupConstants> {
297
+ return this.blockSource.getL1Constants();
298
+ }
299
+
300
+ public getSyncedL2SlotNumber() {
301
+ return this.blockSource.getSyncedL2SlotNumber();
302
+ }
303
+
304
+ public getSyncedL2EpochNumber() {
305
+ return this.blockSource.getSyncedL2EpochNumber();
306
+ }
307
+
308
+ public getSyncedL1Timestamp() {
309
+ return this.blockSource.getL1Timestamp();
234
310
  }
235
311
 
236
312
  public getCheckpointsData(query: CheckpointsQuery) {
237
313
  return this.blockSource.getCheckpointsData(query);
238
314
  }
239
315
 
240
- public async getBlockNumber(tip?: ChainTip): Promise<BlockNumber> {
316
+ public async getBlockNumber(tip?: L2BlockTag): Promise<BlockNumber> {
241
317
  if (tip === undefined || tip === 'proposed') {
242
318
  return this.blockSource.getBlockNumber();
243
319
  }
244
320
  return (await this.blockSource.getBlockNumber({ tag: tip })) ?? BlockNumber.ZERO;
245
321
  }
246
322
 
247
- public async getCheckpointNumber(tip?: ChainTip): Promise<CheckpointNumber> {
323
+ public async getCheckpointNumber(tip?: CheckpointTag): Promise<CheckpointNumber> {
248
324
  const tips = await this.blockSource.getL2Tips();
249
325
  switch (tip) {
250
326
  case undefined:
251
327
  case 'checkpointed':
252
328
  return tips.checkpointed.checkpoint.number;
253
- case 'proposed':
254
- return tips.proposedCheckpoint.checkpoint.number;
255
329
  case 'proven':
256
330
  return tips.proven.checkpoint.number;
257
331
  case 'finalized':
@@ -259,755 +333,38 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, AztecNodeDeb
259
333
  }
260
334
  }
261
335
 
262
- private isChainTip(value: unknown): value is ChainTip {
263
- return value === 'proposed' || value === 'checkpointed' || value === 'proven' || value === 'finalized';
264
- }
265
-
266
- /**
267
- * Normalizes a {@link BlockParameter} (which may be a bare value) into a
268
- * {@link NormalizedBlockParameter} object form. Performs no chain-tip resolution — tag
269
- * lookups are deferred to the underlying block source.
270
- */
271
- private normalizeBlockParameter(param: BlockParameter): NormalizedBlockParameter {
272
- if (BlockHash.isBlockHash(param)) {
273
- return { hash: param };
274
- }
275
- if (typeof param === 'number') {
276
- return { number: param as BlockNumber };
277
- }
278
- if (typeof param === 'string') {
279
- if (this.isBlockTag(param)) {
280
- return { tag: param === 'latest' ? 'proposed' : param };
281
- }
282
- throw new BadRequestError(`Invalid BlockParameter tag: ${param}`);
283
- }
284
- if (typeof param === 'object' && param !== null) {
285
- if ('number' in param) {
286
- return { number: param.number };
287
- }
288
- if ('hash' in param) {
289
- return { hash: param.hash };
290
- }
291
- if ('archive' in param) {
292
- return { archive: param.archive };
293
- }
294
- if ('tag' in param) {
295
- if (this.isBlockTag(param.tag)) {
296
- return { tag: param.tag };
297
- }
298
- throw new BadRequestError(`Invalid BlockParameter tag: ${param.tag}`);
299
- }
300
- }
301
- throw new BadRequestError(`Invalid BlockParameter: ${JSON.stringify(param)}`);
302
- }
303
-
304
- private isBlockTag(value: string): value is BlockTag {
305
- return BlockTag.includes(value as BlockTag);
306
- }
307
-
308
- /**
309
- * Resolves a {@link CheckpointParameter} into a concrete `{ number }` or `{ slot }` query.
310
- *
311
- * Tag-based parameters (`'proposed'`, `'checkpointed'`, `'proven'`, `'finalized'`) are
312
- * translated up-front to the corresponding tip's checkpoint number via {@link L2BlockSource.getL2Tips}.
313
- * After resolution the unified {@link getCheckpoint} flow can perform a single
314
- * confirmed→proposed lookup against either store.
315
- */
316
- private async resolveCheckpointParameter(
317
- param: CheckpointParameter,
318
- ): Promise<{ number: CheckpointNumber } | { slot: SlotNumber }> {
319
- if (typeof param === 'number') {
320
- return { number: param as CheckpointNumber };
321
- }
322
- if (this.isChainTip(param)) {
323
- const tips = await this.blockSource.getL2Tips();
324
- switch (param) {
325
- case 'proposed':
326
- return { number: tips.proposedCheckpoint.checkpoint.number };
327
- case 'checkpointed':
328
- return { number: tips.checkpointed.checkpoint.number };
329
- case 'proven':
330
- return { number: tips.proven.checkpoint.number };
331
- case 'finalized':
332
- return { number: tips.finalized.checkpoint.number };
333
- }
334
- }
335
- if (typeof param === 'object' && param !== null) {
336
- if ('number' in param) {
337
- return { number: param.number };
338
- }
339
- if ('slot' in param) {
340
- return { slot: param.slot };
341
- }
342
- }
343
- throw new BadRequestError(`Invalid CheckpointParameter: ${JSON.stringify(param)}`);
344
- }
345
-
346
- /** Fetches checkpoint-level L1 and attestation data for use as block response context. */
347
- async #getCheckpointContext(
348
- checkpointNumber: CheckpointNumber,
349
- ): Promise<{ l1?: L1PublishedData; attestations?: CommitteeAttestation[] } | undefined> {
350
- const checkpoint = await this.blockSource.getCheckpointData({ number: checkpointNumber });
351
- if (!checkpoint) {
352
- return undefined;
353
- }
354
- return { l1: checkpoint.l1, attestations: checkpoint.attestations };
355
- }
356
-
357
- public async getBlock<Opts extends BlockIncludeOptions = {}>(
336
+ public getBlock<Opts extends BlockIncludeOptions = {}>(
358
337
  param: BlockParameter,
359
338
  options: Opts = {} as Opts,
360
339
  ): Promise<BlockResponse<Opts> | undefined> {
361
- const query = this.normalizeBlockParameter(param);
362
- const wantTxs = !!options.includeTransactions;
363
- const wantContext = !!options.includeL1PublishInfo || !!options.includeAttestations;
364
-
365
- if (wantTxs) {
366
- const block = await this.blockSource.getBlock(query);
367
- if (!block) {
368
- return undefined;
369
- }
370
- const ctx = wantContext ? await this.#getCheckpointContext(block.checkpointNumber) : undefined;
371
- return (await blockResponseFromL2Block(block, options, ctx)) as BlockResponse<Opts>;
372
- }
373
- const data = await this.blockSource.getBlockData(query);
374
- if (!data) {
375
- return undefined;
376
- }
377
- const ctx = wantContext ? await this.#getCheckpointContext(data.checkpointNumber) : undefined;
378
- return blockResponseFromBlockData(data, options, ctx) as BlockResponse<Opts>;
340
+ return this.blockProvider.getBlock(param, options);
379
341
  }
380
342
 
381
343
  public getBlockData(param: BlockParameter): Promise<BlockData | undefined> {
382
- const query = this.normalizeBlockParameter(param);
383
- return this.blockSource.getBlockData(query);
344
+ return this.blockProvider.getBlockData(param);
384
345
  }
385
346
 
386
- public async getBlocks<Opts extends BlocksIncludeOptions = {}>(
347
+ public getBlocks<Opts extends BlocksIncludeOptions = {}>(
387
348
  from: BlockNumber,
388
349
  limit: number,
389
350
  options: Opts = {} as Opts,
390
351
  ): Promise<BlockResponse<Opts>[]> {
391
- const wantTxs = !!options.includeTransactions;
392
- const wantContext = !!options.includeL1PublishInfo || !!options.includeAttestations;
393
- const onlyCheckpointed = !!options.onlyCheckpointed;
394
- if (wantTxs) {
395
- const blocks = await this.blockSource.getBlocks({ from, limit, onlyCheckpointed });
396
- const ctxByCheckpoint = await this.#getCheckpointContextsForBlocks(wantContext ? blocks : []);
397
- return (await Promise.all(
398
- blocks.map(block => blockResponseFromL2Block(block, options, ctxByCheckpoint.get(block.checkpointNumber))),
399
- )) as BlockResponse<Opts>[];
400
- }
401
- const dataItems = await this.blockSource.getBlocksData({ from, limit, onlyCheckpointed });
402
- const ctxByCheckpoint = await this.#getCheckpointContextsForBlocks(wantContext ? dataItems : []);
403
- return (await Promise.all(
404
- dataItems.map(data => blockResponseFromBlockData(data, options, ctxByCheckpoint.get(data.checkpointNumber))),
405
- )) as BlockResponse<Opts>[];
406
- }
407
-
408
- /** Fetches checkpoint context for a set of blocks, deduplicating shared checkpoints. */
409
- async #getCheckpointContextsForBlocks(
410
- blocks: { checkpointNumber: CheckpointNumber }[],
411
- ): Promise<Map<CheckpointNumber, { l1?: L1PublishedData; attestations?: CommitteeAttestation[] } | undefined>> {
412
- const unique = Array.from(new Set(blocks.map(b => b.checkpointNumber)));
413
- const entries = await Promise.all(unique.map(async n => [n, await this.#getCheckpointContext(n)] as const));
414
- return new Map(entries);
352
+ return this.blockProvider.getBlocks(from, limit, options);
415
353
  }
416
354
 
417
- public async getCheckpoint<Opts extends CheckpointIncludeOptions = {}>(
355
+ public getCheckpoint<Opts extends CheckpointIncludeOptions = {}>(
418
356
  param: CheckpointParameter,
419
357
  options: Opts = {} as Opts,
420
358
  ): Promise<CheckpointResponse<Opts> | undefined> {
421
- const query = await this.resolveCheckpointParameter(param);
422
-
423
- // Try the confirmed store first.
424
- const confirmed = options.includeBlocks
425
- ? await this.blockSource.getCheckpoint(query)
426
- : await this.blockSource.getCheckpointData(query);
427
- if (confirmed) {
428
- return (await (options.includeBlocks
429
- ? checkpointResponseFromPublishedCheckpoint(confirmed as PublishedCheckpoint, options)
430
- : checkpointResponseFromCheckpointData(confirmed as CheckpointData, options))) as CheckpointResponse<Opts>;
431
- }
432
-
433
- // Fall back to the proposed store.
434
- const proposed = await this.blockSource.getProposedCheckpointData(query);
435
- if (proposed) {
436
- if (options.includeAttestations || options.includeL1PublishInfo) {
437
- throw new BadRequestError(
438
- `Options includeL1PublishInfo or includeAttestations cannot be satisfied for a proposed checkpoint`,
439
- );
440
- }
441
- const blocks = options.includeBlocks
442
- ? await this.blockSource.getBlocks({ from: proposed.startBlock, limit: proposed.blockCount })
443
- : undefined;
444
- return (await projectProposedToCheckpointResponse(proposed, options, blocks)) as CheckpointResponse<Opts>;
445
- }
446
-
447
- return undefined;
359
+ return this.blockProvider.getCheckpoint(param, options);
448
360
  }
449
361
 
450
- public async getCheckpoints<Opts extends CheckpointIncludeOptions = {}>(
362
+ public getCheckpoints<Opts extends CheckpointIncludeOptions = {}>(
451
363
  from: CheckpointNumber,
452
364
  limit: number,
453
365
  options: Opts = {} as Opts,
454
366
  ): Promise<CheckpointResponse<Opts>[]> {
455
- if (options.includeBlocks) {
456
- const checkpoints = await this.blockSource.getCheckpoints({ from, limit });
457
- return (await Promise.all(
458
- checkpoints.map(cp => checkpointResponseFromPublishedCheckpoint(cp, options)),
459
- )) as CheckpointResponse<Opts>[];
460
- }
461
- const datas = await this.blockSource.getCheckpointsData({ from, limit });
462
- return datas.map(d => checkpointResponseFromCheckpointData(d, options)) as CheckpointResponse<Opts>[];
463
- }
464
-
465
- /**
466
- * initializes the Aztec Node, wait for component to sync.
467
- * @param config - The configuration to be used by the aztec node.
468
- * @returns - A fully synced Aztec Node for use in development/testing.
469
- */
470
- public static async createAndSync(
471
- inputConfig: AztecNodeConfig,
472
- deps: {
473
- telemetry?: TelemetryClient;
474
- logger?: Logger;
475
- publisher?: SequencerPublisher;
476
- dateProvider?: DateProvider;
477
- p2pClientDeps?: P2PClientDeps;
478
- proverNodeDeps?: Partial<ProverNodeDeps>;
479
- slashingProtectionDb?: SlashingProtectionDatabase;
480
- } = {},
481
- options: {
482
- genesis?: GenesisData;
483
- dontStartSequencer?: boolean;
484
- dontStartProverNode?: boolean;
485
- } = {},
486
- ): Promise<AztecNodeService> {
487
- const config = { ...inputConfig }; // Copy the config so we dont mutate the input object
488
- const log = deps.logger ?? createLogger('node');
489
- const packageVersion = getPackageVersion();
490
- const telemetry = deps.telemetry ?? getTelemetryClient();
491
- const dateProvider = deps.dateProvider ?? new DateProvider();
492
- const ethereumChain = createEthereumChain(config.l1RpcUrls, config.l1ChainId);
493
-
494
- // Build a key store from file if given or from environment otherwise.
495
- // We keep the raw KeyStore available so we can merge with prover keys if enableProverNode is set.
496
- let keyStoreManager: KeystoreManager | undefined;
497
- const keyStoreProvided = config.keyStoreDirectory !== undefined && config.keyStoreDirectory.length > 0;
498
- if (keyStoreProvided) {
499
- const keyStores = loadKeystores(config.keyStoreDirectory!);
500
- keyStoreManager = new KeystoreManager(mergeKeystores(keyStores));
501
- } else {
502
- const rawKeyStores: KeyStore[] = [];
503
- const validatorKeyStore = createKeyStoreForValidator(config);
504
- if (validatorKeyStore) {
505
- rawKeyStores.push(validatorKeyStore);
506
- }
507
- if (config.enableProverNode) {
508
- const proverKeyStore = createKeyStoreForProver(config);
509
- if (proverKeyStore) {
510
- rawKeyStores.push(proverKeyStore);
511
- }
512
- }
513
- if (rawKeyStores.length > 0) {
514
- keyStoreManager = new KeystoreManager(
515
- rawKeyStores.length === 1 ? rawKeyStores[0] : mergeKeystores(rawKeyStores),
516
- );
517
- }
518
- }
519
-
520
- await keyStoreManager?.validateSigners();
521
-
522
- // If we are a validator, verify our configuration before doing too much more.
523
- if (!config.disableValidator) {
524
- if (keyStoreManager === undefined) {
525
- throw new Error('Failed to create key store, a requirement for running a validator');
526
- }
527
- if (!keyStoreProvided && process.env.NODE_ENV !== 'test') {
528
- log.warn("Keystore created from env: it's recommended to use a file-based key store for production");
529
- }
530
- ValidatorClient.validateKeyStoreConfiguration(keyStoreManager, log);
531
- }
532
-
533
- // validate that the actual chain id matches that specified in configuration
534
- if (config.l1ChainId !== ethereumChain.chainInfo.id) {
535
- throw new Error(
536
- `RPC URL configured for chain id ${ethereumChain.chainInfo.id} but expected id ${config.l1ChainId}`,
537
- );
538
- }
539
-
540
- const publicClient = createPublicClient({
541
- chain: ethereumChain.chainInfo,
542
- transport: makeL1HttpTransport(config.l1RpcUrls, { timeout: config.l1HttpTimeoutMS }),
543
- pollingInterval: config.viemPollingIntervalMS,
544
- });
545
-
546
- const l1ContractsAddresses = await RegistryContract.collectAddresses(
547
- publicClient,
548
- config.registryAddress,
549
- config.rollupVersion ?? 'canonical',
550
- );
551
-
552
- Object.assign(config, l1ContractsAddresses);
553
-
554
- const rollupContract = new RollupContract(publicClient, config.rollupAddress.toString());
555
- const [l1GenesisTime, slotDuration, rollupVersionFromRollup, rollupManaLimit] = await Promise.all([
556
- rollupContract.getL1GenesisTime(),
557
- rollupContract.getSlotDuration(),
558
- rollupContract.getVersion(),
559
- rollupContract.getManaLimit().then(Number),
560
- ] as const);
561
-
562
- config.rollupVersion ??= Number(rollupVersionFromRollup);
563
-
564
- if (config.rollupVersion !== Number(rollupVersionFromRollup)) {
565
- log.warn(
566
- `Registry looked up and returned a rollup with version (${config.rollupVersion}), but this does not match with version detected from the rollup directly: (${rollupVersionFromRollup}).`,
567
- );
568
- }
569
-
570
- const blobClient = await createBlobClientWithFileStores(config, log.createChild('blob-client'));
571
-
572
- // attempt snapshot sync if possible
573
- await trySnapshotSync(config, log);
574
-
575
- const epochCache = await EpochCache.create(config.rollupAddress, config, { dateProvider });
576
-
577
- // Track started resources so we can clean up on partial failure during node creation.
578
- const started: { stop?(): Promise<void> | void }[] = [];
579
- try {
580
- // Default the orphan-prune grace window from the block build duration when unset, so the archiver
581
- // waits roughly one build slot for a proposed checkpoint to arrive before pruning a block-only tip.
582
- config.orphanProposedBlockPruneGraceSeconds ??=
583
- config.blockDurationMs !== undefined ? Math.ceil(config.blockDurationMs / 1000) : MIN_EXECUTION_TIME;
584
-
585
- // Create world-state first so we can retrieve the initial header before constructing the archiver.
586
- const nativeWs = await createWorldState(config, options.genesis);
587
- const initialHeader = nativeWs.getInitialHeader();
588
- const initialBlockHash = await initialHeader.hash();
589
- const archiver = await createArchiver(
590
- config,
591
- { blobClient, epochCache, telemetry, dateProvider },
592
- { blockUntilSync: !config.skipArchiverInitialSync },
593
- initialHeader,
594
- initialBlockHash,
595
- );
596
- started.push(archiver);
597
-
598
- // The synchronizer takes ownership of the native world-state from here
599
- const worldStateSynchronizer = await createWorldStateSynchronizer(config, archiver, nativeWs, telemetry);
600
- started.push(worldStateSynchronizer);
601
- const useRealVerifiers = config.realProofs || config.debugForceTxProofVerification;
602
- let peerProofVerifier: ClientProtocolCircuitVerifier;
603
- let rpcProofVerifier: ClientProtocolCircuitVerifier;
604
- if (useRealVerifiers) {
605
- peerProofVerifier = await BatchChonkVerifier.new(config, config.bbChonkVerifyMaxBatch, 'peer');
606
- const rpcVerifier = await BBCircuitVerifier.new(config);
607
- rpcProofVerifier = new QueuedIVCVerifier(rpcVerifier, config.numConcurrentIVCVerifiers);
608
- } else {
609
- peerProofVerifier = new TestCircuitVerifier(config.proverTestVerificationDelayMs);
610
- rpcProofVerifier = new TestCircuitVerifier(config.proverTestVerificationDelayMs);
611
- }
612
- started.push(peerProofVerifier, rpcProofVerifier);
613
-
614
- let debugLogStore: DebugLogStore;
615
- if (!config.realProofs) {
616
- log.warn(`Aztec node is accepting fake proofs`);
617
-
618
- debugLogStore = new InMemoryDebugLogStore();
619
- log.info(
620
- 'Aztec node started in test mode (realProofs set to false) hence debug logs from public functions will be collected and served',
621
- );
622
- } else {
623
- debugLogStore = new NullDebugLogStore();
624
- }
625
-
626
- const globalVariableBuilderConfig = {
627
- rollupAddress: config.rollupAddress,
628
- ethereumSlotDuration: config.ethereumSlotDuration,
629
- rollupVersion: BigInt(config.rollupVersion),
630
- l1GenesisTime,
631
- slotDuration: Number(slotDuration),
632
- };
633
-
634
- const globalVariableBuilder = new GlobalVariableBuilder(dateProvider, publicClient, globalVariableBuilderConfig);
635
- const feeProvider = new FeeProviderImpl(dateProvider, publicClient, globalVariableBuilderConfig);
636
-
637
- const proverOnly = config.enableProverNode && config.disableValidator;
638
- if (proverOnly) {
639
- log.info('Starting in prover-only mode: skipping validator, sequencer, sentinel, and slasher subsystems');
640
- }
641
-
642
- // create the tx pool and the p2p client, which will need the l2 block source
643
- const p2pClient = await createP2PClient(
644
- config,
645
- archiver,
646
- peerProofVerifier,
647
- worldStateSynchronizer,
648
- epochCache,
649
- feeProvider,
650
- packageVersion,
651
- dateProvider,
652
- telemetry,
653
- deps.p2pClientDeps,
654
- initialBlockHash,
655
- );
656
- started.push(p2pClient);
657
-
658
- // We'll accumulate sentinel watchers here
659
- const watchers: Watcher[] = [];
660
-
661
- // Create FullNodeCheckpointsBuilder for block proposal handling and tx validation.
662
- // Override maxTxsPerCheckpoint with the validator-specific limit if set.
663
- const validatorCheckpointsBuilder = new FullNodeCheckpointsBuilder(
664
- {
665
- ...config,
666
- l1GenesisTime,
667
- slotDuration: Number(slotDuration),
668
- rollupManaLimit,
669
- maxTxsPerCheckpoint: config.validateMaxTxsPerCheckpoint,
670
- },
671
- worldStateSynchronizer,
672
- archiver,
673
- dateProvider,
674
- telemetry,
675
- );
676
-
677
- let validatorClient: ValidatorClient | undefined;
678
-
679
- // Tracks successful checkpoint re-execution by a checkpoint proposal handler.
680
- const reexecutionTracker = new CheckpointReexecutionTracker();
681
-
682
- if (!config.disableValidator) {
683
- // Create validator client if required
684
- validatorClient = await createValidatorClient(config, {
685
- checkpointsBuilder: validatorCheckpointsBuilder,
686
- worldState: worldStateSynchronizer,
687
- p2pClient,
688
- telemetry,
689
- dateProvider,
690
- epochCache,
691
- blockSource: archiver,
692
- l1ToL2MessageSource: archiver,
693
- keyStoreManager,
694
- blobClient,
695
- reexecutionTracker,
696
- slashingProtectionDb: deps.slashingProtectionDb,
697
- });
698
-
699
- // If we have a validator client, register it as a source of offenses for the slasher,
700
- // and have it register callbacks on the p2p client *before* we start it, otherwise messages
701
- // like attestations or auths will fail.
702
- if (validatorClient) {
703
- watchers.push(validatorClient);
704
-
705
- const vc = validatorClient;
706
- const getValidatorAddresses = () => vc.getValidatorAddresses().map(a => a.toString());
707
- validatorClient.getProposalHandler().register(p2pClient, true, archiver, getValidatorAddresses);
708
-
709
- if (!options.dontStartSequencer) {
710
- await validatorClient.registerHandlers();
711
- }
712
- }
713
- }
714
-
715
- // If there's no validator client, create a ProposalHandler to handle block and checkpoint proposals
716
- // for monitoring or reexecution. Reexecution (default) allows us to follow the pending chain,
717
- // while non-reexecution is used for validating the proposals and collecting their txs.
718
- // Checkpoint proposals rebuild blobs if the blob client can upload blobs.
719
- if (!validatorClient) {
720
- const reexecute = !!config.alwaysReexecuteBlockProposals;
721
- log.info(`Setting up proposal handler` + (reexecute ? ' with reexecution of proposals' : ''));
722
- createProposalHandler(config, {
723
- checkpointsBuilder: validatorCheckpointsBuilder,
724
- worldState: worldStateSynchronizer,
725
- epochCache,
726
- blockSource: archiver,
727
- l1ToL2MessageSource: archiver,
728
- p2pClient,
729
- blobClient,
730
- dateProvider,
731
- telemetry,
732
- reexecutionTracker,
733
- }).register(p2pClient, reexecute, archiver);
734
- }
735
-
736
- // Start world state and wait for it to sync to the archiver.
737
- await worldStateSynchronizer.start();
738
-
739
- // Start p2p. Note that it depends on world state to be running.
740
- await p2pClient.start();
741
-
742
- let validatorsSentinel: Awaited<ReturnType<typeof createSentinel>> | undefined;
743
- let dataWithholdingWatcher: DataWithholdingWatcher | undefined;
744
- let attestationsBlockWatcher: AttestationsBlockWatcher | undefined;
745
- let attestedInvalidProposalWatcher: AttestedInvalidProposalWatcher | undefined;
746
- let broadcastedInvalidCheckpointProposalWatcher: BroadcastedInvalidCheckpointProposalWatcher | undefined;
747
- let checkpointEquivocationWatcher: CheckpointEquivocationWatcher | undefined;
748
-
749
- if (!proverOnly) {
750
- validatorsSentinel = await createSentinel(epochCache, archiver, p2pClient, reexecutionTracker, config);
751
- if (validatorsSentinel) {
752
- watchers.push(validatorsSentinel);
753
- }
754
-
755
- dataWithholdingWatcher = new DataWithholdingWatcher(
756
- epochCache,
757
- archiver,
758
- p2pClient.getTxProvider(),
759
- p2pClient,
760
- reexecutionTracker,
761
- { chainId: config.l1ChainId, rollupAddress: config.rollupAddress },
762
- config,
763
- );
764
- watchers.push(dataWithholdingWatcher);
765
-
766
- broadcastedInvalidCheckpointProposalWatcher = new BroadcastedInvalidCheckpointProposalWatcher(
767
- p2pClient,
768
- archiver,
769
- epochCache,
770
- config,
771
- );
772
- watchers.push(broadcastedInvalidCheckpointProposalWatcher);
773
-
774
- if (validatorClient) {
775
- attestedInvalidProposalWatcher = new AttestedInvalidProposalWatcher(
776
- p2pClient,
777
- validatorClient,
778
- archiver,
779
- epochCache,
780
- config,
781
- { log: log.createChild('attested-invalid-proposal-watcher') },
782
- );
783
- watchers.push(attestedInvalidProposalWatcher);
784
- }
785
-
786
- checkpointEquivocationWatcher = new CheckpointEquivocationWatcher(archiver, epochCache, config);
787
- watchers.push(checkpointEquivocationWatcher);
788
-
789
- attestationsBlockWatcher = new AttestationsBlockWatcher(archiver, epochCache, config, log.getBindings());
790
- watchers.push(attestationsBlockWatcher);
791
- }
792
-
793
- const watchersToStart = compactArray([
794
- validatorsSentinel,
795
- dataWithholdingWatcher,
796
- attestationsBlockWatcher,
797
- broadcastedInvalidCheckpointProposalWatcher,
798
- attestedInvalidProposalWatcher,
799
- checkpointEquivocationWatcher,
800
- ]);
801
- const startedWatchers: Watcher[] = [];
802
- const stopStartedWatchers = async () => {
803
- for (const watcher of startedWatchers) {
804
- await tryStop(watcher);
805
- }
806
- };
807
-
808
- // Start p2p-related services once the archiver has completed sync
809
- void archiver
810
- .waitForInitialSync()
811
- .then(async () => {
812
- for (const watcher of watchersToStart) {
813
- await watcher.start();
814
- startedWatchers.push(watcher);
815
- }
816
- log.info(`All p2p services started`);
817
- })
818
- .catch(err => log.error('Failed to start p2p services after archiver sync', err));
819
- started.push({ stop: stopStartedWatchers });
820
-
821
- // Validator enabled, create/start relevant service
822
- let sequencer: SequencerClient | undefined;
823
- let automineSequencer: AutomineSequencer | undefined;
824
- let slasherClient: SlasherClientInterface | undefined;
825
- if (!config.disableValidator && validatorClient) {
826
- // We create a slasher only if we have a sequencer, since all slashing actions go through the sequencer publisher
827
- // as they are executed when the node is selected as proposer.
828
- const validatorAddresses = keyStoreManager
829
- ? NodeKeystoreAdapter.fromKeyStoreManager(keyStoreManager).getAddresses()
830
- : [];
831
-
832
- slasherClient = await createSlasher(
833
- config,
834
- pickL1ContractAddresses(config),
835
- getPublicClient(config),
836
- watchers,
837
- dateProvider,
838
- epochCache,
839
- validatorAddresses,
840
- undefined, // logger
841
- );
842
- await slasherClient.start();
843
- started.push(slasherClient);
844
-
845
- const l1TxUtils = config.sequencerPublisherForwarderAddress
846
- ? await createForwarderL1TxUtilsFromSigners(
847
- publicClient,
848
- keyStoreManager!.createAllValidatorPublisherSigners(),
849
- config.sequencerPublisherForwarderAddress,
850
- { ...config, scope: 'sequencer' },
851
- { telemetry, logger: log.createChild('l1-tx-utils'), dateProvider, kzg: Blob.getViemKzgInstance() },
852
- )
853
- : await createL1TxUtilsFromSigners(
854
- publicClient,
855
- keyStoreManager!.createAllValidatorPublisherSigners(),
856
- { ...config, scope: 'sequencer' },
857
- { telemetry, logger: log.createChild('l1-tx-utils'), dateProvider, kzg: Blob.getViemKzgInstance() },
858
- );
859
-
860
- // Create a funder L1TxUtils from the keystore funding account (if configured)
861
- const fundingSigner = keyStoreManager?.createFundingSigner();
862
- let funderL1TxUtils: L1TxUtils | undefined;
863
- if (fundingSigner) {
864
- const [funder] = await createL1TxUtilsFromSigners(
865
- publicClient,
866
- [fundingSigner],
867
- { ...config, scope: 'sequencer' },
868
- { telemetry, logger: log.createChild('l1-tx-utils:funder'), dateProvider },
869
- );
870
- funderL1TxUtils = funder;
871
- }
872
-
873
- // Create and start the sequencer client
874
- const checkpointsBuilder = new CheckpointsBuilder(
875
- { ...config, l1GenesisTime, slotDuration: Number(slotDuration), rollupManaLimit },
876
- worldStateSynchronizer,
877
- archiver,
878
- dateProvider,
879
- telemetry,
880
- debugLogStore,
881
- );
882
-
883
- if (config.useAutomineSequencer) {
884
- // Test-only path: deterministic, queue-driven sequencer for non-block-building e2e tests.
885
- // See `AUTOMINE_E2E_OPTS` in `end-to-end/src/fixtures/fixtures.ts`.
886
- automineSequencer = await createAutomineSequencer({
887
- config,
888
- l1TxUtils,
889
- funderL1TxUtils,
890
- publicClient,
891
- rollupContract,
892
- epochCache,
893
- blobClient,
894
- telemetry,
895
- dateProvider,
896
- keyStoreManager: keyStoreManager!,
897
- validatorClient,
898
- checkpointsBuilder,
899
- globalVariableBuilder,
900
- worldStateSynchronizer,
901
- archiver,
902
- p2pClient,
903
- l1Constants: {
904
- l1GenesisTime,
905
- slotDuration: Number(slotDuration),
906
- ethereumSlotDuration: config.ethereumSlotDuration,
907
- rollupManaLimit,
908
- },
909
- log,
910
- });
911
- } else {
912
- sequencer = await SequencerClient.new(config, {
913
- ...deps,
914
- epochCache,
915
- l1TxUtils,
916
- funderL1TxUtils,
917
- validatorClient,
918
- p2pClient,
919
- worldStateSynchronizer,
920
- slasherClient,
921
- checkpointsBuilder,
922
- l2BlockSource: archiver,
923
- l1ToL2MessageSource: archiver,
924
- telemetry,
925
- dateProvider,
926
- blobClient,
927
- nodeKeyStore: keyStoreManager!,
928
- globalVariableBuilder,
929
- });
930
- }
931
- }
932
-
933
- if (!options.dontStartSequencer && sequencer) {
934
- await sequencer.start();
935
- started.push(sequencer);
936
- log.verbose(`Sequencer started`);
937
- } else if (sequencer) {
938
- log.warn(`Sequencer created but not started`);
939
- }
940
-
941
- if (!options.dontStartSequencer && automineSequencer) {
942
- await automineSequencer.start();
943
- started.push({ stop: () => automineSequencer!.stop() });
944
- log.verbose(`AutomineSequencer started`);
945
- } else if (automineSequencer) {
946
- log.warn(`AutomineSequencer created but not started`);
947
- }
948
-
949
- // Create prover node subsystem if enabled
950
- let proverNode: ProverNode | undefined;
951
- if (config.enableProverNode) {
952
- proverNode = await createProverNode(config, {
953
- ...deps.proverNodeDeps,
954
- telemetry,
955
- dateProvider,
956
- archiver,
957
- worldStateSynchronizer,
958
- p2pClient,
959
- epochCache,
960
- blobClient,
961
- keyStoreManager,
962
- });
963
-
964
- if (!options.dontStartProverNode) {
965
- await proverNode.start();
966
- started.push(proverNode);
967
- log.info(`Prover node subsystem started`);
968
- } else {
969
- log.info(`Prover node subsystem created but not started`);
970
- }
971
- }
972
-
973
- const node = new AztecNodeService(
974
- config,
975
- p2pClient,
976
- archiver,
977
- archiver,
978
- archiver,
979
- archiver,
980
- worldStateSynchronizer,
981
- sequencer,
982
- proverNode,
983
- slasherClient,
984
- validatorsSentinel,
985
- stopStartedWatchers,
986
- ethereumChain.chainInfo.id,
987
- config.rollupVersion,
988
- globalVariableBuilder,
989
- feeProvider,
990
- epochCache,
991
- packageVersion,
992
- peerProofVerifier,
993
- rpcProofVerifier,
994
- telemetry,
995
- log,
996
- blobClient,
997
- validatorClient,
998
- keyStoreManager,
999
- debugLogStore,
1000
- automineSequencer,
1001
- );
1002
-
1003
- return node;
1004
- } catch (err) {
1005
- log.error('Failed during node creation, stopping started resources', err);
1006
- for (const resource of started.reverse()) {
1007
- await tryStop(resource);
1008
- }
1009
- throw err;
1010
- }
367
+ return this.blockProvider.getCheckpoints(from, limit, options);
1011
368
  }
1012
369
 
1013
370
  /**
@@ -1065,14 +422,22 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, AztecNodeDeb
1065
422
  }
1066
423
 
1067
424
  public async getNodeInfo(): Promise<NodeInfo> {
1068
- const [nodeVersion, rollupVersion, chainId, enr, contractAddresses, protocolContractAddresses] = await Promise.all([
1069
- this.getNodeVersion(),
1070
- this.getVersion(),
1071
- this.getChainId(),
1072
- this.getEncodedEnr(),
1073
- this.getL1ContractAddresses(),
1074
- this.getProtocolContractAddresses(),
1075
- ]);
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);
1076
441
 
1077
442
  const nodeInfo: NodeInfo = {
1078
443
  nodeVersion,
@@ -1082,6 +447,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, AztecNodeDeb
1082
447
  l1ContractAddresses: contractAddresses,
1083
448
  protocolContractAddresses: protocolContractAddresses,
1084
449
  realProofs: !!this.config.realProofs,
450
+ txsLimits: { gas: { daGas: maxTxGas.daGas, l2Gas: maxTxGas.l2Gas } },
1085
451
  };
1086
452
 
1087
453
  return nodeInfo;
@@ -1097,7 +463,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, AztecNodeDeb
1097
463
  }
1098
464
 
1099
465
  public async getMaxPriorityFees(): Promise<GasFees> {
1100
- for await (const tx of this.p2pClient.iteratePendingTxs()) {
466
+ for await (const tx of this.p2pClient.iteratePendingTxs({ includeProof: false })) {
1101
467
  return tx.getGasSettings().maxPriorityFeesPerGas;
1102
468
  }
1103
469
 
@@ -1132,8 +498,17 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, AztecNodeDeb
1132
498
  return this.contractDataSource.getContractClass(id);
1133
499
  }
1134
500
 
1135
- public getContract(address: AztecAddress): Promise<ContractInstanceWithAddress | undefined> {
1136
- return this.contractDataSource.getContract(address);
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
+ );
510
+ }
511
+ return this.contractDataSource.getContract(address, blockData.header.globalVariables.timestamp);
1137
512
  }
1138
513
 
1139
514
  public getPrivateLogsByTags(query: PrivateLogsQuery): Promise<LogResult[][]> {
@@ -1176,36 +551,11 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, AztecNodeDeb
1176
551
  this.log.info(`Received tx ${txHash} in ${duration}ms`, { txHash });
1177
552
  }
1178
553
 
1179
- public async getTxReceipt(txHash: TxHash): Promise<TxReceipt> {
1180
- // Check the tx pool status first. If the tx is known to the pool (pending or mined), we'll use that
1181
- // as a fallback if we don't find a settled receipt in the archiver.
1182
- const txPoolStatus = await this.p2pClient.getTxStatus(txHash);
1183
- const isKnownToPool = txPoolStatus === 'pending' || txPoolStatus === 'mined';
1184
-
1185
- // Then get the actual tx from the archiver, which tracks every tx in a mined block.
1186
- const settledTxReceipt = await this.blockSource.getSettledTxReceipt(txHash);
1187
-
1188
- let receipt: TxReceipt;
1189
- if (settledTxReceipt) {
1190
- receipt = settledTxReceipt;
1191
- } else if (isKnownToPool) {
1192
- // If the tx is in the pool but not in the archiver, it's pending.
1193
- // This handles race conditions between archiver and p2p, where the archiver
1194
- // has pruned the block in which a tx was mined, but p2p has not caught up yet.
1195
- receipt = new TxReceipt(txHash, TxStatus.PENDING, /*executionResult=*/ undefined, /*error=*/ undefined);
1196
- } else {
1197
- // Otherwise, if we don't know the tx, we consider it dropped.
1198
- receipt = new TxReceipt(
1199
- txHash,
1200
- TxStatus.DROPPED,
1201
- /*executionResult=*/ undefined,
1202
- /*error=*/ 'Tx dropped by P2P node',
1203
- );
1204
- }
1205
-
1206
- this.debugLogStore.decorateReceiptWithLogs(txHash.toString(), receipt);
1207
-
1208
- 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);
1209
559
  }
1210
560
 
1211
561
  public getTxEffect(txHash: TxHash): Promise<IndexedTxEffect | undefined> {
@@ -1224,6 +574,10 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, AztecNodeDeb
1224
574
  await tryStop(this.automineSequencer);
1225
575
  await tryStop(this.proverNode);
1226
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]();
1227
581
  await tryStop(this.worldStateSynchronizer);
1228
582
  await tryStop(this.blockSource);
1229
583
  await tryStop(this.blobClient);
@@ -1245,234 +599,129 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, AztecNodeDeb
1245
599
  * @param after - The last known pending tx. Used for pagination
1246
600
  * @returns - The pending txs.
1247
601
  */
1248
- public getPendingTxs(limit?: number, after?: TxHash): Promise<Tx[]> {
1249
- 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);
1250
604
  }
1251
605
 
1252
606
  public getPendingTxCount(): Promise<number> {
1253
607
  return this.p2pClient!.getPendingTxCount();
1254
608
  }
1255
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
+
1256
625
  /**
1257
- * 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.
1258
628
  * @param txHash - The transaction hash to return.
629
+ * @param options - Options for the returned tx (eg whether to include its proof).
1259
630
  * @returns - The tx if it exists.
1260
631
  */
1261
- public getTxByHash(txHash: TxHash): Promise<Tx | undefined> {
1262
- 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 });
1263
634
  }
1264
635
 
1265
636
  /**
1266
- * 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.
1267
639
  * @param txHash - The transaction hash to return.
640
+ * @param options - Options for the returned txs (eg whether to include their proofs).
1268
641
  * @returns - The txs if it exists.
1269
642
  */
1270
- public async getTxsByHash(txHashes: TxHash[]): Promise<Tx[]> {
1271
- 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);
1272
646
  }
1273
647
 
1274
- public async findLeavesIndexes(
648
+ public findLeavesIndexes(
1275
649
  referenceBlock: BlockParameter,
1276
650
  treeId: MerkleTreeId,
1277
651
  leafValues: Fr[],
1278
652
  ): Promise<(DataInBlock<bigint> | undefined)[]> {
1279
- const committedDb = await this.getWorldState(referenceBlock);
1280
- const maybeIndices = await committedDb.findLeafIndices(
1281
- treeId,
1282
- leafValues.map(x => x.toBuffer()),
1283
- );
1284
- // Filter out undefined values to query block numbers only for found leaves
1285
- const definedIndices = maybeIndices.filter(x => x !== undefined);
1286
-
1287
- // Now we find the block numbers for the defined indices
1288
- const blockNumbers = await committedDb.getBlockNumbersForLeafIndices(treeId, definedIndices);
1289
-
1290
- // Build a map from leaf index to block number
1291
- const indexToBlockNumber = new Map<bigint, BlockNumber>();
1292
- for (let i = 0; i < definedIndices.length; i++) {
1293
- const blockNumber = blockNumbers[i];
1294
- if (blockNumber === undefined) {
1295
- throw new Error(
1296
- `Block number is undefined for leaf index ${definedIndices[i]} in tree ${MerkleTreeId[treeId]}`,
1297
- );
1298
- }
1299
- indexToBlockNumber.set(definedIndices[i], blockNumber);
1300
- }
1301
-
1302
- // Get unique block numbers in order to optimize num calls to getLeafValue function.
1303
- const uniqueBlockNumbers = [...new Set(indexToBlockNumber.values())];
1304
-
1305
- // Now we obtain the block hashes from the archive tree (block number = leaf index in archive tree).
1306
- const blockHashes = await Promise.all(
1307
- uniqueBlockNumbers.map(blockNumber => {
1308
- return committedDb.getLeafValue(MerkleTreeId.ARCHIVE, BigInt(blockNumber));
1309
- }),
1310
- );
1311
-
1312
- // Build a map from block number to block hash
1313
- const blockNumberToHash = new Map<BlockNumber, BlockHash>();
1314
- for (let i = 0; i < uniqueBlockNumbers.length; i++) {
1315
- const blockHash = blockHashes[i];
1316
- if (blockHash === undefined) {
1317
- throw new Error(`Block hash is undefined for block number ${uniqueBlockNumbers[i]}`);
1318
- }
1319
- blockNumberToHash.set(uniqueBlockNumbers[i], blockHash);
1320
- }
1321
-
1322
- // Create DataInBlock objects by combining indices, blockNumbers and blockHashes and return them.
1323
- return maybeIndices.map(index => {
1324
- if (index === undefined) {
1325
- return undefined;
1326
- }
1327
- const blockNumber = indexToBlockNumber.get(index);
1328
- if (blockNumber === undefined) {
1329
- throw new Error(`Block number not found for leaf index ${index} in tree ${MerkleTreeId[treeId]}`);
1330
- }
1331
- const l2BlockHash = blockNumberToHash.get(blockNumber);
1332
- if (l2BlockHash === undefined) {
1333
- throw new Error(`Block hash not found for block number ${blockNumber}`);
1334
- }
1335
- return {
1336
- l2BlockNumber: blockNumber,
1337
- l2BlockHash,
1338
- data: index,
1339
- };
1340
- });
653
+ return this.worldStateQueries.findLeavesIndexes(referenceBlock, treeId, leafValues);
1341
654
  }
1342
655
 
1343
- public async getBlockHashMembershipWitness(
656
+ public getBlockHashMembershipWitness(
1344
657
  referenceBlock: BlockParameter,
1345
658
  blockHash: BlockHash,
1346
659
  ): Promise<MembershipWitness<typeof ARCHIVE_HEIGHT> | undefined> {
1347
- // The Noir circuit checks the archive membership proof against `anchor_block_header.last_archive.root`,
1348
- // which is the archive tree root BEFORE the anchor block was added (i.e. the state after block N-1).
1349
- // So we need the world state at block N-1, not block N, to produce a sibling path matching that root.
1350
- const referenceBlockNumber = await this.resolveBlockNumber(referenceBlock);
1351
- if (referenceBlockNumber === BlockNumber.ZERO) {
1352
- // Block 0 (the initial block) has an empty archive, so no membership witness can exist.
1353
- return undefined;
1354
- }
1355
- const committedDb = await this.getWorldState(BlockNumber(referenceBlockNumber - 1));
1356
- const [pathAndIndex] = await committedDb.findSiblingPaths<MerkleTreeId.ARCHIVE>(MerkleTreeId.ARCHIVE, [blockHash]);
1357
- return pathAndIndex === undefined
1358
- ? undefined
1359
- : MembershipWitness.fromSiblingPath(pathAndIndex.index, pathAndIndex.path);
660
+ return this.worldStateQueries.getBlockHashMembershipWitness(referenceBlock, blockHash);
1360
661
  }
1361
662
 
1362
- public async getNoteHashMembershipWitness(
663
+ public getNoteHashMembershipWitness(
1363
664
  referenceBlock: BlockParameter,
1364
665
  noteHash: Fr,
1365
666
  ): Promise<MembershipWitness<typeof NOTE_HASH_TREE_HEIGHT> | undefined> {
1366
- const committedDb = await this.getWorldState(referenceBlock);
1367
- const [pathAndIndex] = await committedDb.findSiblingPaths<MerkleTreeId.NOTE_HASH_TREE>(
1368
- MerkleTreeId.NOTE_HASH_TREE,
1369
- [noteHash],
1370
- );
1371
- return pathAndIndex === undefined
1372
- ? undefined
1373
- : MembershipWitness.fromSiblingPath(pathAndIndex.index, pathAndIndex.path);
667
+ return this.worldStateQueries.getNoteHashMembershipWitness(referenceBlock, noteHash);
1374
668
  }
1375
669
 
1376
- public async getL1ToL2MessageMembershipWitness(
670
+ public getL1ToL2MessageMembershipWitness(
1377
671
  referenceBlock: BlockParameter,
1378
672
  l1ToL2Message: Fr,
1379
673
  ): Promise<[bigint, SiblingPath<typeof L1_TO_L2_MSG_TREE_HEIGHT>] | undefined> {
1380
- const db = await this.getWorldState(referenceBlock);
1381
- const [witness] = await db.findSiblingPaths(MerkleTreeId.L1_TO_L2_MESSAGE_TREE, [l1ToL2Message]);
1382
- if (!witness) {
1383
- return undefined;
1384
- }
1385
-
1386
- // REFACTOR: Return a MembershipWitness object
1387
- return [witness.index, witness.path];
674
+ return this.worldStateQueries.getL1ToL2MessageMembershipWitness(referenceBlock, l1ToL2Message);
1388
675
  }
1389
676
 
1390
- public async getL1ToL2MessageCheckpoint(l1ToL2Message: Fr): Promise<CheckpointNumber | undefined> {
1391
- const messageIndex = await this.l1ToL2MessageSource.getL1ToL2MessageIndex(l1ToL2Message);
1392
- return messageIndex !== undefined ? InboxLeaf.checkpointNumberFromIndex(messageIndex) : undefined;
677
+ public getL1ToL2MessageCheckpoint(l1ToL2Message: Fr): Promise<CheckpointNumber | undefined> {
678
+ return this.worldStateQueries.getL1ToL2MessageCheckpoint(l1ToL2Message);
1393
679
  }
1394
680
 
1395
681
  /**
1396
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
+ *
1397
686
  * @param epoch - The epoch at which to get the data.
1398
687
  * @returns The L2 to L1 messages (empty array if the epoch is not found).
1399
688
  */
1400
- public async getL2ToL1Messages(epoch: EpochNumber): Promise<Fr[][][][]> {
1401
- const blocks = await this.blockSource.getBlocks({ epoch, onlyCheckpointed: true });
1402
- const blocksInCheckpoints = chunkBy(blocks, block => block.header.globalVariables.slotNumber);
1403
- return blocksInCheckpoints.map(slotBlocks =>
1404
- slotBlocks.map(block => block.body.txEffects.map(txEffect => txEffect.l2ToL1Msgs)),
1405
- );
689
+ public getL2ToL1Messages(epoch: EpochNumber): Promise<Fr[][][][]> {
690
+ return this.worldStateQueries.getL2ToL1Messages(epoch);
1406
691
  }
1407
692
 
1408
- public async getNullifierMembershipWitness(
693
+ /**
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}.
696
+ */
697
+ public getL2ToL1MembershipWitness(
698
+ txHash: TxHash,
699
+ message: Fr,
700
+ messageIndexInTx?: number,
701
+ ): Promise<L2ToL1MembershipWitness | undefined> {
702
+ return this.worldStateQueries.getL2ToL1MembershipWitness(txHash, message, messageIndexInTx);
703
+ }
704
+
705
+ public getNullifierMembershipWitness(
1409
706
  referenceBlock: BlockParameter,
1410
707
  nullifier: Fr,
1411
708
  ): Promise<NullifierMembershipWitness | undefined> {
1412
- const db = await this.getWorldState(referenceBlock);
1413
- const [witness] = await db.findSiblingPaths(MerkleTreeId.NULLIFIER_TREE, [nullifier.toBuffer()]);
1414
- if (!witness) {
1415
- return undefined;
1416
- }
1417
-
1418
- const { index, path } = witness;
1419
- const leafPreimage = await db.getLeafPreimage(MerkleTreeId.NULLIFIER_TREE, index);
1420
- if (!leafPreimage) {
1421
- return undefined;
1422
- }
1423
-
1424
- return new NullifierMembershipWitness(index, leafPreimage as NullifierLeafPreimage, path);
709
+ return this.worldStateQueries.getNullifierMembershipWitness(referenceBlock, nullifier);
1425
710
  }
1426
711
 
1427
- public async getLowNullifierMembershipWitness(
712
+ public getLowNullifierMembershipWitness(
1428
713
  referenceBlock: BlockParameter,
1429
714
  nullifier: Fr,
1430
715
  ): Promise<NullifierMembershipWitness | undefined> {
1431
- const committedDb = await this.getWorldState(referenceBlock);
1432
- const findResult = await committedDb.getPreviousValueIndex(MerkleTreeId.NULLIFIER_TREE, nullifier.toBigInt());
1433
- if (!findResult) {
1434
- return undefined;
1435
- }
1436
- const { index, alreadyPresent } = findResult;
1437
- if (alreadyPresent) {
1438
- throw new Error(
1439
- `Cannot prove nullifier non-inclusion: nullifier ${nullifier.toBigInt()} already exists in the tree`,
1440
- );
1441
- }
1442
- const preimageData = (await committedDb.getLeafPreimage(MerkleTreeId.NULLIFIER_TREE, index))!;
1443
-
1444
- const siblingPath = await committedDb.getSiblingPath(MerkleTreeId.NULLIFIER_TREE, BigInt(index));
1445
- return new NullifierMembershipWitness(BigInt(index), preimageData as NullifierLeafPreimage, siblingPath);
716
+ return this.worldStateQueries.getLowNullifierMembershipWitness(referenceBlock, nullifier);
1446
717
  }
1447
718
 
1448
- async getPublicDataWitness(referenceBlock: BlockParameter, leafSlot: Fr): Promise<PublicDataWitness | undefined> {
1449
- const committedDb = await this.getWorldState(referenceBlock);
1450
- const lowLeafResult = await committedDb.getPreviousValueIndex(MerkleTreeId.PUBLIC_DATA_TREE, leafSlot.toBigInt());
1451
- if (!lowLeafResult) {
1452
- return undefined;
1453
- } else {
1454
- const preimage = (await committedDb.getLeafPreimage(
1455
- MerkleTreeId.PUBLIC_DATA_TREE,
1456
- lowLeafResult.index,
1457
- )) as PublicDataTreeLeafPreimage;
1458
- const path = await committedDb.getSiblingPath(MerkleTreeId.PUBLIC_DATA_TREE, lowLeafResult.index);
1459
- return new PublicDataWitness(lowLeafResult.index, preimage, path);
1460
- }
719
+ public getPublicDataWitness(referenceBlock: BlockParameter, leafSlot: Fr): Promise<PublicDataWitness | undefined> {
720
+ return this.worldStateQueries.getPublicDataWitness(referenceBlock, leafSlot);
1461
721
  }
1462
722
 
1463
- public async getPublicStorageAt(referenceBlock: BlockParameter, contract: AztecAddress, slot: Fr): Promise<Fr> {
1464
- const committedDb = await this.getWorldState(referenceBlock);
1465
- const leafSlot = await computePublicDataTreeLeafSlot(contract, slot);
1466
-
1467
- const lowLeafResult = await committedDb.getPreviousValueIndex(MerkleTreeId.PUBLIC_DATA_TREE, leafSlot.toBigInt());
1468
- if (!lowLeafResult || !lowLeafResult.alreadyPresent) {
1469
- return Fr.ZERO;
1470
- }
1471
- const preimage = (await committedDb.getLeafPreimage(
1472
- MerkleTreeId.PUBLIC_DATA_TREE,
1473
- lowLeafResult.index,
1474
- )) as PublicDataTreeLeafPreimage;
1475
- return preimage.leaf.value;
723
+ public getPublicStorageAt(referenceBlock: BlockParameter, contract: AztecAddress, slot: Fr): Promise<Fr> {
724
+ return this.worldStateQueries.getPublicStorageAt(referenceBlock, contract, slot);
1476
725
  }
1477
726
 
1478
727
  /**
@@ -1484,126 +733,12 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, AztecNodeDeb
1484
733
  @trackSpan('AztecNodeService.simulatePublicCalls', (tx: Tx) => ({
1485
734
  [Attributes.TX_HASH]: tx.getTxHash().toString(),
1486
735
  }))
1487
- public async simulatePublicCalls(
736
+ public simulatePublicCalls(
1488
737
  tx: Tx,
1489
738
  skipFeeEnforcement = false,
1490
739
  overrides?: SimulationOverrides,
1491
740
  ): Promise<PublicSimulationOutput> {
1492
- // Check total gas limit for simulation
1493
- const gasSettings = tx.data.constants.txContext.gasSettings;
1494
- const txGasLimit = gasSettings.gasLimits.l2Gas;
1495
- const teardownGasLimit = gasSettings.teardownGasLimits.l2Gas;
1496
- if (txGasLimit + teardownGasLimit > this.config.rpcSimulatePublicMaxGasLimit) {
1497
- throw new BadRequestError(
1498
- `Transaction total gas limit ${
1499
- txGasLimit + teardownGasLimit
1500
- } (${txGasLimit} + ${teardownGasLimit}) exceeds maximum gas limit ${
1501
- this.config.rpcSimulatePublicMaxGasLimit
1502
- } for simulation`,
1503
- );
1504
- }
1505
-
1506
- const txHash = tx.getTxHash();
1507
- const l2Tips = await this.blockSource.getL2Tips();
1508
- const latestBlockNumber = l2Tips.proposed.number;
1509
- const blockNumber = BlockNumber.add(latestBlockNumber, 1);
1510
-
1511
- // If sequencer is not initialized, we just set these values to zero for simulation.
1512
- const coinbase = EthAddress.ZERO;
1513
- const feeRecipient = AztecAddress.ZERO;
1514
-
1515
- const newGlobalVariables = await this.globalVariableBuilder.buildGlobalVariables(
1516
- blockNumber,
1517
- coinbase,
1518
- feeRecipient,
1519
- );
1520
-
1521
- const publicProcessorFactory = new PublicProcessorFactory(
1522
- this.contractDataSource,
1523
- new DateProvider(),
1524
- this.telemetry,
1525
- this.log.getBindings(),
1526
- );
1527
-
1528
- this.log.verbose(`Simulating public calls for tx ${txHash}`, {
1529
- globalVariables: newGlobalVariables.toInspect(),
1530
- txHash,
1531
- blockNumber,
1532
- });
1533
-
1534
- // Ensure world-state has caught up with the latest block we loaded from the archiver
1535
- await this.worldStateSynchronizer.syncImmediate(latestBlockNumber);
1536
-
1537
- // If we detect the next block would start a new checkpoint, then insert L1-to-L2 messages into
1538
- // the world state tree so simulation can take them into account. We detect if the next block would
1539
- // start a new checkpoint by checking if the proposed checkpoint's block number matches the latest block number,
1540
- // which means the next block would be the first block of the next checkpoint.
1541
- const targetCheckpoint = CheckpointNumber(
1542
- (l2Tips.proposedCheckpoint.checkpoint.number ?? CheckpointNumber.ZERO) + 1,
1543
- );
1544
- const nextCheckpointMessages: Fr[] | undefined =
1545
- l2Tips.proposedCheckpoint.block.number === l2Tips.proposed.number
1546
- ? await this.l1ToL2MessageSource.getL1ToL2Messages(targetCheckpoint).catch(err => {
1547
- if (isErrorClass(err, L1ToL2MessagesNotReadyError)) {
1548
- this.log.warn(
1549
- `L1-to-L2 messages for checkpoint ${targetCheckpoint} are not ready yet (simulating without them)`,
1550
- );
1551
- } else {
1552
- this.log.error(
1553
- `Failed to get L1-to-L2 messages for checkpoint ${targetCheckpoint} (simulating without them)`,
1554
- err,
1555
- );
1556
- }
1557
- return undefined;
1558
- })
1559
- : undefined;
1560
-
1561
- // Request a new fork of the world state at the latest block number, and apply any overrides and next checkpoint messages to it before simulation
1562
- await using merkleTreeFork = await this.worldStateSynchronizer.fork(latestBlockNumber);
1563
-
1564
- if (nextCheckpointMessages !== undefined) {
1565
- this.log.debug(
1566
- `Appending ${nextCheckpointMessages.length} L1-to-L2 messages to the world state tree for the next checkpoint`,
1567
- { checkpointNumber: l2Tips.proposedCheckpoint.checkpoint.number + 1 },
1568
- );
1569
- await appendL1ToL2MessagesToTree(merkleTreeFork, nextCheckpointMessages);
1570
- }
1571
- await applyPublicDataOverrides(merkleTreeFork, overrides?.publicStorage);
1572
-
1573
- const config = PublicSimulatorConfig.from({
1574
- skipFeeEnforcement,
1575
- collectDebugLogs: true,
1576
- collectHints: false,
1577
- collectCallMetadata: true,
1578
- collectStatistics: false,
1579
- collectionLimits: CollectionLimitsConfig.from({
1580
- maxDebugLogMemoryReads: this.config.rpcSimulatePublicMaxDebugLogMemoryReads,
1581
- }),
1582
- });
1583
-
1584
- const contractsDB = new PublicContractsDB(this.contractDataSource, this.log.getBindings());
1585
- if (overrides?.contracts) {
1586
- contractsDB.addContracts(Object.values(overrides.contracts).map(({ instance }) => instance));
1587
- }
1588
- const processor = publicProcessorFactory.create(merkleTreeFork, newGlobalVariables, config, contractsDB);
1589
-
1590
- // REFACTOR: Consider merging ProcessReturnValues into ProcessedTx
1591
- const [processedTxs, failedTxs, _usedTxs, returns, debugLogs] = await processor.process([tx]);
1592
- // REFACTOR: Consider returning the error rather than throwing
1593
- if (failedTxs.length) {
1594
- this.log.warn(`Simulated tx ${txHash} fails: ${failedTxs[0].error}`, { txHash });
1595
- throw failedTxs[0].error;
1596
- }
1597
-
1598
- const [processedTx] = processedTxs;
1599
- return new PublicSimulationOutput(
1600
- processedTx.revertReason,
1601
- processedTx.globalVariables,
1602
- processedTx.txEffect,
1603
- returns,
1604
- processedTx.gasUsed,
1605
- debugLogs,
1606
- );
741
+ return this.nodePublicCallsSimulator.simulate(tx, skipFeeEnforcement, overrides);
1607
742
  }
1608
743
 
1609
744
  public async isValidTx(
@@ -1617,6 +752,9 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, AztecNodeDeb
1617
752
  const { ts: nextSlotTimestamp } = this.epochCache.getEpochAndSlotInNextL1Slot();
1618
753
  const blockNumber = BlockNumber((await this.blockSource.getBlockNumber()) + 1);
1619
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);
1620
758
  const validator = createTxValidatorForAcceptingTxsOverRPC(
1621
759
  db,
1622
760
  this.contractDataSource,
@@ -1632,10 +770,10 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, AztecNodeDeb
1632
770
  ],
1633
771
  gasFees: await this.getCurrentMinFees(),
1634
772
  skipFeeEnforcement,
773
+ isSimulation,
1635
774
  txsPermitted: !this.config.disableTransactions,
1636
- rollupManaLimit: l1Constants.rollupManaLimit,
1637
- maxBlockL2Gas: this.config.validateMaxL2BlockGas,
1638
- maxBlockDAGas: this.config.validateMaxDABlockGas,
775
+ maxTxL2Gas: networkTxGasLimits.l2Gas,
776
+ maxTxDAGas: networkTxGasLimits.daGas,
1639
777
  },
1640
778
  this.log.getBindings(),
1641
779
  );
@@ -1979,92 +1117,33 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, AztecNodeDeb
1979
1117
  }
1980
1118
  }
1981
1119
 
1982
- /**
1983
- * Returns an instance of MerkleTreeOperations having first ensured the world state is fully synched
1984
- * @param block - The block parameter (block number, block hash, or 'latest') at which to get the data.
1985
- * @returns An instance of a committed MerkleTreeOperations
1986
- */
1987
- protected async getWorldState(block: BlockParameter) {
1988
- const query = this.normalizeBlockParameter(block);
1989
-
1990
- // When the request anchors on a specific block hash, resolve it against the archiver up front and
1991
- // drive the world-state sync to that exact block number and hash. Resolving against the archiver
1992
- // first fails fast with a clear reorg error if the hash is unknown, and passing the hash to the
1993
- // synchronizer makes the sync reorg-aware: it barriers until the archive-tree commit for that block
1994
- // has landed and verifies it matches the requested fork, instead of syncing to bare latest height
1995
- // and then racing the snapshot read below against an in-flight archive-tree write.
1996
- const requestedHash = 'hash' in query ? query.hash : undefined;
1997
- const anchorBlockNumber = requestedHash !== undefined ? await this.resolveBlockNumber(query) : undefined;
1998
-
1999
- let blockSyncedTo: BlockNumber = BlockNumber.ZERO;
2000
- try {
2001
- // Attempt to sync the world state if necessary
2002
- blockSyncedTo = await this.#syncWorldState(anchorBlockNumber, requestedHash);
2003
- } catch (err) {
2004
- this.log.error(`Error getting world state: ${err}`);
2005
- }
2006
-
2007
- if ('tag' in query && query.tag === 'proposed') {
2008
- this.log.debug(`Using committed db for latest block, world state synced upto ${blockSyncedTo}`);
2009
- return this.worldStateSynchronizer.getCommitted();
1120
+ public async prove(upToCheckpoint?: CheckpointNumber): Promise<CheckpointNumber> {
1121
+ if (!this.automineSequencer) {
1122
+ throw new BadRequestError('Cannot prove checkpoint: no automine sequencer is running');
2010
1123
  }
1124
+ return await this.automineSequencer.prove(upToCheckpoint);
1125
+ }
2011
1126
 
2012
- const blockNumber = anchorBlockNumber ?? (await this.resolveBlockNumber(query));
2013
-
2014
- // Check it's within world state sync range
2015
- if (blockNumber > blockSyncedTo) {
2016
- throw new Error(
2017
- `Queried block ${inspectBlockParameter(block)} not yet synced by the node (node is synced upto ${blockSyncedTo}).`,
2018
- );
2019
- }
2020
- this.log.debug(`Using snapshot for block ${blockNumber}, world state synced upto ${blockSyncedTo}`);
2021
-
2022
- const snapshot = this.worldStateSynchronizer.getSnapshot(blockNumber);
2023
-
2024
- // Double-check world-state synced to the same block hash as was requested.
2025
- // Block 0 is skipped: the snapshot returned by `getSnapshot(0)` is the *pre*-genesis archive
2026
- // (size 0), so leaf 0 is not yet inserted from that snapshot's view even though block 0's hash
2027
- // does live at archive index 0 in the committed tree. The genesis hash is already validated by
2028
- // the archiver when it resolves the hash query to block number 0.
2029
- if (requestedHash !== undefined && blockNumber !== BlockNumber.ZERO) {
2030
- const blockHash = await snapshot.getLeafValue(MerkleTreeId.ARCHIVE, BigInt(blockNumber));
2031
- if (!blockHash || !requestedHash.equals(blockHash)) {
2032
- throw new Error(
2033
- `Block hash ${requestedHash.toString()} not found in world state at block number ${blockNumber} (world state has ${blockHash?.toString() ?? 'no hash'} at that index, genesis header hash is ${this.blockSource.getGenesisBlockHash().toString()}). If the node API has been queried with anchor block hash possibly a reorg has occurred.`,
2034
- );
2035
- }
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');
2036
1130
  }
2037
-
2038
- return snapshot;
1131
+ await this.automineSequencer.warpTo(targetTimestamp);
2039
1132
  }
2040
1133
 
2041
- /** Resolves any {@link BlockParameter} variant to a concrete block number. */
2042
- protected async resolveBlockNumber(block: BlockParameter): Promise<BlockNumber> {
2043
- const query = this.normalizeBlockParameter(block);
2044
- const blockNumber = await this.blockSource.getBlockNumber(query);
2045
- if (blockNumber === undefined) {
2046
- if ('hash' in query) {
2047
- throw new Error(
2048
- `Block hash ${query.hash.toString()} not found when querying world state. If the node API has been queried with anchor block hash possibly a reorg has occurred.`,
2049
- );
2050
- }
2051
- if ('archive' in query) {
2052
- throw new Error(`Block with archive ${query.archive.toString()} not found.`);
2053
- }
2054
- throw new Error(`Block not found for ${inspectBlockParameter(block)}.`);
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');
2055
1137
  }
2056
- return blockNumber;
1138
+ await this.automineSequencer.warpBy(duration);
2057
1139
  }
2058
1140
 
2059
1141
  /**
2060
- * Ensure the world state is synced.
2061
- * @param targetBlockNumber - Block to sync up to. Defaults to the latest block known to the archiver.
2062
- * @param blockHash - If provided, the synchronizer verifies the block at `targetBlockNumber` matches this
2063
- * hash, resyncing (and so detecting reorgs) if it does not yet match or has been reorged away.
2064
- * @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.
2065
1145
  */
2066
- async #syncWorldState(targetBlockNumber?: BlockNumber, blockHash?: BlockHash): Promise<BlockNumber> {
2067
- const target = targetBlockNumber ?? (await this.blockSource.getBlockNumber());
2068
- return await this.worldStateSynchronizer.syncImmediate(target, blockHash);
1146
+ protected getWorldState(block: BlockParameter) {
1147
+ return this.worldStateQueries.getWorldState(block);
2069
1148
  }
2070
1149
  }