-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
EIP RPC errors #136
Comments
I love this, and think it will make error handling much easier for developers. I'd also like to see a tx_rejected error code for when the user rejects the transaction.
|
This is not entirely correct. The -32000..-32099 range is meant to be used for server errors, i.e. RPC protocol violations that are not covered by the spec. Codes from this range could be used for "invalid hex" and similar errors. Application errors can use any error code, positive numbers are acceptable too. Since the available integer range is so big, it would be much simpler to ignore categories and define a separate error code number for each specific condition, e.g. (100: invalid transaction nonce, 101: unable to sign transaction, 102: insufficient funds, 103: gas price too low, 104: no such account, ...). One important question is the definitive list of errors that must be detected by every compliant implementation of the web3 API. The list you have covers errors for eth_sendTransaction. Are there any other errors that should be included for the initial version of this spec? |
I would like to add "Unsupported" error code which would be a good way for Metamask style sub-providers to tell the client to use a different provider. Not sure if NOT FOUND can be used in this instance... |
Can anyone let me know that what is the meaning of Error: known transaction ?Please |
can anyone tell how far along is this? or this has already been implemented, thanks! |
I haven't really thought through this yet, but in my experience there is value in classifying errors broadly into "retriable" or not. That is, is it possible that if the app were to try again that the transaction will succeed or will the transaction definitely not succeed no matter how many times it is tried. User rejected or gas too low, for example, is a retryable error while a malformed transaction is a non-retryable error. |
Hi @bas-vk. Do you plan to formalize this proposal into an EIP and submit a pull request? |
I think @bas-Vlad is not very active anymore. Somebody needs to overtake that. |
Thanks @frozeman. I'm finishing an EIP to formalize the current RPC specification so it doesn't only exist in a wiki. I'll either roll this error handling into that RPC EIP, or submit this as a separate EIP soon after. |
Problem
The RPC specification implements a subset of the JSON-RPC specification. It defines the available RPC methods together with in- and outputs and serialisation format. It however doesn't specify anything about the errors these methods can return. As a result implementations return different errors which makes it hard for DApp developers to act appropriately. Another problem is that currently there are no well defined errors codes. This causes some clients (e.g. Mist) to do string matching to determine what happened. This is brittle and not generic.
Proposal
Define a standard for Ethereum JSON-RPC errors. One of the problems is finding the correct balans between informing a DApp what happend and being not too specific. Being too specific will make it hard to become fully complient with the specification and would make DApp's more complicated. Being too generic DApps' won't be able to determine what happened.
This problem is tackled by introducing the concept of an error category and allow a node to supply optional extra information about an error. This allows a DApp to get a general understanding what went wrong by looking at the category error code. It also allow a node to provide additional information about an error which the DApp can decide to use.
This proposal contains 2 parts. First it describes how the errors are defined. The second part describes a list with standardized error categories and detailed error messages.
Error structure
JSON-RPC 2.0 has a section dedicated how errors are defined. The
code
field will be used for an error category. This field is mandatory and used by DApp's to get a general understanding what happend. Together with thecode
field themessage
field is filled with a brief description about the category. See for more information about available categories and their description the next section.The
data
field is an optional field. Nodes can decide to supply additonal information through this field. If a node provides detailed information the data field must be an array of objects with the following fields:By using this approach DApp's can get a general understanding what happend through the
code
field. In most cases this is sufficient. It also allow nodes to supply additional information when available.Error categories
The JSON-RPC 2.0 specification defines the range -32000 to -32099 for application specific errors.
Error details
If a node wants to send additional information about an error it can use the
data
field.It is worth noting that
99
is a general code that can be used in any of the categories. It allows a node to provide non-standarised information to a DApp. Also this table doesn't specify thedescription
field. Nodes are free to choose what they put into thedescription
field, it is allowed to omit thedescription
field.Example
Value transaction from an account with a balance of 0. The node determines this transaction will always fail and rejects the transaction. The returned error would look like:
The node doesn't uses the account management most implementations provides but forwards a transaction to an external signing service. When this service could not be reached the node can return the following error:
Required changes
The text was updated successfully, but these errors were encountered: