Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions rs/messaging/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ rust_library(
"//rs/registry/helpers",
"//rs/registry/keys",
"//rs/registry/provisional_whitelist",
"//rs/registry/resource_limits",
"//rs/registry/routing_table",
"//rs/registry/subnet_features",
"//rs/registry/subnet_type",
Expand Down Expand Up @@ -61,6 +62,7 @@ rust_test(
"//rs/registry/fake",
"//rs/registry/local_registry",
"//rs/registry/proto_data_provider",
"//rs/registry/resource_limits",
"//rs/registry/transport",
"//rs/state_manager",
"//rs/test_utilities",
Expand Down
1 change: 1 addition & 0 deletions rs/messaging/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ ic-query-stats = { path = "../query_stats" }
ic-registry-client-helpers = { path = "../registry/helpers" }
ic-registry-keys = { path = "../registry/keys" }
ic-registry-provisional-whitelist = { path = "../registry/provisional_whitelist" }
ic-registry-resource-limits = { path = "../registry/resource_limits" }
ic-registry-routing-table = { path = "../registry/routing_table" }
ic-registry-subnet-features = { path = "../registry/subnet_features" }
ic-registry-subnet-type = { path = "../registry/subnet_type" }
Expand Down
8 changes: 8 additions & 0 deletions rs/messaging/src/message_routing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ use ic_registry_client_helpers::subnet::{
SubnetListRegistry, SubnetRegistry, get_node_ids_from_subnet_record,
};
use ic_registry_provisional_whitelist::ProvisionalWhitelist;
use ic_registry_resource_limits::ResourceLimits;
use ic_registry_subnet_features::{ChainKeyConfig, SubnetFeatures};
use ic_registry_subnet_type::SubnetType;
use ic_replicated_state::metadata_state::ApiBoundaryNodeEntry;
Expand Down Expand Up @@ -800,6 +801,7 @@ impl<RegistryClient_: RegistryClient> BatchProcessorImpl<RegistryClient_> {
) -> (
NetworkTopology,
SubnetFeatures,
ResourceLimits,
RegistryExecutionSettings,
NodePublicKeys,
ApiBoundaryNodes,
Expand Down Expand Up @@ -837,6 +839,7 @@ impl<RegistryClient_: RegistryClient> BatchProcessorImpl<RegistryClient_> {
/// All of the above are required for deterministic processing, so if any
/// entry is missing or cannot be decoded; or reading the registry fails; the
/// call fails and returns an error.
#[allow(clippy::type_complexity)]
fn try_to_read_registry(
&self,
registry_version: RegistryVersion,
Expand All @@ -845,6 +848,7 @@ impl<RegistryClient_: RegistryClient> BatchProcessorImpl<RegistryClient_> {
(
NetworkTopology,
SubnetFeatures,
ResourceLimits,
RegistryExecutionSettings,
NodePublicKeys,
ApiBoundaryNodes,
Expand Down Expand Up @@ -878,6 +882,7 @@ impl<RegistryClient_: RegistryClient> BatchProcessorImpl<RegistryClient_> {
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 resource_limits = subnet_record.resource_limits.unwrap_or_default().into();
let max_number_of_canisters = if subnet_record.max_number_of_canisters == 0 {
DEFAULT_MAX_NUMBER_OF_CANISTERS
} else {
Expand Down Expand Up @@ -965,6 +970,7 @@ impl<RegistryClient_: RegistryClient> BatchProcessorImpl<RegistryClient_> {
Ok((
network_topology,
subnet_features,
resource_limits,
RegistryExecutionSettings {
max_number_of_canisters,
provisional_whitelist,
Expand Down Expand Up @@ -1385,6 +1391,7 @@ impl<RegistryClient_: RegistryClient> BatchProcessor for BatchProcessorImpl<Regi
let (
network_topology,
subnet_features,
resource_limits,
registry_execution_settings,
node_public_keys,
api_boundary_nodes,
Expand Down Expand Up @@ -1413,6 +1420,7 @@ impl<RegistryClient_: RegistryClient> BatchProcessor for BatchProcessorImpl<Regi
network_topology,
batch,
subnet_features,
resource_limits,
&registry_execution_settings,
node_public_keys,
api_boundary_nodes,
Expand Down
27 changes: 24 additions & 3 deletions rs/messaging/src/message_routing/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ use ic_registry_client_fake::FakeRegistryClient;
use ic_registry_keys::{make_canister_ranges_key, make_chain_key_enabled_subnet_list_key};
use ic_registry_local_registry::LocalRegistry;
use ic_registry_proto_data_provider::{ProtoRegistryDataProvider, ProtoRegistryDataProviderError};
use ic_registry_resource_limits::ResourceLimits;
use ic_registry_routing_table::{CanisterMigrations, RoutingTable, routing_table_insert_subnet};
use ic_registry_subnet_features::{ChainKeyConfig, KeyConfig};
use ic_replicated_state::Stream;
Expand Down Expand Up @@ -269,6 +270,7 @@ struct SubnetRecord<'a> {
max_number_of_canisters: u64,
cost_schedule: CanisterCyclesCostSchedule,
subnet_admins: Vec<PrincipalId>,
resource_limits: ResourceLimits,
}

impl From<SubnetRecord<'_>> for SubnetRecordProto {
Expand All @@ -281,6 +283,7 @@ impl From<SubnetRecord<'_>> for SubnetRecordProto {
.with_max_number_of_canisters(record.max_number_of_canisters)
.with_cost_schedule(record.cost_schedule)
.with_subnet_admins(record.subnet_admins)
.with_resource_limits(record.resource_limits)
.build()
}
}
Expand Down Expand Up @@ -625,12 +628,14 @@ impl StateMachine for FakeStateMachine {
network_topology: NetworkTopology,
_batch: Batch,
subnet_features: SubnetFeatures,
resource_limits: ResourceLimits,
registry_settings: &RegistryExecutionSettings,
node_public_keys: NodePublicKeys,
api_boundary_nodes: ApiBoundaryNodes,
) -> ReplicatedState {
state.metadata.network_topology = network_topology;
state.metadata.own_subnet_features = subnet_features;
state.metadata.own_resource_limits = resource_limits;
state.metadata.node_public_keys = node_public_keys;
state.metadata.api_boundary_nodes = api_boundary_nodes;
state.put_canister_state(
Expand Down Expand Up @@ -685,6 +690,7 @@ fn make_batch_processor<RegistryClient_: RegistryClient + 'static>(
}

/// Convenience wrapper for `BatchProcessorImpl::try_to_read_registry()`.
#[allow(clippy::type_complexity)]
fn try_to_read_registry(
registry: Arc<FakeRegistryClient>,
log: ReplicaLogger,
Expand All @@ -693,6 +699,7 @@ fn try_to_read_registry(
(
NetworkTopology,
SubnetFeatures,
ResourceLimits,
RegistryExecutionSettings,
NodePublicKeys,
ApiBoundaryNodes,
Expand Down Expand Up @@ -721,6 +728,7 @@ fn try_read_registry_succeeds_with_fully_specified_registry_records() {

// Own subnet characteristics.
let own_subnet_id = subnet_test_id(13);
let own_maximum_state_size = NumBytes::new(1 << 30);
let own_subnet_record = SubnetRecord {
membership: &[node_test_id(1), node_test_id(2)],
subnet_type: SubnetType::Application,
Expand Down Expand Up @@ -753,6 +761,10 @@ fn try_read_registry_succeeds_with_fully_specified_registry_records() {

max_number_of_canisters: 387,

resource_limits: ResourceLimits {
maximum_state_size: Some(own_maximum_state_size),
},

..Default::default()
};

Expand Down Expand Up @@ -883,6 +895,7 @@ fn try_read_registry_succeeds_with_fully_specified_registry_records() {
let (
network_topology,
own_subnet_features,
own_resource_limits,
registry_execution_settings,
node_public_keys,
api_boundary_nodes,
Expand Down Expand Up @@ -1046,6 +1059,14 @@ fn try_read_registry_succeeds_with_fully_specified_registry_records() {
own_subnet_features,
latest_state.metadata.own_subnet_features
);
assert_eq!(
own_resource_limits,
latest_state.metadata.own_resource_limits
);
assert_eq!(
latest_state.metadata.own_resource_limits.maximum_state_size,
Some(own_maximum_state_size)
);
assert_eq!(
*registry_settings.lock().unwrap(),
registry_execution_settings,
Expand Down Expand Up @@ -1098,7 +1119,7 @@ fn try_read_registry_succeeds_with_minimal_registry_records() {
// critical error for `subnet_size` has incremented.
assert_eq!(metrics.critical_error_missing_subnet_size.get(), 1);
// Check the subnet size was set to the maximum for a small app subnet.
let (_, _, registry_execution_settings, _, _) = result.unwrap();
let (_, _, _, registry_execution_settings, _, _) = result.unwrap();
assert_eq!(
registry_execution_settings.subnet_size,
SMALL_APP_SUBNET_MAX_SIZE
Expand Down Expand Up @@ -1417,7 +1438,7 @@ fn try_read_registry_can_skip_missing_or_invalid_node_public_keys() {
2
);

let (_, _, _, node_public_keys, _) = res.unwrap();
let (_, _, _, _, node_public_keys, _) = res.unwrap();
assert_eq!(node_public_keys.len(), 1);
assert!(!node_public_keys.contains_key(&node_test_id(1)));
assert!(!node_public_keys.contains_key(&node_test_id(2)));
Expand Down Expand Up @@ -1556,7 +1577,7 @@ fn try_read_registry_can_skip_missing_or_invalid_fields_of_api_boundary_nodes()

// There are six API BNs in the registry. However, five nodes have missing or invalid fields of NodeRecord.
// Hence, only one nodes are retrieved.
let (_, _, _, _, api_boundary_nodes) = res.unwrap();
let (_, _, _, _, _, api_boundary_nodes) = res.unwrap();
assert_eq!(api_boundary_nodes.len(), 1);
assert!(api_boundary_nodes.contains_key(&node_test_id(11)));

Expand Down
4 changes: 4 additions & 0 deletions rs/messaging/src/state_machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use ic_interfaces::execution_environment::{
use ic_interfaces::time_source::system_time_now;
use ic_logger::{ReplicaLogger, error, fatal};
use ic_query_stats::deliver_query_stats;
use ic_registry_resource_limits::ResourceLimits;
use ic_registry_subnet_features::SubnetFeatures;
use ic_replicated_state::{NetworkTopology, ReplicatedState};
use ic_types::batch::{Batch, BatchContent};
Expand All @@ -33,6 +34,7 @@ pub(crate) trait StateMachine: Send {
network_topology: NetworkTopology,
batch: Batch,
subnet_features: SubnetFeatures,
resource_limits: ResourceLimits,
registry_settings: &RegistryExecutionSettings,
node_public_keys: NodePublicKeys,
api_boundary_nodes: ApiBoundaryNodes,
Expand Down Expand Up @@ -115,6 +117,7 @@ impl StateMachine for StateMachineImpl {
network_topology: NetworkTopology,
batch: Batch,
subnet_features: SubnetFeatures,
resource_limits: ResourceLimits,
registry_settings: &RegistryExecutionSettings,
node_public_keys: NodePublicKeys,
api_boundary_nodes: ApiBoundaryNodes,
Expand All @@ -135,6 +138,7 @@ impl StateMachine for StateMachineImpl {

state.metadata.network_topology = network_topology;
state.metadata.own_subnet_features = subnet_features;
state.metadata.own_resource_limits = resource_limits;
state.metadata.node_public_keys = node_public_keys;
state.metadata.api_boundary_nodes = api_boundary_nodes;
if let Err(message) = state.metadata.init_allocation_ranges_if_empty() {
Expand Down
4 changes: 4 additions & 0 deletions rs/messaging/src/state_machine/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ fn state_machine_populates_network_topology() {
fixture.network_topology.clone(),
provided_batch,
Default::default(),
Default::default(),
&test_registry_settings(),
Default::default(),
Default::default(),
Expand Down Expand Up @@ -212,6 +213,7 @@ fn test_delivered_batch(provided_batch: Batch) -> ReplicatedState {
fixture.network_topology.clone(),
provided_batch,
Default::default(),
Default::default(),
&test_registry_settings(),
Default::default(),
Default::default(),
Expand Down Expand Up @@ -359,6 +361,7 @@ fn test_online_split(new_subnet_id: SubnetId, other_subnet_id: SubnetId) -> Repl
fixture.network_topology.clone(),
split_batch,
Default::default(),
Default::default(),
&test_registry_settings(),
Default::default(),
Default::default(),
Expand Down Expand Up @@ -476,6 +479,7 @@ fn test_batch_time_impl(
fixture.network_topology.clone(),
provided_batch,
Default::default(),
Default::default(),
&test_registry_settings(),
Default::default(),
Default::default(),
Expand Down
2 changes: 2 additions & 0 deletions rs/protobuf/def/state/metadata/v1/metadata.proto
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,8 @@ message SystemMetadata {
BlockmakerMetricsTimeSeries blockmaker_metrics_time_series = 20;

repeated ApiBoundaryNodeEntry api_boundary_nodes = 21;

registry.subnet.v1.ResourceLimits own_resource_limits = 24;
}

message StableMemory {
Expand Down
3 changes: 3 additions & 0 deletions rs/protobuf/src/gen/state/state.metadata.v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,9 @@ pub struct SystemMetadata {
pub blockmaker_metrics_time_series: ::core::option::Option<BlockmakerMetricsTimeSeries>,
#[prost(message, repeated, tag = "21")]
pub api_boundary_nodes: ::prost::alloc::vec::Vec<ApiBoundaryNodeEntry>,
#[prost(message, optional, tag = "24")]
pub own_resource_limits:
::core::option::Option<super::super::super::registry::subnet::v1::ResourceLimits>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct StableMemory {
Expand Down
1 change: 1 addition & 0 deletions rs/replicated_state/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ rust_library(
"//rs/monitoring/metrics",
"//rs/phantom_newtype",
"//rs/protobuf",
"//rs/registry/resource_limits",
"//rs/registry/routing_table",
"//rs/registry/subnet_features",
"//rs/registry/subnet_type",
Expand Down
1 change: 1 addition & 0 deletions rs/replicated_state/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ ic-logger = { path = "../monitoring/logger" }
ic-management-canister-types-private = { path = "../types/management_canister_types" }
ic-metrics = { path = "../monitoring/metrics" }
ic-protobuf = { path = "../protobuf" }
ic-registry-resource-limits = { path = "../registry/resource_limits" }
ic-registry-routing-table = { path = "../registry/routing_table" }
ic-registry-subnet-features = { path = "../registry/subnet_features" }
ic-registry-subnet-type = { path = "../registry/subnet_type" }
Expand Down
9 changes: 9 additions & 0 deletions rs/replicated_state/src/metadata_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use ic_limits::MAX_INGRESS_TTL;
use ic_management_canister_types_private::{
IC_00, MasterPublicKeyId, NodeMetrics, NodeMetricsHistoryResponse,
};
use ic_registry_resource_limits::ResourceLimits;
use ic_registry_routing_table::{
CANISTER_IDS_PER_SUBNET, CanisterIdRanges, CanisterMigrations, RoutingTable,
canister_id_into_u64, difference, intersection,
Expand Down Expand Up @@ -94,6 +95,8 @@ pub struct SystemMetadata {

pub own_subnet_features: SubnetFeatures,

pub own_resource_limits: ResourceLimits,

/// DER-encoded public keys of the subnet's nodes.
pub node_public_keys: BTreeMap<NodeId, Vec<u8>>,

Expand Down Expand Up @@ -442,6 +445,7 @@ impl SystemMetadata {
network_topology: Default::default(),
subnet_call_context_manager: Default::default(),
own_subnet_features: SubnetFeatures::default(),
own_resource_limits: Default::default(),
node_public_keys: Default::default(),
api_boundary_nodes: Default::default(),
split_from: None,
Expand Down Expand Up @@ -734,6 +738,8 @@ impl SystemMetadata {
// Overwritten as soon as the round begins, no explicit action needed.
own_subnet_features: _,
// Overwritten as soon as the round begins, no explicit action needed.
own_resource_limits: _,
// Overwritten as soon as the round begins, no explicit action needed.
node_public_keys: _,
api_boundary_nodes: _,
ref mut split_from,
Expand Down Expand Up @@ -839,6 +845,7 @@ impl SystemMetadata {
own_subnet_id,
own_subnet_type,
own_subnet_features,
own_resource_limits,
node_public_keys,
api_boundary_nodes,
split_from,
Expand Down Expand Up @@ -942,6 +949,7 @@ impl SystemMetadata {
own_subnet_id: subnet_id,
own_subnet_type,
own_subnet_features,
own_resource_limits,
// Already populated from the registry.
node_public_keys,
api_boundary_nodes,
Expand Down Expand Up @@ -2038,6 +2046,7 @@ pub mod testing {
// Covered in `super::subnet_call_context_manager::testing`.
subnet_call_context_manager: Default::default(),
own_subnet_features: SubnetFeatures::default(),
own_resource_limits: Default::default(),
node_public_keys: Default::default(),
api_boundary_nodes: Default::default(),
split_from: None,
Expand Down
Loading
Loading