Skip to content

Releases: paritytech/jsonrpsee

v0.20.4

24 Aug 08:34
v0.20.4
889b38f
Compare
Choose a tag to compare

[v0.20.4] - 2024-08-24

This release enables HTTP/2 for http client which is backward compatible and
pure HTTP/1 connections will still work.

[Changed]

  • client: enable http2 for http client (#1445)

Full Changelog: v0.20.3...v0.20.4

v0.24.3

14 Aug 14:53
v0.24.3
6c2de38
Compare
Choose a tag to compare

[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

v0.24.2

02 Aug 15:48
v0.24.2
c9e26b0
Compare
Choose a tag to compare

[v0.24.2] - 2024-08-02

Another small release that fixes:

  • Notifications without params were not handled correctly in the client, which been has been fixed.
  • Improve compile times and reduce code-generation in the proc macro crate.

[Fixed]

  • client: parse notification without params (#1436)
  • proc macros: remove direct tracing calls (#1405)

Thanks to the external contributor @DaniPopes who contributed to this release.

Full Changelog: v0.24.1...v0.24.2

v0.24.1

30 Jul 10:27
v0.24.1
65fcb8c
Compare
Choose a tag to compare

[v0.24.1] - 2024-07-30

This is a small release that forces jsonrpsee rustls to use the crypto backend ring which may panic if both ring and aws-lc features are enabled. See rustls/rustls#1877 for further information.

This has no impact on the default configuration of jsonrpsee which was already using ring as the default.

[Changed]

  • chore(deps): update gloo-net requirement from 0.5.0 to 0.6.0 (#1428)

[Fixed]

  • fix: Explicitly set rustls provider before using rustls (#1424)

Full Changelog: v0.24.0...v0.24.1

v0.24.0

09 Jul 08:56
v0.24.0
fc75a88
Compare
Choose a tag to compare

[v0.24.0] - 2024-07-05

A breaking release that mainly changes:

  1. tls feature for the client has been divided into tls and tls-platform-verifier where the tls feature
    will only include rustls and no specific certificate store but the default one is still tls-rustls-platform-verifier.
    This is useful if one wants to avoid bring on openssl dependencies.
  2. Remove dependencies anyhow and beef from the codebase.

[Changed]

  • types: serialize id in Response before result/error fields (#1421)
  • refactor(client+transport)!: split tls into tls and tls-rustls-platform-verifier features (#1419)
  • chore(deps): update rustc-hash requirement from 1 to 2 (#1410)
  • deps: remove anyhow (#1402)
  • deps: remove beef (#1401)

v0.23.2

26 Jun 09:31
v0.23.2
c6344f9
Compare
Choose a tag to compare

[v0.23.2] - 2024-06-26

This a small patch release that fixes a couple of bugs and adds a couple of new APIs.

The bug fixes are:

  • The server::ws::on_connect was not working properly due to a merge nit when upgrading to hyper v1.0
    This impacts only users that are using the low-level API and not the server itself.
  • WsTransport::build_with_stream shouldn't not resolve the socket addresses and it's fixed now, see #1411 for further info.
    This impacts users that are injecting their own TcpStream directly into the WsTransport.

[Added]

  • server: add RpcModule::remove (#1416)
  • server: add capacity and max_capacity to the subscription API (#1414)
  • server: add PendingSubscriptionSink::method_name (#1413)

[Fixed]

  • server: make ws::on_connect work again (#1418)
  • client: WsTransport::build_with_stream don't resolve sockaddrs (#1412)

Full Changelog: v0.23.1...v0.23.2

v0.23.1

10 Jun 15:25
v0.23.1
717e9fe
Compare
Choose a tag to compare

[v0.23.1] - 2024-06-10

This is a patch release that injects the ConnectionId in
the extensions when using a RpcModule without a server. This impacts
users that are using RpcModule directly (e.g., unit testing) and not the
server itself.

[Changed]

  • types: remove anyhow dependency (#1398)

[Fixed]

  • rpc module: inject ConnectionId in extensions (#1399)

Full Changelog: v0.23.0...v0.23.1

v0.23.0

07 Jun 08:02
v0.23.0
251c549
Compare
Choose a tag to compare

[v0.23.0] - 2024-06-07

This is a new breaking release, and let's go through the changes.

hyper v1.0

jsonrpsee has been upgraded to use hyper v1.0 and this mainly impacts users that are using
the low-level API and rely on the hyper::service::make_service_fn
which has been removed, and from now on you need to manage the socket yourself.

The hyper::service::make_service_fn can be replaced by the following example template:

async fn start_server() {
  let listener = tokio::net::TcpListener::bind("127.0.0.1:0").await.unwrap();

  loop {
    let sock = tokio::select! {
    res = listener.accept() => {
        match res {
          Ok((stream, _remote_addr)) => stream,
          Err(e) => {
            tracing::error!("failed to accept v4 connection: {:?}", e);
            continue;
          }
        }
      }
      _ = per_conn.stop_handle.clone().shutdown() => break,
    };

    let svc = tower::service_fn(move |req: hyper::Request<hyper::body::Incoming>| {
      let mut jsonrpsee_svc = svc_builder
        .set_rpc_middleware(rpc_middleware)
        .build(methods, stop_handle);
      // https://github.com/rust-lang/rust/issues/102211 the error type can't be inferred
      // to be `Box<dyn std::error::Error + Send + Sync>` so we need to convert it to a concrete type
      // as workaround.
      jsonrpsee_svc
        .call(req)
        .await
        .map_err(|e| anyhow::anyhow!("{:?}", e))
    });

    tokio::spawn(jsonrpsee::server::serve_with_graceful_shutdown(
      sock,
      svc,
      stop_handle.clone().shutdown(),
    ));
  }
}

Also, be aware that tower::service_fn and hyper::service::service_fn are different and it's recommended to use tower::service_fn from now.

Extensions

Because it was not possible/easy to share state between RPC middleware layers
jsonrpsee has added Extensions to the Request and Response.
To allow users to inject arbitrary data that can be accessed in the RPC middleware
and RPC handlers.

Please be careful when injecting large amounts of data into the extensions because
It's cloned for each RPC call, which can increase memory usage significantly.

The connection ID from the jsonrpsee-server is injected in the extensions by default.
and it is possible to fetch it as follows:

struct LogConnectionId<S>(S);

impl<'a, S: RpcServiceT<'a>> RpcServiceT<'a> for LogConnectionId<S> {
	type Future = S::Future;

	fn call(&self, request: jsonrpsee::types::Request<'a>) -> Self::Future {
		let conn_id = request.extensions().get::<ConnectionId>().unwrap();
		tracing::info!("Connection ID {}", conn_id.0);

		self.0.call(request)
	}
}

In addition the Extensions is not added in the proc-macro API by default and
one has to enable with_extensions attr for that to be available:

#[rpc(client, server)]
pub trait Rpc {
	// legacy
	#[method(name = "foo"])
	async fn async_method(&self) -> u16>;

	// with extensions
	#[method(name = "with_ext", with_extensions)]
	async fn f(&self) -> bool;
}

impl RpcServer for () {
	async fn async_method(&self) -> u16 {
		12
	}

	// NOTE: ext is injected just after self in the API
	async fn f(&self, ext: &Extensions: b: String) -> {
		ext.get::<u32>().is_ok()
	}
}

client - TLS certificate store changed

The default TLS certificate store has been changed to
rustls-platform-verifier to decide the best certificate
store for each platform.

In addition it's now possible to inject a custom certificate store
if one wants need some special certificate store.

client - Subscription API modified

The subscription API has been modified:

  • The error type has been changed to serde_json::Error
    to indicate that error can only occur if the decoding of T fails.
  • It has been some confusion when the subscription is closed which can occur if the client "lagged" or the connection is closed.
    Now it's possible to call Subscription::close_reason after the subscription closed (i.e. has return None) to know why.

If one wants to replace old messages in case of lagging it is recommended to write your own adaptor on top of the subscription:

fn drop_oldest_when_lagging<T: Clone + DeserializeOwned + Send + Sync + 'static>(
    mut sub: Subscription<T>,
    buffer_size: usize,
) -> impl Stream<Item = Result<T, BroadcastStreamRecvError>> {
    let (tx, rx) = tokio::sync::broadcast::channel(buffer_size);

    tokio::spawn(async move {
        // Poll the subscription which ignores errors
        while let Some(n) = sub.next().await {
            let msg = match n {
                Ok(msg) => msg,
                Err(e) => {
                    tracing::error!("Failed to decode the subscription message: {e}");
                    continue;
                }
            };

            // Only fails if the receiver has been dropped
            if tx.send(msg).is_err() {
                return;
            }
        }
    });

    BroadcastStream::new(rx)
}

[Added]

  • server: add serve and serve_with_graceful_shutdown helpers (#1382)
  • server: pass extensions from http layer (#1389)
  • macros: add macro attr with_extensions (#1380)
  • server: inject connection id in extensions (#1381)
  • feat: add Extensions to Request/MethodResponse (#1306)
  • proc-macros: rename parameter names (#1365)
  • client: add Subscription::close_reason (#1320)

[Changed]

  • chore(deps): tokio ^1.23.1 (#1393)
  • server: use ConnectionId in subscription APIs (#1392)
  • server: add logs when connection closed by ws ping/pong (#1386)
  • client: set authorization header from the URL (#1384)
  • client: use rustls-platform-verifier cert store (#1373)
  • client: remove MaxSlots limit (#1377)
  • upgrade to hyper v1.0 (#1368)

v0.22.5

29 Apr 16:11
v0.22.5
f0b27e2
Compare
Choose a tag to compare

[v0.22.5] - 2024-04-29

A small bug-fix release, see each commit below for further information.

[Fixed]

  • proc macros: collision between generated code name and proc macro API (#1363)
  • proc-macros: feature server-core compiles without the feature server (#1360)
  • client: add check in max_buffer_capacity_per_subscription that the buffer size > 0 (#1358)
  • types: Response type ignore unknown fields (#1353)

v0.22.4

08 Apr 16:14
v0.22.4
5134502
Compare
Choose a tag to compare

[v0.22.4] - 2024-04-08

Yet another rather small release that fixes a cancel-safety issue that
could cause an unexpected panic when reading disconnect reason from the background task.

Also this makes the API Client::disconnect_reason cancel-safe.

[Added]

  • client: support batched notifications (#1327)
  • client: support batched subscription notifs (#1332)

[Changed]

  • client: downgrade logs from error/warn -> debug (#1343)

[Fixed]

  • Update MSRV to 1.74.1 in Cargo.toml (#1338)
  • client: disconnect_reason/read_error is now cancel-safe (#1347)