You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
apollo_l1_gas_price: parameterize ExchangeRateOracleClient by metric set (#14199)
Goal: Prerequisite for PR #14158 (`02_provider_holds_oracle`). Before that
PR introduces a second `ExchangeRateOracleClient` for STRK→USD,
parameterize the client by metric set so the two oracles update disjoint
Prometheus series instead of contaminating each other's gauges and
counters. Closes the issue flagged by Cursor bugbot + matanl-starkware on
PR #14158.
Change summary:
- `apollo_l1_gas_price::metrics` defines `ExchangeRateOracleMetrics`
(`rate`, `success_count`, `error_count`, `last_success_timestamp`) as a
`Copy` struct of `&'static` refs, plus two `pub const` instances:
`ETH_TO_STRK_ORACLE_METRICS` and `STRK_TO_USD_ORACLE_METRICS`.
- `SNIP35_STRK_USD_RATE` moves from `apollo_consensus_orchestrator::metrics`
into `apollo_l1_gas_price::metrics`, keeping the Prometheus name
`snip35_strk_usd_rate` so the existing Grafana panel keeps working
without a query rewrite.
- Adds three new SNIP-35 metrics owned by the oracle client:
`snip35_strk_usd_success_count`, `snip35_strk_usd_error_count`,
`snip35_strk_usd_last_success_timestamp_seconds`.
- `ExchangeRateOracleClient::new(config, metrics)` now stores the metric
set; `spawn_query`, `resolve_query`, and `fetch_rate` route through
`self.metrics.*` instead of hardcoded `ETH_TO_STRK_*` symbols. Manual
`Debug` impl on `ExchangeRateOracleMetrics` (the underlying
`MetricCounter`/`MetricGauge` don't derive Debug) prints prom names.
- `L1GasPriceProvider::new_with_oracle` passes `ETH_TO_STRK_ORACLE_METRICS`
to the existing client; PR 02 will pass `STRK_TO_USD_ORACLE_METRICS` to
its new client.
- `SequencerConsensusContext::compute_snip35_fee_proposal` stops calling
`SNIP35_STRK_USD_RATE.set_lossy(rate)`; the oracle client publishes that
gauge itself now. Consensus still reads the rate to compute `fee_target`.
- `apollo_dashboard::panels::consensus` imports `SNIP35_STRK_USD_RATE` (and
the 3 new metrics) from `apollo_l1_gas_price` instead of
`apollo_consensus_orchestrator`; adds 3 new panels (success / error /
seconds-since-last-update) to the SNIP-35 row, matching the ETH→STRK
panel patterns.
- `dev_grafana.json` updated by hand to add the 3 new panel entries; the
Rust toolchain is unavailable in this environment so the generator
could not be re-run. Verify locally with
`cargo run --bin sequencer_dashboard_generator` before pushing.
Decision points:
- Reuse `snip35_strk_usd_rate` rather than defining a new
`strk_to_usd_rate`: the existing time series + Grafana panel keep
continuity, and the SNIP-35 dashboard row is the natural home for the
STRK→USD oracle gauges.
- Move the metric definition into `apollo_l1_gas_price` (owner) rather
than keeping it in `apollo_consensus_orchestrator` and passing a
`&'static` reference down: avoids cross-crate metric ownership and
preserves the existing one-way crate dependency
(consensus → l1_gas_price_types).
- `pub const` struct of `&'static` refs (matches the existing
`TEST_LOCAL_SERVER_METRICS` pattern in `apollo_infra`) rather than
`static`: lets `ExchangeRateOracleClient` store the set by value (Copy)
with no lifetime annotations on the struct.
- Add all 3 observability metrics (success/error/timestamp) symmetrically
with the ETH→STRK side rather than just the rate: keeps the new
dashboard row useful — "did the STRK→USD query just fail or just stop
firing?" is answerable without leaning on log queries.
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: crates/apollo_consensus_orchestrator/src/metrics.rs
+2-3Lines changed: 2 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -33,11 +33,11 @@ define_metrics!(
33
33
// Proposal validation failure metrics
34
34
LabeledMetricCounter{CONSENSUS_VALIDATE_PROPOSAL_FAILURE,"consensus_validate_proposal_failure","Number of failures while validating a proposal", init = 0, labels = VALIDATE_PROPOSAL_FAILURE_REASON},
35
35
36
-
// SNIP-35 dynamic gas pricing metrics
36
+
// SNIP-35 dynamic gas pricing metrics.
37
+
// STRK/USD rate metrics are in `apollo_l1_gas_price`.
37
38
MetricGauge{SNIP35_FEE_ACTUAL,"snip35_fee_actual","The current fee_actual (median of recent fee_proposals sliding window)"},
38
39
MetricGauge{SNIP35_FEE_PROPOSAL,"snip35_fee_proposal","The fee_proposal this node published in the latest block"},
39
40
MetricGauge{SNIP35_FEE_TARGET,"snip35_fee_target","The fee_target computed from the STRK/USD oracle"},
40
-
MetricGauge{SNIP35_STRK_USD_RATE,"snip35_strk_usd_rate","The STRK/USD rate from the oracle"},
0 commit comments