From 6993cacca8fc38e4f8cd68922f88633c03d8a73b Mon Sep 17 00:00:00 2001 From: Gianfranco Date: Tue, 30 Apr 2024 11:38:12 -0300 Subject: [PATCH 1/2] retry on rpc timeout response --- clients/runtime/src/error.rs | 17 +++++++++++++++++ clients/runtime/src/rpc.rs | 2 ++ clients/vault/src/requests/structs.rs | 2 ++ 3 files changed, 21 insertions(+) diff --git a/clients/runtime/src/error.rs b/clients/runtime/src/error.rs index bf3461e6a..2eaa5901c 100644 --- a/clients/runtime/src/error.rs +++ b/clients/runtime/src/error.rs @@ -200,6 +200,23 @@ impl Error { &format!("{:?}", SecurityPalletError::ParachainNotRunning), ) } + + pub fn is_timeout_error(&self) -> bool { + match self { + Error::SubxtRuntimeError(SubxtError::Rpc(RpcError::ClientError(e))) => + match e.downcast_ref::() { + Some(e) => matches!(e, JsonRpseeError::RequestTimeout), + None => { + log::error!( + "Failed to downcast RPC error; this is a bug please file an issue" + ); + false + }, + }, + _ => false, + } + } + } impl RecoverableError { diff --git a/clients/runtime/src/rpc.rs b/clients/runtime/src/rpc.rs index 54018c2c3..f3ea338fb 100644 --- a/clients/runtime/src/rpc.rs +++ b/clients/runtime/src/rpc.rs @@ -247,6 +247,8 @@ impl SpacewalkParachain { } else if err.is_block_hash_not_found_error() { log::info!("Re-sending transaction after apparent fork"); Err(RetryPolicy::Skip(Error::BlockHashNotFound)) + } else if err.is_timeout_error() { + Err(RetryPolicy::Skip(Error::Timeout)) } else { Err(RetryPolicy::Throw(err)) } diff --git a/clients/vault/src/requests/structs.rs b/clients/vault/src/requests/structs.rs index edf190bf8..196a1325b 100644 --- a/clients/vault/src/requests/structs.rs +++ b/clients/vault/src/requests/structs.rs @@ -210,6 +210,8 @@ impl Request { Err(RetryPolicy::Throw(err)) } else if err.is_block_hash_not_found_error() { Err(RetryPolicy::Skip(EnrichedError::BlockHashNotFound)) + } else if err.is_timeout_error() { + Err(RetryPolicy::Skip(EnrichedError::Timeout)) } else { Err(RetryPolicy::Throw(err)) } From 6d9240bbba71c21ebaaa1761261a92bb9a2c39cb Mon Sep 17 00:00:00 2001 From: Gianfranco Date: Thu, 2 May 2024 16:49:10 -0300 Subject: [PATCH 2/2] run fmt --- clients/runtime/src/error.rs | 1 - clients/vault/src/oracle/storage/traits.rs | 4 +++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/clients/runtime/src/error.rs b/clients/runtime/src/error.rs index 2eaa5901c..dd96d6c47 100644 --- a/clients/runtime/src/error.rs +++ b/clients/runtime/src/error.rs @@ -216,7 +216,6 @@ impl Error { _ => false, } } - } impl RecoverableError { diff --git a/clients/vault/src/oracle/storage/traits.rs b/clients/vault/src/oracle/storage/traits.rs index 0b4839922..1eaf648e8 100644 --- a/clients/vault/src/oracle/storage/traits.rs +++ b/clients/vault/src/oracle/storage/traits.rs @@ -141,7 +141,9 @@ pub trait ArchiveStorage { fn remove_file(&self, target_slot: Slot) { let (_, file) = self.get_url_and_file_name(target_slot); if let Err(e) = fs::remove_file(&file) { - tracing::warn!("remove_file(): failed to remove file {file} for slot {target_slot}: {e:?}"); + tracing::warn!( + "remove_file(): failed to remove file {file} for slot {target_slot}: {e:?}" + ); } }