Skip to content

Commit

Permalink
feature(rpc): Migrate from deprecated jsonrpc_* crates to `jsonrpse…
Browse files Browse the repository at this point in the history
…e` (#9059)

* update methods

* update get block template rpc methods

* update other getblocktemplate files

* upgrade server and middlewares

* upgrade zebrad start command

* remove unused imports

* add a todo for unauthenticated rpc error

* upgrade tests, temporally comment out some of them

* fix the rpc tx queue

* update denies

* fix  links

* clippy

* fir more doc links

* fix queue tests

Co-authored-by: Arya <[email protected]>

* add suggestions from code review

* fix snapshots

* try `block_on` instead of `now_or_never` in the http middleware

* move import

* Apply suggestions from code review

Co-authored-by: Arya <[email protected]>

* fix bounds

---------

Co-authored-by: Arya <[email protected]>
  • Loading branch information
oxarbitrage and arya2 authored Dec 21, 2024
1 parent 1ecf655 commit 0fe47bb
Show file tree
Hide file tree
Showing 32 changed files with 2,238 additions and 2,743 deletions.
414 changes: 167 additions & 247 deletions Cargo.lock

Large diffs are not rendered by default.

15 changes: 2 additions & 13 deletions deny.toml
Original file line number Diff line number Diff line change
Expand Up @@ -78,19 +78,8 @@ skip-tree = [
{ name = "base64", version = "=0.21.7" },
{ name = "sync_wrapper", version = "0.1.2" },

# wait for jsonrpc-http-server to update hyper or for Zebra to replace jsonrpc (#8682)
{ name = "h2", version = "=0.3.26" },
{ name = "http", version = "=0.2.12" },
{ name = "http-body", version = "=0.4.6" },
{ name = "hyper", version = "=0.14.31" },
{ name = "hyper-rustls", version = "=0.24.2" },

{ name = "reqwest", version = "=0.11.27" },
{ name = "rustls", version = "=0.21.12" },
{ name = "rustls-pemfile", version = "=1.0.4" },
{ name = "rustls-webpki", version = "=0.101.7" },
{ name = "tokio-rustls", version = "=0.24.1" },
{ name = "webpki-roots", version = "=0.25.4" },
# wait for abscissa_core to update toml
{ name = "toml", version = "=0.5.11" },

# wait for structopt-derive to update heck
{ name = "heck", version = "=0.3.3" },
Expand Down
8 changes: 5 additions & 3 deletions zebra-rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,11 @@ chrono = { version = "0.4.39", default-features = false, features = [
] }
futures = "0.3.31"

jsonrpc-core = "18.0.0"
jsonrpc-derive = "18.0.0"
jsonrpc-http-server = "18.0.0"
jsonrpsee = { version = "0.24.7", features = ["server"] }
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"] }
Expand Down
24 changes: 6 additions & 18 deletions zebra-rpc/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,24 +50,12 @@ pub struct Config {

/// The number of threads used to process RPC requests and responses.
///
/// Zebra's RPC server has a separate thread pool and a `tokio` executor for each thread.
/// State queries are run concurrently using the shared thread pool controlled by
/// the [`SyncSection.parallel_cpu_threads`](https://docs.rs/zebrad/latest/zebrad/components/sync/struct.Config.html#structfield.parallel_cpu_threads) config.
///
/// If the number of threads is not configured or zero, Zebra uses the number of logical cores.
/// If the number of logical cores can't be detected, Zebra uses one thread.
///
/// Set to `1` to run all RPC queries on a single thread, and detect RPC port conflicts from
/// multiple Zebra or `zcashd` instances.
///
/// For details, see [the `jsonrpc_http_server` documentation](https://docs.rs/jsonrpc-http-server/latest/jsonrpc_http_server/struct.ServerBuilder.html#method.threads).
///
/// ## Warning
///
/// The default config uses multiple threads, which disables RPC port conflict detection.
/// This can allow multiple Zebra instances to share the same RPC port.
///
/// If some of those instances are outdated or failed, RPC queries can be slow or inconsistent.
/// This field is deprecated and could be removed in a future release.
/// We keep it just for backward compatibility but it actually do nothing.
/// It was something configurable when the RPC server was based in the jsonrpc-core crate,
/// not anymore since we migrated to jsonrpsee.
// TODO: Prefix this field name with an underscore so it's clear that it's now unused, and
// use serde(rename) to continue successfully deserializing old configs.
pub parallel_cpu_threads: usize,

/// Test-only option that makes Zebra say it is at the chain tip,
Expand Down
Loading

0 comments on commit 0fe47bb

Please sign in to comment.