ethereum / execution-apis

Collection of APIs provided by Ethereum execution layer clients
Creative Commons Zero v1.0 Universal
908 stars 352 forks source link

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

Open smartprogrammer93 opened 5 months ago

smartprogrammer93 commented 5 months ago

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.

smartprogrammer93 commented 5 months ago

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."

smartprogrammer93 commented 5 months ago

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