Parity-ethereum: eth_estimateGas returns "The execution failed due to an exception"

Created on 8 Jan 2019  路  11Comments  路  Source: openethereum/parity-ethereum

_Before filing a new issue, please provide the following information._

  • Parity Ethereum version: 2.1.10
  • Operating system: Linux
  • Installation: one-line installer
  • Fully synchronized: yes
  • Network: ethereum Ropsten
  • Restarted: yes

Calling eth_estimateGas returns an exception error.

Example:

Call:

[2019-01-08 02:29:47.971] [DEBUG] worker - { method: 'eth_estimateGas',
  params:
   [ { from: '0x2c9cb2f3759d188d94b1de9928714ea25892f07d',
       to: '0x76b495bc78d435ddbadac8bb5957f3f141abfd98',
       value: '0x0',
       data: '0xa9059cbb000000000000000000000000593545d60f7be74efb6236e5a5a86f504d287a710000000000000000000000000000000000000000000010f0cf064dd592000000' } ],
  id: 1,
  jsonrpc: '2.0' }

Response:

[2019-01-08 02:29:47.984] [WARN] worker - { jsonrpc: '2.0',
  error:
   { code: -32016,
     message: 'The execution failed due to an exception.' },
  id: 1 }

_Your issue description goes here below. Try to include actual vs. expected behavior and steps to reproduce the issue._

F3-annoyance 馃挬 M6-rpcapi 馃摚

Most helpful comment

Sometimes you surely should specify from to get an estimate. Imagine smart-contract that wastes 100k gas if your address starts with 0x000 and does not waste if it doesn't :)

In case of ERC20 tokens you should provide correct from so that estimateGas would be able to pass all the requires. In your example from is set to default 0, and some requires expectedly fail. And estimateGas says that such txn would fail. Which is correct behaviour in my opinion.

I can not comment whether this behaviour is new or not, as I am not a Parity developer.

All 11 comments

@ThomasProust do you see any additional information in your node's logs?

@joshua-mir Nope, there is no information at all in the logs regarding that error

@ThomasProust I could not reproduce the behavior but I think https://github.com/paritytech/parity-ethereum/blob/master/ethcore/src/client/client.rs#L1544-#L1545 is the cause of this exception

//cc @tomusdrw can you confirm?

It is a bummer that we don't log the what type of exception occurred. Perhaps maybe we could encapsulate the exception cause in CallError::Exceptional. However, it is really hard to investigate it further without logs

@niklasad1 yeah, that's possible it's coming from there.

@Levino do you get this every time with all possible calls? It possibly signifies that the execution couldn't be completed (even if we provide a lot of gas), so most likely some issue with the call itself.

@Levino https://github.com/paritytech/parity-ethereum/blob/7c335e87642b848f61ab3ee7bbff5964b53d6f11/rpc/src/v1/impls/eth.rs#L652-L656

What's going on is while we're trying to calculate the nonce for the transaction, we first attempt to count pending transactions and if there is no value there we fall back to just counting in the latest known block - this is fairly unrelated to the issue you are experiencing here.

My bad. It was an exception in the contracts code because the state of the contract was not as expected. Would have been much better if one would know what exactly happend instead of the cryptic message "Computer says no". I will delete my above comments to unclutter this issue.

Thank you @tomusdrw and @joshua-mir for taking the time to help me.

I've been running into this on Parity v2.2.8, and Geth v1.8.22 and it seems to fail when to is set to certain contracts but not others? The geth ticket suggests it may be related to the Solidity version a contract was compiled with.

Examples:

BeerCoin: https://etherscan.io/address/0x74c1e4b8cae59269ec1d85d3d4f324396048f4ac
parity:

curl -H "Content-Type: application/json" --request POST --data '{"jsonrpc":"2.0","method":"eth_estimateGas","params":[{"to":"0x74c1e4b8cae59269ec1d85d3d4f324396048f4ac","data":"0xa9059cbb0000000000000000000000007cb57b5a97eabe94205c07890be4c1ad31e486a80000000000000000000000000000000000000000000000000000000000000001"}],"id":34}' http://localhost:8889
{"jsonrpc":"2.0","result":"0x1f159","id":34}

geth:

curl -H "Content-Type: application/json" --request POST --data '{"jsonrpc":"2.0","method":"eth_estimateGas","params":[{"to":"0x74c1e4b8cae59269ec1d85d3d4f324396048f4ac","data":"0xa9059cbb0000000000000000000000007cb57b5a97eabe94205c07890be4c1ad31e486a80000000000000000000000000000000000000000000000000000000000000001"}],"id":34}' http://localhost:8889
{"jsonrpc":"2.0","id":34,"result":"0x1f159"}

USDCoin: https://etherscan.io/address/0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48
parity:

curl -H "Content-Type: application/json" --request POST --data '{"jsonrpc":"2.0","method":"eth_estimateGas","params":[{"to":"0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48","data":"0xa9059cbb0000000000000000000000007cb57b5a97eabe94205c07890be4c1ad31e486a80000000000000000000000000000000000000000000000000000000000000001"}],"id":34}' http://localhost:8889
{"jsonrpc":"2.0","error":{"code":-32016,"message":"The execution failed due to an exception."},"id":34}

geth:

curl -H "Content-Type: application/json" --request POST --data '{"jsonrpc":"2.0","method":"eth_estimateGas","params":[{"to":"0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48","data":"0xa9059cbb0000000000000000000000007cb57b5a97eabe94205c07890be4c1ad31e486a80000000000000000000000000000000000000000000000000000000000000001"}],"id":34}' http://localhost:8889
{"jsonrpc":"2.0","id":34,"error":{"code":-32000,"message":"gas required exceeds allowance or always failing transaction"}}

Unfortunately even running parity with --logging rpc=trace doesn't give much more information:

2019-02-06 01:38:24 UTC jsonrpc-eventloop-2 TRACE rpc  Request: {"jsonrpc":"2.0","method":"eth_estimateGas","params":[{"to":"0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48","data":"0xa9059cbb0000000000000000000000007cb57b5a97eabe94205c07890be4c1ad31e486a80000000000000000000000000000000000000000000000000000000000000001"}],"id":34}.
2019-02-06 01:38:24 UTC jsonrpc-eventloop-2 DEBUG rpc  [Some(Num(34))] Took 130ms
2019-02-06 01:38:24 UTC jsonrpc-eventloop-2 DEBUG rpc  Response: {"jsonrpc":"2.0","error":{"code":-32016,"message":"The execution failed due to an exception."},"id":34}.

@jmooo tx to BeerCoin does not fail because it does not have any requires to fail. Tx to USDCoin fails because you did not specify correct from address which would have at least 1 token to transfer. For example this works:

curl -H "Content-Type: application/json" --request POST --data '{"jsonrpc":"2.0","method":"eth_estimateGas","params":[{"from": "0xA910f92ACdAf488fa6eF02174fb86208Ad7722ba","to":"0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48","data":"0xa9059cbb0000000000000000000000007cb57b5a97eabe94205c07890be4c1ad31e486a80000000000000000000000000000000000000000000000000000000000000001"}],"id":34}' http://localhost:8889
{"jsonrpc":"2.0","id":34,"result":"0x9af7"}

You shouldn't have to specify a from to get an estimate should you? This is new behavior as Parity previously didn't fail when you didn't specify a from for estimates.

Sometimes you surely should specify from to get an estimate. Imagine smart-contract that wastes 100k gas if your address starts with 0x000 and does not waste if it doesn't :)

In case of ERC20 tokens you should provide correct from so that estimateGas would be able to pass all the requires. In your example from is set to default 0, and some requires expectedly fail. And estimateGas says that such txn would fail. Which is correct behaviour in my opinion.

I can not comment whether this behaviour is new or not, as I am not a Parity developer.

I feel like this issue can be closed (in favor of #10360), because it actually looks like this is a matter of not being verbose enough and not some kind of failure in performing the estimation on our end. Let me know if you disagree with that assessment.

Was this page helpful?
0 / 5 - 0 ratings