Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(node): Add node reward type update-config parsing #3132

Merged
merged 3 commits into from
Dec 13, 2024
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
4 changes: 1 addition & 3 deletions rs/ic_os/config/src/generate_testnet_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,6 @@ fn create_guestos_config(config: GenerateTestnetConfigArgs) -> Result<GuestOSCon
};

// Construct ICOSSettings
let node_reward_type = node_reward_type.unwrap_or_else(|| "type3.1".to_string());

let mgmt_mac = match mgmt_mac {
Some(mac) => mac,
// Use a dummy MAC address
Expand Down Expand Up @@ -191,7 +189,7 @@ fn create_guestos_config(config: GenerateTestnetConfigArgs) -> Result<GuestOSCon
let use_ssh_authorized_keys = use_ssh_authorized_keys.unwrap_or(true);

let icos_settings = ICOSSettings {
node_reward_type: Some(node_reward_type),
node_reward_type,
mgmt_mac,
deployment_environment,
logging,
Expand Down
12 changes: 11 additions & 1 deletion rs/ic_os/config/src/update_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ pub fn update_guestos_config() -> Result<()> {
let hostname = network_config_result.hostname.clone();

let nns_urls = read_nns_conf(config_dir)?;
let node_reward_type = read_reward_conf(config_dir)?;

let use_nns_public_key = state_root.join("nns_public_key.pem").exists();
let use_node_operator_private_key =
Expand All @@ -45,7 +46,7 @@ pub fn update_guestos_config() -> Result<()> {
let deployment_environment = DeploymentEnvironment::Mainnet;

let icos_settings = ICOSSettings {
node_reward_type: None,
node_reward_type,
mgmt_mac,
deployment_environment,
logging: Logging::default(),
Expand Down Expand Up @@ -174,6 +175,15 @@ fn read_nns_conf(config_dir: &Path) -> Result<Vec<Url>> {
Ok(nns_urls)
}

fn read_reward_conf(config_dir: &Path) -> Result<Option<String>> {
let reward_conf_path = config_dir.join("reward.conf");
let conf_map = read_conf_file(&reward_conf_path)?;

let node_reward_type = conf_map.get("node_reward_type").cloned();

Ok(node_reward_type)
}

fn derive_mgmt_mac_from_hostname(hostname: Option<&str>) -> Result<MacAddr6> {
if let Some(hostname) = hostname {
if let Some(unformatted_mac) = hostname.strip_prefix("guest-") {
Expand Down
2 changes: 1 addition & 1 deletion rs/ic_os/config_types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ mod tests {
domain_name: None,
},
icos_settings: ICOSSettings {
node_reward_type: Some(String::new()),
node_reward_type: None,
mgmt_mac: "00:00:00:00:00:00".parse()?,
deployment_environment: DeploymentEnvironment::Testnet,
logging: Logging::default(),
Expand Down
Loading