Skip to content

Commit

Permalink
add chains to ccip in crib setup (#15862)
Browse files Browse the repository at this point in the history
* support the chains in crib setup

* use fchain of 1

* actually add the changesets, apply them

* apply changeset within the whole system

* go imports
  • Loading branch information
0xAustinWang authored Jan 9, 2025
1 parent c7759e1 commit 4018420
Showing 1 changed file with 35 additions and 9 deletions.
44 changes: 35 additions & 9 deletions deployment/environment/crib/ccip_deployer.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,23 @@ import (
"math/big"

"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"
"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 +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 {
Expand All @@ -93,9 +95,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

0 comments on commit 4018420

Please sign in to comment.