From f3eefc9df9f36b3472fefb0675c8627aa3db7fd6 Mon Sep 17 00:00:00 2001 From: David Date: Mon, 27 Sep 2021 12:24:38 +0000 Subject: [PATCH] Upgrade `jsonrpsee` to v0.3 (#1051) * Upgrade `jsonrpsee` to v0.3 * whitespace * fmt Co-authored-by: Svyatoslav Nikolsky --- bridges/modules/ethereum/src/import.rs | 5 +++-- .../bin-ethereum/src/ethereum_deploy_contract.rs | 5 +++-- bridges/relays/client-ethereum/Cargo.toml | 4 ++-- bridges/relays/client-ethereum/src/error.rs | 12 +++++++----- bridges/relays/client-substrate/Cargo.toml | 5 ++--- bridges/relays/client-substrate/src/chain.rs | 2 +- bridges/relays/client-substrate/src/client.rs | 7 +++++-- bridges/relays/client-substrate/src/error.rs | 12 +++++++----- .../relays/client-substrate/src/finality_source.rs | 3 ++- 9 files changed, 32 insertions(+), 23 deletions(-) diff --git a/bridges/modules/ethereum/src/import.rs b/bridges/modules/ethereum/src/import.rs index 3c99451ca8f1..31e8642d5109 100644 --- a/bridges/modules/ethereum/src/import.rs +++ b/bridges/modules/ethereum/src/import.rs @@ -307,8 +307,9 @@ mod tests { ) .unwrap(); match i { - 2..=10 => - assert_eq!(finalized_blocks, vec![(parent_id, Some(100))], "At {}", i,), + 2..=10 => { + assert_eq!(finalized_blocks, vec![(parent_id, Some(100))], "At {}", i,) + }, _ => assert_eq!(finalized_blocks, vec![], "At {}", i), } latest_block_id = rolling_last_block_id; diff --git a/bridges/relays/bin-ethereum/src/ethereum_deploy_contract.rs b/bridges/relays/bin-ethereum/src/ethereum_deploy_contract.rs index d7006a9c673c..9eecc1a12f51 100644 --- a/bridges/relays/bin-ethereum/src/ethereum_deploy_contract.rs +++ b/bridges/relays/bin-ethereum/src/ethereum_deploy_contract.rs @@ -106,12 +106,13 @@ async fn prepare_initial_header( sub_initial_header: Option>, ) -> Result<(RialtoHeaderId, Vec), String> { match sub_initial_header { - Some(raw_initial_header) => + Some(raw_initial_header) => { match rialto_runtime::Header::decode(&mut &raw_initial_header[..]) { Ok(initial_header) => Ok((HeaderId(initial_header.number, initial_header.hash()), raw_initial_header)), Err(error) => Err(format!("Error decoding initial header: {}", error)), - }, + } + }, None => { let initial_header = sub_client.header_by_number(Zero::zero()).await; initial_header diff --git a/bridges/relays/client-ethereum/Cargo.toml b/bridges/relays/client-ethereum/Cargo.toml index 4ce90cc783bc..6d56eb94dbd7 100644 --- a/bridges/relays/client-ethereum/Cargo.toml +++ b/bridges/relays/client-ethereum/Cargo.toml @@ -10,8 +10,8 @@ async-std = "1.6.5" bp-eth-poa = { path = "../../primitives/ethereum-poa" } headers-relay = { path = "../headers" } hex-literal = "0.3" -jsonrpsee-proc-macros = "0.2" -jsonrpsee-ws-client = "0.2" +jsonrpsee-proc-macros = "0.3.1" +jsonrpsee-ws-client = "0.3.1" libsecp256k1 = { version = "0.3.4", default-features = false, features = ["hmac"] } log = "0.4.11" relay-utils = { path = "../utils" } diff --git a/bridges/relays/client-ethereum/src/error.rs b/bridges/relays/client-ethereum/src/error.rs index f3c832cd4006..23a9138e1208 100644 --- a/bridges/relays/client-ethereum/src/error.rs +++ b/bridges/relays/client-ethereum/src/error.rs @@ -18,7 +18,7 @@ use crate::types::U256; -use jsonrpsee_ws_client::Error as RpcError; +use jsonrpsee_ws_client::types::Error as RpcError; use relay_utils::MaybeConnectionError; /// Result type used by Ethereum client. @@ -73,10 +73,12 @@ impl MaybeConnectionError for Error { fn is_connection_error(&self) -> bool { matches!( *self, - Error::RpcError(RpcError::Transport(_)) | - Error::RpcError(RpcError::Internal(_)) | - Error::RpcError(RpcError::RestartNeeded(_)) | - Error::ClientNotSynced(_), + Error::RpcError(RpcError::Transport(_)) + // right now if connection to the ws server is dropped (after it is already established), + // we're getting this error + | Error::RpcError(RpcError::Internal(_)) + | Error::RpcError(RpcError::RestartNeeded(_)) + | Error::ClientNotSynced(_), ) } } diff --git a/bridges/relays/client-substrate/Cargo.toml b/bridges/relays/client-substrate/Cargo.toml index 90e775b784eb..7d82e365e2f1 100644 --- a/bridges/relays/client-substrate/Cargo.toml +++ b/bridges/relays/client-substrate/Cargo.toml @@ -9,9 +9,8 @@ license = "GPL-3.0-or-later WITH Classpath-exception-2.0" async-std = { version = "1.6.5", features = ["attributes"] } async-trait = "0.1.40" codec = { package = "parity-scale-codec", version = "2.2.0" } -jsonrpsee-proc-macros = "0.2" -jsonrpsee-types = "0.2" -jsonrpsee-ws-client = "0.2" +jsonrpsee-proc-macros = "0.3.1" +jsonrpsee-ws-client = "0.3.1" log = "0.4.11" num-traits = "0.2" rand = "0.7" diff --git a/bridges/relays/client-substrate/src/chain.rs b/bridges/relays/client-substrate/src/chain.rs index c3d4e3045242..75789ce37f30 100644 --- a/bridges/relays/client-substrate/src/chain.rs +++ b/bridges/relays/client-substrate/src/chain.rs @@ -17,7 +17,7 @@ use bp_runtime::{Chain as ChainBase, HashOf, TransactionEraOf}; use codec::{Codec, Encode}; use frame_support::weights::WeightToFeePolynomial; -use jsonrpsee_ws_client::{DeserializeOwned, Serialize}; +use jsonrpsee_ws_client::types::{DeserializeOwned, Serialize}; use num_traits::Zero; use sc_transaction_pool_api::TransactionStatus; use sp_core::{storage::StorageKey, Pair}; diff --git a/bridges/relays/client-substrate/src/client.rs b/bridges/relays/client-substrate/src/client.rs index ca197867bc4b..fd69dd255e6d 100644 --- a/bridges/relays/client-substrate/src/client.rs +++ b/bridges/relays/client-substrate/src/client.rs @@ -28,8 +28,11 @@ use codec::{Decode, Encode}; use frame_system::AccountInfo; use futures::{SinkExt, StreamExt}; use jsonrpsee_ws_client::{ - traits::SubscriptionClient, v2::params::JsonRpcParams, DeserializeOwned, WsClient as RpcClient, - WsClientBuilder as RpcClientBuilder, + types::{ + self as jsonrpsee_types, traits::SubscriptionClient, v2::params::JsonRpcParams, + DeserializeOwned, + }, + WsClient as RpcClient, WsClientBuilder as RpcClientBuilder, }; use num_traits::{Bounded, Zero}; use pallet_balances::AccountData; diff --git a/bridges/relays/client-substrate/src/error.rs b/bridges/relays/client-substrate/src/error.rs index d3444516429b..c3cd236b948c 100644 --- a/bridges/relays/client-substrate/src/error.rs +++ b/bridges/relays/client-substrate/src/error.rs @@ -16,7 +16,7 @@ //! Substrate node RPC errors. -use jsonrpsee_ws_client::Error as RpcError; +use jsonrpsee_ws_client::types::Error as RpcError; use relay_utils::MaybeConnectionError; use sc_rpc_api::system::Health; use sp_runtime::transaction_validity::TransactionValidityError; @@ -96,10 +96,12 @@ impl MaybeConnectionError for Error { fn is_connection_error(&self) -> bool { matches!( *self, - Error::RpcError(RpcError::Transport(_)) | - Error::RpcError(RpcError::Internal(_)) | - Error::RpcError(RpcError::RestartNeeded(_)) | - Error::ClientNotSynced(_), + Error::RpcError(RpcError::Transport(_)) + // right now if connection to the ws server is dropped (after it is already established), + // we're getting this error + | Error::RpcError(RpcError::Internal(_)) + | Error::RpcError(RpcError::RestartNeeded(_)) + | Error::ClientNotSynced(_), ) } } diff --git a/bridges/relays/client-substrate/src/finality_source.rs b/bridges/relays/client-substrate/src/finality_source.rs index 0059429dcb41..98526de178cb 100644 --- a/bridges/relays/client-substrate/src/finality_source.rs +++ b/bridges/relays/client-substrate/src/finality_source.rs @@ -151,8 +151,9 @@ where .await .map_err(|err| log_error(err.to_string())) .ok()??; + let decoded_justification = - GrandpaJustification::::decode(&mut &next_justification.0[..]); + GrandpaJustification::::decode(&mut &next_justification[..]); let justification = match decoded_justification { Ok(j) => j,