-
-
Notifications
You must be signed in to change notification settings - Fork 155
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
feat: provider.batch_requests()
low-level implementation
#2475
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@BobTheBuidler had some sort of batching middleware for Brownie, wonder if that might be useful here to look at
I had been looking at this issue, and I'm curious. What is the reason for using JSON and the requests library instead of using batch requests from web3.py? https://web3py.readthedocs.io/en/v7.7.0/web3.main.html#batch-requests |
Thanks for pointing this out, let me look into it. |
|
||
return [ | ||
self._get_result_from_rpc_response(uri, r, raise_on_failure=False) | ||
for r in response.json() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i remember a bug where erigon returned results out of order, so to be safe we can sort by id
if "jsonrpc" not in request: | ||
request["jsonrpc"] = "2.0" | ||
if "id" not in request: | ||
request["id"] = idx + 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- enumerate has a second arg for start index
- if we allow id overrides (any good reason for that?), then we need to check there are no duplicates
What I did
implements batch requets at the provider level, not sure about a more top level API yet (maybe something like multicall?)
fixes: #2472
How I did it
How to verify it
Checklist