Skip to content

Commit cc1a281

Browse files
feat(registry): Added StandardEngineReplicaVersionRecord proto and corresponding key. (#10774)
This isn't used yet. The plan is, later, this will be used to determine what Replica version engines run. Co-authored-by: Daniel Wong <daniel.wong@dfinity.org>
1 parent 8349230 commit cc1a281

6 files changed

Lines changed: 85 additions & 0 deletions

File tree

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
syntax = "proto3";
2+
package registry.standard_engine_replica_version.v1;
3+
4+
// The default replica/guestos version that engines run, used when an engine's
5+
// own SubnetRecord.replica_version_id is blank (i.e. the engine has not opted
6+
// out of the standard upgrade train).
7+
message StandardEngineReplicaVersionRecord {
8+
// In general, these are (hex encoded) git commit IDs from the dfinity/ic
9+
// repo, identifying the source code from which Replica was built. (Also known
10+
// as Guest OS versions.)
11+
string new_replica_version_id = 1;
12+
string old_replica_version_id = 2;
13+
14+
// The (approximate) fraction of engines that should be on
15+
// new_replica_version_id (the rest should be on old_replica_version_id).
16+
//
17+
// Ranges from 0.0 to 1.0 (inclusive).
18+
//
19+
// Engines with "upgrade priority" <= this should take on
20+
// new_replica_version_id. An engine's upgrade priority is a hash whose inputs
21+
// include its own subnet_id, and new_replica_version_id. More precisely, an
22+
// engine's priority is determined as follows:
23+
//
24+
// 1. Compute SHA-256 of the concatenation of
25+
// a. len("upgrade priority"): a single u8
26+
// b. "upgrade priority": ASCII encoded
27+
// c. new_replica_version_id: hex decoded
28+
// d. the engine's subnet_id: raw bytes
29+
//
30+
// 2. Take the first 8 bytes of that hash, and interpret them as a
31+
// little-endian 64 bit unsigned integer.
32+
//
33+
// 3. Divide that u64 by 2^64 - 1. The result is the engine's upgrade
34+
// priority, a number in [0.0, 1.0].
35+
double deployment_progress = 3;
36+
}

rs/protobuf/generator/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,9 @@ fn build_registry_proto(def: &Path, out: &Path) {
282282
def.join("registry/node_rewards/v2/node_rewards.proto"),
283283
def.join("registry/dc/v1/dc.proto"),
284284
def.join("registry/unassigned_nodes_config/v1/unassigned_nodes_config.proto"),
285+
def.join(
286+
"registry/standard_engine_replica_version/v1/standard_engine_replica_version.proto",
287+
),
285288
];
286289

287290
compile_protos(config, def, &registry_files);
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// This file is @generated by prost-build.
2+
/// The default replica/guestos version that engines run, used when an engine's
3+
/// own SubnetRecord.replica_version_id is blank (i.e. the engine has not opted
4+
/// out of the standard upgrade train).
5+
#[derive(Clone, PartialEq, ::prost::Message)]
6+
pub struct StandardEngineReplicaVersionRecord {
7+
/// In general, these are (hex encoded) git commit IDs from the dfinity/ic
8+
/// repo, identifying the source code from which Replica was built. (Also known
9+
/// as Guest OS versions.)
10+
#[prost(string, tag = "1")]
11+
pub new_replica_version_id: ::prost::alloc::string::String,
12+
#[prost(string, tag = "2")]
13+
pub old_replica_version_id: ::prost::alloc::string::String,
14+
/// The (approximate) fraction of engines that should be on
15+
/// new_replica_version_id (the rest should be on old_replica_version_id).
16+
///
17+
/// Ranges from 0.0 to 1.0 (inclusive).
18+
///
19+
/// Engines with "upgrade priority" \<= this should take on
20+
/// new_replica_version_id. An engine's upgrade priority is a hash whose inputs
21+
/// include its own subnet_id, and new_replica_version_id. More precisely, an
22+
/// engine's priority is determined as follows:
23+
///
24+
/// 1. Compute SHA-256 of the concatenation of
25+
/// a. len("upgrade priority"): a single u8
26+
/// b. "upgrade priority": ASCII encoded
27+
/// c. new_replica_version_id: hex decoded
28+
/// d. the engine's subnet_id: raw bytes
29+
///
30+
/// 1. Take the first 8 bytes of that hash, and interpret them as a
31+
/// little-endian 64 bit unsigned integer.
32+
///
33+
/// 1. Divide that u64 by 2^64 - 1. The result is the engine's upgrade
34+
/// priority, a number in \[0.0, 1.0\].
35+
#[prost(double, tag = "3")]
36+
pub deployment_progress: f64,
37+
}

rs/protobuf/src/registry.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@ pub mod node_rewards;
1010
pub mod provisional_whitelist;
1111
pub mod replica_version;
1212
pub mod routing_table;
13+
pub mod standard_engine_replica_version;
1314
pub mod subnet;
1415
pub mod unassigned_nodes_config;
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#[allow(clippy::all)]
2+
#[path = "../gen/registry/registry.standard_engine_replica_version.v1.rs"]
3+
pub mod v1;

rs/registry/keys/src/lib.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ pub const ROOT_SUBNET_ID_KEY: &str = "nns_subnet_id";
2626
pub const DEFAULT_INITIAL_DKG_SUBNET_ID_KEY: &str = "default_initial_dkg_subnet_id";
2727
pub const NODE_REWARDS_TABLE_KEY: &str = "node_rewards_table";
2828
const UNASSIGNED_NODES_CONFIG_RECORD_KEY: &str = "unassigned_nodes_config";
29+
const STANDARD_ENGINE_REPLICA_VERSION_RECORD_KEY: &str = "standard_engine_replica_version";
2930

3031
pub const API_BOUNDARY_NODE_RECORD_KEY_PREFIX: &str = "api_boundary_node_";
3132
pub const NODE_RECORD_KEY_PREFIX: &str = "node_record_";
@@ -92,6 +93,10 @@ pub fn make_unassigned_nodes_config_record_key() -> String {
9293
UNASSIGNED_NODES_CONFIG_RECORD_KEY.to_string()
9394
}
9495

96+
pub fn make_standard_engine_replica_version_record_key() -> String {
97+
STANDARD_ENGINE_REPLICA_VERSION_RECORD_KEY.to_string()
98+
}
99+
95100
/// Returns the key whose payload is the [`SubnetId`] of the subnet to which
96101
/// `SetupInitialDKG` management canister calls are routed by default.
97102
pub fn make_default_initial_dkg_subnet_id_key() -> String {

0 commit comments

Comments
 (0)