Skip to content

Commit

Permalink
Add WorkflowRegistry to config (#15280)
Browse files Browse the repository at this point in the history
  • Loading branch information
cedric-cordenier authored Nov 20, 2024
1 parent 73e82d2 commit 2ea3aef
Show file tree
Hide file tree
Showing 23 changed files with 177 additions and 1 deletion.
2 changes: 1 addition & 1 deletion core/cmd/shell_local.go
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ func (s *Shell) runNode(c *cli.Context) error {
}
}

if s.Config.Capabilities().Peering().Enabled() {
if s.Config.Capabilities().WorkflowRegistry().Address() != "" {
err2 := app.GetKeyStore().Workflow().EnsureKey(rootCtx)
if err2 != nil {
return errors.Wrap(err2, "failed to ensure workflow key")
Expand Down
8 changes: 8 additions & 0 deletions core/config/capabilities_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ type CapabilitiesExternalRegistry interface {
RelayID() types.RelayID
}

type CapabilitiesWorkflowRegistry interface {
Address() string
NetworkID() string
ChainID() string
RelayID() types.RelayID
}

type GatewayConnector interface {
ChainIDForNodeKey() string
NodeAddress() string
Expand All @@ -30,5 +37,6 @@ type Capabilities interface {
Peering() P2P
Dispatcher() Dispatcher
ExternalRegistry() CapabilitiesExternalRegistry
WorkflowRegistry() CapabilitiesWorkflowRegistry
GatewayConnector() GatewayConnector
}
8 changes: 8 additions & 0 deletions core/config/docs/core.toml
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,14 @@ DeltaReconcile = '1m' # Default
# but the host and port must be fully specified and cannot be empty. You can specify `0.0.0.0` (IPv4) or `::` (IPv6) to listen on all interfaces, but that is not recommended.
ListenAddresses = ['1.2.3.4:9999', '[a52d:0:a88:1274::abcd]:1337'] # Example

[Capabilities.WorkflowRegistry]
# Address is the address for the workflow registry contract.
Address = '0x0' # Example
# NetworkID identifies the target network where the remote registry is located.
NetworkID = 'evm' # Default
# ChainID identifies the target chain id where the remote registry is located.
ChainID = '1' # Default

[Capabilities.ExternalRegistry]
# Address is the address for the capabilities registry contract.
Address = '0x0' # Example
Expand Down
22 changes: 22 additions & 0 deletions core/config/toml/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -1452,6 +1452,26 @@ func (r *ExternalRegistry) setFrom(f *ExternalRegistry) {
}
}

type WorkflowRegistry struct {
Address *string
NetworkID *string
ChainID *string
}

func (r *WorkflowRegistry) setFrom(f *WorkflowRegistry) {
if f.Address != nil {
r.Address = f.Address
}

if f.NetworkID != nil {
r.NetworkID = f.NetworkID
}

if f.ChainID != nil {
r.ChainID = f.ChainID
}
}

type Dispatcher struct {
SupportedVersion *int
ReceiverBufferSize *int
Expand Down Expand Up @@ -1541,12 +1561,14 @@ type Capabilities struct {
Peering P2P `toml:",omitempty"`
Dispatcher Dispatcher `toml:",omitempty"`
ExternalRegistry ExternalRegistry `toml:",omitempty"`
WorkflowRegistry WorkflowRegistry `toml:",omitempty"`
GatewayConnector GatewayConnector `toml:",omitempty"`
}

func (c *Capabilities) setFrom(f *Capabilities) {
c.Peering.setFrom(&f.Peering)
c.ExternalRegistry.setFrom(&f.ExternalRegistry)
c.WorkflowRegistry.setFrom(&f.WorkflowRegistry)
c.Dispatcher.setFrom(&f.Dispatcher)
c.GatewayConnector.setFrom(&f.GatewayConnector)
}
Expand Down
26 changes: 26 additions & 0 deletions core/services/chainlink/config_capabilities.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ func (c *capabilitiesConfig) ExternalRegistry() config.CapabilitiesExternalRegis
}
}

func (c *capabilitiesConfig) WorkflowRegistry() config.CapabilitiesWorkflowRegistry {
return &capabilitiesWorkflowRegistry{
c: c.c.WorkflowRegistry,
}
}

func (c *capabilitiesConfig) Dispatcher() config.Dispatcher {
return &dispatcher{d: c.c.Dispatcher}
}
Expand Down Expand Up @@ -88,6 +94,26 @@ func (c *capabilitiesExternalRegistry) Address() string {
return *c.c.Address
}

type capabilitiesWorkflowRegistry struct {
c toml.WorkflowRegistry
}

func (c *capabilitiesWorkflowRegistry) RelayID() types.RelayID {
return types.NewRelayID(c.NetworkID(), c.ChainID())
}

func (c *capabilitiesWorkflowRegistry) NetworkID() string {
return *c.c.NetworkID
}

func (c *capabilitiesWorkflowRegistry) ChainID() string {
return *c.c.ChainID
}

func (c *capabilitiesWorkflowRegistry) Address() string {
return *c.c.Address
}

type gatewayConnector struct {
c toml.GatewayConnector
}
Expand Down
5 changes: 5 additions & 0 deletions core/services/chainlink/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,11 @@ func TestConfig_Marshal(t *testing.T) {
ChainID: ptr("1"),
NetworkID: ptr("evm"),
},
WorkflowRegistry: toml.WorkflowRegistry{
Address: ptr(""),
ChainID: ptr("1"),
NetworkID: ptr("evm"),
},
Dispatcher: toml.Dispatcher{
SupportedVersion: ptr(1),
ReceiverBufferSize: ptr(10000),
Expand Down
5 changes: 5 additions & 0 deletions core/services/chainlink/testdata/config-empty-effective.toml
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,11 @@ Address = ''
NetworkID = 'evm'
ChainID = '1'

[Capabilities.WorkflowRegistry]
Address = ''
NetworkID = 'evm'
ChainID = '1'

[Capabilities.GatewayConnector]
ChainIDForNodeKey = ''
NodeAddress = ''
Expand Down
5 changes: 5 additions & 0 deletions core/services/chainlink/testdata/config-full.toml
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,11 @@ Address = ''
NetworkID = 'evm'
ChainID = '1'

[Capabilities.WorkflowRegistry]
Address = ''
NetworkID = 'evm'
ChainID = '1'

[Capabilities.GatewayConnector]
ChainIDForNodeKey = '11155111'
NodeAddress = '0x68902d681c28119f9b2531473a417088bf008e59'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,11 @@ Address = ''
NetworkID = 'evm'
ChainID = '1'

[Capabilities.WorkflowRegistry]
Address = ''
NetworkID = 'evm'
ChainID = '1'

[Capabilities.GatewayConnector]
ChainIDForNodeKey = ''
NodeAddress = ''
Expand Down
5 changes: 5 additions & 0 deletions core/web/resolver/testdata/config-empty-effective.toml
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,11 @@ Address = ''
NetworkID = 'evm'
ChainID = '1'

[Capabilities.WorkflowRegistry]
Address = ''
NetworkID = 'evm'
ChainID = '1'

[Capabilities.GatewayConnector]
ChainIDForNodeKey = ''
NodeAddress = ''
Expand Down
5 changes: 5 additions & 0 deletions core/web/resolver/testdata/config-full.toml
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,11 @@ Address = ''
NetworkID = 'evm'
ChainID = '1'

[Capabilities.WorkflowRegistry]
Address = ''
NetworkID = 'evm'
ChainID = '1'

[Capabilities.GatewayConnector]
ChainIDForNodeKey = '11155111'
NodeAddress = '0x68902d681c28119f9b2531473a417088bf008e59'
Expand Down
5 changes: 5 additions & 0 deletions core/web/resolver/testdata/config-multi-chain-effective.toml
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,11 @@ Address = ''
NetworkID = 'evm'
ChainID = '1'

[Capabilities.WorkflowRegistry]
Address = ''
NetworkID = 'evm'
ChainID = '1'

[Capabilities.GatewayConnector]
ChainIDForNodeKey = ''
NodeAddress = ''
Expand Down
27 changes: 27 additions & 0 deletions docs/CONFIG.md
Original file line number Diff line number Diff line change
Expand Up @@ -1213,6 +1213,33 @@ ListenAddresses = ['1.2.3.4:9999', '[a52d:0:a88:1274::abcd]:1337'] # Example
ListenAddresses is the addresses the peer will listen to on the network in `host:port` form as accepted by `net.Listen()`,
but the host and port must be fully specified and cannot be empty. You can specify `0.0.0.0` (IPv4) or `::` (IPv6) to listen on all interfaces, but that is not recommended.

## Capabilities.WorkflowRegistry
```toml
[Capabilities.WorkflowRegistry]
Address = '0x0' # Example
NetworkID = 'evm' # Default
ChainID = '1' # Default
```


### Address
```toml
Address = '0x0' # Example
```
Address is the address for the workflow registry contract.

### NetworkID
```toml
NetworkID = 'evm' # Default
```
NetworkID identifies the target network where the remote registry is located.

### ChainID
```toml
ChainID = '1' # Default
```
ChainID identifies the target chain id where the remote registry is located.

## Capabilities.ExternalRegistry
```toml
[Capabilities.ExternalRegistry]
Expand Down
5 changes: 5 additions & 0 deletions testdata/scripts/config/merge_raw_configs.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,11 @@ Address = ''
NetworkID = 'evm'
ChainID = '1'

[Capabilities.WorkflowRegistry]
Address = ''
NetworkID = 'evm'
ChainID = '1'

[Capabilities.GatewayConnector]
ChainIDForNodeKey = ''
NodeAddress = ''
Expand Down
5 changes: 5 additions & 0 deletions testdata/scripts/node/validate/default.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,11 @@ Address = ''
NetworkID = 'evm'
ChainID = '1'

[Capabilities.WorkflowRegistry]
Address = ''
NetworkID = 'evm'
ChainID = '1'

[Capabilities.GatewayConnector]
ChainIDForNodeKey = ''
NodeAddress = ''
Expand Down
5 changes: 5 additions & 0 deletions testdata/scripts/node/validate/defaults-override.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,11 @@ Address = ''
NetworkID = 'evm'
ChainID = '1'

[Capabilities.WorkflowRegistry]
Address = ''
NetworkID = 'evm'
ChainID = '1'

[Capabilities.GatewayConnector]
ChainIDForNodeKey = ''
NodeAddress = ''
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,11 @@ Address = ''
NetworkID = 'evm'
ChainID = '1'

[Capabilities.WorkflowRegistry]
Address = ''
NetworkID = 'evm'
ChainID = '1'

[Capabilities.GatewayConnector]
ChainIDForNodeKey = ''
NodeAddress = ''
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,11 @@ Address = ''
NetworkID = 'evm'
ChainID = '1'

[Capabilities.WorkflowRegistry]
Address = ''
NetworkID = 'evm'
ChainID = '1'

[Capabilities.GatewayConnector]
ChainIDForNodeKey = ''
NodeAddress = ''
Expand Down
5 changes: 5 additions & 0 deletions testdata/scripts/node/validate/disk-based-logging.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,11 @@ Address = ''
NetworkID = 'evm'
ChainID = '1'

[Capabilities.WorkflowRegistry]
Address = ''
NetworkID = 'evm'
ChainID = '1'

[Capabilities.GatewayConnector]
ChainIDForNodeKey = ''
NodeAddress = ''
Expand Down
5 changes: 5 additions & 0 deletions testdata/scripts/node/validate/invalid-ocr-p2p.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,11 @@ Address = ''
NetworkID = 'evm'
ChainID = '1'

[Capabilities.WorkflowRegistry]
Address = ''
NetworkID = 'evm'
ChainID = '1'

[Capabilities.GatewayConnector]
ChainIDForNodeKey = ''
NodeAddress = ''
Expand Down
5 changes: 5 additions & 0 deletions testdata/scripts/node/validate/invalid.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,11 @@ Address = ''
NetworkID = 'evm'
ChainID = '1'

[Capabilities.WorkflowRegistry]
Address = ''
NetworkID = 'evm'
ChainID = '1'

[Capabilities.GatewayConnector]
ChainIDForNodeKey = ''
NodeAddress = ''
Expand Down
5 changes: 5 additions & 0 deletions testdata/scripts/node/validate/valid.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,11 @@ Address = ''
NetworkID = 'evm'
ChainID = '1'

[Capabilities.WorkflowRegistry]
Address = ''
NetworkID = 'evm'
ChainID = '1'

[Capabilities.GatewayConnector]
ChainIDForNodeKey = ''
NodeAddress = ''
Expand Down
5 changes: 5 additions & 0 deletions testdata/scripts/node/validate/warnings.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,11 @@ Address = ''
NetworkID = 'evm'
ChainID = '1'

[Capabilities.WorkflowRegistry]
Address = ''
NetworkID = 'evm'
ChainID = '1'

[Capabilities.GatewayConnector]
ChainIDForNodeKey = ''
NodeAddress = ''
Expand Down

0 comments on commit 2ea3aef

Please sign in to comment.