Skip to content

Commit

Permalink
fix(rpc): Use jsonrpsee in zebra-node-services (#9151)
Browse files Browse the repository at this point in the history
* replace jsonrpc-core with jsonrpsee-types in zebra-node-services

* remove non needed feature from dependency

* remove jsonrpc-core as a dev dependency in zebra-node-services

* add jsonrpsee-types as a dev dependency
  • Loading branch information
oxarbitrage authored Jan 20, 2025
1 parent c7d8d71 commit c103c2d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 28 deletions.
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
6 changes: 3 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,7 @@ 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"
jsonrpsee-types = "0.24.7"
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 @@ impl RpcRequestClient {
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> =
serde_json::from_str(response_text)?;
match output.payload {
jsonrpsee_types::ResponsePayload::Success(success) => {
Ok(serde_json::from_value(success.into_owned())?)
}
jsonrpsee_types::ResponsePayload::Error(failure) => Err(failure.to_string().into()),
}
}
}
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

0 comments on commit c103c2d

Please sign in to comment.