@aztec/aztec-node 0.0.1-commit.c949de6bc → 0.0.1-commit.cbf2c2d5d
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 +2 -2
- package/dest/aztec-node/config.d.ts.map +1 -1
- package/dest/aztec-node/config.js +1 -1
- package/dest/aztec-node/server.d.ts +19 -19
- package/dest/aztec-node/server.d.ts.map +1 -1
- package/dest/aztec-node/server.js +212 -128
- package/dest/sentinel/factory.d.ts +2 -2
- package/dest/sentinel/factory.d.ts.map +1 -1
- package/dest/sentinel/sentinel.js +8 -8
- package/package.json +26 -27
- package/src/aztec-node/config.ts +1 -1
- package/src/aztec-node/server.ts +212 -126
- package/src/sentinel/factory.ts +1 -1
- package/src/sentinel/sentinel.ts +8 -8
package/src/aztec-node/server.ts
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import { Archiver, createArchiver } from '@aztec/archiver';
|
|
2
|
-
import { BBCircuitVerifier,
|
|
2
|
+
import { BBCircuitVerifier, BatchChonkVerifier, QueuedIVCVerifier } from '@aztec/bb-prover';
|
|
3
|
+
import { TestCircuitVerifier } from '@aztec/bb-prover/test';
|
|
3
4
|
import { type BlobClientInterface, createBlobClientWithFileStores } from '@aztec/blob-client/client';
|
|
4
5
|
import { Blob } from '@aztec/blob-lib';
|
|
5
6
|
import { ARCHIVE_HEIGHT, type L1_TO_L2_MSG_TREE_HEIGHT, type NOTE_HASH_TREE_HEIGHT } from '@aztec/constants';
|
|
6
7
|
import { EpochCache, type EpochCacheInterface } from '@aztec/epoch-cache';
|
|
7
8
|
import { createEthereumChain } from '@aztec/ethereum/chain';
|
|
8
|
-
import { getPublicClient } from '@aztec/ethereum/client';
|
|
9
|
+
import { getPublicClient, makeL1HttpTransport } from '@aztec/ethereum/client';
|
|
9
10
|
import { RegistryContract, RollupContract } from '@aztec/ethereum/contracts';
|
|
10
11
|
import type { L1ContractAddresses } from '@aztec/ethereum/l1-contract-addresses';
|
|
12
|
+
import type { L1TxUtils } from '@aztec/ethereum/l1-tx-utils';
|
|
11
13
|
import { BlockNumber, CheckpointNumber, EpochNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
12
|
-
import { compactArray, pick, unique } from '@aztec/foundation/collection';
|
|
14
|
+
import { chunkBy, compactArray, pick, unique } from '@aztec/foundation/collection';
|
|
13
15
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
14
16
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
15
17
|
import { BadRequestError } from '@aztec/foundation/json-rpc';
|
|
@@ -111,9 +113,10 @@ import {
|
|
|
111
113
|
createBlockProposalHandler,
|
|
112
114
|
createValidatorClient,
|
|
113
115
|
} from '@aztec/validator-client';
|
|
116
|
+
import type { SlashingProtectionDatabase } from '@aztec/validator-ha-signer/types';
|
|
114
117
|
import { createWorldStateSynchronizer } from '@aztec/world-state';
|
|
115
118
|
|
|
116
|
-
import { createPublicClient
|
|
119
|
+
import { createPublicClient } from 'viem';
|
|
117
120
|
|
|
118
121
|
import { createSentinel } from '../sentinel/factory.js';
|
|
119
122
|
import { Sentinel } from '../sentinel/sentinel.js';
|
|
@@ -150,7 +153,8 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
150
153
|
protected readonly globalVariableBuilder: GlobalVariableBuilderInterface,
|
|
151
154
|
protected readonly epochCache: EpochCacheInterface,
|
|
152
155
|
protected readonly packageVersion: string,
|
|
153
|
-
private
|
|
156
|
+
private peerProofVerifier: ClientProtocolCircuitVerifier,
|
|
157
|
+
private rpcProofVerifier: ClientProtocolCircuitVerifier,
|
|
154
158
|
private telemetry: TelemetryClient = getTelemetryClient(),
|
|
155
159
|
private log = createLogger('node'),
|
|
156
160
|
private blobClient?: BlobClientInterface,
|
|
@@ -172,6 +176,11 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
172
176
|
}
|
|
173
177
|
}
|
|
174
178
|
|
|
179
|
+
/** @internal Exposed for testing — returns the RPC proof verifier. */
|
|
180
|
+
public getProofVerifier(): ClientProtocolCircuitVerifier {
|
|
181
|
+
return this.rpcProofVerifier;
|
|
182
|
+
}
|
|
183
|
+
|
|
175
184
|
public async getWorldStateSyncStatus(): Promise<WorldStateSyncStatus> {
|
|
176
185
|
const status = await this.worldStateSynchronizer.status();
|
|
177
186
|
return status.syncSummary;
|
|
@@ -195,6 +204,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
195
204
|
dateProvider?: DateProvider;
|
|
196
205
|
p2pClientDeps?: P2PClientDeps;
|
|
197
206
|
proverNodeDeps?: Partial<ProverNodeDeps>;
|
|
207
|
+
slashingProtectionDb?: SlashingProtectionDatabase;
|
|
198
208
|
} = {},
|
|
199
209
|
options: {
|
|
200
210
|
prefilledPublicData?: PublicDataTreeLeaf[];
|
|
@@ -257,7 +267,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
257
267
|
|
|
258
268
|
const publicClient = createPublicClient({
|
|
259
269
|
chain: ethereumChain.chainInfo,
|
|
260
|
-
transport:
|
|
270
|
+
transport: makeL1HttpTransport(config.l1RpcUrls, { timeout: config.l1HttpTimeoutMS }),
|
|
261
271
|
pollingInterval: config.viemPollingIntervalMS,
|
|
262
272
|
});
|
|
263
273
|
|
|
@@ -271,10 +281,11 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
271
281
|
config.l1Contracts = { ...config.l1Contracts, ...l1ContractsAddresses };
|
|
272
282
|
|
|
273
283
|
const rollupContract = new RollupContract(publicClient, config.l1Contracts.rollupAddress.toString());
|
|
274
|
-
const [l1GenesisTime, slotDuration, rollupVersionFromRollup] = await Promise.all([
|
|
284
|
+
const [l1GenesisTime, slotDuration, rollupVersionFromRollup, rollupManaLimit] = await Promise.all([
|
|
275
285
|
rollupContract.getL1GenesisTime(),
|
|
276
286
|
rollupContract.getSlotDuration(),
|
|
277
287
|
rollupContract.getVersion(),
|
|
288
|
+
rollupContract.getManaLimit().then(Number),
|
|
278
289
|
] as const);
|
|
279
290
|
|
|
280
291
|
config.rollupVersion ??= Number(rollupVersionFromRollup);
|
|
@@ -305,10 +316,17 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
305
316
|
options.prefilledPublicData,
|
|
306
317
|
telemetry,
|
|
307
318
|
);
|
|
308
|
-
const
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
319
|
+
const useRealVerifiers = config.realProofs || config.debugForceTxProofVerification;
|
|
320
|
+
let peerProofVerifier: ClientProtocolCircuitVerifier;
|
|
321
|
+
let rpcProofVerifier: ClientProtocolCircuitVerifier;
|
|
322
|
+
if (useRealVerifiers) {
|
|
323
|
+
peerProofVerifier = await BatchChonkVerifier.new(config, config.bbChonkVerifyMaxBatch, 'peer');
|
|
324
|
+
const rpcVerifier = await BBCircuitVerifier.new(config);
|
|
325
|
+
rpcProofVerifier = new QueuedIVCVerifier(rpcVerifier, config.numConcurrentIVCVerifiers);
|
|
326
|
+
} else {
|
|
327
|
+
peerProofVerifier = new TestCircuitVerifier(config.proverTestVerificationDelayMs);
|
|
328
|
+
rpcProofVerifier = new TestCircuitVerifier(config.proverTestVerificationDelayMs);
|
|
329
|
+
}
|
|
312
330
|
|
|
313
331
|
let debugLogStore: DebugLogStore;
|
|
314
332
|
if (!config.realProofs) {
|
|
@@ -322,8 +340,6 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
322
340
|
debugLogStore = new NullDebugLogStore();
|
|
323
341
|
}
|
|
324
342
|
|
|
325
|
-
const proofVerifier = new QueuedIVCVerifier(config, circuitVerifier);
|
|
326
|
-
|
|
327
343
|
const proverOnly = config.enableProverNode && config.disableValidator;
|
|
328
344
|
if (proverOnly) {
|
|
329
345
|
log.info('Starting in prover-only mode: skipping validator, sequencer, sentinel, and slasher subsystems');
|
|
@@ -333,7 +349,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
333
349
|
const p2pClient = await createP2PClient(
|
|
334
350
|
config,
|
|
335
351
|
archiver,
|
|
336
|
-
|
|
352
|
+
peerProofVerifier,
|
|
337
353
|
worldStateSynchronizer,
|
|
338
354
|
epochCache,
|
|
339
355
|
packageVersion,
|
|
@@ -342,15 +358,19 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
342
358
|
deps.p2pClientDeps,
|
|
343
359
|
);
|
|
344
360
|
|
|
345
|
-
// We should really not be modifying the config object
|
|
346
|
-
config.txPublicSetupAllowList = config.txPublicSetupAllowList ?? (await getDefaultAllowedSetupFunctions());
|
|
347
|
-
|
|
348
361
|
// We'll accumulate sentinel watchers here
|
|
349
362
|
const watchers: Watcher[] = [];
|
|
350
363
|
|
|
351
|
-
// Create FullNodeCheckpointsBuilder for block proposal handling and tx validation
|
|
364
|
+
// Create FullNodeCheckpointsBuilder for block proposal handling and tx validation.
|
|
365
|
+
// Override maxTxsPerCheckpoint with the validator-specific limit if set.
|
|
352
366
|
const validatorCheckpointsBuilder = new FullNodeCheckpointsBuilder(
|
|
353
|
-
{
|
|
367
|
+
{
|
|
368
|
+
...config,
|
|
369
|
+
l1GenesisTime,
|
|
370
|
+
slotDuration: Number(slotDuration),
|
|
371
|
+
rollupManaLimit,
|
|
372
|
+
maxTxsPerCheckpoint: config.validateMaxTxsPerCheckpoint,
|
|
373
|
+
},
|
|
354
374
|
worldStateSynchronizer,
|
|
355
375
|
archiver,
|
|
356
376
|
dateProvider,
|
|
@@ -372,6 +392,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
372
392
|
l1ToL2MessageSource: archiver,
|
|
373
393
|
keyStoreManager,
|
|
374
394
|
blobClient,
|
|
395
|
+
slashingProtectionDb: deps.slashingProtectionDb,
|
|
375
396
|
});
|
|
376
397
|
|
|
377
398
|
// If we have a validator client, register it as a source of offenses for the slasher,
|
|
@@ -383,22 +404,24 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
383
404
|
await validatorClient.registerHandlers();
|
|
384
405
|
}
|
|
385
406
|
}
|
|
407
|
+
}
|
|
386
408
|
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
409
|
+
// If there's no validator client, create a BlockProposalHandler to handle block proposals
|
|
410
|
+
// for monitoring or reexecution. Reexecution (default) allows us to follow the pending chain,
|
|
411
|
+
// while non-reexecution is used for validating the proposals and collecting their txs.
|
|
412
|
+
if (!validatorClient) {
|
|
413
|
+
const reexecute = !!config.alwaysReexecuteBlockProposals;
|
|
414
|
+
log.info(`Setting up block proposal handler` + (reexecute ? ' with reexecution of proposals' : ''));
|
|
415
|
+
createBlockProposalHandler(config, {
|
|
416
|
+
checkpointsBuilder: validatorCheckpointsBuilder,
|
|
417
|
+
worldState: worldStateSynchronizer,
|
|
418
|
+
epochCache,
|
|
419
|
+
blockSource: archiver,
|
|
420
|
+
l1ToL2MessageSource: archiver,
|
|
421
|
+
p2pClient,
|
|
422
|
+
dateProvider,
|
|
423
|
+
telemetry,
|
|
424
|
+
}).register(p2pClient, reexecute);
|
|
402
425
|
}
|
|
403
426
|
|
|
404
427
|
// Start world state and wait for it to sync to the archiver.
|
|
@@ -448,6 +471,14 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
448
471
|
})
|
|
449
472
|
.catch(err => log.error('Failed to start p2p services after archiver sync', err));
|
|
450
473
|
|
|
474
|
+
const globalVariableBuilder = new GlobalVariableBuilder(dateProvider, publicClient, {
|
|
475
|
+
l1Contracts: config.l1Contracts,
|
|
476
|
+
ethereumSlotDuration: config.ethereumSlotDuration,
|
|
477
|
+
rollupVersion: BigInt(config.rollupVersion),
|
|
478
|
+
l1GenesisTime,
|
|
479
|
+
slotDuration: Number(slotDuration),
|
|
480
|
+
});
|
|
481
|
+
|
|
451
482
|
// Validator enabled, create/start relevant service
|
|
452
483
|
let sequencer: SequencerClient | undefined;
|
|
453
484
|
let slasherClient: SlasherClientInterface | undefined;
|
|
@@ -485,9 +516,22 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
485
516
|
{ telemetry, logger: log.createChild('l1-tx-utils'), dateProvider, kzg: Blob.getViemKzgInstance() },
|
|
486
517
|
);
|
|
487
518
|
|
|
519
|
+
// Create a funder L1TxUtils from the keystore funding account (if configured)
|
|
520
|
+
const fundingSigner = keyStoreManager?.createFundingSigner();
|
|
521
|
+
let funderL1TxUtils: L1TxUtils | undefined;
|
|
522
|
+
if (fundingSigner) {
|
|
523
|
+
const [funder] = await createL1TxUtilsFromSigners(
|
|
524
|
+
publicClient,
|
|
525
|
+
[fundingSigner],
|
|
526
|
+
{ ...config, scope: 'sequencer' },
|
|
527
|
+
{ telemetry, logger: log.createChild('l1-tx-utils:funder'), dateProvider },
|
|
528
|
+
);
|
|
529
|
+
funderL1TxUtils = funder;
|
|
530
|
+
}
|
|
531
|
+
|
|
488
532
|
// Create and start the sequencer client
|
|
489
533
|
const checkpointsBuilder = new CheckpointsBuilder(
|
|
490
|
-
{ ...config, l1GenesisTime, slotDuration: Number(slotDuration) },
|
|
534
|
+
{ ...config, l1GenesisTime, slotDuration: Number(slotDuration), rollupManaLimit },
|
|
491
535
|
worldStateSynchronizer,
|
|
492
536
|
archiver,
|
|
493
537
|
dateProvider,
|
|
@@ -499,6 +543,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
499
543
|
...deps,
|
|
500
544
|
epochCache,
|
|
501
545
|
l1TxUtils,
|
|
546
|
+
funderL1TxUtils,
|
|
502
547
|
validatorClient,
|
|
503
548
|
p2pClient,
|
|
504
549
|
worldStateSynchronizer,
|
|
@@ -510,6 +555,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
510
555
|
dateProvider,
|
|
511
556
|
blobClient,
|
|
512
557
|
nodeKeyStore: keyStoreManager!,
|
|
558
|
+
globalVariableBuilder,
|
|
513
559
|
});
|
|
514
560
|
}
|
|
515
561
|
|
|
@@ -543,13 +589,6 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
543
589
|
}
|
|
544
590
|
}
|
|
545
591
|
|
|
546
|
-
const globalVariableBuilder = new GlobalVariableBuilder({
|
|
547
|
-
...config,
|
|
548
|
-
rollupVersion: BigInt(config.rollupVersion),
|
|
549
|
-
l1GenesisTime,
|
|
550
|
-
slotDuration: Number(slotDuration),
|
|
551
|
-
});
|
|
552
|
-
|
|
553
592
|
const node = new AztecNodeService(
|
|
554
593
|
config,
|
|
555
594
|
p2pClient,
|
|
@@ -568,7 +607,8 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
568
607
|
globalVariableBuilder,
|
|
569
608
|
epochCache,
|
|
570
609
|
packageVersion,
|
|
571
|
-
|
|
610
|
+
peerProofVerifier,
|
|
611
|
+
rpcProofVerifier,
|
|
572
612
|
telemetry,
|
|
573
613
|
log,
|
|
574
614
|
blobClient,
|
|
@@ -618,7 +658,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
618
658
|
}
|
|
619
659
|
|
|
620
660
|
public async getAllowedPublicSetup(): Promise<AllowedElement[]> {
|
|
621
|
-
return this.config.
|
|
661
|
+
return [...(await getDefaultAllowedSetupFunctions()), ...(this.config.txPublicSetupAllowListExtend ?? [])];
|
|
622
662
|
}
|
|
623
663
|
|
|
624
664
|
/**
|
|
@@ -713,6 +753,10 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
713
753
|
return (await this.blockSource.getCheckpointedBlocks(from, limit)) ?? [];
|
|
714
754
|
}
|
|
715
755
|
|
|
756
|
+
public getCheckpointsDataForEpoch(epochNumber: EpochNumber) {
|
|
757
|
+
return this.blockSource.getCheckpointsDataForEpoch(epochNumber);
|
|
758
|
+
}
|
|
759
|
+
|
|
716
760
|
/**
|
|
717
761
|
* Method to fetch the current min L2 fees.
|
|
718
762
|
* @returns The current min L2 fees.
|
|
@@ -745,6 +789,10 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
745
789
|
return await this.blockSource.getCheckpointedL2BlockNumber();
|
|
746
790
|
}
|
|
747
791
|
|
|
792
|
+
public getCheckpointNumber(): Promise<CheckpointNumber> {
|
|
793
|
+
return this.blockSource.getCheckpointNumber();
|
|
794
|
+
}
|
|
795
|
+
|
|
748
796
|
/**
|
|
749
797
|
* Method to fetch the version of the package.
|
|
750
798
|
* @returns The node package version
|
|
@@ -782,18 +830,22 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
782
830
|
page?: number,
|
|
783
831
|
referenceBlock?: BlockHash,
|
|
784
832
|
): Promise<TxScopedL2Log[][]> {
|
|
833
|
+
let upToBlockNumber: BlockNumber | undefined;
|
|
785
834
|
if (referenceBlock) {
|
|
786
835
|
const initialBlockHash = await this.#getInitialHeaderHash();
|
|
787
|
-
if (
|
|
836
|
+
if (referenceBlock.equals(initialBlockHash)) {
|
|
837
|
+
upToBlockNumber = BlockNumber(0);
|
|
838
|
+
} else {
|
|
788
839
|
const header = await this.blockSource.getBlockHeaderByHash(referenceBlock);
|
|
789
840
|
if (!header) {
|
|
790
841
|
throw new Error(
|
|
791
842
|
`Block ${referenceBlock.toString()} not found in the node. This might indicate a reorg has occurred.`,
|
|
792
843
|
);
|
|
793
844
|
}
|
|
845
|
+
upToBlockNumber = header.globalVariables.blockNumber;
|
|
794
846
|
}
|
|
795
847
|
}
|
|
796
|
-
return this.logsSource.getPrivateLogsByTags(tags, page);
|
|
848
|
+
return this.logsSource.getPrivateLogsByTags(tags, page, upToBlockNumber);
|
|
797
849
|
}
|
|
798
850
|
|
|
799
851
|
public async getPublicLogsByTagsFromContract(
|
|
@@ -802,18 +854,22 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
802
854
|
page?: number,
|
|
803
855
|
referenceBlock?: BlockHash,
|
|
804
856
|
): Promise<TxScopedL2Log[][]> {
|
|
857
|
+
let upToBlockNumber: BlockNumber | undefined;
|
|
805
858
|
if (referenceBlock) {
|
|
806
859
|
const initialBlockHash = await this.#getInitialHeaderHash();
|
|
807
|
-
if (
|
|
860
|
+
if (referenceBlock.equals(initialBlockHash)) {
|
|
861
|
+
upToBlockNumber = BlockNumber(0);
|
|
862
|
+
} else {
|
|
808
863
|
const header = await this.blockSource.getBlockHeaderByHash(referenceBlock);
|
|
809
864
|
if (!header) {
|
|
810
865
|
throw new Error(
|
|
811
866
|
`Block ${referenceBlock.toString()} not found in the node. This might indicate a reorg has occurred.`,
|
|
812
867
|
);
|
|
813
868
|
}
|
|
869
|
+
upToBlockNumber = header.globalVariables.blockNumber;
|
|
814
870
|
}
|
|
815
871
|
}
|
|
816
|
-
return this.logsSource.getPublicLogsByTagsFromContract(contractAddress, tags, page);
|
|
872
|
+
return this.logsSource.getPublicLogsByTagsFromContract(contractAddress, tags, page, upToBlockNumber);
|
|
817
873
|
}
|
|
818
874
|
|
|
819
875
|
/**
|
|
@@ -899,7 +955,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
899
955
|
await tryStop(this.validatorsSentinel);
|
|
900
956
|
await tryStop(this.epochPruneWatcher);
|
|
901
957
|
await tryStop(this.slasherClient);
|
|
902
|
-
await tryStop(this.
|
|
958
|
+
await Promise.all([tryStop(this.peerProofVerifier), tryStop(this.rpcProofVerifier)]);
|
|
903
959
|
await tryStop(this.sequencer);
|
|
904
960
|
await tryStop(this.proverNode);
|
|
905
961
|
await tryStop(this.p2pClient);
|
|
@@ -955,58 +1011,64 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
955
1011
|
treeId: MerkleTreeId,
|
|
956
1012
|
leafValues: Fr[],
|
|
957
1013
|
): Promise<(DataInBlock<bigint> | undefined)[]> {
|
|
958
|
-
const committedDb = await this
|
|
1014
|
+
const committedDb = await this.getWorldState(referenceBlock);
|
|
959
1015
|
const maybeIndices = await committedDb.findLeafIndices(
|
|
960
1016
|
treeId,
|
|
961
1017
|
leafValues.map(x => x.toBuffer()),
|
|
962
1018
|
);
|
|
963
|
-
//
|
|
964
|
-
const
|
|
1019
|
+
// Filter out undefined values to query block numbers only for found leaves
|
|
1020
|
+
const definedIndices = maybeIndices.filter(x => x !== undefined);
|
|
965
1021
|
|
|
966
|
-
// Now we find the block numbers for the indices
|
|
967
|
-
const blockNumbers = await committedDb.getBlockNumbersForLeafIndices(treeId,
|
|
1022
|
+
// Now we find the block numbers for the defined indices
|
|
1023
|
+
const blockNumbers = await committedDb.getBlockNumbersForLeafIndices(treeId, definedIndices);
|
|
968
1024
|
|
|
969
|
-
//
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
1025
|
+
// Build a map from leaf index to block number
|
|
1026
|
+
const indexToBlockNumber = new Map<bigint, BlockNumber>();
|
|
1027
|
+
for (let i = 0; i < definedIndices.length; i++) {
|
|
1028
|
+
const blockNumber = blockNumbers[i];
|
|
1029
|
+
if (blockNumber === undefined) {
|
|
1030
|
+
throw new Error(
|
|
1031
|
+
`Block number is undefined for leaf index ${definedIndices[i]} in tree ${MerkleTreeId[treeId]}`,
|
|
1032
|
+
);
|
|
973
1033
|
}
|
|
1034
|
+
indexToBlockNumber.set(definedIndices[i], blockNumber);
|
|
974
1035
|
}
|
|
975
1036
|
|
|
976
1037
|
// Get unique block numbers in order to optimize num calls to getLeafValue function.
|
|
977
|
-
const uniqueBlockNumbers = [...new Set(
|
|
1038
|
+
const uniqueBlockNumbers = [...new Set(indexToBlockNumber.values())];
|
|
978
1039
|
|
|
979
|
-
// Now we obtain the block hashes from the archive tree
|
|
980
|
-
// (note that block number corresponds to the leaf index in the archive tree).
|
|
1040
|
+
// Now we obtain the block hashes from the archive tree (block number = leaf index in archive tree).
|
|
981
1041
|
const blockHashes = await Promise.all(
|
|
982
1042
|
uniqueBlockNumbers.map(blockNumber => {
|
|
983
1043
|
return committedDb.getLeafValue(MerkleTreeId.ARCHIVE, BigInt(blockNumber));
|
|
984
1044
|
}),
|
|
985
1045
|
);
|
|
986
1046
|
|
|
987
|
-
//
|
|
1047
|
+
// Build a map from block number to block hash
|
|
1048
|
+
const blockNumberToHash = new Map<BlockNumber, Fr>();
|
|
988
1049
|
for (let i = 0; i < uniqueBlockNumbers.length; i++) {
|
|
989
|
-
|
|
1050
|
+
const blockHash = blockHashes[i];
|
|
1051
|
+
if (blockHash === undefined) {
|
|
990
1052
|
throw new Error(`Block hash is undefined for block number ${uniqueBlockNumbers[i]}`);
|
|
991
1053
|
}
|
|
1054
|
+
blockNumberToHash.set(uniqueBlockNumbers[i], blockHash);
|
|
992
1055
|
}
|
|
993
1056
|
|
|
994
1057
|
// Create DataInBlock objects by combining indices, blockNumbers and blockHashes and return them.
|
|
995
|
-
return maybeIndices.map(
|
|
1058
|
+
return maybeIndices.map(index => {
|
|
996
1059
|
if (index === undefined) {
|
|
997
1060
|
return undefined;
|
|
998
1061
|
}
|
|
999
|
-
const blockNumber =
|
|
1062
|
+
const blockNumber = indexToBlockNumber.get(index);
|
|
1000
1063
|
if (blockNumber === undefined) {
|
|
1001
|
-
|
|
1064
|
+
throw new Error(`Block number not found for leaf index ${index} in tree ${MerkleTreeId[treeId]}`);
|
|
1002
1065
|
}
|
|
1003
|
-
const
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
return undefined;
|
|
1066
|
+
const blockHash = blockNumberToHash.get(blockNumber);
|
|
1067
|
+
if (blockHash === undefined) {
|
|
1068
|
+
throw new Error(`Block hash not found for block number ${blockNumber}`);
|
|
1007
1069
|
}
|
|
1008
1070
|
return {
|
|
1009
|
-
l2BlockNumber:
|
|
1071
|
+
l2BlockNumber: blockNumber,
|
|
1010
1072
|
l2BlockHash: new BlockHash(blockHash),
|
|
1011
1073
|
data: index,
|
|
1012
1074
|
};
|
|
@@ -1017,7 +1079,11 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1017
1079
|
referenceBlock: BlockParameter,
|
|
1018
1080
|
blockHash: BlockHash,
|
|
1019
1081
|
): Promise<MembershipWitness<typeof ARCHIVE_HEIGHT> | undefined> {
|
|
1020
|
-
|
|
1082
|
+
// The Noir circuit checks the archive membership proof against `anchor_block_header.last_archive.root`,
|
|
1083
|
+
// which is the archive tree root BEFORE the anchor block was added (i.e. the state after block N-1).
|
|
1084
|
+
// So we need the world state at block N-1, not block N, to produce a sibling path matching that root.
|
|
1085
|
+
const referenceBlockNumber = await this.resolveBlockNumber(referenceBlock);
|
|
1086
|
+
const committedDb = await this.getWorldState(BlockNumber(referenceBlockNumber - 1));
|
|
1021
1087
|
const [pathAndIndex] = await committedDb.findSiblingPaths<MerkleTreeId.ARCHIVE>(MerkleTreeId.ARCHIVE, [blockHash]);
|
|
1022
1088
|
return pathAndIndex === undefined
|
|
1023
1089
|
? undefined
|
|
@@ -1028,7 +1094,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1028
1094
|
referenceBlock: BlockParameter,
|
|
1029
1095
|
noteHash: Fr,
|
|
1030
1096
|
): Promise<MembershipWitness<typeof NOTE_HASH_TREE_HEIGHT> | undefined> {
|
|
1031
|
-
const committedDb = await this
|
|
1097
|
+
const committedDb = await this.getWorldState(referenceBlock);
|
|
1032
1098
|
const [pathAndIndex] = await committedDb.findSiblingPaths<MerkleTreeId.NOTE_HASH_TREE>(
|
|
1033
1099
|
MerkleTreeId.NOTE_HASH_TREE,
|
|
1034
1100
|
[noteHash],
|
|
@@ -1042,7 +1108,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1042
1108
|
referenceBlock: BlockParameter,
|
|
1043
1109
|
l1ToL2Message: Fr,
|
|
1044
1110
|
): Promise<[bigint, SiblingPath<typeof L1_TO_L2_MSG_TREE_HEIGHT>] | undefined> {
|
|
1045
|
-
const db = await this
|
|
1111
|
+
const db = await this.getWorldState(referenceBlock);
|
|
1046
1112
|
const [witness] = await db.findSiblingPaths(MerkleTreeId.L1_TO_L2_MESSAGE_TREE, [l1ToL2Message]);
|
|
1047
1113
|
if (!witness) {
|
|
1048
1114
|
return undefined;
|
|
@@ -1052,11 +1118,9 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1052
1118
|
return [witness.index, witness.path];
|
|
1053
1119
|
}
|
|
1054
1120
|
|
|
1055
|
-
public async
|
|
1121
|
+
public async getL1ToL2MessageCheckpoint(l1ToL2Message: Fr): Promise<CheckpointNumber | undefined> {
|
|
1056
1122
|
const messageIndex = await this.l1ToL2MessageSource.getL1ToL2MessageIndex(l1ToL2Message);
|
|
1057
|
-
return messageIndex
|
|
1058
|
-
? BlockNumber.fromCheckpointNumber(InboxLeaf.checkpointNumberFromIndex(messageIndex))
|
|
1059
|
-
: undefined;
|
|
1123
|
+
return messageIndex ? InboxLeaf.checkpointNumberFromIndex(messageIndex) : undefined;
|
|
1060
1124
|
}
|
|
1061
1125
|
|
|
1062
1126
|
/**
|
|
@@ -1077,19 +1141,9 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1077
1141
|
public async getL2ToL1Messages(epoch: EpochNumber): Promise<Fr[][][][]> {
|
|
1078
1142
|
// Assumes `getCheckpointedBlocksForEpoch` returns blocks in ascending order of block number.
|
|
1079
1143
|
const checkpointedBlocks = await this.blockSource.getCheckpointedBlocksForEpoch(epoch);
|
|
1080
|
-
const blocksInCheckpoints
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
for (const checkpointedBlock of checkpointedBlocks) {
|
|
1084
|
-
const block = checkpointedBlock.block;
|
|
1085
|
-
const slotNumber = block.header.globalVariables.slotNumber;
|
|
1086
|
-
if (slotNumber !== previousSlotNumber) {
|
|
1087
|
-
checkpointIndex++;
|
|
1088
|
-
blocksInCheckpoints.push([]);
|
|
1089
|
-
previousSlotNumber = slotNumber;
|
|
1090
|
-
}
|
|
1091
|
-
blocksInCheckpoints[checkpointIndex].push(block);
|
|
1092
|
-
}
|
|
1144
|
+
const blocksInCheckpoints = chunkBy(checkpointedBlocks, cb => cb.block.header.globalVariables.slotNumber).map(
|
|
1145
|
+
group => group.map(cb => cb.block),
|
|
1146
|
+
);
|
|
1093
1147
|
return blocksInCheckpoints.map(blocks =>
|
|
1094
1148
|
blocks.map(block => block.body.txEffects.map(txEffect => txEffect.l2ToL1Msgs)),
|
|
1095
1149
|
);
|
|
@@ -1099,7 +1153,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1099
1153
|
referenceBlock: BlockParameter,
|
|
1100
1154
|
nullifier: Fr,
|
|
1101
1155
|
): Promise<NullifierMembershipWitness | undefined> {
|
|
1102
|
-
const db = await this
|
|
1156
|
+
const db = await this.getWorldState(referenceBlock);
|
|
1103
1157
|
const [witness] = await db.findSiblingPaths(MerkleTreeId.NULLIFIER_TREE, [nullifier.toBuffer()]);
|
|
1104
1158
|
if (!witness) {
|
|
1105
1159
|
return undefined;
|
|
@@ -1114,33 +1168,20 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1114
1168
|
return new NullifierMembershipWitness(index, leafPreimage as NullifierLeafPreimage, path);
|
|
1115
1169
|
}
|
|
1116
1170
|
|
|
1117
|
-
/**
|
|
1118
|
-
* Returns a low nullifier membership witness for a given nullifier at a given block.
|
|
1119
|
-
* @param referenceBlock - The block parameter (block number, block hash, or 'latest') at which to get the data
|
|
1120
|
-
* (which contains the root of the nullifier tree in which we are searching for the nullifier).
|
|
1121
|
-
* @param nullifier - Nullifier we try to find the low nullifier witness for.
|
|
1122
|
-
* @returns The low nullifier membership witness (if found).
|
|
1123
|
-
* @remarks Low nullifier witness can be used to perform a nullifier non-inclusion proof by leveraging the "linked
|
|
1124
|
-
* list structure" of leaves and proving that a lower nullifier is pointing to a bigger next value than the nullifier
|
|
1125
|
-
* we are trying to prove non-inclusion for.
|
|
1126
|
-
*
|
|
1127
|
-
* Note: This function returns the membership witness of the nullifier itself and not the low nullifier when
|
|
1128
|
-
* the nullifier already exists in the tree. This is because the `getPreviousValueIndex` function returns the
|
|
1129
|
-
* index of the nullifier itself when it already exists in the tree.
|
|
1130
|
-
* TODO: This is a confusing behavior and we should eventually address that.
|
|
1131
|
-
*/
|
|
1132
1171
|
public async getLowNullifierMembershipWitness(
|
|
1133
1172
|
referenceBlock: BlockParameter,
|
|
1134
1173
|
nullifier: Fr,
|
|
1135
1174
|
): Promise<NullifierMembershipWitness | undefined> {
|
|
1136
|
-
const committedDb = await this
|
|
1175
|
+
const committedDb = await this.getWorldState(referenceBlock);
|
|
1137
1176
|
const findResult = await committedDb.getPreviousValueIndex(MerkleTreeId.NULLIFIER_TREE, nullifier.toBigInt());
|
|
1138
1177
|
if (!findResult) {
|
|
1139
1178
|
return undefined;
|
|
1140
1179
|
}
|
|
1141
1180
|
const { index, alreadyPresent } = findResult;
|
|
1142
1181
|
if (alreadyPresent) {
|
|
1143
|
-
|
|
1182
|
+
throw new Error(
|
|
1183
|
+
`Cannot prove nullifier non-inclusion: nullifier ${nullifier.toBigInt()} already exists in the tree`,
|
|
1184
|
+
);
|
|
1144
1185
|
}
|
|
1145
1186
|
const preimageData = (await committedDb.getLeafPreimage(MerkleTreeId.NULLIFIER_TREE, index))!;
|
|
1146
1187
|
|
|
@@ -1149,7 +1190,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1149
1190
|
}
|
|
1150
1191
|
|
|
1151
1192
|
async getPublicDataWitness(referenceBlock: BlockParameter, leafSlot: Fr): Promise<PublicDataWitness | undefined> {
|
|
1152
|
-
const committedDb = await this
|
|
1193
|
+
const committedDb = await this.getWorldState(referenceBlock);
|
|
1153
1194
|
const lowLeafResult = await committedDb.getPreviousValueIndex(MerkleTreeId.PUBLIC_DATA_TREE, leafSlot.toBigInt());
|
|
1154
1195
|
if (!lowLeafResult) {
|
|
1155
1196
|
return undefined;
|
|
@@ -1164,7 +1205,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1164
1205
|
}
|
|
1165
1206
|
|
|
1166
1207
|
public async getPublicStorageAt(referenceBlock: BlockParameter, contract: AztecAddress, slot: Fr): Promise<Fr> {
|
|
1167
|
-
const committedDb = await this
|
|
1208
|
+
const committedDb = await this.getWorldState(referenceBlock);
|
|
1168
1209
|
const leafSlot = await computePublicDataTreeLeafSlot(contract, slot);
|
|
1169
1210
|
|
|
1170
1211
|
const lowLeafResult = await committedDb.getPreviousValueIndex(MerkleTreeId.PUBLIC_DATA_TREE, leafSlot.toBigInt());
|
|
@@ -1278,7 +1319,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1278
1319
|
const processor = publicProcessorFactory.create(merkleTreeFork, newGlobalVariables, config);
|
|
1279
1320
|
|
|
1280
1321
|
// REFACTOR: Consider merging ProcessReturnValues into ProcessedTx
|
|
1281
|
-
const [processedTxs, failedTxs, _usedTxs, returns,
|
|
1322
|
+
const [processedTxs, failedTxs, _usedTxs, returns, debugLogs] = await processor.process([tx]);
|
|
1282
1323
|
// REFACTOR: Consider returning the error rather than throwing
|
|
1283
1324
|
if (failedTxs.length) {
|
|
1284
1325
|
this.log.warn(`Simulated tx ${txHash} fails: ${failedTxs[0].error}`, { txHash });
|
|
@@ -1304,11 +1345,12 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1304
1345
|
{ isSimulation, skipFeeEnforcement }: { isSimulation?: boolean; skipFeeEnforcement?: boolean } = {},
|
|
1305
1346
|
): Promise<TxValidationResult> {
|
|
1306
1347
|
const db = this.worldStateSynchronizer.getCommitted();
|
|
1307
|
-
const verifier = isSimulation ? undefined : this.
|
|
1348
|
+
const verifier = isSimulation ? undefined : this.rpcProofVerifier;
|
|
1308
1349
|
|
|
1309
1350
|
// We accept transactions if they are not expired by the next slot (checked based on the ExpirationTimestamp field)
|
|
1310
1351
|
const { ts: nextSlotTimestamp } = this.epochCache.getEpochAndSlotInNextL1Slot();
|
|
1311
1352
|
const blockNumber = BlockNumber((await this.blockSource.getBlockNumber()) + 1);
|
|
1353
|
+
const l1Constants = await this.blockSource.getL1Constants();
|
|
1312
1354
|
const validator = createTxValidatorForAcceptingTxsOverRPC(
|
|
1313
1355
|
db,
|
|
1314
1356
|
this.contractDataSource,
|
|
@@ -1318,10 +1360,16 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1318
1360
|
blockNumber,
|
|
1319
1361
|
l1ChainId: this.l1ChainId,
|
|
1320
1362
|
rollupVersion: this.version,
|
|
1321
|
-
setupAllowList:
|
|
1363
|
+
setupAllowList: [
|
|
1364
|
+
...(await getDefaultAllowedSetupFunctions()),
|
|
1365
|
+
...(this.config.txPublicSetupAllowListExtend ?? []),
|
|
1366
|
+
],
|
|
1322
1367
|
gasFees: await this.getCurrentMinFees(),
|
|
1323
1368
|
skipFeeEnforcement,
|
|
1324
1369
|
txsPermitted: !this.config.disableTransactions,
|
|
1370
|
+
rollupManaLimit: l1Constants.rollupManaLimit,
|
|
1371
|
+
maxBlockL2Gas: this.config.validateMaxL2BlockGas,
|
|
1372
|
+
maxBlockDAGas: this.config.validateMaxDABlockGas,
|
|
1325
1373
|
},
|
|
1326
1374
|
this.log.getBindings(),
|
|
1327
1375
|
);
|
|
@@ -1346,7 +1394,15 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1346
1394
|
archiver.updateConfig(config);
|
|
1347
1395
|
}
|
|
1348
1396
|
if (newConfig.realProofs !== this.config.realProofs) {
|
|
1349
|
-
|
|
1397
|
+
await Promise.all([tryStop(this.peerProofVerifier), tryStop(this.rpcProofVerifier)]);
|
|
1398
|
+
if (newConfig.realProofs) {
|
|
1399
|
+
this.peerProofVerifier = await BatchChonkVerifier.new(newConfig, newConfig.bbChonkVerifyMaxBatch, 'peer');
|
|
1400
|
+
const rpcVerifier = await BBCircuitVerifier.new(newConfig);
|
|
1401
|
+
this.rpcProofVerifier = new QueuedIVCVerifier(rpcVerifier, newConfig.numConcurrentIVCVerifiers);
|
|
1402
|
+
} else {
|
|
1403
|
+
this.peerProofVerifier = new TestCircuitVerifier();
|
|
1404
|
+
this.rpcProofVerifier = new TestCircuitVerifier();
|
|
1405
|
+
}
|
|
1350
1406
|
}
|
|
1351
1407
|
|
|
1352
1408
|
this.config = newConfig;
|
|
@@ -1588,7 +1644,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1588
1644
|
* @param block - The block parameter (block number, block hash, or 'latest') at which to get the data.
|
|
1589
1645
|
* @returns An instance of a committed MerkleTreeOperations
|
|
1590
1646
|
*/
|
|
1591
|
-
async
|
|
1647
|
+
protected async getWorldState(block: BlockParameter) {
|
|
1592
1648
|
let blockSyncedTo: BlockNumber = BlockNumber.ZERO;
|
|
1593
1649
|
try {
|
|
1594
1650
|
// Attempt to sync the world state if necessary
|
|
@@ -1602,6 +1658,8 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1602
1658
|
return this.worldStateSynchronizer.getCommitted();
|
|
1603
1659
|
}
|
|
1604
1660
|
|
|
1661
|
+
// Get the block number, either directly from the parameter or by quering the archiver with the block hash
|
|
1662
|
+
let blockNumber: BlockNumber;
|
|
1605
1663
|
if (BlockHash.isBlockHash(block)) {
|
|
1606
1664
|
const initialBlockHash = await this.#getInitialHeaderHash();
|
|
1607
1665
|
if (block.equals(initialBlockHash)) {
|
|
@@ -1615,22 +1673,50 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1615
1673
|
`Block hash ${block.toString()} not found when querying world state. If the node API has been queried with anchor block hash possibly a reorg has occurred.`,
|
|
1616
1674
|
);
|
|
1617
1675
|
}
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1676
|
+
|
|
1677
|
+
blockNumber = header.getBlockNumber();
|
|
1678
|
+
} else {
|
|
1679
|
+
blockNumber = block as BlockNumber;
|
|
1680
|
+
}
|
|
1681
|
+
|
|
1682
|
+
// Check it's within world state sync range
|
|
1683
|
+
if (blockNumber > blockSyncedTo) {
|
|
1684
|
+
throw new Error(`Queried block ${block} not yet synced by the node (node is synced upto ${blockSyncedTo}).`);
|
|
1621
1685
|
}
|
|
1686
|
+
this.log.debug(`Using snapshot for block ${blockNumber}, world state synced upto ${blockSyncedTo}`);
|
|
1622
1687
|
|
|
1623
|
-
|
|
1624
|
-
{
|
|
1625
|
-
const blockNumber = block as BlockNumber;
|
|
1688
|
+
const snapshot = this.worldStateSynchronizer.getSnapshot(blockNumber);
|
|
1626
1689
|
|
|
1627
|
-
|
|
1628
|
-
|
|
1690
|
+
// Double-check world-state synced to the same block hash as was requested
|
|
1691
|
+
if (BlockHash.isBlockHash(block)) {
|
|
1692
|
+
const blockHash = await snapshot.getLeafValue(MerkleTreeId.ARCHIVE, BigInt(blockNumber));
|
|
1693
|
+
if (!blockHash || !new BlockHash(blockHash).equals(block)) {
|
|
1694
|
+
throw new Error(
|
|
1695
|
+
`Block hash ${block.toString()} not found in world state at block number ${blockNumber}. If the node API has been queried with anchor block hash possibly a reorg has occurred.`,
|
|
1696
|
+
);
|
|
1629
1697
|
}
|
|
1698
|
+
}
|
|
1699
|
+
|
|
1700
|
+
return snapshot;
|
|
1701
|
+
}
|
|
1630
1702
|
|
|
1631
|
-
|
|
1632
|
-
|
|
1703
|
+
/** Resolves a block parameter to a block number. */
|
|
1704
|
+
protected async resolveBlockNumber(block: BlockParameter): Promise<BlockNumber> {
|
|
1705
|
+
if (block === 'latest') {
|
|
1706
|
+
return BlockNumber(await this.blockSource.getBlockNumber());
|
|
1707
|
+
}
|
|
1708
|
+
if (BlockHash.isBlockHash(block)) {
|
|
1709
|
+
const initialBlockHash = await this.#getInitialHeaderHash();
|
|
1710
|
+
if (block.equals(initialBlockHash)) {
|
|
1711
|
+
return BlockNumber.ZERO;
|
|
1712
|
+
}
|
|
1713
|
+
const header = await this.blockSource.getBlockHeaderByHash(block);
|
|
1714
|
+
if (!header) {
|
|
1715
|
+
throw new Error(`Block hash ${block.toString()} not found.`);
|
|
1716
|
+
}
|
|
1717
|
+
return header.getBlockNumber();
|
|
1633
1718
|
}
|
|
1719
|
+
return block as BlockNumber;
|
|
1634
1720
|
}
|
|
1635
1721
|
|
|
1636
1722
|
/**
|