Skip to content

Custom branch for OPCraft#3688

Closed
mslipper wants to merge 8 commits intofeat/opcraft-basefrom
feat/opcraft-custom
Closed

Custom branch for OPCraft#3688
mslipper wants to merge 8 commits intofeat/opcraft-basefrom
feat/opcraft-custom

Conversation

@mslipper
Copy link
Contributor

The Geth RPC client does not support subscriptions for HTTP endpoints. As a result, users who set an HTTP endpoint for the op-node were unable to sync since the driver never got any L1 head updates. This PR adds a wrapper around `client.RPC` that makes `newHeads` subscriptions work over HTTP. It does this by layering a notifications system that mimicks what Geth does under the hood on top of an HTTP polling loop.

The interface is the same as the one exposed by the raw RPC client. I tried my best to match Geth's subscription semantics, including:

- Closing the client causes all subscribers to get a nil error on their error channels.
- Unsubscribing closes each subscriber's error channel.
- Calling `Unsubscribe` multiple times is safe.

The poll rate is configurable. It default to 250ms, which should be fine for both L1 and L2. I tried at first to use Geth's underlying libraries, but found that it was impossible to do so without making changes to Geth itself to export more fields. This system is also simpler, and gives us room to instrument the polling loop in the future.

The wrapper is not integrated with the rest of the system in this PR. I'll stack those changes on top of this one so we can review this in isolation.

Totally open to different solutions here - marking as draft to reflect the fact that if there's a better way to do this, I'm happy o close this + the dependent PRs and go a different route.

Meta:

- Fixes ENG-2490
Integrates the HTTP PollingClient with the op-node. To do this, I needed to change the RPC interface to return an `ethereum.Subscription` object rather than a concrete *rpc.ClientSubscription instance. I also introduced a new method to return the correct `client.RPC` implementation based on the user's chosen RPC URL.

Lastly, I added an additional CircleCI job to run all end-to-end tests against an HTTP-based RPC endpoint to prevent issues from arising in the future.
@changeset-bot
Copy link

changeset-bot bot commented Oct 11, 2022

⚠️ No Changeset found

Latest commit: 3a6a280

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@mergify
Copy link
Contributor

mergify bot commented Oct 11, 2022

Hey @mslipper! This PR has merge conflicts. Please fix them before continuing review.

@mergify mergify bot added the conflict label Oct 11, 2022
@mergify
Copy link
Contributor

mergify bot commented Oct 11, 2022

This PR changes implementation code, but doesn't include a changeset. Did you forget to add one?

@mslipper mslipper changed the base branch from develop to feat/opcraft-base October 11, 2022 04:36
@mergify mergify bot removed the conflict label Oct 11, 2022
@mslipper mslipper closed this Oct 19, 2022
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.

2 participants