Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(rpc): Use jsonrpsee in zebra-node-services #9151

Merged
merged 4 commits into from
Jan 20, 2025
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 1 addition & 16 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2149,21 +2149,6 @@ dependencies = [
"serde_json",
]

[[package]]
name = "jsonrpc-core"
version = "18.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "14f7f76aef2d054868398427f6c54943cf3d1caa9a7ec7d0c38d69df97a965eb"
dependencies = [
"futures",
"futures-executor",
"futures-util",
"log",
"serde",
"serde_derive",
"serde_json",
]

[[package]]
name = "jsonrpsee"
version = "0.24.7"
Expand Down Expand Up @@ -5895,7 +5880,7 @@ name = "zebra-node-services"
version = "1.0.0-beta.44"
dependencies = [
"color-eyre",
"jsonrpc-core",
"jsonrpsee-types",
"reqwest",
"serde",
"serde_json",
Expand Down
5 changes: 2 additions & 3 deletions zebra-node-services/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ getblocktemplate-rpcs = [

rpc-client = [
"color-eyre",
"jsonrpc-core",
"jsonrpsee-types",
"reqwest",
"serde",
"serde_json",
Expand All @@ -43,7 +43,7 @@ zebra-chain = { path = "../zebra-chain" , version = "1.0.0-beta.44" }

# Tool and test feature rpc-client
color-eyre = { version = "0.6.3", optional = true }
jsonrpc-core = { version = "18.0.0", optional = true }
jsonrpsee-types = { version = "0.24.7", optional = true }
# Security: avoid default dependency on openssl
reqwest = { version = "0.12.9", default-features = false, features = ["rustls-tls"], optional = true }
serde = { version = "1.0.215", optional = true }
Expand All @@ -53,7 +53,6 @@ tokio = { version = "1.42.0", features = ["time", "sync"] }
[dev-dependencies]

color-eyre = "0.6.3"
jsonrpc-core = "18.0.0"
reqwest = { version = "0.12.9", default-features = false, features = ["rustls-tls"] }
serde = "1.0.215"
serde_json = "1.0.133"
13 changes: 7 additions & 6 deletions zebra-node-services/src/rpc_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,13 @@
fn json_result_from_response_text<T: serde::de::DeserializeOwned>(
response_text: &str,
) -> std::result::Result<T, BoxError> {
use jsonrpc_core::Output;

let output: Output = serde_json::from_str(response_text)?;
match output {
Output::Success(success) => Ok(serde_json::from_value(success.result)?),
Output::Failure(failure) => Err(failure.error.into()),
let output: jsonrpsee_types::Response<serde_json::Value> =

Check failure on line 111 in zebra-node-services/src/rpc_client.rs

View workflow job for this annotation

GitHub Actions / Build zebra-node-services crate

failed to resolve: use of undeclared crate or module `jsonrpsee_types`
serde_json::from_str(response_text)?;
match output.payload {
jsonrpsee_types::ResponsePayload::Success(success) => {

Check failure on line 114 in zebra-node-services/src/rpc_client.rs

View workflow job for this annotation

GitHub Actions / Build zebra-node-services crate

failed to resolve: use of undeclared crate or module `jsonrpsee_types`
Ok(serde_json::from_value(success.into_owned())?)
}
jsonrpsee_types::ResponsePayload::Error(failure) => Err(failure.to_string().into()),

Check failure on line 117 in zebra-node-services/src/rpc_client.rs

View workflow job for this annotation

GitHub Actions / Build zebra-node-services crate

failed to resolve: use of undeclared crate or module `jsonrpsee_types`
}
}
}
4 changes: 1 addition & 3 deletions zebra-rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,7 @@ jsonrpsee-types = "0.24.7"
jsonrpsee-proc-macros = "0.24.7"
hyper = "1.5.0"
http-body-util = "0.1.2"

# zebra-rpc needs the preserve_order feature in serde_json, which is a dependency of jsonrpc-core
serde_json = { version = "1.0.133", features = ["preserve_order"] }
serde_json = "1.0.133"
indexmap = { version = "2.7.0", features = ["serde"] }

# RPC endpoint basic auth
Expand Down
Loading