Bläddra i källkod

fix(fortuna): Propagate submission errors correctly (#2458)

Amin Moghaddam 8 månader sedan
förälder
incheckning
26ae90718a

+ 1 - 1
apps/fortuna/Cargo.lock

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

+ 1 - 1
apps/fortuna/Cargo.toml

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

+ 2 - 2
apps/fortuna/src/eth_utils/utils.rs

@@ -20,7 +20,7 @@ pub struct SubmitTxResult {
     pub gas_multiplier: u64,
     pub fee_multiplier: u64,
     pub duration: Duration,
-    pub receipt: Result<TransactionReceipt, anyhow::Error>,
+    pub receipt: TransactionReceipt,
 }
 
 #[derive(Clone, Debug)]
@@ -193,7 +193,7 @@ pub async fn submit_tx_with_backoff<T: Middleware + NonceManaged + 'static>(
             num_retries.store(retry_number + 1, std::sync::atomic::Ordering::Relaxed);
         },
     )
-    .await;
+    .await?;
 
     let duration = start_time.elapsed();
     let num_retries = num_retries.load(std::sync::atomic::Ordering::Relaxed);

+ 17 - 19
apps/fortuna/src/keeper/process_event.rs

@@ -62,8 +62,8 @@ pub async fn process_event_with_backoff(
         .inc();
 
     match success {
-        Ok(res) => {
-            tracing::info!("Processed event successfully in {:?}", res.duration);
+        Ok(result) => {
+            tracing::info!("Processed event successfully in {:?}", result.duration);
 
             metrics
                 .requests_processed_success
@@ -73,39 +73,37 @@ pub async fn process_event_with_backoff(
             metrics
                 .request_duration_ms
                 .get_or_create(&account_label)
-                .observe(res.duration.as_millis() as f64);
+                .observe(result.duration.as_millis() as f64);
 
             // Track retry count, gas multiplier, and fee multiplier for successful transactions
             metrics
                 .retry_count
                 .get_or_create(&account_label)
-                .observe(res.num_retries as f64);
+                .observe(result.num_retries as f64);
 
             metrics
                 .final_gas_multiplier
                 .get_or_create(&account_label)
-                .observe(res.gas_multiplier as f64);
+                .observe(result.gas_multiplier as f64);
 
             metrics
                 .final_fee_multiplier
                 .get_or_create(&account_label)
-                .observe(res.fee_multiplier as f64);
+                .observe(result.fee_multiplier as f64);
 
-            if let Ok(receipt) = res.receipt {
-                if let Some(gas_used) = receipt.gas_used {
-                    let gas_used_float = gas_used.as_u128() as f64 / 1e18;
+            if let Some(gas_used) = result.receipt.gas_used {
+                let gas_used_float = gas_used.as_u128() as f64 / 1e18;
+                metrics
+                    .total_gas_spent
+                    .get_or_create(&account_label)
+                    .inc_by(gas_used_float);
+
+                if let Some(gas_price) = result.receipt.effective_gas_price {
+                    let gas_fee = (gas_used * gas_price).as_u128() as f64 / 1e18;
                     metrics
-                        .total_gas_spent
+                        .total_gas_fee_spent
                         .get_or_create(&account_label)
-                        .inc_by(gas_used_float);
-
-                    if let Some(gas_price) = receipt.effective_gas_price {
-                        let gas_fee = (gas_used * gas_price).as_u128() as f64 / 1e18;
-                        metrics
-                            .total_gas_fee_spent
-                            .get_or_create(&account_label)
-                            .inc_by(gas_fee);
-                    }
+                        .inc_by(gas_fee);
                 }
             }
             metrics.reveals.get_or_create(&account_label).inc();