Skip to content

Commit

Permalink
fix(pd): remove validator state metrics
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
conorsch committed May 16, 2024
1 parent abfd764 commit 6d344a8
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 327 deletions.
31 changes: 0 additions & 31 deletions crates/core/component/stake/src/component/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}

Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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<T: StateWrite + ?Sized> ValidatorManager for T {}
141 changes: 0 additions & 141 deletions deployments/config/grafana/dashboards/Penumbra.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
122 changes: 0 additions & 122 deletions deployments/config/grafana/dashboards/Validators.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 6d344a8

Please sign in to comment.