Releases: paritytech/jsonrpsee
v0.25.1
[v0.25.1] - 2025-04-24
A small follow-up patch release that adds a Clone impl
for the middleware RpcLogger which was missing
and broke the Clone impl for the HttpClient.
If you are updating from v0.24, have a look at https://github.com/paritytech/jsonrpsee/releases/tag/v0.25.0 because it contains some breaking changes.
Full Changelog: v0.25.0...v0.25.1
v0.25.0
[v0.25.0] - 2025-04-24
A new breaking release which has been in the making for a while and the biggest change is that the
RpcServiceT trait
has been changed to support both the client and server side:
pub trait RpcServiceT {
/// Response type for `RpcServiceT::call`.
type MethodResponse;
/// Response type for `RpcServiceT::notification`.
type NotificationResponse;
/// Response type for `RpcServiceT::batch`.
type BatchResponse;
/// Processes a single JSON-RPC call, which may be a subscription or regular call.
fn call<'a>(&self, request: Request<'a>) -> impl Future<Output = Self::MethodResponse> + Send + 'a;
/// Processes multiple JSON-RPC calls at once, similar to `RpcServiceT::call`.
///
/// This method wraps `RpcServiceT::call` and `RpcServiceT::notification`,
/// but the root RPC service does not inherently recognize custom implementations
/// of these methods.
///
/// As a result, if you have custom logic for individual calls or notifications,
/// you must duplicate that implementation in this method or no middleware will be applied
/// for calls inside the batch.
fn batch<'a>(&self, requests: Batch<'a>) -> impl Future<Output = Self::BatchResponse> + Send + 'a;
/// Similar to `RpcServiceT::call` but processes a JSON-RPC notification.
fn notification<'a>(&self, n: Notification<'a>) -> impl Future<Output = Self::NotificationResponse> + Send + 'a;
}
The reason for this change is to make it work for the client-side as well as make it easier to
implement performantly by relying on impl Future
instead of requiring an associated type for the Future
(which in many cases requires boxing).
The downside of this change is that one has to duplicate the logic in the batch
and call
method to achieve the same
functionality as before. Thus, call
or notification
is not being invoked in the batch
method and one has to implement
them separately.
For example now it's possible to write middleware that counts the number of method calls as follows (both client and server):
#[derive(Clone)]
pub struct Counter<S> {
service: S,
count: Arc<AtomicUsize>,
role: &'static str,
}
impl<S> RpcServiceT for Counter<S>
where
S: RpcServiceT + Send + Sync + Clone + 'static,
{
type MethodResponse = S::MethodResponse;
type NotificationResponse = S::NotificationResponse;
type BatchResponse = S::BatchResponse;
fn call<'a>(&self, req: Request<'a>) -> impl Future<Output = Self::MethodResponse> + Send + 'a {
let count = self.count.clone();
let service = self.service.clone();
let role = self.role;
async move {
let rp = service.call(req).await;
count.fetch_add(1, Ordering::SeqCst);
println!("{role} processed calls={} on the connection", count.load(Ordering::SeqCst));
rp
}
}
fn batch<'a>(&self, batch: Batch<'a>) -> impl Future<Output = Self::BatchResponse> + Send + 'a {
let len = batch.len();
self.count.fetch_add(len, Ordering::SeqCst);
println!("{} processed calls={} on the connection", self.role, self.count.load(Ordering::SeqCst));
self.service.batch(batch)
}
fn notification<'a>(&self, n: Notification<'a>) -> impl Future<Output = Self::NotificationResponse> + Send + 'a {
self.service.notification(n)
}
}
In addition because this middleware is quite powerful it's possible to
modify requests and specifically the request ID which should be avoided
because it may break the response verification especially for the client-side.
See #1565 for further information.
There are also a couple of other changes see the detailed changelog below.
[Added]
- middleware: RpcServiceT distinct return types for notif, batch, call (#1564)
- middleware: add support for client-side (#1521)
- feat: add namespace_separator option for RPC methods (#1544)
- feat: impl Into for Infallible (#1542)
- client: add
request timeout
getter (#1533) - server: add example how to close a connection from a rpc handler (method call or subscription) (#1488)
- server: add missing
ServerConfigBuilder::build
(#1484)
[Fixed]
- chore(macros): fix typo in proc-macro example (#1482)
- chore(macros): fix typo in internal type name (#1507)
- http middleware: preserve the URI query in ProxyGetRequest::call (#1512)
- http middlware: send original error in ProxyGetRequest (#1516)
- docs: update comment for TOO_BIG_BATCH_RESPONSE_CODE error (#1531)
- fix
http request body
log (#1540)
[Changed]
- unify usage of JSON via
Box<RawValue>
(#1545) - server:
ServerConfigBuilder/ServerConfig
replacesServerBuilder
duplicate setter methods (#1487) - server: make
ProxyGetRequestLayer
http middleware support multiple path-method pairs (#1492) - server: propagate extensions in http response (#1514)
- server: add assert set_message_buffer_capacity (#1530)
- client: add #[derive(Clone)] for HttpClientBuilder (#1498)
- client: add Error::Closed for ws close (#1497)
- client: use native async fn in traits instead async_trait crate (#1551)
- refactor: move to rust edition 2024 (MSRV 1.85) (#1528)
- chore(deps): update tower requirement from 0.4.13 to 0.5.1 (#1455)
- chore(deps): update tower-http requirement from 0.5.2 to 0.6.1 (#1463)
- chore(deps): update pprof requirement from 0.13 to 0.14 (#1493)
- chore(deps): update rustls-platform-verifier requirement from 0.3 to 0.4 (#1489)
- chore(deps): update thiserror requirement from 1 to 2 (#1491)
- chore(deps): bump soketto to 0.8.1 (#1501)
- chore(deps): update rustls-platform-verifier requirement from 0.4 to 0.5 (#1506)
- chore(deps): update fast-socks5 requirement from 0.9.1 to 0.10.0 (#1505)
- chore(deps): tokio ^1.42 (#1511)
- chore: use cargo workspace dependencies (#1502)
- chore(deps): update rand requirement from 0.8 to 0.9 (#1523)
New Contributors
- @Pana made their first contribution in #1482
- @HaoranYi made their first contribution in #1507
- @king-11 made their first contribution in #1519
- @AlexZhenWang made their first contribution in #1531
- @emhane made their first contribution in #1533
- @hai-rise made their first contribution in #1540
- @YakupAltay made their first contribution in #1544
- @Hack666r made their first contribution in #1552
- @petryshkaCODE made their first contribution in #1553
- @mdqst made their first contribution in #1556
Full Changelog: v0.24.9...v0.25.0
v0.24.9
[v0.24.9] - 2024-03-17
This is a non-breaking release that updates the dependency rust-platform-verifier
to v0.5 to fix that
that rust-platform-verifier
v0.3 didn't enable the std feature
in rustls
which caused a compilation error.
See #1536 for further information.
Thanks to the external contributor @prestwich who spotted and fixed this issue.
v0.24.8
v0.24.7
[v0.24.7] - 2024-10-16
This is a patch release that mainly fixes the tower::Service implementation to be generic over the HttpBody to work with all middleware layers. For instance, this makes tower_http::compression::CompressionLayer
work, which didn't compile before.
[Added]
- http client: add
max_concurrent_requests
(#1473)
[Fixed]
- fix(server): make tower::Service impl generic over HttpBody (#1475)
New Contributors
- @hanabi1224 made their first contribution in #1475
Full Changelog: v0.24.6...v0.24.7
v0.24.6
[v0.24.6] - 2024-10-07
This is a bug-fix release that fixes that the ConnectionGuard
was dropped before the future was resolved which,
could lead to that HTTP calls were not counted correctly in the ConnectionGuard
. This impacts only the server.
[Fixed]
- fix(server): count http calls in connection guard (#1468)
Full Changelog: v0.24.5...v0.24.6
v0.24.5
[v0.24.5] - 2024-09-26
This is a patch release that mainly fixes a compilation issue for the server because the feature tower/util
was not enabled.
[Fixed]
- server: Enable tower util feature (#1464)
[Changed]
- server: change
http method_not_allowed
message (#1452)
New Contributors
- @IkerAlus made their first contribution in #1454
- @dcfreire made their first contribution in #1452
- @FabianLars made their first contribution in #1464
Full Changelog: v0.24.4...v0.24.5
v0.24.4
[v0.24.4] - 2024-09-11
This is non-breaking release that changes the error variants to be thiserror(transparent)
for wrapped errors and adds ConnectionGuard to the extensions to make it possible to get the number of active connections.
[Added]
- server: expose ConnectionGuard as request extension (#1443)
[Fixed]
- types: use error(transparent) for wrapped errors when possible (#1449)
New Contributors
Full Changelog: v0.24.3...v0.24.4
v0.20.4
v0.24.3
[v0.24.3] - 2024-08-14
This is a small release that adds two new APIs to inject data via the extensions to the RpcModule/Methods
and it only impacts users that are using RpcModule directly via Methods::call/subscribe/raw_json_request
(e.g., unit testing) and not the server itself.
[Added]
- feat(server): add
Methods::extensions/extensions_mut
(#1440)
Full Changelog: v0.24.2...v0.24.3