Skip to content

Commit

Permalink
rename field
Browse files Browse the repository at this point in the history
  • Loading branch information
max-dfinity committed Oct 15, 2024
1 parent 363d198 commit 67f1c34
Show file tree
Hide file tree
Showing 12 changed files with 26 additions and 23 deletions.
2 changes: 1 addition & 1 deletion rs/nns/test_utils/src/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -833,7 +833,7 @@ pub fn prepare_add_node_payload(mutation_id: u8) -> (AddNodePayload, ValidNodePu
// Unused section follows
p2p_flow_endpoints: Default::default(),
prometheus_metrics_endpoint: Default::default(),
node_type: None,
node_reward_type: None,
};

(payload, node_public_keys)
Expand Down
2 changes: 1 addition & 1 deletion rs/orchestrator/src/firewall.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1037,7 +1037,7 @@ mod tests {
hostos_version_id: None,
public_ipv4_config: None,
domain: None,
node_type: None,
node_reward_type: None,
}),
)
.expect("Failed to add node record.");
Expand Down
2 changes: 1 addition & 1 deletion rs/orchestrator/src/registration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ impl NodeRegistration {
// Unused section follows
p2p_flow_endpoints: Default::default(),
prometheus_metrics_endpoint: Default::default(),
node_type: None,
node_reward_type: None,
}
}

Expand Down
2 changes: 1 addition & 1 deletion rs/prep/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ mod node_configuration {
chip_id: None,
public_ipv4_config: None,
domain: None,
node_type: None,
node_reward_type: None,
};

assert_eq!(got, want);
Expand Down
2 changes: 1 addition & 1 deletion rs/protobuf/def/registry/node/v1/node.proto
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ message NodeRecord {
// If a Node is to be converted into the ApiBoundaryNode, the domain field should be set.
optional string domain = 19;

optional NodeRewardType node_type = 20;
optional NodeRewardType node_reward_type = 20;

reserved 1, 2, 3, 4, 7, 8, 9, 10, 11, 12, 13, 14;
reserved "node_id";
Expand Down
2 changes: 1 addition & 1 deletion rs/protobuf/src/gen/registry/registry.node.v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ pub struct NodeRecord {
#[prost(string, optional, tag = "19")]
pub domain: ::core::option::Option<::prost::alloc::string::String>,
#[prost(enumeration = "NodeRewardType", optional, tag = "20")]
pub node_type: ::core::option::Option<i32>,
pub node_reward_type: ::core::option::Option<i32>,
}
/// The type of the node.
#[derive(
Expand Down
6 changes: 3 additions & 3 deletions rs/registry/canister/api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,10 @@ pub struct AddNodePayload {
pub p2p_flow_endpoints: Vec<String>,
pub prometheus_metrics_endpoint: String,

// String representation of the node type. Must be a valid type.
// See registry/canister/src/mutations/do_add_node.rs, fn `try_str_to_node_type` for currently
// String representation of the node reward type. Must be a valid type.
// See registry/canister/src/mutations/do_add_node.rs, fn `validate_str_as_node_reward_type` for currently
// accepted types.
pub node_type: Option<String>,
pub node_reward_type: Option<String>,
}

/// The payload of a request to update keys of the existing node.
Expand Down
2 changes: 1 addition & 1 deletion rs/registry/canister/canister/registry.did
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ type AddNodePayload = record {
transport_tls_cert : blob;
ni_dkg_dealing_encryption_pk : blob;
p2p_flow_endpoints : vec text;
node_type : opt text;
node_reward_type : opt text;
};

type AddNodesToSubnetPayload = record {
Expand Down
2 changes: 1 addition & 1 deletion rs/registry/canister/src/invariants/firewall.rs
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ mod tests {
chip_id: None,
public_ipv4_config: None,
domain: None,
node_type: None,
node_reward_type: None,
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,19 +77,19 @@ impl Registry {
}

// 3. Get valid type if type is in request
let node_type = payload
.node_type
let node_reward_type = payload
.node_reward_type
.as_ref()
.map(|t| {
validate_str_as_node_type(t).map_err(|e| {
validate_str_as_node_reward_type(t).map_err(|e| {
format!(
"{}do_add_node: Error parsing node type from payload: {}",
LOG_PREFIX, e
)
})
})
.transpose()?
.map(|node_type| node_type as i32);
.map(|node_reward_type| node_reward_type as i32);

// 4. Validate keys and get the node id
let (node_id, valid_pks) = valid_keys_from_payload(&payload)
Expand Down Expand Up @@ -138,7 +138,7 @@ impl Registry {
chip_id: payload.chip_id.clone(),
public_ipv4_config: ipv4_intf_config,
domain,
node_type,
node_reward_type,
};

// 8. Insert node, public keys, and crypto keys
Expand All @@ -163,7 +163,7 @@ impl Registry {

// try to convert input string into NodeRewardType enum
// If a type is no longer supported for newly registered nodes, it should be removed from this function
fn validate_str_as_node_type<T: AsRef<str> + Display>(
fn validate_str_as_node_reward_type<T: AsRef<str> + Display>(
type_string: T,
) -> Result<NodeRewardType, String> {
Ok(match type_string.as_ref() {
Expand Down Expand Up @@ -334,7 +334,7 @@ mod tests {
// Unused section follows
p2p_flow_endpoints: Default::default(),
prometheus_metrics_endpoint: Default::default(),
node_type: None,
node_reward_type: None,
};

(payload, node_public_keys)
Expand Down Expand Up @@ -373,7 +373,7 @@ mod tests {
// Unused section follows
p2p_flow_endpoints: Default::default(),
prometheus_metrics_endpoint: Default::default(),
node_type: None,
node_reward_type: None,
};
}

Expand Down
9 changes: 6 additions & 3 deletions rs/registry/canister/tests/add_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ fn node_is_created_on_receiving_the_request() {
.await;

let (mut payload, node_pks) = prepare_add_node_payload(1);
payload.node_type = Some("type3".to_string());
payload.node_reward_type = Some("type3".to_string());
let node_id = node_pks.node_id();

// Then, ensure there is no value for the node
Expand All @@ -59,7 +59,10 @@ fn node_is_created_on_receiving_the_request() {
// Check if some fields are present
assert!(node_record.is_some());
let node_record = node_record.unwrap();
assert_eq!(node_record.node_type, Some(NodeRewardType::Type3 as i32));
assert_eq!(
node_record.node_reward_type,
Some(NodeRewardType::Type3 as i32)
);

// Check that other fields are present
let node_signing_pubkey_record = get_node_signing_key(&registry, node_id).await.unwrap();
Expand Down Expand Up @@ -113,7 +116,7 @@ fn node_is_not_created_with_invalid_type() {
.await;

let (mut payload, node_pks) = prepare_add_node_payload(1);
payload.node_type = Some("type0.11".to_string());
payload.node_reward_type = Some("type0.11".to_string());
let node_id = node_pks.node_id();

// Then, ensure there is no value for the node
Expand Down
2 changes: 1 addition & 1 deletion rs/state_machine_tests/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ fn make_nodes_registry(
chip_id: None,
public_ipv4_config: None,
domain: None,
node_type: None,
node_reward_type: None,
};
registry_data_provider
.add(
Expand Down

0 comments on commit 67f1c34

Please sign in to comment.