chainHead: Backport error codes from spec (#2539)
This PR backports the error codes from the spec.
This relies on two specs for defining the error codes:
- Our rpc-spec-v2 https://github.com/paritytech/json-rpc-interface-spec.
- JSON-RPC spec https://www.jsonrpc.org/specification#error_object.
To better describe the error codes, they are divided into two separate
modules `rpc_spec_v2` and `json_rpc_spec` respectively.
The `InvalidSubscriptionID` and `FetchBlockHeader` are merged into the
JSON-RPC spec `INTERNAL_ERROR`.
While the other error codes are adjusted from spec.
Errors that are currently in use:
- -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](https://www.jsonrpc.org/specification#error_object):
- -32602 The provided parameter isn't one of the expected values, has
different format or is missing
- -32603 Internal server error
Note: Error `-32801` must be introduced and generated by the outstanding
https://github.com/paritytech/polkadot-sdk/issues/1505
Closes: https://github.com/paritytech/polkadot-sdk/issues/2530
---------
Signed-off-by:
Alexandru Vasile <alexandru.vasile@parity.io>
parent
eb46b99b
Branches
Pipeline
#419955
passed
with stages
in
46 minutes and 26 seconds
Stage:
Stage:
Stage:
Stage:
Stage:
Stage:
Showing
- substrate/client/rpc-spec-v2/src/chain_head/chain_head.rs 5 additions, 3 deletionssubstrate/client/rpc-spec-v2/src/chain_head/chain_head.rs
- substrate/client/rpc-spec-v2/src/chain_head/error.rs 37 additions, 27 deletionssubstrate/client/rpc-spec-v2/src/chain_head/error.rs
- substrate/client/rpc-spec-v2/src/chain_head/tests.rs 12 additions, 12 deletionssubstrate/client/rpc-spec-v2/src/chain_head/tests.rs
Please register or sign in to comment