@aztec/aztec-node 0.0.1-commit.6230a0c → 0.0.1-commit.643667a5cb
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 +7 -4
- package/dest/aztec-node/config.d.ts.map +1 -1
- package/dest/aztec-node/config.js +10 -2
- package/dest/aztec-node/server.d.ts +16 -3
- package/dest/aztec-node/server.d.ts.map +1 -1
- package/dest/aztec-node/server.js +145 -20
- package/dest/sentinel/sentinel.d.ts +2 -2
- package/dest/sentinel/sentinel.d.ts.map +1 -1
- package/dest/sentinel/sentinel.js +53 -27
- package/dest/sentinel/store.d.ts +2 -2
- package/dest/sentinel/store.d.ts.map +1 -1
- package/dest/sentinel/store.js +11 -7
- package/package.json +27 -25
- package/src/aztec-node/config.ts +24 -8
- package/src/aztec-node/server.ts +184 -26
- package/src/sentinel/sentinel.ts +56 -23
- 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 { createForwarderL1TxUtilsFromSigners, createL1TxUtilsFromSigners } from '@aztec/node-lib/factories';
|
|
393
394
|
import { createP2PClient, 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';
|
|
@@ -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,8 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
440
444
|
telemetry;
|
|
441
445
|
log;
|
|
442
446
|
blobClient;
|
|
447
|
+
validatorClient;
|
|
448
|
+
keyStoreManager;
|
|
443
449
|
static{
|
|
444
450
|
({ e: [_initProto] } = _apply_decs_2203_r(this, [
|
|
445
451
|
[
|
|
@@ -454,7 +460,7 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
454
460
|
// Prevent two snapshot operations to happen simultaneously
|
|
455
461
|
isUploadingSnapshot;
|
|
456
462
|
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){
|
|
463
|
+
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){
|
|
458
464
|
this.config = config;
|
|
459
465
|
this.p2pClient = p2pClient;
|
|
460
466
|
this.blockSource = blockSource;
|
|
@@ -463,6 +469,7 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
463
469
|
this.l1ToL2MessageSource = l1ToL2MessageSource;
|
|
464
470
|
this.worldStateSynchronizer = worldStateSynchronizer;
|
|
465
471
|
this.sequencer = sequencer;
|
|
472
|
+
this.proverNode = proverNode;
|
|
466
473
|
this.slasherClient = slasherClient;
|
|
467
474
|
this.validatorsSentinel = validatorsSentinel;
|
|
468
475
|
this.epochPruneWatcher = epochPruneWatcher;
|
|
@@ -475,6 +482,8 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
475
482
|
this.telemetry = telemetry;
|
|
476
483
|
this.log = log;
|
|
477
484
|
this.blobClient = blobClient;
|
|
485
|
+
this.validatorClient = validatorClient;
|
|
486
|
+
this.keyStoreManager = keyStoreManager;
|
|
478
487
|
this.initialHeaderHashPromise = (_initProto(this), undefined);
|
|
479
488
|
this.isUploadingSnapshot = false;
|
|
480
489
|
this.metrics = new NodeMetrics(telemetry, 'AztecNodeService');
|
|
@@ -502,16 +511,27 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
502
511
|
const telemetry = deps.telemetry ?? getTelemetryClient();
|
|
503
512
|
const dateProvider = deps.dateProvider ?? new DateProvider();
|
|
504
513
|
const ethereumChain = createEthereumChain(config.l1RpcUrls, config.l1ChainId);
|
|
505
|
-
// Build a key store from file if given or from environment otherwise
|
|
514
|
+
// Build a key store from file if given or from environment otherwise.
|
|
515
|
+
// We keep the raw KeyStore available so we can merge with prover keys if enableProverNode is set.
|
|
506
516
|
let keyStoreManager;
|
|
507
517
|
const keyStoreProvided = config.keyStoreDirectory !== undefined && config.keyStoreDirectory.length > 0;
|
|
508
518
|
if (keyStoreProvided) {
|
|
509
519
|
const keyStores = loadKeystores(config.keyStoreDirectory);
|
|
510
520
|
keyStoreManager = new KeystoreManager(mergeKeystores(keyStores));
|
|
511
521
|
} else {
|
|
512
|
-
const
|
|
513
|
-
|
|
514
|
-
|
|
522
|
+
const rawKeyStores = [];
|
|
523
|
+
const validatorKeyStore = createKeyStoreForValidator(config);
|
|
524
|
+
if (validatorKeyStore) {
|
|
525
|
+
rawKeyStores.push(validatorKeyStore);
|
|
526
|
+
}
|
|
527
|
+
if (config.enableProverNode) {
|
|
528
|
+
const proverKeyStore = createKeyStoreForProver(config);
|
|
529
|
+
if (proverKeyStore) {
|
|
530
|
+
rawKeyStores.push(proverKeyStore);
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
if (rawKeyStores.length > 0) {
|
|
534
|
+
keyStoreManager = new KeystoreManager(rawKeyStores.length === 1 ? rawKeyStores[0] : mergeKeystores(rawKeyStores));
|
|
515
535
|
}
|
|
516
536
|
}
|
|
517
537
|
await keyStoreManager?.validateSigners();
|
|
@@ -520,8 +540,8 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
520
540
|
if (keyStoreManager === undefined) {
|
|
521
541
|
throw new Error('Failed to create key store, a requirement for running a validator');
|
|
522
542
|
}
|
|
523
|
-
if (!keyStoreProvided) {
|
|
524
|
-
log.warn(
|
|
543
|
+
if (!keyStoreProvided && process.env.NODE_ENV !== 'test') {
|
|
544
|
+
log.warn("Keystore created from env: it's recommended to use a file-based key store for production");
|
|
525
545
|
}
|
|
526
546
|
ValidatorClient.validateKeyStoreConfiguration(keyStoreManager, log);
|
|
527
547
|
}
|
|
@@ -552,7 +572,7 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
552
572
|
if (config.rollupVersion !== Number(rollupVersionFromRollup)) {
|
|
553
573
|
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
574
|
}
|
|
555
|
-
const blobClient = await createBlobClientWithFileStores(config,
|
|
575
|
+
const blobClient = await createBlobClientWithFileStores(config, log.createChild('blob-client'));
|
|
556
576
|
// attempt snapshot sync if possible
|
|
557
577
|
await trySnapshotSync(config, log);
|
|
558
578
|
const epochCache = await EpochCache.create(config.l1Contracts.rollupAddress, config, {
|
|
@@ -658,20 +678,22 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
658
678
|
const validatorAddresses = keyStoreManager ? NodeKeystoreAdapter.fromKeyStoreManager(keyStoreManager).getAddresses() : [];
|
|
659
679
|
slasherClient = await createSlasher(config, config.l1Contracts, getPublicClient(config), watchers, dateProvider, epochCache, validatorAddresses, undefined);
|
|
660
680
|
await slasherClient.start();
|
|
661
|
-
const l1TxUtils = config.
|
|
681
|
+
const l1TxUtils = config.sequencerPublisherForwarderAddress ? await createForwarderL1TxUtilsFromSigners(publicClient, keyStoreManager.createAllValidatorPublisherSigners(), config.sequencerPublisherForwarderAddress, {
|
|
662
682
|
...config,
|
|
663
683
|
scope: 'sequencer'
|
|
664
684
|
}, {
|
|
665
685
|
telemetry,
|
|
666
686
|
logger: log.createChild('l1-tx-utils'),
|
|
667
|
-
dateProvider
|
|
668
|
-
|
|
687
|
+
dateProvider,
|
|
688
|
+
kzg: Blob.getViemKzgInstance()
|
|
689
|
+
}) : await createL1TxUtilsFromSigners(publicClient, keyStoreManager.createAllValidatorPublisherSigners(), {
|
|
669
690
|
...config,
|
|
670
691
|
scope: 'sequencer'
|
|
671
692
|
}, {
|
|
672
693
|
telemetry,
|
|
673
694
|
logger: log.createChild('l1-tx-utils'),
|
|
674
|
-
dateProvider
|
|
695
|
+
dateProvider,
|
|
696
|
+
kzg: Blob.getViemKzgInstance()
|
|
675
697
|
});
|
|
676
698
|
// Create and start the sequencer client
|
|
677
699
|
const checkpointsBuilder = new CheckpointsBuilder({
|
|
@@ -702,13 +724,35 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
702
724
|
} else if (sequencer) {
|
|
703
725
|
log.warn(`Sequencer created but not started`);
|
|
704
726
|
}
|
|
727
|
+
// Create prover node subsystem if enabled
|
|
728
|
+
let proverNode;
|
|
729
|
+
if (config.enableProverNode) {
|
|
730
|
+
proverNode = await createProverNode(config, {
|
|
731
|
+
...deps.proverNodeDeps,
|
|
732
|
+
telemetry,
|
|
733
|
+
dateProvider,
|
|
734
|
+
archiver,
|
|
735
|
+
worldStateSynchronizer,
|
|
736
|
+
p2pClient,
|
|
737
|
+
epochCache,
|
|
738
|
+
blobClient,
|
|
739
|
+
keyStoreManager
|
|
740
|
+
});
|
|
741
|
+
if (!options.dontStartProverNode) {
|
|
742
|
+
await proverNode.start();
|
|
743
|
+
log.info(`Prover node subsystem started`);
|
|
744
|
+
} else {
|
|
745
|
+
log.info(`Prover node subsystem created but not started`);
|
|
746
|
+
}
|
|
747
|
+
}
|
|
705
748
|
const globalVariableBuilder = new GlobalVariableBuilder({
|
|
706
749
|
...config,
|
|
707
750
|
rollupVersion: BigInt(config.rollupVersion),
|
|
708
751
|
l1GenesisTime,
|
|
709
752
|
slotDuration: Number(slotDuration)
|
|
710
753
|
});
|
|
711
|
-
|
|
754
|
+
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);
|
|
755
|
+
return node;
|
|
712
756
|
}
|
|
713
757
|
/**
|
|
714
758
|
* Returns the sequencer client instance.
|
|
@@ -716,6 +760,9 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
716
760
|
*/ getSequencer() {
|
|
717
761
|
return this.sequencer;
|
|
718
762
|
}
|
|
763
|
+
/** Returns the prover node subsystem, if enabled. */ getProverNode() {
|
|
764
|
+
return this.proverNode;
|
|
765
|
+
}
|
|
719
766
|
getBlockSource() {
|
|
720
767
|
return this.blockSource;
|
|
721
768
|
}
|
|
@@ -758,7 +805,8 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
758
805
|
rollupVersion,
|
|
759
806
|
enr,
|
|
760
807
|
l1ContractAddresses: contractAddresses,
|
|
761
|
-
protocolContractAddresses: protocolContractAddresses
|
|
808
|
+
protocolContractAddresses: protocolContractAddresses,
|
|
809
|
+
realProofs: !!this.config.realProofs
|
|
762
810
|
};
|
|
763
811
|
return nodeInfo;
|
|
764
812
|
}
|
|
@@ -957,6 +1005,7 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
957
1005
|
await tryStop(this.slasherClient);
|
|
958
1006
|
await tryStop(this.proofVerifier);
|
|
959
1007
|
await tryStop(this.sequencer);
|
|
1008
|
+
await tryStop(this.proverNode);
|
|
960
1009
|
await tryStop(this.p2pClient);
|
|
961
1010
|
await tryStop(this.worldStateSynchronizer);
|
|
962
1011
|
await tryStop(this.blockSource);
|
|
@@ -1194,6 +1243,12 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
1194
1243
|
*/ async getBlockHeaderByArchive(archive) {
|
|
1195
1244
|
return await this.blockSource.getBlockHeaderByArchive(archive);
|
|
1196
1245
|
}
|
|
1246
|
+
getBlockData(number) {
|
|
1247
|
+
return this.blockSource.getBlockData(number);
|
|
1248
|
+
}
|
|
1249
|
+
getBlockDataByArchive(archive) {
|
|
1250
|
+
return this.blockSource.getBlockDataByArchive(archive);
|
|
1251
|
+
}
|
|
1197
1252
|
/**
|
|
1198
1253
|
* Simulates the public part of a transaction with the current state.
|
|
1199
1254
|
* @param tx - The transaction to simulate.
|
|
@@ -1206,7 +1261,8 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
1206
1261
|
throw new BadRequestError(`Transaction total gas limit ${txGasLimit + teardownGasLimit} (${txGasLimit} + ${teardownGasLimit}) exceeds maximum gas limit ${this.config.rpcSimulatePublicMaxGasLimit} for simulation`);
|
|
1207
1262
|
}
|
|
1208
1263
|
const txHash = tx.getTxHash();
|
|
1209
|
-
const
|
|
1264
|
+
const latestBlockNumber = await this.blockSource.getBlockNumber();
|
|
1265
|
+
const blockNumber = BlockNumber.add(latestBlockNumber, 1);
|
|
1210
1266
|
// If sequencer is not initialized, we just set these values to zero for simulation.
|
|
1211
1267
|
const coinbase = EthAddress.ZERO;
|
|
1212
1268
|
const feeRecipient = AztecAddress.ZERO;
|
|
@@ -1217,6 +1273,8 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
1217
1273
|
txHash,
|
|
1218
1274
|
blockNumber
|
|
1219
1275
|
});
|
|
1276
|
+
// Ensure world-state has caught up with the latest block we loaded from the archiver
|
|
1277
|
+
await this.worldStateSynchronizer.syncImmediate(latestBlockNumber);
|
|
1220
1278
|
const merkleTreeFork = await this.worldStateSynchronizer.fork();
|
|
1221
1279
|
try {
|
|
1222
1280
|
const config = PublicSimulatorConfig.from({
|
|
@@ -1231,7 +1289,7 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
1231
1289
|
});
|
|
1232
1290
|
const processor = publicProcessorFactory.create(merkleTreeFork, newGlobalVariables, config);
|
|
1233
1291
|
// REFACTOR: Consider merging ProcessReturnValues into ProcessedTx
|
|
1234
|
-
const [processedTxs, failedTxs, _usedTxs, returns] = await processor.process([
|
|
1292
|
+
const [processedTxs, failedTxs, _usedTxs, returns, _blobFields, debugLogs] = await processor.process([
|
|
1235
1293
|
tx
|
|
1236
1294
|
]);
|
|
1237
1295
|
// REFACTOR: Consider returning the error rather than throwing
|
|
@@ -1242,7 +1300,7 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
1242
1300
|
throw failedTxs[0].error;
|
|
1243
1301
|
}
|
|
1244
1302
|
const [processedTx] = processedTxs;
|
|
1245
|
-
return new PublicSimulationOutput(processedTx.revertReason, processedTx.globalVariables, processedTx.txEffect, returns, processedTx.gasUsed);
|
|
1303
|
+
return new PublicSimulationOutput(processedTx.revertReason, processedTx.globalVariables, processedTx.txEffect, returns, processedTx.gasUsed, debugLogs);
|
|
1246
1304
|
} finally{
|
|
1247
1305
|
await merkleTreeFork.close();
|
|
1248
1306
|
}
|
|
@@ -1250,7 +1308,7 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
1250
1308
|
async isValidTx(tx, { isSimulation, skipFeeEnforcement } = {}) {
|
|
1251
1309
|
const db = this.worldStateSynchronizer.getCommitted();
|
|
1252
1310
|
const verifier = isSimulation ? undefined : this.proofVerifier;
|
|
1253
|
-
// We accept transactions if they are not expired by the next slot (checked based on the
|
|
1311
|
+
// We accept transactions if they are not expired by the next slot (checked based on the ExpirationTimestamp field)
|
|
1254
1312
|
const { ts: nextSlotTimestamp } = this.epochCache.getEpochAndSlotInNextL1Slot();
|
|
1255
1313
|
const blockNumber = BlockNumber(await this.blockSource.getBlockNumber() + 1);
|
|
1256
1314
|
const validator = createValidatorForAcceptingTxs(db, this.contractDataSource, verifier, {
|
|
@@ -1404,6 +1462,73 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
1404
1462
|
return this.slasherClient.gatherOffensesForRound(round === 'current' ? undefined : BigInt(round));
|
|
1405
1463
|
}
|
|
1406
1464
|
}
|
|
1465
|
+
async reloadKeystore() {
|
|
1466
|
+
if (!this.config.keyStoreDirectory?.length) {
|
|
1467
|
+
throw new BadRequestError('Cannot reload keystore: node is not using a file-based keystore. ' + 'Set KEY_STORE_DIRECTORY to use file-based keystores.');
|
|
1468
|
+
}
|
|
1469
|
+
if (!this.validatorClient) {
|
|
1470
|
+
throw new BadRequestError('Cannot reload keystore: validator is not enabled.');
|
|
1471
|
+
}
|
|
1472
|
+
this.log.info('Reloading keystore from disk');
|
|
1473
|
+
// Re-read and validate keystore files
|
|
1474
|
+
const keyStores = loadKeystores(this.config.keyStoreDirectory);
|
|
1475
|
+
const newManager = new KeystoreManager(mergeKeystores(keyStores));
|
|
1476
|
+
await newManager.validateSigners();
|
|
1477
|
+
ValidatorClient.validateKeyStoreConfiguration(newManager, this.log);
|
|
1478
|
+
// Validate that every validator's publisher keys overlap with the L1 signers
|
|
1479
|
+
// that were initialized at startup. Publishers cannot be hot-reloaded, so a
|
|
1480
|
+
// validator with a publisher key that doesn't match any existing L1 signer
|
|
1481
|
+
// would silently fail on every proposer slot.
|
|
1482
|
+
if (this.keyStoreManager && this.sequencer) {
|
|
1483
|
+
const oldAdapter = NodeKeystoreAdapter.fromKeyStoreManager(this.keyStoreManager);
|
|
1484
|
+
const availablePublishers = new Set(oldAdapter.getAttesterAddresses().flatMap((a)=>oldAdapter.getPublisherAddresses(a).map((p)=>p.toString().toLowerCase())));
|
|
1485
|
+
const newAdapter = NodeKeystoreAdapter.fromKeyStoreManager(newManager);
|
|
1486
|
+
for (const attester of newAdapter.getAttesterAddresses()){
|
|
1487
|
+
const pubs = newAdapter.getPublisherAddresses(attester);
|
|
1488
|
+
if (pubs.length > 0 && !pubs.some((p)=>availablePublishers.has(p.toString().toLowerCase()))) {
|
|
1489
|
+
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 ` + `[${[
|
|
1490
|
+
...availablePublishers
|
|
1491
|
+
].join(', ')}]. Publishers cannot be hot-reloaded — ` + `use an existing publisher key or restart the node.`);
|
|
1492
|
+
}
|
|
1493
|
+
}
|
|
1494
|
+
}
|
|
1495
|
+
// Build adapters for old and new keystores to compute diff
|
|
1496
|
+
const newAdapter = NodeKeystoreAdapter.fromKeyStoreManager(newManager);
|
|
1497
|
+
const newAddresses = newAdapter.getAttesterAddresses();
|
|
1498
|
+
const oldAddresses = this.keyStoreManager ? NodeKeystoreAdapter.fromKeyStoreManager(this.keyStoreManager).getAttesterAddresses() : [];
|
|
1499
|
+
const oldSet = new Set(oldAddresses.map((a)=>a.toString()));
|
|
1500
|
+
const newSet = new Set(newAddresses.map((a)=>a.toString()));
|
|
1501
|
+
const added = newAddresses.filter((a)=>!oldSet.has(a.toString()));
|
|
1502
|
+
const removed = oldAddresses.filter((a)=>!newSet.has(a.toString()));
|
|
1503
|
+
if (added.length > 0) {
|
|
1504
|
+
this.log.info(`Keystore reload: adding attester keys: ${added.map((a)=>a.toString()).join(', ')}`);
|
|
1505
|
+
}
|
|
1506
|
+
if (removed.length > 0) {
|
|
1507
|
+
this.log.info(`Keystore reload: removing attester keys: ${removed.map((a)=>a.toString()).join(', ')}`);
|
|
1508
|
+
}
|
|
1509
|
+
if (added.length === 0 && removed.length === 0) {
|
|
1510
|
+
this.log.info('Keystore reload: attester keys unchanged');
|
|
1511
|
+
}
|
|
1512
|
+
// Update the validator client (coinbase, feeRecipient, attester keys)
|
|
1513
|
+
this.validatorClient.reloadKeystore(newManager);
|
|
1514
|
+
// Update the publisher factory's keystore so newly-added validators
|
|
1515
|
+
// can be matched to existing publisher keys when proposing blocks.
|
|
1516
|
+
if (this.sequencer) {
|
|
1517
|
+
this.sequencer.updatePublisherNodeKeyStore(newAdapter);
|
|
1518
|
+
}
|
|
1519
|
+
// Update slasher's "don't-slash-self" list with new validator addresses
|
|
1520
|
+
if (this.slasherClient && !this.config.slashSelfAllowed) {
|
|
1521
|
+
const slashValidatorsNever = unique([
|
|
1522
|
+
...this.config.slashValidatorsNever ?? [],
|
|
1523
|
+
...newAddresses
|
|
1524
|
+
].map((a)=>a.toString())).map(EthAddress.fromString);
|
|
1525
|
+
this.slasherClient.updateConfig({
|
|
1526
|
+
slashValidatorsNever
|
|
1527
|
+
});
|
|
1528
|
+
}
|
|
1529
|
+
this.keyStoreManager = newManager;
|
|
1530
|
+
this.log.info('Keystore reloaded: coinbase, feeRecipient, and attester keys updated');
|
|
1531
|
+
}
|
|
1407
1532
|
#getInitialHeaderHash() {
|
|
1408
1533
|
if (!this.initialHeaderHashPromise) {
|
|
1409
1534
|
this.initialHeaderHashPromise = this.worldStateSynchronizer.getCommitted().getInitialHeader().hash();
|
|
@@ -77,7 +77,7 @@ export declare class Sentinel extends Sentinel_base implements L2BlockStreamEven
|
|
|
77
77
|
/** Computes stats for a single validator. */
|
|
78
78
|
getValidatorStats(validatorAddress: EthAddress, fromSlot?: SlotNumber, toSlot?: SlotNumber): Promise<SingleValidatorStats | undefined>;
|
|
79
79
|
protected computeStatsForValidator(address: `0x${string}`, allHistory: ValidatorStatusHistory, fromSlot?: SlotNumber, toSlot?: SlotNumber): ValidatorStats;
|
|
80
|
-
protected computeMissed(history: ValidatorStatusHistory,
|
|
80
|
+
protected computeMissed(history: ValidatorStatusHistory, computeOverCategory: ValidatorStatusType | undefined, filter: ValidatorStatusInSlot[]): {
|
|
81
81
|
currentStreak: number;
|
|
82
82
|
rate: number | undefined;
|
|
83
83
|
count: number;
|
|
@@ -90,4 +90,4 @@ export declare class Sentinel extends Sentinel_base implements L2BlockStreamEven
|
|
|
90
90
|
} | undefined;
|
|
91
91
|
}
|
|
92
92
|
export {};
|
|
93
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
93
|
+
//# sourceMappingURL=data:application/json;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E9BQU8sRUFBRSxzQkFBc0IsRUFDL0IsbUJBQW1CLEVBQUUsbUJBQW1CLEdBQUcsU0FBUyxFQUNwRCxNQUFNLEVBQUUscUJBQXFCLEVBQUU7Ozs7O01BWWhDO0lBRUQsU0FBUyxDQUFDLGVBQWUsQ0FBQyxJQUFJLEVBQUUsVUFBVSxHQUFHLFNBQVM7Ozs7a0JBTXJEO0NBQ0YifQ==
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sentinel.d.ts","sourceRoot":"","sources":["../../src/sentinel/sentinel.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAe,gBAAgB,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAEzG,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAE3D,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AACnE,OAAO,EAAqB,KAAK,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC7E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAIL,KAAK,OAAO,EACZ,KAAK,cAAc,EACpB,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EACL,KAAK,aAAa,EAClB,aAAa,EACb,KAAK,kBAAkB,EACvB,KAAK,yBAAyB,EAE/B,MAAM,qBAAqB,CAAC;AAE7B,OAAO,KAAK,EACV,oBAAoB,EACpB,cAAc,EACd,sBAAsB,EACtB,qBAAqB,EACrB,mBAAmB,EACnB,0BAA0B,EAC1B,eAAe,EAChB,MAAM,0BAA0B,CAAC;AAIlC,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;;
|
|
1
|
+
{"version":3,"file":"sentinel.d.ts","sourceRoot":"","sources":["../../src/sentinel/sentinel.ts"],"names":[],"mapp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|
|
@@ -8,6 +8,15 @@ import { OffenseType, WANT_TO_SLASH_EVENT } from '@aztec/slasher';
|
|
|
8
8
|
import { L2BlockStream, getAttestationInfoFromPublishedCheckpoint } from '@aztec/stdlib/block';
|
|
9
9
|
import { getEpochAtSlot, getSlotRangeForEpoch, getTimestampForSlot } from '@aztec/stdlib/epoch-helpers';
|
|
10
10
|
import EventEmitter from 'node:events';
|
|
11
|
+
/** Maps a validator status to its category: proposer or attestation. */ function statusToCategory(status) {
|
|
12
|
+
switch(status){
|
|
13
|
+
case 'attestation-sent':
|
|
14
|
+
case 'attestation-missed':
|
|
15
|
+
return 'attestation';
|
|
16
|
+
default:
|
|
17
|
+
return 'proposer';
|
|
18
|
+
}
|
|
19
|
+
}
|
|
11
20
|
export class Sentinel extends EventEmitter {
|
|
12
21
|
epochCache;
|
|
13
22
|
archiver;
|
|
@@ -82,16 +91,14 @@ export class Sentinel extends EventEmitter {
|
|
|
82
91
|
return;
|
|
83
92
|
}
|
|
84
93
|
const blockNumber = event.block.number;
|
|
85
|
-
const
|
|
86
|
-
if (!
|
|
87
|
-
this.logger.error(`Failed to get block ${blockNumber}
|
|
88
|
-
block
|
|
89
|
-
});
|
|
94
|
+
const header = await this.archiver.getBlockHeader(blockNumber);
|
|
95
|
+
if (!header) {
|
|
96
|
+
this.logger.error(`Failed to get block header ${blockNumber}`);
|
|
90
97
|
return;
|
|
91
98
|
}
|
|
92
99
|
// TODO(palla/slash): We should only be computing proven performance if this is
|
|
93
100
|
// a full proof epoch and not a partial one, otherwise we'll end up with skewed stats.
|
|
94
|
-
const epoch = getEpochAtSlot(
|
|
101
|
+
const epoch = getEpochAtSlot(header.getSlot(), this.epochCache.getL1Constants());
|
|
95
102
|
this.logger.debug(`Computing proven performance for epoch ${epoch}`);
|
|
96
103
|
const performance = await this.computeProvenPerformance(epoch);
|
|
97
104
|
this.logger.info(`Computed proven performance for epoch ${epoch}`, performance);
|
|
@@ -100,7 +107,11 @@ export class Sentinel extends EventEmitter {
|
|
|
100
107
|
}
|
|
101
108
|
async computeProvenPerformance(epoch) {
|
|
102
109
|
const [fromSlot, toSlot] = getSlotRangeForEpoch(epoch, this.epochCache.getL1Constants());
|
|
103
|
-
const { committee } = await this.epochCache.getCommittee(fromSlot);
|
|
110
|
+
const { committee, isEscapeHatchOpen } = await this.epochCache.getCommittee(fromSlot);
|
|
111
|
+
if (isEscapeHatchOpen) {
|
|
112
|
+
this.logger.info(`Skipping proven performance for epoch ${epoch} - escape hatch is open`);
|
|
113
|
+
return {};
|
|
114
|
+
}
|
|
104
115
|
if (!committee) {
|
|
105
116
|
this.logger.trace(`No committee found for slot ${fromSlot}`);
|
|
106
117
|
return {};
|
|
@@ -242,7 +253,12 @@ export class Sentinel extends EventEmitter {
|
|
|
242
253
|
* Gathers committee and proposer data for a given slot, computes slot stats,
|
|
243
254
|
* and updates overall stats.
|
|
244
255
|
*/ async processSlot(slot) {
|
|
245
|
-
const { epoch, seed, committee } = await this.epochCache.getCommittee(slot);
|
|
256
|
+
const { epoch, seed, committee, isEscapeHatchOpen } = await this.epochCache.getCommittee(slot);
|
|
257
|
+
if (isEscapeHatchOpen) {
|
|
258
|
+
this.logger.info(`Skipping slot ${slot} at epoch ${epoch} - escape hatch is open`);
|
|
259
|
+
this.lastProcessedSlot = slot;
|
|
260
|
+
return;
|
|
261
|
+
}
|
|
246
262
|
if (!committee || committee.length === 0) {
|
|
247
263
|
this.logger.trace(`No committee found for slot ${slot} at epoch ${epoch}`);
|
|
248
264
|
this.lastProcessedSlot = slot;
|
|
@@ -263,17 +279,17 @@ export class Sentinel extends EventEmitter {
|
|
|
263
279
|
committee
|
|
264
280
|
});
|
|
265
281
|
// Check if there is an L2 block in L1 for this L2 slot
|
|
266
|
-
// Here we get all attestations for the
|
|
267
|
-
// or all attestations for all proposals in the slot if no
|
|
282
|
+
// Here we get all checkpoint attestations for the checkpoint at the given slot,
|
|
283
|
+
// or all checkpoint attestations for all proposals in the slot if no checkpoint was mined.
|
|
268
284
|
// We gather from both p2p (contains the ones seen on the p2p layer) and archiver
|
|
269
|
-
// (contains the ones synced from mined
|
|
270
|
-
const
|
|
271
|
-
const p2pAttested = await this.p2p.getCheckpointAttestationsForSlot(slot,
|
|
285
|
+
// (contains the ones synced from mined checkpoints, which we may have missed from p2p).
|
|
286
|
+
const checkpoint = this.slotNumberToCheckpoint.get(slot);
|
|
287
|
+
const p2pAttested = await this.p2p.getCheckpointAttestationsForSlot(slot, checkpoint?.archive);
|
|
272
288
|
// Filter out attestations with invalid signatures
|
|
273
289
|
const p2pAttestors = p2pAttested.map((a)=>a.getSender()).filter((s)=>s !== undefined);
|
|
274
290
|
const attestors = new Set([
|
|
275
291
|
...p2pAttestors.map((a)=>a.toString()),
|
|
276
|
-
...
|
|
292
|
+
...checkpoint?.attestors.map((a)=>a.toString()) ?? []
|
|
277
293
|
].filter((addr)=>proposer.toString() !== addr));
|
|
278
294
|
// We assume that there was a block proposal if at least one of the validators (other than the proposer) attested to it.
|
|
279
295
|
// It could be the case that every single validator failed, and we could differentiate it by having
|
|
@@ -281,17 +297,26 @@ export class Sentinel extends EventEmitter {
|
|
|
281
297
|
// But we'll leave that corner case out to reduce pressure on the node.
|
|
282
298
|
// TODO(palla/slash): This breaks if a given node has more than one validator in the current committee,
|
|
283
299
|
// since they will attest to their own proposal it even if it's not re-executable.
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
300
|
+
let status;
|
|
301
|
+
if (checkpoint) {
|
|
302
|
+
status = 'checkpoint-mined';
|
|
303
|
+
} else if (attestors.size > 0) {
|
|
304
|
+
status = 'checkpoint-proposed';
|
|
305
|
+
} else {
|
|
306
|
+
// No checkpoint on L1 and no checkpoint attestations seen. Check if block proposals were sent for this slot.
|
|
307
|
+
const hasBlockProposals = await this.p2p.hasBlockProposalsForSlot(slot);
|
|
308
|
+
status = hasBlockProposals ? 'checkpoint-missed' : 'blocks-missed';
|
|
309
|
+
}
|
|
310
|
+
this.logger.debug(`Checkpoint status for slot ${slot}: ${status}`, {
|
|
311
|
+
...checkpoint,
|
|
287
312
|
slot
|
|
288
313
|
});
|
|
289
|
-
// Get attestors that failed their
|
|
290
|
-
const missedAttestors = new Set(
|
|
314
|
+
// Get attestors that failed their checkpoint attestation duties, but only if there was a checkpoint proposed or mined
|
|
315
|
+
const missedAttestors = new Set(status === 'blocks-missed' || status === 'checkpoint-missed' ? [] : committee.filter((v)=>!attestors.has(v.toString()) && !proposer.equals(v)).map((v)=>v.toString()));
|
|
291
316
|
this.logger.debug(`Retrieved ${attestors.size} attestors out of ${committee.length} for slot ${slot}`, {
|
|
292
|
-
|
|
317
|
+
status,
|
|
293
318
|
proposer: proposer.toString(),
|
|
294
|
-
...
|
|
319
|
+
...checkpoint,
|
|
295
320
|
slot,
|
|
296
321
|
attestors: [
|
|
297
322
|
...attestors
|
|
@@ -304,7 +329,7 @@ export class Sentinel extends EventEmitter {
|
|
|
304
329
|
// Compute the status for each validator in the committee
|
|
305
330
|
const statusFor = (who)=>{
|
|
306
331
|
if (who === proposer.toString()) {
|
|
307
|
-
return
|
|
332
|
+
return status;
|
|
308
333
|
} else if (attestors.has(who)) {
|
|
309
334
|
return 'attestation-sent';
|
|
310
335
|
} else if (missedAttestors.has(who)) {
|
|
@@ -361,15 +386,16 @@ export class Sentinel extends EventEmitter {
|
|
|
361
386
|
computeStatsForValidator(address, allHistory, fromSlot, toSlot) {
|
|
362
387
|
let history = fromSlot ? allHistory.filter((h)=>BigInt(h.slot) >= fromSlot) : allHistory;
|
|
363
388
|
history = toSlot ? history.filter((h)=>BigInt(h.slot) <= toSlot) : history;
|
|
364
|
-
const lastProposal = history.filter((h)=>h.status === '
|
|
389
|
+
const lastProposal = history.filter((h)=>h.status === 'checkpoint-proposed' || h.status === 'checkpoint-mined').at(-1);
|
|
365
390
|
const lastAttestation = history.filter((h)=>h.status === 'attestation-sent').at(-1);
|
|
366
391
|
return {
|
|
367
392
|
address: EthAddress.fromString(address),
|
|
368
393
|
lastProposal: this.computeFromSlot(lastProposal?.slot),
|
|
369
394
|
lastAttestation: this.computeFromSlot(lastAttestation?.slot),
|
|
370
395
|
totalSlots: history.length,
|
|
371
|
-
missedProposals: this.computeMissed(history, '
|
|
372
|
-
'
|
|
396
|
+
missedProposals: this.computeMissed(history, 'proposer', [
|
|
397
|
+
'checkpoint-missed',
|
|
398
|
+
'blocks-missed'
|
|
373
399
|
]),
|
|
374
400
|
missedAttestations: this.computeMissed(history, 'attestation', [
|
|
375
401
|
'attestation-missed'
|
|
@@ -377,8 +403,8 @@ export class Sentinel extends EventEmitter {
|
|
|
377
403
|
history
|
|
378
404
|
};
|
|
379
405
|
}
|
|
380
|
-
computeMissed(history,
|
|
381
|
-
const relevantHistory = history.filter((h)=>!
|
|
406
|
+
computeMissed(history, computeOverCategory, filter) {
|
|
407
|
+
const relevantHistory = history.filter((h)=>!computeOverCategory || statusToCategory(h.status) === computeOverCategory);
|
|
382
408
|
const filteredHistory = relevantHistory.filter((h)=>filter.includes(h.status));
|
|
383
409
|
return {
|
|
384
410
|
currentStreak: countWhile([
|
package/dest/sentinel/store.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import type { ValidatorStatusHistory, ValidatorStatusInSlot, ValidatorsEpochPerf
|
|
|
5
5
|
export declare class SentinelStore {
|
|
6
6
|
private store;
|
|
7
7
|
private config;
|
|
8
|
-
static readonly SCHEMA_VERSION =
|
|
8
|
+
static readonly SCHEMA_VERSION = 3;
|
|
9
9
|
private readonly historyMap;
|
|
10
10
|
private readonly provenMap;
|
|
11
11
|
constructor(store: AztecAsyncKVStore, config: {
|
|
@@ -32,4 +32,4 @@ export declare class SentinelStore {
|
|
|
32
32
|
private statusToNumber;
|
|
33
33
|
private statusFromNumber;
|
|
34
34
|
}
|
|
35
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
35
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3RvcmUuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2Vz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,WAEtB;IAEM,kCAAkC,WAExC;IAEY,uBAAuB,CAAC,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,0BAA0B,iBAM/F;IAEY,oBAAoB,CAAC,GAAG,EAAE,UAAU,GAAG,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,WAAW,CAAA;KAAE,EAAE,CAAC,CAGnH;YAEa,sCAAsC;IA6BvC,gBAAgB,CAAC,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,CAAC,KAAK,MAAM,EAAE,EAAE,qBAAqB,GAAG,SAAS,CAAC,iBAQjH;YAEa,0BAA0B;IAQ3B,YAAY,IAAI,OAAO,CAAC,MAAM,CAAC,KAAK,MAAM,EAAE,EAAE,sBAAsB,CAAC,CAAC,CAMlF;IAEY,UAAU,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,sBAAsB,GAAG,SAAS,CAAC,CAGxF;IAED,OAAO,CAAC,oBAAoB;IAM5B,OAAO,CAAC,sBAAsB;IAa9B,OAAO,CAAC,gBAAgB;IAMxB,OAAO,CAAC,kBAAkB;IAW1B,OAAO,CAAC,cAAc;IAqBtB,OAAO,CAAC,gBAAgB;CAkBzB"}
|
package/dest/sentinel/store.js
CHANGED
|
@@ -4,7 +4,7 @@ import { BufferReader, numToUInt8, numToUInt32BE, serializeToBuffer } from '@azt
|
|
|
4
4
|
export class SentinelStore {
|
|
5
5
|
store;
|
|
6
6
|
config;
|
|
7
|
-
static SCHEMA_VERSION =
|
|
7
|
+
static SCHEMA_VERSION = 3;
|
|
8
8
|
// a map from validator address to their ValidatorStatusHistory
|
|
9
9
|
historyMap;
|
|
10
10
|
// a map from validator address to their historical proven epoch performance
|
|
@@ -134,16 +134,18 @@ export class SentinelStore {
|
|
|
134
134
|
}
|
|
135
135
|
statusToNumber(status) {
|
|
136
136
|
switch(status){
|
|
137
|
-
case '
|
|
137
|
+
case 'checkpoint-mined':
|
|
138
138
|
return 1;
|
|
139
|
-
case '
|
|
139
|
+
case 'checkpoint-proposed':
|
|
140
140
|
return 2;
|
|
141
|
-
case '
|
|
141
|
+
case 'checkpoint-missed':
|
|
142
142
|
return 3;
|
|
143
143
|
case 'attestation-sent':
|
|
144
144
|
return 4;
|
|
145
145
|
case 'attestation-missed':
|
|
146
146
|
return 5;
|
|
147
|
+
case 'blocks-missed':
|
|
148
|
+
return 6;
|
|
147
149
|
default:
|
|
148
150
|
{
|
|
149
151
|
const _exhaustive = status;
|
|
@@ -154,15 +156,17 @@ export class SentinelStore {
|
|
|
154
156
|
statusFromNumber(status) {
|
|
155
157
|
switch(status){
|
|
156
158
|
case 1:
|
|
157
|
-
return '
|
|
159
|
+
return 'checkpoint-mined';
|
|
158
160
|
case 2:
|
|
159
|
-
return '
|
|
161
|
+
return 'checkpoint-proposed';
|
|
160
162
|
case 3:
|
|
161
|
-
return '
|
|
163
|
+
return 'checkpoint-missed';
|
|
162
164
|
case 4:
|
|
163
165
|
return 'attestation-sent';
|
|
164
166
|
case 5:
|
|
165
167
|
return 'attestation-missed';
|
|
168
|
+
case 6:
|
|
169
|
+
return 'blocks-missed';
|
|
166
170
|
default:
|
|
167
171
|
throw new Error(`Unknown status: ${status}`);
|
|
168
172
|
}
|