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

feat: use FallbackProvider in the DTL #1393

Merged
merged 1 commit into from
Oct 1, 2021
Merged

Conversation

smartcontracts
Copy link
Contributor

Description
Replaces StaticJsonRpcProvider with FallbackProvider so we can run multiple nodes and get a consensus of results from each.

@changeset-bot
Copy link

changeset-bot bot commented Aug 26, 2021

🦋 Changeset detected

Latest commit: e0be02e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@eth-optimism/core-utils Patch
@eth-optimism/data-transport-layer Patch

Not sure what this means? Click here to learn what changesets are.

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

@smartcontracts smartcontracts marked this pull request as draft August 26, 2021 19:12
@tynes

This comment has been minimized.

@github-actions github-actions bot added the A-pkg-core-utils Area: packages/core-utils label Sep 8, 2021
@tynes tynes marked this pull request as ready for review September 8, 2021 20:14
@tynes
Copy link
Contributor

tynes commented Sep 8, 2021

CI is generally failing here, need to investigate as to why

@tynes tynes force-pushed the sc/use-fallback-provider branch 2 times, most recently from 79f8a4c to 078a041 Compare September 21, 2021 21:46
@tynes
Copy link
Contributor

tynes commented Sep 21, 2021

cc @smartcontracts this is ready for review again

const provider = new ethers.providers.StaticJsonRpcProvider(url)
providers.push(provider)
}
return new ethers.providers.FallbackProvider(providers)
Copy link
Contributor

Choose a reason for hiding this comment

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

looks good - note here that we can further parameterize things like weights of different providers by providing an array of FallbackProviderConfig instead.

FallbackProviderConfig. If a Provider is provided, the defaults are a priority of 1 and a weight of 1.

Copy link
Contributor

Choose a reason for hiding this comment

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

https://github.com/ethers-io/ethers.js/blob/c2c0ce75039e7256b287f9a764188d08ed0b7296/packages/providers/src.ts/fallback-provider.ts#L97

The existing implementation will randomize which is used. We could set the priority based on the order of URLs passed in

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Does this do quorum by default?

Allow the DTL to sync from multiple web3 backends using
the `ethers.providers.FallbackProvider`. Multiple URLs
can be passed through as a comma delimited string to
configure multiple providers.

A helper function is added to `core-utils` to allow
easy configuration between services. This PR only introduces
the usage of the fallback provider into the DTL. In the
future, it should be added to other services that query L1
as well.
import { Provider } from '@ethersproject/providers'

// Copied from @ethersproject/providers since it is not
// currently exported
Copy link
Contributor

Choose a reason for hiding this comment

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

PR to export the interface here: ethers-io/ethers.js#2121

@tynes tynes merged commit 85a1fea into develop Oct 1, 2021
@tynes tynes deleted the sc/use-fallback-provider branch October 1, 2021 20:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-pkg-core-utils Area: packages/core-utils
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants