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

Handle panic errors in EVM #1833

Open
DmytroNazarenko opened this issue Feb 26, 2024 · 0 comments
Open

Handle panic errors in EVM #1833

DmytroNazarenko opened this issue Feb 26, 2024 · 0 comments
Assignees
Milestone

Comments

@DmytroNazarenko
Copy link
Collaborator

Currently skaled is not handling Panic errors like other ethereum clients and returns revert message EVM revert instruction without description message instead. We need to handle internal errors and return the details in revertReason in the same format with Geth.

Map of Panic errors according to solidity doc (https://docs.soliditylang.org/en/v0.8.21/control-structures.html#panic-via-assert-and-error-via-require):

0x00: Used for generic compiler inserted panics.
0x01: If you call assert with an argument that evaluates to false.
0x11: If an arithmetic operation results in underflow or overflow outside of an unchecked { ... } block.
0x12; If you divide or modulo by zero (e.g. 5 / 0 or 23 % 0).
0x21: If you convert a value that is too big or negative into an enum type.
0x22: If you access a storage byte array that is incorrectly encoded.
0x31: If you call .pop() on an empty array.
0x32: If you access an array, bytesN or an array slice at an out-of-bounds or negative index (i.e. x[i] where i >= x.length or i < 0).
0x41: If you allocate too much memory or create an array that is too large.
0x51: If you call a zero-initialized variable of internal function type.

Implementation in go-ethereum: https://github.com/ethereum/go-ethereum/blob/63aaac81007ad46b208570c17cae78b7f60931d4/accounts/abi/abi.go#L258

Example of GETH response:

curl GOERLI_URL -X POST -H "Content-Type: application/json" -d  '{"id":1931024001,"jsonrpc":"2.0","method":"eth_call","params":[{"data":"0x0e955ddb000000000000000000000000000000000000000000000000000000000000000b000000000000000000000000000000000000000000000000000000000000000b","from":"0xa68F946090c600eDa6f139783077EE802Afeb990","to":"0x0139D5EA708C7Fb2e668E032608a65d482e754cB","type":"0x1","value":"0x0"},"latest"]}'
{"jsonrpc":"2.0","id":1931024001,"error":{"code":3,"data":"0x4e487b710000000000000000000000000000000000000000000000000000000000000032","message":"execution reverted: out-of-bounds access of an array or bytesN"}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Ready For Pickup
Development

No branches or pull requests

2 participants