Skip to content

Commit

Permalink
fix: truncate last 255 chars of failure_reason
Browse files Browse the repository at this point in the history
  • Loading branch information
bendanzhentan committed Nov 24, 2023
1 parent 14e6d60 commit c463328
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions cmd/bot/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,25 +103,29 @@ func ProcessUnprovenBotDelegatedWithdrawals(ctx context.Context, log log.Logger,
for _, unproven := range unprovens {
err := processor.ProveWithdrawalTransaction(ctx, &unproven)
if err != nil {
if strings.Contains(err.Error(), "OptimismPortal: withdrawal hash has already been proven") {
errStr := err.Error()
if strings.Contains(errStr, "OptimismPortal: withdrawal hash has already been proven") {
// The withdrawal has already proven, mark it
result := db.Model(&unproven).Update("proven", true)
if result.Error != nil {
log.Error("failed to update proven l2_contract_events", "error", result.Error)
}
} else if strings.Contains(err.Error(), "L2OutputOracle: cannot get output for a block that has not been proposed") {
} else if strings.Contains(errStr, "L2OutputOracle: cannot get output for a block that has not been proposed") {
// Since the unproven withdrawals are sorted by the on-chain order, we can break here because we know
// that the subsequent of the withdrawals are not ready to be proven yet.
return
} else if strings.Contains(err.Error(), "execution reverted") {
} else if strings.Contains(errStr, "execution reverted") {
// Proven transaction reverted, mark it with the failure reason
result := db.Model(&unproven).Update("failure_reason", err.Error())
if len(errStr) >= 255 {
errStr = errStr[len(errStr)-255:]
}
result := db.Model(&unproven).Update("failure_reason", errStr)
if result.Error != nil {
log.Error("failed to update failure reason of l2_contract_events", "error", result.Error)
}
} else {
// non-revert error, stop processing the subsequent withdrawals
log.Error("ProveWithdrawalTransaction", "non-revert error", err.Error())
log.Error("ProveWithdrawalTransaction", "non-revert error", errStr)
return
}
}
Expand Down

0 comments on commit c463328

Please sign in to comment.