Skip to content

SUI - fix ExtraData parsing (LOOP)#21796

Merged
krebernisak merged 3 commits intodevelopfrom
fix/parse-extra-data
Mar 31, 2026
Merged

SUI - fix ExtraData parsing (LOOP)#21796
krebernisak merged 3 commits intodevelopfrom
fix/parse-extra-data

Conversation

@krebernisak
Copy link
Copy Markdown
Contributor

@krebernisak krebernisak commented Mar 31, 2026

When a non-EVM source chain (e.g. TON) sends a message to SUI, the source chain's ExtraDataCodec runs in a LOOP plugin. The decoded map[string]any goes through gRPC protobuf serialization which changes Go types:

  • uint32 → int64
  • [32]byte → []byte
  • [][32]byte → []interface{}

Supports

#21790

@github-actions
Copy link
Copy Markdown
Contributor

👋 krebernisak, thanks for creating this pull request!

To help reviewers, please consider creating future PRs as drafts first. This allows you to self-review and make any final changes before notifying the team.

Once you're ready, you can mark it as "Ready for review" to request feedback. Thanks!

@github-actions
Copy link
Copy Markdown
Contributor

I see you updated files related to core. Please run make gocs in the root directory to add a changeset as well as in the text include at least one of the following tags:

  • #added For any new functionality added.
  • #breaking_change For any functionality that requires manual action for the node to boot.
  • #bugfix For bug fixes.
  • #changed For any change to the existing functionality.
  • #db_update For any feature that introduces updates to database schema.
  • #deprecation_notice For any upcoming deprecation functionality.
  • #internal For changesets that need to be excluded from the final changelog.
  • #nops For any feature that is NOP facing and needs to be in the official Release Notes for the release.
  • #removed For any functionality/config that is removed.
  • #updated For any functionality that is updated.
  • #wip For any change that is not ready yet and external communication about it should be held off till it is feature complete.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 31, 2026

✅ No conflicts with other open PRs targeting develop

Copy link
Copy Markdown
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

Risk Rating: HIGH — changes touch CCIP message hashing inputs for Sui; mistakes here can cause incorrect hashes and failed/off-by-one message verification.

This PR aims to make Sui ExtraData decoding resilient to LOOP gRPC type conversions (e.g., [32]byte[]byte, uint32int64) similar to the Solana fix referenced in #21790.

Changes:

  • Update Sui parseExtraDataMap to accept tokenReceiver as either [32]byte or LOOP-converted []byte (with length validation).
  • Update Sui extractDestGasAmountFromMap to accept LOOP-converted int64 in addition to uint32.
  • Add unit tests for parseExtraDataMap tokenReceiver parsing; minor formatting/comment cleanup elsewhere.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
deployment/ccip/shared/stateview/state.go Whitespace/formatting-only change in SupportedChains().
core/capabilities/ccip/ccipsui/msghasher.go Adds LOOP-compatible parsing for tokenReceiver and destGasAmount (helper).
core/capabilities/ccip/ccipsui/msghasher_test.go Adds tests for [32]byte vs []byte tokenReceiver parsing, including invalid length case.
core/capabilities/ccip/ccipaptos/msghasher.go Removes an incorrect/outdated inline comment.

Comment thread core/capabilities/ccip/ccipsui/msghasher.go
Comment thread core/capabilities/ccip/ccipsui/msghasher.go
Comment on lines +333 to 343
switch v := fieldValue.(type) {
case uint32:
return v, nil
case int64: // LOOP converts expected uint32 to int64
if v > math.MaxUint32 {
return 0, fmt.Errorf("destGasAmount exceeds uint32 max, got %d", v)
}
return uint32(v), nil //nolint:gosec // G115: validated to be within uint32 max above
default:
return 0, errors.New("invalid type for destgasamount, expected uint32 or int64")
}
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

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

New behavior is added here to accept LOOP-converted destGasAmount values (int64uint32 with bounds checks), but there are no tests covering this conversion (including boundary cases like negative values and values > MaxUint32). Please add unit tests for extractDestGasAmountFromMap similar to the existing parseExtraDataMap tests.

Copilot generated this review using guidance from repository custom instructions.
@trunk-io
Copy link
Copy Markdown

trunk-io Bot commented Mar 31, 2026

Static BadgeStatic BadgeStatic BadgeStatic Badge

View Full Report ↗︎Docs

@cl-sonarqube-production
Copy link
Copy Markdown

@krebernisak krebernisak added bug ready for review PR is ready for code review labels Mar 31, 2026
@krebernisak krebernisak enabled auto-merge March 31, 2026 17:02
@krebernisak krebernisak added this pull request to the merge queue Mar 31, 2026
Merged via the queue into develop with commit d351043 Mar 31, 2026
299 of 312 checks passed
@krebernisak krebernisak deleted the fix/parse-extra-data branch March 31, 2026 17:32
prashantkumar1982 pushed a commit that referenced this pull request Apr 2, 2026
* SUI - fix ExtraData parsing (LOOP)

* Add test

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

Labels

bug ready for review PR is ready for code review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants