Skip to content

Commit

Permalink
refactor!: config structs are directly mapped onto toml config
Browse files Browse the repository at this point in the history
  • Loading branch information
sdbondi committed Apr 6, 2022
1 parent 9545e62 commit a20abe5
Show file tree
Hide file tree
Showing 209 changed files with 5,585 additions and 7,290 deletions.
565 changes: 272 additions & 293 deletions Cargo.lock

Large diffs are not rendered by default.

30 changes: 15 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -617,9 +617,9 @@ And then depending on if you are using solo mining or self-select mining you wil

###### Solo mining

- For the Tari Merge Mining Proxy, under section **`merge_mining_proxy.weatherwax`**
- For the Tari Merge Mining Proxy, under section **`merge_mining_proxy`**
```
[merge_mining_proxy.weatherwax]
[merge_mining_proxy]
monerod_url = [ # stagenet
"http://stagenet.xmr-tw.org:38081",
"http://stagenet.community.xmr.to:38081",
Expand All @@ -628,7 +628,7 @@ And then depending on if you are using solo mining or self-select mining you wil
"http://singapore.node.xmr.pm:38081",
]
proxy_host_address = "127.0.0.1:7878"
proxy_host_address = "127.0.0.1:18081"
proxy_submit_to_origin = true
monerod_use_auth = false
monerod_username = ""
Expand All @@ -637,9 +637,9 @@ And then depending on if you are using solo mining or self-select mining you wil

###### Self-Select mining

- For the Tari Merge Mining Proxy, under section **`merge_mining_proxy.weatherwax`**
- For the Tari Merge Mining Proxy, under section **`merge_mining_proxy`**
```
[merge_mining_proxy.weatherwax]
[merge_mining_proxy]
monerod_url = [ # stagenet
"http://stagenet.xmr-tw.org:38081",
"http://stagenet.community.xmr.to:38081",
Expand All @@ -648,14 +648,14 @@ And then depending on if you are using solo mining or self-select mining you wil
"http://singapore.node.xmr.pm:38081",
]
proxy_host_address = "127.0.0.1:7878"
proxy_host_address = "127.0.0.1:18081"
proxy_submit_to_origin = false
monerod_use_auth = false
monerod_username = ""
monerod_password = ""
```

**Note:** The ports `7878`, `18142` and `18143` shown in the example above should not be in use by other processes. If
**Note:** The ports `18081`, `18142` and `18143` shown in the example above should not be in use by other processes. If
they are, choose different ports. You will need to update the ports in the steps below as well.

The `monerod_url` set must contain valid addresses (`host:port`) for `monerod` that is running Monero mainnet (e.g.
Expand Down Expand Up @@ -731,7 +731,7 @@ Using the public stagenet wallet address above the resulting configuration file
"pools": [
{
"coin": "monero",
"url": "127.0.0.1:7878",
"url": "127.0.0.1:18081",
"user": "55LTR8KniP4LQGJSPtbYDacR7dz8RBFnsfAKMaMuwUNYX6aQbBcovzDPyrQF9KXF9tVU6Xk3K8no1BywnJX6GvZX8yJsXvt",
"tls": false,
"daemon": true
Expand Down Expand Up @@ -767,7 +767,7 @@ be augmented with Tari specific settings. Using the wizard, create the following

- Result -> With `Config file`, copy or download, than save as `config.json`.

- Add custom entries for `"self-select": "127.0.0.1:7878"` and `"submit-to-origin": true` in the `"pools"` section.
- Add custom entries for `"self-select": "127.0.0.1:18081"` and `"submit-to-origin": true` in the `"pools"` section.

Mining pool `cryptonote.social` requires you to add a personalized handle to the wallet address so that you can
query your own pool statistics, separated by a full stop, i.e. `<YOUR WALLET ADDRESS>.<pool specific user name>`. For
Expand All @@ -791,7 +791,7 @@ activity for that address. The configuration file used for this exercise is show
"tls": false,
"keepalive": true,
"nicehash": false,
"self-select": "127.0.0.1:7878",
"self-select": "127.0.0.1:18081",
"submit-to-origin": true
}
]
Expand Down Expand Up @@ -874,14 +874,14 @@ Look out for the following outputs in the XMRig console to confirm that it is co
and accepting jobs:

```
* POOL #1 127.0.0.1:7878 coin monero
* POOL #1 127.0.0.1:18081 coin monero
```

```
[2021-01-21 12:10:18.960] net use daemon 127.0.0.1:7878 127.0.0.1
[2021-01-21 12:10:18.960] net new job from 127.0.0.1:7878 diff 286811 algo rx/0 height 756669
[2021-01-21 12:10:18.960] net use daemon 127.0.0.1:18081 127.0.0.1
[2021-01-21 12:10:18.960] net new job from 127.0.0.1:18081 diff 286811 algo rx/0 height 756669
[2021-01-21 12:10:56.730] cpu rejected (0/1) diff 286811 "Block not accepted" (656 ms)
[2021-01-21 12:10:57.398] net new job from 127.0.0.1:7878 diff 293330 algo rx/0 height 756670
[2021-01-21 12:10:57.398] net new job from 127.0.0.1:18081 diff 293330 algo rx/0 height 756670
[2021-01-21 12:12:23.695] miner speed 10s/60s/15m 4089.0 4140.2 n/a H/s max 4390.9 H/s
[2021-01-21 12:12:57.983] cpu accepted (1/1) diff 293330 (594 ms)
```
Expand Down Expand Up @@ -926,7 +926,7 @@ Look out for the following outputs in the XMRig console to confirm that it is co
Mining Proxy and accepting jobs:

```
* POOL #1 cryptonote.social:5555 coin monero self-select 127.0.0.1:7878 submit-to-origin
* POOL #1 cryptonote.social:5555 coin monero self-select 127.0.0.1:18081 submit-to-origin
```

```
Expand Down
11 changes: 7 additions & 4 deletions applications/launchpad/backend/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,28 @@ build = "src/build.rs"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[build-dependencies]
tauri-build = { version = "1.0.0-beta.4" }
tauri-build = { version = "1.0.0-rc.5", features = [] }

[dependencies]
tari_app_utilities = { version = "^0.31", path = "../../tari_app_utilities" }
tari_comms = { version = "^0.31", path = "../../../comms/core" }
bollard = "0.11.0"
config = "0.11.0"
tari_common = { path="../../../common"}

bollard = "0.11.1"
config = "0.13.0"
env_logger = "0.9.0"
log = "0.4.14"
rand = "0.8.4"
serde_json = "1.0"
serde = { version = "1.0", features = ["derive"] }
strum = "0.23.0"
strum_macros = "0.23.0"
tauri = { version = "1.0.0-beta.8", features = ["api-all", "cli"] }
tauri = { version = "1.0.0-rc.6", features = ["api-all", "cli"] }
tor-hash-passwd = "1.0.1"
thiserror = "1.0.30"
tokio = { version = "1.9", features= ["sync"] }
futures = "0.3"
regex= "1.5.4"
derivative = "2.2.0"

[features]
Expand Down
73 changes: 43 additions & 30 deletions applications/launchpad/backend/assets/config.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Config for launchpad v0.0.2
[common]
network = "dibbler"
config = "dibbler"
message_cache_size = 10
message_cache_ttl = 1440
denylist_ban_period = 1440
Expand All @@ -9,19 +9,20 @@ dedup_cache_capacity = 25000
rpc_max_simultaneous_sessions = 1000

[common.igor]
network = "igor"
peer_seeds = [
# igor
"8e7eb81e512f3d6347bf9b1ca9cd67d2c8e29f2836fc5bd608206505cc72af34::/onion3/l4wouomx42nezhzexjdzfh7pcou5l7df24ggmwgekuih7tkv2rsaokqd:18141",
"00b35047a341401bcd336b2a3d564280a72f6dc72ec4c739d30c502acce4e803::/onion3/ojhxd7z6ga7qrvjlr3px66u7eiwasmffnuklscbh5o7g6wrbysj45vid:18141",
"40a9d8573745072534bce7d0ecafe882b1c79570375a69841c08a98dee9ecb5f::/onion3/io37fylc2pupg4cte4siqlsmuszkeythgjsxs2i3prm6jyz2dtophaad:18141",
"126c7ee64f71aca36398b977dd31fbbe9f9dad615df96473fb655bef5709c540::/onion3/6ilmgndocop7ybgmcvivbdsetzr5ggj4hhsivievoa2dx2b43wqlrlid:18141",
]

dns_seeds =["seeds.igor.tari.com"]
dns_seeds = ["seeds.igor.tari.com"]
dns_seeds_use_dnssec = false

[common.dibbler]
dns_seeds =["seeds.dibbler.tari.com"]
network = "dibbler"
dns_seeds = ["seeds.dibbler.tari.com"]
peer_seeds = [
"721e9da488302e69523bca1a9cdcbd2419dddda11698a1e8c6c7bd619659ff21::/onion3/qw4ymrzbanbcr3wwlesxbot72iayd7xdjcrtnacbwgk637vfon47hqad:18141",
# 333388d1cbe3e2bd17453d052f
Expand All @@ -39,72 +40,72 @@ peer_seeds = [
]

[base_node]
network = "dibbler"
config = "dibbler"
grpc_enabled = true
grpc_address = "/ip4/0.0.0.0/tcp/18142"
track_reorgs = true

[base_node.dibbler]
network = "dibbler"
db_type = "lmdb"
flood_ban_max_msg_count = 100_000
allow_test_addresses = false
use_libtor = false
base_node_identity_file = "/var/tari/base_node/config/dibbler/tari_base_node_id.json"
base_node_tor_identity_file = "/var/tari/base_node/config/dibbler/tari_base_node_tor.json"

# -- These values are overridden by envars in the Tauri code for EVERY network
# -------------- Transport configuration --------------
transport = "tor"
tor_control_auth = "password=tari"
tor_forward_address = "/dns4/base_node/tcp/18189"
tcp_listener_address = "/dns4/base_node/tcp/18189"
tor_socks_address_override = "/dns4/tor/tcp/9050"
tor_control_address = "/ip4/tor/tcp/9051"
grpc_enabled = true
grpc_base_node_address = "0.0.0.0:18142"
tor_control_address = "/dns4/tor/tcp/9051"


[base_node.igor]
network = "igor"
db_type = "lmdb"
flood_ban_max_msg_count = 100_000
allow_test_addresses = false
use_libtor = false
base_node_identity_file = "/var/tari/base_node/config/igor/base_node_id.json"
base_node_tor_identity_file = "/var/tari/base_node/config/igor/tari_base_node_tor.json"


[mempool.dibbler]

[mempool.igor]

[wallet]
config = "dibbler"
wallet_db_file = "wallet/wallet.dat"
console_wallet_db_file = "wallet/console-wallet.dat"
grpc_enabled = true
grpc_address = "/ip4/0.0.0.0/tcp/18143"
password = "tari"

[wallet.dibbler]
use_libtor = false
tor_onion_port = 18141

# Overidden in Tauri environment variables for ALL networks
# The following are overridden in Tauri environment variables for ALL networks - so just here for informational purposes
transport = "tor"
tor_control_auth = "password=tari"
tor_control_address = "/ip4/tor/tcp/9051"
tor_control_address = "/dns4/tor/tcp/9051"
tor_socks_address_override = ""
tor_forward_address = ""
tcp_listener_address= ""
tcp_listener_address = ""

[wallet.dibbler]
network = "dibbler"
use_libtor = false
tor_onion_port = 18141

[wallet.igor]
network = "igor"
use_libtor = false
tor_onion_port = 18141

[mining_node]
num_mining_threads=1
base_node_grpc_address = "/ip4/base_node/tcp/18142"
wallet_grpc_address = "/ip4/wallet/tcp/18143"
num_mining_threads = 1
base_node_grpc_address = "/dns4/base_node/tcp/18142"
wallet_grpc_address = "/dns4/wallet/tcp/18143"
base_node_addr = "/dns4/base_node/tcp/18142"
wallet_addr = "/dns4/wallet/tcp/18143"
mine_on_tip_only = true

[merge_mining_proxy]
config = "dibbler"

[merge_mining_proxy.dibbler]
monerod_url = [ # stagenet
"http://stagenet.xmr-tw.org:38081",
Expand All @@ -113,9 +114,21 @@ monerod_url = [ # stagenet
"http://xmr-lux.boldsuck.org:38081",
"http://singapore.node.xmr.pm:38081",
]
proxy_host_address = "/ip4/mm_proxy/tcp/7878"

[merge_mining_proxy]
grpc_base_node_address = "/dns4/base_node/tcp/18142"
grpc_console_wallet_address = "/dns4/wallet/tcp/18143"
proxy_host_address = "/dns4/mm_proxy/tcp/18081"
proxy_submit_to_origin = true
wait_for_initial_sync_at_startup = true
monerod_username = ""
monerod_password = ""
monerod_use_auth = false

[merge_mining_proxy.local]
grpc_base_node_address = "/ip4/127.0.0.1/tcp/18142"
grpc_console_wallet_address = "/ip4/127.0.0.1/tcp/18143"
proxy_host_address = "/ip4/127.0.0.1/tcp/18081"
proxy_submit_to_origin = false
wait_for_initial_sync_at_startup = true

[validator_node]
committee = ["2ea0df3059caf4411624d6bf5b9c02238d607d2798c586b3e6c2a054da3f205a"] # cannot be of zero size
Expand Down
4 changes: 2 additions & 2 deletions applications/launchpad/backend/assets/log4rs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,12 @@ loggers:
- core
additive: false
tari_mining_node:
level: info
level: debug
appenders:
- core
additive: false
tari_mm_proxy:
level: info
level: debug
appenders:
- core
additive: false
Expand Down
22 changes: 15 additions & 7 deletions applications/launchpad/backend/src/commands/create_workspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@
// USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//

use std::path::Path;
use std::{
env,
path::{Path, PathBuf},
str::FromStr,
};

use log::*;
use tauri::{
Expand All @@ -38,14 +42,18 @@ use crate::{commands::AppState, docker::create_workspace_folders, error::Launche
/// Create a new workspace environment by creating a folder hierarchy (if required) at the `root_folder`, and copying
/// the default config files into it.
#[tauri::command]
pub fn create_new_workspace(app: AppHandle<Wry>, root_path: String) -> Result<(), String> {
pub fn create_new_workspace(app: AppHandle<Wry>, root_path: Option<String>) -> Result<(), String> {
let config = app.config();
let package_info = &app.state::<AppState>().package_info;
let _result = create_workspace_folders(root_path.as_str()).map_err(|e| e.chained_message());
let path = Path::new(&root_path);
copy_config_file(path, config.as_ref(), package_info, "log4rs.yml").map_err(|e| e.chained_message())?;
copy_config_file(path, config.as_ref(), package_info, "config.toml").map_err(|e| e.chained_message())?;
info!("Workspace at {} complete!", root_path);
let path = root_path
.as_ref()
.map(|r| PathBuf::from_str(r.as_str()).unwrap())
.unwrap_or_else(|| env::temp_dir().join("tari"));
debug!("Creating workspace at {:?}", path);
create_workspace_folders(&path).map_err(|e| e.chained_message())?;
copy_config_file(path.as_path(), config.as_ref(), package_info, "log4rs.yml").map_err(|e| e.chained_message())?;
copy_config_file(path.as_path(), config.as_ref(), package_info, "config.toml").map_err(|e| e.chained_message())?;
info!("Workspace at {:?} complete!", path);
Ok(())
}

Expand Down
6 changes: 6 additions & 0 deletions applications/launchpad/backend/src/commands/pull_images.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

use bollard::models::CreateImageInfo;
use futures::{future::join_all, stream::StreamExt, TryFutureExt};
use log::{debug, error};
use serde::Serialize;
use tauri::{AppHandle, Manager, Wry};

Expand All @@ -32,6 +33,8 @@ use crate::{
error::LauncherError,
};

const LOG_TARGET: &str = "tari::launchpad::commands::pull_images";

#[derive(Debug, Clone, Serialize)]
pub struct Payload {
image: String,
Expand Down Expand Up @@ -62,6 +65,7 @@ pub fn image_list() -> Vec<String> {
/// Pulls all the images concurrently using the docker API.
#[tauri::command]
pub async fn pull_images(app: AppHandle<Wry>) -> Result<(), String> {
debug!("Command pull_images invoked");
let futures = DEFAULT_IMAGES
.iter()
.map(|image| pull_image(*image, app.clone()).map_err(|e| e.chained_message()));
Expand All @@ -72,6 +76,7 @@ pub async fn pull_images(app: AppHandle<Wry>) -> Result<(), String> {
.map(|e| e.unwrap_err())
.collect::<Vec<String>>();
if !errors.is_empty() {
error!("Error pulling images:{}", errors.join("\n"));
return Err(errors.join("\n"));
}
Ok(())
Expand All @@ -90,6 +95,7 @@ async fn pull_image(image: ImageType, app: AppHandle<Wry>) -> Result<(), Launche
name: image.image_name().to_string(),
info: progress,
};
debug!("Image pull progress:{:?}", payload);
app.emit_all("image-pull-progress", payload)?
},
Err(err) => return Err(err.into()),
Expand Down
Loading

0 comments on commit a20abe5

Please sign in to comment.