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
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fixes, add docs and testdata
  • Loading branch information
DavidOrchard committed Sep 5, 2024
commit 80b5f628f5af60b7152dcbc4f38ad7742800d30b
8 changes: 3 additions & 5 deletions core/config/capabilities_config.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package config

import (
"math/big"

"github.com/smartcontractkit/chainlink-common/pkg/types"
)

Expand All @@ -15,20 +13,20 @@ type CapabilitiesExternalRegistry interface {

type GatewayConnectorConfig interface {
NodeAddress() string
DonId() string
DonID() string
Gateways() []ConnectorGatewayConfig
WsHandshakeTimeoutMillis() uint32
AuthMinChallengeLen() int
AuthTimestampToleranceSec() uint32
}

type ConnectorGatewayConfig interface {
Id() string
ID() string
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.

ChainIDForNodeKey() big.Int
ChainIDForNodeKey() string
GatewayConnectorConfig() GatewayConnectorConfig
}
type Capabilities interface {
Expand Down
22 changes: 22 additions & 0 deletions core/config/docs/core.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
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"

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.


[Capabilities.WorkflowConnectorConfig.GatewayConnectorConfig]
# 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"

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

AuthMinChallengeLen = 10 # Example
# AuthTimestampToleranceSec is Authentication timestamp tolerance
AuthTimestampToleranceSec = 10 # Example

[[Capabilities.WorkflowConnectorConfig.GatewayConnectorConfig.Gateways]]
# 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"


[Keeper]
# **ADVANCED**
# DefaultTransactionQueueDepth controls the queue size for `DropOldestStrategy` in Keeper. Set to 0 to use `SendEvery` strategy instead.
Expand Down
20 changes: 8 additions & 12 deletions core/config/toml/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import (
"regexp"
"strings"

"math/big"

"github.com/google/uuid"
"go.uber.org/multierr"
"go.uber.org/zap/zapcore"
Expand Down Expand Up @@ -1484,7 +1482,7 @@ func (drl *DispatcherRateLimit) setFrom(f *DispatcherRateLimit) {

type GatewayConnectorConfig struct {
NodeAddress *string
DonId *string
DonID *string
Gateways []ConnectorGatewayConfig
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

AuthMinChallengeLen *int
Expand All @@ -1496,8 +1494,8 @@ func (r *GatewayConnectorConfig) setFrom(f *GatewayConnectorConfig) {
r.NodeAddress = f.NodeAddress
}

if f.DonId != nil {
r.DonId = f.DonId
if f.DonID != nil {
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.

Expand All @@ -1519,22 +1517,20 @@ func (r *GatewayConnectorConfig) setFrom(f *GatewayConnectorConfig) {
}

type ConnectorGatewayConfig struct {
Id *string
ID *string
URL *string
}
type WorkflowConnectorConfig struct {
ChainIDForNodeKey *big.Int
GatewayConnectorConfig *GatewayConnectorConfig `json:"gatewayConnectorConfig"`
ChainIDForNodeKey *string
GatewayConnectorConfig GatewayConnectorConfig `json:"gatewayConnectorConfig"`
}

func (r *WorkflowConnectorConfig) setFrom(f *WorkflowConnectorConfig) {
if len(f.ChainIDForNodeKey.Bits()) != 0 {
if f.ChainIDForNodeKey != nil {
r.ChainIDForNodeKey = f.ChainIDForNodeKey
}

if !reflect.ValueOf(f.GatewayConnectorConfig).IsZero() {
r.GatewayConnectorConfig.setFrom(f.GatewayConnectorConfig)
}
r.GatewayConnectorConfig.setFrom(&f.GatewayConnectorConfig)
}

type Capabilities struct {
Expand Down
14 changes: 6 additions & 8 deletions core/services/chainlink/config_capabilities.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package chainlink

import (
"math/big"

"github.com/smartcontractkit/chainlink-common/pkg/types"
"github.com/smartcontractkit/chainlink/v2/core/config"
"github.com/smartcontractkit/chainlink/v2/core/config/toml"
Expand Down Expand Up @@ -94,13 +92,13 @@ type workflowConnectorConfig struct {
c toml.WorkflowConnectorConfig
}

func (c *workflowConnectorConfig) ChainIDForNodeKey() big.Int {
func (c *workflowConnectorConfig) ChainIDForNodeKey() string {
return *c.c.ChainIDForNodeKey
}

func (c *workflowConnectorConfig) GatewayConnectorConfig() config.GatewayConnectorConfig {
return &gatewayConnectorConfig{
c: *c.c.GatewayConnectorConfig,
c: c.c.GatewayConnectorConfig,
}
}

Expand All @@ -112,8 +110,8 @@ func (c *gatewayConnectorConfig) NodeAddress() string {
return *c.c.NodeAddress
}

func (c *gatewayConnectorConfig) DonId() string {
return *c.c.DonId
func (c *gatewayConnectorConfig) DonID() string {
return *c.c.DonID
}

func (c *gatewayConnectorConfig) Gateways() []config.ConnectorGatewayConfig {
Expand All @@ -140,8 +138,8 @@ type connectorGatewayConfig struct {
c toml.ConnectorGatewayConfig
}

func (c *connectorGatewayConfig) Id() string {
return *c.c.Id
func (c *connectorGatewayConfig) ID() string {
return *c.c.ID
}

func (c *connectorGatewayConfig) URL() string {
Expand Down
14 changes: 14 additions & 0 deletions core/services/chainlink/testdata/config-empty-effective.toml
Original file line number Diff line number Diff line change
Expand Up @@ -267,3 +267,17 @@ PerSenderBurst = 50
Address = ''
NetworkID = 'evm'
ChainID = '1'

[Capabilities.WorkflowConnectorConfig]
ChainIDForNodeKey = ''

[Capabilities.WorkflowConnectorConfig.GatewayConnectorConfig]
NodeAddress = ''
DonID = ''
WsHandshakeTimeoutMillis = 0
AuthMinChallengeLen = 0
AuthTimestampToleranceSec = 0

[[Capabilities.WorkflowConnectorConfig.GatewayConnectorConfig.Gateways]]
ID = ''
URL = ''
14 changes: 14 additions & 0 deletions core/services/chainlink/testdata/config-full.toml
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,20 @@ Address = ''
NetworkID = 'evm'
ChainID = '1'

[Capabilities.WorkflowConnectorConfig]
ChainIDForNodeKey = ''

[Capabilities.WorkflowConnectorConfig.GatewayConnectorConfig]
NodeAddress = ''
DonID = ''
WsHandshakeTimeoutMillis = 0
AuthMinChallengeLen = 0
AuthTimestampToleranceSec = 0

[[Capabilities.WorkflowConnectorConfig.GatewayConnectorConfig.Gateways]]
ID = ''
URL = ''

[[EVM]]
ChainID = '1'
Enabled = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,20 @@ Address = ''
NetworkID = 'evm'
ChainID = '1'

[Capabilities.WorkflowConnectorConfig]
ChainIDForNodeKey = ''

[Capabilities.WorkflowConnectorConfig.GatewayConnectorConfig]
NodeAddress = ''
DonID = ''
WsHandshakeTimeoutMillis = 0
AuthMinChallengeLen = 0
AuthTimestampToleranceSec = 0

[[Capabilities.WorkflowConnectorConfig.GatewayConnectorConfig.Gateways]]
ID = ''
URL = ''

[[EVM]]
ChainID = '1'
AutoCreateKey = true
Expand Down
14 changes: 14 additions & 0 deletions core/web/resolver/testdata/config-empty-effective.toml
Original file line number Diff line number Diff line change
Expand Up @@ -267,3 +267,17 @@ PerSenderBurst = 50
Address = ''
NetworkID = 'evm'
ChainID = '1'

[Capabilities.WorkflowConnectorConfig]
ChainIDForNodeKey = ''

[Capabilities.WorkflowConnectorConfig.GatewayConnectorConfig]
NodeAddress = ''
DonID = ''
WsHandshakeTimeoutMillis = 0
AuthMinChallengeLen = 0
AuthTimestampToleranceSec = 0

[[Capabilities.WorkflowConnectorConfig.GatewayConnectorConfig.Gateways]]
ID = ''
URL = ''
14 changes: 14 additions & 0 deletions core/web/resolver/testdata/config-full.toml
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,20 @@ Address = ''
NetworkID = 'evm'
ChainID = '1'

[Capabilities.WorkflowConnectorConfig]
ChainIDForNodeKey = ''

[Capabilities.WorkflowConnectorConfig.GatewayConnectorConfig]
NodeAddress = ''
DonID = ''
WsHandshakeTimeoutMillis = 0
AuthMinChallengeLen = 0
AuthTimestampToleranceSec = 0

[[Capabilities.WorkflowConnectorConfig.GatewayConnectorConfig.Gateways]]
ID = ''
URL = ''

[[EVM]]
ChainID = '1'
Enabled = false
Expand Down
14 changes: 14 additions & 0 deletions core/web/resolver/testdata/config-multi-chain-effective.toml
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,20 @@ Address = ''
NetworkID = 'evm'
ChainID = '1'

[Capabilities.WorkflowConnectorConfig]
ChainIDForNodeKey = ''

[Capabilities.WorkflowConnectorConfig.GatewayConnectorConfig]
NodeAddress = ''
DonID = ''
WsHandshakeTimeoutMillis = 0
AuthMinChallengeLen = 0
AuthTimestampToleranceSec = 0

[[Capabilities.WorkflowConnectorConfig.GatewayConnectorConfig.Gateways]]
ID = ''
URL = ''

[[EVM]]
ChainID = '1'
AutoCreateKey = true
Expand Down
74 changes: 74 additions & 0 deletions docs/CONFIG.md
Original file line number Diff line number Diff line change
Expand Up @@ -1393,6 +1393,80 @@ 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.WorkflowConnectorConfig
```toml
[Capabilities.WorkflowConnectorConfig]
ChainIDForNodeKey = '1' # Example
```


### ChainIDForNodeKey
```toml
ChainIDForNodeKey = '1' # Example
```
ChainIDForNodeKey is the ChainID of the network

## Capabilities.WorkflowConnectorConfig.GatewayConnectorConfig
```toml
[Capabilities.WorkflowConnectorConfig.GatewayConnectorConfig]
NodeAddress = '0x68902d681c28119f9b2531473a417088bf008e59' # Example
DonID = 'example_don' # Example
WsHandshakeTimeoutMillis = 1000 # Example
AuthMinChallengeLen = 10 # Example
AuthTimestampToleranceSec = 10 # Example
```


### NodeAddress
```toml
NodeAddress = '0x68902d681c28119f9b2531473a417088bf008e59' # Example
```
NodeAddress is Workflow Node address

### DonID
```toml
DonID = 'example_don' # Example
```
DonID is the Id of the Don

### WsHandshakeTimeoutMillis
```toml
WsHandshakeTimeoutMillis = 1000 # Example
```
WsHandshakeTimeoutMillis is Websocket handshake timeout

### AuthMinChallengeLen
```toml
AuthMinChallengeLen = 10 # Example
```
AuthMinChallengeLen is the minimum number of bytes in Authentication

### AuthTimestampToleranceSec
```toml
AuthTimestampToleranceSec = 10 # Example
```
AuthTimestampToleranceSec is Authentication timestamp tolerance

## Capabilities.WorkflowConnectorConfig.GatewayConnectorConfig.Gateways
```toml
[[Capabilities.WorkflowConnectorConfig.GatewayConnectorConfig.Gateways]]
ID = 'example_gateway' # Example
URL = 'ws://localhost:8081/node' # Example
```


### ID
```toml
ID = 'example_gateway' # Example
```
ID of the Gateway

### URL
```toml
URL = 'ws://localhost:8081/node' # Example
```
URL of the Gateway

## Keeper
```toml
[Keeper]
Expand Down
2 changes: 1 addition & 1 deletion testdata/scripts/node/db/help.txtar
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.

Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ COMMANDS:

OPTIONS:
--help, -h show help


14 changes: 14 additions & 0 deletions testdata/scripts/node/validate/default.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,20 @@ Address = ''
NetworkID = 'evm'
ChainID = '1'

[Capabilities.WorkflowConnectorConfig]
ChainIDForNodeKey = ''

[Capabilities.WorkflowConnectorConfig.GatewayConnectorConfig]
NodeAddress = ''
DonID = ''
WsHandshakeTimeoutMillis = 0
AuthMinChallengeLen = 0
AuthTimestampToleranceSec = 0

[[Capabilities.WorkflowConnectorConfig.GatewayConnectorConfig.Gateways]]
ID = ''
URL = ''

Invalid configuration: invalid secrets: 2 errors:
- Database.URL: empty: must be provided and non-empty
- Password.Keystore: empty: must be provided and non-empty
Expand Down
Loading
Loading