-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Implement extra args codec #16016
Implement extra args codec #16016
Conversation
Flakeguard SummaryRan new or updated tests between View Flaky Detector Details | Compare Changes Found Flaky Tests ❌
ArtifactsFor detailed logs of the failed tests, please refer to the artifact failed-test-results-with-logs.json. |
AER Report: CI Core ran successfully ✅AER Report: Operator UI CI ran successfully ✅ |
@@ -43,6 +50,61 @@ func decodeExtraArgsV1V2(extraArgs []byte) (gasLimit *big.Int, err error) { | |||
return ifaces[0].(*big.Int), nil | |||
} | |||
|
|||
func decodeExtraArgsSVMV1(extraArgs []byte) (*message_hasher.ClientSVMExtraArgsV1, 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.
This is a method to decode from an EVM source chain right?
EVMExtraArgsKey: gas, | ||
}, nil | ||
|
||
case chainsel.FamilySolana: |
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.
The switch on family here is on the source chain selector, meaning this case applies when source was Solana chain.
Thus decoding this requires Solana decoder.
But the implementation is using EVM decoder.
Flakeguard SummaryRan new or updated tests between View Flaky Detector Details | Compare Changes Found Flaky Tests ❌
ArtifactsFor detailed logs of the failed tests, please refer to the artifact failed-test-results-with-logs.json. |
case chainsel.FamilyEVM: | ||
gas, err1 := decodeExtraArgsV1V2(extraArgs) | ||
if err1 != nil { | ||
return nil, fmt.Errorf("failed to decode EVM extra data, %w", err) | ||
} | ||
|
||
return map[string]any{ | ||
EVMExtraArgsKey: gas, | ||
}, nil |
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'd be tempted to do some minor refactoring here so you can write it like this:
case chainsel.FamilyEVM: | |
gas, err1 := decodeExtraArgsV1V2(extraArgs) | |
if err1 != nil { | |
return nil, fmt.Errorf("failed to decode EVM extra data, %w", err) | |
} | |
return map[string]any{ | |
EVMExtraArgsKey: gas, | |
}, nil | |
case chainsel.FamilyEVM: | |
return decodeExtraArgsV1V2(extraArgs) |
Maybe even some moderate refactoring to avoid having SVM code in the EVM package.
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.
decodeExtraArgsV1V2
returns *big.int
. The return type needs to be map[string]any
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.
The way I understand, the SVMExtraArgsv1 is defined for EVM onchain, and requires abi decoding, which is all EVM
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, I said there would be minor refactoring.
// DecodeExtraArgsToMap is a helper function for converting Borsh encoded extra args bytes into map[string]any, which will be saved in ocr report.message.ExtraArgsDecoded | ||
func DecodeExtraArgsToMap(extraArgs []byte) (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.
Previously, the EVM version had this comment and a special offset. What happened to it?
case string(svmExtraArgsV1Tag):
// for SVMExtraArgs there's the four bytes plus another 32 bytes padding for the dynamic array
method = svmV1DecodeName
extraByteOffset = 36
@@ -20,6 +20,10 @@ import ( | |||
|
|||
ccipcommon "github.com/smartcontractkit/chainlink/v2/core/capabilities/ccip/common" | |||
|
|||
<<<<<<< HEAD |
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.
Merge conflicts need resolving.
// for SVMExtraArgs there's the four bytes plus another 32 bytes padding for the dynamic array | ||
// https://github.com/smartcontractkit/chainlink/blob/33c0bda696b0ed97f587a46eacd5c65bed9fb2c1/contracts/src/v0.8/ccip/libraries/Client.sol#L57 | ||
method = svmV1DecodeName | ||
extraByteOffset = 36 |
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 still don't see why this is 36 instead of 4. It looks like it's encoded the same way as EVM args are encoded: https://github.com/smartcontractkit/chainlink/blob/33c0bda696b0ed97f587a46eacd5c65bed9fb2c1/contracts/src/v0.8/ccip/libraries/Client.sol#L74C35-L74C62
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 we rename or move these functions related to decoding to appropriately named files?
helpers.go seems like a bad place.
Maybe call them extradatadecoder.go
// for SVMExtraArgs there's the four bytes plus another 32 bytes padding for the dynamic array | ||
// https://github.com/smartcontractkit/chainlink/blob/33c0bda696b0ed97f587a46eacd5c65bed9fb2c1/contracts/src/v0.8/ccip/libraries/Client.sol#L57 | ||
// this is a temporary solution, the evm on-chain side will fix it, so the offset should just be 4 instead of 36 |
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.
Thanks for the link, but this doesn't really answer why there are 32 bytes of padding. I'm imagining that this behavior could change in the future, maybe we add a new SVM arg or there is an EVM optimization. When that causes the "abi decode extra args" error below, we should give the future dev something more concrete to work with.
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've created an unassigned ticket https://smartcontract-it.atlassian.net/browse/BCI-4180
Quality Gate passedIssues Measures |
57d0294
into
solana-offchain-plugin
Jira
extra args codec for OCR message. Convert []byte into map[string]any format depends on the source chain.