Skip to content

Commit 5f9ad90

Browse files
alexghrspalladinoclaude
authored
chore: backport to v2 (#18094)
Backports of #18091 #17638 #17531 --------- Co-authored-by: Santiago Palladino <[email protected]> Co-authored-by: Claude <[email protected]>
1 parent 1d11342 commit 5f9ad90

File tree

5 files changed

+58
-19
lines changed

5 files changed

+58
-19
lines changed

yarn-project/archiver/src/archiver/instrumentation.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,9 @@ export class ArchiverInstrumentation {
152152
}
153153

154154
public processNewMessages(count: number, syncPerMessageMs: number) {
155+
if (count === 0) {
156+
return;
157+
}
155158
this.syncMessageCount.add(count);
156159
this.syncDurationPerMessage.record(Math.ceil(syncPerMessageMs));
157160
}

yarn-project/prover-node/src/factory.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ export async function createProverNode(
179179
'txGatheringIntervalMs',
180180
'txGatheringTimeoutMs',
181181
'proverNodeFailedEpochStore',
182+
'proverNodeDisableProofPublish',
182183
'dataDirectory',
183184
'l1ChainId',
184185
'rollupVersion',

yarn-project/telemetry-client/src/metrics.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,9 @@ export const VALIDATOR_RE_EXECUTION_MANA = 'aztec.validator.re_execution_mana';
204204
export const VALIDATOR_RE_EXECUTION_TX_COUNT = 'aztec.validator.re_execution_tx_count';
205205

206206
export const VALIDATOR_FAILED_REEXECUTION_COUNT = 'aztec.validator.failed_reexecution_count';
207-
export const VALIDATOR_ATTESTATION_COUNT = 'aztec.validator.attestation_count';
208-
export const VALIDATOR_FAILED_ATTESTATION_COUNT = 'aztec.validator.failed_attestation_count';
207+
export const VALIDATOR_ATTESTATION_SUCCESS_COUNT = 'aztec.validator.attestation_success_count';
208+
export const VALIDATOR_ATTESTATION_FAILED_BAD_PROPOSAL_COUNT = 'aztec.validator.attestation_failed_bad_proposal_count';
209+
export const VALIDATOR_ATTESTATION_FAILED_NODE_ISSUE_COUNT = 'aztec.validator.attestation_failed_node_issue_count';
209210

210211
export const NODEJS_EVENT_LOOP_DELAY_MIN = 'nodejs.eventloop.delay.min';
211212
export const NODEJS_EVENT_LOOP_DELAY_MEAN = 'nodejs.eventloop.delay.mean';

yarn-project/validator-client/src/metrics.ts

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ import {
1010

1111
export class ValidatorMetrics {
1212
private failedReexecutionCounter: UpDownCounter;
13-
private attestationsCount: UpDownCounter;
14-
private failedAttestationsCount: UpDownCounter;
13+
private successfulAttestationsCount: UpDownCounter;
14+
private failedAttestationsBadProposalCount: UpDownCounter;
15+
private failedAttestationsNodeIssueCount: UpDownCounter;
1516

1617
private reexMana: Histogram;
1718
private reexTx: Histogram;
@@ -26,15 +27,26 @@ export class ValidatorMetrics {
2627
valueType: ValueType.INT,
2728
});
2829

29-
this.attestationsCount = meter.createUpDownCounter(Metrics.VALIDATOR_ATTESTATION_COUNT, {
30-
description: 'The number of attestations',
30+
this.successfulAttestationsCount = meter.createUpDownCounter(Metrics.VALIDATOR_ATTESTATION_SUCCESS_COUNT, {
31+
description: 'The number of successful attestations',
3132
valueType: ValueType.INT,
3233
});
3334

34-
this.failedAttestationsCount = meter.createUpDownCounter(Metrics.VALIDATOR_FAILED_ATTESTATION_COUNT, {
35-
description: 'The number of failed attestations',
36-
valueType: ValueType.INT,
37-
});
35+
this.failedAttestationsBadProposalCount = meter.createUpDownCounter(
36+
Metrics.VALIDATOR_ATTESTATION_FAILED_BAD_PROPOSAL_COUNT,
37+
{
38+
description: 'The number of failed attestations due to invalid block proposals',
39+
valueType: ValueType.INT,
40+
},
41+
);
42+
43+
this.failedAttestationsNodeIssueCount = meter.createUpDownCounter(
44+
Metrics.VALIDATOR_ATTESTATION_FAILED_NODE_ISSUE_COUNT,
45+
{
46+
description: 'The number of failed attestations due to node issues (timeout, missing data, etc.)',
47+
valueType: ValueType.INT,
48+
},
49+
);
3850

3951
this.reexMana = meter.createHistogram(Metrics.VALIDATOR_RE_EXECUTION_MANA, {
4052
description: 'The mana consumed by blocks',
@@ -69,14 +81,19 @@ export class ValidatorMetrics {
6981
});
7082
}
7183

72-
public incAttestations(num: number) {
73-
this.attestationsCount.add(num);
84+
public incSuccessfulAttestations(num: number) {
85+
this.successfulAttestationsCount.add(num);
86+
}
87+
88+
public incFailedAttestationsBadProposal(num: number, reason: string) {
89+
this.failedAttestationsBadProposalCount.add(num, {
90+
[Attributes.ERROR_TYPE]: reason,
91+
});
7492
}
7593

76-
public incFailedAttestations(num: number, reason: string, inCommittee: boolean) {
77-
this.failedAttestationsCount.add(num, {
94+
public incFailedAttestationsNodeIssue(num: number, reason: string) {
95+
this.failedAttestationsNodeIssueCount.add(num, {
7896
[Attributes.ERROR_TYPE]: reason,
79-
[Attributes.VALIDATOR_STATUS]: inCommittee ? 'in-committee' : 'none',
8097
});
8198
}
8299
}

yarn-project/validator-client/src/validator.ts

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,6 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
265265
// Check that I have any address in current committee before attesting
266266
const inCommittee = await this.epochCache.filterInCommittee(slotNumber, this.getValidatorAddresses());
267267
const partOfCommittee = inCommittee.length > 0;
268-
const incFailedAttestation = (reason: string) => this.metrics.incFailedAttestations(1, reason, partOfCommittee);
269268

270269
const proposalInfo = { ...proposal.toBlockInfo(), proposer: proposer.toString() };
271270
this.log.info(`Received proposal for slot ${slotNumber}`, {
@@ -289,9 +288,27 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
289288

290289
if (!validationResult.isValid) {
291290
this.log.warn(`Proposal validation failed: ${validationResult.reason}`, proposalInfo);
292-
incFailedAttestation(validationResult.reason || 'unknown');
293291

294-
// Slash invalid block proposals
292+
// Only track attestation failure metrics if we're actually in the committee
293+
if (partOfCommittee) {
294+
const reason = validationResult.reason || 'unknown';
295+
// Classify failure reason: bad proposal vs node issue
296+
const badProposalReasons: BlockProposalValidationFailureReason[] = [
297+
'invalid_proposal',
298+
'state_mismatch',
299+
'failed_txs',
300+
'in_hash_mismatch',
301+
'parent_block_wrong_slot',
302+
];
303+
304+
if (badProposalReasons.includes(reason as BlockProposalValidationFailureReason)) {
305+
this.metrics.incFailedAttestationsBadProposal(1, reason);
306+
} else {
307+
this.metrics.incFailedAttestationsNodeIssue(1, reason);
308+
}
309+
}
310+
311+
// Slash invalid block proposals (can happen even when not in committee)
295312
if (
296313
validationResult.reason &&
297314
SLASHABLE_BLOCK_PROPOSAL_VALIDATION_RESULT.includes(validationResult.reason) &&
@@ -311,7 +328,7 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
311328

312329
// Provided all of the above checks pass, we can attest to the proposal
313330
this.log.info(`Attesting to proposal for block at slot ${slotNumber}`, proposalInfo);
314-
this.metrics.incAttestations(inCommittee.length);
331+
this.metrics.incSuccessfulAttestations(inCommittee.length);
315332

316333
// If the above function does not throw an error, then we can attest to the proposal
317334
return this.createBlockAttestationsFromProposal(proposal, inCommittee);

0 commit comments

Comments
 (0)