[DO NOT MERGE] feat: Update consumed cycles metrics on free cost schedule#9758
[DO NOT MERGE] feat: Update consumed cycles metrics on free cost schedule#9758dsarlis wants to merge 3 commits intodfinity:masterfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates cycles accounting so that consumed-cycles metrics (nominal) are updated based on resource usage even when the subnet runs on a free cost schedule, while charged cycles (real) remain zero where appropriate. It also adapts and expands tests to validate behavior on both normal and free schedules.
Changes:
- Update
CompoundCycles::newto always preserve nominal cycles while applying cost-schedule rules only to the real (charged) portion. - Adjust scheduler/execution/messaging tests to use
.real()for balance-affecting paths and.nominal()for consumed-metrics assertions, including running key tests under bothNormalandFreeschedules. - Centralize canister creation fee as a constant and update tests to assert nominal consumption on free schedules.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| rs/types/cycles/src/compound_cycles.rs | Separates nominal vs real cycles in CompoundCycles::new, ensuring nominal updates even on free schedule. |
| rs/messaging/src/routing/stream_handler/tests.rs | Runs relevant stream handler tests under both cost schedules; updates lost-cycles expectations. |
| rs/execution_environment/src/scheduler/tests/metrics.rs | Updates consumed-cycles metric tests to assert nominal amounts; adds coverage for free schedule. |
| rs/execution_environment/src/scheduler/tests/ecdsa.rs | Adjusts ECDSA fee usage to pass real cycles where a payment is required. |
| rs/execution_environment/src/scheduler/tests/charging.rs | Updates resource charging assertions to use real cycles from CompoundCycles. |
| rs/execution_environment/src/scheduler/tests.rs | Updates ECDSA injection to use real fee. |
| rs/execution_environment/src/scheduler/test_utilities.rs | Changes fee/cost helpers to return CompoundCycles and adds helpers for time advancement and compute allocation cost. |
| rs/execution_environment/src/execution/response/tests.rs | Extends refund behavior test to both schedules and validates nominal consumed-cycles updates. |
| rs/execution_environment/src/execution_environment/tests.rs | Extends ingress charging test to validate consumed-cycles metrics alongside balance effects across schedules. |
| rs/execution_environment/src/canister_manager/tests.rs | Updates free-schedule canister creation tests to expect nominal consumption equal to creation fee. |
| rs/config/src/subnet_config.rs | Introduces CANISTER_CREATION_FEE constant and reuses it in cycles account manager config. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Review dismissed by automation script.
|
Looks like there are still some linting errors: |
Yeah that's because I committed the suggestion and it happened to create a lint issue this time. I fixed it along with an update to the test that was needed. Should be fine now. |
Separate the values of
NominalCyclesthat are used to count consumed cycles from theCyclesamounts that are charged against the canister's balance. Specifically,NominalCyclesare updated even on a free schedule with the amounts that correspond to the respective resource usage.The main change in production code is in the constructor of
CompoundCycleswhile the rest are updating tests as needed, including fixing expected values, testing both on normal and free schedule as well as adding some new tests for cases that were not covered. Additionally, a const is defined for the canister creation fee to be consistently used in production and test code where necessary.This should be deployed after #9676 to ensure that no wrong values are used before this PR separates the two types of cycles.