alloy
alloy copied to clipboard
[Feature] Add a `CachedReqwestProvider` to cache RPC requests using a `ReqwestProvider`
Component
provider, pubsub
Describe the feature you would like
For use-cases like SP1-Reth
or Kona
, we often want to execute a (historical) block, but we don't have the entire state in memory and we execute this block with a ProviderDb
that fetches accounts, storage, etc. using an RPC. Fetching from the network is slow and often takes minutes for all of the accesses required for an entire block.
Often we re-run these blocks to debug things or tune performance, etc. and each time the feedback loop on iteration is very slow because it requires waiting for all the network requests each time. It would be nice to add a very simple caching layer on top of ReqwestProvider
that can cache the results of RPC calls to a file (or some other easy to set up format) and then first check the cache before sending a network request.
This would speed up iteration time for use-cases like Kona
and SP1-Reth
tremendously.
An interface like this might make sense:
let provider = ReqwestProvider::new_http(rpc_url).cache("my_file.txt")
In our case, we are usually querying old blocks (not near the tip of the chain), so re-org awareness is not important for our use-case. We just want a really simple caching layer.
Additional context
No response