chore_: initial steps to decouple rpc chain modules #5856
+1,213
−666
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The way RPC chain modules were written, it is an extreme pain in the ass to work with them and write tests for them.
This PR doesn't solve that problem, it's just the initial steps of an attempt to bring some order into them, which I needed for activity-related tasks.
There should be 0 functional changes here, I just defined some new interfaces, split packages to avoid circular dependencies in mock files and split some pieces of code to separate classes.
EthClientInterface
defined, representing a high-level wrapper around anrpc.Client
(extension of go-ethereum'sethclient.Client
) .EthClient
defined as its implementation.RPSLimitedEthClientInterface
defined, extendingEthClientInterface
with some random dependencies needed by a bunch of places in the status-go. This shouldn't really exist, ideally we would only useEthClientInterface
everywhere and users wouldn't know if there's RPS limiting, fallbacks or caching involved. Anyway, solving this properly requires much more work, we can think about it later.ChainInterface
removed, it wasn't used anywhere and was replaced byEthClientInterface
.ClientWithFallback
now takesRPSLimitedEthClientInterface
instead of the objects themselves.