From edb4eb9dc76701bf2bbd44c84bdbfdf7fc2d8677 Mon Sep 17 00:00:00 2001 From: connorwstein Date: Wed, 20 Nov 2024 10:34:41 -0500 Subject: [PATCH] Get building --- .../{internal => }/active_candidate.go | 15 +++--- .../active_candidate_helpers.go | 15 +++--- .../{internal => }/active_candidate_test.go | 40 ++++++++-------- deployment/ccip/changeset/add_chain_test.go | 5 +- deployment/ccip/changeset/add_lane.go | 5 +- deployment/ccip/changeset/deploy_chain.go | 3 +- .../ccip/changeset/deploy_home_chain.go | 18 ++++---- deployment/ccip/changeset/home_chain.go | 2 +- deployment/ccip/changeset/initial_deploy.go | 8 ++-- .../changeset/internal/deploy_home_chain.go | 1 + .../changeset/{internal => }/ownership.go | 2 +- deployment/ccip/changeset/prerequisites.go | 3 +- deployment/ccip/changeset/test_assertions.go | 9 ++-- deployment/ccip/changeset/test_helpers.go | 46 +++++++++---------- .../ccip/changeset/test_usdc_helpers.go | 15 +++--- deployment/ccip/changeset/view.go | 3 +- 16 files changed, 87 insertions(+), 103 deletions(-) rename deployment/ccip/changeset/{internal => }/active_candidate.go (86%) rename deployment/ccip/changeset/{internal => }/active_candidate_helpers.go (90%) rename deployment/ccip/changeset/{internal => }/active_candidate_test.go (82%) create mode 100644 deployment/ccip/changeset/internal/deploy_home_chain.go rename deployment/ccip/changeset/{internal => }/ownership.go (98%) diff --git a/deployment/ccip/changeset/internal/active_candidate.go b/deployment/ccip/changeset/active_candidate.go similarity index 86% rename from deployment/ccip/changeset/internal/active_candidate.go rename to deployment/ccip/changeset/active_candidate.go index 8a1b934fc4d..f75d0e5e942 100644 --- a/deployment/ccip/changeset/internal/active_candidate.go +++ b/deployment/ccip/changeset/active_candidate.go @@ -1,4 +1,4 @@ -package internal +package changeset import ( "fmt" @@ -7,14 +7,13 @@ import ( "github.com/smartcontractkit/ccip-owner-contracts/pkg/proposal/timelock" "github.com/smartcontractkit/chainlink/deployment" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset" 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 changeset.CCIPOnChainState, + state CCIPOnChainState, homeChainSel, newChainSel uint64, nodes deployment.Nodes, ) (deployment.ChangesetOutput, error) { @@ -28,7 +27,7 @@ func PromoteAllCandidatesChangeset( return deployment.ChangesetOutput{}, err } - prop, err := changeset.BuildProposalFromBatches(state, []timelock.BatchChainOperation{{ + prop, err := BuildProposalFromBatches(state, []timelock.BatchChainOperation{{ ChainIdentifier: mcms.ChainIdentifier(homeChainSel), Batch: promoteCandidateOps, }}, "promoteCandidate for commit and execution", 0) @@ -44,15 +43,15 @@ func PromoteAllCandidatesChangeset( // SetCandidateExecPluginProposal calls setCandidate on the CCIPHome for setting up OCR3 exec Plugin config for the new chain. func SetCandidatePluginChangeset( - state changeset.CCIPOnChainState, + state CCIPOnChainState, e deployment.Environment, nodes deployment.Nodes, ocrSecrets deployment.OCRSecrets, homeChainSel, feedChainSel, newChainSel uint64, - tokenConfig changeset.TokenConfig, + tokenConfig TokenConfig, pluginType cctypes.PluginType, ) (deployment.ChangesetOutput, error) { - newDONArgs, err := changeset.BuildOCR3ConfigForCCIPHome( + newDONArgs, err := BuildOCR3ConfigForCCIPHome( ocrSecrets, state.Chains[newChainSel].OffRamp, e.Chains[newChainSel], @@ -82,7 +81,7 @@ func SetCandidatePluginChangeset( return deployment.ChangesetOutput{}, err } - prop, err := changeset.BuildProposalFromBatches(state, []timelock.BatchChainOperation{{ + prop, err := BuildProposalFromBatches(state, []timelock.BatchChainOperation{{ ChainIdentifier: mcms.ChainIdentifier(homeChainSel), Batch: setCandidateMCMSOps, }}, "SetCandidate for execution", 0) diff --git a/deployment/ccip/changeset/internal/active_candidate_helpers.go b/deployment/ccip/changeset/active_candidate_helpers.go similarity index 90% rename from deployment/ccip/changeset/internal/active_candidate_helpers.go rename to deployment/ccip/changeset/active_candidate_helpers.go index 26d552ccb77..914f8fc0c17 100644 --- a/deployment/ccip/changeset/internal/active_candidate_helpers.go +++ b/deployment/ccip/changeset/active_candidate_helpers.go @@ -1,4 +1,4 @@ -package internal +package changeset import ( "fmt" @@ -7,7 +7,6 @@ import ( "github.com/smartcontractkit/ccip-owner-contracts/pkg/proposal/mcms" "github.com/smartcontractkit/chainlink/deployment" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset" cctypes "github.com/smartcontractkit/chainlink/v2/core/capabilities/ccip/types" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/ccip_home" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/keystone/generated/capabilities_registry" @@ -23,12 +22,12 @@ func SetCandidateOnExistingDon( nodes deployment.Nodes, ) ([]mcms.Operation, error) { // fetch DON ID for the chain - donID, err := changeset.DonIDForChain(capReg, ccipHome, chainSelector) + donID, err := DonIDForChain(capReg, ccipHome, chainSelector) if err != nil { return nil, fmt.Errorf("fetch don id for chain: %w", err) } fmt.Printf("donID: %d", donID) - encodedSetCandidateCall, err := changeset.CCIPHomeABI.Pack( + encodedSetCandidateCall, err := CCIPHomeABI.Pack( "setCandidate", donID, pluginConfig.PluginType, @@ -46,7 +45,7 @@ func SetCandidateOnExistingDon( nodes.PeerIDs(), []capabilities_registry.CapabilitiesRegistryCapabilityConfiguration{ { - CapabilityId: changeset.CCIPCapabilityID, + CapabilityId: CCIPCapabilityID, Config: encodedSetCandidateCall, }, }, @@ -78,7 +77,7 @@ func PromoteCandidateOp(donID uint32, pluginType uint8, capReg *capabilities_reg } fmt.Printf("commit candidate digest after setCandidate: %x\n", allConfigs.CandidateConfig.ConfigDigest) - encodedPromotionCall, err := changeset.CCIPHomeABI.Pack( + encodedPromotionCall, err := CCIPHomeABI.Pack( "promoteCandidateAndRevokeActive", donID, pluginType, @@ -95,7 +94,7 @@ func PromoteCandidateOp(donID uint32, pluginType uint8, capReg *capabilities_reg nodes.PeerIDs(), []capabilities_registry.CapabilitiesRegistryCapabilityConfiguration{ { - CapabilityId: changeset.CCIPCapabilityID, + CapabilityId: CCIPCapabilityID, Config: encodedPromotionCall, }, }, @@ -120,7 +119,7 @@ func PromoteAllCandidatesForChainOps( nodes deployment.Nodes, ) ([]mcms.Operation, error) { // fetch DON ID for the chain - donID, err := changeset.DonIDForChain(capReg, ccipHome, chainSelector) + donID, err := DonIDForChain(capReg, ccipHome, chainSelector) if err != nil { return nil, fmt.Errorf("fetch don id for chain: %w", err) } diff --git a/deployment/ccip/changeset/internal/active_candidate_test.go b/deployment/ccip/changeset/active_candidate_test.go similarity index 82% rename from deployment/ccip/changeset/internal/active_candidate_test.go rename to deployment/ccip/changeset/active_candidate_test.go index 96f120db58d..0a85b7ef51d 100644 --- a/deployment/ccip/changeset/internal/active_candidate_test.go +++ b/deployment/ccip/changeset/active_candidate_test.go @@ -1,4 +1,4 @@ -package internal +package changeset import ( "testing" @@ -8,8 +8,6 @@ import ( "github.com/smartcontractkit/ccip-owner-contracts/pkg/proposal/timelock" "github.com/smartcontractkit/chainlink-testing-framework/lib/utils/testcontext" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset" - cctypes "github.com/smartcontractkit/chainlink/v2/core/capabilities/ccip/types" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/router" @@ -26,13 +24,13 @@ func TestActiveCandidate(t *testing.T) { t.Skipf("to be enabled after latest cl-ccip is compatible") lggr := logger.TestLogger(t) - tenv := changeset.NewMemoryEnvironmentWithJobsAndContracts(t, lggr, 3, 5) + tenv := NewMemoryEnvironmentWithJobsAndContracts(t, lggr, 3, 5) e := tenv.Env - state, err := changeset.LoadOnchainState(tenv.Env) + state, err := LoadOnchainState(tenv.Env) require.NoError(t, err) // Add all lanes - require.NoError(t, changeset.AddLanesForAll(e, state)) + require.NoError(t, AddLanesForAll(e, state)) // Need to keep track of the block number for each chain so that event subscription can be done from that block. startBlocks := make(map[uint64]*uint64) // Send a message from each chain to every other chain. @@ -46,7 +44,7 @@ func TestActiveCandidate(t *testing.T) { require.NoError(t, err) block := latesthdr.Number.Uint64() startBlocks[dest] = &block - msgSentEvent := changeset.TestSendRequest(t, e, state, src, dest, false, router.ClientEVM2AnyMessage{ + msgSentEvent := TestSendRequest(t, e, state, src, dest, false, router.ClientEVM2AnyMessage{ Receiver: common.LeftPadBytes(state.Chains[dest].Receiver.Address().Bytes(), 32), Data: []byte("hello world"), TokenAmounts: nil, @@ -58,7 +56,7 @@ func TestActiveCandidate(t *testing.T) { } // Wait for all commit reports to land. - changeset.ConfirmCommitForAllWithExpectedSeqNums(t, e, state, expectedSeqNum, startBlocks) + ConfirmCommitForAllWithExpectedSeqNums(t, e, state, expectedSeqNum, startBlocks) //After commit is reported on all chains, token prices should be updated in FeeQuoter. for dest := range e.Chains { @@ -66,15 +64,15 @@ func TestActiveCandidate(t *testing.T) { feeQuoter := state.Chains[dest].FeeQuoter timestampedPrice, err := feeQuoter.GetTokenPrice(nil, linkAddress) require.NoError(t, err) - require.Equal(t, changeset.MockLinkPrice, timestampedPrice.Value) + require.Equal(t, MockLinkPrice, timestampedPrice.Value) } //Wait for all exec reports to land - changeset.ConfirmExecWithSeqNrForAll(t, e, state, expectedSeqNum, startBlocks) + ConfirmExecWithSeqNrForAll(t, e, state, expectedSeqNum, startBlocks) // transfer ownership TransferAllOwnership(t, state, tenv.HomeChainSel, e) - acceptOwnershipProposal, err := changeset.GenerateAcceptOwnershipProposal(state, tenv.HomeChainSel, e.AllChainSelectors()) + acceptOwnershipProposal, err := GenerateAcceptOwnershipProposal(state, tenv.HomeChainSel, e.AllChainSelectors()) require.NoError(t, err) acceptOwnershipExec := commonchangeset.SignProposal(t, e, acceptOwnershipProposal) for _, sel := range e.AllChainSelectors() { @@ -82,19 +80,19 @@ func TestActiveCandidate(t *testing.T) { } // Apply the accept ownership proposal to all the chains. - err = changeset.ConfirmRequestOnSourceAndDest(t, e, state, tenv.HomeChainSel, tenv.FeedChainSel, 2) + err = ConfirmRequestOnSourceAndDest(t, e, state, tenv.HomeChainSel, tenv.FeedChainSel, 2) require.NoError(t, err) // [ACTIVE, CANDIDATE] setup by setting candidate through cap reg capReg, ccipHome := state.Chains[tenv.HomeChainSel].CapabilityRegistry, state.Chains[tenv.HomeChainSel].CCIPHome - donID, err := changeset.DonIDForChain(capReg, ccipHome, tenv.FeedChainSel) + donID, err := DonIDForChain(capReg, ccipHome, tenv.FeedChainSel) require.NoError(t, err) donInfo, err := state.Chains[tenv.HomeChainSel].CapabilityRegistry.GetDON(nil, donID) require.NoError(t, err) require.Equal(t, 5, len(donInfo.NodeP2PIds)) require.Equal(t, uint32(4), donInfo.ConfigCount) - state, err = changeset.LoadOnchainState(e) + state, err = LoadOnchainState(e) require.NoError(t, err) // delete a non-bootstrap node @@ -114,8 +112,8 @@ func TestActiveCandidate(t *testing.T) { // this will construct ocr3 configurations for the // commit and exec plugin we will be using rmnHomeAddress := state.Chains[tenv.HomeChainSel].RMNHome.Address() - tokenConfig := changeset.NewTestTokenConfig(state.Chains[tenv.FeedChainSel].USDFeeds) - ocr3ConfigMap, err := changeset.BuildOCR3ConfigForCCIPHome( + tokenConfig := NewTestTokenConfig(state.Chains[tenv.FeedChainSel].USDFeeds) + ocr3ConfigMap, err := BuildOCR3ConfigForCCIPHome( deployment.XXXGenerateTestOCRSecrets(), state.Chains[tenv.FeedChainSel].OffRamp, e.Chains[tenv.FeedChainSel], @@ -135,7 +133,7 @@ func TestActiveCandidate(t *testing.T) { nodes.NonBootstraps(), ) require.NoError(t, err) - setCommitCandidateProposal, err := changeset.BuildProposalFromBatches(state, []timelock.BatchChainOperation{{ + setCommitCandidateProposal, err := BuildProposalFromBatches(state, []timelock.BatchChainOperation{{ ChainIdentifier: mcms.ChainIdentifier(tenv.HomeChainSel), Batch: setCommitCandidateOp, }}, "set new candidates on commit plugin", 0) @@ -153,7 +151,7 @@ func TestActiveCandidate(t *testing.T) { ) require.NoError(t, err) - setExecCandidateProposal, err := changeset.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) @@ -169,7 +167,7 @@ func TestActiveCandidate(t *testing.T) { // [ACTIVE, CANDIDATE] done setup // [ACTIVE, CANDIDATE] make sure we can still send successful transaction without updating job specs - err = changeset.ConfirmRequestOnSourceAndDest(t, e, state, tenv.HomeChainSel, tenv.FeedChainSel, 3) + err = ConfirmRequestOnSourceAndDest(t, e, state, tenv.HomeChainSel, tenv.FeedChainSel, 3) require.NoError(t, err) // [ACTIVE, CANDIDATE] done send successful transaction on active @@ -180,7 +178,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 := changeset.BuildProposalFromBatches(state, []timelock.BatchChainOperation{{ + promoteProposal, err := BuildProposalFromBatches(state, []timelock.BatchChainOperation{{ ChainIdentifier: mcms.ChainIdentifier(tenv.HomeChainSel), Batch: promoteOps, }}, "promote candidates and revoke actives", 0) @@ -204,7 +202,7 @@ func TestActiveCandidate(t *testing.T) { require.NoError(t, err) require.Equal(t, uint32(8), donInfo.ConfigCount) - err = changeset.ConfirmRequestOnSourceAndDest(t, e, state, tenv.HomeChainSel, tenv.FeedChainSel, 4) + err = ConfirmRequestOnSourceAndDest(t, e, state, tenv.HomeChainSel, tenv.FeedChainSel, 4) require.NoError(t, err) // [NEW ACTIVE, NO CANDIDATE] done sending successful request } diff --git a/deployment/ccip/changeset/add_chain_test.go b/deployment/ccip/changeset/add_chain_test.go index 20f89bffb14..3dc18f5161c 100644 --- a/deployment/ccip/changeset/add_chain_test.go +++ b/deployment/ccip/changeset/add_chain_test.go @@ -5,7 +5,6 @@ import ( "testing" "time" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/internal" 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" @@ -172,12 +171,12 @@ func TestAddChainInbound(t *testing.T) { ProcessChangeset(t, e.Env, addDonChangeset) t.Logf("Executing promote candidate proposal for exec plugin on chain %d", newChain) - setCandidateForExecChangeset, err := internal.SetCandidatePluginChangeset(state, e.Env, nodes, deployment.XXXGenerateTestOCRSecrets(), e.HomeChainSel, e.FeedChainSel, newChain, tokenConfig, types.PluginTypeCCIPExec) + setCandidateForExecChangeset, err := SetCandidatePluginChangeset(state, e.Env, nodes, deployment.XXXGenerateTestOCRSecrets(), e.HomeChainSel, e.FeedChainSel, newChain, tokenConfig, types.PluginTypeCCIPExec) require.NoError(t, err) ProcessChangeset(t, e.Env, setCandidateForExecChangeset) t.Logf("Executing promote candidate proposal for both commit and exec plugins on chain %d", newChain) - donPromoteChangeset, err := internal.PromoteAllCandidatesChangeset(state, e.HomeChainSel, newChain, nodes) + donPromoteChangeset, err := PromoteAllCandidatesChangeset(state, e.HomeChainSel, newChain, nodes) require.NoError(t, err) ProcessChangeset(t, e.Env, donPromoteChangeset) diff --git a/deployment/ccip/changeset/add_lane.go b/deployment/ccip/changeset/add_lane.go index 9eed05a81cd..82cf60b77f6 100644 --- a/deployment/ccip/changeset/add_lane.go +++ b/deployment/ccip/changeset/add_lane.go @@ -7,7 +7,6 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/smartcontractkit/chainlink/deployment" - "github.com/smartcontractkit/chainlink/deployment/ccip" "github.com/smartcontractkit/chainlink/v2/core/capabilities/ccip/ccipevm" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/offramp" @@ -28,11 +27,11 @@ var DefaultInitialPrices = InitialPrices{ GasPrice: ToPackedFee(big.NewInt(8e14), big.NewInt(0)), } -func AddLaneWithDefaultPrices(e deployment.Environment, state ccipdeployment.CCIPOnChainState, from, to uint64) error { +func AddLaneWithDefaultPrices(e deployment.Environment, state CCIPOnChainState, from, to uint64) error { return AddLane(e, state, from, to, DefaultInitialPrices) } -func AddLane(e deployment.Environment, state ccipdeployment.CCIPOnChainState, from, to uint64, initialPrices InitialPrices) error { +func AddLane(e deployment.Environment, state CCIPOnChainState, from, to uint64, initialPrices InitialPrices) error { // TODO: Batch tx, err := state.Chains[from].Router.ApplyRampUpdates(e.Chains[from].DeployerKey, []router.RouterOnRamp{ { diff --git a/deployment/ccip/changeset/deploy_chain.go b/deployment/ccip/changeset/deploy_chain.go index 633d01bbf4c..cb60f1ddabd 100644 --- a/deployment/ccip/changeset/deploy_chain.go +++ b/deployment/ccip/changeset/deploy_chain.go @@ -6,14 +6,13 @@ import ( "github.com/smartcontractkit/ccip-owner-contracts/pkg/proposal/timelock" "github.com/smartcontractkit/chainlink/deployment" - ccipdeployment "github.com/smartcontractkit/chainlink/deployment/ccip" ) var _ deployment.ChangeSet[DeployChainContractsConfig] = DeployChainContracts func DeployChainContracts(env deployment.Environment, c DeployChainContractsConfig) (deployment.ChangesetOutput, error) { newAddresses := deployment.NewMemoryAddressBook() - err := ccipdeployment.DeployChainContractsForChains(env, newAddresses, c.HomeChainSelector, c.ChainSelectors) + err := DeployChainContractsForChains(env, newAddresses, c.HomeChainSelector, c.ChainSelectors) if err != nil { env.Logger.Errorw("Failed to deploy CCIP contracts", "err", err, "newAddresses", newAddresses) return deployment.ChangesetOutput{AddressBook: newAddresses}, deployment.MaybeDataErr(err) diff --git a/deployment/ccip/changeset/deploy_home_chain.go b/deployment/ccip/changeset/deploy_home_chain.go index b07e844be04..47dd5f590e6 100644 --- a/deployment/ccip/changeset/deploy_home_chain.go +++ b/deployment/ccip/changeset/deploy_home_chain.go @@ -20,8 +20,6 @@ import ( "github.com/smartcontractkit/chainlink-ccip/chainconfig" "github.com/smartcontractkit/chainlink-ccip/pkg/types/ccipocr3" "github.com/smartcontractkit/chainlink-ccip/pluginconfig" - "github.com/smartcontractkit/chainlink/deployment/ccip" - commonconfig "github.com/smartcontractkit/chainlink-common/pkg/config" "github.com/smartcontractkit/chainlink-common/pkg/logger" "github.com/smartcontractkit/chainlink-common/pkg/merklemulti" @@ -91,7 +89,7 @@ func MustABIEncode(abiString string, args ...interface{}) []byte { // and returns a deployment.ContractDeploy struct with the address and contract instance. func DeployCapReg( lggr logger.Logger, - state ccipdeployment.CCIPOnChainState, + state CCIPOnChainState, ab deployment.AddressBook, chain deployment.Chain, ) (*deployment.ContractDeploy[*capabilities_registry.CapabilitiesRegistry], error) { @@ -101,7 +99,7 @@ func DeployCapReg( if cr != nil { lggr.Infow("Found CapabilitiesRegistry in chain state", "address", cr.Address().String()) return &deployment.ContractDeploy[*capabilities_registry.CapabilitiesRegistry]{ - Address: cr.Address(), Contract: cr, Tv: deployment.NewTypeAndVersion(ccipdeployment.CapabilitiesRegistry, deployment.Version1_0_0), + Address: cr.Address(), Contract: cr, Tv: deployment.NewTypeAndVersion(CapabilitiesRegistry, deployment.Version1_0_0), }, nil } } @@ -112,7 +110,7 @@ func DeployCapReg( chain.Client, ) return deployment.ContractDeploy[*capabilities_registry.CapabilitiesRegistry]{ - Address: crAddr, Contract: cr, Tv: deployment.NewTypeAndVersion(ccipdeployment.CapabilitiesRegistry, deployment.Version1_0_0), Tx: tx, Err: err2, + Address: crAddr, Contract: cr, Tv: deployment.NewTypeAndVersion(CapabilitiesRegistry, deployment.Version1_0_0), Tx: tx, Err: err2, } }) if err != nil { @@ -122,7 +120,7 @@ func DeployCapReg( return capReg, nil } -func DeployHomeChain( +func deployHomeChain( lggr logger.Logger, e deployment.Environment, ab deployment.AddressBook, @@ -133,7 +131,7 @@ func DeployHomeChain( nodeP2PIDsPerNodeOpAdmin map[string][][32]byte, ) (*deployment.ContractDeploy[*capabilities_registry.CapabilitiesRegistry], error) { // load existing state - state, err := ccipdeployment.LoadOnchainState(e) + state, err := LoadOnchainState(e) if err != nil { return nil, fmt.Errorf("failed to load onchain state: %w", err) } @@ -153,7 +151,7 @@ func DeployHomeChain( capReg.Address, ) return deployment.ContractDeploy[*ccip_home.CCIPHome]{ - Address: ccAddr, Tv: deployment.NewTypeAndVersion(ccipdeployment.CCIPHome, deployment.Version1_6_0_dev), Tx: tx, Err: err2, Contract: cc, + Address: ccAddr, Tv: deployment.NewTypeAndVersion(CCIPHome, deployment.Version1_6_0_dev), Tx: tx, Err: err2, Contract: cc, } }) if err != nil { @@ -170,7 +168,7 @@ func DeployHomeChain( chain.Client, ) return deployment.ContractDeploy[*rmn_home.RMNHome]{ - Address: rmnAddr, Tv: deployment.NewTypeAndVersion(ccipdeployment.RMNHome, deployment.Version1_6_0_dev), Tx: tx, Err: err2, Contract: rmn, + Address: rmnAddr, Tv: deployment.NewTypeAndVersion(RMNHome, deployment.Version1_6_0_dev), Tx: tx, Err: err2, Contract: rmn, } }, ) @@ -1047,7 +1045,7 @@ func AddDON( func ApplyChainConfigUpdatesOp( e deployment.Environment, - state ccipdeployment.CCIPOnChainState, + state CCIPOnChainState, homeChainSel uint64, chains []uint64, ) (mcms.Operation, error) { diff --git a/deployment/ccip/changeset/home_chain.go b/deployment/ccip/changeset/home_chain.go index 51c2a1ed77f..e88db2bcfe0 100644 --- a/deployment/ccip/changeset/home_chain.go +++ b/deployment/ccip/changeset/home_chain.go @@ -22,7 +22,7 @@ func DeployHomeChain(env deployment.Environment, cfg DeployHomeChainConfig) (dep } ab := deployment.NewMemoryAddressBook() // Note we also deploy the cap reg. - _, err = DeployHomeChain(env.Logger, env, ab, env.Chains[cfg.HomeChainSel], cfg.RMNStaticConfig, cfg.RMNDynamicConfig, cfg.NodeOperators, cfg.NodeP2PIDsPerNodeOpAdmin) + _, err = deployHomeChain(env.Logger, env, ab, env.Chains[cfg.HomeChainSel], cfg.RMNStaticConfig, cfg.RMNDynamicConfig, cfg.NodeOperators, cfg.NodeP2PIDsPerNodeOpAdmin) if err != nil { env.Logger.Errorw("Failed to deploy cap reg", "err", err, "addresses", env.ExistingAddresses) return deployment.ChangesetOutput{ diff --git a/deployment/ccip/changeset/initial_deploy.go b/deployment/ccip/changeset/initial_deploy.go index 5d9a9d0b91c..29cfde18ec2 100644 --- a/deployment/ccip/changeset/initial_deploy.go +++ b/deployment/ccip/changeset/initial_deploy.go @@ -4,15 +4,13 @@ import ( "github.com/smartcontractkit/ccip-owner-contracts/pkg/proposal/timelock" "github.com/smartcontractkit/chainlink/deployment" - - ccipdeployment "github.com/smartcontractkit/chainlink/deployment/ccip" ) -var _ deployment.ChangeSet[ccipdeployment.DeployCCIPContractConfig] = InitialDeploy +var _ deployment.ChangeSet[DeployCCIPContractConfig] = InitialDeploy -func InitialDeploy(env deployment.Environment, c ccipdeployment.DeployCCIPContractConfig) (deployment.ChangesetOutput, error) { +func InitialDeploy(env deployment.Environment, c DeployCCIPContractConfig) (deployment.ChangesetOutput, error) { newAddresses := deployment.NewMemoryAddressBook() - err := ccipdeployment.DeployCCIPContracts(env, newAddresses, c) + err := DeployCCIPContracts(env, newAddresses, c) if err != nil { env.Logger.Errorw("Failed to deploy CCIP contracts", "err", err, "newAddresses", newAddresses) return deployment.ChangesetOutput{AddressBook: newAddresses}, deployment.MaybeDataErr(err) diff --git a/deployment/ccip/changeset/internal/deploy_home_chain.go b/deployment/ccip/changeset/internal/deploy_home_chain.go new file mode 100644 index 00000000000..5bf0569ce8c --- /dev/null +++ b/deployment/ccip/changeset/internal/deploy_home_chain.go @@ -0,0 +1 @@ +package internal diff --git a/deployment/ccip/changeset/internal/ownership.go b/deployment/ccip/changeset/ownership.go similarity index 98% rename from deployment/ccip/changeset/internal/ownership.go rename to deployment/ccip/changeset/ownership.go index 50eb8e12b48..4287363b8a6 100644 --- a/deployment/ccip/changeset/internal/ownership.go +++ b/deployment/ccip/changeset/ownership.go @@ -1,4 +1,4 @@ -package internal +package changeset import ( "testing" diff --git a/deployment/ccip/changeset/prerequisites.go b/deployment/ccip/changeset/prerequisites.go index 7332f97fc18..3136c5cc35e 100644 --- a/deployment/ccip/changeset/prerequisites.go +++ b/deployment/ccip/changeset/prerequisites.go @@ -8,7 +8,6 @@ import ( "github.com/smartcontractkit/ccip-owner-contracts/pkg/proposal/timelock" "github.com/smartcontractkit/chainlink/deployment" - ccipdeployment "github.com/smartcontractkit/chainlink/deployment/ccip" ) var ( @@ -23,7 +22,7 @@ func DeployPrerequisites(env deployment.Environment, cfg DeployPrerequisiteConfi return deployment.ChangesetOutput{}, errors.Wrapf(deployment.ErrInvalidConfig, "%v", err) } ab := deployment.NewMemoryAddressBook() - err = ccipdeployment.DeployPrerequisiteChainContracts(env, ab, cfg.ChainSelectors) + err = DeployPrerequisiteChainContracts(env, ab, cfg.ChainSelectors) if err != nil { env.Logger.Errorw("Failed to deploy prerequisite contracts", "err", err, "addressBook", ab) return deployment.ChangesetOutput{ diff --git a/deployment/ccip/changeset/test_assertions.go b/deployment/ccip/changeset/test_assertions.go index f311e670664..8efb83c477d 100644 --- a/deployment/ccip/changeset/test_assertions.go +++ b/deployment/ccip/changeset/test_assertions.go @@ -15,7 +15,6 @@ import ( "github.com/smartcontractkit/chainlink-ccip/pkg/types/ccipocr3" "github.com/smartcontractkit/chainlink-common/pkg/utils/tests" - "github.com/smartcontractkit/chainlink/deployment/ccip" "github.com/smartcontractkit/chainlink/deployment/environment/memory" "github.com/smartcontractkit/chainlink/deployment" @@ -26,7 +25,7 @@ import ( func ConfirmGasPriceUpdatedForAll( t *testing.T, e deployment.Environment, - state ccipdeployment.CCIPOnChainState, + state CCIPOnChainState, startBlocks map[uint64]*uint64, gasPrice *big.Int, ) { @@ -79,7 +78,7 @@ func ConfirmGasPriceUpdated( func ConfirmTokenPriceUpdatedForAll( t *testing.T, e deployment.Environment, - state ccipdeployment.CCIPOnChainState, + state CCIPOnChainState, startBlocks map[uint64]*uint64, linkPrice *big.Int, wethPrice *big.Int, @@ -155,7 +154,7 @@ func ConfirmTokenPriceUpdated( func ConfirmCommitForAllWithExpectedSeqNums( t *testing.T, e deployment.Environment, - state ccipdeployment.CCIPOnChainState, + state CCIPOnChainState, expectedSeqNums map[uint64]uint64, startBlocks map[uint64]*uint64, ) { @@ -307,7 +306,7 @@ func ConfirmCommitWithExpectedSeqNumRange( func ConfirmExecWithSeqNrForAll( t *testing.T, e deployment.Environment, - state ccipdeployment.CCIPOnChainState, + state CCIPOnChainState, expectedSeqNums map[uint64]uint64, startBlocks map[uint64]*uint64, ) (executionStates map[uint64]int) { diff --git a/deployment/ccip/changeset/test_helpers.go b/deployment/ccip/changeset/test_helpers.go index a73075d7bf2..ffc7e9a1a1f 100644 --- a/deployment/ccip/changeset/test_helpers.go +++ b/deployment/ccip/changeset/test_helpers.go @@ -17,8 +17,6 @@ import ( "github.com/pkg/errors" commonconfig "github.com/smartcontractkit/chainlink-common/pkg/config" - "github.com/smartcontractkit/chainlink/deployment/ccip" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/internal" commonchangeset "github.com/smartcontractkit/chainlink/deployment/common/changeset" commontypes "github.com/smartcontractkit/chainlink/deployment/common/types" @@ -128,8 +126,8 @@ func DeployTestContracts(t *testing.T, ) deployment.CapabilityRegistryConfig { capReg, err := DeployCapReg(lggr, // deploying cap reg for the first time on a blank chain state - ccipdeployment.CCIPOnChainState{ - Chains: make(map[uint64]ccipdeployment.CCIPChainState), + CCIPOnChainState{ + Chains: make(map[uint64]CCIPChainState), }, ab, chains[homeChainSel]) require.NoError(t, err) _, err = DeployFeeds(lggr, ab, chains[feedChainSel], linkPrice, wethPrice) @@ -199,7 +197,7 @@ func NewMemoryEnvironment( envNodes, err := deployment.NodeInfo(e.NodeIDs, e.Offchain) require.NoError(t, err) e.ExistingAddresses = ab - _, err = DeployHomeChain(lggr, e, e.ExistingAddresses, chains[homeChainSel], + _, err = deployHomeChain(lggr, e, e.ExistingAddresses, chains[homeChainSel], NewTestRMNStaticConfig(), NewTestRMNDynamicConfig(), NewTestNodeOperator(chains[homeChainSel].DeployerKey.From), @@ -249,7 +247,7 @@ func NewMemoryEnvironmentWithJobsAndContracts(t *testing.T, lggr logger.Logger, e.SetupJobs(t) // Take first non-home chain as the new chain. newAddresses := deployment.NewMemoryAddressBook() - err := ccipdeployment.DeployPrerequisiteChainContracts(e.Env, newAddresses, e.Env.AllChainSelectors()) + err := DeployPrerequisiteChainContracts(e.Env, newAddresses, e.Env.AllChainSelectors()) require.NoError(t, err) require.NoError(t, e.Env.ExistingAddresses.Merge(newAddresses)) @@ -267,7 +265,7 @@ func NewMemoryEnvironmentWithJobsAndContracts(t *testing.T, lggr logger.Logger, out, err := commonchangeset.DeployMCMSWithTimelock(e.Env, mcmsCfg) require.NoError(t, err) require.NoError(t, e.Env.ExistingAddresses.Merge(out.AddressBook)) - state, err := ccipdeployment.LoadOnchainState(e.Env) + state, err := LoadOnchainState(e.Env) require.NoError(t, err) newAddresses = deployment.NewMemoryAddressBook() @@ -275,15 +273,15 @@ func NewMemoryEnvironmentWithJobsAndContracts(t *testing.T, lggr logger.Logger, server := mockAttestationResponse() defer server.Close() endpoint := server.URL - err = ccipdeployment.DeployCCIPContracts(e.Env, newAddresses, ccipdeployment.DeployCCIPContractConfig{ + err = DeployCCIPContracts(e.Env, newAddresses, DeployCCIPContractConfig{ HomeChainSel: e.HomeChainSel, FeedChainSel: e.FeedChainSel, ChainsToDeploy: e.Env.AllChainSelectors(), TokenConfig: tokenConfig, OCRSecrets: deployment.XXXGenerateTestOCRSecrets(), - USDCConfig: ccipdeployment.USDCConfig{ + USDCConfig: USDCConfig{ Enabled: true, - USDCAttestationConfig: ccipdeployment.USDCAttestationConfig{ + USDCAttestationConfig: USDCAttestationConfig{ API: endpoint, APITimeout: commonconfig.MustNewDuration(time.Second), APIInterval: commonconfig.MustNewDuration(500 * time.Millisecond), @@ -292,7 +290,7 @@ func NewMemoryEnvironmentWithJobsAndContracts(t *testing.T, lggr logger.Logger, }) 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) return e @@ -300,7 +298,7 @@ func NewMemoryEnvironmentWithJobsAndContracts(t *testing.T, lggr logger.Logger, func CCIPSendRequest( e deployment.Environment, - state ccipdeployment.CCIPOnChainState, + state CCIPOnChainState, src, dest uint64, testRouter bool, evm2AnyMessage router.ClientEVM2AnyMessage, @@ -342,7 +340,7 @@ func CCIPSendRequest( func TestSendRequest( t *testing.T, e deployment.Environment, - state ccipdeployment.CCIPOnChainState, + state CCIPOnChainState, src, dest uint64, testRouter bool, evm2AnyMessage router.ClientEVM2AnyMessage, @@ -403,11 +401,11 @@ func MakeEVMExtraArgsV2(gasLimit uint64, allowOOO bool) []byte { // AddLanesForAll adds densely connected lanes for all chains in the environment so that each chain // is connected to every other chain except itself. -func AddLanesForAll(e deployment.Environment, state ccipdeployment.CCIPOnChainState) error { +func AddLanesForAll(e deployment.Environment, state CCIPOnChainState) error { for source := range e.Chains { for dest := range e.Chains { if source != dest { - err := internal.AddLaneWithDefaultPrices(e, state, source, dest) + err := AddLaneWithDefaultPrices(e, state, source, dest) if err != nil { return err } @@ -458,7 +456,7 @@ func DeployFeeds( linkPrice *big.Int, wethPrice *big.Int, ) (map[string]common.Address, error) { - linkTV := deployment.NewTypeAndVersion(ccipdeployment.PriceFeed, deployment.Version1_0_0) + linkTV := deployment.NewTypeAndVersion(PriceFeed, deployment.Version1_0_0) mockLinkFeed := func(chain deployment.Chain) deployment.ContractDeploy[*aggregator_v3_interface.AggregatorV3Interface] { linkFeed, tx, _, err1 := mock_v3_aggregator_contract.DeployMockV3Aggregator( chain.DeployerKey, @@ -534,7 +532,7 @@ func deploySingleFeed( return mockTokenFeed.Address, desc, nil } -func ConfirmRequestOnSourceAndDest(t *testing.T, env deployment.Environment, state ccipdeployment.CCIPOnChainState, sourceCS, destCS, expectedSeqNr uint64) error { +func ConfirmRequestOnSourceAndDest(t *testing.T, env deployment.Environment, state CCIPOnChainState, sourceCS, destCS, expectedSeqNr uint64) error { latesthdr, err := env.Chains[destCS].Client.HeaderByNumber(testcontext.Get(t), nil) require.NoError(t, err) startBlock := latesthdr.Number.Uint64() @@ -579,7 +577,7 @@ func ProcessChangeset(t *testing.T, e deployment.Environment, c deployment.Chang // sign and execute all proposals provided if len(c.Proposals) != 0 { - state, err := ccipdeployment.LoadOnchainState(e) + state, err := LoadOnchainState(e) require.NoError(t, err) for _, prop := range c.Proposals { chains := mapset.NewSet[uint64]() @@ -605,7 +603,7 @@ func DeployTransferableToken( lggr logger.Logger, chains map[uint64]deployment.Chain, src, dst uint64, - state ccipdeployment.CCIPOnChainState, + state CCIPOnChainState, addresses deployment.AddressBook, token string, ) (*burn_mint_erc677.BurnMintERC677, *burn_mint_token_pool.BurnMintTokenPool, *burn_mint_erc677.BurnMintERC677, *burn_mint_token_pool.BurnMintTokenPool, error) { @@ -760,7 +758,7 @@ func setTokenPoolCounterPart( func attachTokenToTheRegistry( chain deployment.Chain, - state ccipdeployment.CCIPChainState, + state CCIPChainState, owner *bind.TransactOpts, token common.Address, tokenPool common.Address, @@ -806,10 +804,10 @@ func deployTransferTokenOneEnd( return nil, nil, err } for address, v := range chainAddresses { - if deployment.NewTypeAndVersion(ccipdeployment.ARMProxy, deployment.Version1_0_0) == v { + if deployment.NewTypeAndVersion(ARMProxy, deployment.Version1_0_0) == v { rmnAddress = address } - if deployment.NewTypeAndVersion(ccipdeployment.Router, deployment.Version1_2_0) == v { + if deployment.NewTypeAndVersion(Router, deployment.Version1_2_0) == v { routerAddress = address } if rmnAddress != "" && routerAddress != "" { @@ -828,7 +826,7 @@ func deployTransferTokenOneEnd( big.NewInt(0).Mul(big.NewInt(1e9), big.NewInt(1e18)), ) return deployment.ContractDeploy[*burn_mint_erc677.BurnMintERC677]{ - USDCTokenAddr, token, tx, deployment.NewTypeAndVersion(ccipdeployment.BurnMintToken, deployment.Version1_0_0), err2, + USDCTokenAddr, token, tx, deployment.NewTypeAndVersion(BurnMintToken, deployment.Version1_0_0), err2, } }) if err != nil { @@ -856,7 +854,7 @@ func deployTransferTokenOneEnd( common.HexToAddress(routerAddress), ) return deployment.ContractDeploy[*burn_mint_token_pool.BurnMintTokenPool]{ - tokenPoolAddress, tokenPoolContract, tx, deployment.NewTypeAndVersion(ccipdeployment.BurnMintTokenPool, deployment.Version1_0_0), err2, + tokenPoolAddress, tokenPoolContract, tx, deployment.NewTypeAndVersion(BurnMintTokenPool, deployment.Version1_0_0), err2, } }) if err != nil { diff --git a/deployment/ccip/changeset/test_usdc_helpers.go b/deployment/ccip/changeset/test_usdc_helpers.go index f114cbef8b4..88e9c07f06a 100644 --- a/deployment/ccip/changeset/test_usdc_helpers.go +++ b/deployment/ccip/changeset/test_usdc_helpers.go @@ -8,7 +8,6 @@ import ( "github.com/smartcontractkit/chainlink-ccip/pkg/reader" "github.com/smartcontractkit/chainlink-common/pkg/logger" "github.com/smartcontractkit/chainlink/deployment" - "github.com/smartcontractkit/chainlink/deployment/ccip" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/fee_quoter" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/mock_usdc_token_messenger" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/mock_usdc_token_transmitter" @@ -20,7 +19,7 @@ func ConfigureUSDCTokenPools( lggr logger.Logger, chains map[uint64]deployment.Chain, src, dst uint64, - state ccipdeployment.CCIPOnChainState, + state CCIPOnChainState, ) (*burn_mint_erc677.BurnMintERC677, *burn_mint_erc677.BurnMintERC677, error) { srcToken := state.Chains[src].BurnMintTokens677[USDCSymbol] dstToken := state.Chains[dst].BurnMintTokens677[USDCSymbol] @@ -79,7 +78,7 @@ func ConfigureUSDCTokenPools( func UpdateFeeQuoterForUSDC( lggr logger.Logger, chain deployment.Chain, - state ccipdeployment.CCIPChainState, + state CCIPChainState, dstChain uint64, usdcToken *burn_mint_erc677.BurnMintERC677, ) error { @@ -120,7 +119,7 @@ func DeployUSDC( lggr logger.Logger, chain deployment.Chain, addresses deployment.AddressBook, - state ccipdeployment.CCIPChainState, + state CCIPChainState, ) ( *burn_mint_erc677.BurnMintERC677, *usdc_token_pool.USDCTokenPool, @@ -142,7 +141,7 @@ func DeployUSDC( Address: tokenAddress, Contract: tokenContract, Tx: tx, - Tv: deployment.NewTypeAndVersion(ccipdeployment.USDCToken, deployment.Version1_0_0), + Tv: deployment.NewTypeAndVersion(USDCToken, deployment.Version1_0_0), Err: err2, } }) @@ -174,7 +173,7 @@ func DeployUSDC( Address: transmitterAddress, Contract: transmitterContract, Tx: tx, - Tv: deployment.NewTypeAndVersion(ccipdeployment.USDCMockTransmitter, deployment.Version1_0_0), + Tv: deployment.NewTypeAndVersion(USDCMockTransmitter, deployment.Version1_0_0), Err: err2, } }) @@ -197,7 +196,7 @@ func DeployUSDC( Address: messengerAddress, Contract: messengerContract, Tx: tx, - Tv: deployment.NewTypeAndVersion(ccipdeployment.USDCTokenMessenger, deployment.Version1_0_0), + Tv: deployment.NewTypeAndVersion(USDCTokenMessenger, deployment.Version1_0_0), Err: err2, } }) @@ -222,7 +221,7 @@ func DeployUSDC( Address: tokenPoolAddress, Contract: tokenPoolContract, Tx: tx, - Tv: deployment.NewTypeAndVersion(ccipdeployment.USDCTokenPool, deployment.Version1_0_0), + Tv: deployment.NewTypeAndVersion(USDCTokenPool, deployment.Version1_0_0), Err: err2, } }) diff --git a/deployment/ccip/changeset/view.go b/deployment/ccip/changeset/view.go index 9d3eb8260c7..1fd8fdbe38f 100644 --- a/deployment/ccip/changeset/view.go +++ b/deployment/ccip/changeset/view.go @@ -4,7 +4,6 @@ import ( "encoding/json" "github.com/smartcontractkit/chainlink/deployment" - ccipdeployment "github.com/smartcontractkit/chainlink/deployment/ccip" ccipview "github.com/smartcontractkit/chainlink/deployment/ccip/view" "github.com/smartcontractkit/chainlink/deployment/common/view" ) @@ -12,7 +11,7 @@ import ( var _ deployment.ViewState = ViewCCIP func ViewCCIP(e deployment.Environment) (json.Marshaler, error) { - state, err := ccipdeployment.LoadOnchainState(e) + state, err := LoadOnchainState(e) if err != nil { return nil, err }