mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 13:27:57 +00:00
rpc: bump jsonrpsee v0.22 and fix race in rpc v2 chain_head (#3230)
Close #2992 Breaking changes: - rpc server grafana metric `substrate_rpc_requests_started` is removed (not possible to implement anymore) - rpc server grafana metric `substrate_rpc_requests_finished` is removed (not possible to implement anymore) - rpc server ws ping/pong not ACK:ed within 30 seconds more than three times then the connection will be closed Added - rpc server grafana metric `substrate_rpc_sessions_time` is added to get the duration for each websocket session
This commit is contained in:
@@ -21,10 +21,7 @@ use super::*;
|
||||
use crate::testing::{test_executor, timeout_secs};
|
||||
use assert_matches::assert_matches;
|
||||
use codec::Encode;
|
||||
use jsonrpsee::{
|
||||
core::{EmptyServerParams as EmptyParams, Error as RpcError},
|
||||
RpcModule,
|
||||
};
|
||||
use jsonrpsee::{core::EmptyServerParams as EmptyParams, MethodsError as RpcError, RpcModule};
|
||||
use sc_transaction_pool::{BasicPool, FullChainApi};
|
||||
use sc_transaction_pool_api::TransactionStatus;
|
||||
use sp_core::{
|
||||
@@ -103,7 +100,7 @@ async fn author_submit_transaction_should_not_cause_error() {
|
||||
|
||||
assert_matches!(
|
||||
api.call::<_, H256>("author_submitExtrinsic", [xt]).await,
|
||||
Err(RpcError::Call(err)) if err.message().contains("Already Imported") && err.code() == 1013
|
||||
Err(RpcError::JsonRpc(err)) if err.message().contains("Already Imported") && err.code() == 1013
|
||||
);
|
||||
}
|
||||
|
||||
@@ -160,7 +157,7 @@ async fn author_should_return_watch_validation_error() {
|
||||
|
||||
assert_matches!(
|
||||
failed_sub,
|
||||
Err(RpcError::Call(err)) if err.message().contains("Invalid Transaction") && err.code() == 1010
|
||||
Err(RpcError::JsonRpc(err)) if err.message().contains("Invalid Transaction") && err.code() == 1010
|
||||
);
|
||||
}
|
||||
|
||||
@@ -276,7 +273,7 @@ async fn author_has_session_keys() {
|
||||
|
||||
assert_matches!(
|
||||
api.call::<_, bool>("author_hasSessionKeys", vec![Bytes::from(vec![1, 2, 3])]).await,
|
||||
Err(RpcError::Call(err)) if err.message().contains("Session keys are not encoded correctly")
|
||||
Err(RpcError::JsonRpc(err)) if err.message().contains("Session keys are not encoded correctly")
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -100,7 +100,7 @@ async fn deny_unsafe_works() {
|
||||
let (resp, _) = api.raw_json_request(&request, 1).await.expect("Raw calls should succeed");
|
||||
|
||||
assert_eq!(
|
||||
resp.result,
|
||||
resp,
|
||||
r#"{"jsonrpc":"2.0","error":{"code":-32601,"message":"RPC call is unsafe to be called externally"},"id":1}"#
|
||||
);
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ use super::*;
|
||||
use crate::testing::{test_executor, timeout_secs};
|
||||
use assert_matches::assert_matches;
|
||||
use futures::executor;
|
||||
use jsonrpsee::core::{EmptyServerParams as EmptyParams, Error as RpcError};
|
||||
use jsonrpsee::{core::EmptyServerParams as EmptyParams, MethodsError as RpcError};
|
||||
use sc_block_builder::BlockBuilderBuilder;
|
||||
use sc_rpc_api::DenyUnsafe;
|
||||
use sp_consensus::BlockOrigin;
|
||||
@@ -525,7 +525,7 @@ async fn wildcard_storage_subscriptions_are_rpc_unsafe() {
|
||||
|
||||
let api_rpc = api.into_rpc();
|
||||
let err = api_rpc.subscribe_unbounded("state_subscribeStorage", EmptyParams::new()).await;
|
||||
assert_matches!(err, Err(RpcError::Call(e)) if e.message() == "RPC call is unsafe to be called externally");
|
||||
assert_matches!(err, Err(RpcError::JsonRpc(e)) if e.message() == "RPC call is unsafe to be called externally");
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
|
||||
@@ -19,10 +19,7 @@
|
||||
use super::{helpers::SyncState, *};
|
||||
use assert_matches::assert_matches;
|
||||
use futures::prelude::*;
|
||||
use jsonrpsee::{
|
||||
core::{EmptyServerParams as EmptyParams, Error as RpcError},
|
||||
RpcModule,
|
||||
};
|
||||
use jsonrpsee::{core::EmptyServerParams as EmptyParams, MethodsError as RpcError, RpcModule};
|
||||
use sc_network::{self, config::Role, PeerId};
|
||||
use sc_rpc_api::system::helpers::PeerInfo;
|
||||
use sc_utils::mpsc::tracing_unbounded;
|
||||
@@ -311,7 +308,7 @@ async fn system_network_add_reserved() {
|
||||
let bad_peer_id = ["/ip4/198.51.100.19/tcp/30333"];
|
||||
assert_matches!(
|
||||
api(None).call::<_, ()>("system_addReservedPeer", bad_peer_id).await,
|
||||
Err(RpcError::Call(err)) if err.message().contains("Peer id is missing from the address")
|
||||
Err(RpcError::JsonRpc(err)) if err.message().contains("Peer id is missing from the address")
|
||||
);
|
||||
}
|
||||
|
||||
@@ -327,7 +324,7 @@ async fn system_network_remove_reserved() {
|
||||
|
||||
assert_matches!(
|
||||
api(None).call::<_, String>("system_removeReservedPeer", bad_peer_id).await,
|
||||
Err(RpcError::Call(err)) if err.message().contains("base-58 decode error: provided string contained invalid character '/' at byte 0")
|
||||
Err(RpcError::JsonRpc(err)) if err.message().contains("base-58 decode error: provided string contained invalid character '/' at byte 0")
|
||||
);
|
||||
}
|
||||
#[tokio::test]
|
||||
|
||||
@@ -80,7 +80,7 @@ where
|
||||
Either::Left((Ok(sink), _)) => break sink,
|
||||
Either::Right((Some(msg), f)) => {
|
||||
if buf.push_back(msg).is_err() {
|
||||
log::warn!(target: "rpc", "Subscription::accept failed buffer limit={} exceed; dropping subscription", buf.max_cap);
|
||||
log::warn!(target: "rpc", "Subscription::accept failed buffer limit={} exceeded; dropping subscription", buf.max_cap);
|
||||
return
|
||||
}
|
||||
accept_fut = f;
|
||||
@@ -125,7 +125,13 @@ async fn inner_pipe_from_stream<S, T>(
|
||||
// New item from the stream
|
||||
Either::Right((Either::Right((Some(v), n)), c)) => {
|
||||
if buf.push_back(v).is_err() {
|
||||
log::warn!(target: "rpc", "Subscription buffer limit={} exceed; dropping subscription", buf.max_cap);
|
||||
log::warn!(
|
||||
target: "rpc",
|
||||
"Subscription buffer limit={} exceeded for subscription={} conn_id={}; dropping subscription",
|
||||
buf.max_cap,
|
||||
sink.method_name(),
|
||||
sink.connection_id()
|
||||
);
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user