@aztec/aztec-node 0.0.1-commit.2b2662070 → 0.0.1-commit.2c0ee1788
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/block_response_helpers.d.ts +21 -0
- package/dest/aztec-node/block_response_helpers.d.ts.map +1 -0
- package/dest/aztec-node/block_response_helpers.js +88 -0
- package/dest/aztec-node/server.d.ts +21 -53
- package/dest/aztec-node/server.d.ts.map +1 -1
- package/dest/aztec-node/server.js +552 -336
- package/dest/sentinel/factory.d.ts +3 -2
- package/dest/sentinel/factory.d.ts.map +1 -1
- package/dest/sentinel/sentinel.d.ts +6 -3
- package/dest/sentinel/sentinel.d.ts.map +1 -1
- package/dest/sentinel/sentinel.js +7 -1
- package/package.json +26 -26
- package/src/aztec-node/block_response_helpers.ts +131 -0
- package/src/aztec-node/server.ts +647 -431
- package/src/sentinel/factory.ts +2 -1
- package/src/sentinel/sentinel.ts +17 -5
|
@@ -402,7 +402,7 @@ import { PublicProcessorFactory } from '@aztec/simulator/server';
|
|
|
402
402
|
import { AttestationsBlockWatcher, EpochPruneWatcher, createSlasher } from '@aztec/slasher';
|
|
403
403
|
import { CollectionLimitsConfig, PublicSimulatorConfig } from '@aztec/stdlib/avm';
|
|
404
404
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
405
|
-
import { BlockHash, L2Block } from '@aztec/stdlib/block';
|
|
405
|
+
import { BlockHash, L2Block, inspectBlockParameter } from '@aztec/stdlib/block';
|
|
406
406
|
import { GasFees } from '@aztec/stdlib/gas';
|
|
407
407
|
import { computePublicDataTreeLeafSlot } from '@aztec/stdlib/hash';
|
|
408
408
|
import { AztecNodeAdminConfigSchema } from '@aztec/stdlib/interfaces/client';
|
|
@@ -417,6 +417,7 @@ import { FullNodeCheckpointsBuilder as CheckpointsBuilder, FullNodeCheckpointsBu
|
|
|
417
417
|
import { createWorldStateSynchronizer } from '@aztec/world-state';
|
|
418
418
|
import { createPublicClient } from 'viem';
|
|
419
419
|
import { createSentinel } from '../sentinel/factory.js';
|
|
420
|
+
import { blockResponseFromBlockData, blockResponseFromL2Block, checkpointResponseFromCheckpointData, checkpointResponseFromPublishedCheckpoint } from './block_response_helpers.js';
|
|
420
421
|
import { createKeyStoreForValidator } from './config.js';
|
|
421
422
|
import { NodeMetrics } from './node_metrics.js';
|
|
422
423
|
_dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
@@ -437,6 +438,7 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
437
438
|
slasherClient;
|
|
438
439
|
validatorsSentinel;
|
|
439
440
|
epochPruneWatcher;
|
|
441
|
+
attestationsBlockWatcher;
|
|
440
442
|
l1ChainId;
|
|
441
443
|
version;
|
|
442
444
|
globalVariableBuilder;
|
|
@@ -465,7 +467,7 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
465
467
|
// Prevent two snapshot operations to happen simultaneously
|
|
466
468
|
isUploadingSnapshot;
|
|
467
469
|
tracer;
|
|
468
|
-
constructor(config, p2pClient, blockSource, logsSource, contractDataSource, l1ToL2MessageSource, worldStateSynchronizer, sequencer, proverNode, slasherClient, validatorsSentinel, epochPruneWatcher, l1ChainId, version, globalVariableBuilder, feeProvider, epochCache, packageVersion, peerProofVerifier, rpcProofVerifier, telemetry = getTelemetryClient(), log = createLogger('node'), blobClient, validatorClient, keyStoreManager, debugLogStore = new NullDebugLogStore()){
|
|
470
|
+
constructor(config, p2pClient, blockSource, logsSource, contractDataSource, l1ToL2MessageSource, worldStateSynchronizer, sequencer, proverNode, slasherClient, validatorsSentinel, epochPruneWatcher, attestationsBlockWatcher, l1ChainId, version, globalVariableBuilder, feeProvider, epochCache, packageVersion, peerProofVerifier, rpcProofVerifier, telemetry = getTelemetryClient(), log = createLogger('node'), blobClient, validatorClient, keyStoreManager, debugLogStore = new NullDebugLogStore()){
|
|
469
471
|
this.config = config;
|
|
470
472
|
this.p2pClient = p2pClient;
|
|
471
473
|
this.blockSource = blockSource;
|
|
@@ -478,6 +480,7 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
478
480
|
this.slasherClient = slasherClient;
|
|
479
481
|
this.validatorsSentinel = validatorsSentinel;
|
|
480
482
|
this.epochPruneWatcher = epochPruneWatcher;
|
|
483
|
+
this.attestationsBlockWatcher = attestationsBlockWatcher;
|
|
481
484
|
this.l1ChainId = l1ChainId;
|
|
482
485
|
this.version = version;
|
|
483
486
|
this.globalVariableBuilder = globalVariableBuilder;
|
|
@@ -512,9 +515,273 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
512
515
|
const status = await this.worldStateSynchronizer.status();
|
|
513
516
|
return status.syncSummary;
|
|
514
517
|
}
|
|
518
|
+
async getChainTips() {
|
|
519
|
+
const { proposed, checkpointed, proven, finalized } = await this.blockSource.getL2Tips();
|
|
520
|
+
return {
|
|
521
|
+
proposed,
|
|
522
|
+
checkpointed,
|
|
523
|
+
proven,
|
|
524
|
+
finalized
|
|
525
|
+
};
|
|
526
|
+
}
|
|
515
527
|
getL2Tips() {
|
|
516
528
|
return this.blockSource.getL2Tips();
|
|
517
529
|
}
|
|
530
|
+
async getBlockHeader(number) {
|
|
531
|
+
const resolvedNumber = number === 'latest' ? await this.blockSource.getBlockNumber() : number;
|
|
532
|
+
if (resolvedNumber === BlockNumber.ZERO) {
|
|
533
|
+
return this.worldStateSynchronizer.getCommitted().getInitialHeader();
|
|
534
|
+
}
|
|
535
|
+
return this.blockSource.getBlockHeader(resolvedNumber);
|
|
536
|
+
}
|
|
537
|
+
async getCheckpointedBlocks(from, limit) {
|
|
538
|
+
return await this.blockSource.getCheckpointedBlocks(from, limit) ?? [];
|
|
539
|
+
}
|
|
540
|
+
getCheckpointsDataForEpoch(epoch) {
|
|
541
|
+
return this.blockSource.getCheckpointsDataForEpoch(epoch);
|
|
542
|
+
}
|
|
543
|
+
getBlockNumber(tip) {
|
|
544
|
+
switch(tip){
|
|
545
|
+
case undefined:
|
|
546
|
+
case 'proposed':
|
|
547
|
+
return this.blockSource.getBlockNumber();
|
|
548
|
+
case 'checkpointed':
|
|
549
|
+
return this.blockSource.getCheckpointedL2BlockNumber();
|
|
550
|
+
case 'proven':
|
|
551
|
+
return this.blockSource.getProvenBlockNumber();
|
|
552
|
+
case 'finalized':
|
|
553
|
+
return this.blockSource.getFinalizedL2BlockNumber();
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
async getCheckpointNumber(tip) {
|
|
557
|
+
switch(tip){
|
|
558
|
+
case undefined:
|
|
559
|
+
case 'proposed':
|
|
560
|
+
case 'checkpointed':
|
|
561
|
+
return await this.blockSource.getCheckpointNumber();
|
|
562
|
+
case 'proven':
|
|
563
|
+
case 'finalized':
|
|
564
|
+
{
|
|
565
|
+
const tips = await this.blockSource.getL2Tips();
|
|
566
|
+
return tip === 'proven' ? tips.proven.checkpoint.number : tips.finalized.checkpoint.number;
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
isChainTip(value) {
|
|
571
|
+
return value === 'proposed' || value === 'checkpointed' || value === 'proven' || value === 'finalized';
|
|
572
|
+
}
|
|
573
|
+
async resolveBlockParameter(param) {
|
|
574
|
+
if (BlockHash.isBlockHash(param)) {
|
|
575
|
+
return {
|
|
576
|
+
hash: param
|
|
577
|
+
};
|
|
578
|
+
}
|
|
579
|
+
if (typeof param === 'number') {
|
|
580
|
+
return {
|
|
581
|
+
number: param
|
|
582
|
+
};
|
|
583
|
+
}
|
|
584
|
+
if (param === 'latest') {
|
|
585
|
+
return {
|
|
586
|
+
number: await this.blockSource.getBlockNumber()
|
|
587
|
+
};
|
|
588
|
+
}
|
|
589
|
+
if (this.isChainTip(param)) {
|
|
590
|
+
return {
|
|
591
|
+
number: await this.getBlockNumber(param)
|
|
592
|
+
};
|
|
593
|
+
}
|
|
594
|
+
if (typeof param === 'object' && param !== null) {
|
|
595
|
+
if ('number' in param) {
|
|
596
|
+
return {
|
|
597
|
+
number: param.number
|
|
598
|
+
};
|
|
599
|
+
}
|
|
600
|
+
if ('hash' in param) {
|
|
601
|
+
return {
|
|
602
|
+
hash: param.hash
|
|
603
|
+
};
|
|
604
|
+
}
|
|
605
|
+
if ('archive' in param) {
|
|
606
|
+
return {
|
|
607
|
+
archive: param.archive
|
|
608
|
+
};
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
throw new BadRequestError(`Invalid BlockParameter: ${JSON.stringify(param)}`);
|
|
612
|
+
}
|
|
613
|
+
async resolveCheckpointParameter(param) {
|
|
614
|
+
if (typeof param === 'number') {
|
|
615
|
+
return {
|
|
616
|
+
number: param
|
|
617
|
+
};
|
|
618
|
+
}
|
|
619
|
+
if (param === 'latest') {
|
|
620
|
+
return {
|
|
621
|
+
number: await this.blockSource.getCheckpointNumber()
|
|
622
|
+
};
|
|
623
|
+
}
|
|
624
|
+
if (this.isChainTip(param)) {
|
|
625
|
+
return {
|
|
626
|
+
number: await this.getCheckpointNumber(param)
|
|
627
|
+
};
|
|
628
|
+
}
|
|
629
|
+
if (typeof param === 'object' && param !== null) {
|
|
630
|
+
if ('number' in param) {
|
|
631
|
+
return {
|
|
632
|
+
number: param.number
|
|
633
|
+
};
|
|
634
|
+
}
|
|
635
|
+
if ('slot' in param) {
|
|
636
|
+
return {
|
|
637
|
+
slot: param.slot
|
|
638
|
+
};
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
throw new BadRequestError(`Invalid CheckpointParameter: ${JSON.stringify(param)}`);
|
|
642
|
+
}
|
|
643
|
+
async getBlock(param, options = {}) {
|
|
644
|
+
const resolved = await this.resolveBlockParameter(param);
|
|
645
|
+
const wantTxs = !!options.includeTransactions;
|
|
646
|
+
const wantContext = !!options.includeL1PublishInfo || !!options.includeAttestations;
|
|
647
|
+
if (resolved.hash !== undefined) {
|
|
648
|
+
const initial = await this.#getInitialHeaderHash();
|
|
649
|
+
if (resolved.hash.equals(initial)) {
|
|
650
|
+
return await this.buildGenesisBlockResponse(options);
|
|
651
|
+
}
|
|
652
|
+
if (wantTxs) {
|
|
653
|
+
const block = await this.blockSource.getL2BlockByHash(resolved.hash);
|
|
654
|
+
if (!block) {
|
|
655
|
+
return undefined;
|
|
656
|
+
}
|
|
657
|
+
const ctx = wantContext ? await this.blockSource.getBlockDataWithCheckpointContext(block.number) : undefined;
|
|
658
|
+
return await blockResponseFromL2Block(block, options, ctx);
|
|
659
|
+
}
|
|
660
|
+
const data = await this.blockSource.getBlockHeaderByHash(resolved.hash);
|
|
661
|
+
if (!data) {
|
|
662
|
+
return undefined;
|
|
663
|
+
}
|
|
664
|
+
const blockNumber = data.globalVariables.blockNumber;
|
|
665
|
+
const ctx = wantContext ? await this.blockSource.getBlockDataWithCheckpointContext(blockNumber) : undefined;
|
|
666
|
+
if (ctx) {
|
|
667
|
+
return blockResponseFromBlockData(ctx.data, blockNumber, options, ctx);
|
|
668
|
+
}
|
|
669
|
+
const blockData = await this.blockSource.getBlockData(blockNumber);
|
|
670
|
+
if (!blockData) {
|
|
671
|
+
return undefined;
|
|
672
|
+
}
|
|
673
|
+
return blockResponseFromBlockData(blockData, blockNumber, options);
|
|
674
|
+
}
|
|
675
|
+
if (resolved.archive !== undefined) {
|
|
676
|
+
if (wantTxs) {
|
|
677
|
+
const block = await this.blockSource.getL2BlockByArchive(resolved.archive);
|
|
678
|
+
if (!block) {
|
|
679
|
+
return undefined;
|
|
680
|
+
}
|
|
681
|
+
const ctx = wantContext ? await this.blockSource.getBlockDataWithCheckpointContext(block.number) : undefined;
|
|
682
|
+
return await blockResponseFromL2Block(block, options, ctx);
|
|
683
|
+
}
|
|
684
|
+
const data = await this.blockSource.getBlockDataByArchive(resolved.archive);
|
|
685
|
+
if (!data) {
|
|
686
|
+
return undefined;
|
|
687
|
+
}
|
|
688
|
+
const blockNumber = data.header.globalVariables.blockNumber;
|
|
689
|
+
const ctx = wantContext ? await this.blockSource.getBlockDataWithCheckpointContext(blockNumber) : undefined;
|
|
690
|
+
return blockResponseFromBlockData(data, blockNumber, options, ctx);
|
|
691
|
+
}
|
|
692
|
+
const blockNumber = resolved.number;
|
|
693
|
+
if (blockNumber === BlockNumber.ZERO) {
|
|
694
|
+
return await this.buildGenesisBlockResponse(options);
|
|
695
|
+
}
|
|
696
|
+
if (wantTxs) {
|
|
697
|
+
const block = await this.blockSource.getL2Block(blockNumber);
|
|
698
|
+
if (!block) {
|
|
699
|
+
return undefined;
|
|
700
|
+
}
|
|
701
|
+
const ctx = wantContext ? await this.blockSource.getBlockDataWithCheckpointContext(blockNumber) : undefined;
|
|
702
|
+
return await blockResponseFromL2Block(block, options, ctx);
|
|
703
|
+
}
|
|
704
|
+
const ctx = await this.blockSource.getBlockDataWithCheckpointContext(blockNumber);
|
|
705
|
+
if (!ctx) {
|
|
706
|
+
return undefined;
|
|
707
|
+
}
|
|
708
|
+
return blockResponseFromBlockData(ctx.data, blockNumber, options, ctx);
|
|
709
|
+
}
|
|
710
|
+
async getBlocks(from, limit, options = {}) {
|
|
711
|
+
const wantTxs = !!options.includeTransactions;
|
|
712
|
+
const wantContext = !!options.includeL1PublishInfo || !!options.includeAttestations;
|
|
713
|
+
if (wantTxs) {
|
|
714
|
+
const blocks = await this.blockSource.getBlocks(from, limit);
|
|
715
|
+
return await Promise.all(blocks.map(async (block)=>{
|
|
716
|
+
const ctx = wantContext ? await this.blockSource.getBlockDataWithCheckpointContext(block.number) : undefined;
|
|
717
|
+
return blockResponseFromL2Block(block, options, ctx);
|
|
718
|
+
}));
|
|
719
|
+
}
|
|
720
|
+
const results = [];
|
|
721
|
+
for(let i = 0; i < limit; i++){
|
|
722
|
+
const blockNumber = BlockNumber(from + i);
|
|
723
|
+
const ctx = await this.blockSource.getBlockDataWithCheckpointContext(blockNumber);
|
|
724
|
+
if (!ctx) {
|
|
725
|
+
break;
|
|
726
|
+
}
|
|
727
|
+
results.push(blockResponseFromBlockData(ctx.data, blockNumber, options, ctx));
|
|
728
|
+
}
|
|
729
|
+
return results;
|
|
730
|
+
}
|
|
731
|
+
async getCheckpoint(param, options = {}) {
|
|
732
|
+
const resolved = await this.resolveCheckpointParameter(param);
|
|
733
|
+
let checkpointNumber = resolved.number;
|
|
734
|
+
if (checkpointNumber === undefined && resolved.slot !== undefined) {
|
|
735
|
+
checkpointNumber = await this.blockSource.getCheckpointNumberBySlot(resolved.slot);
|
|
736
|
+
}
|
|
737
|
+
if (checkpointNumber === undefined) {
|
|
738
|
+
return undefined;
|
|
739
|
+
}
|
|
740
|
+
if (options.includeBlocks) {
|
|
741
|
+
const [checkpoint] = await this.blockSource.getCheckpoints(checkpointNumber, 1);
|
|
742
|
+
if (!checkpoint) {
|
|
743
|
+
return undefined;
|
|
744
|
+
}
|
|
745
|
+
return await checkpointResponseFromPublishedCheckpoint(checkpoint, options);
|
|
746
|
+
}
|
|
747
|
+
const data = await this.blockSource.getCheckpointData(checkpointNumber);
|
|
748
|
+
if (!data) {
|
|
749
|
+
return undefined;
|
|
750
|
+
}
|
|
751
|
+
return checkpointResponseFromCheckpointData(data, options);
|
|
752
|
+
}
|
|
753
|
+
async getCheckpoints(from, limit, options = {}) {
|
|
754
|
+
if (options.includeBlocks) {
|
|
755
|
+
const checkpoints = await this.blockSource.getCheckpoints(from, limit);
|
|
756
|
+
return await Promise.all(checkpoints.map((cp)=>checkpointResponseFromPublishedCheckpoint(cp, options)));
|
|
757
|
+
}
|
|
758
|
+
const datas = await this.blockSource.getCheckpointDataRange(from, limit);
|
|
759
|
+
return datas.map((d)=>checkpointResponseFromCheckpointData(d, options));
|
|
760
|
+
}
|
|
761
|
+
async buildGenesisBlockResponse(options) {
|
|
762
|
+
const initial = this.worldStateSynchronizer.getCommitted().getInitialHeader();
|
|
763
|
+
const empty = L2Block.empty(initial);
|
|
764
|
+
const response = {
|
|
765
|
+
header: empty.header,
|
|
766
|
+
archive: empty.archive,
|
|
767
|
+
hash: await this.#getInitialHeaderHash(),
|
|
768
|
+
checkpointNumber: empty.checkpointNumber,
|
|
769
|
+
indexWithinCheckpoint: empty.indexWithinCheckpoint,
|
|
770
|
+
number: empty.number
|
|
771
|
+
};
|
|
772
|
+
if (options.includeTransactions) {
|
|
773
|
+
response.body = empty.body;
|
|
774
|
+
}
|
|
775
|
+
if (options.includeL1PublishInfo) {
|
|
776
|
+
response.l1 = {
|
|
777
|
+
published: false
|
|
778
|
+
};
|
|
779
|
+
}
|
|
780
|
+
if (options.includeAttestations) {
|
|
781
|
+
response.attestations = [];
|
|
782
|
+
}
|
|
783
|
+
return response;
|
|
784
|
+
}
|
|
518
785
|
/**
|
|
519
786
|
* initializes the Aztec Node, wait for component to sync.
|
|
520
787
|
* @param config - The configuration to be used by the aztec node.
|
|
@@ -596,235 +863,261 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
596
863
|
const epochCache = await EpochCache.create(config.l1Contracts.rollupAddress, config, {
|
|
597
864
|
dateProvider
|
|
598
865
|
});
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
dateProvider
|
|
604
|
-
}, {
|
|
605
|
-
blockUntilSync: !config.skipArchiverInitialSync
|
|
606
|
-
});
|
|
607
|
-
// now create the merkle trees and the world state synchronizer
|
|
608
|
-
const worldStateSynchronizer = await createWorldStateSynchronizer(config, archiver, options.genesis, telemetry);
|
|
609
|
-
const useRealVerifiers = config.realProofs || config.debugForceTxProofVerification;
|
|
610
|
-
let peerProofVerifier;
|
|
611
|
-
let rpcProofVerifier;
|
|
612
|
-
if (useRealVerifiers) {
|
|
613
|
-
peerProofVerifier = await BatchChonkVerifier.new(config, config.bbChonkVerifyMaxBatch, 'peer');
|
|
614
|
-
const rpcVerifier = await BBCircuitVerifier.new(config);
|
|
615
|
-
rpcProofVerifier = new QueuedIVCVerifier(rpcVerifier, config.numConcurrentIVCVerifiers);
|
|
616
|
-
} else {
|
|
617
|
-
peerProofVerifier = new TestCircuitVerifier(config.proverTestVerificationDelayMs);
|
|
618
|
-
rpcProofVerifier = new TestCircuitVerifier(config.proverTestVerificationDelayMs);
|
|
619
|
-
}
|
|
620
|
-
let debugLogStore;
|
|
621
|
-
if (!config.realProofs) {
|
|
622
|
-
log.warn(`Aztec node is accepting fake proofs`);
|
|
623
|
-
debugLogStore = new InMemoryDebugLogStore();
|
|
624
|
-
log.info('Aztec node started in test mode (realProofs set to false) hence debug logs from public functions will be collected and served');
|
|
625
|
-
} else {
|
|
626
|
-
debugLogStore = new NullDebugLogStore();
|
|
627
|
-
}
|
|
628
|
-
const proverOnly = config.enableProverNode && config.disableValidator;
|
|
629
|
-
if (proverOnly) {
|
|
630
|
-
log.info('Starting in prover-only mode: skipping validator, sequencer, sentinel, and slasher subsystems');
|
|
631
|
-
}
|
|
632
|
-
// create the tx pool and the p2p client, which will need the l2 block source
|
|
633
|
-
const p2pClient = await createP2PClient(config, archiver, peerProofVerifier, worldStateSynchronizer, epochCache, packageVersion, dateProvider, telemetry, deps.p2pClientDeps);
|
|
634
|
-
// We'll accumulate sentinel watchers here
|
|
635
|
-
const watchers = [];
|
|
636
|
-
// Create FullNodeCheckpointsBuilder for block proposal handling and tx validation.
|
|
637
|
-
// Override maxTxsPerCheckpoint with the validator-specific limit if set.
|
|
638
|
-
const validatorCheckpointsBuilder = new FullNodeCheckpointsBuilder({
|
|
639
|
-
...config,
|
|
640
|
-
l1GenesisTime,
|
|
641
|
-
slotDuration: Number(slotDuration),
|
|
642
|
-
rollupManaLimit,
|
|
643
|
-
maxTxsPerCheckpoint: config.validateMaxTxsPerCheckpoint
|
|
644
|
-
}, worldStateSynchronizer, archiver, dateProvider, telemetry);
|
|
645
|
-
let validatorClient;
|
|
646
|
-
if (!proverOnly) {
|
|
647
|
-
// Create validator client if required
|
|
648
|
-
validatorClient = await createValidatorClient(config, {
|
|
649
|
-
checkpointsBuilder: validatorCheckpointsBuilder,
|
|
650
|
-
worldState: worldStateSynchronizer,
|
|
651
|
-
p2pClient,
|
|
652
|
-
telemetry,
|
|
653
|
-
dateProvider,
|
|
654
|
-
epochCache,
|
|
655
|
-
blockSource: archiver,
|
|
656
|
-
l1ToL2MessageSource: archiver,
|
|
657
|
-
keyStoreManager,
|
|
866
|
+
// Track started resources so we can clean up on partial failure during node creation.
|
|
867
|
+
const started = [];
|
|
868
|
+
try {
|
|
869
|
+
const archiver = await createArchiver(config, {
|
|
658
870
|
blobClient,
|
|
659
|
-
slashingProtectionDb: deps.slashingProtectionDb
|
|
660
|
-
});
|
|
661
|
-
// If we have a validator client, register it as a source of offenses for the slasher,
|
|
662
|
-
// and have it register callbacks on the p2p client *before* we start it, otherwise messages
|
|
663
|
-
// like attestations or auths will fail.
|
|
664
|
-
if (validatorClient) {
|
|
665
|
-
watchers.push(validatorClient);
|
|
666
|
-
const vc = validatorClient;
|
|
667
|
-
const getValidatorAddresses = ()=>vc.getValidatorAddresses().map((a)=>a.toString());
|
|
668
|
-
validatorClient.getProposalHandler().register(p2pClient, true, archiver, getValidatorAddresses);
|
|
669
|
-
if (!options.dontStartSequencer) {
|
|
670
|
-
await validatorClient.registerHandlers();
|
|
671
|
-
}
|
|
672
|
-
}
|
|
673
|
-
}
|
|
674
|
-
// If there's no validator client, create a ProposalHandler to handle block and checkpoint proposals
|
|
675
|
-
// for monitoring or reexecution. Reexecution (default) allows us to follow the pending chain,
|
|
676
|
-
// while non-reexecution is used for validating the proposals and collecting their txs.
|
|
677
|
-
// Checkpoint proposals rebuild blobs if the blob client can upload blobs.
|
|
678
|
-
if (!validatorClient) {
|
|
679
|
-
const reexecute = !!config.alwaysReexecuteBlockProposals;
|
|
680
|
-
log.info(`Setting up proposal handler` + (reexecute ? ' with reexecution of proposals' : ''));
|
|
681
|
-
createProposalHandler(config, {
|
|
682
|
-
checkpointsBuilder: validatorCheckpointsBuilder,
|
|
683
|
-
worldState: worldStateSynchronizer,
|
|
684
871
|
epochCache,
|
|
685
|
-
blockSource: archiver,
|
|
686
|
-
l1ToL2MessageSource: archiver,
|
|
687
|
-
p2pClient,
|
|
688
|
-
blobClient,
|
|
689
|
-
dateProvider,
|
|
690
|
-
telemetry
|
|
691
|
-
}).register(p2pClient, reexecute, archiver);
|
|
692
|
-
}
|
|
693
|
-
// Start world state and wait for it to sync to the archiver.
|
|
694
|
-
await worldStateSynchronizer.start();
|
|
695
|
-
// Start p2p. Note that it depends on world state to be running.
|
|
696
|
-
await p2pClient.start();
|
|
697
|
-
let validatorsSentinel;
|
|
698
|
-
let epochPruneWatcher;
|
|
699
|
-
let attestationsBlockWatcher;
|
|
700
|
-
if (!proverOnly) {
|
|
701
|
-
validatorsSentinel = await createSentinel(epochCache, archiver, p2pClient, config);
|
|
702
|
-
if (validatorsSentinel && config.slashInactivityPenalty > 0n) {
|
|
703
|
-
watchers.push(validatorsSentinel);
|
|
704
|
-
}
|
|
705
|
-
if (config.slashPrunePenalty > 0n || config.slashDataWithholdingPenalty > 0n) {
|
|
706
|
-
epochPruneWatcher = new EpochPruneWatcher(archiver, archiver, epochCache, p2pClient.getTxProvider(), validatorCheckpointsBuilder, config);
|
|
707
|
-
watchers.push(epochPruneWatcher);
|
|
708
|
-
}
|
|
709
|
-
// We assume we want to slash for invalid attestations unless all max penalties are set to 0
|
|
710
|
-
if (config.slashProposeInvalidAttestationsPenalty > 0n || config.slashAttestDescendantOfInvalidPenalty > 0n) {
|
|
711
|
-
attestationsBlockWatcher = new AttestationsBlockWatcher(archiver, epochCache, config);
|
|
712
|
-
watchers.push(attestationsBlockWatcher);
|
|
713
|
-
}
|
|
714
|
-
}
|
|
715
|
-
// Start p2p-related services once the archiver has completed sync
|
|
716
|
-
void archiver.waitForInitialSync().then(async ()=>{
|
|
717
|
-
await validatorsSentinel?.start();
|
|
718
|
-
await epochPruneWatcher?.start();
|
|
719
|
-
await attestationsBlockWatcher?.start();
|
|
720
|
-
log.info(`All p2p services started`);
|
|
721
|
-
}).catch((err)=>log.error('Failed to start p2p services after archiver sync', err));
|
|
722
|
-
const globalVariableBuilderConfig = {
|
|
723
|
-
l1Contracts: config.l1Contracts,
|
|
724
|
-
ethereumSlotDuration: config.ethereumSlotDuration,
|
|
725
|
-
rollupVersion: BigInt(config.rollupVersion),
|
|
726
|
-
l1GenesisTime,
|
|
727
|
-
slotDuration: Number(slotDuration)
|
|
728
|
-
};
|
|
729
|
-
const globalVariableBuilder = new GlobalVariableBuilder(dateProvider, publicClient, globalVariableBuilderConfig);
|
|
730
|
-
const feeProvider = new FeeProviderImpl(dateProvider, publicClient, globalVariableBuilderConfig);
|
|
731
|
-
// Validator enabled, create/start relevant service
|
|
732
|
-
let sequencer;
|
|
733
|
-
let slasherClient;
|
|
734
|
-
if (!config.disableValidator && validatorClient) {
|
|
735
|
-
// We create a slasher only if we have a sequencer, since all slashing actions go through the sequencer publisher
|
|
736
|
-
// as they are executed when the node is selected as proposer.
|
|
737
|
-
const validatorAddresses = keyStoreManager ? NodeKeystoreAdapter.fromKeyStoreManager(keyStoreManager).getAddresses() : [];
|
|
738
|
-
slasherClient = await createSlasher(config, config.l1Contracts, getPublicClient(config), watchers, dateProvider, epochCache, validatorAddresses, undefined);
|
|
739
|
-
await slasherClient.start();
|
|
740
|
-
const l1TxUtils = config.sequencerPublisherForwarderAddress ? await createForwarderL1TxUtilsFromSigners(publicClient, keyStoreManager.createAllValidatorPublisherSigners(), config.sequencerPublisherForwarderAddress, {
|
|
741
|
-
...config,
|
|
742
|
-
scope: 'sequencer'
|
|
743
|
-
}, {
|
|
744
872
|
telemetry,
|
|
745
|
-
|
|
746
|
-
dateProvider,
|
|
747
|
-
kzg: Blob.getViemKzgInstance()
|
|
748
|
-
}) : await createL1TxUtilsFromSigners(publicClient, keyStoreManager.createAllValidatorPublisherSigners(), {
|
|
749
|
-
...config,
|
|
750
|
-
scope: 'sequencer'
|
|
873
|
+
dateProvider
|
|
751
874
|
}, {
|
|
752
|
-
|
|
753
|
-
logger: log.createChild('l1-tx-utils'),
|
|
754
|
-
dateProvider,
|
|
755
|
-
kzg: Blob.getViemKzgInstance()
|
|
875
|
+
blockUntilSync: !config.skipArchiverInitialSync
|
|
756
876
|
});
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
877
|
+
started.push(archiver);
|
|
878
|
+
// now create the merkle trees and the world state synchronizer
|
|
879
|
+
const worldStateSynchronizer = await createWorldStateSynchronizer(config, archiver, options.genesis, telemetry);
|
|
880
|
+
started.push(worldStateSynchronizer);
|
|
881
|
+
const useRealVerifiers = config.realProofs || config.debugForceTxProofVerification;
|
|
882
|
+
let peerProofVerifier;
|
|
883
|
+
let rpcProofVerifier;
|
|
884
|
+
if (useRealVerifiers) {
|
|
885
|
+
peerProofVerifier = await BatchChonkVerifier.new(config, config.bbChonkVerifyMaxBatch, 'peer');
|
|
886
|
+
const rpcVerifier = await BBCircuitVerifier.new(config);
|
|
887
|
+
rpcProofVerifier = new QueuedIVCVerifier(rpcVerifier, config.numConcurrentIVCVerifiers);
|
|
888
|
+
} else {
|
|
889
|
+
peerProofVerifier = new TestCircuitVerifier(config.proverTestVerificationDelayMs);
|
|
890
|
+
rpcProofVerifier = new TestCircuitVerifier(config.proverTestVerificationDelayMs);
|
|
891
|
+
}
|
|
892
|
+
started.push(peerProofVerifier, rpcProofVerifier);
|
|
893
|
+
let debugLogStore;
|
|
894
|
+
if (!config.realProofs) {
|
|
895
|
+
log.warn(`Aztec node is accepting fake proofs`);
|
|
896
|
+
debugLogStore = new InMemoryDebugLogStore();
|
|
897
|
+
log.info('Aztec node started in test mode (realProofs set to false) hence debug logs from public functions will be collected and served');
|
|
898
|
+
} else {
|
|
899
|
+
debugLogStore = new NullDebugLogStore();
|
|
900
|
+
}
|
|
901
|
+
const globalVariableBuilderConfig = {
|
|
902
|
+
l1Contracts: config.l1Contracts,
|
|
903
|
+
ethereumSlotDuration: config.ethereumSlotDuration,
|
|
904
|
+
rollupVersion: BigInt(config.rollupVersion),
|
|
905
|
+
l1GenesisTime,
|
|
906
|
+
slotDuration: Number(slotDuration)
|
|
907
|
+
};
|
|
908
|
+
const globalVariableBuilder = new GlobalVariableBuilder(dateProvider, publicClient, globalVariableBuilderConfig);
|
|
909
|
+
const feeProvider = new FeeProviderImpl(dateProvider, publicClient, globalVariableBuilderConfig);
|
|
910
|
+
const proverOnly = config.enableProverNode && config.disableValidator;
|
|
911
|
+
if (proverOnly) {
|
|
912
|
+
log.info('Starting in prover-only mode: skipping validator, sequencer, sentinel, and slasher subsystems');
|
|
913
|
+
}
|
|
914
|
+
// create the tx pool and the p2p client, which will need the l2 block source
|
|
915
|
+
const p2pClient = await createP2PClient(config, archiver, peerProofVerifier, worldStateSynchronizer, epochCache, feeProvider, packageVersion, dateProvider, telemetry, deps.p2pClientDeps);
|
|
916
|
+
started.push(p2pClient);
|
|
917
|
+
// We'll accumulate sentinel watchers here
|
|
918
|
+
const watchers = [];
|
|
919
|
+
// Create FullNodeCheckpointsBuilder for block proposal handling and tx validation.
|
|
920
|
+
// Override maxTxsPerCheckpoint with the validator-specific limit if set.
|
|
921
|
+
const validatorCheckpointsBuilder = new FullNodeCheckpointsBuilder({
|
|
922
|
+
...config,
|
|
923
|
+
l1GenesisTime,
|
|
924
|
+
slotDuration: Number(slotDuration),
|
|
925
|
+
rollupManaLimit,
|
|
926
|
+
maxTxsPerCheckpoint: config.validateMaxTxsPerCheckpoint
|
|
927
|
+
}, worldStateSynchronizer, archiver, dateProvider, telemetry);
|
|
928
|
+
let validatorClient;
|
|
929
|
+
if (!config.disableValidator) {
|
|
930
|
+
// Create validator client if required
|
|
931
|
+
validatorClient = await createValidatorClient(config, {
|
|
932
|
+
checkpointsBuilder: validatorCheckpointsBuilder,
|
|
933
|
+
worldState: worldStateSynchronizer,
|
|
934
|
+
p2pClient,
|
|
935
|
+
telemetry,
|
|
936
|
+
dateProvider,
|
|
937
|
+
epochCache,
|
|
938
|
+
blockSource: archiver,
|
|
939
|
+
l1ToL2MessageSource: archiver,
|
|
940
|
+
keyStoreManager,
|
|
941
|
+
blobClient,
|
|
942
|
+
slashingProtectionDb: deps.slashingProtectionDb
|
|
943
|
+
});
|
|
944
|
+
// If we have a validator client, register it as a source of offenses for the slasher,
|
|
945
|
+
// and have it register callbacks on the p2p client *before* we start it, otherwise messages
|
|
946
|
+
// like attestations or auths will fail.
|
|
947
|
+
if (validatorClient) {
|
|
948
|
+
watchers.push(validatorClient);
|
|
949
|
+
const vc = validatorClient;
|
|
950
|
+
const getValidatorAddresses = ()=>vc.getValidatorAddresses().map((a)=>a.toString());
|
|
951
|
+
validatorClient.getProposalHandler().register(p2pClient, true, archiver, getValidatorAddresses);
|
|
952
|
+
if (!options.dontStartSequencer) {
|
|
953
|
+
await validatorClient.registerHandlers();
|
|
954
|
+
}
|
|
955
|
+
}
|
|
956
|
+
}
|
|
957
|
+
// If there's no validator client, create a ProposalHandler to handle block and checkpoint proposals
|
|
958
|
+
// for monitoring or reexecution. Reexecution (default) allows us to follow the pending chain,
|
|
959
|
+
// while non-reexecution is used for validating the proposals and collecting their txs.
|
|
960
|
+
// Checkpoint proposals rebuild blobs if the blob client can upload blobs.
|
|
961
|
+
if (!validatorClient) {
|
|
962
|
+
const reexecute = !!config.alwaysReexecuteBlockProposals;
|
|
963
|
+
log.info(`Setting up proposal handler` + (reexecute ? ' with reexecution of proposals' : ''));
|
|
964
|
+
createProposalHandler(config, {
|
|
965
|
+
checkpointsBuilder: validatorCheckpointsBuilder,
|
|
966
|
+
worldState: worldStateSynchronizer,
|
|
967
|
+
epochCache,
|
|
968
|
+
blockSource: archiver,
|
|
969
|
+
l1ToL2MessageSource: archiver,
|
|
970
|
+
p2pClient,
|
|
971
|
+
blobClient,
|
|
972
|
+
dateProvider,
|
|
973
|
+
telemetry
|
|
974
|
+
}).register(p2pClient, reexecute, archiver);
|
|
975
|
+
}
|
|
976
|
+
// Start world state and wait for it to sync to the archiver.
|
|
977
|
+
await worldStateSynchronizer.start();
|
|
978
|
+
// Start p2p. Note that it depends on world state to be running.
|
|
979
|
+
await p2pClient.start();
|
|
980
|
+
let validatorsSentinel;
|
|
981
|
+
let epochPruneWatcher;
|
|
982
|
+
let attestationsBlockWatcher;
|
|
983
|
+
if (!proverOnly) {
|
|
984
|
+
validatorsSentinel = await createSentinel(epochCache, archiver, p2pClient, config);
|
|
985
|
+
if (validatorsSentinel && config.slashInactivityPenalty > 0n) {
|
|
986
|
+
watchers.push(validatorsSentinel);
|
|
987
|
+
}
|
|
988
|
+
if (config.slashPrunePenalty > 0n || config.slashDataWithholdingPenalty > 0n) {
|
|
989
|
+
epochPruneWatcher = new EpochPruneWatcher(archiver, archiver, epochCache, p2pClient.getTxProvider(), validatorCheckpointsBuilder, config);
|
|
990
|
+
watchers.push(epochPruneWatcher);
|
|
991
|
+
}
|
|
992
|
+
// We assume we want to slash for invalid attestations unless all max penalties are set to 0
|
|
993
|
+
if (config.slashProposeInvalidAttestationsPenalty > 0n || config.slashAttestDescendantOfInvalidPenalty > 0n) {
|
|
994
|
+
attestationsBlockWatcher = new AttestationsBlockWatcher(archiver, epochCache, config);
|
|
995
|
+
watchers.push(attestationsBlockWatcher);
|
|
996
|
+
}
|
|
997
|
+
}
|
|
998
|
+
// Start p2p-related services once the archiver has completed sync
|
|
999
|
+
void archiver.waitForInitialSync().then(async ()=>{
|
|
1000
|
+
if (validatorsSentinel) {
|
|
1001
|
+
await validatorsSentinel.start();
|
|
1002
|
+
started.push(validatorsSentinel);
|
|
1003
|
+
}
|
|
1004
|
+
if (epochPruneWatcher) {
|
|
1005
|
+
await epochPruneWatcher.start();
|
|
1006
|
+
started.push(epochPruneWatcher);
|
|
1007
|
+
}
|
|
1008
|
+
if (attestationsBlockWatcher) {
|
|
1009
|
+
await attestationsBlockWatcher.start();
|
|
1010
|
+
started.push(attestationsBlockWatcher);
|
|
1011
|
+
}
|
|
1012
|
+
log.info(`All p2p services started`);
|
|
1013
|
+
}).catch((err)=>log.error('Failed to start p2p services after archiver sync', err));
|
|
1014
|
+
// Validator enabled, create/start relevant service
|
|
1015
|
+
let sequencer;
|
|
1016
|
+
let slasherClient;
|
|
1017
|
+
if (!config.disableValidator && validatorClient) {
|
|
1018
|
+
// We create a slasher only if we have a sequencer, since all slashing actions go through the sequencer publisher
|
|
1019
|
+
// as they are executed when the node is selected as proposer.
|
|
1020
|
+
const validatorAddresses = keyStoreManager ? NodeKeystoreAdapter.fromKeyStoreManager(keyStoreManager).getAddresses() : [];
|
|
1021
|
+
slasherClient = await createSlasher(config, config.l1Contracts, getPublicClient(config), watchers, dateProvider, epochCache, validatorAddresses, undefined);
|
|
1022
|
+
await slasherClient.start();
|
|
1023
|
+
started.push(slasherClient);
|
|
1024
|
+
const l1TxUtils = config.sequencerPublisherForwarderAddress ? await createForwarderL1TxUtilsFromSigners(publicClient, keyStoreManager.createAllValidatorPublisherSigners(), config.sequencerPublisherForwarderAddress, {
|
|
764
1025
|
...config,
|
|
765
1026
|
scope: 'sequencer'
|
|
766
1027
|
}, {
|
|
767
1028
|
telemetry,
|
|
768
|
-
logger: log.createChild('l1-tx-utils
|
|
769
|
-
dateProvider
|
|
1029
|
+
logger: log.createChild('l1-tx-utils'),
|
|
1030
|
+
dateProvider,
|
|
1031
|
+
kzg: Blob.getViemKzgInstance()
|
|
1032
|
+
}) : await createL1TxUtilsFromSigners(publicClient, keyStoreManager.createAllValidatorPublisherSigners(), {
|
|
1033
|
+
...config,
|
|
1034
|
+
scope: 'sequencer'
|
|
1035
|
+
}, {
|
|
1036
|
+
telemetry,
|
|
1037
|
+
logger: log.createChild('l1-tx-utils'),
|
|
1038
|
+
dateProvider,
|
|
1039
|
+
kzg: Blob.getViemKzgInstance()
|
|
1040
|
+
});
|
|
1041
|
+
// Create a funder L1TxUtils from the keystore funding account (if configured)
|
|
1042
|
+
const fundingSigner = keyStoreManager?.createFundingSigner();
|
|
1043
|
+
let funderL1TxUtils;
|
|
1044
|
+
if (fundingSigner) {
|
|
1045
|
+
const [funder] = await createL1TxUtilsFromSigners(publicClient, [
|
|
1046
|
+
fundingSigner
|
|
1047
|
+
], {
|
|
1048
|
+
...config,
|
|
1049
|
+
scope: 'sequencer'
|
|
1050
|
+
}, {
|
|
1051
|
+
telemetry,
|
|
1052
|
+
logger: log.createChild('l1-tx-utils:funder'),
|
|
1053
|
+
dateProvider
|
|
1054
|
+
});
|
|
1055
|
+
funderL1TxUtils = funder;
|
|
1056
|
+
}
|
|
1057
|
+
// Create and start the sequencer client
|
|
1058
|
+
const checkpointsBuilder = new CheckpointsBuilder({
|
|
1059
|
+
...config,
|
|
1060
|
+
l1GenesisTime,
|
|
1061
|
+
slotDuration: Number(slotDuration),
|
|
1062
|
+
rollupManaLimit
|
|
1063
|
+
}, worldStateSynchronizer, archiver, dateProvider, telemetry, debugLogStore);
|
|
1064
|
+
sequencer = await SequencerClient.new(config, {
|
|
1065
|
+
...deps,
|
|
1066
|
+
epochCache,
|
|
1067
|
+
l1TxUtils,
|
|
1068
|
+
funderL1TxUtils,
|
|
1069
|
+
validatorClient,
|
|
1070
|
+
p2pClient,
|
|
1071
|
+
worldStateSynchronizer,
|
|
1072
|
+
slasherClient,
|
|
1073
|
+
checkpointsBuilder,
|
|
1074
|
+
l2BlockSource: archiver,
|
|
1075
|
+
l1ToL2MessageSource: archiver,
|
|
1076
|
+
telemetry,
|
|
1077
|
+
dateProvider,
|
|
1078
|
+
blobClient,
|
|
1079
|
+
nodeKeyStore: keyStoreManager,
|
|
1080
|
+
globalVariableBuilder
|
|
770
1081
|
});
|
|
771
|
-
funderL1TxUtils = funder;
|
|
772
1082
|
}
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
}, worldStateSynchronizer, archiver, dateProvider, telemetry, debugLogStore);
|
|
780
|
-
sequencer = await SequencerClient.new(config, {
|
|
781
|
-
...deps,
|
|
782
|
-
epochCache,
|
|
783
|
-
l1TxUtils,
|
|
784
|
-
funderL1TxUtils,
|
|
785
|
-
validatorClient,
|
|
786
|
-
p2pClient,
|
|
787
|
-
worldStateSynchronizer,
|
|
788
|
-
slasherClient,
|
|
789
|
-
checkpointsBuilder,
|
|
790
|
-
l2BlockSource: archiver,
|
|
791
|
-
l1ToL2MessageSource: archiver,
|
|
792
|
-
telemetry,
|
|
793
|
-
dateProvider,
|
|
794
|
-
blobClient,
|
|
795
|
-
nodeKeyStore: keyStoreManager,
|
|
796
|
-
globalVariableBuilder
|
|
797
|
-
});
|
|
798
|
-
}
|
|
799
|
-
if (!options.dontStartSequencer && sequencer) {
|
|
800
|
-
await sequencer.start();
|
|
801
|
-
log.verbose(`Sequencer started`);
|
|
802
|
-
} else if (sequencer) {
|
|
803
|
-
log.warn(`Sequencer created but not started`);
|
|
804
|
-
}
|
|
805
|
-
// Create prover node subsystem if enabled
|
|
806
|
-
let proverNode;
|
|
807
|
-
if (config.enableProverNode) {
|
|
808
|
-
proverNode = await createProverNode(config, {
|
|
809
|
-
...deps.proverNodeDeps,
|
|
810
|
-
telemetry,
|
|
811
|
-
dateProvider,
|
|
812
|
-
archiver,
|
|
813
|
-
worldStateSynchronizer,
|
|
814
|
-
p2pClient,
|
|
815
|
-
epochCache,
|
|
816
|
-
blobClient,
|
|
817
|
-
keyStoreManager
|
|
818
|
-
});
|
|
819
|
-
if (!options.dontStartProverNode) {
|
|
820
|
-
await proverNode.start();
|
|
821
|
-
log.info(`Prover node subsystem started`);
|
|
822
|
-
} else {
|
|
823
|
-
log.info(`Prover node subsystem created but not started`);
|
|
1083
|
+
if (!options.dontStartSequencer && sequencer) {
|
|
1084
|
+
await sequencer.start();
|
|
1085
|
+
started.push(sequencer);
|
|
1086
|
+
log.verbose(`Sequencer started`);
|
|
1087
|
+
} else if (sequencer) {
|
|
1088
|
+
log.warn(`Sequencer created but not started`);
|
|
824
1089
|
}
|
|
1090
|
+
// Create prover node subsystem if enabled
|
|
1091
|
+
let proverNode;
|
|
1092
|
+
if (config.enableProverNode) {
|
|
1093
|
+
proverNode = await createProverNode(config, {
|
|
1094
|
+
...deps.proverNodeDeps,
|
|
1095
|
+
telemetry,
|
|
1096
|
+
dateProvider,
|
|
1097
|
+
archiver,
|
|
1098
|
+
worldStateSynchronizer,
|
|
1099
|
+
p2pClient,
|
|
1100
|
+
epochCache,
|
|
1101
|
+
blobClient,
|
|
1102
|
+
keyStoreManager
|
|
1103
|
+
});
|
|
1104
|
+
if (!options.dontStartProverNode) {
|
|
1105
|
+
await proverNode.start();
|
|
1106
|
+
started.push(proverNode);
|
|
1107
|
+
log.info(`Prover node subsystem started`);
|
|
1108
|
+
} else {
|
|
1109
|
+
log.info(`Prover node subsystem created but not started`);
|
|
1110
|
+
}
|
|
1111
|
+
}
|
|
1112
|
+
const node = new AztecNodeService(config, p2pClient, archiver, archiver, archiver, archiver, worldStateSynchronizer, sequencer, proverNode, slasherClient, validatorsSentinel, epochPruneWatcher, attestationsBlockWatcher, ethereumChain.chainInfo.id, config.rollupVersion, globalVariableBuilder, feeProvider, epochCache, packageVersion, peerProofVerifier, rpcProofVerifier, telemetry, log, blobClient, validatorClient, keyStoreManager, debugLogStore);
|
|
1113
|
+
return node;
|
|
1114
|
+
} catch (err) {
|
|
1115
|
+
log.error('Failed during node creation, stopping started resources', err);
|
|
1116
|
+
for (const resource of started.reverse()){
|
|
1117
|
+
await tryStop(resource);
|
|
1118
|
+
}
|
|
1119
|
+
throw err;
|
|
825
1120
|
}
|
|
826
|
-
const node = new AztecNodeService(config, p2pClient, archiver, archiver, archiver, archiver, worldStateSynchronizer, sequencer, proverNode, slasherClient, validatorsSentinel, epochPruneWatcher, ethereumChain.chainInfo.id, config.rollupVersion, globalVariableBuilder, feeProvider, epochCache, packageVersion, peerProofVerifier, rpcProofVerifier, telemetry, log, blobClient, validatorClient, keyStoreManager, debugLogStore);
|
|
827
|
-
return node;
|
|
828
1121
|
}
|
|
829
1122
|
/**
|
|
830
1123
|
* Returns the sequencer client instance.
|
|
@@ -885,59 +1178,6 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
885
1178
|
};
|
|
886
1179
|
return nodeInfo;
|
|
887
1180
|
}
|
|
888
|
-
/**
|
|
889
|
-
* Get a block specified by its block number, block hash, or 'latest'.
|
|
890
|
-
* @param block - The block parameter (block number, block hash, or 'latest').
|
|
891
|
-
* @returns The requested block.
|
|
892
|
-
*/ async getBlock(block) {
|
|
893
|
-
if (BlockHash.isBlockHash(block)) {
|
|
894
|
-
return this.getBlockByHash(block);
|
|
895
|
-
}
|
|
896
|
-
const blockNumber = block === 'latest' ? await this.getBlockNumber() : block;
|
|
897
|
-
if (blockNumber === BlockNumber.ZERO) {
|
|
898
|
-
return this.buildInitialBlock();
|
|
899
|
-
}
|
|
900
|
-
return await this.blockSource.getL2Block(blockNumber);
|
|
901
|
-
}
|
|
902
|
-
/**
|
|
903
|
-
* Get a block specified by its hash.
|
|
904
|
-
* @param blockHash - The block hash being requested.
|
|
905
|
-
* @returns The requested block.
|
|
906
|
-
*/ async getBlockByHash(blockHash) {
|
|
907
|
-
const initialBlockHash = await this.#getInitialHeaderHash();
|
|
908
|
-
if (blockHash.equals(initialBlockHash)) {
|
|
909
|
-
return this.buildInitialBlock();
|
|
910
|
-
}
|
|
911
|
-
return await this.blockSource.getL2BlockByHash(blockHash);
|
|
912
|
-
}
|
|
913
|
-
buildInitialBlock() {
|
|
914
|
-
const initialHeader = this.worldStateSynchronizer.getCommitted().getInitialHeader();
|
|
915
|
-
return L2Block.empty(initialHeader);
|
|
916
|
-
}
|
|
917
|
-
/**
|
|
918
|
-
* Get a block specified by its archive root.
|
|
919
|
-
* @param archive - The archive root being requested.
|
|
920
|
-
* @returns The requested block.
|
|
921
|
-
*/ async getBlockByArchive(archive) {
|
|
922
|
-
return await this.blockSource.getL2BlockByArchive(archive);
|
|
923
|
-
}
|
|
924
|
-
/**
|
|
925
|
-
* Method to request blocks. Will attempt to return all requested blocks but will return only those available.
|
|
926
|
-
* @param from - The start of the range of blocks to return.
|
|
927
|
-
* @param limit - The maximum number of blocks to obtain.
|
|
928
|
-
* @returns The blocks requested.
|
|
929
|
-
*/ async getBlocks(from, limit) {
|
|
930
|
-
return await this.blockSource.getBlocks(from, BlockNumber(limit)) ?? [];
|
|
931
|
-
}
|
|
932
|
-
async getCheckpoints(from, limit) {
|
|
933
|
-
return await this.blockSource.getCheckpoints(from, limit) ?? [];
|
|
934
|
-
}
|
|
935
|
-
async getCheckpointedBlocks(from, limit) {
|
|
936
|
-
return await this.blockSource.getCheckpointedBlocks(from, limit) ?? [];
|
|
937
|
-
}
|
|
938
|
-
getCheckpointsDataForEpoch(epochNumber) {
|
|
939
|
-
return this.blockSource.getCheckpointsDataForEpoch(epochNumber);
|
|
940
|
-
}
|
|
941
1181
|
async getCurrentMinFees() {
|
|
942
1182
|
return await this.feeProvider.getCurrentMinFees();
|
|
943
1183
|
}
|
|
@@ -954,21 +1194,6 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
954
1194
|
});
|
|
955
1195
|
}
|
|
956
1196
|
/**
|
|
957
|
-
* Method to fetch the latest block number synchronized by the node.
|
|
958
|
-
* @returns The block number.
|
|
959
|
-
*/ async getBlockNumber() {
|
|
960
|
-
return await this.blockSource.getBlockNumber();
|
|
961
|
-
}
|
|
962
|
-
async getProvenBlockNumber() {
|
|
963
|
-
return await this.blockSource.getProvenBlockNumber();
|
|
964
|
-
}
|
|
965
|
-
async getCheckpointedBlockNumber() {
|
|
966
|
-
return await this.blockSource.getCheckpointedL2BlockNumber();
|
|
967
|
-
}
|
|
968
|
-
getCheckpointNumber() {
|
|
969
|
-
return this.blockSource.getCheckpointNumber();
|
|
970
|
-
}
|
|
971
|
-
/**
|
|
972
1197
|
* Method to fetch the version of the package.
|
|
973
1198
|
* @returns The node package version
|
|
974
1199
|
*/ getNodeVersion() {
|
|
@@ -1056,7 +1281,15 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
1056
1281
|
});
|
|
1057
1282
|
throw new Error(`Invalid tx: ${reason}`);
|
|
1058
1283
|
}
|
|
1059
|
-
|
|
1284
|
+
try {
|
|
1285
|
+
await this.p2pClient.sendTx(tx);
|
|
1286
|
+
} catch (err) {
|
|
1287
|
+
this.metrics.receivedTx(timer.ms(), false);
|
|
1288
|
+
this.log.warn(`Mempool rejected tx ${txHash}: ${err.message}`, {
|
|
1289
|
+
txHash
|
|
1290
|
+
});
|
|
1291
|
+
throw err;
|
|
1292
|
+
}
|
|
1060
1293
|
const duration = timer.ms();
|
|
1061
1294
|
this.metrics.receivedTx(duration, true);
|
|
1062
1295
|
this.log.info(`Received tx ${txHash} in ${duration}ms`, {
|
|
@@ -1077,10 +1310,10 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
1077
1310
|
// If the tx is in the pool but not in the archiver, it's pending.
|
|
1078
1311
|
// This handles race conditions between archiver and p2p, where the archiver
|
|
1079
1312
|
// has pruned the block in which a tx was mined, but p2p has not caught up yet.
|
|
1080
|
-
receipt = new TxReceipt(txHash, TxStatus.PENDING, undefined, undefined);
|
|
1313
|
+
receipt = new TxReceipt(txHash, TxStatus.PENDING, /*executionResult=*/ undefined, /*error=*/ undefined);
|
|
1081
1314
|
} else {
|
|
1082
1315
|
// Otherwise, if we don't know the tx, we consider it dropped.
|
|
1083
|
-
receipt = new TxReceipt(txHash, TxStatus.DROPPED, undefined, 'Tx dropped by P2P node');
|
|
1316
|
+
receipt = new TxReceipt(txHash, TxStatus.DROPPED, /*executionResult=*/ undefined, /*error=*/ 'Tx dropped by P2P node');
|
|
1084
1317
|
}
|
|
1085
1318
|
this.debugLogStore.decorateReceiptWithLogs(txHash.toString(), receipt);
|
|
1086
1319
|
return receipt;
|
|
@@ -1092,6 +1325,7 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
1092
1325
|
* Method to stop the aztec node.
|
|
1093
1326
|
*/ async stop() {
|
|
1094
1327
|
this.log.info(`Stopping Aztec Node`);
|
|
1328
|
+
await tryStop(this.attestationsBlockWatcher);
|
|
1095
1329
|
await tryStop(this.validatorsSentinel);
|
|
1096
1330
|
await tryStop(this.epochPruneWatcher);
|
|
1097
1331
|
await tryStop(this.slasherClient);
|
|
@@ -1300,36 +1534,6 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
1300
1534
|
const preimage = await committedDb.getLeafPreimage(MerkleTreeId.PUBLIC_DATA_TREE, lowLeafResult.index);
|
|
1301
1535
|
return preimage.leaf.value;
|
|
1302
1536
|
}
|
|
1303
|
-
async getBlockHeader(block = 'latest') {
|
|
1304
|
-
if (BlockHash.isBlockHash(block)) {
|
|
1305
|
-
const initialBlockHash = await this.#getInitialHeaderHash();
|
|
1306
|
-
if (block.equals(initialBlockHash)) {
|
|
1307
|
-
// Block source doesn't handle initial header so we need to handle the case separately.
|
|
1308
|
-
return this.worldStateSynchronizer.getCommitted().getInitialHeader();
|
|
1309
|
-
}
|
|
1310
|
-
return this.blockSource.getBlockHeaderByHash(block);
|
|
1311
|
-
} else {
|
|
1312
|
-
// Block source doesn't handle initial header so we need to handle the case separately.
|
|
1313
|
-
const blockNumber = block === 'latest' ? await this.getBlockNumber() : block;
|
|
1314
|
-
if (blockNumber === BlockNumber.ZERO) {
|
|
1315
|
-
return this.worldStateSynchronizer.getCommitted().getInitialHeader();
|
|
1316
|
-
}
|
|
1317
|
-
return this.blockSource.getBlockHeader(block);
|
|
1318
|
-
}
|
|
1319
|
-
}
|
|
1320
|
-
/**
|
|
1321
|
-
* Get a block header specified by its archive root.
|
|
1322
|
-
* @param archive - The archive root being requested.
|
|
1323
|
-
* @returns The requested block header.
|
|
1324
|
-
*/ async getBlockHeaderByArchive(archive) {
|
|
1325
|
-
return await this.blockSource.getBlockHeaderByArchive(archive);
|
|
1326
|
-
}
|
|
1327
|
-
getBlockData(number) {
|
|
1328
|
-
return this.blockSource.getBlockData(number);
|
|
1329
|
-
}
|
|
1330
|
-
getBlockDataByArchive(archive) {
|
|
1331
|
-
return this.blockSource.getBlockDataByArchive(archive);
|
|
1332
|
-
}
|
|
1333
1537
|
/**
|
|
1334
1538
|
* Simulates the public part of a transaction with the current state.
|
|
1335
1539
|
* @param tx - The transaction to simulate.
|
|
@@ -1680,20 +1884,23 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
1680
1884
|
if (BlockHash.isBlockHash(block)) {
|
|
1681
1885
|
const initialBlockHash = await this.#getInitialHeaderHash();
|
|
1682
1886
|
if (block.equals(initialBlockHash)) {
|
|
1683
|
-
// Block
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1887
|
+
// Block 0 is a first-class historical block: its state lives in the trees' persisted
|
|
1888
|
+
// block-0 payload. Resolving the genesis hash to block number 0 lets the snapshot path
|
|
1889
|
+
// pin reads to genesis state even after the node has advanced past it.
|
|
1890
|
+
blockNumber = BlockNumber.ZERO;
|
|
1891
|
+
} else {
|
|
1892
|
+
const header = await this.blockSource.getBlockHeaderByHash(block);
|
|
1893
|
+
if (!header) {
|
|
1894
|
+
throw new Error(`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.`);
|
|
1895
|
+
}
|
|
1896
|
+
blockNumber = header.getBlockNumber();
|
|
1689
1897
|
}
|
|
1690
|
-
blockNumber = header.getBlockNumber();
|
|
1691
1898
|
} else {
|
|
1692
1899
|
blockNumber = block;
|
|
1693
1900
|
}
|
|
1694
1901
|
// Check it's within world state sync range
|
|
1695
1902
|
if (blockNumber > blockSyncedTo) {
|
|
1696
|
-
throw new Error(`Queried block ${block} not yet synced by the node (node is synced upto ${blockSyncedTo}).`);
|
|
1903
|
+
throw new Error(`Queried block ${inspectBlockParameter(block)} not yet synced by the node (node is synced upto ${blockSyncedTo}).`);
|
|
1697
1904
|
}
|
|
1698
1905
|
this.log.debug(`Using snapshot for block ${blockNumber}, world state synced upto ${blockSyncedTo}`);
|
|
1699
1906
|
const snapshot = this.worldStateSynchronizer.getSnapshot(blockNumber);
|
|
@@ -1701,27 +1908,36 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
1701
1908
|
if (BlockHash.isBlockHash(block)) {
|
|
1702
1909
|
const blockHash = await snapshot.getLeafValue(MerkleTreeId.ARCHIVE, BigInt(blockNumber));
|
|
1703
1910
|
if (!blockHash || !block.equals(blockHash)) {
|
|
1704
|
-
|
|
1911
|
+
const initialBlockHash = await this.#getInitialHeaderHash();
|
|
1912
|
+
throw new Error(`Block hash ${block.toString()} not found in world state at block number ${blockNumber} (world state has ${blockHash?.toString() ?? 'no hash'} at that index, genesis header hash is ${initialBlockHash.toString()}). If the node API has been queried with anchor block hash possibly a reorg has occurred.`);
|
|
1705
1913
|
}
|
|
1706
1914
|
}
|
|
1707
1915
|
return snapshot;
|
|
1708
1916
|
}
|
|
1709
|
-
/** Resolves
|
|
1710
|
-
|
|
1711
|
-
|
|
1917
|
+
/** Resolves any {@link BlockParameter} variant to a concrete block number. */ async resolveBlockNumber(block) {
|
|
1918
|
+
const resolved = await this.resolveBlockParameter(block);
|
|
1919
|
+
if (resolved.number !== undefined) {
|
|
1920
|
+
return resolved.number;
|
|
1712
1921
|
}
|
|
1713
|
-
if (
|
|
1922
|
+
if (resolved.hash !== undefined) {
|
|
1714
1923
|
const initialBlockHash = await this.#getInitialHeaderHash();
|
|
1715
|
-
if (
|
|
1924
|
+
if (resolved.hash.equals(initialBlockHash)) {
|
|
1716
1925
|
return BlockNumber.ZERO;
|
|
1717
1926
|
}
|
|
1718
|
-
const header = await this.blockSource.getBlockHeaderByHash(
|
|
1927
|
+
const header = await this.blockSource.getBlockHeaderByHash(resolved.hash);
|
|
1928
|
+
if (!header) {
|
|
1929
|
+
throw new Error(`Block hash ${resolved.hash.toString()} not found.`);
|
|
1930
|
+
}
|
|
1931
|
+
return header.getBlockNumber();
|
|
1932
|
+
}
|
|
1933
|
+
if (resolved.archive !== undefined) {
|
|
1934
|
+
const header = await this.blockSource.getBlockHeaderByArchive(resolved.archive);
|
|
1719
1935
|
if (!header) {
|
|
1720
|
-
throw new Error(`Block
|
|
1936
|
+
throw new Error(`Block with archive ${resolved.archive.toString()} not found.`);
|
|
1721
1937
|
}
|
|
1722
1938
|
return header.getBlockNumber();
|
|
1723
1939
|
}
|
|
1724
|
-
|
|
1940
|
+
throw new BadRequestError(`Invalid BlockParameter: ${JSON.stringify(block)}`);
|
|
1725
1941
|
}
|
|
1726
1942
|
/**
|
|
1727
1943
|
* Ensure we fully sync the world state
|