hardhat icon indicating copy to clipboard operation
hardhat copied to clipboard

ProviderError: Transaction gas limit is 30000000 and exceeds transaction gas cap of 16777216

Open Amxx opened this issue 3 weeks ago • 3 comments

Version of Hardhat

2.27.1

What happened?

Using

  • "hardhat": "^2.27.1"
  • setting evm version to osaka

Whenever doing a operation (deploying a contract, sending a transaction, performing a call), without manually setting the gasLimit, the provider somehow sets the gasLimit to 30 million, which is no longer allowed since fusaka limits the size of every single transaction to 2**24.

Minimal reproduction steps

  • set evm version to osaka
  • start a hardhat node
npx hardhat node
  • send an eth_estimateGas rpc call:
curl http://127.0.0.1:8545 -X POST -H "Content-Type: application/json" --data '{"method":"eth_estimateGas","params":[{"from":"0x8D97689C9818892B700e27F316cc3E41e17fBeb9","to":"0xd3CdA913deB6f67967B99D67aCDFa1712C293601"}],"id":1,"jsonrpc":"2.0"}'

output is

{"jsonrpc":"2.0","id":1,"error":{"code":-32000,"message":"transaction gas limit (30000000) is greater than the cap (16777216)","data":{"message":"transaction gas limit (30000000) is greater than the cap (16777216)","data":null}}}

Alternativelly

  • Use this branch https://github.com/Amxx/openzeppelin-contracts/pull/new/update/use-0.8.31-clz
  • npm ci
  • npm test

Search terms

edr, osaka, gasLimit

Amxx avatar Dec 04 '25 00:12 Amxx

Hi Hadrien, thanks for the report, Hardhat 2 and 3 already support the Fusaka hardfork, but there is a bug in our runtime (EDR) we are fixing right now. We are also setting Fusaka as the default hardfork. We are preparing a bug fix release, the plan is to release today, but there are solc and revm dependencies we do not control which might delay us a bit. You can avoid this issue for the time being by sticking with prague hardfork, but that blocks you from using the CLZ opcode unfortunately.

michalbrabec avatar Dec 04 '25 09:12 michalbrabec

As soon as I was able to replicate the issue using curl on a node, I guessed it was probably on the EDR side and not an issue in the hardhat provider stack.

Good to know that a fix is comming, because on my end we are really looking toward testing the new opcode.

Amxx avatar Dec 04 '25 13:12 Amxx

There is a workaround that you can use, you can set the blockGasLimit: 16000000 for the network you are using. I have run your tests with this in place and all succeeded for me locally. The issue is caused by Hardhat setting the transaction gasLimit to blockGasLimit by default, EDR should override it for Osaka, but there is an issue we are fixing. Like so:

  networks: {
    hardhat: {
      hardfork: argv.evm,
      blockGasLimit: 16000000,
      // Exposed contracts often exceed the maximum contract size. For normal contract,
      // we rely on the `code-size` compiler warning, that will cause a compilation error.
      allowUnlimitedContractSize: true,
      initialBaseFeePerGas: argv.coverage ? 0 : undefined,
      enableRip7212: true,
    },
  },

michalbrabec avatar Dec 04 '25 13:12 michalbrabec

The fix has been released: https://github.com/NomicFoundation/hardhat/releases/tag/hardhat%402.28.0

kanej avatar Dec 15 '25 11:12 kanej