@aztec/validator-client 0.0.1-commit.2eb6648a → 0.0.1-commit.2f68f620
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/README.md +52 -10
- package/dest/checkpoint_builder.d.ts +21 -8
- package/dest/checkpoint_builder.d.ts.map +1 -1
- package/dest/checkpoint_builder.js +124 -46
- package/dest/config.d.ts +1 -1
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +37 -7
- package/dest/duties/validation_service.d.ts +12 -13
- package/dest/duties/validation_service.d.ts.map +1 -1
- package/dest/duties/validation_service.js +33 -45
- package/dest/factory.d.ts +10 -4
- package/dest/factory.d.ts.map +1 -1
- package/dest/factory.js +11 -5
- package/dest/index.d.ts +2 -3
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +1 -2
- package/dest/key_store/ha_key_store.js +1 -1
- package/dest/metrics.d.ts +14 -2
- package/dest/metrics.d.ts.map +1 -1
- package/dest/metrics.js +24 -0
- package/dest/proposal_handler.d.ts +134 -0
- package/dest/proposal_handler.d.ts.map +1 -0
- package/dest/proposal_handler.js +1072 -0
- package/dest/validator.d.ts +53 -23
- package/dest/validator.d.ts.map +1 -1
- package/dest/validator.js +341 -231
- package/package.json +19 -19
- package/src/checkpoint_builder.ts +142 -39
- package/src/config.ts +37 -6
- package/src/duties/validation_service.ts +59 -54
- package/src/factory.ts +20 -3
- package/src/index.ts +1 -2
- package/src/key_store/ha_key_store.ts +1 -1
- package/src/metrics.ts +37 -1
- package/src/proposal_handler.ts +1161 -0
- package/src/validator.ts +460 -272
- package/dest/block_proposal_handler.d.ts +0 -63
- package/dest/block_proposal_handler.d.ts.map +0 -1
- package/dest/block_proposal_handler.js +0 -546
- package/dest/tx_validator/index.d.ts +0 -3
- package/dest/tx_validator/index.d.ts.map +0 -1
- package/dest/tx_validator/index.js +0 -2
- package/dest/tx_validator/nullifier_cache.d.ts +0 -14
- package/dest/tx_validator/nullifier_cache.d.ts.map +0 -1
- package/dest/tx_validator/nullifier_cache.js +0 -24
- package/dest/tx_validator/tx_validator_factory.d.ts +0 -19
- package/dest/tx_validator/tx_validator_factory.d.ts.map +0 -1
- package/dest/tx_validator/tx_validator_factory.js +0 -54
- package/src/block_proposal_handler.ts +0 -555
- package/src/tx_validator/index.ts +0 -2
- package/src/tx_validator/nullifier_cache.ts +0 -30
- package/src/tx_validator/tx_validator_factory.ts +0 -154
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { type CheckpointNumber, IndexWithinCheckpoint, type SlotNumber } from '@aztec/foundation/branded-types';
|
|
2
2
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
3
|
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
4
4
|
import type { Signature } from '@aztec/foundation/eth-signature';
|
|
5
|
-
import
|
|
6
|
-
import type
|
|
7
|
-
import {
|
|
8
|
-
import type { CheckpointHeader } from '@aztec/stdlib/rollup';
|
|
5
|
+
import { CommitteeAttestationsAndSigners } from '@aztec/stdlib/block';
|
|
6
|
+
import { BlockProposal, type BlockProposalOptions, CheckpointAttestation, CheckpointProposal, type CheckpointProposalCore, type CheckpointProposalOptions, type CoordinationSignatureContext } from '@aztec/stdlib/p2p';
|
|
7
|
+
import { CheckpointHeader } from '@aztec/stdlib/rollup';
|
|
9
8
|
import type { BlockHeader, Tx } from '@aztec/stdlib/tx';
|
|
10
9
|
import type { ValidatorKeyStore } from '../key_store/interface.js';
|
|
11
10
|
export declare class ValidationService {
|
|
12
11
|
private keyStore;
|
|
12
|
+
private signatureContext;
|
|
13
13
|
private log;
|
|
14
|
-
constructor(keyStore: ValidatorKeyStore, log?: import("@aztec/foundation/log").Logger);
|
|
14
|
+
constructor(keyStore: ValidatorKeyStore, signatureContext: CoordinationSignatureContext, log?: import("@aztec/foundation/log").Logger);
|
|
15
15
|
/**
|
|
16
16
|
* Create a block proposal with the given header, archive, and transactions
|
|
17
17
|
*
|
|
@@ -27,19 +27,19 @@ export declare class ValidationService {
|
|
|
27
27
|
* @throws DutyAlreadySignedError if HA signer indicates duty already signed by another node
|
|
28
28
|
* @throws SlashingProtectionError if attempting to sign different data for same slot
|
|
29
29
|
*/
|
|
30
|
-
createBlockProposal(blockHeader: BlockHeader, blockIndexWithinCheckpoint: IndexWithinCheckpoint, inHash: Fr, archive: Fr, txs: Tx[], proposerAttesterAddress: EthAddress | undefined, options: BlockProposalOptions): Promise<BlockProposal>;
|
|
30
|
+
createBlockProposal(blockHeader: BlockHeader, checkpointNumber: CheckpointNumber, blockIndexWithinCheckpoint: IndexWithinCheckpoint, inHash: Fr, archive: Fr, txs: Tx[], proposerAttesterAddress: EthAddress | undefined, options: BlockProposalOptions): Promise<BlockProposal>;
|
|
31
31
|
/**
|
|
32
32
|
* Create a checkpoint proposal with the last block header and checkpoint header
|
|
33
33
|
*
|
|
34
34
|
* @param checkpointHeader - The checkpoint header containing aggregated data
|
|
35
35
|
* @param archive - The archive of the checkpoint
|
|
36
|
-
* @param
|
|
36
|
+
* @param lastBlockProposal - Signed block proposal for the last block in the checkpoint, or undefined
|
|
37
37
|
* @param proposerAttesterAddress - The address of the proposer
|
|
38
38
|
* @param options - Checkpoint proposal options
|
|
39
39
|
*
|
|
40
40
|
* @returns A checkpoint proposal signing the above information
|
|
41
41
|
*/
|
|
42
|
-
createCheckpointProposal(checkpointHeader: CheckpointHeader, archive: Fr,
|
|
42
|
+
createCheckpointProposal(checkpointHeader: CheckpointHeader, archive: Fr, checkpointNumber: CheckpointNumber, feeAssetPriceModifier: bigint, lastBlockProposal: BlockProposal | undefined, proposerAttesterAddress: EthAddress | undefined, options: CheckpointProposalOptions): Promise<CheckpointProposal>;
|
|
43
43
|
/**
|
|
44
44
|
* Attest with selection of validators to the given checkpoint proposal
|
|
45
45
|
*
|
|
@@ -50,17 +50,16 @@ export declare class ValidationService {
|
|
|
50
50
|
* @param attestors - The validators to attest with
|
|
51
51
|
* @returns checkpoint attestations
|
|
52
52
|
*/
|
|
53
|
-
attestToCheckpointProposal(proposal: CheckpointProposalCore, attestors: EthAddress[]): Promise<CheckpointAttestation[]>;
|
|
53
|
+
attestToCheckpointProposal(proposal: CheckpointProposalCore, attestors: EthAddress[], checkpointNumber: CheckpointNumber): Promise<CheckpointAttestation[]>;
|
|
54
54
|
/**
|
|
55
55
|
* Sign attestations and signers payload
|
|
56
56
|
* @param attestationsAndSigners - The attestations and signers to sign
|
|
57
57
|
* @param proposer - The proposer address to sign with
|
|
58
58
|
* @param slot - The slot number for HA signing context
|
|
59
|
-
* @param blockNumber - The block or checkpoint number for HA signing context
|
|
60
59
|
* @returns signature
|
|
61
60
|
* @throws DutyAlreadySignedError if already signed by another HA node
|
|
62
61
|
* @throws SlashingProtectionError if attempting to sign different data for same slot
|
|
63
62
|
*/
|
|
64
|
-
signAttestationsAndSigners(attestationsAndSigners: CommitteeAttestationsAndSigners, proposer: EthAddress, slot: SlotNumber,
|
|
63
|
+
signAttestationsAndSigners(attestationsAndSigners: CommitteeAttestationsAndSigners, proposer: EthAddress, slot: SlotNumber, checkpointNumber: CheckpointNumber): Promise<Signature>;
|
|
65
64
|
}
|
|
66
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
65
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidmFsaWRhdGlvbl9zZXJ2aWNlLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvZHV0aWVzL3ZhbGlkYXRpb25fc2VydmljZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsS0FBSyxnQkFBZ0IsRUFBRSxxQkFBcUIsRUFBRSxLQUFLLFVBQVUsRUFBRSxNQUFNLGlDQUFpQyxDQUFDO0FBQ2hILE9BQU8sRUFBRSxFQUFFLEVBQUUsTUFBTSxnQ0FBZ0MsQ0FBQztBQUNwRCxPQUFPLEtBQUssRUFBRSxVQUFVLEVBQUUsTUFBTSwrQk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TyxFQUFFLG9CQUFvQixHQUM1QixPQUFPLENBQUMsYUFBYSxDQUFDLENBOEJ4QjtJQUVEOzs7Ozs7Ozs7O09BVUc7SUFDSSx3QkFBd0IsQ0FDN0IsZ0JBQWdCLEVBQUUsZ0JBQWdCLEVBQ2xDLE9BQU8sRUFBRSxFQUFFLEVBQ1gsZ0JBQWdCLEVBQUUsZ0JBQWdCLEVBQ2xDLHFCQUFxQixFQUFFLE1BQU0sRUFDN0IsaUJBQWlCLEVBQUUsYUFBYSxHQUFHLFNBQVMsRUFDNUMsdUJBQXVCLEVBQUUsVUFBVSxHQUFHLFNBQVMsRUFDL0MsT0FBTyxFQUFFLHlCQUF5QixHQUNqQyxPQUFPLENBQUMsa0JBQWtCLENBQUMsQ0FnQzdCO0lBRUQ7Ozs7Ozs7OztPQVNHO0lBQ0csMEJBQTBCLENBQzlCLFFBQVEsRUFBRSxzQkFBc0IsRUFDaEMsU0FBUyxFQUFFLFVBQVUsRUFBRSxFQUN2QixnQkFBZ0IsRUFBRSxnQkFBZ0IsR0FDakMsT0FBTyxDQUFDLHFCQUFxQixFQUFFLENBQUMsQ0EyQ2xDO0lBRUQ7Ozs7Ozs7O09BUUc7SUFDSCwwQkFBMEIsQ0FDeEIsc0JBQXNCLEVBQUUsK0JBQStCLEVBQ3ZELFFBQVEsRUFBRSxVQUFVLEVBQ3BCLElBQUksRUFBRSxVQUFVLEVBQ2hCLGdCQUFnQixFQUFFLGdCQUFnQixHQUNqQyxPQUFPLENBQUMsU0FBUyxDQUFDLENBU3BCO0NBQ0YifQ==
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validation_service.d.ts","sourceRoot":"","sources":["../../src/duties/validation_service.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"validation_service.d.ts","sourceRoot":"","sources":["../../src/duties/validation_service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,gBAAgB,EAAE,qBAAqB,EAAE,KAAK,UA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C7B,iBAAiB,EAAE,aAAa,GAAG,SAAS,EAC5C,uBAAuB,EAAE,UAAU,GAAG,SAAS,EAC/C,OAAO,EAAE,yBAAyB,GACjC,OAAO,CAAC,kBAAkB,CAAC,CAgC7B;IAED;;;;;;;;;OASG;IACG,0BAA0B,CAC9B,QAAQ,EAAE,sBAAsB,EAChC,SAAS,EAAE,UAAU,EAAE,EACvB,gBAAgB,EAAE,gBAAgB,GACjC,OAAO,CAAC,qBAAqB,EAAE,CAAC,CA2ClC;IAED;;;;;;;;OAQG;IACH,0BAA0B,CACxB,sBAAsB,EAAE,+BAA+B,EACvD,QAAQ,EAAE,UAAU,EACpB,IAAI,EAAE,UAAU,EAChB,gBAAgB,EAAE,gBAAgB,GACjC,OAAO,CAAC,SAAS,CAAC,CASpB;CACF"}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
2
|
-
import { Buffer32 } from '@aztec/foundation/buffer';
|
|
3
|
-
import { keccak256 } from '@aztec/foundation/crypto/keccak';
|
|
4
1
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
5
2
|
import { createLogger } from '@aztec/foundation/log';
|
|
6
|
-
import { BlockProposal, CheckpointAttestation, CheckpointProposal, ConsensusPayload,
|
|
3
|
+
import { BlockProposal, CheckpointAttestation, CheckpointProposal, ConsensusPayload, getCoordinationSignatureTypedData } from '@aztec/stdlib/p2p';
|
|
4
|
+
import { CheckpointHeader } from '@aztec/stdlib/rollup';
|
|
7
5
|
import { DutyAlreadySignedError, SlashingProtectionError } from '@aztec/validator-ha-signer/errors';
|
|
8
6
|
import { DutyType } from '@aztec/validator-ha-signer/types';
|
|
9
7
|
export class ValidationService {
|
|
10
8
|
keyStore;
|
|
9
|
+
signatureContext;
|
|
11
10
|
log;
|
|
12
|
-
constructor(keyStore, log = createLogger('validator:validation-service')){
|
|
11
|
+
constructor(keyStore, signatureContext, log = createLogger('validator:validation-service')){
|
|
13
12
|
this.keyStore = keyStore;
|
|
13
|
+
this.signatureContext = signatureContext;
|
|
14
14
|
this.log = log;
|
|
15
15
|
}
|
|
16
16
|
/**
|
|
@@ -27,7 +27,7 @@ export class ValidationService {
|
|
|
27
27
|
* @returns A block proposal signing the above information
|
|
28
28
|
* @throws DutyAlreadySignedError if HA signer indicates duty already signed by another node
|
|
29
29
|
* @throws SlashingProtectionError if attempting to sign different data for same slot
|
|
30
|
-
*/ createBlockProposal(blockHeader, blockIndexWithinCheckpoint, inHash, archive, txs, proposerAttesterAddress, options) {
|
|
30
|
+
*/ createBlockProposal(blockHeader, checkpointNumber, blockIndexWithinCheckpoint, inHash, archive, txs, proposerAttesterAddress, options) {
|
|
31
31
|
// For testing: change the new archive to trigger state_mismatch validation failure
|
|
32
32
|
if (options.broadcastInvalidBlockProposal) {
|
|
33
33
|
archive = Fr.random();
|
|
@@ -35,38 +35,39 @@ export class ValidationService {
|
|
|
35
35
|
}
|
|
36
36
|
// Create a signer that uses the appropriate address
|
|
37
37
|
const address = proposerAttesterAddress ?? this.keyStore.getAddress(0);
|
|
38
|
-
const payloadSigner = (
|
|
39
|
-
|
|
38
|
+
const payloadSigner = (typedData, context)=>this.keyStore.signTypedDataWithAddress(address, typedData, context);
|
|
39
|
+
const txsSigner = (typedData, context)=>this.keyStore.signTypedDataWithAddress(address, typedData, context);
|
|
40
|
+
return BlockProposal.createProposalFromSigner(blockHeader, checkpointNumber, blockIndexWithinCheckpoint, inHash, archive, txs.map((tx)=>tx.getTxHash()), options.publishFullTxs ? txs : undefined, this.signatureContext, payloadSigner, txsSigner);
|
|
40
41
|
}
|
|
41
42
|
/**
|
|
42
43
|
* Create a checkpoint proposal with the last block header and checkpoint header
|
|
43
44
|
*
|
|
44
45
|
* @param checkpointHeader - The checkpoint header containing aggregated data
|
|
45
46
|
* @param archive - The archive of the checkpoint
|
|
46
|
-
* @param
|
|
47
|
+
* @param lastBlockProposal - Signed block proposal for the last block in the checkpoint, or undefined
|
|
47
48
|
* @param proposerAttesterAddress - The address of the proposer
|
|
48
49
|
* @param options - Checkpoint proposal options
|
|
49
50
|
*
|
|
50
51
|
* @returns A checkpoint proposal signing the above information
|
|
51
|
-
*/ createCheckpointProposal(checkpointHeader, archive,
|
|
52
|
-
// For testing:
|
|
52
|
+
*/ createCheckpointProposal(checkpointHeader, archive, checkpointNumber, feeAssetPriceModifier, lastBlockProposal, proposerAttesterAddress, options) {
|
|
53
|
+
// For testing: corrupt the checkpoint so observers' checkpoint validation fails.
|
|
54
|
+
//
|
|
55
|
+
// Keep `archive` aligned with `lastBlockProposal.archiveRoot` so the archive-based lookup
|
|
56
|
+
// in `validateCheckpointProposal` (`getBlockData({ archive })`) still succeeds
|
|
53
57
|
if (options.broadcastInvalidCheckpointProposal) {
|
|
54
|
-
archive = Fr.random();
|
|
58
|
+
archive = lastBlockProposal?.archiveRoot ?? Fr.random();
|
|
59
|
+
checkpointHeader = CheckpointHeader.from({
|
|
60
|
+
...checkpointHeader,
|
|
61
|
+
epochOutHash: Fr.random()
|
|
62
|
+
});
|
|
55
63
|
this.log.warn(`Creating INVALID checkpoint proposal for slot ${checkpointHeader.slotNumber}`);
|
|
56
64
|
}
|
|
57
65
|
// Create a signer that takes payload and context, and uses the appropriate address
|
|
58
|
-
const payloadSigner = (
|
|
66
|
+
const payloadSigner = (typedData, context)=>{
|
|
59
67
|
const address = proposerAttesterAddress ?? this.keyStore.getAddress(0);
|
|
60
|
-
return this.keyStore.
|
|
61
|
-
};
|
|
62
|
-
// Last block to include in the proposal
|
|
63
|
-
const lastBlock = lastBlockInfo && {
|
|
64
|
-
blockHeader: lastBlockInfo.blockHeader,
|
|
65
|
-
indexWithinCheckpoint: lastBlockInfo.indexWithinCheckpoint,
|
|
66
|
-
txHashes: lastBlockInfo.txs.map((tx)=>tx.getTxHash()),
|
|
67
|
-
txs: options.publishFullTxs ? lastBlockInfo.txs : undefined
|
|
68
|
+
return this.keyStore.signTypedDataWithAddress(address, typedData, context);
|
|
68
69
|
};
|
|
69
|
-
return CheckpointProposal.createProposalFromSigner(checkpointHeader, archive,
|
|
70
|
+
return CheckpointProposal.createProposalFromSigner(checkpointHeader, archive, checkpointNumber, feeAssetPriceModifier, lastBlockProposal, this.signatureContext, payloadSigner);
|
|
70
71
|
}
|
|
71
72
|
/**
|
|
72
73
|
* Attest with selection of validators to the given checkpoint proposal
|
|
@@ -77,30 +78,18 @@ export class ValidationService {
|
|
|
77
78
|
* @param proposal - The checkpoint proposal (core version without lastBlock) to attest to
|
|
78
79
|
* @param attestors - The validators to attest with
|
|
79
80
|
* @returns checkpoint attestations
|
|
80
|
-
*/ async attestToCheckpointProposal(proposal, attestors) {
|
|
81
|
+
*/ async attestToCheckpointProposal(proposal, attestors, checkpointNumber) {
|
|
81
82
|
// Create the attestation payload from the checkpoint proposal
|
|
82
|
-
const payload = new ConsensusPayload(proposal.checkpointHeader, proposal.archive);
|
|
83
|
-
const
|
|
84
|
-
// TODO(spy/ha): Use checkpointNumber instead of blockNumber once CheckpointHeader includes it.
|
|
85
|
-
// Currently using lastBlock.blockNumber as a proxy for checkpoint identification in HA signing.
|
|
86
|
-
// blockNumber is NOT used for the primary key so it's safe to use here.
|
|
87
|
-
// See CheckpointHeader TODO and SigningContext types documentation.
|
|
88
|
-
let blockNumber;
|
|
89
|
-
try {
|
|
90
|
-
blockNumber = proposal.blockNumber;
|
|
91
|
-
} catch {
|
|
92
|
-
// Checkpoint proposal may not have lastBlock, use 0 as fallback
|
|
93
|
-
blockNumber = BlockNumber(0);
|
|
94
|
-
}
|
|
83
|
+
const payload = new ConsensusPayload(proposal.checkpointHeader, proposal.archive, proposal.feeAssetPriceModifier, this.signatureContext);
|
|
84
|
+
const typedData = getCoordinationSignatureTypedData(payload);
|
|
95
85
|
const context = {
|
|
96
86
|
slot: proposal.slotNumber,
|
|
97
|
-
|
|
87
|
+
checkpointNumber,
|
|
98
88
|
dutyType: DutyType.ATTESTATION
|
|
99
89
|
};
|
|
100
90
|
// Sign each attestor in parallel, catching HA errors per-attestor
|
|
101
91
|
const results = await Promise.allSettled(attestors.map(async (attestor)=>{
|
|
102
|
-
const sig = await this.keyStore.
|
|
103
|
-
// return new BlockAttestation(proposal.payload, sig, proposal.signature);
|
|
92
|
+
const sig = await this.keyStore.signTypedDataWithAddress(attestor, typedData, context);
|
|
104
93
|
return new CheckpointAttestation(payload, sig, proposal.signature);
|
|
105
94
|
}));
|
|
106
95
|
const attestations = [];
|
|
@@ -111,7 +100,7 @@ export class ValidationService {
|
|
|
111
100
|
} else {
|
|
112
101
|
const error = result.reason;
|
|
113
102
|
if (error instanceof DutyAlreadySignedError || error instanceof SlashingProtectionError) {
|
|
114
|
-
this.log.
|
|
103
|
+
this.log.verbose(`Attestation for slot ${proposal.slotNumber} by ${attestors[i]} already signed by another High-Availability node`);
|
|
115
104
|
// Continue with remaining attestors
|
|
116
105
|
} else {
|
|
117
106
|
throw error;
|
|
@@ -125,17 +114,16 @@ export class ValidationService {
|
|
|
125
114
|
* @param attestationsAndSigners - The attestations and signers to sign
|
|
126
115
|
* @param proposer - The proposer address to sign with
|
|
127
116
|
* @param slot - The slot number for HA signing context
|
|
128
|
-
* @param blockNumber - The block or checkpoint number for HA signing context
|
|
129
117
|
* @returns signature
|
|
130
118
|
* @throws DutyAlreadySignedError if already signed by another HA node
|
|
131
119
|
* @throws SlashingProtectionError if attempting to sign different data for same slot
|
|
132
|
-
*/ signAttestationsAndSigners(attestationsAndSigners, proposer, slot,
|
|
120
|
+
*/ signAttestationsAndSigners(attestationsAndSigners, proposer, slot, checkpointNumber) {
|
|
133
121
|
const context = {
|
|
134
122
|
slot,
|
|
135
|
-
|
|
123
|
+
checkpointNumber,
|
|
136
124
|
dutyType: DutyType.ATTESTATIONS_AND_SIGNERS
|
|
137
125
|
};
|
|
138
|
-
const
|
|
139
|
-
return this.keyStore.
|
|
126
|
+
const typedData = getCoordinationSignatureTypedData(attestationsAndSigners);
|
|
127
|
+
return this.keyStore.signTypedDataWithAddress(proposer, typedData, context);
|
|
140
128
|
}
|
|
141
129
|
}
|
package/dest/factory.d.ts
CHANGED
|
@@ -4,22 +4,26 @@ import type { DateProvider } from '@aztec/foundation/timer';
|
|
|
4
4
|
import type { KeystoreManager } from '@aztec/node-keystore';
|
|
5
5
|
import { type P2PClient } from '@aztec/p2p';
|
|
6
6
|
import type { L2BlockSink, L2BlockSource } from '@aztec/stdlib/block';
|
|
7
|
+
import type { CheckpointReexecutionTracker } from '@aztec/stdlib/checkpoint';
|
|
7
8
|
import type { ValidatorClientFullConfig, WorldStateSynchronizer } from '@aztec/stdlib/interfaces/server';
|
|
8
9
|
import type { L1ToL2MessageSource } from '@aztec/stdlib/messaging';
|
|
9
10
|
import type { TelemetryClient } from '@aztec/telemetry-client';
|
|
10
|
-
import {
|
|
11
|
+
import type { SlashingProtectionDatabase } from '@aztec/validator-ha-signer/types';
|
|
11
12
|
import type { FullNodeCheckpointsBuilder } from './checkpoint_builder.js';
|
|
13
|
+
import { ProposalHandler } from './proposal_handler.js';
|
|
12
14
|
import { ValidatorClient } from './validator.js';
|
|
13
|
-
export declare function
|
|
15
|
+
export declare function createProposalHandler(config: ValidatorClientFullConfig, deps: {
|
|
14
16
|
checkpointsBuilder: FullNodeCheckpointsBuilder;
|
|
15
17
|
worldState: WorldStateSynchronizer;
|
|
16
18
|
blockSource: L2BlockSource & L2BlockSink;
|
|
17
19
|
l1ToL2MessageSource: L1ToL2MessageSource;
|
|
18
20
|
p2pClient: P2PClient;
|
|
19
21
|
epochCache: EpochCache;
|
|
22
|
+
blobClient: BlobClientInterface;
|
|
20
23
|
dateProvider: DateProvider;
|
|
21
24
|
telemetry: TelemetryClient;
|
|
22
|
-
|
|
25
|
+
reexecutionTracker: CheckpointReexecutionTracker;
|
|
26
|
+
}): ProposalHandler;
|
|
23
27
|
export declare function createValidatorClient(config: ValidatorClientFullConfig, deps: {
|
|
24
28
|
checkpointsBuilder: FullNodeCheckpointsBuilder;
|
|
25
29
|
worldState: WorldStateSynchronizer;
|
|
@@ -31,5 +35,7 @@ export declare function createValidatorClient(config: ValidatorClientFullConfig,
|
|
|
31
35
|
epochCache: EpochCache;
|
|
32
36
|
keyStoreManager: KeystoreManager | undefined;
|
|
33
37
|
blobClient: BlobClientInterface;
|
|
38
|
+
reexecutionTracker: CheckpointReexecutionTracker;
|
|
39
|
+
slashingProtectionDb?: SlashingProtectionDatabase;
|
|
34
40
|
}): Promise<ValidatorClient> | undefined;
|
|
35
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
41
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZmFjdG9yeS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL2ZhY3RvcnkudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxLQUFLLEVBQUUsbUJBQW1CLEVBQUUsTUFBTSwyQkFBMkIsQ0FBQztBQUNyRSxPQUFPLEtBQUssRUFBRSxVQUFVLEVBQUUsTUFBTSxvQkFBb0IsQ0FBQztBQUNyRCxPQUFPLEtBQUssRUFBRSxZQUFZLEVBQUUsTUFBTSx5QkFBeUIsQ0FBQztBQUM1RCxPQUFPLEtBQUssRUFBRSxlQUFlLEVBQUUsTUFBTSxzQkFBc0IsQ0FBQztBQUM1RCxPQUFPLEVBQTBCLEtBQUssU0FBUyxFQUFFLE1BQU0sWUFBWSxDQUFDO0FBQ3BFLE9BQU8sS0FBSyxFQUFFLFdBQVcsRUFBRSxhQUFhLEVBQUUsTUFBTSxxQkFBcUIsQ0FBQztBQUN0RSxPQUFPLEtBQUssRUFBRSw0QkFBNEIsRUFBRSxNQUFNLDBCQUEwQixDQUFDO0FBQzdFLE9BQU8sS0FBSyxFQUFFLHlCQUF5QixFQUFFLHNCQUFzQixFQUFFLE1BQU0saUNBQWlDLENBQUM7QUFDekcsT0FBTyxLQUFLLEVBQUUsbUJBQW1CLEVBQUUsTUFBTSx5QkFBeUIsQ0FBQztBQUNuRSxPQUFP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0FBQztJQUN6QyxTQUFTLEVBQUUsZUFBZSxDQUFDO0lBQzNCLFlBQVksRUFBRSxZQUFZLENBQUM7SUFDM0IsVUFBVSxFQUFFLFVBQVUsQ0FBQztJQUN2QixlQUFlLEVBQUUsZUFBZSxHQUFHLFNBQVMsQ0FBQztJQUM3QyxVQUFVLEVBQUUsbUJBQW1CLENBQUM7SUFDaEMsa0JBQWtCLEVBQUUsNEJBQTRCLENBQUM7SUFDakQsb0JBQW9CLENBQUMsRUFBRSwwQkFBMEIsQ0FBQztDQUNuRCx3Q0F1QkYifQ==
|
package/dest/factory.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../src/factory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AACrE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAA0B,KAAK,SAAS,EAAE,MAAM,YAAY,CAAC;AACpE,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACtE,OAAO,KAAK,EAAE,yBAAyB,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AACzG,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AACnE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../src/factory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AACrE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,KAAK,E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BAAsB,CAAC;IACnC,SAAS,EAAE,SAAS,CAAC;IACrB,WAAW,EAAE,aAAa,GAAG,WAAW,CAAC;IACzC,mBAAmB,EAAE,mBAAmB,CAAC;IACzC,SAAS,EAAE,eAAe,CAAC;IAC3B,YAAY,EAAE,YAAY,CAAC;IAC3B,UAAU,EAAE,UAAU,CAAC;IACvB,eAAe,EAAE,eAAe,GAAG,SAAS,CAAC;IAC7C,UAAU,EAAE,mBAAmB,CAAC;IAChC,kBAAkB,EAAE,4BAA4B,CAAC;IACjD,oBAAoB,CAAC,EAAE,0BAA0B,CAAC;CACnD,wCAuBF"}
|
package/dest/factory.js
CHANGED
|
@@ -1,18 +1,24 @@
|
|
|
1
1
|
import { BlockProposalValidator } from '@aztec/p2p';
|
|
2
|
-
import { BlockProposalHandler } from './block_proposal_handler.js';
|
|
3
2
|
import { ValidatorMetrics } from './metrics.js';
|
|
3
|
+
import { ProposalHandler } from './proposal_handler.js';
|
|
4
4
|
import { ValidatorClient } from './validator.js';
|
|
5
|
-
export function
|
|
5
|
+
export function createProposalHandler(config, deps) {
|
|
6
6
|
const metrics = new ValidatorMetrics(deps.telemetry);
|
|
7
7
|
const blockProposalValidator = new BlockProposalValidator(deps.epochCache, {
|
|
8
|
-
txsPermitted: !config.disableTransactions
|
|
8
|
+
txsPermitted: !config.disableTransactions,
|
|
9
|
+
maxTxsPerBlock: config.validateMaxTxsPerBlock ?? config.validateMaxTxsPerCheckpoint,
|
|
10
|
+
maxBlocksPerCheckpoint: config.maxBlocksPerCheckpoint,
|
|
11
|
+
signatureContext: {
|
|
12
|
+
chainId: config.l1ChainId,
|
|
13
|
+
rollupAddress: config.rollupAddress
|
|
14
|
+
}
|
|
9
15
|
});
|
|
10
|
-
return new
|
|
16
|
+
return new ProposalHandler(deps.checkpointsBuilder, deps.worldState, deps.blockSource, deps.l1ToL2MessageSource, deps.p2pClient.getTxProvider(), blockProposalValidator, deps.epochCache, config, deps.blobClient, deps.reexecutionTracker, metrics, deps.dateProvider, deps.telemetry, undefined);
|
|
11
17
|
}
|
|
12
18
|
export function createValidatorClient(config, deps) {
|
|
13
19
|
if (config.disableValidator || !deps.keyStoreManager) {
|
|
14
20
|
return undefined;
|
|
15
21
|
}
|
|
16
22
|
const txProvider = deps.p2pClient.getTxProvider();
|
|
17
|
-
return ValidatorClient.new(config, deps.checkpointsBuilder, deps.worldState, deps.epochCache, deps.p2pClient, deps.blockSource, deps.l1ToL2MessageSource, txProvider, deps.keyStoreManager, deps.blobClient, deps.dateProvider, deps.telemetry);
|
|
23
|
+
return ValidatorClient.new(config, deps.checkpointsBuilder, deps.worldState, deps.epochCache, deps.p2pClient, deps.blockSource, deps.l1ToL2MessageSource, txProvider, deps.keyStoreManager, deps.blobClient, deps.reexecutionTracker, deps.dateProvider, deps.telemetry, deps.slashingProtectionDb);
|
|
18
24
|
}
|
package/dest/index.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
export * from './
|
|
1
|
+
export * from './proposal_handler.js';
|
|
2
2
|
export * from './checkpoint_builder.js';
|
|
3
3
|
export * from './config.js';
|
|
4
4
|
export * from './factory.js';
|
|
5
5
|
export * from './validator.js';
|
|
6
6
|
export * from './key_store/index.js';
|
|
7
|
-
|
|
8
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxjQUFjLDZCQUE2QixDQUFDO0FBQzVDLGNBQWMseUJBQXlCLENBQUM7QUFDeEMsY0FBYyxhQUFhLENBQUM7QUFDNUIsY0FBYyxjQUFjLENBQUM7QUFDN0IsY0FBYyxnQkFBZ0IsQ0FBQztBQUMvQixjQUFjLHNCQUFzQixDQUFDO0FBQ3JDLGNBQWMseUJBQXlCLENBQUMifQ==
|
|
7
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxjQUFjLHVCQUF1QixDQUFDO0FBQ3RDLGNBQWMseUJBQXlCLENBQUM7QUFDeEMsY0FBYyxhQUFhLENBQUM7QUFDNUIsY0FBYyxjQUFjLENBQUM7QUFDN0IsY0FBYyxnQkFBZ0IsQ0FBQztBQUMvQixjQUFjLHNCQUFzQixDQUFDIn0=
|
package/dest/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,sBAAsB,CAAC"}
|
package/dest/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
export * from './
|
|
1
|
+
export * from './proposal_handler.js';
|
|
2
2
|
export * from './checkpoint_builder.js';
|
|
3
3
|
export * from './config.js';
|
|
4
4
|
export * from './factory.js';
|
|
5
5
|
export * from './validator.js';
|
|
6
6
|
export * from './key_store/index.js';
|
|
7
|
-
export * from './tx_validator/index.js';
|
|
@@ -184,7 +184,7 @@ import { hashTypedData } from 'viem';
|
|
|
184
184
|
return;
|
|
185
185
|
}
|
|
186
186
|
if (error instanceof SlashingProtectionError) {
|
|
187
|
-
this.log.
|
|
187
|
+
this.log.info(`Duty already signed by another node with different payload`, {
|
|
188
188
|
dutyType: context.dutyType,
|
|
189
189
|
slot: context.slot,
|
|
190
190
|
existingMessageHash: error.existingMessageHash,
|
package/dest/metrics.d.ts
CHANGED
|
@@ -1,19 +1,31 @@
|
|
|
1
|
+
import type { EpochNumber } from '@aztec/foundation/branded-types';
|
|
2
|
+
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
1
3
|
import type { BlockProposal } from '@aztec/stdlib/p2p';
|
|
2
4
|
import { type TelemetryClient } from '@aztec/telemetry-client';
|
|
3
|
-
import type { BlockProposalValidationFailureReason } from './
|
|
5
|
+
import type { BlockProposalValidationFailureReason } from './proposal_handler.js';
|
|
4
6
|
export declare class ValidatorMetrics {
|
|
5
7
|
private failedReexecutionCounter;
|
|
6
8
|
private successfulAttestationsCount;
|
|
7
9
|
private failedAttestationsBadProposalCount;
|
|
8
10
|
private failedAttestationsNodeIssueCount;
|
|
11
|
+
private currentEpoch;
|
|
12
|
+
private attestedEpochCount;
|
|
9
13
|
private reexMana;
|
|
10
14
|
private reexTx;
|
|
11
15
|
private reexDuration;
|
|
16
|
+
private checkpointProposalToPipelinedStateDuration;
|
|
17
|
+
private checkpointProposalReceiveOffsetFromNextSlotBoundary;
|
|
12
18
|
constructor(telemetryClient: TelemetryClient);
|
|
13
19
|
recordReex(time: number, txs: number, mManaTotal: number): void;
|
|
20
|
+
recordCheckpointProposalToPipelinedStateDuration(durationMs: number): void;
|
|
21
|
+
recordCheckpointProposalReceiveOffsetFromNextSlotBoundary(offsetMs: number): void;
|
|
14
22
|
recordFailedReexecution(proposal: BlockProposal): void;
|
|
15
23
|
incSuccessfulAttestations(num: number): void;
|
|
16
24
|
incFailedAttestationsBadProposal(num: number, reason: BlockProposalValidationFailureReason, inCommittee: boolean): void;
|
|
17
25
|
incFailedAttestationsNodeIssue(num: number, reason: BlockProposalValidationFailureReason, inCommittee: boolean): void;
|
|
26
|
+
/** Update the gauge tracking the current epoch number (proxy for total epochs elapsed). */
|
|
27
|
+
setCurrentEpoch(epoch: EpochNumber): void;
|
|
28
|
+
/** Increment the count of epochs in which the given attester submitted at least one attestation. */
|
|
29
|
+
incAttestedEpochCount(attester: EthAddress): void;
|
|
18
30
|
}
|
|
19
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
31
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibWV0cmljcy5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL21ldHJpY3MudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxLQUFLLEVBQUUsV0FBVyxFQUFFLE1BQU0saUNBQWlDLENBQUM7QUFDbkUsT0FBTyxLQUFLLEVBQUUsVUFBVSxFQUFFLE1BQU0sK0JBQStCLENBQUM7QUFDaEUsT0FBTyxLQUFLLEVBQUUsYUFBYSxFQUFFLE1BQU0sbUJBQW1CLENBQUM7QUFDdkQsT0FBTyxFQUtMLEtBQUssZUFBZSxFQUdyQixNQUFNLHlCQUF5QixDQUFDO0FBRWpDLE9BQU8sS0FBSyxFQUFFLG9DQUFvQyxFQUFFLE1BQU0sdUJBQXVCLENBQUM7QUFFbEYscUJBQWEsZ0JBQWdCO0lBQzNCLE9BQU8sQ0FBQyx3QkFBd0IsQ0FBZ0I7SUFDaEQsT0FBTyxDQUFDLDJCQUEyQixDQUFnQjtJQUNuRCxPQUFPLENBQUMsa0NBQWtDLENBQWdCO0lBQzFELE9BQU8sQ0FBQyxnQ0FBZ0MsQ0FBZ0I7SUFDeEQsT0FBTyxDQUFDLFlBQVksQ0FBUTtJQUM1QixPQUFPLENBQUMsa0JBQWtCLENBQWdCO0lBRTFDLE9BQU8sQ0FBQyxRQUFRLENBQVk7SUFDNUIsT0FBTyxDQUFDLE1BQU0sQ0FBWTtJQUMxQixPQUFPLENBQUMsWUFBWSxDQUFRO0lBQzVCLE9BQU8sQ0FBQywwQ0FBMEMsQ0FBWTtJQUM5RCxPQUFPLENBQUMsbURBQW1ELENBQVk7SUFFdkUsWUFBWSxlQUFlLEVBQUUsZUFBZSxFQTBEM0M7SUFFTSxVQUFVLENBQUMsSUFBSSxFQUFFLE1BQU0sRUFBRSxHQUFHLEVBQUUsTUFBTSxFQUFFLFVBQVUsRUFBRSxNQUFNLFFBSTlEO0lBRU0sZ0RBQWdELENBQUMsVUFBVSxFQUFFLE1BQU0sUUFFekU7SUFFTSx5REFBeUQsQ0FBQyxRQUFRLEVBQUUsTUFBTSxRQUloRjtJQUVNLHVCQUF1QixDQUFDLFFBQVEsRUFBRSxhQUFhLFFBTXJEO0lBRU0seUJBQXlCLENBQUMsR0FBRyxFQUFFLE1BQU0sUUFFM0M7SUFFTSxnQ0FBZ0MsQ0FDckMsR0FBRyxFQUFFLE1BQU0sRUFDWCxNQUFNLEVBQUUsb0NBQW9DLEVBQzVDLFdBQVcsRUFBRSxPQUFPLFFBTXJCO0lBRU0sOEJBQThCLENBQ25DLEdBQUcsRUFBRSxNQUFNLEVBQ1gsTUFBTSxFQUFFLG9DQUFvQyxFQUM1QyxXQUFXLEVBQUUsT0FBTyxRQU1yQjtJQUVELDJGQUEyRjtJQUNwRixlQUFlLENBQUMsS0FBSyxFQUFFLFdBQVcsUUFFeEM7SUFFRCxvR0FBb0c7SUFDN0YscUJBQXFCLENBQUMsUUFBUSxFQUFFLFVBQVUsUUFFaEQ7Q0FDRiJ9
|
package/dest/metrics.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metrics.d.ts","sourceRoot":"","sources":["../src/metrics.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAKL,KAAK,eAAe,EAGrB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,KAAK,EAAE,oCAAoC,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"metrics.d.ts","sourceRoot":"","sources":["../src/metrics.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,KAAK,EAAE,UA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est/metrics.js
CHANGED
|
@@ -4,9 +4,13 @@ export class ValidatorMetrics {
|
|
|
4
4
|
successfulAttestationsCount;
|
|
5
5
|
failedAttestationsBadProposalCount;
|
|
6
6
|
failedAttestationsNodeIssueCount;
|
|
7
|
+
currentEpoch;
|
|
8
|
+
attestedEpochCount;
|
|
7
9
|
reexMana;
|
|
8
10
|
reexTx;
|
|
9
11
|
reexDuration;
|
|
12
|
+
checkpointProposalToPipelinedStateDuration;
|
|
13
|
+
checkpointProposalReceiveOffsetFromNextSlotBoundary;
|
|
10
14
|
constructor(telemetryClient){
|
|
11
15
|
const meter = telemetryClient.getMeter('Validator');
|
|
12
16
|
this.failedReexecutionCounter = createUpDownCounterWithDefault(meter, Metrics.VALIDATOR_FAILED_REEXECUTION_COUNT, {
|
|
@@ -42,15 +46,27 @@ export class ValidatorMetrics {
|
|
|
42
46
|
false
|
|
43
47
|
]
|
|
44
48
|
});
|
|
49
|
+
this.currentEpoch = meter.createGauge(Metrics.VALIDATOR_CURRENT_EPOCH);
|
|
50
|
+
this.attestedEpochCount = createUpDownCounterWithDefault(meter, Metrics.VALIDATOR_ATTESTED_EPOCH_COUNT);
|
|
45
51
|
this.reexMana = meter.createHistogram(Metrics.VALIDATOR_RE_EXECUTION_MANA);
|
|
46
52
|
this.reexTx = meter.createHistogram(Metrics.VALIDATOR_RE_EXECUTION_TX_COUNT);
|
|
47
53
|
this.reexDuration = meter.createGauge(Metrics.VALIDATOR_RE_EXECUTION_TIME);
|
|
54
|
+
this.checkpointProposalToPipelinedStateDuration = meter.createHistogram(Metrics.VALIDATOR_CHECKPOINT_PROPOSAL_TO_PIPELINED_STATE_DURATION);
|
|
55
|
+
this.checkpointProposalReceiveOffsetFromNextSlotBoundary = meter.createHistogram(Metrics.VALIDATOR_CHECKPOINT_PROPOSAL_RECEIVE_OFFSET_FROM_NEXT_SLOT_BOUNDARY);
|
|
48
56
|
}
|
|
49
57
|
recordReex(time, txs, mManaTotal) {
|
|
50
58
|
this.reexDuration.record(Math.ceil(time));
|
|
51
59
|
this.reexTx.record(txs);
|
|
52
60
|
this.reexMana.record(mManaTotal);
|
|
53
61
|
}
|
|
62
|
+
recordCheckpointProposalToPipelinedStateDuration(durationMs) {
|
|
63
|
+
this.checkpointProposalToPipelinedStateDuration.record(Math.ceil(durationMs));
|
|
64
|
+
}
|
|
65
|
+
recordCheckpointProposalReceiveOffsetFromNextSlotBoundary(offsetMs) {
|
|
66
|
+
this.checkpointProposalReceiveOffsetFromNextSlotBoundary.record(Math.ceil(Math.abs(offsetMs)), {
|
|
67
|
+
[Attributes.SLOT_BOUNDARY_SIDE]: offsetMs < 0 ? 'before' : 'after'
|
|
68
|
+
});
|
|
69
|
+
}
|
|
54
70
|
recordFailedReexecution(proposal) {
|
|
55
71
|
const proposer = proposal.getSender();
|
|
56
72
|
this.failedReexecutionCounter.add(1, {
|
|
@@ -73,4 +89,12 @@ export class ValidatorMetrics {
|
|
|
73
89
|
[Attributes.IS_COMMITTEE_MEMBER]: inCommittee
|
|
74
90
|
});
|
|
75
91
|
}
|
|
92
|
+
/** Update the gauge tracking the current epoch number (proxy for total epochs elapsed). */ setCurrentEpoch(epoch) {
|
|
93
|
+
this.currentEpoch.record(Number(epoch));
|
|
94
|
+
}
|
|
95
|
+
/** Increment the count of epochs in which the given attester submitted at least one attestation. */ incAttestedEpochCount(attester) {
|
|
96
|
+
this.attestedEpochCount.add(1, {
|
|
97
|
+
[Attributes.ATTESTER_ADDRESS]: attester.toString()
|
|
98
|
+
});
|
|
99
|
+
}
|
|
76
100
|
}
|