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

Updates to deploy CCIP Solana to staging #16160

Closed
wants to merge 13 commits into from
16 changes: 8 additions & 8 deletions deployment/ccip/changeset/cs_update_rmn_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func SetRMNRemoteOnRMNProxyChangeset(e deployment.Environment, cfg SetRMNRemoteO
for _, sel := range cfg.ChainSelectors {
chain, exists := e.Chains[sel]
if !exists {
return deployment.ChangesetOutput{}, fmt.Errorf("chain %d not found", sel)
return deployment.ChangesetOutput{}, fmt.Errorf("chain %d not found1", sel)
}
txOpts := chain.DeployerKey
if cfg.MCMSConfig != nil {
Expand Down Expand Up @@ -212,7 +212,7 @@ func (c SetRMNHomeCandidateConfig) Validate(state CCIPOnChainState) error {

homeChain, ok := state.Chains[c.HomeChainSelector]
if !ok {
return fmt.Errorf("chain %d not found", c.HomeChainSelector)
return fmt.Errorf("chain %d not found2", c.HomeChainSelector)
}

rmnHome := homeChain.RMNHome
Expand Down Expand Up @@ -291,7 +291,7 @@ func (c PromoteRMNHomeCandidateConfig) Validate(state CCIPOnChainState) error {
homeChain, ok := state.Chains[c.HomeChainSelector]

if !ok {
return fmt.Errorf("chain %d not found", c.HomeChainSelector)
return fmt.Errorf("chain %d not found3", c.HomeChainSelector)
}

rmnHome := homeChain.RMNHome
Expand Down Expand Up @@ -329,7 +329,7 @@ func SetRMNHomeCandidateConfigChangeset(e deployment.Environment, config SetRMNH

homeChain, ok := e.Chains[config.HomeChainSelector]
if !ok {
return deployment.ChangesetOutput{}, fmt.Errorf("chain %d not found", config.HomeChainSelector)
return deployment.ChangesetOutput{}, fmt.Errorf("chain %d not found4", config.HomeChainSelector)
}

rmnHome := state.Chains[config.HomeChainSelector].RMNHome
Expand Down Expand Up @@ -402,7 +402,7 @@ func PromoteRMNHomeCandidateConfigChangeset(e deployment.Environment, config Pro
homeChain, ok := e.Chains[config.HomeChainSelector]

if !ok {
return deployment.ChangesetOutput{}, fmt.Errorf("chain %d not found", config.HomeChainSelector)
return deployment.ChangesetOutput{}, fmt.Errorf("chain %d not found5", config.HomeChainSelector)
}

rmnHome := state.Chains[config.HomeChainSelector].RMNHome
Expand Down Expand Up @@ -569,7 +569,7 @@ func SetRMNHomeDynamicConfigChangeset(e deployment.Environment, cfg SetRMNHomeDy

chain, exists := e.Chains[cfg.HomeChainSelector]
if !exists {
return deployment.ChangesetOutput{}, fmt.Errorf("chain %d not found", cfg.HomeChainSelector)
return deployment.ChangesetOutput{}, fmt.Errorf("chain %d not found6", cfg.HomeChainSelector)
}

rmnHome := state.Chains[cfg.HomeChainSelector].RMNHome
Expand Down Expand Up @@ -639,7 +639,7 @@ func RevokeRMNHomeCandidateConfigChangeset(e deployment.Environment, cfg RevokeC

chain, exists := e.Chains[cfg.HomeChainSelector]
if !exists {
return deployment.ChangesetOutput{}, fmt.Errorf("chain %d not found", cfg.HomeChainSelector)
return deployment.ChangesetOutput{}, fmt.Errorf("chain %d not found7", cfg.HomeChainSelector)
}

rmnHome := state.Chains[cfg.HomeChainSelector].RMNHome
Expand Down Expand Up @@ -676,7 +676,7 @@ func SetRMNRemoteConfigChangeset(e deployment.Environment, config SetRMNRemoteCo
homeChain, ok := e.Chains[config.HomeChainSelector]

if !ok {
return deployment.ChangesetOutput{}, fmt.Errorf("chain %d not found", config.HomeChainSelector)
return deployment.ChangesetOutput{}, fmt.Errorf("chain %d not found8", config.HomeChainSelector)
}

rmnHome := state.Chains[config.HomeChainSelector].RMNHome
Expand Down
4 changes: 2 additions & 2 deletions deployment/ccip/changeset/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ func (s CCIPOnChainState) GetAllProposerMCMSForChains(chains []uint64) (map[uint
for _, chain := range chains {
chainState, ok := s.Chains[chain]
if !ok {
return nil, fmt.Errorf("chain %d not found", chain)
return nil, fmt.Errorf("chain %d not found9", chain)
}
if chainState.ProposerMcm == nil {
return nil, fmt.Errorf("proposer mcm not found for chain %d", chain)
Expand All @@ -371,7 +371,7 @@ func (s CCIPOnChainState) GetAllTimeLocksForChains(chains []uint64) (map[uint64]
for _, chain := range chains {
chainState, ok := s.Chains[chain]
if !ok {
return nil, fmt.Errorf("chain %d not found", chain)
return nil, fmt.Errorf("chain %d not found10", chain)
}
if chainState.Timelock == nil {
return nil, fmt.Errorf("timelock not found for chain %d", chain)
Expand Down
25 changes: 13 additions & 12 deletions deployment/environment/memory/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,10 @@ func getTestSolanaChainSelectors() []uint64 {
return result
}

func generateSolanaKeypair(t testing.TB) (solana.PrivateKey, string, error) {
// Create a temporary directory that will be cleaned up after the test
tmpDir := t.TempDir()

func GenerateSolanaKeypair(dir string) (solana.PrivateKey, error) {
privateKey, err := solana.NewRandomPrivateKey()
if err != nil {
return solana.PrivateKey{}, "", fmt.Errorf("failed to generate private key: %w", err)
return solana.PrivateKey{}, fmt.Errorf("failed to generate private key: %w", err)
}

// Convert private key bytes to JSON array
Expand All @@ -107,27 +104,31 @@ func generateSolanaKeypair(t testing.TB) (solana.PrivateKey, string, error) {

keypairJSON, err := json.Marshal(intArray)
if err != nil {
return solana.PrivateKey{}, "", fmt.Errorf("failed to marshal keypair: %w", err)
return solana.PrivateKey{}, fmt.Errorf("failed to marshal keypair: %w", err)
}

// Create the keypair file in the temporary directory
keypairPath := filepath.Join(tmpDir, "solana-keypair.json")
// Create the keypair file in the directory
keypairPath := filepath.Join(dir, "solana-keypair.json")
if err := os.WriteFile(keypairPath, keypairJSON, 0600); err != nil {
return solana.PrivateKey{}, "", fmt.Errorf("failed to write keypair to file: %w", err)
return solana.PrivateKey{}, fmt.Errorf("failed to write keypair to file: %w", err)
}

return privateKey, keypairPath, nil
return privateKey, nil
}

func GenerateChainsSol(t *testing.T, numChains int) map[uint64]SolanaChain {
testSolanaChainSelectors := getTestSolanaChainSelectors()
if len(testSolanaChainSelectors) < numChains {
t.Fatalf("not enough test solana chain selectors available")
}

// Create a temporary directory that will be cleaned up after the test
tmpDir := t.TempDir()

chains := make(map[uint64]SolanaChain)
for i := 0; i < numChains; i++ {
chainID := testSolanaChainSelectors[i]
admin, keypairPath, err := generateSolanaKeypair(t)
admin, err := GenerateSolanaKeypair(tmpDir)
require.NoError(t, err)
url, wsURL, err := solChain(t, chainID, &admin)
require.NoError(t, err)
Expand All @@ -140,7 +141,7 @@ func GenerateChainsSol(t *testing.T, numChains int) map[uint64]SolanaChain {
DeployerKey: admin,
URL: url,
WSURL: wsURL,
KeypairPath: keypairPath,
KeypairPath: tmpDir,
}
}
return chains
Expand Down
55 changes: 30 additions & 25 deletions deployment/environment/memory/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (

solRpc "github.com/gagliardetto/solana-go/rpc"

solCommonUtil "github.com/smartcontractkit/chainlink-ccip/chains/solana/utils/common"
"github.com/smartcontractkit/chainlink-common/pkg/logger"
)

Expand Down Expand Up @@ -82,7 +81,36 @@ func NewMemoryChains(t *testing.T, numChains int, numUsers int) (map[uint64]depl

func NewMemoryChainsSol(t *testing.T, numChains int) map[uint64]deployment.SolChain {
mchains := GenerateChainsSol(t, numChains)
return generateMemoryChainSol(mchains)

chains := make(map[uint64]deployment.SolChain)

for cid, chainConfig := range mchains {
chains[cid] = deployment.SolChain{
Selector: cid,
Client: chainConfig.Client,
DeployerKey: &chainConfig.DeployerKey,
URL: chainConfig.URL,
WSURL: chainConfig.WSURL,
KeypairPath: chainConfig.KeypairPath,
ProgramsPath: ProgramsPath,
Confirm: func(instructions []solana.Instruction, opts ...solCommomUtil.TxModifier) error {
_, err := solCommomUtil.SendAndConfirm(
context.Background(),
chainConfig.Client,
instructions,
chainConfig.DeployerKey,
solRpc.CommitmentConfirmed,
opts...,
)
if err != nil {
return err
}
return nil
},
}
}

return chains
}

func NewMemoryChainsWithChainIDs(t *testing.T, chainIDs []uint64, numUsers int) (map[uint64]deployment.Chain, map[uint64][]*bind.TransactOpts) {
Expand Down Expand Up @@ -137,29 +165,6 @@ func generateMemoryChain(t *testing.T, inputs map[uint64]EVMChain) map[uint64]de
return chains
}

func generateMemoryChainSol(inputs map[uint64]SolanaChain) map[uint64]deployment.SolChain {
chains := make(map[uint64]deployment.SolChain)
for cid, chain := range inputs {
chain := chain
chains[cid] = deployment.SolChain{
Selector: cid,
Client: chain.Client,
DeployerKey: &chain.DeployerKey,
URL: chain.URL,
WSURL: chain.WSURL,
KeypairPath: chain.KeypairPath,
ProgramsPath: ProgramsPath,
Confirm: func(instructions []solana.Instruction, opts ...solCommonUtil.TxModifier) error {
_, err := solCommonUtil.SendAndConfirm(
context.Background(), chain.Client, instructions, chain.DeployerKey, solRpc.CommitmentConfirmed, opts...,
)
return err
},
}
}
return chains
}

func NewNodes(t *testing.T, logLevel zapcore.Level, chains map[uint64]deployment.Chain, solChains map[uint64]deployment.SolChain, numNodes, numBootstraps int, registryConfig deployment.CapabilityRegistryConfig) map[string]Node {
nodesByPeerID := make(map[string]Node)
if numNodes+numBootstraps == 0 {
Expand Down
2 changes: 1 addition & 1 deletion deployment/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ require (
github.com/rs/zerolog v1.33.0
github.com/sethvargo/go-retry v0.2.4
github.com/smartcontractkit/ccip-owner-contracts v0.0.0-salt-fix
github.com/smartcontractkit/chain-selectors v1.0.37
github.com/smartcontractkit/chain-selectors v1.0.39
github.com/smartcontractkit/chainlink-ccip v0.0.0-20250130101703-5ba045c38d49
github.com/smartcontractkit/chainlink-ccip/chains/solana v0.0.0-20250103152858-8973fd0c912b
github.com/smartcontractkit/chainlink-common v0.4.2-0.20250130104613-82e554262f7d
Expand Down
4 changes: 2 additions & 2 deletions deployment/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1390,8 +1390,8 @@ github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
github.com/smartcontractkit/ccip-owner-contracts v0.0.0-salt-fix h1:DPJD++yKLSx0EfT+U14P8vLVxjXFmoIETiCO9lVwQo8=
github.com/smartcontractkit/ccip-owner-contracts v0.0.0-salt-fix/go.mod h1:NnT6w4Kj42OFFXhSx99LvJZWPpMjmo4+CpDEWfw61xY=
github.com/smartcontractkit/chain-selectors v1.0.37 h1:EKVl8wayhOVfnlqfVmEyZ8rXOsnihthONvOPfEOfvbI=
github.com/smartcontractkit/chain-selectors v1.0.37/go.mod h1:xsKM0aN3YGcQKTPRPDDtPx2l4mlTN1Djmg0VVXV40b8=
github.com/smartcontractkit/chain-selectors v1.0.39 h1:4lOqUNKmWDZcE7lWEEpV9Il22ltIeyTZZR+J1uKILxw=
github.com/smartcontractkit/chain-selectors v1.0.39/go.mod h1:xsKM0aN3YGcQKTPRPDDtPx2l4mlTN1Djmg0VVXV40b8=
github.com/smartcontractkit/chainlink-automation v0.8.1 h1:sTc9LKpBvcKPc1JDYAmgBc2xpDKBco/Q4h4ydl6+UUU=
github.com/smartcontractkit/chainlink-automation v0.8.1/go.mod h1:Iij36PvWZ6blrdC5A/nrQUBuf3MH3JvsBB9sSyc9W08=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20250130101703-5ba045c38d49 h1:Y9mC8DCJQUjU7IwGi0FVsH2Q8ujv9Na8DLq1StsGbso=
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ require (
github.com/scylladb/go-reflectx v1.0.1
github.com/shirou/gopsutil/v3 v3.24.3
github.com/shopspring/decimal v1.4.0
github.com/smartcontractkit/chain-selectors v1.0.37
github.com/smartcontractkit/chain-selectors v1.0.39
github.com/smartcontractkit/chainlink-automation v0.8.1
github.com/smartcontractkit/chainlink-ccip v0.0.0-20250130101703-5ba045c38d49
github.com/smartcontractkit/chainlink-common v0.4.2-0.20250130104613-82e554262f7d
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1150,8 +1150,8 @@ github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6Mwd
github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
github.com/smartcontractkit/chain-selectors v1.0.37 h1:EKVl8wayhOVfnlqfVmEyZ8rXOsnihthONvOPfEOfvbI=
github.com/smartcontractkit/chain-selectors v1.0.37/go.mod h1:xsKM0aN3YGcQKTPRPDDtPx2l4mlTN1Djmg0VVXV40b8=
github.com/smartcontractkit/chain-selectors v1.0.39 h1:4lOqUNKmWDZcE7lWEEpV9Il22ltIeyTZZR+J1uKILxw=
github.com/smartcontractkit/chain-selectors v1.0.39/go.mod h1:xsKM0aN3YGcQKTPRPDDtPx2l4mlTN1Djmg0VVXV40b8=
github.com/smartcontractkit/chainlink-automation v0.8.1 h1:sTc9LKpBvcKPc1JDYAmgBc2xpDKBco/Q4h4ydl6+UUU=
github.com/smartcontractkit/chainlink-automation v0.8.1/go.mod h1:Iij36PvWZ6blrdC5A/nrQUBuf3MH3JvsBB9sSyc9W08=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20250130101703-5ba045c38d49 h1:Y9mC8DCJQUjU7IwGi0FVsH2Q8ujv9Na8DLq1StsGbso=
Expand Down