Skip to content

Conversation

huangzhen1997
Copy link
Contributor

@huangzhen1997 huangzhen1997 commented Jun 16, 2025

Gobinding for encoding/decoding execute report, following format from contract skeleton PR.

@huangzhen1997 huangzhen1997 changed the title add execute report binding definition, pending tests Execute reporting gobinding Jun 16, 2025
@huangzhen1997 huangzhen1997 marked this pull request as ready for review June 17, 2025 20:57
@Copilot Copilot AI review requested due to automatic review settings June 17, 2025 20:57
Copilot

This comment was marked as outdated.

@huangzhen1997 huangzhen1997 requested a review from Copilot June 17, 2025 21:05
Copilot

This comment was marked as outdated.

@huangzhen1997 huangzhen1997 requested a review from Copilot June 17, 2025 21:10
Copilot

This comment was marked as outdated.

@huangzhen1997 huangzhen1997 requested a review from Copilot June 17, 2025 22:42
Copilot

This comment was marked as outdated.

@huangzhen1997 huangzhen1997 changed the title Execute reporting gobinding Execute report gobinding Jun 18, 2025
if err != nil {
return nil, fmt.Errorf("failed to unpack inner array: %w", err)
}
if len(data) != int(length) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why do we store the length here, just to check for mismatch? This seems unnecessary

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We need to know where to stop reading for each array, and it's indicated by the length we stored before reading each array, when parsing the linked cell.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I might be missing something, can you point me to the LOC where length is used to stop reading the current item?

Copy link
Contributor Author

@huangzhen1997 huangzhen1997 Jul 10, 2025

Choose a reason for hiding this comment

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

You are right the length is not used, I'm revisiting the implementation now. This is used for the offchainData for ccip types and in offramp contract,

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There's a bug, I will fix it

Comment on lines 14 to 16
Messages SnakeRef[Any2TONRampMessage] `tlb:"^"`
OffChainTokenData SnakeBytes2D `tlb:"^"`
Proofs SnakeData[Signature] `tlb:"^"` // []Signature
Copy link
Collaborator

@krebernisak krebernisak Jul 10, 2025

Choose a reason for hiding this comment

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

I kinda suspect we don't actually need three different ways to encode collections of data, do we? cc @archseer

Copy link
Contributor Author

Choose a reason for hiding this comment

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

SnakeData stores array objects in a linked-cell format using the cell's data slice. It only supports structs that do not contain cell references, as it cannot be automatically serialized via TLB otherwise.

SnakeRef addresses this limitation by storing array objects in reference cells instead of the data slice, allowing support for structs that include cell references.

These three are different encoding schemes, but they provide optimal storage efficiency for complex data types.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I was able to solve SnakeData and SnakeRef onchain when decoding in a single pass, but it was dependent on the typed Cell<T> wrapper (Iterator parses directly, Iterator<Cell> loads a ref then parses it), but I'm not sure if there's a straightforward way to do that in Go.

I think we could at least reuse SnakeRef for SnakeBytes2D: it's essentially SnakeRef[SnakeData[[]byte]]`?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wasn't sure how the on-chain [][]byte was encoded, from previous conversation I thought we were going to SnakeBytes2D including array length. We can use SnakeRef[SnakeBytes], to make it simpler, it's just we will need to use more cell, as it produce fragmentation in the cell data.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just pushed a change

Copilot

This comment was marked as outdated.

@huangzhen1997 huangzhen1997 requested a review from Copilot July 10, 2025 20:52
Copy link
Contributor

@Copilot 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

Implements Gobinding for CCIP ExecuteReport messages with new packing/unpacking utilities and tests, and updates dependencies.

  • Introduce generic TLB packing/unpacking helpers (packArrayWithStaticType, SnakeData, etc.) and comprehensive unit tests in types.go/types_test.go.
  • Add ExecuteReport binding and corresponding encoding/decoding tests in executereport.go/executereport_test.go.
  • Remove old commit report implementation but left tests referencing CommitReport, causing a mismatch; update module dependencies and Nix vendor hash.

Reviewed Changes

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

Show a summary per file
File Description
pkg/ccip/bindings/types.go Add array/cell packing and unpacking functions (packArrayWithStaticType, pack2D...).
pkg/ccip/bindings/types_test.go Add unit tests covering edge cases for all new TLB utilities.
pkg/ccip/bindings/executereport.go Define ExecuteReport and related TLB-annotated types.
pkg/ccip/bindings/executereport_test.go Add tests to validate encoding and decoding of ExecuteReport.
pkg/ccip/bindings/commitreport.go Removed commit report logic but tests still reference CommitReport (incomplete update).
pkg/ccip/bindings/commitreport_test.go Old tests pruned, but TestCommitReport_EncodingAndDecoding remains without implementation
go.mod Add Solana and Testify dependencies and bump versions.
cmd/chainlink-ton/default.nix Update vendorHash after dependency changes.
Comments suppressed due to low confidence (1)

pkg/ccip/bindings/commitreport.go:3

  • The CommitReport struct and TLB imports (fmt, github.com/xssnick/tonutils-go/tlb, tvm/cell) were removed, but tests still reference CommitReport. Reintroduce the struct definition and necessary imports to restore compilation.
import (


// Signature represents an ED25519 signature.
type Signature struct {
Sig []byte `tlb:"bits 512"`
Copy link
Collaborator

Choose a reason for hiding this comment

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

Note: this now has a third field labeled pubkey that's the signer's public key

Copy link
Contributor Author

@huangzhen1997 huangzhen1997 Jul 11, 2025

Choose a reason for hiding this comment

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

Can you point me to this new label ? I don't see it from the latest offramp contract on execute report nor commit report.

@huangzhen1997 huangzhen1997 requested a review from archseer July 14, 2025 14:11
// Signature represents an ED25519 signature.
type Signature struct {
Sig []byte `tlb:"bits 512"`
Sig []byte `tlb:"bits 256"`
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is wrong, the signature should be 512 bits (64 bytes), plus the public key (32 bytes)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I got confused when I review the contract code, you used vec

// Any2TONRampMessage represents ramp message, which is part of the execute report.
type Any2TONRampMessage struct {
Header RampMessageHeader `tlb:"."`
Sender SnakeBytes `tlb:"^"`
Copy link
Collaborator

Choose a reason for hiding this comment

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

I added a new type for this called CrossChainAddress, it's 1 byte length len, followed by len bytes (one cell, no snake data, max length of 64 bytes)

Copy link
Collaborator

Choose a reason for hiding this comment

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

It can either be in place or as ^ ref

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't see it in the main branch, is it not merged ?

@huangzhen1997
Copy link
Contributor Author

Close this as changes are migrated to another PR #68

@huangzhen1997 huangzhen1997 deleted the jh/execute-report-gobinding branch August 11, 2025 22:25
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