Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add chains to ccip in crib setup #15862

Merged
merged 5 commits into from
Jan 9, 2025
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 35 additions & 10 deletions deployment/environment/crib/ccip_deployer.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,22 @@ import (
"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 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 {
Expand Down Expand Up @@ -68,6 +68,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 {
Expand All @@ -93,9 +94,33 @@ 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
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: 1,
EncodableChainConfig: chainconfig.ChainConfig{
GasPriceDeviationPPB: cciptypes.BigInt{Int: big.NewInt(1000)},
DAGasPriceDeviationPPB: cciptypes.BigInt{Int: big.NewInt(1_000_000)},
OptimisticConfirmations: 1,
},
}
}

// 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,
},
},
{
Changeset: commonchangeset.WrapChangeSet(commonchangeset.DeployLinkToken),
Config: chainSelectors,
Expand Down
Loading