Skip to content

refactor: introduce CyclesAccountManagerSubnetConfig#10485

Draft
mraszyk wants to merge 14 commits into
masterfrom
mraszyk/cycles-account-manager-subnet-config
Draft

refactor: introduce CyclesAccountManagerSubnetConfig#10485
mraszyk wants to merge 14 commits into
masterfrom
mraszyk/cycles-account-manager-subnet-config

Conversation

@mraszyk

@mraszyk mraszyk commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

No description provided.

mraszyk and others added 11 commits June 16, 2026 08:09
…own_subnet_cycles_config

- Move CyclesAccountManagerSubnetConfig to ic-types-cycles so that
  ReplicatedState can return it without a dependency cycle
- Derive Serialize/Deserialize on CyclesAccountManagerSubnetConfig so it
  can be stored in SandboxSafeSystemState
- Add get_own_subnet_cycles_config() to ReplicatedState
- Store CyclesAccountManagerSubnetConfig directly in SandboxSafeSystemState,
  replacing the separate subnet_size and cost_schedule fields
- Store CyclesAccountManagerSubnetConfig in each OriginalContext struct,
  replacing the separate subnet_size field
- Replace own-subnet inline CyclesAccountManagerSubnetConfig::new(...)
  constructions throughout production code with
  state.get_own_subnet_cycles_config()

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…or::execute_dts

Replace the cost_schedule: CanisterCyclesCostSchedule parameter with
subnet_cycles_config: CyclesAccountManagerSubnetConfig in:
- SandboxSafeSystemState::new() / new_for_testing()
- hypervisor::execute() / execute_dts()
- execute_non_replicated_query()
- execute_inspect_message()

This removes the last own-subnet CyclesAccountManagerSubnetConfig::new(...)
construction in production code (which was inside SandboxSafeSystemState::new()).
Callers in the execution layer use original.subnet_cycles_config directly;
query_context gains a get_own_subnet_cycles_config() helper.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace separate subnet_size: usize + cost_schedule: CanisterCyclesCostSchedule
parameters with subnet_cycles_config: CyclesAccountManagerSubnetConfig throughout:

  scheduler::execute_canisters_in_inner_round
  scheduler::execute_canisters_on_thread
  execute_canister (public)
  execute_canister_input (private fn + method)
  execute_canister_task
  execute_canister_response
  execute_call_or_task
  execute_response

The scheduler's inner round now calls state.get_own_subnet_cycles_config()
once and threads it down, eliminating the last own-subnet
CyclesAccountManagerSubnetConfig::new(...) construction in call_or_task.rs
and the one in response.rs's OriginalContext construction.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace the manual subnet_size lookup + CyclesAccountManagerSubnetConfig::new(...)
construction with a delegation to self.state.get_ref().get_own_subnet_cycles_config().
Remove the now-unused get_cost_schedule() method, CanisterCyclesCostSchedule
import, and SMALL_APP_SUBNET_MAX_SIZE import.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add get_own_subnet_cycles_config() helpers to SchedulerTest and ExecutionTest
that delegate to state.get_own_subnet_cycles_config(), replacing the inline
CyclesAccountManagerSubnetConfig::new(self.subnet_size(), self.cost_schedule())
constructions throughout both test utility structs.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <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

This PR introduces a small, shared configuration struct (CyclesAccountManagerSubnetConfig) that bundles the subnet size and cost schedule, and refactors cycle-fee/cost APIs and call sites to pass this single value instead of separate parameters. This centralizes how “subnet context” for cycle calculations is represented across the execution environment, scheduler, embedders, tests, benches, and related components.

Changes:

  • Added CyclesAccountManagerSubnetConfig to ic-types-cycles (and re-exported via ic-cycles-account-manager).
  • Refactored cycle cost/fee APIs and call sites to accept/pass CyclesAccountManagerSubnetConfig instead of (subnet_size, cost_schedule).
  • Updated tests/benches/build metadata to include new dependencies and adapt to the new signatures.

Reviewed changes

Copilot reviewed 61 out of 62 changed files in this pull request and generated no comments.

Show a summary per file
File Description
rs/types/cycles/src/lib.rs Exposes the new subnet config type from ic-types-cycles.
rs/types/cycles/src/cycles_account_manager_subnet_config.rs Defines CyclesAccountManagerSubnetConfig (subnet size + cost schedule).
rs/tests/networking/Cargo.toml Adds cycles account manager dependency for updated networking tests.
rs/tests/networking/canister_http_correctness_test.rs Updates HTTP fee expectations to pass the new subnet config.
rs/tests/networking/BUILD.bazel Adds Bazel dep needed for the updated networking test.
rs/tests/execution/general_execution_tests/canister_lifecycle.rs Updates ingress cost call to use the new subnet config.
rs/test_utilities/execution_environment/src/lib.rs Adds helper getter and refactors cost/fee calls to pass subnet config.
rs/test_utilities/embedders/src/lib.rs Updates System API test setup to pass subnet config (adds ic-limits size constant).
rs/test_utilities/embedders/Cargo.toml Adds ic-limits dependency needed for subnet sizing in tests.
rs/test_utilities/embedders/BUILD.bazel Adds Bazel dep on //rs/limits.
rs/state_machine_tests/src/lib.rs Removes stored cost_schedule field usage in favor of state-derived subnet config.
rs/replicated_state/src/replicated_state.rs Adds get_own_subnet_cycles_config() convenience accessor.
rs/messaging/src/scheduling/valid_set_rule/test.rs Updates tests to use state-derived subnet config (removes explicit subnet_size param).
rs/messaging/src/scheduling/valid_set_rule.rs Refactors induction/enqueue flow to derive subnet config from state.
rs/ingress_manager/src/ingress_selector.rs Updates ingress induction and cycle checks to use subnet config.
rs/execution_environment/tests/hypervisor.rs Refactors expected costs to use subnet config from ExecutionTest.
rs/execution_environment/src/scheduler/test_utilities.rs Updates scheduler test utilities to use subnet config.
rs/execution_environment/src/scheduler.rs Refactors scheduler execution/charging paths to pass subnet config.
rs/execution_environment/src/query_handler/query_context.rs Removes separate subnet size/cost schedule plumbing; uses state-derived subnet config.
rs/execution_environment/src/query_handler.rs Updates canister status query plumbing to pass subnet config.
rs/execution_environment/src/hypervisor.rs Updates hypervisor entrypoints to accept/pass subnet config.
rs/execution_environment/src/execution/upgrade/tests.rs Refactors upgrade tests to pass subnet config.
rs/execution_environment/src/execution/upgrade.rs Uses subnet config through upgrade execution stages.
rs/execution_environment/src/execution/response/tests.rs Refactors response tests to pass subnet config.
rs/execution_environment/src/execution/response.rs Stores/passes subnet config through response execution/resume paths.
rs/execution_environment/src/execution/nonreplicated_query.rs Updates non-replicated query execution to accept subnet config.
rs/execution_environment/src/execution/install.rs Uses subnet config in install execution stages.
rs/execution_environment/src/execution/install_code/tests.rs Refactors install-code tests to pass subnet config.
rs/execution_environment/src/execution/install_code.rs Stores/passes subnet config through install-code execution/resume paths.
rs/execution_environment/src/execution/inspect_message.rs Updates inspect-message execution to accept subnet config.
rs/execution_environment/src/execution/call_or_task/tests.rs Refactors call/task tests to pass subnet config.
rs/execution_environment/src/execution/call_or_task.rs Stores/passes subnet config through call/task execution/resume paths.
rs/execution_environment/src/execution_environment/tests/compilation.rs Refactors compilation-related tests to use subnet config.
rs/execution_environment/src/execution_environment/tests/canister_snapshots.rs Updates snapshot tests to pass subnet config.
rs/execution_environment/src/execution_environment/tests.rs Updates fee computations in tests to pass subnet config.
rs/execution_environment/src/execution_environment.rs Refactors core execution environment logic to pass subnet config broadly.
rs/execution_environment/src/canister_manager/tests.rs Updates canister manager tests to pass subnet config.
rs/execution_environment/src/canister_manager.rs Refactors canister manager APIs/logic to use subnet config.
rs/execution_environment/src/canister_logs.rs Updates canister logs fee charging to pass subnet config.
rs/execution_environment/BUILD.bazel Adds Bazel deps needed due to new imports (cycles_account_manager, limits).
rs/execution_environment/benches/wasm_instructions/main.rs Updates bench harness to pass subnet config.
rs/execution_environment/benches/system_api/execute_update.rs Updates bench harness to pass subnet config.
rs/execution_environment/benches/system_api/execute_query.rs Updates bench harness to pass subnet config (adds subnet size constant usage).
rs/execution_environment/benches/system_api/execute_inspect_message.rs Updates bench harness to pass subnet config (adds subnet size constant usage).
rs/embedders/tests/wasmtime_random_memory_writes.rs Updates System API test setup to pass subnet config.
rs/embedders/tests/system_api.rs Refactors System API tests to pass subnet config.
rs/embedders/tests/sandbox_safe_system_state.rs Refactors sandbox-safe state tests to pass subnet config.
rs/embedders/tests/common/mod.rs Updates common test helpers to construct System API with subnet config.
rs/embedders/src/wasmtime_embedder/tests.rs Updates embedder tests to pass subnet config.
rs/embedders/src/wasmtime_embedder/system_api/sandbox_safe_system_state.rs Stores subnet config in sandbox-safe system state and updates fee/cost calls accordingly.
rs/embedders/src/wasmtime_embedder/system_api.rs Updates System API cost syscalls to use subnet config-based APIs.
rs/embedders/fuzz/src/wasm_executor.rs Updates fuzz harness System API state construction to pass subnet config.
rs/embedders/fuzz/Cargo.toml Adds ic-limits dependency for subnet sizing in fuzz harness.
rs/embedders/fuzz/BUILD.bazel Adds Bazel dep on //rs/limits.
rs/embedders/BUILD.bazel Adds Bazel dep on //rs/limits.
rs/cycles_account_manager/tests/cycles_account_manager.rs Updates integration tests to pass subnet config.
rs/cycles_account_manager/src/lib.rs Re-exports CyclesAccountManagerSubnetConfig from ic-types-cycles.
rs/cycles_account_manager/src/cycles_account_manager/tests.rs Updates unit tests for signature changes (subnet config).
rs/cycles_account_manager/src/cycles_account_manager.rs Refactors core cycles accounting API to accept subnet config across fee/cost methods.
rs/canister_sandbox/src/sandbox_server.rs Updates sandbox tests to construct sandbox-safe state with subnet config.
rs/canister_sandbox/src/protocol/sbxsvc.rs Updates protocol tests to construct sandbox-safe state with subnet config.
Cargo.lock Updates lockfile for added Rust crate dependencies.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants