-
Notifications
You must be signed in to change notification settings - Fork 246
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
RPC client circuit breaking logic improvements #5854
Comments
From a status go point of view we should only have: rpc url and original one (maybe in constants) |
@dlipicar what do you think of the proposed changes? |
Removing both rps_limiter and circuit_breaker and moving the provider logic to the proxy sounds better. (Basically, this is what the proxy design pattern means) But in this case we still should probably:
|
Agree with your 2 points and: |
tl;dr
Problems with the current implementation:
Table of content
Providers configuration
We transform
WalletSecretConfig
(set on the client side) viadefault_networks.go setRPCs()
toparams.Networks
:Here are some of the issues:
WalletSecretConfig
and only 3 of them are actually respected by thesetRPCs
function. It would be great to have other providers available for RPC calls. For example, the Alchemy.setRPCs
relies on string comparison in URLs which is unreliable.Suggestion
Network
to a separateProviderConfig
. And there should be 1 to many (Network - *ProviderConfig).This will make this logic more predictable and as a bonus it will make it easier to implement a user settings UI for the custom tokens (e.g. if our providers are banned in their country by DNS).
Network type
Network has 6 RPC urls.
Currently we are using 4 of them. And performing RPC attempts in the following order via
ethclient.Client
via circuit_breaker's command with 4 functors (or less)proxy
(DefaultRPCURL
)proxy-fallback
(DefaultFallbackURL
)main
(RPCURL
)fallback
(FallbackURL
)Here are some issues:
OriginalRPCURL
,OriginalFallbackURL
in this datatype.Suggestion:
networks.go
Find
,GetAll
) innetworks.go
that making unobvious side effects likesetDefaultRPCURL
.Suggestion: remove
setDefaultRPCURL
from these methodsRPC client
Currently we are using both RPS limiter to make sure that we are not hitting limits in
chain/client.go
and
circuit_breaker.go
to try multiple providers beforeSo first we pass a functor to
hystrix.DoC()
which checksprovider.limiter.WaitForRequestsAvailability(1)
and may returnErrRequestsOverLimit
without even calling the RPC provider, and it may increase the error percentage for circuit_breaker.here is the config we're using:
Here are some things that can be improved:
provider.limiter.ReduceLimit()
) and opening circuit breaker logic at the same time can be confusing. Circuit_breaker can become open because RPS limiter returnsErrRequestsOverLimit
ClientWithFallback
for all providers.hystrix.DoC
if it is the last resort. It may make sense to let hystrix collect statistics. Here is why this is unpredictable: ifcircuitNameHandler
is used to override the circuit name, then the limits may change. Or if the list of eth clients is updated, it may be useful to have previous statistics for the provider.GethStatusBackend::ConnectionChange
to reset it explicitlyhystrix.Flush()
.Suggestions:
hystrix.Flush()
hack.Reporting provider state
When provider is not "connected" client gets EventBlockchainStatusChanged event with "down" message.
Mobile just logs the event (previously there was a toast).
Desktop has more complex logic and keeps track on the last success timestamp and
Errors are contcatenated
Here are some issues:
Suggestions:
Links:
The text was updated successfully, but these errors were encountered: