-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
FallbackProvider repeatedly requests block numbers #1371
Comments
This seems quite likely and something I should fix. Any two calls to block number during the same event loop should share the same Promise. I have a few other things I need to get to first, but this is a fairly important change I'll get to as soon as possible. |
This should be address in 5.1.1, if you'd like to give it a try. :) |
@ricmoo Looks good! We will be experimenting with it further! Would it be possible to not request the block numbers at all up front? In our use case we don't usually query data for anything other than |
This change won't make it in v5, as it is somewhat low-level behaviour that might have other ramifications, but in v6 the AbstractProvider makes no requests until it is actually used, including for block number. :) |
@ricmoo I'm still noticing that these requests are still made, even if quorum is 1 and stallTimeout is set to 5 seconds. I may have time to submit a PR this week. |
The
FallbackProvider
requests the block number here (https://github.com/ethers-io/ethers.js/blob/master/packages/providers/src.ts/fallback-provider.ts#L500), for it's internal book-keeping of block numbers.If a user does multiple requests at once to the FallbackProvider this will cause multiple requests to eth_blockNumber, which should be unnecessary since each request will have the same response. This happens because
getBlockNumber()
calls_getInternalBlockNumber()
withmaxAge=0
which doesn't allow it to wait for the existing request. I would say that this is unexpected behaviour.As a second suggestion, perhaps the
FallbackProvider
can also wait with fetching the block numbers at all until a request is made that needs them?The text was updated successfully, but these errors were encountered: