-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
support for decoding destexecdata #472
base: main
Are you sure you want to change the base?
Conversation
@@ -21,7 +21,8 @@ type MessageHasher interface { | |||
} | |||
|
|||
type ExtraDataCodec interface { | |||
DecodeExtraData(ExtraArgs Bytes, sourceChainSelector ChainSelector) (map[string]any, error) | |||
DecodeExtraArgs(extraArgs Bytes, sourceChainSelector ChainSelector) (map[string]any, error) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: add comment on which exact field on the Message struct does this work on.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need comments on this entire struct, please add doc comments so this is understandable to people who maintain this codebase
pkg/types/ccipocr3/interfaces.go
Outdated
@@ -21,7 +21,8 @@ type MessageHasher interface { | |||
} | |||
|
|||
type ExtraDataCodec interface { | |||
DecodeExtraData(ExtraArgs Bytes, sourceChainSelector ChainSelector) (map[string]any, error) | |||
DecodeExtraArgs(extraArgs Bytes, sourceChainSelector ChainSelector) (map[string]any, error) | |||
DecodeDestExecData(destExecData Bytes, sourceChainSelector ChainSelector) (Bytes, error) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To what format should this function decode to?
The input is []byte, and output is []byte, so its confusing.
Also, since this is []byte, it means theoretically a family can encode even a struct here, even though today EVM and SVM just use uint32. So I think, to handle any generic struct, we likely need the format similar to the ExtraArgsDecoded.
All the fields here in the generic Any2Any Message ideally should be in a format that is chain agnostic. So we can't have these in either source/destination specific coding.
Lets confirm with CCIP team if they agree here, or have other suggestions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you ask the onchain team? They confirmed the top level ExtraArgs is an object. Is this an object also?
At a minimum, I expect that this type should be any
or map[string]any
.
pkg/types/ccipocr3/interfaces.go
Outdated
@@ -21,7 +21,8 @@ type MessageHasher interface { | |||
} | |||
|
|||
type ExtraDataCodec interface { | |||
DecodeExtraData(ExtraArgs Bytes, sourceChainSelector ChainSelector) (map[string]any, error) | |||
DecodeExtraArgs(extraArgs Bytes, sourceChainSelector ChainSelector) (map[string]any, error) | |||
DecodeDestExecData(destExecData Bytes, sourceChainSelector ChainSelector) (Bytes, error) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: suggestion: function name rename to decodeTokenAmountDestExecData
Hey @huangzhen1997 this doesn't make sense to me, why would we do this in ccip? I'm not aware of this as a feature or functionality. |
@@ -21,7 +21,8 @@ type MessageHasher interface { | |||
} | |||
|
|||
type ExtraDataCodec interface { | |||
DecodeExtraData(ExtraArgs Bytes, sourceChainSelector ChainSelector) (map[string]any, error) | |||
DecodeExtraArgs(extraArgs Bytes, sourceChainSelector ChainSelector) (map[string]any, error) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need comments on this entire struct, please add doc comments so this is understandable to people who maintain this codebase
pkg/types/ccipocr3/interfaces.go
Outdated
@@ -21,7 +21,8 @@ type MessageHasher interface { | |||
} | |||
|
|||
type ExtraDataCodec interface { | |||
DecodeExtraData(ExtraArgs Bytes, sourceChainSelector ChainSelector) (map[string]any, error) | |||
DecodeExtraArgs(extraArgs Bytes, sourceChainSelector ChainSelector) (map[string]any, error) | |||
DecodeTokenAmountDestExecData(destExecData Bytes, sourceChainSelector ChainSelector) (Bytes, error) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a comment here on what this is
pkg/types/ccipocr3/interfaces.go
Outdated
@@ -21,7 +21,8 @@ type MessageHasher interface { | |||
} | |||
|
|||
type ExtraDataCodec interface { | |||
DecodeExtraData(ExtraArgs Bytes, sourceChainSelector ChainSelector) (map[string]any, error) | |||
DecodeExtraArgs(extraArgs Bytes, sourceChainSelector ChainSelector) (map[string]any, error) | |||
DecodeTokenAmountDestExecData(destExecData Bytes, sourceChainSelector ChainSelector) (Bytes, error) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah I see, I believe this is referring to : https://github.com/smartcontractkit/chainlink/blob/99860e4df73602187a926df4cc65c3919232d8f6/contracts/src/v0.8/ccip/libraries/Internal.sol#L230-L232
Lets make that very clear here that this is what this interface is doing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes
pkg/reader/ccip.go
Outdated
for i, token := range msg.Message.TokenAmounts { | ||
token.DestExecData, err = r.extraDataCodec.DecodeTokenAmountDestExecData(token.DestExecData, sourceChainSelector) | ||
if err != nil { | ||
return nil, fmt.Errorf("failed to decode DestExecData: %w", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return nil, fmt.Errorf("failed to decode DestExecData: %w", err) | |
return nil, fmt.Errorf("failed to decode token amount destExecData (%v): %w", tokenAmount, err) |
pkg/reader/ccip.go
Outdated
if err != nil { | ||
return nil, fmt.Errorf("failed to decode ExtraArgs: %w", err) | ||
} | ||
msg.Message.Header.OnRamp = onRampAddress | ||
|
||
for i, token := range msg.Message.TokenAmounts { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for i, token := range msg.Message.TokenAmounts { | |
for i, tokenAmount := range msg.Message.TokenAmounts { |
Not sure how to fix the CI test, it's using a different Chainlink repo I provided in PR description. |
pkg/types/ccipocr3/interfaces.go
Outdated
DecodeExtraData(ExtraArgs Bytes, sourceChainSelector ChainSelector) (map[string]any, error) | ||
// DecodeExtraArgs reformat bytes into a chain agnostic map[string]any representation for extra args | ||
DecodeExtraArgs(extraArgs Bytes, sourceChainSelector ChainSelector) (map[string]any, error) | ||
// DecodeTokenAmountDestExecData provide special treatment for DestExecData in token message depends on source chain |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment doesn't tell me much, can we improve it by saying:
- what it does
- why it does it
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm waiting for feedback here so I will have more details to provide in comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See the thread, posted a message
@@ -21,7 +21,10 @@ type MessageHasher interface { | |||
} | |||
|
|||
type ExtraDataCodec interface { | |||
DecodeExtraData(ExtraArgs Bytes, sourceChainSelector ChainSelector) (map[string]any, error) | |||
// DecodeExtraArgs reformat bytes into a chain agnostic map[string]any representation for extra args |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto here
|
core ref: 663859cd548ca40384ca02ac576961b5b5e53fc5
Add new function to the
extradatacodec
interface for parsing messagedestexecdata
. The destExecData is used when Any2EVM or SVM2Any messages for storing uint32 dest chain gas prices in bytes. Because ABI uses big-endian encoding while Borsch uses little-endian encoding.Corresponding change for chainlink repo: smartcontractkit/chainlink#15944