Skip to content

Commit

Permalink
Minor review feedback; rename GetLocalNode -> LocalNode
Browse files Browse the repository at this point in the history
  • Loading branch information
cedric-cordenier committed Jul 19, 2024
1 parent 1c2caf0 commit 89f7d8e
Show file tree
Hide file tree
Showing 13 changed files with 31 additions and 26 deletions.
8 changes: 5 additions & 3 deletions core/capabilities/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ var (
)

type metadataRegistry interface {
GetLocalNode(ctx context.Context) (capabilities.Node, error)
LocalNode(ctx context.Context) (capabilities.Node, error)
ConfigForCapability(ctx context.Context, capabilityID string, donID uint32) (capabilities.CapabilityConfiguration, error)
}

Expand All @@ -28,12 +28,12 @@ type Registry struct {
mu sync.RWMutex
}

func (r *Registry) GetLocalNode(ctx context.Context) (capabilities.Node, error) {
func (r *Registry) LocalNode(ctx context.Context) (capabilities.Node, error) {
if r.metadataRegistry == nil {
return capabilities.Node{}, errors.New("metadataRegistry information not available")
}

return r.metadataRegistry.GetLocalNode(ctx)
return r.metadataRegistry.LocalNode(ctx)
}

func (r *Registry) ConfigForCapability(ctx context.Context, capabilityID string, donID uint32) (capabilities.CapabilityConfiguration, error) {
Expand All @@ -44,6 +44,8 @@ func (r *Registry) ConfigForCapability(ctx context.Context, capabilityID string,
return r.metadataRegistry.ConfigForCapability(ctx, capabilityID, donID)
}

// SetLocalRegistry sets a local copy of the offchain registry for the registry to use.
// This is only public for testing purposes; the only production use should be from the CapabilitiesLauncher.
func (r *Registry) SetLocalRegistry(lr metadataRegistry) {
r.mu.Lock()
defer r.mu.Unlock()
Expand Down
2 changes: 1 addition & 1 deletion core/scripts/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ require (
github.com/prometheus/client_golang v1.17.0
github.com/shopspring/decimal v1.3.1
github.com/smartcontractkit/chainlink-automation v1.0.4
github.com/smartcontractkit/chainlink-common v0.2.1-0.20240718135951-f777ff165c0c
github.com/smartcontractkit/chainlink-common v0.2.1-0.20240719123314-829de8d964aa
github.com/smartcontractkit/chainlink/v2 v2.0.0-00010101000000-000000000000
github.com/smartcontractkit/libocr v0.0.0-20240702141926-063ceef8c42e
github.com/spf13/cobra v1.8.0
Expand Down
4 changes: 2 additions & 2 deletions core/scripts/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1178,8 +1178,8 @@ github.com/smartcontractkit/chain-selectors v1.0.10 h1:t9kJeE6B6G+hKD0GYR4kGJSCq
github.com/smartcontractkit/chain-selectors v1.0.10/go.mod h1:d4Hi+E1zqjy9HqMkjBE5q1vcG9VGgxf5VxiRHfzi2kE=
github.com/smartcontractkit/chainlink-automation v1.0.4 h1:iyW181JjKHLNMnDleI8umfIfVVlwC7+n5izbLSFgjw8=
github.com/smartcontractkit/chainlink-automation v1.0.4/go.mod h1:u4NbPZKJ5XiayfKHD/v3z3iflQWqvtdhj13jVZXj/cM=
github.com/smartcontractkit/chainlink-common v0.2.1-0.20240718135951-f777ff165c0c h1:jdlQhlTWpvggglGtbzqRHsTgfD01Zr/z1TOheVd+7Y4=
github.com/smartcontractkit/chainlink-common v0.2.1-0.20240718135951-f777ff165c0c/go.mod h1:fh9eBbrReCmv31bfz52ENCAMa7nTKQbdhb2B3+S2VGo=
github.com/smartcontractkit/chainlink-common v0.2.1-0.20240719123314-829de8d964aa h1:flegQyXwOAf+yGm49u0sz1fH5rdb8+8fl1QwsngEHrs=
github.com/smartcontractkit/chainlink-common v0.2.1-0.20240719123314-829de8d964aa/go.mod h1:fh9eBbrReCmv31bfz52ENCAMa7nTKQbdhb2B3+S2VGo=
github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240710121324-3ed288aa9b45 h1:NBQLtqk8zsyY4qTJs+NElI3aDFTcAo83JHvqD04EvB0=
github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240710121324-3ed288aa9b45/go.mod h1:LV0h7QBQUpoC2UUi6TcUvcIFm1xjP/DtEcqV8+qeLUs=
github.com/smartcontractkit/chainlink-data-streams v0.0.0-20240716180914-6fd88994c89c h1:xKj2jtIUhVcIm+RH9r7aTrxFdzM7VsaPLD4biUQj5Dg=
Expand Down
2 changes: 1 addition & 1 deletion core/services/registrysyncer/local_registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ type LocalRegistry struct {
IDsToCapabilities map[CapabilityID]Capability
}

func (l *LocalRegistry) GetLocalNode(ctx context.Context) (capabilities.Node, error) {
func (l *LocalRegistry) LocalNode(ctx context.Context) (capabilities.Node, error) {
if l.peerWrapper.GetPeer() == nil {
return capabilities.Node{}, errors.New("unable to get local node: peerWrapper hasn't started yet")
}
Expand Down
2 changes: 1 addition & 1 deletion core/services/registrysyncer/syncer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ func TestSyncer_LocalNode(t *testing.T) {
},
}

node, err := localRegistry.GetLocalNode(ctx)
node, err := localRegistry.LocalNode(ctx)
require.NoError(t, err)

don := capabilities.DON{
Expand Down
17 changes: 11 additions & 6 deletions core/services/workflows/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ func (e *Engine) init(ctx context.Context) {
retryErr := retryable(ctx, e.logger, e.retryMs, e.maxRetries, func() error {
// first wait for localDON to return a non-error response; this depends
// on the underlying peerWrapper returning the PeerID.
node, err := e.registry.GetLocalNode(ctx)
node, err := e.registry.LocalNode(ctx)
if err != nil {
return fmt.Errorf("failed to get donInfo: %w", err)
}
Expand Down Expand Up @@ -695,7 +695,7 @@ func merge(baseConfig *values.Map, overrideConfig *values.Map) *values.Map {
return m
}

func configForStep(ctx context.Context, reg core.CapabilitiesRegistry, localNode capabilities.Node, step *step) (*values.Map, error) {
func (e *Engine) configForStep(ctx context.Context, executionID string, step *step) (*values.Map, error) {
ID := step.info.ID

// If the capability info is missing a DON, then
Expand All @@ -704,14 +704,19 @@ func configForStep(ctx context.Context, reg core.CapabilitiesRegistry, localNode
if step.info.IsLocal {
donID = step.info.DON.ID
} else {
donID = localNode.WorkflowDON.ID
donID = e.localNode.WorkflowDON.ID
}

capConfig, err := reg.ConfigForCapability(ctx, ID, donID)
capConfig, err := e.registry.ConfigForCapability(ctx, ID, donID)
if err != nil {
return nil, err
e.logger.Warnw(fmt.Sprintf("could not retrieve config from remote registry: %s", err), "executionID", executionID, "capabilityID", ID)
return step.config, nil
}

// Merge the configs for now; note that this means that a workflow can override
// all of the config set by the capability. This is probably not desirable in
// the long-term, but we don't know much about those use cases so stick to a simpler
// implementation for now.
return merge(capConfig.DefaultConfig, step.config), nil
}

Expand Down Expand Up @@ -739,7 +744,7 @@ func (e *Engine) executeStep(ctx context.Context, msg stepRequest) (*values.Map,
return nil, nil, err
}

config, err := configForStep(ctx, e.registry, e.localNode, step)
config, err := e.configForStep(ctx, step)
if err != nil {
return nil, nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion core/services/workflows/engine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ type testConfigProvider struct {
configForCapability func(ctx context.Context, capabilityID string, donID uint32) (capabilities.CapabilityConfiguration, error)
}

func (t testConfigProvider) GetLocalNode(ctx context.Context) (capabilities.Node, error) {
func (t testConfigProvider) LocalNode(ctx context.Context) (capabilities.Node, error) {
if t.localNode != nil {
return t.localNode(ctx)
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ require (
github.com/shopspring/decimal v1.3.1
github.com/smartcontractkit/chain-selectors v1.0.10
github.com/smartcontractkit/chainlink-automation v1.0.4
github.com/smartcontractkit/chainlink-common v0.2.1-0.20240718142935-0c83d559fe6b
github.com/smartcontractkit/chainlink-common v0.2.1-0.20240719123314-829de8d964aa
github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240710121324-3ed288aa9b45
github.com/smartcontractkit/chainlink-data-streams v0.0.0-20240716180914-6fd88994c89c
github.com/smartcontractkit/chainlink-feeds v0.0.0-20240710170203-5b41615da827
Expand Down
6 changes: 2 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1131,10 +1131,8 @@ github.com/smartcontractkit/chain-selectors v1.0.10 h1:t9kJeE6B6G+hKD0GYR4kGJSCq
github.com/smartcontractkit/chain-selectors v1.0.10/go.mod h1:d4Hi+E1zqjy9HqMkjBE5q1vcG9VGgxf5VxiRHfzi2kE=
github.com/smartcontractkit/chainlink-automation v1.0.4 h1:iyW181JjKHLNMnDleI8umfIfVVlwC7+n5izbLSFgjw8=
github.com/smartcontractkit/chainlink-automation v1.0.4/go.mod h1:u4NbPZKJ5XiayfKHD/v3z3iflQWqvtdhj13jVZXj/cM=
github.com/smartcontractkit/chainlink-common v0.2.1-0.20240718135951-f777ff165c0c h1:jdlQhlTWpvggglGtbzqRHsTgfD01Zr/z1TOheVd+7Y4=
github.com/smartcontractkit/chainlink-common v0.2.1-0.20240718135951-f777ff165c0c/go.mod h1:fh9eBbrReCmv31bfz52ENCAMa7nTKQbdhb2B3+S2VGo=
github.com/smartcontractkit/chainlink-common v0.2.1-0.20240718142935-0c83d559fe6b h1:Z8hUt/+5wYDKM2RMCtj4LVlISO32xGqiUPkahOAJshI=
github.com/smartcontractkit/chainlink-common v0.2.1-0.20240718142935-0c83d559fe6b/go.mod h1:fh9eBbrReCmv31bfz52ENCAMa7nTKQbdhb2B3+S2VGo=
github.com/smartcontractkit/chainlink-common v0.2.1-0.20240719123314-829de8d964aa h1:flegQyXwOAf+yGm49u0sz1fH5rdb8+8fl1QwsngEHrs=
github.com/smartcontractkit/chainlink-common v0.2.1-0.20240719123314-829de8d964aa/go.mod h1:fh9eBbrReCmv31bfz52ENCAMa7nTKQbdhb2B3+S2VGo=
github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240710121324-3ed288aa9b45 h1:NBQLtqk8zsyY4qTJs+NElI3aDFTcAo83JHvqD04EvB0=
github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240710121324-3ed288aa9b45/go.mod h1:LV0h7QBQUpoC2UUi6TcUvcIFm1xjP/DtEcqV8+qeLUs=
github.com/smartcontractkit/chainlink-data-streams v0.0.0-20240716180914-6fd88994c89c h1:xKj2jtIUhVcIm+RH9r7aTrxFdzM7VsaPLD4biUQj5Dg=
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ require (
github.com/shopspring/decimal v1.3.1
github.com/slack-go/slack v0.12.2
github.com/smartcontractkit/chainlink-automation v1.0.4
github.com/smartcontractkit/chainlink-common v0.2.1-0.20240718135951-f777ff165c0c
github.com/smartcontractkit/chainlink-common v0.2.1-0.20240719123314-829de8d964aa
github.com/smartcontractkit/chainlink-testing-framework v1.32.7
github.com/smartcontractkit/chainlink-testing-framework/grafana v0.0.0-20240405215812-5a72bc9af239
github.com/smartcontractkit/chainlink/v2 v2.0.0-00010101000000-000000000000
Expand Down
4 changes: 2 additions & 2 deletions integration-tests/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1481,8 +1481,8 @@ github.com/smartcontractkit/chain-selectors v1.0.10 h1:t9kJeE6B6G+hKD0GYR4kGJSCq
github.com/smartcontractkit/chain-selectors v1.0.10/go.mod h1:d4Hi+E1zqjy9HqMkjBE5q1vcG9VGgxf5VxiRHfzi2kE=
github.com/smartcontractkit/chainlink-automation v1.0.4 h1:iyW181JjKHLNMnDleI8umfIfVVlwC7+n5izbLSFgjw8=
github.com/smartcontractkit/chainlink-automation v1.0.4/go.mod h1:u4NbPZKJ5XiayfKHD/v3z3iflQWqvtdhj13jVZXj/cM=
github.com/smartcontractkit/chainlink-common v0.2.1-0.20240718135951-f777ff165c0c h1:jdlQhlTWpvggglGtbzqRHsTgfD01Zr/z1TOheVd+7Y4=
github.com/smartcontractkit/chainlink-common v0.2.1-0.20240718135951-f777ff165c0c/go.mod h1:fh9eBbrReCmv31bfz52ENCAMa7nTKQbdhb2B3+S2VGo=
github.com/smartcontractkit/chainlink-common v0.2.1-0.20240719123314-829de8d964aa h1:flegQyXwOAf+yGm49u0sz1fH5rdb8+8fl1QwsngEHrs=
github.com/smartcontractkit/chainlink-common v0.2.1-0.20240719123314-829de8d964aa/go.mod h1:fh9eBbrReCmv31bfz52ENCAMa7nTKQbdhb2B3+S2VGo=
github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240710121324-3ed288aa9b45 h1:NBQLtqk8zsyY4qTJs+NElI3aDFTcAo83JHvqD04EvB0=
github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240710121324-3ed288aa9b45/go.mod h1:LV0h7QBQUpoC2UUi6TcUvcIFm1xjP/DtEcqV8+qeLUs=
github.com/smartcontractkit/chainlink-data-streams v0.0.0-20240716180914-6fd88994c89c h1:xKj2jtIUhVcIm+RH9r7aTrxFdzM7VsaPLD4biUQj5Dg=
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/load/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ require (
github.com/rs/zerolog v1.31.0
github.com/slack-go/slack v0.12.2
github.com/smartcontractkit/chainlink-automation v1.0.4
github.com/smartcontractkit/chainlink-common v0.2.1-0.20240718135951-f777ff165c0c
github.com/smartcontractkit/chainlink-common v0.2.1-0.20240719123314-829de8d964aa
github.com/smartcontractkit/chainlink-testing-framework v1.32.7
github.com/smartcontractkit/chainlink/integration-tests v0.0.0-20240214231432-4ad5eb95178c
github.com/smartcontractkit/chainlink/v2 v2.9.0-beta0.0.20240216210048-da02459ddad8
Expand Down
4 changes: 2 additions & 2 deletions integration-tests/load/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1463,8 +1463,8 @@ github.com/smartcontractkit/chain-selectors v1.0.10 h1:t9kJeE6B6G+hKD0GYR4kGJSCq
github.com/smartcontractkit/chain-selectors v1.0.10/go.mod h1:d4Hi+E1zqjy9HqMkjBE5q1vcG9VGgxf5VxiRHfzi2kE=
github.com/smartcontractkit/chainlink-automation v1.0.4 h1:iyW181JjKHLNMnDleI8umfIfVVlwC7+n5izbLSFgjw8=
github.com/smartcontractkit/chainlink-automation v1.0.4/go.mod h1:u4NbPZKJ5XiayfKHD/v3z3iflQWqvtdhj13jVZXj/cM=
github.com/smartcontractkit/chainlink-common v0.2.1-0.20240718135951-f777ff165c0c h1:jdlQhlTWpvggglGtbzqRHsTgfD01Zr/z1TOheVd+7Y4=
github.com/smartcontractkit/chainlink-common v0.2.1-0.20240718135951-f777ff165c0c/go.mod h1:fh9eBbrReCmv31bfz52ENCAMa7nTKQbdhb2B3+S2VGo=
github.com/smartcontractkit/chainlink-common v0.2.1-0.20240719123314-829de8d964aa h1:flegQyXwOAf+yGm49u0sz1fH5rdb8+8fl1QwsngEHrs=
github.com/smartcontractkit/chainlink-common v0.2.1-0.20240719123314-829de8d964aa/go.mod h1:fh9eBbrReCmv31bfz52ENCAMa7nTKQbdhb2B3+S2VGo=
github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240710121324-3ed288aa9b45 h1:NBQLtqk8zsyY4qTJs+NElI3aDFTcAo83JHvqD04EvB0=
github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240710121324-3ed288aa9b45/go.mod h1:LV0h7QBQUpoC2UUi6TcUvcIFm1xjP/DtEcqV8+qeLUs=
github.com/smartcontractkit/chainlink-data-streams v0.0.0-20240716180914-6fd88994c89c h1:xKj2jtIUhVcIm+RH9r7aTrxFdzM7VsaPLD4biUQj5Dg=
Expand Down

0 comments on commit 89f7d8e

Please sign in to comment.