-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
add gateway connector capability config #14325
Conversation
50764ea
to
fc3bc6b
Compare
cb8b8d4
to
d78d6fb
Compare
d78d6fb
to
80b5f62
Compare
core/config/capabilities_config.go
Outdated
URL() string | ||
} | ||
|
||
type WorkflowConnectorConfig interface { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should merge these two structs for simplicity. WorkflowConnectorConfig is not a great name (I know I proposed it myself). How about we flatten everything into GatewayConnectorConfig? Simply move ChainIDForNodeKey() in there.
core/config/docs/core.toml
Outdated
@@ -509,6 +509,28 @@ 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.WorkflowConnectorConfig] | |||
# ChainIDForNodeKey is the ChainID of the network | |||
ChainIDForNodeKey = '1' # Example |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed before, you'll also need to provide the desired address of a key you want to use. You can handle it in a separate PR but it will save you some trouble if you don't have to re-generate all test outputs again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've generated 0xfd29Dd9C980D715a64dace97F7A2AB98bcaE0fed
so I'll use that as the default.
ca54c27
to
518b858
Compare
core/config/capabilities_config.go
Outdated
type GatewayConnectorConfig interface { | ||
ChainIDForNodeKey() string | ||
NodeAddress() string | ||
DonID() string | ||
Gateways() []ConnectorGatewayConfig | ||
WsHandshakeTimeoutMillis() uint32 | ||
AuthMinChallengeLen() int | ||
AuthTimestampToleranceSec() uint32 | ||
} | ||
|
||
type ConnectorGatewayConfig interface { | ||
ID() string | ||
URL() string | ||
} | ||
|
||
type Capabilities interface { | ||
Peering() P2P | ||
Dispatcher() Dispatcher | ||
ExternalRegistry() CapabilitiesExternalRegistry | ||
GatewayConnectorConfig() GatewayConnectorConfig |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In most places, the Config
suffix is redundant:
type GatewayConnectorConfig interface { | |
ChainIDForNodeKey() string | |
NodeAddress() string | |
DonID() string | |
Gateways() []ConnectorGatewayConfig | |
WsHandshakeTimeoutMillis() uint32 | |
AuthMinChallengeLen() int | |
AuthTimestampToleranceSec() uint32 | |
} | |
type ConnectorGatewayConfig interface { | |
ID() string | |
URL() string | |
} | |
type Capabilities interface { | |
Peering() P2P | |
Dispatcher() Dispatcher | |
ExternalRegistry() CapabilitiesExternalRegistry | |
GatewayConnectorConfig() GatewayConnectorConfig | |
type GatewayConnector interface { | |
ChainIDForNodeKey() string | |
NodeAddress() string | |
DonID() string | |
Gateways() []ConnectorGateway | |
WsHandshakeTimeoutMillis() uint32 | |
AuthMinChallengeLen() int | |
AuthTimestampToleranceSec() uint32 | |
} | |
type ConnectorGateway interface { | |
ID() string | |
URL() string | |
} | |
type Capabilities interface { | |
Peering() P2P | |
Dispatcher() Dispatcher | |
ExternalRegistry() CapabilitiesExternalRegistry | |
GatewayConnector() GatewayConnector |
core/config/docs/core.toml
Outdated
[Capabilities.GatewayConnectorConfig] | ||
# ChainIDForNodeKey is the ChainID of the network | ||
ChainIDForNodeKey = '0xfd29Dd9C980D715a64dace97F7A2AB98bcaE0fed' # Default | ||
# NodeAddress is Workflow Node address | ||
NodeAddress = '0x68902d681c28119f9b2531473a417088bf008e59' # Example | ||
# DonID is the Id of the Don | ||
DonID = 'example_don' # Example | ||
# WsHandshakeTimeoutMillis is Websocket handshake timeout | ||
WsHandshakeTimeoutMillis = 1000 # Example | ||
# AuthMinChallengeLen is the minimum number of bytes in Authentication | ||
AuthMinChallengeLen = 10 # Example | ||
# AuthTimestampToleranceSec is Authentication timestamp tolerance | ||
AuthTimestampToleranceSec = 10 # Example | ||
|
||
[[Capabilities.GatewayConnectorConfig.Gateways]] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Capabilities.GatewayConnectorConfig] | |
# ChainIDForNodeKey is the ChainID of the network | |
ChainIDForNodeKey = '0xfd29Dd9C980D715a64dace97F7A2AB98bcaE0fed' # Default | |
# NodeAddress is Workflow Node address | |
NodeAddress = '0x68902d681c28119f9b2531473a417088bf008e59' # Example | |
# DonID is the Id of the Don | |
DonID = 'example_don' # Example | |
# WsHandshakeTimeoutMillis is Websocket handshake timeout | |
WsHandshakeTimeoutMillis = 1000 # Example | |
# AuthMinChallengeLen is the minimum number of bytes in Authentication | |
AuthMinChallengeLen = 10 # Example | |
# AuthTimestampToleranceSec is Authentication timestamp tolerance | |
AuthTimestampToleranceSec = 10 # Example | |
[[Capabilities.GatewayConnectorConfig.Gateways]] | |
[Capabilities.GatewayConnector] | |
# ChainIDForNodeKey is the ChainID of the network | |
ChainIDForNodeKey = '0xfd29Dd9C980D715a64dace97F7A2AB98bcaE0fed' # Default | |
# NodeAddress is Workflow Node address | |
NodeAddress = '0x68902d681c28119f9b2531473a417088bf008e59' # Example | |
# DonID is the Id of the Don | |
DonID = 'example_don' # Example | |
# WsHandshakeTimeoutMillis is Websocket handshake timeout | |
WsHandshakeTimeoutMillis = 1000 # Example | |
# AuthMinChallengeLen is the minimum number of bytes in Authentication | |
AuthMinChallengeLen = 10 # Example | |
# AuthTimestampToleranceSec is Authentication timestamp tolerance | |
AuthTimestampToleranceSec = 10 # Example | |
[[Capabilities.GatewayConnector.Gateways]] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, does Connector
add value? Or would this make sense and be clear to users as just Gateway
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah Connector is important as it distinguishes when a node connects to gateways or is a gateway itself. Similarly we talk about Gateway handlers and Connector handlers. Let's keep it.
main_test.go
Outdated
@@ -60,7 +60,7 @@ func TestScripts(t *testing.T) { | |||
Dir: path, | |||
Setup: commonEnv, | |||
ContinueOnError: true, | |||
// UpdateScripts: true, // uncomment to update golden files | |||
UpdateScripts: true, // uncomment to update golden files |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Re-comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like you ran update with a production (non dev/test mode) chainlink binary
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAIK, my build has always been a dev binary via make chainlink-dev
. This file keeps alternating back and forth fwiw.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
testscripts-update
appears to be running chainlink-test
which is not dev mode - just a plain build.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left some minor suggestions but looks good overall!
core/config/docs/core.toml
Outdated
@@ -509,6 +509,26 @@ 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.GatewayConnectorConfig] | |||
# ChainIDForNodeKey is the ChainID of the network | |||
ChainIDForNodeKey = '0xfd29Dd9C980D715a64dace97F7A2AB98bcaE0fed' # Default |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The default here is an integer such as 11155111 for Ethereum Sepolia, not a hex address.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But still a string to be agnostic? And this should be an example, no?
ChainIDForNodeKey = '0xfd29Dd9C980D715a64dace97F7A2AB98bcaE0fed' # Default | |
ChainIDForNodeKey = '11155111' # Example |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, a string, thanks
core/config/docs/core.toml
Outdated
@@ -509,6 +509,26 @@ 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.GatewayConnectorConfig] | |||
# ChainIDForNodeKey is the ChainID of the network |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"ChainIDForNodeKey is the ChainID of the network associated with a private key to be used for authentication with Gateway nodes"
core/config/docs/core.toml
Outdated
[Capabilities.GatewayConnectorConfig] | ||
# ChainIDForNodeKey is the ChainID of the network | ||
ChainIDForNodeKey = '0xfd29Dd9C980D715a64dace97F7A2AB98bcaE0fed' # Default | ||
# NodeAddress is Workflow Node address |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"NodeAddress is the address of the desired private key to be used for authentication with Gateway nodes"
core/config/docs/core.toml
Outdated
DonID = 'example_don' # Example | ||
# WsHandshakeTimeoutMillis is Websocket handshake timeout | ||
WsHandshakeTimeoutMillis = 1000 # Example | ||
# AuthMinChallengeLen is the minimum number of bytes in Authentication |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"... number of bytes in authentication challenge payload"
core/config/docs/core.toml
Outdated
# ID of the Gateway | ||
ID = 'example_gateway' # Example | ||
# URL of the Gateway | ||
URL = 'ws://localhost:8081/node' # Example |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change "ws" to "wss"
core/config/toml/types.go
Outdated
r.DonID = f.DonID | ||
} | ||
|
||
// TODO: verify this copy by reference is ok, or does array need to be copied by value |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
resolve this TODO please - most likely reference is OK (@cedric-cordenier ?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I commented this on the previous PR: it's fine to use the reference here, but the interface implementation (the getter) should do a deep copy before returning it. This will prevent bugs with a caller modifying the underlying array.
core/config/toml/types.go
Outdated
Peering P2P `toml:",omitempty"` | ||
Dispatcher Dispatcher `toml:",omitempty"` | ||
ExternalRegistry ExternalRegistry `toml:",omitempty"` | ||
GatewayConnectorConfig GatewayConnectorConfig `toml:", omitempty"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: unnecessary space before "omitempty"
testdata/scripts/node/db/help.txtar
Outdated
@@ -9,15 +9,12 @@ USAGE: | |||
chainlink node db command [command options] [arguments...] | |||
|
|||
COMMANDS: | |||
reset Drop, create and migrate database. Useful for setting up the database in order to run tests or resetting the dev database. WARNING: This will ERASE ALL DATA for the specified database, referred to by CL_DATABASE_URL env variable or by the Database.URL field in a secrets TOML config. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure why this changed...? try reverting maybe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to alternate back and forth. I have no idea how or why tbh.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are more commands available in dev mode. If you just use go test
then you won't have this problem.
} | ||
|
||
func (c *gatewayConnectorConfig) Gateways() []config.ConnectorGatewayConfig { | ||
t := []config.ConnectorGatewayConfig{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@DavidOrchard Does this work? I think it should panic in practice because you're initializing a zero-length array and then adding elements to indexes that don't exist.
You can get around this by constructing an array of the right length:
t := make([]config.ConnectorGatewayConfig, len(c.c.Gateways))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I honestly don't know if it works or not, I do know the tests seem to pass. But I don't know if there's a test that copies the structure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please update the config-full.toml
test files with example data for all fields so that we have coverage
6c1f41b
to
52bbc8a
Compare
52bbc8a
to
d1a771a
Compare
d1a771a
to
6f0e185
Compare
core/config/toml/types.go
Outdated
NodeAddress *string | ||
DonID *string | ||
Gateways []ConnectorGateway | ||
WsHandshakeTimeoutMillis *uint32 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think WS
should be upper case according to Go naming rules:
WsHandshakeTimeoutMillis *uint32 | |
WSHandshakeTimeoutMillis *uint32 |
37e51f8
to
21b241c
Compare
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We probably don't need this extra line?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fwiw, that's what was generated.
Quality Gate passedIssues Measures |
add
type GatewayConnectorConfig struct {
and add
2. GatewayConnectorConfig GatewayConnectorConfig
toml:", omitempty"
to Capabilities.
core/config/capabilities_config.go
add
type ConnectorConfig interface {
type ConnectorGatewayConfig interface {
services/chainlink/config_capabilities.go
add
type GatewayConnectorConfig struct {