Skip to content

Commit 6622da5

Browse files
committed
feat: add attestation aggregate coverage metrics
Port leanSpec PR #735: register three IntGaugeVec metrics describing attestation aggregate coverage, with default zero-valued series so dashboards render from a fresh node startup. - lean_attestation_aggregate_coverage_validators (section, subnet) - lean_attestation_aggregate_coverage_subnets (section) - lean_attestation_aggregate_coverage_diff_validators (direction) ATTESTATION_AGGREGATE_COVERAGE_SECTIONS and ATTESTATION_AGGREGATE_COVERAGE_DIFF_DIRECTIONS are exported as the single source of truth for label sets. init() forces the new statics and seeds combined-subnet, section, and direction series to 0 (18 default series total). Per-subnet (subnet="subnet_N") series appear lazily when instrumentation writes them. Registration only. The producer side (per-slot coverage computation, de-duplication across payloads, and the chain-status log line) ports zeam #876 and lands in a follow-up PR. The diff_validators help text diverges from upstreams terse phrasing to spell out the symmetric-difference semantics (block_only: in block but not in local timely pool; timely_only: the reverse). Metric name, labels, and values are unchanged.
1 parent ae6ac42 commit 6622da5

1 file changed

Lines changed: 76 additions & 0 deletions

File tree

crates/blockchain/src/metrics.rs

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,27 @@ use std::time::Duration;
44

55
use ethlambda_metrics::*;
66

7+
// --- Label sets ---
8+
9+
/// Section labels for attestation aggregate coverage gauges. Order matches
10+
/// the names printed in slot/report logs.
11+
///
12+
/// Slot is the X-axis (time series), not a label dimension.
13+
pub const ATTESTATION_AGGREGATE_COVERAGE_SECTIONS: &[&str] = &[
14+
"timely",
15+
"late",
16+
"block",
17+
"combined",
18+
"agg_start_new",
19+
"proposal_payloads",
20+
"proposal_gossip",
21+
"proposal_combined",
22+
];
23+
24+
/// Validator-coverage delta directions between block payloads and
25+
/// locally-aggregated pre-merge (`timely`) payloads.
26+
pub const ATTESTATION_AGGREGATE_COVERAGE_DIFF_DIRECTIONS: &[&str] = &["block_only", "timely_only"];
27+
728
// --- Gauges ---
829

930
static LEAN_HEAD_SLOT: std::sync::LazyLock<IntGauge> = std::sync::LazyLock::new(|| {
@@ -104,6 +125,42 @@ static LEAN_TABLE_BYTES: std::sync::LazyLock<IntGaugeVec> = std::sync::LazyLock:
104125
.unwrap()
105126
});
106127

128+
static LEAN_ATTESTATION_AGGREGATE_COVERAGE_VALIDATORS: std::sync::LazyLock<IntGaugeVec> =
129+
std::sync::LazyLock::new(|| {
130+
register_int_gauge_vec!(
131+
"lean_attestation_aggregate_coverage_validators",
132+
"Validator coverage in attestation aggregate reports, labeled by section and \
133+
subnet. subnet=combined is the section total; subnet=subnet_N is per-subnet \
134+
coverage. Updated each slot (slot is the X-axis).",
135+
&["section", "subnet"]
136+
)
137+
.unwrap()
138+
});
139+
140+
static LEAN_ATTESTATION_AGGREGATE_COVERAGE_SUBNETS: std::sync::LazyLock<IntGaugeVec> =
141+
std::sync::LazyLock::new(|| {
142+
register_int_gauge_vec!(
143+
"lean_attestation_aggregate_coverage_subnets",
144+
"Number of covered subnets in attestation aggregate reports, labeled by section. \
145+
Updated each slot (slot is the X-axis).",
146+
&["section"]
147+
)
148+
.unwrap()
149+
});
150+
151+
static LEAN_ATTESTATION_AGGREGATE_COVERAGE_DIFF_VALIDATORS: std::sync::LazyLock<IntGaugeVec> =
152+
std::sync::LazyLock::new(|| {
153+
register_int_gauge_vec!(
154+
"lean_attestation_aggregate_coverage_diff_validators",
155+
"Count of validators in the symmetric difference between block-included aggregates \
156+
and locally-aggregated pre-merge (timely) aggregates for the same slot. \
157+
direction=block_only: in block but not in local pool. direction=timely_only: in \
158+
local pool but not in block. Updated each slot (slot is the X-axis).",
159+
&["direction"]
160+
)
161+
.unwrap()
162+
});
163+
107164
// --- Counters ---
108165

109166
static LEAN_ATTESTATIONS_VALID_TOTAL: std::sync::LazyLock<IntCounter> =
@@ -409,6 +466,25 @@ pub fn init() {
409466
std::sync::LazyLock::force(&LEAN_IS_AGGREGATOR);
410467
std::sync::LazyLock::force(&LEAN_ATTESTATION_COMMITTEE_COUNT);
411468
std::sync::LazyLock::force(&LEAN_TABLE_BYTES);
469+
// Attestation aggregate coverage (leanMetrics: Fork-Choice Metrics).
470+
// Per upstream leanSpec, seed only the combined-subnet series for each
471+
// section; per-subnet series appear lazily when instrumentation writes them.
472+
std::sync::LazyLock::force(&LEAN_ATTESTATION_AGGREGATE_COVERAGE_VALIDATORS);
473+
std::sync::LazyLock::force(&LEAN_ATTESTATION_AGGREGATE_COVERAGE_SUBNETS);
474+
std::sync::LazyLock::force(&LEAN_ATTESTATION_AGGREGATE_COVERAGE_DIFF_VALIDATORS);
475+
for &section in ATTESTATION_AGGREGATE_COVERAGE_SECTIONS {
476+
LEAN_ATTESTATION_AGGREGATE_COVERAGE_VALIDATORS
477+
.with_label_values(&[section, "combined"])
478+
.set(0);
479+
LEAN_ATTESTATION_AGGREGATE_COVERAGE_SUBNETS
480+
.with_label_values(&[section])
481+
.set(0);
482+
}
483+
for &direction in ATTESTATION_AGGREGATE_COVERAGE_DIFF_DIRECTIONS {
484+
LEAN_ATTESTATION_AGGREGATE_COVERAGE_DIFF_VALIDATORS
485+
.with_label_values(&[direction])
486+
.set(0);
487+
}
412488
// Counters
413489
std::sync::LazyLock::force(&LEAN_ATTESTATIONS_VALID_TOTAL);
414490
std::sync::LazyLock::force(&LEAN_ATTESTATIONS_INVALID_TOTAL);

0 commit comments

Comments
 (0)