Skip to content

Releases: paritytech/jsonrpsee

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)

v0.22.3

20 Mar 16:53
v0.22.3
8c73cc6
Compare
Choose a tag to compare

[v0.22.3] - 2024-03-20

Another small release that adds a new API for RpcModule if one already has the state in an Arc
and a couple of bug fixes.

[Added]

  • add RpcModule::from_arc (#1324)

[Fixed]

  • Revert "fix(server): return err on WS handshake err (#1288)" (#1326)
  • export AlreadyStoppedError (#1325)

Thanks to the external contributors @mattsse and @aatifsyed who contributed to this release.

v0.22.2

05 Mar 16:41
v0.22.2
2f16e78
Compare
Choose a tag to compare

[v0.22.2] - 2024-03-05

This is a small patch release that exposes the connection details to server methods without breaking changes.
Currently, users can only retrieve the connection ID from these details.
We plan to extend this functionality in jsonrpsee v1.0, although this will necessitate a breaking change.

[Added]

  • server: Register raw method with connection ID (#1297)

[Changed]

  • Update Syn 1.0 -> 2.0 (#1304)

v0.22.1

19 Feb 15:07
v0.22.1
736dd65
Compare
Choose a tag to compare

[v0.22.1] - 2024-02-19

This is a small patch release that internally changes AtomicU64 to AtomicUsize
to support more targets.

[Fixed]

  • fix(docs): part of proc-macro documentation not rendering correctly in IDE (#1294)
  • fix(client): change to AtomicU64 to AtomicUsize (#1293)
  • fix(server): low-level API return err on WS handshake err (#1288)

v0.22.0

07 Feb 15:43
v0.22.0
72939a9
Compare
Choose a tag to compare

[v0.22.0] - 2024-02-07

Another breaking release where a new ResponsePayload type is introduced in order
to make it possible to determine whether a response has been processed.

Unfortunately, the IntoResponse trait was modified to enable that
and some minor changes were made to make more fields private to avoid further
breakage.

Example of the async ResponsePayload API

#[rpc(server)]
pub trait Api {
	#[method(name = "x")]
	fn x(&self) -> ResponsePayload<'static, String>;
}

impl RpcServer for () {
	fn x(&self) -> ResponsePayload<'static, String> {
		let (rp, rp_done) = ResponsePayload::success("ehheeheh".to_string()).notify_on_completion();

		tokio::spawn(async move {
			if rp_done.await.is_ok() {
				do_task_that_depend_x();
			}
		});

		rp
	}
}

Roadmap

We are getting closer to releasing jsonrpsee v1.0 and
the following work is planned:

  • Native async traits
  • Upgrade hyper to v1.0
  • Better subscription API for the client.

Thanks to the external contributor @dan-starkware who contributed to this release.

[Added]

  • feat(server): add TowerService::on_session_close (#1284)
  • feat(server): async API when Response has been processed. (#1281)

[Changed]

  • client(error): make display impl less verbose (#1283)
  • fix: allow application/json-rpc http content type (#1277)
  • refactor(rpc_module): RpcModule::raw_json_request -> String (#1287)

v0.21.0

13 Dec 08:20
v0.21.0
66af1e7
Compare
Choose a tag to compare

[v0.21.0] - 2023-12-13

This release contains big changes and let's go over the main ones:

JSON-RPC specific middleware

After getting plenty of feedback regarding a JSON-RPC specific middleware,
this release introduces a composable "tower-like" middleware that applies per JSON-RPC method call.
The new middleware also replaces the old RpcLogger which may break some use-cases, such as if
JSON-RPC was made on a WebSocket or HTTP transport, but it's possible to implement that by
using jsonrpsee as a tower service or the low-level server API.

An example how write such middleware:

#[derive(Clone)]
pub struct ModifyRequestIf<S>(S);

impl<'a, S> RpcServiceT<'a> for ModifyRequestIf<S>
where
	S: Send + Sync + RpcServiceT<'a>,
{
	type Future = S::Future;

	fn call(&self, mut req: Request<'a>) -> Self::Future {
		// Example how to modify the params in the call.
		if req.method == "say_hello" {
			// It's a bit awkward to create new params in the request
			// but this shows how to do it.
			let raw_value = serde_json::value::to_raw_value("myparams").unwrap();
			req.params = Some(StdCow::Owned(raw_value));
		}
		// Re-direct all calls that isn't `say_hello` to `say_goodbye`
		else if req.method != "say_hello" {
			req.method = "say_goodbye".into();
		}

		self.0.call(req)
	}
}

async fn run_server() {
	// Construct our middleware and build the server.
	let rpc_middleware = RpcServiceBuilder::new().layer_fn(|service| ModifyRequestIf(service));
	let server = Server::builder().set_rpc_middleware(rpc_middleware).build("127.0.0.1:0").await.unwrap();

	// Start the server.
	let mut module = RpcModule::new(());
	module.register_method("say_hello", |_, _| "lo").unwrap();
	module.register_method("say_goodbye", |_, _| "goodbye").unwrap();

	let handle = server.start(module);
	handle.stopped().await;
}

jsonrpsee server as a tower service

For users who want to get full control of the HTTP request, it's now possible to utilize jsonrpsee as a tower service
example here

jsonrpsee server low-level API

For users who want to get low-level access and for example to disconnect
misbehaving peers that is now possible as well example here

Logging in the server

Logging of RPC calls has been disabled by default,
but it's possible to enable that with the RPC logger middleware or provide
your own middleware for that.

let rpc_middleware = RpcServiceBuilder::new().rpc_logger(1024);
let server = Server::builder().set_rpc_middleware(rpc_middleware).build("127.0.0.1:0").await?;

WebSocket ping/pong API

The WebSocket ping/pong APIs have been refactored to be able
to disconnect inactive connections both by from the server and client-side.

Thanks to the external contributors @oleonardolima
and @venugopv who contributed to this release.

[Changed]

  • chore(deps): update tokio-rustls requirement from 0.24 to 0.25 (#1256)
  • chore(deps): update gloo-net requirement from 0.4.0 to 0.5.0 (#1260)
  • chore(deps): update async-lock requirement from 2.4 to 3.0 (#1226)
  • chore(deps): update proc-macro-crate requirement from 1 to 2 (#1211)
  • chore(deps): update console-subscriber requirement from 0.1.8 to 0.2.0 (#1210)
  • refactor: split client and server errors (#1122)
  • refactor(ws client): impl tokio:{AsyncRead, AsyncWrite} for EitherStream (#1249)
  • refactor(http client): enable all http versions (#1252)
  • refactor(server): change ws ping API (#1248)
  • refactor(ws client): generic over data stream (#1168)
  • refactor(client): unify ws ping/pong API with the server (#1258
  • refactor: set tcp_nodelay == true by default ([#1263])(#1263)

[Added]

  • feat(client): add disconnect_reason API (#1246)
  • feat(server): jsonrpsee as service and low-level API for more fine-grained API to disconnect peers etc (#1224)
  • feat(server): JSON-RPC specific middleware (#1215)
  • feat(middleware): add HostFilterLayer::disable (#1213)

[Fixed]

  • fix(host filtering): support hosts with multiple ports (#1227)

v0.20.3

24 Oct 16:28
v0.20.3
Compare
Choose a tag to compare

[v0.20.3] - 2023-10-24

This release fixes a cancel-safety issue in the server's graceful shutdown which could lead to high CPU usage.

[Fixed]

  • server: graceful shutdown distinguish between stopped and conn closed (#1220)
  • server: graceful shutdown fix cancel-safety issue (#1218)
  • server: graceful shutdown check Incoming::Closed (#1216)

v0.20.2

13 Oct 17:52
v0.20.2
83fd6b1
Compare
Choose a tag to compare

[v0.20.2] - 2023-10-13

This release removes the bounded buffer check which was intended to provide
backpressure all the way down to the TCP layer but it didn't work well.

For subscriptions the backpressure will be handled by implementation itself
and just rely on that.

[Changed]

  • server: remove bounded channel check (#1209)

v0.20.1

15 Sep 16:38
v0.20.1
0baddfd
Compare
Choose a tag to compare

[v0.20.1] - 2023-09-15

This release adds support for synchronous subscriptions and fixes a leak in WebSocket server
where FuturesUnordered was not getting polled until shutdown, so it was accumulating tasks forever.

[Changed]

  • client: downgrade log for unknown subscription to DEBUG (#1185)
  • refactor(http client): use HTTP connector on http URLs (#1187)
  • refactor(server): less alloc per method call (#1188)

[Fixed]

  • fix: remove needless clone in ws background task (#1203)
  • async client: save latest Waker (#1198)
  • chore(deps): bump actions/checkout from 3.6.0 to 4.0.0 (#1197)
  • fix(server): fix leak in FuturesUnordered (#1204)

[Added]

  • feat(server): add sync subscription API register_subscription_raw (#1182)