Repository navigation
fix: run the outcall cycles migration regardless of subnet activity - #11219
Merged
Merged
Conversation
The migration added in #10844, which brings the HTTPOutcalls / ECDSAOutcalls entries of SubnetMetrics::consumed_cycles_by_use_case up to the legacy scalar fields, was invoked from observe_consumed_cycles_with_use_case. That only fires when the subnet observes a subnet-level use case, and those are only observed on HTTP outcalls, threshold signature outcalls, canister deletion and cycles lost to dropped messages. A subnet that does none of these never runs the migration and its use-case entries stay stale indefinitely. This is not hypothetical: on mainnet subnet 2fq7c-slacv-26cgz-vzbx2-2jrcs-5edph-i5s2j-tck77-c3rlz-iobzx-mqe, consumed_cycles_ecdsa_outcalls is 244_900_000_000_000 while the ECDSAOutcalls use-case entry is 228_370_000_000_000, a gap of 16_530_000_000_000 cycles. Its consumed_cycles_by_use_case_as_counters map is empty, which (since that map is incremented on the very same code path) shows that no subnet-level use case has been observed there since the counters were introduced in #9922, i.e. well before the migration was deployed. The migration now runs from the scheduler's finish_round, which is documented as running unconditionally after each round and is also reached by the heap-delta early return and by checkpoint_round_with_no_execution. Running it once per round instead of per observation is equivalent, because the call sites bump the scalar field and the matching use-case entry by the same amount: max(entry, scalar) + delta == max(entry + delta, scalar + delta). It is also idempotent, so the extra invocations are harmless. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
✅ No security or compliance issues detected. Reviewed everything up to ab33d4a. Security OverviewDetected Code Changes
|
eichhorl
approved these changes
Aug 21, 2026
pull Bot
pushed a commit
to bit-cook/ic
that referenced
this pull request
Sep 22, 2026
…finity#11202) The cycles consumed by HTTP and ECDSA outcalls are tracked both in the legacy scalar fields consumed_cycles_http_outcalls / consumed_cycles_ecdsa_outcalls of SubnetMetrics and in the consumed_cycles_by_use_case map, which a migration introduced in dfinity#10844 keeps in lockstep with those fields. dfinity#11219 fixed that migration to run once per round from the scheduler's `finish_round`, i.e. regardless of subnet activity, so the map entries can no longer go stale on a subnet that performs no outcalls. I could now successfully confirm that the migration completed on all subnets with a DFINITY-owned node. This switches all readers over to the map: - get_consumed_cycles_http_outcalls / get_consumed_cycles_ecdsa_outcalls now read the HTTPOutcalls / ECDSAOutcalls entries of consumed_cycles_by_use_case, via a new helper that also backs the existing Schnorr / VetKd / dropped messages getters. - consumed_cycles_total and consumed_cycles_total_v28 add those entries instead of the scalar fields. The scalar fields are still observed and serialized, so that downgrading to an earlier replica version keeps observing the correct totals; only their reads are gone. The fixtures that populate only the scalar fields (`canonical_encoding_subnet_metrics`, the `state_manager` tree hash fixture and `consumed_cycles_total_is_the_same_across_a_restart`) now run the migration first, the way the scheduler does once per round. The expected canonical encodings and state hashes are unchanged. --------- Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The migration added in #10844, which brings the HTTPOutcalls / ECDSAOutcalls entries of SubnetMetrics::consumed_cycles_by_use_case up to the legacy scalar fields, was invoked from observe_consumed_cycles_with_use_case. That only fires when the subnet observes a subnet-level use case, and those are only observed on HTTP outcalls, threshold signature outcalls, canister deletion and cycles lost to dropped messages. A subnet that does none of these never runs the migration and its use-case entries stay stale indefinitely.
This is not hypothetical: on mainnet subnet
2fq7c-slacv-26cgz-vzbx2-2jrcs-5edph-i5s2j-tck77-c3rlz-iobzx-mqe, consumed_cycles_ecdsa_outcalls is 244_900_000_000_000 while the ECDSAOutcalls use-case entry is 228_370_000_000_000, a gap of 16_530_000_000_000 cycles. Its consumed_cycles_by_use_case_as_counters map is empty, which (since that map is incremented on the very same code path) shows that no subnet-level use case has been observed there since the counters were introduced in #9922, i.e. well before the migration was deployed.
The migration now runs from the scheduler's finish_round, which is documented as running unconditionally after each round and is also reached by the heap-delta early return and by checkpoint_round_with_no_execution. Running it once per round instead of per observation is equivalent, because the call sites bump the scalar field and the matching use-case entry by the same amount: max(entry, scalar) + delta == max(entry + delta, scalar + delta). It is also idempotent, so the extra invocations are harmless.