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

WS URL can be optional when LogBroadcaster is disabled #14364

Merged
merged 55 commits into from
Oct 3, 2024

Conversation

huangzhen1997
Copy link
Contributor

@huangzhen1997 huangzhen1997 commented Sep 6, 2024

Description

WS URL can be optional (empty string) when LogBroadcaster is disabled. If WS URL was not provided, SubscribeFilterLogs should fail with an explicit error

Tickets:

BCFR-451

@huangzhen1997 huangzhen1997 marked this pull request as ready for review September 6, 2024 20:46
@huangzhen1997 huangzhen1997 requested review from a team as code owners September 6, 2024 20:46
@huangzhen1997 huangzhen1997 requested review from reductionista and dhaidashenko and removed request for a team September 6, 2024 20:46
core/chains/evm/config/toml/config.go Outdated Show resolved Hide resolved
@@ -20,7 +20,7 @@ func NewEvmClient(cfg evmconfig.NodePool, chainCfg commonclient.ChainConfig, cli
var sendonlys []commonclient.SendOnlyNode[*big.Int, RPCClient]
largePayloadRPCTimeout, defaultRPCTimeout := getRPCTimeouts(chainType)
for i, node := range nodes {
if node.SendOnly != nil && *node.SendOnly {
if node.WSURL == nil || (node.SendOnly != nil && *node.SendOnly) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A secondary or SendOnly node has limited functionality. It's only used to broadcast transactions (fire and forget), and we are not running health checks for it.
We should not change the type of the node. Instead, introduce changes to the RPC client.

Copy link
Contributor Author

@huangzhen1997 huangzhen1997 Sep 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moving the enforcement check to Dial() at rpc_client.go

}

if !hasPrimary {
err = multierr.Append(err, commonconfig.ErrMissing{Name: "Nodes",
Msg: "must have at least one primary node with WSURL"})
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Msg: "must have at least one primary node with WSURL"})
Msg: "must have at least one primary node"})


// if the node is a primary node, then the WS URL is required when LogBroadcaster is enabled
if logBroadcasterEnabled && (n.WSURL == nil || n.WSURL.IsZero()) {
err = multierr.Append(err, commonconfig.ErrMissing{Name: "Nodes", Msg: fmt.Sprintf("%vth node is a primary node and it's missing valid WSURL with LogBroadcaster is enabled", i)})
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
err = multierr.Append(err, commonconfig.ErrMissing{Name: "Nodes", Msg: fmt.Sprintf("%vth node is a primary node and it's missing valid WSURL with LogBroadcaster is enabled", i)})
err = multierr.Append(err, commonconfig.ErrMissing{Name: "Nodes", Msg: fmt.Sprintf("%vth primary node must have a valid WSURL when LogBroadcaster is enabled", i)})

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

%vth node instead of %vth primary node is more accurate. Or %vth node (primary)

if node.SendOnly != nil && *node.SendOnly {
rpc := NewRPCClient(lggr, empty, (*url.URL)(node.HTTPURL), *node.Name, int32(i), chainID,
rpc := NewRPCClient(lggr, ws, (*url.URL)(node.HTTPURL), *node.Name, int32(i), chainID,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
rpc := NewRPCClient(lggr, ws, (*url.URL)(node.HTTPURL), *node.Name, int32(i), chainID,
rpc := NewRPCClient(lggr, nil, (*url.URL)(node.HTTPURL), *node.Name, int32(i), chainID,

Previously, we always passed empty URLs for sendOnly RPC clients. To avoid unexpected behavior, we should pass nil instead of the URL specified in the config.
In theory, NOPs might have specified unreachable URL/empty URL, which we've previously ignored.
But with this change and changes from Dylans PR will start using it, which could cause issue.

jmank88
jmank88 previously approved these changes Sep 27, 2024
@dimriou dimriou added this pull request to the merge queue Oct 3, 2024
Merged via the queue into develop with commit 5d96be5 Oct 3, 2024
130 checks passed
@dimriou dimriou deleted the BCFR-451/make-ws-url-optional branch October 3, 2024 15:14
matYang pushed a commit to smartcontractkit/ccip that referenced this pull request Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants