mixnode config migration
This commit is contained in:
@@ -140,6 +140,7 @@ pub(crate) async fn execute(args: &Run) -> Result<(), Box<dyn std::error::Error
|
||||
}
|
||||
|
||||
let storage =
|
||||
OnDiskPersistent::from_paths(config.storage_paths.common_paths, &config.core.base.debug).await?;
|
||||
OnDiskPersistent::from_paths(config.storage_paths.common_paths, &config.core.base.debug)
|
||||
.await?;
|
||||
NymClient::new(config.core, storage).run_forever().await
|
||||
}
|
||||
|
||||
@@ -8,9 +8,7 @@ use crate::client::key_manager::persistence::KeyStore;
|
||||
use crate::client::key_manager::{KeyManager, ManagedKeys};
|
||||
use crate::init::helpers::{choose_gateway_by_latency, current_gateways, uniformly_random_gateway};
|
||||
use crate::{
|
||||
config::{
|
||||
disk_persistence::keys_paths::ClientKeysPaths, Config, GatewayEndpointConfig,
|
||||
},
|
||||
config::{disk_persistence::keys_paths::ClientKeysPaths, Config, GatewayEndpointConfig},
|
||||
error::ClientCoreError,
|
||||
};
|
||||
use nym_crypto::asymmetric::{encryption, identity};
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
// Copyright 2023 - Nym Technologies SA <contact@nymtech.net>
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// removed in 1.1.19/1.1.20
|
||||
pub mod nym_config {
|
||||
use serde::de::DeserializeOwned;
|
||||
use serde::Serialize;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::{fs, io};
|
||||
|
||||
pub const CONFIG_DIR: &str = "config";
|
||||
pub const DATA_DIR: &str = "data";
|
||||
|
||||
// no need for anything to do with saving.
|
||||
pub trait MigrationNymConfig: Default + Serialize + DeserializeOwned {
|
||||
fn config_file_name() -> String {
|
||||
"config.toml".to_string()
|
||||
}
|
||||
|
||||
fn default_root_directory() -> PathBuf;
|
||||
|
||||
fn default_config_directory(id: &str) -> PathBuf {
|
||||
Self::default_config_directory_with_root(Self::default_root_directory(), id)
|
||||
}
|
||||
|
||||
fn default_config_directory_with_root<P: AsRef<Path>>(root: P, id: &str) -> PathBuf {
|
||||
root.as_ref().join(id).join(CONFIG_DIR)
|
||||
}
|
||||
|
||||
fn default_config_file_path(id: &str) -> PathBuf {
|
||||
Self::default_config_directory(id).join(Self::config_file_name())
|
||||
}
|
||||
|
||||
fn load_from_file(id: &str) -> io::Result<Self> {
|
||||
let file = Self::default_config_file_path(id);
|
||||
Self::load_from_filepath(file)
|
||||
}
|
||||
|
||||
fn load_from_filepath<P: AsRef<Path>>(filepath: P) -> io::Result<Self> {
|
||||
log::trace!("Loading from file: {:#?}", filepath.as_ref().to_owned());
|
||||
let config_contents = fs::read_to_string(filepath)?;
|
||||
|
||||
toml::from_str(&config_contents)
|
||||
.map_err(|toml_err| io::Error::new(io::ErrorKind::Other, toml_err))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,7 @@ pub use toml::de::Error as TomlDeError;
|
||||
|
||||
pub mod defaults;
|
||||
pub mod helpers;
|
||||
pub mod legacy_helpers;
|
||||
|
||||
pub const NYM_DIR: &str = ".nym";
|
||||
pub const DEFAULT_CONFIG_DIR: &str = "config";
|
||||
|
||||
@@ -110,7 +110,12 @@ impl<St> Gateway<St> {
|
||||
version: self.config.gateway.version.clone(),
|
||||
mix_port: self.config.gateway.mix_port,
|
||||
clients_port: self.config.gateway.clients_port,
|
||||
data_store: self.config.storage_paths.clients_storage.display().to_string(),
|
||||
data_store: self
|
||||
.config
|
||||
.storage_paths
|
||||
.clients_storage
|
||||
.display()
|
||||
.to_string(),
|
||||
};
|
||||
|
||||
println!("{}", output.format(&node_details));
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2021-2023 - Nym Technologies SA <contact@nymtech.net>
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
use crate::config::Config;
|
||||
use crate::commands::try_load_current_config;
|
||||
use crate::node::node_description::NodeDescription;
|
||||
use clap::Args;
|
||||
use colored::Colorize;
|
||||
@@ -38,15 +38,9 @@ fn read_user_input() -> String {
|
||||
buf.trim().to_string()
|
||||
}
|
||||
|
||||
pub(crate) fn execute(args: Describe) {
|
||||
pub(crate) fn execute(args: Describe) -> anyhow::Result<()> {
|
||||
// ensure that the mixnode has in fact been initialized
|
||||
let config = match Config::read_from_default_path(&args.id) {
|
||||
Ok(cfg) => cfg,
|
||||
Err(err) => {
|
||||
error!("Failed to load config for {}. Are you sure you have run `init` before? (Error was: {err})", &args.id);
|
||||
return;
|
||||
}
|
||||
};
|
||||
let config = try_load_current_config(&args.id)?;
|
||||
|
||||
let example_url = "https://mixnode.yourdomain.com".bright_cyan();
|
||||
let example_location = "City: London, Country: UK";
|
||||
@@ -80,5 +74,6 @@ pub(crate) fn execute(args: Describe) {
|
||||
};
|
||||
|
||||
// save the struct
|
||||
NodeDescription::save_to_file(&node_description, config.storage_paths.node_description).unwrap()
|
||||
NodeDescription::save_to_file(&node_description, config.storage_paths.node_description)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
// Copyright 2020 - Nym Technologies SA <contact@nymtech.net>
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
use crate::config::old_config_v1_1_20::ConfigV1_1_20;
|
||||
use crate::{config::Config, Cli};
|
||||
use anyhow::anyhow;
|
||||
use clap::CommandFactory;
|
||||
use clap::Subcommand;
|
||||
use colored::Colorize;
|
||||
@@ -57,19 +59,20 @@ struct OverrideConfig {
|
||||
nym_apis: Option<Vec<url::Url>>,
|
||||
}
|
||||
|
||||
pub(crate) async fn execute(args: Cli) {
|
||||
pub(crate) async fn execute(args: Cli) -> anyhow::Result<()> {
|
||||
let bin_name = "nym-mixnode";
|
||||
|
||||
match args.command {
|
||||
Commands::Describe(m) => describe::execute(m),
|
||||
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::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::command(), bin_name),
|
||||
Commands::GenerateFigSpec => fig_generate(&mut crate::Cli::command(), bin_name),
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn override_config(config: Config, args: OverrideConfig) -> Config {
|
||||
@@ -126,3 +129,44 @@ pub(crate) fn version_check(cfg: &Config) -> bool {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn try_upgrade_v1_1_20_config(id: &str) -> std::io::Result<()> {
|
||||
use nym_config::legacy_helpers::nym_config::MigrationNymConfig;
|
||||
|
||||
// explicitly load it as v1.1.20 (which is incompatible with the current, i.e. 1.1.21+)
|
||||
let Ok(old_config) = ConfigV1_1_20::load_from_file(id) else {
|
||||
// if we failed to load it, there might have been nothing to upgrade
|
||||
// or maybe it was an even older file. in either way. just ignore it and carry on with our day
|
||||
return Ok(());
|
||||
};
|
||||
info!("It seems the mixnode is using <= v1.1.20 config template.");
|
||||
info!("It is going to get updated to the current specification.");
|
||||
|
||||
let updated: Config = old_config.into();
|
||||
println!("upgraded to {:#?}", updated);
|
||||
updated.save_to_default_location()
|
||||
}
|
||||
|
||||
fn try_load_current_config(id: &str) -> anyhow::Result<Config> {
|
||||
try_upgrade_v1_1_20_config(id)?;
|
||||
|
||||
Config::read_from_default_path(&id).map_err(|err| {
|
||||
let error_msg =
|
||||
format!(
|
||||
"Failed to load config for {id}. Are you sure you have run `init` before? (Error was: {err})",
|
||||
);
|
||||
error!("{error_msg}");
|
||||
anyhow!(error_msg)
|
||||
})
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use clap::CommandFactory;
|
||||
|
||||
#[test]
|
||||
fn verify_cli() {
|
||||
Cli::command().debug_assert();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2021 - Nym Technologies SA <contact@nymtech.net>
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
use crate::config::Config;
|
||||
use crate::commands::try_load_current_config;
|
||||
use crate::node::MixNode;
|
||||
use clap::Args;
|
||||
use nym_bin_common::output_format::OutputFormat;
|
||||
@@ -16,18 +16,9 @@ pub(crate) struct NodeDetails {
|
||||
output: OutputFormat,
|
||||
}
|
||||
|
||||
pub(crate) fn execute(args: &NodeDetails) {
|
||||
let config = match Config::read_from_default_path(&args.id) {
|
||||
Ok(cfg) => cfg,
|
||||
Err(err) => {
|
||||
error!(
|
||||
"Failed to load config for {}. Are you sure you have run `init` before? (Error was: {})",
|
||||
args.id,
|
||||
err,
|
||||
);
|
||||
return;
|
||||
}
|
||||
};
|
||||
pub(crate) fn execute(args: &NodeDetails) -> anyhow::Result<()> {
|
||||
let config = try_load_current_config(&args.id)?;
|
||||
|
||||
MixNode::new(config).print_node_details(args.output)
|
||||
MixNode::new(config).print_node_details(args.output);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
use super::OverrideConfig;
|
||||
use crate::commands::{override_config, version_check};
|
||||
use crate::config::Config;
|
||||
use crate::commands::{override_config, try_load_current_config, version_check};
|
||||
use crate::node::MixNode;
|
||||
use anyhow::bail;
|
||||
use clap::Args;
|
||||
use nym_bin_common::output_format::OutputFormat;
|
||||
use nym_config::helpers::SPECIAL_ADDRESSES;
|
||||
@@ -69,26 +69,15 @@ fn show_binding_warning(address: &str) {
|
||||
eprintln!("\n\n");
|
||||
}
|
||||
|
||||
pub(crate) async fn execute(args: &Run) {
|
||||
pub(crate) async fn execute(args: &Run) -> anyhow::Result<()> {
|
||||
eprintln!("Starting mixnode {}...", args.id);
|
||||
|
||||
let mut config = match Config::read_from_default_path(&args.id) {
|
||||
Ok(cfg) => cfg,
|
||||
Err(err) => {
|
||||
error!(
|
||||
"Failed to load config for {}. Are you sure you have run `init` before? (Error was: {})",
|
||||
args.id,
|
||||
err
|
||||
);
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
let mut config = try_load_current_config(&args.id)?;
|
||||
config = override_config(config, OverrideConfig::from(args.clone()));
|
||||
|
||||
if !version_check(&config) {
|
||||
error!("failed the local version check");
|
||||
return;
|
||||
bail!("failed the local version check")
|
||||
}
|
||||
|
||||
if SPECIAL_ADDRESSES.contains(&config.mixnode.listening_address) {
|
||||
@@ -102,5 +91,6 @@ pub(crate) async fn execute(args: &Run) {
|
||||
Select the correct version and install it to your machine. You will need to provide the following: \n ");
|
||||
mixnode.print_node_details(args.output);
|
||||
|
||||
mixnode.run().await
|
||||
mixnode.run().await;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
// Copyright 2020-2023 - Nym Technologies SA <contact@nymtech.net>
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
use crate::commands::validate_bech32_address_or_exit;
|
||||
use crate::config::Config;
|
||||
use crate::commands::{try_load_current_config, validate_bech32_address_or_exit};
|
||||
use crate::node::MixNode;
|
||||
use anyhow::{bail, Result};
|
||||
use clap::{ArgGroup, Args};
|
||||
@@ -115,28 +114,19 @@ fn print_signed_contract_msg(
|
||||
println!("{}", output.format(&sign_output));
|
||||
}
|
||||
|
||||
pub(crate) fn execute(args: &Sign) {
|
||||
let config = match Config::read_from_default_path(&args.id) {
|
||||
Ok(cfg) => cfg,
|
||||
Err(err) => {
|
||||
error!(
|
||||
"Failed to load config for {}. Are you sure you have run `init` before? (Error was: {err})",
|
||||
args.id,
|
||||
);
|
||||
return;
|
||||
}
|
||||
};
|
||||
pub(crate) fn execute(args: &Sign) -> anyhow::Result<()> {
|
||||
let config = try_load_current_config(&args.id)?;
|
||||
|
||||
if !version_check(&config) {
|
||||
error!("Failed the local version check");
|
||||
return;
|
||||
error!("failed the local version check");
|
||||
bail!("failed the local version check")
|
||||
}
|
||||
|
||||
let signed_target = match SignedTarget::try_from(args.clone()) {
|
||||
Ok(s) => s,
|
||||
Err(err) => {
|
||||
error!("{err}");
|
||||
return;
|
||||
bail!(err);
|
||||
}
|
||||
};
|
||||
let identity_keypair = MixNode::load_identity_keys(&config);
|
||||
@@ -152,4 +142,5 @@ pub(crate) fn execute(args: &Sign) {
|
||||
print_signed_contract_msg(identity_keypair.private_key(), &raw_msg, args.output)
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// Copyright 2020 - Nym Technologies SA <contact@nymtech.net>
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
use crate::commands::try_upgrade_v1_1_20_config;
|
||||
use crate::config::Config;
|
||||
use clap::Args;
|
||||
use nym_bin_common::version_checker::Version;
|
||||
@@ -123,7 +124,9 @@ fn do_upgrade(mut config: Config, args: &Upgrade, package_version: Version) {
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn execute(args: &Upgrade) {
|
||||
pub(crate) fn execute(args: &Upgrade) -> anyhow::Result<()> {
|
||||
try_upgrade_v1_1_20_config(&args.id)?;
|
||||
|
||||
let package_version = parse_package_version();
|
||||
|
||||
let existing_config = Config::read_from_default_path(&args.id).unwrap_or_else(|err| {
|
||||
@@ -136,5 +139,6 @@ pub(crate) fn execute(args: &Upgrade) {
|
||||
process::exit(1);
|
||||
}
|
||||
|
||||
do_upgrade(existing_config, args, package_version)
|
||||
do_upgrade(existing_config, args, package_version);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ use std::str::FromStr;
|
||||
use std::time::Duration;
|
||||
use url::Url;
|
||||
|
||||
pub(crate) mod old_config_v1_1_20;
|
||||
pub mod persistence;
|
||||
mod template;
|
||||
|
||||
@@ -204,22 +205,27 @@ pub struct Verloc {
|
||||
pub packets_per_node: usize,
|
||||
|
||||
/// Specifies maximum amount of time to wait for the connection to get established.
|
||||
#[serde(with = "humantime_serde")]
|
||||
pub connection_timeout: Duration,
|
||||
|
||||
/// Specifies maximum amount of time to wait for the reply packet to arrive before abandoning the test.
|
||||
#[serde(with = "humantime_serde")]
|
||||
pub packet_timeout: Duration,
|
||||
|
||||
/// Specifies delay between subsequent test packets being sent (after receiving a reply).
|
||||
#[serde(with = "humantime_serde")]
|
||||
pub delay_between_packets: Duration,
|
||||
|
||||
/// Specifies number of nodes being tested at once.
|
||||
pub tested_nodes_batch_size: usize,
|
||||
|
||||
/// Specifies delay between subsequent test runs.
|
||||
#[serde(with = "humantime_serde")]
|
||||
pub testing_interval: Duration,
|
||||
|
||||
/// Specifies delay between attempting to run the measurement again if the previous run failed
|
||||
/// due to being unable to get the list of nodes.
|
||||
#[serde(with = "humantime_serde")]
|
||||
pub retry_timeout: Duration,
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,249 @@
|
||||
// Copyright 2023 - Nym Technologies SA <contact@nymtech.net>
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
use crate::config::persistence::paths::{KeysPaths, MixNodePaths};
|
||||
use crate::config::{Config, Debug, MixNode, Verloc};
|
||||
use nym_bin_common::logging::LoggingSettings;
|
||||
use nym_config::legacy_helpers::nym_config::MigrationNymConfig;
|
||||
use nym_validator_client::nyxd;
|
||||
use serde::{Deserialize, Deserializer, Serialize};
|
||||
use std::net::{IpAddr, SocketAddr};
|
||||
use std::path::PathBuf;
|
||||
use std::str::FromStr;
|
||||
use std::time::Duration;
|
||||
use url::Url;
|
||||
|
||||
const DEFAULT_MIX_LISTENING_PORT: u16 = 1789;
|
||||
const DEFAULT_VERLOC_LISTENING_PORT: u16 = 1790;
|
||||
const DEFAULT_HTTP_API_LISTENING_PORT: u16 = 8000;
|
||||
const NYM_API: &str = "https://validator.nymtech.net/api/";
|
||||
const DESCRIPTION_FILE: &str = "description.toml";
|
||||
|
||||
// 'RTT MEASUREMENT'
|
||||
const DEFAULT_PACKETS_PER_NODE: usize = 100;
|
||||
const DEFAULT_CONNECTION_TIMEOUT: Duration = Duration::from_millis(5000);
|
||||
const DEFAULT_PACKET_TIMEOUT: Duration = Duration::from_millis(1500);
|
||||
const DEFAULT_DELAY_BETWEEN_PACKETS: Duration = Duration::from_millis(50);
|
||||
const DEFAULT_BATCH_SIZE: usize = 50;
|
||||
const DEFAULT_TESTING_INTERVAL: Duration = Duration::from_secs(60 * 60 * 12);
|
||||
const DEFAULT_RETRY_TIMEOUT: Duration = Duration::from_secs(60 * 30);
|
||||
|
||||
// 'DEBUG'
|
||||
const DEFAULT_NODE_STATS_LOGGING_DELAY: Duration = Duration::from_millis(60_000);
|
||||
const DEFAULT_NODE_STATS_UPDATING_DELAY: Duration = Duration::from_millis(30_000);
|
||||
const DEFAULT_PACKET_FORWARDING_INITIAL_BACKOFF: Duration = Duration::from_millis(10_000);
|
||||
const DEFAULT_PACKET_FORWARDING_MAXIMUM_BACKOFF: Duration = Duration::from_millis(300_000);
|
||||
const DEFAULT_INITIAL_CONNECTION_TIMEOUT: Duration = Duration::from_millis(1_500);
|
||||
const DEFAULT_MAXIMUM_CONNECTION_BUFFER_SIZE: usize = 2000;
|
||||
|
||||
pub(super) fn de_ipaddr_from_maybe_str_socks_addr<'de, D>(
|
||||
deserializer: D,
|
||||
) -> Result<IpAddr, D::Error>
|
||||
where
|
||||
D: Deserializer<'de>,
|
||||
{
|
||||
let s = String::deserialize(deserializer)?;
|
||||
if let Ok(socket_addr) = SocketAddr::from_str(&s) {
|
||||
Ok(socket_addr.ip())
|
||||
} else {
|
||||
IpAddr::from_str(&s).map_err(serde::de::Error::custom)
|
||||
}
|
||||
}
|
||||
|
||||
fn bind_all_address() -> IpAddr {
|
||||
"0.0.0.0".parse().unwrap()
|
||||
}
|
||||
|
||||
#[derive(Debug, Default, Deserialize, PartialEq, Serialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct ConfigV1_1_20 {
|
||||
mixnode: MixNodeV1_1_20,
|
||||
|
||||
#[serde(default)]
|
||||
verloc: VerlocV1_1_20,
|
||||
#[serde(default)]
|
||||
logging: LoggingV1_1_20,
|
||||
#[serde(default)]
|
||||
debug: DebugV1_1_20,
|
||||
}
|
||||
|
||||
impl From<ConfigV1_1_20> for Config {
|
||||
fn from(value: ConfigV1_1_20) -> Self {
|
||||
let node_description =
|
||||
ConfigV1_1_20::default_config_directory(&value.mixnode.id).join(DESCRIPTION_FILE);
|
||||
|
||||
Config {
|
||||
mixnode: MixNode {
|
||||
version: value.mixnode.version,
|
||||
id: value.mixnode.id,
|
||||
listening_address: value.mixnode.listening_address,
|
||||
mix_port: value.mixnode.mix_port,
|
||||
verloc_port: value.mixnode.verloc_port,
|
||||
http_api_port: value.mixnode.http_api_port,
|
||||
nym_api_urls: value.mixnode.nym_api_urls,
|
||||
},
|
||||
storage_paths: MixNodePaths {
|
||||
keys: KeysPaths {
|
||||
private_identity_key_file: value.mixnode.private_identity_key_file,
|
||||
public_identity_key_file: value.mixnode.public_identity_key_file,
|
||||
private_sphinx_key_file: value.mixnode.private_sphinx_key_file,
|
||||
public_sphinx_key_file: value.mixnode.public_sphinx_key_file,
|
||||
},
|
||||
node_description,
|
||||
},
|
||||
verloc: value.verloc.into(),
|
||||
logging: value.logging.into(),
|
||||
debug: value.debug.into(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl MigrationNymConfig for ConfigV1_1_20 {
|
||||
fn default_root_directory() -> PathBuf {
|
||||
dirs::home_dir()
|
||||
.expect("Failed to evaluate $HOME value")
|
||||
.join(".nym")
|
||||
.join("mixnodes")
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, PartialEq, Serialize)]
|
||||
struct MixNodeV1_1_20 {
|
||||
version: String,
|
||||
id: String,
|
||||
#[serde(deserialize_with = "de_ipaddr_from_maybe_str_socks_addr")]
|
||||
listening_address: IpAddr,
|
||||
announce_address: String,
|
||||
mix_port: u16,
|
||||
verloc_port: u16,
|
||||
http_api_port: u16,
|
||||
private_identity_key_file: PathBuf,
|
||||
public_identity_key_file: PathBuf,
|
||||
private_sphinx_key_file: PathBuf,
|
||||
public_sphinx_key_file: PathBuf,
|
||||
nym_api_urls: Vec<Url>,
|
||||
nym_root_directory: PathBuf,
|
||||
wallet_address: Option<nyxd::AccountId>,
|
||||
}
|
||||
|
||||
impl Default for MixNodeV1_1_20 {
|
||||
fn default() -> Self {
|
||||
MixNodeV1_1_20 {
|
||||
version: env!("CARGO_PKG_VERSION").to_string(),
|
||||
id: "".to_string(),
|
||||
listening_address: bind_all_address(),
|
||||
announce_address: "127.0.0.1".to_string(),
|
||||
mix_port: DEFAULT_MIX_LISTENING_PORT,
|
||||
verloc_port: DEFAULT_VERLOC_LISTENING_PORT,
|
||||
http_api_port: DEFAULT_HTTP_API_LISTENING_PORT,
|
||||
private_identity_key_file: Default::default(),
|
||||
public_identity_key_file: Default::default(),
|
||||
private_sphinx_key_file: Default::default(),
|
||||
public_sphinx_key_file: Default::default(),
|
||||
nym_api_urls: vec![Url::from_str(NYM_API).expect("Invalid default API URL")],
|
||||
nym_root_directory: ConfigV1_1_20::default_root_directory(),
|
||||
wallet_address: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Default, Deserialize, PartialEq, Serialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
struct LoggingV1_1_20 {}
|
||||
|
||||
impl From<LoggingV1_1_20> for LoggingSettings {
|
||||
fn from(_value: LoggingV1_1_20) -> Self {
|
||||
LoggingSettings {}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, PartialEq, Serialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
struct VerlocV1_1_20 {
|
||||
packets_per_node: usize,
|
||||
connection_timeout: Duration,
|
||||
packet_timeout: Duration,
|
||||
delay_between_packets: Duration,
|
||||
tested_nodes_batch_size: usize,
|
||||
testing_interval: Duration,
|
||||
retry_timeout: Duration,
|
||||
}
|
||||
|
||||
impl From<VerlocV1_1_20> for Verloc {
|
||||
fn from(value: VerlocV1_1_20) -> Self {
|
||||
Verloc {
|
||||
packets_per_node: value.packets_per_node,
|
||||
connection_timeout: value.connection_timeout,
|
||||
packet_timeout: value.packet_timeout,
|
||||
delay_between_packets: value.delay_between_packets,
|
||||
tested_nodes_batch_size: value.tested_nodes_batch_size,
|
||||
testing_interval: value.testing_interval,
|
||||
retry_timeout: value.retry_timeout,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for VerlocV1_1_20 {
|
||||
fn default() -> Self {
|
||||
VerlocV1_1_20 {
|
||||
packets_per_node: DEFAULT_PACKETS_PER_NODE,
|
||||
connection_timeout: DEFAULT_CONNECTION_TIMEOUT,
|
||||
packet_timeout: DEFAULT_PACKET_TIMEOUT,
|
||||
delay_between_packets: DEFAULT_DELAY_BETWEEN_PACKETS,
|
||||
tested_nodes_batch_size: DEFAULT_BATCH_SIZE,
|
||||
testing_interval: DEFAULT_TESTING_INTERVAL,
|
||||
retry_timeout: DEFAULT_RETRY_TIMEOUT,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, PartialEq, Serialize)]
|
||||
#[serde(default)]
|
||||
struct DebugV1_1_20 {
|
||||
#[serde(with = "humantime_serde")]
|
||||
node_stats_logging_delay: Duration,
|
||||
|
||||
#[serde(with = "humantime_serde")]
|
||||
node_stats_updating_delay: Duration,
|
||||
|
||||
#[serde(with = "humantime_serde")]
|
||||
packet_forwarding_initial_backoff: Duration,
|
||||
|
||||
#[serde(with = "humantime_serde")]
|
||||
packet_forwarding_maximum_backoff: Duration,
|
||||
|
||||
#[serde(with = "humantime_serde")]
|
||||
initial_connection_timeout: Duration,
|
||||
|
||||
maximum_connection_buffer_size: usize,
|
||||
|
||||
use_legacy_framed_packet_version: bool,
|
||||
}
|
||||
|
||||
impl From<DebugV1_1_20> for Debug {
|
||||
fn from(value: DebugV1_1_20) -> Self {
|
||||
Debug {
|
||||
node_stats_logging_delay: value.node_stats_logging_delay,
|
||||
node_stats_updating_delay: value.node_stats_updating_delay,
|
||||
packet_forwarding_initial_backoff: value.packet_forwarding_initial_backoff,
|
||||
packet_forwarding_maximum_backoff: value.packet_forwarding_maximum_backoff,
|
||||
initial_connection_timeout: value.initial_connection_timeout,
|
||||
maximum_connection_buffer_size: value.maximum_connection_buffer_size,
|
||||
use_legacy_framed_packet_version: value.use_legacy_framed_packet_version,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for DebugV1_1_20 {
|
||||
fn default() -> Self {
|
||||
DebugV1_1_20 {
|
||||
node_stats_logging_delay: DEFAULT_NODE_STATS_LOGGING_DELAY,
|
||||
node_stats_updating_delay: DEFAULT_NODE_STATS_UPDATING_DELAY,
|
||||
packet_forwarding_initial_backoff: DEFAULT_PACKET_FORWARDING_INITIAL_BACKOFF,
|
||||
packet_forwarding_maximum_backoff: DEFAULT_PACKET_FORWARDING_MAXIMUM_BACKOFF,
|
||||
initial_connection_timeout: DEFAULT_INITIAL_CONNECTION_TIMEOUT,
|
||||
maximum_connection_buffer_size: DEFAULT_MAXIMUM_CONNECTION_BUFFER_SIZE,
|
||||
use_legacy_framed_packet_version: true,
|
||||
}
|
||||
}
|
||||
}
|
||||
+4
-2
@@ -48,7 +48,7 @@ fn test_function() {
|
||||
}
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
async fn main() -> anyhow::Result<()> {
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(feature = "cpucycles")] {
|
||||
let home_dir = dirs::home_dir().expect("Could not get $HOME");
|
||||
@@ -66,12 +66,14 @@ async fn main() {
|
||||
|
||||
let args = Cli::parse();
|
||||
setup_env(args.config_env_file.as_ref());
|
||||
commands::execute(args).await;
|
||||
commands::execute(args).await?;
|
||||
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(feature = "cpucycles")] {
|
||||
opentelemetry::global::shutdown_tracer_provider();
|
||||
}}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
@@ -124,12 +124,12 @@ pub(crate) fn build_config(args: CliArgs) -> Result<Config> {
|
||||
|
||||
let config = Config::new(&id);
|
||||
fs::create_dir_all(default_config_directory(&id))
|
||||
.expect("Could not create config directory");
|
||||
.expect("Could not create config directory");
|
||||
fs::create_dir_all(default_data_directory(&id))
|
||||
.expect("Could not create data directory");
|
||||
.expect("Could not create data directory");
|
||||
crate::coconut::dkg::controller::init_keypair(&config.coconut_signer)?;
|
||||
config
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
let config = override_config(config, args);
|
||||
|
||||
@@ -46,7 +46,10 @@ pub(crate) async fn setup_rocket(
|
||||
// This is not a very nice approach. A lazy value would be more suitable, but that's still
|
||||
// a nightly feature: https://github.com/rust-lang/rust/issues/74465
|
||||
let storage = if config.coconut_signer.enabled || config.network_monitor.enabled {
|
||||
Some(storage::NymApiStorage::init(&config.node_status_api.storage_paths.database_path).await?)
|
||||
Some(
|
||||
storage::NymApiStorage::init(&config.node_status_api.storage_paths.database_path)
|
||||
.await?,
|
||||
)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
@@ -165,7 +165,8 @@ impl NRServiceProviderBuilder {
|
||||
let standard_list = StandardList::new();
|
||||
|
||||
let allowed_hosts = StoredAllowedHosts::new(&config.storage_paths.allowed_list_location);
|
||||
let unknown_hosts = allowed_hosts::HostsStore::new(&config.storage_paths.unknown_list_location);
|
||||
let unknown_hosts =
|
||||
allowed_hosts::HostsStore::new(&config.storage_paths.unknown_list_location);
|
||||
|
||||
let outbound_request_filter =
|
||||
OutboundRequestFilter::new(allowed_hosts.clone(), standard_list.clone(), unknown_hosts);
|
||||
@@ -185,7 +186,8 @@ impl NRServiceProviderBuilder {
|
||||
pub async fn run_service_provider(self) -> Result<(), NetworkRequesterError> {
|
||||
// Connect to the mixnet
|
||||
let mixnet_client =
|
||||
create_mixnet_client(&self.config.base, &self.config.storage_paths.common_paths).await?;
|
||||
create_mixnet_client(&self.config.base, &self.config.storage_paths.common_paths)
|
||||
.await?;
|
||||
|
||||
// channels responsible for managing messages that are to be sent to the mix network. The receiver is
|
||||
// going to be used by `mixnet_response_listener`
|
||||
|
||||
Reference in New Issue
Block a user