Incorrect gas estimation since v2.5
See original GitHub issueExpected Behavior
- Ganache returns a correct gas estimation for a transaction
Current Behavior
- Ganache is returning less gas than needed to execute the transaction
Steps to Reproduce (for bugs)
This test from the ZeppelinOS suite triggers the issue. It currently passes because we have disabled gas estimation on ganache nodes for the time being, but removing this line should make the bug surface.
The test is deploying a proxy, which in turns calls the initialize function of an ERC721. The transaction fails with an out of gas when attempted to be executed with ganache’s estimation.
Context
We received a report of certain contracts failing to be created on ZeppelinOS. Digging deeper, we found that it happens on ganache-core on versions 2.5 and greater. Following are the numbers we got in different ganache versions, as well as geth in dev mode, for comparison:
Ganache CLI v6.3.0 (ganache-core: 2.4.0)
1011031 (1278788)
Ganache CLI v6.4.3 (ganache-core: 2.5.5)
579231 (739038)
Ganache CLI v6.4.4-beta.0 (ganache-core: 2.5.6-beta.0)
579231 (739038)
Geth 1.8.27-stable-4bcc0a37
1035031 (1293788)
The numbers shown are the estimation returned by the eth_estimateGas call, and the numbers between brackets are the amount of gas we actually send to the transaction (we add a 25% extra). The transaction actually uses 1005031 gas.
I’m unsure if this is related to https://github.com/trufflesuite/ganache-core/issues/151.
Your Environment
- Version used: 2.5.5 and 2.5.6-beta.0
- Environment name and version (e.g. PHP 5.4 on nginx 1.9.1): nodejs v10.13.0
- Operating System and version: Ubuntu 18.10
- Link to your project: https://github.com/zeppelinos/zos
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (3 by maintainers)

Top Related StackOverflow Question
Good to hear! Let me know if I can provide any further info, or re-run the test with any new beta release and report back.
Thanks for your patience @spalladino! Can you try your test with https://github.com/trufflesuite/ganache-core/tree/gas-estimation branch?