Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

eth_estimateGas did not return error on invalid contract tx #462

Closed
Detoo opened this issue Aug 3, 2019 · 1 comment
Closed

eth_estimateGas did not return error on invalid contract tx #462

Detoo opened this issue Aug 3, 2019 · 1 comment

Comments

@Detoo
Copy link

Detoo commented Aug 3, 2019

On a regular full node (Parity, for example), calling eth_estimateGas with an invalid contract transaction (ex. transfer ERC20 with insufficient funds) will end up receiving error code -32000; however, the current version of ganache-cli still returns a gas estimation as if the transaction will pass.

The issue seems only happen in more recent versions (Ganache CLI v6.5.1 (ganache-core: 2.6.1-beta.0)) because the previous version we used (Ganache CLI v6.2.5 (ganache-core: 2.3.3)) did return the expected error code like a full node.

I assumed it is a ganache-core bug but I could be wrong. Please feel free to let me know if I should move it to ganache-cli. Thanks!

Steps to Reproduce (for bugs)

  1. ganache-cli -f http://<your-full-node-ip>:<port>
  2. (connect to it through web3.py )
import json

our_accnt_addr = "0xDeaDbeefdEAdbeefdEadbEEFdeadbeEFdEaDbeeF"
dai_mainnet_addr = "0x89d24A6b4CcB1B6fAA2625fE562bDD9a23260359"
dai = web3.eth.contract(
    abi=json.loads('[{"constant":false,"inputs":[{"name":"guy","type":"address"},{"name":"wad","type":"uint256"}],"name":"mint","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"}]')
)(dai_mainnet_addr)

print(dai.functions.mint(our_accnt_addr, 1234).estimateGas({"from": our_accnt_addr}))

Expected Behavior

Should get exception ValueError: {'code': -32000, 'message': 'gas required exceeds allowance or always failing transaction'} because the transaction should revert (not the owner of the DAI contract on mainnet)

Current Behavior

Got an estimated gas of 30204

Context

The issue causes inconsistent behaviors in our client on mainnet vs ganache, because it was expecting the gas estimation of an invalid tx to fail but it didn't happen on ganache.

Your Environment

  • Version used: Ganache CLI v6.5.1 (ganache-core: 2.6.1-beta.0)
  • Environment name and version: Python 3.7, web3.py 4.8.2
  • Operating System and version: Mac OS 10.14.4
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants