-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Description
Ethers Version
6.6.2
Search Terms
FallbackProvider
Describe the Problem
For eth_getLogs requests, we would like to send requests sequentially to providers, in such a way that if the i-th request is successful, then the (i+1)-th request is NOT sent.
Our understanding is that (according to our chat last week) "it is supposed to call parallel up to quorum. So if the quorum is 2 and each provider has a weight of 1, there should be two in-flight at a time. After stallTimeout the next gets kicked off, to account for the overly common case of backends not responding and also not hanging up."
Assuming all our providers have weight 2 and the quorum is 2:
Expected: each provider ("runner") is attempted one at a time, proceeding to the next one only if the request failed.
Actual: 2 runners are simultaneously attempted.
The culprit seems to be this line of code:
ethers.js/src.ts/providers/provider-fallback.ts
Lines 732 to 734 in c5cb7cd
| for (let i = 0; i < this.quorum; i++) { | |
| this.#addRunner(running, req); | |
| } |
Notice how this.quorum runners are started, independently of the weight of each provider runner. I believe that we should instead count the total-so-far weight of runners started and stop the for-loop if enough has been reached for the quorum.
Code Snippet
No response
Contract ABI
No response
Errors
No response
Environment
node.js (v12 or newer), Browser (Chrome, Safari, etc), React Native/Expo/JavaScriptCore
Environment (Other)
No response