diff --git a/rs/protobuf/def/registry/standard_engine_replica_version/v1/standard_engine_replica_version.proto b/rs/protobuf/def/registry/standard_engine_replica_version/v1/standard_engine_replica_version.proto new file mode 100644 index 000000000000..e0bd3a95d660 --- /dev/null +++ b/rs/protobuf/def/registry/standard_engine_replica_version/v1/standard_engine_replica_version.proto @@ -0,0 +1,36 @@ +syntax = "proto3"; +package registry.standard_engine_replica_version.v1; + +// The default replica/guestos version that engines run, used when an engine's +// own SubnetRecord.replica_version_id is blank (i.e. the engine has not opted +// out of the standard upgrade train). +message StandardEngineReplicaVersionRecord { + // In general, these are (hex encoded) git commit IDs from the dfinity/ic + // repo, identifying the source code from which Replica was built. (Also known + // as Guest OS versions.) + string new_replica_version_id = 1; + string old_replica_version_id = 2; + + // The (approximate) fraction of engines that should be on + // new_replica_version_id (the rest should be on old_replica_version_id). + // + // Ranges from 0.0 to 1.0 (inclusive). + // + // Engines with "upgrade priority" <= this should take on + // new_replica_version_id. An engine's upgrade priority is a hash whose inputs + // include its own subnet_id, and new_replica_version_id. More precisely, an + // engine's priority is determined as follows: + // + // 1. Compute SHA-256 of the concatenation of + // a. len("upgrade priority"): a single u8 + // b. "upgrade priority": ASCII encoded + // c. new_replica_version_id: hex decoded + // d. the engine's subnet_id: raw bytes + // + // 2. Take the first 8 bytes of that hash, and interpret them as a + // little-endian 64 bit unsigned integer. + // + // 3. Divide that u64 by 2^64 - 1. The result is the engine's upgrade + // priority, a number in [0.0, 1.0]. + double deployment_progress = 3; +} diff --git a/rs/protobuf/generator/src/lib.rs b/rs/protobuf/generator/src/lib.rs index 4e0cc1f9094e..8bb899ff14e0 100644 --- a/rs/protobuf/generator/src/lib.rs +++ b/rs/protobuf/generator/src/lib.rs @@ -282,6 +282,9 @@ fn build_registry_proto(def: &Path, out: &Path) { def.join("registry/node_rewards/v2/node_rewards.proto"), def.join("registry/dc/v1/dc.proto"), def.join("registry/unassigned_nodes_config/v1/unassigned_nodes_config.proto"), + def.join( + "registry/standard_engine_replica_version/v1/standard_engine_replica_version.proto", + ), ]; compile_protos(config, def, ®istry_files); diff --git a/rs/protobuf/src/gen/registry/registry.standard_engine_replica_version.v1.rs b/rs/protobuf/src/gen/registry/registry.standard_engine_replica_version.v1.rs new file mode 100644 index 000000000000..4126066acd22 --- /dev/null +++ b/rs/protobuf/src/gen/registry/registry.standard_engine_replica_version.v1.rs @@ -0,0 +1,37 @@ +// This file is @generated by prost-build. +/// The default replica/guestos version that engines run, used when an engine's +/// own SubnetRecord.replica_version_id is blank (i.e. the engine has not opted +/// out of the standard upgrade train). +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct StandardEngineReplicaVersionRecord { + /// In general, these are (hex encoded) git commit IDs from the dfinity/ic + /// repo, identifying the source code from which Replica was built. (Also known + /// as Guest OS versions.) + #[prost(string, tag = "1")] + pub new_replica_version_id: ::prost::alloc::string::String, + #[prost(string, tag = "2")] + pub old_replica_version_id: ::prost::alloc::string::String, + /// The (approximate) fraction of engines that should be on + /// new_replica_version_id (the rest should be on old_replica_version_id). + /// + /// Ranges from 0.0 to 1.0 (inclusive). + /// + /// Engines with "upgrade priority" \<= this should take on + /// new_replica_version_id. An engine's upgrade priority is a hash whose inputs + /// include its own subnet_id, and new_replica_version_id. More precisely, an + /// engine's priority is determined as follows: + /// + /// 1. Compute SHA-256 of the concatenation of + /// a. len("upgrade priority"): a single u8 + /// b. "upgrade priority": ASCII encoded + /// c. new_replica_version_id: hex decoded + /// d. the engine's subnet_id: raw bytes + /// + /// 1. Take the first 8 bytes of that hash, and interpret them as a + /// little-endian 64 bit unsigned integer. + /// + /// 1. Divide that u64 by 2^64 - 1. The result is the engine's upgrade + /// priority, a number in \[0.0, 1.0\]. + #[prost(double, tag = "3")] + pub deployment_progress: f64, +} diff --git a/rs/protobuf/src/registry.rs b/rs/protobuf/src/registry.rs index fbbcfe8ffcf6..25f6ae839a8e 100644 --- a/rs/protobuf/src/registry.rs +++ b/rs/protobuf/src/registry.rs @@ -10,5 +10,6 @@ pub mod node_rewards; pub mod provisional_whitelist; pub mod replica_version; pub mod routing_table; +pub mod standard_engine_replica_version; pub mod subnet; pub mod unassigned_nodes_config; diff --git a/rs/protobuf/src/registry/standard_engine_replica_version.rs b/rs/protobuf/src/registry/standard_engine_replica_version.rs new file mode 100644 index 000000000000..b5cc491cf12d --- /dev/null +++ b/rs/protobuf/src/registry/standard_engine_replica_version.rs @@ -0,0 +1,3 @@ +#[allow(clippy::all)] +#[path = "../gen/registry/registry.standard_engine_replica_version.v1.rs"] +pub mod v1; diff --git a/rs/registry/keys/src/lib.rs b/rs/registry/keys/src/lib.rs index a475b7e28450..80fd4843e263 100644 --- a/rs/registry/keys/src/lib.rs +++ b/rs/registry/keys/src/lib.rs @@ -26,6 +26,7 @@ pub const ROOT_SUBNET_ID_KEY: &str = "nns_subnet_id"; pub const DEFAULT_INITIAL_DKG_SUBNET_ID_KEY: &str = "default_initial_dkg_subnet_id"; pub const NODE_REWARDS_TABLE_KEY: &str = "node_rewards_table"; const UNASSIGNED_NODES_CONFIG_RECORD_KEY: &str = "unassigned_nodes_config"; +const STANDARD_ENGINE_REPLICA_VERSION_RECORD_KEY: &str = "standard_engine_replica_version"; pub const API_BOUNDARY_NODE_RECORD_KEY_PREFIX: &str = "api_boundary_node_"; pub const NODE_RECORD_KEY_PREFIX: &str = "node_record_"; @@ -92,6 +93,10 @@ pub fn make_unassigned_nodes_config_record_key() -> String { UNASSIGNED_NODES_CONFIG_RECORD_KEY.to_string() } +pub fn make_standard_engine_replica_version_record_key() -> String { + STANDARD_ENGINE_REPLICA_VERSION_RECORD_KEY.to_string() +} + /// Returns the key whose payload is the [`SubnetId`] of the subnet to which /// `SetupInitialDKG` management canister calls are routed by default. pub fn make_default_initial_dkg_subnet_id_key() -> String {