Skip to content

Commit

Permalink
Use a more readable string for upkeep failure reasons (#11770)
Browse files Browse the repository at this point in the history
  • Loading branch information
shileiwill authored Jan 17, 2024
1 parent acebe22 commit ac372a4
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion core/scripts/chaincli/handler/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ func (k *Keeper) Debug(ctx context.Context, args []string) {
upkeepNeeded, performData = checkResult.UpkeepNeeded, checkResult.PerformData
// handle streams lookup
if checkResult.UpkeepFailureReason != 0 {
message(fmt.Sprintf("checkUpkeep failed with UpkeepFailureReason %d", checkResult.UpkeepFailureReason))
message(fmt.Sprintf("checkUpkeep failed with UpkeepFailureReason %s", getCheckUpkeepFailureReason(checkResult.UpkeepFailureReason)))
}

if checkResult.UpkeepFailureReason == uint8(encoding.UpkeepFailureReasonTargetCheckReverted) {
Expand Down Expand Up @@ -377,6 +377,28 @@ func (k *Keeper) Debug(ctx context.Context, args []string) {
}
}

func getCheckUpkeepFailureReason(reasonIndex uint8) string {
// Copied from KeeperRegistryBase2_1.sol
reasonStrings := []string{
"NONE",
"UPKEEP_CANCELLED",
"UPKEEP_PAUSED",
"TARGET_CHECK_REVERTED",
"UPKEEP_NOT_NEEDED",
"PERFORM_DATA_EXCEEDS_LIMIT",
"INSUFFICIENT_BALANCE",
"CALLBACK_REVERTED",
"REVERT_DATA_EXCEEDS_LIMIT",
"REGISTRY_PAUSED",
}

if int(reasonIndex) < len(reasonStrings) {
return reasonStrings[reasonIndex]
}

return fmt.Sprintf("Unknown : %d", reasonIndex)
}

func mustAutomationCheckResult(upkeepID *big.Int, checkResult iregistry21.CheckUpkeep, trigger ocr2keepers.Trigger) ocr2keepers.CheckResult {
upkeepIdentifier := mustUpkeepIdentifier(upkeepID)
checkResult2 := ocr2keepers.CheckResult{
Expand Down

0 comments on commit ac372a4

Please sign in to comment.