Skip to content
Open
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,16 @@ func (p *abiPacker) UnpackCheckResult(payload ocr2keepers.UpkeepPayload, raw str
fmt.Errorf("upkeepId %s failed to unpack checkUpkeep result %s: %w", payload.UpkeepID.String(), raw, err)
}

gasAllocatedBig := *abi.ConvertType(out[4], new(*big.Int)).(**big.Int)
if !gasAllocatedBig.IsUint64() {
return GetIneligibleCheckResultWithoutPerformData(payload, UpkeepFailureReasonNone, PackUnpackDecodeFailed, false),
fmt.Errorf("upkeepId %s GasAllocated value %s overflows uint64", payload.UpkeepID.String(), gasAllocatedBig.String())
}
Comment on lines +49 to +52
Copy link

Copilot AI Mar 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new overflow check path lacks a unit test. The existing test file (packer_test.go) has dedicated tests for the decode failed and unpack failed error paths in UnpackCheckResult, but there is no test case covering the new GasAllocated overflows uint64 error path. A test case should be added with a raw hex payload whose out[4] encodes a value larger than math.MaxUint64 (e.g., a 256-bit integer with bits set above the 64-bit boundary), verifying that the error is returned and the result has PipelineExecutionState set to PackUnpackDecodeFailed.

Copilot uses AI. Check for mistakes.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test is already there - see the "gas allocated overflow" case in packer_test.go (added in commit 875fbcb). It encodes GasAllocated as 2^64 (math.MaxUint64+1) and asserts the overflow error.


result := ocr2keepers.CheckResult{
Eligible: *abi.ConvertType(out[0], new(bool)).(*bool),
Retryable: false,
GasAllocated: uint64((*abi.ConvertType(out[4], new(*big.Int)).(**big.Int)).Int64()),
GasAllocated: gasAllocatedBig.Uint64(),
UpkeepID: payload.UpkeepID,
Trigger: payload.Trigger,
WorkID: payload.WorkID,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,19 @@ func TestPacker_UnpackCheckResults(t *testing.T) {
},
ExpectedError: fmt.Errorf("upkeepId %s failed to unpack checkUpkeep result 0x123123: abi: cannot marshal in to go type: length insufficient 3 require 32", p2.UpkeepID.String()),
},
{
Name: "gas allocated overflow",
Payload: p1,
// valid checkUpkeep encoding with GasAllocated set to math.MaxUint64+1 (2^64)
RawData: "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000421c0000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000c8caf37f3b3890000000000000000000000000000000000000000000000000000000000000000",
ExpectedResult: ocr2keepers.CheckResult{
UpkeepID: upkeepId,
PipelineExecutionState: uint8(PackUnpackDecodeFailed),
Trigger: p1.Trigger,
WorkID: p1.WorkID,
},
ExpectedError: fmt.Errorf("upkeepId %s GasAllocated value 18446744073709551616 overflows uint64", p1.UpkeepID.String()),
},
}
for _, test := range tests {
t.Run(test.Name, func(t *testing.T) {
Expand Down