fix(eth): use error code 3 for EExecutionReverted#13467
Conversation
BREAKING: RPC error codes changed - EActorNotFound (from 3 to 11), EExecutionReverted (from 11 to 3). Mismatched client/server versions will deserialize these errors as the wrong Go type, breaking errors.Is/As checks. Swap EExecutionReverted and EActorNotFound positions so that EExecutionReverted gets code 3, the de facto Ethereum standard for execution reverted errors. This enables proper error decoding by Ethereum tooling like viem, ethers.js, and other RPC clients. Error code 3 was introduced in geth v1.9.15 and is now expected by most Ethereum ecosystem tooling for automatic ABI decoding of revert reasons from the error data field. Ref: ethereum/go-ethereum#21083 Ref: ethereum/go-ethereum#31456 Ref: ethereum/go-ethereum#21886 Ref: https://github.com/wevm/viem/blob/6c11882938673e939830027f47ed73e907f2b90e/src/utils/errors/getContractError.ts Ref: https://www.quicknode.com/docs/ethereum/error-references Ref: https://docs.metamask.io/services/reference/ethereum/json-rpc-methods/eth_call/
There was a problem hiding this comment.
Pull request overview
This pull request swaps the error code positions of EExecutionReverted and EActorNotFound to align with Ethereum ecosystem standards. The swap ensures EExecutionReverted gets error code 3, which is the de facto standard in Ethereum tooling (established in geth v1.9.15) for automatic ABI decoding of revert reasons.
Key changes:
EExecutionRevertedmoved from position 10 (code 11) to position 1 (code 3) in the error constant enumerationEActorNotFoundmoved from position 1 (code 3) to position 9 (code 11) in the error constant enumeration- Added a new integration test to verify the raw JSON-RPC error code is 3 for execution reverted errors
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| api/api_errors.go | Swapped positions of EExecutionReverted and EActorNotFound in the const block to change their error codes |
| itests/fevm_test.go | Added test case RawErrorCode3 to verify that execution reverted errors return JSON-RPC error code 3 for Ethereum compatibility |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@LesnyRumcajs : I see you have a corresponding change in Forest. Are you able to give a quick review of this change? It realistically may be the only eyes we get on this work anytime soon... |
|
I've not had any objections from elsewhere about this so with a review we can just pull the trigger and make it happen. |
LesnyRumcajs
left a comment
There was a problem hiding this comment.
LGTM. Happy to port it to Forest.
nit: the PR name should have ! to indicate the breaking change. Might help some folks that jump straight into PR/commit history (via web) without looking at the changelog.
|
@BigLep FYI the PR requires review/approval from a maintainer with write permissions. |
BigLep
left a comment
There was a problem hiding this comment.
Proxy approval on behalf of @LesnyRumcajs per #13467 (comment)
BREAKING: RPC error codes changed - EActorNotFound (from 3 to 11), EExecutionReverted (from 11 to 3). Mismatched client/server versions will deserialize these errors as the wrong Go type, breaking errors.Is/As checks.
Swap EExecutionReverted and EActorNotFound positions so that EExecutionReverted gets code 3, the de facto Ethereum standard for execution reverted errors. This enables proper error decoding by Ethereum tooling like viem, ethers.js, and other RPC clients.
Error code 3 was introduced in geth v1.9.15 and is now expected by most Ethereum ecosystem tooling for automatic ABI decoding of revert reasons from the error data field.
Ref: ethereum/go-ethereum#21083
Ref: ethereum/go-ethereum#31456
Ref: ethereum/go-ethereum#21886
Ref: https://github.com/wevm/viem/blob/6c11882938673e939830027f47ed73e907f2b90e/src/utils/errors/getContractError.ts
Ref: https://www.quicknode.com/docs/ethereum/error-references
Ref: https://docs.metamask.io/services/reference/ethereum/json-rpc-methods/eth_call/