Skip to content

Releases: paritytech/jsonrpsee

v0.17.0

18 Apr 10:41
v0.17.0
1cde29c
Compare
Choose a tag to compare

This is a significant release and the major breaking changes to be aware of are:

Server backpressure

This release changes the server to be "backpressured" and it mostly concerns subscriptions.
New APIs has been introduced because of that and the API pipe_from_stream has been removed.

Before it was possible to do:

	module
		.register_subscription("sub", "s", "unsub", |_, sink, _| async move {
			let stream = stream_of_integers();

			tokio::spawn(async move {
				sink.pipe_from_stream(stream)
			});
		})
		.unwrap();

After this release one must do something like:

	// This is just a example helper.
	//
	// Other examples:
	// - <https://github.com/paritytech/jsonrpsee/blob/master/examples/examples/ws_pubsub_broadcast.rs>
	// - <https://github.com/paritytech/jsonrpsee/blob/master/examples/examples/ws_pubsub_with_params.rs>
	async fn pipe_from_stream<T: Serialize>(
		pending: PendingSubscriptionSink,
		mut stream: impl Stream<Item = T> + Unpin,
	) -> Result<(), anyhow::Error> {
		let mut sink = pending.accept().await?;

		loop {
			tokio::select! {
				_ = sink.closed() => break Ok(()),

				maybe_item = stream.next() => {
					let Some(item) = match maybe_item else {
						break Ok(()),
					};

					let msg = SubscriptionMessage::from_json(&item)?;

					if let Err(e) = sink.send_timeout(msg, Duration::from_secs(60)).await {
						match e {
							// The subscription or connection was closed.
							SendTimeoutError::Closed(_) => break Ok(()),
							/// The subscription send timeout expired
							/// the message is returned and you could save that message
							/// and retry again later.
							SendTimeoutError::Timeout(_) => break Err(anyhow::anyhow!("Subscription timeout expired")),
						}
					}
				}
			}
		}
	}


	module
		.register_subscription("sub", "s", "unsub", |_, pending, _| async move {
			let stream = stream();
			pipe_from_stream(sink, stream).await
		})
		.unwrap();

Method call return type is more flexible

This release also introduces a trait called IntoResponse which is makes it possible to return custom types and/or error
types instead of enforcing everything to return Result<T, jsonrpsee::core::Error>

This affects the APIs RpcModule::register_method, RpcModule::register_async_method and RpcModule::register_blocking_method
and when these are used in the proc macro API are affected by this change.
Be aware that the client APIs don't support this yet

The IntoResponse trait is already implemented for Result<T, jsonrpsee::core::Error> and for the primitive types

Before it was possible to do:

	// This would return Result<&str, jsonrpsee::core::Error>
	module.register_method("say_hello", |_, _| Ok("lo"))?;

After this release it's possible to do:

	// Note, this method call is infallible and you might not want to return Result.
	module.register_method("say_hello", |_, _| "lo")?;

Subscription API is changed.

jsonrpsee now spawns the subscriptions via tokio::spawn and it's sufficient to provide an async block in register_subscription

Further, the subscription API had an explicit close API for closing subscriptions which was hard to understand and
to get right. This has been removed and everything is handled by the return value/type of the async block instead.

Example:

	module
		.register_subscription::<RpcResult<(), _, _>::("sub", "s", "unsub", |_, pending, _| async move {
			// This just answers the RPC call and if this fails => no close notification is sent out.
			pending.accept().await?;
			// This is sent out as a `close notification/message`.
			Err(anyhow::anyhow!("The subscription failed"))?;
		})
		.unwrap();

The return value in the example above needs to implement IntoSubscriptionCloseResponse and
any value that is returned after that the subscription has been accepted will be treated as a IntoSubscriptionCloseResponse.

Because Result<(), E> is used here the close notification will be sent out as error notification but it's possible to
disable the subscription close response by using () instead of Result<(), E> or implement IntoSubscriptionCloseResponse for other behaviour.

[Added]

  • feat(server): configurable limit for batch requests. (#1073)
  • feat(http client): add tower middleware (#981)

[Fixed]

  • add tests for ErrorObject (#1078)
  • fix: tokio v1.27 (#1062)
  • fix: remove needless Semaphore::(u32::MAX) (#1051)
  • fix server: don't send error on JSON-RPC notifications (#1021)
  • fix: add max_log_length APIs and use missing configs (#956)
  • fix(rpc module): subscription close bug (#1011)
  • fix: customized server error codes (#1004)

[Changed]

  • docs: introduce workspace attributes and add keywords (#1077)
  • refactor(server): downgrade connection log (#1076)
  • chore(deps): update webpki-roots and tls (#1068)
  • rpc module: refactor subscriptions to return impl IntoSubscriptionResponse (#1034)
  • add IntoResponse trait for method calls (#1057)
  • Make jsonrpc protocol version field in Response as Option (#1046)
  • server: remove dependency http (#1037)
  • chore(deps): update tower-http requirement from 0.3.4 to 0.4.0 (#1033)
  • chore(deps): update socket2 requirement from 0.4.7 to 0.5.1 (#1032)
  • Update bound type name (#1029)
  • rpc module: remove SubscriptionAnswer (#1025)
  • make verify_and_insert pub (#1028)
  • update MethodKind (#1026)
  • remove batch response (#1020)
  • remove debug log (#1024)
  • client: rename max_notifs_per_subscription to max_buffer_capacity_per_subscription (#1012)
  • client: feature gate tls cert store (#994)
  • server: bounded channels and backpressure (#962)
  • client: use tokio channels (#999)
  • chore: update gloo-net ^0.2.6 (#978)
  • Custom errors (#977)
  • client: distinct APIs to configure max request and response sizes (#967)
  • server: replace FutureDriver with tokio::spawn (#1080)
  • server: uniform whitespace handling in rpc calls (#1082)

v0.16.2

01 Dec 13:40
6a15f75
Compare
Choose a tag to compare

[v0.16.2] - 2022-12-01

This release adds Clone and Copy implementations.

[Fixed]

  • fix(rpc module): make async closures Clone (#948)
  • fix(ci): wasm tests (#946)

[Added]

  • add missing Clone and Copy impls (#951)
  • TowerService should be clone-able for handling concurrent request (#950)

v0.16.1

18 Nov 17:37
v0.16.1
82113dc
Compare
Choose a tag to compare

[v0.16.1] - 2022-11-18

v0.16.1 is release that adds two new APIs to the server http_only and ws_only to make it possible to allow only HTTP respectively WebSocket.

Both HTTP and WebSocket are still enabled by default.

[Fixed]

  • docs: remove outdated features (#938)
  • docs: http client url typo in examples (#940)
  • core: remove unused dependency async-channel (#940)

[Added]

  • server: make it possible to enable ws/http only (#939)

v0.16.0

10 Nov 10:52
v0.16.0
932c55a
Compare
Choose a tag to compare

[v0.16.0] - 2022-11-09

v0.16.0 is a breaking release and the major changes are:

  • The server now support WS and HTTP on the same socket and the jsonrpsee-http-server and jsonrpsee-ws-server crates are moved to the jsonrpsee-server crate instead.
  • The client batch request API is improved such as the errors and valid responses can be iterated over.
  • The server has tower middleware support.
  • The server now adds a tracing span for each connection to distinguish logs per connection.
  • CORS has been moved to tower middleware.

[Fixed]

  • server: read accepted conns properly (#929)
  • server: proper handling of batch errors and mixed calls (#917)
  • jsonrpsee: add types to server feature (#891)
  • http client: more user-friendly error messages when decoding fails (#853)
  • http_server: handle http2 requests host filtering correctly (#866)
  • server: RpcModule::call decode response correctly (#839)

[Added]

  • proc macro: support camelCase & snake_case for object params (#921)
  • server: add connection span (#922)
  • server: Expose the subscription ID (#900)
  • jsonrpsee wrapper crate: add feature async_wasm_client (#893)
  • server: add transport protocol details to the logger trait (#886)
  • middleware: Implement proxy URI paths to RPC methods (#859)
  • client: Implement notify_on_disconnect (#837)
  • Add bytes_len() to Params (#848)
  • Benchmarks for different HTTP header sizes (#824)

[Changed]

  • replace WS and HTTP servers with a server that supports both WS and HTTP (#863)
  • Optimize serialization for client parameters (#864)
  • Uniform log messages (#855)
  • Move CORS logic to tower middleware CorsLayer (#851)
  • server: add log for the http request (#854)
  • server: add tower support (#831)
  • jsonrpsee: less deps when defining RPC API. (#849)
  • server: rename Middleware to Logger (#845)
  • client: adjust TransportSenderT (#852)
  • client: improve batch request API (#910)
  • server: Optimize sending for SubscriptionSink::pipe_from_stream (#901)
  • ws-client: downgrade connection log to debug (#865)
  • use tracing instrument macro (#846)

v0.15.1

29 Jul 11:20
4a7d725
Compare
Choose a tag to compare

[v0.15.1] - 2022-07-29

This release fixes some incorrect tracing spans.

[Fixed]

  • [Bug Fix] - Incorrect trace caused by use of Span::enter in asynchronous code #835

v0.15.0

21 Jul 13:09
e7dc80d
Compare
Choose a tag to compare

[v0.15.0] - 2022-07-20

v0.15.0 is a breaking release. The main changes are:

  • It's now possible to apply resource limits to subscriptions as well as regular calls.
  • We now allow trait bounds to be overridden in the proc macros. See examples/examples/proc_macro_bounds.rs for examples.
  • We've tidied up the subscription API, removing the PendingSink concept (you can still manually accept or reject a sink, but otherwise it'll be accepted automatically if you send a message down it) (#799).
  • Our logging Middleware trait has been split into HttpMiddleware and WsMiddleware to better capture the differences between the two. if you use custom middleware, you'll need to implement one or the other trait on it depending on your used transport method (#793). We also provide params and the method type to middleware calls now, too (#820).
  • We've consistified the API for setting headers across HTTP and WS clients (#799).

Here's the full list of changes:

[Fixed]

  • Fix client generation with param_kind = map #805
  • ws-server: Handle soketto::Incoming::Closed frames #815
  • fix(ws server): reply HTTP 403 on all failed conns #819
  • fix clippy #817

[Added]

  • Add resource limiting for Subscriptions #786
  • feat(logging): add tracing span per JSON-RPC call #722
  • feat(clients): add explicit unsubscribe API #789
  • Allow trait bounds to be overridden in macro #808

[Changed]

  • Point to a new v1.0 milestone in the README.md #801
  • chore(deps): upgrade tracing v0.1.34 #800
  • Replace cargo-nextest with cargo-test for running tests #802
  • Remove deny_unknown_fields from Request and Response #803
  • substrate-subxt -> subxt #807
  • chore(deps): update pprof requirement from 0.9 to 0.10 #810
  • Return error from subscription callbacks #799
  • middleware refactoring #793
  • feat(middleware): expose type of the method call #820
  • Uniform API for custom headers between clients #814
  • Update links to client directories. #822

v0.14.0

14 Jun 10:09
2118975
Compare
Choose a tag to compare

[v0.14.0] - 2022-06-14

v0.14.0 is breaking release which changes the health and access control APIs and a bunch of bug fixes.

[Fixed]

  • fix(servers): more descriptive errors when calls fail #790
  • fix(ws server): support * in host and origin filtering #781
  • fix(rpc module): register failed unsubscribe calls in middleware #792
  • fix(http server): omit jsonrpc details in health API #785
  • fix(servers): skip leading whitespace in JSON deserialization #783
  • fix(ws-server): Submit ping regardless of WS messages #788
  • fix(rpc_module): remove expect in fn call #774

[Added]

  • feat(ws-client): ping-pong for WebSocket clients #772
  • feat(ws-server): Implement ping-pong for WebSocket server #782

[Changed]

  • chore(deps): bump Swatinem/rust-cache from 1.3.0 to 1.4.0 #778
  • chore(deps): bump actions/checkout from 2.4.0 to 3.0.2 #779
  • chore(ci): bring back daily benchmarks #777
  • chore(examples): Move examples under dedicated folder to simplify Cargo.toml #769

v0.13.1

13 May 18:36
4706aad
Compare
Choose a tag to compare

[v0.13.1] - 2022-05-13

v0.13.1 is a release that fixes the documentation for feature-gated items on docs.rs.

v0.13.0

11 May 19:57
ea36d88
Compare
Choose a tag to compare

[v0.13.0] - 2022-05-11

v0.13.0 is release that adds health API support for the HTTP server and a few bug fixes.

[Added]

feat: add http health API #763

[Fixed]

  • hide internal macros from public interface #755
  • fix: add core behind http-server feature #760

v0.12.0

06 May 11:26
7690a26
Compare
Choose a tag to compare

[v0.12.0] - 2022-05-06

v0.12.0 is mainly a patch release with some minor features added.

[Added]

  • Make it possible to disable batch requests support #744
  • feat: add a way to limit the number of subscriptions per connection #739

[Fixed]

  • fix(http client): use https connector for https #750
  • fix(rpc module): close subscription task when a subscription is unsubscribed via the unsubscribe call #743
  • fix(jsonrpsee): generate docs behind features #741

[Changed]

  • remove vault from ci #745
  • chore(deps): update pprof requirement from 0.7 to 0.8 #732
  • chore(deps): update gloo-net requirement from 0.1.0 to 0.2.0 #733