ethereum / execution-apis

Collection of APIs provided by Ethereum execution layer clients

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Standardise error response with error codes instead of strings for `eth_sendTransaction`, `eth_sendRawTransaction` and `eth_estimateGas`

smartprogrammer93 opened this issue · comments

Like seen in this issue, there is no standard error code response for such errors.
My opinion is that depending on strings is futile. and we should possibly try to depend on error codes for tx failure errors instead.
Geth implementation:
https://github.com/ethereum/go-ethereum/blob/master/core/error.go
and here
https://github.com/ethereum/go-ethereum/blob/master/core/types/transaction.go
and here
https://github.com/ethereum/go-ethereum/blob/master/core/txpool/errors.go
Neth implementation:
https://github.com/NethermindEth/nethermind/blob/master/src/Nethermind/Nethermind.TxPool/AcceptTxResult.cs
and possibly other places as well.

One thing to note is what @shemnon said on discord:
"This list should be prioritized, in case there are multiple things wrong with a single call."

from @fjl

At the moment, we only have a single custom error code: when eth_call or eth_estimateGas hits a revert, Geth returns error code 3
I have added a hive test to check this behavior and while other clients including Nethermind catch the revert and return an error, we do not all agree on the code in this situation
As a first step, I propose we come up with a list of error situations
Then we can assign the codes and add rpc-compat tests