From 4aa43b7a3bf1f9e03bcefd3d3fc8de7b624fc364 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C4=99drzej=20Stuczy=C5=84ski?= Date: Tue, 3 Jan 2023 14:59:17 +0000 Subject: [PATCH 1/9] Renamed "address" argument in "sign" command to "wallet-address" --- gateway/src/commands/sign.rs | 8 ++++---- mixnode/src/commands/sign.rs | 11 ++++++----- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/gateway/src/commands/sign.rs b/gateway/src/commands/sign.rs index 61e9495f09..3449648378 100644 --- a/gateway/src/commands/sign.rs +++ b/gateway/src/commands/sign.rs @@ -1,4 +1,4 @@ -// Copyright 2020 - Nym Technologies SA +// Copyright 2020-2023 - Nym Technologies SA // SPDX-License-Identifier: Apache-2.0 use crate::{ @@ -12,7 +12,7 @@ use crypto::asymmetric::identity; use log::error; #[derive(Args, Clone)] -#[clap(group(ArgGroup::new("sign").required(true).args(&["address", "text"])))] +#[clap(group(ArgGroup::new("sign").required(true).args(&["wallet_address", "text"])))] pub struct Sign { /// The id of the mixnode you want to sign with #[clap(long)] @@ -20,7 +20,7 @@ pub struct Sign { /// Signs your blockchain address with your identity key #[clap(long)] - address: Option, + wallet_address: Option, /// Signs an arbitrary piece of text with your identity key #[clap(long)] @@ -38,7 +38,7 @@ impl TryFrom for SignedTarget { fn try_from(args: Sign) -> Result { if let Some(text) = args.text { Ok(SignedTarget::Text(text)) - } else if let Some(address) = args.address { + } else if let Some(address) = args.wallet_address { Ok(SignedTarget::Address(address)) } else { // This is unreachable, and hopefully clap will support it explicitly by outputting an diff --git a/mixnode/src/commands/sign.rs b/mixnode/src/commands/sign.rs index 46158a9b42..5967e99dd0 100644 --- a/mixnode/src/commands/sign.rs +++ b/mixnode/src/commands/sign.rs @@ -1,4 +1,4 @@ -// Copyright 2020 - Nym Technologies SA +// Copyright 2020-2023 - Nym Technologies SA // SPDX-License-Identifier: Apache-2.0 use std::convert::TryFrom; @@ -15,15 +15,16 @@ use log::error; use super::version_check; #[derive(Args, Clone)] -#[clap(group(ArgGroup::new("sign").required(true).args(&["address", "text"])))] +#[clap(group(ArgGroup::new("sign").required(true).args(&["wallet-address", "text"])))] pub(crate) struct Sign { /// The id of the mixnode you want to sign with #[clap(long)] id: String, /// Signs your blockchain address with your identity key - #[clap(long)] - address: Option, + // the alias here is included for backwards compatibility (1.1.4 and before) + #[clap(long, alias = "address")] + wallet_address: Option, /// Signs an arbitrary piece of text with your identity key #[clap(long)] @@ -41,7 +42,7 @@ impl TryFrom for SignedTarget { fn try_from(args: Sign) -> Result { if let Some(text) = args.text { Ok(SignedTarget::Text(text)) - } else if let Some(address) = args.address { + } else if let Some(address) = args.wallet_address { Ok(SignedTarget::Address(address)) } else { // This is unreachable, and hopefully clap will support it explicitly by outputting an From 35666c77f514693b1bac9acca906a53be1b15f86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C4=99drzej=20Stuczy=C5=84ski?= Date: Tue, 3 Jan 2023 15:15:37 +0000 Subject: [PATCH 2/9] Ability to optionally describe mixnode with command line arguments --- mixnode/src/commands/describe.rs | 70 +++++++++++++++++++++----------- mixnode/src/commands/mod.rs | 12 +++--- 2 files changed, 52 insertions(+), 30 deletions(-) diff --git a/mixnode/src/commands/describe.rs b/mixnode/src/commands/describe.rs index 07b2d420c8..5b66eb8d87 100644 --- a/mixnode/src/commands/describe.rs +++ b/mixnode/src/commands/describe.rs @@ -1,3 +1,6 @@ +// Copyright 2021-2023 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 + use crate::config::Config; use crate::node::node_description::NodeDescription; use clap::Args; @@ -11,9 +14,32 @@ pub(crate) struct Describe { /// The id of the mixnode you want to describe #[clap(long)] id: String, + + /// Human readable name of this node + #[clap(long)] + name: Option, + + /// Description of this node + #[clap(long)] + description: Option, + + /// Link associated with this node, for example `https://mixnode.yourdomain.com` + #[clap(long)] + link: Option, + + /// Physical location of this node, for example `City: London, Country: UK` + #[clap(long)] + location: Option, +} + +fn read_user_input() -> String { + io::stdout().flush().unwrap(); + let mut buf = String::new(); + io::stdin().read_line(&mut buf).unwrap(); + buf.trim().to_string() } -pub(crate) fn execute(args: &Describe) { +pub(crate) fn execute(args: Describe) { // ensure that the mixnode has in fact been initialized match Config::load_from_file(Some(&args.id)) { Ok(cfg) => cfg, @@ -23,33 +49,29 @@ pub(crate) fn execute(args: &Describe) { } }; - // get input from the user - print!("name: "); - io::stdout().flush().unwrap(); - let mut name_buf = String::new(); - io::stdin().read_line(&mut name_buf).unwrap(); - let name = name_buf.trim().to_string(); - - print!("description: "); - io::stdout().flush().unwrap(); - let mut desc_buf = String::new(); - io::stdin().read_line(&mut desc_buf).unwrap(); - let description = desc_buf.trim().to_string(); - let example_url = "https://mixnode.yourdomain.com".bright_cyan(); let example_location = "City: London, Country: UK"; - print!("link, e.g. {}: ", example_url); - io::stdout().flush().unwrap(); - let mut link_buf = String::new(); - io::stdin().read_line(&mut link_buf).unwrap(); - let link = link_buf.trim().to_string(); + // get input from the user if not provided via the arguments + let name = args.name.unwrap_or_else(|| { + print!("name: "); + read_user_input() + }); - print!("location, e.g. {}: ", example_location); - io::stdout().flush().unwrap(); - let mut location_buf = String::new(); - io::stdin().read_line(&mut location_buf).unwrap(); - let location = location_buf.trim().to_string(); + let description = args.description.unwrap_or_else(|| { + print!("description: "); + read_user_input() + }); + + let link = args.link.unwrap_or_else(|| { + print!("link, e.g. {example_url}: "); + read_user_input() + }); + + let location = args.location.unwrap_or_else(|| { + print!("location, e.g. {example_location}: "); + read_user_input() + }); let node_description = NodeDescription { name, diff --git a/mixnode/src/commands/mod.rs b/mixnode/src/commands/mod.rs index 2edad136f9..86f54af703 100644 --- a/mixnode/src/commands/mod.rs +++ b/mixnode/src/commands/mod.rs @@ -64,13 +64,13 @@ struct OverrideConfig { pub(crate) async fn execute(args: Cli) { let bin_name = "nym-mixnode"; - match &args.command { + match args.command { Commands::Describe(m) => describe::execute(m), - Commands::Init(m) => init::execute(m), - Commands::Run(m) => run::execute(m).await, - Commands::Sign(m) => sign::execute(m), - Commands::Upgrade(m) => upgrade::execute(m), - Commands::NodeDetails(m) => node_details::execute(m), + Commands::Init(m) => init::execute(&m), + Commands::Run(m) => run::execute(&m).await, + Commands::Sign(m) => sign::execute(&m), + Commands::Upgrade(m) => upgrade::execute(&m), + Commands::NodeDetails(m) => node_details::execute(&m), Commands::Completions(s) => s.generate(&mut crate::Cli::into_app(), bin_name), Commands::GenerateFigSpec => fig_generate(&mut crate::Cli::into_app(), bin_name), } From ca77459b50b644d4750179a7adbd3d2f1e916f57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C4=99drzej=20Stuczy=C5=84ski?= Date: Tue, 3 Jan 2023 15:21:49 +0000 Subject: [PATCH 3/9] renamed 'validators' arguments to 'nym-apis' in mixnode binary --- clients/native/src/commands/mod.rs | 8 ++++---- clients/socks5/src/commands/mod.rs | 10 +++++----- common/config/src/lib.rs | 8 ++++---- gateway/src/commands/mod.rs | 10 +++++----- mixnode/src/commands/init.rs | 11 ++++++----- mixnode/src/commands/mod.rs | 10 +++++----- mixnode/src/commands/run.rs | 9 +++++---- nym-connect/src-tauri/src/config/mod.rs | 2 +- 8 files changed, 35 insertions(+), 33 deletions(-) diff --git a/clients/native/src/commands/mod.rs b/clients/native/src/commands/mod.rs index cf40470556..8f90690f86 100644 --- a/clients/native/src/commands/mod.rs +++ b/clients/native/src/commands/mod.rs @@ -104,24 +104,24 @@ pub(crate) fn override_config(mut config: Config, args: OverrideConfig) -> Confi if let Some(raw_validators) = args.nymd_validators { config .get_base_mut() - .set_custom_validators(config::parse_validators(&raw_validators)); + .set_custom_validators(config::parse_urls(&raw_validators)); } else if std::env::var(network_defaults::var_names::CONFIGURED).is_ok() { let raw_validators = std::env::var(network_defaults::var_names::NYMD_VALIDATOR) .expect("nymd validator not set"); config .get_base_mut() - .set_custom_validators(config::parse_validators(&raw_validators)); + .set_custom_validators(config::parse_urls(&raw_validators)); } if let Some(raw_validators) = args.api_validators { config .get_base_mut() - .set_custom_nym_apis(config::parse_validators(&raw_validators)); + .set_custom_nym_apis(config::parse_urls(&raw_validators)); } else if std::env::var(network_defaults::var_names::CONFIGURED).is_ok() { let raw_validators = std::env::var(network_defaults::var_names::API_VALIDATOR) .expect("api validator not set"); config .get_base_mut() - .set_custom_nym_apis(config::parse_validators(&raw_validators)); + .set_custom_nym_apis(config::parse_urls(&raw_validators)); } if args.disable_socket { diff --git a/clients/socks5/src/commands/mod.rs b/clients/socks5/src/commands/mod.rs index 4d4345f1ce..3a25e17af9 100644 --- a/clients/socks5/src/commands/mod.rs +++ b/clients/socks5/src/commands/mod.rs @@ -7,7 +7,7 @@ use crate::client::config::Config; use clap::CommandFactory; use clap::{Parser, Subcommand}; use completions::{fig_generate, ArgShell}; -use config::parse_validators; +use config::parse_urls; pub mod init; pub(crate) mod run; @@ -107,20 +107,20 @@ pub(crate) fn override_config(mut config: Config, args: OverrideConfig) -> Confi if let Some(raw_validators) = args.nymd_validators { config .get_base_mut() - .set_custom_validators(parse_validators(&raw_validators)); + .set_custom_validators(parse_urls(&raw_validators)); } else if let Ok(raw_validators) = std::env::var(network_defaults::var_names::NYMD_VALIDATOR) { config .get_base_mut() - .set_custom_validators(parse_validators(&raw_validators)); + .set_custom_validators(parse_urls(&raw_validators)); } if let Some(raw_validators) = args.api_validators { config .get_base_mut() - .set_custom_nym_apis(parse_validators(&raw_validators)); + .set_custom_nym_apis(parse_urls(&raw_validators)); } else if let Ok(raw_validators) = std::env::var(network_defaults::var_names::API_VALIDATOR) { config .get_base_mut() - .set_custom_nym_apis(parse_validators(&raw_validators)); + .set_custom_nym_apis(parse_urls(&raw_validators)); } if args.use_anonymous_sender_tag { diff --git a/common/config/src/lib.rs b/common/config/src/lib.rs index f7bf7c2149..eb53cd698b 100644 --- a/common/config/src/lib.rs +++ b/common/config/src/lib.rs @@ -118,13 +118,13 @@ pub trait NymConfig: Default + Serialize + DeserializeOwned { } } -pub fn parse_validators(raw: &str) -> Vec { +pub fn parse_urls(raw: &str) -> Vec { raw.split(',') - .map(|raw_validator| { - raw_validator + .map(|raw_url| { + raw_url .trim() .parse() - .expect("one of the provided validator api urls is invalid") + .expect("one of the provided nym api urls is invalid") }) .collect() } diff --git a/gateway/src/commands/mod.rs b/gateway/src/commands/mod.rs index b3fbb6f537..12b809d430 100644 --- a/gateway/src/commands/mod.rs +++ b/gateway/src/commands/mod.rs @@ -8,7 +8,7 @@ use clap::CommandFactory; use clap::Subcommand; use colored::Colorize; use completions::{fig_generate, ArgShell}; -use config::parse_validators; +use config::parse_urls; use crypto::bech32_address_validation; use network_defaults::mainnet::read_var_if_not_default; use network_defaults::var_names::{ @@ -120,18 +120,18 @@ pub(crate) fn override_config(mut config: Config, args: OverrideConfig) -> Confi } if let Some(raw_validators) = args.nym_apis { - config = config.with_custom_nym_apis(parse_validators(&raw_validators)); + config = config.with_custom_nym_apis(parse_urls(&raw_validators)); } else if std::env::var(CONFIGURED).is_ok() { if let Some(raw_validators) = read_var_if_not_default(API_VALIDATOR) { - config = config.with_custom_nym_apis(::config::parse_validators(&raw_validators)) + config = config.with_custom_nym_apis(::config::parse_urls(&raw_validators)) } } if let Some(ref raw_validators) = args.validators { - config = config.with_custom_validator_nymd(parse_validators(raw_validators)); + config = config.with_custom_validator_nymd(parse_urls(raw_validators)); } else if std::env::var(CONFIGURED).is_ok() { if let Some(raw_validators) = read_var_if_not_default(NYMD_VALIDATOR) { - config = config.with_custom_validator_nymd(::config::parse_validators(&raw_validators)) + config = config.with_custom_validator_nymd(::config::parse_urls(&raw_validators)) } } diff --git a/mixnode/src/commands/init.rs b/mixnode/src/commands/init.rs index 7d848c7849..d3e6036ba0 100644 --- a/mixnode/src/commands/init.rs +++ b/mixnode/src/commands/init.rs @@ -1,4 +1,4 @@ -// Copyright 2020 - Nym Technologies SA +// Copyright 2020-2023 - Nym Technologies SA // SPDX-License-Identifier: Apache-2.0 use crate::config::Config; @@ -40,9 +40,10 @@ pub(crate) struct Init { #[clap(long)] announce_host: Option, - /// Comma separated list of rest endpoints of the validators - #[clap(long)] - validators: Option, + /// Comma separated list of nym-api endpoints of the validators + // the alias here is included for backwards compatibility (1.1.4 and before) + #[clap(long, alias = "validators")] + nym_apis: Option, } impl From for OverrideConfig { @@ -55,7 +56,7 @@ impl From for OverrideConfig { verloc_port: init_config.verloc_port, http_api_port: init_config.http_api_port, announce_host: init_config.announce_host, - validators: init_config.validators, + nym_apis: init_config.nym_apis, } } } diff --git a/mixnode/src/commands/mod.rs b/mixnode/src/commands/mod.rs index 86f54af703..7eaf4b5347 100644 --- a/mixnode/src/commands/mod.rs +++ b/mixnode/src/commands/mod.rs @@ -11,7 +11,7 @@ use completions::{fig_generate, ArgShell}; use config::defaults::mainnet::read_var_if_not_default; use config::{ defaults::var_names::{API_VALIDATOR, BECH32_PREFIX, CONFIGURED}, - parse_validators, + parse_urls, }; use crypto::bech32_address_validation; @@ -58,7 +58,7 @@ struct OverrideConfig { verloc_port: Option, http_api_port: Option, announce_host: Option, - validators: Option, + nym_apis: Option, } pub(crate) async fn execute(args: Cli) { @@ -95,11 +95,11 @@ fn override_config(mut config: Config, args: OverrideConfig) -> Config { config = config.with_http_api_port(port); } - if let Some(ref raw_validators) = args.validators { - config = config.with_custom_nym_apis(parse_validators(raw_validators)); + if let Some(ref raw_validators) = args.nym_apis { + config = config.with_custom_nym_apis(parse_urls(raw_validators)); } else if std::env::var(CONFIGURED).is_ok() { if let Some(raw_validators) = read_var_if_not_default(API_VALIDATOR) { - config = config.with_custom_nym_apis(::config::parse_validators(&raw_validators)) + config = config.with_custom_nym_apis(::config::parse_urls(&raw_validators)) } } diff --git a/mixnode/src/commands/run.rs b/mixnode/src/commands/run.rs index c0106034b9..37786730fe 100644 --- a/mixnode/src/commands/run.rs +++ b/mixnode/src/commands/run.rs @@ -39,9 +39,10 @@ pub(crate) struct Run { #[clap(long)] announce_host: Option, - /// Comma separated list of rest endpoints of the validators - #[clap(long)] - validators: Option, + /// Comma separated list of nym-api endpoints of the validators + // the alias here is included for backwards compatibility (1.1.4 and before) + #[clap(long, alias = "validators")] + nym_apis: Option, } impl From for OverrideConfig { @@ -54,7 +55,7 @@ impl From for OverrideConfig { verloc_port: run_config.verloc_port, http_api_port: run_config.http_api_port, announce_host: run_config.announce_host, - validators: run_config.validators, + nym_apis: run_config.nym_apis, } } } diff --git a/nym-connect/src-tauri/src/config/mod.rs b/nym-connect/src-tauri/src/config/mod.rs index fcbd9a2d96..34bf7efcfb 100644 --- a/nym-connect/src-tauri/src/config/mod.rs +++ b/nym-connect/src-tauri/src/config/mod.rs @@ -130,7 +130,7 @@ pub async fn init_socks5_config(provider_address: String, chosen_gateway_id: Str if let Ok(raw_validators) = std::env::var(config_common::defaults::var_names::API_VALIDATOR) { config .get_base_mut() - .set_custom_nym_apis(config_common::parse_validators(&raw_validators)); + .set_custom_nym_apis(config_common::parse_urls(&raw_validators)); } // Setup gateway by either registering a new one, or reusing exiting keys From 4f6b4317d4250b94fc9f07902f86a6ea2578820f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C4=99drzej=20Stuczy=C5=84ski?= Date: Tue, 3 Jan 2023 15:34:17 +0000 Subject: [PATCH 4/9] cleaned up gateway validator-related url arguments --- gateway/src/commands/init.rs | 20 ++++++++++++-------- gateway/src/commands/mod.rs | 4 ++-- gateway/src/commands/run.rs | 20 ++++++++++++-------- 3 files changed, 26 insertions(+), 18 deletions(-) diff --git a/gateway/src/commands/init.rs b/gateway/src/commands/init.rs index abd668b33f..3b2ddad827 100644 --- a/gateway/src/commands/init.rs +++ b/gateway/src/commands/init.rs @@ -40,12 +40,15 @@ pub struct Init { datastore: Option, /// Comma separated list of endpoints of nym APIs - #[clap(long)] + #[clap(long, alias = "validator_apis")] + // the alias here is included for backwards compatibility (1.1.4 and before) nym_apis: Option, /// Comma separated list of endpoints of the validator - #[clap(long)] - validators: Option, + #[cfg(feature = "coconut")] + #[clap(long, alias = "validators")] + // the alias here is included for backwards compatibility (1.1.4 and before) + nymd_endpoints: Option, /// Cosmos wallet mnemonic needed for double spending protection #[clap(long)] @@ -76,14 +79,15 @@ impl From for OverrideConfig { datastore: init_config.datastore, announce_host: init_config.announce_host, nym_apis: init_config.nym_apis, - validators: init_config.validators, mnemonic: init_config.mnemonic, - #[cfg(feature = "coconut")] - only_coconut_credentials: init_config.only_coconut_credentials, - enabled_statistics: init_config.enabled_statistics, statistics_service_url: init_config.statistics_service_url, + + #[cfg(feature = "coconut")] + nymd_endpoints: init_config.nymd_endpoints, + #[cfg(feature = "coconut")] + only_coconut_credentials: init_config.only_coconut_credentials, } } } @@ -166,7 +170,7 @@ mod tests { announce_host: Some("foo-announce-host".to_string()), datastore: Some("foo-datastore".to_string()), nym_apis: None, - validators: None, + nymd_endpoints: None, mnemonic: None, statistics_service_url: None, enabled_statistics: None, diff --git a/gateway/src/commands/mod.rs b/gateway/src/commands/mod.rs index 12b809d430..32dac80f54 100644 --- a/gateway/src/commands/mod.rs +++ b/gateway/src/commands/mod.rs @@ -56,7 +56,7 @@ pub(crate) struct OverrideConfig { enabled_statistics: Option, statistics_service_url: Option, nym_apis: Option, - validators: Option, + nymd_endpoints: Option, mnemonic: Option, #[cfg(feature = "coconut")] @@ -127,7 +127,7 @@ pub(crate) fn override_config(mut config: Config, args: OverrideConfig) -> Confi } } - if let Some(ref raw_validators) = args.validators { + if let Some(ref raw_validators) = args.nymd_endpoints { config = config.with_custom_validator_nymd(parse_urls(raw_validators)); } else if std::env::var(CONFIGURED).is_ok() { if let Some(raw_validators) = read_var_if_not_default(NYMD_VALIDATOR) { diff --git a/gateway/src/commands/run.rs b/gateway/src/commands/run.rs index e91f260d1b..a8bd2e6c47 100644 --- a/gateway/src/commands/run.rs +++ b/gateway/src/commands/run.rs @@ -39,13 +39,16 @@ pub struct Run { #[clap(long)] datastore: Option, - /// Comma separated list of endpoints of the nym APIs - #[clap(long)] + /// Comma separated list of endpoints of nym APIs + #[clap(long, alias = "validator_apis")] + // the alias here is included for backwards compatibility (1.1.4 and before) nym_apis: Option, /// Comma separated list of endpoints of the validator - #[clap(long)] - validators: Option, + #[cfg(feature = "coconut")] + #[clap(long, alias = "validators")] + // the alias here is included for backwards compatibility (1.1.4 and before) + nymd_endpoints: Option, /// Cosmos wallet mnemonic #[clap(long)] @@ -76,14 +79,15 @@ impl From for OverrideConfig { datastore: run_config.datastore, announce_host: run_config.announce_host, nym_apis: run_config.nym_apis, - validators: run_config.validators, mnemonic: run_config.mnemonic, - #[cfg(feature = "coconut")] - only_coconut_credentials: run_config.only_coconut_credentials, - enabled_statistics: run_config.enabled_statistics, statistics_service_url: run_config.statistics_service_url, + + #[cfg(feature = "coconut")] + nymd_endpoints: run_config.nymd_endpoints, + #[cfg(feature = "coconut")] + only_coconut_credentials: run_config.only_coconut_credentials, } } } From f68f3957a852f461f25073931a5807b3ba334b0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C4=99drzej=20Stuczy=C5=84ski?= Date: Thu, 15 Dec 2022 10:16:12 +0000 Subject: [PATCH 5/9] fixup! Renamed "address" argument in "sign" command to "wallet-address" --- gateway/src/commands/sign.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gateway/src/commands/sign.rs b/gateway/src/commands/sign.rs index 3449648378..696ebdc859 100644 --- a/gateway/src/commands/sign.rs +++ b/gateway/src/commands/sign.rs @@ -12,7 +12,7 @@ use crypto::asymmetric::identity; use log::error; #[derive(Args, Clone)] -#[clap(group(ArgGroup::new("sign").required(true).args(&["wallet_address", "text"])))] +#[clap(group(ArgGroup::new("sign").required(true).args(&["wallet-address", "text"])))] pub struct Sign { /// The id of the mixnode you want to sign with #[clap(long)] From f0b89851f60f001854efdccd97b6a338cf6591a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C4=99drzej=20Stuczy=C5=84ski?= Date: Tue, 3 Jan 2023 15:59:42 +0000 Subject: [PATCH 6/9] renamed 'use_anonymous_sender_tag' to 'use_anonymous_replies' --- clients/socks5/src/commands/init.rs | 7 ++++--- clients/socks5/src/commands/mod.rs | 4 ++-- clients/socks5/src/commands/run.rs | 7 ++++--- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/clients/socks5/src/commands/init.rs b/clients/socks5/src/commands/init.rs index 70e8935ca3..f5eeadba58 100644 --- a/clients/socks5/src/commands/init.rs +++ b/clients/socks5/src/commands/init.rs @@ -28,8 +28,9 @@ pub(crate) struct Init { /// slower and consume nearly double the bandwidth as it will require sending reply SURBs. /// /// Note that some service providers might not support this. - #[clap(long)] - use_anonymous_sender_tag: bool, + // the alias here is included for backwards compatibility (1.1.4 and before) + #[clap(long, alias = "use_anonymous_sender_tag")] + use_reply_surbs: bool, /// Id of the gateway we are going to connect to. #[clap(long)] @@ -78,7 +79,7 @@ impl From for OverrideConfig { nymd_validators: init_config.nymd_validators, api_validators: init_config.api_validators, port: init_config.port, - use_anonymous_sender_tag: init_config.use_anonymous_sender_tag, + use_anonymous_replies: init_config.use_reply_surbs, fastmode: init_config.fastmode, no_cover: init_config.no_cover, #[cfg(feature = "coconut")] diff --git a/clients/socks5/src/commands/mod.rs b/clients/socks5/src/commands/mod.rs index 3a25e17af9..f84f185187 100644 --- a/clients/socks5/src/commands/mod.rs +++ b/clients/socks5/src/commands/mod.rs @@ -82,7 +82,7 @@ pub(crate) struct OverrideConfig { nymd_validators: Option, api_validators: Option, port: Option, - use_anonymous_sender_tag: bool, + use_anonymous_replies: bool, fastmode: bool, no_cover: bool, @@ -123,7 +123,7 @@ pub(crate) fn override_config(mut config: Config, args: OverrideConfig) -> Confi .set_custom_nym_apis(parse_urls(&raw_validators)); } - if args.use_anonymous_sender_tag { + if args.use_anonymous_replies { config = config.with_anonymous_replies(true) } diff --git a/clients/socks5/src/commands/run.rs b/clients/socks5/src/commands/run.rs index 807186b7ed..04e926cb42 100644 --- a/clients/socks5/src/commands/run.rs +++ b/clients/socks5/src/commands/run.rs @@ -27,8 +27,9 @@ pub(crate) struct Run { /// slower and consume nearly double the bandwidth as it will require sending reply SURBs. /// /// Note that some service providers might not support this. - #[clap(long)] - use_anonymous_sender_tag: bool, + // the alias here is included for backwards compatibility (1.1.4 and before) + #[clap(long, alias = "use_anonymous_sender_tag")] + use_anonymous_replies: bool, /// Address of the socks5 provider to send messages to. #[clap(long)] @@ -73,7 +74,7 @@ impl From for OverrideConfig { nymd_validators: run_config.nymd_validators, api_validators: run_config.nym_apis, port: run_config.port, - use_anonymous_sender_tag: run_config.use_anonymous_sender_tag, + use_anonymous_replies: run_config.use_anonymous_replies, fastmode: run_config.fastmode, no_cover: run_config.no_cover, #[cfg(feature = "coconut")] From 3932160fbe4b035533b339bc8c282128956c316a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C4=99drzej=20Stuczy=C5=84ski?= Date: Tue, 3 Jan 2023 16:05:22 +0000 Subject: [PATCH 7/9] 'nymd_endpoints => 'nymd_validators' --- gateway/src/commands/init.rs | 6 +++--- gateway/src/commands/mod.rs | 4 ++-- gateway/src/commands/run.rs | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/gateway/src/commands/init.rs b/gateway/src/commands/init.rs index 3b2ddad827..b1b39af3e7 100644 --- a/gateway/src/commands/init.rs +++ b/gateway/src/commands/init.rs @@ -48,7 +48,7 @@ pub struct Init { #[cfg(feature = "coconut")] #[clap(long, alias = "validators")] // the alias here is included for backwards compatibility (1.1.4 and before) - nymd_endpoints: Option, + nymd_validators: Option, /// Cosmos wallet mnemonic needed for double spending protection #[clap(long)] @@ -85,7 +85,7 @@ impl From for OverrideConfig { statistics_service_url: init_config.statistics_service_url, #[cfg(feature = "coconut")] - nymd_endpoints: init_config.nymd_endpoints, + nymd_validators: init_config.nymd_validators, #[cfg(feature = "coconut")] only_coconut_credentials: init_config.only_coconut_credentials, } @@ -170,7 +170,7 @@ mod tests { announce_host: Some("foo-announce-host".to_string()), datastore: Some("foo-datastore".to_string()), nym_apis: None, - nymd_endpoints: None, + nymd_validators: None, mnemonic: None, statistics_service_url: None, enabled_statistics: None, diff --git a/gateway/src/commands/mod.rs b/gateway/src/commands/mod.rs index 32dac80f54..292d5b68f4 100644 --- a/gateway/src/commands/mod.rs +++ b/gateway/src/commands/mod.rs @@ -56,7 +56,7 @@ pub(crate) struct OverrideConfig { enabled_statistics: Option, statistics_service_url: Option, nym_apis: Option, - nymd_endpoints: Option, + nymd_validators: Option, mnemonic: Option, #[cfg(feature = "coconut")] @@ -127,7 +127,7 @@ pub(crate) fn override_config(mut config: Config, args: OverrideConfig) -> Confi } } - if let Some(ref raw_validators) = args.nymd_endpoints { + if let Some(ref raw_validators) = args.nymd_validators { config = config.with_custom_validator_nymd(parse_urls(raw_validators)); } else if std::env::var(CONFIGURED).is_ok() { if let Some(raw_validators) = read_var_if_not_default(NYMD_VALIDATOR) { diff --git a/gateway/src/commands/run.rs b/gateway/src/commands/run.rs index a8bd2e6c47..369822bf88 100644 --- a/gateway/src/commands/run.rs +++ b/gateway/src/commands/run.rs @@ -48,7 +48,7 @@ pub struct Run { #[cfg(feature = "coconut")] #[clap(long, alias = "validators")] // the alias here is included for backwards compatibility (1.1.4 and before) - nymd_endpoints: Option, + nymd_validators: Option, /// Cosmos wallet mnemonic #[clap(long)] @@ -85,7 +85,7 @@ impl From for OverrideConfig { statistics_service_url: run_config.statistics_service_url, #[cfg(feature = "coconut")] - nymd_endpoints: run_config.nymd_endpoints, + nymd_validators: run_config.nymd_validators, #[cfg(feature = "coconut")] only_coconut_credentials: run_config.only_coconut_credentials, } From d61aedc952f9d12f65faa7b4b940e26ddcc5169c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C4=99drzej=20Stuczy=C5=84ski?= Date: Tue, 3 Jan 2023 16:18:50 +0000 Subject: [PATCH 8/9] more consistency for nymd_validators and nym_apis urls arguments --- clients/native/src/commands/init.rs | 11 +++++++---- clients/native/src/commands/mod.rs | 29 +++++++++++++++-------------- clients/native/src/commands/run.rs | 14 +++++++++----- clients/socks5/src/commands/init.rs | 12 ++++++++---- clients/socks5/src/commands/mod.rs | 27 +++++++++++++++------------ clients/socks5/src/commands/run.rs | 7 +++++-- gateway/src/commands/mod.rs | 22 ++++++++++++---------- gateway/src/config/mod.rs | 1 + 8 files changed, 72 insertions(+), 51 deletions(-) diff --git a/clients/native/src/commands/init.rs b/clients/native/src/commands/init.rs index 3caf3a5d0d..098fab5754 100644 --- a/clients/native/src/commands/init.rs +++ b/clients/native/src/commands/init.rs @@ -30,11 +30,13 @@ pub(crate) struct Init { /// Comma separated list of rest endpoints of the nymd validators #[clap(long)] + #[cfg(feature = "coconut")] nymd_validators: Option, /// Comma separated list of rest endpoints of the API validators - #[clap(long)] - api_validators: Option, + #[clap(long, alias = "api_validators")] + // the alias here is included for backwards compatibility (1.1.4 and before) + nym_apis: Option, /// Whether to not start the websocket #[clap(long)] @@ -67,13 +69,14 @@ pub(crate) struct Init { impl From for OverrideConfig { fn from(init_config: Init) -> Self { OverrideConfig { - nymd_validators: init_config.nymd_validators, - api_validators: init_config.api_validators, + nym_apis: init_config.nym_apis, disable_socket: init_config.disable_socket, port: init_config.port, fastmode: init_config.fastmode, no_cover: init_config.no_cover, + #[cfg(feature = "coconut")] + nymd_validators: init_config.nymd_validators, #[cfg(feature = "coconut")] enabled_credentials_mode: init_config.enabled_credentials_mode, } diff --git a/clients/native/src/commands/mod.rs b/clients/native/src/commands/mod.rs index 8f90690f86..c2ad5ec9f6 100644 --- a/clients/native/src/commands/mod.rs +++ b/clients/native/src/commands/mod.rs @@ -76,13 +76,14 @@ pub(crate) enum Commands { // Configuration that can be overridden. pub(crate) struct OverrideConfig { - nymd_validators: Option, - api_validators: Option, + nym_apis: Option, disable_socket: bool, port: Option, fastmode: bool, no_cover: bool, + #[cfg(feature = "coconut")] + nymd_validators: Option, #[cfg(feature = "coconut")] enabled_credentials_mode: bool, } @@ -101,18 +102,7 @@ pub(crate) async fn execute(args: &Cli) -> Result<(), Box Config { - if let Some(raw_validators) = args.nymd_validators { - config - .get_base_mut() - .set_custom_validators(config::parse_urls(&raw_validators)); - } else if std::env::var(network_defaults::var_names::CONFIGURED).is_ok() { - let raw_validators = std::env::var(network_defaults::var_names::NYMD_VALIDATOR) - .expect("nymd validator not set"); - config - .get_base_mut() - .set_custom_validators(config::parse_urls(&raw_validators)); - } - if let Some(raw_validators) = args.api_validators { + if let Some(raw_validators) = args.nym_apis { config .get_base_mut() .set_custom_nym_apis(config::parse_urls(&raw_validators)); @@ -134,6 +124,17 @@ pub(crate) fn override_config(mut config: Config, args: OverrideConfig) -> Confi #[cfg(feature = "coconut")] { + if let Some(raw_validators) = args.nymd_validators { + config + .get_base_mut() + .set_custom_validators(config::parse_urls(&raw_validators)); + } else if std::env::var(network_defaults::var_names::CONFIGURED).is_ok() { + let raw_validators = std::env::var(network_defaults::var_names::NYMD_VALIDATOR) + .expect("nymd validator not set"); + config + .get_base_mut() + .set_custom_validators(config::parse_urls(&raw_validators)); + } if args.enabled_credentials_mode { config.get_base_mut().with_disabled_credentials(false) } diff --git a/clients/native/src/commands/run.rs b/clients/native/src/commands/run.rs index b5d606a112..db3d0cedad 100644 --- a/clients/native/src/commands/run.rs +++ b/clients/native/src/commands/run.rs @@ -1,4 +1,4 @@ -// Copyright 2021 - Nym Technologies SA +// Copyright 2021-2023 - Nym Technologies SA // SPDX-License-Identifier: Apache-2.0 use std::error::Error; @@ -22,11 +22,13 @@ pub(crate) struct Run { /// Comma separated list of rest endpoints of the nymd validators #[clap(long)] + #[cfg(feature = "coconut")] nymd_validators: Option, /// Comma separated list of rest endpoints of the API validators - #[clap(long)] - api_validators: Option, + #[clap(long, alias = "api_validators")] + // the alias here is included for backwards compatibility (1.1.4 and before) + nym_apis: Option, /// Id of the gateway we want to connect to. If overridden, it is user's responsibility to /// ensure prior registration happened @@ -60,12 +62,14 @@ pub(crate) struct Run { impl From for OverrideConfig { fn from(run_config: Run) -> Self { OverrideConfig { - nymd_validators: run_config.nymd_validators, - api_validators: run_config.api_validators, + nym_apis: run_config.nym_apis, disable_socket: run_config.disable_socket, port: run_config.port, fastmode: run_config.fastmode, no_cover: run_config.no_cover, + + #[cfg(feature = "coconut")] + nymd_validators: run_config.nymd_validators, #[cfg(feature = "coconut")] enabled_credentials_mode: run_config.enabled_credentials_mode, } diff --git a/clients/socks5/src/commands/init.rs b/clients/socks5/src/commands/init.rs index f5eeadba58..2f53e61d08 100644 --- a/clients/socks5/src/commands/init.rs +++ b/clients/socks5/src/commands/init.rs @@ -42,12 +42,14 @@ pub(crate) struct Init { force_register_gateway: bool, /// Comma separated list of rest endpoints of the nymd validators + #[cfg(feature = "coconut")] #[clap(long)] nymd_validators: Option, /// Comma separated list of rest endpoints of the API validators - #[clap(long)] - api_validators: Option, + #[clap(long, alias = "api_validators")] + // the alias here is included for backwards compatibility (1.1.4 and before) + nym_apis: Option, /// Port for the socket to listen on in all subsequent runs #[clap(short, long)] @@ -76,12 +78,14 @@ pub(crate) struct Init { impl From for OverrideConfig { fn from(init_config: Init) -> Self { OverrideConfig { - nymd_validators: init_config.nymd_validators, - api_validators: init_config.api_validators, + nym_apis: init_config.nym_apis, port: init_config.port, use_anonymous_replies: init_config.use_reply_surbs, fastmode: init_config.fastmode, no_cover: init_config.no_cover, + + #[cfg(feature = "coconut")] + nymd_validators: init_config.nymd_validators, #[cfg(feature = "coconut")] enabled_credentials_mode: init_config.enabled_credentials_mode, } diff --git a/clients/socks5/src/commands/mod.rs b/clients/socks5/src/commands/mod.rs index f84f185187..39368dfb64 100644 --- a/clients/socks5/src/commands/mod.rs +++ b/clients/socks5/src/commands/mod.rs @@ -79,13 +79,14 @@ pub(crate) enum Commands { // Configuration that can be overridden. pub(crate) struct OverrideConfig { - nymd_validators: Option, - api_validators: Option, + nym_apis: Option, port: Option, use_anonymous_replies: bool, fastmode: bool, no_cover: bool, + #[cfg(feature = "coconut")] + nymd_validators: Option, #[cfg(feature = "coconut")] enabled_credentials_mode: bool, } @@ -104,16 +105,7 @@ pub(crate) async fn execute(args: &Cli) -> Result<(), Box Config { - if let Some(raw_validators) = args.nymd_validators { - config - .get_base_mut() - .set_custom_validators(parse_urls(&raw_validators)); - } else if let Ok(raw_validators) = std::env::var(network_defaults::var_names::NYMD_VALIDATOR) { - config - .get_base_mut() - .set_custom_validators(parse_urls(&raw_validators)); - } - if let Some(raw_validators) = args.api_validators { + if let Some(raw_validators) = args.nym_apis { config .get_base_mut() .set_custom_nym_apis(parse_urls(&raw_validators)); @@ -133,6 +125,17 @@ pub(crate) fn override_config(mut config: Config, args: OverrideConfig) -> Confi #[cfg(feature = "coconut")] { + if let Some(raw_validators) = args.nymd_validators { + config + .get_base_mut() + .set_custom_validators(parse_urls(&raw_validators)); + } else if let Ok(raw_validators) = + std::env::var(network_defaults::var_names::NYMD_VALIDATOR) + { + config + .get_base_mut() + .set_custom_validators(parse_urls(&raw_validators)); + } if args.enabled_credentials_mode { config.get_base_mut().with_disabled_credentials(false) } diff --git a/clients/socks5/src/commands/run.rs b/clients/socks5/src/commands/run.rs index 04e926cb42..a92715aa97 100644 --- a/clients/socks5/src/commands/run.rs +++ b/clients/socks5/src/commands/run.rs @@ -41,6 +41,7 @@ pub(crate) struct Run { gateway: Option, /// Comma separated list of rest endpoints of the nymd validators + #[cfg(feature = "coconut")] #[clap(long)] nymd_validators: Option, @@ -71,12 +72,14 @@ pub(crate) struct Run { impl From for OverrideConfig { fn from(run_config: Run) -> Self { OverrideConfig { - nymd_validators: run_config.nymd_validators, - api_validators: run_config.nym_apis, + nym_apis: run_config.nym_apis, port: run_config.port, use_anonymous_replies: run_config.use_anonymous_replies, fastmode: run_config.fastmode, no_cover: run_config.no_cover, + + #[cfg(feature = "coconut")] + nymd_validators: run_config.nymd_validators, #[cfg(feature = "coconut")] enabled_credentials_mode: run_config.enabled_credentials_mode, } diff --git a/gateway/src/commands/mod.rs b/gateway/src/commands/mod.rs index 292d5b68f4..46bfbc69a3 100644 --- a/gateway/src/commands/mod.rs +++ b/gateway/src/commands/mod.rs @@ -12,7 +12,7 @@ use config::parse_urls; use crypto::bech32_address_validation; use network_defaults::mainnet::read_var_if_not_default; use network_defaults::var_names::{ - API_VALIDATOR, BECH32_PREFIX, CONFIGURED, NYMD_VALIDATOR, STATISTICS_SERVICE_DOMAIN_ADDRESS, + API_VALIDATOR, BECH32_PREFIX, CONFIGURED, STATISTICS_SERVICE_DOMAIN_ADDRESS, }; pub(crate) mod init; @@ -56,9 +56,10 @@ pub(crate) struct OverrideConfig { enabled_statistics: Option, statistics_service_url: Option, nym_apis: Option, - nymd_validators: Option, mnemonic: Option, + #[cfg(feature = "coconut")] + nymd_validators: Option, #[cfg(feature = "coconut")] only_coconut_credentials: bool, } @@ -127,14 +128,6 @@ pub(crate) fn override_config(mut config: Config, args: OverrideConfig) -> Confi } } - if let Some(ref raw_validators) = args.nymd_validators { - config = config.with_custom_validator_nymd(parse_urls(raw_validators)); - } else if std::env::var(CONFIGURED).is_ok() { - if let Some(raw_validators) = read_var_if_not_default(NYMD_VALIDATOR) { - config = config.with_custom_validator_nymd(::config::parse_urls(&raw_validators)) - } - } - if let Some(wallet_address) = args.wallet_address { let trimmed = wallet_address.trim(); validate_bech32_address_or_exit(trimmed); @@ -153,6 +146,15 @@ pub(crate) fn override_config(mut config: Config, args: OverrideConfig) -> Confi #[cfg(feature = "coconut")] { + use network_defaults::var_names::NYMD_VALIDATOR; + + if let Some(ref raw_validators) = args.nymd_validators { + config = config.with_custom_validator_nymd(parse_urls(raw_validators)); + } else if std::env::var(CONFIGURED).is_ok() { + if let Some(raw_validators) = read_var_if_not_default(NYMD_VALIDATOR) { + config = config.with_custom_validator_nymd(::config::parse_urls(&raw_validators)) + } + } config = config.with_only_coconut_credentials(args.only_coconut_credentials); } diff --git a/gateway/src/config/mod.rs b/gateway/src/config/mod.rs index 9eb15c1c5a..e562ec2496 100644 --- a/gateway/src/config/mod.rs +++ b/gateway/src/config/mod.rs @@ -149,6 +149,7 @@ impl Config { self } + #[cfg(feature = "coconut")] pub fn with_custom_validator_nymd(mut self, validator_nymd_urls: Vec) -> Self { self.gateway.validator_nymd_urls = validator_nymd_urls; self From ecebbaf9c5b3dd56dfd4bf301807c7cd2c51d20c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C4=99drzej=20Stuczy=C5=84ski?= Date: Tue, 3 Jan 2023 16:49:24 +0000 Subject: [PATCH 9/9] updated changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0ad6a39d1f..7bab113189 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ Post 1.0.0 release, the changelog format is based on [Keep a Changelog](https:// - all-binaries: improved error logging ([#2686]) - native client: bring shutdown logic up to the same level as socks5-client - nym-api, coconut-dkg contract: automatic, time-based dkg epoch state advancement ([#2670]) +- all-binaries: standarised argument names (note: old names should still be accepted) ([#2762] ### Fixed @@ -21,6 +22,7 @@ Post 1.0.0 release, the changelog format is based on [Keep a Changelog](https:// [#2686]: https://github.com/nymtech/nym/pull/2686 [#2670]: https://github.com/nymtech/nym/pull/2670 [#2753]: https://github.com/nymtech/nym/pull/2753 +[#2762]: https://github.com/nymtech/nym/pull/2762 ## [v1.1.4] (2022-12-20)