question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Incorrect gas estimation since v2.5

See original GitHub issue

Expected 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:closed
  • Created 4 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
spalladinocommented, May 20, 2019

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.

1reaction
nicholasjpaternocommented, Jun 17, 2019

Thanks for your patience @spalladino! Can you try your test with https://github.com/trufflesuite/ganache-core/tree/gas-estimation branch?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Incorrect gas estimation when account has not enough ETH
Gas estimation is ok (about 65k); Try to execute tx with ETH amount you don't own - metamask will show correct error "insufficient...
Read more >
Gas estimation errored with the following message
This happens when one of your assert() or revert() condition returned false. Hence transaction mined but execution failed. – itsHarshad. Nov 20, ...
Read more >
We were not able to estimate gas. There might be an error in ...
I created my own fork of the contract (identical to original contract), when I deploy the contract in Remix, deployment works fine. I...
Read more >
transaction may fail or may require manual gas limit" : r/ethdev
I am trying a mint function that I wrote and getting this error: Error: cannot estimate gas; transaction may fail or may require...
Read more >
How to FIX cannot estimate gas on PancakeSwap - YouTube
How to FIX cannot estimate gas on PancakeSwapBinance: ... DON'T USE GMAIL unless you make these 5 Critical Security Changes.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found