Support for batching individual RPC calls #3274
Unanswered
frolic
asked this question in
Idea / Feature Request
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I am trying to add an option into MUD's logs fetching mechanism (used to sync data from chain) that turns an RPC request like
eth_getLogsinto[eth_getBlockByNumber, eth_getLogs]to help with issues related to load balanced RPCs: https://indexsupply.com/shovel/docs/#unsynchronized-ethereum-nodesHowever, I am failing to find a good entry point into Viem to do this without creating a bunch of wrappers around Viem things (e.g. http transport or rpc client) or "prop drilling" options through the whole MUD stack.
For context, when using MUD's sync tooling, you provide a Viem client, which allows users to configure their transport in a way that suits them/their RPC best (http vs ws, fallbacks, retries, etc.).
Some ideas on the Viem side that could help with this (ordered by favorite to least favorite):
Extend
EIP1193RequestFnor offer an alternative that supports batched calls likerequest([body, body]). I realize the EIP-1193 spec doesn't account for this, so I'm not sure how best to model this on the Viem side. This could would likely require some refactoring of the batch scheduler and de-duping.Expose transport options or whether batching is enabled. If I can detect that batching is enabled, I could do the RPC calls in parallel like
Promise.all([eth_getBlockByNumber, eth_getLogs])and expect the batch scheduler to put this into a single RPC call.Expose
urlinHttpRpcClientso I can take this as a type of client for fetching logs and be able to throwRpcRequestErrorusing theurl. Without this, I'd have to make my owncreateHttpRpcClientwrapper that either exposesurlor internally throws theRpcRequestErrorwith the providedurl.HttpRpcClientas a client type means we miss out on retry logic, fallback handling, etc. that transports give. So although this would be a small hole to poke, it probably isn't a great overall solution.Allow
onRequestandonResponseoverrides insideEIP1193RequestFnoptions. This means I could write a transport wrapper that taps into the RPC request/response lifecycle to transform specificeth_getLogsrequests into the desired[eth_getBlockByNumber, eth_getLogs].Beta Was this translation helpful? Give feedback.
All reactions