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
PR comments: add chainid and collapse workflowconnectorconfig
  • Loading branch information
DavidOrchard committed Sep 5, 2024
commit 518b8583e0d9ce36d03a48fd7c2d8c9481461be2
7 changes: 2 additions & 5 deletions core/config/capabilities_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ type CapabilitiesExternalRegistry interface {
}

type GatewayConnectorConfig interface {
ChainIDForNodeKey() string
NodeAddress() string
DonID() string
Gateways() []ConnectorGatewayConfig
Expand All @@ -25,13 +26,9 @@ type ConnectorGatewayConfig interface {
URL() string
}

type WorkflowConnectorConfig interface {
ChainIDForNodeKey() string
GatewayConnectorConfig() GatewayConnectorConfig
}
type Capabilities interface {
Peering() P2P
Dispatcher() Dispatcher
ExternalRegistry() CapabilitiesExternalRegistry
WorkflowConnectorConfig() WorkflowConnectorConfig
GatewayConnectorConfig() GatewayConnectorConfig
}
8 changes: 3 additions & 5 deletions core/config/docs/core.toml
Original file line number Diff line number Diff line change
Expand Up @@ -509,11 +509,9 @@ 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]
[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"

ChainIDForNodeKey = '1' # Example

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

# 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
Expand All @@ -525,7 +523,7 @@ AuthMinChallengeLen = 10 # Example
# AuthTimestampToleranceSec is Authentication timestamp tolerance
AuthTimestampToleranceSec = 10 # Example

[[Capabilities.WorkflowConnectorConfig.GatewayConnectorConfig.Gateways]]
[[Capabilities.GatewayConnectorConfig.Gateways]]
# ID of the Gateway
ID = 'example_gateway' # Example
# URL of the Gateway
Expand Down
27 changes: 10 additions & 17 deletions core/config/toml/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -1481,6 +1481,7 @@ func (drl *DispatcherRateLimit) setFrom(f *DispatcherRateLimit) {
}

type GatewayConnectorConfig struct {
ChainIDForNodeKey *string
NodeAddress *string
DonID *string
Gateways []ConnectorGatewayConfig
Expand All @@ -1490,6 +1491,10 @@ type GatewayConnectorConfig struct {
}

func (r *GatewayConnectorConfig) setFrom(f *GatewayConnectorConfig) {
if f.ChainIDForNodeKey != nil {
r.ChainIDForNodeKey = f.ChainIDForNodeKey
}

if f.NodeAddress != nil {
r.NodeAddress = f.NodeAddress
}
Expand Down Expand Up @@ -1520,31 +1525,19 @@ type ConnectorGatewayConfig struct {
ID *string
URL *string
}
type WorkflowConnectorConfig struct {
ChainIDForNodeKey *string
GatewayConnectorConfig GatewayConnectorConfig `json:"gatewayConnectorConfig"`
}

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

r.GatewayConnectorConfig.setFrom(&f.GatewayConnectorConfig)
}

type Capabilities struct {
Peering P2P `toml:",omitempty"`
Dispatcher Dispatcher `toml:",omitempty"`
ExternalRegistry ExternalRegistry `toml:",omitempty"`
WorkflowConnectorConfig WorkflowConnectorConfig `toml:", omitempty"`
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"

}

func (c *Capabilities) setFrom(f *Capabilities) {
c.Peering.setFrom(&f.Peering)
c.ExternalRegistry.setFrom(&f.ExternalRegistry)
c.Dispatcher.setFrom(&f.Dispatcher)
c.WorkflowConnectorConfig.setFrom(&f.WorkflowConnectorConfig)
c.GatewayConnectorConfig.setFrom(&f.GatewayConnectorConfig)
}

type ThresholdKeyShareSecrets struct {
Expand Down
23 changes: 6 additions & 17 deletions core/services/chainlink/config_capabilities.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ func (r *dispatcherRateLimit) PerSenderBurst() int {
return *r.r.PerSenderBurst
}

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

Expand All @@ -88,24 +88,13 @@ func (c *capabilitiesExternalRegistry) Address() string {
return *c.c.Address
}

type workflowConnectorConfig struct {
c toml.WorkflowConnectorConfig
}

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

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

type gatewayConnectorConfig struct {
c toml.GatewayConnectorConfig
}

func (c *gatewayConnectorConfig) ChainIDForNodeKey() string {
return *c.c.ChainIDForNodeKey
}
func (c *gatewayConnectorConfig) NodeAddress() string {
return *c.c.NodeAddress
}
Expand Down
11 changes: 11 additions & 0 deletions core/services/chainlink/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,17 @@ func TestConfig_Marshal(t *testing.T) {
PerSenderBurst: ptr(50),
},
},
GatewayConnectorConfig: toml.GatewayConnectorConfig{
ChainIDForNodeKey: ptr("0xfd29Dd9C980D715a64dace97F7A2AB98bcaE0fed"),
NodeAddress: ptr(""),
DonID: ptr(""),
WsHandshakeTimeoutMillis: ptr[uint32](0),
AuthMinChallengeLen: ptr[int](0),
AuthTimestampToleranceSec: ptr[uint32](0),
Gateways: []toml.ConnectorGatewayConfig{
{ID: ptr(""), URL: ptr("")},
},
},
}
full.Keeper = toml.Keeper{
DefaultTransactionQueueDepth: ptr[uint32](17),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,16 +268,14 @@ Address = ''
NetworkID = 'evm'
ChainID = '1'

[Capabilities.WorkflowConnectorConfig]
ChainIDForNodeKey = ''

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

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

[Capabilities.WorkflowConnectorConfig]
ChainIDForNodeKey = ''

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

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,17 +268,15 @@ Address = ''
NetworkID = 'evm'
ChainID = '1'

[Capabilities.WorkflowConnectorConfig]
ChainIDForNodeKey = ''

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

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

Expand Down
8 changes: 3 additions & 5 deletions core/web/resolver/testdata/config-empty-effective.toml
Original file line number Diff line number Diff line change
Expand Up @@ -268,16 +268,14 @@ Address = ''
NetworkID = 'evm'
ChainID = '1'

[Capabilities.WorkflowConnectorConfig]
ChainIDForNodeKey = ''

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

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

[Capabilities.WorkflowConnectorConfig]
ChainIDForNodeKey = ''

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

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,17 +268,15 @@ Address = ''
NetworkID = 'evm'
ChainID = '1'

[Capabilities.WorkflowConnectorConfig]
ChainIDForNodeKey = ''

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

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

Expand Down
28 changes: 11 additions & 17 deletions docs/CONFIG.md
Original file line number Diff line number Diff line change
Expand Up @@ -1393,22 +1393,10 @@ 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
## Capabilities.GatewayConnectorConfig
```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]
[Capabilities.GatewayConnectorConfig]
ChainIDForNodeKey = '0xfd29Dd9C980D715a64dace97F7A2AB98bcaE0fed' # Default
NodeAddress = '0x68902d681c28119f9b2531473a417088bf008e59' # Example
DonID = 'example_don' # Example
WsHandshakeTimeoutMillis = 1000 # Example
Expand All @@ -1417,6 +1405,12 @@ AuthTimestampToleranceSec = 10 # Example
```


### ChainIDForNodeKey
```toml
ChainIDForNodeKey = '0xfd29Dd9C980D715a64dace97F7A2AB98bcaE0fed' # Default
```
ChainIDForNodeKey is the ChainID of the network

### NodeAddress
```toml
NodeAddress = '0x68902d681c28119f9b2531473a417088bf008e59' # Example
Expand Down Expand Up @@ -1447,9 +1441,9 @@ AuthTimestampToleranceSec = 10 # Example
```
AuthTimestampToleranceSec is Authentication timestamp tolerance

## Capabilities.WorkflowConnectorConfig.GatewayConnectorConfig.Gateways
## Capabilities.GatewayConnectorConfig.Gateways
```toml
[[Capabilities.WorkflowConnectorConfig.GatewayConnectorConfig.Gateways]]
[[Capabilities.GatewayConnectorConfig.Gateways]]
ID = 'example_gateway' # Example
URL = 'ws://localhost:8081/node' # Example
```
Expand Down
2 changes: 1 addition & 1 deletion main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

})
})
return nil
Expand Down
13 changes: 5 additions & 8 deletions 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 @@ -9,14 +9,11 @@ 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.

preparetest Reset database and load fixtures.
version Display the current database version.
status Display the current database migration status.
migrate Migrate the database to the latest version.
rollback Roll back the database to a previous <version>. Rolls back a single migration if no version specified.
create-migration Create a new migration.
delete-chain Commands for cleaning up chain specific db tables. WARNING: This will ERASE ALL chain specific data referred to by --type and --id options for the specified database, referred to by CL_DATABASE_URL env variable or by the Database.URL field in a secrets TOML config.
version Display the current database version.
status Display the current database migration status.
migrate Migrate the database to the latest version.
rollback Roll back the database to a previous <version>. Rolls back a single migration if no version specified.
delete-chain Commands for cleaning up chain specific db tables. WARNING: This will ERASE ALL chain specific data referred to by --type and --id options for the specified database, referred to by CL_DATABASE_URL env variable or by the Database.URL field in a secrets TOML config.

OPTIONS:
--help, -h show help
Expand Down
8 changes: 3 additions & 5 deletions testdata/scripts/node/validate/default.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -280,17 +280,15 @@ Address = ''
NetworkID = 'evm'
ChainID = '1'

[Capabilities.WorkflowConnectorConfig]
ChainIDForNodeKey = ''

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

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

Expand Down
Loading
Loading