Skip to content

Commit

Permalink
Upgrade jsonrpsee to v0.3 (#1051)
Browse files Browse the repository at this point in the history
* Upgrade `jsonrpsee` to v0.3

* whitespace

* fmt

Co-authored-by: Svyatoslav Nikolsky <svyatonik@gmail.com>
  • Loading branch information
2 people authored and bkchr committed Apr 10, 2024
1 parent 84258f5 commit f3eefc9
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 23 deletions.
5 changes: 3 additions & 2 deletions bridges/modules/ethereum/src/import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 3 additions & 2 deletions bridges/relays/bin-ethereum/src/ethereum_deploy_contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,13 @@ async fn prepare_initial_header(
sub_initial_header: Option<Vec<u8>>,
) -> Result<(RialtoHeaderId, Vec<u8>), 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
Expand Down
4 changes: 2 additions & 2 deletions bridges/relays/client-ethereum/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down
12 changes: 7 additions & 5 deletions bridges/relays/client-ethereum/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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(_),
)
}
}
Expand Down
5 changes: 2 additions & 3 deletions bridges/relays/client-substrate/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion bridges/relays/client-substrate/src/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
7 changes: 5 additions & 2 deletions bridges/relays/client-substrate/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
12 changes: 7 additions & 5 deletions bridges/relays/client-substrate/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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(_),
)
}
}
Expand Down
3 changes: 2 additions & 1 deletion bridges/relays/client-substrate/src/finality_source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,9 @@ where
.await
.map_err(|err| log_error(err.to_string()))
.ok()??;

let decoded_justification =
GrandpaJustification::<C::Header>::decode(&mut &next_justification.0[..]);
GrandpaJustification::<C::Header>::decode(&mut &next_justification[..]);

let justification = match decoded_justification {
Ok(j) => j,
Expand Down

0 comments on commit f3eefc9

Please sign in to comment.