Skip to content

Commit

Permalink
fix!: console wallet grpc_console_wallet_addresss config (#3619)
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
StriderDM authored Nov 26, 2021
1 parent 414f4cd commit b09acd1
Show file tree
Hide file tree
Showing 13 changed files with 54 additions and 51 deletions.
33 changes: 20 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand All @@ -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:
Expand Down Expand Up @@ -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.

Expand All @@ -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

Expand Down Expand Up @@ -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:
Expand Down
4 changes: 0 additions & 4 deletions applications/launchpad/docker_rig/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"

Expand Down
6 changes: 3 additions & 3 deletions applications/launchpad/docker_rig/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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}
Expand Down
15 changes: 15 additions & 0 deletions applications/tari_app_utilities/src/initialization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use tari_common::{
DatabaseType,
GlobalConfig,
};
use tari_comms::multiaddr::Multiaddr;

pub const LOG_TARGET: &str = "tari::application";

Expand Down Expand Up @@ -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::<Multiaddr>()
.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))
Expand Down
6 changes: 0 additions & 6 deletions common/config/presets/base_node.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down
5 changes: 4 additions & 1 deletion common/config/presets/console_wallet.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;

3 changes: 1 addition & 2 deletions common/config/presets/mining_node.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -32,4 +32,3 @@
# mining_pool_address = "miningcore.tari.com:3052"
# mining_wallet_address = "YOUR_WALLET_PUBLIC_KEY"
# mining_worker_name = "worker1"

3 changes: 3 additions & 0 deletions common/src/configuration/bootstrap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ pub struct ConfigBootstrap {
/// Supply a network (overrides existing configuration)
#[structopt(long, alias = "network")]
pub network: Option<String>,
#[structopt(long, alias = "grpc-address")]
pub wallet_grpc_address: Option<String>,
/// Metrics server bind address (prometheus pull)
#[structopt(long, alias = "metrics-bind-addr")]
pub metrics_server_bind_addr: Option<SocketAddr>,
Expand Down Expand Up @@ -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,
}
Expand Down
8 changes: 4 additions & 4 deletions common/src/configuration/global.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
16 changes: 1 addition & 15 deletions common/src/configuration/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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",
Expand All @@ -244,7 +235,6 @@ pub fn default_config(bootstrap: &ConfigBootstrap) -> Config {

cfg.set_default("wallet.base_node_service_peers", Vec::<String>::new())
.unwrap();

//---------------------------------- Igor Defaults --------------------------------------------//

cfg.set_default("base_node.igor.db_type", "lmdb").unwrap();
Expand All @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion integration_tests/features/support/steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion integration_tests/helpers/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`,

Expand Down
2 changes: 1 addition & 1 deletion integration_tests/helpers/walletProcess.js
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down

0 comments on commit b09acd1

Please sign in to comment.