trufflesuite / ganache

:warning: The Truffle Suite is being sunset. For information on ongoing support, migration options and FAQs, visit the Consensys blog. Thank you for all the support over the years.
https://consensys.io/blog/consensys-announces-the-sunset-of-truffle-and-ganache-and-new-hardhat?utm_source=github&utm_medium=referral&utm_campaign=2023_Sep_truffle-sunset-2023_announcement_
MIT License
2.62k stars 680 forks source link

`unlimitedContractSize` option is not applied to calls to `eth_estimateGas` #3332

Open davidmurdoch opened 2 years ago

davidmurdoch commented 2 years ago

Reporduction:

Clone https://github.com/anishnaik/ganache-bug and checkout the bug branch.

The testing script is called deploy.js.

Ganache@7.3.2 Terminal 1

npm uninstall -g ganache-cli (if applicable)
npm install -g ganache
ganache -d -l 100000000000 --chain.allowUnlimitedContractSize --miner.callGasLimit 0x1fffffffffffff

Terminal 2

npm install
npx hardhat test deploy.js

This should fail with the following error:

  Deploy contracts for Echidna
    1) Deploy

  0 passing (110ms)
  1 failing

  1) Deploy contracts for Echidna
       Deploy:
     ProviderError: VM Exception while processing transaction: out of gas
      at HttpProvider.request (node_modules/hardhat/src/internal/core/providers/http.ts:78:19)
      at GanacheGasMultiplierProvider._getMultipliedGasEstimation (node_modules/hardhat/src/internal/core/providers/gas-providers.ts:72:59)
      at GanacheGasMultiplierProvider.request (node_modules/hardhat/src/internal/core/providers/gas-providers.ts:309:19)
      at processTicksAndRejections (node:internal/process/task_queues:96:5)

You can try to set a gasLimit for the deploy() call and if it is large enough, the test will pass.

ganache-cli@6.12.2 Terminal 1

npm uninstall -g ganache
npm install -g ganache-cli
ganache-cli -d --gasLimit 100000000000 --allowUnlimitedContractSize

Terminal 2

npx hardhat test deploy.js

This test should pass

This could also be a dependency issue in the hardhat environment?

Environment MacBook Pro w/ Apple M1 Max Hardhat v2.9.9 Ganache@7.3.2 ganache-cli@6.12.2

Originally posted by @anishnaik in https://github.com/trufflesuite/ganache/issues/1645#issuecomment-1171642018

davidmurdoch commented 2 years ago

@anishnaik I've found the issue. callGasLimit is working in eth_estimateGas, but allowUnlimitedContractSize is not.

estimateGas makes a copy of the VM before running the transaction in order to estimate it. The allowUnlimitedContractSize property is not copied, as you can see here:

image

There is currently no work around but I hope to get a fix in for this very soon.

anishnaik commented 2 years ago

Hi @davidmurdoch this makes sense! Appreciate your help.

davidmurdoch commented 2 years ago

Related issue: https://github.com/ethereumjs/ethereumjs-monorepo/issues/2017

anishnaik commented 2 years ago

@davidmurdoch any updates on this?

davidmurdoch commented 2 years ago

Can you try ganache@alpha and let me know if that fixes it for you??

anishnaik commented 2 years ago

Hey @davidmurdoch apologies for the delayed response. ganache@alpha worked with the above codebase :)

Is there a timeline for an official release?

davidmurdoch commented 2 years ago

There is no timeline; we are working now to improve stability.