Merge branch 'release/v0.4.1'

This commit is contained in:
Jedrzej Stuczynski
2020-01-29 10:15:30 +00:00
10 changed files with 78 additions and 80 deletions
+4 -4
View File
@@ -1,8 +1,8 @@
# Changelog
## [Unreleased](https://github.com/nymtech/nym/tree/HEAD)
## [v0.4.0](https://github.com/nymtech/nym/tree/v0.4.0) (2020-01-28)
[Full Changelog](https://github.com/nymtech/nym/compare/0.4.0-rc.2...HEAD)
[Full Changelog](https://github.com/nymtech/nym/compare/v0.4.0-rc.2...v0.4.0)
Nym 0.4.0 Platform
@@ -10,9 +10,9 @@ In this release, we're taking a lot more care with version numbers, so that we c
This release also integrates a health-checker and network topology refresh into the Nym client, so that the client can intelligently choose paths which route around any non-functional or incompatible nodes.
## [0.4.0-rc.2](https://github.com/nymtech/nym/tree/0.4.0-rc.2) (2020-01-28)
## [v0.4.0-rc.2](https://github.com/nymtech/nym/tree/v0.4.0-rc.2) (2020-01-28)
[Full Changelog](https://github.com/nymtech/nym/compare/v0.4.0-rc.1...0.4.0-rc.2)
[Full Changelog](https://github.com/nymtech/nym/compare/v0.4.0-rc.1...v0.4.0-rc.2)
**Merged pull requests:**
Generated
+6 -4
View File
@@ -1343,7 +1343,7 @@ dependencies = [
[[package]]
name = "nym-client"
version = "0.4.0"
version = "0.4.1"
dependencies = [
"addressing",
"bs58",
@@ -1375,7 +1375,7 @@ dependencies = [
[[package]]
name = "nym-mixnode"
version = "0.4.0"
version = "0.4.1"
dependencies = [
"addressing",
"bs58",
@@ -1393,7 +1393,7 @@ dependencies = [
[[package]]
name = "nym-sfw-provider"
version = "0.4.0"
version = "0.4.1"
dependencies = [
"bs58",
"built",
@@ -1417,11 +1417,12 @@ dependencies = [
[[package]]
name = "nym-validator"
version = "0.4.0"
version = "0.4.1"
dependencies = [
"built",
"clap",
"crypto",
"directory-client",
"dotenv",
"futures 0.3.1",
"healthcheck",
@@ -1431,6 +1432,7 @@ dependencies = [
"serde_derive",
"tokio 0.2.10",
"toml",
"topology",
]
[[package]]
+12 -39
View File
@@ -6,7 +6,7 @@ use log::{debug, error, info, trace};
use std::fmt::{Error, Formatter};
use std::marker::PhantomData;
use std::time::Duration;
use topology::NymTopologyError;
use topology::{NymTopology, NymTopologyError};
pub mod config;
mod path_check;
@@ -42,8 +42,6 @@ where
Priv: MixnetIdentityPrivateKey,
Pub: MixnetIdentityPublicKey,
{
directory_client: directory_client::Client,
interval: Duration,
num_test_packets: usize,
resolution_timeout: Duration,
identity_keypair: IDPair,
@@ -58,17 +56,14 @@ where
Priv: crypto::identity::MixnetIdentityPrivateKey,
Pub: crypto::identity::MixnetIdentityPublicKey,
{
pub fn new(config: config::HealthCheck, identity_keypair: IDPair) -> Self {
debug!(
"healthcheck will be using the following directory server: {:?}",
config.directory_server
);
let directory_client_config = directory_client::Config::new(config.directory_server);
pub fn new(
resolution_timeout_f64: f64,
num_test_packets: usize,
identity_keypair: IDPair,
) -> Self {
HealthChecker {
directory_client: directory_client::Client::new(directory_client_config),
interval: Duration::from_secs_f64(config.interval),
resolution_timeout: Duration::from_secs_f64(config.resolution_timeout),
num_test_packets: config.num_test_packets,
resolution_timeout: Duration::from_secs_f64(resolution_timeout_f64),
num_test_packets,
identity_keypair,
_phantom_private: PhantomData,
@@ -76,18 +71,12 @@ where
}
}
pub async fn do_check(&self) -> Result<HealthCheckResult, HealthCheckerError> {
pub async fn do_check<T: NymTopology>(
&self,
current_topology: &T,
) -> Result<HealthCheckResult, HealthCheckerError> {
trace!("going to perform a healthcheck!");
let current_topology = match self.directory_client.presence_topology.get() {
Ok(topology) => topology,
Err(err) => {
error!("failed to obtain topology - {:?}", err);
return Err(HealthCheckerError::FailedToObtainTopologyError);
}
};
trace!("current topology: {:?}", current_topology);
let mut healthcheck_result = HealthCheckResult::calculate(
current_topology,
self.num_test_packets,
@@ -98,20 +87,4 @@ where
healthcheck_result.sort_scores();
Ok(healthcheck_result)
}
pub async fn run(self) -> Result<(), HealthCheckerError> {
debug!(
"healthcheck will run every {:?} and will send {} packets to each node",
self.interval, self.num_test_packets
);
loop {
match self.do_check().await {
Ok(health) => info!("current network health: \n{}", health),
Err(err) => error!("failed to perform healthcheck - {:?}", err),
};
tokio::time::delay_for(self.interval).await;
}
}
}
+2 -2
View File
@@ -27,7 +27,7 @@ impl HealthCheckResult {
self.0.sort();
}
fn zero_score<T: NymTopology>(topology: T) -> Self {
fn zero_score<T: NymTopology>(topology: &T) -> Self {
warn!("The network is unhealthy, could not send any packets - returning zero score!");
let mixes = topology.mix_nodes();
let providers = topology.providers();
@@ -103,7 +103,7 @@ impl HealthCheckResult {
}
pub async fn calculate<T, IDPair, Priv, Pub>(
topology: T,
topology: &T,
iterations: usize,
resolution_timeout: Duration,
identity_keys: &IDPair,
+1 -1
View File
@@ -1,7 +1,7 @@
[package]
build = "build.rs"
name = "nym-mixnode"
version = "0.4.0"
version = "0.4.1"
authors = ["Dave Hrycyszyn <futurechimp@users.noreply.github.com>", "Jędrzej Stuczyński <andrew@nymtech.net>"]
edition = "2018"
+1 -1
View File
@@ -1,7 +1,7 @@
[package]
build = "build.rs"
name = "nym-client"
version = "0.4.0"
version = "0.4.1"
authors = ["Dave Hrycyszyn <futurechimp@users.noreply.github.com>", "Jędrzej Stuczyński <andrew@nymtech.net>"]
edition = "2018"
+14 -21
View File
@@ -43,17 +43,8 @@ where
refresh_rate: f64,
identity_keypair: IDPair,
) -> Self {
// topology control run a healthcheck to determine healthy-ish nodes:
// this is a temporary solution as the healthcheck will eventually be moved to validators
let healthcheck_config = healthcheck::config::HealthCheck {
directory_server: directory_server.clone(),
// those are literally irrelevant when running single check
interval: 100000.0,
resolution_timeout: 5.0,
num_test_packets: 2,
};
let health_checker = healthcheck::HealthChecker::new(healthcheck_config, identity_keypair);
let health_checker = healthcheck::HealthChecker::new(5.0, 2, identity_keypair);
let mut topology_control = TopologyControl {
directory_server,
@@ -79,8 +70,16 @@ where
async fn get_current_compatible_topology(&self) -> Result<T, TopologyError> {
let full_topology = T::new(self.directory_server.clone());
let version_filtered_topology = full_topology.filter_node_versions(
built_info::PKG_VERSION,
built_info::PKG_VERSION,
built_info::PKG_VERSION,
);
let healthcheck_result = self.health_checker.do_check().await;
let healthcheck_result = self
.health_checker
.do_check(&version_filtered_topology)
.await;
let healthcheck_scores = match healthcheck_result {
Err(err) => {
error!("Error while performing the healthcheck: {:?}", err);
@@ -89,21 +88,15 @@ where
Ok(scores) => scores,
};
let healthy_topology =
healthcheck_scores.filter_topology_by_score(&full_topology, NODE_HEALTH_THRESHOLD);
let versioned_healthy_topology = healthy_topology.filter_node_versions(
built_info::PKG_VERSION,
built_info::PKG_VERSION,
built_info::PKG_VERSION,
);
let healthy_topology = healthcheck_scores
.filter_topology_by_score(&version_filtered_topology, NODE_HEALTH_THRESHOLD);
// make sure you can still send a packet through the network:
if !versioned_healthy_topology.can_construct_path_through() {
if !healthy_topology.can_construct_path_through() {
return Err(TopologyError::NoValidPathsError);
}
Ok(versioned_healthy_topology)
Ok(healthy_topology)
}
pub(crate) fn get_inner_ref(&self) -> Arc<FRwLock<Inner<T>>> {
+1 -1
View File
@@ -1,7 +1,7 @@
[package]
build = "build.rs"
name = "nym-sfw-provider"
version = "0.4.0"
version = "0.4.1"
authors = ["Dave Hrycyszyn <futurechimp@users.noreply.github.com>", "Jędrzej Stuczyński <andrew@nymtech.net>"]
edition = "2018"
+3 -1
View File
@@ -1,7 +1,7 @@
[package]
build = "build.rs"
name = "nym-validator"
version = "0.4.0"
version = "0.4.1"
authors = ["Jedrzej Stuczynski <andrew@nymtech.net>"]
edition = "2018"
@@ -21,7 +21,9 @@ toml = "0.5.5"
## internal
crypto = {path = "../common/crypto"}
directory-client = { path = "../common/clients/directory-client" }
healthcheck = {path = "../common/healthcheck" }
topology = {path = "../common/topology"}
[build-dependencies]
built = "0.3.2"
+34 -6
View File
@@ -3,9 +3,12 @@ use crypto::identity::{
DummyMixIdentityKeyPair, DummyMixIdentityPrivateKey, DummyMixIdentityPublicKey,
MixnetIdentityKeyPair, MixnetIdentityPrivateKey, MixnetIdentityPublicKey,
};
use directory_client::presence::Topology;
use healthcheck::HealthChecker;
use log::debug;
use log::{debug, error, info};
use std::time::Duration;
use tokio::runtime::Runtime;
use topology::NymTopology;
pub mod config;
@@ -16,6 +19,7 @@ where
Priv: MixnetIdentityPrivateKey,
Pub: MixnetIdentityPublicKey,
{
config: Config,
#[allow(dead_code)]
identity_keypair: IDPair,
heath_check: HealthChecker<IDPair, Priv, Pub>,
@@ -30,7 +34,33 @@ impl Validator<DummyMixIdentityKeyPair, DummyMixIdentityPrivateKey, DummyMixIden
Validator {
identity_keypair: dummy_keypair.clone(),
heath_check: HealthChecker::new(config.health_check, dummy_keypair),
heath_check: HealthChecker::new(
config.health_check.resolution_timeout,
config.health_check.num_test_packets,
dummy_keypair,
),
config,
}
}
async fn healthcheck_runner<T: NymTopology>(&self) {
let healthcheck_interval = Duration::from_secs_f64(self.config.health_check.interval);
debug!("healthcheck will run every {:?}", healthcheck_interval);
loop {
let full_topology = T::new(self.config.health_check.directory_server.clone());
let version_filtered_topology = full_topology.filter_node_versions(
crate::built_info::PKG_VERSION,
crate::built_info::PKG_VERSION,
crate::built_info::PKG_VERSION,
);
match self.heath_check.do_check(&version_filtered_topology).await {
Ok(health) => info!("current network health: \n{}", health),
Err(err) => error!("failed to perform healthcheck - {:?}", err),
};
tokio::time::delay_for(healthcheck_interval).await;
}
}
@@ -39,9 +69,7 @@ impl Validator<DummyMixIdentityKeyPair, DummyMixIdentityPrivateKey, DummyMixIden
let mut rt = Runtime::new().unwrap();
let health_check_future = self.heath_check.run();
let health_check_res = rt.block_on(health_check_future);
assert!(health_check_res.is_ok()); // if it got here it means healthchecker failed anyway
let health_check_future = self.healthcheck_runner::<Topology>();
rt.block_on(health_check_future);
}
}