Skip to content

fix: account for Schnorr/VetKd/dropped-message cycles in consumed_cycles gauge#10794

Open
mraszyk wants to merge 1 commit into
masterfrom
fix/consumed-cycles-schnorr-vetkd-dropped
Open

fix: account for Schnorr/VetKd/dropped-message cycles in consumed_cycles gauge#10794
mraszyk wants to merge 1 commit into
masterfrom
fix/consumed-cycles-schnorr-vetkd-dropped

Conversation

@mraszyk

@mraszyk mraszyk commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

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.

In particular, replicated_state_consumed_cycles_since_replica_started is 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).

…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>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 SubnetMetrics getters 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.

Comment on lines +543 to +547
consumed_cycles_total += state
.metadata
.subnet_metrics
.get_consumed_cycles_schnorr_outcalls();
consumed_cycles_total += state.metadata.subnet_metrics.get_consumed_cycles_vetkd();

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not every cycles use case contributes to replicated_state_consumed_cycles_since_replica_started so omitting such a test for now.

@mraszyk
mraszyk marked this pull request as ready for review July 17, 2026 08:01
@mraszyk
mraszyk requested a review from a team as a code owner July 17, 2026 08:01
@zeropath-ai

zeropath-ai Bot commented Jul 17, 2026

Copy link
Copy Markdown

No security or compliance issues detected. Reviewed everything up to a3f1408.

Security Overview
Detected Code Changes
Change Type Relevant files
Enhancement ► rs/replicated_state/src/metadata_state.rs
    Add get_consumed_cycles_schnorr_outcalls, get_consumed_cycles_vetkd, get_consumed_cycles_dropped_messages methods
► rs/replicated_state/src/metrics.rs
    Utilize new by-use-case cycle getters to accumulate total consumed cycles

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants