Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CCIP Merge] Capabilities fix [CCIP-2943] #14048

Merged
merged 16 commits into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Move registrySyncer creation into ccip delegate
  • Loading branch information
asoliman92 committed Aug 7, 2024
commit e35df28ec47b057a0eb78ddcd0098f7ea73a918b
39 changes: 33 additions & 6 deletions core/capabilities/ccip/delegate.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,14 @@ import (
"fmt"
"time"

"github.com/smartcontractkit/chainlink-common/pkg/loop"
"github.com/smartcontractkit/chainlink/v2/core/capabilities/ccip/common"
configsevm "github.com/smartcontractkit/chainlink/v2/core/capabilities/ccip/configs/evm"
"github.com/smartcontractkit/chainlink/v2/core/capabilities/ccip/launcher"
"github.com/smartcontractkit/chainlink/v2/core/capabilities/ccip/oraclecreator"
"github.com/smartcontractkit/chainlink/v2/core/services/ocrcommon"
p2ptypes "github.com/smartcontractkit/chainlink/v2/core/services/p2p/types"
"github.com/smartcontractkit/chainlink/v2/core/services/registrysyncer"

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

Expand All @@ -27,25 +31,28 @@ import (
"github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/ocr2key"
"github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/p2pkey"
"github.com/smartcontractkit/chainlink/v2/core/services/ocr2"
"github.com/smartcontractkit/chainlink/v2/core/services/ocrcommon"
"github.com/smartcontractkit/chainlink/v2/core/services/pipeline"
"github.com/smartcontractkit/chainlink/v2/core/services/registrysyncer"
"github.com/smartcontractkit/chainlink/v2/core/services/relay"
"github.com/smartcontractkit/chainlink/v2/core/services/relay/evm"
"github.com/smartcontractkit/chainlink/v2/core/services/telemetry"
"github.com/smartcontractkit/chainlink/v2/plugins"
)

type RelayGetter interface {
Get(types.RelayID) (loop.Relayer, error)
GetIDToRelayerMap() (map[types.RelayID]loop.Relayer, error)
}

type Delegate struct {
lggr logger.Logger
registrarConfig plugins.RegistrarConfig
pipelineRunner pipeline.Runner
chains legacyevm.LegacyChainContainer
relayers RelayGetter
keystore keystore.Master
ds sqlutil.DataSource
peerWrapper *ocrcommon.SingletonPeerWrapper
monitoringEndpointGen telemetry.MonitoringEndpointGenerator
registrySyncer registrysyncer.Syncer
capabilityConfig config.Capabilities

isNewlyCreatedJob bool
Expand All @@ -56,7 +63,7 @@ func NewDelegate(
registrarConfig plugins.RegistrarConfig,
pipelineRunner pipeline.Runner,
chains legacyevm.LegacyChainContainer,
registrySyncer registrysyncer.Syncer,
relayers RelayGetter,
keystore keystore.Master,
ds sqlutil.DataSource,
peerWrapper *ocrcommon.SingletonPeerWrapper,
Expand All @@ -68,7 +75,7 @@ func NewDelegate(
registrarConfig: registrarConfig,
pipelineRunner: pipelineRunner,
chains: chains,
registrySyncer: registrySyncer,
relayers: relayers,
ds: ds,
keystore: keystore,
peerWrapper: peerWrapper,
Expand Down Expand Up @@ -99,6 +106,25 @@ func (d *Delegate) ServicesForSpec(ctx context.Context, spec job.Job) (services
return nil, fmt.Errorf("failed to get all p2p keys: %w", err)
}

cfg := d.capabilityConfig
rid := cfg.ExternalRegistry().RelayID()
registryAddress := cfg.ExternalRegistry().Address()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: you can inline this

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)
}
registrySyncer, err := registrysyncer.New(
d.lggr,
func() (p2ptypes.PeerID, error) {
return p2ptypes.PeerID(p2pID.PeerID()), nil
},
relayer,
registryAddress,
)
if err != nil {
return nil, fmt.Errorf("could not configure syncer: %w", err)
}

ocrKeys, err := d.getOCRKeys(spec.CCIPSpec.OCRKeyBundleIDs)
if err != nil {
return nil, err
Expand Down Expand Up @@ -160,9 +186,10 @@ func (d *Delegate) ServicesForSpec(ctx context.Context, spec job.Job) (services
)

// register the capability launcher with the registry syncer
d.registrySyncer.AddLauncher(capLauncher)
registrySyncer.AddLauncher(capLauncher)

return []job.ServiceCtx{
registrySyncer,
hcr,
capLauncher,
}, nil
Expand Down
2 changes: 1 addition & 1 deletion core/services/chainlink/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ func NewApplication(opts ApplicationOpts) (Application, error) {
loopRegistrarConfig,
pipelineRunner,
opts.RelayerChainInteroperators.LegacyEVMChains(),
capabilityRegistrySyncer,
relayerChainInterops,
opts.KeyStore,
opts.DS,
peerWrapper,
Expand Down
Loading