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

chainHead: Define error codes returned by the server #117

Merged
merged 8 commits into from
Nov 28, 2023

Conversation

lexnv
Copy link
Contributor

@lexnv lexnv commented Nov 27, 2023

This PR defined the error codes returned by the server:

  • -32800 two or more subscriptions requested for chainHead_follow
  • -32801 block hash not reported by chainHead_follow or block hash has been unpinned
  • -32802 chainHead_follow started with withRuntime == false
  • -32803 chainHead_follow did not generate an operationWaitingForContinue event

The following are errors defined in the JSON-RPC spec:

This is done for consistency reasons, since at the moment the chainHead_follow is the only method that has an associated return code, although the other methods could still generate JSON-RPC errors.
This ensures interoperability as both substrate and light-client implementations will return similar codes.

cc @tomaka @jsdw @josepot @bkchr

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
@tomaka
Copy link
Contributor

tomaka commented Nov 28, 2023

The server was unable to generate a valid subscription ID (https://github.com/paritytech/polkadot-sdk/blob/21f1811c6600d8a7fe043592ff34dcb79284d583/substrate/client/rpc-spec-v2/src/chain_head/chain_head.rs#L198-L204)

Note that this shouldn't be a legitimate error. Subscription IDs can be strings, so there is an infinite number of possible IDs. Even if it wasn't infinite, the spec mentions that there's a maximum number of simultaneous chainHead_follow subscriptions. I don't see in which world you can't generate a subscription ID.

lexnv and others added 2 commits November 28, 2023 15:04
Co-authored-by: Pierre Krieger <pierre.krieger1708@gmail.com>
Co-authored-by: Pierre Krieger <pierre.krieger1708@gmail.com>
Copy link

@tadeohepperle tadeohepperle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@lexnv
Copy link
Contributor Author

lexnv commented Nov 28, 2023

Thanks for the reviews 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants