Make block metrics more accurate (#2835)

* Check for state errors before updating metrics

Previously, the metrics would be updated for some rejected blocks.

* Clarify and expand block verification metrics

Rename checkpoint-specific metrics to clarify their purpose.

Add metrics for:
- finalized blocks on disk
- blocks verified using the full block verifier
  (this metric was previously incorrectly called `zcash_chain_verified_block_height`)

* Update dashboard metric names

Also:
- add some extra block height metrics
- fix a dashboard name

* Add exact block heights to Grafana dashboards

* Add a missing comment

* grafana: use 0 decimals for metrics

Co-authored-by: Conrado Gouvea <conrado@zfnd.org>

* grafana: show the entire height instead of abbreviated

Co-authored-by: Conrado Gouvea <conrado@zfnd.org>

* grafana: show the entire height instead of abbreviated

Co-authored-by: Conrado Gouvea <conrado@zfnd.org>

* Fix typo in metric name

Co-authored-by: Conrado Gouvea <conrado@zfnd.org>

* Move height gauges to the state, so they are correct

If we update height gauges in futures, they can execute out of order,
so the metrics can be incorrect.

Instead:
- move the height gauges to the state, and update them based on the best tip
- move the verified block counts to the state
- continue to include all verified blocks on all non-finalized chains
  (not just the best chain)

* Show exact checkpoint heights in the dashboard

Co-authored-by: Deirdre Connolly <deirdre@zfnd.org>
Co-authored-by: Conrado Gouvea <conrado@zfnd.org>
This commit is contained in:
teor 2021-10-07 23:42:38 +10:00 committed by GitHub
parent 04d2cfb3d0
commit f4118dadda
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 221 additions and 118 deletions

View File

@ -15,8 +15,8 @@
"editable": true,
"gnetId": null,
"graphTooltip": 0,
"id": 5,
"iteration": 1614572681383,
"id": 1,
"iteration": 1633497866311,
"links": [],
"panels": [
{
@ -25,10 +25,9 @@
"dashLength": 10,
"dashes": false,
"datasource": null,
"decimals": 0,
"fieldConfig": {
"defaults": {
"custom": {}
},
"defaults": {},
"overrides": []
},
"fill": 1,
@ -42,13 +41,16 @@
"hiddenSeries": false,
"id": 4,
"legend": {
"alignAsTable": false,
"avg": false,
"current": false,
"current": true,
"max": false,
"min": false,
"rightSide": true,
"show": true,
"sideWidth": null,
"total": false,
"values": false
"values": true
},
"lines": true,
"linewidth": 1,
@ -57,7 +59,7 @@
"alertThreshold": true
},
"percentage": false,
"pluginVersion": "7.2.2",
"pluginVersion": "7.5.7",
"pointradius": 2,
"points": false,
"renderer": "flot",
@ -75,17 +77,42 @@
"steppedLine": false,
"targets": [
{
"exemplar": true,
"expr": "zcash_chain_verified_block_height{job=\"$job\"}",
"interval": "",
"legendFormat": "verified block height",
"legendFormat": "committed block height",
"refId": "A"
},
{
"exemplar": true,
"expr": "state_full_verifier_committed_block_height{job=\"$job\"}",
"hide": false,
"interval": "",
"legendFormat": "full block verifier height",
"refId": "B"
},
{
"exemplar": true,
"expr": "state_checkpoint_finalized_block_height{job=\"$job\"}",
"hide": false,
"interval": "",
"legendFormat": "checkpoint verifier height",
"refId": "C"
},
{
"exemplar": true,
"expr": "state_finalized_block_height{job=\"$job\"}",
"hide": false,
"interval": "",
"legendFormat": "finalized block height",
"refId": "D"
}
],
"thresholds": [],
"timeFrom": null,
"timeRegions": [],
"timeShift": null,
"title": "Block Verifier Block Height - $job",
"title": "Verified Block Height - $job",
"tooltip": {
"shared": true,
"sort": 0,
@ -101,7 +128,8 @@
},
"yaxes": [
{
"format": "short",
"$$hashKey": "object:84",
"format": "none",
"label": null,
"logBase": 1,
"max": null,
@ -109,7 +137,8 @@
"show": true
},
{
"format": "short",
"$$hashKey": "object:85",
"format": "none",
"label": null,
"logBase": 1,
"max": null,
@ -128,10 +157,9 @@
"dashLength": 10,
"dashes": false,
"datasource": null,
"decimals": 6,
"fieldConfig": {
"defaults": {
"custom": {}
},
"defaults": {},
"overrides": []
},
"fill": 1,
@ -145,13 +173,16 @@
"hiddenSeries": false,
"id": 6,
"legend": {
"alignAsTable": false,
"avg": false,
"current": false,
"current": true,
"max": false,
"min": false,
"rightSide": true,
"show": true,
"sideWidth": null,
"total": false,
"values": false
"values": true
},
"lines": true,
"linewidth": 1,
@ -160,11 +191,11 @@
"alertThreshold": true
},
"percentage": false,
"pluginVersion": "7.2.2",
"pluginVersion": "7.5.7",
"pointradius": 2,
"points": false,
"renderer": "flot",
"repeatIteration": 1614572681383,
"repeatIteration": 1633497866311,
"repeatPanelId": 4,
"scopedVars": {
"job": {
@ -179,17 +210,42 @@
"steppedLine": false,
"targets": [
{
"exemplar": true,
"expr": "zcash_chain_verified_block_height{job=\"$job\"}",
"interval": "",
"legendFormat": "verified block height",
"legendFormat": "committed block height",
"refId": "A"
},
{
"exemplar": true,
"expr": "state_full_verifier_committed_block_height{job=\"$job\"}",
"hide": false,
"interval": "",
"legendFormat": "full block verifier height",
"refId": "B"
},
{
"exemplar": true,
"expr": "state_checkpoint_finalized_block_height{job=\"$job\"}",
"hide": false,
"interval": "",
"legendFormat": "checkpoint verifier height",
"refId": "C"
},
{
"exemplar": true,
"expr": "state_finalized_block_height{job=\"$job\"}",
"hide": false,
"interval": "",
"legendFormat": "finalized block height",
"refId": "D"
}
],
"thresholds": [],
"timeFrom": null,
"timeRegions": [],
"timeShift": null,
"title": "Block Verifier Block Height - $job",
"title": "Verified Block Height - $job",
"tooltip": {
"shared": true,
"sort": 0,
@ -205,6 +261,7 @@
},
"yaxes": [
{
"$$hashKey": "object:84",
"format": "short",
"label": null,
"logBase": 1,
@ -213,6 +270,7 @@
"show": true
},
{
"$$hashKey": "object:85",
"format": "short",
"label": null,
"logBase": 1,
@ -233,9 +291,7 @@
"dashes": false,
"datasource": null,
"fieldConfig": {
"defaults": {
"custom": {}
},
"defaults": {},
"overrides": []
},
"fill": 1,
@ -264,7 +320,7 @@
"alertThreshold": true
},
"percentage": false,
"pluginVersion": "7.2.2",
"pluginVersion": "7.5.7",
"pointradius": 2,
"points": false,
"renderer": "flot",
@ -311,7 +367,7 @@
"timeFrom": null,
"timeRegions": [],
"timeShift": null,
"title": "Block Verifier Sync Count - $job",
"title": "Block Sync Count - $job",
"tooltip": {
"shared": true,
"sort": 0,
@ -327,6 +383,7 @@
},
"yaxes": [
{
"$$hashKey": "object:167",
"format": "short",
"label": null,
"logBase": 1,
@ -335,6 +392,7 @@
"show": true
},
{
"$$hashKey": "object:168",
"format": "short",
"label": null,
"logBase": 1,
@ -355,9 +413,7 @@
"dashes": false,
"datasource": null,
"fieldConfig": {
"defaults": {
"custom": {}
},
"defaults": {},
"overrides": []
},
"fill": 1,
@ -386,12 +442,12 @@
"alertThreshold": true
},
"percentage": false,
"pluginVersion": "7.2.2",
"pluginVersion": "7.5.7",
"pointradius": 2,
"points": false,
"renderer": "flot",
"repeatDirection": "h",
"repeatIteration": 1614572681383,
"repeatIteration": 1633497866311,
"repeatPanelId": 5,
"scopedVars": {
"job": {
@ -434,7 +490,7 @@
"timeFrom": null,
"timeRegions": [],
"timeShift": null,
"title": "Block Verifier Sync Count - $job",
"title": "Block Sync Count - $job",
"tooltip": {
"shared": true,
"sort": 0,
@ -450,6 +506,7 @@
},
"yaxes": [
{
"$$hashKey": "object:167",
"format": "short",
"label": null,
"logBase": 1,
@ -458,6 +515,7 @@
"show": true
},
{
"$$hashKey": "object:168",
"format": "short",
"label": null,
"logBase": 1,
@ -478,9 +536,7 @@
"dashes": false,
"datasource": null,
"fieldConfig": {
"defaults": {
"custom": {}
},
"defaults": {},
"overrides": []
},
"fill": 1,
@ -509,7 +565,7 @@
"alertThreshold": true
},
"percentage": false,
"pluginVersion": "7.2.2",
"pluginVersion": "7.5.7",
"pointradius": 2,
"points": false,
"renderer": "flot",
@ -556,7 +612,7 @@
"timeFrom": null,
"timeRegions": [],
"timeShift": null,
"title": "Block Verifier Gossip Count - $job",
"title": "Block Gossip Count - $job",
"tooltip": {
"shared": true,
"sort": 0,
@ -572,6 +628,7 @@
},
"yaxes": [
{
"$$hashKey": "object:252",
"format": "short",
"label": null,
"logBase": 1,
@ -580,6 +637,7 @@
"show": true
},
{
"$$hashKey": "object:253",
"format": "short",
"label": null,
"logBase": 1,
@ -600,9 +658,7 @@
"dashes": false,
"datasource": null,
"fieldConfig": {
"defaults": {
"custom": {}
},
"defaults": {},
"overrides": []
},
"fill": 1,
@ -631,12 +687,12 @@
"alertThreshold": true
},
"percentage": false,
"pluginVersion": "7.2.2",
"pluginVersion": "7.5.7",
"pointradius": 2,
"points": false,
"renderer": "flot",
"repeatDirection": "h",
"repeatIteration": 1614572681383,
"repeatIteration": 1633497866311,
"repeatPanelId": 2,
"scopedVars": {
"job": {
@ -679,7 +735,7 @@
"timeFrom": null,
"timeRegions": [],
"timeShift": null,
"title": "Block Verifier Gossip Count - $job",
"title": "Block Gossip Count - $job",
"tooltip": {
"shared": true,
"sort": 0,
@ -695,6 +751,7 @@
},
"yaxes": [
{
"$$hashKey": "object:252",
"format": "short",
"label": null,
"logBase": 1,
@ -703,6 +760,7 @@
"show": true
},
{
"$$hashKey": "object:253",
"format": "short",
"label": null,
"logBase": 1,
@ -718,7 +776,7 @@
}
],
"refresh": "5s",
"schemaVersion": 26,
"schemaVersion": 27,
"style": "dark",
"tags": [],
"templating": {
@ -726,7 +784,7 @@
{
"allValue": null,
"current": {
"selected": false,
"selected": true,
"text": [
"All"
],
@ -736,13 +794,18 @@
},
"datasource": "Prometheus-Zebra",
"definition": "label_values(zcash_chain_verified_block_height, job)",
"description": null,
"error": null,
"hide": 0,
"includeAll": true,
"label": null,
"multi": true,
"name": "job",
"options": [],
"query": "label_values(zcash_chain_verified_block_height, job)",
"query": {
"query": "label_values(zcash_chain_verified_block_height, job)",
"refId": "Prometheus-Zebra-job-Variable-Query"
},
"refresh": 1,
"regex": "",
"skipUrlSync": false,
@ -763,5 +826,5 @@
"timezone": "",
"title": "block verification",
"uid": "rO_Cl5tGz",
"version": 19
"version": 8
}

View File

@ -15,8 +15,8 @@
"editable": true,
"gnetId": null,
"graphTooltip": 0,
"id": 3,
"iteration": 1614572686856,
"id": 2,
"iteration": 1633574016226,
"links": [],
"panels": [
{
@ -25,10 +25,9 @@
"dashLength": 10,
"dashes": false,
"datasource": null,
"decimals": null,
"fieldConfig": {
"defaults": {
"custom": {}
},
"defaults": {},
"overrides": []
},
"fill": 1,
@ -43,12 +42,13 @@
"id": 2,
"legend": {
"avg": false,
"current": false,
"current": true,
"max": false,
"min": false,
"rightSide": true,
"show": true,
"total": false,
"values": false
"values": true
},
"lines": true,
"linewidth": 1,
@ -57,7 +57,7 @@
"alertThreshold": true
},
"percentage": false,
"pluginVersion": "7.2.2",
"pluginVersion": "7.5.7",
"pointradius": 2,
"points": false,
"renderer": "flot",
@ -100,13 +100,15 @@
"refId": "D"
},
{
"expr": "state_finalized_committed_block_height{job=\"$job\"}",
"exemplar": true,
"expr": "state_checkpoint_committed_block_height{job=\"$job\"}",
"interval": "",
"legendFormat": "state_finalized_committed_block_height",
"refId": "E"
},
{
"expr": "state_finalized_queued_max_height{job=\"$job\"}",
"exemplar": true,
"expr": "state_checkpoint_queued_max_height{job=\"$job\"}",
"interval": "",
"legendFormat": "state_finalized_queued_max_height",
"refId": "F"
@ -132,7 +134,8 @@
},
"yaxes": [
{
"format": "short",
"$$hashKey": "object:84",
"format": "none",
"label": null,
"logBase": 1,
"max": null,
@ -140,7 +143,8 @@
"show": true
},
{
"format": "short",
"$$hashKey": "object:85",
"format": "none",
"label": null,
"logBase": 1,
"max": null,
@ -159,10 +163,9 @@
"dashLength": 10,
"dashes": false,
"datasource": null,
"decimals": null,
"fieldConfig": {
"defaults": {
"custom": {}
},
"defaults": {},
"overrides": []
},
"fill": 1,
@ -177,12 +180,13 @@
"id": 9,
"legend": {
"avg": false,
"current": false,
"current": true,
"max": false,
"min": false,
"rightSide": true,
"show": true,
"total": false,
"values": false
"values": true
},
"lines": true,
"linewidth": 1,
@ -191,12 +195,12 @@
"alertThreshold": true
},
"percentage": false,
"pluginVersion": "7.2.2",
"pluginVersion": "7.5.7",
"pointradius": 2,
"points": false,
"renderer": "flot",
"repeatDirection": "h",
"repeatIteration": 1614572686856,
"repeatIteration": 1633574016226,
"repeatPanelId": 2,
"scopedVars": {
"job": {
@ -235,13 +239,15 @@
"refId": "D"
},
{
"expr": "state_finalized_committed_block_height{job=\"$job\"}",
"exemplar": true,
"expr": "state_checkpoint_committed_block_height{job=\"$job\"}",
"interval": "",
"legendFormat": "state_finalized_committed_block_height",
"refId": "E"
},
{
"expr": "state_finalized_queued_max_height{job=\"$job\"}",
"exemplar": true,
"expr": "state_checkpoint_queued_max_height{job=\"$job\"}",
"interval": "",
"legendFormat": "state_finalized_queued_max_height",
"refId": "F"
@ -267,7 +273,8 @@
},
"yaxes": [
{
"format": "short",
"$$hashKey": "object:84",
"format": "none",
"label": null,
"logBase": 1,
"max": null,
@ -275,7 +282,8 @@
"show": true
},
{
"format": "short",
"$$hashKey": "object:85",
"format": "none",
"label": null,
"logBase": 1,
"max": null,
@ -295,9 +303,7 @@
"dashes": false,
"datasource": null,
"fieldConfig": {
"defaults": {
"custom": {}
},
"defaults": {},
"overrides": []
},
"fill": 1,
@ -326,7 +332,7 @@
"alertThreshold": true
},
"percentage": false,
"pluginVersion": "7.2.2",
"pluginVersion": "7.5.7",
"pointradius": 2,
"points": false,
"renderer": "flot",
@ -351,7 +357,8 @@
"refId": "A"
},
{
"expr": "rate(state_finalized_committed_block_count[1s])",
"exemplar": true,
"expr": "rate(state_checkpoint_committed_block_count[1s])",
"interval": "",
"legendFormat": "state commit rate [1s]",
"refId": "C"
@ -389,6 +396,7 @@
},
"yaxes": [
{
"$$hashKey": "object:252",
"format": "short",
"label": null,
"logBase": 1,
@ -397,6 +405,7 @@
"show": true
},
{
"$$hashKey": "object:253",
"format": "short",
"label": null,
"logBase": 1,
@ -417,9 +426,7 @@
"dashes": false,
"datasource": null,
"fieldConfig": {
"defaults": {
"custom": {}
},
"defaults": {},
"overrides": []
},
"fill": 1,
@ -448,12 +455,12 @@
"alertThreshold": true
},
"percentage": false,
"pluginVersion": "7.2.2",
"pluginVersion": "7.5.7",
"pointradius": 2,
"points": false,
"renderer": "flot",
"repeatDirection": "h",
"repeatIteration": 1614572686856,
"repeatIteration": 1633574016226,
"repeatPanelId": 8,
"scopedVars": {
"job": {
@ -474,7 +481,8 @@
"refId": "A"
},
{
"expr": "rate(state_finalized_committed_block_count[1s])",
"exemplar": true,
"expr": "rate(state_checkpoint_committed_block_count[1s])",
"interval": "",
"legendFormat": "state commit rate [1s]",
"refId": "C"
@ -512,6 +520,7 @@
},
"yaxes": [
{
"$$hashKey": "object:252",
"format": "short",
"label": null,
"logBase": 1,
@ -520,6 +529,7 @@
"show": true
},
{
"$$hashKey": "object:253",
"format": "short",
"label": null,
"logBase": 1,
@ -540,9 +550,7 @@
"dashes": false,
"datasource": null,
"fieldConfig": {
"defaults": {
"custom": {}
},
"defaults": {},
"overrides": []
},
"fill": 1,
@ -571,7 +579,7 @@
"alertThreshold": true
},
"percentage": false,
"pluginVersion": "7.2.2",
"pluginVersion": "7.5.7",
"pointradius": 2,
"points": false,
"renderer": "flot",
@ -596,7 +604,8 @@
"refId": "A"
},
{
"expr": "state_finalized_queued_block_count{job=\"$job\"}",
"exemplar": true,
"expr": "state_checkpoint_queued_block_count{job=\"$job\"}",
"interval": "",
"legendFormat": "state_finalized_queued_block_count",
"refId": "B"
@ -658,6 +667,7 @@
},
"yaxes": [
{
"$$hashKey": "object:337",
"format": "short",
"label": null,
"logBase": 1,
@ -666,6 +676,7 @@
"show": true
},
{
"$$hashKey": "object:338",
"format": "short",
"label": null,
"logBase": 1,
@ -686,9 +697,7 @@
"dashes": false,
"datasource": null,
"fieldConfig": {
"defaults": {
"custom": {}
},
"defaults": {},
"overrides": []
},
"fill": 1,
@ -717,12 +726,12 @@
"alertThreshold": true
},
"percentage": false,
"pluginVersion": "7.2.2",
"pluginVersion": "7.5.7",
"pointradius": 2,
"points": false,
"renderer": "flot",
"repeatDirection": "h",
"repeatIteration": 1614572686856,
"repeatIteration": 1633574016226,
"repeatPanelId": 4,
"scopedVars": {
"job": {
@ -743,7 +752,8 @@
"refId": "A"
},
{
"expr": "state_finalized_queued_block_count{job=\"$job\"}",
"exemplar": true,
"expr": "state_checkpoint_queued_block_count{job=\"$job\"}",
"interval": "",
"legendFormat": "state_finalized_queued_block_count",
"refId": "B"
@ -805,6 +815,7 @@
},
"yaxes": [
{
"$$hashKey": "object:337",
"format": "short",
"label": null,
"logBase": 1,
@ -813,6 +824,7 @@
"show": true
},
{
"$$hashKey": "object:338",
"format": "short",
"label": null,
"logBase": 1,
@ -828,7 +840,7 @@
}
],
"refresh": "5s",
"schemaVersion": 26,
"schemaVersion": 27,
"style": "dark",
"tags": [],
"templating": {
@ -836,7 +848,7 @@
{
"allValue": null,
"current": {
"selected": false,
"selected": true,
"text": [
"All"
],
@ -846,13 +858,18 @@
},
"datasource": "Prometheus-Zebra",
"definition": "label_values(sync_prospective_tips_len, job)",
"description": null,
"error": null,
"hide": 0,
"includeAll": true,
"label": null,
"multi": true,
"name": "job",
"options": [],
"query": "label_values(sync_prospective_tips_len, job)",
"query": {
"query": "label_values(sync_prospective_tips_len, job)",
"refId": "Prometheus-Zebra-job-Variable-Query"
},
"refresh": 1,
"regex": "",
"skipUrlSync": false,
@ -886,5 +903,5 @@
"timezone": "",
"title": "checkpoint verification",
"uid": "o4LmN_OMk",
"version": 42
"version": 6
}

View File

@ -17,7 +17,7 @@
"gnetId": null,
"graphTooltip": 0,
"id": 5,
"iteration": 1628659147689,
"iteration": 1633496321106,
"links": [],
"panels": [
{
@ -172,7 +172,7 @@
"pointradius": 2,
"points": false,
"renderer": "flot",
"repeatIteration": 1628659147689,
"repeatIteration": 1633496321106,
"repeatPanelId": 2,
"scopedVars": {
"job": {
@ -363,7 +363,7 @@
"show": false
},
"pluginVersion": "7.5.7",
"repeatIteration": 1628659147689,
"repeatIteration": 1633496321106,
"repeatPanelId": 4,
"reverseYBuckets": false,
"scopedVars": {
@ -602,7 +602,7 @@
"pointradius": 2,
"points": false,
"renderer": "flot",
"repeatIteration": 1628659147689,
"repeatIteration": 1633496321106,
"repeatPanelId": 7,
"scopedVars": {
"job": {
@ -757,7 +757,7 @@
},
"timepicker": {},
"timezone": "",
"title": "Syncer",
"title": "syncer",
"uid": "Sl3h19Gnk",
"version": 9
"version": 11
}

View File

@ -198,11 +198,6 @@ where
.map_err(VerifyBlockError::Transaction)?;
}
// Update the metrics after all the validation is finished
tracing::trace!("verified block");
metrics::gauge!("zcash.chain.verified.block.height", height.0 as _);
metrics::counter!("zcash.chain.verified.block.total", 1);
let new_outputs = Arc::try_unwrap(known_utxos)
.expect("all verification tasks using known_utxos are complete");

View File

@ -203,6 +203,20 @@ impl StateService {
self.queued_blocks.prune_by_height(finalized_tip_height);
let tip_block = self.mem.best_tip_block().map(ChainTipBlock::from);
// update metrics using the best non-finalized tip
if let Some(tip_block) = tip_block.as_ref() {
metrics::gauge!(
"state.full_verifier.committed.block.height",
tip_block.height.0 as _
);
// This height gauge is updated for both fully verified and checkpoint blocks.
// These updates can't conflict, because the state makes sure that blocks
// are committed in order.
metrics::gauge!("zcash.chain.verified.block.height", tip_block.height.0 as _);
}
self.chain_tip_sender.set_best_non_finalized_tip(tip_block);
tracing::trace!("finished processing queued block");
@ -260,6 +274,11 @@ impl StateService {
} else {
tracing::trace!(?child_hash, "validating queued child");
result = self.validate_and_commit(child).map_err(CloneError::from);
if result.is_ok() {
// Update the metrics if semantic and contextual validation passes
metrics::counter!("state.full_verifier.committed.block.count", 1);
metrics::counter!("zcash.chain.verified.block.total", 1);
}
}
let _ = rsp_tx.send(result.clone().map(|()| child_hash).map_err(BoxError::from));

View File

@ -180,9 +180,9 @@ impl FinalizedState {
self.max_queued_height = height.0 as _;
}
metrics::gauge!("state.finalized.queued.max.height", self.max_queued_height);
metrics::gauge!("state.checkpoint.queued.max.height", self.max_queued_height);
metrics::gauge!(
"state.finalized.queued.block.count",
"state.checkpoint.queued.block.count",
self.queued_by_prev_hash.len() as f64
);
@ -228,8 +228,6 @@ impl FinalizedState {
finalized: FinalizedBlock,
source: &str,
) -> Result<block::Hash, BoxError> {
block_precommit_metrics(&finalized);
let finalized_tip_height = self.finalized_tip_height();
let hash_by_height = self.db.cf_handle("hash_by_height").unwrap();
@ -443,6 +441,9 @@ impl FinalizedState {
// In case of errors, propagate and do not write the batch.
let batch = prepare_commit()?;
// The block has passed contextual validation, so update the metrics
block_precommit_metrics(&block, hash, height);
let result = self.db.write(batch).map(|()| hash);
tracing::trace!(?source, "committed block from");
@ -473,17 +474,23 @@ impl FinalizedState {
let block_result;
if result.is_ok() {
metrics::counter!("state.finalized.committed.block.count", 1);
metrics::counter!("state.checkpoint.finalized.block.count", 1);
metrics::gauge!(
"state.finalized.committed.block.height",
"state.checkpoint.finalized.block.height",
finalized.height.0 as _
);
// This height gauge is updated for both fully verified and checkpoint blocks.
// These updates can't conflict, because the state makes sure that blocks
// are committed in order.
metrics::gauge!("zcash.chain.verified.block.height", finalized.height.0 as _);
metrics::counter!("zcash.chain.verified.block.total", 1);
block_result = Ok(finalized);
} else {
metrics::counter!("state.finalized.error.block.count", 1);
metrics::counter!("state.checkpoint.error.block.count", 1);
metrics::gauge!(
"state.finalized.error.block.height",
"state.checkpoint.error.block.height",
finalized.height.0 as _
);
@ -677,9 +684,7 @@ impl Drop for FinalizedState {
}
}
fn block_precommit_metrics(finalized: &FinalizedBlock) {
let (hash, height, block) = (finalized.hash, finalized.height, finalized.block.as_ref());
fn block_precommit_metrics(block: &Block, hash: block::Hash, height: block::Height) {
let transaction_count = block.transactions.len();
let transparent_prevout_count = block
.transactions
@ -723,6 +728,10 @@ fn block_precommit_metrics(finalized: &FinalizedBlock) {
orchard_nullifier_count,
"preparing to commit finalized block"
);
metrics::counter!("state.finalized.block.count", 1);
metrics::gauge!("state.finalized.block.height", height.0 as _);
metrics::counter!(
"state.finalized.cumulative.transactions",
transaction_count as u64