Skip to content
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

solana ccip contract split #16159

Merged
merged 46 commits into from
Feb 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
ceaadeb
clean commit history
tt-cll Feb 3, 2025
b0a07ae
Merge remote-tracking branch 'origin/develop' into deploy-transferabl…
tt-cll Feb 3, 2025
1f54d12
merging
yashnevatia Feb 4, 2025
71b1083
adding test for setpool and pool lookuptable
yashnevatia Feb 4, 2025
38792b7
fee quoter changes barring tests
yashnevatia Feb 5, 2025
f405018
fixing after fee quoter
yashnevatia Jan 14, 2025
dc19cdc
updating receiver
yashnevatia Feb 5, 2025
b39d51d
bug fixes
yashnevatia Feb 6, 2025
5c07022
go mods
yashnevatia Feb 6, 2025
37a1af3
logs
yashnevatia Feb 6, 2025
3a0dd90
bug fix
yashnevatia Feb 6, 2025
280c6f5
offramp changes
yashnevatia Feb 6, 2025
461d94a
Bump chainlink-solana
archseer Feb 7, 2025
b8428ac
Merge remote-tracking branch 'origin/develop' into deploy-transferabl…
tt-cll Feb 7, 2025
f461167
merging with bump-chainlink-solana
yashnevatia Feb 7, 2025
cb9fe10
merging
yashnevatia Feb 7, 2025
db0f8bf
bug fix
yashnevatia Feb 7, 2025
8f470d5
linting
yashnevatia Feb 7, 2025
201402a
bug fix
yashnevatia Feb 7, 2025
e6a2fb5
Revert "solana tooling dev"
tt-cll Feb 7, 2025
26de28b
Merge remote-tracking branch 'origin/develop' into deploy-transferabl…
tt-cll Feb 7, 2025
684a9dc
revert smoke
tt-cll Feb 7, 2025
2007899
fix tests
tt-cll Feb 7, 2025
18267f4
lint
tt-cll Feb 7, 2025
8cca8ef
change address table init
tt-cll Feb 7, 2025
95d877d
fix tests
tt-cll Feb 7, 2025
148ff22
pass offramp in CCIP home
tt-cll Feb 7, 2025
d0040f9
Merge branch 'deploy-transferable-solana' of github.com:smartcontract…
yashnevatia Feb 8, 2025
9b311a5
Merge remote-tracking branch 'origin/develop' into deploy-transferabl…
tt-cll Feb 8, 2025
a0312a4
rename addresslookup to offrampaddresslookup
yashnevatia Feb 8, 2025
1a26763
Merge branch 'deploy-transferable-solana' of github.com:smartcontract…
yashnevatia Feb 8, 2025
5fdc155
semantics
yashnevatia Feb 8, 2025
93ca26f
file split and extending lookup table
yashnevatia Feb 8, 2025
d77b530
append pool instruction
yashnevatia Feb 8, 2025
c2cf9ca
fix chainlink_models_test.go
archseer Feb 10, 2025
76a1803
fix lint
archseer Feb 10, 2025
7f82d87
Fix more tests
archseer Feb 10, 2025
4a578e3
remove prints
tt-cll Feb 10, 2025
d96978e
remove deploy transferable
tt-cll Feb 10, 2025
4e4ca64
bug fix
yashnevatia Feb 10, 2025
849eec2
const
yashnevatia Feb 10, 2025
5727ff9
lint
tt-cll Feb 10, 2025
a2a324a
rename func
yashnevatia Feb 10, 2025
1822ce1
Merge branch 'deploy-transferable-solana' of github.com:smartcontract…
yashnevatia Feb 10, 2025
aa23442
lint
tt-cll Feb 10, 2025
8b105b5
Merge remote-tracking branch 'origin/develop' into deploy-transferabl…
tt-cll Feb 10, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading