-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Fix rustls setup for jsonrpsee clients (#2417)
## What ❔ `jsonrpsee` client expects `rustls` to use the default crypto provider, but `rustls` cannot choose and panics if there are multiple providers available. See [this issue](rustls/rustls#1877) for more detail. Recently `rustls` changed the default backend, so now some (older) of crates use `ring` backend, while some (newer) use `aws-lc-rs`. Until the issue is fixed on `jsonrpsee` side, we're making sure that the provider is installed before we create any `jsonrpsee` client. Added test used to fail before the change and passes now. ## Why ❔ Panics are bad. ## Checklist <!-- Check your PR fulfills the following items. --> <!-- For draft PRs check the boxes as you complete them. --> - [ ] PR title corresponds to the body of PR (we generate changelog entries from PRs). - [ ] Tests for the changes have been added / updated. - [ ] Documentation comments have been added / updated. - [ ] Code has been formatted via `zk fmt` and `zk lint`.
- Loading branch information
Showing
7 changed files
with
81 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/// Makes sure that `rustls` crypto backend is set before we instantiate | ||
/// a `Web3` client. `jsonrpsee` doesn't explicitly set it, and when | ||
/// multiple crypto backends are enabled, `rustls` can't choose one and panics. | ||
/// See [this issue](https://github.com/rustls/rustls/issues/1877) for more detail. | ||
/// | ||
/// The problem is on `jsonrpsee` side, but until it's fixed we have to patch it. | ||
pub(super) fn set_rustls_backend_if_required() { | ||
// Function returns an error if the provider is already installed, and we're fine with it. | ||
let _ = rustls::crypto::aws_lc_rs::default_provider().install_default(); | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.