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

support new heads polling over http rpc client #14373

Open
wants to merge 31 commits into
base: develop
Choose a base branch
from

Conversation

huangzhen1997
Copy link
Contributor

@huangzhen1997 huangzhen1997 commented Sep 9, 2024

Description

EVM RPCClient uses web sockets to provide users with nearly real-time access to new blocks. While WS provides better performance, its reliability is sometimes not sufficient. We should be able to use HTTP instead.

In this PR:

  • added a new flag NewHeadsPollInterval (>0 indicate the polling new head is enabled), it's done with a separate PR for better readability hopefully.
  • created a new handler for polling new head over http, and register the subscription in node lifecycle logic
  • if polling new head enabled we will not subscribe to new head over ws (eth_subscribe)

In another PR we make the ws url optional if Logbroadcaster is disabled.

Tickets:

BCFR-706

@huangzhen1997 huangzhen1997 changed the title add functions for newHead polling support new heads polling over http rpc client Sep 11, 2024
@huangzhen1997 huangzhen1997 marked this pull request as ready for review September 13, 2024 22:36
@huangzhen1997 huangzhen1997 requested review from a team as code owners September 13, 2024 22:37
.changeset/happy-feet-rhyme.md Outdated Show resolved Hide resolved
core/chains/evm/client/rpc_client.go Outdated Show resolved Hide resolved
core/web/router.go Outdated Show resolved Hide resolved
dhaidashenko
dhaidashenko previously approved these changes Sep 20, 2024
Copy link
Collaborator

@dhaidashenko dhaidashenko left a comment

Choose a reason for hiding this comment

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

Nice work. Feel free to ignore nit comments, unless there is need for additional changes

core/chains/evm/client/rpc_client.go Outdated Show resolved Hide resolved
if r.newHeadsPollInterval > 0 {
interval := r.newHeadsPollInterval
timeout := interval
poller, _ := commonclient.NewPoller[*evmtypes.Head](interval, r.latestBlock, timeout, r.rpcLog)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why copy r.newHeadsPollInterval twice? Not a big deal either way I guess, just wondering why not just:

poller, _ := commonclient.NewPoller[*evmtypes.Head](interval, r.latestBlock, interval, r.rpcLog)

or even:

poller, _ := commonclient.NewPoller[*evmtypes.Head](r.newHeadsPollInterval, r.latestBlock, r.newHeadsPollInterval, r.rpcLog)

?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It makes the line 499 more readable, so it's not looking like passing the same parameter twice. And it's more configurable if we decided to update the timeout value later. And it's consistent with the SubscribeToFinalizedHeads function

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.

3 participants