moved nym-gateway-probe to monorepo and updated rust-edition to 2024 (#6094)
dont build netstack in CI additional rust 2024 fixes fixes removed temp.rs first round of cleanup removed duplicated NS types moved gateway probe to the monorepo
This commit is contained in:
@@ -18,7 +18,10 @@ impl Display for BondingInformation {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
writeln!(f, "Identity Key: {}", self.identity_key)?;
|
||||
writeln!(f, "Host: {}", self.host)?;
|
||||
writeln!(f, "Custom HTTP Port: you might want to set it if your node won't be accessible on any of the ports: 80/443/8080")?;
|
||||
writeln!(
|
||||
f,
|
||||
"Custom HTTP Port: you might want to set it if your node won't be accessible on any of the ports: 80/443/8080"
|
||||
)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -7,11 +7,11 @@ use crate::node::key_rotation::key::{SphinxPrivateKey, SphinxPublicKey};
|
||||
use crate::node::nym_apis_client::NymApisClient;
|
||||
use nym_crypto::asymmetric::{ed25519, x25519};
|
||||
use nym_node_requests::api::v1::node::models::NodeDescription;
|
||||
use nym_pemstore::traits::{PemStorableKey, PemStorableKeyPair};
|
||||
use nym_pemstore::KeyPairPath;
|
||||
use nym_pemstore::traits::{PemStorableKey, PemStorableKeyPair};
|
||||
use nym_task::ShutdownToken;
|
||||
use nym_validator_client::nyxd::contract_traits::MixnetQueryClient;
|
||||
use nym_validator_client::QueryHttpRpcNyxdClient;
|
||||
use nym_validator_client::nyxd::contract_traits::MixnetQueryClient;
|
||||
use serde::Serialize;
|
||||
use std::fmt::{Display, Formatter};
|
||||
use std::path::Path;
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
// Copyright 2023 - Nym Technologies SA <contact@nymtech.net>
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
use axum::extract::connect_info::IntoMakeServiceWithConnectInfo;
|
||||
use axum::Router;
|
||||
use axum::extract::ConnectInfo;
|
||||
use axum::extract::connect_info::IntoMakeServiceWithConnectInfo;
|
||||
use axum::middleware::AddExtension;
|
||||
use axum::serve::Serve;
|
||||
use axum::Router;
|
||||
use std::net::SocketAddr;
|
||||
|
||||
pub use router::{api, HttpServerConfig, NymNodeRouter};
|
||||
pub use router::{HttpServerConfig, NymNodeRouter, api};
|
||||
|
||||
pub mod error;
|
||||
pub mod helpers;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
// Copyright 2024 - Nym Technologies SA <contact@nymtech.net>
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
use axum::routing::get;
|
||||
use axum::Router;
|
||||
use axum::routing::get;
|
||||
use nym_node_requests::api::v1::authenticator::models;
|
||||
|
||||
pub mod root;
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
// Copyright 2023 - Nym Technologies SA <contact@nymtech.net>
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
use axum::Router;
|
||||
use axum::extract::Query;
|
||||
use axum::http::StatusCode;
|
||||
use axum::routing::get;
|
||||
use axum::Router;
|
||||
use nym_http_api_common::{FormattedResponse, OutputParams};
|
||||
use nym_node_requests::api::v1::gateway::models::{ClientInterfaces, WebSockets, Wireguard};
|
||||
use nym_node_requests::routes::api::v1::gateway::client_interfaces;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
// Copyright 2023 - Nym Technologies SA <contact@nymtech.net>
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
use axum::routing::get;
|
||||
use axum::Router;
|
||||
use axum::routing::get;
|
||||
use nym_node_requests::api::v1::gateway::models;
|
||||
use nym_node_requests::routes::api::v1::gateway;
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
// Copyright 2023 - Nym Technologies SA <contact@nymtech.net>
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
use axum::routing::get;
|
||||
use axum::Router;
|
||||
use axum::routing::get;
|
||||
use nym_node_requests::api::v1::ip_packet_router::models;
|
||||
|
||||
pub mod root;
|
||||
|
||||
@@ -7,9 +7,9 @@ use crate::node::http::api::v1::metrics::sessions::sessions_stats;
|
||||
use crate::node::http::api::v1::metrics::verloc::verloc_stats;
|
||||
use crate::node::http::api::v1::metrics::wireguard::wireguard_stats;
|
||||
use crate::node::http::state::metrics::MetricsAppState;
|
||||
use axum::Router;
|
||||
use axum::extract::FromRef;
|
||||
use axum::routing::get;
|
||||
use axum::Router;
|
||||
use nym_http_api_common::middleware::bearer_auth::AuthLayer;
|
||||
use nym_node_requests::routes::api::v1::metrics;
|
||||
use nym_node_requests::routes::api::v1::metrics::prometheus_absolute;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
// Copyright 2023 - Nym Technologies SA <contact@nymtech.net>
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
use axum::routing::get;
|
||||
use axum::Router;
|
||||
use axum::routing::get;
|
||||
use nym_node_requests::api::v1::mixnode::models;
|
||||
|
||||
pub mod root;
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
use crate::node::http::state::AppState;
|
||||
use axum::routing::get;
|
||||
use axum::Router;
|
||||
use axum::routing::get;
|
||||
use nym_node_requests::routes::api::v1;
|
||||
|
||||
pub mod authenticator;
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
use crate::node::http::api::v1::network_requester::exit_policy::node_exit_policy;
|
||||
use axum::routing::get;
|
||||
use axum::Router;
|
||||
use axum::routing::get;
|
||||
use nym_node_requests::api::v1::network_requester::exit_policy::models::UsedExitPolicy;
|
||||
use nym_node_requests::api::v1::network_requester::models;
|
||||
use nym_node_requests::routes::api::v1::network_requester;
|
||||
|
||||
@@ -5,7 +5,7 @@ use crate::node::http::api::api_requests;
|
||||
use crate::node::http::state::AppState;
|
||||
use axum::extract::{Query, State};
|
||||
use nym_http_api_common::{FormattedResponse, OutputParams};
|
||||
use nym_node_requests::api::{v1::node::models::SignedHostInformation, SignedDataHostInfo};
|
||||
use nym_node_requests::api::{SignedDataHostInfo, v1::node::models::SignedHostInformation};
|
||||
|
||||
/// Returns host information of this node.
|
||||
#[utoipa::path(
|
||||
|
||||
@@ -8,8 +8,8 @@ use crate::node::http::api::v1::node::hardware::host_system;
|
||||
use crate::node::http::api::v1::node::host_information::host_information;
|
||||
use crate::node::http::api::v1::node::roles::roles;
|
||||
use crate::node::http::state::AppState;
|
||||
use axum::routing::get;
|
||||
use axum::Router;
|
||||
use axum::routing::get;
|
||||
use nym_node_requests::api::v1::node::models;
|
||||
use nym_node_requests::routes::api::v1;
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ use axum::Router;
|
||||
use nym_node_requests::api as api_requests;
|
||||
use nym_node_requests::routes::api::{v1, v1_absolute};
|
||||
use utoipa::openapi::security::{Http, HttpAuthScheme};
|
||||
use utoipa::{openapi::security::SecurityScheme, Modify, OpenApi};
|
||||
use utoipa::{Modify, OpenApi, openapi::security::SecurityScheme};
|
||||
use utoipa_swagger_ui::SwaggerUi;
|
||||
|
||||
#[derive(OpenApi)]
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
// Copyright 2023 - Nym Technologies SA <contact@nymtech.net>
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
use axum::Router;
|
||||
use axum::response::Html;
|
||||
use axum::routing::get;
|
||||
use axum::Router;
|
||||
use std::path::PathBuf;
|
||||
use tower_http::services::ServeDir;
|
||||
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
// Copyright 2023 - Nym Technologies SA <contact@nymtech.net>
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
use crate::node::http::NymNodeHttpServer;
|
||||
use crate::node::http::error::NymNodeHttpError;
|
||||
use crate::node::http::state::AppState;
|
||||
use crate::node::http::NymNodeHttpServer;
|
||||
use axum::Router;
|
||||
use axum::response::Redirect;
|
||||
use axum::routing::get;
|
||||
use axum::Router;
|
||||
use nym_bin_common::bin_info_owned;
|
||||
use nym_http_api_common::middleware::logging;
|
||||
use nym_node_requests::api::v1::authenticator::models::Authenticator;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
// Copyright 2023 - Nym Technologies SA <contact@nymtech.net>
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
use axum::Json;
|
||||
use axum::http::StatusCode;
|
||||
use axum::response::{IntoResponse, Response};
|
||||
use axum::Json;
|
||||
pub use nym_node_requests::api::ErrorResponse;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
|
||||
use arc_swap::ArcSwap;
|
||||
use nym_node_requests::api::v1::node_load::models::{Load, NodeLoad};
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
use std::sync::Arc;
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
use std::time::Duration;
|
||||
use sysinfo::{CpuRefreshKind, MemoryRefreshKind, Networks, System};
|
||||
use time::OffsetDateTime;
|
||||
|
||||
@@ -92,7 +92,9 @@ impl ActiveSphinxKeys {
|
||||
// and the current primary as the secondary (for the overlap epoch)
|
||||
pub(crate) fn rotate(&self, expected_new_rotation: u32) -> bool {
|
||||
let Some(pre_announced) = self.inner.secondary_key.load_full() else {
|
||||
error!("sphinx key inconsistency - attempted to perform key rotation without having pre-announced new key");
|
||||
error!(
|
||||
"sphinx key inconsistency - attempted to perform key rotation without having pre-announced new key"
|
||||
);
|
||||
return false;
|
||||
};
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ use nym_task::ShutdownToken;
|
||||
use nym_validator_client::models::{KeyRotationDetails, KeyRotationInfoResponse, KeyRotationState};
|
||||
use std::time::Duration;
|
||||
use time::OffsetDateTime;
|
||||
use tokio::time::{interval, sleep, Instant};
|
||||
use tokio::time::{Instant, interval, sleep};
|
||||
use tracing::{debug, error, info, trace, warn};
|
||||
|
||||
pub(crate) struct RotationConfig {
|
||||
@@ -154,7 +154,9 @@ impl KeyRotationController {
|
||||
let expected_current_rotation_id = key_rotation_info.expected_current_rotation_id();
|
||||
|
||||
if current_rotation_id != expected_current_rotation_id {
|
||||
warn!("the current rotation is {current_rotation_id} whilst we expected {expected_current_rotation_id}");
|
||||
warn!(
|
||||
"the current rotation is {current_rotation_id} whilst we expected {expected_current_rotation_id}"
|
||||
);
|
||||
// if we got here, it means epoch is most likely NOT stuck (we're within the threshold)
|
||||
// so probably we prematurely called this method before nym-api(s) got to advancing
|
||||
// the epoch and thus the rotation, so wait a bit instead.
|
||||
@@ -200,7 +202,9 @@ impl KeyRotationController {
|
||||
// pre-announce new key for the following rotation
|
||||
|
||||
if primary_key_rotation_id != current_rotation_id {
|
||||
warn!("current primary key does not correspond to the current rotation - immediately pre-announcing new key (rotates next epoch: {rotates_next_epoch}");
|
||||
warn!(
|
||||
"current primary key does not correspond to the current rotation - immediately pre-announcing new key (rotates next epoch: {rotates_next_epoch}"
|
||||
);
|
||||
// we don't have a secondary key and our current key is already outdated -
|
||||
// preannounce a key for either this or the next rotation
|
||||
// (and next time this method is called, it will be promoted to primary)
|
||||
@@ -267,7 +271,9 @@ impl KeyRotationController {
|
||||
|
||||
async fn try_get_key_rotation_info(&self) -> Option<KeyRotationDetails> {
|
||||
let Ok(rotation_info) = self.client.get_key_rotation_info().await else {
|
||||
warn!("failed to retrieve key rotation information from ANY nym-api - we might miss configuration changes");
|
||||
warn!(
|
||||
"failed to retrieve key rotation information from ANY nym-api - we might miss configuration changes"
|
||||
);
|
||||
return None;
|
||||
};
|
||||
|
||||
|
||||
@@ -154,21 +154,25 @@ impl SphinxKeyManager {
|
||||
let secondary_id = secondary.as_ref().map(|k| k.rotation_id());
|
||||
|
||||
// 1. check for failed (or missed) rotation, i.e. secondary > primary AND current_rotation > primary
|
||||
if let Some(secondary_id) = secondary_id {
|
||||
if secondary_id > primary_id && current_rotation_id > primary_id {
|
||||
Self::swap_key_files(primary_key_path.as_ref(), secondary_key_path.as_ref())?;
|
||||
// SAFETY: we just checked secondary exists
|
||||
#[allow(clippy::unwrap_used)]
|
||||
let tmp = secondary.take().unwrap();
|
||||
secondary = Some(primary);
|
||||
primary = tmp;
|
||||
}
|
||||
if let Some(secondary_id) = secondary_id
|
||||
&& secondary_id > primary_id
|
||||
&& current_rotation_id > primary_id
|
||||
{
|
||||
Self::swap_key_files(primary_key_path.as_ref(), secondary_key_path.as_ref())?;
|
||||
// SAFETY: we just checked secondary exists
|
||||
#[allow(clippy::unwrap_used)]
|
||||
let tmp = secondary.take().unwrap();
|
||||
secondary = Some(primary);
|
||||
primary = tmp;
|
||||
}
|
||||
|
||||
// if upon loading it turns out that the node has been inactive for a long time,
|
||||
// immediately rotate keys (but leave 1h grace period for current primary, i.e. set it as secondary)
|
||||
if primary.rotation_id() != current_rotation_id {
|
||||
warn!("this node has been inactive for more than a key rotation duration. the current primary key was generated for rotation {} while the current rotation is {current_rotation_id}. new key will be generated now.", primary.rotation_id());
|
||||
warn!(
|
||||
"this node has been inactive for more than a key rotation duration. the current primary key was generated for rotation {} while the current rotation is {current_rotation_id}. new key will be generated now.",
|
||||
primary.rotation_id()
|
||||
);
|
||||
let this = SphinxKeyManager {
|
||||
keys: ActiveSphinxKeys::new_loaded(primary, None),
|
||||
primary_key_path: primary_key_path.as_ref().to_path_buf(),
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
use crate::node::metrics::handler::{HandlerWrapper, MetricsHandler, RegistrableHandler};
|
||||
use futures::StreamExt;
|
||||
use nym_node_metrics::events::{
|
||||
events_channels, MetricEventsReceiver, MetricEventsSender, MetricsEvent,
|
||||
MetricEventsReceiver, MetricEventsSender, MetricsEvent, events_channels,
|
||||
};
|
||||
use nym_task::ShutdownToken;
|
||||
use std::any;
|
||||
@@ -12,7 +12,7 @@ use std::any::TypeId;
|
||||
use std::collections::HashMap;
|
||||
use std::ops::DerefMut;
|
||||
use std::time::Duration;
|
||||
use tokio::time::{interval_at, Instant};
|
||||
use tokio::time::{Instant, interval_at};
|
||||
use tracing::{debug, error, trace, warn};
|
||||
|
||||
pub(crate) struct MetricsAggregator {
|
||||
|
||||
@@ -7,7 +7,7 @@ use human_repr::HumanThroughput;
|
||||
use nym_node_metrics::NymNodeMetrics;
|
||||
use std::time::Duration;
|
||||
use time::OffsetDateTime;
|
||||
use tokio::time::{interval_at, Instant};
|
||||
use tokio::time::{Instant, interval_at};
|
||||
use tokio_stream::wrappers::IntervalStream;
|
||||
use tracing::{error, info, trace};
|
||||
|
||||
@@ -84,7 +84,8 @@ impl ConsoleLogger {
|
||||
let wg_tx_rate = (wg_tx - self.at_last_update.wg_tx) as f64 / delta_secs;
|
||||
let wg_rx_rate = (wg_rx - self.at_last_update.wg_rx) as f64 / delta_secs;
|
||||
|
||||
info!("↑↓ Packets sent [total] / sent [acks] / received [mix] / received [gw]: {} ({}) / {} ({}) / {} ({}) / {} ({})",
|
||||
info!(
|
||||
"↑↓ Packets sent [total] / sent [acks] / received [mix] / received [gw]: {} ({}) / {} ({}) / {} ({}) / {} ({})",
|
||||
forward_sent.human_count_bare(),
|
||||
forward_sent_rate.human_throughput_bare(),
|
||||
acks.human_count_bare(),
|
||||
|
||||
@@ -7,11 +7,11 @@ use crate::node::metrics::handler::{
|
||||
use async_trait::async_trait;
|
||||
use nym_gateway::node::PersistentStatsStorage;
|
||||
use nym_gateway_stats_storage::error::StatsStorageError;
|
||||
use nym_node_metrics::NymNodeMetrics;
|
||||
use nym_node_metrics::entry::{ActiveSession, ClientSessions, FinishedSession};
|
||||
use nym_node_metrics::events::GatewaySessionEvent;
|
||||
use nym_node_metrics::prometheus_wrapper::PrometheusMetric::EntryClientSessionsDurations;
|
||||
use nym_node_metrics::prometheus_wrapper::PROMETHEUS_METRICS;
|
||||
use nym_node_metrics::NymNodeMetrics;
|
||||
use nym_node_metrics::prometheus_wrapper::PrometheusMetric::EntryClientSessionsDurations;
|
||||
use nym_sphinx_types::DestinationAddressBytes;
|
||||
use nym_statistics_common::types::SessionType;
|
||||
use time::{Date, Duration, OffsetDateTime};
|
||||
@@ -51,21 +51,21 @@ impl GatewaySessionStatsHandler {
|
||||
client: DestinationAddressBytes,
|
||||
) -> Result<(), StatsStorageError> {
|
||||
if let Some(session) = self.storage.get_active_session(client).await? {
|
||||
if session.remember {
|
||||
if let Some(finished_session) = session.end_at(stop_time) {
|
||||
PROMETHEUS_METRICS.observe_histogram(
|
||||
EntryClientSessionsDurations {
|
||||
typ: finished_session.typ.to_string(),
|
||||
},
|
||||
finished_session.duration.as_secs_f64(),
|
||||
);
|
||||
self.storage
|
||||
.insert_unique_user(self.current_day, client.as_base58_string())
|
||||
.await?;
|
||||
self.storage
|
||||
.insert_finished_session(self.current_day, finished_session)
|
||||
.await?;
|
||||
}
|
||||
if session.remember
|
||||
&& let Some(finished_session) = session.end_at(stop_time)
|
||||
{
|
||||
PROMETHEUS_METRICS.observe_histogram(
|
||||
EntryClientSessionsDurations {
|
||||
typ: finished_session.typ.to_string(),
|
||||
},
|
||||
finished_session.duration.as_secs_f64(),
|
||||
);
|
||||
self.storage
|
||||
.insert_unique_user(self.current_day, client.as_base58_string())
|
||||
.await?;
|
||||
self.storage
|
||||
.insert_finished_session(self.current_day, finished_session)
|
||||
.await?;
|
||||
}
|
||||
self.storage.delete_active_session(client).await?;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
// Copyright 2024 - Nym Technologies SA <contact@nymtech.net>
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
use nym_node_metrics::NymNodeMetrics;
|
||||
use nym_node_metrics::mixnet::{EgressMixingStats, IngressMixingStats, MixingStats};
|
||||
use nym_node_metrics::wireguard::WireguardStats;
|
||||
use nym_node_metrics::NymNodeMetrics;
|
||||
use time::OffsetDateTime;
|
||||
|
||||
// used to calculate traffic rates
|
||||
|
||||
@@ -6,10 +6,10 @@ use crate::node::metrics::handler::{
|
||||
MetricsHandler, OnStartMetricsHandler, OnUpdateMetricsHandler,
|
||||
};
|
||||
use async_trait::async_trait;
|
||||
use nym_node_metrics::prometheus_wrapper::{
|
||||
NymNodePrometheusMetrics, PrometheusMetric, PROMETHEUS_METRICS,
|
||||
};
|
||||
use nym_node_metrics::NymNodeMetrics;
|
||||
use nym_node_metrics::prometheus_wrapper::{
|
||||
NymNodePrometheusMetrics, PROMETHEUS_METRICS, PrometheusMetric,
|
||||
};
|
||||
|
||||
mod at_last_update;
|
||||
|
||||
@@ -233,6 +233,8 @@ impl MetricsHandler for PrometheusGlobalNodeMetricsRegistryUpdater {
|
||||
// SAFETY: `PrometheusNodeMetricsRegistryUpdater` doesn't have any associated events
|
||||
#[allow(clippy::panic)]
|
||||
async fn handle_event(&mut self, _event: Self::Events) {
|
||||
panic!("this should have never been called! MetricsHandler has been incorrectly called on PrometheusNodeMetricsRegistryUpdater")
|
||||
panic!(
|
||||
"this should have never been called! MetricsHandler has been incorrectly called on PrometheusNodeMetricsRegistryUpdater"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,6 +65,8 @@ impl MetricsHandler for LegacyMixingStatsUpdater {
|
||||
// SAFETY: `LegacyMixingStatsUpdater` doesn't have any associated events
|
||||
#[allow(clippy::panic)]
|
||||
async fn handle_event(&mut self, _event: Self::Events) {
|
||||
panic!("this should have never been called! MetricsHandler has been incorrectly called on LegacyMixingStatsUpdater")
|
||||
panic!(
|
||||
"this should have never been called! MetricsHandler has been incorrectly called on LegacyMixingStatsUpdater"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,8 +5,8 @@ use crate::node::metrics::handler::{
|
||||
MetricsHandler, OnStartMetricsHandler, OnUpdateMetricsHandler,
|
||||
};
|
||||
use async_trait::async_trait;
|
||||
use nym_node_metrics::mixnet::{EgressRecipientStats, IngressRecipientStats};
|
||||
use nym_node_metrics::NymNodeMetrics;
|
||||
use nym_node_metrics::mixnet::{EgressRecipientStats, IngressRecipientStats};
|
||||
use std::collections::HashMap;
|
||||
use std::net::{IpAddr, SocketAddr};
|
||||
|
||||
@@ -43,10 +43,10 @@ impl OnUpdateMetricsHandler for MixnetMetricsCleaner {
|
||||
let mut recipients_to_remove = Vec::new();
|
||||
|
||||
for sender_entry in self.metrics.mixnet.ingress.senders().iter() {
|
||||
if let Some(last_seen) = self.last_seen.ingress_senders.get(sender_entry.key()) {
|
||||
if sender_entry.value() == last_seen {
|
||||
senders_to_remove.push(*sender_entry.key());
|
||||
}
|
||||
if let Some(last_seen) = self.last_seen.ingress_senders.get(sender_entry.key())
|
||||
&& sender_entry.value() == last_seen
|
||||
{
|
||||
senders_to_remove.push(*sender_entry.key());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,10 +55,9 @@ impl OnUpdateMetricsHandler for MixnetMetricsCleaner {
|
||||
.last_seen
|
||||
.egress_forward_recipients
|
||||
.get(recipient_entry.key())
|
||||
&& recipient_entry.value() == last_seen
|
||||
{
|
||||
if recipient_entry.value() == last_seen {
|
||||
recipients_to_remove.push(*recipient_entry.key());
|
||||
}
|
||||
recipients_to_remove.push(*recipient_entry.key());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,6 +103,8 @@ impl MetricsHandler for MixnetMetricsCleaner {
|
||||
// SAFETY: `MixnetMetricsCleaner` doesn't have any associated events
|
||||
#[allow(clippy::panic)]
|
||||
async fn handle_event(&mut self, _event: Self::Events) {
|
||||
panic!("this should have never been called! MetricsHandler has been incorrectly called on MixnetMetricsCleaner")
|
||||
panic!(
|
||||
"this should have never been called! MetricsHandler has been incorrectly called on MixnetMetricsCleaner"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,6 +57,8 @@ impl MetricsHandler for PendingEgressPacketsUpdater {
|
||||
// SAFETY: `PendingEgressPacketsUpdater` doesn't have any associated events
|
||||
#[allow(clippy::panic)]
|
||||
async fn handle_event(&mut self, _event: Self::Events) {
|
||||
panic!("this should have never been called! MetricsHandler has been incorrectly called on PendingEgressPacketsUpdater")
|
||||
panic!(
|
||||
"this should have never been called! MetricsHandler has been incorrectly called on PendingEgressPacketsUpdater"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,8 +9,8 @@ use nym_sphinx_forwarding::packet::MixPacket;
|
||||
use nym_sphinx_framing::codec::NymCodec;
|
||||
use nym_sphinx_framing::packet::FramedNymPacket;
|
||||
use nym_sphinx_framing::processing::{
|
||||
process_framed_packet, MixProcessingResult, MixProcessingResultData, PacketProcessingError,
|
||||
PartiallyUnwrappedPacket, PartialyUnwrappedPacketWithKeyRotation, ProcessedFinalHop,
|
||||
MixProcessingResult, MixProcessingResultData, PacketProcessingError, PartiallyUnwrappedPacket,
|
||||
PartialyUnwrappedPacketWithKeyRotation, ProcessedFinalHop, process_framed_packet,
|
||||
};
|
||||
use nym_sphinx_params::SphinxKeyRotation;
|
||||
use nym_sphinx_types::{Delay, REPLAY_TAG_SIZE};
|
||||
|
||||
@@ -25,7 +25,10 @@ impl Listener {
|
||||
let tcp_listener = match tokio::net::TcpListener::bind(self.bind_address).await {
|
||||
Ok(listener) => listener,
|
||||
Err(err) => {
|
||||
error!("Failed to bind to {}: {err}. Are you sure nothing else is running on the specified port and your user has sufficient permission to bind to the requested address?", self.bind_address);
|
||||
error!(
|
||||
"Failed to bind to {}: {err}. Are you sure nothing else is running on the specified port and your user has sufficient permission to bind to the requested address?",
|
||||
self.bind_address
|
||||
);
|
||||
shutdown.cancel();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -7,4 +7,4 @@ pub(crate) mod packet_forwarding;
|
||||
pub(crate) mod shared;
|
||||
|
||||
pub(crate) use listener::Listener;
|
||||
pub(crate) use shared::{final_hop::SharedFinalHopData, SharedData};
|
||||
pub(crate) use shared::{SharedData, final_hop::SharedFinalHopData};
|
||||
|
||||
@@ -3,10 +3,10 @@
|
||||
|
||||
use crate::node::routing_filter::RoutingFilter;
|
||||
use futures::StreamExt;
|
||||
use nym_mixnet_client::forwarder::{
|
||||
mix_forwarding_channels, MixForwardingReceiver, MixForwardingSender, PacketToForward,
|
||||
};
|
||||
use nym_mixnet_client::SendWithoutResponse;
|
||||
use nym_mixnet_client::forwarder::{
|
||||
MixForwardingReceiver, MixForwardingSender, PacketToForward, mix_forwarding_channels,
|
||||
};
|
||||
use nym_node_metrics::NymNodeMetrics;
|
||||
use nym_nonexhaustive_delayqueue::{Expired, NonExhaustiveDelayQueue};
|
||||
use nym_sphinx_forwarding::packet::MixPacket;
|
||||
|
||||
@@ -3,13 +3,13 @@
|
||||
|
||||
use crate::config::Config;
|
||||
use crate::node::key_rotation::active_keys::ActiveSphinxKeys;
|
||||
use crate::node::mixnet::handler::ConnectionHandler;
|
||||
use crate::node::mixnet::SharedFinalHopData;
|
||||
use crate::node::mixnet::handler::ConnectionHandler;
|
||||
use crate::node::replay_protection::bloomfilter::ReplayProtectionBloomfilters;
|
||||
use nym_gateway::node::GatewayStorageError;
|
||||
use nym_mixnet_client::forwarder::{MixForwardingSender, PacketToForward};
|
||||
use nym_node_metrics::mixnet::PacketKind;
|
||||
use nym_node_metrics::NymNodeMetrics;
|
||||
use nym_node_metrics::mixnet::PacketKind;
|
||||
use nym_noise::config::NoiseConfig;
|
||||
use nym_sphinx_forwarding::packet::MixPacket;
|
||||
use nym_sphinx_framing::processing::{
|
||||
@@ -150,10 +150,10 @@ impl SharedData {
|
||||
.ingress_received_forward_packet(source, packet_version);
|
||||
|
||||
// check if the delay wasn't excessive
|
||||
if let Some(delay) = delay {
|
||||
if delay.to_duration() > self.processing_config.maximum_packet_delay {
|
||||
self.metrics.mixnet.ingress_excessive_delay_packet()
|
||||
}
|
||||
if let Some(delay) = delay
|
||||
&& delay.to_duration() > self.processing_config.maximum_packet_delay
|
||||
{
|
||||
self.metrics.mixnet.ingress_excessive_delay_packet()
|
||||
}
|
||||
}
|
||||
MixProcessingResultData::FinalHop { .. } => {
|
||||
@@ -191,7 +191,9 @@ impl SharedData {
|
||||
.is_err()
|
||||
&& !self.shutdown_token.is_cancelled()
|
||||
{
|
||||
error!("failed to forward sphinx packet on the channel while the process is not going through the shutdown!");
|
||||
error!(
|
||||
"failed to forward sphinx packet on the channel while the process is not going through the shutdown!"
|
||||
);
|
||||
self.shutdown_token.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
+20
-13
@@ -4,14 +4,14 @@
|
||||
use self::helpers::load_x25519_wireguard_keypair;
|
||||
use crate::config::helpers::gateway_tasks_config;
|
||||
use crate::config::{
|
||||
Config, GatewayTasksConfig, NodeModes, ServiceProvidersConfig, Wireguard, DEFAULT_MIXNET_PORT,
|
||||
Config, DEFAULT_MIXNET_PORT, GatewayTasksConfig, NodeModes, ServiceProvidersConfig, Wireguard,
|
||||
};
|
||||
use crate::error::{EntryGatewayError, NymNodeError, ServiceProvidersError};
|
||||
use crate::node::description::{load_node_description, save_node_description};
|
||||
use crate::node::helpers::{
|
||||
get_current_rotation_id, load_ed25519_identity_keypair, load_key, load_x25519_noise_keypair,
|
||||
store_ed25519_identity_keypair, store_key, store_keypair, store_x25519_noise_keypair,
|
||||
DisplayDetails,
|
||||
DisplayDetails, get_current_rotation_id, load_ed25519_identity_keypair, load_key,
|
||||
load_x25519_noise_keypair, store_ed25519_identity_keypair, store_key, store_keypair,
|
||||
store_x25519_noise_keypair,
|
||||
};
|
||||
use crate::node::http::api::api_requests;
|
||||
use crate::node::http::helpers::system_info::get_system_info;
|
||||
@@ -27,9 +27,9 @@ use crate::node::metrics::handler::global_prometheus_updater::PrometheusGlobalNo
|
||||
use crate::node::metrics::handler::legacy_packet_data::LegacyMixingStatsUpdater;
|
||||
use crate::node::metrics::handler::mixnet_data_cleaner::MixnetMetricsCleaner;
|
||||
use crate::node::metrics::handler::pending_egress_packets_updater::PendingEgressPacketsUpdater;
|
||||
use crate::node::mixnet::SharedFinalHopData;
|
||||
use crate::node::mixnet::packet_forwarding::PacketForwarder;
|
||||
use crate::node::mixnet::shared::ProcessingConfig;
|
||||
use crate::node::mixnet::SharedFinalHopData;
|
||||
use crate::node::nym_apis_client::NymApisClient;
|
||||
use crate::node::replay_protection::background_task::ReplayProtectionDiskFlush;
|
||||
use crate::node::replay_protection::bloomfilter::ReplayProtectionBloomfilters;
|
||||
@@ -44,11 +44,11 @@ use nym_gateway::node::{ActiveClientsStore, GatewayTasksBuilder};
|
||||
use nym_mixnet_client::client::ActiveConnections;
|
||||
use nym_mixnet_client::forwarder::MixForwardingSender;
|
||||
use nym_network_requester::{
|
||||
set_active_gateway, setup_fs_gateways_storage, store_gateway_details, CustomGatewayDetails,
|
||||
GatewayDetails, GatewayRegistration,
|
||||
CustomGatewayDetails, GatewayDetails, GatewayRegistration, set_active_gateway,
|
||||
setup_fs_gateways_storage, store_gateway_details,
|
||||
};
|
||||
use nym_node_metrics::events::MetricEventsSender;
|
||||
use nym_node_metrics::NymNodeMetrics;
|
||||
use nym_node_metrics::events::MetricEventsSender;
|
||||
use nym_node_requests::api::v1::node::models::{AnnouncePorts, NodeDescription};
|
||||
use nym_noise::config::{NoiseConfig, NoiseNetworkView};
|
||||
use nym_noise_keys::VersionedNoiseKey;
|
||||
@@ -58,7 +58,7 @@ use nym_task::{ShutdownManager, ShutdownToken, ShutdownTracker};
|
||||
use nym_validator_client::UserAgent;
|
||||
use nym_verloc::measurements::SharedVerlocStats;
|
||||
use nym_verloc::{self, measurements::VerlocMeasurer};
|
||||
use nym_wireguard::{peer_controller::PeerControlRequest, WireguardGatewayData};
|
||||
use nym_wireguard::{WireguardGatewayData, peer_controller::PeerControlRequest};
|
||||
use rand::rngs::OsRng;
|
||||
use rand::{CryptoRng, RngCore};
|
||||
use std::net::SocketAddr;
|
||||
@@ -660,13 +660,17 @@ impl NymNode {
|
||||
info!("started NR at: {}", started_nr.on_start_data.address);
|
||||
info!("started IPR at: {}", started_ipr.on_start_data.address);
|
||||
} else {
|
||||
info!("node not running in exit mode: the exit service providers (NR + IPR) will remain unavailable");
|
||||
info!(
|
||||
"node not running in exit mode: the exit service providers (NR + IPR) will remain unavailable"
|
||||
);
|
||||
}
|
||||
|
||||
// if we're running wireguard, start the authenticator
|
||||
// and the actual wireguard listener
|
||||
if self.config.wireguard.enabled {
|
||||
info!("starting the wireguard tasks: authenticator service provider + wireguard peer controller");
|
||||
info!(
|
||||
"starting the wireguard tasks: authenticator service provider + wireguard peer controller"
|
||||
);
|
||||
|
||||
gateway_tasks_builder.set_authenticator_opts(config.auth_opts);
|
||||
|
||||
@@ -693,7 +697,9 @@ impl NymNode {
|
||||
.await
|
||||
.map_err(NymNodeError::GatewayTasksStartupFailure)?;
|
||||
} else {
|
||||
info!("node not running with wireguard: authenticator service provider and wireguard will remain unavailable");
|
||||
info!(
|
||||
"node not running with wireguard: authenticator service provider and wireguard will remain unavailable"
|
||||
);
|
||||
}
|
||||
|
||||
// start task for removing stale and un-retrieved client messages
|
||||
@@ -1147,7 +1153,8 @@ impl NymNode {
|
||||
}
|
||||
|
||||
async fn start_nym_node_tasks(mut self) -> Result<ShutdownManager, NymNodeError> {
|
||||
info!("starting Nym Node {} with the following modes: mixnode: {}, entry: {}, exit: {}, wireguard: {}",
|
||||
info!(
|
||||
"starting Nym Node {} with the following modes: mixnode: {}, entry: {}, exit: {}, wireguard: {}",
|
||||
self.ed25519_identity_key(),
|
||||
self.config.modes.mixnode,
|
||||
self.config.modes.entry,
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
use crate::error::NymNodeError;
|
||||
use crate::node::NymNode;
|
||||
use futures::{stream, StreamExt};
|
||||
use futures::{StreamExt, stream};
|
||||
use nym_crypto::asymmetric::ed25519;
|
||||
use nym_http_api_client::Client;
|
||||
use nym_task::ShutdownToken;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
// Copyright 2025 - Nym Technologies SA <contact@nymtech.net>
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
use crate::config::persistence::DEFAULT_RD_BLOOMFILTER_FLUSH_FILE_EXT;
|
||||
use crate::config::Config;
|
||||
use crate::config::persistence::DEFAULT_RD_BLOOMFILTER_FLUSH_FILE_EXT;
|
||||
use crate::error::NymNodeError;
|
||||
use crate::node::replay_protection::bloomfilter::RotationFilter;
|
||||
use crate::node::replay_protection::helpers::parse_rotation_id_from_filename;
|
||||
@@ -17,7 +17,7 @@ use std::path::PathBuf;
|
||||
use std::time::Duration;
|
||||
use tokio::fs::File;
|
||||
use tokio::io::AsyncWriteExt;
|
||||
use tokio::time::{interval, Instant};
|
||||
use tokio::time::{Instant, interval};
|
||||
use tracing::{debug, error, info, trace, warn};
|
||||
|
||||
// background task responsible for periodically flushing the bloomfilters to disk
|
||||
@@ -70,15 +70,15 @@ impl ReplayProtectionDiskFlush {
|
||||
};
|
||||
|
||||
// if any bloomfilter has the temp extension, we can't trust its data as it hasn't completed the flush
|
||||
if let Some(ext) = entry.path().extension() {
|
||||
if ext == DEFAULT_RD_BLOOMFILTER_FLUSH_FILE_EXT {
|
||||
error!(
|
||||
"bloomfilter {rotation} didn't get successfully flushed to disk and its data got corrupted"
|
||||
);
|
||||
fs::remove_file(&path)
|
||||
.map_err(|source| NymNodeError::BloomfilterIoFailure { source, path })?;
|
||||
continue;
|
||||
}
|
||||
if let Some(ext) = entry.path().extension()
|
||||
&& ext == DEFAULT_RD_BLOOMFILTER_FLUSH_FILE_EXT
|
||||
{
|
||||
error!(
|
||||
"bloomfilter {rotation} didn't get successfully flushed to disk and its data got corrupted"
|
||||
);
|
||||
fs::remove_file(&path)
|
||||
.map_err(|source| NymNodeError::BloomfilterIoFailure { source, path })?;
|
||||
continue;
|
||||
}
|
||||
|
||||
filter_files.insert(rotation, path);
|
||||
@@ -254,7 +254,9 @@ impl ReplayProtectionDiskFlush {
|
||||
}
|
||||
}
|
||||
|
||||
info!("SHUTDOWN: flushing replay detection bloomfilter to disk. this might take a while. DO NOT INTERRUPT THIS PROCESS");
|
||||
info!(
|
||||
"SHUTDOWN: flushing replay detection bloomfilter to disk. this might take a while. DO NOT INTERRUPT THIS PROCESS"
|
||||
);
|
||||
if let Err(err) = self.flush_filters_to_disk().await {
|
||||
warn!("failed to flush replay detection bloom filters on shutdown: {err}");
|
||||
}
|
||||
|
||||
@@ -92,7 +92,9 @@ impl ReplayProtectionBloomfilters {
|
||||
} else if Some(secondary_id) == previous {
|
||||
(Some(secondary_filter), None)
|
||||
} else {
|
||||
warn!("{secondary_id} is not valid for either pre_announced or overlap bloomfilter given primary rotation of {primary_id}");
|
||||
warn!(
|
||||
"{secondary_id} is not valid for either pre_announced or overlap bloomfilter given primary rotation of {primary_id}"
|
||||
);
|
||||
(None, None)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ use async_trait::async_trait;
|
||||
use nym_crypto::asymmetric::ed25519;
|
||||
use nym_gateway::node::UserAgent;
|
||||
use nym_http_api_client::Client;
|
||||
use nym_node_metrics::prometheus_wrapper::{PrometheusMetric, PROMETHEUS_METRICS};
|
||||
use nym_node_metrics::prometheus_wrapper::{PROMETHEUS_METRICS, PrometheusMetric};
|
||||
use nym_noise::config::NoiseNetworkView;
|
||||
use nym_task::ShutdownToken;
|
||||
use nym_topology::node::RoutingNode;
|
||||
@@ -17,11 +17,11 @@ use nym_topology::{
|
||||
EntryDetails, EpochRewardedSet, NodeId, NymTopology, NymTopologyMetadata, Role,
|
||||
TopologyProvider,
|
||||
};
|
||||
use nym_validator_client::ValidatorClientError;
|
||||
use nym_validator_client::nym_api::NymApiClientExt;
|
||||
use nym_validator_client::nym_nodes::{
|
||||
NodesByAddressesResponse, SemiSkimmedNode, SemiSkimmedNodesWithMetadata,
|
||||
};
|
||||
use nym_validator_client::ValidatorClientError;
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use std::net::{IpAddr, SocketAddr};
|
||||
use std::ops::Deref;
|
||||
@@ -44,7 +44,9 @@ struct NodesQuerier {
|
||||
impl NodesQuerier {
|
||||
fn use_next_nym_api(&mut self) {
|
||||
if self.nym_api_urls.len() == 1 {
|
||||
warn!("There's only a single nym API available - it won't be possible to use a different one");
|
||||
warn!(
|
||||
"There's only a single nym API available - it won't be possible to use a different one"
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user