Skip to content
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

Merged
merged 8 commits into from
Sep 5, 2024

Conversation

DavidOrchard
Copy link
Contributor

@DavidOrchard DavidOrchard commented Sep 3, 2024

  1. toml/types.go
    add
    type GatewayConnectorConfig struct {

and add
2. GatewayConnectorConfig GatewayConnectorConfig toml:", omitempty"
to Capabilities.

  1. core/config/capabilities_config.go
    add
    type ConnectorConfig interface {
    type ConnectorGatewayConfig interface {

  2. services/chainlink/config_capabilities.go
    add
    type GatewayConnectorConfig struct {

@DavidOrchard DavidOrchard force-pushed the feature/CAPPL-19-connector-service-2 branch from 50764ea to fc3bc6b Compare September 3, 2024 23:11
@DavidOrchard DavidOrchard force-pushed the feature/CAPPL-19-connector-service-2 branch 8 times, most recently from cb8b8d4 to d78d6fb Compare September 4, 2024 23:02
@DavidOrchard DavidOrchard force-pushed the feature/CAPPL-19-connector-service-2 branch from d78d6fb to 80b5f62 Compare September 5, 2024 01:28
URL() string
}

type WorkflowConnectorConfig interface {
Copy link
Contributor

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.

@@ -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
Copy link
Contributor

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.

Copy link
Contributor Author

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.

@DavidOrchard DavidOrchard force-pushed the feature/CAPPL-19-connector-service-2 branch from ca54c27 to 518b858 Compare September 5, 2024 03:47
@DavidOrchard DavidOrchard marked this pull request as ready for review September 5, 2024 05:03
@DavidOrchard DavidOrchard requested a review from a team as a code owner September 5, 2024 05:03
@DavidOrchard DavidOrchard requested review from agparadiso, bolekk, cedric-cordenier and ettec and removed request for a team September 5, 2024 05:03
jmank88
jmank88 previously requested changes Sep 5, 2024
Comment on lines 14 to 33
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
Copy link
Contributor

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:

Suggested change
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

Comment on lines 512 to 526
[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]]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
[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]]

Copy link
Contributor

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?

Copy link
Contributor

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-comment

Copy link
Contributor

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

Copy link
Contributor Author

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.

Copy link
Contributor

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.

Copy link
Contributor

@bolekk bolekk left a 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!

@@ -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
Copy link
Contributor

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.

Copy link
Contributor

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?

Suggested change
ChainIDForNodeKey = '0xfd29Dd9C980D715a64dace97F7A2AB98bcaE0fed' # Default
ChainIDForNodeKey = '11155111' # Example

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, a string, thanks

@@ -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
Copy link
Contributor

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"

[Capabilities.GatewayConnectorConfig]
# ChainIDForNodeKey is the ChainID of the network
ChainIDForNodeKey = '0xfd29Dd9C980D715a64dace97F7A2AB98bcaE0fed' # Default
# NodeAddress is Workflow Node address
Copy link
Contributor

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"

DonID = 'example_don' # Example
# WsHandshakeTimeoutMillis is Websocket handshake timeout
WsHandshakeTimeoutMillis = 1000 # Example
# AuthMinChallengeLen is the minimum number of bytes in Authentication
Copy link
Contributor

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"

# ID of the Gateway
ID = 'example_gateway' # Example
# URL of the Gateway
URL = 'ws://localhost:8081/node' # Example
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change "ws" to "wss"

r.DonID = f.DonID
}

// TODO: verify this copy by reference is ok, or does array need to be copied by value
Copy link
Contributor

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 ?)

Copy link
Contributor

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.

Peering P2P `toml:",omitempty"`
Dispatcher Dispatcher `toml:",omitempty"`
ExternalRegistry ExternalRegistry `toml:",omitempty"`
GatewayConnectorConfig GatewayConnectorConfig `toml:", omitempty"`
Copy link
Contributor

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"

@@ -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.
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

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{}
Copy link
Contributor

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))

Copy link
Contributor Author

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.

Copy link
Contributor

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

@DavidOrchard DavidOrchard force-pushed the feature/CAPPL-19-connector-service-2 branch 2 times, most recently from 6c1f41b to 52bbc8a Compare September 5, 2024 17:02
@DavidOrchard DavidOrchard force-pushed the feature/CAPPL-19-connector-service-2 branch from d1a771a to 6f0e185 Compare September 5, 2024 17:32
NodeAddress *string
DonID *string
Gateways []ConnectorGateway
WsHandshakeTimeoutMillis *uint32
Copy link
Contributor

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:

Suggested change
WsHandshakeTimeoutMillis *uint32
WSHandshakeTimeoutMillis *uint32

@DavidOrchard DavidOrchard force-pushed the feature/CAPPL-19-connector-service-2 branch from 37e51f8 to 21b241c Compare September 5, 2024 19:31

Copy link
Contributor

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?

Copy link
Contributor Author

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.

@jmank88 jmank88 added this pull request to the merge queue Sep 5, 2024
Merged via the queue into develop with commit b1c59dd Sep 5, 2024
134 of 135 checks passed
@jmank88 jmank88 deleted the feature/CAPPL-19-connector-service-2 branch September 5, 2024 23:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants