From 8731934f46d5419c2e74646abe42aff307963a4d Mon Sep 17 00:00:00 2001 From: Jedrzej Stuczynski Date: Tue, 28 Jan 2020 12:26:24 +0000 Subject: [PATCH 01/17] Fixed semver version compatibility --- common/version-checker/src/lib.rs | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/common/version-checker/src/lib.rs b/common/version-checker/src/lib.rs index 55232a9885..9cca937c37 100644 --- a/common/version-checker/src/lib.rs +++ b/common/version-checker/src/lib.rs @@ -1,5 +1,4 @@ use semver::Version; -use semver::VersionReq; /// Checks whether given `version` is compatible with a given semantic version requirement `req` /// according to major-minor semver rules. The semantic version requirement can be passed as a full, @@ -7,18 +6,16 @@ use semver::VersionReq; /// The patch number in the requirement gets dropped and replaced with a wildcard (0.3.*) as all /// minor versions should be compatible with each other. pub fn is_minor_version_compatible(version: &str, req: &str) -> bool { - let version = match Version::parse(version) { + let expected_version = match Version::parse(version) { Ok(v) => v, Err(_) => return false, }; - let tmp = match Version::parse(req) { + let req_version = match Version::parse(req) { Ok(v) => v, Err(_) => return false, }; - let wildcard = format!("{}.{}.*", tmp.major, tmp.minor).to_string(); - let semver_requirement = VersionReq::parse(&wildcard).expect("panicked on semver requirement parsing. This should never happen as inputs should already have been sanitized."); - semver_requirement.matches(&version) + expected_version.major == req_version.major && expected_version.minor == req_version.minor } #[cfg(test)] @@ -56,12 +53,17 @@ mod tests { } #[test] - fn returns_false_on_foo_version() { - assert!(!is_minor_version_compatible("foo", "0.3.2")); + fn version_0_4_0_rc_1_is_compatible_with_version_0_4_0_rc_1() { + assert!(is_minor_version_compatible("0.4.0-rc.1", "0.4.0-rc.1")); } - #[test] - fn returns_false_on_bar_version() { - assert!(!is_minor_version_compatible("0.3.2", "bar")); - } + // #[test] + // fn returns_false_on_foo_version() { + // assert!(!is_minor_version_compatible("foo", "0.3.2")); + // } + // + // #[test] + // fn returns_false_on_bar_version() { + // assert!(!is_minor_version_compatible("0.3.2", "bar")); + // } } From 3e40d90b72a9de0c3bf23ef7529404b201cd37d1 Mon Sep 17 00:00:00 2001 From: Jedrzej Stuczynski Date: Tue, 28 Jan 2020 12:26:46 +0000 Subject: [PATCH 02/17] Restored commented tests --- common/version-checker/src/lib.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/common/version-checker/src/lib.rs b/common/version-checker/src/lib.rs index 9cca937c37..eda9391205 100644 --- a/common/version-checker/src/lib.rs +++ b/common/version-checker/src/lib.rs @@ -57,13 +57,13 @@ mod tests { assert!(is_minor_version_compatible("0.4.0-rc.1", "0.4.0-rc.1")); } - // #[test] - // fn returns_false_on_foo_version() { - // assert!(!is_minor_version_compatible("foo", "0.3.2")); - // } - // - // #[test] - // fn returns_false_on_bar_version() { - // assert!(!is_minor_version_compatible("0.3.2", "bar")); - // } + #[test] + fn returns_false_on_foo_version() { + assert!(!is_minor_version_compatible("foo", "0.3.2")); + } + + #[test] + fn returns_false_on_bar_version() { + assert!(!is_minor_version_compatible("0.3.2", "bar")); + } } From cdbadaf5810dea95ba91ab3b40b3000760772137 Mon Sep 17 00:00:00 2001 From: Dave Hrycyszyn Date: Tue, 28 Jan 2020 12:49:28 +0000 Subject: [PATCH 03/17] scripts: changelog generation script --- CHANGELOG.md | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5dfcddc34a..a60b1de804 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,15 @@ ## [Unreleased](https://github.com/nymtech/nym/tree/HEAD) -[Full Changelog](https://github.com/nymtech/nym/compare/v0.3.3...HEAD) +[Full Changelog](https://github.com/nymtech/nym/compare/v0.4.0-rc.1...HEAD) + +**Merged pull requests:** + +- Hotfix/semver compatibility [\#106](https://github.com/nymtech/nym/pull/106) ([jstuczyn](https://github.com/jstuczyn)) + +## [v0.4.0-rc.1](https://github.com/nymtech/nym/tree/v0.4.0-rc.1) (2020-01-28) + +[Full Changelog](https://github.com/nymtech/nym/compare/v0.3.3...v0.4.0-rc.1) **Closed issues:** @@ -30,10 +38,10 @@ - Feature/check packet length [\#99](https://github.com/nymtech/nym/pull/99) ([futurechimp](https://github.com/futurechimp)) - Feature/version filtering improvements [\#96](https://github.com/nymtech/nym/pull/96) ([futurechimp](https://github.com/futurechimp)) - Feature/refreshing topology [\#94](https://github.com/nymtech/nym/pull/94) ([jstuczyn](https://github.com/jstuczyn)) -- Feature/consistent logging [\#93](https://github.com/nymtech/nym/pull/93) ([futurechimp](https://github.com/futurechimp)) - Feature/semver client [\#92](https://github.com/nymtech/nym/pull/92) ([futurechimp](https://github.com/futurechimp)) - Feature/client refactor [\#91](https://github.com/nymtech/nym/pull/91) ([jstuczyn](https://github.com/jstuczyn)) - Release builds should no longer silently fail - everything will be im… [\#89](https://github.com/nymtech/nym/pull/89) ([jstuczyn](https://github.com/jstuczyn)) +- Feature/nym client lib [\#61](https://github.com/nymtech/nym/pull/61) ([jstuczyn](https://github.com/jstuczyn)) ## [v0.3.3](https://github.com/nymtech/nym/tree/v0.3.3) (2020-01-20) @@ -56,9 +64,10 @@ **Merged pull requests:** +- Feature/consistent logging [\#93](https://github.com/nymtech/nym/pull/93) ([futurechimp](https://github.com/futurechimp)) - Feature/websocket improvements [\#88](https://github.com/nymtech/nym/pull/88) ([jstuczyn](https://github.com/jstuczyn)) - Using println rather than log for startup banner, it's not an error [\#87](https://github.com/nymtech/nym/pull/87) ([futurechimp](https://github.com/futurechimp)) -- Feature/nym client lib [\#61](https://github.com/nymtech/nym/pull/61) ([jstuczyn](https://github.com/jstuczyn)) +- Feature/client topology filtering [\#54](https://github.com/nymtech/nym/pull/54) ([jstuczyn](https://github.com/jstuczyn)) ## [v0.3.2](https://github.com/nymtech/nym/tree/v0.3.2) (2020-01-17) @@ -94,7 +103,6 @@ **Merged pull requests:** -- Feature/client topology filtering [\#54](https://github.com/nymtech/nym/pull/54) ([jstuczyn](https://github.com/jstuczyn)) - print public key for nym client tools [\#53](https://github.com/nymtech/nym/pull/53) ([mileschet](https://github.com/mileschet)) - Showing binding warning on binding to localhost, 0.0.0.0 or 127.0.0.1 [\#52](https://github.com/nymtech/nym/pull/52) ([jstuczyn](https://github.com/jstuczyn)) - validator: moving sample config files into sample configs directory [\#51](https://github.com/nymtech/nym/pull/51) ([futurechimp](https://github.com/futurechimp)) @@ -114,7 +122,11 @@ ## [v0.2.0](https://github.com/nymtech/nym/tree/v0.2.0) (2020-01-07) -[Full Changelog](https://github.com/nymtech/nym/compare/3c64a2facd753f4f2f431e7f888e54842e2bc64e...v0.2.0) +[Full Changelog](https://github.com/nymtech/nym/compare/0.2.0...v0.2.0) + +## [0.2.0](https://github.com/nymtech/nym/tree/0.2.0) (2020-01-06) + +[Full Changelog](https://github.com/nymtech/nym/compare/0.1.0...0.2.0) From 677791d64c7442ff86a83d52130a9ad95da054d1 Mon Sep 17 00:00:00 2001 From: Dave Hrycyszyn Date: Tue, 28 Jan 2020 12:49:34 +0000 Subject: [PATCH 04/17] ibid --- scripts/generate_changelog.sh | 1 + 1 file changed, 1 insertion(+) create mode 100644 scripts/generate_changelog.sh diff --git a/scripts/generate_changelog.sh b/scripts/generate_changelog.sh new file mode 100644 index 0000000000..be3a627d90 --- /dev/null +++ b/scripts/generate_changelog.sh @@ -0,0 +1 @@ +github_changelog_generator -u nymtech -p nym --exclude-tags 0.1.0 --token From 516077086ca2183e982dd65eb574f521c07eeb7d Mon Sep 17 00:00:00 2001 From: Dave Hrycyszyn Date: Tue, 28 Jan 2020 15:32:09 +0000 Subject: [PATCH 05/17] all: bumped version numbers to 0.4.0-rc.2 --- Cargo.lock | 8 ++++---- mixnode/Cargo.toml | 2 +- nym-client/Cargo.toml | 2 +- sfw-provider/Cargo.toml | 2 +- validator/Cargo.toml | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 14b3f014ca..52d308dff0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1343,7 +1343,7 @@ dependencies = [ [[package]] name = "nym-client" -version = "0.4.0-rc.1" +version = "0.4.0-rc.2" dependencies = [ "addressing", "bs58", @@ -1375,7 +1375,7 @@ dependencies = [ [[package]] name = "nym-mixnode" -version = "0.4.0-rc.1" +version = "0.4.0-rc.2" dependencies = [ "addressing", "bs58", @@ -1393,7 +1393,7 @@ dependencies = [ [[package]] name = "nym-sfw-provider" -version = "0.4.0-rc.1" +version = "0.4.0-rc.2" dependencies = [ "bs58", "built", @@ -1417,7 +1417,7 @@ dependencies = [ [[package]] name = "nym-validator" -version = "0.4.0-rc.1" +version = "0.4.0-rc.2" dependencies = [ "built", "clap", diff --git a/mixnode/Cargo.toml b/mixnode/Cargo.toml index a87431cd2e..add76f93e6 100644 --- a/mixnode/Cargo.toml +++ b/mixnode/Cargo.toml @@ -1,7 +1,7 @@ [package] build = "build.rs" name = "nym-mixnode" -version = "0.4.0-rc.1" +version = "0.4.0-rc.2" authors = ["Dave Hrycyszyn ", "Jędrzej Stuczyński "] edition = "2018" diff --git a/nym-client/Cargo.toml b/nym-client/Cargo.toml index ec184005c2..3fb8b0a55d 100644 --- a/nym-client/Cargo.toml +++ b/nym-client/Cargo.toml @@ -1,7 +1,7 @@ [package] build = "build.rs" name = "nym-client" -version = "0.4.0-rc.1" +version = "0.4.0-rc.2" authors = ["Dave Hrycyszyn ", "Jędrzej Stuczyński "] edition = "2018" diff --git a/sfw-provider/Cargo.toml b/sfw-provider/Cargo.toml index 5bb8306412..1284e31ef4 100644 --- a/sfw-provider/Cargo.toml +++ b/sfw-provider/Cargo.toml @@ -1,7 +1,7 @@ [package] build = "build.rs" name = "nym-sfw-provider" -version = "0.4.0-rc.1" +version = "0.4.0-rc.2" authors = ["Dave Hrycyszyn ", "Jędrzej Stuczyński "] edition = "2018" diff --git a/validator/Cargo.toml b/validator/Cargo.toml index 5bf0cf583a..2eedf207f0 100644 --- a/validator/Cargo.toml +++ b/validator/Cargo.toml @@ -1,7 +1,7 @@ [package] build = "build.rs" name = "nym-validator" -version = "0.4.0-rc.1" +version = "0.4.0-rc.2" authors = ["Jedrzej Stuczynski "] edition = "2018" From 1d58d1c2f1fb2f754166432f394864721bbf1b71 Mon Sep 17 00:00:00 2001 From: Dave Hrycyszyn Date: Tue, 28 Jan 2020 15:38:01 +0000 Subject: [PATCH 06/17] Fixed changelog generator script --- scripts/generate_changelog.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) mode change 100644 => 100755 scripts/generate_changelog.sh diff --git a/scripts/generate_changelog.sh b/scripts/generate_changelog.sh old mode 100644 new mode 100755 index be3a627d90..22097168ba --- a/scripts/generate_changelog.sh +++ b/scripts/generate_changelog.sh @@ -1 +1,3 @@ -github_changelog_generator -u nymtech -p nym --exclude-tags 0.1.0 --token +#!/bin/bash +# set CHANGELOG_GITHUB_TOKEN in your .bashrc file +github_changelog_generator -u nymtech -p nym --exclude-tags 0.1.0 --token "$CHANGELOG_GITHUB_TOKEN" From d189e6f55d173e6880bdf75e1f2f11c9c17c9d7d Mon Sep 17 00:00:00 2001 From: Dave Hrycyszyn Date: Tue, 28 Jan 2020 15:38:09 +0000 Subject: [PATCH 07/17] Regenerated changelog --- CHANGELOG.md | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a60b1de804..f04b7d09a6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -38,10 +38,10 @@ - Feature/check packet length [\#99](https://github.com/nymtech/nym/pull/99) ([futurechimp](https://github.com/futurechimp)) - Feature/version filtering improvements [\#96](https://github.com/nymtech/nym/pull/96) ([futurechimp](https://github.com/futurechimp)) - Feature/refreshing topology [\#94](https://github.com/nymtech/nym/pull/94) ([jstuczyn](https://github.com/jstuczyn)) +- Feature/consistent logging [\#93](https://github.com/nymtech/nym/pull/93) ([futurechimp](https://github.com/futurechimp)) - Feature/semver client [\#92](https://github.com/nymtech/nym/pull/92) ([futurechimp](https://github.com/futurechimp)) - Feature/client refactor [\#91](https://github.com/nymtech/nym/pull/91) ([jstuczyn](https://github.com/jstuczyn)) - Release builds should no longer silently fail - everything will be im… [\#89](https://github.com/nymtech/nym/pull/89) ([jstuczyn](https://github.com/jstuczyn)) -- Feature/nym client lib [\#61](https://github.com/nymtech/nym/pull/61) ([jstuczyn](https://github.com/jstuczyn)) ## [v0.3.3](https://github.com/nymtech/nym/tree/v0.3.3) (2020-01-20) @@ -64,19 +64,14 @@ **Merged pull requests:** -- Feature/consistent logging [\#93](https://github.com/nymtech/nym/pull/93) ([futurechimp](https://github.com/futurechimp)) - Feature/websocket improvements [\#88](https://github.com/nymtech/nym/pull/88) ([jstuczyn](https://github.com/jstuczyn)) - Using println rather than log for startup banner, it's not an error [\#87](https://github.com/nymtech/nym/pull/87) ([futurechimp](https://github.com/futurechimp)) -- Feature/client topology filtering [\#54](https://github.com/nymtech/nym/pull/54) ([jstuczyn](https://github.com/jstuczyn)) +- Feature/nym client lib [\#61](https://github.com/nymtech/nym/pull/61) ([jstuczyn](https://github.com/jstuczyn)) ## [v0.3.2](https://github.com/nymtech/nym/tree/v0.3.2) (2020-01-17) [Full Changelog](https://github.com/nymtech/nym/compare/v0.3.1...v0.3.2) -**Merged pull requests:** - -- Feature/separate presence address [\#59](https://github.com/nymtech/nym/pull/59) ([jstuczyn](https://github.com/jstuczyn)) - ## [v0.3.1](https://github.com/nymtech/nym/tree/v0.3.1) (2020-01-16) [Full Changelog](https://github.com/nymtech/nym/compare/v0.3.0...v0.3.1) @@ -103,6 +98,8 @@ **Merged pull requests:** +- Feature/separate presence address [\#59](https://github.com/nymtech/nym/pull/59) ([jstuczyn](https://github.com/jstuczyn)) +- Feature/client topology filtering [\#54](https://github.com/nymtech/nym/pull/54) ([jstuczyn](https://github.com/jstuczyn)) - print public key for nym client tools [\#53](https://github.com/nymtech/nym/pull/53) ([mileschet](https://github.com/mileschet)) - Showing binding warning on binding to localhost, 0.0.0.0 or 127.0.0.1 [\#52](https://github.com/nymtech/nym/pull/52) ([jstuczyn](https://github.com/jstuczyn)) - validator: moving sample config files into sample configs directory [\#51](https://github.com/nymtech/nym/pull/51) ([futurechimp](https://github.com/futurechimp)) From 922223219dab7448e5dc78221d44cb753da41099 Mon Sep 17 00:00:00 2001 From: Dave Hrycyszyn Date: Tue, 28 Jan 2020 16:19:56 +0000 Subject: [PATCH 08/17] Version bump for release 0.4.0 --- Cargo.lock | 8 ++++---- mixnode/Cargo.toml | 2 +- nym-client/Cargo.toml | 2 +- sfw-provider/Cargo.toml | 2 +- validator/Cargo.toml | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 52d308dff0..adaec6c811 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1343,7 +1343,7 @@ dependencies = [ [[package]] name = "nym-client" -version = "0.4.0-rc.2" +version = "0.4.0" dependencies = [ "addressing", "bs58", @@ -1375,7 +1375,7 @@ dependencies = [ [[package]] name = "nym-mixnode" -version = "0.4.0-rc.2" +version = "0.4.0" dependencies = [ "addressing", "bs58", @@ -1393,7 +1393,7 @@ dependencies = [ [[package]] name = "nym-sfw-provider" -version = "0.4.0-rc.2" +version = "0.4.0" dependencies = [ "bs58", "built", @@ -1417,7 +1417,7 @@ dependencies = [ [[package]] name = "nym-validator" -version = "0.4.0-rc.2" +version = "0.4.0" dependencies = [ "built", "clap", diff --git a/mixnode/Cargo.toml b/mixnode/Cargo.toml index add76f93e6..130e068d65 100644 --- a/mixnode/Cargo.toml +++ b/mixnode/Cargo.toml @@ -1,7 +1,7 @@ [package] build = "build.rs" name = "nym-mixnode" -version = "0.4.0-rc.2" +version = "0.4.0" authors = ["Dave Hrycyszyn ", "Jędrzej Stuczyński "] edition = "2018" diff --git a/nym-client/Cargo.toml b/nym-client/Cargo.toml index 3fb8b0a55d..388dcfa9ce 100644 --- a/nym-client/Cargo.toml +++ b/nym-client/Cargo.toml @@ -1,7 +1,7 @@ [package] build = "build.rs" name = "nym-client" -version = "0.4.0-rc.2" +version = "0.4.0" authors = ["Dave Hrycyszyn ", "Jędrzej Stuczyński "] edition = "2018" diff --git a/sfw-provider/Cargo.toml b/sfw-provider/Cargo.toml index 1284e31ef4..d0b34bb121 100644 --- a/sfw-provider/Cargo.toml +++ b/sfw-provider/Cargo.toml @@ -1,7 +1,7 @@ [package] build = "build.rs" name = "nym-sfw-provider" -version = "0.4.0-rc.2" +version = "0.4.0" authors = ["Dave Hrycyszyn ", "Jędrzej Stuczyński "] edition = "2018" diff --git a/validator/Cargo.toml b/validator/Cargo.toml index 2eedf207f0..3895b662fe 100644 --- a/validator/Cargo.toml +++ b/validator/Cargo.toml @@ -1,7 +1,7 @@ [package] build = "build.rs" name = "nym-validator" -version = "0.4.0-rc.2" +version = "0.4.0" authors = ["Jedrzej Stuczynski "] edition = "2018" From 30da43060f4441fa8a671784657742d3434bb844 Mon Sep 17 00:00:00 2001 From: Dave Hrycyszyn Date: Tue, 28 Jan 2020 16:26:57 +0000 Subject: [PATCH 09/17] Changelog for 0.4.0 --- CHANGELOG.md | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f04b7d09a6..4e4b8acc1d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,17 @@ ## [Unreleased](https://github.com/nymtech/nym/tree/HEAD) -[Full Changelog](https://github.com/nymtech/nym/compare/v0.4.0-rc.1...HEAD) +[Full Changelog](https://github.com/nymtech/nym/compare/0.4.0-rc.2...HEAD) + +Nym 0.4.0 Platform + +In this release, we're taking a lot more care with version numbers, so that we can ensure upgrade compatibility for mixnodes, providers, clients, and validators more easily. + +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) + +[Full Changelog](https://github.com/nymtech/nym/compare/v0.4.0-rc.1...0.4.0-rc.2) **Merged pull requests:** @@ -72,6 +82,10 @@ [Full Changelog](https://github.com/nymtech/nym/compare/v0.3.1...v0.3.2) +**Merged pull requests:** + +- Feature/separate presence address [\#59](https://github.com/nymtech/nym/pull/59) ([jstuczyn](https://github.com/jstuczyn)) + ## [v0.3.1](https://github.com/nymtech/nym/tree/v0.3.1) (2020-01-16) [Full Changelog](https://github.com/nymtech/nym/compare/v0.3.0...v0.3.1) @@ -98,7 +112,6 @@ **Merged pull requests:** -- Feature/separate presence address [\#59](https://github.com/nymtech/nym/pull/59) ([jstuczyn](https://github.com/jstuczyn)) - Feature/client topology filtering [\#54](https://github.com/nymtech/nym/pull/54) ([jstuczyn](https://github.com/jstuczyn)) - print public key for nym client tools [\#53](https://github.com/nymtech/nym/pull/53) ([mileschet](https://github.com/mileschet)) - Showing binding warning on binding to localhost, 0.0.0.0 or 127.0.0.1 [\#52](https://github.com/nymtech/nym/pull/52) ([jstuczyn](https://github.com/jstuczyn)) From 24d9825a49f14ca73b6112fc5084e967dd11520f Mon Sep 17 00:00:00 2001 From: Dave Hrycyszyn Date: Tue, 28 Jan 2020 17:04:37 +0000 Subject: [PATCH 10/17] Fixed changelog v prefix on version --- CHANGELOG.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4e4b8acc1d..4f60174ed7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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:** From d7b069e0e5b6ba84adc835e08d02fa91578f472f Mon Sep 17 00:00:00 2001 From: Jedrzej Stuczynski Date: Tue, 28 Jan 2020 18:06:39 +0000 Subject: [PATCH 11/17] validator responsible for running healtchecker loop --- validator/src/validator/mod.rs | 40 +++++++++++++++++++++++++++++----- 1 file changed, 34 insertions(+), 6 deletions(-) diff --git a/validator/src/validator/mod.rs b/validator/src/validator/mod.rs index 6ed56fa42b..26f031fab5 100644 --- a/validator/src/validator/mod.rs +++ b/validator/src/validator/mod.rs @@ -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, @@ -30,7 +34,33 @@ impl Validator(&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(); + rt.block_on(health_check_future); } } From eb3aa0baf18eb380f41b9025f207d7e35bd867f4 Mon Sep 17 00:00:00 2001 From: Jedrzej Stuczynski Date: Tue, 28 Jan 2020 18:06:59 +0000 Subject: [PATCH 12/17] healthchecker no longer pulling entire topology itself --- common/healthcheck/src/lib.rs | 51 ++++++++------------------------ common/healthcheck/src/result.rs | 4 +-- 2 files changed, 14 insertions(+), 41 deletions(-) diff --git a/common/healthcheck/src/lib.rs b/common/healthcheck/src/lib.rs index b95eefd454..7cd97692db 100644 --- a/common/healthcheck/src/lib.rs +++ b/common/healthcheck/src/lib.rs @@ -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 { + pub async fn do_check( + &self, + current_topology: &T, + ) -> Result { 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; - } - } } diff --git a/common/healthcheck/src/result.rs b/common/healthcheck/src/result.rs index 83d1f8778c..9eda0885f5 100644 --- a/common/healthcheck/src/result.rs +++ b/common/healthcheck/src/result.rs @@ -27,7 +27,7 @@ impl HealthCheckResult { self.0.sort(); } - fn zero_score(topology: T) -> Self { + fn zero_score(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( - topology: T, + topology: &T, iterations: usize, resolution_timeout: Duration, identity_keys: &IDPair, From e23dd5721333c51ffb1db6c0f922b250c3545ebb Mon Sep 17 00:00:00 2001 From: Jedrzej Stuczynski Date: Tue, 28 Jan 2020 18:07:24 +0000 Subject: [PATCH 13/17] Client using pre-filtered topology for the healthchecker --- Cargo.lock | 2 ++ nym-client/src/client/topology_control.rs | 35 +++++++++-------------- validator/Cargo.toml | 2 ++ 3 files changed, 18 insertions(+), 21 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index adaec6c811..a08936e126 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1422,6 +1422,7 @@ 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]] diff --git a/nym-client/src/client/topology_control.rs b/nym-client/src/client/topology_control.rs index 9daafc0572..9833f81166 100644 --- a/nym-client/src/client/topology_control.rs +++ b/nym-client/src/client/topology_control.rs @@ -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 { 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>> { diff --git a/validator/Cargo.toml b/validator/Cargo.toml index 3895b662fe..00cc970649 100644 --- a/validator/Cargo.toml +++ b/validator/Cargo.toml @@ -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" From 2b73aa9976d3b5cc6991942c8f0a934887bde5fb Mon Sep 17 00:00:00 2001 From: Jedrzej Stuczynski Date: Wed, 29 Jan 2020 10:14:53 +0000 Subject: [PATCH 14/17] Updated packages versions --- Cargo.lock | 8 ++++---- mixnode/Cargo.toml | 2 +- nym-client/Cargo.toml | 2 +- sfw-provider/Cargo.toml | 2 +- validator/Cargo.toml | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a08936e126..dbf0d16af9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -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,7 +1417,7 @@ dependencies = [ [[package]] name = "nym-validator" -version = "0.4.0" +version = "0.4.1" dependencies = [ "built", "clap", diff --git a/mixnode/Cargo.toml b/mixnode/Cargo.toml index 130e068d65..4685d6416e 100644 --- a/mixnode/Cargo.toml +++ b/mixnode/Cargo.toml @@ -1,7 +1,7 @@ [package] build = "build.rs" name = "nym-mixnode" -version = "0.4.0" +version = "0.4.1" authors = ["Dave Hrycyszyn ", "Jędrzej Stuczyński "] edition = "2018" diff --git a/nym-client/Cargo.toml b/nym-client/Cargo.toml index 388dcfa9ce..e5b16383f7 100644 --- a/nym-client/Cargo.toml +++ b/nym-client/Cargo.toml @@ -1,7 +1,7 @@ [package] build = "build.rs" name = "nym-client" -version = "0.4.0" +version = "0.4.1" authors = ["Dave Hrycyszyn ", "Jędrzej Stuczyński "] edition = "2018" diff --git a/sfw-provider/Cargo.toml b/sfw-provider/Cargo.toml index d0b34bb121..d2a7cf2c5c 100644 --- a/sfw-provider/Cargo.toml +++ b/sfw-provider/Cargo.toml @@ -1,7 +1,7 @@ [package] build = "build.rs" name = "nym-sfw-provider" -version = "0.4.0" +version = "0.4.1" authors = ["Dave Hrycyszyn ", "Jędrzej Stuczyński "] edition = "2018" diff --git a/validator/Cargo.toml b/validator/Cargo.toml index 00cc970649..c64de656cd 100644 --- a/validator/Cargo.toml +++ b/validator/Cargo.toml @@ -1,7 +1,7 @@ [package] build = "build.rs" name = "nym-validator" -version = "0.4.0" +version = "0.4.1" authors = ["Jedrzej Stuczynski "] edition = "2018" From b9f3000dcc412dd6c11bfad483ac7f1d34b5da22 Mon Sep 17 00:00:00 2001 From: Jedrzej Stuczynski Date: Wed, 29 Jan 2020 10:17:47 +0000 Subject: [PATCH 15/17] Updated changelog --- CHANGELOG.md | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4f60174ed7..983dcc4625 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,17 @@ # Changelog +## [v0.4.1](https://github.com/nymtech/nym/tree/v0.4.1) (2020-01-29) + +[Full Changelog](https://github.com/nymtech/nym/compare/v0.4.0...v0.4.1) + +**Closed issues:** + +- Change healthcheck to run on provided topology rather than pull one itself [\#95](https://github.com/nymtech/nym/issues/95) + +**Merged pull requests:** + +- Bugfix/healthcheck on provided topology [\#108](https://github.com/nymtech/nym/pull/108) ([jstuczyn](https://github.com/jstuczyn)) + ## [v0.4.0](https://github.com/nymtech/nym/tree/v0.4.0) (2020-01-28) [Full Changelog](https://github.com/nymtech/nym/compare/v0.4.0-rc.2...v0.4.0) @@ -82,10 +94,6 @@ This release also integrates a health-checker and network topology refresh into [Full Changelog](https://github.com/nymtech/nym/compare/v0.3.1...v0.3.2) -**Merged pull requests:** - -- Feature/separate presence address [\#59](https://github.com/nymtech/nym/pull/59) ([jstuczyn](https://github.com/jstuczyn)) - ## [v0.3.1](https://github.com/nymtech/nym/tree/v0.3.1) (2020-01-16) [Full Changelog](https://github.com/nymtech/nym/compare/v0.3.0...v0.3.1) @@ -112,6 +120,7 @@ This release also integrates a health-checker and network topology refresh into **Merged pull requests:** +- Feature/separate presence address [\#59](https://github.com/nymtech/nym/pull/59) ([jstuczyn](https://github.com/jstuczyn)) - Feature/client topology filtering [\#54](https://github.com/nymtech/nym/pull/54) ([jstuczyn](https://github.com/jstuczyn)) - print public key for nym client tools [\#53](https://github.com/nymtech/nym/pull/53) ([mileschet](https://github.com/mileschet)) - Showing binding warning on binding to localhost, 0.0.0.0 or 127.0.0.1 [\#52](https://github.com/nymtech/nym/pull/52) ([jstuczyn](https://github.com/jstuczyn)) From a73585e13aeddfac4c419db8eabee9dda0fef556 Mon Sep 17 00:00:00 2001 From: Jedrzej Stuczynski Date: Wed, 29 Jan 2020 15:30:20 +0000 Subject: [PATCH 16/17] Simplified the use of generics on identity keypair by using output types --- common/crypto/src/identity/mod.rs | 20 ++++++++--------- common/healthcheck/src/lib.rs | 27 ++++------------------- common/healthcheck/src/path_check.rs | 11 +++------ common/healthcheck/src/result.rs | 8 +++---- common/pemstore/src/pemstore.rs | 19 ++++++---------- nym-client/src/client/mod.rs | 22 +++++------------- nym-client/src/client/topology_control.rs | 16 +++++--------- 7 files changed, 39 insertions(+), 84 deletions(-) diff --git a/common/crypto/src/identity/mod.rs b/common/crypto/src/identity/mod.rs index cf39000e5d..3c920f84dc 100644 --- a/common/crypto/src/identity/mod.rs +++ b/common/crypto/src/identity/mod.rs @@ -6,14 +6,13 @@ use bs58; use curve25519_dalek::scalar::Scalar; use sphinx::route::DestinationAddressBytes; -pub trait MixnetIdentityKeyPair: Clone -where - Priv: MixnetIdentityPrivateKey, - Pub: MixnetIdentityPublicKey, -{ +pub trait MixnetIdentityKeyPair: Clone { + type PublicKeyMaterial: MixnetIdentityPublicKey; + type PrivateKeyMaterial: MixnetIdentityPrivateKey; + fn new() -> Self; - fn private_key(&self) -> &Priv; - fn public_key(&self) -> &Pub; + fn private_key(&self) -> &Self::PrivateKeyMaterial; + fn public_key(&self) -> &Self::PublicKeyMaterial; fn from_bytes(priv_bytes: &[u8], pub_bytes: &[u8]) -> Self; // TODO: signing related methods @@ -56,9 +55,10 @@ pub struct DummyMixIdentityKeyPair { pub public_key: DummyMixIdentityPublicKey, } -impl MixnetIdentityKeyPair - for DummyMixIdentityKeyPair -{ +impl MixnetIdentityKeyPair for DummyMixIdentityKeyPair { + type PublicKeyMaterial = DummyMixIdentityPublicKey; + type PrivateKeyMaterial = DummyMixIdentityPrivateKey; + fn new() -> Self { let keypair = encryption::x25519::KeyPair::new(); DummyMixIdentityKeyPair { diff --git a/common/healthcheck/src/lib.rs b/common/healthcheck/src/lib.rs index 7cd97692db..5554b2bb97 100644 --- a/common/healthcheck/src/lib.rs +++ b/common/healthcheck/src/lib.rs @@ -1,10 +1,7 @@ use crate::result::HealthCheckResult; -use crypto::identity::{MixnetIdentityKeyPair, MixnetIdentityPrivateKey, MixnetIdentityPublicKey}; -use directory_client::requests::presence_topology_get::PresenceTopologyGetRequester; -use directory_client::DirectoryClient; -use log::{debug, error, info, trace}; +use crypto::identity::MixnetIdentityKeyPair; +use log::trace; use std::fmt::{Error, Formatter}; -use std::marker::PhantomData; use std::time::Duration; use topology::{NymTopology, NymTopologyError}; @@ -36,26 +33,13 @@ impl From for HealthCheckerError { } } -pub struct HealthChecker -where - IDPair: MixnetIdentityKeyPair, - Priv: MixnetIdentityPrivateKey, - Pub: MixnetIdentityPublicKey, -{ +pub struct HealthChecker { num_test_packets: usize, resolution_timeout: Duration, identity_keypair: IDPair, - - _phantom_private: PhantomData, - _phantom_public: PhantomData, } -impl HealthChecker -where - IDPair: crypto::identity::MixnetIdentityKeyPair, - Priv: crypto::identity::MixnetIdentityPrivateKey, - Pub: crypto::identity::MixnetIdentityPublicKey, -{ +impl HealthChecker { pub fn new( resolution_timeout_f64: f64, num_test_packets: usize, @@ -65,9 +49,6 @@ where resolution_timeout: Duration::from_secs_f64(resolution_timeout_f64), num_test_packets, identity_keypair, - - _phantom_private: PhantomData, - _phantom_public: PhantomData, } } diff --git a/common/healthcheck/src/path_check.rs b/common/healthcheck/src/path_check.rs index b1d2617ad8..a345e82d99 100644 --- a/common/healthcheck/src/path_check.rs +++ b/common/healthcheck/src/path_check.rs @@ -1,4 +1,4 @@ -use crypto::identity::{MixnetIdentityKeyPair, MixnetIdentityPrivateKey, MixnetIdentityPublicKey}; +use crypto::identity::{MixnetIdentityKeyPair, MixnetIdentityPublicKey}; use itertools::Itertools; use log::{debug, error, info, trace, warn}; use mix_client::MixClient; @@ -27,16 +27,11 @@ pub(crate) struct PathChecker { } impl PathChecker { - pub(crate) async fn new( + pub(crate) async fn new( providers: Vec, identity_keys: &IDPair, check_id: [u8; 16], - ) -> Self - where - IDPair: MixnetIdentityKeyPair, - Priv: MixnetIdentityPrivateKey, - Pub: MixnetIdentityPublicKey, - { + ) -> Self { let mut provider_clients = HashMap::new(); let address = identity_keys.public_key().derive_address(); diff --git a/common/healthcheck/src/result.rs b/common/healthcheck/src/result.rs index 9eda0885f5..2dd199ffde 100644 --- a/common/healthcheck/src/result.rs +++ b/common/healthcheck/src/result.rs @@ -1,6 +1,6 @@ use crate::path_check::{PathChecker, PathStatus}; use crate::score::NodeScore; -use crypto::identity::{MixnetIdentityKeyPair, MixnetIdentityPrivateKey, MixnetIdentityPublicKey}; +use crypto::identity::MixnetIdentityKeyPair; use log::{debug, error, info, warn}; use rand_os::rand_core::RngCore; use sphinx::route::NodeAddressBytes; @@ -102,7 +102,7 @@ impl HealthCheckResult { id } - pub async fn calculate( + pub async fn calculate( topology: &T, iterations: usize, resolution_timeout: Duration, @@ -110,9 +110,7 @@ impl HealthCheckResult { ) -> Self where T: NymTopology, - IDPair: MixnetIdentityKeyPair, - Priv: MixnetIdentityPrivateKey, - Pub: MixnetIdentityPublicKey, + IDPair: MixnetIdentityKeyPair, { // currently healthchecker supports only up to 255 iterations - if we somehow // find we need more, it's relatively easy change diff --git a/common/pemstore/src/pemstore.rs b/common/pemstore/src/pemstore.rs index 9c7a914d02..84bc8cf60a 100644 --- a/common/pemstore/src/pemstore.rs +++ b/common/pemstore/src/pemstore.rs @@ -1,4 +1,6 @@ use crate::pathfinder::PathFinder; +use crypto::identity::{MixnetIdentityKeyPair, MixnetIdentityPrivateKey, MixnetIdentityPublicKey}; +use crypto::PemStorable; use pem::{encode, parse, Pem}; use std::fs::File; use std::io; @@ -25,12 +27,7 @@ impl PemStore { } } - pub fn read_identity(&self) -> io::Result - where - IDPair: crypto::identity::MixnetIdentityKeyPair, - Priv: crypto::identity::MixnetIdentityPrivateKey, - Pub: crypto::identity::MixnetIdentityPublicKey, - { + pub fn read_identity(&self) -> io::Result { let private_pem = self.read_pem_file(self.private_mix_key.clone())?; let public_pem = self.read_pem_file(self.public_mix_key.clone())?; @@ -62,12 +59,10 @@ impl PemStore { // This should be refactored and made more generic for when we have other kinds of // KeyPairs that we want to persist (e.g. validator keypairs, or keys for // signing vs encryption). However, for the moment, it does the job. - pub fn write_identity(&self, key_pair: IDPair) -> io::Result<()> - where - IDPair: crypto::identity::MixnetIdentityKeyPair, - Priv: crypto::identity::MixnetIdentityPrivateKey, - Pub: crypto::identity::MixnetIdentityPublicKey, - { + pub fn write_identity( + &self, + key_pair: IDPair, + ) -> io::Result<()> { std::fs::create_dir_all(self.config_dir.clone())?; let private_key = key_pair.private_key(); diff --git a/nym-client/src/client/mod.rs b/nym-client/src/client/mod.rs index 4d4e0da408..8bb090b95f 100644 --- a/nym-client/src/client/mod.rs +++ b/nym-client/src/client/mod.rs @@ -3,14 +3,13 @@ use crate::client::received_buffer::ReceivedMessagesBuffer; use crate::client::topology_control::TopologyInnerRef; use crate::sockets::tcp; use crate::sockets::ws; -use crypto::identity::{MixnetIdentityKeyPair, MixnetIdentityPrivateKey, MixnetIdentityPublicKey}; +use crypto::identity::{MixnetIdentityKeyPair, MixnetIdentityPublicKey}; use directory_client::presence::Topology; use futures::channel::mpsc; use futures::join; use log::*; use sfw_provider_requests::AuthToken; use sphinx::route::Destination; -use std::marker::PhantomData; use std::net::SocketAddr; use tokio::runtime::Runtime; use topology::NymTopology; @@ -37,11 +36,9 @@ pub enum SocketType { None, } -pub struct NymClient +pub struct NymClient where - IDPair: MixnetIdentityKeyPair + Send + Sync, - Priv: MixnetIdentityPrivateKey + Send + Sync, - Pub: MixnetIdentityPublicKey + Send + Sync, + IDPair: MixnetIdentityKeyPair + Send + Sync, { keypair: IDPair, @@ -53,19 +50,14 @@ where directory: String, auth_token: Option, socket_type: SocketType, - - _phantom_private: PhantomData, - _phantom_public: PhantomData, } #[derive(Debug)] pub struct InputMessage(pub Destination, pub Vec); -impl NymClient +impl NymClient where - IDPair: MixnetIdentityKeyPair + Send + Sync, - Priv: MixnetIdentityPrivateKey + Send + Sync, - Pub: MixnetIdentityPublicKey + Send + Sync, + IDPair: 'static + MixnetIdentityKeyPair + Send + Sync, { pub fn new( keypair: IDPair, @@ -84,8 +76,6 @@ where directory, auth_token, socket_type, - _phantom_private: PhantomData, - _phantom_public: PhantomData, } } @@ -129,7 +119,7 @@ where // TODO: when we switch to our graph topology, we need to remember to change 'Topology' type let topology_controller = - rt.block_on(topology_control::TopologyControl::::new( + rt.block_on(topology_control::TopologyControl::::new( self.directory.clone(), TOPOLOGY_REFRESH_RATE, healthcheck_keys, diff --git a/nym-client/src/client/topology_control.rs b/nym-client/src/client/topology_control.rs index 9833f81166..5ec9422782 100644 --- a/nym-client/src/client/topology_control.rs +++ b/nym-client/src/client/topology_control.rs @@ -1,5 +1,5 @@ use crate::built_info; -use crypto::identity::{MixnetIdentityKeyPair, MixnetIdentityPrivateKey, MixnetIdentityPublicKey}; +use crypto::identity::MixnetIdentityKeyPair; use healthcheck::HealthChecker; use log::{error, info, trace, warn}; use std::sync::Arc; @@ -12,16 +12,14 @@ const NODE_HEALTH_THRESHOLD: f64 = 0.0; // auxiliary type for ease of use pub type TopologyInnerRef = Arc>>; -pub(crate) struct TopologyControl +pub(crate) struct TopologyControl where T: NymTopology, - IDPair: MixnetIdentityKeyPair, - Priv: MixnetIdentityPrivateKey, - Pub: MixnetIdentityPublicKey, + IDPair: MixnetIdentityKeyPair, { directory_server: String, inner: Arc>>, - health_checker: HealthChecker, + health_checker: HealthChecker, refresh_rate: f64, } @@ -31,12 +29,10 @@ enum TopologyError { NoValidPathsError, } -impl TopologyControl +impl TopologyControl where T: NymTopology, - IDPair: MixnetIdentityKeyPair, - Priv: MixnetIdentityPrivateKey, - Pub: MixnetIdentityPublicKey, + IDPair: MixnetIdentityKeyPair, { pub(crate) async fn new( directory_server: String, From 2d99b2b93ac9872ed2425286397a9e6b6c845c39 Mon Sep 17 00:00:00 2001 From: Jedrzej Stuczynski Date: Thu, 30 Jan 2020 10:19:55 +0000 Subject: [PATCH 17/17] Fixed validator compilation error --- validator/src/validator/mod.rs | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/validator/src/validator/mod.rs b/validator/src/validator/mod.rs index 26f031fab5..4cd4891255 100644 --- a/validator/src/validator/mod.rs +++ b/validator/src/validator/mod.rs @@ -1,8 +1,5 @@ use crate::validator::config::Config; -use crypto::identity::{ - DummyMixIdentityKeyPair, DummyMixIdentityPrivateKey, DummyMixIdentityPublicKey, - MixnetIdentityKeyPair, MixnetIdentityPrivateKey, MixnetIdentityPublicKey, -}; +use crypto::identity::{DummyMixIdentityKeyPair, MixnetIdentityKeyPair}; use directory_client::presence::Topology; use healthcheck::HealthChecker; use log::{debug, error, info}; @@ -13,20 +10,15 @@ use topology::NymTopology; pub mod config; // allow for a generic validator -pub struct Validator -where - IDPair: MixnetIdentityKeyPair, - Priv: MixnetIdentityPrivateKey, - Pub: MixnetIdentityPublicKey, -{ +pub struct Validator { config: Config, #[allow(dead_code)] identity_keypair: IDPair, - heath_check: HealthChecker, + heath_check: HealthChecker, } // but for time being, since it's a dummy one, have it use dummy keys -impl Validator { +impl Validator { pub fn new(config: Config) -> Self { debug!("validator new");