From bb53d8bb2d496f6901c0e2d809519f93cac82b99 Mon Sep 17 00:00:00 2001 From: Cedric Cordenier Date: Mon, 18 Nov 2024 13:08:25 +0000 Subject: [PATCH] Add WorkflowRegistry to config --- core/cmd/shell_local.go | 2 +- core/config/capabilities_config.go | 8 ++++++ core/config/docs/core.toml | 8 ++++++ core/config/toml/types.go | 22 +++++++++++++++ .../services/chainlink/config_capabilities.go | 26 ++++++++++++++++++ core/services/chainlink/config_test.go | 5 ++++ .../testdata/config-empty-effective.toml | 5 ++++ .../chainlink/testdata/config-full.toml | 5 ++++ .../config-multi-chain-effective.toml | 5 ++++ .../testdata/config-empty-effective.toml | 5 ++++ core/web/resolver/testdata/config-full.toml | 5 ++++ .../config-multi-chain-effective.toml | 5 ++++ docs/CONFIG.md | 27 +++++++++++++++++++ .../scripts/config/merge_raw_configs.txtar | 5 ++++ testdata/scripts/node/validate/default.txtar | 5 ++++ .../node/validate/defaults-override.txtar | 5 ++++ .../disk-based-logging-disabled.txtar | 5 ++++ .../validate/disk-based-logging-no-dir.txtar | 5 ++++ .../node/validate/disk-based-logging.txtar | 5 ++++ .../node/validate/invalid-ocr-p2p.txtar | 5 ++++ testdata/scripts/node/validate/invalid.txtar | 5 ++++ testdata/scripts/node/validate/valid.txtar | 5 ++++ testdata/scripts/node/validate/warnings.txtar | 5 ++++ 23 files changed, 177 insertions(+), 1 deletion(-) diff --git a/core/cmd/shell_local.go b/core/cmd/shell_local.go index f6b8db43123..6261d23ef82 100644 --- a/core/cmd/shell_local.go +++ b/core/cmd/shell_local.go @@ -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") diff --git a/core/config/capabilities_config.go b/core/config/capabilities_config.go index b7e5a3b86a7..74e06bf8bbb 100644 --- a/core/config/capabilities_config.go +++ b/core/config/capabilities_config.go @@ -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 @@ -30,5 +37,6 @@ type Capabilities interface { Peering() P2P Dispatcher() Dispatcher ExternalRegistry() CapabilitiesExternalRegistry + WorkflowRegistry() CapabilitiesWorkflowRegistry GatewayConnector() GatewayConnector } diff --git a/core/config/docs/core.toml b/core/config/docs/core.toml index edd1494e4f0..20c519e81a1 100644 --- a/core/config/docs/core.toml +++ b/core/config/docs/core.toml @@ -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 diff --git a/core/config/toml/types.go b/core/config/toml/types.go index 610d18b6b4d..475e95d53df 100644 --- a/core/config/toml/types.go +++ b/core/config/toml/types.go @@ -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 @@ -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) } diff --git a/core/services/chainlink/config_capabilities.go b/core/services/chainlink/config_capabilities.go index 032eec58bea..37ab1fce72f 100644 --- a/core/services/chainlink/config_capabilities.go +++ b/core/services/chainlink/config_capabilities.go @@ -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} } @@ -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 } diff --git a/core/services/chainlink/config_test.go b/core/services/chainlink/config_test.go index e04d6d7e25b..769005feb72 100644 --- a/core/services/chainlink/config_test.go +++ b/core/services/chainlink/config_test.go @@ -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), diff --git a/core/services/chainlink/testdata/config-empty-effective.toml b/core/services/chainlink/testdata/config-empty-effective.toml index 0f26b02ab6f..a2052c04a8e 100644 --- a/core/services/chainlink/testdata/config-empty-effective.toml +++ b/core/services/chainlink/testdata/config-empty-effective.toml @@ -269,6 +269,11 @@ Address = '' NetworkID = 'evm' ChainID = '1' +[Capabilities.WorkflowRegistry] +Address = '' +NetworkID = 'evm' +ChainID = '1' + [Capabilities.GatewayConnector] ChainIDForNodeKey = '' NodeAddress = '' diff --git a/core/services/chainlink/testdata/config-full.toml b/core/services/chainlink/testdata/config-full.toml index 3191ce576ed..47193f80184 100644 --- a/core/services/chainlink/testdata/config-full.toml +++ b/core/services/chainlink/testdata/config-full.toml @@ -279,6 +279,11 @@ Address = '' NetworkID = 'evm' ChainID = '1' +[Capabilities.WorkflowRegistry] +Address = '' +NetworkID = 'evm' +ChainID = '1' + [Capabilities.GatewayConnector] ChainIDForNodeKey = '11155111' NodeAddress = '0x68902d681c28119f9b2531473a417088bf008e59' diff --git a/core/services/chainlink/testdata/config-multi-chain-effective.toml b/core/services/chainlink/testdata/config-multi-chain-effective.toml index 5f52c06ca1f..7e658b170db 100644 --- a/core/services/chainlink/testdata/config-multi-chain-effective.toml +++ b/core/services/chainlink/testdata/config-multi-chain-effective.toml @@ -269,6 +269,11 @@ Address = '' NetworkID = 'evm' ChainID = '1' +[Capabilities.WorkflowRegistry] +Address = '' +NetworkID = 'evm' +ChainID = '1' + [Capabilities.GatewayConnector] ChainIDForNodeKey = '' NodeAddress = '' diff --git a/core/web/resolver/testdata/config-empty-effective.toml b/core/web/resolver/testdata/config-empty-effective.toml index 0f26b02ab6f..a2052c04a8e 100644 --- a/core/web/resolver/testdata/config-empty-effective.toml +++ b/core/web/resolver/testdata/config-empty-effective.toml @@ -269,6 +269,11 @@ Address = '' NetworkID = 'evm' ChainID = '1' +[Capabilities.WorkflowRegistry] +Address = '' +NetworkID = 'evm' +ChainID = '1' + [Capabilities.GatewayConnector] ChainIDForNodeKey = '' NodeAddress = '' diff --git a/core/web/resolver/testdata/config-full.toml b/core/web/resolver/testdata/config-full.toml index 113d319e3c5..ef26bfea75a 100644 --- a/core/web/resolver/testdata/config-full.toml +++ b/core/web/resolver/testdata/config-full.toml @@ -279,6 +279,11 @@ Address = '' NetworkID = 'evm' ChainID = '1' +[Capabilities.WorkflowRegistry] +Address = '' +NetworkID = 'evm' +ChainID = '1' + [Capabilities.GatewayConnector] ChainIDForNodeKey = '11155111' NodeAddress = '0x68902d681c28119f9b2531473a417088bf008e59' diff --git a/core/web/resolver/testdata/config-multi-chain-effective.toml b/core/web/resolver/testdata/config-multi-chain-effective.toml index cb2884fde8f..7bdf50b9080 100644 --- a/core/web/resolver/testdata/config-multi-chain-effective.toml +++ b/core/web/resolver/testdata/config-multi-chain-effective.toml @@ -269,6 +269,11 @@ Address = '' NetworkID = 'evm' ChainID = '1' +[Capabilities.WorkflowRegistry] +Address = '' +NetworkID = 'evm' +ChainID = '1' + [Capabilities.GatewayConnector] ChainIDForNodeKey = '' NodeAddress = '' diff --git a/docs/CONFIG.md b/docs/CONFIG.md index 20965d816ec..8911aff141f 100644 --- a/docs/CONFIG.md +++ b/docs/CONFIG.md @@ -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] diff --git a/testdata/scripts/config/merge_raw_configs.txtar b/testdata/scripts/config/merge_raw_configs.txtar index bf0da942eea..efac49f8ef8 100644 --- a/testdata/scripts/config/merge_raw_configs.txtar +++ b/testdata/scripts/config/merge_raw_configs.txtar @@ -416,6 +416,11 @@ Address = '' NetworkID = 'evm' ChainID = '1' +[Capabilities.WorkflowRegistry] +Address = '' +NetworkID = 'evm' +ChainID = '1' + [Capabilities.GatewayConnector] ChainIDForNodeKey = '' NodeAddress = '' diff --git a/testdata/scripts/node/validate/default.txtar b/testdata/scripts/node/validate/default.txtar index 51edf69d599..d4e4a188d2a 100644 --- a/testdata/scripts/node/validate/default.txtar +++ b/testdata/scripts/node/validate/default.txtar @@ -281,6 +281,11 @@ Address = '' NetworkID = 'evm' ChainID = '1' +[Capabilities.WorkflowRegistry] +Address = '' +NetworkID = 'evm' +ChainID = '1' + [Capabilities.GatewayConnector] ChainIDForNodeKey = '' NodeAddress = '' diff --git a/testdata/scripts/node/validate/defaults-override.txtar b/testdata/scripts/node/validate/defaults-override.txtar index 19bae4bec1a..336f170bd1b 100644 --- a/testdata/scripts/node/validate/defaults-override.txtar +++ b/testdata/scripts/node/validate/defaults-override.txtar @@ -342,6 +342,11 @@ Address = '' NetworkID = 'evm' ChainID = '1' +[Capabilities.WorkflowRegistry] +Address = '' +NetworkID = 'evm' +ChainID = '1' + [Capabilities.GatewayConnector] ChainIDForNodeKey = '' NodeAddress = '' diff --git a/testdata/scripts/node/validate/disk-based-logging-disabled.txtar b/testdata/scripts/node/validate/disk-based-logging-disabled.txtar index ddd01a4c1e4..677058e1c08 100644 --- a/testdata/scripts/node/validate/disk-based-logging-disabled.txtar +++ b/testdata/scripts/node/validate/disk-based-logging-disabled.txtar @@ -325,6 +325,11 @@ Address = '' NetworkID = 'evm' ChainID = '1' +[Capabilities.WorkflowRegistry] +Address = '' +NetworkID = 'evm' +ChainID = '1' + [Capabilities.GatewayConnector] ChainIDForNodeKey = '' NodeAddress = '' diff --git a/testdata/scripts/node/validate/disk-based-logging-no-dir.txtar b/testdata/scripts/node/validate/disk-based-logging-no-dir.txtar index 0f40ad6a208..0e5a78f4a39 100644 --- a/testdata/scripts/node/validate/disk-based-logging-no-dir.txtar +++ b/testdata/scripts/node/validate/disk-based-logging-no-dir.txtar @@ -325,6 +325,11 @@ Address = '' NetworkID = 'evm' ChainID = '1' +[Capabilities.WorkflowRegistry] +Address = '' +NetworkID = 'evm' +ChainID = '1' + [Capabilities.GatewayConnector] ChainIDForNodeKey = '' NodeAddress = '' diff --git a/testdata/scripts/node/validate/disk-based-logging.txtar b/testdata/scripts/node/validate/disk-based-logging.txtar index dd7455ca3a8..7fc05533a47 100644 --- a/testdata/scripts/node/validate/disk-based-logging.txtar +++ b/testdata/scripts/node/validate/disk-based-logging.txtar @@ -325,6 +325,11 @@ Address = '' NetworkID = 'evm' ChainID = '1' +[Capabilities.WorkflowRegistry] +Address = '' +NetworkID = 'evm' +ChainID = '1' + [Capabilities.GatewayConnector] ChainIDForNodeKey = '' NodeAddress = '' diff --git a/testdata/scripts/node/validate/invalid-ocr-p2p.txtar b/testdata/scripts/node/validate/invalid-ocr-p2p.txtar index 1ffe2ab718c..2cc7b7afe0e 100644 --- a/testdata/scripts/node/validate/invalid-ocr-p2p.txtar +++ b/testdata/scripts/node/validate/invalid-ocr-p2p.txtar @@ -310,6 +310,11 @@ Address = '' NetworkID = 'evm' ChainID = '1' +[Capabilities.WorkflowRegistry] +Address = '' +NetworkID = 'evm' +ChainID = '1' + [Capabilities.GatewayConnector] ChainIDForNodeKey = '' NodeAddress = '' diff --git a/testdata/scripts/node/validate/invalid.txtar b/testdata/scripts/node/validate/invalid.txtar index 52edd2b8065..b048af38a3b 100644 --- a/testdata/scripts/node/validate/invalid.txtar +++ b/testdata/scripts/node/validate/invalid.txtar @@ -315,6 +315,11 @@ Address = '' NetworkID = 'evm' ChainID = '1' +[Capabilities.WorkflowRegistry] +Address = '' +NetworkID = 'evm' +ChainID = '1' + [Capabilities.GatewayConnector] ChainIDForNodeKey = '' NodeAddress = '' diff --git a/testdata/scripts/node/validate/valid.txtar b/testdata/scripts/node/validate/valid.txtar index 623459ce253..bc84a9b2a37 100644 --- a/testdata/scripts/node/validate/valid.txtar +++ b/testdata/scripts/node/validate/valid.txtar @@ -322,6 +322,11 @@ Address = '' NetworkID = 'evm' ChainID = '1' +[Capabilities.WorkflowRegistry] +Address = '' +NetworkID = 'evm' +ChainID = '1' + [Capabilities.GatewayConnector] ChainIDForNodeKey = '' NodeAddress = '' diff --git a/testdata/scripts/node/validate/warnings.txtar b/testdata/scripts/node/validate/warnings.txtar index 5452c49f122..85b7bc6a253 100644 --- a/testdata/scripts/node/validate/warnings.txtar +++ b/testdata/scripts/node/validate/warnings.txtar @@ -304,6 +304,11 @@ Address = '' NetworkID = 'evm' ChainID = '1' +[Capabilities.WorkflowRegistry] +Address = '' +NetworkID = 'evm' +ChainID = '1' + [Capabilities.GatewayConnector] ChainIDForNodeKey = '' NodeAddress = ''