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
@@ -19,7 +19,7 @@
#![allow(non_snake_case)]
//! API trait of the chain head.
use crate::chain_head::event::{ChainHeadEvent, FollowEvent, NetworkConfig};
use crate::chain_head::event::{ChainHeadEvent, FollowEvent, NetworkConfig, StorageQuery};
use jsonrpsee::{core::RpcResult, proc_macros::rpc};
#[rpc(client, server)]
@@ -86,7 +86,7 @@ pub trait ChainHeadApi<Hash> {
#[method(name = "chainHead_unstable_genesisHash", blocking)]
fn chain_head_unstable_genesis_hash(&self) -> RpcResult<String>;
/// Return a storage entry at a specific block's state.
/// Returns storage entries at a specific block's state.
///
/// # Unstable
///
@@ -100,8 +100,8 @@ pub trait ChainHeadApi<Hash> {
&self,
follow_subscription: String,
hash: Hash,
key: String,
child_key: Option<String>,
items: Vec<StorageQuery<String>>,
child_trie: Option<String>,
network_config: Option<NetworkConfig>,
);