From 120220517da368f907c95381608704200e10ccfc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bogdan-=C8=98tefan=20Neac=C5=9Fu?= Date: Thu, 21 Aug 2025 17:54:34 +0300 Subject: [PATCH] Retry sign&broadcast on sequence errors --- .../client_traits/signing_client.rs | 32 +++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/common/client-libs/validator-client/src/nyxd/cosmwasm_client/client_traits/signing_client.rs b/common/client-libs/validator-client/src/nyxd/cosmwasm_client/client_traits/signing_client.rs index cec29e9c50..4acf61827b 100644 --- a/common/client-libs/validator-client/src/nyxd/cosmwasm_client/client_traits/signing_client.rs +++ b/common/client-libs/validator-client/src/nyxd/cosmwasm_client/client_traits/signing_client.rs @@ -665,8 +665,7 @@ where CosmWasmClient::broadcast_tx_commit(self, tx_bytes).await } - /// Broadcast a transaction to the network and monitors its inclusion in a block. - async fn sign_and_broadcast( + async fn sign_and_broadcast_inner( &self, signer_address: &AccountId, messages: Vec, @@ -686,6 +685,35 @@ 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, + fee: Fee, + memo: impl Into + Send + 'static, + ) -> Result { + 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,