@aztec/aztec-node 0.0.1-commit.3469e52 → 0.0.1-commit.3895657bc
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.
- package/dest/aztec-node/config.d.ts +8 -5
- package/dest/aztec-node/config.d.ts.map +1 -1
- package/dest/aztec-node/config.js +11 -3
- package/dest/aztec-node/node_metrics.d.ts +1 -1
- package/dest/aztec-node/node_metrics.d.ts.map +1 -1
- package/dest/aztec-node/node_metrics.js +8 -4
- package/dest/aztec-node/server.d.ts +41 -31
- package/dest/aztec-node/server.d.ts.map +1 -1
- package/dest/aztec-node/server.js +325 -155
- package/dest/sentinel/factory.d.ts +2 -2
- package/dest/sentinel/factory.d.ts.map +1 -1
- package/dest/sentinel/factory.js +1 -1
- package/dest/sentinel/sentinel.d.ts +2 -2
- package/dest/sentinel/sentinel.d.ts.map +1 -1
- package/dest/sentinel/sentinel.js +53 -27
- package/dest/sentinel/store.d.ts +2 -2
- package/dest/sentinel/store.d.ts.map +1 -1
- package/dest/sentinel/store.js +11 -7
- package/package.json +27 -25
- package/src/aztec-node/config.ts +25 -9
- package/src/aztec-node/node_metrics.ts +12 -5
- package/src/aztec-node/server.ts +416 -218
- package/src/sentinel/factory.ts +2 -7
- package/src/sentinel/sentinel.ts +56 -23
- package/src/sentinel/store.ts +12 -12
package/src/aztec-node/server.ts
CHANGED
|
@@ -1,20 +1,15 @@
|
|
|
1
1
|
import { Archiver, createArchiver } from '@aztec/archiver';
|
|
2
2
|
import { BBCircuitVerifier, QueuedIVCVerifier, TestCircuitVerifier } from '@aztec/bb-prover';
|
|
3
3
|
import { type BlobClientInterface, createBlobClientWithFileStores } from '@aztec/blob-client/client';
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
type L1_TO_L2_MSG_TREE_HEIGHT,
|
|
7
|
-
type NOTE_HASH_TREE_HEIGHT,
|
|
8
|
-
type NULLIFIER_TREE_HEIGHT,
|
|
9
|
-
type PUBLIC_DATA_TREE_HEIGHT,
|
|
10
|
-
} from '@aztec/constants';
|
|
4
|
+
import { Blob } from '@aztec/blob-lib';
|
|
5
|
+
import { ARCHIVE_HEIGHT, type L1_TO_L2_MSG_TREE_HEIGHT, type NOTE_HASH_TREE_HEIGHT } from '@aztec/constants';
|
|
11
6
|
import { EpochCache, type EpochCacheInterface } from '@aztec/epoch-cache';
|
|
12
7
|
import { createEthereumChain } from '@aztec/ethereum/chain';
|
|
13
8
|
import { getPublicClient } from '@aztec/ethereum/client';
|
|
14
9
|
import { RegistryContract, RollupContract } from '@aztec/ethereum/contracts';
|
|
15
10
|
import type { L1ContractAddresses } from '@aztec/ethereum/l1-contract-addresses';
|
|
16
11
|
import { BlockNumber, CheckpointNumber, EpochNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
17
|
-
import { compactArray, pick } from '@aztec/foundation/collection';
|
|
12
|
+
import { compactArray, pick, unique } from '@aztec/foundation/collection';
|
|
18
13
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
19
14
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
20
15
|
import { BadRequestError } from '@aztec/foundation/json-rpc';
|
|
@@ -22,14 +17,19 @@ import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
|
22
17
|
import { count } from '@aztec/foundation/string';
|
|
23
18
|
import { DateProvider, Timer } from '@aztec/foundation/timer';
|
|
24
19
|
import { MembershipWitness, SiblingPath } from '@aztec/foundation/trees';
|
|
25
|
-
import { KeystoreManager, loadKeystores, mergeKeystores } from '@aztec/node-keystore';
|
|
20
|
+
import { type KeyStore, KeystoreManager, loadKeystores, mergeKeystores } from '@aztec/node-keystore';
|
|
26
21
|
import { trySnapshotSync, uploadSnapshot } from '@aztec/node-lib/actions';
|
|
22
|
+
import { createForwarderL1TxUtilsFromSigners, createL1TxUtilsFromSigners } from '@aztec/node-lib/factories';
|
|
27
23
|
import {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
24
|
+
type P2P,
|
|
25
|
+
type P2PClientDeps,
|
|
26
|
+
createP2PClient,
|
|
27
|
+
createTxValidatorForAcceptingTxsOverRPC,
|
|
28
|
+
getDefaultAllowedSetupFunctions,
|
|
29
|
+
} from '@aztec/p2p';
|
|
32
30
|
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
33
|
import { GlobalVariableBuilder, SequencerClient, type SequencerPublisher } from '@aztec/sequencer-client';
|
|
34
34
|
import { PublicProcessorFactory } from '@aztec/simulator/server';
|
|
35
35
|
import {
|
|
@@ -42,11 +42,11 @@ import {
|
|
|
42
42
|
import { CollectionLimitsConfig, PublicSimulatorConfig } from '@aztec/stdlib/avm';
|
|
43
43
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
44
44
|
import {
|
|
45
|
+
type BlockData,
|
|
46
|
+
BlockHash,
|
|
45
47
|
type BlockParameter,
|
|
46
|
-
type CheckpointedL2Block,
|
|
47
48
|
type DataInBlock,
|
|
48
|
-
|
|
49
|
-
L2BlockNew,
|
|
49
|
+
L2Block,
|
|
50
50
|
type L2BlockSource,
|
|
51
51
|
} from '@aztec/stdlib/block';
|
|
52
52
|
import type { PublishedCheckpoint } from '@aztec/stdlib/checkpoint';
|
|
@@ -76,9 +76,9 @@ import {
|
|
|
76
76
|
type WorldStateSynchronizer,
|
|
77
77
|
tryStop,
|
|
78
78
|
} from '@aztec/stdlib/interfaces/server';
|
|
79
|
-
import type { LogFilter, SiloedTag, Tag, TxScopedL2Log } from '@aztec/stdlib/logs';
|
|
79
|
+
import type { DebugLogStore, LogFilter, SiloedTag, Tag, TxScopedL2Log } from '@aztec/stdlib/logs';
|
|
80
|
+
import { InMemoryDebugLogStore, NullDebugLogStore } from '@aztec/stdlib/logs';
|
|
80
81
|
import { InboxLeaf, type L1ToL2MessageSource } from '@aztec/stdlib/messaging';
|
|
81
|
-
import { P2PClientType } from '@aztec/stdlib/p2p';
|
|
82
82
|
import type { Offense, SlashPayloadRound } from '@aztec/stdlib/slashing';
|
|
83
83
|
import type { NullifierLeafPreimage, PublicDataTreeLeaf, PublicDataTreeLeafPreimage } from '@aztec/stdlib/trees';
|
|
84
84
|
import { MerkleTreeId, NullifierMembershipWitness, PublicDataWitness } from '@aztec/stdlib/trees';
|
|
@@ -110,7 +110,6 @@ import {
|
|
|
110
110
|
ValidatorClient,
|
|
111
111
|
createBlockProposalHandler,
|
|
112
112
|
createValidatorClient,
|
|
113
|
-
createValidatorForAcceptingTxs,
|
|
114
113
|
} from '@aztec/validator-client';
|
|
115
114
|
import { createWorldStateSynchronizer } from '@aztec/world-state';
|
|
116
115
|
|
|
@@ -126,7 +125,7 @@ import { NodeMetrics } from './node_metrics.js';
|
|
|
126
125
|
*/
|
|
127
126
|
export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
128
127
|
private metrics: NodeMetrics;
|
|
129
|
-
private initialHeaderHashPromise: Promise<
|
|
128
|
+
private initialHeaderHashPromise: Promise<BlockHash> | undefined = undefined;
|
|
130
129
|
|
|
131
130
|
// Prevent two snapshot operations to happen simultaneously
|
|
132
131
|
private isUploadingSnapshot = false;
|
|
@@ -142,6 +141,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
142
141
|
protected readonly l1ToL2MessageSource: L1ToL2MessageSource,
|
|
143
142
|
protected readonly worldStateSynchronizer: WorldStateSynchronizer,
|
|
144
143
|
protected readonly sequencer: SequencerClient | undefined,
|
|
144
|
+
protected readonly proverNode: ProverNode | undefined,
|
|
145
145
|
protected readonly slasherClient: SlasherClientInterface | undefined,
|
|
146
146
|
protected readonly validatorsSentinel: Sentinel | undefined,
|
|
147
147
|
protected readonly epochPruneWatcher: EpochPruneWatcher | undefined,
|
|
@@ -154,12 +154,22 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
154
154
|
private telemetry: TelemetryClient = getTelemetryClient(),
|
|
155
155
|
private log = createLogger('node'),
|
|
156
156
|
private blobClient?: BlobClientInterface,
|
|
157
|
+
private validatorClient?: ValidatorClient,
|
|
158
|
+
private keyStoreManager?: KeystoreManager,
|
|
159
|
+
private debugLogStore: DebugLogStore = new NullDebugLogStore(),
|
|
157
160
|
) {
|
|
158
161
|
this.metrics = new NodeMetrics(telemetry, 'AztecNodeService');
|
|
159
162
|
this.tracer = telemetry.getTracer('AztecNodeService');
|
|
160
163
|
|
|
161
164
|
this.log.info(`Aztec Node version: ${this.packageVersion}`);
|
|
162
165
|
this.log.info(`Aztec Node started on chain 0x${l1ChainId.toString(16)}`, config.l1Contracts);
|
|
166
|
+
|
|
167
|
+
// A defensive check that protects us against introducing a bug in the complex `createAndSync` function. We must
|
|
168
|
+
// never have debugLogStore enabled when not in test mode because then we would be accumulating debug logs in
|
|
169
|
+
// memory which could be a DoS vector on the sequencer (since no fees are paid for debug logs).
|
|
170
|
+
if (debugLogStore.isEnabled && config.realProofs) {
|
|
171
|
+
throw new Error('debugLogStore should never be enabled when realProofs are set');
|
|
172
|
+
}
|
|
163
173
|
}
|
|
164
174
|
|
|
165
175
|
public async getWorldStateSyncStatus(): Promise<WorldStateSyncStatus> {
|
|
@@ -183,11 +193,13 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
183
193
|
logger?: Logger;
|
|
184
194
|
publisher?: SequencerPublisher;
|
|
185
195
|
dateProvider?: DateProvider;
|
|
186
|
-
p2pClientDeps?: P2PClientDeps
|
|
196
|
+
p2pClientDeps?: P2PClientDeps;
|
|
197
|
+
proverNodeDeps?: Partial<ProverNodeDeps>;
|
|
187
198
|
} = {},
|
|
188
199
|
options: {
|
|
189
200
|
prefilledPublicData?: PublicDataTreeLeaf[];
|
|
190
201
|
dontStartSequencer?: boolean;
|
|
202
|
+
dontStartProverNode?: boolean;
|
|
191
203
|
} = {},
|
|
192
204
|
): Promise<AztecNodeService> {
|
|
193
205
|
const config = { ...inputConfig }; // Copy the config so we dont mutate the input object
|
|
@@ -197,16 +209,29 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
197
209
|
const dateProvider = deps.dateProvider ?? new DateProvider();
|
|
198
210
|
const ethereumChain = createEthereumChain(config.l1RpcUrls, config.l1ChainId);
|
|
199
211
|
|
|
200
|
-
// Build a key store from file if given or from environment otherwise
|
|
212
|
+
// Build a key store from file if given or from environment otherwise.
|
|
213
|
+
// We keep the raw KeyStore available so we can merge with prover keys if enableProverNode is set.
|
|
201
214
|
let keyStoreManager: KeystoreManager | undefined;
|
|
202
215
|
const keyStoreProvided = config.keyStoreDirectory !== undefined && config.keyStoreDirectory.length > 0;
|
|
203
216
|
if (keyStoreProvided) {
|
|
204
217
|
const keyStores = loadKeystores(config.keyStoreDirectory!);
|
|
205
218
|
keyStoreManager = new KeystoreManager(mergeKeystores(keyStores));
|
|
206
219
|
} else {
|
|
207
|
-
const
|
|
208
|
-
|
|
209
|
-
|
|
220
|
+
const rawKeyStores: KeyStore[] = [];
|
|
221
|
+
const validatorKeyStore = createKeyStoreForValidator(config);
|
|
222
|
+
if (validatorKeyStore) {
|
|
223
|
+
rawKeyStores.push(validatorKeyStore);
|
|
224
|
+
}
|
|
225
|
+
if (config.enableProverNode) {
|
|
226
|
+
const proverKeyStore = createKeyStoreForProver(config);
|
|
227
|
+
if (proverKeyStore) {
|
|
228
|
+
rawKeyStores.push(proverKeyStore);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
if (rawKeyStores.length > 0) {
|
|
232
|
+
keyStoreManager = new KeystoreManager(
|
|
233
|
+
rawKeyStores.length === 1 ? rawKeyStores[0] : mergeKeystores(rawKeyStores),
|
|
234
|
+
);
|
|
210
235
|
}
|
|
211
236
|
}
|
|
212
237
|
|
|
@@ -217,10 +242,8 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
217
242
|
if (keyStoreManager === undefined) {
|
|
218
243
|
throw new Error('Failed to create key store, a requirement for running a validator');
|
|
219
244
|
}
|
|
220
|
-
if (!keyStoreProvided) {
|
|
221
|
-
log.warn(
|
|
222
|
-
'KEY STORE CREATED FROM ENVIRONMENT, IT IS RECOMMENDED TO USE A FILE-BASED KEY STORE IN PRODUCTION ENVIRONMENTS',
|
|
223
|
-
);
|
|
245
|
+
if (!keyStoreProvided && process.env.NODE_ENV !== 'test') {
|
|
246
|
+
log.warn("Keystore created from env: it's recommended to use a file-based key store for production");
|
|
224
247
|
}
|
|
225
248
|
ValidatorClient.validateKeyStoreConfiguration(keyStoreManager, log);
|
|
226
249
|
}
|
|
@@ -248,10 +271,11 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
248
271
|
config.l1Contracts = { ...config.l1Contracts, ...l1ContractsAddresses };
|
|
249
272
|
|
|
250
273
|
const rollupContract = new RollupContract(publicClient, config.l1Contracts.rollupAddress.toString());
|
|
251
|
-
const [l1GenesisTime, slotDuration, rollupVersionFromRollup] = await Promise.all([
|
|
274
|
+
const [l1GenesisTime, slotDuration, rollupVersionFromRollup, rollupManaLimit] = await Promise.all([
|
|
252
275
|
rollupContract.getL1GenesisTime(),
|
|
253
276
|
rollupContract.getSlotDuration(),
|
|
254
277
|
rollupContract.getVersion(),
|
|
278
|
+
rollupContract.getManaLimit().then(Number),
|
|
255
279
|
] as const);
|
|
256
280
|
|
|
257
281
|
config.rollupVersion ??= Number(rollupVersionFromRollup);
|
|
@@ -262,7 +286,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
262
286
|
);
|
|
263
287
|
}
|
|
264
288
|
|
|
265
|
-
const blobClient = await createBlobClientWithFileStores(config,
|
|
289
|
+
const blobClient = await createBlobClientWithFileStores(config, log.createChild('blob-client'));
|
|
266
290
|
|
|
267
291
|
// attempt snapshot sync if possible
|
|
268
292
|
await trySnapshotSync(config, log);
|
|
@@ -286,14 +310,28 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
286
310
|
config.realProofs || config.debugForceTxProofVerification
|
|
287
311
|
? await BBCircuitVerifier.new(config)
|
|
288
312
|
: new TestCircuitVerifier(config.proverTestVerificationDelayMs);
|
|
313
|
+
|
|
314
|
+
let debugLogStore: DebugLogStore;
|
|
289
315
|
if (!config.realProofs) {
|
|
290
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();
|
|
291
324
|
}
|
|
325
|
+
|
|
292
326
|
const proofVerifier = new QueuedIVCVerifier(config, circuitVerifier);
|
|
293
327
|
|
|
328
|
+
const proverOnly = config.enableProverNode && config.disableValidator;
|
|
329
|
+
if (proverOnly) {
|
|
330
|
+
log.info('Starting in prover-only mode: skipping validator, sequencer, sentinel, and slasher subsystems');
|
|
331
|
+
}
|
|
332
|
+
|
|
294
333
|
// create the tx pool and the p2p client, which will need the l2 block source
|
|
295
334
|
const p2pClient = await createP2PClient(
|
|
296
|
-
P2PClientType.Full,
|
|
297
335
|
config,
|
|
298
336
|
archiver,
|
|
299
337
|
proofVerifier,
|
|
@@ -305,49 +343,59 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
305
343
|
deps.p2pClientDeps,
|
|
306
344
|
);
|
|
307
345
|
|
|
308
|
-
// We
|
|
309
|
-
|
|
346
|
+
// We'll accumulate sentinel watchers here
|
|
347
|
+
const watchers: Watcher[] = [];
|
|
310
348
|
|
|
311
|
-
// Create FullNodeCheckpointsBuilder for
|
|
349
|
+
// Create FullNodeCheckpointsBuilder for block proposal handling and tx validation.
|
|
350
|
+
// Override maxTxsPerCheckpoint with the validator-specific limit if set.
|
|
312
351
|
const validatorCheckpointsBuilder = new FullNodeCheckpointsBuilder(
|
|
313
|
-
{
|
|
352
|
+
{
|
|
353
|
+
...config,
|
|
354
|
+
l1GenesisTime,
|
|
355
|
+
slotDuration: Number(slotDuration),
|
|
356
|
+
rollupManaLimit,
|
|
357
|
+
maxTxsPerCheckpoint: config.validateMaxTxsPerCheckpoint,
|
|
358
|
+
},
|
|
314
359
|
worldStateSynchronizer,
|
|
315
360
|
archiver,
|
|
316
361
|
dateProvider,
|
|
317
362
|
telemetry,
|
|
318
363
|
);
|
|
319
364
|
|
|
320
|
-
|
|
321
|
-
const watchers: Watcher[] = [];
|
|
365
|
+
let validatorClient: ValidatorClient | undefined;
|
|
322
366
|
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
367
|
+
if (!proverOnly) {
|
|
368
|
+
// Create validator client if required
|
|
369
|
+
validatorClient = await createValidatorClient(config, {
|
|
370
|
+
checkpointsBuilder: validatorCheckpointsBuilder,
|
|
371
|
+
worldState: worldStateSynchronizer,
|
|
372
|
+
p2pClient,
|
|
373
|
+
telemetry,
|
|
374
|
+
dateProvider,
|
|
375
|
+
epochCache,
|
|
376
|
+
blockSource: archiver,
|
|
377
|
+
l1ToL2MessageSource: archiver,
|
|
378
|
+
keyStoreManager,
|
|
379
|
+
blobClient,
|
|
380
|
+
});
|
|
336
381
|
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
382
|
+
// If we have a validator client, register it as a source of offenses for the slasher,
|
|
383
|
+
// and have it register callbacks on the p2p client *before* we start it, otherwise messages
|
|
384
|
+
// like attestations or auths will fail.
|
|
385
|
+
if (validatorClient) {
|
|
386
|
+
watchers.push(validatorClient);
|
|
387
|
+
if (!options.dontStartSequencer) {
|
|
388
|
+
await validatorClient.registerHandlers();
|
|
389
|
+
}
|
|
344
390
|
}
|
|
345
391
|
}
|
|
346
392
|
|
|
347
|
-
// If there's no validator client
|
|
348
|
-
//
|
|
349
|
-
|
|
350
|
-
|
|
393
|
+
// If there's no validator client, create a BlockProposalHandler to handle block proposals
|
|
394
|
+
// for monitoring or reexecution. Reexecution (default) allows us to follow the pending chain,
|
|
395
|
+
// while non-reexecution is used for validating the proposals and collecting their txs.
|
|
396
|
+
if (!validatorClient) {
|
|
397
|
+
const reexecute = !!config.alwaysReexecuteBlockProposals;
|
|
398
|
+
log.info(`Setting up block proposal handler` + (reexecute ? ' with reexecution of proposals' : ''));
|
|
351
399
|
createBlockProposalHandler(config, {
|
|
352
400
|
checkpointsBuilder: validatorCheckpointsBuilder,
|
|
353
401
|
worldState: worldStateSynchronizer,
|
|
@@ -357,7 +405,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
357
405
|
p2pClient,
|
|
358
406
|
dateProvider,
|
|
359
407
|
telemetry,
|
|
360
|
-
}).
|
|
408
|
+
}).register(p2pClient, reexecute);
|
|
361
409
|
}
|
|
362
410
|
|
|
363
411
|
// Start world state and wait for it to sync to the archiver.
|
|
@@ -366,29 +414,33 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
366
414
|
// Start p2p. Note that it depends on world state to be running.
|
|
367
415
|
await p2pClient.start();
|
|
368
416
|
|
|
369
|
-
|
|
370
|
-
if (validatorsSentinel && config.slashInactivityPenalty > 0n) {
|
|
371
|
-
watchers.push(validatorsSentinel);
|
|
372
|
-
}
|
|
373
|
-
|
|
417
|
+
let validatorsSentinel: Awaited<ReturnType<typeof createSentinel>> | undefined;
|
|
374
418
|
let epochPruneWatcher: EpochPruneWatcher | undefined;
|
|
375
|
-
if (config.slashPrunePenalty > 0n || config.slashDataWithholdingPenalty > 0n) {
|
|
376
|
-
epochPruneWatcher = new EpochPruneWatcher(
|
|
377
|
-
archiver,
|
|
378
|
-
archiver,
|
|
379
|
-
epochCache,
|
|
380
|
-
p2pClient.getTxProvider(),
|
|
381
|
-
validatorCheckpointsBuilder,
|
|
382
|
-
config,
|
|
383
|
-
);
|
|
384
|
-
watchers.push(epochPruneWatcher);
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
// We assume we want to slash for invalid attestations unless all max penalties are set to 0
|
|
388
419
|
let attestationsBlockWatcher: AttestationsBlockWatcher | undefined;
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
420
|
+
|
|
421
|
+
if (!proverOnly) {
|
|
422
|
+
validatorsSentinel = await createSentinel(epochCache, archiver, p2pClient, config);
|
|
423
|
+
if (validatorsSentinel && config.slashInactivityPenalty > 0n) {
|
|
424
|
+
watchers.push(validatorsSentinel);
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
if (config.slashPrunePenalty > 0n || config.slashDataWithholdingPenalty > 0n) {
|
|
428
|
+
epochPruneWatcher = new EpochPruneWatcher(
|
|
429
|
+
archiver,
|
|
430
|
+
archiver,
|
|
431
|
+
epochCache,
|
|
432
|
+
p2pClient.getTxProvider(),
|
|
433
|
+
validatorCheckpointsBuilder,
|
|
434
|
+
config,
|
|
435
|
+
);
|
|
436
|
+
watchers.push(epochPruneWatcher);
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
// We assume we want to slash for invalid attestations unless all max penalties are set to 0
|
|
440
|
+
if (config.slashProposeInvalidAttestationsPenalty > 0n || config.slashAttestDescendantOfInvalidPenalty > 0n) {
|
|
441
|
+
attestationsBlockWatcher = new AttestationsBlockWatcher(archiver, epochCache, config);
|
|
442
|
+
watchers.push(attestationsBlockWatcher);
|
|
443
|
+
}
|
|
392
444
|
}
|
|
393
445
|
|
|
394
446
|
// Start p2p-related services once the archiver has completed sync
|
|
@@ -425,28 +477,29 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
425
477
|
);
|
|
426
478
|
await slasherClient.start();
|
|
427
479
|
|
|
428
|
-
const l1TxUtils = config.
|
|
429
|
-
? await
|
|
480
|
+
const l1TxUtils = config.sequencerPublisherForwarderAddress
|
|
481
|
+
? await createForwarderL1TxUtilsFromSigners(
|
|
430
482
|
publicClient,
|
|
431
483
|
keyStoreManager!.createAllValidatorPublisherSigners(),
|
|
432
|
-
config.
|
|
484
|
+
config.sequencerPublisherForwarderAddress,
|
|
433
485
|
{ ...config, scope: 'sequencer' },
|
|
434
|
-
{ telemetry, logger: log.createChild('l1-tx-utils'), dateProvider },
|
|
486
|
+
{ telemetry, logger: log.createChild('l1-tx-utils'), dateProvider, kzg: Blob.getViemKzgInstance() },
|
|
435
487
|
)
|
|
436
|
-
: await
|
|
488
|
+
: await createL1TxUtilsFromSigners(
|
|
437
489
|
publicClient,
|
|
438
490
|
keyStoreManager!.createAllValidatorPublisherSigners(),
|
|
439
491
|
{ ...config, scope: 'sequencer' },
|
|
440
|
-
{ telemetry, logger: log.createChild('l1-tx-utils'), dateProvider },
|
|
492
|
+
{ telemetry, logger: log.createChild('l1-tx-utils'), dateProvider, kzg: Blob.getViemKzgInstance() },
|
|
441
493
|
);
|
|
442
494
|
|
|
443
495
|
// Create and start the sequencer client
|
|
444
496
|
const checkpointsBuilder = new CheckpointsBuilder(
|
|
445
|
-
{ ...config, l1GenesisTime, slotDuration: Number(slotDuration) },
|
|
497
|
+
{ ...config, l1GenesisTime, slotDuration: Number(slotDuration), rollupManaLimit },
|
|
446
498
|
worldStateSynchronizer,
|
|
447
499
|
archiver,
|
|
448
500
|
dateProvider,
|
|
449
501
|
telemetry,
|
|
502
|
+
debugLogStore,
|
|
450
503
|
);
|
|
451
504
|
|
|
452
505
|
sequencer = await SequencerClient.new(config, {
|
|
@@ -474,6 +527,29 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
474
527
|
log.warn(`Sequencer created but not started`);
|
|
475
528
|
}
|
|
476
529
|
|
|
530
|
+
// Create prover node subsystem if enabled
|
|
531
|
+
let proverNode: ProverNode | undefined;
|
|
532
|
+
if (config.enableProverNode) {
|
|
533
|
+
proverNode = await createProverNode(config, {
|
|
534
|
+
...deps.proverNodeDeps,
|
|
535
|
+
telemetry,
|
|
536
|
+
dateProvider,
|
|
537
|
+
archiver,
|
|
538
|
+
worldStateSynchronizer,
|
|
539
|
+
p2pClient,
|
|
540
|
+
epochCache,
|
|
541
|
+
blobClient,
|
|
542
|
+
keyStoreManager,
|
|
543
|
+
});
|
|
544
|
+
|
|
545
|
+
if (!options.dontStartProverNode) {
|
|
546
|
+
await proverNode.start();
|
|
547
|
+
log.info(`Prover node subsystem started`);
|
|
548
|
+
} else {
|
|
549
|
+
log.info(`Prover node subsystem created but not started`);
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
|
|
477
553
|
const globalVariableBuilder = new GlobalVariableBuilder({
|
|
478
554
|
...config,
|
|
479
555
|
rollupVersion: BigInt(config.rollupVersion),
|
|
@@ -481,7 +557,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
481
557
|
slotDuration: Number(slotDuration),
|
|
482
558
|
});
|
|
483
559
|
|
|
484
|
-
|
|
560
|
+
const node = new AztecNodeService(
|
|
485
561
|
config,
|
|
486
562
|
p2pClient,
|
|
487
563
|
archiver,
|
|
@@ -490,6 +566,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
490
566
|
archiver,
|
|
491
567
|
worldStateSynchronizer,
|
|
492
568
|
sequencer,
|
|
569
|
+
proverNode,
|
|
493
570
|
slasherClient,
|
|
494
571
|
validatorsSentinel,
|
|
495
572
|
epochPruneWatcher,
|
|
@@ -502,7 +579,12 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
502
579
|
telemetry,
|
|
503
580
|
log,
|
|
504
581
|
blobClient,
|
|
582
|
+
validatorClient,
|
|
583
|
+
keyStoreManager,
|
|
584
|
+
debugLogStore,
|
|
505
585
|
);
|
|
586
|
+
|
|
587
|
+
return node;
|
|
506
588
|
}
|
|
507
589
|
|
|
508
590
|
/**
|
|
@@ -513,6 +595,11 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
513
595
|
return this.sequencer;
|
|
514
596
|
}
|
|
515
597
|
|
|
598
|
+
/** Returns the prover node subsystem, if enabled. */
|
|
599
|
+
public getProverNode(): ProverNode | undefined {
|
|
600
|
+
return this.proverNode;
|
|
601
|
+
}
|
|
602
|
+
|
|
516
603
|
public getBlockSource(): L2BlockSource {
|
|
517
604
|
return this.blockSource;
|
|
518
605
|
}
|
|
@@ -538,7 +625,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
538
625
|
}
|
|
539
626
|
|
|
540
627
|
public async getAllowedPublicSetup(): Promise<AllowedElement[]> {
|
|
541
|
-
return this.config.
|
|
628
|
+
return [...(await getDefaultAllowedSetupFunctions()), ...(this.config.txPublicSetupAllowListExtend ?? [])];
|
|
542
629
|
}
|
|
543
630
|
|
|
544
631
|
/**
|
|
@@ -566,6 +653,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
566
653
|
enr,
|
|
567
654
|
l1ContractAddresses: contractAddresses,
|
|
568
655
|
protocolContractAddresses: protocolContractAddresses,
|
|
656
|
+
realProofs: !!this.config.realProofs,
|
|
569
657
|
};
|
|
570
658
|
|
|
571
659
|
return nodeInfo;
|
|
@@ -576,15 +664,15 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
576
664
|
* @param block - The block parameter (block number, block hash, or 'latest').
|
|
577
665
|
* @returns The requested block.
|
|
578
666
|
*/
|
|
579
|
-
public async getBlock(block: BlockParameter): Promise<
|
|
580
|
-
if (
|
|
581
|
-
return this.getBlockByHash(
|
|
667
|
+
public async getBlock(block: BlockParameter): Promise<L2Block | undefined> {
|
|
668
|
+
if (BlockHash.isBlockHash(block)) {
|
|
669
|
+
return this.getBlockByHash(block);
|
|
582
670
|
}
|
|
583
671
|
const blockNumber = block === 'latest' ? await this.getBlockNumber() : (block as BlockNumber);
|
|
584
672
|
if (blockNumber === BlockNumber.ZERO) {
|
|
585
673
|
return this.buildInitialBlock();
|
|
586
674
|
}
|
|
587
|
-
return await this.blockSource.
|
|
675
|
+
return await this.blockSource.getL2Block(blockNumber);
|
|
588
676
|
}
|
|
589
677
|
|
|
590
678
|
/**
|
|
@@ -592,17 +680,17 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
592
680
|
* @param blockHash - The block hash being requested.
|
|
593
681
|
* @returns The requested block.
|
|
594
682
|
*/
|
|
595
|
-
public async getBlockByHash(blockHash:
|
|
683
|
+
public async getBlockByHash(blockHash: BlockHash): Promise<L2Block | undefined> {
|
|
596
684
|
const initialBlockHash = await this.#getInitialHeaderHash();
|
|
597
|
-
if (blockHash.equals(
|
|
685
|
+
if (blockHash.equals(initialBlockHash)) {
|
|
598
686
|
return this.buildInitialBlock();
|
|
599
687
|
}
|
|
600
|
-
return await this.blockSource.
|
|
688
|
+
return await this.blockSource.getL2BlockByHash(blockHash);
|
|
601
689
|
}
|
|
602
690
|
|
|
603
|
-
private buildInitialBlock():
|
|
691
|
+
private buildInitialBlock(): L2Block {
|
|
604
692
|
const initialHeader = this.worldStateSynchronizer.getCommitted().getInitialHeader();
|
|
605
|
-
return
|
|
693
|
+
return L2Block.empty(initialHeader);
|
|
606
694
|
}
|
|
607
695
|
|
|
608
696
|
/**
|
|
@@ -610,8 +698,8 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
610
698
|
* @param archive - The archive root being requested.
|
|
611
699
|
* @returns The requested block.
|
|
612
700
|
*/
|
|
613
|
-
public async getBlockByArchive(archive: Fr): Promise<
|
|
614
|
-
return await this.blockSource.
|
|
701
|
+
public async getBlockByArchive(archive: Fr): Promise<L2Block | undefined> {
|
|
702
|
+
return await this.blockSource.getL2BlockByArchive(archive);
|
|
615
703
|
}
|
|
616
704
|
|
|
617
705
|
/**
|
|
@@ -620,24 +708,16 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
620
708
|
* @param limit - The maximum number of blocks to obtain.
|
|
621
709
|
* @returns The blocks requested.
|
|
622
710
|
*/
|
|
623
|
-
public async getBlocks(from: BlockNumber, limit: number): Promise<
|
|
624
|
-
return (await this.blockSource.
|
|
625
|
-
}
|
|
626
|
-
|
|
627
|
-
public async getPublishedBlocks(from: BlockNumber, limit: number): Promise<CheckpointedL2Block[]> {
|
|
628
|
-
return (await this.blockSource.getPublishedBlocks(from, limit)) ?? [];
|
|
629
|
-
}
|
|
630
|
-
|
|
631
|
-
public async getPublishedCheckpoints(from: CheckpointNumber, limit: number): Promise<PublishedCheckpoint[]> {
|
|
632
|
-
return (await this.blockSource.getPublishedCheckpoints(from, limit)) ?? [];
|
|
711
|
+
public async getBlocks(from: BlockNumber, limit: number): Promise<L2Block[]> {
|
|
712
|
+
return (await this.blockSource.getBlocks(from, BlockNumber(limit))) ?? [];
|
|
633
713
|
}
|
|
634
714
|
|
|
635
|
-
public async
|
|
636
|
-
return (await this.blockSource.
|
|
715
|
+
public async getCheckpoints(from: CheckpointNumber, limit: number): Promise<PublishedCheckpoint[]> {
|
|
716
|
+
return (await this.blockSource.getCheckpoints(from, limit)) ?? [];
|
|
637
717
|
}
|
|
638
718
|
|
|
639
|
-
public async getCheckpointedBlocks(from: BlockNumber, limit: number
|
|
640
|
-
return (await this.blockSource.getCheckpointedBlocks(from, limit
|
|
719
|
+
public async getCheckpointedBlocks(from: BlockNumber, limit: number) {
|
|
720
|
+
return (await this.blockSource.getCheckpointedBlocks(from, limit)) ?? [];
|
|
641
721
|
}
|
|
642
722
|
|
|
643
723
|
/**
|
|
@@ -668,6 +748,14 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
668
748
|
return await this.blockSource.getProvenBlockNumber();
|
|
669
749
|
}
|
|
670
750
|
|
|
751
|
+
public async getCheckpointedBlockNumber(): Promise<BlockNumber> {
|
|
752
|
+
return await this.blockSource.getCheckpointedL2BlockNumber();
|
|
753
|
+
}
|
|
754
|
+
|
|
755
|
+
public getCheckpointNumber(): Promise<CheckpointNumber> {
|
|
756
|
+
return this.blockSource.getCheckpointNumber();
|
|
757
|
+
}
|
|
758
|
+
|
|
671
759
|
/**
|
|
672
760
|
* Method to fetch the version of the package.
|
|
673
761
|
* @returns The node package version
|
|
@@ -700,15 +788,42 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
700
788
|
return this.contractDataSource.getContract(address);
|
|
701
789
|
}
|
|
702
790
|
|
|
703
|
-
public getPrivateLogsByTags(
|
|
791
|
+
public async getPrivateLogsByTags(
|
|
792
|
+
tags: SiloedTag[],
|
|
793
|
+
page?: number,
|
|
794
|
+
referenceBlock?: BlockHash,
|
|
795
|
+
): Promise<TxScopedL2Log[][]> {
|
|
796
|
+
if (referenceBlock) {
|
|
797
|
+
const initialBlockHash = await this.#getInitialHeaderHash();
|
|
798
|
+
if (!referenceBlock.equals(initialBlockHash)) {
|
|
799
|
+
const header = await this.blockSource.getBlockHeaderByHash(referenceBlock);
|
|
800
|
+
if (!header) {
|
|
801
|
+
throw new Error(
|
|
802
|
+
`Block ${referenceBlock.toString()} not found in the node. This might indicate a reorg has occurred.`,
|
|
803
|
+
);
|
|
804
|
+
}
|
|
805
|
+
}
|
|
806
|
+
}
|
|
704
807
|
return this.logsSource.getPrivateLogsByTags(tags, page);
|
|
705
808
|
}
|
|
706
809
|
|
|
707
|
-
public getPublicLogsByTagsFromContract(
|
|
810
|
+
public async getPublicLogsByTagsFromContract(
|
|
708
811
|
contractAddress: AztecAddress,
|
|
709
812
|
tags: Tag[],
|
|
710
813
|
page?: number,
|
|
814
|
+
referenceBlock?: BlockHash,
|
|
711
815
|
): Promise<TxScopedL2Log[][]> {
|
|
816
|
+
if (referenceBlock) {
|
|
817
|
+
const initialBlockHash = await this.#getInitialHeaderHash();
|
|
818
|
+
if (!referenceBlock.equals(initialBlockHash)) {
|
|
819
|
+
const header = await this.blockSource.getBlockHeaderByHash(referenceBlock);
|
|
820
|
+
if (!header) {
|
|
821
|
+
throw new Error(
|
|
822
|
+
`Block ${referenceBlock.toString()} not found in the node. This might indicate a reorg has occurred.`,
|
|
823
|
+
);
|
|
824
|
+
}
|
|
825
|
+
}
|
|
826
|
+
}
|
|
712
827
|
return this.logsSource.getPublicLogsByTagsFromContract(contractAddress, tags, page);
|
|
713
828
|
}
|
|
714
829
|
|
|
@@ -751,26 +866,36 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
751
866
|
}
|
|
752
867
|
|
|
753
868
|
await this.p2pClient!.sendTx(tx);
|
|
754
|
-
|
|
755
|
-
this.
|
|
869
|
+
const duration = timer.ms();
|
|
870
|
+
this.metrics.receivedTx(duration, true);
|
|
871
|
+
this.log.info(`Received tx ${txHash} in ${duration}ms`, { txHash });
|
|
756
872
|
}
|
|
757
873
|
|
|
758
874
|
public async getTxReceipt(txHash: TxHash): Promise<TxReceipt> {
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
// and we would incorrectly return a TxReceipt with status DROPPED
|
|
764
|
-
if ((await this.p2pClient.getTxStatus(txHash)) === 'pending') {
|
|
765
|
-
txReceipt = new TxReceipt(txHash, TxStatus.PENDING, '');
|
|
766
|
-
}
|
|
875
|
+
// Check the tx pool status first. If the tx is known to the pool (pending or mined), we'll use that
|
|
876
|
+
// as a fallback if we don't find a settled receipt in the archiver.
|
|
877
|
+
const txPoolStatus = await this.p2pClient.getTxStatus(txHash);
|
|
878
|
+
const isKnownToPool = txPoolStatus === 'pending' || txPoolStatus === 'mined';
|
|
767
879
|
|
|
880
|
+
// Then get the actual tx from the archiver, which tracks every tx in a mined block.
|
|
768
881
|
const settledTxReceipt = await this.blockSource.getSettledTxReceipt(txHash);
|
|
882
|
+
|
|
883
|
+
let receipt: TxReceipt;
|
|
769
884
|
if (settledTxReceipt) {
|
|
770
|
-
|
|
885
|
+
receipt = settledTxReceipt;
|
|
886
|
+
} else if (isKnownToPool) {
|
|
887
|
+
// If the tx is in the pool but not in the archiver, it's pending.
|
|
888
|
+
// This handles race conditions between archiver and p2p, where the archiver
|
|
889
|
+
// has pruned the block in which a tx was mined, but p2p has not caught up yet.
|
|
890
|
+
receipt = new TxReceipt(txHash, TxStatus.PENDING, undefined, undefined);
|
|
891
|
+
} else {
|
|
892
|
+
// Otherwise, if we don't know the tx, we consider it dropped.
|
|
893
|
+
receipt = new TxReceipt(txHash, TxStatus.DROPPED, undefined, 'Tx dropped by P2P node');
|
|
771
894
|
}
|
|
772
895
|
|
|
773
|
-
|
|
896
|
+
this.debugLogStore.decorateReceiptWithLogs(txHash.toString(), receipt);
|
|
897
|
+
|
|
898
|
+
return receipt;
|
|
774
899
|
}
|
|
775
900
|
|
|
776
901
|
public getTxEffect(txHash: TxHash): Promise<IndexedTxEffect | undefined> {
|
|
@@ -787,6 +912,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
787
912
|
await tryStop(this.slasherClient);
|
|
788
913
|
await tryStop(this.proofVerifier);
|
|
789
914
|
await tryStop(this.sequencer);
|
|
915
|
+
await tryStop(this.proverNode);
|
|
790
916
|
await tryStop(this.p2pClient);
|
|
791
917
|
await tryStop(this.worldStateSynchronizer);
|
|
792
918
|
await tryStop(this.blockSource);
|
|
@@ -836,11 +962,11 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
836
962
|
}
|
|
837
963
|
|
|
838
964
|
public async findLeavesIndexes(
|
|
839
|
-
|
|
965
|
+
referenceBlock: BlockParameter,
|
|
840
966
|
treeId: MerkleTreeId,
|
|
841
967
|
leafValues: Fr[],
|
|
842
968
|
): Promise<(DataInBlock<bigint> | undefined)[]> {
|
|
843
|
-
const committedDb = await this.#getWorldState(
|
|
969
|
+
const committedDb = await this.#getWorldState(referenceBlock);
|
|
844
970
|
const maybeIndices = await committedDb.findLeafIndices(
|
|
845
971
|
treeId,
|
|
846
972
|
leafValues.map(x => x.toBuffer()),
|
|
@@ -892,44 +1018,28 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
892
1018
|
}
|
|
893
1019
|
return {
|
|
894
1020
|
l2BlockNumber: BlockNumber(Number(blockNumber)),
|
|
895
|
-
l2BlockHash:
|
|
1021
|
+
l2BlockHash: new BlockHash(blockHash),
|
|
896
1022
|
data: index,
|
|
897
1023
|
};
|
|
898
1024
|
});
|
|
899
1025
|
}
|
|
900
1026
|
|
|
901
|
-
public async
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
): Promise<SiblingPath<typeof NULLIFIER_TREE_HEIGHT>> {
|
|
905
|
-
const committedDb = await this.#getWorldState(block);
|
|
906
|
-
return committedDb.getSiblingPath(MerkleTreeId.NULLIFIER_TREE, leafIndex);
|
|
907
|
-
}
|
|
908
|
-
|
|
909
|
-
public async getNoteHashSiblingPath(
|
|
910
|
-
block: BlockParameter,
|
|
911
|
-
leafIndex: bigint,
|
|
912
|
-
): Promise<SiblingPath<typeof NOTE_HASH_TREE_HEIGHT>> {
|
|
913
|
-
const committedDb = await this.#getWorldState(block);
|
|
914
|
-
return committedDb.getSiblingPath(MerkleTreeId.NOTE_HASH_TREE, leafIndex);
|
|
915
|
-
}
|
|
916
|
-
|
|
917
|
-
public async getArchiveMembershipWitness(
|
|
918
|
-
block: BlockParameter,
|
|
919
|
-
archive: Fr,
|
|
1027
|
+
public async getBlockHashMembershipWitness(
|
|
1028
|
+
referenceBlock: BlockParameter,
|
|
1029
|
+
blockHash: BlockHash,
|
|
920
1030
|
): Promise<MembershipWitness<typeof ARCHIVE_HEIGHT> | undefined> {
|
|
921
|
-
const committedDb = await this.#getWorldState(
|
|
922
|
-
const [pathAndIndex] = await committedDb.findSiblingPaths<MerkleTreeId.ARCHIVE>(MerkleTreeId.ARCHIVE, [
|
|
1031
|
+
const committedDb = await this.#getWorldState(referenceBlock);
|
|
1032
|
+
const [pathAndIndex] = await committedDb.findSiblingPaths<MerkleTreeId.ARCHIVE>(MerkleTreeId.ARCHIVE, [blockHash]);
|
|
923
1033
|
return pathAndIndex === undefined
|
|
924
1034
|
? undefined
|
|
925
1035
|
: MembershipWitness.fromSiblingPath(pathAndIndex.index, pathAndIndex.path);
|
|
926
1036
|
}
|
|
927
1037
|
|
|
928
1038
|
public async getNoteHashMembershipWitness(
|
|
929
|
-
|
|
1039
|
+
referenceBlock: BlockParameter,
|
|
930
1040
|
noteHash: Fr,
|
|
931
1041
|
): Promise<MembershipWitness<typeof NOTE_HASH_TREE_HEIGHT> | undefined> {
|
|
932
|
-
const committedDb = await this.#getWorldState(
|
|
1042
|
+
const committedDb = await this.#getWorldState(referenceBlock);
|
|
933
1043
|
const [pathAndIndex] = await committedDb.findSiblingPaths<MerkleTreeId.NOTE_HASH_TREE>(
|
|
934
1044
|
MerkleTreeId.NOTE_HASH_TREE,
|
|
935
1045
|
[noteHash],
|
|
@@ -940,10 +1050,10 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
940
1050
|
}
|
|
941
1051
|
|
|
942
1052
|
public async getL1ToL2MessageMembershipWitness(
|
|
943
|
-
|
|
1053
|
+
referenceBlock: BlockParameter,
|
|
944
1054
|
l1ToL2Message: Fr,
|
|
945
1055
|
): Promise<[bigint, SiblingPath<typeof L1_TO_L2_MSG_TREE_HEIGHT>] | undefined> {
|
|
946
|
-
const db = await this.#getWorldState(
|
|
1056
|
+
const db = await this.#getWorldState(referenceBlock);
|
|
947
1057
|
const [witness] = await db.findSiblingPaths(MerkleTreeId.L1_TO_L2_MESSAGE_TREE, [l1ToL2Message]);
|
|
948
1058
|
if (!witness) {
|
|
949
1059
|
return undefined;
|
|
@@ -953,11 +1063,9 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
953
1063
|
return [witness.index, witness.path];
|
|
954
1064
|
}
|
|
955
1065
|
|
|
956
|
-
public async
|
|
1066
|
+
public async getL1ToL2MessageCheckpoint(l1ToL2Message: Fr): Promise<CheckpointNumber | undefined> {
|
|
957
1067
|
const messageIndex = await this.l1ToL2MessageSource.getL1ToL2MessageIndex(l1ToL2Message);
|
|
958
|
-
return messageIndex
|
|
959
|
-
? BlockNumber.fromCheckpointNumber(InboxLeaf.checkpointNumberFromIndex(messageIndex))
|
|
960
|
-
: undefined;
|
|
1068
|
+
return messageIndex ? InboxLeaf.checkpointNumberFromIndex(messageIndex) : undefined;
|
|
961
1069
|
}
|
|
962
1070
|
|
|
963
1071
|
/**
|
|
@@ -976,12 +1084,13 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
976
1084
|
* @returns The L2 to L1 messages (empty array if the epoch is not found).
|
|
977
1085
|
*/
|
|
978
1086
|
public async getL2ToL1Messages(epoch: EpochNumber): Promise<Fr[][][][]> {
|
|
979
|
-
// Assumes `
|
|
980
|
-
const
|
|
981
|
-
const blocksInCheckpoints:
|
|
1087
|
+
// Assumes `getCheckpointedBlocksForEpoch` returns blocks in ascending order of block number.
|
|
1088
|
+
const checkpointedBlocks = await this.blockSource.getCheckpointedBlocksForEpoch(epoch);
|
|
1089
|
+
const blocksInCheckpoints: L2Block[][] = [];
|
|
982
1090
|
let previousSlotNumber = SlotNumber.ZERO;
|
|
983
1091
|
let checkpointIndex = -1;
|
|
984
|
-
for (const
|
|
1092
|
+
for (const checkpointedBlock of checkpointedBlocks) {
|
|
1093
|
+
const block = checkpointedBlock.block;
|
|
985
1094
|
const slotNumber = block.header.globalVariables.slotNumber;
|
|
986
1095
|
if (slotNumber !== previousSlotNumber) {
|
|
987
1096
|
checkpointIndex++;
|
|
@@ -995,27 +1104,11 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
995
1104
|
);
|
|
996
1105
|
}
|
|
997
1106
|
|
|
998
|
-
public async getArchiveSiblingPath(
|
|
999
|
-
block: BlockParameter,
|
|
1000
|
-
leafIndex: bigint,
|
|
1001
|
-
): Promise<SiblingPath<typeof ARCHIVE_HEIGHT>> {
|
|
1002
|
-
const committedDb = await this.#getWorldState(block);
|
|
1003
|
-
return committedDb.getSiblingPath(MerkleTreeId.ARCHIVE, leafIndex);
|
|
1004
|
-
}
|
|
1005
|
-
|
|
1006
|
-
public async getPublicDataSiblingPath(
|
|
1007
|
-
block: BlockParameter,
|
|
1008
|
-
leafIndex: bigint,
|
|
1009
|
-
): Promise<SiblingPath<typeof PUBLIC_DATA_TREE_HEIGHT>> {
|
|
1010
|
-
const committedDb = await this.#getWorldState(block);
|
|
1011
|
-
return committedDb.getSiblingPath(MerkleTreeId.PUBLIC_DATA_TREE, leafIndex);
|
|
1012
|
-
}
|
|
1013
|
-
|
|
1014
1107
|
public async getNullifierMembershipWitness(
|
|
1015
|
-
|
|
1108
|
+
referenceBlock: BlockParameter,
|
|
1016
1109
|
nullifier: Fr,
|
|
1017
1110
|
): Promise<NullifierMembershipWitness | undefined> {
|
|
1018
|
-
const db = await this.#getWorldState(
|
|
1111
|
+
const db = await this.#getWorldState(referenceBlock);
|
|
1019
1112
|
const [witness] = await db.findSiblingPaths(MerkleTreeId.NULLIFIER_TREE, [nullifier.toBuffer()]);
|
|
1020
1113
|
if (!witness) {
|
|
1021
1114
|
return undefined;
|
|
@@ -1032,7 +1125,8 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1032
1125
|
|
|
1033
1126
|
/**
|
|
1034
1127
|
* Returns a low nullifier membership witness for a given nullifier at a given block.
|
|
1035
|
-
* @param
|
|
1128
|
+
* @param referenceBlock - The block parameter (block number, block hash, or 'latest') at which to get the data
|
|
1129
|
+
* (which contains the root of the nullifier tree in which we are searching for the nullifier).
|
|
1036
1130
|
* @param nullifier - Nullifier we try to find the low nullifier witness for.
|
|
1037
1131
|
* @returns The low nullifier membership witness (if found).
|
|
1038
1132
|
* @remarks Low nullifier witness can be used to perform a nullifier non-inclusion proof by leveraging the "linked
|
|
@@ -1045,10 +1139,10 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1045
1139
|
* TODO: This is a confusing behavior and we should eventually address that.
|
|
1046
1140
|
*/
|
|
1047
1141
|
public async getLowNullifierMembershipWitness(
|
|
1048
|
-
|
|
1142
|
+
referenceBlock: BlockParameter,
|
|
1049
1143
|
nullifier: Fr,
|
|
1050
1144
|
): Promise<NullifierMembershipWitness | undefined> {
|
|
1051
|
-
const committedDb = await this.#getWorldState(
|
|
1145
|
+
const committedDb = await this.#getWorldState(referenceBlock);
|
|
1052
1146
|
const findResult = await committedDb.getPreviousValueIndex(MerkleTreeId.NULLIFIER_TREE, nullifier.toBigInt());
|
|
1053
1147
|
if (!findResult) {
|
|
1054
1148
|
return undefined;
|
|
@@ -1063,8 +1157,8 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1063
1157
|
return new NullifierMembershipWitness(BigInt(index), preimageData as NullifierLeafPreimage, siblingPath);
|
|
1064
1158
|
}
|
|
1065
1159
|
|
|
1066
|
-
async getPublicDataWitness(
|
|
1067
|
-
const committedDb = await this.#getWorldState(
|
|
1160
|
+
async getPublicDataWitness(referenceBlock: BlockParameter, leafSlot: Fr): Promise<PublicDataWitness | undefined> {
|
|
1161
|
+
const committedDb = await this.#getWorldState(referenceBlock);
|
|
1068
1162
|
const lowLeafResult = await committedDb.getPreviousValueIndex(MerkleTreeId.PUBLIC_DATA_TREE, leafSlot.toBigInt());
|
|
1069
1163
|
if (!lowLeafResult) {
|
|
1070
1164
|
return undefined;
|
|
@@ -1078,8 +1172,8 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1078
1172
|
}
|
|
1079
1173
|
}
|
|
1080
1174
|
|
|
1081
|
-
public async getPublicStorageAt(
|
|
1082
|
-
const committedDb = await this.#getWorldState(
|
|
1175
|
+
public async getPublicStorageAt(referenceBlock: BlockParameter, contract: AztecAddress, slot: Fr): Promise<Fr> {
|
|
1176
|
+
const committedDb = await this.#getWorldState(referenceBlock);
|
|
1083
1177
|
const leafSlot = await computePublicDataTreeLeafSlot(contract, slot);
|
|
1084
1178
|
|
|
1085
1179
|
const lowLeafResult = await committedDb.getPreviousValueIndex(MerkleTreeId.PUBLIC_DATA_TREE, leafSlot.toBigInt());
|
|
@@ -1094,14 +1188,13 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1094
1188
|
}
|
|
1095
1189
|
|
|
1096
1190
|
public async getBlockHeader(block: BlockParameter = 'latest'): Promise<BlockHeader | undefined> {
|
|
1097
|
-
if (
|
|
1191
|
+
if (BlockHash.isBlockHash(block)) {
|
|
1098
1192
|
const initialBlockHash = await this.#getInitialHeaderHash();
|
|
1099
1193
|
if (block.equals(initialBlockHash)) {
|
|
1100
1194
|
// Block source doesn't handle initial header so we need to handle the case separately.
|
|
1101
1195
|
return this.worldStateSynchronizer.getCommitted().getInitialHeader();
|
|
1102
1196
|
}
|
|
1103
|
-
|
|
1104
|
-
return this.blockSource.getBlockHeaderByHash(blockHashFr);
|
|
1197
|
+
return this.blockSource.getBlockHeaderByHash(block);
|
|
1105
1198
|
} else {
|
|
1106
1199
|
// Block source doesn't handle initial header so we need to handle the case separately.
|
|
1107
1200
|
const blockNumber = block === 'latest' ? await this.getBlockNumber() : (block as BlockNumber);
|
|
@@ -1121,6 +1214,14 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1121
1214
|
return await this.blockSource.getBlockHeaderByArchive(archive);
|
|
1122
1215
|
}
|
|
1123
1216
|
|
|
1217
|
+
public getBlockData(number: BlockNumber): Promise<BlockData | undefined> {
|
|
1218
|
+
return this.blockSource.getBlockData(number);
|
|
1219
|
+
}
|
|
1220
|
+
|
|
1221
|
+
public getBlockDataByArchive(archive: Fr): Promise<BlockData | undefined> {
|
|
1222
|
+
return this.blockSource.getBlockDataByArchive(archive);
|
|
1223
|
+
}
|
|
1224
|
+
|
|
1124
1225
|
/**
|
|
1125
1226
|
* Simulates the public part of a transaction with the current state.
|
|
1126
1227
|
* @param tx - The transaction to simulate.
|
|
@@ -1144,7 +1245,8 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1144
1245
|
}
|
|
1145
1246
|
|
|
1146
1247
|
const txHash = tx.getTxHash();
|
|
1147
|
-
const
|
|
1248
|
+
const latestBlockNumber = await this.blockSource.getBlockNumber();
|
|
1249
|
+
const blockNumber = BlockNumber.add(latestBlockNumber, 1);
|
|
1148
1250
|
|
|
1149
1251
|
// If sequencer is not initialized, we just set these values to zero for simulation.
|
|
1150
1252
|
const coinbase = EthAddress.ZERO;
|
|
@@ -1159,6 +1261,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1159
1261
|
this.contractDataSource,
|
|
1160
1262
|
new DateProvider(),
|
|
1161
1263
|
this.telemetry,
|
|
1264
|
+
this.log.getBindings(),
|
|
1162
1265
|
);
|
|
1163
1266
|
|
|
1164
1267
|
this.log.verbose(`Simulating public calls for tx ${txHash}`, {
|
|
@@ -1167,6 +1270,8 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1167
1270
|
blockNumber,
|
|
1168
1271
|
});
|
|
1169
1272
|
|
|
1273
|
+
// Ensure world-state has caught up with the latest block we loaded from the archiver
|
|
1274
|
+
await this.worldStateSynchronizer.syncImmediate(latestBlockNumber);
|
|
1170
1275
|
const merkleTreeFork = await this.worldStateSynchronizer.fork();
|
|
1171
1276
|
try {
|
|
1172
1277
|
const config = PublicSimulatorConfig.from({
|
|
@@ -1182,7 +1287,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1182
1287
|
const processor = publicProcessorFactory.create(merkleTreeFork, newGlobalVariables, config);
|
|
1183
1288
|
|
|
1184
1289
|
// REFACTOR: Consider merging ProcessReturnValues into ProcessedTx
|
|
1185
|
-
const [processedTxs, failedTxs, _usedTxs, returns] = await processor.process([tx]);
|
|
1290
|
+
const [processedTxs, failedTxs, _usedTxs, returns, debugLogs] = await processor.process([tx]);
|
|
1186
1291
|
// REFACTOR: Consider returning the error rather than throwing
|
|
1187
1292
|
if (failedTxs.length) {
|
|
1188
1293
|
this.log.warn(`Simulated tx ${txHash} fails: ${failedTxs[0].error}`, { txHash });
|
|
@@ -1196,6 +1301,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1196
1301
|
processedTx.txEffect,
|
|
1197
1302
|
returns,
|
|
1198
1303
|
processedTx.gasUsed,
|
|
1304
|
+
debugLogs,
|
|
1199
1305
|
);
|
|
1200
1306
|
} finally {
|
|
1201
1307
|
await merkleTreeFork.close();
|
|
@@ -1209,19 +1315,28 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1209
1315
|
const db = this.worldStateSynchronizer.getCommitted();
|
|
1210
1316
|
const verifier = isSimulation ? undefined : this.proofVerifier;
|
|
1211
1317
|
|
|
1212
|
-
// We accept transactions if they are not expired by the next slot (checked based on the
|
|
1318
|
+
// We accept transactions if they are not expired by the next slot (checked based on the ExpirationTimestamp field)
|
|
1213
1319
|
const { ts: nextSlotTimestamp } = this.epochCache.getEpochAndSlotInNextL1Slot();
|
|
1214
1320
|
const blockNumber = BlockNumber((await this.blockSource.getBlockNumber()) + 1);
|
|
1215
|
-
const validator =
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1321
|
+
const validator = createTxValidatorForAcceptingTxsOverRPC(
|
|
1322
|
+
db,
|
|
1323
|
+
this.contractDataSource,
|
|
1324
|
+
verifier,
|
|
1325
|
+
{
|
|
1326
|
+
timestamp: nextSlotTimestamp,
|
|
1327
|
+
blockNumber,
|
|
1328
|
+
l1ChainId: this.l1ChainId,
|
|
1329
|
+
rollupVersion: this.version,
|
|
1330
|
+
setupAllowList: [
|
|
1331
|
+
...(await getDefaultAllowedSetupFunctions()),
|
|
1332
|
+
...(this.config.txPublicSetupAllowListExtend ?? []),
|
|
1333
|
+
],
|
|
1334
|
+
gasFees: await this.getCurrentMinFees(),
|
|
1335
|
+
skipFeeEnforcement,
|
|
1336
|
+
txsPermitted: !this.config.disableTransactions,
|
|
1337
|
+
},
|
|
1338
|
+
this.log.getBindings(),
|
|
1339
|
+
);
|
|
1225
1340
|
|
|
1226
1341
|
return await validator.validateTx(tx);
|
|
1227
1342
|
}
|
|
@@ -1385,13 +1500,97 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1385
1500
|
}
|
|
1386
1501
|
}
|
|
1387
1502
|
|
|
1388
|
-
|
|
1503
|
+
public async reloadKeystore(): Promise<void> {
|
|
1504
|
+
if (!this.config.keyStoreDirectory?.length) {
|
|
1505
|
+
throw new BadRequestError(
|
|
1506
|
+
'Cannot reload keystore: node is not using a file-based keystore. ' +
|
|
1507
|
+
'Set KEY_STORE_DIRECTORY to use file-based keystores.',
|
|
1508
|
+
);
|
|
1509
|
+
}
|
|
1510
|
+
if (!this.validatorClient) {
|
|
1511
|
+
throw new BadRequestError('Cannot reload keystore: validator is not enabled.');
|
|
1512
|
+
}
|
|
1513
|
+
|
|
1514
|
+
this.log.info('Reloading keystore from disk');
|
|
1515
|
+
|
|
1516
|
+
// Re-read and validate keystore files
|
|
1517
|
+
const keyStores = loadKeystores(this.config.keyStoreDirectory);
|
|
1518
|
+
const newManager = new KeystoreManager(mergeKeystores(keyStores));
|
|
1519
|
+
await newManager.validateSigners();
|
|
1520
|
+
ValidatorClient.validateKeyStoreConfiguration(newManager, this.log);
|
|
1521
|
+
|
|
1522
|
+
// Validate that every validator's publisher keys overlap with the L1 signers
|
|
1523
|
+
// that were initialized at startup. Publishers cannot be hot-reloaded, so a
|
|
1524
|
+
// validator with a publisher key that doesn't match any existing L1 signer
|
|
1525
|
+
// would silently fail on every proposer slot.
|
|
1526
|
+
if (this.keyStoreManager && this.sequencer) {
|
|
1527
|
+
const oldAdapter = NodeKeystoreAdapter.fromKeyStoreManager(this.keyStoreManager);
|
|
1528
|
+
const availablePublishers = new Set(
|
|
1529
|
+
oldAdapter
|
|
1530
|
+
.getAttesterAddresses()
|
|
1531
|
+
.flatMap(a => oldAdapter.getPublisherAddresses(a).map(p => p.toString().toLowerCase())),
|
|
1532
|
+
);
|
|
1533
|
+
|
|
1534
|
+
const newAdapter = NodeKeystoreAdapter.fromKeyStoreManager(newManager);
|
|
1535
|
+
for (const attester of newAdapter.getAttesterAddresses()) {
|
|
1536
|
+
const pubs = newAdapter.getPublisherAddresses(attester);
|
|
1537
|
+
if (pubs.length > 0 && !pubs.some(p => availablePublishers.has(p.toString().toLowerCase()))) {
|
|
1538
|
+
throw new BadRequestError(
|
|
1539
|
+
`Cannot reload keystore: validator ${attester} has publisher keys ` +
|
|
1540
|
+
`[${pubs.map(p => p.toString()).join(', ')}] but none match the L1 signers initialized at startup ` +
|
|
1541
|
+
`[${[...availablePublishers].join(', ')}]. Publishers cannot be hot-reloaded — ` +
|
|
1542
|
+
`use an existing publisher key or restart the node.`,
|
|
1543
|
+
);
|
|
1544
|
+
}
|
|
1545
|
+
}
|
|
1546
|
+
}
|
|
1547
|
+
|
|
1548
|
+
// Build adapters for old and new keystores to compute diff
|
|
1549
|
+
const newAdapter = NodeKeystoreAdapter.fromKeyStoreManager(newManager);
|
|
1550
|
+
const newAddresses = newAdapter.getAttesterAddresses();
|
|
1551
|
+
const oldAddresses = this.keyStoreManager
|
|
1552
|
+
? NodeKeystoreAdapter.fromKeyStoreManager(this.keyStoreManager).getAttesterAddresses()
|
|
1553
|
+
: [];
|
|
1554
|
+
|
|
1555
|
+
const oldSet = new Set(oldAddresses.map(a => a.toString()));
|
|
1556
|
+
const newSet = new Set(newAddresses.map(a => a.toString()));
|
|
1557
|
+
const added = newAddresses.filter(a => !oldSet.has(a.toString()));
|
|
1558
|
+
const removed = oldAddresses.filter(a => !newSet.has(a.toString()));
|
|
1559
|
+
|
|
1560
|
+
if (added.length > 0) {
|
|
1561
|
+
this.log.info(`Keystore reload: adding attester keys: ${added.map(a => a.toString()).join(', ')}`);
|
|
1562
|
+
}
|
|
1563
|
+
if (removed.length > 0) {
|
|
1564
|
+
this.log.info(`Keystore reload: removing attester keys: ${removed.map(a => a.toString()).join(', ')}`);
|
|
1565
|
+
}
|
|
1566
|
+
if (added.length === 0 && removed.length === 0) {
|
|
1567
|
+
this.log.info('Keystore reload: attester keys unchanged');
|
|
1568
|
+
}
|
|
1569
|
+
|
|
1570
|
+
// Update the validator client (coinbase, feeRecipient, attester keys)
|
|
1571
|
+
this.validatorClient.reloadKeystore(newManager);
|
|
1572
|
+
|
|
1573
|
+
// Update the publisher factory's keystore so newly-added validators
|
|
1574
|
+
// can be matched to existing publisher keys when proposing blocks.
|
|
1575
|
+
if (this.sequencer) {
|
|
1576
|
+
this.sequencer.updatePublisherNodeKeyStore(newAdapter);
|
|
1577
|
+
}
|
|
1578
|
+
|
|
1579
|
+
// Update slasher's "don't-slash-self" list with new validator addresses
|
|
1580
|
+
if (this.slasherClient && !this.config.slashSelfAllowed) {
|
|
1581
|
+
const slashValidatorsNever = unique(
|
|
1582
|
+
[...(this.config.slashValidatorsNever ?? []), ...newAddresses].map(a => a.toString()),
|
|
1583
|
+
).map(EthAddress.fromString);
|
|
1584
|
+
this.slasherClient.updateConfig({ slashValidatorsNever });
|
|
1585
|
+
}
|
|
1586
|
+
|
|
1587
|
+
this.keyStoreManager = newManager;
|
|
1588
|
+
this.log.info('Keystore reloaded: coinbase, feeRecipient, and attester keys updated');
|
|
1589
|
+
}
|
|
1590
|
+
|
|
1591
|
+
#getInitialHeaderHash(): Promise<BlockHash> {
|
|
1389
1592
|
if (!this.initialHeaderHashPromise) {
|
|
1390
|
-
this.initialHeaderHashPromise = this.worldStateSynchronizer
|
|
1391
|
-
.getCommitted()
|
|
1392
|
-
.getInitialHeader()
|
|
1393
|
-
.hash()
|
|
1394
|
-
.then(hash => L2BlockHash.fromField(hash));
|
|
1593
|
+
this.initialHeaderHashPromise = this.worldStateSynchronizer.getCommitted().getInitialHeader().hash();
|
|
1395
1594
|
}
|
|
1396
1595
|
return this.initialHeaderHashPromise;
|
|
1397
1596
|
}
|
|
@@ -1415,15 +1614,14 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1415
1614
|
return this.worldStateSynchronizer.getCommitted();
|
|
1416
1615
|
}
|
|
1417
1616
|
|
|
1418
|
-
if (
|
|
1617
|
+
if (BlockHash.isBlockHash(block)) {
|
|
1419
1618
|
const initialBlockHash = await this.#getInitialHeaderHash();
|
|
1420
1619
|
if (block.equals(initialBlockHash)) {
|
|
1421
1620
|
// Block source doesn't handle initial header so we need to handle the case separately.
|
|
1422
1621
|
return this.worldStateSynchronizer.getSnapshot(BlockNumber.ZERO);
|
|
1423
1622
|
}
|
|
1424
1623
|
|
|
1425
|
-
const
|
|
1426
|
-
const header = await this.blockSource.getBlockHeaderByHash(blockHashFr);
|
|
1624
|
+
const header = await this.blockSource.getBlockHeaderByHash(block);
|
|
1427
1625
|
if (!header) {
|
|
1428
1626
|
throw new Error(
|
|
1429
1627
|
`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.`,
|