From 1cf71d17bdb4822a027ef6754ea2a870b78c3c78 Mon Sep 17 00:00:00 2001 From: Rod Vagg Date: Thu, 8 Jan 2026 22:43:52 +1100 Subject: [PATCH 1/2] fix(eth): use error code 3 for EExecutionReverted 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: https://github.com/ethereum/go-ethereum/pull/21083 Ref: https://github.com/ethereum/go-ethereum/pull/31456 Ref: https://github.com/ethereum/go-ethereum/issues/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/ --- api/api_errors.go | 4 ++-- itests/fevm_test.go | 28 ++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/api/api_errors.go b/api/api_errors.go index 3d4854261fd..480518ff099 100644 --- a/api/api_errors.go +++ b/api/api_errors.go @@ -19,7 +19,7 @@ var invalidExecutionRevertedMsg = xerrors.New("invalid execution reverted error" const ( EOutOfGas = iota + jsonrpc.FirstUserCode - EActorNotFound + EExecutionReverted EF3Disabled EF3ParticipationTicketInvalid EF3ParticipationTicketExpired @@ -27,7 +27,7 @@ const ( EF3ParticipationTooManyInstances EF3ParticipationTicketStartBeforeExisting EF3NotReady - EExecutionReverted + EActorNotFound ENullRound EPaymentChannelDisabled ) diff --git a/itests/fevm_test.go b/itests/fevm_test.go index 53daa49c815..8611f245b10 100644 --- a/itests/fevm_test.go +++ b/itests/fevm_test.go @@ -1066,6 +1066,34 @@ func TestFEVMErrorParsing(t *testing.T) { }) }) } + + // Verify that the raw JSON-RPC error code is 3, per Ethereum standard for execution reverted. + // See: https://github.com/ethereum/go-ethereum/pull/21083 (geth v1.9.15) + t.Run("RawErrorCode3", func(t *testing.T) { + entryPoint := kit.CalcFuncSignature("failRevertReason()") + + request := fmt.Sprintf(`{ + "jsonrpc": "2.0", + "id": 1, + "method": "eth_call", + "params": [{"to": "%s", "data": "0x%x"}, "latest"] + }`, contractAddrEth.String(), entryPoint) + + statusCode, responseBody := client.DoRawRPCRequest(t, 1, request) + require.Equal(t, 200, statusCode) + + var rpcResponse struct { + Error struct { + Code int `json:"code"` + Message string `json:"message"` + Data string `json:"data"` + } `json:"error"` + } + require.NoError(t, json.Unmarshal(responseBody, &rpcResponse)) + require.Equal(t, 3, rpcResponse.Error.Code, + "execution reverted error code must be 3 for Ethereum RPC compatibility (EIP-1474 de facto standard)") + require.NotEmpty(t, rpcResponse.Error.Data, "error response should include revert data") + }) } // TestEthGetBlockReceipts tests retrieving block receipts after invoking a contract From ae5fb597eedc5e83fb69176a9ba277b364dd1477 Mon Sep 17 00:00:00 2001 From: Rod Vagg Date: Thu, 8 Jan 2026 22:53:18 +1100 Subject: [PATCH 2/2] fixup! fix(eth): use error code 3 for EExecutionReverted --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 925fd418730..729c37d1b45 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,8 @@ ## 👌 Improvements - docs: fix outdated link in documentation ([#13436](https://github.com/filecoin-project/lotus/pull/13436)) - docs: fix dead link in documentation ([#13437](https://github.com/filecoin-project/lotus/pull/13437)) +- fix(eth): use error code 3 for EExecutionReverted for Ethereum RPC tooling compatibility ([filecoin-project/lotus#13467](https://github.com/filecoin-project/lotus/pull/13467)) + - BREAKING: RPC error codes changed - EActorNotFound (3→11), EExecutionReverted (11→3). Mismatched client/server versions will deserialize these errors as the wrong Go type, breaking errors.Is/As checks. # Node v1.34.3 / 2025-12-03