Преглед на файлове

Retry if receipt indicates failure (#2522)

Amin Moghaddam преди 8 месеца
родител
ревизия
c1365193f9
променени са 4 файла, в които са добавени 16 реда и са изтрити 3 реда
  1. 1 1
      apps/fortuna/Cargo.lock
  2. 1 1
      apps/fortuna/Cargo.toml
  3. 8 0
      apps/fortuna/src/eth_utils/utils.rs
  4. 6 1
      apps/fortuna/src/keeper/process_event.rs

+ 1 - 1
apps/fortuna/Cargo.lock

@@ -1554,7 +1554,7 @@ dependencies = [
 
 [[package]]
 name = "fortuna"
-version = "7.4.8"
+version = "7.4.9"
 dependencies = [
  "anyhow",
  "axum",

+ 1 - 1
apps/fortuna/Cargo.toml

@@ -1,6 +1,6 @@
 [package]
 name = "fortuna"
-version = "7.4.8"
+version = "7.4.9"
 edition = "2021"
 
 [lib]

+ 8 - 0
apps/fortuna/src/eth_utils/utils.rs

@@ -1,3 +1,4 @@
+use ethabi::ethereum_types::U64;
 use {
     crate::eth_utils::nonce_manager::NonceManaged,
     anyhow::{anyhow, Result},
@@ -315,5 +316,12 @@ pub async fn submit_tx<T: Middleware + NonceManaged + 'static>(
             ))
         })?;
 
+    if receipt.status == Some(U64::from(0)) {
+        return Err(backoff::Error::transient(anyhow!(
+            "Reveal transaction reverted on-chain. Tx:{:?}",
+            transaction
+        )));
+    }
+
     Ok(receipt)
 }

+ 6 - 1
apps/fortuna/src/keeper/process_event.rs

@@ -63,7 +63,12 @@ pub async fn process_event_with_backoff(
 
     match success {
         Ok(result) => {
-            tracing::info!("Processed event successfully in {:?}", result.duration);
+            tracing::info!(
+                "Processed event successfully in {:?} after {} retries. Receipt: {:?}",
+                result.duration,
+                result.num_retries,
+                result.receipt
+            );
 
             metrics
                 .requests_processed_success