fix: account for Schnorr/VetKd/dropped-message cycles in consumed_cycles gauge#10794
fix: account for Schnorr/VetKd/dropped-message cycles in consumed_cycles gauge#10794mraszyk wants to merge 1 commit into
Conversation
…les gauge `replicated_state_consumed_cycles_since_replica_started` was computed by manually adding only the deleted-canisters, ECDSA-outcall and HTTP-outcall subnet-level use cases to the per-canister totals. The `SchnorrOutcalls`, `VetKd` and `DroppedMessages` subnet-level use cases (which have no dedicated scalar field and live only in the by-use-case map) were omitted, so the gauge under-counted consumed cycles. Add dedicated getters `get_consumed_cycles_schnorr_outcalls`, `get_consumed_cycles_vetkd` and `get_consumed_cycles_dropped_messages` on `SubnetMetrics` (reading from the by-use-case map, since these use cases can never originate from a deleted canister) and include them in the gauge, for parity with the existing ECDSA/HTTP getters. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Fixes undercounting in the replicated_state_consumed_cycles_since_replica_started gauge by including previously omitted subnet-level consumed-cycles use cases (Schnorr outcalls, VetKd, and dropped messages), bringing the gauge in line with the sum of canister-level consumption plus subnet-metrics consumption across all use cases.
Changes:
- Extend the total consumed-cycles gauge computation to include Schnorr outcalls, VetKd, and dropped-message cycles from
SubnetMetrics. - Add dedicated
SubnetMetricsgetters for Schnorr/VetKd/DroppedMessages that read from the by-use-case map (matching existing patterns for other subnet-level use cases).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| rs/replicated_state/src/metrics.rs | Updates the consumed-cycles total gauge to add Schnorr/VetKd/DroppedMessages subnet-level cycles. |
| rs/replicated_state/src/metadata_state.rs | Adds SubnetMetrics getters for Schnorr/VetKd/DroppedMessages cycles backed by the by-use-case map. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| consumed_cycles_total += state | ||
| .metadata | ||
| .subnet_metrics | ||
| .get_consumed_cycles_schnorr_outcalls(); | ||
| consumed_cycles_total += state.metadata.subnet_metrics.get_consumed_cycles_vetkd(); |
There was a problem hiding this comment.
Not every cycles use case contributes to replicated_state_consumed_cycles_since_replica_started so omitting such a test for now.
|
✅ No security or compliance issues detected. Reviewed everything up to a3f1408. Security Overview
Detected Code Changes
|
replicated_state_consumed_cycles_since_replica_startedwas computed by manually adding only the deleted-canisters, ECDSA-outcall and HTTP-outcall subnet-level use cases to the per-canister totals. TheSchnorrOutcalls,VetKdandDroppedMessagessubnet-level use cases (which have no dedicated scalar field and live only in the by-use-case map) were omitted, so the gauge under-counted consumed cycles.Add dedicated getters
get_consumed_cycles_schnorr_outcalls,get_consumed_cycles_vetkdandget_consumed_cycles_dropped_messagesonSubnetMetrics(reading from the by-use-case map, since these use cases can never originate from a deleted canister) and include them in the gauge, for parity with the existing ECDSA/HTTP getters.In particular,
replicated_state_consumed_cycles_since_replica_startedis now equal to the sum of consumed cycles over all canisters + subnet metrics over all use cases (ignoring the fact that on mainnet the dedicated scalar fields might be higher than the corresponding entries in the by-use-case map that were only added later).