From 6d344a89f25abff178469e0a498029145497fce6 Mon Sep 17 00:00:00 2001 From: Conor Schaefer Date: Wed, 15 May 2024 17:28:22 -0700 Subject: [PATCH] fix(pd): remove validator state metrics The validator state metrics are not accurate, and should be refactored to use ABCI event emission so that developers can leverage the state transitions in a sane way. In the meantime, let's remove the incorrect metrics entirely. Refs #3746, #4336. --- .../component/stake/src/component/metrics.rs | 31 ---- .../validator_handler/validator_manager.rs | 33 ---- .../config/grafana/dashboards/Penumbra.json | 141 ------------------ .../config/grafana/dashboards/Validators.json | 122 --------------- 4 files changed, 327 deletions(-) diff --git a/crates/core/component/stake/src/component/metrics.rs b/crates/core/component/stake/src/component/metrics.rs index 2aa501bf68..7939be0f6d 100644 --- a/crates/core/component/stake/src/component/metrics.rs +++ b/crates/core/component/stake/src/component/metrics.rs @@ -20,37 +20,6 @@ pub fn register_metrics() { Unit::Count, "The number of missed blocks per validator" ); - describe_gauge!( - ACTIVE_VALIDATORS, - Unit::Count, - "The number of active validators" - ); - describe_gauge!( - INACTIVE_VALIDATORS, - Unit::Count, - "The number of inactive validators" - ); - describe_gauge!( - JAILED_VALIDATORS, - Unit::Count, - "The number of jailed validators" - ); - describe_gauge!( - DISABLED_VALIDATORS, - Unit::Count, - "The number of disabled validators" - ); - describe_gauge!( - TOMBSTONED_VALIDATORS, - Unit::Count, - "The number of tombstoned validators" - ); } pub const MISSED_BLOCKS: &str = "penumbra_stake_missed_blocks"; -pub const ACTIVE_VALIDATORS: &str = "penumbra_stake_validators_active"; -pub const DISABLED_VALIDATORS: &str = "penumbra_stake_validators_disabled"; -pub const DEFINED_VALIDATORS: &str = "penumbra_stake_validators_defined"; -pub const INACTIVE_VALIDATORS: &str = "penumbra_stake_validators_inactive"; -pub const JAILED_VALIDATORS: &str = "penumbra_stake_validators_jailed"; -pub const TOMBSTONED_VALIDATORS: &str = "penumbra_stake_validators_tombstoned"; diff --git a/crates/core/component/stake/src/component/validator_handler/validator_manager.rs b/crates/core/component/stake/src/component/validator_handler/validator_manager.rs index caf1b78c67..e20f8ae68e 100644 --- a/crates/core/component/stake/src/component/validator_handler/validator_manager.rs +++ b/crates/core/component/stake/src/component/validator_handler/validator_manager.rs @@ -302,8 +302,6 @@ pub trait ValidatorManager: StateWrite { tracing::info!("successful state transition"); self.put(validator_state_path, new_state); - Self::state_machine_metrics(old_state, new_state); - Ok((old_state, new_state)) } @@ -485,17 +483,6 @@ pub trait ValidatorManager: StateWrite { self.set_validator_bonding_state(&validator_identity, initial_bonding_state); self.set_validator_pool_size(&validator_identity, initial_delegation_pool_size); - // Finally, update metrics for the new validator. - match initial_state { - validator::State::Active => { - metrics::gauge!(metrics::ACTIVE_VALIDATORS).increment(1.0); - } - validator::State::Defined => { - metrics::gauge!(metrics::DEFINED_VALIDATORS).increment(1.0); - } - _ => unreachable!("the initial state was validated by the guard condition"), - }; - metrics::gauge!(metrics::MISSED_BLOCKS, "identity_key" => validator_identity.to_string()) .increment(0.0); @@ -674,26 +661,6 @@ pub trait ValidatorManager: StateWrite { Ok(()) } - - fn state_machine_metrics(old_state: validator::State, new_state: validator::State) { - // Update the validator metrics once the state transition has been applied. - match old_state { - Defined => metrics::gauge!(metrics::DEFINED_VALIDATORS).decrement(1.0), - Inactive => metrics::gauge!(metrics::INACTIVE_VALIDATORS).decrement(1.0), - Active => metrics::gauge!(metrics::ACTIVE_VALIDATORS).decrement(1.0), - Disabled => metrics::gauge!(metrics::DISABLED_VALIDATORS).decrement(1.0), - Jailed => metrics::gauge!(metrics::JAILED_VALIDATORS).decrement(1.0), - Tombstoned => metrics::gauge!(metrics::TOMBSTONED_VALIDATORS).decrement(1.0), - }; - match new_state { - Defined => metrics::gauge!(metrics::DEFINED_VALIDATORS).increment(1.0), - Inactive => metrics::gauge!(metrics::INACTIVE_VALIDATORS).increment(1.0), - Active => metrics::gauge!(metrics::ACTIVE_VALIDATORS).increment(1.0), - Disabled => metrics::gauge!(metrics::DISABLED_VALIDATORS).increment(1.0), - Jailed => metrics::gauge!(metrics::JAILED_VALIDATORS).increment(1.0), - Tombstoned => metrics::gauge!(metrics::TOMBSTONED_VALIDATORS).increment(1.0), - }; - } } impl ValidatorManager for T {} diff --git a/deployments/config/grafana/dashboards/Penumbra.json b/deployments/config/grafana/dashboards/Penumbra.json index 44d0fe7adf..fede433063 100644 --- a/deployments/config/grafana/dashboards/Penumbra.json +++ b/deployments/config/grafana/dashboards/Penumbra.json @@ -590,147 +590,6 @@ ], "title": "Penumbra CheckTX", "type": "timeseries" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "description": "States of known validators", - "fieldConfig": { - "defaults": { - "color": { - "mode": "palette-classic" - }, - "custom": { - "axisCenteredZero": false, - "axisColorMode": "text", - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "drawStyle": "line", - "fillOpacity": 0, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "auto", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "none" - }, - "thresholdsStyle": { - "mode": "off" - } - }, - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - }, - { - "color": "red", - "value": 80 - } - ] - } - }, - "overrides": [] - }, - "gridPos": { - "h": 8, - "w": 12, - "x": 12, - "y": 8 - }, - "id": 2, - "options": { - "legend": { - "calcs": [], - "displayMode": "list", - "placement": "bottom", - "showLegend": true - }, - "tooltip": { - "mode": "single", - "sort": "none" - } - }, - "targets": [ - { - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "exemplar": true, - "expr": "sum(penumbra_stake_validators_active)", - "interval": "", - "legendFormat": "Active Validators", - "refId": "A" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "exemplar": true, - "expr": "sum(penumbra_stake_validators_inactive)", - "hide": false, - "interval": "", - "legendFormat": "Inactive Validators", - "refId": "B" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "exemplar": true, - "expr": "sum(penumbra_stake_validators_disabled)", - "hide": false, - "interval": "", - "legendFormat": "Disabled Validators", - "refId": "C" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "exemplar": true, - "expr": "sum(penumbra_stake_validators_tombstoned)", - "hide": false, - "interval": "", - "legendFormat": "Tombstoned Validators", - "refId": "D" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "exemplar": true, - "expr": "sum(penumbra_stake_validators_jailed)", - "hide": false, - "interval": "", - "legendFormat": "Jailed Validators", - "refId": "E" - } - ], - "title": "Validator States", - "type": "timeseries" } ], "refresh": false, diff --git a/deployments/config/grafana/dashboards/Validators.json b/deployments/config/grafana/dashboards/Validators.json index efeaa2d75b..b945566670 100644 --- a/deployments/config/grafana/dashboards/Validators.json +++ b/deployments/config/grafana/dashboards/Validators.json @@ -59,128 +59,6 @@ "links": [], "liveNow": false, "panels": [ - { - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "fieldConfig": { - "defaults": { - "color": { - "mode": "palette-classic" - }, - "custom": { - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "drawStyle": "line", - "fillOpacity": 0, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "auto", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "none" - }, - "thresholdsStyle": { - "mode": "off" - } - }, - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - }, - { - "color": "red", - "value": 80 - } - ] - } - }, - "overrides": [] - }, - "gridPos": { - "h": 11, - "w": 24, - "x": 0, - "y": 0 - }, - "id": 2, - "options": { - "legend": { - "calcs": [], - "displayMode": "list", - "placement": "bottom" - }, - "tooltip": { - "mode": "single", - "sort": "none" - } - }, - "targets": [ - { - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "expr": "penumbra_stake_validators_active", - "refId": "A" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "expr": "penumbra_stake_validators_disabled", - "hide": false, - "refId": "B" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "expr": "penumbra_stake_validators_inactive", - "hide": false, - "refId": "C" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "expr": "penumbra_stake_validators_jailed", - "hide": false, - "refId": "D" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "expr": "penumbra_stake_validators_tombstoned", - "hide": false, - "refId": "E" - } - ], - "title": "Panel Title", - "type": "timeseries" - }, { "datasource": { "type": "prometheus",