From 4417be7238be526c1126ccdcc7d4a065e63e9b64 Mon Sep 17 00:00:00 2001 From: nikolamilosa Date: Fri, 30 Aug 2024 18:24:27 +0200 Subject: [PATCH 1/5] renaming and adding a trait --- rs/cli/src/commands/api_boundary_nodes/add.rs | 2 +- .../src/commands/api_boundary_nodes/remove.rs | 2 +- .../src/commands/api_boundary_nodes/update.rs | 2 +- rs/cli/src/commands/firewall.rs | 8 +- rs/cli/src/commands/get.rs | 2 + rs/cli/src/commands/neuron/balance.rs | 4 +- rs/cli/src/commands/neuron/refresh.rs | 4 +- rs/cli/src/commands/neuron/top_up.rs | 6 +- rs/cli/src/commands/propose.rs | 2 + rs/cli/src/commands/qualify/execute.rs | 1 + .../src/commands/update_authorized_subnets.rs | 2 +- rs/cli/src/commands/vote.rs | 4 +- rs/cli/src/ctx.rs | 18 +- rs/cli/src/ic_admin.rs | 419 ++++++++++-------- .../qualification/ensure_blessed_versions.rs | 2 +- .../qualification/retire_blessed_versions.rs | 2 +- rs/cli/src/qualification/upgrade_subnets.rs | 2 +- rs/cli/src/runner.rs | 25 +- rs/rollout-controller/src/actions/mod.rs | 8 +- 19 files changed, 277 insertions(+), 238 deletions(-) diff --git a/rs/cli/src/commands/api_boundary_nodes/add.rs b/rs/cli/src/commands/api_boundary_nodes/add.rs index cdda19e7c..71fb1aa09 100644 --- a/rs/cli/src/commands/api_boundary_nodes/add.rs +++ b/rs/cli/src/commands/api_boundary_nodes/add.rs @@ -3,7 +3,7 @@ use ic_types::PrincipalId; use crate::{ commands::{ExecutableCommand, IcAdminRequirement}, - ic_admin, + ic_admin::{self, IcAdmin}, }; #[derive(Args, Debug)] diff --git a/rs/cli/src/commands/api_boundary_nodes/remove.rs b/rs/cli/src/commands/api_boundary_nodes/remove.rs index 2923b5d0f..91922243d 100644 --- a/rs/cli/src/commands/api_boundary_nodes/remove.rs +++ b/rs/cli/src/commands/api_boundary_nodes/remove.rs @@ -3,7 +3,7 @@ use ic_types::PrincipalId; use crate::{ commands::{ExecutableCommand, IcAdminRequirement}, - ic_admin, + ic_admin::{self, IcAdmin}, }; #[derive(Args, Debug)] diff --git a/rs/cli/src/commands/api_boundary_nodes/update.rs b/rs/cli/src/commands/api_boundary_nodes/update.rs index 18a443bd2..866983a84 100644 --- a/rs/cli/src/commands/api_boundary_nodes/update.rs +++ b/rs/cli/src/commands/api_boundary_nodes/update.rs @@ -3,7 +3,7 @@ use ic_types::PrincipalId; use crate::{ commands::{ExecutableCommand, IcAdminRequirement}, - ic_admin, + ic_admin::{self, IcAdmin}, }; #[derive(Args, Debug)] diff --git a/rs/cli/src/commands/firewall.rs b/rs/cli/src/commands/firewall.rs index 8d22db019..e94dcd7b9 100644 --- a/rs/cli/src/commands/firewall.rs +++ b/rs/cli/src/commands/firewall.rs @@ -13,7 +13,7 @@ use log::{info, warn}; use serde::Serialize; use tempfile::NamedTempFile; -use crate::ic_admin::{IcAdminWrapper, ProposeCommand, ProposeOptions}; +use crate::ic_admin::{IcAdmin, IcAdminImpl, ProposeCommand, ProposeOptions}; use super::{ExecutableCommand, IcAdminRequirement}; @@ -119,7 +119,7 @@ impl ExecutableCommand for Firewall { impl Firewall { async fn submit_proposal( - admin_wrapper: Arc, + admin: Arc, modifications: Vec, propose_options: ProposeOptions, firewall_rules_scope: &FirewallRulesScope, @@ -156,7 +156,7 @@ impl Firewall { args: test_args.clone(), }; - let output = admin_wrapper + let output = admin .propose_run(cmd, propose_options.clone()) .await .map_err(|e| anyhow::anyhow!("Couldn't execute test for {}-firewall-rules: {:?}", change_type, e))?; @@ -185,7 +185,7 @@ impl Firewall { command: format!("{}-firewall-rules", change_type), args: final_args, }; - let _ = admin_wrapper.propose_run(cmd, propose_options.clone()).await?; + let _ = admin.propose_run(cmd, propose_options.clone()).await?; Ok(()) } } diff --git a/rs/cli/src/commands/get.rs b/rs/cli/src/commands/get.rs index 74c83509e..03c764d89 100644 --- a/rs/cli/src/commands/get.rs +++ b/rs/cli/src/commands/get.rs @@ -1,5 +1,7 @@ use clap::Args; +use crate::ic_admin::IcAdmin; + use super::{ExecutableCommand, IcAdminRequirement}; #[derive(Args, Debug)] diff --git a/rs/cli/src/commands/neuron/balance.rs b/rs/cli/src/commands/neuron/balance.rs index d7ffea14e..21ca9278e 100644 --- a/rs/cli/src/commands/neuron/balance.rs +++ b/rs/cli/src/commands/neuron/balance.rs @@ -1,7 +1,7 @@ use clap::Args; use ic_canisters::governance::GovernanceCanisterWrapper; -use crate::commands::ExecutableCommand; +use crate::{commands::ExecutableCommand, ic_admin::IcAdmin}; #[derive(Args, Debug)] pub struct Balance { @@ -23,7 +23,7 @@ impl ExecutableCommand for Balance { async fn execute(&self, ctx: crate::ctx::DreContext) -> anyhow::Result<()> { let governance = GovernanceCanisterWrapper::from(ctx.create_canister_client()?); let neuron_info = governance - .get_neuron_info(self.neuron.unwrap_or_else(|| ctx.ic_admin().neuron.neuron_id)) + .get_neuron_info(self.neuron.unwrap_or_else(|| ctx.ic_admin().neuron().neuron_id)) .await?; println!("{}", neuron_info.stake_e8s / 10_u64.pow(8)); diff --git a/rs/cli/src/commands/neuron/refresh.rs b/rs/cli/src/commands/neuron/refresh.rs index ddb8aa037..14a23344b 100644 --- a/rs/cli/src/commands/neuron/refresh.rs +++ b/rs/cli/src/commands/neuron/refresh.rs @@ -1,7 +1,7 @@ use clap::Args; use ic_canisters::governance::GovernanceCanisterWrapper; -use crate::commands::ExecutableCommand; +use crate::{commands::ExecutableCommand, ic_admin::IcAdmin}; #[derive(Args, Debug)] pub struct Refresh {} @@ -16,7 +16,7 @@ impl ExecutableCommand for Refresh { async fn execute(&self, ctx: crate::ctx::DreContext) -> anyhow::Result<()> { let governance_canister = GovernanceCanisterWrapper::from(ctx.create_canister_client()?); - let resp = governance_canister.refresh_neuron(ctx.ic_admin().neuron.neuron_id).await?; + let resp = governance_canister.refresh_neuron(ctx.ic_admin().neuron().neuron_id).await?; println!("{:?}", resp); Ok(()) diff --git a/rs/cli/src/commands/neuron/top_up.rs b/rs/cli/src/commands/neuron/top_up.rs index 2f448e39f..d0dd37f49 100644 --- a/rs/cli/src/commands/neuron/top_up.rs +++ b/rs/cli/src/commands/neuron/top_up.rs @@ -2,7 +2,7 @@ use clap::Args; use ic_canisters::governance::GovernanceCanisterWrapper; use itertools::Itertools; -use crate::commands::ExecutableCommand; +use crate::{commands::ExecutableCommand, ic_admin::IcAdmin}; #[derive(Args, Debug)] pub struct TopUp {} @@ -16,14 +16,14 @@ impl ExecutableCommand for TopUp { async fn execute(&self, ctx: crate::ctx::DreContext) -> anyhow::Result<()> { let governance = GovernanceCanisterWrapper::from(ctx.create_canister_client()?); - let full_neuron = governance.get_full_neuron(ctx.ic_admin().neuron.neuron_id).await?; + let full_neuron = governance.get_full_neuron(ctx.ic_admin().neuron().neuron_id).await?; let account_hex = full_neuron.account.iter().map(|byte| format!("{:02x}", byte)).join(""); println!("Please request ICP in the #icp-to-go slack channel:"); println!( "> Hi! Can I please get XX ICPs on the account address `{}` for neuron ID {} in order to be able to submit more NNS proposals. Thank you\n", account_hex, - ctx.ic_admin().neuron.neuron_id + ctx.ic_admin().neuron().neuron_id ); println!("You can check balance by running `dre neuron balance`"); diff --git a/rs/cli/src/commands/propose.rs b/rs/cli/src/commands/propose.rs index c79401927..7fb6653ea 100644 --- a/rs/cli/src/commands/propose.rs +++ b/rs/cli/src/commands/propose.rs @@ -1,5 +1,7 @@ use clap::Args; +use crate::ic_admin::IcAdmin; + use super::{ExecutableCommand, IcAdminRequirement}; #[derive(Args, Debug)] diff --git a/rs/cli/src/commands/qualify/execute.rs b/rs/cli/src/commands/qualify/execute.rs index 53dcfbbb6..40f7d1021 100644 --- a/rs/cli/src/commands/qualify/execute.rs +++ b/rs/cli/src/commands/qualify/execute.rs @@ -6,6 +6,7 @@ use serde_json::Value; use crate::{ commands::{ExecutableCommand, IcAdminRequirement}, + ic_admin::IcAdmin, qualification::QualificationExecutorBuilder, }; diff --git a/rs/cli/src/commands/update_authorized_subnets.rs b/rs/cli/src/commands/update_authorized_subnets.rs index 57fa8c4b7..fa25340e5 100644 --- a/rs/cli/src/commands/update_authorized_subnets.rs +++ b/rs/cli/src/commands/update_authorized_subnets.rs @@ -7,7 +7,7 @@ use ic_types::PrincipalId; use itertools::Itertools; use log::info; -use crate::ic_admin::{ProposeCommand, ProposeOptions}; +use crate::ic_admin::{IcAdmin, ProposeCommand, ProposeOptions}; use super::ExecutableCommand; diff --git a/rs/cli/src/commands/vote.rs b/rs/cli/src/commands/vote.rs index a66fe3cee..68aae88b2 100644 --- a/rs/cli/src/commands/vote.rs +++ b/rs/cli/src/commands/vote.rs @@ -8,7 +8,7 @@ use log::info; use spinners::{Spinner, Spinners}; use super::{ExecutableCommand, IcAdminRequirement}; -use crate::desktop_notify::DesktopNotifier; +use crate::{desktop_notify::DesktopNotifier, ic_admin::IcAdmin}; #[derive(Args, Debug)] pub struct Vote { @@ -78,7 +78,7 @@ impl ExecutableCommand for Vote { ), ); - let response = match client.register_vote(ctx.ic_admin().neuron.neuron_id, proposal.id.unwrap().id).await { + let response = match client.register_vote(ctx.ic_admin().neuron().neuron_id, proposal.id.unwrap().id).await { Ok(response) => format!("Voted successfully: {}", response), Err(e) => { DesktopNotifier::send_critical( diff --git a/rs/cli/src/ctx.rs b/rs/cli/src/ctx.rs index 96b21f4e5..48e1f564b 100644 --- a/rs/cli/src/ctx.rs +++ b/rs/cli/src/ctx.rs @@ -20,7 +20,7 @@ use log::info; use crate::{ auth::Neuron, commands::{Args, ExecutableCommand, IcAdminRequirement}, - ic_admin::{download_ic_admin, should_update_ic_admin, IcAdminWrapper}, + ic_admin::{download_ic_admin, should_update_ic_admin, IcAdmin, IcAdminImpl}, runner::Runner, subnet_manager::SubnetManager, }; @@ -30,7 +30,7 @@ const STAGING_NEURON_ID: u64 = 49; pub struct DreContext { network: Network, registry: RefCell>>, - ic_admin: Option>, + ic_admin: Option>, runner: RefCell>>, verbose_runner: bool, skip_sync: bool, @@ -98,7 +98,7 @@ impl DreContext { proceed_without_confirmation: bool, dry_run: bool, requirement: IcAdminRequirement, - ) -> anyhow::Result<(Option>, Option)> { + ) -> anyhow::Result<(Option>, Option)> { if let IcAdminRequirement::None = requirement { return Ok((None, None)); } @@ -138,7 +138,7 @@ impl DreContext { (false, s) => s, }; - let ic_admin = Some(Arc::new(IcAdminWrapper::new( + let ic_admin = Some(Arc::new(IcAdminImpl::new( network.clone(), Some(ic_admin_path.clone()), proceed_without_confirmation, @@ -176,7 +176,7 @@ impl DreContext { let nns_url = self.network.get_nns_urls().first().expect("Should have at least one NNS url"); match &self.ic_admin { - Some(a) => match &a.neuron.auth { + Some(a) => match &a.neuron().auth { crate::auth::Auth::Hsm { pin, slot, key_id } => CanisterClient::from_hsm(pin.clone(), *slot, key_id.clone(), nns_url), crate::auth::Auth::Keyfile { path } => CanisterClient::from_key_file(path.clone(), nns_url), crate::auth::Auth::Anonymous => CanisterClient::from_anonymous(nns_url), @@ -189,7 +189,7 @@ impl DreContext { pub fn create_ic_agent_canister_client(&self, lock: Option>) -> anyhow::Result { let nns_url = self.network.get_nns_urls().first().expect("Should have at least one NNS url"); match &self.ic_admin { - Some(a) => match &a.neuron.auth { + Some(a) => match &a.neuron().auth { crate::auth::Auth::Hsm { pin, slot, key_id } => { IcAgentCanisterClient::from_hsm(pin.to_string(), *slot, key_id.to_string(), nns_url.to_owned(), lock) } @@ -200,15 +200,15 @@ impl DreContext { } } - pub fn ic_admin(&self) -> Arc { + pub fn ic_admin(&self) -> Arc { match &self.ic_admin { Some(a) => a.clone(), None => panic!("This command is not configured to use ic admin"), } } - pub fn readonly_ic_admin_for_other_network(&self, network: Network) -> IcAdminWrapper { - IcAdminWrapper::new(network, self.ic_admin_path.clone(), true, Neuron::anonymous_neuron(), false) + pub fn readonly_ic_admin_for_other_network(&self, network: Network) -> IcAdminImpl { + IcAdminImpl::new(network, self.ic_admin_path.clone(), true, Neuron::anonymous_neuron(), false) } pub async fn subnet_manager(&self) -> SubnetManager { diff --git a/rs/cli/src/ic_admin.rs b/rs/cli/src/ic_admin.rs index e13d9ffa4..8ef259886 100644 --- a/rs/cli/src/ic_admin.rs +++ b/rs/cli/src/ic_admin.rs @@ -3,6 +3,7 @@ use anyhow::{anyhow, Result}; use colored::Colorize; use dialoguer::Confirm; use flate2::read::GzDecoder; +use futures::future::BoxFuture; use futures::stream::{self, StreamExt}; use ic_base_types::PrincipalId; use ic_management_types::{Artifact, Network}; @@ -57,16 +58,237 @@ impl UpdateVersion { } } +pub trait IcAdmin: Send + Sync { + fn neuron(&self) -> Neuron; + + fn propose_run<'a>(&'a self, cmd: ProposeCommand, opts: ProposeOptions) -> BoxFuture<'a, anyhow::Result>; + + fn run<'a>(&'a self, command: &'a str, args: &'a [String], silent: bool) -> BoxFuture<'a, anyhow::Result>; + + fn grep_subcommand_arguments(&self, subcommand: &str) -> String; + + fn run_passthrough_get<'a>(&'a self, args: &'a [String], silent: bool) -> BoxFuture<'a, anyhow::Result>; + + fn run_passthrough_propose<'a>(&'a self, args: &'a [String]) -> BoxFuture<'a, anyhow::Result>; + + fn prepare_to_propose_to_revise_elected_versions<'a>( + &'a self, + release_artifact: &'a Artifact, + version: &'a String, + release_tag: &'a String, + force: bool, + retire_versions: Option>, + ) -> BoxFuture<'a, anyhow::Result>; +} + #[derive(Clone)] -pub struct IcAdminWrapper { +pub struct IcAdminImpl { network: Network, ic_admin_bin_path: Option, proceed_without_confirmation: bool, - pub neuron: Neuron, + neuron: Neuron, dry_run: bool, } -impl IcAdminWrapper { +impl IcAdmin for IcAdminImpl { + fn neuron(&self) -> Neuron { + self.neuron.clone() + } + + fn propose_run<'a>(&'a self, cmd: ProposeCommand, opts: ProposeOptions) -> BoxFuture<'a, anyhow::Result> { + Box::pin(async move { self.propose_run_inner(cmd, opts, self.dry_run).await }) + } + + fn run<'a>(&'a self, command: &'a str, args: &'a [String], silent: bool) -> BoxFuture<'a, anyhow::Result> { + let ic_admin_args = [&[command.to_string()], args].concat(); + Box::pin(async move { self._run_ic_admin_with_args(&ic_admin_args, silent).await }) + } + + fn grep_subcommand_arguments(&self, subcommand: &str) -> String { + let ic_admin_path = self.ic_admin_bin_path.clone().unwrap_or_else(|| "ic-admin".to_string()); + let cmd_result = Command::new(ic_admin_path).args([subcommand, "--help"]).output(); + match cmd_result.map_err(|e| e.to_string()) { + Ok(output) => { + if output.status.success() { + String::from_utf8_lossy(output.stdout.as_ref()).to_string() + } else { + error!("Execution of ic-admin failed: {}", String::from_utf8_lossy(output.stderr.as_ref())); + String::new() + } + } + Err(err) => { + error!("Error starting ic-admin process: {}", err); + String::new() + } + } + } + + /// Run an `ic-admin get-*` command directly, and without an HSM + fn run_passthrough_get<'a>(&'a self, args: &'a [String], silent: bool) -> BoxFuture<'a, anyhow::Result> { + if args.is_empty() { + println!("List of available ic-admin 'get' sub-commands:\n"); + for subcmd in self.grep_subcommands(r"\s+get-(.+?)\s") { + println!("\t{}", subcmd) + } + std::process::exit(1); + } + + // The `get` subcommand of the cli expects that "get-" prefix is not provided as + // the ic-admin command + let args = if args[0].starts_with("get-") { + // The user did provide the "get-" prefix, so let's just keep it and use it. + // This provides a convenient backward compatibility with ic-admin commands + // i.e., `dre get get-subnet 0` still works, although `dre get + // subnet 0` is preferred + args.to_vec() + } else { + // But since ic-admin expects these commands to include the "get-" prefix, we + // need to add it back Example: + // `dre get subnet 0` becomes + // `ic-admin --nns-url "http://[2600:3000:6100:200:5000:b0ff:fe8e:6b7b]:8080" get-subnet 0` + let mut args_with_get_prefix = vec![String::from("get-") + args[0].as_str()]; + args_with_get_prefix.extend_from_slice(args.split_at(1).1); + args_with_get_prefix + }; + + Box::pin(async move { self.run(&args[0], &args.iter().skip(1).cloned().collect::>(), silent).await }) + } + + /// Run an `ic-admin propose-to-*` command directly + fn run_passthrough_propose<'a>(&'a self, args: &'a [String]) -> BoxFuture<'a, anyhow::Result> { + if args.is_empty() { + println!("List of available ic-admin 'propose' sub-commands:\n"); + for subcmd in self.grep_subcommands(r"\s+propose-to-(.+?)\s") { + println!("\t{}", subcmd) + } + std::process::exit(1); + } + + // The `propose` subcommand of the cli expects that "propose-to-" prefix is not + // provided as the ic-admin command + let args = if args[0].starts_with("propose-to-") { + // The user did provide the "propose-to-" prefix, so let's just keep it and use + // it. + args.to_vec() + } else { + // But since ic-admin expects these commands to include the "propose-to-" + // prefix, we need to add it back. + let mut args_with_fixed_prefix = vec![String::from("propose-to-") + args[0].as_str()]; + args_with_fixed_prefix.extend_from_slice(args.split_at(1).1); + args_with_fixed_prefix + }; + + // ic-admin expects --summary and not --motivation + // make sure the expected argument is provided + let args = if !args.contains(&String::from("--summary")) && args.contains(&String::from("--motivation")) { + args.iter() + .map(|arg| if arg == "--motivation" { "--summary".to_string() } else { arg.clone() }) + .collect::>() + } else { + args.to_vec() + }; + + let cmd = ProposeCommand::Raw { + command: args[0].clone(), + args: args.iter().skip(1).cloned().collect::>(), + }; + let dry_run = self.dry_run || cmd.args().contains(&String::from("--dry-run")); + Box::pin(async move { self.propose_run_inner(cmd, Default::default(), dry_run).await }) + } + + fn prepare_to_propose_to_revise_elected_versions<'a>( + &'a self, + release_artifact: &'a Artifact, + version: &'a String, + release_tag: &'a String, + force: bool, + retire_versions: Option>, + ) -> BoxFuture<'a, anyhow::Result> { + Box::pin(async move { + let (update_urls, expected_hash) = Self::download_images_and_validate_sha256(release_artifact, version, force).await?; + + let template = format!( + r#"Elect new {release_artifact} binary revision [{version}](https://github.com/dfinity/ic/tree/{release_tag}) + + # Release Notes: + + [comment]: <> Remove this block of text from the proposal. + [comment]: <> Then, add the {release_artifact} binary release notes as bullet points here. + [comment]: <> Any [commit ID] within square brackets will auto-link to the specific changeset. + + # IC-OS Verification + + To build and verify the IC-OS disk image, run: + + ``` + # From https://github.com/dfinity/ic#verifying-releases + sudo apt-get install -y curl && curl --proto '=https' --tlsv1.2 -sSLO https://raw.githubusercontent.com/dfinity/ic/{version}/gitlab-ci/tools/repro-check.sh && chmod +x repro-check.sh && ./repro-check.sh -c {version} + ``` + + The two SHA256 sums printed above from a) the downloaded CDN image and b) the locally built image, + must be identical, and must match the SHA256 from the payload of the NNS proposal. + "# + ); + + // Remove from the commit + // Leading or trailing spaces are removed as well and replaced with a single space. + // Regex can be analyzed and tested at: + // https://rregex.dev/?version=1.7&method=replace®ex=%5Cs*%3C%21--.%2B%3F--%3E%5Cs*&replace=+&text=*+%5Babc%5D+%3C%21--+ignored+1+--%3E+line%0A*+%5Babc%5D+%3C%21--+ignored+2+--%3E+comment+1+%3C%21--+ignored+3+--%3E+comment+2%0A + let re_comment = Regex::new(r"\s*\s*").unwrap(); + let mut builder = edit::Builder::new(); + let with_suffix = builder.suffix(".md"); + let edited = edit::edit_with_builder(template, with_suffix)? + .trim() + .replace("\r(\n)?", "\n") + .split('\n') + .map(|f| { + let f = re_comment.replace_all(f.trim(), " "); + + if !f.starts_with('*') { + return f.to_string(); + } + match f.split_once(']') { + Some((left, message)) => { + let commit_hash = left.split_once('[').unwrap().1.to_string(); + + format!("* [[{}](https://github.com/dfinity/ic/commit/{})] {}", commit_hash, commit_hash, message) + } + None => f.to_string(), + } + }) + .join("\n"); + if edited.contains(&String::from("Remove this block of text from the proposal.")) { + Err(anyhow::anyhow!("The edited proposal text has not been edited to add release notes.")) + } else { + let proposal_title = match &retire_versions { + Some(v) => { + let pluralize = if v.len() == 1 { "version" } else { "versions" }; + format!( + "Elect new IC/{} revision (commit {}), and retire old replica {} {}", + release_artifact.capitalized(), + &version[..8], + pluralize, + v.iter().map(|v| &v[..8]).join(",") + ) + } + None => format!("Elect new IC/{} revision (commit {})", release_artifact.capitalized(), &version[..8]), + }; + + Ok(UpdateVersion { + release_artifact: release_artifact.clone(), + version: version.clone(), + title: proposal_title.clone(), + stringified_hash: expected_hash, + summary: edited, + update_urls, + versions_to_retire: retire_versions.clone(), + }) + } + }) + } +} + +impl IcAdminImpl { pub fn new(network: Network, ic_admin_bin_path: Option, proceed_without_confirmation: bool, neuron: Neuron, dry_run: bool) -> Self { Self { network, @@ -175,10 +397,6 @@ impl IcAdminWrapper { Ok(cmd_out) } - pub async fn propose_run(&self, cmd: ProposeCommand, opts: ProposeOptions) -> anyhow::Result { - self.propose_run_inner(cmd, opts, self.dry_run).await - } - async fn propose_run_inner(&self, cmd: ProposeCommand, opts: ProposeOptions, dry_run: bool) -> anyhow::Result { // Dry run, or --help executions run immediately and do not proceed. if dry_run || cmd.args().contains(&String::from("--help")) || cmd.args().contains(&String::from("--dry-run")) { @@ -253,11 +471,6 @@ impl IcAdminWrapper { } } - pub async fn run(&self, command: &str, args: &[String], silent: bool) -> anyhow::Result { - let ic_admin_args = [&[command.to_string()], args].concat(); - self._run_ic_admin_with_args(&ic_admin_args, silent).await - } - /// Run ic-admin and parse sub-commands that it lists with "--help", /// extract the ones matching `needle_regex` and return them as a /// `Vec` @@ -284,100 +497,6 @@ impl IcAdminWrapper { } } - pub(crate) fn grep_subcommand_arguments(&self, subcommand: &str) -> String { - let ic_admin_path = self.ic_admin_bin_path.clone().unwrap_or_else(|| "ic-admin".to_string()); - let cmd_result = Command::new(ic_admin_path).args([subcommand, "--help"]).output(); - match cmd_result.map_err(|e| e.to_string()) { - Ok(output) => { - if output.status.success() { - String::from_utf8_lossy(output.stdout.as_ref()).to_string() - } else { - error!("Execution of ic-admin failed: {}", String::from_utf8_lossy(output.stderr.as_ref())); - String::new() - } - } - Err(err) => { - error!("Error starting ic-admin process: {}", err); - String::new() - } - } - } - - /// Run an `ic-admin get-*` command directly, and without an HSM - pub async fn run_passthrough_get(&self, args: &[String], silent: bool) -> anyhow::Result { - if args.is_empty() { - println!("List of available ic-admin 'get' sub-commands:\n"); - for subcmd in self.grep_subcommands(r"\s+get-(.+?)\s") { - println!("\t{}", subcmd) - } - std::process::exit(1); - } - - // The `get` subcommand of the cli expects that "get-" prefix is not provided as - // the ic-admin command - let args = if args[0].starts_with("get-") { - // The user did provide the "get-" prefix, so let's just keep it and use it. - // This provides a convenient backward compatibility with ic-admin commands - // i.e., `dre get get-subnet 0` still works, although `dre get - // subnet 0` is preferred - args.to_vec() - } else { - // But since ic-admin expects these commands to include the "get-" prefix, we - // need to add it back Example: - // `dre get subnet 0` becomes - // `ic-admin --nns-url "http://[2600:3000:6100:200:5000:b0ff:fe8e:6b7b]:8080" get-subnet 0` - let mut args_with_get_prefix = vec![String::from("get-") + args[0].as_str()]; - args_with_get_prefix.extend_from_slice(args.split_at(1).1); - args_with_get_prefix - }; - - let stdout = self.run(&args[0], &args.iter().skip(1).cloned().collect::>(), silent).await?; - Ok(stdout) - } - - /// Run an `ic-admin propose-to-*` command directly - pub async fn run_passthrough_propose(&self, args: &[String]) -> anyhow::Result<()> { - if args.is_empty() { - println!("List of available ic-admin 'propose' sub-commands:\n"); - for subcmd in self.grep_subcommands(r"\s+propose-to-(.+?)\s") { - println!("\t{}", subcmd) - } - std::process::exit(1); - } - - // The `propose` subcommand of the cli expects that "propose-to-" prefix is not - // provided as the ic-admin command - let args = if args[0].starts_with("propose-to-") { - // The user did provide the "propose-to-" prefix, so let's just keep it and use - // it. - args.to_vec() - } else { - // But since ic-admin expects these commands to include the "propose-to-" - // prefix, we need to add it back. - let mut args_with_fixed_prefix = vec![String::from("propose-to-") + args[0].as_str()]; - args_with_fixed_prefix.extend_from_slice(args.split_at(1).1); - args_with_fixed_prefix - }; - - // ic-admin expects --summary and not --motivation - // make sure the expected argument is provided - let args = if !args.contains(&String::from("--summary")) && args.contains(&String::from("--motivation")) { - args.iter() - .map(|arg| if arg == "--motivation" { "--summary".to_string() } else { arg.clone() }) - .collect::>() - } else { - args.to_vec() - }; - - let cmd = ProposeCommand::Raw { - command: args[0].clone(), - args: args.iter().skip(1).cloned().collect::>(), - }; - let dry_run = self.dry_run || cmd.args().contains(&String::from("--dry-run")); - self.propose_run_inner(cmd, Default::default(), dry_run).await?; - Ok(()) - } - fn get_s3_cdn_image_url(version: &String, s3_subdir: &String) -> String { format!( "https://download.dfinity.systems/ic/{}/{}/update-img/update-img.tar.gz", @@ -496,94 +615,6 @@ impl IcAdminWrapper { } Ok((update_urls, expected_hash)) } - - pub async fn prepare_to_propose_to_revise_elected_versions( - release_artifact: &Artifact, - version: &String, - release_tag: &String, - force: bool, - retire_versions: Option>, - ) -> anyhow::Result { - let (update_urls, expected_hash) = Self::download_images_and_validate_sha256(release_artifact, version, force).await?; - - let template = format!( - r#"Elect new {release_artifact} binary revision [{version}](https://github.com/dfinity/ic/tree/{release_tag}) - -# Release Notes: - -[comment]: <> Remove this block of text from the proposal. -[comment]: <> Then, add the {release_artifact} binary release notes as bullet points here. -[comment]: <> Any [commit ID] within square brackets will auto-link to the specific changeset. - -# IC-OS Verification - -To build and verify the IC-OS disk image, run: - -``` -# From https://github.com/dfinity/ic#verifying-releases -sudo apt-get install -y curl && curl --proto '=https' --tlsv1.2 -sSLO https://raw.githubusercontent.com/dfinity/ic/{version}/gitlab-ci/tools/repro-check.sh && chmod +x repro-check.sh && ./repro-check.sh -c {version} -``` - -The two SHA256 sums printed above from a) the downloaded CDN image and b) the locally built image, -must be identical, and must match the SHA256 from the payload of the NNS proposal. -"# - ); - - // Remove from the commit - // Leading or trailing spaces are removed as well and replaced with a single space. - // Regex can be analyzed and tested at: - // https://rregex.dev/?version=1.7&method=replace®ex=%5Cs*%3C%21--.%2B%3F--%3E%5Cs*&replace=+&text=*+%5Babc%5D+%3C%21--+ignored+1+--%3E+line%0A*+%5Babc%5D+%3C%21--+ignored+2+--%3E+comment+1+%3C%21--+ignored+3+--%3E+comment+2%0A - let re_comment = Regex::new(r"\s*\s*").unwrap(); - let mut builder = edit::Builder::new(); - let with_suffix = builder.suffix(".md"); - let edited = edit::edit_with_builder(template, with_suffix)? - .trim() - .replace("\r(\n)?", "\n") - .split('\n') - .map(|f| { - let f = re_comment.replace_all(f.trim(), " "); - - if !f.starts_with('*') { - return f.to_string(); - } - match f.split_once(']') { - Some((left, message)) => { - let commit_hash = left.split_once('[').unwrap().1.to_string(); - - format!("* [[{}](https://github.com/dfinity/ic/commit/{})] {}", commit_hash, commit_hash, message) - } - None => f.to_string(), - } - }) - .join("\n"); - if edited.contains(&String::from("Remove this block of text from the proposal.")) { - Err(anyhow::anyhow!("The edited proposal text has not been edited to add release notes.")) - } else { - let proposal_title = match &retire_versions { - Some(v) => { - let pluralize = if v.len() == 1 { "version" } else { "versions" }; - format!( - "Elect new IC/{} revision (commit {}), and retire old replica {} {}", - release_artifact.capitalized(), - &version[..8], - pluralize, - v.iter().map(|v| &v[..8]).join(",") - ) - } - None => format!("Elect new IC/{} revision (commit {})", release_artifact.capitalized(), &version[..8]), - }; - - Ok(UpdateVersion { - release_artifact: release_artifact.clone(), - version: version.clone(), - title: proposal_title.clone(), - stringified_hash: expected_hash, - summary: edited, - update_urls, - versions_to_retire: retire_versions.clone(), - }) - } - } } #[derive(Display, Clone)] diff --git a/rs/cli/src/qualification/ensure_blessed_versions.rs b/rs/cli/src/qualification/ensure_blessed_versions.rs index 767e86b7b..78549833d 100644 --- a/rs/cli/src/qualification/ensure_blessed_versions.rs +++ b/rs/cli/src/qualification/ensure_blessed_versions.rs @@ -3,7 +3,7 @@ use comfy_table::CellAlignment; use itertools::Itertools; use crate::{ - ic_admin::{ProposeCommand, ProposeOptions}, + ic_admin::{IcAdmin, ProposeCommand, ProposeOptions}, qualification::Step, }; diff --git a/rs/cli/src/qualification/retire_blessed_versions.rs b/rs/cli/src/qualification/retire_blessed_versions.rs index 5303b276a..f0f050c20 100644 --- a/rs/cli/src/qualification/retire_blessed_versions.rs +++ b/rs/cli/src/qualification/retire_blessed_versions.rs @@ -2,7 +2,7 @@ use backon::{ExponentialBuilder, Retryable}; use comfy_table::CellAlignment; use itertools::Itertools; -use crate::ic_admin::{ProposeCommand, ProposeOptions}; +use crate::ic_admin::{IcAdmin, ProposeCommand, ProposeOptions}; use super::{comfy_table_util::Table, step::Step, util::StepCtx}; diff --git a/rs/cli/src/qualification/upgrade_subnets.rs b/rs/cli/src/qualification/upgrade_subnets.rs index e3fd0e428..1934a53eb 100644 --- a/rs/cli/src/qualification/upgrade_subnets.rs +++ b/rs/cli/src/qualification/upgrade_subnets.rs @@ -8,7 +8,7 @@ use itertools::Itertools; use reqwest::ClientBuilder; use crate::{ - ic_admin::{ProposeCommand, ProposeOptions}, + ic_admin::{IcAdmin, ProposeCommand, ProposeOptions}, qualification::comfy_table_util::Table, }; diff --git a/rs/cli/src/runner.rs b/rs/cli/src/runner.rs index 5c741c810..480372c58 100644 --- a/rs/cli/src/runner.rs +++ b/rs/cli/src/runner.rs @@ -36,14 +36,15 @@ use registry_canister::mutations::do_change_subnet_membership::ChangeSubnetMembe use tabled::builder::Builder; use tabled::settings::Style; -use crate::ic_admin::{self, IcAdminWrapper}; +use crate::ic_admin::IcAdmin; +use crate::ic_admin::{self, IcAdminImpl}; use crate::ic_admin::{ProposeCommand, ProposeOptions}; use crate::operations::hostos_rollout::HostosRollout; use crate::operations::hostos_rollout::HostosRolloutResponse; use crate::operations::hostos_rollout::NodeGroupUpdate; pub struct Runner { - ic_admin: Arc, + ic_admin: Arc, registry: Arc, ic_repo: RefCell>>, network: Network, @@ -52,7 +53,7 @@ pub struct Runner { } impl Runner { - pub fn new(ic_admin: Arc, registry: Arc, network: Network, agent: ProposalAgent, verbose: bool) -> Self { + pub fn new(ic_admin: Arc, registry: Arc, network: Network, agent: ProposalAgent, verbose: bool) -> Self { Self { ic_admin, registry, @@ -285,14 +286,16 @@ impl Runner { force: bool, forum_post_link: Option, ) -> anyhow::Result<()> { - let update_version = IcAdminWrapper::prepare_to_propose_to_revise_elected_versions( - release_artifact, - version, - release_tag, - force, - self.prepare_versions_to_retire(release_artifact, false).await.map(|r| r.1)?, - ) - .await?; + let update_version = self + .ic_admin + .prepare_to_propose_to_revise_elected_versions( + release_artifact, + version, + release_tag, + force, + self.prepare_versions_to_retire(release_artifact, false).await.map(|r| r.1)?, + ) + .await?; self.ic_admin .propose_run( diff --git a/rs/rollout-controller/src/actions/mod.rs b/rs/rollout-controller/src/actions/mod.rs index 867522224..a7dd3e0b1 100644 --- a/rs/rollout-controller/src/actions/mod.rs +++ b/rs/rollout-controller/src/actions/mod.rs @@ -2,7 +2,7 @@ use std::{path::PathBuf, time::Duration}; use dre::{ auth::Neuron, - ic_admin::{IcAdminWrapper, ProposeCommand, ProposeOptions}, + ic_admin::{IcAdminImpl, ProposeCommand, ProposeOptions}, }; use ic_base_types::PrincipalId; use ic_management_types::Network; @@ -106,7 +106,7 @@ impl<'a> SubnetAction { } pub struct ActionExecutor<'a> { - ic_admin_wrapper: IcAdminWrapper, + ic_admin_wrapper: IcAdminImpl, logger: Option<&'a Logger>, } @@ -114,7 +114,7 @@ impl<'a> ActionExecutor<'a> { pub async fn new(neuron_id: u64, private_key_pem: String, network: Network, simulate: bool, logger: Option<&'a Logger>) -> anyhow::Result { let neuron = Neuron::new(Some(PathBuf::from(private_key_pem)), None, None, None, Some(neuron_id), &network, true).await?; Ok(Self { - ic_admin_wrapper: IcAdminWrapper::new(network, None, true, neuron, simulate), + ic_admin_wrapper: IcAdminImpl::new(network, None, true, neuron, simulate), logger, }) } @@ -122,7 +122,7 @@ impl<'a> ActionExecutor<'a> { pub async fn test(network: Network, logger: Option<&'a Logger>) -> anyhow::Result { let neuron = Neuron::new(None, None, None, None, None, &network, true).await?; Ok(Self { - ic_admin_wrapper: IcAdminWrapper::new(network, None, true, neuron, true), + ic_admin_wrapper: IcAdminImpl::new(network, None, true, neuron, true), logger, }) } From 8744895aa22acddcd7444e2caacfd5a25583792c Mon Sep 17 00:00:00 2001 From: nikolamilosa Date: Fri, 30 Aug 2024 18:27:18 +0200 Subject: [PATCH 2/5] clippy --- rs/cli/src/ic_admin.rs | 20 ++++++++++---------- rs/cli/src/runner.rs | 4 ++-- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/rs/cli/src/ic_admin.rs b/rs/cli/src/ic_admin.rs index 8ef259886..796f2d6a1 100644 --- a/rs/cli/src/ic_admin.rs +++ b/rs/cli/src/ic_admin.rs @@ -61,7 +61,7 @@ impl UpdateVersion { pub trait IcAdmin: Send + Sync { fn neuron(&self) -> Neuron; - fn propose_run<'a>(&'a self, cmd: ProposeCommand, opts: ProposeOptions) -> BoxFuture<'a, anyhow::Result>; + fn propose_run(&self, cmd: ProposeCommand, opts: ProposeOptions) -> BoxFuture<'_, anyhow::Result>; fn run<'a>(&'a self, command: &'a str, args: &'a [String], silent: bool) -> BoxFuture<'a, anyhow::Result>; @@ -74,8 +74,8 @@ pub trait IcAdmin: Send + Sync { fn prepare_to_propose_to_revise_elected_versions<'a>( &'a self, release_artifact: &'a Artifact, - version: &'a String, - release_tag: &'a String, + version: &'a str, + release_tag: &'a str, force: bool, retire_versions: Option>, ) -> BoxFuture<'a, anyhow::Result>; @@ -95,7 +95,7 @@ impl IcAdmin for IcAdminImpl { self.neuron.clone() } - fn propose_run<'a>(&'a self, cmd: ProposeCommand, opts: ProposeOptions) -> BoxFuture<'a, anyhow::Result> { + fn propose_run(&self, cmd: ProposeCommand, opts: ProposeOptions) -> BoxFuture<'_, anyhow::Result> { Box::pin(async move { self.propose_run_inner(cmd, opts, self.dry_run).await }) } @@ -199,8 +199,8 @@ impl IcAdmin for IcAdminImpl { fn prepare_to_propose_to_revise_elected_versions<'a>( &'a self, release_artifact: &'a Artifact, - version: &'a String, - release_tag: &'a String, + version: &'a str, + release_tag: &'a str, force: bool, retire_versions: Option>, ) -> BoxFuture<'a, anyhow::Result> { @@ -276,7 +276,7 @@ impl IcAdmin for IcAdminImpl { Ok(UpdateVersion { release_artifact: release_artifact.clone(), - version: version.clone(), + version: version.to_string(), title: proposal_title.clone(), stringified_hash: expected_hash, summary: edited, @@ -497,14 +497,14 @@ impl IcAdminImpl { } } - fn get_s3_cdn_image_url(version: &String, s3_subdir: &String) -> String { + fn get_s3_cdn_image_url(version: &str, s3_subdir: &String) -> String { format!( "https://download.dfinity.systems/ic/{}/{}/update-img/update-img.tar.gz", version, s3_subdir ) } - fn get_r2_cdn_image_url(version: &String, s3_subdir: &String) -> String { + fn get_r2_cdn_image_url(version: &str, s3_subdir: &String) -> String { format!( "https://download.dfinity.network/ic/{}/{}/update-img/update-img.tar.gz", version, s3_subdir @@ -553,7 +553,7 @@ impl IcAdminImpl { async fn download_images_and_validate_sha256( image: &Artifact, - version: &String, + version: &str, ignore_missing_urls: bool, ) -> anyhow::Result<(Vec, String)> { let update_urls = vec![ diff --git a/rs/cli/src/runner.rs b/rs/cli/src/runner.rs index 480372c58..1ea365daf 100644 --- a/rs/cli/src/runner.rs +++ b/rs/cli/src/runner.rs @@ -281,8 +281,8 @@ impl Runner { pub async fn do_revise_elected_replica_versions( &self, release_artifact: &Artifact, - version: &String, - release_tag: &String, + version: &str, + release_tag: &str, force: bool, forum_post_link: Option, ) -> anyhow::Result<()> { From d777a366513a75951597e9608d276554d0d792c7 Mon Sep 17 00:00:00 2001 From: nikolamilosa Date: Fri, 30 Aug 2024 18:41:29 +0200 Subject: [PATCH 3/5] using IcAdmin trait --- rs/cli/src/commands/firewall.rs | 4 ++-- rs/cli/src/ctx.rs | 10 +++++----- rs/cli/src/runner.rs | 7 +++---- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/rs/cli/src/commands/firewall.rs b/rs/cli/src/commands/firewall.rs index e94dcd7b9..9182d27d6 100644 --- a/rs/cli/src/commands/firewall.rs +++ b/rs/cli/src/commands/firewall.rs @@ -13,7 +13,7 @@ use log::{info, warn}; use serde::Serialize; use tempfile::NamedTempFile; -use crate::ic_admin::{IcAdmin, IcAdminImpl, ProposeCommand, ProposeOptions}; +use crate::ic_admin::{IcAdmin, ProposeCommand, ProposeOptions}; use super::{ExecutableCommand, IcAdminRequirement}; @@ -119,7 +119,7 @@ impl ExecutableCommand for Firewall { impl Firewall { async fn submit_proposal( - admin: Arc, + admin: Arc, modifications: Vec, propose_options: ProposeOptions, firewall_rules_scope: &FirewallRulesScope, diff --git a/rs/cli/src/ctx.rs b/rs/cli/src/ctx.rs index 48e1f564b..4ee9fefc9 100644 --- a/rs/cli/src/ctx.rs +++ b/rs/cli/src/ctx.rs @@ -30,7 +30,7 @@ const STAGING_NEURON_ID: u64 = 49; pub struct DreContext { network: Network, registry: RefCell>>, - ic_admin: Option>, + ic_admin: Option>, runner: RefCell>>, verbose_runner: bool, skip_sync: bool, @@ -98,7 +98,7 @@ impl DreContext { proceed_without_confirmation: bool, dry_run: bool, requirement: IcAdminRequirement, - ) -> anyhow::Result<(Option>, Option)> { + ) -> anyhow::Result<(Option>, Option)> { if let IcAdminRequirement::None = requirement { return Ok((None, None)); } @@ -144,7 +144,7 @@ impl DreContext { proceed_without_confirmation, neuron, dry_run, - ))); + )) as Arc); Ok((ic_admin, Some(ic_admin_path))) } @@ -200,14 +200,14 @@ impl DreContext { } } - pub fn ic_admin(&self) -> Arc { + pub fn ic_admin(&self) -> Arc { match &self.ic_admin { Some(a) => a.clone(), None => panic!("This command is not configured to use ic admin"), } } - pub fn readonly_ic_admin_for_other_network(&self, network: Network) -> IcAdminImpl { + pub fn readonly_ic_admin_for_other_network(&self, network: Network) -> impl IcAdmin { IcAdminImpl::new(network, self.ic_admin_path.clone(), true, Neuron::anonymous_neuron(), false) } diff --git a/rs/cli/src/runner.rs b/rs/cli/src/runner.rs index 1ea365daf..2ac575056 100644 --- a/rs/cli/src/runner.rs +++ b/rs/cli/src/runner.rs @@ -36,15 +36,14 @@ use registry_canister::mutations::do_change_subnet_membership::ChangeSubnetMembe use tabled::builder::Builder; use tabled::settings::Style; -use crate::ic_admin::IcAdmin; -use crate::ic_admin::{self, IcAdminImpl}; +use crate::ic_admin::{self, IcAdmin}; use crate::ic_admin::{ProposeCommand, ProposeOptions}; use crate::operations::hostos_rollout::HostosRollout; use crate::operations::hostos_rollout::HostosRolloutResponse; use crate::operations::hostos_rollout::NodeGroupUpdate; pub struct Runner { - ic_admin: Arc, + ic_admin: Arc, registry: Arc, ic_repo: RefCell>>, network: Network, @@ -53,7 +52,7 @@ pub struct Runner { } impl Runner { - pub fn new(ic_admin: Arc, registry: Arc, network: Network, agent: ProposalAgent, verbose: bool) -> Self { + pub fn new(ic_admin: Arc, registry: Arc, network: Network, agent: ProposalAgent, verbose: bool) -> Self { Self { ic_admin, registry, From 5acdf96710d86c7c76441c67d09df22f4e647d83 Mon Sep 17 00:00:00 2001 From: nikolamilosa Date: Fri, 30 Aug 2024 18:45:46 +0200 Subject: [PATCH 4/5] clippy --- rs/cli/src/commands/api_boundary_nodes/add.rs | 2 +- rs/cli/src/commands/api_boundary_nodes/remove.rs | 2 +- rs/cli/src/commands/api_boundary_nodes/update.rs | 2 +- rs/cli/src/commands/get.rs | 2 -- rs/cli/src/commands/neuron/balance.rs | 2 +- rs/cli/src/commands/neuron/refresh.rs | 2 +- rs/cli/src/commands/neuron/top_up.rs | 2 +- rs/cli/src/commands/propose.rs | 2 -- rs/cli/src/commands/update_authorized_subnets.rs | 2 +- rs/cli/src/commands/vote.rs | 2 +- rs/cli/src/qualification/ensure_blessed_versions.rs | 2 +- rs/cli/src/qualification/retire_blessed_versions.rs | 2 +- rs/cli/src/qualification/upgrade_subnets.rs | 2 +- 13 files changed, 11 insertions(+), 15 deletions(-) diff --git a/rs/cli/src/commands/api_boundary_nodes/add.rs b/rs/cli/src/commands/api_boundary_nodes/add.rs index 71fb1aa09..2f04a0f3f 100644 --- a/rs/cli/src/commands/api_boundary_nodes/add.rs +++ b/rs/cli/src/commands/api_boundary_nodes/add.rs @@ -3,7 +3,7 @@ use ic_types::PrincipalId; use crate::{ commands::{ExecutableCommand, IcAdminRequirement}, - ic_admin::{self, IcAdmin}, + ic_admin::{self}, }; #[derive(Args, Debug)] diff --git a/rs/cli/src/commands/api_boundary_nodes/remove.rs b/rs/cli/src/commands/api_boundary_nodes/remove.rs index 91922243d..ce54e8900 100644 --- a/rs/cli/src/commands/api_boundary_nodes/remove.rs +++ b/rs/cli/src/commands/api_boundary_nodes/remove.rs @@ -3,7 +3,7 @@ use ic_types::PrincipalId; use crate::{ commands::{ExecutableCommand, IcAdminRequirement}, - ic_admin::{self, IcAdmin}, + ic_admin::{self}, }; #[derive(Args, Debug)] diff --git a/rs/cli/src/commands/api_boundary_nodes/update.rs b/rs/cli/src/commands/api_boundary_nodes/update.rs index 866983a84..00b8389e3 100644 --- a/rs/cli/src/commands/api_boundary_nodes/update.rs +++ b/rs/cli/src/commands/api_boundary_nodes/update.rs @@ -3,7 +3,7 @@ use ic_types::PrincipalId; use crate::{ commands::{ExecutableCommand, IcAdminRequirement}, - ic_admin::{self, IcAdmin}, + ic_admin::{self}, }; #[derive(Args, Debug)] diff --git a/rs/cli/src/commands/get.rs b/rs/cli/src/commands/get.rs index 03c764d89..74c83509e 100644 --- a/rs/cli/src/commands/get.rs +++ b/rs/cli/src/commands/get.rs @@ -1,7 +1,5 @@ use clap::Args; -use crate::ic_admin::IcAdmin; - use super::{ExecutableCommand, IcAdminRequirement}; #[derive(Args, Debug)] diff --git a/rs/cli/src/commands/neuron/balance.rs b/rs/cli/src/commands/neuron/balance.rs index 21ca9278e..128468e04 100644 --- a/rs/cli/src/commands/neuron/balance.rs +++ b/rs/cli/src/commands/neuron/balance.rs @@ -1,7 +1,7 @@ use clap::Args; use ic_canisters::governance::GovernanceCanisterWrapper; -use crate::{commands::ExecutableCommand, ic_admin::IcAdmin}; +use crate::commands::ExecutableCommand; #[derive(Args, Debug)] pub struct Balance { diff --git a/rs/cli/src/commands/neuron/refresh.rs b/rs/cli/src/commands/neuron/refresh.rs index 14a23344b..6a1162839 100644 --- a/rs/cli/src/commands/neuron/refresh.rs +++ b/rs/cli/src/commands/neuron/refresh.rs @@ -1,7 +1,7 @@ use clap::Args; use ic_canisters::governance::GovernanceCanisterWrapper; -use crate::{commands::ExecutableCommand, ic_admin::IcAdmin}; +use crate::commands::ExecutableCommand; #[derive(Args, Debug)] pub struct Refresh {} diff --git a/rs/cli/src/commands/neuron/top_up.rs b/rs/cli/src/commands/neuron/top_up.rs index d0dd37f49..e52135e54 100644 --- a/rs/cli/src/commands/neuron/top_up.rs +++ b/rs/cli/src/commands/neuron/top_up.rs @@ -2,7 +2,7 @@ use clap::Args; use ic_canisters::governance::GovernanceCanisterWrapper; use itertools::Itertools; -use crate::{commands::ExecutableCommand, ic_admin::IcAdmin}; +use crate::commands::ExecutableCommand; #[derive(Args, Debug)] pub struct TopUp {} diff --git a/rs/cli/src/commands/propose.rs b/rs/cli/src/commands/propose.rs index 7fb6653ea..c79401927 100644 --- a/rs/cli/src/commands/propose.rs +++ b/rs/cli/src/commands/propose.rs @@ -1,7 +1,5 @@ use clap::Args; -use crate::ic_admin::IcAdmin; - use super::{ExecutableCommand, IcAdminRequirement}; #[derive(Args, Debug)] diff --git a/rs/cli/src/commands/update_authorized_subnets.rs b/rs/cli/src/commands/update_authorized_subnets.rs index fa25340e5..57fa8c4b7 100644 --- a/rs/cli/src/commands/update_authorized_subnets.rs +++ b/rs/cli/src/commands/update_authorized_subnets.rs @@ -7,7 +7,7 @@ use ic_types::PrincipalId; use itertools::Itertools; use log::info; -use crate::ic_admin::{IcAdmin, ProposeCommand, ProposeOptions}; +use crate::ic_admin::{ProposeCommand, ProposeOptions}; use super::ExecutableCommand; diff --git a/rs/cli/src/commands/vote.rs b/rs/cli/src/commands/vote.rs index 68aae88b2..75a770af7 100644 --- a/rs/cli/src/commands/vote.rs +++ b/rs/cli/src/commands/vote.rs @@ -8,7 +8,7 @@ use log::info; use spinners::{Spinner, Spinners}; use super::{ExecutableCommand, IcAdminRequirement}; -use crate::{desktop_notify::DesktopNotifier, ic_admin::IcAdmin}; +use crate::desktop_notify::DesktopNotifier; #[derive(Args, Debug)] pub struct Vote { diff --git a/rs/cli/src/qualification/ensure_blessed_versions.rs b/rs/cli/src/qualification/ensure_blessed_versions.rs index 78549833d..767e86b7b 100644 --- a/rs/cli/src/qualification/ensure_blessed_versions.rs +++ b/rs/cli/src/qualification/ensure_blessed_versions.rs @@ -3,7 +3,7 @@ use comfy_table::CellAlignment; use itertools::Itertools; use crate::{ - ic_admin::{IcAdmin, ProposeCommand, ProposeOptions}, + ic_admin::{ProposeCommand, ProposeOptions}, qualification::Step, }; diff --git a/rs/cli/src/qualification/retire_blessed_versions.rs b/rs/cli/src/qualification/retire_blessed_versions.rs index f0f050c20..5303b276a 100644 --- a/rs/cli/src/qualification/retire_blessed_versions.rs +++ b/rs/cli/src/qualification/retire_blessed_versions.rs @@ -2,7 +2,7 @@ use backon::{ExponentialBuilder, Retryable}; use comfy_table::CellAlignment; use itertools::Itertools; -use crate::ic_admin::{IcAdmin, ProposeCommand, ProposeOptions}; +use crate::ic_admin::{ProposeCommand, ProposeOptions}; use super::{comfy_table_util::Table, step::Step, util::StepCtx}; diff --git a/rs/cli/src/qualification/upgrade_subnets.rs b/rs/cli/src/qualification/upgrade_subnets.rs index 1934a53eb..e3fd0e428 100644 --- a/rs/cli/src/qualification/upgrade_subnets.rs +++ b/rs/cli/src/qualification/upgrade_subnets.rs @@ -8,7 +8,7 @@ use itertools::Itertools; use reqwest::ClientBuilder; use crate::{ - ic_admin::{IcAdmin, ProposeCommand, ProposeOptions}, + ic_admin::{ProposeCommand, ProposeOptions}, qualification::comfy_table_util::Table, }; From 9892d323ec07a1c9792327b2bf273d3a09a9272c Mon Sep 17 00:00:00 2001 From: nikolamilosa Date: Fri, 30 Aug 2024 19:08:59 +0200 Subject: [PATCH 5/5] fixing error --- rs/rollout-controller/src/actions/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rs/rollout-controller/src/actions/mod.rs b/rs/rollout-controller/src/actions/mod.rs index a7dd3e0b1..959fdfaa4 100644 --- a/rs/rollout-controller/src/actions/mod.rs +++ b/rs/rollout-controller/src/actions/mod.rs @@ -2,7 +2,7 @@ use std::{path::PathBuf, time::Duration}; use dre::{ auth::Neuron, - ic_admin::{IcAdminImpl, ProposeCommand, ProposeOptions}, + ic_admin::{IcAdmin, IcAdminImpl, ProposeCommand, ProposeOptions}, }; use ic_base_types::PrincipalId; use ic_management_types::Network;