From c74a9f2a1faa81a72d7296aaf1dc5602bcf6d841 Mon Sep 17 00:00:00 2001 From: Stefan Schneider Date: Mon, 12 Jan 2026 10:33:08 +0000 Subject: [PATCH] chore: Set default maximum number of canisters For subnets that do not set an explicit maximum number of canisters in the registry, this PR changes the behavior from interpreting this from unlimited to a sensible default (120000). When set explicitly, the value can still be set higher or lower. --- rs/config/src/execution_environment.rs | 3 +++ rs/messaging/src/message_routing.rs | 10 ++++++++-- rs/protobuf/def/registry/subnet/v1/subnet.proto | 3 +-- rs/protobuf/src/gen/registry/registry.subnet.v1.rs | 3 +-- rs/protobuf/src/gen/state/registry.subnet.v1.rs | 3 +-- rs/protobuf/src/gen/types/registry.subnet.v1.rs | 3 +-- 6 files changed, 15 insertions(+), 10 deletions(-) diff --git a/rs/config/src/execution_environment.rs b/rs/config/src/execution_environment.rs index 9b3f841eb6a0..2d38b2b71742 100644 --- a/rs/config/src/execution_environment.rs +++ b/rs/config/src/execution_environment.rs @@ -170,6 +170,9 @@ pub const MAX_COMPILATION_CACHE_SIZE: NumBytes = NumBytes::new(10 * GIB); /// Maximum number of controllers allowed in a request (specified in the interface spec). pub const MAX_ALLOWED_CONTROLLERS_COUNT: usize = 10; +/// Default maximum number of canisters per subnet if not set in the registry. +pub const DEFAULT_MAX_NUMBER_OF_CANISTERS: u64 = 120_000; + /// Maximum number of canister snapshots that can be stored for a single canister. pub const MAX_NUMBER_OF_SNAPSHOTS_PER_CANISTER: usize = 10; diff --git a/rs/messaging/src/message_routing.rs b/rs/messaging/src/message_routing.rs index 4256fe0709c2..25ee257f35b9 100644 --- a/rs/messaging/src/message_routing.rs +++ b/rs/messaging/src/message_routing.rs @@ -1,6 +1,8 @@ use crate::state_machine::{StateMachine, StateMachineImpl}; use crate::{routing, scheduling}; -use ic_config::execution_environment::{BitcoinConfig, Config as HypervisorConfig}; +use ic_config::execution_environment::{ + BitcoinConfig, Config as HypervisorConfig, DEFAULT_MAX_NUMBER_OF_CANISTERS, +}; use ic_config::message_routing::{MAX_STREAM_MESSAGES, TARGET_STREAM_SIZE_BYTES}; use ic_cycles_account_manager::CyclesAccountManager; use ic_interfaces::execution_environment::{ @@ -868,7 +870,11 @@ impl BatchProcessorImpl { let node_public_keys = self.try_to_populate_node_public_keys(&nodes, registry_version)?; let subnet_features = subnet_record.features.unwrap_or_default().into(); - let max_number_of_canisters = subnet_record.max_number_of_canisters; + let max_number_of_canisters = if subnet_record.max_number_of_canisters == 0 { + DEFAULT_MAX_NUMBER_OF_CANISTERS + } else { + subnet_record.max_number_of_canisters + }; let chain_key_settings = if let Some(chain_key_config) = subnet_record.chain_key_config { let chain_key_config = ChainKeyConfig::try_from(chain_key_config).map_err(|err| { diff --git a/rs/protobuf/def/registry/subnet/v1/subnet.proto b/rs/protobuf/def/registry/subnet/v1/subnet.proto index e6ece52f6f9d..ce4f08ad8783 100644 --- a/rs/protobuf/def/registry/subnet/v1/subnet.proto +++ b/rs/protobuf/def/registry/subnet/v1/subnet.proto @@ -49,8 +49,7 @@ message SubnetRecord { // The maximum number of canisters that may be present on the subnet at any given time. // - // A value of 0 is equivalent to setting no limit. This also provides an easy way - // to maintain compatibility of different versions of replica and registry. + // A value of 0 means that the replica's default value will be used. uint64 max_number_of_canisters = 24; // The list of public keys whose owners have "readonly" SSH access to all replicas on this subnet, diff --git a/rs/protobuf/src/gen/registry/registry.subnet.v1.rs b/rs/protobuf/src/gen/registry/registry.subnet.v1.rs index 8aa2537eb55f..eff5cf8b10a8 100644 --- a/rs/protobuf/src/gen/registry/registry.subnet.v1.rs +++ b/rs/protobuf/src/gen/registry/registry.subnet.v1.rs @@ -45,8 +45,7 @@ pub struct SubnetRecord { pub features: ::core::option::Option, /// The maximum number of canisters that may be present on the subnet at any given time. /// - /// A value of 0 is equivalent to setting no limit. This also provides an easy way - /// to maintain compatibility of different versions of replica and registry. + /// A value of 0 means that the replica's default value will be used. #[prost(uint64, tag = "24")] pub max_number_of_canisters: u64, /// The list of public keys whose owners have "readonly" SSH access to all replicas on this subnet, diff --git a/rs/protobuf/src/gen/state/registry.subnet.v1.rs b/rs/protobuf/src/gen/state/registry.subnet.v1.rs index acedbe31e77c..afb84c436db7 100644 --- a/rs/protobuf/src/gen/state/registry.subnet.v1.rs +++ b/rs/protobuf/src/gen/state/registry.subnet.v1.rs @@ -45,8 +45,7 @@ pub struct SubnetRecord { pub features: ::core::option::Option, /// The maximum number of canisters that may be present on the subnet at any given time. /// - /// A value of 0 is equivalent to setting no limit. This also provides an easy way - /// to maintain compatibility of different versions of replica and registry. + /// A value of 0 means that the replica's default value will be used. #[prost(uint64, tag = "24")] pub max_number_of_canisters: u64, /// The list of public keys whose owners have "readonly" SSH access to all replicas on this subnet, diff --git a/rs/protobuf/src/gen/types/registry.subnet.v1.rs b/rs/protobuf/src/gen/types/registry.subnet.v1.rs index acedbe31e77c..afb84c436db7 100644 --- a/rs/protobuf/src/gen/types/registry.subnet.v1.rs +++ b/rs/protobuf/src/gen/types/registry.subnet.v1.rs @@ -45,8 +45,7 @@ pub struct SubnetRecord { pub features: ::core::option::Option, /// The maximum number of canisters that may be present on the subnet at any given time. /// - /// A value of 0 is equivalent to setting no limit. This also provides an easy way - /// to maintain compatibility of different versions of replica and registry. + /// A value of 0 means that the replica's default value will be used. #[prost(uint64, tag = "24")] pub max_number_of_canisters: u64, /// The list of public keys whose owners have "readonly" SSH access to all replicas on this subnet,