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

feat: Make eth_call gas limit configurable #3783

Open
Tracked by #8269
Theo- opened this issue Nov 29, 2022 · 8 comments
Open
Tracked by #8269

feat: Make eth_call gas limit configurable #3783

Theo- opened this issue Nov 29, 2022 · 8 comments
Labels
C-anvil Command: anvil T-feature Type: feature
Milestone

Comments

@Theo-
Copy link

Theo- commented Nov 29, 2022

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)

@Theo- Theo- added the T-feature Type: feature label Nov 29, 2022
@mattsse
Copy link
Member

mattsse commented Nov 29, 2022

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?

@Theo-
Copy link
Author

Theo- commented Nov 29, 2022

@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

@rkrasiuk rkrasiuk added the C-anvil Command: anvil label Nov 29, 2022
@mattsse
Copy link
Member

mattsse commented Nov 29, 2022

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.

@sewinter
Copy link

sewinter commented Dec 4, 2022

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?

@Alexintosh
Copy link

Experienced the same issue while forking Goerli, call via multicall which were working on Goerli go CallerGasLimitMoreThenBlock for some reason in anvil.

@sewinter
Copy link

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?

@raphdeknop
Copy link

raphdeknop commented Jan 24, 2023

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)

@mattsse
Copy link
Member

mattsse commented Feb 10, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-anvil Command: anvil T-feature Type: feature
Projects
None yet
Development

No branches or pull requests

7 participants