Skip to content
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

Optimize multicall to run in parallel #1503

Open
roninjin10 opened this issue Dec 3, 2024 · 2 comments
Open

Optimize multicall to run in parallel #1503

roninjin10 opened this issue Dec 3, 2024 · 2 comments

Comments

@roninjin10
Copy link
Collaborator

The EVM is single threaded. So users will intuitively expect client.multicall(calls) to be faster than Promise.all(calls.map(call => client.call(call) but this is actually not the case.

Solution

We don't want users to think about this so we should optimize multicall to be faster

  1. Write a javascript precompile for multicall that optimizes multicall by running it in parallel
  2. Write plug into the EVM to detect whenever the bytecode matches multicall3 and if it does use our javascript precompile rather than executing the evm bytecode
Copy link

linear bot commented Dec 3, 2024

@roninjin10
Copy link
Collaborator Author

We want gas metering to be right so what we should do is run the calls in parallel but then at the end run it all together to produce the final result. Running it all together can naively just reexecute now that all state has been cached or if we want to avoid the 2x overhead we can just return early from the inner calls

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant