Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

chainHead: Produce method responses on chainHead_follow #14692

Merged
merged 19 commits into from
Aug 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
4787dba
chainHead/api: Make storage/body/call pure RPC methods
lexnv Jul 27, 2023
8050811
chainHead: Add mpsc channel between RPC methods
lexnv Jul 27, 2023
3b30eb3
chainHead/subscriptions: Extract mpsc::Sender via BlockGuard
lexnv Jul 27, 2023
d5305a9
chainHead/subscriptions: Generate and provide the method operation ID
lexnv Jul 27, 2023
50c840d
chainHead: Generate `chainHead_body` response
lexnv Jul 27, 2023
6c5940c
chainHead: Generate `chainHead_call` response
lexnv Jul 27, 2023
589efa8
chainHead: Generate `chainHead_storage` responses
lexnv Jul 27, 2023
8062837
chainHead: Propagate responses of methods to chainHead_follow
lexnv Jul 27, 2023
4f7b445
chainHead/tests: Adjust `chainHead_body` responses
lexnv Jul 31, 2023
53fcd99
chainHead/tests: Adjust `chainHead_call` responses
lexnv Jul 31, 2023
167dd72
chainHead/tests: Adjust `chainHead_call` responses
lexnv Jul 31, 2023
35aca6d
chainHead/tests: Ensure unique operation IDs across methods
lexnv Jul 31, 2023
008fa22
chainHead/events: Remove old method events
lexnv Jul 31, 2023
0773aa2
Merge remote-tracking branch 'origin/master' into lexnv/chainhead_ext…
Jul 31, 2023
2e2fa9c
Merge remote-tracking branch 'origin/master' into lexnv/chainhead_ext…
Aug 1, 2023
1ace528
chainHead: Return `InvalidBlock` error if pinning fails
lexnv Aug 8, 2023
5679aa2
Merge remote-tracking branch 'origin/master' into lexnv/chainhead_ext…
lexnv Aug 8, 2023
e189a73
chainHead: Wrap subscription IDs
lexnv Aug 8, 2023
83afea8
chainHead/tests: Ensure separate operation IDs across subscriptions
lexnv Aug 8, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion client/rpc-spec-v2/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ sp-api = { version = "4.0.0-dev", path = "../../primitives/api" }
sp-blockchain = { version = "4.0.0-dev", path = "../../primitives/blockchain" }
sp-version = { version = "22.0.0", path = "../../primitives/version" }
sc-client-api = { version = "4.0.0-dev", path = "../api" }
sc-utils = { version = "4.0.0-dev", path = "../utils" }
codec = { package = "parity-scale-codec", version = "3.6.1" }
thiserror = "1.0"
serde = "1.0"
Expand All @@ -44,6 +45,5 @@ sp-consensus = { version = "0.10.0-dev", path = "../../primitives/consensus/comm
sp-maybe-compressed-blob = { version = "4.1.0-dev", path = "../../primitives/maybe-compressed-blob" }
sc-block-builder = { version = "0.10.0-dev", path = "../block-builder" }
sc-service = { version = "0.10.0-dev", features = ["test-helpers"], path = "../service" }
sc-utils = { version = "4.0.0-dev", path = "../utils" }
assert_matches = "1.3.0"
pretty_assertions = "1.2.1"
30 changes: 11 additions & 19 deletions client/rpc-spec-v2/src/chain_head/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#![allow(non_snake_case)]

//! API trait of the chain head.
use crate::chain_head::event::{ChainHeadEvent, FollowEvent, StorageQuery};
use crate::chain_head::event::{FollowEvent, MethodResponse, StorageQuery};
use jsonrpsee::{core::RpcResult, proc_macros::rpc};

#[rpc(client, server)]
Expand Down Expand Up @@ -47,12 +47,12 @@ pub trait ChainHeadApi<Hash> {
/// # Unstable
///
/// This method is unstable and subject to change in the future.
#[subscription(
name = "chainHead_unstable_body",
unsubscribe = "chainHead_unstable_stopBody",
item = ChainHeadEvent<String>,
)]
fn chain_head_unstable_body(&self, follow_subscription: String, hash: Hash);
#[method(name = "chainHead_unstable_body", blocking)]
fn chain_head_unstable_body(
&self,
follow_subscription: String,
hash: Hash,
) -> RpcResult<MethodResponse>;

/// Retrieves the header of a pinned block.
///
Expand Down Expand Up @@ -86,36 +86,28 @@ pub trait ChainHeadApi<Hash> {
/// # Unstable
///
/// This method is unstable and subject to change in the future.
#[subscription(
name = "chainHead_unstable_storage",
unsubscribe = "chainHead_unstable_stopStorage",
item = ChainHeadEvent<String>,
)]
#[method(name = "chainHead_unstable_storage", blocking)]
fn chain_head_unstable_storage(
&self,
follow_subscription: String,
hash: Hash,
items: Vec<StorageQuery<String>>,
child_trie: Option<String>,
);
) -> RpcResult<MethodResponse>;

/// Call into the Runtime API at a specified block's state.
///
/// # Unstable
///
/// This method is unstable and subject to change in the future.
#[subscription(
name = "chainHead_unstable_call",
unsubscribe = "chainHead_unstable_stopCall",
item = ChainHeadEvent<String>,
)]
#[method(name = "chainHead_unstable_call", blocking)]
fn chain_head_unstable_call(
&self,
follow_subscription: String,
hash: Hash,
function: String,
call_parameters: String,
);
) -> RpcResult<MethodResponse>;

/// Unpin a block reported by the `follow` method.
///
Expand Down
Loading