Skip to content
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

feat(api): Introduce Error Codes for Node RPC #3529

Open
6 tasks
walldiss opened this issue Jun 26, 2024 · 1 comment
Open
6 tasks

feat(api): Introduce Error Codes for Node RPC #3529

walldiss opened this issue Jun 26, 2024 · 1 comment
Labels
area:api Related to celestia-node API enhancement New feature or request

Comments

@walldiss
Copy link
Member

Implementation ideas

The JSON-RPC specification mandates the return of an error object with specific codes for failed requests (see JSON-RPC Error Specification). Our current node API implementation only provides data or a generic error message, omitting these specific error codes. As we continue to develop a comprehensive canonical API that will address this in the future, we can start improving our existing API by introducing error codes for common error scenarios. Initially, we don’t need a full set of refined error codes; we can implement a basic set and expand and refine these codes gradually based on user feedback and system requirements.

To streamline this process, we should establish an infrastructure to wrap all errors in a generic "Internal error" code, which can later be detailed into more specific codes as we refine our error handling strategy. This initial step will help standardize our error responses and make them more predictable for API users.

Implementation ideas

Node may utilise go-jsonrpc existing functionality for error codes, by providing global map of error codes to server and client via WithErrors option: https://github.com/filecoin-project/go-jsonrpc/blob/e75dcdc8133848b9b60335d5779e3af1ac3cb447/options.go#L88
It will allow go clients to use golang native errors.Is call to identify which error is returned. Other language clients would need to parse error code from response json object and map it to proper error value.

Some basic error codes that were requested include:

Cross posted from #3335 (comment) :

  • "rpc error: code = Unknown desc = timed out waiting for tx to be included in a block" error is returned frequently possibly due to 1) mempool congestion 2) big blobs 3) too small timeout_broadcast_tx_commit
  • ": tx already in mempool" always happens immediately after the above error and requires waiting out until the tx drops from the mempool
  • ": incorrect account sequence" occasionally happens in place of the above error but also requires waiting out until the tx drops from the mempool
  • rpc error: code = Unknown desc = error on broadcastTxCommit: tx size is too big: 1962442, max: 1962441 happens when submitting big blobs due to padding shares even though the supposed limit is 1974272 so this breaks the contract with node.
  • rpc error: code = Unknown desc = error on broadcastTxCommit: tx too large occasionally big blobs return this in place of the above. I see that there's also Tx too large. Max size is %d, but got %d in the code.

Adding error codes will enhance error traceability and debugging, making our API more robust and user-friendly in the interim period before the canonical API rollout.

@walldiss walldiss added enhancement New feature or request area:api Related to celestia-node API labels Jun 26, 2024
@liamsi

This comment was marked as duplicate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:api Related to celestia-node API enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants