Skip to content

Commit

Permalink
Move the rest
Browse files Browse the repository at this point in the history
  • Loading branch information
connorwstein committed Nov 20, 2024
1 parent 95fd35a commit 654f326
Show file tree
Hide file tree
Showing 19 changed files with 74 additions and 94 deletions.
9 changes: 4 additions & 5 deletions deployment/ccip/changeset/active_candidate.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,13 @@ import (
"github.com/smartcontractkit/ccip-owner-contracts/pkg/proposal/timelock"

"github.com/smartcontractkit/chainlink/deployment"
ccdeploy "github.com/smartcontractkit/chainlink/deployment/ccip"
cctypes "github.com/smartcontractkit/chainlink/v2/core/capabilities/ccip/types"
)

// PromoteAllCandidatesChangeset generates a proposal to call promoteCandidate on the CCIPHome through CapReg.
// This needs to be called after SetCandidateProposal is executed.
func PromoteAllCandidatesChangeset(
state ccdeploy.CCIPOnChainState,
state CCIPOnChainState,
homeChainSel, newChainSel uint64,
nodes deployment.Nodes,
) (deployment.ChangesetOutput, error) {
Expand All @@ -28,7 +27,7 @@ func PromoteAllCandidatesChangeset(
return deployment.ChangesetOutput{}, err
}

prop, err := ccdeploy.BuildProposalFromBatches(state, []timelock.BatchChainOperation{{
prop, err := BuildProposalFromBatches(state, []timelock.BatchChainOperation{{
ChainIdentifier: mcms.ChainIdentifier(homeChainSel),
Batch: promoteCandidateOps,
}}, "promoteCandidate for commit and execution", 0)
Expand All @@ -44,7 +43,7 @@ func PromoteAllCandidatesChangeset(

// SetCandidateExecPluginProposal calls setCandidate on the CCIPHome for setting up OCR3 exec Plugin config for the new chain.
func SetCandidatePluginChangeset(
state ccdeploy.CCIPOnChainState,
state CCIPOnChainState,
e deployment.Environment,
nodes deployment.Nodes,
ocrSecrets deployment.OCRSecrets,
Expand Down Expand Up @@ -82,7 +81,7 @@ func SetCandidatePluginChangeset(
return deployment.ChangesetOutput{}, err
}

prop, err := ccdeploy.BuildProposalFromBatches(state, []timelock.BatchChainOperation{{
prop, err := BuildProposalFromBatches(state, []timelock.BatchChainOperation{{
ChainIdentifier: mcms.ChainIdentifier(homeChainSel),
Batch: setCandidateMCMSOps,
}}, "SetCandidate for execution", 0)
Expand Down
15 changes: 7 additions & 8 deletions deployment/ccip/changeset/active_candidate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import (

"github.com/stretchr/testify/require"

ccdeploy "github.com/smartcontractkit/chainlink/deployment/ccip"
commonchangeset "github.com/smartcontractkit/chainlink/deployment/common/changeset"

"github.com/smartcontractkit/chainlink/v2/core/logger"
Expand All @@ -28,7 +27,7 @@ func TestActiveCandidate(t *testing.T) {
lggr := logger.TestLogger(t)
tenv := NewMemoryEnvironmentWithJobsAndContracts(t, lggr, 3, 5)
e := tenv.Env
state, err := ccdeploy.LoadOnchainState(tenv.Env)
state, err := LoadOnchainState(tenv.Env)
require.NoError(t, err)

// Add all lanes
Expand Down Expand Up @@ -73,8 +72,8 @@ func TestActiveCandidate(t *testing.T) {
ConfirmExecWithSeqNrForAll(t, e, state, expectedSeqNum, startBlocks)

// transfer ownership
ccdeploy.TransferAllOwnership(t, state, tenv.HomeChainSel, e)
acceptOwnershipProposal, err := ccdeploy.GenerateAcceptOwnershipProposal(state, tenv.HomeChainSel, e.AllChainSelectors())
TransferAllOwnership(t, state, tenv.HomeChainSel, e)
acceptOwnershipProposal, err := GenerateAcceptOwnershipProposal(state, tenv.HomeChainSel, e.AllChainSelectors())
require.NoError(t, err)
acceptOwnershipExec := commonchangeset.SignProposal(t, e, acceptOwnershipProposal)
for _, sel := range e.AllChainSelectors() {
Expand All @@ -94,7 +93,7 @@ func TestActiveCandidate(t *testing.T) {
require.Equal(t, 5, len(donInfo.NodeP2PIds))
require.Equal(t, uint32(4), donInfo.ConfigCount)

state, err = ccdeploy.LoadOnchainState(e)
state, err = LoadOnchainState(e)
require.NoError(t, err)

// delete a non-bootstrap node
Expand Down Expand Up @@ -135,7 +134,7 @@ func TestActiveCandidate(t *testing.T) {
nodes.NonBootstraps(),
)
require.NoError(t, err)
setCommitCandidateProposal, err := ccdeploy.BuildProposalFromBatches(state, []timelock.BatchChainOperation{{
setCommitCandidateProposal, err := BuildProposalFromBatches(state, []timelock.BatchChainOperation{{
ChainIdentifier: mcms.ChainIdentifier(tenv.HomeChainSel),
Batch: setCommitCandidateOp,
}}, "set new candidates on commit plugin", 0)
Expand All @@ -153,7 +152,7 @@ func TestActiveCandidate(t *testing.T) {
)
require.NoError(t, err)

setExecCandidateProposal, err := ccdeploy.BuildProposalFromBatches(state, []timelock.BatchChainOperation{{
setExecCandidateProposal, err := BuildProposalFromBatches(state, []timelock.BatchChainOperation{{
ChainIdentifier: mcms.ChainIdentifier(tenv.HomeChainSel),
Batch: setExecCandidateOp,
}}, "set new candidates on commit and exec plugins", 0)
Expand All @@ -180,7 +179,7 @@ func TestActiveCandidate(t *testing.T) {

promoteOps, err := PromoteAllCandidatesForChainOps(state.Chains[tenv.HomeChainSel].CapabilityRegistry, state.Chains[tenv.HomeChainSel].CCIPHome, tenv.FeedChainSel, nodes.NonBootstraps())
require.NoError(t, err)
promoteProposal, err := ccdeploy.BuildProposalFromBatches(state, []timelock.BatchChainOperation{{
promoteProposal, err := BuildProposalFromBatches(state, []timelock.BatchChainOperation{{
ChainIdentifier: mcms.ChainIdentifier(tenv.HomeChainSel),
Batch: promoteOps,
}}, "promote candidates and revoke actives", 0)
Expand Down
21 changes: 10 additions & 11 deletions deployment/ccip/changeset/add_chain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"testing"
"time"

ccipdeployment "github.com/smartcontractkit/chainlink/deployment/ccip"
commonchangeset "github.com/smartcontractkit/chainlink/deployment/common/changeset"
commontypes "github.com/smartcontractkit/chainlink/deployment/common/types"
"github.com/smartcontractkit/chainlink/v2/core/capabilities/ccip/types"
Expand All @@ -32,14 +31,14 @@ import (
func TestAddChainInbound(t *testing.T) {
// 4 chains where the 4th is added after initial deployment.
e := NewMemoryEnvironmentWithJobs(t, logger.TestLogger(t), 4, 4)
state, err := ccipdeployment.LoadOnchainState(e.Env)
state, err := LoadOnchainState(e.Env)
require.NoError(t, err)
// Take first non-home chain as the new chain.
newChain := e.Env.AllChainSelectorsExcluding([]uint64{e.HomeChainSel})[0]
// We deploy to the rest.
initialDeploy := e.Env.AllChainSelectorsExcluding([]uint64{newChain})
newAddresses := deployment.NewMemoryAddressBook()
err = ccipdeployment.DeployPrerequisiteChainContracts(e.Env, newAddresses, initialDeploy)
err = DeployPrerequisiteChainContracts(e.Env, newAddresses, initialDeploy)
require.NoError(t, err)
require.NoError(t, e.Env.ExistingAddresses.Merge(newAddresses))

Expand All @@ -59,7 +58,7 @@ func TestAddChainInbound(t *testing.T) {
require.NoError(t, e.Env.ExistingAddresses.Merge(out.AddressBook))
newAddresses = deployment.NewMemoryAddressBook()
tokenConfig := NewTestTokenConfig(state.Chains[e.FeedChainSel].USDFeeds)
err = ccipdeployment.DeployCCIPContracts(e.Env, newAddresses, ccipdeployment.DeployCCIPContractConfig{
err = DeployCCIPContracts(e.Env, newAddresses, DeployCCIPContractConfig{
HomeChainSel: e.HomeChainSel,
FeedChainSel: e.FeedChainSel,
ChainsToDeploy: initialDeploy,
Expand All @@ -68,7 +67,7 @@ func TestAddChainInbound(t *testing.T) {
})
require.NoError(t, err)
require.NoError(t, e.Env.ExistingAddresses.Merge(newAddresses))
state, err = ccipdeployment.LoadOnchainState(e.Env)
state, err = LoadOnchainState(e.Env)
require.NoError(t, err)

// Connect all the existing lanes.
Expand All @@ -80,7 +79,7 @@ func TestAddChainInbound(t *testing.T) {
}
}

rmnHomeAddress, err := deployment.SearchAddressBook(e.Env.ExistingAddresses, e.HomeChainSel, ccipdeployment.RMNHome)
rmnHomeAddress, err := deployment.SearchAddressBook(e.Env.ExistingAddresses, e.HomeChainSel, RMNHome)
require.NoError(t, err)
require.True(t, common.IsHexAddress(rmnHomeAddress))
rmnHome, err := rmn_home.NewRMNHome(common.HexToAddress(rmnHomeAddress), e.Env.Chains[e.HomeChainSel].Client)
Expand All @@ -94,15 +93,15 @@ func TestAddChainInbound(t *testing.T) {
require.NoError(t, e.Env.ExistingAddresses.Merge(out.AddressBook))

newAddresses = deployment.NewMemoryAddressBook()
err = ccipdeployment.DeployPrerequisiteChainContracts(e.Env, newAddresses, []uint64{newChain})
err = DeployPrerequisiteChainContracts(e.Env, newAddresses, []uint64{newChain})
require.NoError(t, err)
require.NoError(t, e.Env.ExistingAddresses.Merge(newAddresses))
newAddresses = deployment.NewMemoryAddressBook()
err = ccipdeployment.DeployChainContracts(e.Env,
err = deployChainContracts(e.Env,
e.Env.Chains[newChain], newAddresses, rmnHome)
require.NoError(t, err)
require.NoError(t, e.Env.ExistingAddresses.Merge(newAddresses))
state, err = ccipdeployment.LoadOnchainState(e.Env)
state, err = LoadOnchainState(e.Env)
require.NoError(t, err)

// Transfer onramp/fq ownership to timelock.
Expand Down Expand Up @@ -135,7 +134,7 @@ func TestAddChainInbound(t *testing.T) {
_, err = deployment.ConfirmIfNoError(e.Env.Chains[e.HomeChainSel], tx, err)
require.NoError(t, err)

acceptOwnershipProposal, err := ccipdeployment.GenerateAcceptOwnershipProposal(state, e.HomeChainSel, initialDeploy)
acceptOwnershipProposal, err := GenerateAcceptOwnershipProposal(state, e.HomeChainSel, initialDeploy)
require.NoError(t, err)
acceptOwnershipExec := commonchangeset.SignProposal(t, e.Env, acceptOwnershipProposal)
// Apply the accept ownership proposal to all the chains.
Expand Down Expand Up @@ -215,7 +214,7 @@ func TestAddChainInbound(t *testing.T) {
require.NoError(t, err)

// Assert the inbound lanes to the new chain are wired correctly.
state, err = ccipdeployment.LoadOnchainState(e.Env)
state, err = LoadOnchainState(e.Env)
require.NoError(t, err)
for _, chain := range initialDeploy {
cfg, err2 := state.Chains[chain].OnRamp.GetDestChainConfig(nil, newChain)
Expand Down
3 changes: 1 addition & 2 deletions deployment/ccip/changeset/add_lane_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
commonutils "github.com/smartcontractkit/chainlink-common/pkg/utils"
"github.com/smartcontractkit/chainlink-testing-framework/lib/utils/testcontext"
"github.com/smartcontractkit/chainlink/deployment"
"github.com/smartcontractkit/chainlink/deployment/ccip"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/offramp"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/router"
"github.com/smartcontractkit/chainlink/v2/core/logger"
Expand All @@ -23,7 +22,7 @@ func TestAddLane(t *testing.T) {
// We add more chains to the chainlink nodes than the number of chains where CCIP is deployed.
e := NewMemoryEnvironmentWithJobsAndContracts(t, logger.TestLogger(t), 2, 4)
// Here we have CR + nodes set up, but no CCIP contracts deployed.
state, err := ccipdeployment.LoadOnchainState(e.Env)
state, err := LoadOnchainState(e.Env)
require.NoError(t, err)

selectors := e.Env.AllChainSelectors()
Expand Down
23 changes: 11 additions & 12 deletions deployment/ccip/changeset/deploy.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package ccipdeployment
package changeset

import (
"fmt"
Expand All @@ -12,7 +12,6 @@ import (
cciptypes "github.com/smartcontractkit/chainlink-ccip/pkg/types/ccipocr3"
"github.com/smartcontractkit/chainlink-ccip/pluginconfig"
commonconfig "github.com/smartcontractkit/chainlink-common/pkg/config"
"github.com/smartcontractkit/chainlink/deployment/ccip/changeset"

"github.com/smartcontractkit/chainlink/deployment"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/ccip_home"
Expand Down Expand Up @@ -283,7 +282,7 @@ type DeployCCIPContractConfig struct {
HomeChainSel uint64
FeedChainSel uint64
ChainsToDeploy []uint64
TokenConfig changeset.TokenConfig
TokenConfig TokenConfig
USDCConfig USDCConfig
// For setting OCR configuration
OCRSecrets deployment.OCRSecrets
Expand Down Expand Up @@ -338,7 +337,7 @@ func DeployCCIPContracts(
return fmt.Errorf("chain %d not found", chainSel)
}
if c.USDCConfig.Enabled {
token, pool, messenger, transmitter, err1 := changeset.DeployUSDC(e.Logger, chain, ab, existingState.Chains[chainSel])
token, pool, messenger, transmitter, err1 := DeployUSDC(e.Logger, chain, ab, existingState.Chains[chainSel])
if err1 != nil {
return err1
}
Expand Down Expand Up @@ -377,7 +376,7 @@ func DeployCCIPContracts(
tokenInfo := c.TokenConfig.GetTokenInfo(e.Logger, existingState.Chains[chainSel].LinkToken, existingState.Chains[chainSel].Weth9)
// TODO: Do we want to extract this?
// Add chain config for each chain.
_, err = changeset.AddChainConfig(
_, err = AddChainConfig(
e.Logger,
e.Chains[c.HomeChainSel],
ccipHome,
Expand All @@ -400,7 +399,7 @@ func DeployCCIPContracts(
}}
}
// For each chain, we create a DON on the home chain (2 OCR instances)
if err := changeset.AddDON(
if err := AddDON(
e.Logger,
c.OCRSecrets,
capReg,
Expand Down Expand Up @@ -439,15 +438,15 @@ func DeployChainContractsForChains(
return fmt.Errorf("capability registry not found")
}
cr, err := capReg.GetHashedCapabilityId(
&bind.CallOpts{}, changeset.CapabilityLabelledName, changeset.CapabilityVersion)
&bind.CallOpts{}, CapabilityLabelledName, CapabilityVersion)
if err != nil {
e.Logger.Errorw("Failed to get hashed capability id", "err", err)
return err
}
if cr != changeset.CCIPCapabilityID {
return fmt.Errorf("capability registry does not support CCIP %s %s", hexutil.Encode(cr[:]), hexutil.Encode(changeset.CCIPCapabilityID[:]))
if cr != CCIPCapabilityID {
return fmt.Errorf("capability registry does not support CCIP %s %s", hexutil.Encode(cr[:]), hexutil.Encode(CCIPCapabilityID[:]))
}
capability, err := capReg.GetCapability(nil, changeset.CCIPCapabilityID)
capability, err := capReg.GetCapability(nil, CCIPCapabilityID)
if err != nil {
e.Logger.Errorw("Failed to get capability", "err", err)
return err
Expand All @@ -473,7 +472,7 @@ func DeployChainContractsForChains(
if existingState.Chains[chainSel].LinkToken == nil || existingState.Chains[chainSel].Weth9 == nil {
return fmt.Errorf("fee tokens not found for chain %d", chainSel)
}
err := DeployChainContracts(e, chain, ab, rmnHome)
err := deployChainContracts(e, chain, ab, rmnHome)
if err != nil {
e.Logger.Errorw("Failed to deploy chain contracts", "chain", chainSel, "err", err)
return fmt.Errorf("failed to deploy chain contracts for chain %d: %w", chainSel, err)
Expand All @@ -482,7 +481,7 @@ func DeployChainContractsForChains(
return nil
}

func DeployChainContracts(
func deployChainContracts(
e deployment.Environment,
chain deployment.Chain,
ab deployment.AddressBook,
Expand Down
3 changes: 1 addition & 2 deletions deployment/ccip/changeset/deploy_chain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"go.uber.org/zap/zapcore"

"github.com/smartcontractkit/chainlink/deployment"
ccdeploy "github.com/smartcontractkit/chainlink/deployment/ccip"
commonchangeset "github.com/smartcontractkit/chainlink/deployment/common/changeset"
commontypes "github.com/smartcontractkit/chainlink/deployment/common/types"
"github.com/smartcontractkit/chainlink/deployment/environment/memory"
Expand Down Expand Up @@ -71,7 +70,7 @@ func TestDeployChainContractsChangeset(t *testing.T) {
require.NoError(t, e.ExistingAddresses.Merge(output.AddressBook))

// load onchain state
state, err := ccdeploy.LoadOnchainState(e)
state, err := LoadOnchainState(e)
require.NoError(t, err)

// verify all contracts populated
Expand Down
5 changes: 2 additions & 3 deletions deployment/ccip/changeset/deploy_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package ccipdeployment
package changeset

import (
"encoding/json"
Expand All @@ -7,13 +7,12 @@ import (

"github.com/stretchr/testify/require"

"github.com/smartcontractkit/chainlink/deployment/ccip/changeset"
"github.com/smartcontractkit/chainlink/v2/core/logger"
)

func TestDeployCCIPContracts(t *testing.T) {
lggr := logger.TestLogger(t)
e := changeset.NewMemoryEnvironmentWithJobsAndContracts(t, lggr,
e := NewMemoryEnvironmentWithJobsAndContracts(t, lggr,
2,
4,
)
Expand Down
3 changes: 1 addition & 2 deletions deployment/ccip/changeset/home_chain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"go.uber.org/zap/zapcore"

"github.com/smartcontractkit/chainlink/deployment"
ccdeploy "github.com/smartcontractkit/chainlink/deployment/ccip"
"github.com/smartcontractkit/chainlink/deployment/common/view/v1_0"
"github.com/smartcontractkit/chainlink/deployment/environment/memory"
"github.com/smartcontractkit/chainlink/v2/core/logger"
Expand Down Expand Up @@ -37,7 +36,7 @@ func TestDeployHomeChain(t *testing.T) {
output, err := DeployHomeChain(e, homeChainCfg)
require.NoError(t, err)
require.NoError(t, e.ExistingAddresses.Merge(output.AddressBook))
state, err := ccdeploy.LoadOnchainState(e)
state, err := LoadOnchainState(e)
require.NoError(t, err)
require.NotNil(t, state.Chains[homeChainSel].CapabilityRegistry)
require.NotNil(t, state.Chains[homeChainSel].CCIPHome)
Expand Down
10 changes: 4 additions & 6 deletions deployment/ccip/changeset/initial_deploy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@ import (
commonchangeset "github.com/smartcontractkit/chainlink/deployment/common/changeset"
commontypes "github.com/smartcontractkit/chainlink/deployment/common/types"

"github.com/smartcontractkit/chainlink/deployment"
ccdeploy "github.com/smartcontractkit/chainlink/deployment/ccip"

"github.com/smartcontractkit/chainlink-testing-framework/lib/utils/testcontext"
"github.com/smartcontractkit/chainlink/deployment"

"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/router"
"github.com/smartcontractkit/chainlink/v2/core/logger"
Expand All @@ -27,7 +25,7 @@ func TestInitialDeploy(t *testing.T) {
tenv := NewMemoryEnvironment(t, lggr, 3, 4, MockLinkPrice, MockWethPrice)
e := tenv.Env

state, err := ccdeploy.LoadOnchainState(tenv.Env)
state, err := LoadOnchainState(tenv.Env)
require.NoError(t, err)
output, err := DeployPrerequisites(e, DeployPrerequisiteConfig{
ChainSelectors: tenv.Env.AllChainSelectors(),
Expand All @@ -49,7 +47,7 @@ func TestInitialDeploy(t *testing.T) {
require.NoError(t, err)
require.NoError(t, e.ExistingAddresses.Merge(output.AddressBook))

output, err = InitialDeploy(tenv.Env, ccdeploy.DeployCCIPContractConfig{
output, err = InitialDeploy(tenv.Env, DeployCCIPContractConfig{
HomeChainSel: tenv.HomeChainSel,
FeedChainSel: tenv.FeedChainSel,
ChainsToDeploy: tenv.Env.AllChainSelectors(),
Expand All @@ -59,7 +57,7 @@ func TestInitialDeploy(t *testing.T) {
require.NoError(t, err)
// Get new state after migration.
require.NoError(t, tenv.Env.ExistingAddresses.Merge(output.AddressBook))
state, err = ccdeploy.LoadOnchainState(e)
state, err = LoadOnchainState(e)
require.NoError(t, err)
require.NotNil(t, state.Chains[tenv.HomeChainSel].LinkToken)
// Ensure capreg logs are up to date.
Expand Down
Loading

0 comments on commit 654f326

Please sign in to comment.