Skip to content

Commit

Permalink
Fix RPC name override (#11813)
Browse files Browse the repository at this point in the history
* Fix rpc name override

* use configured name without additional checks

* multi-node metrics test

* Fix typo
  • Loading branch information
dhaidashenko authored Jan 22, 2024
1 parent b164040 commit 41f2497
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 4 deletions.
6 changes: 2 additions & 4 deletions core/chains/legacyevm/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -474,15 +474,13 @@ func newEthClientFromCfg(cfg evmconfig.NodePool, noNewHeadsThreshold time.Durati
var sendonlys []commonclient.SendOnlyNode[*big.Int, evmclient.RPCCLient]
for i, node := range nodes {
if node.SendOnly != nil && *node.SendOnly {
name := fmt.Sprintf("eth-sendonly-rpc-%d", i)
rpc := evmclient.NewRPCClient(lggr, empty, (*url.URL)(node.HTTPURL), name, int32(i), chainID,
rpc := evmclient.NewRPCClient(lggr, empty, (*url.URL)(node.HTTPURL), *node.Name, int32(i), chainID,
commonclient.Secondary)
sendonly := commonclient.NewSendOnlyNode[*big.Int, evmclient.RPCCLient](lggr, (url.URL)(*node.HTTPURL),
*node.Name, chainID, rpc)
sendonlys = append(sendonlys, sendonly)
} else {
name := fmt.Sprintf("eth-primary-rpc-%d", i)
rpc := evmclient.NewRPCClient(lggr, (url.URL)(*node.WSURL), (*url.URL)(node.HTTPURL), name, int32(i),
rpc := evmclient.NewRPCClient(lggr, (url.URL)(*node.WSURL), (*url.URL)(node.HTTPURL), *node.Name, int32(i),
chainID, commonclient.Primary)
primaryNode := commonclient.NewNode[*big.Int, *evmtypes.Head, evmclient.RPCCLient](cfg, noNewHeadsThreshold,
lggr, (url.URL)(*node.WSURL), (*url.URL)(node.HTTPURL), *node.Name, int32(i), chainID, *node.Order,
Expand Down
78 changes: 78 additions & 0 deletions testdata/scripts/metrics/multi-node.txtar
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# Check that metrics specified in the expected_metrics are present in /metrics response
# start node
exec sh -c 'eval "echo \"$(cat config.toml.tmpl)\" > config.toml"'
exec chainlink node -c config.toml start -p password -a creds &

# ensure node is up and running
env NODEURL=http://localhost:$PORT
exec curl --retry 10 --retry-max-time 60 --retry-connrefused $NODEURL


# Check
chmod 700 ./script.sh
exec sh -c './script.sh'

-- script.sh --

maxRetries=5
for retriesNum in $(seq 1 $maxRetries); do
passedAllChecks=true
curl $NODEURL/metrics > metrics.txt
while IFS= read -r expectedMetric; do
grep -q $expectedMetric metrics.txt && continue

if [[ $retriesNum -ge $maxRetries ]]; then
cat metrics.txt
echo "FAIL Expected metric $expectedMetric to be present in GET /metrics response"
exit 1
fi

echo "Metric $expectedMetric is not present in GET /metrics response - retrying after 5s"
passedAllChecks=false
sleep 5
break
done < expected_metrics.txt

$passedAllChecks && break
done

-- testdb.txt --
CL_DATABASE_URL
-- testport.txt --
PORT

-- password --
T.tLHkcmwePT/p,]sYuntjwHKAsrhm#4eRs4LuKHwvHejWYAC2JP4M8HimwgmbaZ
-- creds --
[email protected]
fj293fbBnlQ!f9vNs

-- config.toml.tmpl --
[Webserver]
HTTPPort = $PORT

[[EVM]]
ChainID = '68472'

[[EVM.Nodes]]
Name = 'BlueEVMPrimaryNode'
WSURL = 'wss://primaryfoo.bar/ws'
HTTPURL = 'https://primaryfoo.bar'

[[EVM.Nodes]]
Name = 'YellowEVMPrimaryNode'
WSURL = 'wss://sendonlyfoo.bar/ws'
HTTPURL = 'https://sendonlyfoo.bar'
SendOnly = true

-- expected_metrics.txt --
evm_pool_rpc_node_dials_total{evmChainID="68472",nodeName="BlueEVMPrimaryNode"}
evm_pool_rpc_node_dials_total{evmChainID="68472",nodeName="YellowEVMPrimaryNode"}
multi_node_states{chainId="68472",network="EVM",state="Alive"}
multi_node_states{chainId="68472",network="EVM",state="Closed"}
multi_node_states{chainId="68472",network="EVM",state="Dialed"}
multi_node_states{chainId="68472",network="EVM",state="InvalidChainID"}
multi_node_states{chainId="68472",network="EVM",state="OutOfSync"}
multi_node_states{chainId="68472",network="EVM",state="Undialed"}
multi_node_states{chainId="68472",network="EVM",state="Unreachable"}
multi_node_states{chainId="68472",network="EVM",state="Unusable"}

0 comments on commit 41f2497

Please sign in to comment.