Skip to content

Commit

Permalink
Cleaning up
Browse files Browse the repository at this point in the history
  • Loading branch information
asoliman92 committed Aug 7, 2024
1 parent 3fcaec9 commit c495985
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 59 deletions.
3 changes: 1 addition & 2 deletions core/capabilities/ccip/delegate.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ func (d *Delegate) ServicesForSpec(ctx context.Context, spec job.Job) (services

cfg := d.capabilityConfig
rid := cfg.ExternalRegistry().RelayID()
registryAddress := cfg.ExternalRegistry().Address()
relayer, err := d.relayers.Get(rid)
if err != nil {
return nil, fmt.Errorf("could not fetch relayer %s configured for capabilities registry: %w", rid, err)
Expand All @@ -119,7 +118,7 @@ func (d *Delegate) ServicesForSpec(ctx context.Context, spec job.Job) (services
return p2ptypes.PeerID(p2pID.PeerID()), nil
},
relayer,
registryAddress,
cfg.ExternalRegistry().Address(),
)
if err != nil {
return nil, fmt.Errorf("could not configure syncer: %w", err)
Expand Down
6 changes: 3 additions & 3 deletions core/capabilities/ccip/launcher/diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func compareDONs(

// filterCCIPDONs filters the CCIP DONs from the given state.
func filterCCIPDONs(
ccipCapability registrysyncer.Capability, // This will change to registrysyncer.Capability
ccipCapability registrysyncer.Capability,
state registrysyncer.LocalRegistry,
) (map[registrysyncer.DonID]registrysyncer.DON, error) {
ccipDONs := make(map[registrysyncer.DonID]registrysyncer.DON)
Expand All @@ -101,8 +101,8 @@ func filterCCIPDONs(
return ccipDONs, nil
}

// checkCapabilityPresence checks if the capability with the given version and
// labelled name is present in the given capability registry state.
// checkCapabilityPresence checks if the capability with the given capabilityID
// is present in the given capability registry state.
func checkCapabilityPresence(
capabilityID string,
state registrysyncer.LocalRegistry,
Expand Down
45 changes: 0 additions & 45 deletions core/capabilities/ccip/launcher/diff_test.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
package launcher

import (
"fmt"
"math/big"
"reflect"
"testing"

"github.com/smartcontractkit/chainlink-common/pkg/capabilities"

ragep2ptypes "github.com/smartcontractkit/libocr/ragep2p/types"

"github.com/stretchr/testify/require"
Expand All @@ -18,40 +15,6 @@ import (
"github.com/smartcontractkit/chainlink/v2/core/services/registrysyncer"
)

const (
ccipCapVersion = "v1.0.0"
ccipCapNewVersion = "v1.1.0"
ccipCapName = "ccip"
)

var defaultCapability = getCapability(ccipCapName, ccipCapVersion)
var newCapability = getCapability(ccipCapName, ccipCapNewVersion)

func getDON(id uint32, members []ragep2ptypes.PeerID, cfgVersion uint32) capabilities.DON {
return capabilities.DON{
ID: id,
ConfigVersion: cfgVersion,
F: uint8(1),
IsPublic: true,
AcceptsWorkflows: true,
Members: members,
}
}
func getP2PID(id uint32) ragep2ptypes.PeerID {
return ragep2ptypes.PeerID(p2pkey.MustNewV2XXXTestingOnly(big.NewInt(int64(id))).PeerID())
}

var p2pID1 = getP2PID(1)
var p2pID2 = getP2PID(2)

var defaultCapCfgs = map[string]registrysyncer.CapabilityConfiguration{
defaultCapability.ID: registrysyncer.CapabilityConfiguration{},
}
var defaultRegistryDon = registrysyncer.DON{
DON: getDON(1, []ragep2ptypes.PeerID{p2pID1}, 0),
CapabilityConfigurations: defaultCapCfgs,
}

func Test_diff(t *testing.T) {
type args struct {
capabilityID string
Expand Down Expand Up @@ -387,11 +350,3 @@ func Test_isMemberOfBootstrapSubcommittee(t *testing.T) {
require.True(t, isMemberOfBootstrapSubcommittee(bootstrapKeys, p2pID1))
require.False(t, isMemberOfBootstrapSubcommittee(bootstrapKeys, getP2PID(5)))
}

func getCapability(ccipCapName, ccipCapVersion string) registrysyncer.Capability {
id := fmt.Sprintf("%s@%s", ccipCapName, ccipCapVersion)
return registrysyncer.Capability{
CapabilityType: capabilities.CapabilityTypeTarget,
ID: id,
}
}
5 changes: 2 additions & 3 deletions core/capabilities/ccip/launcher/launcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import (
ragep2ptypes "github.com/smartcontractkit/libocr/ragep2p/types"

ccipreader "github.com/smartcontractkit/chainlink-ccip/pkg/reader"
ccipreaderpkg "github.com/smartcontractkit/chainlink-ccip/pkg/reader"

"github.com/smartcontractkit/chainlink-common/pkg/services"

Expand Down Expand Up @@ -329,7 +328,7 @@ func updateDON(
// All other cases are invalid. This is enforced in the ccip config contract.
func createFutureBlueGreenDeployment(
prevDeployment ccipDeployment,
ocrConfigs []ccipreaderpkg.OCR3ConfigWithMeta,
ocrConfigs []ccipreader.OCR3ConfigWithMeta,
oracleCreator cctypes.OracleCreator,
pluginType cctypes.PluginType,
) (blueGreenDeployment, error) {
Expand Down Expand Up @@ -415,7 +414,7 @@ func createOracle(
p2pID ragep2ptypes.PeerID,
oracleCreator cctypes.OracleCreator,
pluginType cctypes.PluginType,
ocrConfigs []ccipreaderpkg.OCR3ConfigWithMeta,
ocrConfigs []ccipreader.OCR3ConfigWithMeta,
) (pluginOracle, bootstrapOracle cctypes.CCIPOracle, err error) {
pluginOracle, err = oracleCreator.CreatePluginOracle(pluginType, cctypes.OCR3ConfigWithMeta(ocrConfigs[0]))
if err != nil {
Expand Down
56 changes: 56 additions & 0 deletions core/capabilities/ccip/launcher/test_helpers.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package launcher

import (
"fmt"
"math/big"

"github.com/smartcontractkit/chainlink-common/pkg/capabilities"

"github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/p2pkey"
"github.com/smartcontractkit/chainlink/v2/core/services/registrysyncer"

ragep2ptypes "github.com/smartcontractkit/libocr/ragep2p/types"
)

const (
ccipCapVersion = "v1.0.0"
ccipCapNewVersion = "v1.1.0"
ccipCapName = "ccip"
)

var (
defaultCapability = getCapability(ccipCapName, ccipCapVersion)
newCapability = getCapability(ccipCapName, ccipCapNewVersion)
p2pID1 = getP2PID(1)
p2pID2 = getP2PID(2)
defaultCapCfgs = map[string]registrysyncer.CapabilityConfiguration{
defaultCapability.ID: registrysyncer.CapabilityConfiguration{},
}
defaultRegistryDon = registrysyncer.DON{
DON: getDON(1, []ragep2ptypes.PeerID{p2pID1}, 0),
CapabilityConfigurations: defaultCapCfgs,
}
)

func getP2PID(id uint32) ragep2ptypes.PeerID {
return ragep2ptypes.PeerID(p2pkey.MustNewV2XXXTestingOnly(big.NewInt(int64(id))).PeerID())
}

func getCapability(ccipCapName, ccipCapVersion string) registrysyncer.Capability {
id := fmt.Sprintf("%s@%s", ccipCapName, ccipCapVersion)
return registrysyncer.Capability{
CapabilityType: capabilities.CapabilityTypeTarget,
ID: id,
}
}

func getDON(id uint32, members []ragep2ptypes.PeerID, cfgVersion uint32) capabilities.DON {
return capabilities.DON{
ID: id,
ConfigVersion: cfgVersion,
F: uint8(1),
IsPublic: true,
AcceptsWorkflows: true,
Members: members,
}
}
11 changes: 5 additions & 6 deletions core/services/chainlink/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,20 @@ import (
"go.uber.org/multierr"
"go.uber.org/zap/zapcore"

"github.com/smartcontractkit/chainlink/v2/core/capabilities/ccip"

"github.com/smartcontractkit/chainlink-common/pkg/loop"
commonservices "github.com/smartcontractkit/chainlink-common/pkg/services"
"github.com/smartcontractkit/chainlink-common/pkg/sqlutil"
"github.com/smartcontractkit/chainlink-common/pkg/utils"
"github.com/smartcontractkit/chainlink-common/pkg/utils/jsonserializable"
"github.com/smartcontractkit/chainlink-common/pkg/utils/mailbox"
"github.com/smartcontractkit/chainlink/v2/core/capabilities"
"github.com/smartcontractkit/chainlink/v2/core/chains/evm/logpoller"
"github.com/smartcontractkit/chainlink/v2/core/services/standardcapabilities"
"github.com/smartcontractkit/chainlink/v2/core/static"

"github.com/smartcontractkit/chainlink/v2/core/bridges"
"github.com/smartcontractkit/chainlink/v2/core/build"
"github.com/smartcontractkit/chainlink/v2/core/capabilities"
"github.com/smartcontractkit/chainlink/v2/core/capabilities/ccip"
"github.com/smartcontractkit/chainlink/v2/core/capabilities/remote"
remotetypes "github.com/smartcontractkit/chainlink/v2/core/capabilities/remote/types"
"github.com/smartcontractkit/chainlink/v2/core/chains/evm/logpoller"
"github.com/smartcontractkit/chainlink/v2/core/chains/evm/txmgr"
evmtypes "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types"
evmutils "github.com/smartcontractkit/chainlink/v2/core/chains/evm/utils"
Expand Down Expand Up @@ -63,6 +60,7 @@ import (
"github.com/smartcontractkit/chainlink/v2/core/services/registrysyncer"
"github.com/smartcontractkit/chainlink/v2/core/services/relay/evm/mercury"
"github.com/smartcontractkit/chainlink/v2/core/services/relay/evm/mercury/wsrpc"
"github.com/smartcontractkit/chainlink/v2/core/services/standardcapabilities"
"github.com/smartcontractkit/chainlink/v2/core/services/streams"
"github.com/smartcontractkit/chainlink/v2/core/services/telemetry"
"github.com/smartcontractkit/chainlink/v2/core/services/vrf"
Expand All @@ -72,6 +70,7 @@ import (
"github.com/smartcontractkit/chainlink/v2/core/sessions"
"github.com/smartcontractkit/chainlink/v2/core/sessions/ldapauth"
"github.com/smartcontractkit/chainlink/v2/core/sessions/localauth"
"github.com/smartcontractkit/chainlink/v2/core/static"
"github.com/smartcontractkit/chainlink/v2/plugins"
)

Expand Down

0 comments on commit c495985

Please sign in to comment.