From 1fb7e9b46109ad5c81a13f2e97621c5b71a757be Mon Sep 17 00:00:00 2001 From: ltitanb Date: Thu, 17 Oct 2024 13:39:01 +0100 Subject: [PATCH 1/3] add relay header metric --- crates/pbs/src/metrics.rs | 11 +++++++++++ crates/pbs/src/mev_boost/get_header.rs | 8 ++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/crates/pbs/src/metrics.rs b/crates/pbs/src/metrics.rs index e3700931..814d00a1 100644 --- a/crates/pbs/src/metrics.rs +++ b/crates/pbs/src/metrics.rs @@ -41,6 +41,17 @@ lazy_static! { ) .unwrap(); + /// Latest slot for which relay delivered a header + // Don't store slot number to avoid creating high cardinality, if needed can just aggregate for 12sec + pub static ref RELAY_HEADER_VALUE: IntGaugeVec = register_int_gauge_vec_with_registry!( + "relay_header_value", + "Header value in gwei delivered by relay", + &["relay_id"], + PBS_METRICS_REGISTRY + ) + .unwrap(); + + // TO BEACON NODE /// Status code returned to beacon node by endpoint pub static ref BEACON_NODE_STATUS: IntCounterVec = register_int_counter_vec_with_registry!( diff --git a/crates/pbs/src/mev_boost/get_header.rs b/crates/pbs/src/mev_boost/get_header.rs index 772f8c5a..7dc3cfff 100644 --- a/crates/pbs/src/mev_boost/get_header.rs +++ b/crates/pbs/src/mev_boost/get_header.rs @@ -25,7 +25,7 @@ use url::Url; use crate::{ constants::{GET_HEADER_ENDPOINT_TAG, TIMEOUT_ERROR_CODE, TIMEOUT_ERROR_CODE_STR}, - metrics::{RELAY_LAST_SLOT, RELAY_LATENCY, RELAY_STATUS_CODE}, + metrics::{RELAY_HEADER_VALUE, RELAY_LAST_SLOT, RELAY_LATENCY, RELAY_STATUS_CODE}, state::{BuilderApiState, PbsState}, }; @@ -76,11 +76,15 @@ pub async fn get_header( let results = join_all(handles).await; let mut relay_bids = Vec::with_capacity(relays.len()); for (i, res) in results.into_iter().enumerate() { - let relay_id = relays[i].id.as_ref(); + let relay_id = relays[i].id.as_str(); match res { Ok(Some(res)) => { RELAY_LAST_SLOT.with_label_values(&[relay_id]).set(params.slot as i64); + let value_gwei = + (res.value() / U256::from(1_000_000_000)).try_into().unwrap_or_default(); + RELAY_HEADER_VALUE.with_label_values(&[relay_id]).set(value_gwei); + relay_bids.push(res) } Ok(_) => {} From 6d7b0f851aeb2745255a28ecc27d1ca0099d08ce Mon Sep 17 00:00:00 2001 From: ltitanb Date: Thu, 17 Oct 2024 16:47:41 +0100 Subject: [PATCH 2/3] add header panel --- grafana/dashboards/dashboard.json | 79 ++++++++++++++++++++++++++++++- grafana/public_dashboard.json | 77 +++++++++++++++++++++++++++++- 2 files changed, 153 insertions(+), 3 deletions(-) diff --git a/grafana/dashboards/dashboard.json b/grafana/dashboards/dashboard.json index 701948e7..94dd0626 100644 --- a/grafana/dashboards/dashboard.json +++ b/grafana/dashboards/dashboard.json @@ -46,7 +46,7 @@ "editable": true, "fiscalYearStartMonth": 0, "graphTooltip": 0, - "id": null, + "id": 1, "links": [], "liveNow": true, "panels": [ @@ -127,6 +127,81 @@ "title": "Last delivered slot", "type": "stat" }, + { + "datasource": { + "type": "prometheus", + "uid": "cb_prometheus" + }, + "fieldConfig": { + "defaults": { + "color": { + "fixedColor": "text", + "mode": "thresholds" + }, + "decimals": 6, + "fieldMinMax": false, + "mappings": [], + "thresholds": { + "mode": "percentage", + "steps": [ + { + "color": "text", + "value": null + } + ] + }, + "unit": "ETH" + }, + "overrides": [] + }, + "gridPos": { + "h": 11, + "w": 6, + "x": 6, + "y": 0 + }, + "id": 78, + "options": { + "colorMode": "none", + "graphMode": "area", + "justifyMode": "auto", + "orientation": "horizontal", + "percentChangeColorMode": "standard", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "showPercentChange": false, + "textMode": "auto", + "wideLayout": true + }, + "pluginVersion": "11.1.0", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "cb_prometheus" + }, + "disableTextWrap": false, + "editorMode": "code", + "exemplar": false, + "expr": "cb_pbs_relay_header_value / 1e9", + "format": "time_series", + "fullMetaSearch": false, + "includeNullMetadata": true, + "instant": false, + "legendFormat": "{{relay_id}}", + "range": true, + "refId": "A", + "useBackend": false + } + ], + "title": "Last delivered header value", + "type": "stat" + }, { "collapsed": false, "gridPos": { @@ -904,6 +979,6 @@ "timezone": "browser", "title": "PBS Metrics", "uid": "cb_pbs_metrics", - "version": 2, + "version": 1, "weekStart": "" } \ No newline at end of file diff --git a/grafana/public_dashboard.json b/grafana/public_dashboard.json index 89f84c51..d7106639 100644 --- a/grafana/public_dashboard.json +++ b/grafana/public_dashboard.json @@ -136,6 +136,81 @@ "title": "Last delivered slot", "type": "stat" }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_CB_PROMETHEUS}" + }, + "fieldConfig": { + "defaults": { + "color": { + "fixedColor": "text", + "mode": "thresholds" + }, + "decimals": 6, + "fieldMinMax": false, + "mappings": [], + "thresholds": { + "mode": "percentage", + "steps": [ + { + "color": "text", + "value": null + } + ] + }, + "unit": "ETH" + }, + "overrides": [] + }, + "gridPos": { + "h": 11, + "w": 6, + "x": 6, + "y": 0 + }, + "id": 78, + "options": { + "colorMode": "none", + "graphMode": "area", + "justifyMode": "auto", + "orientation": "horizontal", + "percentChangeColorMode": "standard", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "showPercentChange": false, + "textMode": "auto", + "wideLayout": true + }, + "pluginVersion": "11.1.0", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_CB_PROMETHEUS}" + }, + "disableTextWrap": false, + "editorMode": "code", + "exemplar": false, + "expr": "cb_pbs_relay_header_value / 1e9", + "format": "time_series", + "fullMetaSearch": false, + "includeNullMetadata": true, + "instant": false, + "legendFormat": "{{relay_id}}", + "range": true, + "refId": "A", + "useBackend": false + } + ], + "title": "Last delivered header value", + "type": "stat" + }, { "collapsed": false, "gridPos": { @@ -913,6 +988,6 @@ "timezone": "browser", "title": "PBS Metrics", "uid": "cb_pbs_metrics", - "version": 2, + "version": 1, "weekStart": "" } \ No newline at end of file From 747a9a871f16149af40bab28f146456e36397960 Mon Sep 17 00:00:00 2001 From: ltitanb Date: Thu, 17 Oct 2024 16:51:00 +0100 Subject: [PATCH 3/3] fix value in logs --- crates/pbs/src/mev_boost/get_header.rs | 2 +- crates/pbs/src/routes/get_header.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/pbs/src/mev_boost/get_header.rs b/crates/pbs/src/mev_boost/get_header.rs index 7dc3cfff..5b07454a 100644 --- a/crates/pbs/src/mev_boost/get_header.rs +++ b/crates/pbs/src/mev_boost/get_header.rs @@ -280,8 +280,8 @@ async fn send_one_get_header( debug!( latency = ?request_latency, - block_hash = %get_header_response.block_hash(), value_eth = format_ether(get_header_response.value()), + block_hash = %get_header_response.block_hash(), "received new header" ); diff --git a/crates/pbs/src/routes/get_header.rs b/crates/pbs/src/routes/get_header.rs index e6dea2a2..242c4283 100644 --- a/crates/pbs/src/routes/get_header.rs +++ b/crates/pbs/src/routes/get_header.rs @@ -39,7 +39,7 @@ pub async fn handle_get_header>( state.publish_event(BuilderEvent::GetHeaderResponse(Box::new(res.clone()))); if let Some(max_bid) = res { - info!(block_hash =% max_bid.block_hash(), value_eth = format_ether(max_bid.value()), "received header"); + info!(value_eth = format_ether(max_bid.value()), block_hash =% max_bid.block_hash(), "received header"); BEACON_NODE_STATUS.with_label_values(&["200", GET_HEADER_ENDPOINT_TAG]).inc(); Ok((StatusCode::OK, axum::Json(max_bid)).into_response())