Skip to content

Commit faa8cc2

Browse files
committed
Merge branch 'main' into update-maturity-model
2 parents d8c095c + ed6103e commit faa8cc2

File tree

16 files changed

+1043
-85
lines changed

16 files changed

+1043
-85
lines changed

lib/.changeset/v1.50.14.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
- Update deps
2+
- Allows Seth to run with only HTTP but defaults to WS when available
3+
- Allows Network to initialize with only HTTP
4+
- Adjust RPC url validation to accept only HTTP or WS + HTTP only.

lib/config/network.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -141,13 +141,18 @@ func (n *NetworkConfig) Validate() error {
141141
continue
142142
}
143143
}
144-
// if the network is not forked, we need to validate RPC endpoints and private keys
145-
if _, ok := n.RpcHttpUrls[network]; !ok {
146-
return fmt.Errorf("at least one HTTP RPC endpoint for %s network must be set", network)
144+
145+
// If the network is not forked, we need to validate RPC endpoints and private keys
146+
_, httpOk := n.RpcHttpUrls[network]
147+
_, wsOk := n.RpcWsUrls[network]
148+
// WS can be present but only if HTTP is also available
149+
if wsOk && !httpOk {
150+
return fmt.Errorf("WS RPC endpoint for %s network is set without an HTTP endpoint; only HTTP or both HTTP and WS are allowed", network)
147151
}
148152

149-
if _, ok := n.RpcWsUrls[network]; !ok {
150-
return fmt.Errorf("at least one WS RPC endpoint for %s network must be set", network)
153+
// Validate that there is at least one HTTP endpoint
154+
if !httpOk {
155+
return fmt.Errorf("at least one HTTP RPC endpoint for %s network must be set", network)
151156
}
152157

153158
if _, ok := n.WalletKeys[network]; !ok {

lib/config/testconfig_test.go

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@ package config
22

33
import (
44
"errors"
5+
"fmt"
56
"os"
67
"reflect"
78
"testing"
89

10+
"github.com/stretchr/testify/require"
11+
912
"github.com/smartcontractkit/chainlink-testing-framework/lib/utils/ptr"
1013
)
1114

@@ -123,3 +126,106 @@ func TestReadConfigValuesFromEnvVars(t *testing.T) {
123126
func newString(s string) *string {
124127
return &s
125128
}
129+
130+
func TestValidateNetworkConfig(t *testing.T) {
131+
testCases := []struct {
132+
name string
133+
networkConfig NetworkConfig
134+
expectedError error
135+
}{
136+
{
137+
name: "Valid configuration with HTTP and WS URLs",
138+
networkConfig: NetworkConfig{
139+
SelectedNetworks: []string{"MAINNET"},
140+
RpcHttpUrls: map[string][]string{
141+
"MAINNET": {"http://localhost:8545"},
142+
},
143+
RpcWsUrls: map[string][]string{
144+
"MAINNET": {"ws://localhost:8546"},
145+
},
146+
WalletKeys: map[string][]string{
147+
"MAINNET": {"0xPrivateKey"},
148+
},
149+
},
150+
expectedError: nil,
151+
},
152+
{
153+
name: "Valid configuration with only HTTP URL",
154+
networkConfig: NetworkConfig{
155+
SelectedNetworks: []string{"MAINNET"},
156+
RpcHttpUrls: map[string][]string{
157+
"MAINNET": {"http://localhost:8545"},
158+
},
159+
WalletKeys: map[string][]string{
160+
"MAINNET": {"0xPrivateKey"},
161+
},
162+
},
163+
expectedError: nil,
164+
},
165+
{
166+
name: "Invalid configuration with only WS URL",
167+
networkConfig: NetworkConfig{
168+
SelectedNetworks: []string{"MAINNET"},
169+
RpcWsUrls: map[string][]string{
170+
"MAINNET": {"ws://localhost:8546"},
171+
},
172+
WalletKeys: map[string][]string{
173+
"MAINNET": {"0xPrivateKey"},
174+
},
175+
},
176+
expectedError: fmt.Errorf("WS RPC endpoint for MAINNET network is set without an HTTP endpoint; only HTTP or both HTTP and WS are allowed"),
177+
},
178+
{
179+
name: "Invalid configuration without HTTP or WS URLs",
180+
networkConfig: NetworkConfig{
181+
SelectedNetworks: []string{"MAINNET"},
182+
WalletKeys: map[string][]string{
183+
"MAINNET": {"0xPrivateKey"},
184+
},
185+
},
186+
expectedError: fmt.Errorf("at least one HTTP RPC endpoint for MAINNET network must be set"),
187+
},
188+
{
189+
name: "Valid simulated network without RPC URLs",
190+
networkConfig: NetworkConfig{
191+
SelectedNetworks: []string{"SIMULATED"},
192+
},
193+
expectedError: nil,
194+
},
195+
{
196+
name: "Valid forked network (Anvil) without RPC URLs",
197+
networkConfig: NetworkConfig{
198+
SelectedNetworks: []string{"MAINNET"},
199+
AnvilConfigs: map[string]*AnvilConfig{
200+
"MAINNET": {URL: ptr.Ptr("http://forked-node-url")},
201+
},
202+
},
203+
expectedError: nil,
204+
},
205+
{
206+
name: "Missing private key",
207+
networkConfig: NetworkConfig{
208+
SelectedNetworks: []string{"MAINNET"},
209+
RpcHttpUrls: map[string][]string{
210+
"MAINNET": {"http://localhost:8545"},
211+
},
212+
RpcWsUrls: map[string][]string{
213+
"MAINNET": {"ws://localhost:8546"},
214+
},
215+
},
216+
expectedError: fmt.Errorf("at least one private key of funding wallet for MAINNET network must be set"),
217+
},
218+
}
219+
220+
for _, tc := range testCases {
221+
tc := tc // capture range variable
222+
t.Run(tc.name, func(t *testing.T) {
223+
err := tc.networkConfig.Validate()
224+
if tc.expectedError != nil {
225+
require.EqualError(t, err, tc.expectedError.Error())
226+
} else {
227+
require.NoError(t, err)
228+
}
229+
})
230+
}
231+
}

lib/go.mod

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ require (
3232
github.com/prometheus/common v0.60.0
3333
github.com/rs/zerolog v1.33.0
3434
github.com/slack-go/slack v0.15.0
35-
github.com/smartcontractkit/chainlink-testing-framework/seth v1.50.4
35+
github.com/smartcontractkit/chainlink-testing-framework/seth v1.50.9
3636
github.com/smartcontractkit/chainlink-testing-framework/wasp v1.50.1
3737
github.com/spf13/cobra v1.8.1
3838
github.com/spf13/pflag v1.0.5
@@ -191,7 +191,7 @@ require (
191191
github.com/hashicorp/memberlist v0.5.0 // indirect
192192
github.com/hashicorp/serf v0.10.1 // indirect
193193
github.com/holiman/bloomfilter/v2 v2.0.3 // indirect
194-
github.com/holiman/uint256 v1.2.4 // indirect
194+
github.com/holiman/uint256 v1.3.1 // indirect
195195
github.com/huandu/xstrings v1.3.3 // indirect
196196
github.com/inconshreveable/mousetrap v1.1.0 // indirect
197197
github.com/jmespath/go-jmespath v0.4.0 // indirect
@@ -292,7 +292,7 @@ require (
292292
go.starlark.net v0.0.0-20230525235612-a134d8f9ddca // indirect
293293
go.uber.org/goleak v1.3.0 // indirect
294294
go.uber.org/multierr v1.11.0 // indirect
295-
go.uber.org/ratelimit v0.3.0 // indirect
295+
go.uber.org/ratelimit v0.3.1 // indirect
296296
go4.org/netipx v0.0.0-20230125063823-8449b0a6169f // indirect
297297
golang.org/x/arch v0.4.0 // indirect
298298
golang.org/x/crypto v0.28.0 // indirect

lib/go.sum

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -256,8 +256,9 @@ github.com/cpuguy83/dockercfg v0.3.2 h1:DlJTyZGBDlXqUZ2Dk2Q3xHs/FtnooJJVaad2S9GK
256256
github.com/cpuguy83/dockercfg v0.3.2/go.mod h1:sugsbF4//dDlL/i+S+rtpIWp+5h0BHJHfjj5/jFyUJc=
257257
github.com/cpuguy83/go-md2man v1.0.10 h1:BSKMNlYxDvnunlTymqtgONjNnaRV1sTpcovwwjF22jk=
258258
github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE=
259-
github.com/cpuguy83/go-md2man/v2 v2.0.4 h1:wfIWP927BUkWJb2NmU/kNDYIBTh/ziUX91+lVfRxZq4=
260259
github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
260+
github.com/cpuguy83/go-md2man/v2 v2.0.5 h1:ZtcqGrnekaHpVLArFSe4HK5DoKx1T0rq2DwVB0alcyc=
261+
github.com/cpuguy83/go-md2man/v2 v2.0.5/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
261262
github.com/crate-crypto/go-ipa v0.0.0-20231025140028-3c0104f4b233 h1:d28BXYi+wUpz1KBmiF9bWrjEMacUEREV6MBi2ODnrfQ=
262263
github.com/crate-crypto/go-ipa v0.0.0-20231025140028-3c0104f4b233/go.mod h1:geZJZH3SzKCqnz5VT0q/DyIG/tvu/dZk+VIfXicupJs=
263264
github.com/crate-crypto/go-kzg-4844 v0.7.0 h1:C0vgZRk4q4EZ/JgPfzuSoxdCq3C3mOZMBShovmncxvA=
@@ -678,8 +679,8 @@ github.com/holiman/billy v0.0.0-20230718173358-1c7e68d277a7 h1:3JQNjnMRil1yD0IfZ
678679
github.com/holiman/billy v0.0.0-20230718173358-1c7e68d277a7/go.mod h1:5GuXa7vkL8u9FkFuWdVvfR5ix8hRB7DbOAaYULamFpc=
679680
github.com/holiman/bloomfilter/v2 v2.0.3 h1:73e0e/V0tCydx14a0SCYS/EWCxgwLZ18CZcZKVu0fao=
680681
github.com/holiman/bloomfilter/v2 v2.0.3/go.mod h1:zpoh+gs7qcpqrHr3dB55AMiJwo0iURXE7ZOP9L9hSkA=
681-
github.com/holiman/uint256 v1.2.4 h1:jUc4Nk8fm9jZabQuqr2JzednajVmBpC+oiTiXZJEApU=
682-
github.com/holiman/uint256 v1.2.4/go.mod h1:EOMSn4q6Nyt9P6efbI3bueV4e1b3dGlUCXeiRV4ng7E=
682+
github.com/holiman/uint256 v1.3.1 h1:JfTzmih28bittyHM8z360dCjIA9dbPIBlcTI6lmctQs=
683+
github.com/holiman/uint256 v1.3.1/go.mod h1:EOMSn4q6Nyt9P6efbI3bueV4e1b3dGlUCXeiRV4ng7E=
683684
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
684685
github.com/huandu/xstrings v1.3.3 h1:/Gcsuc1x8JVbJ9/rlye4xZnVAbEkGauT8lbebqcQws4=
685686
github.com/huandu/xstrings v1.3.3/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE=
@@ -1051,8 +1052,8 @@ github.com/slack-go/slack v0.15.0 h1:LE2lj2y9vqqiOf+qIIy0GvEoxgF1N5yLGZffmEZykt0
10511052
github.com/slack-go/slack v0.15.0/go.mod h1:hlGi5oXA+Gt+yWTPP0plCdRKmjsDxecdHxYQdlMQKOw=
10521053
github.com/smartcontractkit/chainlink-testing-framework/lib/grafana v1.50.0 h1:VIxK8u0Jd0Q/VuhmsNm6Bls6Tb31H/sA3A/rbc5hnhg=
10531054
github.com/smartcontractkit/chainlink-testing-framework/lib/grafana v1.50.0/go.mod h1:lyAu+oMXdNUzEDScj2DXB2IueY+SDXPPfyl/kb63tMM=
1054-
github.com/smartcontractkit/chainlink-testing-framework/seth v1.50.4 h1:hPI9GhHE1RmIG1oyPeFjED0AhWnNb9JzD74Oq2bO+IQ=
1055-
github.com/smartcontractkit/chainlink-testing-framework/seth v1.50.4/go.mod h1:afY3QmNgeR/VI1pRbGH8g3YXGy7C2RrFOwUzEFvL3L8=
1055+
github.com/smartcontractkit/chainlink-testing-framework/seth v1.50.9 h1:yB1x5UXvpZNka+5h57yo1/GrKfXKCqMzChCISpldZx4=
1056+
github.com/smartcontractkit/chainlink-testing-framework/seth v1.50.9/go.mod h1:lJk0atEJ5Zyo3Tqrmf1Pl9jUEe79EgDb9bD3K5OTUBI=
10561057
github.com/smartcontractkit/chainlink-testing-framework/wasp v1.50.1 h1:hbapxD2wjGJNkP9Re2LqzPDbejzRP25Yk5vKfuaHs6U=
10571058
github.com/smartcontractkit/chainlink-testing-framework/wasp v1.50.1/go.mod h1:tMdjHVfgp1QBLfVieSTGNR0kem8cOnH2bOXXXiaTwZ0=
10581059
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
@@ -1125,8 +1126,8 @@ github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljT
11251126
github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY=
11261127
github.com/ugorji/go/codec v1.2.11 h1:BMaWp1Bb6fHwEtbplGBGJ498wD+LKlNSl25MjdZY4dU=
11271128
github.com/ugorji/go/codec v1.2.11/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg=
1128-
github.com/urfave/cli/v2 v2.25.7 h1:VAzn5oq403l5pHjc4OhD54+XGO9cdKVL/7lDjF+iKUs=
1129-
github.com/urfave/cli/v2 v2.25.7/go.mod h1:8qnjx1vcq5s2/wpsqoZFndg2CE5tNFyrTvS6SinrnYQ=
1129+
github.com/urfave/cli/v2 v2.27.5 h1:WoHEJLdsXr6dDWoJgMq/CboDmyY/8HMMH1fTECbih+w=
1130+
github.com/urfave/cli/v2 v2.27.5/go.mod h1:3Sevf16NykTbInEnD0yKkjDAeZDS0A6bzhBH5hrMvTQ=
11301131
github.com/urfave/negroni v1.0.0/go.mod h1:Meg73S6kFm/4PpbYdq35yYWoCZ9mS/YSx+lKnmiohz4=
11311132
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
11321133
github.com/valyala/fasthttp v1.6.0/go.mod h1:FstJa9V+Pj9vQ7OJie2qMHdwemEDaDiSdBnvPM1Su9w=
@@ -1150,8 +1151,8 @@ github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQ
11501151
github.com/xlab/treeprint v1.2.0 h1:HzHnuAF1plUN2zGlAFHbSQP2qJ0ZAD3XF5XD7OesXRQ=
11511152
github.com/xlab/treeprint v1.2.0/go.mod h1:gj5Gd3gPdKtR1ikdDK6fnFLdmIS0X30kTTuNd/WEJu0=
11521153
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
1153-
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU=
1154-
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8=
1154+
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 h1:gEOO8jv9F4OT7lGCjxCBTO/36wtF6j2nSip77qHd4x4=
1155+
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1/go.mod h1:Ohn+xnUBiLI6FVj/9LpzZWtj1/D6lUovWYBkxHVV3aM=
11551156
github.com/yalp/jsonpath v0.0.0-20180802001716-5cc68e5049a0/go.mod h1:/LWChgwKmvncFJFHJ7Gvn9wZArjbV5/FppcK2fKk/tI=
11561157
github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d/go.mod h1:rHwXgn7JulP+udvsHwJoVG1YGAP6VLg4y9I5dyZdqmA=
11571158
github.com/yudai/gojsondiff v1.0.0/go.mod h1:AY32+k2cwILAkW1fbgxQ5mUmMiZFgLIV+FBNExI05xg=
@@ -1211,8 +1212,8 @@ go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
12111212
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
12121213
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
12131214
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
1214-
go.uber.org/ratelimit v0.3.0 h1:IdZd9wqvFXnvLvSEBo0KPcGfkoBGNkpTHlrE3Rcjkjw=
1215-
go.uber.org/ratelimit v0.3.0/go.mod h1:So5LG7CV1zWpY1sHe+DXTJqQvOx+FFPFaAs2SnoyBaI=
1215+
go.uber.org/ratelimit v0.3.1 h1:K4qVE+byfv/B3tC+4nYWP7v/6SimcO7HzHekoMNBma0=
1216+
go.uber.org/ratelimit v0.3.1/go.mod h1:6euWsTB6U/Nb3X++xEUXA8ciPJvr19Q/0h1+oDcJhRk=
12161217
go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8=
12171218
go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E=
12181219
go4.org/netipx v0.0.0-20230125063823-8449b0a6169f h1:ketMxHg+vWm3yccyYiq+uK8D3fRmna2Fcj+awpQp84s=

lib/networks/known_networks.go

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1101,17 +1101,23 @@ func SetNetworks(networkCfg config.NetworkConfig) ([]blockchain.EVMNetwork, erro
11011101
if networkCfg.AnvilConfigs != nil {
11021102
_, forked = networkCfg.AnvilConfigs[networkName]
11031103
}
1104+
11041105
// if network is not simulated or forked, use the rpc urls and wallet keys from config
11051106
if !strings.Contains(networkName, "SIMULATED") && !forked {
1106-
var ok bool
1107-
wsUrls, ok = networkCfg.RpcWsUrls[selectedNetworks[i]]
1108-
if !ok {
1109-
return nil, fmt.Errorf("no rpc ws urls found in config for '%s' network", selectedNetworks[i])
1107+
var ok, wsOk, httpOk bool
1108+
// Check for WS URLs
1109+
wsUrls, wsOk = networkCfg.RpcWsUrls[selectedNetworks[i]]
1110+
// Check for HTTP URLs
1111+
httpUrls, httpOk = networkCfg.RpcHttpUrls[selectedNetworks[i]]
1112+
1113+
// WS can be present but only if HTTP is also available, the CL node cannot function only on WS
1114+
if wsOk && !httpOk {
1115+
return nil, fmt.Errorf("WS RPC endpoint for %s network is set without an HTTP endpoint; only HTTP or both HTTP and WS are allowed", selectedNetworks[i])
11101116
}
11111117

1112-
httpUrls, ok = networkCfg.RpcHttpUrls[selectedNetworks[i]]
1113-
if !ok {
1114-
return nil, fmt.Errorf("no rpc http urls found in config for '%s' network", selectedNetworks[i])
1118+
// Validate that there is at least one HTTP endpoint
1119+
if !httpOk {
1120+
return nil, fmt.Errorf("at least one HTTP RPC endpoint for %s network must be set", selectedNetworks[i])
11151121
}
11161122

11171123
walletKeys, ok = networkCfg.WalletKeys[selectedNetworks[i]]

0 commit comments

Comments
 (0)