Skip to content

Commit

Permalink
Merge pull request #5242 from nymtech/merge/release/2024.14-crunch
Browse files Browse the repository at this point in the history
Merge/release/2024.14-crunch
  • Loading branch information
jstuczyn authored Dec 10, 2024
2 parents 66fea38 + 4e2aa2c commit fd47768
Show file tree
Hide file tree
Showing 178 changed files with 5,735 additions and 2,591 deletions.
9 changes: 6 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 1 addition & 28 deletions clients/native/src/commands/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,10 @@

use crate::commands::try_load_current_config;
use crate::{
client::{config::Config, SocketClient},
client::SocketClient,
commands::{override_config, OverrideConfig},
error::ClientError,
};
use clap::Args;
use log::*;
use nym_bin_common::version_checker::is_minor_version_compatible;
use nym_client_core::cli_helpers::client_run::CommonClientRunArgs;
use std::error::Error;
use std::net::IpAddr;
Expand Down Expand Up @@ -48,36 +45,12 @@ impl From<Run> for OverrideConfig {
}
}

// this only checks compatibility between config the binary. It does not take into consideration
// network version. It might do so in the future.
fn version_check(cfg: &Config) -> bool {
let binary_version = env!("CARGO_PKG_VERSION");
let config_version = &cfg.base.client.version;
if binary_version == config_version {
true
} else {
warn!("The native-client binary has different version than what is specified in config file! {} and {}", binary_version, config_version);
if is_minor_version_compatible(binary_version, config_version) {
info!("but they are still semver compatible. However, consider running the `upgrade` command");
true
} else {
error!("and they are semver incompatible! - please run the `upgrade` command before attempting `run` again");
false
}
}
}

pub(crate) async fn execute(args: Run) -> Result<(), Box<dyn Error + Send + Sync>> {
eprintln!("Starting client {}...", args.common_args.id);

let mut config = try_load_current_config(&args.common_args.id).await?;
config = override_config(config, OverrideConfig::from(args.clone()));

if !version_check(&config) {
error!("failed the local version check");
return Err(Box::new(ClientError::FailedLocalVersionCheck));
}

SocketClient::new(config, args.common_args.custom_mixnet)
.run_socket_forever()
.await
Expand Down
3 changes: 0 additions & 3 deletions clients/native/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ pub enum ClientError {
#[error("Failed to validate the loaded config")]
ConfigValidationFailure,

#[error("Failed local version check, client and config mismatch")]
FailedLocalVersionCheck,

#[error("Attempted to start the client in invalid socket mode")]
InvalidSocketMode,

Expand Down
34 changes: 1 addition & 33 deletions clients/socks5/src/commands/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,8 @@
// SPDX-License-Identifier: Apache-2.0

use crate::commands::try_load_current_config;
use crate::config::Config;
use crate::{
commands::{override_config, OverrideConfig},
error::Socks5ClientError,
};
use crate::commands::{override_config, OverrideConfig};
use clap::Args;
use log::*;
use nym_bin_common::version_checker::is_minor_version_compatible;
use nym_client_core::cli_helpers::client_run::CommonClientRunArgs;
use nym_client_core::client::base_client::storage::OnDiskPersistent;
use nym_client_core::client::topology_control::geo_aware_provider::CountryGroup;
Expand Down Expand Up @@ -82,38 +76,12 @@ fn validate_country_group(s: &str) -> Result<CountryGroup, String> {
}
}

// this only checks compatibility between config the binary. It does not take into consideration
// network version. It might do so in the future.
fn version_check(cfg: &Config) -> bool {
let binary_version = env!("CARGO_PKG_VERSION");
let config_version = &cfg.core.base.client.version;
if binary_version == config_version {
true
} else {
warn!(
"The socks5-client binary has different version than what is specified in config file! {binary_version} and {config_version}",
);
if is_minor_version_compatible(binary_version, config_version) {
info!("but they are still semver compatible. However, consider running the `upgrade` command");
true
} else {
error!("and they are semver incompatible! - please run the `upgrade` command before attempting `run` again");
false
}
}
}

pub(crate) async fn execute(args: Run) -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
eprintln!("Starting client {}...", args.common_args.id);

let mut config = try_load_current_config(&args.common_args.id).await?;
config = override_config(config, OverrideConfig::from(args.clone()));

if !version_check(&config) {
error!("failed the local version check");
return Err(Box::new(Socks5ClientError::FailedLocalVersionCheck));
}

let storage =
OnDiskPersistent::from_paths(config.storage_paths.common_paths, &config.core.base.debug)
.await?;
Expand Down
3 changes: 0 additions & 3 deletions clients/socks5/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ pub enum Socks5ClientError {
#[error("Failed to validate the loaded config")]
ConfigValidationFailure,

#[error("Failed local version check, client and config mismatch")]
FailedLocalVersionCheck,

#[error("Fail to bind address")]
FailToBindAddress,

Expand Down
2 changes: 1 addition & 1 deletion common/bandwidth-controller/src/acquire/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use nym_validator_client::coconut::all_ecash_api_clients;
use nym_validator_client::nym_api::EpochId;
use nym_validator_client::nyxd::contract_traits::EcashSigningClient;
use nym_validator_client::nyxd::contract_traits::{DkgQueryClient, EcashQueryClient};
use nym_validator_client::nyxd::cosmwasm_client::ToSingletonContractData;
use nym_validator_client::nyxd::cosmwasm_client::ContractResponseData;
use nym_validator_client::EcashApiClient;
use rand::rngs::OsRng;

Expand Down
3 changes: 1 addition & 2 deletions common/bin-common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ const-str = { workspace = true }
log = { workspace = true }
pretty_env_logger = { workspace = true }
schemars = { workspace = true, features = ["preserve_order"], optional = true }
semver.workspace = true
serde = { workspace = true, features = ["derive"] }
serde_json = { workspace = true, optional = true }

Expand Down Expand Up @@ -44,5 +43,5 @@ tracing = [
"tracing-opentelemetry",
"opentelemetry",
]
clap = [ "dep:clap", "dep:clap_complete", "dep:clap_complete_fig" ]
clap = ["dep:clap", "dep:clap_complete", "dep:clap_complete_fig"]
models = []
1 change: 0 additions & 1 deletion common/bin-common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

pub mod build_information;
pub mod logging;
pub mod version_checker;

#[cfg(feature = "clap")]
pub mod completions;
Expand Down
78 changes: 0 additions & 78 deletions common/bin-common/src/version_checker/mod.rs

This file was deleted.

7 changes: 1 addition & 6 deletions common/client-core/src/client/base_client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -514,15 +514,10 @@ where
min_gateway_performance: config_topology.minimum_gateway_performance,
},
nym_api_urls,
env!("CARGO_PKG_VERSION").to_string(),
user_agent,
)),
config::TopologyStructure::GeoAware(group_by) => {
Box::new(GeoAwareTopologyProvider::new(
nym_api_urls,
env!("CARGO_PKG_VERSION").to_string(),
group_by,
))
Box::new(GeoAwareTopologyProvider::new(nym_api_urls, group_by))
}
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,10 @@ fn check_layer_integrity(topology: NymTopology) -> Result<(), ()> {
pub struct GeoAwareTopologyProvider {
validator_client: nym_validator_client::client::NymApiClient,
filter_on: GroupBy,
client_version: String,
}

impl GeoAwareTopologyProvider {
pub fn new(
mut nym_api_urls: Vec<Url>,
client_version: String,
filter_on: GroupBy,
) -> GeoAwareTopologyProvider {
pub fn new(mut nym_api_urls: Vec<Url>, filter_on: GroupBy) -> GeoAwareTopologyProvider {
log::info!(
"Creating geo-aware topology provider with filter on {}",
filter_on
Expand All @@ -105,14 +100,13 @@ impl GeoAwareTopologyProvider {
nym_api_urls[0].clone(),
),
filter_on,
client_version,
}
}

async fn get_topology(&self) -> Option<NymTopology> {
let mixnodes = match self
.validator_client
.get_all_basic_active_mixing_assigned_nodes(Some(self.client_version.clone()))
.get_all_basic_active_mixing_assigned_nodes()
.await
{
Err(err) => {
Expand All @@ -124,7 +118,7 @@ impl GeoAwareTopologyProvider {

let gateways = match self
.validator_client
.get_all_basic_entry_assigned_nodes(Some(self.client_version.clone()))
.get_all_basic_entry_assigned_nodes()
.await
{
Err(err) => {
Expand Down
14 changes: 3 additions & 11 deletions common/client-core/src/client/topology_control/nym_api_provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,11 @@ pub struct NymApiTopologyProvider {

validator_client: nym_validator_client::client::NymApiClient,
nym_api_urls: Vec<Url>,

client_version: String,
currently_used_api: usize,
}

impl NymApiTopologyProvider {
pub fn new(
config: Config,
mut nym_api_urls: Vec<Url>,
client_version: String,
user_agent: Option<UserAgent>,
) -> Self {
pub fn new(config: Config, mut nym_api_urls: Vec<Url>, user_agent: Option<UserAgent>) -> Self {
nym_api_urls.shuffle(&mut thread_rng());

let validator_client = if let Some(user_agent) = user_agent {
Expand All @@ -62,7 +55,6 @@ impl NymApiTopologyProvider {
config,
validator_client,
nym_api_urls,
client_version,
currently_used_api: 0,
}
}
Expand Down Expand Up @@ -99,7 +91,7 @@ impl NymApiTopologyProvider {
async fn get_current_compatible_topology(&mut self) -> Option<NymTopology> {
let mixnodes = match self
.validator_client
.get_all_basic_active_mixing_assigned_nodes(Some(self.client_version.clone()))
.get_all_basic_active_mixing_assigned_nodes()
.await
{
Err(err) => {
Expand All @@ -111,7 +103,7 @@ impl NymApiTopologyProvider {

let gateways = match self
.validator_client
.get_all_basic_entry_assigned_nodes(Some(self.client_version.clone()))
.get_all_basic_entry_assigned_nodes()
.await
{
Err(err) => {
Expand Down
Loading

0 comments on commit fd47768

Please sign in to comment.