From 72707557fc8c5ec44d4f00a0bb9e8b70b68582cd Mon Sep 17 00:00:00 2001 From: Rakan Al-Huneiti Date: Thu, 6 Jun 2024 15:51:17 +0300 Subject: [PATCH] Remove redundant sleep (#670) * Remove unnecessary sleep * log error message before returning * print error message using error macro --- .../full-node/sov-stf-runner/src/runner.rs | 25 +++++++++---------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/crates/sovereign-sdk/full-node/sov-stf-runner/src/runner.rs b/crates/sovereign-sdk/full-node/sov-stf-runner/src/runner.rs index 909fb4705..5768755db 100644 --- a/crates/sovereign-sdk/full-node/sov-stf-runner/src/runner.rs +++ b/crates/sovereign-sdk/full-node/sov-stf-runner/src/runner.rs @@ -422,14 +422,9 @@ where match inner_client.get_soft_batch::(l2_height).await { Ok(Some(soft_batch)) => Ok(soft_batch), Ok(None) => { - debug!( - "Soft Batch: no batch at height {}, retrying...", - l2_height - ); + debug!("Soft Batch: no batch at height {}", l2_height); - // We wait for 2 seconds and then return a Permanent error so that we exit the retry. - // This should not backoff exponentially - sleep(Duration::from_secs(2)).await; + // Return a Permanent error so that we exit the retry. Err(backoff::Error::Permanent( "No soft batch published".to_owned(), )) @@ -440,19 +435,23 @@ where "Soft Batch: connection error during RPC call: {:?}", e ); - debug!(error_msg); + error!(error_msg); Err(backoff::Error::Transient { err: error_msg, retry_after: None, }) } - _ => Err(backoff::Error::Transient { - err: format!( + _ => { + let error_msg = format!( "Soft Batch: unknown error from RPC call: {:?}", e - ), - retry_after: None, - }), + ); + error!(error_msg); + Err(backoff::Error::Transient { + err: error_msg, + retry_after: None, + }) + } }, } })