-
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
base: solana-offchain-plugin
Are you sure you want to change the base?
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 Coreaer_workflow , commit , Clean Go Tidy & Generate , Detect Changes , Scheduled Run Frequency , test-scripts , Core Tests (go_core_tests) , Core Tests (go_core_tests_integration) , Core Tests (go_core_ccip_deployment_tests) , Core Tests (go_core_fuzz) , GolangCI Lint (core/scripts) , Core Tests (go_core_race_tests) , GolangCI Lint (.) , GolangCI Lint (integration-tests/load) , GolangCI Lint (integration-tests) , GolangCI Lint (deployment) , lint , SonarQube Scan 1. Not enough arguments in call to ccip_router.NewInitializeInstruction: Golang Lint (deployment)Source of Error:ccip/changeset/cs_deploy_chain.go:643:3: not enough arguments in call to ccip_router.NewInitializeInstruction
have (uint64, bin.Uint128, bool, int64, solana.PublicKey, solana.PublicKey, solana.PublicKey, solana.PublicKey, solana.PublicKey, solana.PublicKey, solana.PublicKey, solana.PublicKey, solana.PublicKey)
want (uint64, bin.Uint128, bool, int64, solana.PublicKey, solana.PublicKey, bin.Uint128, solana.PublicKey, solana.PublicKey, solana.PublicKey, solana.PublicKey, solana.PublicKey, solana.PublicKey, solana.PublicKey, solana.PublicKey) (typecheck) Why: The function Suggested fix: Update the call to 2. Declared and not used: Golang Lint (deployment)Source of Error:deployment/ccip/changeset/cs_active_candidate_test.go:139:3: declared and not used: block (typecheck)
deployment/ccip/changeset/cs_active_candidate_test.go:193:2: declared and not used: tokenConfig (typecheck)
deployment/ccip/changeset/cs_ccip_home_test.go:35:2: declared and not used: envNodes (typecheck)
deployment/ccip/changeset/cs_ccip_home_test.go:248:4: declared and not used: tokenConfig (typecheck)
deployment/ccip/changeset/cs_ccip_home_test.go:361:4: declared and not used: tokenConfig (typecheck) Why: Variables Suggested fix: Remove the unused variable declarations or use them appropriately in the code. 3. Imported and not used: Golang Lint (deployment)Source of Error:deployment/ccip/changeset/cs_active_candidate_test.go:4:2: "math/big" imported and not used (typecheck)
deployment/ccip/changeset/cs_active_candidate_test.go:23:2: "github.com/smartcontractkit/chainlink/v2/core/logger" imported and not used (typecheck)
deployment/ccip/changeset/cs_ccip_home_test.go:4:2: "math/big" imported and not used (typecheck)
deployment/ccip/changeset/cs_ccip_home_test.go:13:2: "github.com/smartcontractkit/chainlink-ccip/chainconfig" imported and not used (typecheck)
deployment/ccip/changeset/cs_ccip_home_test.go:14:2: "github.com/smartcontractkit/chainlink-ccip/pkg/types/ccipocr3" imported as cciptypes and not used (typecheck)
deployment/ccip/changeset/cs_ccip_home_test.go:19:2: "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/globals" imported and not used (typecheck)
deployment/ccip/changeset/cs_ccip_home_test.go:23:2: "github.com/smartcontractkit/chainlink/v2/core/logger" imported and not used (typecheck) Why: The listed packages are imported but not used in the code, leading to unused import errors. Suggested fix: Remove the unused import statements or use the imported packages in the code. 4. Could not import github.com/smartcontractkit/chainlink/deployment/ccip/changeset: Golang Lint (integration-tests/load)Source of Error:integration-tests/load/ccip/destination_gun.go:20:16: could not import github.com/smartcontractkit/chainlink/deployment/ccip/changeset (-: # github.com/smartcontractkit/chainlink/deployment/ccip/changeset
../../deployment/ccip/changeset/cs_deploy_chain.go:643:3: not enough arguments in call to ccip_router.NewInitializeInstruction
have (uint64, bin.Uint128, bool, int64, solana.PublicKey, solana.PublicKey, solana.PublicKey, solana.PublicKey, solana.PublicKey, solana.PublicKey, solana.PublicKey, solana.PublicKey, solana.PublicKey)
want (uint64, bin.Uint128, bool, int64, solana.PublicKey, solana.PublicKey, bin.Uint128, solana.PublicKey, solana.PublicKey, solana.PublicKey, solana.PublicKey, solana.PublicKey, solana.PublicKey, solana.PublicKey, solana.PublicKey)) (typecheck) Why: The import of Suggested fix: Fix the argument mismatch in the 5. Declared and not used: Golang Lint (integration-tests)Source of Error:integration-tests/smoke/ccip/ccip_usdc_test.go:54:2: declared and not used: ownerChainB (typecheck) Why: The variable Suggested fix: Remove the unused variable declaration or use it appropriately in the code. 6. Imported and not used: Golang Lint (integration-tests)Source of Error:integration-tests/smoke/ccip/ccip_reader_test.go:27:2: "github.com/smartcontractkit/chainlink/deployment/environment/memory" imported and not used (typecheck) Why: The package Suggested fix: Remove the unused import statement or use the imported package in the code. 7. Received unexpected error: abi decode extra args decodeSVMExtraArgsV1: Core Tests (go_core_tests)Source of Error:helpers_test.go:93:
Error Trace: /home/runner/work/chainlink/chainlink/core/capabilities/ccip/ccipevm/helpers_test.go:93
Error: Received unexpected error:
abi decode extra args decodeSVMExtraArgsV1: abi: improperly encoded boolean value
Test: Test_decodeExtraArgs/decode_extra_args_into_map_svm Why: The test Suggested fix: Ensure that the boolean values are properly encoded in the ABI before decoding. Verify the encoding process and correct any issues. 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.
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. |
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.
The way I understand, the SVMExtraArgsv1 is defined for EVM onchain, and requires abi decoding, which is all EVM
|
||
func DecodeExtraArgsToMap(extraArgs []byte) (map[string]any, error) { | ||
outputMap := make(map[string]any) | ||
var args ccip_router.SVMExtraArgs |
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 type is wrong.
This is used in the Any2SVMRampMessage, where SVM is a target family. The SVMExtraArgs will be provided by source chain, when SVM is the destination.
However this is ccipsolana codec, which should be decoding the message when SVM is the source chain.
The right type here should be AnyExtraArgs, which is used inside SVM2AnyRampMessage, here:
https://github.com/smartcontractkit/chainlink-ccip/blob/6b09016243f66e494499e8bac9947706908d1497/chains/solana/gobindings/ccip_router/types.go#L510
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.
Although I don't think AnyExtraArgs is the right structure. Instead it should be EVMExtraArgsv1 or EVMExtraArgsv2. But that is something we should talk to onchain folks about.
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. |
solana.SystemProgramID, | ||
}, | ||
extraArgs := ccip_router.AnyExtraArgs{ | ||
// TODO wait for onchain team fix this AnyExtraArgs |
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.
Since the source chain here is SVM, we won't need these SVM specific fields here, since you will not go from SVM -> SVM.
Atleast not until CCIP supports another SVM chain apart from Solana.
For testing right now, we should be good with just EVM specific fields in this struct.
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. |
t.Run("decode extra args into map svm", func(t *testing.T) { | ||
key, err := solana.NewRandomPrivateKey() | ||
require.NoError(t, err) | ||
encoded, err := d.contract.EncodeSVMExtraArgsV1(nil, message_hasher.ClientSVMExtraArgsV1{ |
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.
@prashantkumar1982 This is the failing test I was talking about. By inspecting the encoded bytes, I suspect this EncodeSVMExtraArgsV1
is not working properly.
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. |
require.NoError(t, err) | ||
output, err := DecodeExtraArgsToMap(buf.Bytes()) | ||
require.NoError(t, err) | ||
require.Len(t, output, 2) |
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.
Can you add require.Equal
checks on the contents of the output
map?
func (ExtraArgsCodec) DecodeExtraData(extraArgs cciptypes.Bytes, sourceChainSelector cciptypes.ChainSelector) (map[string]any, error) { | ||
family, err := chainsel.GetSelectorFamily(uint64(sourceChainSelector)) | ||
if err != nil { | ||
return nil, fmt.Errorf("failed to decode extra data, %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 extra data, %w", err) | |
return nil, fmt.Errorf("failed to get chain family for selector %d: %w", sourceChainSelector, err) |
"github.com/smartcontractkit/chainlink-ccip/chains/solana/gobindings/ccip_router" | ||
) | ||
|
||
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.
Good rule of thumb to add a docstring to exported methods
|
||
m, err := DecodeExtraArgsToMap(encoded) | ||
require.NoError(t, err) | ||
require.Len(t, m, 1) |
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.
Lets add require.Equal
checks on the contents of the map.
|
||
m, err := DecodeExtraArgsToMap(encoded) | ||
require.NoError(t, err) | ||
require.Len(t, m, 2) |
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 re: equality checks.
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. |
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. |
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. |
Quality Gate passedIssues Measures |
Jira
extra args codec for OCR message. Convert []byte into map[string]any format depends on the source chain.