chainHead_storage: Backport queries for value types (#14551)

* chainHead/events: Add storage params and events

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* chainHead/tests: Check storage events serialization / deserialization

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* chainHead/error: Add error for invalid WaitForContinue storage call

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* chainHead/storage: Use new items params

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* chainHead/tests: Adjust storage tests to the new API

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* chainHead/events: Generalize StorageQuery by provided key

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* chain_head: Add dedicated ChainHeadStorage client for queries

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* chainHead/storage: Implement queries for hashes of values

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* chainHead/tests: Check storage queries for hashes of values

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* chainHead: Improve API documentation wrt multiple entries

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* chainHead/event: Rename StorageQueue ty to queue_ty

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* chianHead: Add helper to encode chainHead results as hex str

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* Update client/rpc-spec-v2/src/chain_head/error.rs

Co-authored-by: Sebastian Kunert <skunert49@gmail.com>

* chainHead: Change the `queryResult` to a plain `Result`

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* chainHead: Stop producing events after the first error

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* chainHead: Change child_key to child_trie API param

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

---------

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Co-authored-by: Sebastian Kunert <skunert49@gmail.com>
This commit is contained in:
Alexandru Vasile
2023-07-21 19:56:40 +03:00
committed by GitHub
parent 649be3aaaa
commit 1fef5ee4a4
7 changed files with 703 additions and 110 deletions
@@ -39,6 +39,9 @@ pub enum Error {
/// Invalid subscription ID provided by the RPC server.
#[error("Invalid subscription ID")]
InvalidSubscriptionID,
/// Wait-for-continue event not generated.
#[error("Wait for continue event was not generated for the subscription")]
InvalidContinue,
}
// Base code for all `chainHead` errors.
@@ -51,6 +54,8 @@ const FETCH_BLOCK_HEADER_ERROR: i32 = BASE_ERROR + 2;
const INVALID_PARAM_ERROR: i32 = BASE_ERROR + 3;
/// Invalid subscription ID.
const INVALID_SUB_ID: i32 = BASE_ERROR + 4;
/// Wait-for-continue event not generated.
const INVALID_CONTINUE: i32 = BASE_ERROR + 5;
impl From<Error> for ErrorObject<'static> {
fn from(e: Error) -> Self {
@@ -62,6 +67,7 @@ impl From<Error> for ErrorObject<'static> {
ErrorObject::owned(FETCH_BLOCK_HEADER_ERROR, msg, None::<()>),
Error::InvalidParam(_) => ErrorObject::owned(INVALID_PARAM_ERROR, msg, None::<()>),
Error::InvalidSubscriptionID => ErrorObject::owned(INVALID_SUB_ID, msg, None::<()>),
Error::InvalidContinue => ErrorObject::owned(INVALID_CONTINUE, msg, None::<()>),
}
.into()
}