Skip to content

Commit

Permalink
Changesets for solana tokenPool, billing, registry (#16088)
Browse files Browse the repository at this point in the history
* Adding solchains in NewEnv

* Revert "Adding solchains in NewEnv"

This reverts commit aaab52e.

* adding sol chains to newenv

* newEnv needs to send nil

* adding test env setup

* adding link token deployment and test

* adding nil for crib sol chains

* using switch case

* Adding decimal const

* adding chain selectors commit

* go mod tidy

* adding initial code for solana chain contracts deploy

* linting

* adding solana state

* adding initial code for solana chain contracts deploy

* wip

* chain sel update

* update core/scripts go files

* again

* add changeset

* go imports

* go mod

* go mod

* go mod tidy

* todo

* deploy stuff

* Adding solana router deploy

* Adding

* updates

* adding stuff for tests

* linting

* linting

* changing to ctf

* bug

* Add CI Action to build Solana contracts

* testing stuff

* continue testing

* Update action.yml

* Update action.yml

* Update action.yml

* Update action.yml

* Update action.yml

* Update action.yml

* Update action.yml

* Update action.yml

* deployment: memory: Generate more transmitter key types, expose in JD

* deployment: memory: Configure nodes with solana config too

* Use CTF to spin up the solana validator for in-memory tests

* Use autopatchelf on solana binaries to make them usable on NixOS

* memory: solana: Shut down the container when test terminates

* go mod tidy

* Use latest upstream CTF

* Add missing import

* make modgraph

* Use framework.DefaultNetwork()

* changes

* tidying

* ignoring keypair if not provided

* fix

* adding solchains to newnodes

* adding home chain changes

* delegate changes

* Update action.yml

* Update action.yml

* Update action.yml

* Update action.yml

* Update action.yml

* Update action.yml

* test integrating with CI build step

* working tests

* bump ccip

* test fix

* save existing solana + tests

* try reading program ids

* Update action.yml

* Update action.yml

* Update action.yml

* Update action.yml

* Update chain.go

* Update action.yml

* last try

* Update action.yml

* Update action.yml

* make script executable

* reverting changes to stabilize the branch

* Create ccip_router.so

* go mod tidy

* sol chains param

* linting

* adding build here

* try without parallel

* yash fixed it!

* function signature

* Update chain.go

* parallel

* try defer

* retries

* still linting

* Revert "retries"

This reverts commit f9f5fd2.

* revert

* lint

* gomod

* remove cleanup

* fix deps

* try empty map

* Revert "yash fixed it!"

This reverts commit ff35f21.

* remove token info changes

* revert function call

* revert

* go mod tidy

* no return

* try retries

* try returning again

* use CI artifact

* try without ctf bump

* CR comments

* lint

* add global lookup table

* call utils

* adding token pool deploy

* test commit

* adding solana token stufF

* adding token pool so

* add retries

* fix token test

* setup token pool last

* match lookup table from tests

* lint

* revert token pool uncomment

* skip early return

* remove retries

* add ccip receiver to helpers

* initial token admin registry

* billing

* adding billing stuff

* cr comments

* fix home chain

* test fix

* run receiver in CI

* skip receiver again

* change set program id

* addLane for solana

* clean up supported chain checks

* using AddLane for evm to sol

* make it one operation

* adding router account check for router init (solana)

* adding default commitment to solana_chain

* Adding support for solana in validateRemoteChain

* Adding test TestUpdateOnRampsDestsSolana

* move to switch

* Revmoing solana from UpdateOnRampsDests

* adding separate solana AddRemoteChainToSolana

* moving to changeset_solana

* Reuse GetAccountDataBorshInto

* validation comment

* update test helpers based on AddRemoteChainOnSolana

* AddRemoteChainOnSolana test update

* uncommenting test but this will break

* validation comment

* remove token pools; consolidate home chain

* Revert "test commit"

This reverts commit 2f315cd.

* lint

* cleanup

* cleanup

* cr comments

* cr comments

* reverting UpdateOnRampDestsConfig

* bumping chainlink-ccip

* use common PDA functions

* tokenSymbol

* solana tooling dev

* adding back token pool deploy and converting token state to list

* Adding token stuff

* Revert "cleanup"

This reverts commit 7388c49.

* delete artifacts again

* adding logic for add token pool

* Adding wsol

* adding SetupTokenPoolForRemoteChain

* adding changesets

* move solana logic

* lint

* lint

* gomodtidy

* move parallel calls

* cr comments

* lint

* adding token pool setup and billing

* merging

* gitignore solana contracts

* lint

* lint

* token admin registry tests

* addressing comments

* fix remote config check

* Revert "solana tooling dev"

This reverts commit 866a1d5.

* linting

* lint

* linting

* error wrapping

---------

Co-authored-by: Terry Tata <[email protected]>
Co-authored-by: jlaveracll <[email protected]>
Co-authored-by: Blaž Hrastnik <[email protected]>
Co-authored-by: tt-cll <[email protected]>
  • Loading branch information
5 people authored Jan 31, 2025
1 parent 638de29 commit 6118cc6
Show file tree
Hide file tree
Showing 19 changed files with 1,297 additions and 356 deletions.
2 changes: 1 addition & 1 deletion core/scripts/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ require (
github.com/smartcontractkit/ccip-owner-contracts v0.0.0-salt-fix // indirect
github.com/smartcontractkit/chain-selectors v1.0.37 // indirect
github.com/smartcontractkit/chainlink-ccip v0.0.0-20250130101703-5ba045c38d49 // indirect
github.com/smartcontractkit/chainlink-ccip/chains/solana v0.0.0-20250103152858-8973fd0c912b // indirect
github.com/smartcontractkit/chainlink-ccip/chains/solana v0.0.0-20250128074412-9b02e505b268 // indirect
github.com/smartcontractkit/chainlink-cosmos v0.5.2-0.20250130125138-3df261e09ddc // indirect
github.com/smartcontractkit/chainlink-feeds v0.1.1 // indirect
github.com/smartcontractkit/chainlink-framework/chains v0.0.0-20250124205858-500edf2db981 // indirect
Expand Down
4 changes: 2 additions & 2 deletions core/scripts/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1331,8 +1331,8 @@ github.com/smartcontractkit/chainlink-automation v0.8.1 h1:sTc9LKpBvcKPc1JDYAmgB
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=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20250130101703-5ba045c38d49/go.mod h1:UEnHaxkUsfreeA7rR45LMmua1Uen95tOFUR8/AI9BAo=
github.com/smartcontractkit/chainlink-ccip/chains/solana v0.0.0-20250103152858-8973fd0c912b h1:UBXi9Yj8YSMHDDaxQLu273x1fWjyEL9xP58nuJsqZfg=
github.com/smartcontractkit/chainlink-ccip/chains/solana v0.0.0-20250103152858-8973fd0c912b/go.mod h1:Bmwq4lNb5tE47sydN0TKetcLEGbgl+VxHEWp4S0LI60=
github.com/smartcontractkit/chainlink-ccip/chains/solana v0.0.0-20250128074412-9b02e505b268 h1:R1fQXQL1AKLfRqZHlbGO0NHN3uZKEkI3r2uBlctwt7k=
github.com/smartcontractkit/chainlink-ccip/chains/solana v0.0.0-20250128074412-9b02e505b268/go.mod h1:Bmwq4lNb5tE47sydN0TKetcLEGbgl+VxHEWp4S0LI60=
github.com/smartcontractkit/chainlink-common v0.4.2-0.20250130104613-82e554262f7d h1:ez+JYyIJ7pUR0/OnnU3AIKaC0Re85qB2fkA1NfiAnuA=
github.com/smartcontractkit/chainlink-common v0.4.2-0.20250130104613-82e554262f7d/go.mod h1:Z2e1ynSJ4pg83b4Qldbmryc5lmnrI3ojOdg1FUloa68=
github.com/smartcontractkit/chainlink-cosmos v0.5.2-0.20250130125138-3df261e09ddc h1:WZERXv2hTYRA0NpWg79ci/ZZSxucmvkty39iUOV8d7I=
Expand Down
82 changes: 59 additions & 23 deletions deployment/ccip/changeset/cs_deploy_chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
chainsel "github.com/smartcontractkit/chain-selectors"
solRouter "github.com/smartcontractkit/chainlink-ccip/chains/solana/gobindings/ccip_router"
solCommonUtil "github.com/smartcontractkit/chainlink-ccip/chains/solana/utils/common"
solState "github.com/smartcontractkit/chainlink-ccip/chains/solana/utils/state"

"github.com/smartcontractkit/chainlink/deployment"
"github.com/smartcontractkit/chainlink/deployment/ccip/changeset/internal"
Expand Down Expand Up @@ -558,37 +559,42 @@ func solRouterProgramData(e deployment.Environment, chain deployment.SolChain, c
return programData, nil
}

func initializeRouter(e deployment.Environment, chain deployment.SolChain, ccipRouterProgram solana.PublicKey) error {
func initializeRouter(e deployment.Environment, chain deployment.SolChain, ccipRouterProgram solana.PublicKey, linkTokenAddress solana.PublicKey) error {
programData, err := solRouterProgramData(e, chain, ccipRouterProgram)
if err != nil {
return fmt.Errorf("failed to get solana router program data: %w", err)
}
// addressing errcheck in the next PR
routerConfigPDA, _, _ := solState.FindConfigPDA(ccipRouterProgram)
routerStatePDA, _, _ := solState.FindStatePDA(ccipRouterProgram)
externalExecutionConfigPDA, _, _ := solState.FindExternalExecutionConfigPDA(ccipRouterProgram)
externalTokenPoolsSignerPDA, _, _ := solState.FindExternalTokenPoolsSignerPDA(ccipRouterProgram)

instruction, err := solRouter.NewInitializeInstruction(
chain.Selector, // chain selector
deployment.SolDefaultGasLimit, // default gas limit
true, // allow out of order execution
EnableExecutionAfter, // period to wait before allowing manual execution
solana.PublicKey{}, // fee aggregator
GetRouterConfigPDA(ccipRouterProgram),
GetRouterStatePDA(ccipRouterProgram),
chain.Selector, // chain selector
deployment.SolDefaultGasLimit, // default gas limit
true, // allow out of order execution
EnableExecutionAfter, // period to wait before allowing manual execution
solana.PublicKey{}, // fee aggregator (TODO: changeset to set the fee aggregator)
linkTokenAddress, // link token mint
deployment.SolDefaultMaxFeeJuelsPerMsg, // max fee juels per msg
routerConfigPDA,
routerStatePDA,
chain.DeployerKey.PublicKey(),
solana.SystemProgramID,
ccipRouterProgram,
programData.Address,
GetExternalExecutionConfigPDA(ccipRouterProgram),
GetExternalTokenPoolsSignerPDA(ccipRouterProgram),
externalExecutionConfigPDA,
externalTokenPoolsSignerPDA,
).ValidateAndBuild()

if err != nil {
return fmt.Errorf("failed to build instruction: %w", err)
}

err = chain.Confirm([]solana.Instruction{instruction})
if err != nil {
if err := chain.Confirm([]solana.Instruction{instruction}); err != nil {
return fmt.Errorf("failed to confirm instructions: %w", err)
}

e.Logger.Infow("Initialized router", "chain", chain.String())
return nil
}

Expand All @@ -604,10 +610,11 @@ func deployChainContractsSolana(
}
chainState, chainExists := state.SolChains[chain.Selector]
if !chainExists {
return fmt.Errorf("chain %s not found in existing state, deploy the prerequisites first", chain.String())
return fmt.Errorf("chain %s not found in existing state, deploy the link token first", chain.String())
}
if chainState.LinkToken.IsZero() {
return fmt.Errorf("failed to get link token address for chain %s", chain.String())
}
linkTokenContract := chainState.LinkToken
e.Logger.Infow("link token", "addr", linkTokenContract.String())

// ROUTER DEPLOY AND INITIALIZE
var ccipRouterProgram solana.PublicKey
Expand All @@ -634,17 +641,44 @@ func deployChainContractsSolana(

// check if solana router is initialised
var routerConfigAccount solRouter.Config
err = chain.GetAccountDataBorshInto(e.GetContext(), GetRouterConfigPDA(ccipRouterProgram), &routerConfigAccount)
// addressing errcheck in the next PR
routerConfigPDA, _, _ := solState.FindConfigPDA(ccipRouterProgram)
err = chain.GetAccountDataBorshInto(e.GetContext(), routerConfigPDA, &routerConfigAccount)
if err != nil {
if err2 := initializeRouter(e, chain, ccipRouterProgram); err2 != nil {
if err2 := initializeRouter(e, chain, ccipRouterProgram, chainState.LinkToken); err2 != nil {
return err2
}
} else {
e.Logger.Infow("Router already initialized, skipping initialization", "chain", chain.String())
}

var tokenPoolProgram solana.PublicKey
if chainState.TokenPool.IsZero() {
// TODO: there should be two token pools deployed one of each type (lock/burn)
// separate token pools are not ready yet
programID, err := chain.DeployProgram(e.Logger, "token_pool")
if err != nil {
return fmt.Errorf("failed to deploy program: %w", err)
}
tv := deployment.NewTypeAndVersion(TokenPool, deployment.Version1_0_0)
e.Logger.Infow("Deployed contract", "Contract", tv.String(), "addr", programID, "chain", chain.String())
tokenPoolProgram = solana.MustPublicKeyFromBase58(programID)
err = ab.Save(chain.Selector, programID, tv)
if err != nil {
return fmt.Errorf("failed to save address: %w", err)
}
} else {
e.Logger.Infow("Using existing token pool", "addr", chainState.TokenPool.String())
tokenPoolProgram = chainState.TokenPool
}

// initialize this last with every address we need
if chainState.AddressLookupTable.IsZero() {
// addressing errcheck in the next PR
routerConfigPDA, _, _ := solState.FindConfigPDA(ccipRouterProgram)
routerStatePDA, _, _ := solState.FindStatePDA(ccipRouterProgram)
externalExecutionConfigPDA, _, _ := solState.FindExternalExecutionConfigPDA(ccipRouterProgram)
externalTokenPoolsSignerPDA, _, _ := solState.FindExternalTokenPoolsSignerPDA(ccipRouterProgram)
table, err := solCommonUtil.SetupLookupTable(
e.GetContext(),
chain.Client,
Expand All @@ -656,10 +690,12 @@ func deployChainContractsSolana(
solana.SysVarInstructionsPubkey,
// router
ccipRouterProgram,
GetRouterConfigPDA(ccipRouterProgram),
GetRouterStatePDA(ccipRouterProgram),
GetExternalExecutionConfigPDA(ccipRouterProgram),
GetExternalTokenPoolsSignerPDA(ccipRouterProgram),
routerConfigPDA,
routerStatePDA,
externalExecutionConfigPDA,
externalTokenPoolsSignerPDA,
// token pools
tokenPoolProgram,
// token
solana.Token2022ProgramID,
solana.TokenProgramID,
Expand Down
Loading

0 comments on commit 6118cc6

Please sign in to comment.