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

CCIP - Version based changesets #16504

Merged
merged 7 commits into from
Feb 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 5 additions & 5 deletions deployment/ccip/changeset/deployer_group_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -360,14 +360,14 @@ func TestDeployerGroupMultipleProposalsMCMS(t *testing.T) {

e, _ := testhelpers.NewMemoryEnvironment(t, testhelpers.WithNumOfChains(2))

state, err := changeset.LoadOnchainState(e.Env)
currentState, err := changeset.LoadOnchainState(e.Env)
require.NoError(t, err)

timelocksPerChain := changeset.BuildTimelockPerChain(e.Env, state)
timelocksPerChain := changeset.BuildTimelockPerChain(e.Env, currentState)

contractsByChain := make(map[uint64][]common.Address)
for _, chain := range e.Env.AllChainSelectors() {
contractsByChain[chain] = []common.Address{state.Chains[chain].LinkToken.Address()}
contractsByChain[chain] = []common.Address{currentState.Chains[chain].LinkToken.Address()}
}

_, err = commonchangeset.Apply(t, e.Env, timelocksPerChain,
Expand Down Expand Up @@ -397,10 +397,10 @@ func TestDeployerGroupMultipleProposalsMCMS(t *testing.T) {
)
require.NoError(t, err)

state, err = changeset.LoadOnchainState(e.Env)
currentState, err = changeset.LoadOnchainState(e.Env)
require.NoError(t, err)

token := state.Chains[e.HomeChainSel].LinkToken
token := currentState.Chains[e.HomeChainSel].LinkToken

amount, err := token.BalanceOf(nil, cfg.address)
require.NoError(t, err)
Expand Down
13 changes: 7 additions & 6 deletions deployment/ccip/changeset/solana/cs_chain_contracts.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ import (
solState "github.com/smartcontractkit/chainlink-ccip/chains/solana/utils/state"

"github.com/smartcontractkit/chainlink/deployment"
cs "github.com/smartcontractkit/chainlink/deployment/ccip/changeset"
"github.com/smartcontractkit/chainlink/deployment/ccip/changeset"
"github.com/smartcontractkit/chainlink/deployment/ccip/changeset/v1_6"
)

var _ deployment.ChangeSet[cs.SetOCR3OffRampConfig] = SetOCR3ConfigSolana
var _ deployment.ChangeSet[v1_6.SetOCR3OffRampConfig] = SetOCR3ConfigSolana
var _ deployment.ChangeSet[AddRemoteChainToSolanaConfig] = AddRemoteChainToSolana
var _ deployment.ChangeSet[BillingTokenConfig] = AddBillingToken
var _ deployment.ChangeSet[BillingTokenForRemoteChainConfig] = AddBillingTokenForRemoteChain
Expand Down Expand Up @@ -44,7 +45,7 @@ func commonValidation(e deployment.Environment, selector uint64, tokenPubKey sol
if !ok {
return fmt.Errorf("chain selector %d not found in environment", selector)
}
state, err := cs.LoadOnchainState(e)
state, err := changeset.LoadOnchainState(e)
if err != nil {
return fmt.Errorf("failed to load onchain state: %w", err)
}
Expand All @@ -68,7 +69,7 @@ func commonValidation(e deployment.Environment, selector uint64, tokenPubKey sol
return nil
}

func validateRouterConfig(chain deployment.SolChain, chainState cs.SolCCIPChainState) error {
func validateRouterConfig(chain deployment.SolChain, chainState changeset.SolCCIPChainState) error {
if chainState.Router.IsZero() {
return fmt.Errorf("router not found in existing state, deploy the router first for chain %d", chain.Selector)
}
Expand All @@ -81,7 +82,7 @@ func validateRouterConfig(chain deployment.SolChain, chainState cs.SolCCIPChainS
return nil
}

func validateFeeQuoterConfig(chain deployment.SolChain, chainState cs.SolCCIPChainState) error {
func validateFeeQuoterConfig(chain deployment.SolChain, chainState changeset.SolCCIPChainState) error {
if chainState.FeeQuoter.IsZero() {
return fmt.Errorf("fee quoter not found in existing state, deploy the fee quoter first for chain %d", chain.Selector)
}
Expand All @@ -94,7 +95,7 @@ func validateFeeQuoterConfig(chain deployment.SolChain, chainState cs.SolCCIPCha
return nil
}

func validateOffRampConfig(chain deployment.SolChain, chainState cs.SolCCIPChainState) error {
func validateOffRampConfig(chain deployment.SolChain, chainState changeset.SolCCIPChainState) error {
if chainState.OffRamp.IsZero() {
return fmt.Errorf("offramp not found in existing state, deploy the offramp first for chain %d", chain.Selector)
}
Expand Down
8 changes: 5 additions & 3 deletions deployment/ccip/changeset/solana/cs_chain_contracts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@ import (
solTokenUtil "github.com/smartcontractkit/chainlink-ccip/chains/solana/utils/tokens"

"github.com/smartcontractkit/chainlink-testing-framework/lib/utils/testcontext"

ccipChangeset "github.com/smartcontractkit/chainlink/deployment/ccip/changeset"
changeset_solana "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/solana"
"github.com/smartcontractkit/chainlink/deployment/ccip/changeset/testhelpers"
"github.com/smartcontractkit/chainlink/deployment/ccip/changeset/v1_6"

"github.com/smartcontractkit/chainlink/deployment"
commonchangeset "github.com/smartcontractkit/chainlink/deployment/common/changeset"
Expand All @@ -38,9 +40,9 @@ func TestAddRemoteChain(t *testing.T) {

tenv.Env, err = commonchangeset.Apply(t, tenv.Env, nil,
commonchangeset.Configure(
deployment.CreateLegacyChangeSet(ccipChangeset.UpdateOnRampsDestsChangeset),
ccipChangeset.UpdateOnRampDestsConfig{
UpdatesByChain: map[uint64]map[uint64]ccipChangeset.OnRampDestinationUpdate{
deployment.CreateLegacyChangeSet(v1_6.UpdateOnRampsDestsChangeset),
v1_6.UpdateOnRampDestsConfig{
UpdatesByChain: map[uint64]map[uint64]v1_6.OnRampDestinationUpdate{
evmChain: {
solChain: {
IsEnabled: true,
Expand Down
21 changes: 11 additions & 10 deletions deployment/ccip/changeset/solana/cs_deploy_chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import (

"github.com/smartcontractkit/chainlink/deployment"
"github.com/smartcontractkit/chainlink/deployment/ccip/changeset"
cs "github.com/smartcontractkit/chainlink/deployment/ccip/changeset"
state2 "github.com/smartcontractkit/chainlink/deployment/ccip/changeset"
"github.com/smartcontractkit/chainlink/deployment/ccip/changeset/v1_6"

solBinary "github.com/gagliardetto/binary"
solRpc "github.com/gagliardetto/solana-go/rpc"
Expand All @@ -21,20 +22,20 @@ import (
solState "github.com/smartcontractkit/chainlink-ccip/chains/solana/utils/state"
)

var _ deployment.ChangeSet[changeset.DeployChainContractsConfig] = DeployChainContractsChangesetSolana
var _ deployment.ChangeSet[v1_6.DeployChainContractsConfig] = DeployChainContractsChangesetSolana

func DeployChainContractsChangesetSolana(e deployment.Environment, c changeset.DeployChainContractsConfig) (deployment.ChangesetOutput, error) {
func DeployChainContractsChangesetSolana(e deployment.Environment, c v1_6.DeployChainContractsConfig) (deployment.ChangesetOutput, error) {
if err := c.Validate(); err != nil {
return deployment.ChangesetOutput{}, fmt.Errorf("invalid DeployChainContractsConfig: %w", err)
}
newAddresses := deployment.NewMemoryAddressBook()
existingState, err := changeset.LoadOnchainState(e)
existingState, err := state2.LoadOnchainState(e)
if err != nil {
e.Logger.Errorw("Failed to load existing onchain state", "err", err)
return deployment.ChangesetOutput{}, err
}

err = changeset.ValidateHomeChainState(e, c.HomeChainSelector, existingState)
err = v1_6.ValidateHomeChainState(e, c.HomeChainSelector, existingState)
if err != nil {
return deployment.ChangesetOutput{}, err
}
Expand Down Expand Up @@ -282,7 +283,7 @@ func deployChainContractsSolana(
return fmt.Errorf("failed to deploy program: %w", err)
}

tv := deployment.NewTypeAndVersion(changeset.FeeQuoter, deployment.Version1_0_0)
tv := deployment.NewTypeAndVersion(state2.FeeQuoter, deployment.Version1_0_0)
e.Logger.Infow("Deployed contract", "Contract", tv.String(), "addr", programID, "chain", chain.String())

feeQuoterAddress = solana.MustPublicKeyFromBase58(programID)
Expand All @@ -305,7 +306,7 @@ func deployChainContractsSolana(
return fmt.Errorf("failed to deploy program: %w", err)
}

tv := deployment.NewTypeAndVersion(changeset.Router, deployment.Version1_0_0)
tv := deployment.NewTypeAndVersion(state2.Router, deployment.Version1_0_0)
e.Logger.Infow("Deployed contract", "Contract", tv.String(), "addr", programID, "chain", chain.String())

ccipRouterProgram = solana.MustPublicKeyFromBase58(programID)
Expand All @@ -327,7 +328,7 @@ func deployChainContractsSolana(
if err != nil {
return fmt.Errorf("failed to deploy program: %w", err)
}
tv := deployment.NewTypeAndVersion(changeset.OffRamp, deployment.Version1_0_0)
tv := deployment.NewTypeAndVersion(state2.OffRamp, deployment.Version1_0_0)
e.Logger.Infow("Deployed contract", "Contract", tv.String(), "addr", programID, "chain", chain.String())
offRampAddress = solana.MustPublicKeyFromBase58(programID)
err = ab.Save(chain.Selector, programID, tv)
Expand Down Expand Up @@ -437,7 +438,7 @@ type SetFeeAggregatorConfig struct {
}

func (cfg SetFeeAggregatorConfig) Validate(e deployment.Environment) error {
state, err := cs.LoadOnchainState(e)
state, err := state2.LoadOnchainState(e)
if err != nil {
return fmt.Errorf("failed to load onchain state: %w", err)
}
Expand Down Expand Up @@ -468,7 +469,7 @@ func SetFeeAggregator(e deployment.Environment, cfg SetFeeAggregatorConfig) (dep
return deployment.ChangesetOutput{}, err
}

state, _ := cs.LoadOnchainState(e)
state, _ := state2.LoadOnchainState(e)
chainState := state.SolChains[cfg.ChainSelector]
chain := e.SolChains[cfg.ChainSelector]

Expand Down
25 changes: 13 additions & 12 deletions deployment/ccip/changeset/solana/cs_deploy_chain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/smartcontractkit/chainlink/deployment/ccip/changeset"
cs_solana "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/solana"
"github.com/smartcontractkit/chainlink/deployment/ccip/changeset/testhelpers"
"github.com/smartcontractkit/chainlink/deployment/ccip/changeset/v1_6"
"github.com/smartcontractkit/chainlink/deployment/common/proposalutils"
"github.com/smartcontractkit/chainlink/deployment/environment/memory"
"github.com/smartcontractkit/chainlink/v2/core/logger"
Expand All @@ -34,12 +35,12 @@ func TestDeployChainContractsChangesetSolana(t *testing.T) {
nodes, err := deployment.NodeInfo(e.NodeIDs, e.Offchain)
require.NoError(t, err)
cfg := make(map[uint64]commontypes.MCMSWithTimelockConfigV2)
contractParams := make(map[uint64]changeset.ChainContractParams)
contractParams := make(map[uint64]v1_6.ChainContractParams)
for _, chain := range e.AllChainSelectors() {
cfg[chain] = proposalutils.SingleGroupTimelockConfigV2(t)
contractParams[chain] = changeset.ChainContractParams{
FeeQuoterParams: changeset.DefaultFeeQuoterParams(),
OffRampParams: changeset.DefaultOffRampParams(),
contractParams[chain] = v1_6.ChainContractParams{
FeeQuoterParams: v1_6.DefaultFeeQuoterParams(),
OffRampParams: v1_6.DefaultOffRampParams(),
}
}
prereqCfg := make([]changeset.DeployPrerequisiteConfigPerChain, 0)
Expand All @@ -55,8 +56,8 @@ func TestDeployChainContractsChangesetSolana(t *testing.T) {
testhelpers.SavePreloadedSolAddresses(t, e, solChainSelectors[0])
e, err = commonchangeset.Apply(t, e, nil,
commonchangeset.Configure(
deployment.CreateLegacyChangeSet(changeset.DeployHomeChainChangeset),
changeset.DeployHomeChainConfig{
deployment.CreateLegacyChangeSet(v1_6.DeployHomeChainChangeset),
v1_6.DeployHomeChainConfig{
HomeChainSel: homeChainSel,
RMNStaticConfig: testhelpers.NewTestRMNStaticConfig(),
RMNDynamicConfig: testhelpers.NewTestRMNDynamicConfig(),
Expand Down Expand Up @@ -86,20 +87,20 @@ func TestDeployChainContractsChangesetSolana(t *testing.T) {
},
),
commonchangeset.Configure(
deployment.CreateLegacyChangeSet(changeset.DeployChainContractsChangeset),
changeset.DeployChainContractsConfig{
deployment.CreateLegacyChangeSet(v1_6.DeployChainContractsChangeset),
v1_6.DeployChainContractsConfig{
HomeChainSelector: homeChainSel,
ContractParamsPerChain: contractParams,
},
),
commonchangeset.Configure(
deployment.CreateLegacyChangeSet(cs_solana.DeployChainContractsChangesetSolana),
changeset.DeployChainContractsConfig{
v1_6.DeployChainContractsConfig{
HomeChainSelector: homeChainSel,
ContractParamsPerChain: map[uint64]changeset.ChainContractParams{
ContractParamsPerChain: map[uint64]v1_6.ChainContractParams{
solChainSelectors[0]: {
FeeQuoterParams: changeset.DefaultFeeQuoterParams(),
OffRampParams: changeset.DefaultOffRampParams(),
FeeQuoterParams: v1_6.DefaultFeeQuoterParams(),
OffRampParams: v1_6.DefaultOffRampParams(),
},
},
},
Expand Down
9 changes: 5 additions & 4 deletions deployment/ccip/changeset/solana/cs_set_ocr3.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ import (
solOffRamp "github.com/smartcontractkit/chainlink-ccip/chains/solana/gobindings/ccip_offramp"

"github.com/smartcontractkit/chainlink/deployment"
cs "github.com/smartcontractkit/chainlink/deployment/ccip/changeset"
"github.com/smartcontractkit/chainlink/deployment/ccip/changeset"
"github.com/smartcontractkit/chainlink/deployment/ccip/changeset/internal"
"github.com/smartcontractkit/chainlink/deployment/ccip/changeset/v1_6"
)

const (
Expand All @@ -32,8 +33,8 @@ func btoi(b bool) uint8 {
// run after the candidate is confirmed to be working correctly.
// Multichain is especially helpful for NOP rotations where we have
// to touch all the chain to change signers.
func SetOCR3ConfigSolana(e deployment.Environment, cfg cs.SetOCR3OffRampConfig) (deployment.ChangesetOutput, error) {
state, err := cs.LoadOnchainState(e)
func SetOCR3ConfigSolana(e deployment.Environment, cfg v1_6.SetOCR3OffRampConfig) (deployment.ChangesetOutput, error) {
state, err := changeset.LoadOnchainState(e)
if err != nil {
return deployment.ChangesetOutput{}, fmt.Errorf("failed to load onchain state: %w", err)
}
Expand Down Expand Up @@ -105,7 +106,7 @@ func SetOCR3ConfigSolana(e deployment.Environment, cfg cs.SetOCR3OffRampConfig)
func isOCR3ConfigSetOnOffRampSolana(
e deployment.Environment,
chain deployment.SolChain,
chainState cs.SolCCIPChainState,
chainState changeset.SolCCIPChainState,
args []internal.MultiOCR3BaseOCRConfigArgsSolana,
) (bool, error) {
var configAccount solOffRamp.Config
Expand Down
1 change: 1 addition & 0 deletions deployment/ccip/changeset/solana/cs_solana_token_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"go.uber.org/zap/zapcore"

solTokenUtil "github.com/smartcontractkit/chainlink-ccip/chains/solana/utils/tokens"

"github.com/smartcontractkit/chainlink/deployment"
ccipChangeset "github.com/smartcontractkit/chainlink/deployment/ccip/changeset"
changeset_solana "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/solana"
Expand Down
21 changes: 11 additions & 10 deletions deployment/ccip/changeset/solana/cs_token_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import (
solTokenUtil "github.com/smartcontractkit/chainlink-ccip/chains/solana/utils/tokens"

"github.com/smartcontractkit/chainlink/deployment"
cs "github.com/smartcontractkit/chainlink/deployment/ccip/changeset"
"github.com/smartcontractkit/chainlink/deployment/ccip/changeset"
state2 "github.com/smartcontractkit/chainlink/deployment/ccip/changeset"
)

var _ deployment.ChangeSet[TokenPoolConfig] = AddTokenPool
Expand All @@ -32,7 +33,7 @@ func (cfg TokenPoolConfig) Validate(e deployment.Environment) error {
if err := commonValidation(e, cfg.ChainSelector, tokenPubKey); err != nil {
return err
}
state, _ := cs.LoadOnchainState(e)
state, _ := state2.LoadOnchainState(e)
chainState := state.SolChains[cfg.ChainSelector]
if chainState.TokenPool.IsZero() {
return fmt.Errorf("token pool not found in existing state, deploy the token pool first for chain %d", cfg.ChainSelector)
Expand All @@ -59,7 +60,7 @@ func AddTokenPool(e deployment.Environment, cfg TokenPoolConfig) (deployment.Cha
return deployment.ChangesetOutput{}, err
}
chain := e.SolChains[cfg.ChainSelector]
state, _ := cs.LoadOnchainState(e)
state, _ := state2.LoadOnchainState(e)
chainState := state.SolChains[cfg.ChainSelector]
authorityPubKey := solana.MustPublicKeyFromBase58(cfg.Authority)
tokenPubKey := solana.MustPublicKeyFromBase58(cfg.TokenPubKey)
Expand Down Expand Up @@ -136,7 +137,7 @@ func (cfg RemoteChainTokenPoolConfig) Validate(e deployment.Environment) error {
if err := commonValidation(e, cfg.SolChainSelector, tokenPubKey); err != nil {
return err
}
state, _ := cs.LoadOnchainState(e)
state, _ := state2.LoadOnchainState(e)
chainState := state.SolChains[cfg.SolChainSelector]
if chainState.TokenPool.IsZero() {
return fmt.Errorf("token pool not found in existing state, deploy token pool for chain %d", cfg.SolChainSelector)
Expand Down Expand Up @@ -173,7 +174,7 @@ func SetupTokenPoolForRemoteChain(e deployment.Environment, cfg RemoteChainToken
}
tokenPubKey := solana.MustPublicKeyFromBase58(cfg.SolTokenPubKey)
chain := e.SolChains[cfg.SolChainSelector]
state, _ := cs.LoadOnchainState(e)
state, _ := state2.LoadOnchainState(e)
chainState := state.SolChains[cfg.SolChainSelector]
// verified
poolConfigPDA, _ := solTokenUtil.TokenPoolConfigAddress(tokenPubKey, chainState.TokenPool)
Expand Down Expand Up @@ -240,7 +241,7 @@ func (cfg TokenPoolLookupTableConfig) Validate(e deployment.Environment) error {
if err := commonValidation(e, cfg.ChainSelector, tokenPubKey); err != nil {
return err
}
state, _ := cs.LoadOnchainState(e)
state, _ := state2.LoadOnchainState(e)
chainState := state.SolChains[cfg.ChainSelector]
if chainState.TokenPool.IsZero() {
return fmt.Errorf("token pool not found in existing state, deploy the token pool first for chain %d", cfg.ChainSelector)
Expand All @@ -256,7 +257,7 @@ func AddTokenPoolLookupTable(e deployment.Environment, cfg TokenPoolLookupTableC
chain := e.SolChains[cfg.ChainSelector]
ctx := e.GetContext()
client := chain.Client
state, _ := cs.LoadOnchainState(e)
state, _ := state2.LoadOnchainState(e)
chainState := state.SolChains[cfg.ChainSelector]
authorityPrivKey := chain.DeployerKey // assuming the authority is the deployer key
tokenPubKey := solana.MustPublicKeyFromBase58(cfg.TokenPubKey)
Expand Down Expand Up @@ -293,7 +294,7 @@ func AddTokenPoolLookupTable(e deployment.Environment, cfg TokenPoolLookupTableC
return deployment.ChangesetOutput{}, fmt.Errorf("failed to await slot change while extending lookup table: %w", err)
}
newAddressBook := deployment.NewMemoryAddressBook()
tv := deployment.NewTypeAndVersion(cs.TokenPoolLookupTable, deployment.Version1_0_0)
tv := deployment.NewTypeAndVersion(changeset.TokenPoolLookupTable, deployment.Version1_0_0)
tv.Labels.Add(tokenPubKey.String())
if err := newAddressBook.Save(cfg.ChainSelector, table.String(), tv); err != nil {
return deployment.ChangesetOutput{}, fmt.Errorf("failed to save tokenpool address lookup table: %w", err)
Expand All @@ -317,7 +318,7 @@ func (cfg SetPoolConfig) Validate(e deployment.Environment) error {
if err := commonValidation(e, cfg.ChainSelector, tokenPubKey); err != nil {
return err
}
state, _ := cs.LoadOnchainState(e)
state, _ := state2.LoadOnchainState(e)
chainState := state.SolChains[cfg.ChainSelector]
chain := e.SolChains[cfg.ChainSelector]
if chainState.TokenPool.IsZero() {
Expand All @@ -344,7 +345,7 @@ func SetPool(e deployment.Environment, cfg SetPoolConfig) (deployment.ChangesetO
}

chain := e.SolChains[cfg.ChainSelector]
state, _ := cs.LoadOnchainState(e)
state, _ := state2.LoadOnchainState(e)
chainState := state.SolChains[cfg.ChainSelector]
tokenPubKey := solana.MustPublicKeyFromBase58(cfg.TokenPubKey)
routerConfigPDA, _, _ := solState.FindConfigPDA(chainState.Router)
Expand Down
Loading
Loading