From 22fafc19f5d4857ba74bfda90a70bb87415825fa Mon Sep 17 00:00:00 2001 From: 0xAustinWang Date: Wed, 4 Dec 2024 18:32:45 +0800 Subject: [PATCH 01/26] wip --- .../ccip/changeset/cs_add_chain_test.go | 10 ++----- .../ccip/changeset/cs_deploy_chain_test.go | 9 +------ deployment/ccip/changeset/test_helpers.go | 8 +----- .../common/changeset/internal/mcms_test.go | 20 ++++++-------- .../common/changeset/mcms_test_helpers.go | 27 ++++++++++++++++--- deployment/environment.go | 5 ++-- deployment/environment/devenv/jd.go | 7 +++++ deployment/evm_kmsclient.go | 19 +++++++++++++ .../changeset/accept_ownership_test.go | 9 +------ .../changeset/transfer_ownership_test.go | 9 +------ .../testsetups/ccip/test_helpers.go | 8 +----- 11 files changed, 68 insertions(+), 63 deletions(-) diff --git a/deployment/ccip/changeset/cs_add_chain_test.go b/deployment/ccip/changeset/cs_add_chain_test.go index 96727d0e4f8..6d93940418d 100644 --- a/deployment/ccip/changeset/cs_add_chain_test.go +++ b/deployment/ccip/changeset/cs_add_chain_test.go @@ -1,7 +1,6 @@ package changeset import ( - "math/big" "testing" "time" @@ -45,13 +44,8 @@ func TestAddChainInbound(t *testing.T) { require.NoError(t, err) require.NoError(t, e.Env.ExistingAddresses.Merge(newAddresses)) - cfg := commontypes.MCMSWithTimelockConfig{ - Canceller: commonchangeset.SingleGroupMCMS(t), - Bypasser: commonchangeset.SingleGroupMCMS(t), - Proposer: commonchangeset.SingleGroupMCMS(t), - TimelockExecutors: e.Env.AllDeployerKeys(), - TimelockMinDelay: big.NewInt(0), - } + cfg := commonchangeset.CreateMCMSConfig(t, e.Env.AllDeployerKeys()) + out, err := commonchangeset.DeployMCMSWithTimelock(e.Env, map[uint64]commontypes.MCMSWithTimelockConfig{ initialDeploy[0]: cfg, initialDeploy[1]: cfg, diff --git a/deployment/ccip/changeset/cs_deploy_chain_test.go b/deployment/ccip/changeset/cs_deploy_chain_test.go index f599ab2d6f3..90127b7f39d 100644 --- a/deployment/ccip/changeset/cs_deploy_chain_test.go +++ b/deployment/ccip/changeset/cs_deploy_chain_test.go @@ -3,7 +3,6 @@ package changeset import ( "encoding/json" "fmt" - "math/big" "testing" "github.com/stretchr/testify/require" @@ -51,13 +50,7 @@ func TestDeployChainContractsChangeset(t *testing.T) { cfg := make(map[uint64]commontypes.MCMSWithTimelockConfig) for _, chain := range e.AllChainSelectors() { - cfg[chain] = commontypes.MCMSWithTimelockConfig{ - Canceller: commonchangeset.SingleGroupMCMS(t), - Bypasser: commonchangeset.SingleGroupMCMS(t), - Proposer: commonchangeset.SingleGroupMCMS(t), - TimelockExecutors: e.AllDeployerKeys(), - TimelockMinDelay: big.NewInt(0), - } + cfg[chain] = commonchangeset.CreateMCMSConfig(t, e.AllDeployerKeys()) } output, err = commonchangeset.DeployMCMSWithTimelock(e, cfg) require.NoError(t, err) diff --git a/deployment/ccip/changeset/test_helpers.go b/deployment/ccip/changeset/test_helpers.go index cd135cf7975..9705b8cae02 100644 --- a/deployment/ccip/changeset/test_helpers.go +++ b/deployment/ccip/changeset/test_helpers.go @@ -269,13 +269,7 @@ func NewMemoryEnvironmentWithJobsAndContracts(t *testing.T, lggr logger.Logger, allChains := e.Env.AllChainSelectors() mcmsCfg := make(map[uint64]commontypes.MCMSWithTimelockConfig) for _, c := range e.Env.AllChainSelectors() { - mcmsCfg[c] = commontypes.MCMSWithTimelockConfig{ - Canceller: commonchangeset.SingleGroupMCMS(t), - Bypasser: commonchangeset.SingleGroupMCMS(t), - Proposer: commonchangeset.SingleGroupMCMS(t), - TimelockExecutors: e.Env.AllDeployerKeys(), - TimelockMinDelay: big.NewInt(0), - } + mcmsCfg[c] = commonchangeset.CreateMCMSConfig(t, e.Env.AllDeployerKeys()) } var usdcChains []uint64 if tCfg != nil && tCfg.IsUSDC { diff --git a/deployment/common/changeset/internal/mcms_test.go b/deployment/common/changeset/internal/mcms_test.go index 9969a0e5bc9..7b857da80e3 100644 --- a/deployment/common/changeset/internal/mcms_test.go +++ b/deployment/common/changeset/internal/mcms_test.go @@ -2,7 +2,6 @@ package internal_test import ( "encoding/json" - "math/big" "testing" "github.com/ethereum/go-ethereum/common" @@ -23,8 +22,10 @@ func TestDeployMCMSWithConfig(t *testing.T) { chainsel.TEST_90000001.EvmChainID, }) ab := deployment.NewMemoryAddressBook() - _, err := internal.DeployMCMSWithConfig(types.ProposerManyChainMultisig, - lggr, chains[chainsel.TEST_90000001.Selector], ab, changeset.SingleGroupMCMS(t)) + m, err := changeset.SingleGroupMCMS() + require.NoError(t, err) + _, err = internal.DeployMCMSWithConfig(types.ProposerManyChainMultisig, + lggr, chains[chainsel.TEST_90000001.Selector], ab, m) require.NoError(t, err) } @@ -36,15 +37,10 @@ func TestDeployMCMSWithTimelockContracts(t *testing.T) { ab := deployment.NewMemoryAddressBook() _, err := internal.DeployMCMSWithTimelockContracts(lggr, chains[chainsel.TEST_90000001.Selector], - ab, types.MCMSWithTimelockConfig{ - Canceller: changeset.SingleGroupMCMS(t), - Bypasser: changeset.SingleGroupMCMS(t), - Proposer: changeset.SingleGroupMCMS(t), - TimelockExecutors: []common.Address{ - chains[chainsel.TEST_90000001.Selector].DeployerKey.From, - }, - TimelockMinDelay: big.NewInt(0), - }) + ab, + changeset.CreateMCMSConfig(t, []common.Address{ + chains[chainsel.TEST_90000001.Selector].DeployerKey.From, + })) require.NoError(t, err) addresses, err := ab.AddressesForChain(chainsel.TEST_90000001.Selector) require.NoError(t, err) diff --git a/deployment/common/changeset/mcms_test_helpers.go b/deployment/common/changeset/mcms_test_helpers.go index 3951149815c..90341c13668 100644 --- a/deployment/common/changeset/mcms_test_helpers.go +++ b/deployment/common/changeset/mcms_test_helpers.go @@ -4,6 +4,8 @@ import ( "bytes" "context" "crypto/ecdsa" + commontypes "github.com/smartcontractkit/chainlink/deployment/common/types" + "math/big" "testing" "github.com/ethereum/go-ethereum/accounts/abi/bind" @@ -33,15 +35,34 @@ func init() { TestXXXMCMSSigner = key } -func SingleGroupMCMS(t *testing.T) config.Config { +func SingleGroupMCMS() (config.Config, error) { publicKey := TestXXXMCMSSigner.Public().(*ecdsa.PublicKey) // Convert the public key to an Ethereum address address := crypto.PubkeyToAddress(*publicKey) c, err := config.NewConfig(1, []common.Address{address}, []config.Config{}) - require.NoError(t, err) - return *c + + if err != nil { + return config.Config{}, err + } + return *c, nil } +func CreateMCMSConfig(t *testing.T, depKeys []common.Address) commontypes.MCMSWithTimelockConfig { + c, err := SingleGroupMCMS() + require.NoError(t, err) + b, err := SingleGroupMCMS() + require.NoError(t, err) + p, err := SingleGroupMCMS() + require.NoError(t, err) + return commontypes.MCMSWithTimelockConfig{ + Canceller: c, + Bypasser: b, + Proposer: p, + TimelockExecutors: depKeys, + TimelockMinDelay: big.NewInt(0), + } + +} func SignProposal(t *testing.T, env deployment.Environment, proposal *timelock.MCMSWithTimelockProposal) *mcms.Executor { executorClients := make(map[mcms.ChainIdentifier]mcms.ContractDeployBackend) for _, chain := range env.Chains { diff --git a/deployment/environment.go b/deployment/environment.go index d356148c225..b4f965e34c4 100644 --- a/deployment/environment.go +++ b/deployment/environment.go @@ -409,6 +409,7 @@ func NodeInfo(nodeIDs []string, oc NodeChainConfigsLister) (Nodes, error) { } type CapabilityRegistryConfig struct { - EVMChainID uint64 // chain id of the chain the CR is deployed on - Contract common.Address // address of the CR contract + NetworkType string + EVMChainID uint64 // chain id of the chain the CR is deployed on + Contract common.Address // address of the CR contract } diff --git a/deployment/environment/devenv/jd.go b/deployment/environment/devenv/jd.go index 818f9b09400..a2328d8204e 100644 --- a/deployment/environment/devenv/jd.go +++ b/deployment/environment/devenv/jd.go @@ -61,6 +61,13 @@ func gapTokenInterceptor(token string) grpc.UnaryClientInterceptor { } } +func (cfg JDConfig) IsEmpty() bool { + if cfg.GRPC == "" && cfg.WSRPC == "" { + return true + } + return false +} + func NewJDConnection(cfg JDConfig) (*grpc.ClientConn, error) { opts := []grpc.DialOption{} interceptors := []grpc.UnaryClientInterceptor{} diff --git a/deployment/evm_kmsclient.go b/deployment/evm_kmsclient.go index 07af77523c8..b28a3842930 100644 --- a/deployment/evm_kmsclient.go +++ b/deployment/evm_kmsclient.go @@ -8,6 +8,7 @@ import ( "encoding/hex" "fmt" "math/big" + "os" "github.com/aws/aws-sdk-go/aws/session" @@ -231,3 +232,21 @@ var awsSessionFromProfileFn = func(config KMS) *session.Session { }, })) } + +func KMSConfigFromEnvVars() (KMS, error) { + var config KMS + var exists bool + config.KmsDeployerKeyId, exists = os.LookupEnv("KMS_DEPLOYER_KEY_ID") + if !exists { + return config, fmt.Errorf("KMS_DEPLOYER_KEY_ID is required") + } + config.KmsDeployerKeyRegion, exists = os.LookupEnv("KMS_DEPLOYER_KEY_REGION") + if !exists { + return config, fmt.Errorf("KMS_DEPLOYER_KEY_REGION is required") + } + config.AwsProfileName, exists = os.LookupEnv("AWS_PROFILE") + if !exists { + return config, fmt.Errorf("AWS_PROFILE is required") + } + return config, nil +} diff --git a/deployment/keystone/changeset/accept_ownership_test.go b/deployment/keystone/changeset/accept_ownership_test.go index 996ff08c149..0b1d0bc4058 100644 --- a/deployment/keystone/changeset/accept_ownership_test.go +++ b/deployment/keystone/changeset/accept_ownership_test.go @@ -1,7 +1,6 @@ package changeset_test import ( - "math/big" "testing" "time" @@ -51,13 +50,7 @@ func TestAcceptAllOwnership(t *testing.T) { require.NoError(t, err) chMcms, err := commonchangeset.DeployMCMSWithTimelock(env, map[uint64]types.MCMSWithTimelockConfig{ - registrySel: { - Canceller: commonchangeset.SingleGroupMCMS(t), - Bypasser: commonchangeset.SingleGroupMCMS(t), - Proposer: commonchangeset.SingleGroupMCMS(t), - TimelockExecutors: env.AllDeployerKeys(), - TimelockMinDelay: big.NewInt(0), - }, + registrySel: commonchangeset.CreateMCMSConfig(t, env.AllDeployerKeys()), }) err = env.ExistingAddresses.Merge(chMcms.AddressBook) require.NoError(t, err) diff --git a/deployment/keystone/changeset/transfer_ownership_test.go b/deployment/keystone/changeset/transfer_ownership_test.go index dc5630076bd..1dafba56939 100644 --- a/deployment/keystone/changeset/transfer_ownership_test.go +++ b/deployment/keystone/changeset/transfer_ownership_test.go @@ -1,7 +1,6 @@ package changeset_test import ( - "math/big" "testing" "github.com/smartcontractkit/chainlink-common/pkg/logger" @@ -50,13 +49,7 @@ func TestTransferAllOwnership(t *testing.T) { require.NoError(t, err) chMcms, err := commonchangeset.DeployMCMSWithTimelock(env, map[uint64]types.MCMSWithTimelockConfig{ - registrySel: { - Canceller: commonchangeset.SingleGroupMCMS(t), - Bypasser: commonchangeset.SingleGroupMCMS(t), - Proposer: commonchangeset.SingleGroupMCMS(t), - TimelockExecutors: env.AllDeployerKeys(), - TimelockMinDelay: big.NewInt(0), - }, + registrySel: commonchangeset.CreateMCMSConfig(t, env.AllDeployerKeys()), }) err = env.ExistingAddresses.Merge(chMcms.AddressBook) require.NoError(t, err) diff --git a/integration-tests/testsetups/ccip/test_helpers.go b/integration-tests/testsetups/ccip/test_helpers.go index 8ffce77cc6b..46f386f7ae1 100644 --- a/integration-tests/testsetups/ccip/test_helpers.go +++ b/integration-tests/testsetups/ccip/test_helpers.go @@ -142,13 +142,7 @@ func NewLocalDevEnvironment( } mcmsCfg := make(map[uint64]commontypes.MCMSWithTimelockConfig) for _, c := range env.AllChainSelectors() { - mcmsCfg[c] = commontypes.MCMSWithTimelockConfig{ - Canceller: commonchangeset.SingleGroupMCMS(t), - Bypasser: commonchangeset.SingleGroupMCMS(t), - Proposer: commonchangeset.SingleGroupMCMS(t), - TimelockExecutors: env.AllDeployerKeys(), - TimelockMinDelay: big.NewInt(0), - } + mcmsCfg[c] = commonchangeset.CreateMCMSConfig(t, env.AllDeployerKeys()) } // Need to deploy prerequisites first so that we can form the USDC config // no proposals to be made, timelock can be passed as nil here From ea946d014fc3acc8d6461cfbf78aad6828cbfaa2 Mon Sep 17 00:00:00 2001 From: 0xAustinWang Date: Wed, 4 Dec 2024 20:53:48 +0800 Subject: [PATCH 02/26] test crib integration flow --- deployment/address_book.go | 4 +- .../ccip/changeset/cs_add_chain_test.go | 5 +- deployment/ccip/changeset/cs_deploy_chain.go | 4 +- .../ccip/changeset/cs_deploy_chain_test.go | 3 +- deployment/ccip/changeset/cs_home_chain.go | 6 +- deployment/ccip/changeset/test_helpers.go | 5 +- .../common/changeset/internal/mcms_test.go | 10 +- .../common/changeset/mcms_test_helpers.go | 16 +- deployment/environment/crib/ccip_deployer.go | 158 ++++++++++++++++++ deployment/environment/crib/types.go | 39 +++++ deployment/environment/devenv/chain.go | 35 +++- deployment/environment/devenv/environment.go | 44 ++--- .../changeset/accept_ownership_test.go | 4 +- .../changeset/transfer_ownership_test.go | 3 +- integration-tests/testconfig/ccip/config.go | 66 +++++--- .../testsetups/ccip/test_helpers.go | 32 ++-- 16 files changed, 346 insertions(+), 88 deletions(-) create mode 100644 deployment/environment/crib/ccip_deployer.go create mode 100644 deployment/environment/crib/types.go diff --git a/deployment/address_book.go b/deployment/address_book.go index 7997507554f..28fc94e09a6 100644 --- a/deployment/address_book.go +++ b/deployment/address_book.go @@ -89,8 +89,10 @@ type AddressBook interface { Remove(ab AddressBook) error } +type AddressesByChain map[uint64]map[string]TypeAndVersion + type AddressBookMap struct { - addressesByChain map[uint64]map[string]TypeAndVersion + addressesByChain AddressesByChain mtx sync.RWMutex } diff --git a/deployment/ccip/changeset/cs_add_chain_test.go b/deployment/ccip/changeset/cs_add_chain_test.go index 6d93940418d..98e8057f5d0 100644 --- a/deployment/ccip/changeset/cs_add_chain_test.go +++ b/deployment/ccip/changeset/cs_add_chain_test.go @@ -44,7 +44,8 @@ func TestAddChainInbound(t *testing.T) { require.NoError(t, err) require.NoError(t, e.Env.ExistingAddresses.Merge(newAddresses)) - cfg := commonchangeset.CreateMCMSConfig(t, e.Env.AllDeployerKeys()) + cfg, err := commonchangeset.CreateMCMSConfig(e.Env.AllDeployerKeys()) + require.NoError(t, err) out, err := commonchangeset.DeployMCMSWithTimelock(e.Env, map[uint64]commontypes.MCMSWithTimelockConfig{ initialDeploy[0]: cfg, @@ -60,7 +61,7 @@ func TestAddChainInbound(t *testing.T) { for _, chain := range initialDeploy { chainConfig[chain] = DefaultOCRParams(e.FeedChainSel, nil, nil) } - err = deployCCIPContracts(e.Env, newAddresses, NewChainsConfig{ + err = DeployCCIPContracts(e.Env, newAddresses, NewChainsConfig{ HomeChainSel: e.HomeChainSel, FeedChainSel: e.FeedChainSel, ChainConfigByChain: chainConfig, diff --git a/deployment/ccip/changeset/cs_deploy_chain.go b/deployment/ccip/changeset/cs_deploy_chain.go index b57c00fd796..72219ede5e2 100644 --- a/deployment/ccip/changeset/cs_deploy_chain.go +++ b/deployment/ccip/changeset/cs_deploy_chain.go @@ -65,7 +65,7 @@ func (c DeployChainContractsConfig) Validate() error { return nil } -// deployCCIPContracts assumes the following contracts are deployed: +// DeployCCIPContracts assumes the following contracts are deployed: // - Capability registry // - CCIP home // - RMN home @@ -74,7 +74,7 @@ func (c DeployChainContractsConfig) Validate() error { // It then deploys the rest of the CCIP chain contracts to the selected chains // registers the nodes with the capability registry and creates a DON for // each new chain. -func deployCCIPContracts( +func DeployCCIPContracts( e deployment.Environment, ab deployment.AddressBook, c NewChainsConfig) error { diff --git a/deployment/ccip/changeset/cs_deploy_chain_test.go b/deployment/ccip/changeset/cs_deploy_chain_test.go index 90127b7f39d..01c2e17f76b 100644 --- a/deployment/ccip/changeset/cs_deploy_chain_test.go +++ b/deployment/ccip/changeset/cs_deploy_chain_test.go @@ -50,7 +50,8 @@ func TestDeployChainContractsChangeset(t *testing.T) { cfg := make(map[uint64]commontypes.MCMSWithTimelockConfig) for _, chain := range e.AllChainSelectors() { - cfg[chain] = commonchangeset.CreateMCMSConfig(t, e.AllDeployerKeys()) + cfg[chain], err = commonchangeset.CreateMCMSConfig(e.AllDeployerKeys()) + require.NoError(t, err) } output, err = commonchangeset.DeployMCMSWithTimelock(e, cfg) require.NoError(t, err) diff --git a/deployment/ccip/changeset/cs_home_chain.go b/deployment/ccip/changeset/cs_home_chain.go index 0df8d87affb..6474da2baf8 100644 --- a/deployment/ccip/changeset/cs_home_chain.go +++ b/deployment/ccip/changeset/cs_home_chain.go @@ -82,9 +82,9 @@ func (c DeployHomeChainConfig) Validate() error { return nil } -// deployCapReg deploys the CapabilitiesRegistry contract if it is not already deployed +// DeployCapReg deploys the CapabilitiesRegistry contract if it is not already deployed // and returns a deployment.ContractDeploy struct with the address and contract instance. -func deployCapReg( +func DeployCapReg( lggr logger.Logger, state CCIPOnChainState, ab deployment.AddressBook, @@ -133,7 +133,7 @@ func deployHomeChain( return nil, fmt.Errorf("failed to load onchain state: %w", err) } // Deploy CapabilitiesRegistry, CCIPHome, RMNHome - capReg, err := deployCapReg(lggr, state, ab, chain) + capReg, err := DeployCapReg(lggr, state, ab, chain) if err != nil { return nil, err } diff --git a/deployment/ccip/changeset/test_helpers.go b/deployment/ccip/changeset/test_helpers.go index 9705b8cae02..92546fa04ce 100644 --- a/deployment/ccip/changeset/test_helpers.go +++ b/deployment/ccip/changeset/test_helpers.go @@ -136,7 +136,7 @@ func DeployTestContracts(t *testing.T, linkPrice *big.Int, wethPrice *big.Int, ) deployment.CapabilityRegistryConfig { - capReg, err := deployCapReg(lggr, + capReg, err := DeployCapReg(lggr, // deploying cap reg for the first time on a blank chain state CCIPOnChainState{ Chains: make(map[uint64]CCIPChainState), @@ -269,7 +269,8 @@ func NewMemoryEnvironmentWithJobsAndContracts(t *testing.T, lggr logger.Logger, allChains := e.Env.AllChainSelectors() mcmsCfg := make(map[uint64]commontypes.MCMSWithTimelockConfig) for _, c := range e.Env.AllChainSelectors() { - mcmsCfg[c] = commonchangeset.CreateMCMSConfig(t, e.Env.AllDeployerKeys()) + mcmsCfg[c], err = commonchangeset.CreateMCMSConfig(e.Env.AllDeployerKeys()) + require.NoError(t, err) } var usdcChains []uint64 if tCfg != nil && tCfg.IsUSDC { diff --git a/deployment/common/changeset/internal/mcms_test.go b/deployment/common/changeset/internal/mcms_test.go index 7b857da80e3..c3e9900b243 100644 --- a/deployment/common/changeset/internal/mcms_test.go +++ b/deployment/common/changeset/internal/mcms_test.go @@ -35,12 +35,14 @@ func TestDeployMCMSWithTimelockContracts(t *testing.T) { chainsel.TEST_90000001.EvmChainID, }) ab := deployment.NewMemoryAddressBook() - _, err := internal.DeployMCMSWithTimelockContracts(lggr, + mcmsConfig, err := changeset.CreateMCMSConfig([]common.Address{ + chains[chainsel.TEST_90000001.Selector].DeployerKey.From, + }) + require.NoError(t, err) + _, err = internal.DeployMCMSWithTimelockContracts(lggr, chains[chainsel.TEST_90000001.Selector], ab, - changeset.CreateMCMSConfig(t, []common.Address{ - chains[chainsel.TEST_90000001.Selector].DeployerKey.From, - })) + mcmsConfig) require.NoError(t, err) addresses, err := ab.AddressesForChain(chainsel.TEST_90000001.Selector) require.NoError(t, err) diff --git a/deployment/common/changeset/mcms_test_helpers.go b/deployment/common/changeset/mcms_test_helpers.go index 90341c13668..9b337a34a30 100644 --- a/deployment/common/changeset/mcms_test_helpers.go +++ b/deployment/common/changeset/mcms_test_helpers.go @@ -47,20 +47,26 @@ func SingleGroupMCMS() (config.Config, error) { return *c, nil } -func CreateMCMSConfig(t *testing.T, depKeys []common.Address) commontypes.MCMSWithTimelockConfig { +func CreateMCMSConfig(depKeys []common.Address) (commontypes.MCMSWithTimelockConfig, error) { c, err := SingleGroupMCMS() - require.NoError(t, err) + if err != nil { + return commontypes.MCMSWithTimelockConfig{}, err + } b, err := SingleGroupMCMS() - require.NoError(t, err) + if err != nil { + return commontypes.MCMSWithTimelockConfig{}, err + } p, err := SingleGroupMCMS() - require.NoError(t, err) + if err != nil { + return commontypes.MCMSWithTimelockConfig{}, err + } return commontypes.MCMSWithTimelockConfig{ Canceller: c, Bypasser: b, Proposer: p, TimelockExecutors: depKeys, TimelockMinDelay: big.NewInt(0), - } + }, nil } func SignProposal(t *testing.T, env deployment.Environment, proposal *timelock.MCMSWithTimelockProposal) *mcms.Executor { diff --git a/deployment/environment/crib/ccip_deployer.go b/deployment/environment/crib/ccip_deployer.go new file mode 100644 index 00000000000..335f456d2ac --- /dev/null +++ b/deployment/environment/crib/ccip_deployer.go @@ -0,0 +1,158 @@ +package crib + +import ( + "context" + "errors" + chainsel "github.com/smartcontractkit/chain-selectors" + jobv1 "github.com/smartcontractkit/chainlink-protos/job-distributor/v1/job" + commonchangeset "github.com/smartcontractkit/chainlink/deployment/common/changeset" + commontypes "github.com/smartcontractkit/chainlink/deployment/common/types" + "golang.org/x/exp/maps" + "math/big" + + "github.com/smartcontractkit/chainlink/deployment/environment/devenv" + + "github.com/smartcontractkit/chainlink/deployment" + "github.com/smartcontractkit/chainlink/deployment/ccip/changeset" + "github.com/smartcontractkit/chainlink/v2/core/logger" + "github.com/smartcontractkit/chainlink/v2/core/services/relay" +) + +// DeployHomeChainContracts deploys the home chain contracts so that the chainlink nodes can be started with the CR address in Capabilities.ExternalRegistry +func DeployHomeChainContracts(lggr logger.Logger, envConfig devenv.EnvironmentConfig, homeChainSel uint64) (deployment.CapabilityRegistryConfig, deployment.AddressBook, error) { + chains, err := devenv.NewChains(lggr, envConfig.Chains) + if err != nil { + return deployment.CapabilityRegistryConfig{}, nil, err + } + ab := deployment.NewMemoryAddressBook() + capReg, err := changeset.DeployCapReg(lggr, + // deploying cap reg for the first time on a blank chain state + changeset.CCIPOnChainState{ + Chains: make(map[uint64]changeset.CCIPChainState), + }, ab, chains[homeChainSel]) + if err != nil { + return deployment.CapabilityRegistryConfig{}, nil, err + } + evmChainID, err := chainsel.ChainIdFromSelector(homeChainSel) + if err != nil { + return deployment.CapabilityRegistryConfig{}, nil, err + } + return deployment.CapabilityRegistryConfig{ + NetworkType: relay.NetworkEVM, + EVMChainID: evmChainID, + Contract: capReg.Address, + }, ab, nil +} + +func DeployCCIPAndAddLanes(lggr logger.Logger, envCfg devenv.EnvironmentConfig, homeChainSel, feedChainSel uint64, ab deployment.AddressBook) (DeployCCIPOutput, error) { + ctx := context.Background() + e, _, err := devenv.NewEnvironment(func() context.Context { return context.Background() }, lggr, envCfg) + if err != nil { + return DeployCCIPOutput{}, err + } + if e == nil { + return DeployCCIPOutput{}, errors.New("environment is nil") + } + + _, err = changeset.DeployFeeds(lggr, ab, e.Chains[feedChainSel], big.NewInt(9000000), big.NewInt(9000000)) + if err != nil { + return DeployCCIPOutput{}, err + } + + e.ExistingAddresses = ab + tenv := changeset.DeployedEnv{ + Env: *e, + HomeChainSel: homeChainSel, + FeedChainSel: feedChainSel, + } + chains := tenv.Env.AllChainSelectors() + out, err := changeset.DeployPrerequisites(tenv.Env, changeset.DeployPrerequisiteConfig{ + ChainSelectors: chains, + }) + if err != nil { + return DeployCCIPOutput{}, err + } + err = tenv.Env.ExistingAddresses.Merge(out.AddressBook) + if err != nil { + return DeployCCIPOutput{}, err + } + + state, err := changeset.LoadOnchainState(tenv.Env) + if err != nil { + return DeployCCIPOutput{}, err + } + if state.Chains[tenv.HomeChainSel].LinkToken == nil { + return DeployCCIPOutput{}, errors.New("link token not deployed") + } + + // Deploy contracts to new chain + cfg, err := commonchangeset.CreateMCMSConfig(tenv.Env.AllDeployerKeys()) + if err != nil { + return DeployCCIPOutput{}, err + } + var mcmsConfigs = make(map[uint64]commontypes.MCMSWithTimelockConfig) + for _, chain := range chains { + mcmsConfigs[chain] = cfg + } + out, err = commonchangeset.DeployMCMSWithTimelock(tenv.Env, mcmsConfigs) + if err != nil { + return DeployCCIPOutput{}, err + } + err = tenv.Env.ExistingAddresses.Merge(out.AddressBook) + if err != nil { + return DeployCCIPOutput{}, err + } + + chainConfig := make(map[uint64]changeset.CCIPOCRParams) + for _, chain := range chains { + chainConfig[chain] = changeset.DefaultOCRParams(tenv.FeedChainSel, nil, nil) + } + err = changeset.DeployCCIPContracts(tenv.Env, tenv.Env.ExistingAddresses, changeset.NewChainsConfig{ + HomeChainSel: tenv.HomeChainSel, + FeedChainSel: tenv.FeedChainSel, + ChainConfigByChain: chainConfig, + OCRSecrets: deployment.XXXGenerateTestOCRSecrets(), + }) + if err != nil { + return DeployCCIPOutput{}, err + } + // Get new state after migration. + + state, err = changeset.LoadOnchainState(tenv.Env) + if err != nil { + return DeployCCIPOutput{}, err + } + + out, err = changeset.CCIPCapabilityJobspec(tenv.Env, struct{}{}) + if err != nil { + return DeployCCIPOutput{}, err + } + for nodeID, jobs := range out.JobSpecs { + for _, job := range jobs { + // Note these auto-accept + _, err := tenv.Env.Offchain.ProposeJob(ctx, + &jobv1.ProposeJobRequest{ + NodeId: nodeID, + Spec: job, + }) + if err != nil { + return DeployCCIPOutput{}, err + } + } + } + + // Add all lanes + err = changeset.AddLanesForAll(tenv.Env, state) + if err != nil { + return DeployCCIPOutput{}, err + } + + addresses, err := ab.Addresses() + if err != nil { + return DeployCCIPOutput{}, err + } + return DeployCCIPOutput{ + AddressBook: *deployment.NewMemoryAddressBookFromMap(addresses), + NodeIDs: maps.Keys(out.JobSpecs), + }, err +} diff --git a/deployment/environment/crib/types.go b/deployment/environment/crib/types.go new file mode 100644 index 00000000000..d0513ef9575 --- /dev/null +++ b/deployment/environment/crib/types.go @@ -0,0 +1,39 @@ +package crib + +import ( + "context" + "github.com/smartcontractkit/chainlink-common/pkg/logger" + "github.com/smartcontractkit/chainlink/deployment" + "github.com/smartcontractkit/chainlink/deployment/environment/devenv" +) + +const ( + CRIB_ENV_NAME = "Crib Environment" +) + +type DeployOutput struct { + NodeIDs []string + Chains []devenv.ChainConfig // chain selector -> Chain Config + AddressBook deployment.AddressBook // Addresses of all contracts +} + +type DeployCCIPOutput struct { + AddressBook deployment.AddressBookMap + NodeIDs []string +} + +func NewDeployEnvironmentFromCribOutput(lggr logger.Logger, output DeployOutput) (*deployment.Environment, error) { + chains, err := devenv.NewChains(lggr, output.Chains) + if err != nil { + return nil, err + } + return deployment.NewEnvironment( + CRIB_ENV_NAME, + lggr, + output.AddressBook, + chains, + output.NodeIDs, + nil, // todo: populate the offchain client using output.DON + func() context.Context { return context.Background() }, + ), nil +} diff --git a/deployment/environment/devenv/chain.go b/deployment/environment/devenv/chain.go index cdbaf35e860..09ab6dfc7be 100644 --- a/deployment/environment/devenv/chain.go +++ b/deployment/environment/devenv/chain.go @@ -3,6 +3,8 @@ package devenv import ( "context" "fmt" + "github.com/ethereum/go-ethereum/crypto" + "math/big" "time" "github.com/ethereum/go-ethereum/accounts/abi/bind" @@ -76,7 +78,7 @@ func NewChains(logger logger.Logger, configs []ChainConfig) (map[uint64]deployme if receipt.Status == 0 { errReason, err := deployment.GetErrorReasonFromTx(ec, chainCfg.DeployerKey.From, tx, receipt) if err == nil && errReason != "" { - return blockNumber, fmt.Errorf("tx %s reverted,error reason: %s", tx.Hash().Hex(), errReason) + return blockNumber, fmt.Errorf("tx %s reverted, error reason: %s", tx.Hash().Hex(), errReason) } return blockNumber, fmt.Errorf("tx %s reverted, could not decode error reason", tx.Hash().Hex()) } @@ -86,3 +88,34 @@ func NewChains(logger logger.Logger, configs []ChainConfig) (map[uint64]deployme } return chains, nil } + +// SetDeployerKey sets the deployer key for the chain. If private key is not provided, it fetches the deployer key from KMS. +func (c *ChainConfig) SetDeployerKey(pvtKeyStr *string) error { + if pvtKeyStr != nil && *pvtKeyStr != "" { + pvtKey, err := crypto.HexToECDSA(*pvtKeyStr) + if err != nil { + return fmt.Errorf("failed to convert private key to ECDSA: %w", err) + } + deployer, err := bind.NewKeyedTransactorWithChainID(pvtKey, new(big.Int).SetUint64(c.ChainID)) + if err != nil { + return fmt.Errorf("failed to create transactor: %w", err) + } + fmt.Printf("Deployer Address: %s for chain id %d\n", deployer.From.Hex(), c.ChainID) + c.DeployerKey = deployer + return nil + } + kmsConfig, err := deployment.KMSConfigFromEnvVars() + if err != nil { + return fmt.Errorf("failed to get kms config from env vars: %w", err) + } + kmsClient, err := deployment.NewKMSClient(kmsConfig) + if err != nil { + return fmt.Errorf("failed to create KMS client: %w", err) + } + evmKMSClient := deployment.NewEVMKMSClient(kmsClient, kmsConfig.KmsDeployerKeyId) + c.DeployerKey, err = evmKMSClient.GetKMSTransactOpts(context.Background(), new(big.Int).SetUint64(c.ChainID)) + if err != nil { + return fmt.Errorf("failed to get transactor from KMS client: %w", err) + } + return nil +} diff --git a/deployment/environment/devenv/environment.go b/deployment/environment/devenv/environment.go index e9586467acd..7d2a8f62ce4 100644 --- a/deployment/environment/devenv/environment.go +++ b/deployment/environment/devenv/environment.go @@ -14,10 +14,8 @@ const ( ) type EnvironmentConfig struct { - Chains []ChainConfig - HomeChainSelector uint64 - FeedChainSelector uint64 - JDConfig JDConfig + Chains []ChainConfig + JDConfig JDConfig } func NewEnvironment(ctx func() context.Context, lggr logger.Logger, config EnvironmentConfig) (*deployment.Environment, *DON, error) { @@ -25,25 +23,31 @@ func NewEnvironment(ctx func() context.Context, lggr logger.Logger, config Envir if err != nil { return nil, nil, fmt.Errorf("failed to create chains: %w", err) } - offChain, err := NewJDClient(ctx(), config.JDConfig) - if err != nil { - return nil, nil, fmt.Errorf("failed to create JD client: %w", err) - } - jd, ok := offChain.(*JobDistributor) - if !ok { - return nil, nil, fmt.Errorf("offchain client does not implement JobDistributor") - } - if jd == nil { - return nil, nil, fmt.Errorf("offchain client is not set up") - } var nodeIDs []string - if jd.don != nil { - err = jd.don.CreateSupportedChains(ctx(), config.Chains, *jd) + var offChain deployment.OffchainClient + var don *DON + if !config.JDConfig.IsEmpty() { + offChain, err := NewJDClient(ctx(), config.JDConfig) if err != nil { - return nil, nil, err + return nil, nil, fmt.Errorf("failed to create JD client: %w", err) + } + + jd, ok := offChain.(*JobDistributor) + if !ok { + return nil, nil, fmt.Errorf("offchain client does not implement JobDistributor") + } + if jd == nil { + return nil, nil, fmt.Errorf("offchain client is not set up") + } + if jd.don != nil { + err = jd.don.CreateSupportedChains(ctx(), config.Chains, *jd) + if err != nil { + return nil, nil, err + } + nodeIDs = jd.don.NodeIds() + don = jd.don } - nodeIDs = jd.don.NodeIds() } return deployment.NewEnvironment( @@ -54,5 +58,5 @@ func NewEnvironment(ctx func() context.Context, lggr logger.Logger, config Envir nodeIDs, offChain, ctx, - ), jd.don, nil + ), don, nil } diff --git a/deployment/keystone/changeset/accept_ownership_test.go b/deployment/keystone/changeset/accept_ownership_test.go index 0b1d0bc4058..e7024dbca58 100644 --- a/deployment/keystone/changeset/accept_ownership_test.go +++ b/deployment/keystone/changeset/accept_ownership_test.go @@ -49,8 +49,10 @@ func TestAcceptAllOwnership(t *testing.T) { err = env.ExistingAddresses.Merge(chConsumer.AddressBook) require.NoError(t, err) + mcmsConfig, err := commonchangeset.CreateMCMSConfig(env.AllDeployerKeys()) + require.NoError(t, err) chMcms, err := commonchangeset.DeployMCMSWithTimelock(env, map[uint64]types.MCMSWithTimelockConfig{ - registrySel: commonchangeset.CreateMCMSConfig(t, env.AllDeployerKeys()), + registrySel: mcmsConfig, }) err = env.ExistingAddresses.Merge(chMcms.AddressBook) require.NoError(t, err) diff --git a/deployment/keystone/changeset/transfer_ownership_test.go b/deployment/keystone/changeset/transfer_ownership_test.go index 1dafba56939..caa42032345 100644 --- a/deployment/keystone/changeset/transfer_ownership_test.go +++ b/deployment/keystone/changeset/transfer_ownership_test.go @@ -48,8 +48,9 @@ func TestTransferAllOwnership(t *testing.T) { err = env.ExistingAddresses.Merge(chConsumer.AddressBook) require.NoError(t, err) + mcmsConfig, err := commonchangeset.CreateMCMSConfig(env.AllDeployerKeys()) chMcms, err := commonchangeset.DeployMCMSWithTimelock(env, map[uint64]types.MCMSWithTimelockConfig{ - registrySel: commonchangeset.CreateMCMSConfig(t, env.AllDeployerKeys()), + registrySel: mcmsConfig, }) err = env.ExistingAddresses.Merge(chMcms.AddressBook) require.NoError(t, err) diff --git a/integration-tests/testconfig/ccip/config.go b/integration-tests/testconfig/ccip/config.go index 6c1bfcbe560..8fbd2760e04 100644 --- a/integration-tests/testconfig/ccip/config.go +++ b/integration-tests/testconfig/ccip/config.go @@ -8,8 +8,6 @@ import ( "github.com/AlekSi/pointer" chainselectors "github.com/smartcontractkit/chain-selectors" - "github.com/smartcontractkit/chainlink-testing-framework/lib/blockchain" - ctfconfig "github.com/smartcontractkit/chainlink-testing-framework/lib/config" "github.com/smartcontractkit/chainlink/deployment/environment/nodeclient" @@ -147,52 +145,70 @@ func (o *JDConfig) GetJDDBVersion() string { } func (o *Config) Validate() error { - return nil -} - -func (o *Config) GetHomeChainSelector(evmNetworks []blockchain.EVMNetwork) (uint64, error) { + var chainIds []int64 + for _, net := range o.PrivateEthereumNetworks { + chainIds = append(chainIds, int64(net.EthereumChainConfig.ChainID)) + } homeChainSelector, err := strconv.ParseUint(pointer.GetString(o.HomeChainSelector), 10, 64) if err != nil { - return 0, err + return err } - isValid, err := IsSelectorValid(homeChainSelector, evmNetworks) + isValid, err := IsSelectorValid(homeChainSelector, chainIds) if err != nil { - return 0, err + return err } if !isValid { - return 0, ErrInvalidHomeChainSelector + return ErrInvalidHomeChainSelector } - return homeChainSelector, nil -} - -func (o *Config) GetFeedChainSelector(evmNetworks []blockchain.EVMNetwork) (uint64, error) { feedChainSelector, err := strconv.ParseUint(pointer.GetString(o.FeedChainSelector), 10, 64) if err != nil { - return 0, err + return err } - isValid, err := IsSelectorValid(feedChainSelector, evmNetworks) + isValid, err = IsSelectorValid(feedChainSelector, chainIds) if err != nil { - return 0, err + return err } if !isValid { - return 0, ErrInvalidFeedChainSelector + return ErrInvalidFeedChainSelector } - return feedChainSelector, nil + return nil } -func IsSelectorValid(selector uint64, evmNetworks []blockchain.EVMNetwork) (bool, error) { - chainId, err := chainselectors.ChainIdFromSelector(selector) +func (o *Config) GetHomeChainSelector() uint64 { + selector, _ := strconv.ParseUint(pointer.GetString(o.HomeChainSelector), 10, 64) + return selector +} + +func (o *Config) GetFeedChainSelector() uint64 { + selector, _ := strconv.ParseUint(pointer.GetString(o.FeedChainSelector), 10, 64) + return selector +} + +func IsSelectorValid(selector uint64, chainIds []int64) (bool, error) { + chainId, err := chainselectors.GetChainIDFromSelector(selector) if err != nil { return false, err } - if chainId >= math.MaxInt64 { + + id, err := convertToInt64(chainId) + if err != nil { return false, fmt.Errorf("chain id overflows int64: %d", chainId) } - id := int64(chainId) - for _, net := range evmNetworks { - if net.ChainID == id { + for _, cID := range chainIds { + if cID == id { return true, nil } } return false, nil } + +func convertToInt64(s string) (int64, error) { + num, err := strconv.ParseInt(s, 10, 64) + if err != nil { + return 0, err + } + if num > math.MaxInt64 { + return 0, fmt.Errorf("value %d is greater than math.MaxInt64", num) + } + return num, nil +} diff --git a/integration-tests/testsetups/ccip/test_helpers.go b/integration-tests/testsetups/ccip/test_helpers.go index 46f386f7ae1..8fe7396ec8a 100644 --- a/integration-tests/testsetups/ccip/test_helpers.go +++ b/integration-tests/testsetups/ccip/test_helpers.go @@ -34,6 +34,11 @@ import ( evmcfg "github.com/smartcontractkit/chainlink/v2/core/chains/evm/config/toml" corechainlink "github.com/smartcontractkit/chainlink/v2/core/services/chainlink" + "github.com/AlekSi/pointer" + "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/crypto" + "github.com/rs/zerolog" "github.com/smartcontractkit/chainlink/deployment/environment/devenv" clclient "github.com/smartcontractkit/chainlink/deployment/environment/nodeclient" "github.com/smartcontractkit/chainlink/integration-tests/actions" @@ -43,13 +48,6 @@ import ( tc "github.com/smartcontractkit/chainlink/integration-tests/testconfig" "github.com/smartcontractkit/chainlink/integration-tests/utils" "github.com/smartcontractkit/chainlink/v2/core/logger" - "github.com/smartcontractkit/chainlink/v2/core/services/relay" - - "github.com/AlekSi/pointer" - "github.com/ethereum/go-ethereum/accounts/abi/bind" - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/crypto" - "github.com/rs/zerolog" "github.com/stretchr/testify/require" "github.com/subosito/gotenv" "golang.org/x/sync/errgroup" @@ -107,9 +105,9 @@ func NewLocalDevEnvironment( chains, err := devenv.NewChains(lggr, envConfig.Chains) require.NoError(t, err) // locate the home chain - homeChainSel := envConfig.HomeChainSelector + homeChainSel, _ := strconv.ParseUint(pointer.GetString(cfg.CCIP.HomeChainSelector), 10, 64) require.NotEmpty(t, homeChainSel, "homeChainSel should not be empty") - feedSel := envConfig.FeedChainSelector + feedSel, _ := strconv.ParseUint(pointer.GetString(cfg.CCIP.FeedChainSelector), 10, 64) require.NotEmpty(t, feedSel, "feedSel should not be empty") replayBlocks, err := changeset.LatestBlocksByChain(ctx, chains) require.NoError(t, err) @@ -142,7 +140,8 @@ func NewLocalDevEnvironment( } mcmsCfg := make(map[uint64]commontypes.MCMSWithTimelockConfig) for _, c := range env.AllChainSelectors() { - mcmsCfg[c] = commonchangeset.CreateMCMSConfig(t, env.AllDeployerKeys()) + mcmsCfg[c], err = commonchangeset.CreateMCMSConfig(env.AllDeployerKeys()) + require.NoError(t, err) } // Need to deploy prerequisites first so that we can form the USDC config // no proposals to be made, timelock can be passed as nil here @@ -454,16 +453,9 @@ func CreateDockerEnv(t *testing.T) ( } require.NotEmpty(t, jdConfig, "JD config is empty") - homeChainSelector, err := cfg.CCIP.GetHomeChainSelector(evmNetworks) - require.NoError(t, err, "Error getting home chain selector") - feedChainSelector, err := cfg.CCIP.GetFeedChainSelector(evmNetworks) - require.NoError(t, err, "Error getting feed chain selector") - return &devenv.EnvironmentConfig{ - Chains: chains, - JDConfig: jdConfig, - HomeChainSelector: homeChainSelector, - FeedChainSelector: feedChainSelector, + Chains: chains, + JDConfig: jdConfig, }, env, cfg } @@ -509,7 +501,7 @@ func StartChainlinkNodes( cfg.NodeConfig.ChainConfigTOMLByChainID, ) - toml.Capabilities.ExternalRegistry.NetworkID = ptr.Ptr(relay.NetworkEVM) + toml.Capabilities.ExternalRegistry.NetworkID = ptr.Ptr(registryConfig.NetworkType) toml.Capabilities.ExternalRegistry.ChainID = ptr.Ptr(strconv.FormatUint(registryConfig.EVMChainID, 10)) toml.Capabilities.ExternalRegistry.Address = ptr.Ptr(registryConfig.Contract.String()) From b05777de41380aa16643258b5f38b2e4700bb589 Mon Sep 17 00:00:00 2001 From: 0xAustinWang Date: Wed, 4 Dec 2024 23:53:22 +0800 Subject: [PATCH 03/26] build failures --- deployment/environment/devenv/chain.go | 31 --------------------- integration-tests/testconfig/ccip/config.go | 17 +---------- 2 files changed, 1 insertion(+), 47 deletions(-) diff --git a/deployment/environment/devenv/chain.go b/deployment/environment/devenv/chain.go index 446040a81c7..2979b7c54a5 100644 --- a/deployment/environment/devenv/chain.go +++ b/deployment/environment/devenv/chain.go @@ -145,34 +145,3 @@ func NewChains(logger logger.Logger, configs []ChainConfig) (map[uint64]deployme } return chains, nil } - -// SetDeployerKey sets the deployer key for the chain. If private key is not provided, it fetches the deployer key from KMS. -func (c *ChainConfig) SetDeployerKey(pvtKeyStr *string) error { - if pvtKeyStr != nil && *pvtKeyStr != "" { - pvtKey, err := crypto.HexToECDSA(*pvtKeyStr) - if err != nil { - return fmt.Errorf("failed to convert private key to ECDSA: %w", err) - } - deployer, err := bind.NewKeyedTransactorWithChainID(pvtKey, new(big.Int).SetUint64(c.ChainID)) - if err != nil { - return fmt.Errorf("failed to create transactor: %w", err) - } - fmt.Printf("Deployer Address: %s for chain id %d\n", deployer.From.Hex(), c.ChainID) - c.DeployerKey = deployer - return nil - } - kmsConfig, err := deployment.KMSConfigFromEnvVars() - if err != nil { - return fmt.Errorf("failed to get kms config from env vars: %w", err) - } - kmsClient, err := deployment.NewKMSClient(kmsConfig) - if err != nil { - return fmt.Errorf("failed to create KMS client: %w", err) - } - evmKMSClient := deployment.NewEVMKMSClient(kmsClient, kmsConfig.KmsDeployerKeyId) - c.DeployerKey, err = evmKMSClient.GetKMSTransactOpts(context.Background(), new(big.Int).SetUint64(c.ChainID)) - if err != nil { - return fmt.Errorf("failed to get transactor from KMS client: %w", err) - } - return nil -} diff --git a/integration-tests/testconfig/ccip/config.go b/integration-tests/testconfig/ccip/config.go index e836d4152e5..caf2efaa0d6 100644 --- a/integration-tests/testconfig/ccip/config.go +++ b/integration-tests/testconfig/ccip/config.go @@ -2,7 +2,6 @@ package ccip import ( "fmt" - "math" "strconv" "github.com/AlekSi/pointer" @@ -190,10 +189,7 @@ func IsSelectorValid(selector uint64, chainIds []int64) (bool, error) { return false, err } - id, err := convertToInt64(chainId) - if err != nil { - return false, fmt.Errorf("chain id overflows int64: %d", chainId) - } + id := int64(chainId) for _, cID := range chainIds { if cID == id { return true, nil @@ -201,14 +197,3 @@ func IsSelectorValid(selector uint64, chainIds []int64) (bool, error) { } return false, nil } - -func convertToInt64(s string) (int64, error) { - num, err := strconv.ParseInt(s, 10, 64) - if err != nil { - return 0, err - } - if num > math.MaxInt64 { - return 0, fmt.Errorf("value %d is greater than math.MaxInt64", num) - } - return num, nil -} From 26863f777f5ee3fe90940bcc430e029769368bbb Mon Sep 17 00:00:00 2001 From: 0xAustinWang Date: Thu, 5 Dec 2024 20:57:34 +0800 Subject: [PATCH 04/26] changes from ani's comments --- .../ccip/changeset/cs_add_chain_test.go | 2 +- deployment/ccip/changeset/cs_deploy_chain.go | 4 +- deployment/ccip/changeset/cs_home_chain.go | 6 +- deployment/ccip/changeset/test_helpers.go | 6 +- deployment/environment/crib/ccip_deployer.go | 161 +++++++++--------- 5 files changed, 89 insertions(+), 90 deletions(-) diff --git a/deployment/ccip/changeset/cs_add_chain_test.go b/deployment/ccip/changeset/cs_add_chain_test.go index bb1fbb3098e..d1f30009d9e 100644 --- a/deployment/ccip/changeset/cs_add_chain_test.go +++ b/deployment/ccip/changeset/cs_add_chain_test.go @@ -67,7 +67,7 @@ func TestAddChainInbound(t *testing.T) { for _, chain := range initialDeploy { chainConfig[chain] = DefaultOCRParams(e.FeedChainSel, nil, nil) } - err = DeployCCIPContracts(e.Env, newAddresses, NewChainsConfig{ + err = deployCCIPContracts(e.Env, newAddresses, NewChainsConfig{ HomeChainSel: e.HomeChainSel, FeedChainSel: e.FeedChainSel, ChainConfigByChain: chainConfig, diff --git a/deployment/ccip/changeset/cs_deploy_chain.go b/deployment/ccip/changeset/cs_deploy_chain.go index 72219ede5e2..b57c00fd796 100644 --- a/deployment/ccip/changeset/cs_deploy_chain.go +++ b/deployment/ccip/changeset/cs_deploy_chain.go @@ -65,7 +65,7 @@ func (c DeployChainContractsConfig) Validate() error { return nil } -// DeployCCIPContracts assumes the following contracts are deployed: +// deployCCIPContracts assumes the following contracts are deployed: // - Capability registry // - CCIP home // - RMN home @@ -74,7 +74,7 @@ func (c DeployChainContractsConfig) Validate() error { // It then deploys the rest of the CCIP chain contracts to the selected chains // registers the nodes with the capability registry and creates a DON for // each new chain. -func DeployCCIPContracts( +func deployCCIPContracts( e deployment.Environment, ab deployment.AddressBook, c NewChainsConfig) error { diff --git a/deployment/ccip/changeset/cs_home_chain.go b/deployment/ccip/changeset/cs_home_chain.go index 6474da2baf8..0df8d87affb 100644 --- a/deployment/ccip/changeset/cs_home_chain.go +++ b/deployment/ccip/changeset/cs_home_chain.go @@ -82,9 +82,9 @@ func (c DeployHomeChainConfig) Validate() error { return nil } -// DeployCapReg deploys the CapabilitiesRegistry contract if it is not already deployed +// deployCapReg deploys the CapabilitiesRegistry contract if it is not already deployed // and returns a deployment.ContractDeploy struct with the address and contract instance. -func DeployCapReg( +func deployCapReg( lggr logger.Logger, state CCIPOnChainState, ab deployment.AddressBook, @@ -133,7 +133,7 @@ func deployHomeChain( return nil, fmt.Errorf("failed to load onchain state: %w", err) } // Deploy CapabilitiesRegistry, CCIPHome, RMNHome - capReg, err := DeployCapReg(lggr, state, ab, chain) + capReg, err := deployCapReg(lggr, state, ab, chain) if err != nil { return nil, err } diff --git a/deployment/ccip/changeset/test_helpers.go b/deployment/ccip/changeset/test_helpers.go index 5c7785952ea..abe6c8dde8e 100644 --- a/deployment/ccip/changeset/test_helpers.go +++ b/deployment/ccip/changeset/test_helpers.go @@ -138,14 +138,14 @@ func DeployTestContracts(t *testing.T, linkPrice *big.Int, wethPrice *big.Int, ) deployment.CapabilityRegistryConfig { - capReg, err := DeployCapReg(lggr, + capReg, err := deployCapReg(lggr, // deploying cap reg for the first time on a blank chain state CCIPOnChainState{ Chains: make(map[uint64]CCIPChainState), }, ab, chains[homeChainSel]) require.NoError(t, err) - _, err = DeployFeeds(lggr, ab, chains[feedChainSel], linkPrice, wethPrice) + _, err = deployFeeds(lggr, ab, chains[feedChainSel], linkPrice, wethPrice) require.NoError(t, err) evmChainID, err := chainsel.ChainIdFromSelector(homeChainSel) @@ -662,7 +662,7 @@ var ( } ) -func DeployFeeds( +func deployFeeds( lggr logger.Logger, ab deployment.AddressBook, chain deployment.Chain, diff --git a/deployment/environment/crib/ccip_deployer.go b/deployment/environment/crib/ccip_deployer.go index 335f456d2ac..32ad9c363fa 100644 --- a/deployment/environment/crib/ccip_deployer.go +++ b/deployment/environment/crib/ccip_deployer.go @@ -3,153 +3,152 @@ package crib import ( "context" "errors" - chainsel "github.com/smartcontractkit/chain-selectors" + "fmt" + "github.com/ethereum/go-ethereum/common" jobv1 "github.com/smartcontractkit/chainlink-protos/job-distributor/v1/job" commonchangeset "github.com/smartcontractkit/chainlink/deployment/common/changeset" commontypes "github.com/smartcontractkit/chainlink/deployment/common/types" - "golang.org/x/exp/maps" - "math/big" - "github.com/smartcontractkit/chainlink/deployment/environment/devenv" + "github.com/smartcontractkit/chainlink/v2/core/services/relay" + "golang.org/x/exp/maps" "github.com/smartcontractkit/chainlink/deployment" "github.com/smartcontractkit/chainlink/deployment/ccip/changeset" "github.com/smartcontractkit/chainlink/v2/core/logger" - "github.com/smartcontractkit/chainlink/v2/core/services/relay" ) // DeployHomeChainContracts deploys the home chain contracts so that the chainlink nodes can be started with the CR address in Capabilities.ExternalRegistry -func DeployHomeChainContracts(lggr logger.Logger, envConfig devenv.EnvironmentConfig, homeChainSel uint64) (deployment.CapabilityRegistryConfig, deployment.AddressBook, error) { - chains, err := devenv.NewChains(lggr, envConfig.Chains) - if err != nil { - return deployment.CapabilityRegistryConfig{}, nil, err - } - ab := deployment.NewMemoryAddressBook() - capReg, err := changeset.DeployCapReg(lggr, - // deploying cap reg for the first time on a blank chain state - changeset.CCIPOnChainState{ - Chains: make(map[uint64]changeset.CCIPChainState), - }, ab, chains[homeChainSel]) - if err != nil { - return deployment.CapabilityRegistryConfig{}, nil, err - } - evmChainID, err := chainsel.ChainIdFromSelector(homeChainSel) +// DeployHomeChainContracts is to 1. Set up crib with chains and chainlink nodes ( cap reg is not known yet so not setting the config with capreg address) +// Call DeployHomeChain changeset with nodeinfo ( the peer id and all) +func DeployHomeChainContracts(ctx context.Context, lggr logger.Logger, envConfig devenv.EnvironmentConfig, homeChainSel uint64, feedChainSel uint64) (deployment.CapabilityRegistryConfig, deployment.AddressBook, error) { + e, _, err := devenv.NewEnvironment(func() context.Context { return ctx }, lggr, envConfig) if err != nil { return deployment.CapabilityRegistryConfig{}, nil, err } - return deployment.CapabilityRegistryConfig{ - NetworkType: relay.NetworkEVM, - EVMChainID: evmChainID, - Contract: capReg.Address, - }, ab, nil -} - -func DeployCCIPAndAddLanes(lggr logger.Logger, envCfg devenv.EnvironmentConfig, homeChainSel, feedChainSel uint64, ab deployment.AddressBook) (DeployCCIPOutput, error) { - ctx := context.Background() - e, _, err := devenv.NewEnvironment(func() context.Context { return context.Background() }, lggr, envCfg) - if err != nil { - return DeployCCIPOutput{}, err - } if e == nil { - return DeployCCIPOutput{}, errors.New("environment is nil") + return deployment.CapabilityRegistryConfig{}, nil, errors.New("environment is nil") } - _, err = changeset.DeployFeeds(lggr, ab, e.Chains[feedChainSel], big.NewInt(9000000), big.NewInt(9000000)) - if err != nil { - return DeployCCIPOutput{}, err - } - - e.ExistingAddresses = ab tenv := changeset.DeployedEnv{ Env: *e, HomeChainSel: homeChainSel, FeedChainSel: feedChainSel, } - chains := tenv.Env.AllChainSelectors() - out, err := changeset.DeployPrerequisites(tenv.Env, changeset.DeployPrerequisiteConfig{ - ChainSelectors: chains, + + // Call DeployHomeChain changeset with nodeinfo ( the peer id and all) + nodes, err := deployment.NodeInfo(e.NodeIDs, e.Offchain) + if err != nil { + return deployment.CapabilityRegistryConfig{}, e.ExistingAddresses, fmt.Errorf("Failed to get node info from env", err) + } + p2pIds := nodes.NonBootstraps().PeerIDs() + out, err := changeset.DeployHomeChain(tenv.Env, changeset.DeployHomeChainConfig{ + HomeChainSel: homeChainSel, + RMNStaticConfig: changeset.NewTestRMNStaticConfig(), + RMNDynamicConfig: changeset.NewTestRMNDynamicConfig(), + NodeOperators: changeset.NewTestNodeOperator(e.Chains[homeChainSel].DeployerKey.From), + NodeP2PIDsPerNodeOpAdmin: map[string][][32]byte{ + "NodeOperator": p2pIds, + }, }) if err != nil { - return DeployCCIPOutput{}, err + return deployment.CapabilityRegistryConfig{}, e.ExistingAddresses, fmt.Errorf("Failed to deploy home chain", err) } err = tenv.Env.ExistingAddresses.Merge(out.AddressBook) + + capRegAddress, err := deployment.SearchAddressBook(e.ExistingAddresses, homeChainSel, "CapabilityRegistry") if err != nil { - return DeployCCIPOutput{}, err + return deployment.CapabilityRegistryConfig{}, e.ExistingAddresses, fmt.Errorf("Cap Reg not found!", err) } + capRegConfig := deployment.CapabilityRegistryConfig{ + EVMChainID: homeChainSel, + Contract: common.HexToAddress(capRegAddress), + NetworkType: relay.NetworkEVM, + } + return capRegConfig, e.ExistingAddresses, nil +} - state, err := changeset.LoadOnchainState(tenv.Env) +func DeployCCIPAndAddLanes(ctx context.Context, lggr logger.Logger, envConfig devenv.EnvironmentConfig, homeChainSel, feedChainSel uint64, ab deployment.AddressBook) (DeployCCIPOutput, error) { + e, _, err := devenv.NewEnvironment(func() context.Context { return ctx }, lggr, envConfig) if err != nil { - return DeployCCIPOutput{}, err - } - if state.Chains[tenv.HomeChainSel].LinkToken == nil { - return DeployCCIPOutput{}, errors.New("link token not deployed") + return DeployCCIPOutput{}, fmt.Errorf("Failed to initiate new environment", err) } + e.ExistingAddresses = ab + allChainIds := e.AllChainSelectors() - // Deploy contracts to new chain - cfg, err := commonchangeset.CreateMCMSConfig(tenv.Env.AllDeployerKeys()) + // deploy pre requisites + out, err := changeset.DeployPrerequisites(*e, changeset.DeployPrerequisiteConfig{ + ChainSelectors: allChainIds, + }) + if err != nil { + return DeployCCIPOutput{}, fmt.Errorf("Failed to deploy prerequisites", err) + } + err = e.ExistingAddresses.Merge(out.AddressBook) if err != nil { - return DeployCCIPOutput{}, err + return DeployCCIPOutput{}, fmt.Errorf("Failed to merge addresses after deploying prereqs", err) } - var mcmsConfigs = make(map[uint64]commontypes.MCMSWithTimelockConfig) - for _, chain := range chains { - mcmsConfigs[chain] = cfg + + // deploy MCMS With Timelock + cfg := make(map[uint64]commontypes.MCMSWithTimelockConfig) + for _, chain := range e.AllChainSelectors() { + cfg[chain], err = commonchangeset.CreateMCMSConfig(e.AllDeployerKeys()) + if err != nil { + return DeployCCIPOutput{}, fmt.Errorf("Failed to create MCMS config for %d", chain, err) + } } - out, err = commonchangeset.DeployMCMSWithTimelock(tenv.Env, mcmsConfigs) + out, err = commonchangeset.DeployMCMSWithTimelock(*e, cfg) if err != nil { - return DeployCCIPOutput{}, err + return DeployCCIPOutput{}, fmt.Errorf("Failed to deploy MCMS with timelock", err) } - err = tenv.Env.ExistingAddresses.Merge(out.AddressBook) + err = e.ExistingAddresses.Merge(out.AddressBook) if err != nil { - return DeployCCIPOutput{}, err + return DeployCCIPOutput{}, fmt.Errorf("Failed to merge addresses after deploying MCMS with timelock", err) } - chainConfig := make(map[uint64]changeset.CCIPOCRParams) - for _, chain := range chains { - chainConfig[chain] = changeset.DefaultOCRParams(tenv.FeedChainSel, nil, nil) - } - err = changeset.DeployCCIPContracts(tenv.Env, tenv.Env.ExistingAddresses, changeset.NewChainsConfig{ - HomeChainSel: tenv.HomeChainSel, - FeedChainSel: tenv.FeedChainSel, - ChainConfigByChain: chainConfig, - OCRSecrets: deployment.XXXGenerateTestOCRSecrets(), + // deploy ccip chain contracts + out, err = changeset.DeployChainContracts(*e, changeset.DeployChainContractsConfig{ + ChainSelectors: allChainIds, + HomeChainSelector: homeChainSel, }) if err != nil { - return DeployCCIPOutput{}, err + return DeployCCIPOutput{}, fmt.Errorf("Failed to deploy chain contracts", err) + } + err = e.ExistingAddresses.Merge(out.AddressBook) + if err != nil { + return DeployCCIPOutput{}, fmt.Errorf("Failed to merge addresses after deploying chain contracts", err) } - // Get new state after migration. - state, err = changeset.LoadOnchainState(tenv.Env) + state, err := changeset.LoadOnchainState(*e) if err != nil { - return DeployCCIPOutput{}, err + return DeployCCIPOutput{}, fmt.Errorf("Failed to load onchain state", err) } - out, err = changeset.CCIPCapabilityJobspec(tenv.Env, struct{}{}) + out, err = changeset.CCIPCapabilityJobspec(*e, struct{}{}) if err != nil { - return DeployCCIPOutput{}, err + return DeployCCIPOutput{}, fmt.Errorf("Failed to get CCIP capability jobspec", err) } for nodeID, jobs := range out.JobSpecs { for _, job := range jobs { // Note these auto-accept - _, err := tenv.Env.Offchain.ProposeJob(ctx, + _, err := e.Offchain.ProposeJob(ctx, &jobv1.ProposeJobRequest{ NodeId: nodeID, Spec: job, }) if err != nil { - return DeployCCIPOutput{}, err + return DeployCCIPOutput{}, fmt.Errorf("failed to propose job: %w", err) } } } // Add all lanes - err = changeset.AddLanesForAll(tenv.Env, state) + err = changeset.AddLanesForAll(*e, state) if err != nil { - return DeployCCIPOutput{}, err + return DeployCCIPOutput{}, fmt.Errorf("Failed to add lanes", err) } - addresses, err := ab.Addresses() + addresses, err := e.ExistingAddresses.Addresses() if err != nil { - return DeployCCIPOutput{}, err + return DeployCCIPOutput{}, fmt.Errorf("Failed to get convert address book to address book map", err) } return DeployCCIPOutput{ AddressBook: *deployment.NewMemoryAddressBookFromMap(addresses), From 6bf1bf6a8a405abdfd848e15244b9858f60c3ede Mon Sep 17 00:00:00 2001 From: 0xAustinWang Date: Fri, 6 Dec 2024 01:00:28 +0800 Subject: [PATCH 05/26] some changes --- deployment/ccip/changeset/test_helpers.go | 4 ++-- integration-tests/testconfig/ccip/config.go | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/deployment/ccip/changeset/test_helpers.go b/deployment/ccip/changeset/test_helpers.go index cc133af6cd3..f9566e317a4 100644 --- a/deployment/ccip/changeset/test_helpers.go +++ b/deployment/ccip/changeset/test_helpers.go @@ -145,7 +145,7 @@ func DeployTestContracts(t *testing.T, }, ab, chains[homeChainSel]) require.NoError(t, err) - _, err = deployFeeds(lggr, ab, chains[feedChainSel], linkPrice, wethPrice) + _, err = DeployFeeds(lggr, ab, chains[feedChainSel], linkPrice, wethPrice) require.NoError(t, err) evmChainID, err := chainsel.ChainIdFromSelector(homeChainSel) @@ -672,7 +672,7 @@ var ( } ) -func deployFeeds( +func DeployFeeds( lggr logger.Logger, ab deployment.AddressBook, chain deployment.Chain, diff --git a/integration-tests/testconfig/ccip/config.go b/integration-tests/testconfig/ccip/config.go index caf2efaa0d6..174d6a3b1f6 100644 --- a/integration-tests/testconfig/ccip/config.go +++ b/integration-tests/testconfig/ccip/config.go @@ -189,9 +189,8 @@ func IsSelectorValid(selector uint64, chainIds []int64) (bool, error) { return false, err } - id := int64(chainId) for _, cID := range chainIds { - if cID == id { + if uint64(cID) == chainId { return true, nil } } From 8b558dac499c570aabbb00c1bd14e6b47c5c1d58 Mon Sep 17 00:00:00 2001 From: 0xAustinWang Date: Fri, 6 Dec 2024 01:40:33 +0800 Subject: [PATCH 06/26] revert isempty check --- deployment/environment/devenv/environment.go | 38 +++++++++----------- deployment/environment/devenv/jd.go | 7 ---- integration-tests/testconfig/ccip/config.go | 8 ++--- 3 files changed, 20 insertions(+), 33 deletions(-) diff --git a/deployment/environment/devenv/environment.go b/deployment/environment/devenv/environment.go index 7d2a8f62ce4..094eba99adf 100644 --- a/deployment/environment/devenv/environment.go +++ b/deployment/environment/devenv/environment.go @@ -23,31 +23,25 @@ func NewEnvironment(ctx func() context.Context, lggr logger.Logger, config Envir if err != nil { return nil, nil, fmt.Errorf("failed to create chains: %w", err) } + offChain, err := NewJDClient(ctx(), config.JDConfig) + if err != nil { + return nil, nil, fmt.Errorf("failed to create JD client: %w", err) + } + jd, ok := offChain.(*JobDistributor) + if !ok { + return nil, nil, fmt.Errorf("offchain client does not implement JobDistributor") + } + if jd == nil { + return nil, nil, fmt.Errorf("offchain client is not set up") + } var nodeIDs []string - var offChain deployment.OffchainClient - var don *DON - if !config.JDConfig.IsEmpty() { - offChain, err := NewJDClient(ctx(), config.JDConfig) + if jd.don != nil { + err = jd.don.CreateSupportedChains(ctx(), config.Chains, *jd) if err != nil { - return nil, nil, fmt.Errorf("failed to create JD client: %w", err) - } - - jd, ok := offChain.(*JobDistributor) - if !ok { - return nil, nil, fmt.Errorf("offchain client does not implement JobDistributor") - } - if jd == nil { - return nil, nil, fmt.Errorf("offchain client is not set up") - } - if jd.don != nil { - err = jd.don.CreateSupportedChains(ctx(), config.Chains, *jd) - if err != nil { - return nil, nil, err - } - nodeIDs = jd.don.NodeIds() - don = jd.don + return nil, nil, err } + nodeIDs = jd.don.NodeIds() } return deployment.NewEnvironment( @@ -58,5 +52,5 @@ func NewEnvironment(ctx func() context.Context, lggr logger.Logger, config Envir nodeIDs, offChain, ctx, - ), don, nil + ), jd.don, nil } diff --git a/deployment/environment/devenv/jd.go b/deployment/environment/devenv/jd.go index a2328d8204e..818f9b09400 100644 --- a/deployment/environment/devenv/jd.go +++ b/deployment/environment/devenv/jd.go @@ -61,13 +61,6 @@ func gapTokenInterceptor(token string) grpc.UnaryClientInterceptor { } } -func (cfg JDConfig) IsEmpty() bool { - if cfg.GRPC == "" && cfg.WSRPC == "" { - return true - } - return false -} - func NewJDConnection(cfg JDConfig) (*grpc.ClientConn, error) { opts := []grpc.DialOption{} interceptors := []grpc.UnaryClientInterceptor{} diff --git a/integration-tests/testconfig/ccip/config.go b/integration-tests/testconfig/ccip/config.go index 174d6a3b1f6..c688c057653 100644 --- a/integration-tests/testconfig/ccip/config.go +++ b/integration-tests/testconfig/ccip/config.go @@ -144,9 +144,9 @@ func (o *JDConfig) GetJDDBVersion() string { } func (o *Config) Validate() error { - var chainIds []int64 + var chainIds []uint64 for _, net := range o.PrivateEthereumNetworks { - chainIds = append(chainIds, int64(net.EthereumChainConfig.ChainID)) + chainIds = append(chainIds, uint64(net.EthereumChainConfig.ChainID)) } homeChainSelector, err := strconv.ParseUint(pointer.GetString(o.HomeChainSelector), 10, 64) if err != nil { @@ -183,14 +183,14 @@ func (o *Config) GetFeedChainSelector() uint64 { return selector } -func IsSelectorValid(selector uint64, chainIds []int64) (bool, error) { +func IsSelectorValid(selector uint64, chainIds []uint64) (bool, error) { chainId, err := chainselectors.ChainIdFromSelector(selector) if err != nil { return false, err } for _, cID := range chainIds { - if uint64(cID) == chainId { + if cID == chainId { return true, nil } } From 848c49a37a2416f58a839bfc77f1e9b401a716b0 Mon Sep 17 00:00:00 2001 From: 0xAustinWang Date: Fri, 6 Dec 2024 15:48:52 +0800 Subject: [PATCH 07/26] go lint and compare integers --- deployment/environment/crib/ccip_deployer.go | 15 ++++++++++--- integration-tests/testconfig/ccip/config.go | 22 ++++++++++++++++---- 2 files changed, 30 insertions(+), 7 deletions(-) diff --git a/deployment/environment/crib/ccip_deployer.go b/deployment/environment/crib/ccip_deployer.go index 32ad9c363fa..3f07282b802 100644 --- a/deployment/environment/crib/ccip_deployer.go +++ b/deployment/environment/crib/ccip_deployer.go @@ -54,14 +54,23 @@ func DeployHomeChainContracts(ctx context.Context, lggr logger.Logger, envConfig return deployment.CapabilityRegistryConfig{}, e.ExistingAddresses, fmt.Errorf("Failed to deploy home chain", err) } err = tenv.Env.ExistingAddresses.Merge(out.AddressBook) + if err != nil { + return deployment.CapabilityRegistryConfig{}, e.ExistingAddresses, fmt.Errorf("Failed to merge addresses after deploying home chain", err) + } + + fmt.Printf("Deployed home chain contracts\n") - capRegAddress, err := deployment.SearchAddressBook(e.ExistingAddresses, homeChainSel, "CapabilityRegistry") + state, err := changeset.LoadOnchainState(*e) if err != nil { - return deployment.CapabilityRegistryConfig{}, e.ExistingAddresses, fmt.Errorf("Cap Reg not found!", err) + return deployment.CapabilityRegistryConfig{}, e.ExistingAddresses, fmt.Errorf("Failed to load on chain state", err) + } + capRegAddr := state.Chains[homeChainSel].CapabilityRegistry.Address() + if capRegAddr == common.HexToAddress("0x") { + return deployment.CapabilityRegistryConfig{}, e.ExistingAddresses, fmt.Errorf("Cap Reg address not found") } capRegConfig := deployment.CapabilityRegistryConfig{ EVMChainID: homeChainSel, - Contract: common.HexToAddress(capRegAddress), + Contract: state.Chains[homeChainSel].CapabilityRegistry.Address(), NetworkType: relay.NetworkEVM, } return capRegConfig, e.ExistingAddresses, nil diff --git a/integration-tests/testconfig/ccip/config.go b/integration-tests/testconfig/ccip/config.go index c688c057653..ae0b9b655d3 100644 --- a/integration-tests/testconfig/ccip/config.go +++ b/integration-tests/testconfig/ccip/config.go @@ -2,6 +2,7 @@ package ccip import ( "fmt" + "math" "strconv" "github.com/AlekSi/pointer" @@ -144,9 +145,12 @@ func (o *JDConfig) GetJDDBVersion() string { } func (o *Config) Validate() error { - var chainIds []uint64 + var chainIds []int64 for _, net := range o.PrivateEthereumNetworks { - chainIds = append(chainIds, uint64(net.EthereumChainConfig.ChainID)) + if net.EthereumChainConfig.ChainID < 0 { + return fmt.Errorf("negative chain ID found for network %s", net.EthereumChainConfig.ChainID) + } + chainIds = append(chainIds, int64(net.EthereumChainConfig.ChainID)) } homeChainSelector, err := strconv.ParseUint(pointer.GetString(o.HomeChainSelector), 10, 64) if err != nil { @@ -183,16 +187,26 @@ func (o *Config) GetFeedChainSelector() uint64 { return selector } -func IsSelectorValid(selector uint64, chainIds []uint64) (bool, error) { +func IsSelectorValid(selector uint64, chainIds []int64) (bool, error) { chainId, err := chainselectors.ChainIdFromSelector(selector) if err != nil { return false, err } for _, cID := range chainIds { - if cID == chainId { + if isEqualUint64AndInt64(chainId, cID) { return true, nil } } return false, nil } + +func isEqualUint64AndInt64(u uint64, i int64) bool { + if i < 0 { + return false // uint64 cannot be equal to a negative int64 + } + if u > math.MaxInt64 { + return false // uint64 cannot be equal to an int64 if it exceeds the maximum int64 value + } + return u == uint64(i) +} From dc7744bf888054920cf3034ae9f2e79bec1945aa Mon Sep 17 00:00:00 2001 From: 0xAustinWang Date: Fri, 6 Dec 2024 15:50:46 +0800 Subject: [PATCH 08/26] fix types in test --- deployment/keystone/changeset/accept_ownership_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/deployment/keystone/changeset/accept_ownership_test.go b/deployment/keystone/changeset/accept_ownership_test.go index c40aca4f423..b49ea9e679f 100644 --- a/deployment/keystone/changeset/accept_ownership_test.go +++ b/deployment/keystone/changeset/accept_ownership_test.go @@ -1,6 +1,7 @@ package changeset_test import ( + "github.com/smartcontractkit/chainlink/deployment/common/types" "testing" owner_helpers "github.com/smartcontractkit/ccip-owner-contracts/pkg/gethwrappers" @@ -44,7 +45,7 @@ func TestAcceptAllOwnership(t *testing.T) { }, { Changeset: commonchangeset.WrapChangeSet(commonchangeset.DeployMCMSWithTimelock), - Config: mcmsConfig, + Config: map[uint64]types.MCMSWithTimelockConfig{registrySel: mcmsConfig}, }, }) require.NoError(t, err) From 1361ceef6ca4853c718cd1bf2570c1efce9122d5 Mon Sep 17 00:00:00 2001 From: 0xAustinWang Date: Fri, 6 Dec 2024 18:21:48 +0800 Subject: [PATCH 09/26] check for error if there's already a feeds manager --- deployment/environment/devenv/don.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/deployment/environment/devenv/don.go b/deployment/environment/devenv/don.go index 05a3d5bea08..f4763de5e38 100644 --- a/deployment/environment/devenv/don.go +++ b/deployment/environment/devenv/don.go @@ -394,7 +394,8 @@ func (n *Node) SetUpAndLinkJobDistributor(ctx context.Context, jd JobDistributor } // now create the job distributor in the node id, err := n.CreateJobDistributor(ctx, jd) - if err != nil && !strings.Contains(err.Error(), "DuplicateFeedsManagerError") { + if err != nil && + (!strings.Contains(err.Error(), "only a single feeds manager is supported") || !strings.Contains(err.Error(), "DuplicateFeedsManagerError")) { return err } // wait for the node to connect to the job distributor From 6d799af18f59105f8462379d40858e65bf8a8668 Mon Sep 17 00:00:00 2001 From: 0xAustinWang Date: Mon, 9 Dec 2024 20:00:26 +0800 Subject: [PATCH 10/26] check if job distributors exist first --- deployment/environment/devenv/don.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/deployment/environment/devenv/don.go b/deployment/environment/devenv/don.go index f4763de5e38..a8f7f464ed7 100644 --- a/deployment/environment/devenv/don.go +++ b/deployment/environment/devenv/don.go @@ -377,6 +377,13 @@ func (n *Node) CreateJobDistributor(ctx context.Context, jd JobDistributor) (str return "", err } // create the job distributor in the node with the csa key + resp, err := n.gqlClient.ListJobDistributors(ctx) + if err != nil { + return "", fmt.Errorf("Could not list job distrubutors: %w", err) + } + if len(resp.FeedsManagers.Results) > 0 { + return resp.FeedsManagers.Results[0].Id, nil + } return n.gqlClient.CreateJobDistributor(ctx, client.JobDistributorInput{ Name: "Job Distributor", Uri: jd.WSRPC, @@ -396,6 +403,7 @@ func (n *Node) SetUpAndLinkJobDistributor(ctx context.Context, jd JobDistributor id, err := n.CreateJobDistributor(ctx, jd) if err != nil && (!strings.Contains(err.Error(), "only a single feeds manager is supported") || !strings.Contains(err.Error(), "DuplicateFeedsManagerError")) { + fmt.Errorf("failed to create job distributor in node %s: %w", n.Name, err) return err } // wait for the node to connect to the job distributor From 5791b427096d2e2f0058ad252b20a0a93d2d384e Mon Sep 17 00:00:00 2001 From: 0xAustinWang Date: Mon, 9 Dec 2024 21:17:57 +0800 Subject: [PATCH 11/26] wip changes --- deployment/environment/crib/ccip_deployer.go | 1 + deployment/environment/devenv/don.go | 4 ++-- deployment/environment/web/sdk/client/client.go | 14 +++++++++++++- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/deployment/environment/crib/ccip_deployer.go b/deployment/environment/crib/ccip_deployer.go index 3f07282b802..c97cb7e6ec4 100644 --- a/deployment/environment/crib/ccip_deployer.go +++ b/deployment/environment/crib/ccip_deployer.go @@ -91,6 +91,7 @@ func DeployCCIPAndAddLanes(ctx context.Context, lggr logger.Logger, envConfig de if err != nil { return DeployCCIPOutput{}, fmt.Errorf("Failed to deploy prerequisites", err) } + fmt.Printf("PreReq AddressBook %+v\n", out.AddressBook) err = e.ExistingAddresses.Merge(out.AddressBook) if err != nil { return DeployCCIPOutput{}, fmt.Errorf("Failed to merge addresses after deploying prereqs", err) diff --git a/deployment/environment/devenv/don.go b/deployment/environment/devenv/don.go index a8f7f464ed7..ffed8d8ca1e 100644 --- a/deployment/environment/devenv/don.go +++ b/deployment/environment/devenv/don.go @@ -403,9 +403,9 @@ func (n *Node) SetUpAndLinkJobDistributor(ctx context.Context, jd JobDistributor id, err := n.CreateJobDistributor(ctx, jd) if err != nil && (!strings.Contains(err.Error(), "only a single feeds manager is supported") || !strings.Contains(err.Error(), "DuplicateFeedsManagerError")) { - fmt.Errorf("failed to create job distributor in node %s: %w", n.Name, err) - return err + return fmt.Errorf("failed to create job distributor in node %s: %w", n.Name, err) } + fmt.Printf("Using job distributor with ID: %s\n", id) // wait for the node to connect to the job distributor err = retry.Do(ctx, retry.WithMaxDuration(1*time.Minute, retry.NewFibonacci(1*time.Second)), func(ctx context.Context) error { getRes, err := jd.GetNode(ctx, &nodev1.GetNodeRequest{ diff --git a/deployment/environment/web/sdk/client/client.go b/deployment/environment/web/sdk/client/client.go index 5472591ef94..29603fb7e5c 100644 --- a/deployment/environment/web/sdk/client/client.go +++ b/deployment/environment/web/sdk/client/client.go @@ -6,6 +6,7 @@ import ( "fmt" "net/http" "strings" + "time" "github.com/Khan/genqlient/graphql" @@ -61,7 +62,18 @@ func New(baseURI string, creds Credentials) (Client, error) { credentials: creds, } - if err := c.login(); err != nil { + fmt.Printf("Loggging in to node using cookie %s, endpoint %s\n", c.cookie, c.endpoints.Sessions) + var err error + for _ = range 5 { + err := c.login() + if err == nil { + break + } else { + fmt.Println("retrying.....") + time.Sleep(10 * time.Second) + } + } + if err != nil { return nil, fmt.Errorf("failed to login to node: %w", err) } From df1680ce196244db7127fe943a571f4ba38aaf9e Mon Sep 17 00:00:00 2001 From: 0xAustinWang Date: Tue, 10 Dec 2024 16:03:14 +0800 Subject: [PATCH 12/26] add retries to consistently failing JD cals --- deployment/environment/crib/ccip_deployer.go | 9 ++- deployment/environment/devenv/don.go | 76 ++++++++++++------- .../environment/web/sdk/client/client.go | 17 ++--- 3 files changed, 62 insertions(+), 40 deletions(-) diff --git a/deployment/environment/crib/ccip_deployer.go b/deployment/environment/crib/ccip_deployer.go index c97cb7e6ec4..e971307c276 100644 --- a/deployment/environment/crib/ccip_deployer.go +++ b/deployment/environment/crib/ccip_deployer.go @@ -84,8 +84,14 @@ func DeployCCIPAndAddLanes(ctx context.Context, lggr logger.Logger, envConfig de e.ExistingAddresses = ab allChainIds := e.AllChainSelectors() + out, err := commonchangeset.DeployLinkToken(*e, allChainIds) + if err != nil { + return DeployCCIPOutput{}, fmt.Errorf("Failed to deploy link token", err) + } + err = e.ExistingAddresses.Merge(out.AddressBook) + // deploy pre requisites - out, err := changeset.DeployPrerequisites(*e, changeset.DeployPrerequisiteConfig{ + out, err = changeset.DeployPrerequisites(*e, changeset.DeployPrerequisiteConfig{ ChainSelectors: allChainIds, }) if err != nil { @@ -160,6 +166,7 @@ func DeployCCIPAndAddLanes(ctx context.Context, lggr logger.Logger, envConfig de if err != nil { return DeployCCIPOutput{}, fmt.Errorf("Failed to get convert address book to address book map", err) } + fmt.Printf("New Addresses %+v\n", addresses) return DeployCCIPOutput{ AddressBook: *deployment.NewMemoryAddressBookFromMap(addresses), NodeIDs: maps.Keys(out.JobSpecs), diff --git a/deployment/environment/devenv/don.go b/deployment/environment/devenv/don.go index ffed8d8ca1e..771d30fa3a7 100644 --- a/deployment/environment/devenv/don.go +++ b/deployment/environment/devenv/don.go @@ -2,7 +2,9 @@ package devenv import ( "context" + "errors" "fmt" + chainsel "github.com/smartcontractkit/chain-selectors" "strconv" "strings" "time" @@ -10,8 +12,6 @@ import ( "github.com/hashicorp/go-multierror" "github.com/rs/zerolog" "github.com/sethvargo/go-retry" - chainsel "github.com/smartcontractkit/chain-selectors" - nodev1 "github.com/smartcontractkit/chainlink-protos/job-distributor/v1/node" clclient "github.com/smartcontractkit/chainlink/deployment/environment/nodeclient" "github.com/smartcontractkit/chainlink/deployment/environment/web/sdk/client" @@ -185,7 +185,7 @@ type JDChainConfigInput struct { // It expects bootstrap nodes to have label with key "type" and value as "bootstrap". // It fetches the account address, peer id, and OCR2 key bundle id and creates the JobDistributorChainConfig. func (n *Node) CreateCCIPOCRSupportedChains(ctx context.Context, chains []JDChainConfigInput, jd JobDistributor) error { - for i, chain := range chains { + for _, chain := range chains { chainId := strconv.FormatUint(chain.ChainID, 10) var account string switch chain.ChainType { @@ -239,35 +239,51 @@ func (n *Node) CreateCCIPOCRSupportedChains(ctx context.Context, chains []JDChai break } } - // JD silently fails to update nodeChainConfig. Therefore, we fetch the node config and - // if it's not updated , throw an error - _, err = n.gqlClient.CreateJobDistributorChainConfig(ctx, client.JobDistributorChainConfigInput{ - JobDistributorID: n.JDId, - ChainID: chainId, - ChainType: chain.ChainType, - AccountAddr: account, - AdminAddr: n.adminAddr, - Ocr2Enabled: true, - Ocr2IsBootstrap: isBootstrap, - Ocr2Multiaddr: n.multiAddr, - Ocr2P2PPeerID: value(peerID), - Ocr2KeyBundleID: ocr2BundleId, - Ocr2Plugins: `{"commit":true,"execute":true,"median":false,"mercury":false}`, + + // retry twice with 5 seconds interval to create JobDistributorChainConfig + err = retry.Do(ctx, retry.WithMaxDuration(10*time.Second, retry.NewFibonacci(1*time.Second)), func(ctx context.Context) error { + // check the node chain config to see if this chain already exists + nodeChainConfigs, err := jd.ListNodeChainConfigs(context.Background(), &nodev1.ListNodeChainConfigsRequest{ + Filter: &nodev1.ListNodeChainConfigsRequest_Filter{ + NodeIds: []string{n.NodeId}, + }}) + if err != nil { + return retry.RetryableError(fmt.Errorf("failed to list node chain configs for node %s, retrying..: %w", n.Name, err)) + } + if nodeChainConfigs != nil { + for _, chainConfig := range nodeChainConfigs.ChainConfigs { + if chainConfig.Chain.Id == chainId { + return nil + } + } + } + + // JD silently fails to update nodeChainConfig. Therefore, we fetch the node config and + // if it's not updated , throw an error + _, err = n.gqlClient.CreateJobDistributorChainConfig(ctx, client.JobDistributorChainConfigInput{ + JobDistributorID: n.JDId, + ChainID: chainId, + ChainType: chain.ChainType, + AccountAddr: account, + AdminAddr: n.adminAddr, + Ocr2Enabled: true, + Ocr2IsBootstrap: isBootstrap, + Ocr2Multiaddr: n.multiAddr, + Ocr2P2PPeerID: value(peerID), + Ocr2KeyBundleID: ocr2BundleId, + Ocr2Plugins: `{"commit":true,"execute":true,"median":false,"mercury":false}`, + }) + // todo: add a check if the chain config failed because of a duplicate in that case, should we update or return success? + if err != nil { + return fmt.Errorf("failed to create CCIPOCR2SupportedChains for node %s: %w", n.Name, err) + } + + return retry.RetryableError(errors.New("retrying CreateChainConfig in JD")) }) + if err != nil { return fmt.Errorf("failed to create CCIPOCR2SupportedChains for node %s: %w", n.Name, err) } - // query the node chain config to check if it's created - nodeChainConfigs, err := jd.ListNodeChainConfigs(context.Background(), &nodev1.ListNodeChainConfigsRequest{ - Filter: &nodev1.ListNodeChainConfigsRequest_Filter{ - NodeIds: []string{n.NodeId}, - }}) - if err != nil { - return fmt.Errorf("failed to list node chain configs for node %s: %w", n.Name, err) - } - if nodeChainConfigs == nil || len(nodeChainConfigs.ChainConfigs) < i+1 { - return fmt.Errorf("failed to create chain config for node %s", n.Name) - } } return nil } @@ -382,8 +398,10 @@ func (n *Node) CreateJobDistributor(ctx context.Context, jd JobDistributor) (str return "", fmt.Errorf("Could not list job distrubutors: %w", err) } if len(resp.FeedsManagers.Results) > 0 { - return resp.FeedsManagers.Results[0].Id, nil + fmt.Printf("Using existing job distributor with ID: %s\n", resp.FeedsManagers.Results[0].FeedsManagerParts.GetId()) + return resp.FeedsManagers.Results[0].FeedsManagerParts.GetId(), nil } + fmt.Printf("Could not find existing JD in node %s, creating... ", n.NodeId) return n.gqlClient.CreateJobDistributor(ctx, client.JobDistributorInput{ Name: "Job Distributor", Uri: jd.WSRPC, diff --git a/deployment/environment/web/sdk/client/client.go b/deployment/environment/web/sdk/client/client.go index 29603fb7e5c..015320a5779 100644 --- a/deployment/environment/web/sdk/client/client.go +++ b/deployment/environment/web/sdk/client/client.go @@ -4,12 +4,12 @@ import ( "context" "encoding/json" "fmt" + "github.com/Khan/genqlient/graphql" + "github.com/sethvargo/go-retry" "net/http" "strings" "time" - "github.com/Khan/genqlient/graphql" - "github.com/smartcontractkit/chainlink/deployment/environment/web/sdk/client/doer" "github.com/smartcontractkit/chainlink/deployment/environment/web/sdk/internal/generated" ) @@ -63,16 +63,13 @@ func New(baseURI string, creds Credentials) (Client, error) { } fmt.Printf("Loggging in to node using cookie %s, endpoint %s\n", c.cookie, c.endpoints.Sessions) - var err error - for _ = range 5 { + err := retry.Do(context.Background(), retry.WithMaxDuration(10*time.Second, retry.NewFibonacci(1*time.Second)), func(ctx context.Context) error { err := c.login() - if err == nil { - break - } else { - fmt.Println("retrying.....") - time.Sleep(10 * time.Second) + if err != nil { + return retry.RetryableError(fmt.Errorf("failed to login to node: %w", err)) } - } + return nil + }) if err != nil { return nil, fmt.Errorf("failed to login to node: %w", err) } From af23f937f8173e213ed1fc8fa24f40d8ea08d40a Mon Sep 17 00:00:00 2001 From: 0xAustinWang Date: Tue, 10 Dec 2024 16:29:58 +0800 Subject: [PATCH 13/26] update retries with static duration --- deployment/environment/crib/ccip_deployer.go | 2 -- deployment/environment/devenv/don.go | 2 +- deployment/environment/web/sdk/client/client.go | 4 ++-- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/deployment/environment/crib/ccip_deployer.go b/deployment/environment/crib/ccip_deployer.go index e971307c276..0e27b1e711f 100644 --- a/deployment/environment/crib/ccip_deployer.go +++ b/deployment/environment/crib/ccip_deployer.go @@ -97,7 +97,6 @@ func DeployCCIPAndAddLanes(ctx context.Context, lggr logger.Logger, envConfig de if err != nil { return DeployCCIPOutput{}, fmt.Errorf("Failed to deploy prerequisites", err) } - fmt.Printf("PreReq AddressBook %+v\n", out.AddressBook) err = e.ExistingAddresses.Merge(out.AddressBook) if err != nil { return DeployCCIPOutput{}, fmt.Errorf("Failed to merge addresses after deploying prereqs", err) @@ -166,7 +165,6 @@ func DeployCCIPAndAddLanes(ctx context.Context, lggr logger.Logger, envConfig de if err != nil { return DeployCCIPOutput{}, fmt.Errorf("Failed to get convert address book to address book map", err) } - fmt.Printf("New Addresses %+v\n", addresses) return DeployCCIPOutput{ AddressBook: *deployment.NewMemoryAddressBookFromMap(addresses), NodeIDs: maps.Keys(out.JobSpecs), diff --git a/deployment/environment/devenv/don.go b/deployment/environment/devenv/don.go index 771d30fa3a7..c50550dcc48 100644 --- a/deployment/environment/devenv/don.go +++ b/deployment/environment/devenv/don.go @@ -241,7 +241,7 @@ func (n *Node) CreateCCIPOCRSupportedChains(ctx context.Context, chains []JDChai } // retry twice with 5 seconds interval to create JobDistributorChainConfig - err = retry.Do(ctx, retry.WithMaxDuration(10*time.Second, retry.NewFibonacci(1*time.Second)), func(ctx context.Context) error { + err = retry.Do(ctx, retry.WithMaxDuration(10*time.Second, retry.NewConstant(3*time.Second)), func(ctx context.Context) error { // check the node chain config to see if this chain already exists nodeChainConfigs, err := jd.ListNodeChainConfigs(context.Background(), &nodev1.ListNodeChainConfigsRequest{ Filter: &nodev1.ListNodeChainConfigsRequest_Filter{ diff --git a/deployment/environment/web/sdk/client/client.go b/deployment/environment/web/sdk/client/client.go index 015320a5779..4c711513383 100644 --- a/deployment/environment/web/sdk/client/client.go +++ b/deployment/environment/web/sdk/client/client.go @@ -63,10 +63,10 @@ func New(baseURI string, creds Credentials) (Client, error) { } fmt.Printf("Loggging in to node using cookie %s, endpoint %s\n", c.cookie, c.endpoints.Sessions) - err := retry.Do(context.Background(), retry.WithMaxDuration(10*time.Second, retry.NewFibonacci(1*time.Second)), func(ctx context.Context) error { + err := retry.Do(context.Background(), retry.WithMaxDuration(10*time.Second, retry.NewFibonacci(2*time.Second)), func(ctx context.Context) error { err := c.login() if err != nil { - return retry.RetryableError(fmt.Errorf("failed to login to node: %w", err)) + return retry.RetryableError(fmt.Errorf("retrying login to node: %w", err)) } return nil }) From c42ac1408a6638384debe3d4f695f56841ce0af5 Mon Sep 17 00:00:00 2001 From: 0xAustinWang Date: Tue, 10 Dec 2024 16:32:43 +0800 Subject: [PATCH 14/26] remove print statements --- deployment/environment/crib/ccip_deployer.go | 4 +--- deployment/environment/devenv/chain.go | 18 +++++++++--------- deployment/environment/devenv/don.go | 3 --- .../environment/web/sdk/client/client.go | 3 +-- 4 files changed, 11 insertions(+), 17 deletions(-) diff --git a/deployment/environment/crib/ccip_deployer.go b/deployment/environment/crib/ccip_deployer.go index 0e27b1e711f..76918449723 100644 --- a/deployment/environment/crib/ccip_deployer.go +++ b/deployment/environment/crib/ccip_deployer.go @@ -57,9 +57,7 @@ func DeployHomeChainContracts(ctx context.Context, lggr logger.Logger, envConfig if err != nil { return deployment.CapabilityRegistryConfig{}, e.ExistingAddresses, fmt.Errorf("Failed to merge addresses after deploying home chain", err) } - - fmt.Printf("Deployed home chain contracts\n") - + state, err := changeset.LoadOnchainState(*e) if err != nil { return deployment.CapabilityRegistryConfig{}, e.ExistingAddresses, fmt.Errorf("Failed to load on chain state", err) diff --git a/deployment/environment/devenv/chain.go b/deployment/environment/devenv/chain.go index 01b87753a93..5c6c4336ed7 100644 --- a/deployment/environment/devenv/chain.go +++ b/deployment/environment/devenv/chain.go @@ -108,6 +108,10 @@ func NewChains(logger logger.Logger, configs []ChainConfig) (map[uint64]deployme if ec == nil { return nil, fmt.Errorf("failed to connect to chain %s", chainCfg.ChainName) } + chainInfo, err := deployment.ChainInfo(selector) + if err != nil { + return nil, fmt.Errorf("failed to get chain info for chain %s: %w", chainCfg.ChainName, err) + } chains[selector] = deployment.Chain{ Selector: selector, Client: ec, @@ -115,28 +119,24 @@ func NewChains(logger logger.Logger, configs []ChainConfig) (map[uint64]deployme Confirm: func(tx *types.Transaction) (uint64, error) { var blockNumber uint64 if tx == nil { - return 0, fmt.Errorf("tx was nil, nothing to confirm") + return 0, fmt.Errorf("tx was nil, nothing to confirm chain %s", chainInfo.ChainName) } ctx, cancel := context.WithTimeout(context.Background(), 3*time.Minute) defer cancel() - chainId, err := ec.ChainID(ctx) - if err != nil { - return blockNumber, fmt.Errorf("failed to get chain id: %w", err) - } receipt, err := bind.WaitMined(ctx, ec, tx) if err != nil { - return blockNumber, fmt.Errorf("failed to get confirmed receipt for chain %d: %w", chainId, err) + return blockNumber, fmt.Errorf("failed to get confirmed receipt for chain %s: %w", chainInfo.ChainName, err) } if receipt == nil { - return blockNumber, fmt.Errorf("receipt was nil for tx %s", tx.Hash().Hex()) + return blockNumber, fmt.Errorf("receipt was nil for tx %s chain %s", tx.Hash().Hex(), chainInfo.ChainName) } blockNumber = receipt.BlockNumber.Uint64() if receipt.Status == 0 { errReason, err := deployment.GetErrorReasonFromTx(ec, chainCfg.DeployerKey.From, tx, receipt) if err == nil && errReason != "" { - return blockNumber, fmt.Errorf("tx %s reverted, error reason: %s", tx.Hash().Hex(), errReason) + return blockNumber, fmt.Errorf("tx %s reverted,error reason: %s chain %s", tx.Hash().Hex(), errReason, chainInfo.ChainName) } - return blockNumber, fmt.Errorf("tx %s reverted, could not decode error reason", tx.Hash().Hex()) + return blockNumber, fmt.Errorf("tx %s reverted, could not decode error reason chain %s", tx.Hash().Hex(), chainInfo.ChainName) } return blockNumber, nil }, diff --git a/deployment/environment/devenv/don.go b/deployment/environment/devenv/don.go index c50550dcc48..79dbc6e7d0e 100644 --- a/deployment/environment/devenv/don.go +++ b/deployment/environment/devenv/don.go @@ -398,10 +398,8 @@ func (n *Node) CreateJobDistributor(ctx context.Context, jd JobDistributor) (str return "", fmt.Errorf("Could not list job distrubutors: %w", err) } if len(resp.FeedsManagers.Results) > 0 { - fmt.Printf("Using existing job distributor with ID: %s\n", resp.FeedsManagers.Results[0].FeedsManagerParts.GetId()) return resp.FeedsManagers.Results[0].FeedsManagerParts.GetId(), nil } - fmt.Printf("Could not find existing JD in node %s, creating... ", n.NodeId) return n.gqlClient.CreateJobDistributor(ctx, client.JobDistributorInput{ Name: "Job Distributor", Uri: jd.WSRPC, @@ -423,7 +421,6 @@ func (n *Node) SetUpAndLinkJobDistributor(ctx context.Context, jd JobDistributor (!strings.Contains(err.Error(), "only a single feeds manager is supported") || !strings.Contains(err.Error(), "DuplicateFeedsManagerError")) { return fmt.Errorf("failed to create job distributor in node %s: %w", n.Name, err) } - fmt.Printf("Using job distributor with ID: %s\n", id) // wait for the node to connect to the job distributor err = retry.Do(ctx, retry.WithMaxDuration(1*time.Minute, retry.NewFibonacci(1*time.Second)), func(ctx context.Context) error { getRes, err := jd.GetNode(ctx, &nodev1.GetNodeRequest{ diff --git a/deployment/environment/web/sdk/client/client.go b/deployment/environment/web/sdk/client/client.go index 4c711513383..e0a56b9e642 100644 --- a/deployment/environment/web/sdk/client/client.go +++ b/deployment/environment/web/sdk/client/client.go @@ -61,8 +61,7 @@ func New(baseURI string, creds Credentials) (Client, error) { endpoints: ep, credentials: creds, } - - fmt.Printf("Loggging in to node using cookie %s, endpoint %s\n", c.cookie, c.endpoints.Sessions) + err := retry.Do(context.Background(), retry.WithMaxDuration(10*time.Second, retry.NewFibonacci(2*time.Second)), func(ctx context.Context) error { err := c.login() if err != nil { From 52585a6e1fe0c6acabf5cd9919a1771d55e06f28 Mon Sep 17 00:00:00 2001 From: Radek Scheibinger Date: Tue, 10 Dec 2024 11:04:31 +0100 Subject: [PATCH 15/26] fix compile error --- deployment/environment/crib/types.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deployment/environment/crib/types.go b/deployment/environment/crib/types.go index d0513ef9575..d19c8424443 100644 --- a/deployment/environment/crib/types.go +++ b/deployment/environment/crib/types.go @@ -34,6 +34,6 @@ func NewDeployEnvironmentFromCribOutput(lggr logger.Logger, output DeployOutput) chains, output.NodeIDs, nil, // todo: populate the offchain client using output.DON - func() context.Context { return context.Background() }, + func() context.Context { return context.Background() }, deployment.XXXGenerateTestOCRSecrets(), ), nil } From 50479b730c86b684a52fc5cb1383b5413de87e64 Mon Sep 17 00:00:00 2001 From: 0xAustinWang Date: Wed, 11 Dec 2024 14:59:38 +0800 Subject: [PATCH 16/26] remove unnecessary mcms changes --- .../common/changeset/mcms_test_helpers.go | 33 ++----------------- 1 file changed, 3 insertions(+), 30 deletions(-) diff --git a/deployment/common/changeset/mcms_test_helpers.go b/deployment/common/changeset/mcms_test_helpers.go index 1c96c947f30..ffa99114d74 100644 --- a/deployment/common/changeset/mcms_test_helpers.go +++ b/deployment/common/changeset/mcms_test_helpers.go @@ -4,8 +4,6 @@ import ( "bytes" "context" "crypto/ecdsa" - commontypes "github.com/smartcontractkit/chainlink/deployment/common/types" - "math/big" "testing" "github.com/ethereum/go-ethereum/accounts/abi/bind" @@ -42,40 +40,15 @@ func init() { TestXXXMCMSSigner = key } -func SingleGroupMCMS() (config.Config, error) { +func SingleGroupMCMS(t *testing.T) config.Config { publicKey := TestXXXMCMSSigner.Public().(*ecdsa.PublicKey) // Convert the public key to an Ethereum address address := crypto.PubkeyToAddress(*publicKey) c, err := config.NewConfig(1, []common.Address{address}, []config.Config{}) - - if err != nil { - return config.Config{}, err - } - return *c, nil + require.NoError(t, err) + return *c } -func CreateMCMSConfig(depKeys []common.Address) (commontypes.MCMSWithTimelockConfig, error) { - c, err := SingleGroupMCMS() - if err != nil { - return commontypes.MCMSWithTimelockConfig{}, err - } - b, err := SingleGroupMCMS() - if err != nil { - return commontypes.MCMSWithTimelockConfig{}, err - } - p, err := SingleGroupMCMS() - if err != nil { - return commontypes.MCMSWithTimelockConfig{}, err - } - return commontypes.MCMSWithTimelockConfig{ - Canceller: c, - Bypasser: b, - Proposer: p, - TimelockExecutors: depKeys, - TimelockMinDelay: big.NewInt(0), - }, nil - -} func SignProposal(t *testing.T, env deployment.Environment, proposal *timelock.MCMSWithTimelockProposal) *mcms.Executor { executorClients := make(map[mcms.ChainIdentifier]mcms.ContractDeployBackend) for _, chain := range env.Chains { From 1083fd07095b96025de1f068188f9a236bd074fe Mon Sep 17 00:00:00 2001 From: 0xAustinWang Date: Wed, 11 Dec 2024 15:17:07 +0800 Subject: [PATCH 17/26] build issues --- deployment/environment/crib/ccip_deployer.go | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/deployment/environment/crib/ccip_deployer.go b/deployment/environment/crib/ccip_deployer.go index 76918449723..37580e009dc 100644 --- a/deployment/environment/crib/ccip_deployer.go +++ b/deployment/environment/crib/ccip_deployer.go @@ -5,12 +5,14 @@ import ( "errors" "fmt" "github.com/ethereum/go-ethereum/common" + "github.com/smartcontractkit/ccip-owner-contracts/pkg/config" jobv1 "github.com/smartcontractkit/chainlink-protos/job-distributor/v1/job" commonchangeset "github.com/smartcontractkit/chainlink/deployment/common/changeset" commontypes "github.com/smartcontractkit/chainlink/deployment/common/types" "github.com/smartcontractkit/chainlink/deployment/environment/devenv" "github.com/smartcontractkit/chainlink/v2/core/services/relay" "golang.org/x/exp/maps" + "math/big" "github.com/smartcontractkit/chainlink/deployment" "github.com/smartcontractkit/chainlink/deployment/ccip/changeset" @@ -57,7 +59,7 @@ func DeployHomeChainContracts(ctx context.Context, lggr logger.Logger, envConfig if err != nil { return deployment.CapabilityRegistryConfig{}, e.ExistingAddresses, fmt.Errorf("Failed to merge addresses after deploying home chain", err) } - + state, err := changeset.LoadOnchainState(*e) if err != nil { return deployment.CapabilityRegistryConfig{}, e.ExistingAddresses, fmt.Errorf("Failed to load on chain state", err) @@ -103,9 +105,15 @@ func DeployCCIPAndAddLanes(ctx context.Context, lggr logger.Logger, envConfig de // deploy MCMS With Timelock cfg := make(map[uint64]commontypes.MCMSWithTimelockConfig) for _, chain := range e.AllChainSelectors() { - cfg[chain], err = commonchangeset.CreateMCMSConfig(e.AllDeployerKeys()) + mcmsConfig, err := config.NewConfig(1, []common.Address{e.Chains[chain].DeployerKey.From}, []config.Config{}) if err != nil { - return DeployCCIPOutput{}, fmt.Errorf("Failed to create MCMS config for %d", chain, err) + return DeployCCIPOutput{}, fmt.Errorf("Failed to create mcms config") + } + cfg[chain] = commontypes.MCMSWithTimelockConfig{ + Canceller: *mcmsConfig, + Bypasser: *mcmsConfig, + Proposer: *mcmsConfig, + TimelockMinDelay: big.NewInt(0), } } out, err = commonchangeset.DeployMCMSWithTimelock(*e, cfg) From 63c8b1baf97a2de3547cc7caa6e406346080d00b Mon Sep 17 00:00:00 2001 From: 0xAustinWang Date: Wed, 11 Dec 2024 15:38:30 +0800 Subject: [PATCH 18/26] passing deployment --- deployment/environment/crib/ccip_deployer.go | 158 ++++++++++++------- 1 file changed, 97 insertions(+), 61 deletions(-) diff --git a/deployment/environment/crib/ccip_deployer.go b/deployment/environment/crib/ccip_deployer.go index 37580e009dc..50be70f42bc 100644 --- a/deployment/environment/crib/ccip_deployer.go +++ b/deployment/environment/crib/ccip_deployer.go @@ -6,12 +6,10 @@ import ( "fmt" "github.com/ethereum/go-ethereum/common" "github.com/smartcontractkit/ccip-owner-contracts/pkg/config" - jobv1 "github.com/smartcontractkit/chainlink-protos/job-distributor/v1/job" commonchangeset "github.com/smartcontractkit/chainlink/deployment/common/changeset" commontypes "github.com/smartcontractkit/chainlink/deployment/common/types" "github.com/smartcontractkit/chainlink/deployment/environment/devenv" "github.com/smartcontractkit/chainlink/v2/core/services/relay" - "golang.org/x/exp/maps" "math/big" "github.com/smartcontractkit/chainlink/deployment" @@ -83,26 +81,6 @@ func DeployCCIPAndAddLanes(ctx context.Context, lggr logger.Logger, envConfig de } e.ExistingAddresses = ab allChainIds := e.AllChainSelectors() - - out, err := commonchangeset.DeployLinkToken(*e, allChainIds) - if err != nil { - return DeployCCIPOutput{}, fmt.Errorf("Failed to deploy link token", err) - } - err = e.ExistingAddresses.Merge(out.AddressBook) - - // deploy pre requisites - out, err = changeset.DeployPrerequisites(*e, changeset.DeployPrerequisiteConfig{ - ChainSelectors: allChainIds, - }) - if err != nil { - return DeployCCIPOutput{}, fmt.Errorf("Failed to deploy prerequisites", err) - } - err = e.ExistingAddresses.Merge(out.AddressBook) - if err != nil { - return DeployCCIPOutput{}, fmt.Errorf("Failed to merge addresses after deploying prereqs", err) - } - - // deploy MCMS With Timelock cfg := make(map[uint64]commontypes.MCMSWithTimelockConfig) for _, chain := range e.AllChainSelectors() { mcmsConfig, err := config.NewConfig(1, []common.Address{e.Chains[chain].DeployerKey.From}, []config.Config{}) @@ -116,51 +94,109 @@ func DeployCCIPAndAddLanes(ctx context.Context, lggr logger.Logger, envConfig de TimelockMinDelay: big.NewInt(0), } } - out, err = commonchangeset.DeployMCMSWithTimelock(*e, cfg) - if err != nil { - return DeployCCIPOutput{}, fmt.Errorf("Failed to deploy MCMS with timelock", err) - } - err = e.ExistingAddresses.Merge(out.AddressBook) - if err != nil { - return DeployCCIPOutput{}, fmt.Errorf("Failed to merge addresses after deploying MCMS with timelock", err) - } + *e, err = commonchangeset.ApplyChangesets(nil, *e, nil, []commonchangeset.ChangesetApplication{ + { + Changeset: commonchangeset.WrapChangeSet(commonchangeset.DeployLinkToken), + Config: allChainIds, + }, + { + Changeset: commonchangeset.WrapChangeSet(changeset.DeployPrerequisites), + Config: changeset.DeployPrerequisiteConfig{ + ChainSelectors: allChainIds, + }, + }, + { + Changeset: commonchangeset.WrapChangeSet(commonchangeset.DeployMCMSWithTimelock), + Config: cfg, + }, + { + Changeset: commonchangeset.WrapChangeSet(changeset.DeployChainContracts), + Config: changeset.DeployChainContractsConfig{ + ChainSelectors: allChainIds, + HomeChainSelector: homeChainSel, + }, + }, + { + Changeset: commonchangeset.WrapChangeSet(changeset.CCIPCapabilityJobspec), + Config: struct{}{}, + }, + }) + //out, err := commonchangeset.DeployLinkToken(*e, allChainIds) + //if err != nil { + // return DeployCCIPOutput{}, fmt.Errorf("Failed to deploy link token", err) + //} + //err = e.ExistingAddresses.Merge(out.AddressBook) + // + //// deploy pre requisites + //out, err = changeset.DeployPrerequisites(*e, changeset.DeployPrerequisiteConfig{ + // ChainSelectors: allChainIds, + //}) + //if err != nil { + // return DeployCCIPOutput{}, fmt.Errorf("Failed to deploy prerequisites", err) + //} + //err = e.ExistingAddresses.Merge(out.AddressBook) + //if err != nil { + // return DeployCCIPOutput{}, fmt.Errorf("Failed to merge addresses after deploying prereqs", err) + //} + + // deploy MCMS With Timelock + //cfg := make(map[uint64]commontypes.MCMSWithTimelockConfig) + //for _, chain := range e.AllChainSelectors() { + // mcmsConfig, err := config.NewConfig(1, []common.Address{e.Chains[chain].DeployerKey.From}, []config.Config{}) + // if err != nil { + // return DeployCCIPOutput{}, fmt.Errorf("Failed to create mcms config") + // } + // cfg[chain] = commontypes.MCMSWithTimelockConfig{ + // Canceller: *mcmsConfig, + // Bypasser: *mcmsConfig, + // Proposer: *mcmsConfig, + // TimelockMinDelay: big.NewInt(0), + // } + //} + //out, err = commonchangeset.DeployMCMSWithTimelock(*e, cfg) + //if err != nil { + // return DeployCCIPOutput{}, fmt.Errorf("Failed to deploy MCMS with timelock", err) + //} + //err = e.ExistingAddresses.Merge(out.AddressBook) + //if err != nil { + // return DeployCCIPOutput{}, fmt.Errorf("Failed to merge addresses after deploying MCMS with timelock", err) + //} // deploy ccip chain contracts - out, err = changeset.DeployChainContracts(*e, changeset.DeployChainContractsConfig{ - ChainSelectors: allChainIds, - HomeChainSelector: homeChainSel, - }) - if err != nil { - return DeployCCIPOutput{}, fmt.Errorf("Failed to deploy chain contracts", err) - } - err = e.ExistingAddresses.Merge(out.AddressBook) - if err != nil { - return DeployCCIPOutput{}, fmt.Errorf("Failed to merge addresses after deploying chain contracts", err) - } + //out, err = changeset.DeployChainContracts(*e, changeset.DeployChainContractsConfig{ + // ChainSelectors: allChainIds, + // HomeChainSelector: homeChainSel, + //}) + //if err != nil { + // return DeployCCIPOutput{}, fmt.Errorf("Failed to deploy chain contracts", err) + //} + //err = e.ExistingAddresses.Merge(out.AddressBook) + //if err != nil { + // return DeployCCIPOutput{}, fmt.Errorf("Failed to merge addresses after deploying chain contracts", err) + //} + // + //out, err = changeset.CCIPCapabilityJobspec(*e, struct{}{}) + //if err != nil { + // return DeployCCIPOutput{}, fmt.Errorf("Failed to get CCIP capability jobspec", err) + //} + //for nodeID, jobs := range out.JobSpecs { + // for _, job := range jobs { + // // Note these auto-accept + // _, err := e.Offchain.ProposeJob(ctx, + // &jobv1.ProposeJobRequest{ + // NodeId: nodeID, + // Spec: job, + // }) + // if err != nil { + // return DeployCCIPOutput{}, fmt.Errorf("failed to propose job: %w", err) + // } + // } + //} state, err := changeset.LoadOnchainState(*e) if err != nil { return DeployCCIPOutput{}, fmt.Errorf("Failed to load onchain state", err) } - - out, err = changeset.CCIPCapabilityJobspec(*e, struct{}{}) - if err != nil { - return DeployCCIPOutput{}, fmt.Errorf("Failed to get CCIP capability jobspec", err) - } - for nodeID, jobs := range out.JobSpecs { - for _, job := range jobs { - // Note these auto-accept - _, err := e.Offchain.ProposeJob(ctx, - &jobv1.ProposeJobRequest{ - NodeId: nodeID, - Spec: job, - }) - if err != nil { - return DeployCCIPOutput{}, fmt.Errorf("failed to propose job: %w", err) - } - } - } - // Add all lanes err = changeset.AddLanesForAll(*e, state) if err != nil { @@ -173,6 +209,6 @@ func DeployCCIPAndAddLanes(ctx context.Context, lggr logger.Logger, envConfig de } return DeployCCIPOutput{ AddressBook: *deployment.NewMemoryAddressBookFromMap(addresses), - NodeIDs: maps.Keys(out.JobSpecs), + NodeIDs: e.NodeIDs, }, err } From 0dd4fde7e8b233da70c2495edd9397ac9dbfb34a Mon Sep 17 00:00:00 2001 From: 0xAustinWang Date: Wed, 11 Dec 2024 15:42:21 +0800 Subject: [PATCH 19/26] clean up code comments --- deployment/environment/crib/ccip_deployer.go | 75 +------------------- 1 file changed, 3 insertions(+), 72 deletions(-) diff --git a/deployment/environment/crib/ccip_deployer.go b/deployment/environment/crib/ccip_deployer.go index 50be70f42bc..69770c74790 100644 --- a/deployment/environment/crib/ccip_deployer.go +++ b/deployment/environment/crib/ccip_deployer.go @@ -94,6 +94,9 @@ func DeployCCIPAndAddLanes(ctx context.Context, lggr logger.Logger, envConfig de TimelockMinDelay: big.NewInt(0), } } + + // This will not apply any proposals because we pass nil to testing. + // However, setup is ok because we only need to deploy the contracts and distribute job specs *e, err = commonchangeset.ApplyChangesets(nil, *e, nil, []commonchangeset.ChangesetApplication{ { Changeset: commonchangeset.WrapChangeSet(commonchangeset.DeployLinkToken), @@ -121,78 +124,6 @@ func DeployCCIPAndAddLanes(ctx context.Context, lggr logger.Logger, envConfig de Config: struct{}{}, }, }) - //out, err := commonchangeset.DeployLinkToken(*e, allChainIds) - //if err != nil { - // return DeployCCIPOutput{}, fmt.Errorf("Failed to deploy link token", err) - //} - //err = e.ExistingAddresses.Merge(out.AddressBook) - // - //// deploy pre requisites - //out, err = changeset.DeployPrerequisites(*e, changeset.DeployPrerequisiteConfig{ - // ChainSelectors: allChainIds, - //}) - //if err != nil { - // return DeployCCIPOutput{}, fmt.Errorf("Failed to deploy prerequisites", err) - //} - //err = e.ExistingAddresses.Merge(out.AddressBook) - //if err != nil { - // return DeployCCIPOutput{}, fmt.Errorf("Failed to merge addresses after deploying prereqs", err) - //} - - // deploy MCMS With Timelock - //cfg := make(map[uint64]commontypes.MCMSWithTimelockConfig) - //for _, chain := range e.AllChainSelectors() { - // mcmsConfig, err := config.NewConfig(1, []common.Address{e.Chains[chain].DeployerKey.From}, []config.Config{}) - // if err != nil { - // return DeployCCIPOutput{}, fmt.Errorf("Failed to create mcms config") - // } - // cfg[chain] = commontypes.MCMSWithTimelockConfig{ - // Canceller: *mcmsConfig, - // Bypasser: *mcmsConfig, - // Proposer: *mcmsConfig, - // TimelockMinDelay: big.NewInt(0), - // } - //} - //out, err = commonchangeset.DeployMCMSWithTimelock(*e, cfg) - //if err != nil { - // return DeployCCIPOutput{}, fmt.Errorf("Failed to deploy MCMS with timelock", err) - //} - //err = e.ExistingAddresses.Merge(out.AddressBook) - //if err != nil { - // return DeployCCIPOutput{}, fmt.Errorf("Failed to merge addresses after deploying MCMS with timelock", err) - //} - - // deploy ccip chain contracts - //out, err = changeset.DeployChainContracts(*e, changeset.DeployChainContractsConfig{ - // ChainSelectors: allChainIds, - // HomeChainSelector: homeChainSel, - //}) - //if err != nil { - // return DeployCCIPOutput{}, fmt.Errorf("Failed to deploy chain contracts", err) - //} - //err = e.ExistingAddresses.Merge(out.AddressBook) - //if err != nil { - // return DeployCCIPOutput{}, fmt.Errorf("Failed to merge addresses after deploying chain contracts", err) - //} - - // - //out, err = changeset.CCIPCapabilityJobspec(*e, struct{}{}) - //if err != nil { - // return DeployCCIPOutput{}, fmt.Errorf("Failed to get CCIP capability jobspec", err) - //} - //for nodeID, jobs := range out.JobSpecs { - // for _, job := range jobs { - // // Note these auto-accept - // _, err := e.Offchain.ProposeJob(ctx, - // &jobv1.ProposeJobRequest{ - // NodeId: nodeID, - // Spec: job, - // }) - // if err != nil { - // return DeployCCIPOutput{}, fmt.Errorf("failed to propose job: %w", err) - // } - // } - //} state, err := changeset.LoadOnchainState(*e) if err != nil { return DeployCCIPOutput{}, fmt.Errorf("Failed to load onchain state", err) From 791c01355c439bd5447269eb23ce9436c3c17be8 Mon Sep 17 00:00:00 2001 From: 0xAustinWang Date: Wed, 11 Dec 2024 15:46:15 +0800 Subject: [PATCH 20/26] gomodtidy --- integration-tests/load/go.mod | 1 + 1 file changed, 1 insertion(+) diff --git a/integration-tests/load/go.mod b/integration-tests/load/go.mod index 39bdb3ad2ba..58071cd9c50 100644 --- a/integration-tests/load/go.mod +++ b/integration-tests/load/go.mod @@ -393,6 +393,7 @@ require ( github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529 // indirect github.com/segmentio/ksuid v1.0.4 // indirect github.com/sercand/kuberesolver/v5 v5.1.1 // indirect + github.com/sethvargo/go-retry v0.2.4 // indirect github.com/shirou/gopsutil v3.21.11+incompatible // indirect github.com/shirou/gopsutil/v3 v3.24.3 // indirect github.com/shoenig/go-m1cpu v0.1.6 // indirect From 56b5f87f864515c17379d028cd266d157d640d49 Mon Sep 17 00:00:00 2001 From: 0xAustinWang Date: Wed, 11 Dec 2024 17:24:59 +0800 Subject: [PATCH 21/26] lint --- integration-tests/testconfig/ccip/config.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration-tests/testconfig/ccip/config.go b/integration-tests/testconfig/ccip/config.go index ae0b9b655d3..70c850fd591 100644 --- a/integration-tests/testconfig/ccip/config.go +++ b/integration-tests/testconfig/ccip/config.go @@ -148,7 +148,7 @@ func (o *Config) Validate() error { var chainIds []int64 for _, net := range o.PrivateEthereumNetworks { if net.EthereumChainConfig.ChainID < 0 { - return fmt.Errorf("negative chain ID found for network %s", net.EthereumChainConfig.ChainID) + return fmt.Errorf("negative chain ID found for network %d", net.EthereumChainConfig.ChainID) } chainIds = append(chainIds, int64(net.EthereumChainConfig.ChainID)) } From 1713660435a54d3325d07d2c7ae65589f022376e Mon Sep 17 00:00:00 2001 From: 0xAustinWang Date: Wed, 11 Dec 2024 17:27:56 +0800 Subject: [PATCH 22/26] formatting strings --- deployment/environment/crib/ccip_deployer.go | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/deployment/environment/crib/ccip_deployer.go b/deployment/environment/crib/ccip_deployer.go index 69770c74790..007e6ed044f 100644 --- a/deployment/environment/crib/ccip_deployer.go +++ b/deployment/environment/crib/ccip_deployer.go @@ -38,7 +38,7 @@ func DeployHomeChainContracts(ctx context.Context, lggr logger.Logger, envConfig // Call DeployHomeChain changeset with nodeinfo ( the peer id and all) nodes, err := deployment.NodeInfo(e.NodeIDs, e.Offchain) if err != nil { - return deployment.CapabilityRegistryConfig{}, e.ExistingAddresses, fmt.Errorf("Failed to get node info from env", err) + return deployment.CapabilityRegistryConfig{}, e.ExistingAddresses, fmt.Errorf("failed to get node info from env: %w", err) } p2pIds := nodes.NonBootstraps().PeerIDs() out, err := changeset.DeployHomeChain(tenv.Env, changeset.DeployHomeChainConfig{ @@ -51,20 +51,20 @@ func DeployHomeChainContracts(ctx context.Context, lggr logger.Logger, envConfig }, }) if err != nil { - return deployment.CapabilityRegistryConfig{}, e.ExistingAddresses, fmt.Errorf("Failed to deploy home chain", err) + return deployment.CapabilityRegistryConfig{}, e.ExistingAddresses, fmt.Errorf("failed to deploy home chain: %w", err) } err = tenv.Env.ExistingAddresses.Merge(out.AddressBook) if err != nil { - return deployment.CapabilityRegistryConfig{}, e.ExistingAddresses, fmt.Errorf("Failed to merge addresses after deploying home chain", err) + return deployment.CapabilityRegistryConfig{}, e.ExistingAddresses, fmt.Errorf("failed to merge addresses after deploying home chain, %w", err) } state, err := changeset.LoadOnchainState(*e) if err != nil { - return deployment.CapabilityRegistryConfig{}, e.ExistingAddresses, fmt.Errorf("Failed to load on chain state", err) + return deployment.CapabilityRegistryConfig{}, e.ExistingAddresses, fmt.Errorf("failed to load on chain state: %w", err) } capRegAddr := state.Chains[homeChainSel].CapabilityRegistry.Address() if capRegAddr == common.HexToAddress("0x") { - return deployment.CapabilityRegistryConfig{}, e.ExistingAddresses, fmt.Errorf("Cap Reg address not found") + return deployment.CapabilityRegistryConfig{}, e.ExistingAddresses, fmt.Errorf("cap Reg address not found: %w", err) } capRegConfig := deployment.CapabilityRegistryConfig{ EVMChainID: homeChainSel, @@ -77,7 +77,7 @@ func DeployHomeChainContracts(ctx context.Context, lggr logger.Logger, envConfig func DeployCCIPAndAddLanes(ctx context.Context, lggr logger.Logger, envConfig devenv.EnvironmentConfig, homeChainSel, feedChainSel uint64, ab deployment.AddressBook) (DeployCCIPOutput, error) { e, _, err := devenv.NewEnvironment(func() context.Context { return ctx }, lggr, envConfig) if err != nil { - return DeployCCIPOutput{}, fmt.Errorf("Failed to initiate new environment", err) + return DeployCCIPOutput{}, fmt.Errorf("failed to initiate new environment: %w", err) } e.ExistingAddresses = ab allChainIds := e.AllChainSelectors() @@ -85,7 +85,7 @@ func DeployCCIPAndAddLanes(ctx context.Context, lggr logger.Logger, envConfig de for _, chain := range e.AllChainSelectors() { mcmsConfig, err := config.NewConfig(1, []common.Address{e.Chains[chain].DeployerKey.From}, []config.Config{}) if err != nil { - return DeployCCIPOutput{}, fmt.Errorf("Failed to create mcms config") + return DeployCCIPOutput{}, fmt.Errorf("failed to create mcms config: %w", err) } cfg[chain] = commontypes.MCMSWithTimelockConfig{ Canceller: *mcmsConfig, @@ -126,17 +126,17 @@ func DeployCCIPAndAddLanes(ctx context.Context, lggr logger.Logger, envConfig de }) state, err := changeset.LoadOnchainState(*e) if err != nil { - return DeployCCIPOutput{}, fmt.Errorf("Failed to load onchain state", err) + return DeployCCIPOutput{}, fmt.Errorf("failed to load onchain state: %w", err) } // Add all lanes err = changeset.AddLanesForAll(*e, state) if err != nil { - return DeployCCIPOutput{}, fmt.Errorf("Failed to add lanes", err) + return DeployCCIPOutput{}, fmt.Errorf("failed to add lanes: %w", err) } addresses, err := e.ExistingAddresses.Addresses() if err != nil { - return DeployCCIPOutput{}, fmt.Errorf("Failed to get convert address book to address book map", err) + return DeployCCIPOutput{}, fmt.Errorf("failed to get convert address book to address book map: %w", err) } return DeployCCIPOutput{ AddressBook: *deployment.NewMemoryAddressBookFromMap(addresses), From a8d7cf9898cdd70bf2039ffa20871130abfc6b51 Mon Sep 17 00:00:00 2001 From: 0xAustinWang Date: Wed, 11 Dec 2024 18:10:01 +0800 Subject: [PATCH 23/26] use the common changeset utilities when deploying home chain as well --- deployment/environment/crib/ccip_deployer.go | 33 +++++++------------- 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/deployment/environment/crib/ccip_deployer.go b/deployment/environment/crib/ccip_deployer.go index 007e6ed044f..aea7ad0cb8f 100644 --- a/deployment/environment/crib/ccip_deployer.go +++ b/deployment/environment/crib/ccip_deployer.go @@ -29,34 +29,25 @@ func DeployHomeChainContracts(ctx context.Context, lggr logger.Logger, envConfig return deployment.CapabilityRegistryConfig{}, nil, errors.New("environment is nil") } - tenv := changeset.DeployedEnv{ - Env: *e, - HomeChainSel: homeChainSel, - FeedChainSel: feedChainSel, - } - - // Call DeployHomeChain changeset with nodeinfo ( the peer id and all) nodes, err := deployment.NodeInfo(e.NodeIDs, e.Offchain) if err != nil { return deployment.CapabilityRegistryConfig{}, e.ExistingAddresses, fmt.Errorf("failed to get node info from env: %w", err) } p2pIds := nodes.NonBootstraps().PeerIDs() - out, err := changeset.DeployHomeChain(tenv.Env, changeset.DeployHomeChainConfig{ - HomeChainSel: homeChainSel, - RMNStaticConfig: changeset.NewTestRMNStaticConfig(), - RMNDynamicConfig: changeset.NewTestRMNDynamicConfig(), - NodeOperators: changeset.NewTestNodeOperator(e.Chains[homeChainSel].DeployerKey.From), - NodeP2PIDsPerNodeOpAdmin: map[string][][32]byte{ - "NodeOperator": p2pIds, + *e, err = commonchangeset.ApplyChangesets(nil, *e, nil, []commonchangeset.ChangesetApplication{ + { + Changeset: commonchangeset.WrapChangeSet(changeset.DeployHomeChain), + Config: changeset.DeployHomeChainConfig{ + HomeChainSel: homeChainSel, + RMNStaticConfig: changeset.NewTestRMNStaticConfig(), + RMNDynamicConfig: changeset.NewTestRMNDynamicConfig(), + NodeOperators: changeset.NewTestNodeOperator(e.Chains[homeChainSel].DeployerKey.From), + NodeP2PIDsPerNodeOpAdmin: map[string][][32]byte{ + "NodeOperator": p2pIds, + }, + }, }, }) - if err != nil { - return deployment.CapabilityRegistryConfig{}, e.ExistingAddresses, fmt.Errorf("failed to deploy home chain: %w", err) - } - err = tenv.Env.ExistingAddresses.Merge(out.AddressBook) - if err != nil { - return deployment.CapabilityRegistryConfig{}, e.ExistingAddresses, fmt.Errorf("failed to merge addresses after deploying home chain, %w", err) - } state, err := changeset.LoadOnchainState(*e) if err != nil { From 030ab7a6c4f521a0c1831794b8e5ea546e3f0f99 Mon Sep 17 00:00:00 2001 From: 0xAustinWang Date: Thu, 12 Dec 2024 16:23:51 +0800 Subject: [PATCH 24/26] compare nodes job distributors public key against the one we expect --- deployment/environment/devenv/don.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/deployment/environment/devenv/don.go b/deployment/environment/devenv/don.go index 79dbc6e7d0e..76f6ee92b68 100644 --- a/deployment/environment/devenv/don.go +++ b/deployment/environment/devenv/don.go @@ -395,10 +395,14 @@ func (n *Node) CreateJobDistributor(ctx context.Context, jd JobDistributor) (str // create the job distributor in the node with the csa key resp, err := n.gqlClient.ListJobDistributors(ctx) if err != nil { - return "", fmt.Errorf("Could not list job distrubutors: %w", err) + return "", fmt.Errorf("could not list job distrubutors: %w", err) } if len(resp.FeedsManagers.Results) > 0 { - return resp.FeedsManagers.Results[0].FeedsManagerParts.GetId(), nil + for _, fm := range resp.FeedsManagers.Results { + if fm.GetPublicKey() == csaKey { + return fm.GetId(), nil + } + } } return n.gqlClient.CreateJobDistributor(ctx, client.JobDistributorInput{ Name: "Job Distributor", From 95cd43ea77ae64c53faec116c24c0e25987a7ad0 Mon Sep 17 00:00:00 2001 From: Radek Scheibinger Date: Thu, 12 Dec 2024 10:56:46 +0100 Subject: [PATCH 25/26] move state reader under deployment module --- deployment/environment/crib/data.go | 95 +++++++++++++++++++ deployment/environment/crib/env.go | 40 ++++++++ deployment/environment/crib/env_test.go | 18 ++++ .../ccip-v2-scripts-address-book.json | 1 + .../ccip-v2-scripts-chains-details.json | 24 +++++ .../ccip-v2-scripts-nodes-details.json | 1 + 6 files changed, 179 insertions(+) create mode 100644 deployment/environment/crib/data.go create mode 100644 deployment/environment/crib/env.go create mode 100644 deployment/environment/crib/env_test.go create mode 100644 deployment/environment/crib/testdata/lanes-deployed-state/ccip-v2-scripts-address-book.json create mode 100644 deployment/environment/crib/testdata/lanes-deployed-state/ccip-v2-scripts-chains-details.json create mode 100644 deployment/environment/crib/testdata/lanes-deployed-state/ccip-v2-scripts-nodes-details.json diff --git a/deployment/environment/crib/data.go b/deployment/environment/crib/data.go new file mode 100644 index 00000000000..2a029d40dd5 --- /dev/null +++ b/deployment/environment/crib/data.go @@ -0,0 +1,95 @@ +package crib + +import ( + "encoding/json" + "fmt" + "io" + "os" + + "github.com/smartcontractkit/chainlink/deployment" + "github.com/smartcontractkit/chainlink/deployment/environment/devenv" +) + +type OutputReader struct { + outputDir string +} + +func NewOutputReader(outputDir string) *OutputReader { + return &OutputReader{outputDir: outputDir} +} + +func (r *OutputReader) ReadNodesDetails() NodesDetails { + byteValue := r.readFile(NodesDetailsFileName) + + var result NodesDetails + + // Unmarshal the JSON into the map + err := json.Unmarshal(byteValue, &result) + if err != nil { + fmt.Println("Error unmarshalling JSON:", err) + panic(err) + } + + return result +} + +func (r *OutputReader) ReadChainConfigs() []devenv.ChainConfig { + byteValue := r.readFile(ChainsConfigsFileName) + + var result []devenv.ChainConfig + + // Unmarshal the JSON into the map + err := json.Unmarshal(byteValue, &result) + if err != nil { + fmt.Println("Error unmarshalling JSON:", err) + panic(err) + } + + return result +} + +func ToChainConfigs(cc []ChainConfig) []devenv.ChainConfig { + chainConfigs := make([]devenv.ChainConfig, 0) + for _, c := range cc { + chainConfigs = append(chainConfigs, devenv.ChainConfig{ + ChainID: c.ChainID, + ChainName: c.ChainName, + ChainType: c.ChainType, + WSRPCs: c.WSRPCs, + HTTPRPCs: c.HTTPRPCs, + }) + } + return chainConfigs +} + +func (r *OutputReader) ReadAddressBook() *deployment.AddressBookMap { + byteValue := r.readFile(AddressBookFileName) + + var result map[uint64]map[string]deployment.TypeAndVersion + + // Unmarshal the JSON into the map + err := json.Unmarshal(byteValue, &result) + if err != nil { + fmt.Println("Error unmarshalling JSON:", err) + panic(err) + } + + return deployment.NewMemoryAddressBookFromMap(result) +} + +func (r *OutputReader) readFile(fileName string) []byte { + file, err := os.Open(fmt.Sprintf("%s/%s", r.outputDir, fileName)) + if err != nil { + fmt.Println("Error opening file:", err) + panic(err) + } + defer file.Close() + + // Read the file's content into a byte slice + byteValue, err := io.ReadAll(file) + if err != nil { + fmt.Println("Error reading file:", err) + panic(err) + } + return byteValue +} diff --git a/deployment/environment/crib/env.go b/deployment/environment/crib/env.go new file mode 100644 index 00000000000..07a1b2c80e7 --- /dev/null +++ b/deployment/environment/crib/env.go @@ -0,0 +1,40 @@ +package crib + +const ( + AddressBookFileName = "ccip-v2-scripts-address-book.json" + NodesDetailsFileName = "ccip-v2-scripts-nodes-details.json" + ChainsConfigsFileName = "ccip-v2-scripts-chains-details.json" +) + +type CRIBEnv struct { + envStateDir string +} + +func NewDevspaceEnvFromStateDir(envStateDir string) CRIBEnv { + return CRIBEnv{ + envStateDir: envStateDir, + } +} + +func (c CRIBEnv) GetConfig() DeployOutput { + reader := NewOutputReader(c.envStateDir) + nodesDetails := reader.ReadNodesDetails() + chainConfigs := reader.ReadChainConfigs() + return DeployOutput{ + AddressBook: reader.ReadAddressBook(), + NodeIDs: nodesDetails.NodeIDs, + Chains: chainConfigs, + } +} + +type ChainConfig struct { + ChainID uint64 // chain id as per EIP-155, mainly applicable for EVM chains + ChainName string // name of the chain populated from chainselector repo + ChainType string // should denote the chain family. Acceptable values are EVM, COSMOS, SOLANA, STARKNET, APTOS etc + WSRPCs []string // websocket rpcs to connect to the chain + HTTPRPCs []string // http rpcs to connect to the chain +} + +type NodesDetails struct { + NodeIDs []string +} diff --git a/deployment/environment/crib/env_test.go b/deployment/environment/crib/env_test.go new file mode 100644 index 00000000000..262a2540923 --- /dev/null +++ b/deployment/environment/crib/env_test.go @@ -0,0 +1,18 @@ +package crib + +import ( + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func TestShouldProvideEnvironmentConfig(t *testing.T) { + t.Parallel() + env := NewDevspaceEnvFromStateDir("testdata/lanes-deployed-state") + config := env.GetConfig() + require.NotNil(t, config) + assert.NotEmpty(t, config.NodeIDs) + assert.NotNil(t, config.AddressBook) + assert.NotEmpty(t, config.Chains) +} diff --git a/deployment/environment/crib/testdata/lanes-deployed-state/ccip-v2-scripts-address-book.json b/deployment/environment/crib/testdata/lanes-deployed-state/ccip-v2-scripts-address-book.json new file mode 100644 index 00000000000..e4b2672cb5f --- /dev/null +++ b/deployment/environment/crib/testdata/lanes-deployed-state/ccip-v2-scripts-address-book.json @@ -0,0 +1 @@ +{"12922642891491394802":{"0x05Aa229Aec102f78CE0E852A812a388F076Aa555":{"Type":"CancellerManyChainMultiSig","Version":"1.0.0"},"0x0D4ff719551E23185Aeb16FFbF2ABEbB90635942":{"Type":"TestRouter","Version":"1.2.0"},"0x0f5D1ef48f12b6f691401bfe88c2037c690a6afe":{"Type":"ProposerManyChainMultiSig","Version":"1.0.0"},"0x2dE080e97B0caE9825375D31f5D0eD5751fDf16D":{"Type":"CCIPReceiver","Version":"1.0.0"},"0x2fc631e4B3018258759C52AF169200213e84ABab":{"Type":"OnRamp","Version":"1.6.0-dev"},"0x5C7c905B505f0Cf40Ab6600d05e677F717916F6B":{"Type":"Router","Version":"1.2.0"},"0x63cf2Cd54fE91e3545D1379abf5bfd194545259d":{"Type":"OffRamp","Version":"1.6.0-dev"},"0x712516e61C8B383dF4A63CFe83d7701Bce54B03e":{"Type":"LinkToken","Version":"1.0.0"},"0x71C95911E9a5D330f4D621842EC243EE1343292e":{"Type":"PriceFeed","Version":"1.0.0"},"0x73eccD6288e117cAcA738BDAD4FEC51312166C1A":{"Type":"RMNRemote","Version":"1.6.0-dev"},"0x8464135c8F25Da09e49BC8782676a84730C318bC":{"Type":"PriceFeed","Version":"1.0.0"},"0x85C5Dd61585773423e378146D4bEC6f8D149E248":{"Type":"TokenAdminRegistry","Version":"1.5.0"},"0x948B3c65b89DF0B4894ABE91E6D02FE579834F8F":{"Type":"WETH9","Version":"1.0.0"},"0xAfe1b5bdEbD4ae65AF2024738bf0735fbb65d44b":{"Type":"FeeQuoter","Version":"1.6.0-dev"},"0xC6bA8C3233eCF65B761049ef63466945c362EdD2":{"Type":"BypasserManyChainMultiSig","Version":"1.0.0"},"0xbCF26943C0197d2eE0E5D05c716Be60cc2761508":{"Type":"AdminManyChainMultiSig","Version":"1.0.0"},"0xcA03Dc4665A8C3603cb4Fd5Ce71Af9649dC00d44":{"Type":"RBACTimelock","Version":"1.0.0"},"0xe6b98F104c1BEf218F3893ADab4160Dc73Eb8367":{"Type":"ARMProxy","Version":"1.0.0"},"0xfbAb4aa40C202E4e80390171E82379824f7372dd":{"Type":"NonceManager","Version":"1.6.0-dev"}},"3379446385462418246":{"0x09635F643e140090A9A8Dcd712eD6285858ceBef":{"Type":"RMNRemote","Version":"1.6.0-dev"},"0x0B306BF915C4d645ff596e518fAf3F9669b97016":{"Type":"LinkToken","Version":"1.0.0"},"0x1613beB3B2C4f22Ee086B2b38C1476A3cE7f78E8":{"Type":"OnRamp","Version":"1.6.0-dev"},"0x2279B7A0a67DB372996a5FaB50D91eAA73d2eBe6":{"Type":"CCIPHome","Version":"1.6.0-dev"},"0x322813Fd9A801c5507c9de605d63CEA4f2CE6c44":{"Type":"ProposerManyChainMultiSig","Version":"1.0.0"},"0x3Aa5ebB10DC797CAC828524e59A333d0A371443c":{"Type":"BypasserManyChainMultiSig","Version":"1.0.0"},"0x4A679253410272dd5232B3Ff7cF5dbB88f295319":{"Type":"RBACTimelock","Version":"1.0.0"},"0x59b670e9fA9D0A427751Af201D676719a970857b":{"Type":"CancellerManyChainMultiSig","Version":"1.0.0"},"0x67d269191c92Caf3cD7723F116c85e6E9bf55933":{"Type":"ARMProxy","Version":"1.0.0"},"0x7a2088a1bFc9d81c55368AE168C2C02570cB814F":{"Type":"CCIPReceiver","Version":"1.0.0"},"0x84eA74d481Ee0A5332c457a4d796187F6Ba67fEB":{"Type":"TokenAdminRegistry","Version":"1.5.0"},"0x851356ae760d987E095750cCeb3bC6014560891C":{"Type":"OffRamp","Version":"1.6.0-dev"},"0x8A791620dd6260079BF849Dc5567aDC3F2FdC318":{"Type":"RMNHome","Version":"1.6.0-dev"},"0x9A676e781A523b5d0C0e43731313A708CB607508":{"Type":"WETH9","Version":"1.0.0"},"0x9A9f2CCfdE556A7E9Ff0848998Aa4a0CFD8863AE":{"Type":"AdminManyChainMultiSig","Version":"1.0.0"},"0x9E545E3C0baAB3E08CdfD552C960A1050f373042":{"Type":"NonceManager","Version":"1.6.0-dev"},"0xE6E340D132b5f46d1e472DebcD681B2aBc16e57E":{"Type":"Router","Version":"1.2.0"},"0xa513E6E4b8f2a923D98304ec87F64353C4D5C853":{"Type":"CapabilitiesRegistry","Version":"1.0.0"},"0xa82fF9aFd8f496c3d6ac40E2a0F282E47488CFc9":{"Type":"FeeQuoter","Version":"1.6.0-dev"},"0xc3e53F4d16Ae77Db1c982e75a937B9f60FE63690":{"Type":"TestRouter","Version":"1.2.0"}}} diff --git a/deployment/environment/crib/testdata/lanes-deployed-state/ccip-v2-scripts-chains-details.json b/deployment/environment/crib/testdata/lanes-deployed-state/ccip-v2-scripts-chains-details.json new file mode 100644 index 00000000000..f93ea4ce231 --- /dev/null +++ b/deployment/environment/crib/testdata/lanes-deployed-state/ccip-v2-scripts-chains-details.json @@ -0,0 +1,24 @@ +[ + { + "ChainID": 1337, + "ChainName": "alpha", + "ChainType": "EVM", + "WSRPCs": [ + "wss://crib-local-geth-1337-ws.local:443" + ], + "HTTPRPCs": [ + "https://crib-local-geth-1337-ws.local:443" + ] + }, + { + "ChainID": 2337, + "ChainName": "alpha", + "ChainType": "EVM", + "WSRPCs": [ + "wss://crib-local-geth-2337-ws.local:443" + ], + "HTTPRPCs": [ + "https://crib-local-geth-2337-ws.local:443" + ] + } +] diff --git a/deployment/environment/crib/testdata/lanes-deployed-state/ccip-v2-scripts-nodes-details.json b/deployment/environment/crib/testdata/lanes-deployed-state/ccip-v2-scripts-nodes-details.json new file mode 100644 index 00000000000..477ae0527b1 --- /dev/null +++ b/deployment/environment/crib/testdata/lanes-deployed-state/ccip-v2-scripts-nodes-details.json @@ -0,0 +1 @@ +{"NodeIDs":["node_2URuou3RXmtZu5gLQX8qd","node_m9TTQbUxBx3WjDEjmpVDL","node_4FiKVPtuQjCTvHnS7QpES","node_A4VTgecDwMoG2YYicyjuG","node_jQFpzXDadzaADq147nThS"]} From 8b31af9729ca254f9b0dbb2df565506c9dcb98f0 Mon Sep 17 00:00:00 2001 From: Radek Scheibinger Date: Thu, 12 Dec 2024 13:30:34 +0100 Subject: [PATCH 26/26] add RPC type with internal and external rpcs --- deployment/environment/crib/data.go | 14 -------------- deployment/environment/crib/env.go | 15 ++++++++++----- 2 files changed, 10 insertions(+), 19 deletions(-) diff --git a/deployment/environment/crib/data.go b/deployment/environment/crib/data.go index 2a029d40dd5..b9197691613 100644 --- a/deployment/environment/crib/data.go +++ b/deployment/environment/crib/data.go @@ -48,20 +48,6 @@ func (r *OutputReader) ReadChainConfigs() []devenv.ChainConfig { return result } -func ToChainConfigs(cc []ChainConfig) []devenv.ChainConfig { - chainConfigs := make([]devenv.ChainConfig, 0) - for _, c := range cc { - chainConfigs = append(chainConfigs, devenv.ChainConfig{ - ChainID: c.ChainID, - ChainName: c.ChainName, - ChainType: c.ChainType, - WSRPCs: c.WSRPCs, - HTTPRPCs: c.HTTPRPCs, - }) - } - return chainConfigs -} - func (r *OutputReader) ReadAddressBook() *deployment.AddressBookMap { byteValue := r.readFile(AddressBookFileName) diff --git a/deployment/environment/crib/env.go b/deployment/environment/crib/env.go index 07a1b2c80e7..3af1acaf754 100644 --- a/deployment/environment/crib/env.go +++ b/deployment/environment/crib/env.go @@ -27,12 +27,17 @@ func (c CRIBEnv) GetConfig() DeployOutput { } } +type RPC struct { + External *string + Internal *string +} + type ChainConfig struct { - ChainID uint64 // chain id as per EIP-155, mainly applicable for EVM chains - ChainName string // name of the chain populated from chainselector repo - ChainType string // should denote the chain family. Acceptable values are EVM, COSMOS, SOLANA, STARKNET, APTOS etc - WSRPCs []string // websocket rpcs to connect to the chain - HTTPRPCs []string // http rpcs to connect to the chain + ChainID uint64 // chain id as per EIP-155, mainly applicable for EVM chains + ChainName string // name of the chain populated from chainselector repo + ChainType string // should denote the chain family. Acceptable values are EVM, COSMOS, SOLANA, STARKNET, APTOS etc + WSRPCs []RPC // websocket rpcs to connect to the chain + HTTPRPCs []RPC // http rpcs to connect to the chain } type NodesDetails struct {