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

Merged

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

@dimriou dimriou added this pull request to the merge queue Sep 23, 2024
Merged via the queue into develop with commit 5acca37 Sep 23, 2024
137 of 138 checks passed
@dimriou dimriou deleted the BCFR-706/rpc-client-polling-implementation-of-head-subscriptions branch September 23, 2024 10:21
momentmaker added a commit that referenced this pull request Sep 24, 2024
…develop

* origin/develop: (233 commits)
  update Smoke Test TestAutomationBasic to load pre-deployed contracts if given (#14537)
  CCIP-2881  USDC Reader integration tests  (#14516)
  [TT-1624] link PR to solidity review issue (#14521)
  Fix skipped notification in E2E test workflow (#14538)
  Add regression testing for pruning bug (#14454)
  Bump owner dep (#14531)
  Fix state view (#14532)
  Deployment tooling (#14533)
  CCIP 3388 - add offramp generation (#14526)
  CCIP-3416 paginate token admin registry get all tokens call (#14514)
  Change Polygon zkEVM to use FeeHistory estimator (#14161)
  [TT-1747] fix core changeset (#14524)
  TT-1459 Use CTF actions from .github repo (#14522)
  [TT-1693] try more universal Solidity scripts (#14436)
  Remove unused workflow for e2e tests (#14520)
  BCI-3668 Optimise HeadTracker's memory usage (#14130)
  BCFR-888 LP support chains that have not reached finality yet (#14366)
  support new heads polling over http rpc client (#14373)
  Bump CTF (#14518)
  TT-1550 Migrate remaining E2E workflows to the reusable workflow (#14403)
  ...
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.

4 participants