Skip to content

Commit ade5b2c

Browse files
[Merge 5th Jan][CLD-910]: fix(JD): remove wsrpc config (#643)
WSRPC endpoint was never really needed for the JD client, yet we are providing it in the CLD side in the config and env var, we should remove it. Merge once code freeze end JIRA: https://smartcontract-it.atlassian.net/browse/CLD-910
1 parent 0688e4d commit ade5b2c

File tree

15 files changed

+31
-78
lines changed

15 files changed

+31
-78
lines changed

.changeset/true-carrots-heal.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
"chainlink-deployments-framework": minor
3+
---
4+
5+
fix(JD): remove WSRPC field from JDConfig
6+
7+
The WSRPC in JDConfig was never needed as it was never used. Only GRPC field is needed.
8+

engine/cld/config/env/config.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,7 @@ type JobDistributorAuth struct {
9898

9999
// JobDistributorEndpoints is the configuration for the URL endpoints for the Job Distributor.
100100
type JobDistributorEndpoints struct {
101-
WSRPC string `mapstructure:"wsrpc" yaml:"wsrpc"` // The WebSocket RPC URL for the Job Distributor. Used to connect Job Distributor to CL nodes.
102-
GRPC string `mapstructure:"grpc" yaml:"grpc"` // The gRPC URL for the Job Distributor. Used to interact with the Job Distributor API.
101+
GRPC string `mapstructure:"grpc" yaml:"grpc"` // The gRPC URL for the Job Distributor. Used to interact with the Job Distributor API.
103102
}
104103

105104
// OCRConfig is the configuration for the OCR.
@@ -232,7 +231,6 @@ var (
232231
"offchain.job_distributor.auth.aws_region": {"OFFCHAIN_JD_AUTH_AWS_REGION", "JD_AUTH_AWS_REGION"},
233232
"offchain.job_distributor.auth.username": {"OFFCHAIN_JD_AUTH_USERNAME", "JD_AUTH_USERNAME"},
234233
"offchain.job_distributor.auth.password": {"OFFCHAIN_JD_AUTH_PASSWORD", "JD_AUTH_PASSWORD"},
235-
"offchain.job_distributor.endpoints.wsrpc": {"OFFCHAIN_JD_ENDPOINTS_WSRPC", "JD_WS_RPC"},
236234
"offchain.job_distributor.endpoints.grpc": {"OFFCHAIN_JD_ENDPOINTS_GRPC", "JD_GRPC"},
237235
"offchain.ocr.x_signers": {"OFFCHAIN_OCR_X_SIGNERS", "OCR_X_SIGNERS"},
238236
"offchain.ocr.x_proposers": {"OFFCHAIN_OCR_X_PROPOSERS", "OCR_X_PROPOSERS"},

engine/cld/config/env/config_test.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,7 @@ var (
5252
Password: "password1",
5353
},
5454
Endpoints: JobDistributorEndpoints{
55-
WSRPC: "ws://localhost:1234",
56-
GRPC: "grpc://localhost:4567",
55+
GRPC: "grpc://localhost:4567",
5756
},
5857
},
5958
OCR: OCRConfig{
@@ -89,7 +88,6 @@ var (
8988
"OFFCHAIN_JD_AUTH_AWS_REGION": "us-east-1",
9089
"OFFCHAIN_JD_AUTH_USERNAME": "123",
9190
"OFFCHAIN_JD_AUTH_PASSWORD": "123",
92-
"OFFCHAIN_JD_ENDPOINTS_WSRPC": "WSRPC2",
9391
"OFFCHAIN_JD_ENDPOINTS_GRPC": "GRPC2",
9492
"OFFCHAIN_OCR_X_SIGNERS": "awkward bat",
9593
"OFFCHAIN_OCR_X_PROPOSERS": "caring deer",
@@ -114,7 +112,6 @@ var (
114112
"JD_AUTH_AWS_REGION": "us-east-1",
115113
"JD_AUTH_USERNAME": "123",
116114
"JD_AUTH_PASSWORD": "123",
117-
"JD_WS_RPC": "WSRPC2",
118115
"JD_GRPC": "GRPC2",
119116
"OCR_X_SIGNERS": "awkward bat",
120117
"OCR_X_PROPOSERS": "caring deer",
@@ -168,8 +165,7 @@ var (
168165
Password: "123",
169166
},
170167
Endpoints: JobDistributorEndpoints{
171-
WSRPC: "WSRPC2",
172-
GRPC: "GRPC2",
168+
GRPC: "GRPC2",
173169
},
174170
},
175171
OCR: OCRConfig{

engine/cld/config/env/testdata/config.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ onchain:
2525
offchain:
2626
job_distributor:
2727
endpoints:
28-
wsrpc: "ws://localhost:1234"
2928
grpc: "grpc://localhost:4567"
3029
auth:
3130
cognito_app_client_id: "af1a2b3c"

engine/cld/config/env/testdata/config_with_optional_values.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ onchain:
2020
offchain:
2121
job_distributor:
2222
endpoints:
23-
wsrpc: "ws://localhost:1234"
2423
grpc: "grpc://localhost:4567"
2524
ocr:
2625
x_signers: "rabid mouse"

engine/cld/config/env_test.go

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ func Test_LoadEnvConfig(t *testing.T) { //nolint:paralleltest // These tests are
4949
envvars: map[string]string{
5050
"CI": "true",
5151
"NEW_CONFIG_ENABLED": "true",
52-
"JD_WS_RPC": "ws://localhost:1234",
5352
"JD_GRPC": "grpc://localhost:4567",
5453
"JD_AUTH_COGNITO_APP_CLIENT_ID": "2b3caf1a",
5554
"JD_AUTH_COGNITO_APP_CLIENT_SECRET": "22222222",
@@ -74,7 +73,6 @@ func Test_LoadEnvConfig(t *testing.T) { //nolint:paralleltest // These tests are
7473
require.NotNil(t, cfg)
7574

7675
// Validate environment configuration
77-
assert.Equal(t, "ws://localhost:1234", cfg.Offchain.JobDistributor.Endpoints.WSRPC)
7876
assert.Equal(t, "grpc://localhost:4567", cfg.Offchain.JobDistributor.Endpoints.GRPC)
7977
assert.Equal(t, "2b3caf1a", cfg.Offchain.JobDistributor.Auth.CognitoAppClientID)
8078
assert.Equal(t, "22222222", cfg.Offchain.JobDistributor.Auth.CognitoAppClientSecret)
@@ -96,10 +94,9 @@ func Test_LoadEnvConfig(t *testing.T) { //nolint:paralleltest // These tests are
9694
{
9795
name: "Load config with new config enabled (loads from env vars)",
9896
envvars: map[string]string{
99-
"CI": "true",
100-
"OFFCHAIN_JD_ENDPOINTS_WSRPC": "ws://localhost:1234",
101-
"OFFCHAIN_JD_ENDPOINTS_GRPC": "grpc://localhost:4567",
102-
"OFFCHAIN_JD_AUTH_COGNITO_APP_CLIENT_ID": "2b3caf1a",
97+
"CI": "true",
98+
"OFFCHAIN_JD_ENDPOINTS_GRPC": "grpc://localhost:4567",
99+
"OFFCHAIN_JD_AUTH_COGNITO_APP_CLIENT_ID": "2b3caf1a",
103100
"OFFCHAIN_JD_AUTH_COGNITO_APP_CLIENT_SECRET": "22222222",
104101
"OFFCHAIN_JD_AUTH_AWS_REGION": "us-east-1",
105102
"OFFCHAIN_JD_AUTH_USERNAME": "testuser2",
@@ -128,7 +125,6 @@ func Test_LoadEnvConfig(t *testing.T) { //nolint:paralleltest // These tests are
128125
require.NotNil(t, cfg)
129126

130127
// Validate environment configuration
131-
assert.Equal(t, "ws://localhost:1234", cfg.Offchain.JobDistributor.Endpoints.WSRPC)
132128
assert.Equal(t, "grpc://localhost:4567", cfg.Offchain.JobDistributor.Endpoints.GRPC)
133129
assert.Equal(t, "2b3caf1a", cfg.Offchain.JobDistributor.Auth.CognitoAppClientID)
134130
assert.Equal(t, "22222222", cfg.Offchain.JobDistributor.Auth.CognitoAppClientSecret)

engine/cld/environment/environment_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,8 @@ func Test_Load_LoadOffchainClientFailure(t *testing.T) { //nolint:paralleltest /
5959
// In CI mode, config is loaded from environment variables instead of files.
6060
// We manually set the required env vars for this test and clean up afterward.
6161
if os.Getenv("CI") == "true" {
62-
os.Setenv("OFFCHAIN_JD_ENDPOINTS_WSRPC", "ws://localhost:8080")
6362
os.Setenv("OFFCHAIN_JD_ENDPOINTS_GRPC", "localhost:9090")
6463
t.Cleanup(func() {
65-
os.Unsetenv("OFFCHAIN_JD_ENDPOINTS_WSRPC")
6664
os.Unsetenv("OFFCHAIN_JD_ENDPOINTS_GRPC")
6765
})
6866
}

engine/cld/offchain/offchain.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ import (
1919
fjdprov "github.com/smartcontractkit/chainlink-deployments-framework/offchain/jd/provider"
2020
)
2121

22-
// ErrEndpointsRequired is returned during loading of the offchain client when both gRPC and wsRPC
23-
// endpoints are required.
24-
var ErrEndpointsRequired = errors.New("both gRPC and wsRPC endpoints are required")
22+
// ErrEndpointsRequired is returned during loading of the offchain client when gRPC endpoint is
23+
// required.
24+
var ErrEndpointsRequired = errors.New("gRPC endpoint is required")
2525

2626
// loadConfig contains the configuration for loading an offchain client.
2727
type loadConfig struct {
@@ -123,13 +123,13 @@ func LoadOffchainClient(
123123
)
124124

125125
// TODO: Remove this domain specific check
126-
if dom.Key() == "keystone" && endpoints.WSRPC == "" {
126+
if dom.Key() == "keystone" && endpoints.GRPC == "" {
127127
lggr.Warn("Skipping JD initialization for Keystone, fallback to CLO data")
128128

129129
return nil, nil //nolint:nilnil // We want to return nil if the JD is not initialized for now.
130130
}
131131

132-
if endpoints.WSRPC == "" || endpoints.GRPC == "" {
132+
if endpoints.GRPC == "" {
133133
return nil, ErrEndpointsRequired
134134
}
135135

@@ -162,7 +162,6 @@ func LoadOffchainClient(
162162
} else {
163163
provider = fjdprov.NewClientOffchainProvider(fjdprov.ClientOffchainProviderConfig{
164164
GRPC: endpoints.GRPC,
165-
WSRPC: endpoints.WSRPC,
166165
Creds: loadCfg.creds,
167166
Auth: oauth,
168167
}, provOpts...)

engine/cld/offchain/offchain_test.go

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,7 @@ func TestLoadOffchainClient(t *testing.T) {
114114
testDomain = domain.NewDomain("/tmp", "test")
115115
keystoneDomain = domain.NewDomain("/tmp", "keystone")
116116
endpoints = cfgenv.JobDistributorEndpoints{
117-
WSRPC: "ws://localhost:8080",
118-
GRPC: "localhost:9090",
117+
GRPC: "localhost:9090",
119118
}
120119
)
121120

@@ -188,45 +187,30 @@ func TestLoadOffchainClient(t *testing.T) {
188187
domain: testDomain,
189188
cfg: cfgenv.JobDistributorConfig{
190189
Endpoints: cfgenv.JobDistributorEndpoints{
191-
WSRPC: "ws://localhost:8080",
192-
GRPC: "localhost:9090",
190+
GRPC: "localhost:9090",
193191
},
194192
},
195193
opts: []LoadOffchainClientOpt{
196194
WithDryRun(true),
197195
},
198196
},
199-
{
200-
name: "missing WSRPC endpoint",
201-
domain: testDomain,
202-
cfg: cfgenv.JobDistributorConfig{
203-
Endpoints: cfgenv.JobDistributorEndpoints{
204-
WSRPC: "", // Missing
205-
GRPC: "localhost:9090",
206-
},
207-
},
208-
opts: []LoadOffchainClientOpt{},
209-
wantErr: "both gRPC and wsRPC endpoints are required",
210-
},
211197
{
212198
name: "missing GRPC endpoint",
213199
domain: testDomain,
214200
cfg: cfgenv.JobDistributorConfig{
215201
Endpoints: cfgenv.JobDistributorEndpoints{
216-
WSRPC: "ws://localhost:8080",
217-
GRPC: "", // Missing
202+
GRPC: "", // Missing
218203
},
219204
},
220205
opts: []LoadOffchainClientOpt{},
221-
wantErr: "both gRPC and wsRPC endpoints are required",
206+
wantErr: "gRPC endpoint is required",
222207
},
223208
{
224-
name: "keystone domain with missing WSRPC",
209+
name: "keystone domain with missing GRPC",
225210
domain: keystoneDomain,
226211
cfg: cfgenv.JobDistributorConfig{
227212
Endpoints: cfgenv.JobDistributorEndpoints{
228-
WSRPC: "", // Missing for keystone
229-
GRPC: "localhost:9090",
213+
GRPC: "", // Missing for keystone
230214
},
231215
},
232216
opts: []LoadOffchainClientOpt{},

offchain/jd/client.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import (
1717
// JDConfig is the configuration for the Job Distributor client.
1818
type JDConfig struct {
1919
GRPC string
20-
WSRPC string
2120
Creds credentials.TransportCredentials
2221
Auth oauth2.TokenSource
2322
}
@@ -27,8 +26,6 @@ type JobDistributor struct {
2726
nodev1.NodeServiceClient
2827
jobv1.JobServiceClient
2928
csav1.CSAServiceClient
30-
31-
WSRPC string
3229
}
3330

3431
// NewJDClient creates a new Job Distributor client
@@ -38,7 +35,6 @@ func NewJDClient(cfg JDConfig) (*JobDistributor, error) {
3835
return nil, fmt.Errorf("failed to connect Job Distributor service. Err: %w", err)
3936
}
4037
jd := &JobDistributor{
41-
WSRPC: cfg.WSRPC,
4238
NodeServiceClient: nodev1.NewNodeServiceClient(conn),
4339
JobServiceClient: jobv1.NewJobServiceClient(conn),
4440
CSAServiceClient: csav1.NewCSAServiceClient(conn),

0 commit comments

Comments
 (0)