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

Reduce provider RPC requests #357

Merged
merged 3 commits into from
Jul 9, 2022
Merged

Conversation

mds1
Copy link
Collaborator

@mds1 mds1 commented Jun 30, 2022

This should significantly reduce the number of eth_chainId calls we see to Infura. More info in the ethers docs:

An ethers Provider will execute frequent getNetwork calls to ensure the network calls and network being communicated with are consistent.

In the case of a client like MetaMask, this is desired as the network may be changed by the user at any time, in such cases the cost of checking the chainId is local and therefore cheap.

However, there are also many times where it is known the network cannot change, such as when connecting to an INFURA endpoint, in which case, the StaticJsonRpcProvider can be used which will indefinitely cache the chain ID, which can reduce network traffic and reduce round-trip queries for the chain ID.

This Provider should only be used when it is known the network cannot change.

Related issue with more info: ethers-io/ethers.js#901

@mds1 mds1 requested review from apbendi and garyghayrat June 30, 2022 14:37
@netlify
Copy link

netlify bot commented Jun 30, 2022

Deploy Preview for jolly-shaw-20fe62 ready!

Name Link
🔨 Latest commit 071f2db
🔍 Latest deploy log https://app.netlify.com/sites/jolly-shaw-20fe62/deploys/62c9d24894822c00089f5178
😎 Deploy Preview https://deploy-preview-357--jolly-shaw-20fe62.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@garyghayrat garyghayrat added enhancement New feature or request app A change related to the Umbra frontend labels Jul 7, 2022
@apbendi apbendi force-pushed the reduce-provider-rpc-requests branch from a6bd60e to 071f2db Compare July 9, 2022 19:08
@apbendi apbendi merged commit 071f2db into master Jul 9, 2022
@apbendi apbendi deleted the reduce-provider-rpc-requests branch July 11, 2022 13:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
app A change related to the Umbra frontend enhancement New feature or request
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants