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

Consider making EthersProviderWrapper a StaticJsonRpcProvider #1938

Open
maraoz opened this issue Oct 9, 2021 · 4 comments
Open

Consider making EthersProviderWrapper a StaticJsonRpcProvider #1938

maraoz opened this issue Oct 9, 2021 · 4 comments
Labels

Comments

@maraoz
Copy link

maraoz commented Oct 9, 2021

Currently, EthersProviderWrapper inherits from JsonRpcProvider. See: https://github.com/nomiclabs/hardhat/blob/51cb14a5d8bdb90c11529322bc76b45adbab2e20/packages/hardhat-core/test/internal/hardhat-network/helpers/ethers-provider-wrapper.ts#L8

This makes client code make an eth_chainId call before every use of the provider.
See: ethers-io/ethers.js#901

Given hardhat tasks and scripts usually run in the same network (or at least that's my case, and kind if implied by the --network option in most commands), consider changing inheritance to StaticJsonRpcProvider, which only performs the eth_chainId call at the beginning. This could potentially save lots of requests in most cases. I managed to get my infura requests down 50% by using my own StaticJsonRpcProvider instead of relying on hardhat's .

@fvictorio
Copy link
Member

This makes a lot of sense. I think this is a somewhat new provider, so we should check when it was added and how we should bump the ethers peer dependency of the plugin.

@github-actions
Copy link
Contributor

This issue was marked as stale because it didn't have any activity in the last 30 days. If you think it's still relevant, please leave a comment indicating so. Otherwise, it will be closed in 7 days.

@myc0058

This comment was marked as off-topic.

@leckylao
Copy link

leckylao commented Mar 18, 2023

Bumping the priority on this as it greatly impacts our running cost, as you could see the top 1 RPC call is chainId which can be removed as it's running on the same network and it would greatly reduce everyone's running cost.

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: No status
Development

No branches or pull requests

4 participants