From 597ad12d12dbb961f1de170e833ce86d29e9248b Mon Sep 17 00:00:00 2001 From: 0xAustinWang Date: Wed, 8 Jan 2025 21:16:13 +0800 Subject: [PATCH 1/5] support the chains in crib setup --- deployment/environment/crib/ccip_deployer.go | 35 +++++++++++++++++--- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/deployment/environment/crib/ccip_deployer.go b/deployment/environment/crib/ccip_deployer.go index bb3acec8aa4..fc1e5a464c1 100644 --- a/deployment/environment/crib/ccip_deployer.go +++ b/deployment/environment/crib/ccip_deployer.go @@ -4,6 +4,8 @@ import ( "context" "errors" "fmt" + "github.com/smartcontractkit/chainlink-ccip/chainconfig" + cciptypes "github.com/smartcontractkit/chainlink-ccip/pkg/types/ccipocr3" "math/big" "github.com/ethereum/go-ethereum/common" @@ -20,9 +22,8 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/logger" ) -// DeployHomeChainContracts deploys the home chain contracts so that the chainlink nodes can be started with the CR address in Capabilities.ExternalRegistry -// 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) +// DeployHomeChainContracts deploys the home chain contracts so that the chainlink nodes can use the CR address in Capabilities.ExternalRegistry +// Afterwards, we 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 { @@ -68,6 +69,7 @@ func DeployHomeChainContracts(ctx context.Context, lggr logger.Logger, envConfig return capRegConfig, e.ExistingAddresses, nil } +// DeployCCIPAndAddLanes is the actual ccip setup once the nodes are initialized. 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 { @@ -93,8 +95,31 @@ func DeployCCIPAndAddLanes(ctx context.Context, lggr logger.Logger, envConfig de }) } - // 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 + // set up chains + var addChainChangesets []commonchangeset.ChangesetApplication + chainConfigs := make(map[uint64]changeset.ChainConfig) + nodeInfo, err := deployment.NodeInfo(e.NodeIDs, e.Offchain) + if err != nil { + return DeployCCIPOutput{}, fmt.Errorf("failed to get node info from env: %w", err) + } + for _, chain := range chainSelectors { + chainConfigs[chain] = changeset.ChainConfig{ + Readers: nodeInfo.NonBootstraps().PeerIDs(), + FChain: uint8(len(nodeInfo.NonBootstraps().PeerIDs()) / 3), + EncodableChainConfig: chainconfig.ChainConfig{ + GasPriceDeviationPPB: cciptypes.BigInt{Int: big.NewInt(1000)}, + DAGasPriceDeviationPPB: cciptypes.BigInt{Int: big.NewInt(1_000_000)}, + OptimisticConfirmations: 1, + }, + } + } + + *e, err = commonchangeset.ApplyChangesets(nil, *e, nil, addChainChangesets) + if err != nil { + return DeployCCIPOutput{}, fmt.Errorf("failed to add chains: %w", err) + } + + // Setup 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), From 29638ffb5dc2487b55f98cc2d9ebcf3e4279da4a Mon Sep 17 00:00:00 2001 From: 0xAustinWang Date: Wed, 8 Jan 2025 21:29:53 +0800 Subject: [PATCH 2/5] use fchain of 1 --- deployment/environment/crib/ccip_deployer.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deployment/environment/crib/ccip_deployer.go b/deployment/environment/crib/ccip_deployer.go index fc1e5a464c1..fbd33447fde 100644 --- a/deployment/environment/crib/ccip_deployer.go +++ b/deployment/environment/crib/ccip_deployer.go @@ -105,7 +105,7 @@ func DeployCCIPAndAddLanes(ctx context.Context, lggr logger.Logger, envConfig de for _, chain := range chainSelectors { chainConfigs[chain] = changeset.ChainConfig{ Readers: nodeInfo.NonBootstraps().PeerIDs(), - FChain: uint8(len(nodeInfo.NonBootstraps().PeerIDs()) / 3), + FChain: 1, EncodableChainConfig: chainconfig.ChainConfig{ GasPriceDeviationPPB: cciptypes.BigInt{Int: big.NewInt(1000)}, DAGasPriceDeviationPPB: cciptypes.BigInt{Int: big.NewInt(1_000_000)}, From 93d44f6c48483f13b8c6eb0c65ba529c0cd53528 Mon Sep 17 00:00:00 2001 From: 0xAustinWang Date: Wed, 8 Jan 2025 23:53:28 +0800 Subject: [PATCH 3/5] actually add the changesets, apply them --- deployment/environment/crib/ccip_deployer.go | 23 ++++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/deployment/environment/crib/ccip_deployer.go b/deployment/environment/crib/ccip_deployer.go index fbd33447fde..018707e69af 100644 --- a/deployment/environment/crib/ccip_deployer.go +++ b/deployment/environment/crib/ccip_deployer.go @@ -4,22 +4,21 @@ import ( "context" "errors" "fmt" - "github.com/smartcontractkit/chainlink-ccip/chainconfig" - cciptypes "github.com/smartcontractkit/chainlink-ccip/pkg/types/ccipocr3" "math/big" "github.com/ethereum/go-ethereum/common" - "github.com/smartcontractkit/ccip-owner-contracts/pkg/config" + "github.com/smartcontractkit/ccip-owner-contracts/pkg/config" + "github.com/smartcontractkit/chainlink-ccip/chainconfig" + cciptypes "github.com/smartcontractkit/chainlink-ccip/pkg/types/ccipocr3" + "github.com/smartcontractkit/chainlink/deployment" + "github.com/smartcontractkit/chainlink/deployment/ccip/changeset" 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/gethwrappers/ccip/generated/fee_quoter" - "github.com/smartcontractkit/chainlink/v2/core/services/relay" - - "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 use the CR address in Capabilities.ExternalRegistry @@ -114,6 +113,16 @@ func DeployCCIPAndAddLanes(ctx context.Context, lggr logger.Logger, envConfig de } } + for range chainSelectors { + addChainChangesets = append(addChainChangesets, commonchangeset.ChangesetApplication{ + Changeset: commonchangeset.WrapChangeSet(changeset.UpdateChainConfig), + Config: changeset.UpdateChainConfigConfig{ + HomeChainSelector: homeChainSel, + RemoteChainAdds: chainConfigs, + }, + }) + } + *e, err = commonchangeset.ApplyChangesets(nil, *e, nil, addChainChangesets) if err != nil { return DeployCCIPOutput{}, fmt.Errorf("failed to add chains: %w", err) From 031c1e8f61dd83f410132bb105dc0ef9a2b732fd Mon Sep 17 00:00:00 2001 From: 0xAustinWang Date: Thu, 9 Jan 2025 11:33:05 +0800 Subject: [PATCH 4/5] apply changeset within the whole system --- deployment/environment/crib/ccip_deployer.go | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/deployment/environment/crib/ccip_deployer.go b/deployment/environment/crib/ccip_deployer.go index 018707e69af..584120f4a03 100644 --- a/deployment/environment/crib/ccip_deployer.go +++ b/deployment/environment/crib/ccip_deployer.go @@ -95,7 +95,6 @@ func DeployCCIPAndAddLanes(ctx context.Context, lggr logger.Logger, envConfig de } // set up chains - var addChainChangesets []commonchangeset.ChangesetApplication chainConfigs := make(map[uint64]changeset.ChainConfig) nodeInfo, err := deployment.NodeInfo(e.NodeIDs, e.Offchain) if err != nil { @@ -113,23 +112,15 @@ func DeployCCIPAndAddLanes(ctx context.Context, lggr logger.Logger, envConfig de } } - for range chainSelectors { - addChainChangesets = append(addChainChangesets, commonchangeset.ChangesetApplication{ + // Setup because we only need to deploy the contracts and distribute job specs + *e, err = commonchangeset.ApplyChangesets(nil, *e, nil, []commonchangeset.ChangesetApplication{ + { Changeset: commonchangeset.WrapChangeSet(changeset.UpdateChainConfig), Config: changeset.UpdateChainConfigConfig{ HomeChainSelector: homeChainSel, RemoteChainAdds: chainConfigs, }, - }) - } - - *e, err = commonchangeset.ApplyChangesets(nil, *e, nil, addChainChangesets) - if err != nil { - return DeployCCIPOutput{}, fmt.Errorf("failed to add chains: %w", err) - } - - // Setup 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), Config: chainSelectors, From 8fec9463d67d13ec7ede5d0cff664a25a7e3615a Mon Sep 17 00:00:00 2001 From: 0xAustinWang Date: Thu, 9 Jan 2025 17:14:54 +0800 Subject: [PATCH 5/5] go imports --- deployment/environment/crib/ccip_deployer.go | 1 + 1 file changed, 1 insertion(+) diff --git a/deployment/environment/crib/ccip_deployer.go b/deployment/environment/crib/ccip_deployer.go index 584120f4a03..639e42b4024 100644 --- a/deployment/environment/crib/ccip_deployer.go +++ b/deployment/environment/crib/ccip_deployer.go @@ -9,6 +9,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/smartcontractkit/ccip-owner-contracts/pkg/config" + "github.com/smartcontractkit/chainlink-ccip/chainconfig" cciptypes "github.com/smartcontractkit/chainlink-ccip/pkg/types/ccipocr3" "github.com/smartcontractkit/chainlink/deployment"