From b09acd1442ff6d0ff58530df0698eaa0934a2b61 Mon Sep 17 00:00:00 2001 From: David Main <51991544+StriderDM@users.noreply.github.com> Date: Fri, 26 Nov 2021 15:11:22 +0200 Subject: [PATCH] fix!: console wallet grpc_console_wallet_addresss config (#3619) Description --- This PR changes `grpc_console_wallet_address` to `grpc_address` and moves it into the `wallet` section of the config. It also allows a grpc address to be specified via the `--grpc-address` command line argument for the console_wallet (using standard multiaddr formatting). Additionally, fixes a bug due to a missing config default. How Has This Been Tested? --- cargo test --all nvm use 12.22.6 && node_modules/.bin/cucumber-js --profile "ci" --tags "not @long-running and not @broken" manually (`cargo run --bin tari_console_wallet -- --grpc-address /ip4/127.0.0.1/tcp/18144` + bloomRPC client) --- README.md | 33 +++++++++++-------- applications/launchpad/docker_rig/config.toml | 4 --- .../launchpad/docker_rig/docker-compose.yml | 6 ++-- .../tari_app_utilities/src/initialization.rs | 15 +++++++++ common/config/presets/base_node.toml | 6 ---- common/config/presets/console_wallet.toml | 5 ++- common/config/presets/mining_node.toml | 3 +- common/src/configuration/bootstrap.rs | 3 ++ common/src/configuration/global.rs | 8 ++--- common/src/configuration/utils.rs | 16 +-------- integration_tests/features/support/steps.js | 2 +- integration_tests/helpers/config.js | 2 +- integration_tests/helpers/walletProcess.js | 2 +- 13 files changed, 54 insertions(+), 51 deletions(-) diff --git a/README.md b/README.md index b34b179d2a..b8d3a63517 100644 --- a/README.md +++ b/README.md @@ -129,13 +129,13 @@ First you'll need to make sure you have a full development environment set up: - Build Tools - [CMake](https://cmake.org/download/) (Used for RandomX) - - - Either: + + - Either: - Microsoft Visual Studio Version 2019 or later - C++ CMake tools for Windows - MSVC build tools (latest version for your platform ARM, ARM64 or x64.x86) - Spectre-mitigated libs (latest version for your platform ARM, ARM64 or x64.x86) - + or - [Build Tools for Visual Studio 2019](https://visualstudio.microsoft.com/thank-you-downloading-visual-studio/?sku=BuildTools&rel=16) @@ -432,15 +432,19 @@ will be created in the `~/tari_weatherwax_testnet/config` (on Linux) or `%USERPR directory. With the main configuration file, in addition to the settings already present, the following must also be enabled for -the Tari Base Node and the Tari Console Wallet, if they are not enabled already. Under section **`base_node.weatherwax`**: +the Tari Base Node and the Tari Console Wallet, if they are not enabled already. Under sections **`base_node.weatherwax`** and **`wallet`** respectively: +``` +[wallet] + +grpc_address = "127.0.0.1:18143" +``` ``` [base_node.weatherwax] transport = "tor" allow_test_addresses = false grpc_enabled = true grpc_base_node_address = "127.0.0.1:18142" -grpc_console_wallet_address = "127.0.0.1:18143" ``` For Tari Stratum Transcoder: @@ -468,7 +472,7 @@ For the Tari Mining Node there are some additional settings under section **`min #base_node_grpc_address = "127.0.0.1:18142" # GRPC address of console wallet -# Default: value from `base_node.grpc_console_wallet_address` +# Default: value from `wallet.grpc_address` #wallet_grpc_address = "127.0.0.1:18143" # Start mining only when base node is bootstrapped @@ -492,14 +496,14 @@ For pooled SHA3 mining: # Stratum Mode configuration # mining_pool_address = "miningcore.tari.com:3052" -# mining_wallet_address = "YOUR_WALLET_PUBLIC_KEY" +# mining_wallet_address = "YOUR_WALLET_PUBLIC_KEY" # mining_worker_name = "worker1" ``` -Uncomment `mining_pool_address` and `mining_wallet_address`. Adjust the values to your intended configuration. +Uncomment `mining_pool_address` and `mining_wallet_address`. Adjust the values to your intended configuration. `mining_worker_name` is an optional configuration field allowing you to name your worker. #### Perform SHA3 mining -* For SHA3 mining: +* For SHA3 mining: Tor and the required Tari applications must be started and preferably in this order: - Tor: @@ -545,7 +549,7 @@ and performing mining: * Pool Operators: Tor and the required Tari applications must be started in this order: - Tor: - + - Linux/OSX: Execute `start_tor.sh`. - Windows: `Start Tor Serviecs` menu item or `start_tor` shortcut in the Tari installation folder. @@ -566,7 +570,7 @@ and performing mining: - Tari Mining Node: - Linux/OSX: As per [Runtime links](#runtime-links). - Windows: As per [Runtime links](#runtime-links) or `Start Mining Node` menu item - or `start_tari_mining_node` shortcut in the Tari installation folder. + or `start_tari_mining_node` shortcut in the Tari installation folder. ### Tari merge mining @@ -603,14 +607,17 @@ directory. With the main configuration file, in addition to the settings already present, the following must also be enabled if they are not enabled already: -- For the Tari Base Node and the Tari Console Wallet, under section **`base_node.weatherwax`** +- For the Tari Base Node and the Tari Console Wallet, under sections **`base_node.weatherwax`** and **`wallet`** respectively + ``` + [wallet] + grpc_address = "127.0.0.1:18143" + ``` ``` [base_node.weatherwax] transport = "tor" allow_test_addresses = false grpc_enabled = true grpc_base_node_address = "127.0.0.1:18142" - grpc_console_wallet_address = "127.0.0.1:18143" ``` And then depending on if you are using solo mining or self-select mining you will use one of the following: diff --git a/applications/launchpad/docker_rig/config.toml b/applications/launchpad/docker_rig/config.toml index 20f902026b..9d97586e67 100644 --- a/applications/launchpad/docker_rig/config.toml +++ b/applications/launchpad/docker_rig/config.toml @@ -192,9 +192,6 @@ grpc_enabled = true # The socket to expose for the gRPC base node server. This value is ignored if grpc_enabled is false. # Valid values here are IPv4 and IPv6 TCP sockets, local unix sockets (e.g. "ipc://base-node-gprc.sock.100") grpc_base_node_address = "0.0.0.0:18142" -# The socket to expose for the gRPC wallet server. This value is ignored if grpc_enabled is false. -# Valid values here are IPv4 and IPv6 TCP sockets, local unix sockets (e.g. "ipc://base-node-gprc.sock.100") -grpc_console_wallet_address = "0.0.0.0:18143" # A path to the file that stores your node identity and secret key base_node_identity_file = "config/base_node_id.json" @@ -283,7 +280,6 @@ allow_test_addresses = false # Enable the gRPC server for the base node. Set this to true if you want to enable third-party wallet software grpc_enabled = true grpc_base_node_address = "127.0.0.1:18142" -grpc_console_wallet_address = "127.0.0.1:18143" base_node_identity_file = "config/igor/base_node_id.json" console_wallet_identity_file = "config/igor/console_wallet_id.json" diff --git a/applications/launchpad/docker_rig/docker-compose.yml b/applications/launchpad/docker_rig/docker-compose.yml index e062458ffa..7dde2f30fa 100644 --- a/applications/launchpad/docker_rig/docker-compose.yml +++ b/applications/launchpad/docker_rig/docker-compose.yml @@ -34,7 +34,7 @@ services: TARI_WALLET__WEATHERWAX__TOR_SOCKS_ADDRESS_OVERRIDE: "/dns4/tor/tcp/9050" TARI_WALLET__WEATHERWAX__TOR_FORWARD_ADDRESS: "/dns4/wallet/tcp/18188" TARI_WALLET__WEATHERWAX__TCP_LISTENER_ADDRESS: "/dns4/wallet/tcp/18188" - TARI_BASE_NODE__WEATHERWAX__GRPC_CONSOLE_WALLET_ADDRESS: "0.0.0.0:18143" + TARI_WALLET__GRPC_ADDRESS: "0.0.0.0:18143" command: ["--non-interactive"] ports: - 18188:18188 @@ -101,7 +101,7 @@ services: TARI_MINING_NODE__NUM_MINING_THREADS: 2 TARI_MINING_NODE__MINE_ON_TIP_ONLY: 1 TARI_BASE_NODE__WEATHERWAX__GRPC_BASE_NODE_ADDRESS: "/dns4/base_node/tcp/18142" - TARI_BASE_NODE__WEATHERWAX__GRPC_CONSOLE_WALLET_ADDRESS: "/dns4/wallet/tcp/18143" + TARI_WALLET__GRPC_ADDRESS: "/dns4/wallet/tcp/18143" command: [ ] depends_on: - base_node @@ -158,7 +158,7 @@ services: WAIT_FOR_TOR: 0 TARI_NETWORK: ${TARI_NETWORK} TARI_BASE_NODE__WEATHERWAX__GRPC_BASE_NODE_ADDRESS: "/dns4/base_node/tcp/18142" - TARI_BASE_NODE__WEATHERWAX__GRPC_CONSOLE_WALLET_ADDRESS: "/dns4/wallet/tcp/18143" + TARI_WALLET__GRPC_ADDRESS: "/dns4/wallet/tcp/18143" TARI_MERGE_MINING_PROXY__WEATHERWAX__MONEROD_URL: ${TARI_MONEROD_URL:-http://monero-stagenet.exan.tech:38081} TARI_MERGE_MINING_PROXY__WEATHERWAX__MONEROD_USERNAME: ${TARI_MONEROD_USERNAME} TARI_MERGE_MINING_PROXY__WEATHERWAX__MONEROD_PASSWORD: ${TARI_MONEROD_PASSWORD} diff --git a/applications/tari_app_utilities/src/initialization.rs b/applications/tari_app_utilities/src/initialization.rs index ead5b89f4b..8d84ef4240 100644 --- a/applications/tari_app_utilities/src/initialization.rs +++ b/applications/tari_app_utilities/src/initialization.rs @@ -9,6 +9,7 @@ use tari_common::{ DatabaseType, GlobalConfig, }; +use tari_comms::multiaddr::Multiaddr; pub const LOG_TARGET: &str = "tari::application"; @@ -61,6 +62,20 @@ pub fn init_configuration( }, } } + + if let Some(str) = bootstrap.wallet_grpc_address.clone() { + log::info!( + target: LOG_TARGET, + "{}", + format!("GRPC address specified in command parameters: {}", str) + ); + + let grpc_address = str + .parse::() + .map_err(|_| ExitCodes::InputError("GRPC address is not valid".to_string()))?; + global_config.grpc_console_wallet_address = grpc_address; + } + check_file_paths(&mut global_config, &bootstrap); Ok((bootstrap, global_config, cfg)) diff --git a/common/config/presets/base_node.toml b/common/config/presets/base_node.toml index aa359724c4..f1145ef36e 100644 --- a/common/config/presets/base_node.toml +++ b/common/config/presets/base_node.toml @@ -87,9 +87,6 @@ grpc_enabled = true # The socket to expose for the gRPC base node server. This value is ignored if grpc_enabled is false. # Valid values here are IPv4 and IPv6 TCP sockets, local unix sockets (e.g. "ipc://base-node-gprc.sock.100") grpc_base_node_address = "127.0.0.1:18142" -# The socket to expose for the gRPC wallet server. This value is ignored if grpc_enabled is false. -# Valid values here are IPv4 and IPv6 TCP sockets, local unix sockets (e.g. "ipc://base-node-gprc.sock.100") -grpc_console_wallet_address = "127.0.0.1:18143" # A path to the file that stores your node identity and secret key base_node_identity_file = "config/base_node_id.json" @@ -265,9 +262,6 @@ grpc_enabled = true # The socket to expose for the gRPC base node server. This value is ignored if grpc_enabled is false. # Valid values here are IPv4 and IPv6 TCP sockets, local unix sockets (e.g. "ipc://base-node-gprc.sock.100") grpc_base_node_address = "127.0.0.1:18142" -# The socket to expose for the gRPC wallet server. This value is ignored if grpc_enabled is false. -# Valid values here are IPv4 and IPv6 TCP sockets, local unix sockets (e.g. "ipc://base-node-gprc.sock.100") -grpc_console_wallet_address = "127.0.0.1:18143" # A path to the file that stores your node identity and secret key base_node_identity_file = "config/base_node_id.json" diff --git a/common/config/presets/console_wallet.toml b/common/config/presets/console_wallet.toml index ea7a7a4636..b071343dd0 100644 --- a/common/config/presets/console_wallet.toml +++ b/common/config/presets/console_wallet.toml @@ -14,6 +14,10 @@ wallet_db_file = "wallet/wallet.dat" console_wallet_db_file = "wallet/console-wallet.dat" +# The socket to expose for the gRPC wallet server. This value is ignored if grpc_enabled is false. +# Valid values here are IPv4 and IPv6 TCP sockets, local unix sockets (e.g. "ipc://base-node-gprc.sock.100") +grpc_address = "127.0.0.1:18143" + # Console wallet password # Should you wish to start your console wallet without typing in your password, the following options are available: # 1. Start the console wallet with the --password=secret argument, or @@ -197,4 +201,3 @@ tor_control_auth = "none" # or "password=xxxxxx" # tor_proxy_bypass_addresses = ["/dns4/my-foo-base-node/tcp/9998"] # When using the tor transport and set to true, outbound TCP connections bypass the tor proxy. Defaults to false for better privacy # tor_proxy_bypass_for_outbound_tcp = false; - diff --git a/common/config/presets/mining_node.toml b/common/config/presets/mining_node.toml index 87f3f1aa1f..3c5aa31bb1 100644 --- a/common/config/presets/mining_node.toml +++ b/common/config/presets/mining_node.toml @@ -14,7 +14,7 @@ #base_node_grpc_address = "127.0.0.1:18142" # GRPC address of console wallet -# Default: value from `base_node.grpc_console_wallet_address` +# Default: value from `wallet.grpc_address` #wallet_grpc_address = "127.0.0.1:18143" # Start mining only when base node is bootstrapped @@ -32,4 +32,3 @@ # mining_pool_address = "miningcore.tari.com:3052" # mining_wallet_address = "YOUR_WALLET_PUBLIC_KEY" # mining_worker_name = "worker1" - diff --git a/common/src/configuration/bootstrap.rs b/common/src/configuration/bootstrap.rs index 083b70a9bb..c659fae24f 100644 --- a/common/src/configuration/bootstrap.rs +++ b/common/src/configuration/bootstrap.rs @@ -154,6 +154,8 @@ pub struct ConfigBootstrap { /// Supply a network (overrides existing configuration) #[structopt(long, alias = "network")] pub network: Option, + #[structopt(long, alias = "grpc-address")] + pub wallet_grpc_address: Option, /// Metrics server bind address (prometheus pull) #[structopt(long, alias = "metrics-bind-addr")] pub metrics_server_bind_addr: Option, @@ -196,6 +198,7 @@ impl Default for ConfigBootstrap { miner_max_diff: None, tracing_enabled: false, network: None, + wallet_grpc_address: None, metrics_server_bind_addr: None, metrics_push_endpoint: None, } diff --git a/common/src/configuration/global.rs b/common/src/configuration/global.rs index 34ba629e92..0ee4c92999 100644 --- a/common/src/configuration/global.rs +++ b/common/src/configuration/global.rs @@ -345,11 +345,11 @@ fn convert_node_config( .get_str(&key) .map(|addr| socket_or_multi(&addr).map_err(|e| ConfigurationError::new(&key, &e.to_string())))??; - let key = config_string("base_node", net_str, "grpc_console_wallet_address"); + let key = "wallet.grpc_address"; let grpc_console_wallet_address = cfg - .get_str(&key) - .map_err(|e| ConfigurationError::new(&key, &e.to_string())) - .map(|addr| socket_or_multi(&addr).map_err(|e| ConfigurationError::new(&key, &e.to_string())))??; + .get_str(key) + .map_err(|e| ConfigurationError::new(key, &e.to_string())) + .map(|addr| socket_or_multi(&addr).map_err(|e| ConfigurationError::new(key, &e.to_string())))??; // Peer and DNS seeds let key = "common.peer_seeds"; diff --git a/common/src/configuration/utils.rs b/common/src/configuration/utils.rs index 78aaa5c73e..db72daa146 100644 --- a/common/src/configuration/utils.rs +++ b/common/src/configuration/utils.rs @@ -63,7 +63,6 @@ pub fn config_installer(app_type: ApplicationType, path: &Path) -> Result<(), st /// These will typically be overridden by userland settings in envars, the config file, or the command line. pub fn default_config(bootstrap: &ConfigBootstrap) -> Config { let mut cfg = Config::new(); - let local_ip_addr = get_local_ip().unwrap_or_else(|| "/ip4/1.2.3.4".parse().unwrap()); // Common settings cfg.set_default("common.message_cache_size", 10).unwrap(); @@ -171,18 +170,12 @@ pub fn default_config(bootstrap: &ConfigBootstrap) -> Config { default_subdir("config/console_wallet_tor.json", Some(&bootstrap.base_path)), ) .unwrap(); - cfg.set_default( - "base_node.mainnet.public_address", - format!("{}/tcp/18041", local_ip_addr), - ) - .unwrap(); cfg.set_default("base_node.mainnet.grpc_enabled", false).unwrap(); cfg.set_default("base_node.mainnet.allow_test_addresses", false) .unwrap(); cfg.set_default("base_node.mainnet.grpc_base_node_address", "127.0.0.1:18142") .unwrap(); - cfg.set_default("base_node.mainnet.grpc_console_wallet_address", "127.0.0.1:18143") - .unwrap(); + cfg.set_default("wallet.grpc_address", "127.0.0.1:18143").unwrap(); cfg.set_default("base_node.mainnet.flood_ban_max_msg_count", 10000) .unwrap(); @@ -231,8 +224,6 @@ pub fn default_config(bootstrap: &ConfigBootstrap) -> Config { cfg.set_default("base_node.weatherwax.grpc_enabled", false).unwrap(); cfg.set_default("base_node.weatherwax.grpc_base_node_address", "127.0.0.1:18142") .unwrap(); - cfg.set_default("base_node.weatherwax.grpc_console_wallet_address", "127.0.0.1:18143") - .unwrap(); cfg.set_default( "base_node.weatherwax.dns_seeds_name_server", "1.1.1.1:853/cloudflare-dns.com", @@ -244,7 +235,6 @@ pub fn default_config(bootstrap: &ConfigBootstrap) -> Config { cfg.set_default("wallet.base_node_service_peers", Vec::::new()) .unwrap(); - //---------------------------------- Igor Defaults --------------------------------------------// cfg.set_default("base_node.igor.db_type", "lmdb").unwrap(); @@ -255,13 +245,9 @@ pub fn default_config(bootstrap: &ConfigBootstrap) -> Config { cfg.set_default("base_node.igor.pruned_mode_cleanup_interval", 50) .unwrap(); cfg.set_default("base_node.igor.flood_ban_max_msg_count", 1000).unwrap(); - cfg.set_default("base_node.igor.public_address", format!("{}/tcp/18141", local_ip_addr)) - .unwrap(); cfg.set_default("base_node.igor.grpc_enabled", false).unwrap(); cfg.set_default("base_node.igor.grpc_base_node_address", "127.0.0.1:18142") .unwrap(); - cfg.set_default("base_node.igor.grpc_console_wallet_address", "127.0.0.1:18143") - .unwrap(); cfg.set_default("base_node.igor.dns_seeds_name_server", "1.1.1.1:853/cloudflare-dns.com") .unwrap(); cfg.set_default("base_node.igor.dns_seeds_use_dnssec", true).unwrap(); diff --git a/integration_tests/features/support/steps.js b/integration_tests/features/support/steps.js index 1dc1374b04..5958886e28 100644 --- a/integration_tests/features/support/steps.js +++ b/integration_tests/features/support/steps.js @@ -2032,7 +2032,7 @@ When( When( /I send(.*) uT without waiting for broadcast from wallet (.*) to wallet (.*) at fee (.*)/, - { timeout: 20 * 1000 }, + { timeout: 120 * 1000 }, async function (tariAmount, source, dest, feePerGram) { const sourceWallet = this.getWallet(source); const sourceClient = await sourceWallet.connectClient(); diff --git a/integration_tests/helpers/config.js b/integration_tests/helpers/config.js index 23653699b8..1e44a0e464 100644 --- a/integration_tests/helpers/config.js +++ b/integration_tests/helpers/config.js @@ -136,7 +136,7 @@ function createEnv( const configEnvs = { [`TARI_BASE_NODE__${network}__GRPC_BASE_NODE_ADDRESS`]: `${baseNodeGrpcAddress}:${baseNodeGrpcPort}`, - [`TARI_BASE_NODE__${network}__GRPC_CONSOLE_WALLET_ADDRESS`]: `${walletGrpcAddress}:${walletGrpcPort}`, + [`TARI_WALLET__GRPC_ADDRESS`]: `${walletGrpcAddress}:${walletGrpcPort}`, [`TARI_BASE_NODE__${network}__BASE_NODE_IDENTITY_FILE`]: `${nodeFile}`, diff --git a/integration_tests/helpers/walletProcess.js b/integration_tests/helpers/walletProcess.js index aad8ed7048..986fec2ec7 100644 --- a/integration_tests/helpers/walletProcess.js +++ b/integration_tests/helpers/walletProcess.js @@ -89,7 +89,7 @@ class WalletProcess { this.peerSeeds ); } else if (this.options["grpc_console_wallet_address"]) { - envs[`TARI_BASE_NODE__${network}__GRPC_CONSOLE_WALLET_ADDRESS`] = + envs[`TARI_WALLET__GRPC_ADDRESS`] = this.options["grpc_console_wallet_address"]; this.grpcPort = this.options["grpc_console_wallet_address"].split(":")[1];