Skip to content

Commit

Permalink
update sanity check
Browse files Browse the repository at this point in the history
  • Loading branch information
huangzhen1997 committed Oct 8, 2024
1 parent 2ebc866 commit ae9344c
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions core/chains/evm/txmgr/stuck_tx_detector.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,8 @@ func (d *stuckTxDetector) detectStuckTransactionsHeuristic(ctx context.Context,
oldestBroadcastAttempt, newestBroadcastAttempt, broadcastedAttemptsCount := findBroadcastedAttempts(tx)
d.lggr.Debugf("found %d broadcasted attempts for tx id %d in stuck transaction heuristic", broadcastedAttemptsCount, tx.ID)

// 2. Check if Threshold amount of blocks have passed since the oldest attempt's broadcast block num
if oldestBroadcastAttempt == nil {
// sanity checks
if oldestBroadcastAttempt == nil || newestBroadcastAttempt == nil {
d.lggr.Debugw("failed to find broadcast attempt for tx in stuck transaction heuristic", "tx", tx)
continue
}
Expand All @@ -230,6 +230,7 @@ func (d *stuckTxDetector) detectStuckTransactionsHeuristic(ctx context.Context,
continue
}

// 2. Check if Threshold amount of blocks have passed since the oldest attempt's broadcast block num
if *oldestBroadcastAttempt.BroadcastBeforeBlockNum > blockNum-int64(*d.cfg.Threshold()) {
continue
}
Expand All @@ -239,7 +240,7 @@ func (d *stuckTxDetector) detectStuckTransactionsHeuristic(ctx context.Context,
continue
}
// 4. Check if the newest broadcasted attempt's gas price is higher than what our gas estimator's GetFee method returns
if newestBroadcastAttempt != nil && compareGasFees(newestBroadcastAttempt.TxFee, marketGasPrice) <= 0 {
if compareGasFees(newestBroadcastAttempt.TxFee, marketGasPrice) <= 0 {
continue
}
// 5. Return the transaction since it is likely stuck due to overflow
Expand Down

0 comments on commit ae9344c

Please sign in to comment.