Skip to content

Commit

Permalink
Bump chainlink-solana
Browse files Browse the repository at this point in the history
  • Loading branch information
archseer committed Feb 7, 2025
1 parent e6dfb80 commit 461d94a
Show file tree
Hide file tree
Showing 20 changed files with 125 additions and 125 deletions.
18 changes: 9 additions & 9 deletions core/capabilities/ccip/ccipsolana/commitcodec.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
agbinary "github.com/gagliardetto/binary"
"github.com/gagliardetto/solana-go"

"github.com/smartcontractkit/chainlink-ccip/chains/solana/gobindings/ccip_router"
"github.com/smartcontractkit/chainlink-ccip/chains/solana/gobindings/ccip_offramp"
cciptypes "github.com/smartcontractkit/chainlink-ccip/pkg/types/ccipocr3"
)

Expand All @@ -29,15 +29,15 @@ func (c *CommitPluginCodecV1) Encode(ctx context.Context, report cciptypes.Commi
return nil, fmt.Errorf("unexpected merkle root length in report: %d", len(report.MerkleRoots))
}

mr := ccip_router.MerkleRoot{
mr := ccip_offramp.MerkleRoot{
SourceChainSelector: uint64(report.MerkleRoots[0].ChainSel),
OnRampAddress: report.MerkleRoots[0].OnRampAddress,
MinSeqNr: uint64(report.MerkleRoots[0].SeqNumsRange.Start()),
MaxSeqNr: uint64(report.MerkleRoots[0].SeqNumsRange.End()),
MerkleRoot: report.MerkleRoots[0].MerkleRoot,
}

tpu := make([]ccip_router.TokenPriceUpdate, 0, len(report.PriceUpdates.TokenPriceUpdates))
tpu := make([]ccip_offramp.TokenPriceUpdate, 0, len(report.PriceUpdates.TokenPriceUpdates))
for _, update := range report.PriceUpdates.TokenPriceUpdates {
token, err := solana.PublicKeyFromBase58(string(update.TokenID))
if err != nil {
Expand All @@ -46,27 +46,27 @@ func (c *CommitPluginCodecV1) Encode(ctx context.Context, report cciptypes.Commi
if update.Price.IsEmpty() {
return nil, fmt.Errorf("empty price for token: %s", update.TokenID)
}
tpu = append(tpu, ccip_router.TokenPriceUpdate{
tpu = append(tpu, ccip_offramp.TokenPriceUpdate{
SourceToken: token,
UsdPerToken: [28]uint8(encodeBigIntToFixedLengthLE(update.Price.Int, 28)),
})
}

gpu := make([]ccip_router.GasPriceUpdate, 0, len(report.PriceUpdates.GasPriceUpdates))
gpu := make([]ccip_offramp.GasPriceUpdate, 0, len(report.PriceUpdates.GasPriceUpdates))
for _, update := range report.PriceUpdates.GasPriceUpdates {
if update.GasPrice.IsEmpty() {
return nil, fmt.Errorf("empty gas price for chain: %d", update.ChainSel)
}

gpu = append(gpu, ccip_router.GasPriceUpdate{
gpu = append(gpu, ccip_offramp.GasPriceUpdate{
DestChainSelector: uint64(update.ChainSel),
UsdPerUnitGas: [28]uint8(encodeBigIntToFixedLengthLE(update.GasPrice.Int, 28)),
})
}

commit := ccip_router.CommitInput{
commit := ccip_offramp.CommitInput{
MerkleRoot: mr,
PriceUpdates: ccip_router.PriceUpdates{
PriceUpdates: ccip_offramp.PriceUpdates{
TokenPriceUpdates: tpu,
GasPriceUpdates: gpu,
},
Expand All @@ -82,7 +82,7 @@ func (c *CommitPluginCodecV1) Encode(ctx context.Context, report cciptypes.Commi

func (c *CommitPluginCodecV1) Decode(ctx context.Context, bytes []byte) (cciptypes.CommitPluginReport, error) {
decoder := agbinary.NewBorshDecoder(bytes)
commitReport := ccip_router.CommitInput{}
commitReport := ccip_offramp.CommitInput{}
err := commitReport.UnmarshalWithDecoder(decoder)
if err != nil {
return cciptypes.CommitPluginReport{}, err
Expand Down
14 changes: 7 additions & 7 deletions core/capabilities/ccip/ccipsolana/commitcodec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/smartcontractkit/chainlink-ccip/chains/solana/gobindings/ccip_router"
"github.com/smartcontractkit/chainlink-ccip/chains/solana/gobindings/ccip_offramp"

cciptypes "github.com/smartcontractkit/chainlink-ccip/pkg/types/ccipocr3"
"github.com/smartcontractkit/chainlink-integrations/evm/utils"
Expand Down Expand Up @@ -172,28 +172,28 @@ func Test_DecodingCommitReport(t *testing.T) {
gasPrice := encodeBigIntToFixedLengthLE(big.NewInt(rand.Int63()), 28)
merkleRoot := utils.RandomBytes32()

tpu := []ccip_router.TokenPriceUpdate{
tpu := []ccip_offramp.TokenPriceUpdate{
{
SourceToken: tokenSource,
UsdPerToken: [28]uint8(tokenPrice),
},
}

gpu := []ccip_router.GasPriceUpdate{
gpu := []ccip_offramp.GasPriceUpdate{
{UsdPerUnitGas: [28]uint8(gasPrice), DestChainSelector: uint64(chainSel)},
{UsdPerUnitGas: [28]uint8(gasPrice), DestChainSelector: uint64(chainSel)},
{UsdPerUnitGas: [28]uint8(gasPrice), DestChainSelector: uint64(chainSel)},
}

onChainReport := ccip_router.CommitInput{
MerkleRoot: ccip_router.MerkleRoot{
onChainReport := ccip_offramp.CommitInput{
MerkleRoot: ccip_offramp.MerkleRoot{
SourceChainSelector: uint64(chainSel),
OnRampAddress: onRampAddr.PublicKey().Bytes(),
MinSeqNr: minSeqNr,
MaxSeqNr: maxSeqNr,
MerkleRoot: merkleRoot,
},
PriceUpdates: ccip_router.PriceUpdates{
PriceUpdates: ccip_offramp.PriceUpdates{
TokenPriceUpdates: tpu,
GasPriceUpdates: gpu,
},
Expand Down Expand Up @@ -233,7 +233,7 @@ func Test_DecodingCommitReport(t *testing.T) {
require.NoError(t, err)

decoder := agbinary.NewBorshDecoder(decode)
decodedReport := ccip_router.CommitInput{}
decodedReport := ccip_offramp.CommitInput{}
err = decodedReport.UnmarshalWithDecoder(decoder)
require.NoError(t, err)

Expand Down
20 changes: 10 additions & 10 deletions core/capabilities/ccip/ccipsolana/executecodec.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
agbinary "github.com/gagliardetto/binary"
"github.com/gagliardetto/solana-go"

"github.com/smartcontractkit/chainlink-ccip/chains/solana/gobindings/ccip_router"
"github.com/smartcontractkit/chainlink-ccip/chains/solana/gobindings/ccip_offramp"
cciptypes "github.com/smartcontractkit/chainlink-ccip/pkg/types/ccipocr3"
)

Expand All @@ -35,12 +35,12 @@ func (e *ExecutePluginCodecV1) Encode(ctx context.Context, report cciptypes.Exec
return nil, fmt.Errorf("unexpected report message length: %d", len(chainReport.Messages))
}

var message ccip_router.Any2SVMRampMessage
var message ccip_offramp.Any2SVMRampMessage
var offChainTokenData [][]byte
if len(chainReport.Messages) > 0 {
// currently only allow executing one message at a time
msg := chainReport.Messages[0]
tokenAmounts := make([]ccip_router.Any2SVMTokenTransfer, 0, len(msg.TokenAmounts))
tokenAmounts := make([]ccip_offramp.Any2SVMTokenTransfer, 0, len(msg.TokenAmounts))
for _, tokenAmount := range msg.TokenAmounts {
if tokenAmount.Amount.IsEmpty() {
return nil, fmt.Errorf("empty amount for token: %s", tokenAmount.DestTokenAddress)
Expand All @@ -55,16 +55,16 @@ func (e *ExecutePluginCodecV1) Encode(ctx context.Context, report cciptypes.Exec
return nil, err
}

tokenAmounts = append(tokenAmounts, ccip_router.Any2SVMTokenTransfer{
tokenAmounts = append(tokenAmounts, ccip_offramp.Any2SVMTokenTransfer{
SourcePoolAddress: tokenAmount.SourcePoolAddress,
DestTokenAddress: solana.PublicKeyFromBytes(tokenAmount.DestTokenAddress),
ExtraData: tokenAmount.ExtraData,
Amount: ccip_router.CrossChainAmount{LeBytes: [32]uint8(encodeBigIntToFixedLengthLE(tokenAmount.Amount.Int, 32))},
Amount: ccip_offramp.CrossChainAmount{LeBytes: [32]uint8(encodeBigIntToFixedLengthLE(tokenAmount.Amount.Int, 32))},
DestGasAmount: destGasAmount,
})
}

var extraArgs ccip_router.Any2SVMRampExtraArgs
var extraArgs ccip_offramp.Any2SVMRampExtraArgs
extraArgs, _, err := parseExtraArgsMapWithAccounts(msg.ExtraArgsDecoded)
if err != nil {
return nil, fmt.Errorf("invalid extra args map: %w", err)
Expand All @@ -74,8 +74,8 @@ func (e *ExecutePluginCodecV1) Encode(ctx context.Context, report cciptypes.Exec
return nil, fmt.Errorf("invalid receiver address: %v", msg.Receiver)
}

message = ccip_router.Any2SVMRampMessage{
Header: ccip_router.RampMessageHeader{
message = ccip_offramp.Any2SVMRampMessage{
Header: ccip_offramp.RampMessageHeader{
MessageId: msg.Header.MessageID,
SourceChainSelector: uint64(msg.Header.SourceChainSelector),
DestChainSelector: uint64(msg.Header.DestChainSelector),
Expand All @@ -100,7 +100,7 @@ func (e *ExecutePluginCodecV1) Encode(ctx context.Context, report cciptypes.Exec
solanaProofs = append(solanaProofs, proof)
}

solanaReport := ccip_router.ExecutionReportSingleChain{
solanaReport := ccip_offramp.ExecutionReportSingleChain{
SourceChainSelector: uint64(chainReport.SourceChainSelector),
Message: message,
OffchainTokenData: offChainTokenData,
Expand All @@ -119,7 +119,7 @@ func (e *ExecutePluginCodecV1) Encode(ctx context.Context, report cciptypes.Exec

func (e *ExecutePluginCodecV1) Decode(ctx context.Context, encodedReport []byte) (cciptypes.ExecutePluginReport, error) {
decoder := agbinary.NewBorshDecoder(encodedReport)
executeReport := ccip_router.ExecutionReportSingleChain{}
executeReport := ccip_offramp.ExecutionReportSingleChain{}
err := executeReport.UnmarshalWithDecoder(decoder)
if err != nil {
return cciptypes.ExecutePluginReport{}, fmt.Errorf("unpack encoded report: %w", err)
Expand Down
18 changes: 9 additions & 9 deletions core/capabilities/ccip/ccipsolana/executecodec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
agbinary "github.com/gagliardetto/binary"
solanago "github.com/gagliardetto/solana-go"

"github.com/smartcontractkit/chainlink-ccip/chains/solana/gobindings/ccip_router"
"github.com/smartcontractkit/chainlink-ccip/chains/solana/gobindings/ccip_offramp"

cciptypes "github.com/smartcontractkit/chainlink-ccip/pkg/types/ccipocr3"
"github.com/smartcontractkit/chainlink-integrations/evm/utils"
Expand Down Expand Up @@ -54,7 +54,7 @@ var randomExecuteReport = func(t *testing.T, sourceChainSelector uint64) cciptyp
}
}

extraArgs := ccip_router.Any2SVMRampExtraArgs{
extraArgs := ccip_offramp.Any2SVMRampExtraArgs{
ComputeUnits: 1000,
IsWritableBitmap: 2,
}
Expand Down Expand Up @@ -189,22 +189,22 @@ func Test_DecodingExecuteReport(t *testing.T) {
destGasAmount := uint32(10)
tokenAmount := big.NewInt(rand.Int63())
tokenReceiver := solanago.MustPublicKeyFromBase58("C8WSPj3yyus1YN3yNB6YA5zStYtbjQWtpmKadmvyUXq8")
extraArgs := ccip_router.Any2SVMRampExtraArgs{
extraArgs := ccip_offramp.Any2SVMRampExtraArgs{
ComputeUnits: 1000,
IsWritableBitmap: 2,
}

onChainReport := ccip_router.ExecutionReportSingleChain{
onChainReport := ccip_offramp.ExecutionReportSingleChain{
SourceChainSelector: uint64(chainSel),
Message: ccip_router.Any2SVMRampMessage{
Header: ccip_router.RampMessageHeader{
Message: ccip_offramp.Any2SVMRampMessage{
Header: ccip_offramp.RampMessageHeader{
SourceChainSelector: uint64(chainSel),
},
TokenReceiver: tokenReceiver,
ExtraArgs: extraArgs,
TokenAmounts: []ccip_router.Any2SVMTokenTransfer{
TokenAmounts: []ccip_offramp.Any2SVMTokenTransfer{
{
Amount: ccip_router.CrossChainAmount{LeBytes: [32]uint8(encodeBigIntToFixedLengthLE(tokenAmount, 32))},
Amount: ccip_offramp.CrossChainAmount{LeBytes: [32]uint8(encodeBigIntToFixedLengthLE(tokenAmount, 32))},
DestGasAmount: destGasAmount,
},
},
Expand Down Expand Up @@ -243,7 +243,7 @@ func Test_DecodingExecuteReport(t *testing.T) {
require.NoError(t, err)

decoder := agbinary.NewBorshDecoder(encodedReport)
executeReport := ccip_router.ExecutionReportSingleChain{}
executeReport := ccip_offramp.ExecutionReportSingleChain{}
err = executeReport.UnmarshalWithDecoder(decoder)
require.NoError(t, err)

Expand Down
6 changes: 3 additions & 3 deletions core/capabilities/ccip/ccipsolana/extradatadecoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/ethereum/go-ethereum/common/hexutil"
agbinary "github.com/gagliardetto/binary"

"github.com/smartcontractkit/chainlink-ccip/chains/solana/gobindings/ccip_router"
"github.com/smartcontractkit/chainlink-ccip/chains/solana/gobindings/fee_quoter"
)

const (
Expand Down Expand Up @@ -37,7 +37,7 @@ func DecodeExtraArgsToMap(extraArgs []byte) (map[string]any, error) {
outputMap := make(map[string]any)
switch string(extraArgs[:4]) {
case string(evmExtraArgsV2Tag):
var args ccip_router.EVMExtraArgsV2
var args fee_quoter.EVMExtraArgsV2
decoder := agbinary.NewBorshDecoder(extraArgs[4:])
err := args.UnmarshalWithDecoder(decoder)
if err != nil {
Expand All @@ -46,7 +46,7 @@ func DecodeExtraArgsToMap(extraArgs []byte) (map[string]any, error) {
val = reflect.ValueOf(args)
typ = reflect.TypeOf(args)
case string(svmExtraArgsV1Tag):
var args ccip_router.SVMExtraArgsV1
var args fee_quoter.SVMExtraArgsV1
decoder := agbinary.NewBorshDecoder(extraArgs[4:])
err := args.UnmarshalWithDecoder(decoder)
if err != nil {
Expand Down
6 changes: 3 additions & 3 deletions core/capabilities/ccip/ccipsolana/extradatadecoder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (

"github.com/smartcontractkit/chainlink-ccip/chains/solana/contracts/tests/config"

"github.com/smartcontractkit/chainlink-ccip/chains/solana/gobindings/ccip_router"
"github.com/smartcontractkit/chainlink-ccip/chains/solana/gobindings/fee_quoter"
)

func Test_decodeExtraArgs(t *testing.T) {
Expand All @@ -30,7 +30,7 @@ func Test_decodeExtraArgs(t *testing.T) {
t.Run("decode extra args into map svm", func(t *testing.T) {
destGasAmount := uint32(10000)
bitmap := uint64(0)
extraArgs := ccip_router.SVMExtraArgsV1{
extraArgs := fee_quoter.SVMExtraArgsV1{
ComputeUnits: destGasAmount,
AccountIsWritableBitmap: bitmap,
AllowOutOfOrderExecution: false,
Expand Down Expand Up @@ -64,7 +64,7 @@ func Test_decodeExtraArgs(t *testing.T) {
})

t.Run("decode extra args into map evm", func(t *testing.T) {
extraArgs := ccip_router.EVMExtraArgsV2{
extraArgs := fee_quoter.EVMExtraArgsV2{
GasLimit: agbinary.Uint128{Lo: 5000, Hi: 0},
AllowOutOfOrderExecution: false,
}
Expand Down
14 changes: 7 additions & 7 deletions core/capabilities/ccip/ccipsolana/msghasher.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

"github.com/gagliardetto/solana-go"

"github.com/smartcontractkit/chainlink-ccip/chains/solana/gobindings/ccip_router"
"github.com/smartcontractkit/chainlink-ccip/chains/solana/gobindings/ccip_offramp"
"github.com/smartcontractkit/chainlink-ccip/chains/solana/utils/ccip"
"github.com/smartcontractkit/chainlink-ccip/chains/solana/utils/tokens"
"github.com/smartcontractkit/chainlink-common/pkg/logger"
Expand All @@ -33,8 +33,8 @@ func NewMessageHasherV1(lggr logger.Logger) *MessageHasherV1 {
func (h *MessageHasherV1) Hash(_ context.Context, msg cciptypes.Message) (cciptypes.Bytes32, error) {
h.lggr.Debugw("hashing message", "msg", msg)

anyToSolanaMessage := ccip_router.Any2SVMRampMessage{}
anyToSolanaMessage.Header = ccip_router.RampMessageHeader{
anyToSolanaMessage := ccip_offramp.Any2SVMRampMessage{}
anyToSolanaMessage.Header = ccip_offramp.RampMessageHeader{
SourceChainSelector: uint64(msg.Header.SourceChainSelector),
DestChainSelector: uint64(msg.Header.DestChainSelector),
SequenceNumber: uint64(msg.Header.SequenceNumber),
Expand All @@ -50,12 +50,12 @@ func (h *MessageHasherV1) Hash(_ context.Context, msg cciptypes.Message) (ccipty
return [32]byte{}, err
}

anyToSolanaMessage.TokenAmounts = append(anyToSolanaMessage.TokenAmounts, ccip_router.Any2SVMTokenTransfer{
anyToSolanaMessage.TokenAmounts = append(anyToSolanaMessage.TokenAmounts, ccip_offramp.Any2SVMTokenTransfer{
SourcePoolAddress: ta.SourcePoolAddress,
DestTokenAddress: solana.PublicKeyFromBytes(ta.DestTokenAddress),
ExtraData: ta.ExtraData,
DestGasAmount: destGasAmount,
Amount: ccip_router.CrossChainAmount{LeBytes: tokens.ToLittleEndianU256(ta.Amount.Int.Uint64())},
Amount: ccip_offramp.CrossChainAmount{LeBytes: tokens.ToLittleEndianU256(ta.Amount.Int.Uint64())},
})
}

Expand All @@ -70,9 +70,9 @@ func (h *MessageHasherV1) Hash(_ context.Context, msg cciptypes.Message) (ccipty
return [32]byte(hash), err
}

func parseExtraArgsMapWithAccounts(input map[string]any) (ccip_router.Any2SVMRampExtraArgs, []solana.PublicKey, error) {
func parseExtraArgsMapWithAccounts(input map[string]any) (ccip_offramp.Any2SVMRampExtraArgs, []solana.PublicKey, error) {
// Parse input map into SolanaExtraArgs
var out ccip_router.Any2SVMRampExtraArgs
var out ccip_offramp.Any2SVMRampExtraArgs
var accounts []solana.PublicKey

// Iterate through the expected fields in the struct
Expand Down
Loading

0 comments on commit 461d94a

Please sign in to comment.