Skip to content

Commit 1258474

Browse files
authored
Feature/directory server transition (#401)
* Initial changes to validator client API * Updated models * GatewayRegistrationInfo constructor * Change validator topology to convert into NymTopology without failure * Mixnode registering and unregistering presence * Directory -> Validator renamings + adjustments * Updated upgrade command for mixnode * Extracted metrics part of directory client into separate library * Removed no longer needed traits * Integrated new metrics client into mixnode * Introduced the same set of changes to the gateway * Getting active topology in client core via validator client * Updated clients to get correct topology * Introduced mix mining endpoints to validator client * Network monitor using validator client * Removed directory client * Updated wasm client * Temporarily disabled the test * Checking ok status for validator client response * Updated upgrade command for clients * Allowing using old presence directory as new validator endpoint for mixnodes and gateways * Fixed tests in non-default crates
1 parent e759db4 commit 1258474

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+1698
-1986
lines changed

Cargo.lock

+24-30
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1-2
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,8 @@ members = [
1313
"clients/socks5",
1414
"clients/webassembly",
1515
"clients/client-core",
16-
"common/client-libs/directory-client",
17-
"common/client-libs/directory-client/models",
1816
"common/client-libs/gateway-client",
17+
"common/client-libs/metrics-client",
1918
"common/client-libs/mixnet-client",
2019
"common/client-libs/validator-client",
2120
"common/config",

clients/client-core/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ tokio = { version = "0.2", features = ["full"] }
1919
# internal
2020
config = { path = "../../common/config" }
2121
crypto = { path = "../../common/crypto" }
22-
directory-client = { path = "../../common/client-libs/directory-client" }
2322
gateway-client = { path = "../../common/client-libs/gateway-client" }
2423
gateway-requests = { path = "../../gateway/gateway-requests" }
2524
nonexhaustive-delayqueue = { path = "../../common/nonexhaustive-delayqueue" }
2625
nymsphinx = { path = "../../common/nymsphinx" }
2726
pemstore = { path = "../../common/pemstore" }
2827
topology = { path = "../../common/topology" }
28+
validator-client = { path = "../../common/client-libs/validator-client" }
2929

3030
[dev-dependencies]
3131
tempfile = "3.1.0"

clients/client-core/src/client/topology_control.rs

+7-9
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,9 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
use directory_client::DirectoryClient;
1615
use log::*;
1716
use nymsphinx::addressing::clients::Recipient;
1817
use nymsphinx::params::DEFAULT_NUM_MIX_HOPS;
19-
use std::convert::TryInto;
2018
use std::ops::Deref;
2119
use std::sync::Arc;
2220
use std::time;
@@ -146,7 +144,7 @@ impl TopologyRefresherConfig {
146144
}
147145

148146
pub struct TopologyRefresher {
149-
directory_client: directory_client::Client,
147+
validator_client: validator_client::Client,
150148
topology_accessor: TopologyAccessor,
151149
refresh_rate: Duration,
152150
}
@@ -156,24 +154,24 @@ impl TopologyRefresher {
156154
cfg: TopologyRefresherConfig,
157155
topology_accessor: TopologyAccessor,
158156
) -> Self {
159-
let directory_client_config = directory_client::Config::new(cfg.directory_server);
160-
let directory_client = directory_client::Client::new(directory_client_config);
157+
let validator_client_config = validator_client::Config::new(cfg.directory_server);
158+
let validator_client = validator_client::Client::new(validator_client_config);
161159

162160
TopologyRefresher {
163-
directory_client,
161+
validator_client,
164162
topology_accessor,
165163
refresh_rate: cfg.refresh_rate,
166164
}
167165
}
168166

169167
async fn get_current_compatible_topology(&self) -> Option<NymTopology> {
170-
match self.directory_client.get_topology().await {
168+
match self.validator_client.get_active_topology().await {
171169
Err(err) => {
172-
error!("failed to get network topology! - {:?}", err);
170+
error!("failed to get active network topology! - {:?}", err);
173171
None
174172
}
175173
Ok(topology) => {
176-
let nym_topology: NymTopology = topology.try_into().ok()?;
174+
let nym_topology: NymTopology = topology.into();
177175
Some(nym_topology.filter_system_version(env!("CARGO_PKG_VERSION")))
178176
}
179177
}

clients/client-core/src/config/mod.rs

+11-9
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ pub mod persistence;
2626
pub const MISSING_VALUE: &str = "MISSING VALUE";
2727

2828
// 'CLIENT'
29-
const DEFAULT_DIRECTORY_SERVER: &str = "https://directory.nymtech.net";
29+
const DEFAULT_VALIDATOR_REST_ENDPOINT: &str = "https://directory.nymtech.net";
30+
3031
// 'DEBUG'
3132
const DEFAULT_ACK_WAIT_MULTIPLIER: f64 = 1.5;
3233

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

178-
pub fn with_custom_directory<S: Into<String>>(&mut self, directory_server: S) {
179-
self.client.directory_server = directory_server.into();
179+
pub fn with_custom_validator<S: Into<String>>(&mut self, validator: S) {
180+
self.client.validator_rest_url = validator.into();
180181
}
181182

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

236-
pub fn get_directory_server(&self) -> String {
237-
self.client.directory_server.clone()
237+
pub fn get_validator_rest_endpoint(&self) -> String {
238+
self.client.validator_rest_url.clone()
238239
}
239240

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

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

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

340342
/// Special mode of the system such that all messages are sent as soon as they are received
341343
/// and no cover traffic is generated. If set all message delays are set to 0 and overwriting
@@ -388,7 +390,7 @@ impl<T: NymConfig> Default for Client<T> {
388390
Client {
389391
version: env!("CARGO_PKG_VERSION").to_string(),
390392
id: "".to_string(),
391-
directory_server: DEFAULT_DIRECTORY_SERVER.to_string(),
393+
validator_rest_url: DEFAULT_VALIDATOR_REST_ENDPOINT.to_string(),
392394
vpn_mode: false,
393395
private_identity_key_file: Default::default(),
394396
public_identity_key_file: Default::default(),

clients/native/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@ tokio-tungstenite = "0.11.0" # websocket
3333
client-core = { path = "../client-core" }
3434
config = { path = "../../common/config" }
3535
crypto = { path = "../../common/crypto" }
36-
directory-client = { path = "../../common/client-libs/directory-client" }
3736
gateway-client = { path = "../../common/client-libs/gateway-client" }
3837
gateway-requests = { path = "../../gateway/gateway-requests" }
3938
nymsphinx = { path = "../../common/nymsphinx" }
4039
pemstore = { path = "../../common/pemstore" }
4140
topology = { path = "../../common/topology" }
4241
websocket-requests = { path = "websocket-requests" }
42+
validator-client = { path = "../../common/client-libs/validator-client" }
4343
version-checker = { path = "../../common/version-checker" }
4444

4545
[dev-dependencies]

clients/native/src/client/config/template.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ version = '{{ client.version }}'
3030
# Human readable ID of this particular client.
3131
id = '{{ client.id }}'
3232
33-
# URL to the directory server.
34-
directory_server = '{{ client.directory_server }}'
33+
# URL to the validator server for obtaining network topology.
34+
validator_rest_url = '{{ client.validator_rest_url }}'
3535
3636
# Special mode of the system such that all messages are sent as soon as they are received
3737
# and no cover traffic is generated. If set all message delays are set to 0 and overwriting

clients/native/src/client/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ impl NymClient {
226226
// the current global view of topology
227227
fn start_topology_refresher(&mut self, topology_accessor: TopologyAccessor) {
228228
let topology_refresher_config = TopologyRefresherConfig::new(
229-
self.config.get_base().get_directory_server(),
229+
self.config.get_base().get_validator_rest_endpoint(),
230230
self.config.get_base().get_topology_refresh_rate(),
231231
);
232232
let mut topology_refresher =
@@ -235,7 +235,7 @@ impl NymClient {
235235
// components depending on topology would see a non-empty view
236236
info!(
237237
"Obtaining initial network topology from {}",
238-
self.config.get_base().get_directory_server()
238+
self.config.get_base().get_validator_rest_endpoint()
239239
);
240240
self.runtime.block_on(topology_refresher.refresh());
241241

0 commit comments

Comments
 (0)