@aztec/validator-client 0.0.1-commit.f5d02921e → 0.0.1-commit.f7ea82942
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/config.js +4 -4
- package/dest/duties/validation_service.d.ts +7 -9
- package/dest/duties/validation_service.d.ts.map +1 -1
- package/dest/duties/validation_service.js +13 -25
- package/dest/factory.d.ts +1 -1
- package/dest/factory.d.ts.map +1 -1
- package/dest/factory.js +1 -1
- package/dest/metrics.d.ts +5 -1
- package/dest/metrics.d.ts.map +1 -1
- package/dest/metrics.js +12 -0
- package/dest/proposal_handler.d.ts +2 -1
- package/dest/proposal_handler.d.ts.map +1 -1
- package/dest/proposal_handler.js +23 -12
- package/dest/validator.d.ts +8 -8
- package/dest/validator.d.ts.map +1 -1
- package/dest/validator.js +18 -14
- package/package.json +19 -19
- package/src/config.ts +4 -4
- package/src/duties/validation_service.ts +16 -29
- package/src/factory.ts +1 -0
- package/src/metrics.ts +18 -0
- package/src/proposal_handler.ts +30 -15
- package/src/validator.ts +28 -17
package/src/validator.ts
CHANGED
|
@@ -1,13 +1,7 @@
|
|
|
1
1
|
import type { BlobClientInterface } from '@aztec/blob-client/client';
|
|
2
2
|
import { type Blob, getBlobsPerL1Block } from '@aztec/blob-lib';
|
|
3
3
|
import type { EpochCache } from '@aztec/epoch-cache';
|
|
4
|
-
import {
|
|
5
|
-
BlockNumber,
|
|
6
|
-
CheckpointNumber,
|
|
7
|
-
EpochNumber,
|
|
8
|
-
IndexWithinCheckpoint,
|
|
9
|
-
SlotNumber,
|
|
10
|
-
} from '@aztec/foundation/branded-types';
|
|
4
|
+
import { CheckpointNumber, EpochNumber, IndexWithinCheckpoint, SlotNumber } from '@aztec/foundation/branded-types';
|
|
11
5
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
12
6
|
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
13
7
|
import type { Signature } from '@aztec/foundation/eth-signature';
|
|
@@ -23,7 +17,6 @@ import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
|
23
17
|
import type { CommitteeAttestationsAndSigners, L2BlockSink, L2BlockSource } from '@aztec/stdlib/block';
|
|
24
18
|
import { getEpochAtSlot } from '@aztec/stdlib/epoch-helpers';
|
|
25
19
|
import type {
|
|
26
|
-
CreateCheckpointProposalLastBlockData,
|
|
27
20
|
ITxProvider,
|
|
28
21
|
Validator,
|
|
29
22
|
ValidatorClientFullConfig,
|
|
@@ -217,6 +210,7 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
|
|
|
217
210
|
metrics,
|
|
218
211
|
dateProvider,
|
|
219
212
|
telemetry,
|
|
213
|
+
undefined,
|
|
220
214
|
);
|
|
221
215
|
|
|
222
216
|
const nodeKeystoreAdapter = NodeKeystoreAdapter.fromKeyStoreManager(keyStoreManager);
|
|
@@ -514,14 +508,17 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
|
|
|
514
508
|
|
|
515
509
|
// Validate the checkpoint proposal before attesting (unless skipCheckpointProposalValidation is set).
|
|
516
510
|
// Uses the cached result from the all-nodes callback if available (avoids double validation).
|
|
511
|
+
let checkpointNumber: CheckpointNumber;
|
|
517
512
|
if (this.config.skipCheckpointProposalValidation) {
|
|
518
513
|
this.log.warn(`Skipping checkpoint proposal validation for slot ${proposalSlotNumber}`, proposalInfo);
|
|
514
|
+
checkpointNumber = CheckpointNumber(0);
|
|
519
515
|
} else {
|
|
520
516
|
const validationResult = await this.proposalHandler.handleCheckpointProposal(proposal, proposalInfo);
|
|
521
517
|
if (!validationResult.isValid) {
|
|
522
518
|
this.log.warn(`Checkpoint proposal validation failed: ${validationResult.reason}`, proposalInfo);
|
|
523
519
|
return undefined;
|
|
524
520
|
}
|
|
521
|
+
checkpointNumber = validationResult.checkpointNumber;
|
|
525
522
|
}
|
|
526
523
|
|
|
527
524
|
// Check that I have any address in current committee before attesting
|
|
@@ -579,7 +576,7 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
|
|
|
579
576
|
return undefined;
|
|
580
577
|
}
|
|
581
578
|
|
|
582
|
-
return await this.createCheckpointAttestationsFromProposal(proposal, attestors);
|
|
579
|
+
return await this.createCheckpointAttestationsFromProposal(proposal, attestors, checkpointNumber);
|
|
583
580
|
}
|
|
584
581
|
|
|
585
582
|
/**
|
|
@@ -606,13 +603,14 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
|
|
|
606
603
|
private async createCheckpointAttestationsFromProposal(
|
|
607
604
|
proposal: CheckpointProposalCore,
|
|
608
605
|
attestors: EthAddress[] = [],
|
|
606
|
+
checkpointNumber: CheckpointNumber,
|
|
609
607
|
): Promise<CheckpointAttestation[] | undefined> {
|
|
610
608
|
// Equivocation check: must happen right before signing to minimize the race window
|
|
611
609
|
if (!this.shouldAttestToSlot(proposal.slotNumber)) {
|
|
612
610
|
return undefined;
|
|
613
611
|
}
|
|
614
612
|
|
|
615
|
-
const attestations = await this.validationService.attestToCheckpointProposal(proposal, attestors);
|
|
613
|
+
const attestations = await this.validationService.attestToCheckpointProposal(proposal, attestors, checkpointNumber);
|
|
616
614
|
|
|
617
615
|
// Track the proposal we attested to (to prevent equivocation)
|
|
618
616
|
this.lastAttestedProposal = proposal;
|
|
@@ -725,6 +723,7 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
|
|
|
725
723
|
|
|
726
724
|
async createBlockProposal(
|
|
727
725
|
blockHeader: BlockHeader,
|
|
726
|
+
checkpointNumber: CheckpointNumber,
|
|
728
727
|
indexWithinCheckpoint: IndexWithinCheckpoint,
|
|
729
728
|
inHash: Fr,
|
|
730
729
|
archive: Fr,
|
|
@@ -751,6 +750,7 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
|
|
|
751
750
|
);
|
|
752
751
|
const newProposal = await this.validationService.createBlockProposal(
|
|
753
752
|
blockHeader,
|
|
753
|
+
checkpointNumber,
|
|
754
754
|
indexWithinCheckpoint,
|
|
755
755
|
inHash,
|
|
756
756
|
archive,
|
|
@@ -768,8 +768,9 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
|
|
|
768
768
|
async createCheckpointProposal(
|
|
769
769
|
checkpointHeader: CheckpointHeader,
|
|
770
770
|
archive: Fr,
|
|
771
|
+
checkpointNumber: CheckpointNumber,
|
|
771
772
|
feeAssetPriceModifier: bigint,
|
|
772
|
-
|
|
773
|
+
lastBlockProposal: BlockProposal | undefined,
|
|
773
774
|
proposerAddress: EthAddress | undefined,
|
|
774
775
|
options: CheckpointProposalOptions = {},
|
|
775
776
|
): Promise<CheckpointProposal> {
|
|
@@ -790,8 +791,9 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
|
|
|
790
791
|
const newProposal = await this.validationService.createCheckpointProposal(
|
|
791
792
|
checkpointHeader,
|
|
792
793
|
archive,
|
|
794
|
+
checkpointNumber,
|
|
793
795
|
feeAssetPriceModifier,
|
|
794
|
-
|
|
796
|
+
lastBlockProposal,
|
|
795
797
|
proposerAddress,
|
|
796
798
|
options,
|
|
797
799
|
);
|
|
@@ -807,16 +809,24 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
|
|
|
807
809
|
attestationsAndSigners: CommitteeAttestationsAndSigners,
|
|
808
810
|
proposer: EthAddress,
|
|
809
811
|
slot: SlotNumber,
|
|
810
|
-
|
|
812
|
+
checkpointNumber: CheckpointNumber,
|
|
811
813
|
): Promise<Signature> {
|
|
812
|
-
return await this.validationService.signAttestationsAndSigners(
|
|
814
|
+
return await this.validationService.signAttestationsAndSigners(
|
|
815
|
+
attestationsAndSigners,
|
|
816
|
+
proposer,
|
|
817
|
+
slot,
|
|
818
|
+
checkpointNumber,
|
|
819
|
+
);
|
|
813
820
|
}
|
|
814
821
|
|
|
815
|
-
async collectOwnAttestations(
|
|
822
|
+
async collectOwnAttestations(
|
|
823
|
+
proposal: CheckpointProposal,
|
|
824
|
+
checkpointNumber: CheckpointNumber,
|
|
825
|
+
): Promise<CheckpointAttestation[]> {
|
|
816
826
|
const slot = proposal.slotNumber;
|
|
817
827
|
const inCommittee = await this.epochCache.filterInCommittee(slot, this.getValidatorAddresses());
|
|
818
828
|
this.log.debug(`Collecting ${inCommittee.length} self-attestations for slot ${slot}`, { inCommittee });
|
|
819
|
-
const attestations = await this.createCheckpointAttestationsFromProposal(proposal, inCommittee);
|
|
829
|
+
const attestations = await this.createCheckpointAttestationsFromProposal(proposal, inCommittee, checkpointNumber);
|
|
820
830
|
|
|
821
831
|
if (!attestations) {
|
|
822
832
|
return [];
|
|
@@ -835,6 +845,7 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
|
|
|
835
845
|
proposal: CheckpointProposal,
|
|
836
846
|
required: number,
|
|
837
847
|
deadline: Date,
|
|
848
|
+
checkpointNumber: CheckpointNumber,
|
|
838
849
|
): Promise<CheckpointAttestation[]> {
|
|
839
850
|
// Wait and poll the p2pClient's attestation pool for this checkpoint until we have enough attestations
|
|
840
851
|
const slot = proposal.slotNumber;
|
|
@@ -847,7 +858,7 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
|
|
|
847
858
|
throw new AttestationTimeoutError(0, required, slot);
|
|
848
859
|
}
|
|
849
860
|
|
|
850
|
-
await this.collectOwnAttestations(proposal);
|
|
861
|
+
await this.collectOwnAttestations(proposal, checkpointNumber);
|
|
851
862
|
|
|
852
863
|
const proposalId = proposal.archive.toString();
|
|
853
864
|
const myAddresses = this.getValidatorAddresses();
|