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:
Niklas Adolfsson
2024-02-14 23:18:22 +01:00
committed by GitHub
parent 7e7c488ba8
commit c7c4fe0184
53 changed files with 777 additions and 468 deletions
+3 -6
View File
@@ -38,7 +38,7 @@ use std::{collections::HashMap, net::SocketAddr};
use codec::{Decode, Encode};
use futures::{pin_mut, FutureExt, StreamExt};
use jsonrpsee::{core::Error as JsonRpseeError, RpcModule};
use jsonrpsee::RpcModule;
use log::{debug, error, warn};
use sc_client_api::{blockchain::HeaderBackend, BlockBackend, BlockchainEvents, ProofProvider};
use sc_network::{
@@ -109,17 +109,14 @@ impl RpcHandlers {
pub async fn rpc_query(
&self,
json_query: &str,
) -> Result<(String, tokio::sync::mpsc::Receiver<String>), JsonRpseeError> {
) -> Result<(String, tokio::sync::mpsc::Receiver<String>), serde_json::Error> {
// Because `tokio::sync::mpsc::channel` is used under the hood
// it will panic if it's set to usize::MAX.
//
// This limit is used to prevent panics and is large enough.
const TOKIO_MPSC_MAX_SIZE: usize = tokio::sync::Semaphore::MAX_PERMITS;
self.0
.raw_json_request(json_query, TOKIO_MPSC_MAX_SIZE)
.await
.map(|(method_res, recv)| (method_res.result, recv))
self.0.raw_json_request(json_query, TOKIO_MPSC_MAX_SIZE).await
}
/// Provides access to the underlying `RpcModule`