Skip to content

feat(perf): batch eth_call requests in tests/scripts #5363

Open
@mds1

Description

@mds1

Component

Forge

Describe the feature you would like

See gakonst/ethers-rs#2508 for details/rationale on the request here

forge batching is not necessarily dependent on that ethers-rs feature, as even without it forge could presumably convert batches calls into multicalls. This could result in significant performance improvements for RPC-heavy scripts and fork tests

Currently instead of eth_call we simulate the call and use eth_getStorageAt as needed. This is suboptimal than just using eth_call directly because:

  • Alchemy prices eth_getStorageAt at 17 CUPS but eth_call is 26, so any tx reading 2+ slots is currently paying more (and running slower due to multiple requests) than necessary, especially when you consider that we can batch eth_calls but can't batch eth_getStorageAt
  • Simulating might not give the right result for chains where some opcodes behave differently than on mainnet (e.g. NUMBER returns L2 block number on optimism but L1 block number on arbitrum)

So I think the best path forward is:

  1. Replace the current behavior to use eth_call instead
  2. Then, batch eth_calls. The approach here would be:
  • Collect all consecutive staticcalls, stop collecting when there's a state changing operation
  • If Multicall3 is available on the chain, batch calls with it. If Multicall3 is not available on the chain, either use eth_call state overrides to place it there as part of the call, or just send normal requests without Multicall3

Additional context

No response

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Todo

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions