Skip to content

Commit cfefa39

Browse files
apollo_consensus_orchestrator,apollo_dashboard: add USD fee target panel and unit suffixes
1 parent 7da3e50 commit cfefa39

4 files changed

Lines changed: 47 additions & 22 deletions

File tree

crates/apollo_consensus_orchestrator/src/metrics.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,10 @@ define_metrics!(
3535

3636
// SNIP-35 dynamic gas pricing metrics.
3737
// STRK/USD rate metrics are in `apollo_l1_gas_price`.
38-
MetricGauge { SNIP35_FEE_ACTUAL, "snip35_fee_actual", "The current fee_actual (median of recent fee_proposals sliding window)" },
39-
MetricGauge { SNIP35_FEE_PROPOSAL, "snip35_fee_proposal", "The fee_proposal this node published in the latest block" },
40-
MetricGauge { SNIP35_FEE_TARGET, "snip35_fee_target", "The fee_target computed from the STRK/USD oracle" },
38+
MetricGauge { SNIP35_FEE_ACTUAL_FRI, "snip35_fee_actual_fri", "The current fee_actual (median of recent fee_proposals sliding window), in Fri" },
39+
MetricGauge { SNIP35_FEE_PROPOSAL_FRI, "snip35_fee_proposal_fri", "The fee_proposal this node published in the latest block, in Fri" },
40+
MetricGauge { SNIP35_FEE_TARGET_FRI, "snip35_fee_target_fri", "The fee_target computed from the STRK/USD oracle, in Fri" },
41+
MetricGauge { SNIP35_FEE_TARGET_ATTO_USD, "snip35_fee_target_atto_usd", "Configured target USD cost per L2 gas unit, in atto-USD" },
4142
}
4243
);
4344

@@ -106,7 +107,8 @@ pub(crate) fn register_metrics() {
106107
CONSENSUS_BUILD_PROPOSAL_FAILURE.register();
107108
CONSENSUS_VALIDATE_PROPOSAL_FAILURE.register();
108109
CONSENSUS_PROOF_MANAGER_STORE_LATENCY.register();
109-
SNIP35_FEE_ACTUAL.register();
110-
SNIP35_FEE_PROPOSAL.register();
111-
SNIP35_FEE_TARGET.register();
110+
SNIP35_FEE_ACTUAL_FRI.register();
111+
SNIP35_FEE_PROPOSAL_FRI.register();
112+
SNIP35_FEE_TARGET_FRI.register();
113+
SNIP35_FEE_TARGET_ATTO_USD.register();
112114
}

crates/apollo_consensus_orchestrator/src/sequencer_consensus_context.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,10 @@ use crate::metrics::{
101101
record_validate_proposal_failure,
102102
register_metrics,
103103
CONSENSUS_L2_GAS_PRICE,
104-
SNIP35_FEE_ACTUAL,
105-
SNIP35_FEE_PROPOSAL,
106-
SNIP35_FEE_TARGET,
104+
SNIP35_FEE_ACTUAL_FRI,
105+
SNIP35_FEE_PROPOSAL_FRI,
106+
SNIP35_FEE_TARGET_ATTO_USD,
107+
SNIP35_FEE_TARGET_FRI,
107108
};
108109
use crate::utils::{
109110
convert_to_sn_api_block_info,
@@ -446,19 +447,20 @@ impl SequencerConsensusContext {
446447
timestamp: u64,
447448
target_atto_usd_per_l2_gas: u128,
448449
) -> GasPrice {
450+
SNIP35_FEE_TARGET_ATTO_USD.set_lossy(target_atto_usd_per_l2_gas);
449451
let Some(fee_actual) = fee_actual else {
450452
warn!("fee_actual unavailable, freezing fee_proposal at l2_gas_price");
451-
SNIP35_FEE_PROPOSAL.set_lossy(self.l2_gas_price.0);
453+
SNIP35_FEE_PROPOSAL_FRI.set_lossy(self.l2_gas_price.0);
452454
return self.l2_gas_price;
453455
};
454-
SNIP35_FEE_ACTUAL.set_lossy(fee_actual.0);
456+
SNIP35_FEE_ACTUAL_FRI.set_lossy(fee_actual.0);
455457

456458
let fee_target = match self.deps.l1_gas_price_provider.get_strk_to_usd_rate(timestamp).await
457459
{
458460
Ok(rate) => {
459461
let target = compute_fee_target(target_atto_usd_per_l2_gas, rate);
460462
match target {
461-
Some(t) => SNIP35_FEE_TARGET.set_lossy(t.0),
463+
Some(t) => SNIP35_FEE_TARGET_FRI.set_lossy(t.0),
462464
None => warn!("STRK/USD oracle returned zero rate, freezing fee_proposal"),
463465
}
464466
target
@@ -474,7 +476,7 @@ impl SequencerConsensusContext {
474476
fee_actual,
475477
VersionedConstants::latest_constants().fee_proposal_margin_ppt,
476478
);
477-
SNIP35_FEE_PROPOSAL.set_lossy(proposal.0);
479+
SNIP35_FEE_PROPOSAL_FRI.set_lossy(proposal.0);
478480
proposal
479481
}
480482

crates/apollo_dashboard/resources/dev_grafana.json

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@
402402
"description": "Median of recent fee_proposals over the sliding window, in GFri",
403403
"type": "timeseries",
404404
"exprs": [
405-
"snip35_fee_actual{cluster=~\"$cluster\", namespace=~\"$namespace\", pod=~\"$pod\"} / 1e9"
405+
"snip35_fee_actual_fri{cluster=~\"$cluster\", namespace=~\"$namespace\", pod=~\"$pod\"} / 1e9"
406406
],
407407
"extra_params": {}
408408
},
@@ -411,7 +411,7 @@
411411
"description": "fee_proposal this node published in the latest block, in GFri",
412412
"type": "timeseries",
413413
"exprs": [
414-
"snip35_fee_proposal{cluster=~\"$cluster\", namespace=~\"$namespace\", pod=~\"$pod\"} / 1e9"
414+
"snip35_fee_proposal_fri{cluster=~\"$cluster\", namespace=~\"$namespace\", pod=~\"$pod\"} / 1e9"
415415
],
416416
"extra_params": {}
417417
},
@@ -420,7 +420,16 @@
420420
"description": "fee_target computed from the STRK/USD oracle, in GFri",
421421
"type": "timeseries",
422422
"exprs": [
423-
"snip35_fee_target{cluster=~\"$cluster\", namespace=~\"$namespace\", pod=~\"$pod\"} / 1e9"
423+
"snip35_fee_target_fri{cluster=~\"$cluster\", namespace=~\"$namespace\", pod=~\"$pod\"} / 1e9"
424+
],
425+
"extra_params": {}
426+
},
427+
{
428+
"title": "Fee Target (USD per 1B L2 gas)",
429+
"description": "Configured target USD cost per 1 billion L2 gas units (raw metric is atto-USD per L2 gas; atto-USD / 1e9 = USD per 1B L2 gas)",
430+
"type": "timeseries",
431+
"exprs": [
432+
"snip35_fee_target_atto_usd{cluster=~\"$cluster\", namespace=~\"$namespace\", pod=~\"$pod\"} / 1e9"
424433
],
425434
"extra_params": {}
426435
},

crates/apollo_dashboard/src/panels/consensus.rs

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,10 @@ use apollo_consensus_orchestrator::metrics::{
5656
LABEL_BUILD_PROPOSAL_FAILURE_REASON,
5757
LABEL_CENDE_FAILURE_REASON,
5858
LABEL_VALIDATE_PROPOSAL_FAILURE_REASON,
59-
SNIP35_FEE_ACTUAL,
60-
SNIP35_FEE_PROPOSAL,
61-
SNIP35_FEE_TARGET,
59+
SNIP35_FEE_ACTUAL_FRI,
60+
SNIP35_FEE_PROPOSAL_FRI,
61+
SNIP35_FEE_TARGET_ATTO_USD,
62+
SNIP35_FEE_TARGET_FRI,
6263
};
6364
use apollo_l1_gas_price::metrics::{
6465
SNIP35_STRK_USD_ERROR_COUNT,
@@ -725,7 +726,7 @@ fn get_panel_snip35_fee_actual() -> Panel {
725726
Panel::new(
726727
"Fee Actual (GFri)",
727728
"Median of recent fee_proposals over the sliding window, in GFri",
728-
format!("{} / 1e9", SNIP35_FEE_ACTUAL.get_name_with_filter()),
729+
format!("{} / 1e9", SNIP35_FEE_ACTUAL_FRI.get_name_with_filter()),
729730
PanelType::TimeSeries,
730731
)
731732
}
@@ -734,7 +735,7 @@ fn get_panel_snip35_fee_proposal() -> Panel {
734735
Panel::new(
735736
"Fee Proposal (GFri)",
736737
"fee_proposal this node published in the latest block, in GFri",
737-
format!("{} / 1e9", SNIP35_FEE_PROPOSAL.get_name_with_filter()),
738+
format!("{} / 1e9", SNIP35_FEE_PROPOSAL_FRI.get_name_with_filter()),
738739
PanelType::TimeSeries,
739740
)
740741
}
@@ -743,7 +744,17 @@ fn get_panel_snip35_fee_target() -> Panel {
743744
Panel::new(
744745
"Fee Target (GFri)",
745746
"fee_target computed from the STRK/USD oracle, in GFri",
746-
format!("{} / 1e9", SNIP35_FEE_TARGET.get_name_with_filter()),
747+
format!("{} / 1e9", SNIP35_FEE_TARGET_FRI.get_name_with_filter()),
748+
PanelType::TimeSeries,
749+
)
750+
}
751+
752+
fn get_panel_snip35_fee_target_atto_usd() -> Panel {
753+
Panel::new(
754+
"Fee Target (USD per 1B L2 gas)",
755+
"Configured target USD cost per 1 billion L2 gas units (raw metric is atto-USD per L2 gas; \
756+
atto-USD / 1e9 = USD per 1B L2 gas)",
757+
format!("{} / 1e9", SNIP35_FEE_TARGET_ATTO_USD.get_name_with_filter()),
747758
PanelType::TimeSeries,
748759
)
749760
}
@@ -799,6 +810,7 @@ pub(crate) fn get_snip35_row() -> Row {
799810
get_panel_snip35_fee_actual(),
800811
get_panel_snip35_fee_proposal(),
801812
get_panel_snip35_fee_target(),
813+
get_panel_snip35_fee_target_atto_usd(),
802814
get_panel_snip35_strk_usd_rate(),
803815
get_panel_snip35_strk_usd_success_count(),
804816
get_panel_snip35_strk_usd_error_count(),

0 commit comments

Comments
 (0)