From 4f1297e740c97cd9e1f3d05a02c8f49ae90b4a62 Mon Sep 17 00:00:00 2001 From: Mark Sinclair Date: Tue, 30 Sep 2025 19:33:19 +0100 Subject: [PATCH 1/3] ns-api: when `score` is `Offline`, clamp `load` to `Offline` --- .../nym-node-status-api/src/http/models.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/nym-node-status-api/nym-node-status-api/src/http/models.rs b/nym-node-status-api/nym-node-status-api/src/http/models.rs index 74d827aa8a8..884757a0ebb 100644 --- a/nym-node-status-api/nym-node-status-api/src/http/models.rs +++ b/nym-node-status-api/nym-node-status-api/src/http/models.rs @@ -78,6 +78,7 @@ pub struct Location { #[derive(Debug, Clone, Deserialize, Serialize, ToSchema, EnumString)] #[serde(rename_all = "snake_case")] #[strum(serialize_all = "snake_case")] +#[derive(PartialEq)] pub enum ScoreValue { Offline, Low, @@ -293,10 +294,18 @@ impl DVpnGateway { }); tracing::info!("🌈 gateway probe parsed: {:?}", parsed); + let score = calculate_score(&gateway, &parsed); + let mut load = calculate_load(&parsed); + + // clamp the load value to offline, when the score is offline + if score == ScoreValue::Offline { + load = ScoreValue::Offline; + } + let performance_v2 = DVpnGatewayPerformance { last_updated_utc: last_updated_utc.to_string(), - load: calculate_load(&parsed), - score: calculate_score(&gateway, &parsed), + load, + score, // the network monitor's measure is a good proxy for node uptime, it can be improved in the future uptime_percentage_last_24_hours: network_monitor_performance_mixnet_mode, From d6a43a0c23c6ea93da5156594dc96de50cf900fa Mon Sep 17 00:00:00 2001 From: Mark Sinclair Date: Tue, 30 Sep 2025 20:03:11 +0100 Subject: [PATCH 2/3] ns-api: bump version --- Cargo.lock | 2 +- nym-node-status-api/nym-node-status-api/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index bf1fe092e54..7339d676170 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6433,7 +6433,7 @@ dependencies = [ [[package]] name = "nym-node-status-api" -version = "4.0.5" +version = "4.0.6" dependencies = [ "ammonia", "anyhow", diff --git a/nym-node-status-api/nym-node-status-api/Cargo.toml b/nym-node-status-api/nym-node-status-api/Cargo.toml index 5637a214a03..77afe6fc10d 100644 --- a/nym-node-status-api/nym-node-status-api/Cargo.toml +++ b/nym-node-status-api/nym-node-status-api/Cargo.toml @@ -3,7 +3,7 @@ [package] name = "nym-node-status-api" -version = "4.0.5" +version = "4.0.6" authors.workspace = true repository.workspace = true homepage.workspace = true From 86430044b3860a3ee79f7d37b41a009b96124732 Mon Sep 17 00:00:00 2001 From: Mark Sinclair Date: Tue, 30 Sep 2025 20:03:31 +0100 Subject: [PATCH 3/3] ns-api: add mixnet score field to performance_v2 struct --- .../nym-node-status-api/src/http/models.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/nym-node-status-api/nym-node-status-api/src/http/models.rs b/nym-node-status-api/nym-node-status-api/src/http/models.rs index 884757a0ebb..9bcd01e6103 100644 --- a/nym-node-status-api/nym-node-status-api/src/http/models.rs +++ b/nym-node-status-api/nym-node-status-api/src/http/models.rs @@ -90,6 +90,7 @@ pub enum ScoreValue { pub struct DVpnGatewayPerformance { last_updated_utc: String, score: ScoreValue, + mixnet_score: ScoreValue, load: ScoreValue, uptime_percentage_last_24_hours: f32, } @@ -294,6 +295,7 @@ impl DVpnGateway { }); tracing::info!("🌈 gateway probe parsed: {:?}", parsed); + let mixnet_score = calculate_mixnet_score(&gateway); let score = calculate_score(&gateway, &parsed); let mut load = calculate_load(&parsed); @@ -306,6 +308,7 @@ impl DVpnGateway { last_updated_utc: last_updated_utc.to_string(), load, score, + mixnet_score, // the network monitor's measure is a good proxy for node uptime, it can be improved in the future uptime_percentage_last_24_hours: network_monitor_performance_mixnet_mode, @@ -362,6 +365,21 @@ impl DVpnGateway { } } +/// calculates the gateway probe score for mixnet mode +fn calculate_mixnet_score(gateway: &Gateway) -> ScoreValue { + let mixnet_performance = gateway.performance as f64 / 100.0; + + if mixnet_performance > 0.8 { + ScoreValue::High + } else if mixnet_performance > 0.6 { + ScoreValue::Medium + } else if mixnet_performance > 0.1 { + ScoreValue::Low + } else { + ScoreValue::Offline + } +} + /// calculates a visual score for the gateway fn calculate_score(gateway: &Gateway, probe_outcome: &LastProbeResult) -> ScoreValue { let mixnet_performance = gateway.performance as f64 / 100.0;