From 82e6d7335b5ed50cd49417bc9ab70899ee23891e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C4=99drzej=20Stuczy=C5=84ski?= Date: Wed, 27 Apr 2022 16:05:38 +0100 Subject: [PATCH] Bandwidth credentials disabled by default --- clients/client-core/src/config/mod.rs | 2 +- clients/native/src/commands/init.rs | 10 +++++----- clients/native/src/commands/mod.rs | 6 +++--- clients/native/src/commands/run.rs | 8 ++++---- clients/socks5/src/commands/init.rs | 12 ++++++------ clients/socks5/src/commands/mod.rs | 6 +++--- clients/socks5/src/commands/run.rs | 6 +++--- common/client-libs/gateway-client/src/client.rs | 4 ++-- gateway/src/commands/init.rs | 6 +++--- gateway/src/commands/mod.rs | 6 ++++-- gateway/src/config/mod.rs | 2 +- validator-api/src/config/mod.rs | 2 +- validator-api/src/main.rs | 12 ++++++------ 13 files changed, 42 insertions(+), 40 deletions(-) diff --git a/clients/client-core/src/config/mod.rs b/clients/client-core/src/config/mod.rs index 476672973d..27037fe125 100644 --- a/clients/client-core/src/config/mod.rs +++ b/clients/client-core/src/config/mod.rs @@ -354,7 +354,7 @@ impl Default for Client { Client { version: env!("CARGO_PKG_VERSION").to_string(), id: "".to_string(), - disabled_credentials_mode: false, + disabled_credentials_mode: true, validator_api_urls: default_api_endpoints(), private_identity_key_file: Default::default(), public_identity_key_file: Default::default(), diff --git a/clients/native/src/commands/init.rs b/clients/native/src/commands/init.rs index caa70b9b49..2ef90debf1 100644 --- a/clients/native/src/commands/init.rs +++ b/clients/native/src/commands/init.rs @@ -24,7 +24,7 @@ use crate::commands::override_config; #[cfg(feature = "eth")] #[cfg(not(feature = "coconut"))] use crate::commands::{ - DEFAULT_ETH_ENDPOINT, DEFAULT_ETH_PRIVATE_KEY, DISABLED_CREDENTIALS_MODE_ARG_NAME, + DEFAULT_ETH_ENDPOINT, DEFAULT_ETH_PRIVATE_KEY, ENABLED_CREDENTIALS_MODE_ARG_NAME, ETH_ENDPOINT_ARG_NAME, ETH_PRIVATE_KEY_ARG_NAME, }; @@ -66,8 +66,8 @@ pub fn command_args<'a, 'b>() -> clap::App<'a, 'b> { #[cfg(not(feature = "coconut"))] let app = app .arg( - Arg::with_name(DISABLED_CREDENTIALS_MODE_ARG_NAME) - .long(DISABLED_CREDENTIALS_MODE_ARG_NAME) + Arg::with_name(ENABLED_CREDENTIALS_MODE_ARG_NAME) + .long(ENABLED_CREDENTIALS_MODE_ARG_NAME) .help("Set this client to work in a disabled credentials mode that would attempt to use gateway without bandwidth credential requirement. If this value is set, --eth_endpoint and --eth_private_key don't need to be set.") .conflicts_with_all(&[ETH_ENDPOINT_ARG_NAME, ETH_PRIVATE_KEY_ARG_NAME]) ) @@ -75,13 +75,13 @@ pub fn command_args<'a, 'b>() -> clap::App<'a, 'b> { .long(ETH_ENDPOINT_ARG_NAME) .help("URL of an Ethereum full node that we want to use for getting bandwidth tokens from ERC20 tokens. If you don't want to set this value, use --testnet-mode instead") .takes_value(true) - .default_value_if(DISABLED_CREDENTIALS_MODE_ARG_NAME, None, DEFAULT_ETH_ENDPOINT) + .default_value_if(ENABLED_CREDENTIALS_MODE_ARG_NAME, None, DEFAULT_ETH_ENDPOINT) .required(true)) .arg(Arg::with_name(ETH_PRIVATE_KEY_ARG_NAME) .long(ETH_PRIVATE_KEY_ARG_NAME) .help("Ethereum private key used for obtaining bandwidth tokens from ERC20 tokens. If you don't want to set this value, use --testnet-mode instead") .takes_value(true) - .default_value_if(DISABLED_CREDENTIALS_MODE_ARG_NAME, None, DEFAULT_ETH_PRIVATE_KEY) + .default_value_if(ENABLED_CREDENTIALS_MODE_ARG_NAME, None, DEFAULT_ETH_PRIVATE_KEY) .required(true) ); diff --git a/clients/native/src/commands/mod.rs b/clients/native/src/commands/mod.rs index c6ea1788b3..f3a1d408f0 100644 --- a/clients/native/src/commands/mod.rs +++ b/clients/native/src/commands/mod.rs @@ -5,7 +5,7 @@ use crate::client::config::{Config, SocketType}; use clap::ArgMatches; use url::Url; -pub(crate) const DISABLED_CREDENTIALS_MODE_ARG_NAME: &str = "testnet-mode"; +pub(crate) const ENABLED_CREDENTIALS_MODE_ARG_NAME: &str = "enabled-credentials-mode"; #[cfg(not(feature = "coconut"))] pub(crate) const ETH_ENDPOINT_ARG_NAME: &str = "eth_endpoint"; #[cfg(not(feature = "coconut"))] @@ -72,8 +72,8 @@ pub(crate) fn override_config(mut config: Config, matches: &ArgMatches<'_>) -> C .with_eth_private_key(DEFAULT_ETH_PRIVATE_KEY); } - if !cfg!(feature = "eth") || matches.is_present(DISABLED_CREDENTIALS_MODE_ARG_NAME) { - config.get_base_mut().with_disabled_credentials(true) + if matches.is_present(ENABLED_CREDENTIALS_MODE_ARG_NAME) { + config.get_base_mut().with_disabled_credentials(false) } config diff --git a/clients/native/src/commands/run.rs b/clients/native/src/commands/run.rs index 3069205418..1ccbcc9ed9 100644 --- a/clients/native/src/commands/run.rs +++ b/clients/native/src/commands/run.rs @@ -7,7 +7,7 @@ use crate::commands::override_config; #[cfg(feature = "eth")] #[cfg(not(feature = "coconut"))] use crate::commands::{ - DISABLED_CREDENTIALS_MODE_ARG_NAME, ETH_ENDPOINT_ARG_NAME, ETH_PRIVATE_KEY_ARG_NAME, + ENABLED_CREDENTIALS_MODE_ARG_NAME, ETH_ENDPOINT_ARG_NAME, ETH_PRIVATE_KEY_ARG_NAME, }; use clap::{App, Arg, ArgMatches}; use config::NymConfig; @@ -48,9 +48,9 @@ pub fn command_args<'a, 'b>() -> clap::App<'a, 'b> { #[cfg(not(feature = "coconut"))] let app = app .arg( - Arg::with_name(DISABLED_CREDENTIALS_MODE_ARG_NAME) - .long(DISABLED_CREDENTIALS_MODE_ARG_NAME) - .help("Set this client to work in a disabled credentials mode that would attempt to use gateway without bandwidth credential requirement. If this value is set, --eth_endpoint and --eth_private_key don't need to be set.") + Arg::with_name(ENABLED_CREDENTIALS_MODE_ARG_NAME) + .long(ENABLED_CREDENTIALS_MODE_ARG_NAME) + .help("Set this client to work in a enabled credentials mode that would attempt to use gateway with bandwidth credential requirement. If this value is set, --eth_endpoint and --eth_private_key don't need to be set.") .conflicts_with_all(&[ETH_ENDPOINT_ARG_NAME, ETH_PRIVATE_KEY_ARG_NAME]) ) .arg(Arg::with_name(ETH_ENDPOINT_ARG_NAME) diff --git a/clients/socks5/src/commands/init.rs b/clients/socks5/src/commands/init.rs index e31427e9d5..4ada9a6296 100644 --- a/clients/socks5/src/commands/init.rs +++ b/clients/socks5/src/commands/init.rs @@ -22,7 +22,7 @@ use crate::commands::override_config; #[cfg(feature = "eth")] #[cfg(not(feature = "coconut"))] use crate::commands::{ - DEFAULT_ETH_ENDPOINT, DEFAULT_ETH_PRIVATE_KEY, DISABLED_CREDENTIALS_MODE_ARG_NAME, + DEFAULT_ETH_ENDPOINT, DEFAULT_ETH_PRIVATE_KEY, ENABLED_CREDENTIALS_MODE_ARG_NAME, ETH_ENDPOINT_ARG_NAME, ETH_PRIVATE_KEY_ARG_NAME, }; @@ -66,22 +66,22 @@ pub fn command_args<'a, 'b>() -> clap::App<'a, 'b> { #[cfg(not(feature = "coconut"))] let app = app .arg( - Arg::with_name(DISABLED_CREDENTIALS_MODE_ARG_NAME) - .long(DISABLED_CREDENTIALS_MODE_ARG_NAME) - .help("Set this client to work in a disabled credentials mode that would attempt to use gateway without bandwidth credential requirement. If this value is set, --eth_endpoint and --eth_private_key don't need to be set.") + Arg::with_name(ENABLED_CREDENTIALS_MODE_ARG_NAME) + .long(ENABLED_CREDENTIALS_MODE_ARG_NAME) + .help("Set this client to work in a enabled credentials mode that would attempt to use gateway with bandwidth credential requirement. If this value is set, --eth_endpoint and --eth_private_key don't need to be set.") .conflicts_with_all(&[ETH_ENDPOINT_ARG_NAME, ETH_PRIVATE_KEY_ARG_NAME]) ) .arg(Arg::with_name(ETH_ENDPOINT_ARG_NAME) .long(ETH_ENDPOINT_ARG_NAME) .help("URL of an Ethereum full node that we want to use for getting bandwidth tokens from ERC20 tokens. If you don't want to set this value, use --testnet-mode instead") .takes_value(true) - .default_value_if(DISABLED_CREDENTIALS_MODE_ARG_NAME, None, DEFAULT_ETH_ENDPOINT) + .default_value_if(ENABLED_CREDENTIALS_MODE_ARG_NAME, None, DEFAULT_ETH_ENDPOINT) .required(true)) .arg(Arg::with_name(ETH_PRIVATE_KEY_ARG_NAME) .long(ETH_PRIVATE_KEY_ARG_NAME) .help("Ethereum private key used for obtaining bandwidth tokens from ERC20 tokens. If you don't want to set this value, use --testnet-mode instead") .takes_value(true) - .default_value_if(DISABLED_CREDENTIALS_MODE_ARG_NAME, None, DEFAULT_ETH_PRIVATE_KEY) + .default_value_if(ENABLED_CREDENTIALS_MODE_ARG_NAME, None, DEFAULT_ETH_PRIVATE_KEY) .required(true) ); diff --git a/clients/socks5/src/commands/mod.rs b/clients/socks5/src/commands/mod.rs index 0115249299..3aa1131a24 100644 --- a/clients/socks5/src/commands/mod.rs +++ b/clients/socks5/src/commands/mod.rs @@ -9,7 +9,7 @@ pub(crate) mod init; pub(crate) mod run; pub(crate) mod upgrade; -pub(crate) const DISABLED_CREDENTIALS_MODE_ARG_NAME: &str = "testnet-mode"; +pub(crate) const ENABLED_CREDENTIALS_MODE_ARG_NAME: &str = "enabled-credentials-mode"; #[cfg(not(feature = "coconut"))] pub(crate) const ETH_ENDPOINT_ARG_NAME: &str = "eth_endpoint"; #[cfg(not(feature = "coconut"))] @@ -68,8 +68,8 @@ pub(crate) fn override_config(mut config: Config, matches: &ArgMatches<'_>) -> C .with_eth_private_key(DEFAULT_ETH_PRIVATE_KEY); } - if !cfg!(feature = "eth") || matches.is_present(DISABLED_CREDENTIALS_MODE_ARG_NAME) { - config.get_base_mut().with_disabled_credentials(true) + if matches.is_present(ENABLED_CREDENTIALS_MODE_ARG_NAME) { + config.get_base_mut().with_disabled_credentials(false) } config diff --git a/clients/socks5/src/commands/run.rs b/clients/socks5/src/commands/run.rs index b414277afb..889da7e432 100644 --- a/clients/socks5/src/commands/run.rs +++ b/clients/socks5/src/commands/run.rs @@ -7,7 +7,7 @@ use crate::commands::override_config; #[cfg(feature = "eth")] #[cfg(not(feature = "coconut"))] use crate::commands::{ - DISABLED_CREDENTIALS_MODE_ARG_NAME, ETH_ENDPOINT_ARG_NAME, ETH_PRIVATE_KEY_ARG_NAME, + ENABLED_CREDENTIALS_MODE_ARG_NAME, ETH_ENDPOINT_ARG_NAME, ETH_PRIVATE_KEY_ARG_NAME, }; use clap::{App, Arg, ArgMatches}; use config::NymConfig; @@ -54,8 +54,8 @@ pub fn command_args<'a, 'b>() -> clap::App<'a, 'b> { #[cfg(not(feature = "coconut"))] let app = app .arg( - Arg::with_name(DISABLED_CREDENTIALS_MODE_ARG_NAME) - .long(DISABLED_CREDENTIALS_MODE_ARG_NAME) + Arg::with_name(ENABLED_CREDENTIALS_MODE_ARG_NAME) + .long(ENABLED_CREDENTIALS_MODE_ARG_NAME) .help("Set this client to work in a disabled credentials mode that would attempt to use gateway without bandwidth credential requirement. If this value is set, --eth_endpoint and --eth_private_key don't need to be set.") .conflicts_with_all(&[ETH_ENDPOINT_ARG_NAME, ETH_PRIVATE_KEY_ARG_NAME]) ) diff --git a/common/client-libs/gateway-client/src/client.rs b/common/client-libs/gateway-client/src/client.rs index 4f48659e99..0435c6cab4 100644 --- a/common/client-libs/gateway-client/src/client.rs +++ b/common/client-libs/gateway-client/src/client.rs @@ -83,7 +83,7 @@ impl GatewayClient { ) -> Self { GatewayClient { authenticated: false, - disabled_credentials_mode: false, + disabled_credentials_mode: true, bandwidth_remaining: 0, gateway_address, gateway_identity, @@ -134,7 +134,7 @@ impl GatewayClient { GatewayClient { authenticated: false, - disabled_credentials_mode: false, + disabled_credentials_mode: true, bandwidth_remaining: 0, gateway_address, gateway_identity, diff --git a/gateway/src/commands/init.rs b/gateway/src/commands/init.rs index 23634122e9..d43d9bec37 100644 --- a/gateway/src/commands/init.rs +++ b/gateway/src/commands/init.rs @@ -47,10 +47,10 @@ pub struct Init { #[clap(long)] mnemonic: String, - /// Set this gateway to work in a disabled credentials mode that would allow clients to bypass bandwidth credential requirement + /// Set this gateway to work in a enabled credentials mode that would disallow clients to bypass bandwidth credential requirement #[cfg(all(feature = "eth", not(feature = "coconut")))] #[clap(long)] - disabled_credentials_mode: bool, + enabled_credentials_mode: Option, /// URL of an Ethereum full node that we want to use for getting bandwidth tokens from ERC20 tokens #[cfg(all(feature = "eth", not(feature = "coconut")))] @@ -76,7 +76,7 @@ impl From for OverrideConfig { mnemonic: Some(init_config.mnemonic), #[cfg(all(feature = "eth", not(feature = "coconut")))] - disabled_credentials_mode: init_config.disabled_credentials_mode, + enabled_credentials_mode: init_config.enabled_credentials_mode, #[cfg(all(feature = "eth", not(feature = "coconut")))] eth_endpoint: Some(init_config.eth_endpoint), diff --git a/gateway/src/commands/mod.rs b/gateway/src/commands/mod.rs index e89e0c97ca..680636d9b6 100644 --- a/gateway/src/commands/mod.rs +++ b/gateway/src/commands/mod.rs @@ -50,7 +50,7 @@ pub(crate) struct OverrideConfig { mnemonic: Option, #[cfg(all(feature = "eth", not(feature = "coconut")))] - disabled_credentials_mode: bool, + enabled_credentials_mode: Option, #[cfg(all(feature = "eth", not(feature = "coconut")))] eth_endpoint: Option, @@ -134,7 +134,9 @@ pub(crate) fn override_config(mut config: Config, args: OverrideConfig) -> Confi #[cfg(all(feature = "eth", not(feature = "coconut")))] { - config = config.with_disabled_credentials_mode(args.disabled_credentials_mode); + if let Some(enabled_credentials_mode) = args.enabled_credentials_mode { + config = config.with_disabled_credentials_mode(enabled_credentials_mode); + } if let Some(raw_validators) = args.validators { config = config.with_custom_validator_nymd(parse_validators(&raw_validators)); diff --git a/gateway/src/config/mod.rs b/gateway/src/config/mod.rs index 8badbfaf73..e7214ca5ba 100644 --- a/gateway/src/config/mod.rs +++ b/gateway/src/config/mod.rs @@ -388,7 +388,7 @@ impl Default for Gateway { Gateway { version: env!("CARGO_PKG_VERSION").to_string(), id: "".to_string(), - disabled_credentials_mode: false, + disabled_credentials_mode: true, listening_address: bind_all_address(), announce_address: "127.0.0.1".to_string(), mix_port: DEFAULT_MIX_LISTENING_PORT, diff --git a/validator-api/src/config/mod.rs b/validator-api/src/config/mod.rs index 2c7885764f..c3a07d145a 100644 --- a/validator-api/src/config/mod.rs +++ b/validator-api/src/config/mod.rs @@ -200,7 +200,7 @@ impl Default for NetworkMonitor { min_mixnode_reliability: DEFAULT_MIN_MIXNODE_RELIABILITY, min_gateway_reliability: DEFAULT_MIN_GATEWAY_RELIABILITY, enabled: false, - disabled_credentials_mode: false, + disabled_credentials_mode: true, all_validator_apis: default_api_endpoints(), run_interval: DEFAULT_MONITOR_RUN_INTERVAL, gateway_ping_interval: DEFAULT_GATEWAY_PING_INTERVAL, diff --git a/validator-api/src/main.rs b/validator-api/src/main.rs index f175a98d32..7e8288e161 100644 --- a/validator-api/src/main.rs +++ b/validator-api/src/main.rs @@ -50,7 +50,7 @@ const MNEMONIC_ARG: &str = "mnemonic"; const WRITE_CONFIG_ARG: &str = "save-config"; const NYMD_VALIDATOR_ARG: &str = "nymd-validator"; const API_VALIDATORS_ARG: &str = "api-validators"; -const DISABLED_CREDENTIALS_MODE_ARG_NAME: &str = "disabled-credentials-mode"; +const ENABLED_CREDENTIALS_MODE_ARG_NAME: &str = "enabled-credentials-mode"; #[cfg(feature = "coconut")] const KEYPAIR_ARG: &str = "keypair"; @@ -164,9 +164,9 @@ fn parse_args<'a>() -> ArgMatches<'a> { .long(REWARDING_MONITOR_THRESHOLD_ARG) ) .arg( - Arg::with_name(DISABLED_CREDENTIALS_MODE_ARG_NAME) - .long(DISABLED_CREDENTIALS_MODE_ARG_NAME) - .help("Set this validator api to work in a disabled credentials mode that would attempt to use gateway without bandwidth credential requirement") + Arg::with_name(ENABLED_CREDENTIALS_MODE_ARG_NAME) + .long(ENABLED_CREDENTIALS_MODE_ARG_NAME) + .help("Set this validator api to work in a enabled credentials that would attempt to use gateway with the bandwidth credential requirement") ); #[cfg(feature = "coconut")] @@ -320,8 +320,8 @@ fn override_config(mut config: Config, matches: &ArgMatches<'_>) -> Config { config = config.with_eth_endpoint(String::from(eth_endpoint)); } - if matches.is_present(DISABLED_CREDENTIALS_MODE_ARG_NAME) { - config = config.with_disabled_credentials_mode(true) + if matches.is_present(ENABLED_CREDENTIALS_MODE_ARG_NAME) { + config = config.with_disabled_credentials_mode(false) } if matches.is_present(WRITE_CONFIG_ARG) {