Skip to content
This repository has been archived by the owner on Aug 24, 2023. It is now read-only.

bump(deps): update rust crate jsonrpsee to 0.20.0 #84

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

renovate[bot]
Copy link
Contributor

@renovate renovate bot commented Sep 12, 2022

Mend Renovate

This PR contains the following updates:

Package Type Update Change
jsonrpsee (source) dependencies minor 0.15.1 -> 0.20.0

Release Notes

paritytech/jsonrpsee (jsonrpsee)

v0.20.0

Compare Source

Another breaking release where the major changes are:

  • host filtering has been moved to tower middleware instead of the server API.
  • the clients now supports default port number such wss://my.server.com
  • the background task for the async client has been refactored to multiplex send and read operations.

Regarding host filtering prior to this release one had to do:

let acl = AllowHosts::Only(vec!["http://localhost:*".into(), "http://127.0.0.1:*".into()]);
let server = ServerBuilder::default().set_host_filtering(acl).build("127.0.0.1:0").await.unwrap();

After this release then one have to do:

let middleware = tower::ServiceBuilder::new().layer(HostFilterLayer::new(["example.com"]).unwrap());
let server = Server::builder().set_middleware(middleware).build("127.0.0.1:0".parse::<SocketAddr>()?).await?;

Thanks to the external contributors @​polachok, @​bobs4462 and @​aj3n that contributed to this release.

[Added]
  • feat(server): add SubscriptionMessage::new (#​1176)
  • feat(server): add SubscriptionSink::connection_id (#​1175)
  • feat(server): add Params::get (#​1173)
  • feat(server): add PendingSubscriptionSink::connection_id (#​1163)
[Fixed]
  • fix(server): host filtering URI read authority (#​1178)
[Changed]
  • refactor: make ErrorObject::borrowed accept &str (#​1160)
  • refactor(client): support default port number (#​1172)
  • refactor(server): server host filtering (#​1174)
  • refactor(client): refactor background task (#​1145)
  • refactor: use RootCertStore::add_trust_anchors (#​1165)
  • chore(deps): update criterion v0.5 and pprof 0.12 (#​1161)
  • chore(deps): update webpki-roots requirement from 0.24 to 0.25 (#​1158)
  • refactor(server): move host filtering to tower middleware (#​1179)

v0.19.0

Compare Source

[Fixed]
  • Fixed connections processing await on server shutdown (#​1153)
  • fix: include error code in RpcLogger (#​1135)
  • fix: downgrade more logs to debug (#​1127)
  • fix(server): remove MethodSinkPermit to fix backpressure issue on concurrent subscriptions (#​1126)
  • fix readme links (#​1152)
[Changed]
  • server: downgrade connection logs to debug (#​1123)
  • refactor(server): make Server::start infallible and add fn builder() (#​1137)

v0.18.2

Compare Source

This release improves error message for too big batch response and exposes the BatchRequestConfig type in order to make it possible to use ServerBuilder::set_batch_request_config

[Fixed]
  • server: export BatchRequestConfig (#​1112)
  • fix(server): improve too big batch response msg (#​1107)

v0.18.1

Compare Source

This release fixes a couple bugs and improves the ergonomics for the HTTP client
when no tower middleware is enabled.

[Changed]
  • http client: add default generic param for the backend (#​1099)
[Fixed]
  • rpc module: fix race in subscription close callback (#​1098)
  • client: add missing batch request tracing span (#​1097)
  • ws server: don't wait for graceful shutdown when connection already closed (#​1103)

v0.18.0

Compare Source

This is a breaking release that removes the CallError which was used to represent a JSON-RPC error object that
could happen during JSON-RPC method call and one could assign application specific error code, message and data in a
specific implementation.

Previously jsonrpsee provided CallError that could be converted to/from jsonrpsee::core::Error
and in some scenarios the error code was automatically assigned by jsonrpsee. After jsonrpsee
added support for custom error types the CallError doesn't provide any benefit because one has to implement Into<ErrorObjectOwned>
on the error type anyway.

Thus, jsonrpsee::core::Error can't be used in the proc macro API anymore and the type alias
RpcResult has been modified to Result<(), ErrorObjectOwned> instead.

Before it was possible to do:

#[derive(thiserror::Error)]
enum Error {
	A,
	B,
}

#[rpc(server, client)]
pub trait Rpc
{
	#[method(name = "getKeys")]
	async fn keys(&self) -> Result<String, jsonrpsee::core::Error> {
		Err(jsonrpsee::core::Error::to_call_error(Error::A))
		// or jsonrpsee::core::Error::Call(CallError::Custom(ErrorObject::owned(1, "a", None::<()>)))
	}
}

After this change one has to do:

pub enum Error {
	A,
	B,
}

impl From<Error> for ErrorObjectOwned {
	fn from(e: Error) -> Self {
		match e {
			Error::A => ErrorObject::owned(1, "a", None::<()>),
			Error::B => ErrorObject::owned(2, "b", None::<()>),
		}
	}
}

#[rpc(server, client)]
pub trait Rpc {
	// Use a custom error type that implements `Into<ErrorObject>`
	#[method(name = "custom_err_ty")]
	async fn custom_err_type(&self) -> Result<String, Error> {
		Err(Error::A)
	}

	// Use `ErrorObject` as error type directly.
	#[method(name = "err_obj")]
	async fn error_obj(&self) -> RpcResult<String> {
		Err(ErrorObjectOwned::owned(1, "c", None::<()>))
	}
}
[Changed]
[Fixed]
  • fix(proc macros): support parsing params !Result (#​1094)

v0.17.1

Compare Source

This release fixes HTTP graceful shutdown for the server.

[Fixed]
  • server: fix http graceful shutdown (#​1090)

v0.17.0

Compare Source

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

Compare Source

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

Compare Source

v0.16.1 is release that adds two new APIs to 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

Compare Source

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)

Configuration

📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 Ignore: Close this PR and you won't be reminded about this update again.


  • If you want to rebase/retry this PR, check this box

This PR has been generated by Mend Renovate. View repository job log here.

@netlify
Copy link

netlify bot commented Sep 12, 2022

Deploy Preview for metachain failed.

Name Link
🔨 Latest commit c5c9e20
🔍 Latest deploy log https://app.netlify.com/sites/metachain/deploys/64d65f909778680008b0cc6d

@defichain-bot defichain-bot added area/meta kind/dependencies Pull requests that update a dependency file meta/node labels Sep 12, 2022
@codecov
Copy link

codecov bot commented Oct 3, 2022

Codecov Report

Patch coverage has no change and project coverage change: +85.50% 🎉

Comparison is base (111e219) 3.96% compared to head (8d5fd06) 89.47%.

❗ Current head 8d5fd06 differs from pull request most recent head c5c9e20. Consider uploading reports for the commit c5c9e20 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##            main      #84       +/-   ##
==========================================
+ Coverage   3.96%   89.47%   +85.50%     
==========================================
  Files         10        4        -6     
  Lines       1766       57     -1709     
  Branches       0        3        +3     
==========================================
- Hits          70       51       -19     
+ Misses      1696        6     -1690     

see 14 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@renovate renovate bot changed the title bump(deps): update rust crate jsonrpsee to 0.15.1 bump(deps): update rust crate jsonrpsee to 0.16.0 Nov 9, 2022
@renovate renovate bot changed the title bump(deps): update rust crate jsonrpsee to 0.16.0 bump(deps): update rust crate jsonrpsee to 0.16.1 Nov 18, 2022
@renovate renovate bot changed the title bump(deps): update rust crate jsonrpsee to 0.16.1 bump(deps): update rust crate jsonrpsee to 0.16.2 Dec 1, 2022
@renovate renovate bot changed the title bump(deps): update rust crate jsonrpsee to 0.16.2 Update Rust crate jsonrpsee to 0.16.2 Dec 17, 2022
@defichain-bot defichain-bot removed the kind/dependencies Pull requests that update a dependency file label Dec 17, 2022
@renovate renovate bot changed the title Update Rust crate jsonrpsee to 0.16.2 bump(deps): update rust crate jsonrpsee to 0.16.2 Dec 17, 2022
@defichain-bot defichain-bot added the kind/dependencies Pull requests that update a dependency file label Dec 17, 2022
@renovate renovate bot changed the title bump(deps): update rust crate jsonrpsee to 0.16.2 bump(deps): update rust crate jsonrpsee to 0.17.0 Apr 18, 2023
@renovate renovate bot changed the title bump(deps): update rust crate jsonrpsee to 0.17.0 bump(deps): update rust crate jsonrpsee to 0.17.1 Apr 21, 2023
@renovate renovate bot changed the title bump(deps): update rust crate jsonrpsee to 0.17.1 bump(deps): update rust crate jsonrpsee to 0.18.0 Apr 24, 2023
@renovate renovate bot changed the title bump(deps): update rust crate jsonrpsee to 0.18.0 bump(deps): update rust crate jsonrpsee to 0.18.1 Apr 27, 2023
@renovate renovate bot force-pushed the renovate/jsonrpsee-0.x branch from 7e1644a to 1d46e62 Compare May 28, 2023 09:40
@renovate renovate bot changed the title bump(deps): update rust crate jsonrpsee to 0.18.1 bump(deps): update rust crate jsonrpsee to 0.18.2 May 28, 2023
@renovate renovate bot changed the title bump(deps): update rust crate jsonrpsee to 0.18.2 bump(deps): update rust crate jsonrpsee to 0.19.0 Jul 24, 2023
@renovate renovate bot changed the title bump(deps): update rust crate jsonrpsee to 0.19.0 bump(deps): update rust crate jsonrpsee to 0.20.0 Aug 11, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area/meta kind/dependencies Pull requests that update a dependency file meta/node
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant