Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all 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
198 changes: 132 additions & 66 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bin/node-template/node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ sp-runtime = { version = "5.0.0", path = "../../../primitives/runtime" }
sp-timestamp = { version = "4.0.0-dev", path = "../../../primitives/timestamp" }

# These dependencies are used for the node template's RPCs
jsonrpsee = { version = "0.8.0", features = ["server"] }
jsonrpsee = { version = "0.9", features = ["server"] }
sc-rpc = { version = "4.0.0-dev", path = "../../../client/rpc" }
sp-api = { version = "4.0.0-dev", path = "../../../primitives/api" }
sc-rpc-api = { version = "0.10.0-dev", path = "../../../client/rpc-api" }
Expand Down
2 changes: 1 addition & 1 deletion bin/node/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ clap = { version = "3.0", features = ["derive"], optional = true }
codec = { package = "parity-scale-codec", version = "2.0.0" }
serde = { version = "1.0.132", features = ["derive"] }
futures = "0.3.16"
jsonrpsee = { version = "0.8.0", features = ["server"] }
jsonrpsee = { version = "0.9", features = ["server"] }
hex-literal = "0.3.4"
log = "0.4.8"
rand = "0.8"
Expand Down
1 change: 1 addition & 0 deletions bin/node/cli/benches/block_production.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ fn new_node(tokio_handle: Handle) -> node_cli::service::NewFullBase {
rpc_cors: None,
rpc_methods: Default::default(),
rpc_max_payload: None,
rpc_id_provider: None,
ws_max_out_buffer_capacity: None,
prometheus_config: None,
telemetry_endpoints: None,
Expand Down
1 change: 1 addition & 0 deletions bin/node/cli/benches/transaction_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ fn new_node(tokio_handle: Handle) -> node_cli::service::NewFullBase {
rpc_cors: None,
rpc_methods: Default::default(),
rpc_max_payload: None,
rpc_id_provider: None,
ws_max_out_buffer_capacity: None,
prometheus_config: None,
telemetry_endpoints: None,
Expand Down
2 changes: 1 addition & 1 deletion bin/node/rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ repository = "https://github.com/paritytech/substrate/"
targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
jsonrpsee = { version = "0.8.0", features = ["server"] }
jsonrpsee = { version = "0.9", features = ["server"] }
node-primitives = { version = "2.0.0", path = "../primitives" }
pallet-contracts-rpc = { version = "4.0.0-dev", path = "../../../frame/contracts/rpc/" }
pallet-mmr-rpc = { version = "3.0.0", path = "../../../frame/merkle-mountain-range/rpc/" }
Expand Down
2 changes: 1 addition & 1 deletion client/beefy/rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ parking_lot = "0.11"
thiserror = "1.0"
serde = { version = "1.0.132", features = ["derive"] }

jsonrpsee = { version = "0.8.0", features = ["server", "macros"] }
jsonrpsee = { version = "0.9", features = ["server", "macros"] }

codec = { version = "2.2.0", package = "parity-scale-codec", features = ["derive"] }

Expand Down
1 change: 1 addition & 0 deletions client/cli/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,7 @@ pub trait CliConfiguration<DCV: DefaultConfigurationValues = ()>: Sized {
rpc_ws_max_connections: self.rpc_ws_max_connections()?,
rpc_cors: self.rpc_cors(is_dev)?,
rpc_max_payload: self.rpc_max_payload()?,
rpc_id_provider: None,
ws_max_out_buffer_capacity: self.ws_max_out_buffer_capacity()?,
prometheus_config: self
.prometheus_config(DCV::prometheus_listen_port(), &chain_spec)?,
Expand Down
2 changes: 1 addition & 1 deletion client/consensus/babe/rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ readme = "README.md"
targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
jsonrpsee = { version = "0.8.0", features = ["server", "macros"] }
jsonrpsee = { version = "0.9", features = ["server", "macros"] }
sc-consensus-babe = { version = "0.10.0-dev", path = "../" }
sc-rpc-api = { version = "0.10.0-dev", path = "../../../rpc-api" }
sp-consensus-babe = { version = "0.10.0-dev", path = "../../../../primitives/consensus/babe" }
Expand Down
2 changes: 1 addition & 1 deletion client/consensus/manual-seal/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ targets = ["x86_64-unknown-linux-gnu"]
thiserror = "1.0"
futures = "0.3.9"

jsonrpsee = { version = "0.8.0", features = ["server", "macros"] }
jsonrpsee = { version = "0.9", features = ["server", "macros"] }
log = "0.4"
codec = { package = "parity-scale-codec", version = "2.0.0" }
serde = { version = "1.0", features = ["derive"] }
Expand Down
2 changes: 1 addition & 1 deletion client/finality-grandpa/rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ sp-blockchain = { version = "4.0.0-dev", path = "../../../primitives/blockchain"
sp-core = { version = "5.0.0", path = "../../../primitives/core" }
sp-runtime = { version = "5.0.0", path = "../../../primitives/runtime" }
finality-grandpa = { version = "0.14.4", features = ["derive-codec"] }
jsonrpsee = { version = "0.8.0", features = ["server", "macros"] }
jsonrpsee = { version = "0.9", features = ["server", "macros"] }
futures = "0.3.4"
serde = { version = "1.0.105", features = ["derive"] }
serde_json = "1.0.50"
Expand Down
2 changes: 1 addition & 1 deletion client/rpc-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ serde_json = "1.0.74"
sc-transaction-pool-api = { version = "4.0.0-dev", path = "../transaction-pool/api" }
sp-rpc = { version = "5.0.0", path = "../../primitives/rpc" }
sp-tracing = { version = "4.0.0", path = "../../primitives/tracing" }
jsonrpsee = { version = "0.8.0", features = ["server", "macros"] }
jsonrpsee = { version = "0.9", features = ["server", "macros"] }
2 changes: 1 addition & 1 deletion client/rpc-servers/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
anyhow = "1"
jsonrpsee = { version = "0.8.0", features = ["server"] }
jsonrpsee = { version = "0.9", features = ["server"] }
log = "0.4.8"
prometheus-endpoint = { package = "substrate-prometheus-endpoint", path = "../../utils/prometheus", version = "0.10.0-dev"}
serde_json = "1.0.74"
Expand Down
14 changes: 12 additions & 2 deletions client/rpc-servers/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,16 @@

use jsonrpsee::{
http_server::{AccessControlBuilder, HttpServerBuilder, HttpServerHandle},
ws_server::{RandomStringIdProvider, WsServerBuilder, WsServerHandle},
ws_server::{WsServerBuilder, WsServerHandle},
RpcModule,
};
use std::net::SocketAddr;

pub use crate::middleware::{RpcMetrics, RpcMiddleware};
pub use jsonrpsee::core::{
id_providers::{RandomIntegerIdProvider, RandomStringIdProvider},
traits::IdProvider,
};

const MEGABYTE: usize = 1024 * 1024;

Expand Down Expand Up @@ -95,6 +99,7 @@ pub fn start_ws<M: Send + Sync + 'static>(
metrics: Option<RpcMetrics>,
rpc_api: RpcModule<M>,
rt: tokio::runtime::Handle,
id_provider: Option<Box<dyn IdProvider>>,
) -> Result<WsServerHandle, anyhow::Error> {
let max_request_body_size = max_payload_mb
.map(|mb| mb.saturating_mul(MEGABYTE))
Expand All @@ -104,9 +109,14 @@ pub fn start_ws<M: Send + Sync + 'static>(
let mut builder = WsServerBuilder::new()
.max_request_body_size(max_request_body_size as u32)
.max_connections(max_connections as u64)
.set_id_provider(RandomStringIdProvider::new(16))
.custom_tokio_runtime(rt.clone());

if let Some(provider) = id_provider {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did this to avoid to have to Box<RandomStringIdProvider>, a little awkward but...

builder = builder.set_id_provider(provider);
} else {
builder = builder.set_id_provider(RandomStringIdProvider::new(16));
};

if let Some(cors) = cors {
// Whitelist listening address.
// NOTE: set_allowed_hosts will whitelist both ports but only one will used.
Expand Down
2 changes: 1 addition & 1 deletion client/rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ sc-tracing = { version = "4.0.0-dev", path = "../tracing" }
hash-db = { version = "0.15.2", default-features = false }
parking_lot = "0.11.2"
lazy_static = { version = "1.4.0", optional = true }
jsonrpsee = { version = "0.8.0", features = ["server"] }
jsonrpsee = { version = "0.9", features = ["server"] }
sc-transaction-pool-api = { version = "4.0.0-dev", path = "../transaction-pool/api" }
tokio = { version = "1.15.0", optional = true }

Expand Down
7 changes: 7 additions & 0 deletions client/rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ use futures::{
use sp_core::{testing::TaskExecutor, traits::SpawnNamed};
use std::sync::Arc;

pub use jsonrpsee::core::{
id_providers::{
RandomIntegerIdProvider as RandomIntegerSubscriptionId,
RandomStringIdProvider as RandomStringSubscriptionId,
},
traits::IdProvider as RpcSubscriptionIdProvider,
};
pub use sc_rpc_api::DenyUnsafe;

pub mod author;
Expand Down
2 changes: 1 addition & 1 deletion client/service/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ wasmtime = ["sc-executor/wasmtime"]
test-helpers = []

[dependencies]
jsonrpsee = { version = "0.8.0", features = ["server"] }
jsonrpsee = { version = "0.9", features = ["server"] }
thiserror = "1.0.30"
futures = "0.3.16"
rand = "0.7.3"
Expand Down
4 changes: 3 additions & 1 deletion client/service/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,8 @@ where
metrics_service.run(client.clone(), transaction_pool.clone(), network.clone()),
);

let rpc_id_provider = config.rpc_id_provider.take();

// jsonrpsee RPC
let gen_rpc_module = |deny_unsafe: DenyUnsafe| {
gen_rpc_module(
Expand All @@ -491,7 +493,7 @@ where
)
};

let rpc = start_rpc_servers(&config, gen_rpc_module)?;
let rpc = start_rpc_servers(&config, gen_rpc_module, rpc_id_provider)?;
let rpc_handlers = RpcHandlers(Arc::new(gen_rpc_module(sc_rpc::DenyUnsafe::No)?.into()));

// Spawn informant task
Expand Down
4 changes: 4 additions & 0 deletions client/service/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ pub struct Configuration {
pub rpc_methods: RpcMethods,
/// Maximum payload of rpc request/responses.
pub rpc_max_payload: Option<usize>,
/// Custom JSON-RPC subscription ID provider.
///
/// Default: [`crate::RandomStringSubscriptionId`].
pub rpc_id_provider: Option<Box<dyn crate::RpcSubscriptionIdProvider>>,
/// Maximum size of the output buffer capacity for websocket connections.
pub ws_max_out_buffer_capacity: Option<usize>,
/// Prometheus endpoint configuration. `None` if disabled.
Expand Down
5 changes: 5 additions & 0 deletions client/service/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ pub use sc_consensus::ImportQueue;
pub use sc_executor::NativeExecutionDispatch;
#[doc(hidden)]
pub use sc_network::config::{TransactionImport, TransactionImportFuture};
pub use sc_rpc::{
RandomIntegerSubscriptionId, RandomStringSubscriptionId, RpcSubscriptionIdProvider,
};
pub use sc_tracing::TracingReceiver;
pub use sc_transaction_pool::Options as TransactionPoolOptions;
pub use sc_transaction_pool_api::{error::IntoPoolError, InPoolTransaction, TransactionPool};
Expand Down Expand Up @@ -295,6 +298,7 @@ mod waiting {
fn start_rpc_servers<R>(
config: &Configuration,
gen_rpc_module: R,
rpc_id_provider: Option<Box<dyn RpcSubscriptionIdProvider>>,
) -> Result<Box<dyn std::any::Any + Send + Sync>, error::Error>
where
R: Fn(sc_rpc::DenyUnsafe) -> Result<RpcModule<()>, Error>,
Expand Down Expand Up @@ -341,6 +345,7 @@ where
metrics,
gen_rpc_module(deny_unsafe(http_addr, &config.rpc_methods))?,
config.tokio_handle.clone(),
rpc_id_provider,
)
.map_err(|e| Error::Application(e.into()))?;

Expand Down
1 change: 1 addition & 0 deletions client/service/test/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ fn node_config<
rpc_cors: None,
rpc_methods: Default::default(),
rpc_max_payload: None,
rpc_id_provider: None,
ws_max_out_buffer_capacity: None,
prometheus_config: None,
telemetry_endpoints: None,
Expand Down
2 changes: 1 addition & 1 deletion client/sync-state-rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ targets = ["x86_64-unknown-linux-gnu"]
[dependencies]
thiserror = "1.0.30"
anyhow = "1"
jsonrpsee = { version = "0.8.0", features = ["server", "macros"] }
jsonrpsee = { version = "0.9", features = ["server", "macros"] }
sc-chain-spec = { version = "4.0.0-dev", path = "../chain-spec" }
sc-client-api = { version = "4.0.0-dev", path = "../api" }
sc-consensus-babe = { version = "0.10.0-dev", path = "../consensus/babe" }
Expand Down
2 changes: 1 addition & 1 deletion frame/contracts/rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ targets = ["x86_64-unknown-linux-gnu"]
[dependencies]
codec = { package = "parity-scale-codec", version = "2" }
anyhow = "1"
jsonrpsee = { version = "0.8.0", features = ["server", "macros"] }
jsonrpsee = { version = "0.9", features = ["server", "macros"] }
serde = { version = "1", features = ["derive"] }

# Substrate Dependencies
Expand Down
2 changes: 1 addition & 1 deletion frame/merkle-mountain-range/rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
codec = { package = "parity-scale-codec", version = "2.0.0" }
jsonrpsee = { version = "0.8.0", features = ["server", "macros"] }
jsonrpsee = { version = "0.9", features = ["server", "macros"] }
serde_json = "1.0.74"
serde = { version = "1.0.132", features = ["derive"] }

Expand Down
2 changes: 1 addition & 1 deletion frame/transaction-payment/rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ targets = ["x86_64-unknown-linux-gnu"]
anyhow = "1"
codec = { package = "parity-scale-codec", version = "2.0.0" }

jsonrpsee = { version = "0.8.0", features = ["server", "macros"] }
jsonrpsee = { version = "0.9", features = ["server", "macros"] }

sp-api = { version = "4.0.0-dev", path = "../../../primitives/api" }
sp-blockchain = { version = "4.0.0-dev", path = "../../../primitives/blockchain" }
Expand Down
2 changes: 1 addition & 1 deletion utils/frame/remote-externalities/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ readme = "README.md"
targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
jsonrpsee = { version = "0.8", features = ["ws-client", "macros"] }
jsonrpsee = { version = "0.9", features = ["ws-client", "macros"] }

env_logger = "0.9"
frame-support = { path = "../../../frame/support", optional = true, version = "4.0.0-dev" }
Expand Down
4 changes: 2 additions & 2 deletions utils/frame/rpc/support/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
futures = "0.3.16"
jsonrpsee = { version = "0.8.0", features = ["jsonrpsee-types"] }
jsonrpsee = { version = "0.9", features = ["jsonrpsee-types"] }
codec = { package = "parity-scale-codec", version = "2.0.0" }
serde = "1"
frame-support = { version = "4.0.0-dev", path = "../../../../frame/support" }
Expand All @@ -26,5 +26,5 @@ sc-rpc-api = { version = "0.10.0-dev", path = "../../../../client/rpc-api" }
[dev-dependencies]
frame-system = { version = "4.0.0-dev", path = "../../../../frame/system" }
scale-info = "1.0"
jsonrpsee = { version = "0.8.0", features = ["ws-client", "jsonrpsee-types"] }
jsonrpsee = { version = "0.9", features = ["ws-client", "jsonrpsee-types"] }
tokio = { version = "1.15.0", features = ["macros"] }
2 changes: 1 addition & 1 deletion utils/frame/rpc/system/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ serde_json = "1"
sc-client-api = { version = "4.0.0-dev", path = "../../../../client/api" }
codec = { package = "parity-scale-codec", version = "2.0.0" }
futures = "0.3.16"
jsonrpsee = { version = "0.8.0", features = ["server"] }
jsonrpsee = { version = "0.9", features = ["server"] }
log = "0.4.8"
sp-runtime = { version = "5.0.0", path = "../../../../primitives/runtime" }
sp-api = { version = "4.0.0-dev", path = "../../../../primitives/api" }
Expand Down
2 changes: 1 addition & 1 deletion utils/frame/try-runtime/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ sp-externalities = { version = "0.11.0", path = "../../../../primitives/external
sp-version = { version = "4.0.0-dev", path = "../../../../primitives/version" }

remote-externalities = { version = "0.10.0-dev", path = "../../remote-externalities" }
jsonrpsee = { version = "0.8.0", default-features = false, features = ["ws-client"] }
jsonrpsee = { version = "0.9", default-features = false, features = ["ws-client"] }