Upgrade jsonrpsee to v0.3 (#1051)

* Upgrade `jsonrpsee` to v0.3

* whitespace

* fmt

Co-authored-by: Svyatoslav Nikolsky <svyatonik@gmail.com>
This commit is contained in:
David
2021-09-27 12:24:38 +00:00
committed by Bastian Köcher
parent 84258f5d8c
commit f3eefc9df9
9 changed files with 32 additions and 23 deletions
+3 -2
View File
@@ -307,8 +307,9 @@ mod tests {
) )
.unwrap(); .unwrap();
match i { match i {
2..=10 => 2..=10 => {
assert_eq!(finalized_blocks, vec![(parent_id, Some(100))], "At {}", i,), assert_eq!(finalized_blocks, vec![(parent_id, Some(100))], "At {}", i,)
},
_ => assert_eq!(finalized_blocks, vec![], "At {}", i), _ => assert_eq!(finalized_blocks, vec![], "At {}", i),
} }
latest_block_id = rolling_last_block_id; latest_block_id = rolling_last_block_id;
@@ -106,12 +106,13 @@ async fn prepare_initial_header(
sub_initial_header: Option<Vec<u8>>, sub_initial_header: Option<Vec<u8>>,
) -> Result<(RialtoHeaderId, Vec<u8>), String> { ) -> Result<(RialtoHeaderId, Vec<u8>), String> {
match sub_initial_header { match sub_initial_header {
Some(raw_initial_header) => Some(raw_initial_header) => {
match rialto_runtime::Header::decode(&mut &raw_initial_header[..]) { match rialto_runtime::Header::decode(&mut &raw_initial_header[..]) {
Ok(initial_header) => Ok(initial_header) =>
Ok((HeaderId(initial_header.number, initial_header.hash()), raw_initial_header)), Ok((HeaderId(initial_header.number, initial_header.hash()), raw_initial_header)),
Err(error) => Err(format!("Error decoding initial header: {}", error)), Err(error) => Err(format!("Error decoding initial header: {}", error)),
}, }
},
None => { None => {
let initial_header = sub_client.header_by_number(Zero::zero()).await; let initial_header = sub_client.header_by_number(Zero::zero()).await;
initial_header initial_header
+2 -2
View File
@@ -10,8 +10,8 @@ async-std = "1.6.5"
bp-eth-poa = { path = "../../primitives/ethereum-poa" } bp-eth-poa = { path = "../../primitives/ethereum-poa" }
headers-relay = { path = "../headers" } headers-relay = { path = "../headers" }
hex-literal = "0.3" hex-literal = "0.3"
jsonrpsee-proc-macros = "0.2" jsonrpsee-proc-macros = "0.3.1"
jsonrpsee-ws-client = "0.2" jsonrpsee-ws-client = "0.3.1"
libsecp256k1 = { version = "0.3.4", default-features = false, features = ["hmac"] } libsecp256k1 = { version = "0.3.4", default-features = false, features = ["hmac"] }
log = "0.4.11" log = "0.4.11"
relay-utils = { path = "../utils" } relay-utils = { path = "../utils" }
+7 -5
View File
@@ -18,7 +18,7 @@
use crate::types::U256; use crate::types::U256;
use jsonrpsee_ws_client::Error as RpcError; use jsonrpsee_ws_client::types::Error as RpcError;
use relay_utils::MaybeConnectionError; use relay_utils::MaybeConnectionError;
/// Result type used by Ethereum client. /// Result type used by Ethereum client.
@@ -73,10 +73,12 @@ impl MaybeConnectionError for Error {
fn is_connection_error(&self) -> bool { fn is_connection_error(&self) -> bool {
matches!( matches!(
*self, *self,
Error::RpcError(RpcError::Transport(_)) | Error::RpcError(RpcError::Transport(_))
Error::RpcError(RpcError::Internal(_)) | // right now if connection to the ws server is dropped (after it is already established),
Error::RpcError(RpcError::RestartNeeded(_)) | // we're getting this error
Error::ClientNotSynced(_), | Error::RpcError(RpcError::Internal(_))
| Error::RpcError(RpcError::RestartNeeded(_))
| Error::ClientNotSynced(_),
) )
} }
} }
+2 -3
View File
@@ -9,9 +9,8 @@ license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
async-std = { version = "1.6.5", features = ["attributes"] } async-std = { version = "1.6.5", features = ["attributes"] }
async-trait = "0.1.40" async-trait = "0.1.40"
codec = { package = "parity-scale-codec", version = "2.2.0" } codec = { package = "parity-scale-codec", version = "2.2.0" }
jsonrpsee-proc-macros = "0.2" jsonrpsee-proc-macros = "0.3.1"
jsonrpsee-types = "0.2" jsonrpsee-ws-client = "0.3.1"
jsonrpsee-ws-client = "0.2"
log = "0.4.11" log = "0.4.11"
num-traits = "0.2" num-traits = "0.2"
rand = "0.7" rand = "0.7"
+1 -1
View File
@@ -17,7 +17,7 @@
use bp_runtime::{Chain as ChainBase, HashOf, TransactionEraOf}; use bp_runtime::{Chain as ChainBase, HashOf, TransactionEraOf};
use codec::{Codec, Encode}; use codec::{Codec, Encode};
use frame_support::weights::WeightToFeePolynomial; use frame_support::weights::WeightToFeePolynomial;
use jsonrpsee_ws_client::{DeserializeOwned, Serialize}; use jsonrpsee_ws_client::types::{DeserializeOwned, Serialize};
use num_traits::Zero; use num_traits::Zero;
use sc_transaction_pool_api::TransactionStatus; use sc_transaction_pool_api::TransactionStatus;
use sp_core::{storage::StorageKey, Pair}; use sp_core::{storage::StorageKey, Pair};
@@ -28,8 +28,11 @@ use codec::{Decode, Encode};
use frame_system::AccountInfo; use frame_system::AccountInfo;
use futures::{SinkExt, StreamExt}; use futures::{SinkExt, StreamExt};
use jsonrpsee_ws_client::{ use jsonrpsee_ws_client::{
traits::SubscriptionClient, v2::params::JsonRpcParams, DeserializeOwned, WsClient as RpcClient, types::{
WsClientBuilder as RpcClientBuilder, self as jsonrpsee_types, traits::SubscriptionClient, v2::params::JsonRpcParams,
DeserializeOwned,
},
WsClient as RpcClient, WsClientBuilder as RpcClientBuilder,
}; };
use num_traits::{Bounded, Zero}; use num_traits::{Bounded, Zero};
use pallet_balances::AccountData; use pallet_balances::AccountData;
+7 -5
View File
@@ -16,7 +16,7 @@
//! Substrate node RPC errors. //! Substrate node RPC errors.
use jsonrpsee_ws_client::Error as RpcError; use jsonrpsee_ws_client::types::Error as RpcError;
use relay_utils::MaybeConnectionError; use relay_utils::MaybeConnectionError;
use sc_rpc_api::system::Health; use sc_rpc_api::system::Health;
use sp_runtime::transaction_validity::TransactionValidityError; use sp_runtime::transaction_validity::TransactionValidityError;
@@ -96,10 +96,12 @@ impl MaybeConnectionError for Error {
fn is_connection_error(&self) -> bool { fn is_connection_error(&self) -> bool {
matches!( matches!(
*self, *self,
Error::RpcError(RpcError::Transport(_)) | Error::RpcError(RpcError::Transport(_))
Error::RpcError(RpcError::Internal(_)) | // right now if connection to the ws server is dropped (after it is already established),
Error::RpcError(RpcError::RestartNeeded(_)) | // we're getting this error
Error::ClientNotSynced(_), | Error::RpcError(RpcError::Internal(_))
| Error::RpcError(RpcError::RestartNeeded(_))
| Error::ClientNotSynced(_),
) )
} }
} }
@@ -151,8 +151,9 @@ where
.await .await
.map_err(|err| log_error(err.to_string())) .map_err(|err| log_error(err.to_string()))
.ok()??; .ok()??;
let decoded_justification = let decoded_justification =
GrandpaJustification::<C::Header>::decode(&mut &next_justification.0[..]); GrandpaJustification::<C::Header>::decode(&mut &next_justification[..]);
let justification = match decoded_justification { let justification = match decoded_justification {
Ok(j) => j, Ok(j) => j,