Skip to content

Commit

Permalink
Add WorkflowRegistry to config
Browse files Browse the repository at this point in the history
  • Loading branch information
cedric-cordenier committed Nov 18, 2024
1 parent 07a2cec commit 5229d20
Show file tree
Hide file tree
Showing 14 changed files with 114 additions and 0 deletions.
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 @@ -1448,6 +1448,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 @@ -1537,12 +1557,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 testdata/scripts/config/merge_raw_configs.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,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 @@ -280,6 +280,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 @@ -341,6 +341,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 @@ -324,6 +324,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 @@ -324,6 +324,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 @@ -324,6 +324,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 @@ -309,6 +309,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 @@ -314,6 +314,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 @@ -321,6 +321,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 @@ -303,6 +303,11 @@ Address = ''
NetworkID = 'evm'
ChainID = '1'

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

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

0 comments on commit 5229d20

Please sign in to comment.