-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* cleanup * update * fix mod * update * revert mod change * add changeset * fix smoke test * fix lint * revert go mod * fix * revert * revert * again * update * remove file * revert * update * update * update version * revert * downgrade version * go mod tidy * tidy * add token indexes * update comment * add solana and remove evm specific * add solana config * grammar * update go mod * go mod * update * update * changeset * update * refactor * update * refactor * update lint * fix lint * add chain reader config to plugin creator * update changeset * Part 1 for Prashant comments * refactor getTransmitterKeys * go mod tidy * minor * fix lint * go import * gomod * Blaž comments * part 1 * fix lint * data type * add solana home chain merge func * rephrase * add entire config from example * rm comments * lint * lint * refactor * update comments * fix lint * make generate * Add solana support to contract transmitter (#15869) * add solana support to contract transmitter * add changeset * one more place * address unsupported chain family * encode offramp addr * fix breaking change * rename * test * revert * update version * go mod * go mod tidy * go mod * go.md * go md * remove hard coded * go.md * go import * remove unused * update mod * update with new generated go binding * Amit comments * Solana estimate providers no-op (#15909) * no-op for solana estimate providers * add changeset * token data noop * noop for solana rmn * fix lint * mod tidy * Use SVM ABI, needs to check test * add comment * goimport * update * rename * go mod tidy * goimport * tidy * refactor * fix lint * step 1 for parse extra args map * add comment * fix test * fix * update * improvement * update * update * tidy * update * fix test * Matt comments * address Makram comments * Makram comments part1 * refactor * lint * go mod * update * fix * mod tidy * go md * gomd * fix import * fix broken integration test * change commit to little endian, to do for execute * update * use LE * update * update * update padding * fix make * fix test * rename * fix test * update source chain * update * lower case * update test * goimport * minor * tidy * implement and add test * update comments * goimport * implement dest exec data handling * fix conflicts * fix * fix * fix test * update * fix test * update * add comment * fix mod * fix * refactor * refactor * update * update comment * add unit test * update * lint * mod * mod tidy * fix * lint * update * update * goimport * update * Solana MessageHasher (#15911) * initial code * update * minor * update test * update * lint * change set * update * update * update token data and test * update * fix test --------- Co-authored-by: Joe Huang <[email protected]> * mod * update * clean up * update * update * add on-chain data decoding unit test coverage * add comment * fix import * more test * update * update * fix * fix import * rm unused * remove unused * downgrade * downgrade * rm * update * update * rm * update * revert * revert * revert * fix * update * fix * update * update * mod clean * fix * mod tidy * fix * fix * update * fix * update with develop * fix * go mod * update * update * update * update * update * more * update * update * mod * update * refactor extradata codec * update * goimport * update * add error * tidy * fix import * revert previous extra data codec refactor * fix --------- Co-authored-by: Prashant Yadav <[email protected]>
- Loading branch information
1 parent
bee407b
commit 111fe84
Showing
41 changed files
with
2,280 additions
and
132 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"chainlink": minor | ||
--- | ||
|
||
add solana chain reader config support to plugin creator, remove evm specific code #added |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"chainlink": minor | ||
--- | ||
|
||
Add solana chain writer config initialization #added |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"chainlink": minor | ||
--- | ||
|
||
Adding solana message hasher #added |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"chainlink": minor | ||
--- | ||
|
||
add Solana estimate provider as a no-op #added |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"chainlink": minor | ||
--- | ||
|
||
Solana CCIP plugin codec support for both commit and execute report #added |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"chainlink": minor | ||
--- | ||
|
||
Add solana support for contract transmitter and remove evm depdendency for address encoding #added |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package ccipevm | ||
|
||
import ( | ||
"fmt" | ||
|
||
cciptypes "github.com/smartcontractkit/chainlink-ccip/pkg/types/ccipocr3" | ||
) | ||
|
||
func DecodeDestExecDataToMap(DestExecData cciptypes.Bytes) (map[string]interface{}, error) { | ||
destGasAmount, err := abiDecodeUint32(DestExecData) | ||
if err != nil { | ||
return nil, fmt.Errorf("decode dest gas amount: %w", err) | ||
} | ||
|
||
return map[string]interface{}{ | ||
evmDestExecDataKey: destGasAmount, | ||
}, nil | ||
} | ||
|
||
func DecodeExtraArgsToMap(extraArgs []byte) (map[string]any, error) { | ||
if len(extraArgs) < 4 { | ||
return nil, fmt.Errorf("extra args too short: %d, should be at least 4 (i.e the extraArgs tag)", len(extraArgs)) | ||
} | ||
|
||
var method string | ||
var extraByteOffset int | ||
switch string(extraArgs[:4]) { | ||
case string(evmExtraArgsV1Tag): | ||
// for EVMExtraArgs, the first four bytes is the method name | ||
method = evmV1DecodeName | ||
extraByteOffset = 4 | ||
case string(evmExtraArgsV2Tag): | ||
method = evmV2DecodeName | ||
extraByteOffset = 4 | ||
case string(svmExtraArgsV1Tag): | ||
// for SVMExtraArgs there's the four bytes plus another 32 bytes padding for the dynamic array | ||
// TODO this is a temporary solution, the evm on-chain side will fix it, so the offset should just be 4 instead of 36 | ||
// https://smartcontract-it.atlassian.net/browse/BCI-4180 | ||
method = svmV1DecodeName | ||
extraByteOffset = 36 | ||
default: | ||
return nil, fmt.Errorf("unknown extra args tag: %x", extraArgs) | ||
} | ||
|
||
output := make(map[string]any) | ||
args := make(map[string]interface{}) | ||
err := messageHasherABI.Methods[method].Inputs.UnpackIntoMap(args, extraArgs[extraByteOffset:]) | ||
if err != nil { | ||
return nil, fmt.Errorf("abi decode extra args %v: %w", method, err) | ||
} | ||
|
||
for k, val := range args { | ||
output[k] = val | ||
} | ||
return output, nil | ||
} |
105 changes: 105 additions & 0 deletions
105
core/capabilities/ccip/ccipevm/extradatadecoder_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
package ccipevm | ||
|
||
import ( | ||
"math/big" | ||
"math/rand" | ||
"testing" | ||
|
||
"github.com/gagliardetto/solana-go" | ||
"github.com/stretchr/testify/require" | ||
|
||
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/message_hasher" | ||
) | ||
|
||
func Test_decodeExtraData(t *testing.T) { | ||
d := testSetup(t) | ||
gasLimit := big.NewInt(rand.Int63()) | ||
|
||
t.Run("decode extra args into map evm v1", func(t *testing.T) { | ||
encoded, err := d.contract.EncodeEVMExtraArgsV1(nil, message_hasher.ClientEVMExtraArgsV1{ | ||
GasLimit: gasLimit, | ||
}) | ||
require.NoError(t, err) | ||
|
||
m, err := DecodeExtraArgsToMap(encoded) | ||
require.NoError(t, err) | ||
require.Len(t, m, 1) | ||
|
||
gl, exist := m["gasLimit"] | ||
require.True(t, exist) | ||
require.Equal(t, gl, gasLimit) | ||
}) | ||
|
||
t.Run("decode extra args into map evm v2", func(t *testing.T) { | ||
encoded, err := d.contract.EncodeEVMExtraArgsV2(nil, message_hasher.ClientEVMExtraArgsV2{ | ||
GasLimit: gasLimit, | ||
AllowOutOfOrderExecution: true, | ||
}) | ||
require.NoError(t, err) | ||
|
||
m, err := DecodeExtraArgsToMap(encoded) | ||
require.NoError(t, err) | ||
require.Len(t, m, 2) | ||
|
||
gl, exist := m["gasLimit"] | ||
require.True(t, exist) | ||
require.Equal(t, gl, gasLimit) | ||
|
||
ooe, exist := m["allowOutOfOrderExecution"] | ||
require.True(t, exist) | ||
require.Equal(t, true, ooe) | ||
}) | ||
|
||
t.Run("decode extra args into map svm", func(t *testing.T) { | ||
key, err := solana.NewRandomPrivateKey() | ||
require.NoError(t, err) | ||
cu := uint32(10000) | ||
bitmap := uint64(4) | ||
ooe := false | ||
tokenReceiver := [32]byte(key.PublicKey().Bytes()) | ||
accounts := [][32]byte{[32]byte(key.PublicKey().Bytes())} | ||
decoded, err := d.contract.DecodeSVMExtraArgsV1(nil, cu, bitmap, ooe, tokenReceiver, accounts) | ||
if err != nil { | ||
return | ||
} | ||
encoded, err := d.contract.EncodeSVMExtraArgsV1(nil, decoded) | ||
require.NoError(t, err) | ||
|
||
m, err := DecodeExtraArgsToMap(encoded) | ||
require.NoError(t, err) | ||
require.Len(t, m, 5) | ||
|
||
cuDecoded, exist := m["computeUnits"] | ||
require.True(t, exist) | ||
require.Equal(t, cuDecoded, cu) | ||
|
||
bitmapDecoded, exist := m["accountIsWritableBitmap"] | ||
require.True(t, exist) | ||
require.Equal(t, bitmapDecoded, bitmap) | ||
|
||
ooeDecoded, exist := m["allowOutOfOrderExecution"] | ||
require.True(t, exist) | ||
require.Equal(t, ooeDecoded, ooe) | ||
|
||
tokenReceiverDecoded, exist := m["tokenReceiver"] | ||
require.True(t, exist) | ||
require.Equal(t, tokenReceiverDecoded, tokenReceiver) | ||
|
||
accountsDecoded, exist := m["accounts"] | ||
require.True(t, exist) | ||
require.Equal(t, accountsDecoded, accounts) | ||
}) | ||
|
||
t.Run("decode dest exec data into map", func(t *testing.T) { | ||
destGasAmount := uint32(10000) | ||
encoded, err := abiEncodeUint32(destGasAmount) | ||
require.NoError(t, err) | ||
m, err := DecodeDestExecDataToMap(encoded) | ||
require.NoError(t, err) | ||
require.Len(t, m, 1) | ||
|
||
decoded, exist := m[evmDestExecDataKey] | ||
require.True(t, exist) | ||
require.Equal(t, destGasAmount, decoded) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.