Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use a more readable string for upkeep failure reasons #11770

Merged
merged 1 commit into from
Jan 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading