Skip to content

Commit

Permalink
Move a bunch of home chain stuff to internal
Browse files Browse the repository at this point in the history
  • Loading branch information
connorwstein committed Nov 20, 2024
1 parent edb4eb9 commit b375b3c
Show file tree
Hide file tree
Showing 9 changed files with 576 additions and 553 deletions.
3 changes: 2 additions & 1 deletion deployment/ccip/changeset/active_candidate.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/smartcontractkit/ccip-owner-contracts/pkg/proposal/timelock"

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

Expand Down Expand Up @@ -51,7 +52,7 @@ func SetCandidatePluginChangeset(
tokenConfig TokenConfig,
pluginType cctypes.PluginType,
) (deployment.ChangesetOutput, error) {
newDONArgs, err := BuildOCR3ConfigForCCIPHome(
newDONArgs, err := internal.BuildOCR3ConfigForCCIPHome(
ocrSecrets,
state.Chains[newChainSel].OffRamp,
e.Chains[newChainSel],
Expand Down
13 changes: 7 additions & 6 deletions deployment/ccip/changeset/active_candidate_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/smartcontractkit/ccip-owner-contracts/pkg/proposal/mcms"

"github.com/smartcontractkit/chainlink/deployment"
"github.com/smartcontractkit/chainlink/deployment/ccip/changeset/internal"
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"
Expand All @@ -22,12 +23,12 @@ func SetCandidateOnExistingDon(
nodes deployment.Nodes,
) ([]mcms.Operation, error) {
// fetch DON ID for the chain
donID, err := DonIDForChain(capReg, ccipHome, chainSelector)
donID, err := internal.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 := CCIPHomeABI.Pack(
encodedSetCandidateCall, err := internal.CCIPHomeABI.Pack(
"setCandidate",
donID,
pluginConfig.PluginType,
Expand All @@ -45,7 +46,7 @@ func SetCandidateOnExistingDon(
nodes.PeerIDs(),
[]capabilities_registry.CapabilitiesRegistryCapabilityConfiguration{
{
CapabilityId: CCIPCapabilityID,
CapabilityId: internal.CCIPCapabilityID,
Config: encodedSetCandidateCall,
},
},
Expand Down Expand Up @@ -77,7 +78,7 @@ func PromoteCandidateOp(donID uint32, pluginType uint8, capReg *capabilities_reg
}
fmt.Printf("commit candidate digest after setCandidate: %x\n", allConfigs.CandidateConfig.ConfigDigest)

encodedPromotionCall, err := CCIPHomeABI.Pack(
encodedPromotionCall, err := internal.CCIPHomeABI.Pack(
"promoteCandidateAndRevokeActive",
donID,
pluginType,
Expand All @@ -94,7 +95,7 @@ func PromoteCandidateOp(donID uint32, pluginType uint8, capReg *capabilities_reg
nodes.PeerIDs(),
[]capabilities_registry.CapabilitiesRegistryCapabilityConfiguration{
{
CapabilityId: CCIPCapabilityID,
CapabilityId: internal.CCIPCapabilityID,
Config: encodedPromotionCall,
},
},
Expand All @@ -119,7 +120,7 @@ func PromoteAllCandidatesForChainOps(
nodes deployment.Nodes,
) ([]mcms.Operation, error) {
// fetch DON ID for the chain
donID, err := DonIDForChain(capReg, ccipHome, chainSelector)
donID, err := internal.DonIDForChain(capReg, ccipHome, chainSelector)
if err != nil {
return nil, fmt.Errorf("fetch don id for chain: %w", err)
}
Expand Down
5 changes: 3 additions & 2 deletions deployment/ccip/changeset/active_candidate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ 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/internal"
cctypes "github.com/smartcontractkit/chainlink/v2/core/capabilities/ccip/types"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/router"

Expand Down Expand Up @@ -85,7 +86,7 @@ func TestActiveCandidate(t *testing.T) {

// [ACTIVE, CANDIDATE] setup by setting candidate through cap reg
capReg, ccipHome := state.Chains[tenv.HomeChainSel].CapabilityRegistry, state.Chains[tenv.HomeChainSel].CCIPHome
donID, err := DonIDForChain(capReg, ccipHome, tenv.FeedChainSel)
donID, err := internal.DonIDForChain(capReg, ccipHome, tenv.FeedChainSel)
require.NoError(t, err)
donInfo, err := state.Chains[tenv.HomeChainSel].CapabilityRegistry.GetDON(nil, donID)
require.NoError(t, err)
Expand Down Expand Up @@ -113,7 +114,7 @@ func TestActiveCandidate(t *testing.T) {
// commit and exec plugin we will be using
rmnHomeAddress := state.Chains[tenv.HomeChainSel].RMNHome.Address()
tokenConfig := NewTestTokenConfig(state.Chains[tenv.FeedChainSel].USDFeeds)
ocr3ConfigMap, err := BuildOCR3ConfigForCCIPHome(
ocr3ConfigMap, err := internal.BuildOCR3ConfigForCCIPHome(
deployment.XXXGenerateTestOCRSecrets(),
state.Chains[tenv.FeedChainSel].OffRamp,
e.Chains[tenv.FeedChainSel],
Expand Down
5 changes: 3 additions & 2 deletions deployment/ccip/changeset/add_chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"math/big"

"github.com/smartcontractkit/chainlink/deployment/ccip/changeset/internal"
"github.com/smartcontractkit/chainlink/v2/core/capabilities/ccip/types"

"github.com/smartcontractkit/ccip-owner-contracts/pkg/proposal/mcms"
Expand Down Expand Up @@ -97,7 +98,7 @@ func AddDonAndSetCandidateChangeset(
tokenConfig TokenConfig,
pluginType types.PluginType,
) (deployment.ChangesetOutput, error) {
newDONArgs, err := BuildOCR3ConfigForCCIPHome(
newDONArgs, err := internal.BuildOCR3ConfigForCCIPHome(
ocrSecrets,
state.Chains[newChainSel].OffRamp,
e.Chains[newChainSel],
Expand All @@ -110,7 +111,7 @@ func AddDonAndSetCandidateChangeset(
if err != nil {
return deployment.ChangesetOutput{}, err
}
latestDon, err := LatestCCIPDON(state.Chains[homeChainSel].CapabilityRegistry)
latestDon, err := internal.LatestCCIPDON(state.Chains[homeChainSel].CapabilityRegistry)
if err != nil {
return deployment.ChangesetOutput{}, err
}
Expand Down
5 changes: 3 additions & 2 deletions deployment/ccip/changeset/add_chain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ 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"
Expand Down Expand Up @@ -204,9 +205,9 @@ func TestAddChainInbound(t *testing.T) {
_, err = deployment.ConfirmIfNoError(e.Env.Chains[newChain], tx, err)
require.NoError(t, err)
// Set the OCR3 config on new 4th chain to enable the plugin.
latestDON, err := LatestCCIPDON(state.Chains[e.HomeChainSel].CapabilityRegistry)
latestDON, err := internal.LatestCCIPDON(state.Chains[e.HomeChainSel].CapabilityRegistry)
require.NoError(t, err)
ocrConfigs, err := BuildSetOCR3ConfigArgs(latestDON.Id, state.Chains[e.HomeChainSel].CCIPHome, newChain)
ocrConfigs, err := internal.BuildSetOCR3ConfigArgs(latestDON.Id, state.Chains[e.HomeChainSel].CCIPHome, newChain)
require.NoError(t, err)
tx, err = state.Chains[newChain].OffRamp.SetOCR3Configs(e.Env.Chains[newChain].DeployerKey, ocrConfigs)
require.NoError(t, err)
Expand Down
9 changes: 5 additions & 4 deletions deployment/ccip/changeset/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ 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/internal"

"github.com/smartcontractkit/chainlink/deployment"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/ccip_home"
Expand Down Expand Up @@ -438,15 +439,15 @@ func DeployChainContractsForChains(
return fmt.Errorf("capability registry not found")
}
cr, err := capReg.GetHashedCapabilityId(
&bind.CallOpts{}, CapabilityLabelledName, CapabilityVersion)
&bind.CallOpts{}, internal.CapabilityLabelledName, internal.CapabilityVersion)
if err != nil {
e.Logger.Errorw("Failed to get hashed capability id", "err", err)
return err
}
if cr != CCIPCapabilityID {
return fmt.Errorf("capability registry does not support CCIP %s %s", hexutil.Encode(cr[:]), hexutil.Encode(CCIPCapabilityID[:]))
if cr != internal.CCIPCapabilityID {
return fmt.Errorf("capability registry does not support CCIP %s %s", hexutil.Encode(cr[:]), hexutil.Encode(internal.CCIPCapabilityID[:]))
}
capability, err := capReg.GetCapability(nil, CCIPCapabilityID)
capability, err := capReg.GetCapability(nil, internal.CCIPCapabilityID)
if err != nil {
e.Logger.Errorw("Failed to get capability", "err", err)
return err
Expand Down
Loading

0 comments on commit b375b3c

Please sign in to comment.