Skip to content

Commit

Permalink
show a more verbose message when perform gas is lower than gas used (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
shileiwill authored Jan 9, 2024
1 parent fa00dd3 commit 8499fe8
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion core/scripts/chaincli/handler/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
evm21 "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ocr2keeper/evmregistry/v21"

commonhex "github.com/smartcontractkit/chainlink-common/pkg/utils/hex"

"github.com/smartcontractkit/chainlink/core/scripts/chaincli/config"
"github.com/smartcontractkit/chainlink/core/scripts/common"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/automation_utils_2_1"
Expand Down Expand Up @@ -362,7 +363,17 @@ func (k *Keeper) Debug(ctx context.Context, args []string) {
if simulateResult.Success {
resolveEligible()
} else {
resolveIneligible("simulate perform upkeep unsuccessful")
// Convert performGas to *big.Int for comparison
performGasBigInt := new(big.Int).SetUint64(uint64(upkeepInfo.PerformGas))
// Compare PerformGas and GasUsed
result := performGasBigInt.Cmp(simulateResult.GasUsed)

if result < 0 {
// PerformGas is smaller than GasUsed
resolveIneligible(fmt.Sprintf("simulate perform upkeep unsuccessful, PerformGas (%d) is lower than GasUsed (%s)", upkeepInfo.PerformGas, simulateResult.GasUsed.String()))
} else {
resolveIneligible("simulate perform upkeep unsuccessful")
}
}
}

Expand Down

0 comments on commit 8499fe8

Please sign in to comment.