-
Notifications
You must be signed in to change notification settings - Fork 456
JSON RPC Error codes standardization using open-rpc extension specs #650
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
Open
simsonraj
wants to merge
29
commits into
ethereum:main
Choose a base branch
from
simsonraj:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+307
−1
Open
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
510cc9f
sample implementation
simsonraj 68efb67
Pulling the x-error-groups from open-rpc package
simsonraj b7da3a7
updated gastsby & docs generator
simsonraj 46a9906
few fixes
simsonraj 623c57a
Merge pull request #1 from simsonraj/error_groups
simsonraj 2500734
Merge branch 'ethereum:main' into main
simsonraj 721f190
Update scripts/build.js
simsonraj 3bd6d47
meta data extension
simsonraj 4eacff2
Merge pull request #2 from simsonraj/error_groups
simsonraj 53d5577
sample implementation
simsonraj 554443e
Pulling the x-error-groups from open-rpc package
simsonraj d3f6f22
updated gastsby & docs generator
simsonraj 8d1dd3c
few fixes
simsonraj 50113ef
Update scripts/build.js
simsonraj fc8aacc
meta data extension
simsonraj 1ded1ed
Merge pull request #4 from simsonraj/sync_main_again
simsonraj 019a359
fix package conflicts
simsonraj 2b7da45
fix packages
simsonraj 9b06027
Merge pull request #5 from simsonraj/sync_main_again
simsonraj 5c8daea
extended error categories & code ranges implementation
simsonraj 4019acd
Added TXPOOL errors, README file and fixes
simsonraj 527bb9a
Added context in README
simsonraj 89f012f
Update src/extensions/components/txpool-errors.yaml
simsonraj 75fb065
Update src/extensions/components/txpool-errors.yaml
simsonraj d3948f7
Update src/extensions/components/txpool-errors.yaml
simsonraj 490218e
Update src/extensions/components/txpool-errors.yaml
simsonraj 8ab56cf
updated & re-organized error ranges & codes after review
simsonraj bc78032
fix ranges
simsonraj f77a8f7
Removed Data & Updated Message for errors
simsonraj File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| # Extensions overview | ||
|
|
||
| ## Proposal | ||
| #### Goal | ||
| A standard for JSON-RPC error codes & ship a shared catalog of JSON-RPC error codes and messages for EVM clients to unlock consistent tooling and developer ergonomics. | ||
|
|
||
| #### Motivation | ||
| Client implementations and EVM-compatible chains currently reuse codes or return generic error messages, making cross-client debugging brittle. | ||
|
|
||
| #### Solution | ||
| The solution incorporates [OpenRPC's extension schemas](https://github.com/open-rpc/specification-extension-spec) feature, specifically `x-error-group` [extension](https://github.com/open-rpc/tools/blob/main/packages/extensions/src/x-error-groups/x-error-groups.json), so common scenarios can be bundled into reusable categories, each backed by a reserved range of **200 codes** outside the JSON-RPC 2.0 reserved bands. | ||
| With the error grouping and inline provisioning offered by the extension schemas, we could onboard methods over time with granular control over the errors or groups each method would need to handle without copy pasting in the final spec. | ||
|
|
||
| The corresponding PR definition frames these groups as the canonical vocabulary for wallets, infra providers, and execution clients. | ||
|
|
||
| ## Solution Layout | ||
| - `components/` – YAML fragments exposing each error family as an OpenRPC `x-error-group` definition. | ||
| - `schemas/x-error-category-ranges.json` – Extension to official `x-error-groups` that enforces the reserved integer windows per category during validation. | ||
| - This is to achieve inbuild validation of the reserved ranges per category using native `minimum` & `maximum` properties of the extended schema. | ||
| - Validation happens while running `scripts/validate.js` after building the final `refs-openrpc.json` / `openrpc.json`. | ||
| - `scripts/build.js` – Loads the schema above, augments the `XErrorGroupsJSON` extension, and merges the groups into `refs-openrpc.json` / `openrpc.json`. | ||
|
|
||
| ## Implemented Methods | ||
| Currently, only below methods import all the error groups via `$ref` and may include inline method-specific codes while still inheriting the standard set. | ||
| - `eth_sendTransaction` in `src/eth/submit.yaml` | ||
| - `eth_sendRawTransaction` in `src/eth/submit.yaml` | ||
|
|
||
|
|
||
| ## Reserved ranges at a glance | ||
| | Extension group | Category label | Reserved range | Source | | ||
| | --- | --- | --- | --- | | ||
| | JSON-RPC standard | — | $-32768$ to $-32000$ | JSON-RPC 2.0 spec | | ||
| | JSON-RPC non-standard | Client-specific | $-32099$ to $-32000$ | JSON-RPC 2.0 addendum | | ||
| | Gas errors | `GAS_ERRORS` | $800$ to $999$ | `gas-error-groups.yaml` | | ||
| | Execution errors | `EXECUTION_ERRORS` | $1$ to $999$ | `execution-errors.yaml` | | ||
| | TxPool errors | `TXPOOL_ERRORS` | $1000$ to $1199$ | `txpool-errors.yaml` | | ||
| | ZK execution errors | `ZK_EXECUTION_ERRORS` | $2000$ to $2199$ | `zk-execution-errors.yaml` | | ||
|
|
||
|
|
||
| **Validation** of these bands happens through `XErrorGroupsJSON.schema` in `scripts/build.js`, so build failures flag any out-of-range additions early. | ||
|
|
||
|
|
||
| ## Extending the catalog | ||
| 1. Pick or create a YAML fragment under `components/` and add the new entry with `code`, `message`, `data`, and `x-error-category` per the proposal. | ||
| 2. Stay within the reserved window; the JSON Schema guard in `schemas/x-error-category-ranges.json` will break the build if you drift. | ||
| 3. Reference the group from the relevant method spec via `$ref: '#/components/x-error-group/<GroupName>'` and layer any bespoke errors inline. | ||
| 4. Run the documentation build (e.g. `node scripts/build.js`) to regenerate `refs-openrpc.json` / `openrpc.json` and confirm validation passes. | ||
|
|
||
| Following this flow keeps the execution client surface aligned with the standard and preserves interoperability for downstream consumers. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| x-error-group: | ||
| ExecutionErrors: | ||
| - code: 1 | ||
| message: "Nonce too low" | ||
| x-error-category: "EXECUTION_ERRORS" | ||
| - code: 2 | ||
| message: "Nonce too high" | ||
| x-error-category: "EXECUTION_ERRORS" | ||
| - code: 3 | ||
| message: "Execution reverted by REVERT Opcode" | ||
| x-error-category: "EXECUTION_ERRORS" | ||
| - code: 4 | ||
| message: "Invalid opcode" | ||
| x-error-category: "EXECUTION_ERRORS" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| x-error-group: | ||
| GasErrors: | ||
| - code: 800 | ||
| message: "Intrinsic gas too low / Intrinsic gas exceeds gas limit" | ||
| x-error-category: "GAS_ERRORS" | ||
| - code: 801 | ||
| message: "Insufficient gas for floor data gas cost" | ||
| x-error-category: "GAS_ERRORS" | ||
| - code: 802 | ||
| message: "Tx gas limit exceeds max block gas limit / intrinsic gas exceeds gas limit" | ||
| x-error-category: "GAS_ERRORS" | ||
| - code: 803 | ||
| message: "Transaction gas limit too high" | ||
| - code: 804 | ||
| message: "Gas price below configured minimum gas price / transaction gas price below minimum" | ||
| x-error-category: "GAS_ERRORS" | ||
| - code: 805 | ||
| message: "Insufficient funds for gas * price + value / Upfront cost exceeds account balance" | ||
| x-error-category: "GAS_ERRORS" | ||
| - code: 806 | ||
| message: "Max priority fee per gas higher than max fee per gas" | ||
| x-error-category: "GAS_ERRORS" | ||
| - code: 807 | ||
| message: "Tx fee exceeds the configured cap / Transaction fee cap exceeded" | ||
| x-error-category: "GAS_ERRORS" | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| x-error-group: | ||
| JSONRPCNonStandardErrors: | ||
| - code: -32000 | ||
| message: "Invalid input" | ||
| - code: -32001 | ||
| message: "Resource not found" | ||
| - code: -32002 | ||
| message: "Resource unavailable" | ||
| - code: -32003 | ||
| message: "Transaction rejected" | ||
| - code: -32004 | ||
| message: "Method not supported" | ||
| - code: -32005 | ||
| message: "Limit exceeded" | ||
| - code: -32006 | ||
| message: "JSON-RPC version not supported" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| x-error-group: | ||
| JSONRPCStandardErrors: | ||
| - code: -32700 | ||
| message: "Parse error" | ||
| - code: -32600 | ||
| message: "Invalid request" | ||
| - code: -32601 | ||
| message: "Method not found" | ||
| - code: -32602 | ||
| message: "Invalid params" | ||
| - code: -32603 | ||
| message: "Internal error" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| x-error-group: | ||
| TxPoolErrors: | ||
| - code: 1000 | ||
| message: "Transaction is already known to the transaction pool" | ||
| x-error-category: "TXPOOL_ERRORS" | ||
| - code: 1001 | ||
| message: "Replacement transaction is sent without the required price bump" | ||
| x-error-category: "TXPOOL_ERRORS" | ||
| - code: 1002 | ||
| message: "Oversized data: Transaction input data exceeds the allowed limit" | ||
| x-error-category: "TXPOOL_ERRORS" | ||
| - code: 1003 | ||
| message: "Only replay-protected (EIP-155) transactions allowed over RPC" | ||
| x-error-category: "TXPOOL_ERRORS" | ||
| - code: 1004 | ||
| message: "Transaction pool is full" | ||
| x-error-category: "TXPOOL_ERRORS" | ||
| - code: 1005 | ||
| message: "Transaction Data contains invalid RLP encoding" | ||
| x-error-category: "TXPOOL_ERRORS" | ||
| - code: 1006 | ||
| message: "Transaction sender is invalid" | ||
| x-error-category: "TXPOOL_ERRORS" | ||
| - code: 1007 | ||
| message: "Transaction with negative value" | ||
| x-error-category: "TXPOOL_ERRORS" | ||
| - code: 1008 | ||
| message: "Transaction sender is denylisted" | ||
| x-error-category: "TXPOOL_ERRORS" | ||
| - code: 1009 | ||
| message: "Transaction receiver is denylisted" | ||
| x-error-category: "TXPOOL_ERRORS" | ||
| - code: 1010 | ||
| message: "Transaction chain ID does not match the expected chain ID" | ||
| x-error-category: "TXPOOL_ERRORS" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| x-error-group: | ||
| ZKExecutionErrors: | ||
| - code: 2000 | ||
| message: "Not enough step counters to continue the execution" | ||
| x-error-category: "ZK_EXECUTION_ERRORS" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| { | ||
| "type": "array", | ||
| "items": { | ||
| "oneOf": [ | ||
| { | ||
| "type": "array", | ||
| "items": { | ||
| "allOf": [ | ||
| { | ||
| "type": "object", | ||
| "properties": { | ||
| "code": { "type": "integer", "description": "The code of the error." }, | ||
| "message": { "type": "string", "description": "The message of the error." }, | ||
| "data": {"description": "The data of the error." }, | ||
| "x-error-category": { "type": "string"} | ||
| }, | ||
| "required": ["code", "message"] | ||
| }, | ||
| { | ||
| "if": { | ||
| "properties": { | ||
| "x-error-category": { "const": "GAS_ERRORS" } | ||
| }, | ||
| "required": ["x-error-category"] | ||
| }, | ||
| "then": { | ||
| "properties": { | ||
| "code": { "type": "integer", "minimum": 800, "maximum": 999 } | ||
| } | ||
| } | ||
| }, | ||
| { | ||
| "if": { | ||
| "properties": { | ||
| "x-error-category": { "const": "EXECUTION_ERRORS" } | ||
| }, | ||
| "required": ["x-error-category"] | ||
| }, | ||
| "then": { | ||
| "properties": { | ||
| "code": { "type": "integer", "minimum": 1, "maximum": 199 } | ||
| } | ||
| } | ||
| }, | ||
| { | ||
| "if": { | ||
| "properties": { | ||
| "x-error-category": { "const": "TXPOOL_ERRORS" } | ||
| }, | ||
| "required": ["x-error-category"] | ||
| }, | ||
| "then": { | ||
| "properties": { | ||
| "code": { "type": "integer", "minimum": 1000, "maximum": 1199 } | ||
| } | ||
| } | ||
| }, | ||
| { | ||
| "if": { | ||
| "properties": { | ||
| "x-error-category": { "const": "ZK_EXECUTION_ERRORS" } | ||
| }, | ||
| "required": ["x-error-category"] | ||
| }, | ||
| "then": { | ||
| "properties": { | ||
| "code": { "type": "integer", "minimum": 2000, "maximum": 2199 } | ||
| } | ||
| } | ||
| } | ||
| ] | ||
| } | ||
| }, | ||
| { | ||
| "type": "object", | ||
| "properties": { | ||
| "$ref": { "type": "string" } | ||
| }, | ||
| "required": ["$ref"] | ||
| } | ||
| ] | ||
| } | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just going to write this here for tracking purposes, that this works as a stopgap until we on the OpenRPC side have a better story for being able to apply extensions to json pointer references. If we have that then there's no need to overwrite the error group spec. You'll able to just push the two specs, here but we're still a little ways from that.