Compare commits

..

2 Commits

Author SHA1 Message Date
Jędrzej Stuczyński 856ebc5227 return error rather than panic when merging socket during shutdown 2025-08-08 10:06:38 +01:00
Jędrzej Stuczyński 9a217d1e5c feat: introduce additional checks when attempting to send to bounded channels
or to fallible gateway
2025-08-06 17:10:40 +01:00
5 changed files with 12 additions and 40 deletions
@@ -97,8 +97,6 @@ impl MixTrafficController {
) -> Result<(), ErasedGatewayError> {
debug_assert!(!mix_packets.is_empty());
let send_future = if mix_packets.len() == 1 {
// SAFETY: we just checked we have one packet
#[allow(clippy::unwrap_used)]
let mix_packet = mix_packets.pop().unwrap();
self.gateway_transceiver.send_mix_packet(mix_packet)
} else {
@@ -129,6 +127,7 @@ impl MixTrafficController {
biased;
_ = self.task_client.recv() => {
trace!("received shutdown while handling client request");
return
}
result = self.gateway_transceiver.send_client_request(client_request) => {
if let Err(err) = result {
@@ -145,10 +144,11 @@ impl MixTrafficController {
while !self.task_client.is_shutdown() {
tokio::select! {
biased;
_ = self.task_client.recv() => {
tracing::trace!("MixTrafficController: Received shutdown");
break;
}mix_packets = self.mix_rx.recv() => match mix_packets {
_ = self.task_client.recv() => {
tracing::trace!("MixTrafficController: Received shutdown");
break;
}
mix_packets = self.mix_rx.recv() => match mix_packets {
Some(mix_packets) => {
if let Err(err) = self.on_messages(mix_packets).await {
error!("Failed to send sphinx packet(s) to the gateway: {err}");
@@ -170,14 +170,12 @@ impl MixTrafficController {
},
client_request = self.client_rx.recv() => match client_request {
Some(client_request) => {
self.on_client_request(client_request).await;
self.on_client_request(client_request).await;
},
None => {
tracing::trace!("MixTrafficController, client request channel closed");
}
},
}
}
self.task_client.recv_timeout().await;
@@ -725,6 +725,7 @@ where
biased;
_ = self.task_client.recv() => {
trace!("received shutdown while attempting to forward mixnet messages");
return;
}
sending_res = self.real_message_sender.send((messages, transmission_lane)) => {
if sending_res.is_err() {
+1
View File
@@ -25,6 +25,7 @@ where
wasm_bindgen_futures::spawn_local(future);
}
#[track_caller]
#[cfg(not(target_arch = "wasm32"))]
pub(crate) fn spawn_future<F>(future: F)
where
@@ -665,7 +665,8 @@ where
CosmWasmClient::broadcast_tx_commit(self, tx_bytes).await
}
async fn sign_and_broadcast_inner(
/// Broadcast a transaction to the network and monitors its inclusion in a block.
async fn sign_and_broadcast(
&self,
signer_address: &AccountId,
messages: Vec<Any>,
@@ -685,35 +686,6 @@ where
self.broadcast_tx(tx_bytes, None, None).await
}
/// Broadcast a transaction to the network and monitors its inclusion in a block.
async fn sign_and_broadcast(
&self,
signer_address: &AccountId,
messages: Vec<Any>,
fee: Fee,
memo: impl Into<String> + Send + 'static,
) -> Result<TxResponse, NyxdError> {
let memo = memo.into();
loop {
match self
.sign_and_broadcast_inner(
signer_address,
messages.clone(),
fee.clone(),
memo.clone(),
)
.await
{
Ok(res) => return Ok(res),
Err(err) => {
if !err.to_string().contains("sequence") {
return Err(err);
}
}
}
}
}
async fn sign(
&self,
signer_address: &AccountId,
+1 -1
View File
@@ -3,7 +3,7 @@
[package]
name = "nym-node"
version = "1.15.1"
version = "1.15.0"
authors.workspace = true
repository.workspace = true
homepage.workspace = true