From 78993c0f9ec44ff6babe675b15968df708ecab44 Mon Sep 17 00:00:00 2001 From: AnieeG Date: Mon, 18 Nov 2024 12:04:15 -0800 Subject: [PATCH 1/4] initial deploy chain --- deployment/ccip/changeset/deploy_chain.go | 29 +++++++ deployment/ccip/deploy.go | 100 ++++++++++++++-------- 2 files changed, 94 insertions(+), 35 deletions(-) create mode 100644 deployment/ccip/changeset/deploy_chain.go diff --git a/deployment/ccip/changeset/deploy_chain.go b/deployment/ccip/changeset/deploy_chain.go new file mode 100644 index 00000000000..7160e08cd8d --- /dev/null +++ b/deployment/ccip/changeset/deploy_chain.go @@ -0,0 +1,29 @@ +package changeset + +import ( + "github.com/smartcontractkit/ccip-owner-contracts/pkg/proposal/timelock" + + "github.com/smartcontractkit/chainlink/deployment" + ccipdeployment "github.com/smartcontractkit/chainlink/deployment/ccip" +) + +var _ deployment.ChangeSet[ccipdeployment.DeployCCIPContractConfig] = InitialDeploy + +func DeployChainContracts(env deployment.Environment, c ccipdeployment.DeployCCIPContractConfig) (deployment.ChangesetOutput, error) { + newAddresses := deployment.NewMemoryAddressBook() + err := ccipdeployment.DeployChainContractsForChains(env, newAddresses, c) + if err != nil { + env.Logger.Errorw("Failed to deploy CCIP contracts", "err", err, "newAddresses", newAddresses) + return deployment.ChangesetOutput{AddressBook: newAddresses}, deployment.MaybeDataErr(err) + } + js, err := ccipdeployment.NewCCIPJobSpecs(env.NodeIDs, env.Offchain) + if err != nil { + return deployment.ChangesetOutput{AddressBook: newAddresses}, err + } + return deployment.ChangesetOutput{ + Proposals: []timelock.MCMSWithTimelockProposal{}, + AddressBook: newAddresses, + // Mapping of which nodes get which jobs. + JobSpecs: js, + }, nil +} diff --git a/deployment/ccip/deploy.go b/deployment/ccip/deploy.go index 83e233b71bb..bdeb70fd6c1 100644 --- a/deployment/ccip/deploy.go +++ b/deployment/ccip/deploy.go @@ -321,29 +321,11 @@ func DeployCCIPContracts(e deployment.Environment, ab deployment.AddressBook, c e.Logger.Errorw("Failed to get capability registry") return fmt.Errorf("capability registry not found") } - cr, err := capReg.GetHashedCapabilityId( - &bind.CallOpts{}, CapabilityLabelledName, CapabilityVersion) - if err != nil { - e.Logger.Errorw("Failed to get hashed capability id", "err", err) - return err - } - if cr != CCIPCapabilityID { - return fmt.Errorf("capability registry does not support CCIP %s %s", hexutil.Encode(cr[:]), hexutil.Encode(CCIPCapabilityID[:])) + ccipHome := existingState.Chains[c.HomeChainSel].CCIPHome + if ccipHome == nil { + e.Logger.Errorw("Failed to get ccip home", "err", err) + return fmt.Errorf("ccip home not found") } - capability, err := capReg.GetCapability(nil, CCIPCapabilityID) - if err != nil { - e.Logger.Errorw("Failed to get capability", "err", err) - return err - } - ccipHome, err := ccip_home.NewCCIPHome(capability.ConfigurationContract, e.Chains[c.HomeChainSel].Client) - if err != nil { - e.Logger.Errorw("Failed to get ccip config", "err", err) - return err - } - if ccipHome.Address() != existingState.Chains[c.HomeChainSel].CCIPHome.Address() { - return fmt.Errorf("ccip home address mismatch") - } - rmnHome := existingState.Chains[c.HomeChainSel].RMNHome if rmnHome == nil { e.Logger.Errorw("Failed to get rmn home", "err", err) @@ -352,18 +334,6 @@ func DeployCCIPContracts(e deployment.Environment, ab deployment.AddressBook, c usdcConfiguration := make(map[cciptypes.ChainSelector]pluginconfig.USDCCCTPTokenConfig) for _, chainSel := range c.ChainsToDeploy { - chain, ok := e.Chains[chainSel] - if !ok { - return fmt.Errorf("chain %d not found", chainSel) - } - if existingState.Chains[chainSel].LinkToken == nil || existingState.Chains[chainSel].Weth9 == nil { - return fmt.Errorf("fee tokens not found for chain %d", chainSel) - } - err = DeployChainContracts(e, chain, ab, c.MCMSConfig, rmnHome) - if err != nil { - return err - } - if c.USDCConfig.Enabled { token, pool, messenger, transmitter, err1 := DeployUSDC(e.Logger, chain, ab, existingState.Chains[chainSel]) if err1 != nil { @@ -383,7 +353,11 @@ func DeployCCIPContracts(e deployment.Environment, ab deployment.AddressBook, c } } } - + err = DeployChainContractsForChains(e, ab, c) + if err != nil { + e.Logger.Errorw("Failed to deploy chain contracts", "err", err) + return err + } for _, chainSel := range c.ChainsToDeploy { chain, _ := e.Chains[chainSel] @@ -553,6 +527,62 @@ func DeployMCMSContracts( }, nil } +func DeployChainContractsForChains(e deployment.Environment, ab deployment.AddressBook, c DeployCCIPContractConfig) error { + existingState, err := LoadOnchainState(e) + if err != nil { + e.Logger.Errorw("Failed to load existing onchain state", "err") + return err + } + + capReg := existingState.Chains[c.HomeChainSel].CapabilityRegistry + if capReg == nil { + e.Logger.Errorw("Failed to get capability registry") + return fmt.Errorf("capability registry not found") + } + cr, err := capReg.GetHashedCapabilityId( + &bind.CallOpts{}, CapabilityLabelledName, CapabilityVersion) + if err != nil { + e.Logger.Errorw("Failed to get hashed capability id", "err", err) + return err + } + if cr != CCIPCapabilityID { + return fmt.Errorf("capability registry does not support CCIP %s %s", hexutil.Encode(cr[:]), hexutil.Encode(CCIPCapabilityID[:])) + } + capability, err := capReg.GetCapability(nil, CCIPCapabilityID) + if err != nil { + e.Logger.Errorw("Failed to get capability", "err", err) + return err + } + ccipHome, err := ccip_home.NewCCIPHome(capability.ConfigurationContract, e.Chains[c.HomeChainSel].Client) + if err != nil { + e.Logger.Errorw("Failed to get ccip config", "err", err) + return err + } + if ccipHome.Address() != existingState.Chains[c.HomeChainSel].CCIPHome.Address() { + return fmt.Errorf("ccip home address mismatch") + } + rmnHome := existingState.Chains[c.HomeChainSel].RMNHome + if rmnHome == nil { + e.Logger.Errorw("Failed to get rmn home", "err", err) + return fmt.Errorf("rmn home not found") + } + for _, chainSel := range c.ChainsToDeploy { + chain, ok := e.Chains[chainSel] + if !ok { + return fmt.Errorf("chain %d not found", chainSel) + } + if existingState.Chains[chainSel].LinkToken == nil || existingState.Chains[chainSel].Weth9 == nil { + return fmt.Errorf("fee tokens not found for chain %d", chainSel) + } + err := DeployChainContracts(e, chain, ab, c.MCMSConfig, rmnHome) + if err != nil { + e.Logger.Errorw("Failed to deploy chain contracts", "chain", chainSel, "err", err) + return fmt.Errorf("failed to deploy chain contracts for chain %d: %w", chainSel, err) + } + } + return nil +} + func DeployChainContracts( e deployment.Environment, chain deployment.Chain, From 191e5c45bfeee2ab115f1109c7ea097137be2baf Mon Sep 17 00:00:00 2001 From: AnieeG Date: Mon, 18 Nov 2024 13:00:13 -0800 Subject: [PATCH 2/4] more updates --- deployment/ccip/changeset/Jobspec_test.go | 35 +++++++++ deployment/ccip/changeset/deploy_chain.go | 31 ++++++-- .../ccip/changeset/deploy_chain_test.go | 78 +++++++++++++++++++ deployment/ccip/changeset/home_chain.go | 4 +- deployment/ccip/changeset/jobspec.go | 21 +++++ deployment/ccip/changeset/prerequisites.go | 12 +-- deployment/ccip/changeset/save_existing.go | 7 +- deployment/ccip/deploy.go | 21 ++--- deployment/ccip/deploy_test.go | 14 ---- deployment/helpers.go | 12 +++ 10 files changed, 189 insertions(+), 46 deletions(-) create mode 100644 deployment/ccip/changeset/Jobspec_test.go create mode 100644 deployment/ccip/changeset/deploy_chain_test.go create mode 100644 deployment/ccip/changeset/jobspec.go diff --git a/deployment/ccip/changeset/Jobspec_test.go b/deployment/ccip/changeset/Jobspec_test.go new file mode 100644 index 00000000000..4a10bdc2436 --- /dev/null +++ b/deployment/ccip/changeset/Jobspec_test.go @@ -0,0 +1,35 @@ +package changeset + +import ( + "testing" + + "github.com/stretchr/testify/require" + "go.uber.org/zap/zapcore" + + "github.com/smartcontractkit/chainlink/deployment" + "github.com/smartcontractkit/chainlink/deployment/environment/memory" + ccip "github.com/smartcontractkit/chainlink/v2/core/capabilities/ccip/validate" + "github.com/smartcontractkit/chainlink/v2/core/logger" +) + +func TestJobSpecChangeset(t *testing.T) { + lggr := logger.TestLogger(t) + e := memory.NewMemoryEnvironment(t, lggr, zapcore.InfoLevel, memory.MemoryEnvironmentConfig{ + Chains: 1, + Nodes: 4, + }) + output, err := Jobspec(e, nil) + require.NoError(t, err) + require.NotNil(t, output.JobSpecs) + nodes, err := deployment.NodeInfo(e.NodeIDs, e.Offchain) + require.NoError(t, err) + for _, node := range nodes { + jobs, exists := output.JobSpecs[node.NodeID] + require.True(t, exists) + require.NotNil(t, jobs) + for _, job := range jobs { + _, err = ccip.ValidatedCCIPSpec(job) + require.NoError(t, err) + } + } +} diff --git a/deployment/ccip/changeset/deploy_chain.go b/deployment/ccip/changeset/deploy_chain.go index 7160e08cd8d..7de2de40c37 100644 --- a/deployment/ccip/changeset/deploy_chain.go +++ b/deployment/ccip/changeset/deploy_chain.go @@ -1,6 +1,8 @@ package changeset import ( + "fmt" + "github.com/smartcontractkit/ccip-owner-contracts/pkg/proposal/timelock" "github.com/smartcontractkit/chainlink/deployment" @@ -9,21 +11,34 @@ import ( var _ deployment.ChangeSet[ccipdeployment.DeployCCIPContractConfig] = InitialDeploy -func DeployChainContracts(env deployment.Environment, c ccipdeployment.DeployCCIPContractConfig) (deployment.ChangesetOutput, error) { +func DeployChainContracts(env deployment.Environment, c DeployChainContractsConfig) (deployment.ChangesetOutput, error) { newAddresses := deployment.NewMemoryAddressBook() - err := ccipdeployment.DeployChainContractsForChains(env, newAddresses, c) + err := ccipdeployment.DeployChainContractsForChains(env, newAddresses, c.HomeChainSelector, c.ChainSelectors, c.MCMSCfg) if err != nil { env.Logger.Errorw("Failed to deploy CCIP contracts", "err", err, "newAddresses", newAddresses) return deployment.ChangesetOutput{AddressBook: newAddresses}, deployment.MaybeDataErr(err) } - js, err := ccipdeployment.NewCCIPJobSpecs(env.NodeIDs, env.Offchain) - if err != nil { - return deployment.ChangesetOutput{AddressBook: newAddresses}, err - } return deployment.ChangesetOutput{ Proposals: []timelock.MCMSWithTimelockProposal{}, AddressBook: newAddresses, - // Mapping of which nodes get which jobs. - JobSpecs: js, + JobSpecs: nil, }, nil } + +type DeployChainContractsConfig struct { + ChainSelectors []uint64 + HomeChainSelector uint64 + MCMSCfg ccipdeployment.MCMSConfig +} + +func (c DeployChainContractsConfig) Validate() error { + for _, cs := range c.ChainSelectors { + if err := deployment.IsValidChainSelector(cs); err != nil { + return fmt.Errorf("invalid chain selector: %d - %w", cs, err) + } + } + if err := deployment.IsValidChainSelector(c.HomeChainSelector); err != nil { + return fmt.Errorf("invalid home chain selector: %d - %w", c.HomeChainSelector, err) + } + return nil +} diff --git a/deployment/ccip/changeset/deploy_chain_test.go b/deployment/ccip/changeset/deploy_chain_test.go new file mode 100644 index 00000000000..b197c90eca5 --- /dev/null +++ b/deployment/ccip/changeset/deploy_chain_test.go @@ -0,0 +1,78 @@ +package changeset + +import ( + "testing" + + "github.com/stretchr/testify/require" + "go.uber.org/zap/zapcore" + + "github.com/smartcontractkit/chainlink/deployment" + ccdeploy "github.com/smartcontractkit/chainlink/deployment/ccip" + "github.com/smartcontractkit/chainlink/deployment/environment/memory" + "github.com/smartcontractkit/chainlink/v2/core/logger" +) + +func TestDeployChainContractsChangeset(t *testing.T) { + lggr := logger.TestLogger(t) + e := memory.NewMemoryEnvironment(t, lggr, zapcore.InfoLevel, memory.MemoryEnvironmentConfig{ + Bootstraps: 1, + Chains: 2, + Nodes: 4, + }) + selectors := e.AllChainSelectors() + homeChainSel := selectors[0] + nodes, err := deployment.NodeInfo(e.NodeIDs, e.Offchain) + require.NoError(t, err) + p2pIds := nodes.NonBootstraps().PeerIDs() + // deploy home chain + homeChainCfg := DeployHomeChainConfig{ + HomeChainSel: homeChainSel, + RMNStaticConfig: ccdeploy.NewTestRMNStaticConfig(), + RMNDynamicConfig: ccdeploy.NewTestRMNDynamicConfig(), + NodeOperators: ccdeploy.NewTestNodeOperator(e.Chains[homeChainSel].DeployerKey.From), + NodeP2PIDsPerNodeOpAdmin: map[string][][32]byte{ + "NodeOperator": p2pIds, + }, + } + output, err := DeployHomeChain(e, homeChainCfg) + require.NoError(t, err) + require.NoError(t, e.ExistingAddresses.Merge(output.AddressBook)) + + // deploy pre-requisites + prerequisites, err := DeployPrerequisites(e, DeployPrerequisiteConfig{ + ChainSelectors: selectors, + }) + require.NoError(t, err) + require.NoError(t, e.ExistingAddresses.Merge(prerequisites.AddressBook)) + + // deploy ccip chain contracts + output, err = DeployChainContracts(e, DeployChainContractsConfig{ + ChainSelectors: selectors, + HomeChainSelector: homeChainSel, + MCMSCfg: ccdeploy.NewTestMCMSConfig(t, e), + }) + require.NoError(t, err) + require.NoError(t, e.ExistingAddresses.Merge(output.AddressBook)) + + // load onchain state + state, err := ccdeploy.LoadOnchainState(e) + require.NoError(t, err) + + // verify all contracts populated + require.NotNil(t, state.Chains[homeChainSel].CapabilityRegistry) + require.NotNil(t, state.Chains[homeChainSel].CCIPHome) + require.NotNil(t, state.Chains[homeChainSel].RMNHome) + for _, sel := range selectors { + require.NotNil(t, state.Chains[sel].LinkToken) + require.NotNil(t, state.Chains[sel].Weth9) + require.NotNil(t, state.Chains[sel].TokenAdminRegistry) + require.NotNil(t, state.Chains[sel].RegistryModule) + require.NotNil(t, state.Chains[sel].Router) + require.NotNil(t, state.Chains[sel].RMNRemote) + require.NotNil(t, state.Chains[sel].TestRouter) + require.NotNil(t, state.Chains[sel].NonceManager) + require.NotNil(t, state.Chains[sel].FeeQuoter) + require.NotNil(t, state.Chains[sel].OffRamp) + require.NotNil(t, state.Chains[sel].OnRamp) + } +} diff --git a/deployment/ccip/changeset/home_chain.go b/deployment/ccip/changeset/home_chain.go index 0fabd2efb18..92b5b09c695 100644 --- a/deployment/ccip/changeset/home_chain.go +++ b/deployment/ccip/changeset/home_chain.go @@ -26,7 +26,9 @@ func DeployHomeChain(env deployment.Environment, cfg DeployHomeChainConfig) (dep _, err = ccipdeployment.DeployHomeChain(env.Logger, env, ab, env.Chains[cfg.HomeChainSel], cfg.RMNStaticConfig, cfg.RMNDynamicConfig, cfg.NodeOperators, cfg.NodeP2PIDsPerNodeOpAdmin) if err != nil { env.Logger.Errorw("Failed to deploy cap reg", "err", err, "addresses", env.ExistingAddresses) - return deployment.ChangesetOutput{}, err + return deployment.ChangesetOutput{ + AddressBook: ab, + }, err } return deployment.ChangesetOutput{ diff --git a/deployment/ccip/changeset/jobspec.go b/deployment/ccip/changeset/jobspec.go new file mode 100644 index 00000000000..76352ff364f --- /dev/null +++ b/deployment/ccip/changeset/jobspec.go @@ -0,0 +1,21 @@ +package changeset + +import ( + "github.com/pkg/errors" + "github.com/smartcontractkit/ccip-owner-contracts/pkg/proposal/timelock" + + "github.com/smartcontractkit/chainlink/deployment" + ccipdeployment "github.com/smartcontractkit/chainlink/deployment/ccip" +) + +func Jobspec(env deployment.Environment, _ any) (deployment.ChangesetOutput, error) { + js, err := ccipdeployment.NewCCIPJobSpecs(env.NodeIDs, env.Offchain) + if err != nil { + return deployment.ChangesetOutput{}, errors.Wrapf(err, "failed to create job specs") + } + return deployment.ChangesetOutput{ + Proposals: []timelock.MCMSWithTimelockProposal{}, + AddressBook: deployment.NewMemoryAddressBook(), + JobSpecs: js, + }, nil +} diff --git a/deployment/ccip/changeset/prerequisites.go b/deployment/ccip/changeset/prerequisites.go index 7bead1cc05c..20ff7f5a935 100644 --- a/deployment/ccip/changeset/prerequisites.go +++ b/deployment/ccip/changeset/prerequisites.go @@ -6,7 +6,6 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/pkg/errors" "github.com/smartcontractkit/ccip-owner-contracts/pkg/proposal/timelock" - chain_selectors "github.com/smartcontractkit/chain-selectors" "github.com/smartcontractkit/chainlink/deployment" ccipdeployment "github.com/smartcontractkit/chainlink/deployment/ccip" @@ -27,7 +26,9 @@ func DeployPrerequisites(env deployment.Environment, cfg DeployPrerequisiteConfi err = ccipdeployment.DeployPrerequisiteChainContracts(env, ab, cfg.ChainSelectors) if err != nil { env.Logger.Errorw("Failed to deploy prerequisite contracts", "err", err, "addressBook", ab) - return deployment.ChangesetOutput{}, fmt.Errorf("failed to deploy prerequisite contracts: %w", err) + return deployment.ChangesetOutput{ + AddressBook: ab, + }, fmt.Errorf("failed to deploy prerequisite contracts: %w", err) } return deployment.ChangesetOutput{ Proposals: []timelock.MCMSWithTimelockProposal{}, @@ -45,14 +46,9 @@ type DeployPrerequisiteConfig struct { func (c DeployPrerequisiteConfig) Validate() error { for _, cs := range c.ChainSelectors { - if cs == 0 { - return fmt.Errorf("chain selector must be set") - } - _, err := chain_selectors.ChainIdFromSelector(cs) - if err != nil { + if err := deployment.IsValidChainSelector(cs); err != nil { return fmt.Errorf("invalid chain selector: %d - %w", cs, err) } - } return nil } diff --git a/deployment/ccip/changeset/save_existing.go b/deployment/ccip/changeset/save_existing.go index 8995fdf7f4c..76330a3a20a 100644 --- a/deployment/ccip/changeset/save_existing.go +++ b/deployment/ccip/changeset/save_existing.go @@ -6,7 +6,6 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/pkg/errors" "github.com/smartcontractkit/ccip-owner-contracts/pkg/proposal/timelock" - chain_selectors "github.com/smartcontractkit/chain-selectors" "github.com/smartcontractkit/chainlink/deployment" ) @@ -27,11 +26,7 @@ type ExistingContractsConfig struct { func (cfg ExistingContractsConfig) Validate() error { for _, ec := range cfg.ExistingContracts { - if ec.ChainSelector == 0 { - return fmt.Errorf("chain selectors must be set") - } - _, err := chain_selectors.ChainIdFromSelector(ec.ChainSelector) - if err != nil { + if err := deployment.IsValidChainSelector(ec.ChainSelector); err != nil { return fmt.Errorf("invalid chain selector: %d - %w", ec.ChainSelector, err) } if ec.Address == (common.Address{}) { diff --git a/deployment/ccip/deploy.go b/deployment/ccip/deploy.go index bdeb70fd6c1..d1f6866190d 100644 --- a/deployment/ccip/deploy.go +++ b/deployment/ccip/deploy.go @@ -334,6 +334,10 @@ func DeployCCIPContracts(e deployment.Environment, ab deployment.AddressBook, c usdcConfiguration := make(map[cciptypes.ChainSelector]pluginconfig.USDCCCTPTokenConfig) for _, chainSel := range c.ChainsToDeploy { + chain, exists := e.Chains[chainSel] + if !exists { + return fmt.Errorf("chain %d not found", chainSel) + } if c.USDCConfig.Enabled { token, pool, messenger, transmitter, err1 := DeployUSDC(e.Logger, chain, ab, existingState.Chains[chainSel]) if err1 != nil { @@ -353,14 +357,13 @@ func DeployCCIPContracts(e deployment.Environment, ab deployment.AddressBook, c } } } - err = DeployChainContractsForChains(e, ab, c) + err = DeployChainContractsForChains(e, ab, c.HomeChainSel, c.ChainsToDeploy, c.MCMSConfig) if err != nil { e.Logger.Errorw("Failed to deploy chain contracts", "err", err) return err } for _, chainSel := range c.ChainsToDeploy { chain, _ := e.Chains[chainSel] - chainAddresses, err := ab.AddressesForChain(chain.Selector) if err != nil { e.Logger.Errorw("Failed to get chain addresses", "err", err) @@ -527,14 +530,14 @@ func DeployMCMSContracts( }, nil } -func DeployChainContractsForChains(e deployment.Environment, ab deployment.AddressBook, c DeployCCIPContractConfig) error { +func DeployChainContractsForChains(e deployment.Environment, ab deployment.AddressBook, homeChainSel uint64, chainsToDeploy []uint64, mcmsConfig MCMSConfig) error { existingState, err := LoadOnchainState(e) if err != nil { e.Logger.Errorw("Failed to load existing onchain state", "err") return err } - capReg := existingState.Chains[c.HomeChainSel].CapabilityRegistry + capReg := existingState.Chains[homeChainSel].CapabilityRegistry if capReg == nil { e.Logger.Errorw("Failed to get capability registry") return fmt.Errorf("capability registry not found") @@ -553,20 +556,20 @@ func DeployChainContractsForChains(e deployment.Environment, ab deployment.Addre e.Logger.Errorw("Failed to get capability", "err", err) return err } - ccipHome, err := ccip_home.NewCCIPHome(capability.ConfigurationContract, e.Chains[c.HomeChainSel].Client) + ccipHome, err := ccip_home.NewCCIPHome(capability.ConfigurationContract, e.Chains[homeChainSel].Client) if err != nil { e.Logger.Errorw("Failed to get ccip config", "err", err) return err } - if ccipHome.Address() != existingState.Chains[c.HomeChainSel].CCIPHome.Address() { + if ccipHome.Address() != existingState.Chains[homeChainSel].CCIPHome.Address() { return fmt.Errorf("ccip home address mismatch") } - rmnHome := existingState.Chains[c.HomeChainSel].RMNHome + rmnHome := existingState.Chains[homeChainSel].RMNHome if rmnHome == nil { e.Logger.Errorw("Failed to get rmn home", "err", err) return fmt.Errorf("rmn home not found") } - for _, chainSel := range c.ChainsToDeploy { + for _, chainSel := range chainsToDeploy { chain, ok := e.Chains[chainSel] if !ok { return fmt.Errorf("chain %d not found", chainSel) @@ -574,7 +577,7 @@ func DeployChainContractsForChains(e deployment.Environment, ab deployment.Addre if existingState.Chains[chainSel].LinkToken == nil || existingState.Chains[chainSel].Weth9 == nil { return fmt.Errorf("fee tokens not found for chain %d", chainSel) } - err := DeployChainContracts(e, chain, ab, c.MCMSConfig, rmnHome) + err := DeployChainContracts(e, chain, ab, mcmsConfig, rmnHome) if err != nil { e.Logger.Errorw("Failed to deploy chain contracts", "chain", chainSel, "err", err) return fmt.Errorf("failed to deploy chain contracts for chain %d: %w", chainSel, err) diff --git a/deployment/ccip/deploy_test.go b/deployment/ccip/deploy_test.go index dc1927261d1..2ca9901ddbf 100644 --- a/deployment/ccip/deploy_test.go +++ b/deployment/ccip/deploy_test.go @@ -70,17 +70,3 @@ func TestDeployCCIPContracts(t *testing.T) { require.NoError(t, err) fmt.Println(string(b)) } - -func TestJobSpecGeneration(t *testing.T) { - lggr := logger.TestLogger(t) - e := memory.NewMemoryEnvironment(t, lggr, zapcore.InfoLevel, memory.MemoryEnvironmentConfig{ - Chains: 1, - Nodes: 1, - }) - js, err := NewCCIPJobSpecs(e.NodeIDs, e.Offchain) - require.NoError(t, err) - for node, jb := range js { - fmt.Println(node, jb) - } - // TODO: Add job assertions -} diff --git a/deployment/helpers.go b/deployment/helpers.go index 1f0dc3064d6..e8d2d8c8d59 100644 --- a/deployment/helpers.go +++ b/deployment/helpers.go @@ -15,6 +15,7 @@ import ( "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto" "github.com/pkg/errors" + chain_selectors "github.com/smartcontractkit/chain-selectors" "github.com/smartcontractkit/chainlink-common/pkg/logger" ) @@ -152,3 +153,14 @@ func DeployContract[C any]( } return &contractDeploy, nil } + +func IsValidChainSelector(cs uint64) error { + if cs == 0 { + return fmt.Errorf("chain selector must be set") + } + _, err := chain_selectors.ChainIdFromSelector(cs) + if err != nil { + return fmt.Errorf("invalid chain selector: %d - %w", cs, err) + } + return nil +} From 80e0ee1ac0c7dd839d1b7c7d7d879566dcc15f6f Mon Sep 17 00:00:00 2001 From: AnieeG Date: Mon, 18 Nov 2024 13:01:31 -0800 Subject: [PATCH 3/4] rename --- deployment/ccip/changeset/{Jobspec_test.go => jobspec_test.go} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename deployment/ccip/changeset/{Jobspec_test.go => jobspec_test.go} (100%) diff --git a/deployment/ccip/changeset/Jobspec_test.go b/deployment/ccip/changeset/jobspec_test.go similarity index 100% rename from deployment/ccip/changeset/Jobspec_test.go rename to deployment/ccip/changeset/jobspec_test.go From c6f6fd09f82bb06507657695005f4b949740ef97 Mon Sep 17 00:00:00 2001 From: AnieeG Date: Mon, 18 Nov 2024 14:30:16 -0800 Subject: [PATCH 4/4] fix DeployChainContracts --- deployment/ccip/changeset/deploy_chain.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deployment/ccip/changeset/deploy_chain.go b/deployment/ccip/changeset/deploy_chain.go index 7de2de40c37..68f350a9af7 100644 --- a/deployment/ccip/changeset/deploy_chain.go +++ b/deployment/ccip/changeset/deploy_chain.go @@ -9,7 +9,7 @@ import ( ccipdeployment "github.com/smartcontractkit/chainlink/deployment/ccip" ) -var _ deployment.ChangeSet[ccipdeployment.DeployCCIPContractConfig] = InitialDeploy +var _ deployment.ChangeSet[DeployChainContractsConfig] = DeployChainContracts func DeployChainContracts(env deployment.Environment, c DeployChainContractsConfig) (deployment.ChangesetOutput, error) { newAddresses := deployment.NewMemoryAddressBook()