ethermint icon indicating copy to clipboard operation
ethermint copied to clipboard

EVM Revert and Out-of-gas error doesn't follow the correct format

Open yijiasu-crypto opened this issue 3 years ago • 12 comments

System info:

0.0.0-308-g7e1b45b

Steps to reproduce:

  1. Make a out-of-gas eth_call
  • Can use: yarn test --network ethermint proxy
  1. The out-of-gas error occured. However the JSON-RPC message is in a different format compared to ganache

Expected behavior: [What you expected to happen]

 <   {
 <     "id": 1626419303744,
 <     "jsonrpc": "2.0",
 <     "error": {
 <       "message": "VM Exception while processing transaction: out of gas",
 <       "code": -32000,
 <       "data": {
 <         "0xf08cc2bfa30270de3f28f2d8349d2797e9e15251c0cd8c2555b581c8428f2904": {
 <           "error": "out of gas",
 <           "program_counter": 219,
 <           "return": "0x"
 <         },
 <         "name": "c"
 <       }
 <     }
 <   }

Actual behavior: [What actually happened]


 <   {
 <     "jsonrpc": "2.0",
 <     "id": 1626419644885,
 <     "error": {
 <       "code": -32000,
 <       "message": "out of gas"
 <     }
 <   }

Additional info: [Include gist of relevant config, logs, etc.]

Since the out-of-gas error is correctly occured. But the returned message can't be parsed by truffle framework, returned in a test failed.

yijiasu-crypto avatar Jul 17 '21 10:07 yijiasu-crypto

nice catch

leejw51crypto avatar Jul 18 '21 01:07 leejw51crypto

linked to #247

thomas-nguy avatar Jul 19 '21 12:07 thomas-nguy

To re-produce the error:

  1. Start ethermint node on localhost. Listen on 8545
  2. cd tests/solidity/suites/proxy
  3. Run yarn truffle test --network ethermint --verbose-rpc | grep "out of gas" -A 50 -B 50 ( You can omitted the grep part to inspect the full rpc logs. However it's very verbose and will output a lot)
  4. The screen will not print anything for a while (1~2 mins). This is normal, since it has not started the execution of that problematic test case.
  5. You can see something like this:
   > {
   >   "jsonrpc": "2.0",
   >   "method": "eth_call",
   >   "params": [
   >     {
   >       "from": "0x90fdb51c13ce085ce7f9c0da8683b7327711b064",
   >       "gas": "0x5a0a",
   >       "gasPrice": "0x3b9aca00",
   >       "value": "0x64",
   >       "to": "0x260d4674b0b54f771d588cafdefd4bb7cfee280a"
   >     },
   >     "latest"
   >   ],
   >   "id": 1626855091441
   > }
 <   {
 <     "jsonrpc": "2.0",
 <     "id": 1626855091441,
 <     "error": {
 <       "code": -32000,
 <       "message": "out of gas"
 <     }
 <   }

The log lines start with >>> means this is a request from truffle to ethermint, those start with <<< means it's a json-rpc response. Look at the id, every request will have an unique id and you could found its response followed by the request log.

cc @thomas-nguy

yijiasu-crypto avatar Jul 21 '21 08:07 yijiasu-crypto

You can stop the ethermint and run ganache-cli to listen on 8545 and re-run the test. Then you can see logs with legitimate error response.

To install ganache-cli: https://github.com/trufflesuite/ganache-cli

yijiasu-crypto avatar Jul 21 '21 08:07 yijiasu-crypto

@thomas-nguy are you still working on this?

fedekunze avatar Jul 23 '21 10:07 fedekunze

yes, I need to do more testing but I will open the PR soon

thomas-nguy avatar Jul 26 '21 00:07 thomas-nguy

for

 <       "data": {
 <         "0xf08cc2bfa30270de3f28f2d8349d2797e9e15251c0cd8c2555b581c8428f2904": {
 <           "error": "out of gas",
 <           "program_counter": 219,
 <           "return": "0x"
 <         },

I wonder if it is not a specific implementation of ganache. I cannot find anything like that in geth @fedekunze @yihuang ?

thomas-nguy avatar Jul 26 '21 02:07 thomas-nguy

https://github.com/ethereum/go-ethereum/blob/master/rpc/json.go#L109 all i can find is here, we might need to actually run it to check out the actual error message.

yihuang avatar Jul 26 '21 02:07 yihuang

{
   "jsonrpc":"2.0",
   "id":1627577507785,
   "error":{
      "code":-32015,
      "data":"Out of gas",
      "message":"VM execution error."
   }
}

Here's the raw RPC response from Kovan

yijiasu-crypto avatar Jul 29 '21 16:07 yijiasu-crypto

@yihuang @yijiasu-crypto @thomas-nguy is this fixed? I saw the errors format was improved a few times, e.g. https://github.com/tharsis/ethermint/pull/350 ?

tomtau avatar Oct 27 '21 09:10 tomtau

This issue is stale because it has been open 45 days with no activity. Remove Status: Stale label or comment or this will be closed in 7 days.

github-actions[bot] avatar Oct 05 '22 00:10 github-actions[bot]

I think it's fixed

yihuang avatar Oct 05 '22 05:10 yihuang

This issue is stale because it has been open 45 days with no activity. Remove Status: Stale label or comment or this will be closed in 7 days.

github-actions[bot] avatar Nov 21 '22 00:11 github-actions[bot]