Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/directory server transition #401

Merged
merged 23 commits into from
Oct 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
10ff704
Initial changes to validator client API
jstuczyn Oct 26, 2020
6823738
Updated models
jstuczyn Oct 26, 2020
4201867
GatewayRegistrationInfo constructor
jstuczyn Oct 26, 2020
7b14f73
Change validator topology to convert into NymTopology without failure
jstuczyn Oct 27, 2020
e79fa4f
Mixnode registering and unregistering presence
jstuczyn Oct 27, 2020
c0403a9
Directory -> Validator renamings + adjustments
jstuczyn Oct 27, 2020
e1b7b92
Updated upgrade command for mixnode
jstuczyn Oct 27, 2020
d27289d
Extracted metrics part of directory client into separate library
jstuczyn Oct 27, 2020
56db7f3
Removed no longer needed traits
jstuczyn Oct 27, 2020
7466053
Integrated new metrics client into mixnode
jstuczyn Oct 27, 2020
fe80cf9
Introduced the same set of changes to the gateway
jstuczyn Oct 27, 2020
1ce1573
Getting active topology in client core via validator client
jstuczyn Oct 28, 2020
9385ab5
Updated clients to get correct topology
jstuczyn Oct 28, 2020
901e2c4
Introduced mix mining endpoints to validator client
jstuczyn Oct 28, 2020
0e6952a
Network monitor using validator client
jstuczyn Oct 28, 2020
7a6e470
Removed directory client
jstuczyn Oct 28, 2020
673933d
Updated wasm client
jstuczyn Oct 28, 2020
3b5358a
Temporarily disabled the test
jstuczyn Oct 28, 2020
cf8494b
Checking ok status for validator client response
jstuczyn Oct 28, 2020
7f70a96
Updated upgrade command for clients
jstuczyn Oct 28, 2020
3c0e35b
Allowing using old presence directory as new validator endpoint for m…
jstuczyn Oct 28, 2020
dcbf842
Merge branch 'develop' into feature/directory-server-transition
jstuczyn Oct 28, 2020
dc3a449
Fixed tests in non-default crates
jstuczyn Oct 28, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 24 additions & 30 deletions Cargo.lock

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

3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@ members = [
"clients/socks5",
"clients/webassembly",
"clients/client-core",
"common/client-libs/directory-client",
"common/client-libs/directory-client/models",
"common/client-libs/gateway-client",
"common/client-libs/metrics-client",
"common/client-libs/mixnet-client",
"common/client-libs/validator-client",
"common/config",
Expand Down
2 changes: 1 addition & 1 deletion clients/client-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ tokio = { version = "0.2", features = ["full"] }
# internal
config = { path = "../../common/config" }
crypto = { path = "../../common/crypto" }
directory-client = { path = "../../common/client-libs/directory-client" }
gateway-client = { path = "../../common/client-libs/gateway-client" }
gateway-requests = { path = "../../gateway/gateway-requests" }
nonexhaustive-delayqueue = { path = "../../common/nonexhaustive-delayqueue" }
nymsphinx = { path = "../../common/nymsphinx" }
pemstore = { path = "../../common/pemstore" }
topology = { path = "../../common/topology" }
validator-client = { path = "../../common/client-libs/validator-client" }

[dev-dependencies]
tempfile = "3.1.0"
16 changes: 7 additions & 9 deletions clients/client-core/src/client/topology_control.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.

use directory_client::DirectoryClient;
use log::*;
use nymsphinx::addressing::clients::Recipient;
use nymsphinx::params::DEFAULT_NUM_MIX_HOPS;
use std::convert::TryInto;
use std::ops::Deref;
use std::sync::Arc;
use std::time;
Expand Down Expand Up @@ -146,7 +144,7 @@ impl TopologyRefresherConfig {
}

pub struct TopologyRefresher {
directory_client: directory_client::Client,
validator_client: validator_client::Client,
topology_accessor: TopologyAccessor,
refresh_rate: Duration,
}
Expand All @@ -156,24 +154,24 @@ impl TopologyRefresher {
cfg: TopologyRefresherConfig,
topology_accessor: TopologyAccessor,
) -> Self {
let directory_client_config = directory_client::Config::new(cfg.directory_server);
let directory_client = directory_client::Client::new(directory_client_config);
let validator_client_config = validator_client::Config::new(cfg.directory_server);
let validator_client = validator_client::Client::new(validator_client_config);

TopologyRefresher {
directory_client,
validator_client,
topology_accessor,
refresh_rate: cfg.refresh_rate,
}
}

async fn get_current_compatible_topology(&self) -> Option<NymTopology> {
match self.directory_client.get_topology().await {
match self.validator_client.get_active_topology().await {
Err(err) => {
error!("failed to get network topology! - {:?}", err);
error!("failed to get active network topology! - {:?}", err);
None
}
Ok(topology) => {
let nym_topology: NymTopology = topology.try_into().ok()?;
let nym_topology: NymTopology = topology.into();
Some(nym_topology.filter_system_version(env!("CARGO_PKG_VERSION")))
}
}
Expand Down
20 changes: 11 additions & 9 deletions clients/client-core/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ pub mod persistence;
pub const MISSING_VALUE: &str = "MISSING VALUE";

// 'CLIENT'
const DEFAULT_DIRECTORY_SERVER: &str = "https://directory.nymtech.net";
const DEFAULT_VALIDATOR_REST_ENDPOINT: &str = "https://directory.nymtech.net";

// 'DEBUG'
const DEFAULT_ACK_WAIT_MULTIPLIER: f64 = 1.5;

Expand Down Expand Up @@ -175,8 +176,8 @@ impl<T: NymConfig> Config<T> {
self.client.gateway_listener = gateway_listener.into();
}

pub fn with_custom_directory<S: Into<String>>(&mut self, directory_server: S) {
self.client.directory_server = directory_server.into();
pub fn with_custom_validator<S: Into<String>>(&mut self, validator: S) {
self.client.validator_rest_url = validator.into();
}

pub fn set_high_default_traffic_volume(&mut self) {
Expand Down Expand Up @@ -233,8 +234,8 @@ impl<T: NymConfig> Config<T> {
self.client.ack_key_file.clone()
}

pub fn get_directory_server(&self) -> String {
self.client.directory_server.clone()
pub fn get_validator_rest_endpoint(&self) -> String {
self.client.validator_rest_url.clone()
}

pub fn get_gateway_id(&self) -> String {
Expand Down Expand Up @@ -325,7 +326,6 @@ impl<T: NymConfig> Default for Config<T> {
}

#[derive(Debug, Deserialize, PartialEq, Serialize)]
#[serde(deny_unknown_fields)]
pub struct Client<T> {
/// Version of the client for which this configuration was created.
#[serde(default = "missing_string_value")]
Expand All @@ -334,8 +334,10 @@ pub struct Client<T> {
/// ID specifies the human readable ID of this particular client.
id: String,

/// URL to the directory server.
directory_server: String,
/// URL to the validator server for obtaining network topology.
// before 0.9.0 this was the directory server
#[serde(alias = "directory_server")]
validator_rest_url: String,

/// Special mode of the system such that all messages are sent as soon as they are received
/// and no cover traffic is generated. If set all message delays are set to 0 and overwriting
Expand Down Expand Up @@ -388,7 +390,7 @@ impl<T: NymConfig> Default for Client<T> {
Client {
version: env!("CARGO_PKG_VERSION").to_string(),
id: "".to_string(),
directory_server: DEFAULT_DIRECTORY_SERVER.to_string(),
validator_rest_url: DEFAULT_VALIDATOR_REST_ENDPOINT.to_string(),
vpn_mode: false,
private_identity_key_file: Default::default(),
public_identity_key_file: Default::default(),
Expand Down
2 changes: 1 addition & 1 deletion clients/native/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ tokio-tungstenite = "0.11.0" # websocket
client-core = { path = "../client-core" }
config = { path = "../../common/config" }
crypto = { path = "../../common/crypto" }
directory-client = { path = "../../common/client-libs/directory-client" }
gateway-client = { path = "../../common/client-libs/gateway-client" }
gateway-requests = { path = "../../gateway/gateway-requests" }
nymsphinx = { path = "../../common/nymsphinx" }
pemstore = { path = "../../common/pemstore" }
topology = { path = "../../common/topology" }
websocket-requests = { path = "websocket-requests" }
validator-client = { path = "../../common/client-libs/validator-client" }
version-checker = { path = "../../common/version-checker" }

[dev-dependencies]
Expand Down
4 changes: 2 additions & 2 deletions clients/native/src/client/config/template.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ version = '{{ client.version }}'
# Human readable ID of this particular client.
id = '{{ client.id }}'

# URL to the directory server.
directory_server = '{{ client.directory_server }}'
# URL to the validator server for obtaining network topology.
validator_rest_url = '{{ client.validator_rest_url }}'

# Special mode of the system such that all messages are sent as soon as they are received
# and no cover traffic is generated. If set all message delays are set to 0 and overwriting
Expand Down
4 changes: 2 additions & 2 deletions clients/native/src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ impl NymClient {
// the current global view of topology
fn start_topology_refresher(&mut self, topology_accessor: TopologyAccessor) {
let topology_refresher_config = TopologyRefresherConfig::new(
self.config.get_base().get_directory_server(),
self.config.get_base().get_validator_rest_endpoint(),
self.config.get_base().get_topology_refresh_rate(),
);
let mut topology_refresher =
Expand All @@ -235,7 +235,7 @@ impl NymClient {
// components depending on topology would see a non-empty view
info!(
"Obtaining initial network topology from {}",
self.config.get_base().get_directory_server()
self.config.get_base().get_validator_rest_endpoint()
);
self.runtime.block_on(topology_refresher.refresh());

Expand Down
Loading