Open friofry opened 2 months ago
It's not clear why we need OriginalRPCURL, OriginalFallbackURL in this datatype.
As user needs to be able to revert to original rpc url after changing them
It would be more reliable to introduce RPS limiting logic on the status proxy side.
I would even most of it should be move to the proxy itself.
From a status go point of view we should only have: rpc url and original one (maybe in constants) The proxy should be the one handling the fallback etc.
@dlipicar what do you think of the proposed changes?
It's not clear why we need OriginalRPCURL, OriginalFallbackURL in this datatype.
As user needs to be able to revert to original rpc url after changing them
It would be more reliable to introduce RPS limiting logic on the status proxy side.
I would even most of it should be move to the proxy itself.From a status go point of view we should only have: rpc url and original one (maybe in constants) The proxy should be the one handling the fallback etc.
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: Allow users to override the web3 client with their own urls/credentials
is already the case on desktop. That would simplify the UI :)
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: