feat: Make eth_call gas limit configurable
Component
Anvil
Describe the feature you would like
Using a multicall contract to read a lot of data at once is a common use case. Anvil caps the gas limit of eth_call to the maximum gas limit of a block. I'm running into EVM error CallerGasLimitMoreThenBlock when trying to read lots of data from a multicall contract (> 100 calls)
Additional context
For any eth_call, set the gas limit to 18446744073709551615 (the maximum possible value)
there's the --gas-limit argument to set this to any value.
--gas-limit <GAS_LIMIT>
The block gas limit
I guess we could add an alias for max?
@mattsse this argument is very useful when calling evm_mine to create new block, I don't think the same limit should apply to eth_call. What is the reasoning behind limiting the gas_limit on a eth_call?
Btw, I really appreciate how responsive the Foundry/Anvil team is ✨ thank you all for the great work
eth_call is executed without creating a transaction on the chain, and instead returns the result as it would if included in a block. So we don't want to return a success if the call would actually fail if mined.
but I'm not sure if the same applies to hardhat.
there's also anvil_setBlockGasLimit that you can use to set the block gaslimit an the fly.
anvil doesn't seem to respect the block gas limit for eth_call because setting the gas limit to 18446744073709551615 still results in CallerGasLimitMoreThenBlock (which has a misspelling by the way). This issue from a month ago reports the same bug and is also still open. Will this be fixed?
Experienced the same issue while forking Goerli, call via multicall which were working on Goerli go CallerGasLimitMoreThenBlock for some reason in anvil.
I think that setting the env var mentioned here will probably fix it. I'm not a rust dev though, so I'm not sure how to do this exactly. Can someone weigh in?
Same behaviour here. I made a mainnet fork using anvil and changed the gas limit to 100M, but when I cast call my contract's view function (contract which needed the --via-ir flag btw), I get the CallerGasLimitMoreThenBlock error when I put a gas limit higher than 30M (which iirc is the original block gas limit)
I get the CallerGasLimitMoreThenBlock error when I put a gas limit higher than 30M (which iirc is the original block gas limit)
can't reproduce this, sorry.
This issue is a bit difficult for me to understand, because:
- block gas limit
- call gas limit
are configurable
and CallerGasLimitMoreThanBlock is a constraint violation, so I'm actually not sure what the issue here is.
If you set the tx gas limit > block gas limit, it should fail even in eth_call, no?
that being said, I'll enable the optional_block_gas_limit feature and add a new flag.