JSON RPC Error codes standardization using open-rpc extension specs#650
JSON RPC Error codes standardization using open-rpc extension specs#650simsonraj wants to merge 31 commits intoethereum:mainfrom
Conversation
Error groups - Extended open-rpc spec sample implementation
Co-authored-by: Zane Starr <zcstarr@gmail.com>
|
STOP THIS A.I. SLOP NOW!!!!!!!!!!!! |
|
@sambacha this is not AI, but the culmination of many months and pretty close to a year of work, to put together a PR that can help move the ecosystem forward. If you have a criticism of the PR or something about it's content please feel free to comment with something constructive or instructive. If you don't have anything constructive to add to this conversation, please refrain from spamming the PR with comments |
meta data extension
Co-authored-by: Zane Starr <zcstarr@gmail.com>
Sync main again
Sync main again
|
One thing to note, is that there is no requirement for RPC errors to be negative numbers. The JSON-RPC specification itself uses a specific range of negative numbers for its errors, but the predefined errors are just for reporting protocol-level faults. The entire range of positive integer values is available to us, so we should use it. |
| message: "INVALID_OPCODE" | ||
| data: "An invalid opcode was encountered during execution" | ||
| x-error-category: "EXECUTION_ERRORS" | ||
| - code: -31604 |
There was a problem hiding this comment.
Same with this one, what is the meaning of this particular code? The term "step counters" has no defined meaning in Ethereum.
There was a problem hiding this comment.
This is ZK stack specific, I will move this out to a separate category
Co-authored-by: Sally MacFarlane <macfarla.github@gmail.com>
Co-authored-by: Sally MacFarlane <macfarla.github@gmail.com>
Co-authored-by: Sally MacFarlane <macfarla.github@gmail.com>
Co-authored-by: Sally MacFarlane <macfarla.github@gmail.com>
|
We have just rewritten the spec build system in Go. For this change, it means we will have to find another way to integrate the error groups into the YAML files, but I think it's for the better anyway. The spec extension always felt a bit much, and it is something every single tool would have to support to use the spec possibly. Let's just implement this in a pragmatic way. We can define the error groups in a separate YAML file and change the |
|
@fjl From OpenRPC here, just for clarity every tool in OpenRPC ecosystem implements the extensions and extension framework. Is there some complication in the implementation of spec gen that is preventing you from supporting extensions? It's how we support OpenRPC specification upgrades(it's a part of the process) and application specific extensions. We've had more explicit support/clarity for extensions for about two years, and before then x-(extensions) have always been apart of the spec maybe 7 years. All extensions are defined within the doc or may be externally referenced, but for the most part are inlined in the specification itself, so it's not that tools will need some other system to then deal with the extension. If you're a downstream consumer of the spec the expectation is that you'll have the spec and therefore knowledge of the extension that is in use. We're also adding additional extensions that will support bidirectional signaling for client/server relations and pub/sub so, it's an increasingly important aspect of the spec. In other things with regards to specgen, I wouldn't worry too deeply about linting, as we have a linter that we're rolling out at the end of Apr, that will allow you to place rules to the spec to keep the spec implementation clean. I assume that no refs or feature bans like allOf are things that we will be able to specify fairly easy as a lint rule. I'm just mentioning it here so if there something with regards to linting or general OpenRPC concerns can like address/capture them. |
|
It works a bit different now. Since we have the tool right here, we can apply any transform on our input files. I like the idea with error groups, but it doesn't make sense for me to have this feature in the JSON output. And how will we document it anyway? In the end, what matters is that each method has a set of errors that can be produced, and they have to have unique codes. There is some value in documenting the group association of errors, but I see it more like a secondary concern. For the validation (speccheck), we'd have to implement the extension as well. I think it's best to add the error codes in the YAML and change specgen to copy them into each method for now. We can use the extension in the spec JSON later by simply changing specgen again. |
|
This is similar to how we handle allOf and $ref. They are standard features of JSON-Schema but our tool processes them to make it easier for consumers of the spec. The spec consumers don't have to implement JSON-pointer because we resolve everything. AFAIK we remove allOf because it makes the documentation complicated, certainly it is easier to understand the input format when it is given as a simple alternation instead of a union of constraints. |
|
It makes sense to have a native expansion and parse tool for sure. To answer your question about documentation, documentation for x-error-groups is already implemented across the tools in open-rpc. Playground, docs gen, inspector... . Visually in the docs, it appears as the errors currently do, and if there's a category it shows the category there as well. I agree that speccheck would then need to do the full validation if it were to support extensions. We like that you're doubling down on the golang tooling infrastructure, we'd like to offer our support to make that better and more fully supported. We're currently working on tooling for this repo, it'd be great to sync with both you and @lightclient , because I think there's alot of overlap, and opportunity to make things better! |
@fjl Just to clarify, the errors are already inlined per method, flattened & de-referenced. |
Goal
A standard for JSON-RPC error codes and messages across EVM-compatible chains and execution clients to improve interoperability, facilitate consistent error handling, and provide a better developer experience.
Motivation
Different Ethereum clients and EVM-compatible chains often use overlapping error codes or generic messages in their JSON-RPC API responses. This inconsistency confuses end users and developers, complicates cross-client tooling, and hampers interoperability.
Solution Abstract
Reserved ranges at a glance
GAS_ERRORSgas-error-groups.yamlEXECUTION_ERRORSexecution-errors.yamlTXPOOL_ERRORStxpool-errors.yamlZK_EXECUTION_ERRORSzk-execution-errors.yaml