소스 검색

chore(fortuna): improve fee withdrawal logs, dont error log on pkey unique constraint violation (#2852)

* chore(fortuna): improve fee withdrawal logs, dont error log on pkey unique violation

* bump ver
Tejas Badadare 4 달 전
부모
커밋
8ad30ca4df
4개의 변경된 파일23개의 추가작업 그리고 4개의 파일을 삭제
  1. 1 1
      Cargo.lock
  2. 1 1
      apps/fortuna/Cargo.toml
  3. 12 1
      apps/fortuna/src/history.rs
  4. 9 1
      apps/fortuna/src/keeper/fee.rs

+ 1 - 1
Cargo.lock

@@ -3071,7 +3071,7 @@ dependencies = [
 
 [[package]]
 name = "fortuna"
-version = "8.2.0"
+version = "8.2.1"
 dependencies = [
  "anyhow",
  "axum 0.6.20",

+ 1 - 1
apps/fortuna/Cargo.toml

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

+ 12 - 1
apps/fortuna/src/history.rs

@@ -357,7 +357,18 @@ impl History {
             }
         };
         if let Err(e) = result {
-            tracing::error!("Failed to update request status: {}", e);
+            match e.as_database_error() {
+                Some(db_error) if db_error.is_unique_violation() => {
+                    tracing::info!(
+                        "Failed to insert request, request already exists: Chain ID: {}, Sequence: {}",
+                        network_id,
+                        sequence
+                    );
+                }
+                _ => {
+                    tracing::error!("Failed to update request status: {}", e);
+                }
+            }
         }
     }
 

+ 9 - 1
apps/fortuna/src/keeper/fee.rs

@@ -44,6 +44,13 @@ async fn calculate_fair_fee_withdrawal_amount<M: Middleware + 'static>(
         .await
         .map_err(|e| anyhow!("Error while getting current keeper balance. error: {:?}", e))?;
 
+    tracing::info!(
+        "Contract has available fees: {:?}, current keeper ({:?}) has balance: {:?}",
+        available_fees,
+        keeper_address,
+        current_balance
+    );
+
     // Calculate total funds across all keepers + available fees
     let mut total_funds = current_balance + available_fees;
 
@@ -55,6 +62,7 @@ async fn calculate_fair_fee_withdrawal_amount<M: Middleware + 'static>(
                 e
             )
         })?;
+        tracing::info!("Keeper address {:?} has balance: {:?}", address, balance);
         total_funds += balance;
     }
 
@@ -174,7 +182,7 @@ pub async fn withdraw_fees_if_necessary(
     if withdrawal_amount < min_withdrawal_amount {
         // We don't have enough to meaningfully top up the balance.
         // NOTE: This log message triggers a grafana alert. If you want to change the text, please change the alert also.
-        tracing::warn!("Keeper balance {:?} is too low (< {:?}) but provider fees are not sufficient to top-up.", keeper_balance, min_balance);
+        tracing::warn!("Keeper balance {:?} is too low (< {:?}) but provider fees are not sufficient to top-up. (withdrawal_amount={:?} < min_withdrawal_amount={:?})", keeper_balance, min_balance, withdrawal_amount, min_withdrawal_amount);
         return Ok(());
     }