Skip to content

Conversation

@huangzhen1997
Copy link
Contributor

No description provided.

@huangzhen1997 huangzhen1997 marked this pull request as ready for review February 2, 2026 19:59
@huangzhen1997 huangzhen1997 requested a review from a team as a code owner February 2, 2026 19:59
Copilot AI review requested due to automatic review settings February 2, 2026 19:59
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR enhances error handling in the ParseLispTuple and ParseLispTupleBigInt functions by returning errors when malformed input is encountered, rather than silently returning empty results. This change helps detect ABI mismatches or contract regressions earlier in the execution flow.

Changes:

  • Modified ParseLispTuple and ParseLispTupleBigInt to return error as a second return value
  • Added ErrMalformedLispTuple error for invalid tuple structures
  • Updated all call sites to handle the new error return value
  • Added comprehensive test cases for malformed input scenarios

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.

Show a summary per file
File Description
pkg/ton/parser/parser.go Added error returns to parsing functions with explicit validation and error propagation
pkg/ton/parser/parser_test.go Extended test coverage with malformed input cases and error validation
pkg/ccip/bindings/router/reader.go Updated to propagate parser errors through the decoder
pkg/ccip/bindings/onramp/reader.go Updated to propagate parser errors through the decoder
pkg/ccip/bindings/offramp/reader.go Updated to propagate parser errors through the decoder for both tuple types
pkg/ccip/bindings/feequoter/reader.go Updated to propagate parser errors through the decoder
pkg/ccip/bindings/feequoter/fee_quoter.go Added explicit error handling for parser results
deployment/ccip/1_6_0/sequences/fastcurse.go Added explicit error handling with context-specific error message

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

patricios-space
patricios-space previously approved these changes Feb 2, 2026
krebernisak
krebernisak previously approved these changes Feb 3, 2026
func ParseLispTupleBigInt(tuple []any) []*big.Int {
// Returns an error if the tuple structure is malformed (e.g., unexpected types), which can indicate
// ABI mismatches or contract regressions. An empty input tuple returns nil without error.
func ParseLispTupleBigInt(tuple []any) ([]*big.Int, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please work on deduplicating these two functions (same except the return type) or scope out a follow up ticket. Thx!

Copy link
Collaborator

Choose a reason for hiding this comment

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

@huangzhen1997 were you able to dedupe? I think @krebernisak was suggesting having a single function where maybe the return type is passed in as an arg and then the function switches on the return type when constructing the return val, but correct me if that's wrong @krebernisak

for len(lispList) == 2 {
if bi, ok = lispList[0].(*big.Int); ok {
result = append(result, bi)
val, ok := lispList[0].(T)
Copy link
Collaborator

@krebernisak krebernisak Feb 3, 2026

Choose a reason for hiding this comment

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

Previously in both cases we cast to *big.Int, then take (map) bi.Uint64() when we want []uint64.

Now with generic we use it as parser.ParseLispTuple[uint64](r.AsTuple()) - will this work (against real network result)?

--

We can just do parser.ParseLispTuple[*big.Int](r.AsTuple()) and (again) map the result with bi.Uint64()

@huangzhen1997 huangzhen1997 force-pushed the NONEVM-3627/return-error-when-parseLispTuple-failed branch 2 times, most recently from ef6d94a to 479053c Compare February 3, 2026 18:29
// Returns an error if the tuple structure is malformed (e.g., unexpected types), which can indicate
// ABI mismatches or contract regressions. An empty input tuple returns nil without error.
func ParseLispTuple(tuple []any) ([]uint64, error) {
func ParseLispTuple[T uint64 | *big.Int](tuple []any) ([]T, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

T here should be any of these (cell, slice, Int): https://github.com/xssnick/tonutils-go/blob/master/ton/runmethod.go as this will be a potential cast lispList[0].(T); - we can't cast to uint64, not a type ExecutionResult returns.

The way we do it is with custom code in this fn.

It would it better if this fn is general for the types ExecutionResult possibly returns, and we map to uint64 outside this fn.

Copy link
Collaborator

Choose a reason for hiding this comment

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

We can just do parser.ParseLispTuple*big.Int and (again) map the result with bi.Uint64()

Example using https://github.com/samber/lo

numbersBig := parser.ParseLispTuple[*big.Int](r.AsTuple())
numbers := lo.Map(numbersBig, func(x *big.Int, index int) string {
    return x.Uint64();
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants