Skip to content

Address gobinding inconsistency#566

Open
huangzhen1997 wants to merge 27 commits intomainfrom
jh/fix-bindings-incompatbilities
Open

Address gobinding inconsistency#566
huangzhen1997 wants to merge 27 commits intomainfrom
jh/fix-bindings-incompatbilities

Conversation

@huangzhen1997
Copy link
Contributor

@huangzhen1997 huangzhen1997 commented Feb 2, 2026

Summary

  • Updated TLB opcodes for MessageValidated (#cbc4af76 → #1fa60374) and MessageValidationFailed (#0f756150 → #bcf0ab0f) to match on-chain changes
  • Changed Context field encoding from maybe ^ to . (RemainingBitsAndRefs pattern) in FeeQuoter message types
  • Renamed Metadata field to Context in ccipsendexecutor structs
  • Fixed TokenAmount.Amount type from *big.Int to *tlb.Coins to match on-chain encoding
  • Updated PendingOwner in ownable2step and FeeToken in CCIPSend to use maybe addr for optional addresses
  • Updated offramp error codes: renamed ErrorSenderIsNotRouter → ErrorInsufficientFee, added ErrorTooManyMessagesInReport
  • Added input validation and error handling to PackGasPrice/UnpackGasPrice functions (nil checks, negative value checks, bit overflow checks)
  • Fixed WithdrawFeeTokens.FeeTokens encoding from inline to ref cell (^)
  • Removed obsolete WithdrawJettons struct and added new OnRamp event topics
  • Restructured UpdateTokenTransferFeeConfig to match on-chain dictionary format
  • Removed the duplicate types and reused the correct ones from the feequoter package

AllowedPriceUpdaters *cell.Dictionary `tlb:"dict 267"`
MaxFeeJuelsPerMsg *big.Int `tlb:"## 96"`
LinkToken *address.Address `tlb:"addr"`
// TODO: Consider changing to uint32 for EVM compatibility. Currently uint64 on-chain.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@vicentevieytes why are we using uint64 on-chain for TokenPriceStalenessThreshold ?

@huangzhen1997 huangzhen1997 marked this pull request as ready for review February 2, 2026 02:34
@huangzhen1997 huangzhen1997 requested a review from a team as a code owner February 2, 2026 02:34
Copilot AI review requested due to automatic review settings February 2, 2026 02:34
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 addresses inconsistencies between the Go bindings and on-chain TON contract schemas by updating TLB (Type-Length-Value) encodings, opcodes, and error codes to match the current on-chain implementation.

Changes:

  • Updated TLB opcodes and field encodings (Context, FeeToken, PendingOwner, TokenAmount) to match on-chain schema changes
  • Added comprehensive input validation and error handling to PackGasPrice/UnpackGasPrice functions with nil checks, negative value checks, and bit overflow checks
  • Restructured types to eliminate duplication by reusing feequoter package types in ccipsendexecutor, and updated UpdateTokenTransferFeeConfig to match on-chain dictionary format

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
pkg/ccip/codec/commitcodec.go Updated to handle new error returns from PackGasPrice/UnpackGasPrice functions
pkg/ccip/chainaccessor/ton_accessor.go Added error handling for PackGasPrice calls
pkg/ccip/chainaccessor/config.go Added overflow check for uint64 to uint32 conversion of StalenessThreshold
pkg/ccip/bindings/router/router.go Changed TokenAmount.Amount from *big.Int to tlb.Coins and FeeToken to optional address
pkg/ccip/bindings/ownable2step/storage.go Updated PendingOwner encoding to use "maybe addr" for optional addresses
pkg/ccip/bindings/onramp/onramp_test.go Added test cases to verify CRC32 values for event topics
pkg/ccip/bindings/onramp/onramp.go Updated event topics, renamed structs, removed obsolete WithdrawJettons, and fixed WithdrawFeeTokens encoding
pkg/ccip/bindings/offramp/offramp.go Updated error codes by renaming ErrorSenderIsNotRouter to ErrorInsufficientFee and adding ErrorTooManyMessagesInReport
pkg/ccip/bindings/offramp/exitcode_string.go Regenerated string representations for updated error codes
pkg/ccip/bindings/feequoter/reader.go Updated StalenessThreshold type from uint32 to uint64 and added documentation for GetDestChainConfig
pkg/ccip/bindings/feequoter/gaspriceutils_test.go Added comprehensive error case tests for PackGasPrice/UnpackGasPrice and renamed helper function
pkg/ccip/bindings/feequoter/gaspriceutils.go Added input validation with error returns for nil, negative, and bit overflow checks
pkg/ccip/bindings/feequoter/fee_quoter.go Updated Context field encoding, restructured UpdateTokenTransferFeeConfig, and added documentation
pkg/ccip/bindings/ccipsendexecutor/ccipsendexecutor.go Removed duplicate types and reused feequoter package types

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

@@ -104,6 +87,6 @@ type StateOnGoingFeeValidation struct {

// TokenAmount structure (reused from router package concept)
Copy link

Copilot AI Feb 2, 2026

Choose a reason for hiding this comment

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

The struct name 'TokenAmount' is confusing because it appears in multiple packages (router, ccipsendexecutor) with the same name but potentially different purposes. Consider adding a package-specific prefix (e.g., ExecutorTokenAmount) or documenting why this duplicates the router.TokenAmount type instead of reusing it.

Suggested change
// TokenAmount structure (reused from router package concept)
// TokenAmount represents an amount of a given token for the CCIP Send Executor.
// It intentionally mirrors the schema and naming of router.TokenAmount instead of
// reusing that type directly, to keep this bindings package self-contained and to
// match the on-chain / TLB schema for executor messages.

Copilot uses AI. Check for mistakes.
@huangzhen1997
Copy link
Contributor Author

Hey @patricios-space, can you help review these off-chain bindings updates

patricios-space
patricios-space previously approved these changes Feb 2, 2026
krebernisak
krebernisak previously approved these changes Feb 3, 2026
//
// NOTE: This Go type is named "DestChainConfig" but corresponds to the on-chain "FeeQuoterDestChainConfig"
// struct (see contracts/contracts/ccip/fee_quoter/types.tolk). The on-chain "DestChainConfig" is a larger
// struct that wraps FeeQuoterDestChainConfig along with usdPerUnitGas and tokenTransferFeeConfigs fields.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks for the comment - imo this is super confusing and the naming is not best we can do.

krebernisak
krebernisak previously approved these changes Feb 4, 2026
Copy link
Collaborator

@krebernisak krebernisak left a comment

Choose a reason for hiding this comment

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

Looks good! Needs CI fix.

Value *tlb.Coins `tlb:"."`
}

type WithdrawJettons struct {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This was stale/unused, right?

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