Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[EVM] EVM.dryRun method inconsistent behavior for certain errors #5902

Closed
m-Peter opened this issue May 13, 2024 · 0 comments · Fixed by #5909
Closed

[EVM] EVM.dryRun method inconsistent behavior for certain errors #5902

m-Peter opened this issue May 13, 2024 · 0 comments · Fixed by #5909
Assignees

Comments

@m-Peter
Copy link
Contributor

m-Peter commented May 13, 2024

When the RLP encoded tx passed to EVM.dryRun, has fund errors, the Cadence script/tx panics, for example:

curl --silent -XPOST 'localhost:8545' --header 'Content-Type: application/json' --data-raw '{"jsonrpc":"2.0","method":"eth_call","params":[{"from":"0x658bdf435d810c91414ec09147daa6db62406379","to":"0x99466ed2e37b892a2ee3e9cd55a98b68f5735db2","gas":"0x76c0","gasPrice":"0x0","value":"0xf0","input":"0xc6888fa10000000000000000000000000000000000000000000000000000000000000006"}, "latest"],"id":4}' | jq
{
  "jsonrpc": "2.0",
  "id": 4,
  "error": {
    "code": -32000,
    "message": "failed to execute script: client: rpc error: code = InvalidArgument desc = [Error Code: 1300] error caused by: 1 error occurred:\n\t* [Error Code: 1101] cadence runtime error: Execution failed:\n --> 072a06e8ab6b5fab43516dc56e1a9f9f67283df4d15ae0cc9f992c19df8a4611:8:11\n  |\n8 |     return EVM.dryRun(tx: hexEncodedTx.decodeHex(), from: address)\n  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\nerror: [Error Code: 1300] evm runtime error: insufficient funds for gas * price + value: address 0x658Bdf435d810C91414eC09147DAA6DB62406379 have 0 want 240\n   --> f8d6e0586b0a20c7.EVM:477:8\n    |\n477 |         return InternalEVM.dryRun(\n478 |             tx: tx,\n479 |             from: from.bytes,\n480 |         ) as! Result\n    |         ^^^^^^^^^^^^\n\n\n"
  }
}

However, when there is a different error occurring, the Cadence script/tx returns an EVM.Result struct with the proper errorCode, for example:

curl -XPOST --silent 'localhost:8545' --header 'Content-Type: application/json' --data-raw '{"jsonrpc":"2.0","method":"eth_call","params":[{"from":"0x658bdf435d810c91414ec09147daa6db62406379","to":"0x99466ed2e37b892a2ee3e9cd55a98b68f5735db2","gas":"0x539C","gasPrice":"0x0","value":"0x0","input":"0xc6888fa10000000000000000000000000000000000000000000000000000000000000006"}, "latest"],"id":4}' | jq
{
  "jsonrpc": "2.0",
  "id": 4,
  "error": {
    "code": -32000,
    "message": "out of gas"
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants