Replies: 3 comments 11 replies
-
@ricmoo does this align with your views on how this should work? If yes I'd like to try implementing this. Should I target v5 or v6? |
Beta Was this translation helpful? Give feedback.
-
This is what I'd expect from FallbackProvider but seems like the name is misleading. Maybe it's better to rename the current fallback provider to QuorumProvider and have FallbackProvider attempt to try a list of providers (waterfall) when individual ones fail @ricmoo |
Beta Was this translation helpful? Give feedback.
-
A 429 will still retry (after the proper amount of time, explicit retry-after is honoured, otherwise an implicit exponential-backoff is used). After the stall-timeout, the next provider is kicked off regardless, the stall-timeout can be adjusted, but most retry-after timeouts are longer than the default 600ms, so the next in the list will begin and run in parallel to the first; whichever responds first will get the first stab at resolving the quorum. I think the OP has made wrong assumptions about the fallback provider. A quorum of 1 will still try the next provider in the list, on a non-response error, such as a server error. But if I for example, ask for the result if a call (which is what estimate gas is, effectively) and the result is a call exception, that is the result. If you ask some service for the result of “what is 5 diced by 0”, and the response is “error; division by zero”, that is the result and there is no reason to ask the next service. If you have added additional server-side constraints to a node, and use that in a FallbackProvider, that response is out of band, and it cannot know that that server is (albeit, intentionally) incorrectly responding to a request. You will need to configure each backend to have the same rules. The FallbackProvider, falls back onto other services only when the error is recoverable and the backend queried just failed. If the backend returns a result that is systemic, there is no reason to try the next. Does that make sense? |
Beta Was this translation helpful? Give feedback.
-
Describe the Feature
As I understand the code of the current FallbackProvider with
n
providers and a quorum of1
it would always do a single request and if that fails fail. For rpc errors like gas estimation, that is somewhat reasonable but for some other errors it is not.The specific case i'm currently looking at is a
FallbackProvider([privateRPCWithContractAllowList, publicRPC])
my thinking was - when for some reason i forgot to allowList a contract address the request would fail, but then be resolved on the public one.That is not the case though and i think with the current
FallbackProvider
that behaviour is also not enforceable.With a quorum of
1
you would always do one request, failing when the first one fails.With a quorum of
2
you would always do two requests, which would still fail with quorum not reached in case the first one fails.Therefore I think certain errors (also e.g. network errors like 429) should result in a retry on another provider when using a Fallbackprovider.
TBH i was under the impression that this is how the FallbackProvider already works("falling back"), but after looking at the source I think it isn't 😅
Code Example
No response
I think this intersects a bit with #2937
Beta Was this translation helpful? Give feedback.
All reactions