Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
2d7bcdf
Bump jsonrpsee to v0.15.1
lexnv Jul 29, 2022
595b1b9
Update cargo.lock
lexnv Jul 29, 2022
4a63c48
rpc-servers: Adjust RpcMiddleware to WS and HTTP traits
lexnv Jul 29, 2022
4e897e1
rpc/author: Use `SubscriptionSink`
lexnv Jul 29, 2022
eba2554
rpc/chain: Use `SubscriptionSink`
lexnv Jul 29, 2022
0b7ba7f
rpc/state: Use `SubscriptionSink`
lexnv Jul 29, 2022
5ad1b56
rpc/finality-grandpa: Use `SubscriptionSink`
lexnv Jul 29, 2022
264dd45
rpc/beefy: Use `SubscriptionSink`
lexnv Jul 29, 2022
03159c9
client: Extract RPC string result from queries
lexnv Jul 29, 2022
fd14381
Apply rust-fmt
lexnv Jul 29, 2022
ac5ed14
Fix warnings
lexnv Jul 29, 2022
6546ff3
Fix testing
lexnv Jul 29, 2022
bb7df13
Merge remote-tracking branch 'origin/master' into jsonrpsee_v0.15.1
lexnv Jul 29, 2022
102d8f6
rpc/tests: Remove trailing comma
lexnv Aug 1, 2022
320c0b5
rpc: Use `SubscriptionResult` for implementations
lexnv Aug 1, 2022
bf603c1
rpc: Remove comment
lexnv Aug 1, 2022
f60cb16
rpc: Delegate middleware calls to `RpcMiddleware`
lexnv Aug 1, 2022
8f447a7
rpc: Remove comment
lexnv Aug 1, 2022
baa6127
Revert Cargo.lock
lexnv Aug 1, 2022
1ac4370
Merge remote-tracking branch 'origin/master' into jsonrpsee_v0.15.1
lexnv Aug 1, 2022
c9592c3
Update Cargo.lock with minimal changes
lexnv Aug 1, 2022
4034180
rpc: Update imports for `SubscriptionResult`
lexnv Aug 1, 2022
af488aa
Apply cargo fmt
lexnv Aug 1, 2022
08b2108
Merge remote-tracking branch 'origin/master' into jsonrpsee_v0.15.1
lexnv Aug 2, 2022
36cf278
rpc/tests: Submit raw json requests to validate DenyUnsafe
lexnv Aug 2, 2022
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
52 changes: 29 additions & 23 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion bin/node-template/node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ frame-system = { version = "4.0.0-dev", path = "../../../frame/system" }
pallet-transaction-payment = { version = "4.0.0-dev", default-features = false, path = "../../../frame/transaction-payment" }

# These dependencies are used for the node template's RPCs
jsonrpsee = { version = "0.14.0", features = ["server"] }
jsonrpsee = { version = "0.15.1", features = ["server"] }
sc-rpc = { version = "4.0.0-dev", path = "../../../client/rpc" }
sp-api = { version = "4.0.0-dev", path = "../../../primitives/api" }
sc-rpc-api = { version = "0.10.0-dev", path = "../../../client/rpc-api" }
Expand Down
2 changes: 1 addition & 1 deletion bin/node/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ crate-type = ["cdylib", "rlib"]
clap = { version = "3.1.18", features = ["derive"], optional = true }
codec = { package = "parity-scale-codec", version = "3.0.0" }
serde = { version = "1.0.136", features = ["derive"] }
jsonrpsee = { version = "0.14.0", features = ["server"] }
jsonrpsee = { version = "0.15.1", features = ["server"] }
futures = "0.3.21"
hex-literal = "0.3.4"
log = "0.4.17"
Expand Down
2 changes: 1 addition & 1 deletion bin/node/rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ repository = "https://github.com/paritytech/substrate/"
targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
jsonrpsee = { version = "0.14.0", features = ["server"] }
jsonrpsee = { version = "0.15.1", features = ["server"] }
node-primitives = { version = "2.0.0", path = "../primitives" }
pallet-contracts-rpc = { version = "4.0.0-dev", path = "../../../frame/contracts/rpc/" }
pallet-mmr-rpc = { version = "3.0.0", path = "../../../frame/merkle-mountain-range/rpc/" }
Expand Down
2 changes: 1 addition & 1 deletion client/beefy/rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ homepage = "https://substrate.io"
[dependencies]
codec = { package = "parity-scale-codec", version = "3.0.0", features = ["derive"] }
futures = "0.3.21"
jsonrpsee = { version = "0.14.0", features = ["server", "macros"] }
jsonrpsee = { version = "0.15.1", features = ["server", "macros"] }
log = "0.4"
parking_lot = "0.12.0"
serde = { version = "1.0.136", features = ["derive"] }
Expand Down
21 changes: 10 additions & 11 deletions client/beefy/rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ use futures::{task::SpawnError, FutureExt, StreamExt};
use jsonrpsee::{
core::{async_trait, Error as JsonRpseeError, RpcResult},
proc_macros::rpc,
types::{error::CallError, ErrorObject},
PendingSubscription,
types::{error::CallError, ErrorObject, SubscriptionResult},
SubscriptionSink,
};
use log::warn;

Expand Down Expand Up @@ -135,19 +135,18 @@ impl<Block> BeefyApiServer<notification::EncodedSignedCommitment, Block::Hash> f
where
Block: BlockT,
{
fn subscribe_justifications(&self, pending: PendingSubscription) {
fn subscribe_justifications(&self, mut sink: SubscriptionSink) -> SubscriptionResult {
let stream = self
.signed_commitment_stream
.subscribe()
.map(|sc| notification::EncodedSignedCommitment::new::<Block>(sc));

let fut = async move {
if let Some(mut sink) = pending.accept() {
sink.pipe_from_stream(stream).await;
}
sink.pipe_from_stream(stream).await;
};

self.executor.spawn("substrate-rpc-subscription", Some("rpc"), fut.boxed());
Ok(())
}

async fn latest_finalized(&self) -> RpcResult<Block::Hash> {
Expand Down Expand Up @@ -197,9 +196,9 @@ mod tests {
let (rpc, _) = setup_io_handler();
let request = r#"{"jsonrpc":"2.0","method":"beefy_getFinalizedHead","params":[],"id":1}"#;
let expected_response = r#"{"jsonrpc":"2.0","error":{"code":1,"message":"BEEFY RPC endpoint not ready"},"id":1}"#.to_string();
let (result, _) = rpc.raw_json_request(&request).await.unwrap();
let (response, _) = rpc.raw_json_request(&request).await.unwrap();

assert_eq!(expected_response, result,);
assert_eq!(expected_response, response.result);
}

#[tokio::test]
Expand Down Expand Up @@ -229,8 +228,8 @@ mod tests {
let deadline = std::time::Instant::now() + std::time::Duration::from_secs(2);
while std::time::Instant::now() < deadline {
let (response, _) = io.raw_json_request(request).await.expect("RPC requests work");
if response != not_ready {
assert_eq!(response, expected);
if response.result != not_ready {
assert_eq!(response.result, expected);
// Success
return
}
Expand Down Expand Up @@ -260,7 +259,7 @@ mod tests {
.unwrap();
let expected = r#"{"jsonrpc":"2.0","result":false,"id":1}"#;

assert_eq!(response, expected);
assert_eq!(response.result, expected);
}

fn create_commitment() -> BeefySignedCommitment<Block> {
Expand Down
2 changes: 1 addition & 1 deletion client/consensus/babe/rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ readme = "README.md"
targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
jsonrpsee = { version = "0.14.0", features = ["server", "macros"] }
jsonrpsee = { version = "0.15.1", features = ["server", "macros"] }
futures = "0.3.21"
serde = { version = "1.0.136", features = ["derive"] }
thiserror = "1.0"
Expand Down
4 changes: 2 additions & 2 deletions client/consensus/babe/rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ mod tests {
let (response, _) = api.raw_json_request(request).await.unwrap();
let expected = r#"{"jsonrpc":"2.0","result":{"5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY":{"primary":[0],"secondary":[1,2,4],"secondary_vrf":[]}},"id":1}"#;

assert_eq!(&response, expected);
assert_eq!(&response.result, expected);
}

#[tokio::test]
Expand All @@ -274,6 +274,6 @@ mod tests {
let (response, _) = api.raw_json_request(request).await.unwrap();
let expected = r#"{"jsonrpc":"2.0","error":{"code":-32601,"message":"RPC call is unsafe to be called externally"},"id":1}"#;

assert_eq!(&response, expected);
assert_eq!(&response.result, expected);
}
}
2 changes: 1 addition & 1 deletion client/consensus/manual-seal/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ readme = "README.md"
targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
jsonrpsee = { version = "0.14.0", features = ["server", "macros"] }
jsonrpsee = { version = "0.15.1", features = ["server", "macros"] }
assert_matches = "1.3.0"
async-trait = "0.1.50"
codec = { package = "parity-scale-codec", version = "3.0.0" }
Expand Down
2 changes: 1 addition & 1 deletion client/finality-grandpa/rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ homepage = "https://substrate.io"
[dependencies]
finality-grandpa = { version = "0.16.0", features = ["derive-codec"] }
futures = "0.3.16"
jsonrpsee = { version = "0.14.0", features = ["server", "macros"] }
jsonrpsee = { version = "0.15.1", features = ["server", "macros"] }
log = "0.4.8"
parity-scale-codec = { version = "3.0.0", features = ["derive"] }
serde = { version = "1.0.105", features = ["derive"] }
Expand Down
20 changes: 10 additions & 10 deletions client/finality-grandpa/rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ use std::sync::Arc;
use jsonrpsee::{
core::{async_trait, RpcResult},
proc_macros::rpc,
PendingSubscription,
types::SubscriptionResult,
SubscriptionSink,
};

mod error;
Expand Down Expand Up @@ -102,20 +103,19 @@ where
ReportedRoundStates::from(&self.authority_set, &self.voter_state).map_err(Into::into)
}

fn subscribe_justifications(&self, pending: PendingSubscription) {
fn subscribe_justifications(&self, mut sink: SubscriptionSink) -> SubscriptionResult {
let stream = self.justification_stream.subscribe().map(
|x: sc_finality_grandpa::GrandpaJustification<Block>| {
JustificationNotification::from(x)
},
);

let fut = async move {
if let Some(mut sink) = pending.accept() {
sink.pipe_from_stream(stream).await;
}
sink.pipe_from_stream(stream).await;
};

self.executor.spawn("substrate-rpc-subscription", Some("rpc"), fut.boxed());
Ok(())
}

async fn prove_finality(
Expand Down Expand Up @@ -283,9 +283,9 @@ mod tests {
let (rpc, _) = setup_io_handler(EmptyVoterState);
let expected_response = r#"{"jsonrpc":"2.0","error":{"code":1,"message":"GRANDPA RPC endpoint not ready"},"id":0}"#.to_string();
let request = r#"{"jsonrpc":"2.0","method":"grandpa_roundState","params":[],"id":0}"#;
let (result, _) = rpc.raw_json_request(&request).await.unwrap();
let (response, _) = rpc.raw_json_request(&request).await.unwrap();

assert_eq!(expected_response, result,);
assert_eq!(expected_response, response.result);
}

#[tokio::test]
Expand All @@ -306,8 +306,8 @@ mod tests {
},\"id\":0}".to_string();

let request = r#"{"jsonrpc":"2.0","method":"grandpa_roundState","params":[],"id":0}"#;
let (result, _) = rpc.raw_json_request(&request).await.unwrap();
assert_eq!(expected_response, result);
let (response, _) = rpc.raw_json_request(&request).await.unwrap();
assert_eq!(expected_response, response.result);
}

#[tokio::test]
Expand All @@ -328,7 +328,7 @@ mod tests {
.unwrap();
let expected = r#"{"jsonrpc":"2.0","result":false,"id":1}"#;

assert_eq!(response, expected);
assert_eq!(response.result, expected);
}

fn create_justification() -> GrandpaJustification<Block> {
Expand Down
2 changes: 1 addition & 1 deletion client/rpc-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ sp-rpc = { version = "6.0.0", path = "../../primitives/rpc" }
sp-runtime = { version = "6.0.0", path = "../../primitives/runtime" }
sp-tracing = { version = "5.0.0", path = "../../primitives/tracing" }
sp-version = { version = "5.0.0", path = "../../primitives/version" }
jsonrpsee = { version = "0.14.0", features = ["server", "macros"] }
jsonrpsee = { version = "0.15.1", features = ["server", "macros"] }
2 changes: 1 addition & 1 deletion client/rpc-servers/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
futures = "0.3.21"
jsonrpsee = { version = "0.14.0", features = ["server"] }
jsonrpsee = { version = "0.15.1", features = ["server"] }
log = "0.4.17"
serde_json = "1.0.79"
tokio = { version = "1.17.0", features = ["parking_lot"] }
Expand Down
Loading