Compare commits

...

3 Commits

Author SHA1 Message Date
Andrej Mihajlov 50a259d454 Propagate cancel token to mixnet client 2025-10-14 13:19:56 +03:00
Jędrzej Stuczyński 0e3ffb749e using same hierarchy of trackers for client shutdown control 2025-10-14 13:13:39 +03:00
Bogdan-Ștefan Neacşu bd2e6ee812 Signal shutdown when gateway is considered unreachable 2025-10-14 12:12:16 +03:00
5 changed files with 18 additions and 16 deletions
Generated
-1
View File
@@ -5746,7 +5746,6 @@ dependencies = [
"criterion",
"ff",
"group",
"lazy_static",
"nym-contracts-common",
"nym-pemstore",
"rand 0.8.5",
@@ -892,7 +892,7 @@ where
// Create a shutdown tracker for this client - either as a child of provided tracker
// or get one from the registry
let shutdown_tracker = match self.shutdown {
Some(parent_tracker) => parent_tracker.child_tracker(),
Some(parent_tracker) => parent_tracker.clone(),
None => nym_task::get_sdk_shutdown_tracker()?,
};
@@ -926,7 +926,7 @@ where
self.user_agent.clone(),
generate_client_stats_id(*self_address.identity()),
input_sender.clone(),
&shutdown_tracker.child_tracker(),
&shutdown_tracker.clone(),
);
// needs to be started as the first thing to block if required waiting for the gateway
@@ -936,7 +936,7 @@ where
shared_topology_accessor.clone(),
self_address.gateway(),
self.wait_for_gateway,
&shutdown_tracker.child_tracker(),
&shutdown_tracker.clone(),
)
.await?;
@@ -956,7 +956,7 @@ where
stats_reporter.clone(),
#[cfg(unix)]
self.connection_fd_callback,
&shutdown_tracker.child_tracker(),
&shutdown_tracker.clone(),
)
.await?;
let gateway_ws_fd = gateway_transceiver.ws_fd();
@@ -964,7 +964,7 @@ where
let reply_storage = Self::setup_persistent_reply_storage(
reply_storage_backend,
key_rotation_config,
&shutdown_tracker.child_tracker(),
&shutdown_tracker.clone(),
)
.await?;
@@ -975,7 +975,7 @@ where
reply_storage.key_storage(),
reply_controller_sender.clone(),
stats_reporter.clone(),
&shutdown_tracker.child_tracker(),
&shutdown_tracker.clone(),
);
// The message_sender is the transmitter for any component generating sphinx packets
@@ -983,10 +983,8 @@ where
// traffic stream.
// The MixTrafficController then sends the actual traffic
let (message_sender, client_request_sender) = Self::start_mix_traffic_controller(
gateway_transceiver,
&shutdown_tracker.child_tracker(),
);
let (message_sender, client_request_sender) =
Self::start_mix_traffic_controller(gateway_transceiver, &shutdown_tracker.clone());
// Channels that the websocket listener can use to signal downstream to the real traffic
// controller that connections are closed.
@@ -1015,7 +1013,7 @@ where
shared_lane_queue_lengths.clone(),
client_connection_rx,
stats_reporter.clone(),
&shutdown_tracker.child_tracker(),
&shutdown_tracker.clone(),
);
if !self
@@ -1031,7 +1029,7 @@ where
shared_topology_accessor.clone(),
message_sender,
stats_reporter.clone(),
&shutdown_tracker.child_tracker(),
&shutdown_tracker.clone(),
);
}
@@ -155,6 +155,7 @@ impl MixTrafficController {
error!("Failed to send sphinx packet to the gateway {MAX_FAILURE_COUNT} times in a row - assuming the gateway is dead");
// Do we need to handle the embedded mixnet client case
// separately?
self.shutdown_token.cancel();
break;
}
}
@@ -4,7 +4,8 @@
use nym_credential_storage::persistent_storage::PersistentStorage;
use nym_registration_common::NymNode;
use nym_sdk::{
DebugConfig, NymNetworkDetails, RememberMe, TopologyProvider, UserAgent,
DebugConfig, NymNetworkDetails, RememberMe, ShutdownToken, ShutdownTracker, TopologyProvider,
UserAgent,
mixnet::{
CredentialStorage, GatewaysDetailsStore, KeyStore, MixnetClient, MixnetClientBuilder,
MixnetClientStorage, OnDiskPersistent, ReplyStorageBackend, StoragePaths, x25519::KeyPair,
@@ -115,7 +116,10 @@ impl BuilderConfig {
.debug_config(debug_config)
.credentials_mode(true)
.with_remember_me(remember_me)
.custom_topology_provider(self.custom_topology_provider);
.custom_topology_provider(self.custom_topology_provider)
.custom_shutdown(ShutdownTracker::new_from_external_shutdown_token(
ShutdownToken::from(self.cancel_token),
));
#[cfg(unix)]
let builder = builder.with_connection_fd_callback(self.connection_fd_callback);
+1 -1
View File
@@ -770,7 +770,7 @@ where
client_output,
client_state.clone(),
nym_address,
started_client.shutdown_handle.child_tracker(),
started_client.shutdown_handle.clone(),
packet_type,
);