@aztec/aztec-node 0.0.1-commit.aada20e3 → 0.0.1-commit.b1c78909e
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/server.d.ts +21 -7
- package/dest/aztec-node/server.d.ts.map +1 -1
- package/dest/aztec-node/server.js +277 -104
- package/dest/sentinel/factory.d.ts +2 -2
- package/dest/sentinel/factory.d.ts.map +1 -1
- package/dest/sentinel/sentinel.d.ts +2 -2
- package/dest/sentinel/sentinel.d.ts.map +1 -1
- package/dest/sentinel/sentinel.js +56 -30
- 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/server.ts +341 -119
- package/src/sentinel/factory.ts +1 -1
- package/src/sentinel/sentinel.ts +59 -26
- package/src/sentinel/store.ts +12 -12
|
@@ -374,12 +374,13 @@ var _dec, _initProto;
|
|
|
374
374
|
import { createArchiver } from '@aztec/archiver';
|
|
375
375
|
import { BBCircuitVerifier, QueuedIVCVerifier, TestCircuitVerifier } from '@aztec/bb-prover';
|
|
376
376
|
import { createBlobClientWithFileStores } from '@aztec/blob-client/client';
|
|
377
|
+
import { Blob } from '@aztec/blob-lib';
|
|
377
378
|
import { EpochCache } from '@aztec/epoch-cache';
|
|
378
379
|
import { createEthereumChain } from '@aztec/ethereum/chain';
|
|
379
380
|
import { getPublicClient } from '@aztec/ethereum/client';
|
|
380
381
|
import { RegistryContract, RollupContract } from '@aztec/ethereum/contracts';
|
|
381
382
|
import { BlockNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
382
|
-
import { compactArray, pick } from '@aztec/foundation/collection';
|
|
383
|
+
import { compactArray, pick, unique } from '@aztec/foundation/collection';
|
|
383
384
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
384
385
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
385
386
|
import { BadRequestError } from '@aztec/foundation/json-rpc';
|
|
@@ -389,9 +390,11 @@ import { DateProvider, Timer } from '@aztec/foundation/timer';
|
|
|
389
390
|
import { MembershipWitness } from '@aztec/foundation/trees';
|
|
390
391
|
import { KeystoreManager, loadKeystores, mergeKeystores } from '@aztec/node-keystore';
|
|
391
392
|
import { trySnapshotSync, uploadSnapshot } from '@aztec/node-lib/actions';
|
|
392
|
-
import {
|
|
393
|
-
import { createP2PClient, getDefaultAllowedSetupFunctions } from '@aztec/p2p';
|
|
393
|
+
import { createForwarderL1TxUtilsFromSigners, createL1TxUtilsFromSigners } from '@aztec/node-lib/factories';
|
|
394
|
+
import { createP2PClient, createTxValidatorForAcceptingTxsOverRPC, getDefaultAllowedSetupFunctions } from '@aztec/p2p';
|
|
394
395
|
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
396
|
+
import { createProverNode } from '@aztec/prover-node';
|
|
397
|
+
import { createKeyStoreForProver } from '@aztec/prover-node/config';
|
|
395
398
|
import { GlobalVariableBuilder, SequencerClient } from '@aztec/sequencer-client';
|
|
396
399
|
import { PublicProcessorFactory } from '@aztec/simulator/server';
|
|
397
400
|
import { AttestationsBlockWatcher, EpochPruneWatcher, createSlasher } from '@aztec/slasher';
|
|
@@ -402,13 +405,13 @@ import { GasFees } from '@aztec/stdlib/gas';
|
|
|
402
405
|
import { computePublicDataTreeLeafSlot } from '@aztec/stdlib/hash';
|
|
403
406
|
import { AztecNodeAdminConfigSchema } from '@aztec/stdlib/interfaces/client';
|
|
404
407
|
import { tryStop } from '@aztec/stdlib/interfaces/server';
|
|
408
|
+
import { InMemoryDebugLogStore, NullDebugLogStore } from '@aztec/stdlib/logs';
|
|
405
409
|
import { InboxLeaf } from '@aztec/stdlib/messaging';
|
|
406
|
-
import { P2PClientType } from '@aztec/stdlib/p2p';
|
|
407
410
|
import { MerkleTreeId, NullifierMembershipWitness, PublicDataWitness } from '@aztec/stdlib/trees';
|
|
408
411
|
import { PublicSimulationOutput, TxReceipt, TxStatus } from '@aztec/stdlib/tx';
|
|
409
412
|
import { getPackageVersion } from '@aztec/stdlib/update-checker';
|
|
410
413
|
import { Attributes, getTelemetryClient, trackSpan } from '@aztec/telemetry-client';
|
|
411
|
-
import { FullNodeCheckpointsBuilder as CheckpointsBuilder, FullNodeCheckpointsBuilder, NodeKeystoreAdapter, ValidatorClient, createBlockProposalHandler, createValidatorClient
|
|
414
|
+
import { FullNodeCheckpointsBuilder as CheckpointsBuilder, FullNodeCheckpointsBuilder, NodeKeystoreAdapter, ValidatorClient, createBlockProposalHandler, createValidatorClient } from '@aztec/validator-client';
|
|
412
415
|
import { createWorldStateSynchronizer } from '@aztec/world-state';
|
|
413
416
|
import { createPublicClient, fallback, http } from 'viem';
|
|
414
417
|
import { createSentinel } from '../sentinel/factory.js';
|
|
@@ -428,6 +431,7 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
428
431
|
l1ToL2MessageSource;
|
|
429
432
|
worldStateSynchronizer;
|
|
430
433
|
sequencer;
|
|
434
|
+
proverNode;
|
|
431
435
|
slasherClient;
|
|
432
436
|
validatorsSentinel;
|
|
433
437
|
epochPruneWatcher;
|
|
@@ -440,6 +444,9 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
440
444
|
telemetry;
|
|
441
445
|
log;
|
|
442
446
|
blobClient;
|
|
447
|
+
validatorClient;
|
|
448
|
+
keyStoreManager;
|
|
449
|
+
debugLogStore;
|
|
443
450
|
static{
|
|
444
451
|
({ e: [_initProto] } = _apply_decs_2203_r(this, [
|
|
445
452
|
[
|
|
@@ -454,7 +461,7 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
454
461
|
// Prevent two snapshot operations to happen simultaneously
|
|
455
462
|
isUploadingSnapshot;
|
|
456
463
|
tracer;
|
|
457
|
-
constructor(config, p2pClient, blockSource, logsSource, contractDataSource, l1ToL2MessageSource, worldStateSynchronizer, sequencer, slasherClient, validatorsSentinel, epochPruneWatcher, l1ChainId, version, globalVariableBuilder, epochCache, packageVersion, proofVerifier, telemetry = getTelemetryClient(), log = createLogger('node'), blobClient){
|
|
464
|
+
constructor(config, p2pClient, blockSource, logsSource, contractDataSource, l1ToL2MessageSource, worldStateSynchronizer, sequencer, proverNode, slasherClient, validatorsSentinel, epochPruneWatcher, l1ChainId, version, globalVariableBuilder, epochCache, packageVersion, proofVerifier, telemetry = getTelemetryClient(), log = createLogger('node'), blobClient, validatorClient, keyStoreManager, debugLogStore = new NullDebugLogStore()){
|
|
458
465
|
this.config = config;
|
|
459
466
|
this.p2pClient = p2pClient;
|
|
460
467
|
this.blockSource = blockSource;
|
|
@@ -463,6 +470,7 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
463
470
|
this.l1ToL2MessageSource = l1ToL2MessageSource;
|
|
464
471
|
this.worldStateSynchronizer = worldStateSynchronizer;
|
|
465
472
|
this.sequencer = sequencer;
|
|
473
|
+
this.proverNode = proverNode;
|
|
466
474
|
this.slasherClient = slasherClient;
|
|
467
475
|
this.validatorsSentinel = validatorsSentinel;
|
|
468
476
|
this.epochPruneWatcher = epochPruneWatcher;
|
|
@@ -475,12 +483,21 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
475
483
|
this.telemetry = telemetry;
|
|
476
484
|
this.log = log;
|
|
477
485
|
this.blobClient = blobClient;
|
|
486
|
+
this.validatorClient = validatorClient;
|
|
487
|
+
this.keyStoreManager = keyStoreManager;
|
|
488
|
+
this.debugLogStore = debugLogStore;
|
|
478
489
|
this.initialHeaderHashPromise = (_initProto(this), undefined);
|
|
479
490
|
this.isUploadingSnapshot = false;
|
|
480
491
|
this.metrics = new NodeMetrics(telemetry, 'AztecNodeService');
|
|
481
492
|
this.tracer = telemetry.getTracer('AztecNodeService');
|
|
482
493
|
this.log.info(`Aztec Node version: ${this.packageVersion}`);
|
|
483
494
|
this.log.info(`Aztec Node started on chain 0x${l1ChainId.toString(16)}`, config.l1Contracts);
|
|
495
|
+
// A defensive check that protects us against introducing a bug in the complex `createAndSync` function. We must
|
|
496
|
+
// never have debugLogStore enabled when not in test mode because then we would be accumulating debug logs in
|
|
497
|
+
// memory which could be a DoS vector on the sequencer (since no fees are paid for debug logs).
|
|
498
|
+
if (debugLogStore.isEnabled && config.realProofs) {
|
|
499
|
+
throw new Error('debugLogStore should never be enabled when realProofs are set');
|
|
500
|
+
}
|
|
484
501
|
}
|
|
485
502
|
async getWorldStateSyncStatus() {
|
|
486
503
|
const status = await this.worldStateSynchronizer.status();
|
|
@@ -502,16 +519,27 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
502
519
|
const telemetry = deps.telemetry ?? getTelemetryClient();
|
|
503
520
|
const dateProvider = deps.dateProvider ?? new DateProvider();
|
|
504
521
|
const ethereumChain = createEthereumChain(config.l1RpcUrls, config.l1ChainId);
|
|
505
|
-
// Build a key store from file if given or from environment otherwise
|
|
522
|
+
// Build a key store from file if given or from environment otherwise.
|
|
523
|
+
// We keep the raw KeyStore available so we can merge with prover keys if enableProverNode is set.
|
|
506
524
|
let keyStoreManager;
|
|
507
525
|
const keyStoreProvided = config.keyStoreDirectory !== undefined && config.keyStoreDirectory.length > 0;
|
|
508
526
|
if (keyStoreProvided) {
|
|
509
527
|
const keyStores = loadKeystores(config.keyStoreDirectory);
|
|
510
528
|
keyStoreManager = new KeystoreManager(mergeKeystores(keyStores));
|
|
511
529
|
} else {
|
|
512
|
-
const
|
|
513
|
-
|
|
514
|
-
|
|
530
|
+
const rawKeyStores = [];
|
|
531
|
+
const validatorKeyStore = createKeyStoreForValidator(config);
|
|
532
|
+
if (validatorKeyStore) {
|
|
533
|
+
rawKeyStores.push(validatorKeyStore);
|
|
534
|
+
}
|
|
535
|
+
if (config.enableProverNode) {
|
|
536
|
+
const proverKeyStore = createKeyStoreForProver(config);
|
|
537
|
+
if (proverKeyStore) {
|
|
538
|
+
rawKeyStores.push(proverKeyStore);
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
if (rawKeyStores.length > 0) {
|
|
542
|
+
keyStoreManager = new KeystoreManager(rawKeyStores.length === 1 ? rawKeyStores[0] : mergeKeystores(rawKeyStores));
|
|
515
543
|
}
|
|
516
544
|
}
|
|
517
545
|
await keyStoreManager?.validateSigners();
|
|
@@ -520,8 +548,8 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
520
548
|
if (keyStoreManager === undefined) {
|
|
521
549
|
throw new Error('Failed to create key store, a requirement for running a validator');
|
|
522
550
|
}
|
|
523
|
-
if (!keyStoreProvided) {
|
|
524
|
-
log.warn(
|
|
551
|
+
if (!keyStoreProvided && process.env.NODE_ENV !== 'test') {
|
|
552
|
+
log.warn("Keystore created from env: it's recommended to use a file-based key store for production");
|
|
525
553
|
}
|
|
526
554
|
ValidatorClient.validateKeyStoreConfiguration(keyStoreManager, log);
|
|
527
555
|
}
|
|
@@ -543,16 +571,17 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
543
571
|
...l1ContractsAddresses
|
|
544
572
|
};
|
|
545
573
|
const rollupContract = new RollupContract(publicClient, config.l1Contracts.rollupAddress.toString());
|
|
546
|
-
const [l1GenesisTime, slotDuration, rollupVersionFromRollup] = await Promise.all([
|
|
574
|
+
const [l1GenesisTime, slotDuration, rollupVersionFromRollup, rollupManaLimit] = await Promise.all([
|
|
547
575
|
rollupContract.getL1GenesisTime(),
|
|
548
576
|
rollupContract.getSlotDuration(),
|
|
549
|
-
rollupContract.getVersion()
|
|
577
|
+
rollupContract.getVersion(),
|
|
578
|
+
rollupContract.getManaLimit().then(Number)
|
|
550
579
|
]);
|
|
551
580
|
config.rollupVersion ??= Number(rollupVersionFromRollup);
|
|
552
581
|
if (config.rollupVersion !== Number(rollupVersionFromRollup)) {
|
|
553
582
|
log.warn(`Registry looked up and returned a rollup with version (${config.rollupVersion}), but this does not match with version detected from the rollup directly: (${rollupVersionFromRollup}).`);
|
|
554
583
|
}
|
|
555
|
-
const blobClient = await createBlobClientWithFileStores(config,
|
|
584
|
+
const blobClient = await createBlobClientWithFileStores(config, log.createChild('blob-client'));
|
|
556
585
|
// attempt snapshot sync if possible
|
|
557
586
|
await trySnapshotSync(config, log);
|
|
558
587
|
const epochCache = await EpochCache.create(config.l1Contracts.rollupAddress, config, {
|
|
@@ -569,48 +598,63 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
569
598
|
// now create the merkle trees and the world state synchronizer
|
|
570
599
|
const worldStateSynchronizer = await createWorldStateSynchronizer(config, archiver, options.prefilledPublicData, telemetry);
|
|
571
600
|
const circuitVerifier = config.realProofs || config.debugForceTxProofVerification ? await BBCircuitVerifier.new(config) : new TestCircuitVerifier(config.proverTestVerificationDelayMs);
|
|
601
|
+
let debugLogStore;
|
|
572
602
|
if (!config.realProofs) {
|
|
573
603
|
log.warn(`Aztec node is accepting fake proofs`);
|
|
604
|
+
debugLogStore = new InMemoryDebugLogStore();
|
|
605
|
+
log.info('Aztec node started in test mode (realProofs set to false) hence debug logs from public functions will be collected and served');
|
|
606
|
+
} else {
|
|
607
|
+
debugLogStore = new NullDebugLogStore();
|
|
574
608
|
}
|
|
575
609
|
const proofVerifier = new QueuedIVCVerifier(config, circuitVerifier);
|
|
610
|
+
const proverOnly = config.enableProverNode && config.disableValidator;
|
|
611
|
+
if (proverOnly) {
|
|
612
|
+
log.info('Starting in prover-only mode: skipping validator, sequencer, sentinel, and slasher subsystems');
|
|
613
|
+
}
|
|
576
614
|
// create the tx pool and the p2p client, which will need the l2 block source
|
|
577
|
-
const p2pClient = await createP2PClient(
|
|
578
|
-
// We
|
|
579
|
-
|
|
580
|
-
// Create FullNodeCheckpointsBuilder for
|
|
615
|
+
const p2pClient = await createP2PClient(config, archiver, proofVerifier, worldStateSynchronizer, epochCache, packageVersion, dateProvider, telemetry, deps.p2pClientDeps);
|
|
616
|
+
// We'll accumulate sentinel watchers here
|
|
617
|
+
const watchers = [];
|
|
618
|
+
// Create FullNodeCheckpointsBuilder for block proposal handling and tx validation.
|
|
619
|
+
// Override maxTxsPerCheckpoint with the validator-specific limit if set.
|
|
581
620
|
const validatorCheckpointsBuilder = new FullNodeCheckpointsBuilder({
|
|
582
621
|
...config,
|
|
583
622
|
l1GenesisTime,
|
|
584
|
-
slotDuration: Number(slotDuration)
|
|
623
|
+
slotDuration: Number(slotDuration),
|
|
624
|
+
rollupManaLimit,
|
|
625
|
+
maxTxsPerCheckpoint: config.validateMaxTxsPerCheckpoint
|
|
585
626
|
}, worldStateSynchronizer, archiver, dateProvider, telemetry);
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
627
|
+
let validatorClient;
|
|
628
|
+
if (!proverOnly) {
|
|
629
|
+
// Create validator client if required
|
|
630
|
+
validatorClient = await createValidatorClient(config, {
|
|
631
|
+
checkpointsBuilder: validatorCheckpointsBuilder,
|
|
632
|
+
worldState: worldStateSynchronizer,
|
|
633
|
+
p2pClient,
|
|
634
|
+
telemetry,
|
|
635
|
+
dateProvider,
|
|
636
|
+
epochCache,
|
|
637
|
+
blockSource: archiver,
|
|
638
|
+
l1ToL2MessageSource: archiver,
|
|
639
|
+
keyStoreManager,
|
|
640
|
+
blobClient
|
|
641
|
+
});
|
|
642
|
+
// If we have a validator client, register it as a source of offenses for the slasher,
|
|
643
|
+
// and have it register callbacks on the p2p client *before* we start it, otherwise messages
|
|
644
|
+
// like attestations or auths will fail.
|
|
645
|
+
if (validatorClient) {
|
|
646
|
+
watchers.push(validatorClient);
|
|
647
|
+
if (!options.dontStartSequencer) {
|
|
648
|
+
await validatorClient.registerHandlers();
|
|
649
|
+
}
|
|
608
650
|
}
|
|
609
651
|
}
|
|
610
|
-
// If there's no validator client
|
|
611
|
-
//
|
|
612
|
-
|
|
613
|
-
|
|
652
|
+
// If there's no validator client, create a BlockProposalHandler to handle block proposals
|
|
653
|
+
// for monitoring or reexecution. Reexecution (default) allows us to follow the pending chain,
|
|
654
|
+
// while non-reexecution is used for validating the proposals and collecting their txs.
|
|
655
|
+
if (!validatorClient) {
|
|
656
|
+
const reexecute = !!config.alwaysReexecuteBlockProposals;
|
|
657
|
+
log.info(`Setting up block proposal handler` + (reexecute ? ' with reexecution of proposals' : ''));
|
|
614
658
|
createBlockProposalHandler(config, {
|
|
615
659
|
checkpointsBuilder: validatorCheckpointsBuilder,
|
|
616
660
|
worldState: worldStateSynchronizer,
|
|
@@ -620,26 +664,29 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
620
664
|
p2pClient,
|
|
621
665
|
dateProvider,
|
|
622
666
|
telemetry
|
|
623
|
-
}).
|
|
667
|
+
}).register(p2pClient, reexecute);
|
|
624
668
|
}
|
|
625
669
|
// Start world state and wait for it to sync to the archiver.
|
|
626
670
|
await worldStateSynchronizer.start();
|
|
627
671
|
// Start p2p. Note that it depends on world state to be running.
|
|
628
672
|
await p2pClient.start();
|
|
629
|
-
|
|
630
|
-
if (validatorsSentinel && config.slashInactivityPenalty > 0n) {
|
|
631
|
-
watchers.push(validatorsSentinel);
|
|
632
|
-
}
|
|
673
|
+
let validatorsSentinel;
|
|
633
674
|
let epochPruneWatcher;
|
|
634
|
-
if (config.slashPrunePenalty > 0n || config.slashDataWithholdingPenalty > 0n) {
|
|
635
|
-
epochPruneWatcher = new EpochPruneWatcher(archiver, archiver, epochCache, p2pClient.getTxProvider(), validatorCheckpointsBuilder, config);
|
|
636
|
-
watchers.push(epochPruneWatcher);
|
|
637
|
-
}
|
|
638
|
-
// We assume we want to slash for invalid attestations unless all max penalties are set to 0
|
|
639
675
|
let attestationsBlockWatcher;
|
|
640
|
-
if (
|
|
641
|
-
|
|
642
|
-
|
|
676
|
+
if (!proverOnly) {
|
|
677
|
+
validatorsSentinel = await createSentinel(epochCache, archiver, p2pClient, config);
|
|
678
|
+
if (validatorsSentinel && config.slashInactivityPenalty > 0n) {
|
|
679
|
+
watchers.push(validatorsSentinel);
|
|
680
|
+
}
|
|
681
|
+
if (config.slashPrunePenalty > 0n || config.slashDataWithholdingPenalty > 0n) {
|
|
682
|
+
epochPruneWatcher = new EpochPruneWatcher(archiver, archiver, epochCache, p2pClient.getTxProvider(), validatorCheckpointsBuilder, config);
|
|
683
|
+
watchers.push(epochPruneWatcher);
|
|
684
|
+
}
|
|
685
|
+
// We assume we want to slash for invalid attestations unless all max penalties are set to 0
|
|
686
|
+
if (config.slashProposeInvalidAttestationsPenalty > 0n || config.slashAttestDescendantOfInvalidPenalty > 0n) {
|
|
687
|
+
attestationsBlockWatcher = new AttestationsBlockWatcher(archiver, epochCache, config);
|
|
688
|
+
watchers.push(attestationsBlockWatcher);
|
|
689
|
+
}
|
|
643
690
|
}
|
|
644
691
|
// Start p2p-related services once the archiver has completed sync
|
|
645
692
|
void archiver.waitForInitialSync().then(async ()=>{
|
|
@@ -658,27 +705,30 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
658
705
|
const validatorAddresses = keyStoreManager ? NodeKeystoreAdapter.fromKeyStoreManager(keyStoreManager).getAddresses() : [];
|
|
659
706
|
slasherClient = await createSlasher(config, config.l1Contracts, getPublicClient(config), watchers, dateProvider, epochCache, validatorAddresses, undefined);
|
|
660
707
|
await slasherClient.start();
|
|
661
|
-
const l1TxUtils = config.
|
|
708
|
+
const l1TxUtils = config.sequencerPublisherForwarderAddress ? await createForwarderL1TxUtilsFromSigners(publicClient, keyStoreManager.createAllValidatorPublisherSigners(), config.sequencerPublisherForwarderAddress, {
|
|
662
709
|
...config,
|
|
663
710
|
scope: 'sequencer'
|
|
664
711
|
}, {
|
|
665
712
|
telemetry,
|
|
666
713
|
logger: log.createChild('l1-tx-utils'),
|
|
667
|
-
dateProvider
|
|
668
|
-
|
|
714
|
+
dateProvider,
|
|
715
|
+
kzg: Blob.getViemKzgInstance()
|
|
716
|
+
}) : await createL1TxUtilsFromSigners(publicClient, keyStoreManager.createAllValidatorPublisherSigners(), {
|
|
669
717
|
...config,
|
|
670
718
|
scope: 'sequencer'
|
|
671
719
|
}, {
|
|
672
720
|
telemetry,
|
|
673
721
|
logger: log.createChild('l1-tx-utils'),
|
|
674
|
-
dateProvider
|
|
722
|
+
dateProvider,
|
|
723
|
+
kzg: Blob.getViemKzgInstance()
|
|
675
724
|
});
|
|
676
725
|
// Create and start the sequencer client
|
|
677
726
|
const checkpointsBuilder = new CheckpointsBuilder({
|
|
678
727
|
...config,
|
|
679
728
|
l1GenesisTime,
|
|
680
|
-
slotDuration: Number(slotDuration)
|
|
681
|
-
|
|
729
|
+
slotDuration: Number(slotDuration),
|
|
730
|
+
rollupManaLimit
|
|
731
|
+
}, worldStateSynchronizer, archiver, dateProvider, telemetry, debugLogStore);
|
|
682
732
|
sequencer = await SequencerClient.new(config, {
|
|
683
733
|
...deps,
|
|
684
734
|
epochCache,
|
|
@@ -702,13 +752,35 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
702
752
|
} else if (sequencer) {
|
|
703
753
|
log.warn(`Sequencer created but not started`);
|
|
704
754
|
}
|
|
755
|
+
// Create prover node subsystem if enabled
|
|
756
|
+
let proverNode;
|
|
757
|
+
if (config.enableProverNode) {
|
|
758
|
+
proverNode = await createProverNode(config, {
|
|
759
|
+
...deps.proverNodeDeps,
|
|
760
|
+
telemetry,
|
|
761
|
+
dateProvider,
|
|
762
|
+
archiver,
|
|
763
|
+
worldStateSynchronizer,
|
|
764
|
+
p2pClient,
|
|
765
|
+
epochCache,
|
|
766
|
+
blobClient,
|
|
767
|
+
keyStoreManager
|
|
768
|
+
});
|
|
769
|
+
if (!options.dontStartProverNode) {
|
|
770
|
+
await proverNode.start();
|
|
771
|
+
log.info(`Prover node subsystem started`);
|
|
772
|
+
} else {
|
|
773
|
+
log.info(`Prover node subsystem created but not started`);
|
|
774
|
+
}
|
|
775
|
+
}
|
|
705
776
|
const globalVariableBuilder = new GlobalVariableBuilder({
|
|
706
777
|
...config,
|
|
707
778
|
rollupVersion: BigInt(config.rollupVersion),
|
|
708
779
|
l1GenesisTime,
|
|
709
780
|
slotDuration: Number(slotDuration)
|
|
710
781
|
});
|
|
711
|
-
|
|
782
|
+
const node = new AztecNodeService(config, p2pClient, archiver, archiver, archiver, archiver, worldStateSynchronizer, sequencer, proverNode, slasherClient, validatorsSentinel, epochPruneWatcher, ethereumChain.chainInfo.id, config.rollupVersion, globalVariableBuilder, epochCache, packageVersion, proofVerifier, telemetry, log, blobClient, validatorClient, keyStoreManager, debugLogStore);
|
|
783
|
+
return node;
|
|
712
784
|
}
|
|
713
785
|
/**
|
|
714
786
|
* Returns the sequencer client instance.
|
|
@@ -716,6 +788,9 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
716
788
|
*/ getSequencer() {
|
|
717
789
|
return this.sequencer;
|
|
718
790
|
}
|
|
791
|
+
/** Returns the prover node subsystem, if enabled. */ getProverNode() {
|
|
792
|
+
return this.proverNode;
|
|
793
|
+
}
|
|
719
794
|
getBlockSource() {
|
|
720
795
|
return this.blockSource;
|
|
721
796
|
}
|
|
@@ -735,7 +810,10 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
735
810
|
return Promise.resolve(this.p2pClient.getEnr()?.encodeTxt());
|
|
736
811
|
}
|
|
737
812
|
async getAllowedPublicSetup() {
|
|
738
|
-
return
|
|
813
|
+
return [
|
|
814
|
+
...await getDefaultAllowedSetupFunctions(),
|
|
815
|
+
...this.config.txPublicSetupAllowListExtend ?? []
|
|
816
|
+
];
|
|
739
817
|
}
|
|
740
818
|
/**
|
|
741
819
|
* Method to determine if the node is ready to accept transactions.
|
|
@@ -758,7 +836,8 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
758
836
|
rollupVersion,
|
|
759
837
|
enr,
|
|
760
838
|
l1ContractAddresses: contractAddresses,
|
|
761
|
-
protocolContractAddresses: protocolContractAddresses
|
|
839
|
+
protocolContractAddresses: protocolContractAddresses,
|
|
840
|
+
realProofs: !!this.config.realProofs
|
|
762
841
|
};
|
|
763
842
|
return nodeInfo;
|
|
764
843
|
}
|
|
@@ -839,6 +918,9 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
839
918
|
async getCheckpointedBlockNumber() {
|
|
840
919
|
return await this.blockSource.getCheckpointedL2BlockNumber();
|
|
841
920
|
}
|
|
921
|
+
getCheckpointNumber() {
|
|
922
|
+
return this.blockSource.getCheckpointNumber();
|
|
923
|
+
}
|
|
842
924
|
/**
|
|
843
925
|
* Method to fetch the version of the package.
|
|
844
926
|
* @returns The node package version
|
|
@@ -920,8 +1002,9 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
920
1002
|
throw new Error(`Invalid tx: ${reason}`);
|
|
921
1003
|
}
|
|
922
1004
|
await this.p2pClient.sendTx(tx);
|
|
923
|
-
|
|
924
|
-
this.
|
|
1005
|
+
const duration = timer.ms();
|
|
1006
|
+
this.metrics.receivedTx(duration, true);
|
|
1007
|
+
this.log.info(`Received tx ${txHash} in ${duration}ms`, {
|
|
925
1008
|
txHash
|
|
926
1009
|
});
|
|
927
1010
|
}
|
|
@@ -932,18 +1015,20 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
932
1015
|
const isKnownToPool = txPoolStatus === 'pending' || txPoolStatus === 'mined';
|
|
933
1016
|
// Then get the actual tx from the archiver, which tracks every tx in a mined block.
|
|
934
1017
|
const settledTxReceipt = await this.blockSource.getSettledTxReceipt(txHash);
|
|
1018
|
+
let receipt;
|
|
935
1019
|
if (settledTxReceipt) {
|
|
936
|
-
|
|
937
|
-
return settledTxReceipt;
|
|
1020
|
+
receipt = settledTxReceipt;
|
|
938
1021
|
} else if (isKnownToPool) {
|
|
939
1022
|
// If the tx is in the pool but not in the archiver, it's pending.
|
|
940
1023
|
// This handles race conditions between archiver and p2p, where the archiver
|
|
941
1024
|
// has pruned the block in which a tx was mined, but p2p has not caught up yet.
|
|
942
|
-
|
|
1025
|
+
receipt = new TxReceipt(txHash, TxStatus.PENDING, undefined, undefined);
|
|
943
1026
|
} else {
|
|
944
1027
|
// Otherwise, if we don't know the tx, we consider it dropped.
|
|
945
|
-
|
|
1028
|
+
receipt = new TxReceipt(txHash, TxStatus.DROPPED, undefined, 'Tx dropped by P2P node');
|
|
946
1029
|
}
|
|
1030
|
+
this.debugLogStore.decorateReceiptWithLogs(txHash.toString(), receipt);
|
|
1031
|
+
return receipt;
|
|
947
1032
|
}
|
|
948
1033
|
getTxEffect(txHash) {
|
|
949
1034
|
return this.blockSource.getTxEffect(txHash);
|
|
@@ -957,6 +1042,7 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
957
1042
|
await tryStop(this.slasherClient);
|
|
958
1043
|
await tryStop(this.proofVerifier);
|
|
959
1044
|
await tryStop(this.sequencer);
|
|
1045
|
+
await tryStop(this.proverNode);
|
|
960
1046
|
await tryStop(this.p2pClient);
|
|
961
1047
|
await tryStop(this.worldStateSynchronizer);
|
|
962
1048
|
await tryStop(this.blockSource);
|
|
@@ -998,47 +1084,51 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
998
1084
|
async findLeavesIndexes(referenceBlock, treeId, leafValues) {
|
|
999
1085
|
const committedDb = await this.#getWorldState(referenceBlock);
|
|
1000
1086
|
const maybeIndices = await committedDb.findLeafIndices(treeId, leafValues.map((x)=>x.toBuffer()));
|
|
1001
|
-
//
|
|
1002
|
-
const
|
|
1003
|
-
// Now we find the block numbers for the indices
|
|
1004
|
-
const blockNumbers = await committedDb.getBlockNumbersForLeafIndices(treeId,
|
|
1005
|
-
//
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1087
|
+
// Filter out undefined values to query block numbers only for found leaves
|
|
1088
|
+
const definedIndices = maybeIndices.filter((x)=>x !== undefined);
|
|
1089
|
+
// Now we find the block numbers for the defined indices
|
|
1090
|
+
const blockNumbers = await committedDb.getBlockNumbersForLeafIndices(treeId, definedIndices);
|
|
1091
|
+
// Build a map from leaf index to block number
|
|
1092
|
+
const indexToBlockNumber = new Map();
|
|
1093
|
+
for(let i = 0; i < definedIndices.length; i++){
|
|
1094
|
+
const blockNumber = blockNumbers[i];
|
|
1095
|
+
if (blockNumber === undefined) {
|
|
1096
|
+
throw new Error(`Block number is undefined for leaf index ${definedIndices[i]} in tree ${MerkleTreeId[treeId]}`);
|
|
1009
1097
|
}
|
|
1098
|
+
indexToBlockNumber.set(definedIndices[i], blockNumber);
|
|
1010
1099
|
}
|
|
1011
1100
|
// Get unique block numbers in order to optimize num calls to getLeafValue function.
|
|
1012
1101
|
const uniqueBlockNumbers = [
|
|
1013
|
-
...new Set(
|
|
1102
|
+
...new Set(indexToBlockNumber.values())
|
|
1014
1103
|
];
|
|
1015
|
-
// Now we obtain the block hashes from the archive tree
|
|
1016
|
-
// (note that block number corresponds to the leaf index in the archive tree).
|
|
1104
|
+
// Now we obtain the block hashes from the archive tree (block number = leaf index in archive tree).
|
|
1017
1105
|
const blockHashes = await Promise.all(uniqueBlockNumbers.map((blockNumber)=>{
|
|
1018
1106
|
return committedDb.getLeafValue(MerkleTreeId.ARCHIVE, BigInt(blockNumber));
|
|
1019
1107
|
}));
|
|
1020
|
-
//
|
|
1108
|
+
// Build a map from block number to block hash
|
|
1109
|
+
const blockNumberToHash = new Map();
|
|
1021
1110
|
for(let i = 0; i < uniqueBlockNumbers.length; i++){
|
|
1022
|
-
|
|
1111
|
+
const blockHash = blockHashes[i];
|
|
1112
|
+
if (blockHash === undefined) {
|
|
1023
1113
|
throw new Error(`Block hash is undefined for block number ${uniqueBlockNumbers[i]}`);
|
|
1024
1114
|
}
|
|
1115
|
+
blockNumberToHash.set(uniqueBlockNumbers[i], blockHash);
|
|
1025
1116
|
}
|
|
1026
1117
|
// Create DataInBlock objects by combining indices, blockNumbers and blockHashes and return them.
|
|
1027
|
-
return maybeIndices.map((index
|
|
1118
|
+
return maybeIndices.map((index)=>{
|
|
1028
1119
|
if (index === undefined) {
|
|
1029
1120
|
return undefined;
|
|
1030
1121
|
}
|
|
1031
|
-
const blockNumber =
|
|
1122
|
+
const blockNumber = indexToBlockNumber.get(index);
|
|
1032
1123
|
if (blockNumber === undefined) {
|
|
1033
|
-
|
|
1124
|
+
throw new Error(`Block number not found for leaf index ${index} in tree ${MerkleTreeId[treeId]}`);
|
|
1034
1125
|
}
|
|
1035
|
-
const
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
return undefined;
|
|
1126
|
+
const blockHash = blockNumberToHash.get(blockNumber);
|
|
1127
|
+
if (blockHash === undefined) {
|
|
1128
|
+
throw new Error(`Block hash not found for block number ${blockNumber}`);
|
|
1039
1129
|
}
|
|
1040
1130
|
return {
|
|
1041
|
-
l2BlockNumber:
|
|
1131
|
+
l2BlockNumber: blockNumber,
|
|
1042
1132
|
l2BlockHash: new BlockHash(blockHash),
|
|
1043
1133
|
data: index
|
|
1044
1134
|
};
|
|
@@ -1072,9 +1162,9 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
1072
1162
|
witness.path
|
|
1073
1163
|
];
|
|
1074
1164
|
}
|
|
1075
|
-
async
|
|
1165
|
+
async getL1ToL2MessageCheckpoint(l1ToL2Message) {
|
|
1076
1166
|
const messageIndex = await this.l1ToL2MessageSource.getL1ToL2MessageIndex(l1ToL2Message);
|
|
1077
|
-
return messageIndex ?
|
|
1167
|
+
return messageIndex ? InboxLeaf.checkpointNumberFromIndex(messageIndex) : undefined;
|
|
1078
1168
|
}
|
|
1079
1169
|
/**
|
|
1080
1170
|
* Returns whether an L1 to L2 message is synced by archiver and if it's ready to be included in a block.
|
|
@@ -1194,6 +1284,12 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
1194
1284
|
*/ async getBlockHeaderByArchive(archive) {
|
|
1195
1285
|
return await this.blockSource.getBlockHeaderByArchive(archive);
|
|
1196
1286
|
}
|
|
1287
|
+
getBlockData(number) {
|
|
1288
|
+
return this.blockSource.getBlockData(number);
|
|
1289
|
+
}
|
|
1290
|
+
getBlockDataByArchive(archive) {
|
|
1291
|
+
return this.blockSource.getBlockDataByArchive(archive);
|
|
1292
|
+
}
|
|
1197
1293
|
/**
|
|
1198
1294
|
* Simulates the public part of a transaction with the current state.
|
|
1199
1295
|
* @param tx - The transaction to simulate.
|
|
@@ -1206,7 +1302,8 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
1206
1302
|
throw new BadRequestError(`Transaction total gas limit ${txGasLimit + teardownGasLimit} (${txGasLimit} + ${teardownGasLimit}) exceeds maximum gas limit ${this.config.rpcSimulatePublicMaxGasLimit} for simulation`);
|
|
1207
1303
|
}
|
|
1208
1304
|
const txHash = tx.getTxHash();
|
|
1209
|
-
const
|
|
1305
|
+
const latestBlockNumber = await this.blockSource.getBlockNumber();
|
|
1306
|
+
const blockNumber = BlockNumber.add(latestBlockNumber, 1);
|
|
1210
1307
|
// If sequencer is not initialized, we just set these values to zero for simulation.
|
|
1211
1308
|
const coinbase = EthAddress.ZERO;
|
|
1212
1309
|
const feeRecipient = AztecAddress.ZERO;
|
|
@@ -1217,6 +1314,8 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
1217
1314
|
txHash,
|
|
1218
1315
|
blockNumber
|
|
1219
1316
|
});
|
|
1317
|
+
// Ensure world-state has caught up with the latest block we loaded from the archiver
|
|
1318
|
+
await this.worldStateSynchronizer.syncImmediate(latestBlockNumber);
|
|
1220
1319
|
const merkleTreeFork = await this.worldStateSynchronizer.fork();
|
|
1221
1320
|
try {
|
|
1222
1321
|
const config = PublicSimulatorConfig.from({
|
|
@@ -1231,7 +1330,7 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
1231
1330
|
});
|
|
1232
1331
|
const processor = publicProcessorFactory.create(merkleTreeFork, newGlobalVariables, config);
|
|
1233
1332
|
// REFACTOR: Consider merging ProcessReturnValues into ProcessedTx
|
|
1234
|
-
const [processedTxs, failedTxs, _usedTxs, returns] = await processor.process([
|
|
1333
|
+
const [processedTxs, failedTxs, _usedTxs, returns, debugLogs] = await processor.process([
|
|
1235
1334
|
tx
|
|
1236
1335
|
]);
|
|
1237
1336
|
// REFACTOR: Consider returning the error rather than throwing
|
|
@@ -1242,7 +1341,7 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
1242
1341
|
throw failedTxs[0].error;
|
|
1243
1342
|
}
|
|
1244
1343
|
const [processedTx] = processedTxs;
|
|
1245
|
-
return new PublicSimulationOutput(processedTx.revertReason, processedTx.globalVariables, processedTx.txEffect, returns, processedTx.gasUsed);
|
|
1344
|
+
return new PublicSimulationOutput(processedTx.revertReason, processedTx.globalVariables, processedTx.txEffect, returns, processedTx.gasUsed, debugLogs);
|
|
1246
1345
|
} finally{
|
|
1247
1346
|
await merkleTreeFork.close();
|
|
1248
1347
|
}
|
|
@@ -1250,18 +1349,25 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
1250
1349
|
async isValidTx(tx, { isSimulation, skipFeeEnforcement } = {}) {
|
|
1251
1350
|
const db = this.worldStateSynchronizer.getCommitted();
|
|
1252
1351
|
const verifier = isSimulation ? undefined : this.proofVerifier;
|
|
1253
|
-
// We accept transactions if they are not expired by the next slot (checked based on the
|
|
1352
|
+
// We accept transactions if they are not expired by the next slot (checked based on the ExpirationTimestamp field)
|
|
1254
1353
|
const { ts: nextSlotTimestamp } = this.epochCache.getEpochAndSlotInNextL1Slot();
|
|
1255
1354
|
const blockNumber = BlockNumber(await this.blockSource.getBlockNumber() + 1);
|
|
1256
|
-
const
|
|
1355
|
+
const l1Constants = await this.blockSource.getL1Constants();
|
|
1356
|
+
const validator = createTxValidatorForAcceptingTxsOverRPC(db, this.contractDataSource, verifier, {
|
|
1257
1357
|
timestamp: nextSlotTimestamp,
|
|
1258
1358
|
blockNumber,
|
|
1259
1359
|
l1ChainId: this.l1ChainId,
|
|
1260
1360
|
rollupVersion: this.version,
|
|
1261
|
-
setupAllowList:
|
|
1361
|
+
setupAllowList: [
|
|
1362
|
+
...await getDefaultAllowedSetupFunctions(),
|
|
1363
|
+
...this.config.txPublicSetupAllowListExtend ?? []
|
|
1364
|
+
],
|
|
1262
1365
|
gasFees: await this.getCurrentMinFees(),
|
|
1263
1366
|
skipFeeEnforcement,
|
|
1264
|
-
txsPermitted: !this.config.disableTransactions
|
|
1367
|
+
txsPermitted: !this.config.disableTransactions,
|
|
1368
|
+
rollupManaLimit: l1Constants.rollupManaLimit,
|
|
1369
|
+
maxBlockL2Gas: this.config.validateMaxL2BlockGas,
|
|
1370
|
+
maxBlockDAGas: this.config.validateMaxDABlockGas
|
|
1265
1371
|
}, this.log.getBindings());
|
|
1266
1372
|
return await validator.validateTx(tx);
|
|
1267
1373
|
}
|
|
@@ -1404,6 +1510,73 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
1404
1510
|
return this.slasherClient.gatherOffensesForRound(round === 'current' ? undefined : BigInt(round));
|
|
1405
1511
|
}
|
|
1406
1512
|
}
|
|
1513
|
+
async reloadKeystore() {
|
|
1514
|
+
if (!this.config.keyStoreDirectory?.length) {
|
|
1515
|
+
throw new BadRequestError('Cannot reload keystore: node is not using a file-based keystore. ' + 'Set KEY_STORE_DIRECTORY to use file-based keystores.');
|
|
1516
|
+
}
|
|
1517
|
+
if (!this.validatorClient) {
|
|
1518
|
+
throw new BadRequestError('Cannot reload keystore: validator is not enabled.');
|
|
1519
|
+
}
|
|
1520
|
+
this.log.info('Reloading keystore from disk');
|
|
1521
|
+
// Re-read and validate keystore files
|
|
1522
|
+
const keyStores = loadKeystores(this.config.keyStoreDirectory);
|
|
1523
|
+
const newManager = new KeystoreManager(mergeKeystores(keyStores));
|
|
1524
|
+
await newManager.validateSigners();
|
|
1525
|
+
ValidatorClient.validateKeyStoreConfiguration(newManager, this.log);
|
|
1526
|
+
// Validate that every validator's publisher keys overlap with the L1 signers
|
|
1527
|
+
// that were initialized at startup. Publishers cannot be hot-reloaded, so a
|
|
1528
|
+
// validator with a publisher key that doesn't match any existing L1 signer
|
|
1529
|
+
// would silently fail on every proposer slot.
|
|
1530
|
+
if (this.keyStoreManager && this.sequencer) {
|
|
1531
|
+
const oldAdapter = NodeKeystoreAdapter.fromKeyStoreManager(this.keyStoreManager);
|
|
1532
|
+
const availablePublishers = new Set(oldAdapter.getAttesterAddresses().flatMap((a)=>oldAdapter.getPublisherAddresses(a).map((p)=>p.toString().toLowerCase())));
|
|
1533
|
+
const newAdapter = NodeKeystoreAdapter.fromKeyStoreManager(newManager);
|
|
1534
|
+
for (const attester of newAdapter.getAttesterAddresses()){
|
|
1535
|
+
const pubs = newAdapter.getPublisherAddresses(attester);
|
|
1536
|
+
if (pubs.length > 0 && !pubs.some((p)=>availablePublishers.has(p.toString().toLowerCase()))) {
|
|
1537
|
+
throw new BadRequestError(`Cannot reload keystore: validator ${attester} has publisher keys ` + `[${pubs.map((p)=>p.toString()).join(', ')}] but none match the L1 signers initialized at startup ` + `[${[
|
|
1538
|
+
...availablePublishers
|
|
1539
|
+
].join(', ')}]. Publishers cannot be hot-reloaded — ` + `use an existing publisher key or restart the node.`);
|
|
1540
|
+
}
|
|
1541
|
+
}
|
|
1542
|
+
}
|
|
1543
|
+
// Build adapters for old and new keystores to compute diff
|
|
1544
|
+
const newAdapter = NodeKeystoreAdapter.fromKeyStoreManager(newManager);
|
|
1545
|
+
const newAddresses = newAdapter.getAttesterAddresses();
|
|
1546
|
+
const oldAddresses = this.keyStoreManager ? NodeKeystoreAdapter.fromKeyStoreManager(this.keyStoreManager).getAttesterAddresses() : [];
|
|
1547
|
+
const oldSet = new Set(oldAddresses.map((a)=>a.toString()));
|
|
1548
|
+
const newSet = new Set(newAddresses.map((a)=>a.toString()));
|
|
1549
|
+
const added = newAddresses.filter((a)=>!oldSet.has(a.toString()));
|
|
1550
|
+
const removed = oldAddresses.filter((a)=>!newSet.has(a.toString()));
|
|
1551
|
+
if (added.length > 0) {
|
|
1552
|
+
this.log.info(`Keystore reload: adding attester keys: ${added.map((a)=>a.toString()).join(', ')}`);
|
|
1553
|
+
}
|
|
1554
|
+
if (removed.length > 0) {
|
|
1555
|
+
this.log.info(`Keystore reload: removing attester keys: ${removed.map((a)=>a.toString()).join(', ')}`);
|
|
1556
|
+
}
|
|
1557
|
+
if (added.length === 0 && removed.length === 0) {
|
|
1558
|
+
this.log.info('Keystore reload: attester keys unchanged');
|
|
1559
|
+
}
|
|
1560
|
+
// Update the validator client (coinbase, feeRecipient, attester keys)
|
|
1561
|
+
this.validatorClient.reloadKeystore(newManager);
|
|
1562
|
+
// Update the publisher factory's keystore so newly-added validators
|
|
1563
|
+
// can be matched to existing publisher keys when proposing blocks.
|
|
1564
|
+
if (this.sequencer) {
|
|
1565
|
+
this.sequencer.updatePublisherNodeKeyStore(newAdapter);
|
|
1566
|
+
}
|
|
1567
|
+
// Update slasher's "don't-slash-self" list with new validator addresses
|
|
1568
|
+
if (this.slasherClient && !this.config.slashSelfAllowed) {
|
|
1569
|
+
const slashValidatorsNever = unique([
|
|
1570
|
+
...this.config.slashValidatorsNever ?? [],
|
|
1571
|
+
...newAddresses
|
|
1572
|
+
].map((a)=>a.toString())).map(EthAddress.fromString);
|
|
1573
|
+
this.slasherClient.updateConfig({
|
|
1574
|
+
slashValidatorsNever
|
|
1575
|
+
});
|
|
1576
|
+
}
|
|
1577
|
+
this.keyStoreManager = newManager;
|
|
1578
|
+
this.log.info('Keystore reloaded: coinbase, feeRecipient, and attester keys updated');
|
|
1579
|
+
}
|
|
1407
1580
|
#getInitialHeaderHash() {
|
|
1408
1581
|
if (!this.initialHeaderHashPromise) {
|
|
1409
1582
|
this.initialHeaderHashPromise = this.worldStateSynchronizer.getCommitted().getInitialHeader().hash();
|