diff --git a/src/eth/relayer/external.rs b/src/eth/relayer/external.rs index 740141163..da49277e1 100644 --- a/src/eth/relayer/external.rs +++ b/src/eth/relayer/external.rs @@ -8,6 +8,7 @@ use sqlx::postgres::PgPoolOptions; use sqlx::PgPool; use tokio::fs::File; use tokio::io::AsyncWriteExt; +use tokio::time::timeout; use tokio::time::Instant; use tracing::Span; @@ -142,7 +143,12 @@ impl ExternalRelayer { let start = Instant::now(); let mut substrate_receipt = substrate_pending_transaction; loop { - match substrate_receipt.await { + let Ok(receipt) = timeout(Duration::from_secs(30), substrate_receipt).await else { + tracing::error!(?tx_hash, "no receipt returned by substrate for more than 30 seconds, retrying block"); + return Err(RelayError::CompareTimeout(anyhow!("no receipt returned by substrate for more than 30 seconds"))); + }; + + match receipt { Ok(Some(substrate_receipt)) => if let Err(compare_error) = substrate_receipt.compare(&stratus_receipt) { let err_string = compare_error.to_string(); diff --git a/src/infra/blockchain_client/pending_transaction.rs b/src/infra/blockchain_client/pending_transaction.rs index 4f1efaf6d..4ea2f7729 100644 --- a/src/infra/blockchain_client/pending_transaction.rs +++ b/src/infra/blockchain_client/pending_transaction.rs @@ -88,7 +88,7 @@ impl<'a> Future for PendingTransaction<'a> { fn poll(self: Pin<&mut Self>, ctx: &mut Context) -> Poll { let this = self.project(); - tracing::debug!(?this.state); + tracing::debug!(?this.state, ?this.retries_remaining); match this.state { PendingTxState::InitialDelay(fut) => { @@ -119,7 +119,7 @@ impl<'a> Future for PendingTransaction<'a> { let tx_opt = tx_res.unwrap(); if tx_opt.is_none() { - if *this.retries_remaining == 0 { + if *this.retries_remaining <= 0 { *this.state = PendingTxState::Completed; return Poll::Ready(Ok(None)); }