diff --git a/Cargo.lock b/Cargo.lock index b2b5ca31f3e47..f7d859ba067b3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -507,7 +507,7 @@ dependencies = [ "beefy-gadget", "beefy-primitives", "futures", - "jsonrpsee 0.9.0", + "jsonrpsee", "log", "parity-scale-codec", "parking_lot 0.12.0", @@ -3156,51 +3156,18 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "jsonrpsee" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0d0b8cc1959f8c05256ace093b2317482da9127f1d9227564f47e7e6bf9bda8" -dependencies = [ - "jsonrpsee-core 0.9.0", - "jsonrpsee-http-server", - "jsonrpsee-proc-macros 0.9.0", - "jsonrpsee-types 0.9.0", - "jsonrpsee-ws-client 0.9.0", - "jsonrpsee-ws-server", -] - [[package]] name = "jsonrpsee" version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "91dc760c341fa81173f9a434931aaf32baad5552b0230cc6c93e8fb7eaad4c19" dependencies = [ - "jsonrpsee-core 0.10.1", - "jsonrpsee-proc-macros 0.10.1", - "jsonrpsee-types 0.10.1", - "jsonrpsee-ws-client 0.10.1", -] - -[[package]] -name = "jsonrpsee-client-transport" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa370c2c717d798c3c0a315ae3f0a707a388c6963c11f9da7dbbe1d3f7392f5f" -dependencies = [ - "futures", - "http", - "jsonrpsee-core 0.9.0", - "jsonrpsee-types 0.9.0", - "pin-project 1.0.10", - "rustls-native-certs 0.6.1", - "soketto 0.7.1", - "thiserror", - "tokio", - "tokio-rustls 0.23.2", - "tokio-util 0.6.7", - "tracing", - "webpki-roots 0.22.2", + "jsonrpsee-core", + "jsonrpsee-http-server", + "jsonrpsee-proc-macros", + "jsonrpsee-types", + "jsonrpsee-ws-client", + "jsonrpsee-ws-server", ] [[package]] @@ -3211,8 +3178,8 @@ checksum = "765f7a36d5087f74e3b3b47805c2188fef8eb54afcb587b078d9f8ebfe9c7220" dependencies = [ "futures", "http", - "jsonrpsee-core 0.10.1", - "jsonrpsee-types 0.10.1", + "jsonrpsee-core", + "jsonrpsee-types", "pin-project 1.0.10", "rustls-native-certs 0.6.1", "soketto 0.7.1", @@ -3224,32 +3191,6 @@ dependencies = [ "webpki-roots 0.22.2", ] -[[package]] -name = "jsonrpsee-core" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22abc3274b265dcefe2e26c4beecf9fda4fffa48cf94930443a6c73678f020d5" -dependencies = [ - "anyhow", - "arrayvec 0.7.1", - "async-channel", - "async-trait", - "beef", - "futures-channel", - "futures-util", - "hyper", - "jsonrpsee-types 0.9.0", - "parking_lot 0.12.0", - "rand 0.8.4", - "rustc-hash", - "serde", - "serde_json", - "soketto 0.7.1", - "thiserror", - "tokio", - "tracing", -] - [[package]] name = "jsonrpsee-core" version = "0.10.1" @@ -3263,7 +3204,9 @@ dependencies = [ "futures-channel", "futures-util", "hyper", - "jsonrpsee-types 0.10.1", + "jsonrpsee-types", + "parking_lot 0.12.0", + "rand 0.8.4", "rustc-hash", "serde", "serde_json", @@ -3275,36 +3218,23 @@ dependencies = [ [[package]] name = "jsonrpsee-http-server" -version = "0.9.0" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8dd99cccd549e3c3bb9dc6a490d7e5cf507f4d2b0177abd16f9c63b3ee1c2d67" +checksum = "d35477aab03691360d21a77dd475f384474bc138c2051aafa766fe4aed50ac50" dependencies = [ "futures-channel", "futures-util", "globset", "hyper", - "jsonrpsee-core 0.9.0", - "jsonrpsee-types 0.9.0", + "jsonrpsee-core", + "jsonrpsee-types", "lazy_static", "serde_json", - "socket2 0.4.4", "tokio", "tracing", "unicase", ] -[[package]] -name = "jsonrpsee-proc-macros" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "63e171d8071079c8ccdce1b4ab34411c5afa6158d57db7963311ad3c6d073cb1" -dependencies = [ - "proc-macro-crate", - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "jsonrpsee-proc-macros" version = "0.10.1" @@ -3317,20 +3247,6 @@ dependencies = [ "syn", ] -[[package]] -name = "jsonrpsee-types" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f4c45d2e2aa1db4c7d7d7dbaabc10a5b5258d99cd9d42fbfd5260b76f80c324" -dependencies = [ - "anyhow", - "beef", - "serde", - "serde_json", - "thiserror", - "tracing", -] - [[package]] name = "jsonrpsee-types" version = "0.10.1" @@ -3345,43 +3261,31 @@ dependencies = [ "tracing", ] -[[package]] -name = "jsonrpsee-ws-client" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31b58983485b2b626c276f1eb367d62dae82132451b281072a7bfa536a33ddf3" -dependencies = [ - "jsonrpsee-client-transport 0.9.0", - "jsonrpsee-core 0.9.0", - "jsonrpsee-types 0.9.0", -] - [[package]] name = "jsonrpsee-ws-client" version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd66d18bab78d956df24dd0d2e41e4c00afbb818fda94a98264bdd12ce8506ac" dependencies = [ - "jsonrpsee-client-transport 0.10.1", - "jsonrpsee-core 0.10.1", - "jsonrpsee-types 0.10.1", + "jsonrpsee-client-transport", + "jsonrpsee-core", + "jsonrpsee-types", ] [[package]] name = "jsonrpsee-ws-server" -version = "0.9.0" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84fbcab8488704be093f682540b0b80c623e1683a1d832d67b63bf52de9dceac" +checksum = "a382e22db11cd9a1f04f5a4cc5446f155a3cd20cd1778fc65f30a76aff524120" dependencies = [ - "async-channel", "futures-channel", "futures-util", - "jsonrpsee-core 0.9.0", - "jsonrpsee-types 0.9.0", + "jsonrpsee-core", + "jsonrpsee-types", "serde_json", "soketto 0.7.1", "tokio", - "tokio-util 0.6.7", + "tokio-util 0.7.1", "tracing", ] @@ -4575,7 +4479,7 @@ dependencies = [ "frame-system-rpc-runtime-api", "futures", "hex-literal", - "jsonrpsee 0.9.0", + "jsonrpsee", "log", "nix", "node-executor", @@ -4709,7 +4613,7 @@ dependencies = [ name = "node-rpc" version = "3.0.0-dev" dependencies = [ - "jsonrpsee 0.9.0", + "jsonrpsee", "node-primitives", "pallet-contracts-rpc", "pallet-mmr-rpc", @@ -4839,7 +4743,7 @@ dependencies = [ "clap 3.1.6", "frame-benchmarking", "frame-benchmarking-cli", - "jsonrpsee 0.9.0", + "jsonrpsee", "node-template-runtime", "pallet-transaction-payment-rpc", "sc-basic-authorship", @@ -5516,7 +5420,7 @@ name = "pallet-contracts-rpc" version = "4.0.0-dev" dependencies = [ "anyhow", - "jsonrpsee 0.9.0", + "jsonrpsee", "pallet-contracts-primitives", "pallet-contracts-rpc-runtime-api", "parity-scale-codec", @@ -5844,7 +5748,7 @@ dependencies = [ name = "pallet-mmr-rpc" version = "3.0.0" dependencies = [ - "jsonrpsee 0.9.0", + "jsonrpsee", "pallet-mmr-primitives", "parity-scale-codec", "serde", @@ -6284,7 +6188,7 @@ name = "pallet-transaction-payment-rpc" version = "4.0.0-dev" dependencies = [ "anyhow", - "jsonrpsee 0.9.0", + "jsonrpsee", "pallet-transaction-payment-rpc-runtime-api", "parity-scale-codec", "sp-api", @@ -7436,7 +7340,7 @@ version = "0.10.0-dev" dependencies = [ "env_logger 0.9.0", "frame-support", - "jsonrpsee 0.10.1", + "jsonrpsee", "log", "pallet-elections-phragmen", "parity-scale-codec", @@ -8019,7 +7923,7 @@ name = "sc-consensus-babe-rpc" version = "0.10.0-dev" dependencies = [ "futures", - "jsonrpsee 0.9.0", + "jsonrpsee", "sc-consensus", "sc-consensus-babe", "sc-consensus-epochs", @@ -8061,7 +7965,7 @@ dependencies = [ "assert_matches", "async-trait", "futures", - "jsonrpsee 0.9.0", + "jsonrpsee", "log", "parity-scale-codec", "sc-basic-authorship", @@ -8294,7 +8198,7 @@ version = "0.10.0-dev" dependencies = [ "finality-grandpa", "futures", - "jsonrpsee 0.9.0", + "jsonrpsee", "log", "parity-scale-codec", "sc-block-builder", @@ -8513,7 +8417,7 @@ dependencies = [ "env_logger 0.9.0", "futures", "hash-db", - "jsonrpsee 0.9.0", + "jsonrpsee", "lazy_static", "log", "parity-scale-codec", @@ -8549,7 +8453,7 @@ version = "0.10.0-dev" dependencies = [ "anyhow", "futures", - "jsonrpsee 0.9.0", + "jsonrpsee", "log", "parity-scale-codec", "parking_lot 0.12.0", @@ -8571,7 +8475,7 @@ name = "sc-rpc-server" version = "4.0.0-dev" dependencies = [ "anyhow", - "jsonrpsee 0.9.0", + "jsonrpsee", "log", "serde_json", "substrate-prometheus-endpoint", @@ -8603,7 +8507,7 @@ dependencies = [ "futures", "futures-timer", "hash-db", - "jsonrpsee 0.9.0", + "jsonrpsee", "log", "parity-scale-codec", "parity-util-mem", @@ -8711,7 +8615,7 @@ name = "sc-sync-state-rpc" version = "0.10.0-dev" dependencies = [ "anyhow", - "jsonrpsee 0.9.0", + "jsonrpsee", "parity-scale-codec", "sc-chain-spec", "sc-client-api", @@ -10262,7 +10166,7 @@ dependencies = [ "frame-support", "frame-system", "futures", - "jsonrpsee 0.9.0", + "jsonrpsee", "parity-scale-codec", "sc-rpc-api", "scale-info", @@ -10278,7 +10182,7 @@ dependencies = [ "assert_matches", "frame-system-rpc-runtime-api", "futures", - "jsonrpsee 0.9.0", + "jsonrpsee", "log", "parity-scale-codec", "sc-client-api", @@ -10313,7 +10217,7 @@ name = "substrate-state-trie-migration-rpc" version = "4.0.0-dev" dependencies = [ "anyhow", - "jsonrpsee 0.9.0", + "jsonrpsee", "log", "parity-scale-codec", "sc-client-api", @@ -10763,7 +10667,6 @@ checksum = "1caa0b0c8d94a049db56b5acf8cba99dc0623aab1b26d5b5f5e2d945846b3592" dependencies = [ "bytes 1.1.0", "futures-core", - "futures-io", "futures-sink", "log", "pin-project-lite 0.2.6", @@ -10994,7 +10897,7 @@ name = "try-runtime-cli" version = "0.10.0-dev" dependencies = [ "clap 3.1.6", - "jsonrpsee 0.10.1", + "jsonrpsee", "log", "parity-scale-codec", "remote-externalities", diff --git a/bin/node-template/node/Cargo.toml b/bin/node-template/node/Cargo.toml index b2750ec92bb64..432bda5663b22 100644 --- a/bin/node-template/node/Cargo.toml +++ b/bin/node-template/node/Cargo.toml @@ -38,7 +38,7 @@ sp-runtime = { version = "6.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.9", features = ["server"] } +jsonrpsee = { version = "0.10.1", 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" } diff --git a/bin/node/cli/Cargo.toml b/bin/node/cli/Cargo.toml index f4afaa7c6aca7..0e211762f367b 100644 --- a/bin/node/cli/Cargo.toml +++ b/bin/node/cli/Cargo.toml @@ -37,7 +37,7 @@ crate-type = ["cdylib", "rlib"] clap = { version = "3.1.6", features = ["derive"], optional = true } codec = { package = "parity-scale-codec", version = "3.0.0" } serde = { version = "1.0.136", features = ["derive"] } -jsonrpsee = { version = "0.9", features = ["server"] } +jsonrpsee = { version = "0.10.1", features = ["server"] } futures = "0.3.21" hex-literal = "0.3.4" log = "0.4.8" diff --git a/bin/node/cli/benches/block_production.rs b/bin/node/cli/benches/block_production.rs index 3d325c65e5442..de93ad3b05e93 100644 --- a/bin/node/cli/benches/block_production.rs +++ b/bin/node/cli/benches/block_production.rs @@ -92,6 +92,8 @@ fn new_node(tokio_handle: Handle) -> node_cli::service::NewFullBase { rpc_cors: None, rpc_methods: Default::default(), rpc_max_payload: None, + rpc_max_request_size: None, + rpc_max_response_size: None, rpc_id_provider: None, ws_max_out_buffer_capacity: None, prometheus_config: None, diff --git a/bin/node/cli/benches/transaction_pool.rs b/bin/node/cli/benches/transaction_pool.rs index bd8825b291556..88b8303a37d42 100644 --- a/bin/node/cli/benches/transaction_pool.rs +++ b/bin/node/cli/benches/transaction_pool.rs @@ -84,6 +84,8 @@ fn new_node(tokio_handle: Handle) -> node_cli::service::NewFullBase { rpc_cors: None, rpc_methods: Default::default(), rpc_max_payload: None, + rpc_max_request_size: None, + rpc_max_response_size: None, rpc_id_provider: None, ws_max_out_buffer_capacity: None, prometheus_config: None, diff --git a/bin/node/rpc/Cargo.toml b/bin/node/rpc/Cargo.toml index 414f1b83530ba..ad609f64bf55b 100644 --- a/bin/node/rpc/Cargo.toml +++ b/bin/node/rpc/Cargo.toml @@ -11,7 +11,7 @@ repository = "https://github.com/paritytech/substrate/" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -jsonrpsee = { version = "0.9", features = ["server"] } +jsonrpsee = { version = "0.10.1", 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/" } diff --git a/bin/node/rpc/src/lib.rs b/bin/node/rpc/src/lib.rs index f7ef02bbbb1de..05aa973e102b1 100644 --- a/bin/node/rpc/src/lib.rs +++ b/bin/node/rpc/src/lib.rs @@ -123,10 +123,9 @@ where use pallet_contracts_rpc::{ContractsApiServer, ContractsRpc}; use pallet_mmr_rpc::{MmrApiServer, MmrRpc}; use pallet_transaction_payment_rpc::{TransactionPaymentApiServer, TransactionPaymentRpc}; - // TODO: (dp) need porting - // use sc_rpc::dev::{Dev, DevApi}; use sc_consensus_babe_rpc::BabeApiServer; use sc_finality_grandpa_rpc::GrandpaApiServer; + use sc_rpc::dev::{Dev, DevApiServer}; use sc_sync_state_rpc::{SyncStateRpc, SyncStateRpcApiServer}; use substrate_frame_rpc_system::{SystemApiServer, SystemRpc}; use substrate_state_trie_migration_rpc::StateMigrationApiServer; @@ -178,11 +177,10 @@ where )?; io.merge( - substrate_state_trie_migration_rpc::MigrationRpc::new(client, backend, deny_unsafe) + substrate_state_trie_migration_rpc::MigrationRpc::new(client.clone(), backend, deny_unsafe) .into_rpc(), )?; - // TODO: (dp) Port to jsonrpsee - // io.extend_with(DevApi::to_delegate(Dev::new(client, deny_unsafe))); + io.merge(Dev::new(client, deny_unsafe).into_rpc())?; Ok(io) } diff --git a/client/beefy/rpc/Cargo.toml b/client/beefy/rpc/Cargo.toml index 3b420df0f88a5..11ed1276fe6b5 100644 --- a/client/beefy/rpc/Cargo.toml +++ b/client/beefy/rpc/Cargo.toml @@ -14,7 +14,7 @@ parking_lot = "0.12.0" thiserror = "1.0" serde = { version = "1.0.136", features = ["derive"] } -jsonrpsee = { version = "0.9", features = ["server", "macros"] } +jsonrpsee = { version = "0.10.1", features = ["server", "macros"] } codec = { version = "3.0.0", package = "parity-scale-codec", features = ["derive"] } diff --git a/client/beefy/rpc/src/lib.rs b/client/beefy/rpc/src/lib.rs index 74d4f45f72d2e..0c29f0e60952c 100644 --- a/client/beefy/rpc/src/lib.rs +++ b/client/beefy/rpc/src/lib.rs @@ -58,6 +58,7 @@ pub trait BeefyApi { /// Returns the block most recently finalized by BEEFY, alongside side its justification. #[subscription( name = "beefy_subscribeJustifications" => "beefy_justifications", + unsubscribe = "beefy_unsubscribeJustifications", item = Notification, )] fn subscribe_justifications(&self) -> RpcResult<()>; diff --git a/client/cli/src/commands/run_cmd.rs b/client/cli/src/commands/run_cmd.rs index b9318813b0480..cf23f49239e4b 100644 --- a/client/cli/src/commands/run_cmd.rs +++ b/client/cli/src/commands/run_cmd.rs @@ -100,18 +100,28 @@ pub struct RunCmd { #[clap(long)] pub unsafe_ws_external: bool, - /// Set the the maximum RPC payload size for both requests and responses (both http and ws), in - /// megabytes. Default is 15MiB. + /// DEPRECATED, this has no affect anymore. Use `rpc_max_request_size` or + /// `rpc_max_response_size` instead. #[clap(long)] pub rpc_max_payload: Option, + /// Set the the maximum RPC request payload size for both HTTP and WS in megabytes. + /// Default is 15MiB. + #[clap(long)] + pub rpc_max_request_size: Option, + + /// Set the the maximum RPC response payload size for both HTTP and WS in megabytes. + /// Default is 15MiB. + #[clap(long)] + pub rpc_max_response_size: Option, + /// Expose Prometheus exporter on all interfaces. /// /// Default is local. #[clap(long)] pub prometheus_external: bool, - /// Specify IPC RPC server path + /// DEPRECATED, IPC support has been removed. #[clap(long, value_name = "PATH")] pub ipc_path: Option, @@ -127,7 +137,7 @@ pub struct RunCmd { #[clap(long, value_name = "COUNT")] pub ws_max_connections: Option, - /// Set the the maximum WebSocket output buffer size in MiB. Default is 16. + /// DEPRECATED, this has no affect anymore. Use `rpc_max_response_size` instead. #[clap(long)] pub ws_max_out_buffer_capacity: Option, diff --git a/client/cli/src/config.rs b/client/cli/src/config.rs index 28b7186f1f495..8ab49dc010736 100644 --- a/client/cli/src/config.rs +++ b/client/cli/src/config.rs @@ -359,6 +359,16 @@ pub trait CliConfiguration: Sized { Ok(None) } + /// Get maximum RPC request payload size. + fn rpc_max_request_size(&self) -> Result> { + Ok(None) + } + + /// Get maximum RPC response payload size. + fn rpc_max_response_size(&self) -> Result> { + Ok(None) + } + /// Get maximum WS output buffer capacity. fn ws_max_out_buffer_capacity(&self) -> Result> { Ok(None) @@ -528,6 +538,8 @@ pub trait CliConfiguration: 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_max_request_size: self.rpc_max_request_size()?, + rpc_max_response_size: self.rpc_max_response_size()?, rpc_id_provider: None, ws_max_out_buffer_capacity: self.ws_max_out_buffer_capacity()?, prometheus_config: self diff --git a/client/consensus/babe/rpc/Cargo.toml b/client/consensus/babe/rpc/Cargo.toml index 8fd82bbb570ee..3ca0a682a87f3 100644 --- a/client/consensus/babe/rpc/Cargo.toml +++ b/client/consensus/babe/rpc/Cargo.toml @@ -13,7 +13,7 @@ readme = "README.md" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -jsonrpsee = { version = "0.9", features = ["server", "macros"] } +jsonrpsee = { version = "0.10.1", 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" } diff --git a/client/consensus/manual-seal/Cargo.toml b/client/consensus/manual-seal/Cargo.toml index 56b3d8b647cad..6e782144df336 100644 --- a/client/consensus/manual-seal/Cargo.toml +++ b/client/consensus/manual-seal/Cargo.toml @@ -14,7 +14,7 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] thiserror = "1.0" -jsonrpsee = { version = "0.9", features = ["server", "macros"] } +jsonrpsee = { version = "0.10.1", features = ["server", "macros"] } futures = "0.3.21" log = "0.4.8" codec = { package = "parity-scale-codec", version = "3.0.0" } diff --git a/client/finality-grandpa/rpc/Cargo.toml b/client/finality-grandpa/rpc/Cargo.toml index 63e80c2217806..f6fb53611da87 100644 --- a/client/finality-grandpa/rpc/Cargo.toml +++ b/client/finality-grandpa/rpc/Cargo.toml @@ -15,7 +15,7 @@ sp-blockchain = { version = "4.0.0-dev", path = "../../../primitives/blockchain" sp-core = { version = "6.0.0", path = "../../../primitives/core" } sp-runtime = { version = "6.0.0", path = "../../../primitives/runtime" } finality-grandpa = { version = "0.15.0", features = ["derive-codec"] } -jsonrpsee = { version = "0.9", features = ["server", "macros"] } +jsonrpsee = { version = "0.10.1", features = ["server", "macros"] } futures = "0.3.16" serde = { version = "1.0.105", features = ["derive"] } serde_json = "1.0.50" diff --git a/client/finality-grandpa/rpc/src/lib.rs b/client/finality-grandpa/rpc/src/lib.rs index 508b0a5dee60b..8735a40e288f1 100644 --- a/client/finality-grandpa/rpc/src/lib.rs +++ b/client/finality-grandpa/rpc/src/lib.rs @@ -54,6 +54,7 @@ pub trait GrandpaApi { /// side its justification. #[subscription( name = "grandpa_subscribeJustifications" => "grandpa_justifications", + unsubscribe = "grandpa_unsubscribeJustifications", item = Notification )] fn subscribe_justifications(&self) -> RpcResult<()>; diff --git a/client/rpc-api/Cargo.toml b/client/rpc-api/Cargo.toml index 2d6e07456e539..9ba343ac6ef34 100644 --- a/client/rpc-api/Cargo.toml +++ b/client/rpc-api/Cargo.toml @@ -30,4 +30,4 @@ serde_json = "1.0.79" sc-transaction-pool-api = { version = "4.0.0-dev", path = "../transaction-pool/api" } sp-rpc = { version = "6.0.0", path = "../../primitives/rpc" } sp-tracing = { version = "5.0.0", path = "../../primitives/tracing" } -jsonrpsee = { version = "0.9", features = ["server", "macros"] } +jsonrpsee = { version = "0.10.1", features = ["server", "macros"] } diff --git a/client/rpc-api/src/author/mod.rs b/client/rpc-api/src/author/mod.rs index bac554cf3a65d..7ff498aca388f 100644 --- a/client/rpc-api/src/author/mod.rs +++ b/client/rpc-api/src/author/mod.rs @@ -71,7 +71,7 @@ pub trait AuthorApi { /// transaction life cycle. #[subscription( name = "author_submitAndWatchExtrinsic" => "author_extrinsicUpdate", - unsubscribe_aliases = ["author_unwatchExtrinsic"], + unsubscribe = "author_unwatchExtrinsic", item = TransactionStatus, )] fn watch_extrinsic(&self, bytes: Bytes) -> RpcResult<()>; diff --git a/client/rpc-api/src/chain/mod.rs b/client/rpc-api/src/chain/mod.rs index 5cc44dec8b947..dbd6a6eadb1db 100644 --- a/client/rpc-api/src/chain/mod.rs +++ b/client/rpc-api/src/chain/mod.rs @@ -49,6 +49,7 @@ pub trait ChainApi { /// All head subscription. #[subscription( name = "chain_subscribeAllHeads" => "chain_allHead", + unsubscribe = "chain_unsubscribeAllHeads", item = Header )] fn subscribe_all_heads(&self) -> RpcResult<()>; @@ -57,7 +58,7 @@ pub trait ChainApi { #[subscription( name = "chain_subscribeNewHeads" => "chain_newHead", aliases = ["subscribe_newHead", "chain_subscribeNewHead"], - unsubscribe_aliases = ["chain_unsubscribeNewHead"], + unsubscribe = "chain_unsubscribeNewHead", item = Header )] fn subscribe_new_heads(&self) -> RpcResult<()>; @@ -66,7 +67,7 @@ pub trait ChainApi { #[subscription( name = "chain_subscribeFinalizedHeads" => "chain_finalizedHead", aliases = ["chain_subscribeFinalisedHeads"], - unsubscribe_aliases = ["chain_unsubscribeFinalisedHeads"], + unsubscribe = "chain_unsubscribeFinalisedHeads", item = Header )] fn subscribe_finalized_heads(&self) -> RpcResult<()>; diff --git a/client/rpc-api/src/state/mod.rs b/client/rpc-api/src/state/mod.rs index dd431ca8b31f1..87b268effa4cc 100644 --- a/client/rpc-api/src/state/mod.rs +++ b/client/rpc-api/src/state/mod.rs @@ -118,17 +118,19 @@ pub trait StateApi { /// New runtime version subscription #[subscription( name = "state_subscribeRuntimeVersion" => "state_runtimeVersion", + unsubscribe = "state_unsubscribeRuntimeVersion", aliases = ["chain_subscribeRuntimeVersion"], unsubscribe_aliases = ["chain_unsubscribeRuntimeVersion"], - item = RuntimeVersion, + item = RuntimeVersion, )] fn subscribe_runtime_version(&self) -> RpcResult<()>; /// New storage subscription #[subscription( - name = "state_subscribeStorage" => "state_storage", - item = StorageChangeSet, - )] + name = "state_subscribeStorage" => "state_storage", + unsubscribe = "state_unsubscribeStorage", + item = StorageChangeSet, + )] fn subscribe_storage(&self, keys: Option>) -> RpcResult<()>; /// The `traceBlock` RPC provides a way to trace the re-execution of a single diff --git a/client/rpc-servers/Cargo.toml b/client/rpc-servers/Cargo.toml index 15f9997db4056..888a0a411b31f 100644 --- a/client/rpc-servers/Cargo.toml +++ b/client/rpc-servers/Cargo.toml @@ -14,7 +14,7 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] anyhow = "1" -jsonrpsee = { version = "0.9", features = ["server"] } +jsonrpsee = { version = "0.10.1", features = ["server"] } log = "0.4.8" prometheus-endpoint = { package = "substrate-prometheus-endpoint", path = "../../utils/prometheus", version = "0.10.0-dev"} serde_json = "1.0.79" diff --git a/client/rpc-servers/src/lib.rs b/client/rpc-servers/src/lib.rs index c3205ef3b3e42..70e819d4ad5c9 100644 --- a/client/rpc-servers/src/lib.rs +++ b/client/rpc-servers/src/lib.rs @@ -52,14 +52,14 @@ pub type WsServer = WsServerHandle; pub fn start_http( addrs: &[SocketAddr], cors: Option<&Vec>, - max_payload_mb: Option, + max_payload_in_mb: Option, + max_payload_out_mb: Option, metrics: Option, rpc_api: RpcModule, rt: tokio::runtime::Handle, ) -> Result { - let max_request_body_size = max_payload_mb - .map(|mb| mb.saturating_mul(MEGABYTE)) - .unwrap_or(RPC_MAX_PAYLOAD_DEFAULT); + let max_payload_in = payload_size_or_default(max_payload_in_mb); + let max_payload_out = payload_size_or_default(max_payload_out_mb); let mut acl = AccessControlBuilder::new(); @@ -71,7 +71,8 @@ pub fn start_http( }; let builder = HttpServerBuilder::new() - .max_request_body_size(max_request_body_size as u32) + .max_request_body_size(max_payload_in as u32) + .max_response_body_size(max_payload_out as u32) .set_access_control(acl.build()) .custom_tokio_runtime(rt.clone()); @@ -79,10 +80,10 @@ pub fn start_http( let handle = if let Some(metrics) = metrics { let middleware = RpcMiddleware::new(metrics, "http".into()); let builder = builder.set_middleware(middleware); - let server = tokio::task::block_in_place(|| rt.block_on(async { builder.build(addrs) }))?; + let server = tokio::task::block_in_place(|| rt.block_on(builder.build(addrs)))?; server.start(rpc_api)? } else { - let server = tokio::task::block_in_place(|| rt.block_on(async { builder.build(addrs) }))?; + let server = tokio::task::block_in_place(|| rt.block_on(builder.build(addrs)))?; server.start(rpc_api)? }; @@ -95,19 +96,21 @@ pub fn start_ws( addrs: &[SocketAddr], max_connections: Option, cors: Option<&Vec>, - max_payload_mb: Option, + max_payload_in_mb: Option, + max_payload_out_mb: Option, metrics: Option, rpc_api: RpcModule, rt: tokio::runtime::Handle, id_provider: Option>, ) -> Result { - let max_request_body_size = max_payload_mb - .map(|mb| mb.saturating_mul(MEGABYTE)) - .unwrap_or(RPC_MAX_PAYLOAD_DEFAULT); + let max_payload_in = payload_size_or_default(max_payload_in_mb); + let max_payload_out = payload_size_or_default(max_payload_out_mb); + let max_connections = max_connections.unwrap_or(WS_MAX_CONNECTIONS); let mut builder = WsServerBuilder::new() - .max_request_body_size(max_request_body_size as u32) + .max_request_body_size(max_payload_in as u32) + .max_response_body_size(max_payload_out as u32) .max_connections(max_connections as u64) .custom_tokio_runtime(rt.clone()); @@ -163,3 +166,7 @@ fn build_rpc_api(mut rpc_api: RpcModule) -> RpcModu rpc_api } + +fn payload_size_or_default(size_mb: Option) -> usize { + size_mb.map_or(RPC_MAX_PAYLOAD_DEFAULT, |mb| mb.saturating_mul(MEGABYTE)) +} diff --git a/client/rpc/Cargo.toml b/client/rpc/Cargo.toml index 09a22a035a60e..5ead648d3aca4 100644 --- a/client/rpc/Cargo.toml +++ b/client/rpc/Cargo.toml @@ -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.12.0" lazy_static = { version = "1.4.0", optional = true } -jsonrpsee = { version = "0.9", features = ["server"] } +jsonrpsee = { version = "0.10.1", features = ["server"] } sc-transaction-pool-api = { version = "4.0.0-dev", path = "../transaction-pool/api" } tokio = { version = "1.15.0", optional = true } diff --git a/client/rpc/src/author/tests.rs b/client/rpc/src/author/tests.rs index 0edf4f24566eb..f016fb57be1fc 100644 --- a/client/rpc/src/author/tests.rs +++ b/client/rpc/src/author/tests.rs @@ -26,7 +26,7 @@ use jsonrpsee::{ error::{SubscriptionClosed, SubscriptionClosedReason}, Error as RpcError, }, - types::EmptyParams, + types::{error::CallError, EmptyParams}, RpcModule, }; use sc_transaction_pool::{BasicPool, FullChainApi}; @@ -107,7 +107,7 @@ async fn author_submit_transaction_should_not_cause_error() { assert_matches!( api.call::<_, H256>("author_submitExtrinsic", [xt]).await, - Err(RpcError::Request(e)) if e.contains("Already imported") + Err(RpcError::Call(CallError::Custom { message, ..})) if message.contains("Already imported") ); } @@ -287,7 +287,7 @@ async fn author_has_session_keys() { assert_matches!( api.call::<_, bool>("author_hasSessionKeys", vec![Bytes::from(vec![1, 2, 3])]).await, - Err(RpcError::Request(e)) if e.contains("Session keys are not encoded correctly") + Err(RpcError::Call(CallError::Custom { message, ..})) if message.as_str() == "Session keys are not encoded correctly" ); } diff --git a/client/rpc/src/dev/tests.rs b/client/rpc/src/dev/tests.rs index 6568863817e22..4dae4ca2b43e4 100644 --- a/client/rpc/src/dev/tests.rs +++ b/client/rpc/src/dev/tests.rs @@ -18,7 +18,7 @@ use super::*; use assert_matches::assert_matches; -use jsonrpsee::core::Error as JsonRpseeError; +use jsonrpsee::{core::Error as JsonRpseeError, types::error::CallError}; use sc_block_builder::BlockBuilderProvider; use sp_blockchain::HeaderBackend; use sp_consensus::BlockOrigin; @@ -64,6 +64,6 @@ async fn deny_unsafe_works() { assert_matches!( api.call::<_, Option>("dev_getBlockStats", [client.info().best_hash]) .await, - Err(JsonRpseeError::Request(e)) if e.to_string().contains("RPC call is unsafe to be called externally") + Err(JsonRpseeError::Call(CallError::Custom { message, .. })) if message.as_str() == "RPC call is unsafe to be called externally" ); } diff --git a/client/rpc/src/system/tests.rs b/client/rpc/src/system/tests.rs index db612d9a81868..3ccb85d1ac748 100644 --- a/client/rpc/src/system/tests.rs +++ b/client/rpc/src/system/tests.rs @@ -19,7 +19,11 @@ use super::{helpers::SyncState, *}; use assert_matches::assert_matches; use futures::prelude::*; -use jsonrpsee::{core::Error as RpcError, types::EmptyParams, RpcModule}; +use jsonrpsee::{ + core::Error as RpcError, + types::{error::CallError, EmptyParams}, + RpcModule, +}; use sc_network::{self, config::Role, PeerId}; use sc_rpc_api::system::helpers::PeerInfo; use sc_utils::mpsc::tracing_unbounded; @@ -311,7 +315,7 @@ async fn system_network_add_reserved() { let bad_peer_id = ["/ip4/198.51.100.19/tcp/30333"]; assert_matches!( api(None).call::<_, ()>("system_addReservedPeer", bad_peer_id).await, - Err(RpcError::Request(e)) if e.contains("Peer id is missing from the address") + Err(RpcError::Call(CallError::Custom { message, .. })) if message.as_str() == "Peer id is missing from the address" ); } @@ -327,7 +331,7 @@ async fn system_network_remove_reserved() { assert_matches!( api(None).call::<_, String>("system_removeReservedPeer", bad_peer_id).await, - Err(RpcError::Request(e)) if e.contains("base-58 decode error: provided string contained invalid character '/' at byte 0\"") + Err(RpcError::Call(CallError::Custom { message, .. })) if message.as_str() == "base-58 decode error: provided string contained invalid character '/' at byte 0" ); } #[tokio::test] diff --git a/client/service/Cargo.toml b/client/service/Cargo.toml index 7cc46c4171103..9f8f66b05de95 100644 --- a/client/service/Cargo.toml +++ b/client/service/Cargo.toml @@ -22,7 +22,7 @@ wasmtime = ["sc-executor/wasmtime"] test-helpers = [] [dependencies] -jsonrpsee = { version = "0.9", features = ["server"] } +jsonrpsee = { version = "0.10.1", features = ["server"] } thiserror = "1.0.30" futures = "0.3.21" rand = "0.7.3" diff --git a/client/service/src/config.rs b/client/service/src/config.rs index f8a66fa1f2587..586713cad0546 100644 --- a/client/service/src/config.rs +++ b/client/service/src/config.rs @@ -95,6 +95,10 @@ pub struct Configuration { pub rpc_methods: RpcMethods, /// Maximum payload of rpc request/responses. pub rpc_max_payload: Option, + /// Maximum payload of a rpc request + pub rpc_max_request_size: Option, + /// Maximum payload of a rpc request + pub rpc_max_response_size: Option, /// Custom JSON-RPC subscription ID provider. /// /// Default: [`crate::RandomStringSubscriptionId`]. diff --git a/client/service/src/lib.rs b/client/service/src/lib.rs index 9574d7c13d54b..6e98aae94b730 100644 --- a/client/service/src/lib.rs +++ b/client/service/src/lib.rs @@ -302,6 +302,9 @@ fn start_rpc_servers( where R: Fn(sc_rpc::DenyUnsafe) -> Result, Error>, { + let (max_request_size, ws_max_response_size, http_max_response_size) = + legacy_cli_parsing(config); + fn deny_unsafe(addr: SocketAddr, methods: &RpcMethods) -> sc_rpc::DenyUnsafe { let is_exposed_addr = !addr.ip().is_loopback(); match (is_exposed_addr, methods) { @@ -329,7 +332,8 @@ where let http = sc_rpc_server::start_http( &[http_addr, http_addr2], config.rpc_cors.as_ref(), - config.rpc_max_payload, + max_request_size, + http_max_response_size, metrics.clone(), gen_rpc_module(deny_unsafe(ws_addr, &config.rpc_methods))?, config.tokio_handle.clone(), @@ -340,7 +344,8 @@ where &[ws_addr, ws_addr2], config.rpc_ws_max_connections, config.rpc_cors.as_ref(), - config.rpc_max_payload, + max_request_size, + ws_max_response_size, metrics, gen_rpc_module(deny_unsafe(http_addr, &config.rpc_methods))?, config.tokio_handle.clone(), @@ -449,6 +454,44 @@ where } } +fn legacy_cli_parsing(config: &Configuration) -> (Option, Option, Option) { + let ws_max_response_size = config.ws_max_out_buffer_capacity.map(|max| { + eprintln!("DEPRECATED: `--ws_max_out_buffer_capacity` has been removed use `rpc-max-response-size or rpc-max-request-size` instead"); + eprintln!("Setting WS `rpc-max-response-size` to `max(ws_max_out_buffer_capacity, rpc_max_response_size)`"); + std::cmp::max(max, config.rpc_max_response_size.unwrap_or(0)) + }); + + let max_request_size = match (config.rpc_max_payload, config.rpc_max_request_size) { + (Some(legacy_max), max) => { + eprintln!("DEPRECATED: `--rpc_max_payload` has been removed use `rpc-max-response-size or rpc-max-request-size` instead"); + eprintln!( + "Setting `rpc-max-response-size` to `max(rpc_max_payload, rpc_max_request_size)`" + ); + Some(std::cmp::max(legacy_max, max.unwrap_or(0))) + }, + (None, Some(max)) => Some(max), + (None, None) => None, + }; + + let http_max_response_size = match (config.rpc_max_payload, config.rpc_max_request_size) { + (Some(legacy_max), max) => { + eprintln!("DEPRECATED: `--rpc_max_payload` has been removed use `rpc-max-response-size or rpc-max-request-size` instead"); + eprintln!( + "Setting HTTP `rpc-max-response-size` to `max(rpc_max_payload, rpc_max_response_size)`" + ); + Some(std::cmp::max(legacy_max, max.unwrap_or(0))) + }, + (None, Some(max)) => Some(max), + (None, None) => None, + }; + + if config.rpc_ipc.is_some() { + eprintln!("DEPRECATED: `--ipc-path` has no effect anymore IPC support has been removed"); + } + + (max_request_size, ws_max_response_size, http_max_response_size) +} + #[cfg(test)] mod tests { use super::*; diff --git a/client/service/test/src/lib.rs b/client/service/test/src/lib.rs index 066e9ede5e79e..6d44cabf7e1c1 100644 --- a/client/service/test/src/lib.rs +++ b/client/service/test/src/lib.rs @@ -246,6 +246,8 @@ fn node_config< rpc_cors: None, rpc_methods: Default::default(), rpc_max_payload: None, + rpc_max_request_size: None, + rpc_max_response_size: None, rpc_id_provider: None, ws_max_out_buffer_capacity: None, prometheus_config: None, diff --git a/client/sync-state-rpc/Cargo.toml b/client/sync-state-rpc/Cargo.toml index 3f727e5654608..3597a6035cbd6 100644 --- a/client/sync-state-rpc/Cargo.toml +++ b/client/sync-state-rpc/Cargo.toml @@ -15,7 +15,7 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] thiserror = "1.0.30" anyhow = "1" -jsonrpsee = { version = "0.9", features = ["server", "macros"] } +jsonrpsee = { version = "0.10.1", 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" } diff --git a/frame/contracts/rpc/Cargo.toml b/frame/contracts/rpc/Cargo.toml index 36f26b928e1e8..8b44de926daa6 100644 --- a/frame/contracts/rpc/Cargo.toml +++ b/frame/contracts/rpc/Cargo.toml @@ -15,7 +15,7 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] codec = { package = "parity-scale-codec", version = "3.0.0" } anyhow = "1" -jsonrpsee = { version = "0.9", features = ["server", "macros"] } +jsonrpsee = { version = "0.10.1", features = ["server", "macros"] } serde = { version = "1", features = ["derive"] } # Substrate Dependencies diff --git a/frame/merkle-mountain-range/rpc/Cargo.toml b/frame/merkle-mountain-range/rpc/Cargo.toml index 2bcd6a1e151df..10b237e86fb17 100644 --- a/frame/merkle-mountain-range/rpc/Cargo.toml +++ b/frame/merkle-mountain-range/rpc/Cargo.toml @@ -14,7 +14,7 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] codec = { package = "parity-scale-codec", version = "3.0.0" } -jsonrpsee = { version = "0.9", features = ["server", "macros"] } +jsonrpsee = { version = "0.10.1", features = ["server", "macros"] } serde = { version = "1.0.136", features = ["derive"] } serde_json = "1" sp-api = { version = "4.0.0-dev", path = "../../../primitives/api" } diff --git a/frame/transaction-payment/rpc/Cargo.toml b/frame/transaction-payment/rpc/Cargo.toml index 0f8c006b90fd4..fed53083e67bc 100644 --- a/frame/transaction-payment/rpc/Cargo.toml +++ b/frame/transaction-payment/rpc/Cargo.toml @@ -15,7 +15,7 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] anyhow = "1" codec = { package = "parity-scale-codec", version = "3.0.0" } -jsonrpsee = { version = "0.9", features = ["server", "macros"] } +jsonrpsee = { version = "0.10.1", features = ["server", "macros"] } sp-api = { version = "4.0.0-dev", path = "../../../primitives/api" } sp-blockchain = { version = "4.0.0-dev", path = "../../../primitives/blockchain" } diff --git a/utils/frame/rpc/state-trie-migration-rpc/Cargo.toml b/utils/frame/rpc/state-trie-migration-rpc/Cargo.toml index fc5aedbf9a119..c7d9234cd479d 100644 --- a/utils/frame/rpc/state-trie-migration-rpc/Cargo.toml +++ b/utils/frame/rpc/state-trie-migration-rpc/Cargo.toml @@ -26,7 +26,7 @@ sp-state-machine = { path = "../../../../primitives/state-machine" } sp-trie = { path = "../../../../primitives/trie" } trie-db = { version = "0.23.1" } -jsonrpsee = { version = "0.9", features = ["server", "macros"] } +jsonrpsee = { version = "0.10.1", features = ["server", "macros"] } # Substrate Dependencies sc-client-api = { version = "4.0.0-dev", path = "../../../../client/api" } diff --git a/utils/frame/rpc/support/Cargo.toml b/utils/frame/rpc/support/Cargo.toml index bdfe9bc0eabf7..22f53da940782 100644 --- a/utils/frame/rpc/support/Cargo.toml +++ b/utils/frame/rpc/support/Cargo.toml @@ -15,7 +15,7 @@ description = "Substrate RPC for FRAME's support" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -jsonrpsee = { version = "0.9", features = ["jsonrpsee-types"] } +jsonrpsee = { version = "0.10.1", features = ["jsonrpsee-types"] } futures = "0.3.21" codec = { package = "parity-scale-codec", version = "3.0.0" } serde = "1" @@ -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 = "2.0.1" -jsonrpsee = { version = "0.9", features = ["ws-client", "jsonrpsee-types"] } +jsonrpsee = { version = "0.10.1", features = ["ws-client", "jsonrpsee-types"] } tokio = "1.17.0" diff --git a/utils/frame/rpc/system/Cargo.toml b/utils/frame/rpc/system/Cargo.toml index e353b07075f96..28773a5d23687 100644 --- a/utils/frame/rpc/system/Cargo.toml +++ b/utils/frame/rpc/system/Cargo.toml @@ -16,7 +16,7 @@ targets = ["x86_64-unknown-linux-gnu"] serde_json = "1" sc-client-api = { version = "4.0.0-dev", path = "../../../../client/api" } codec = { package = "parity-scale-codec", version = "3.0.0" } -jsonrpsee = { version = "0.9", features = ["server"] } +jsonrpsee = { version = "0.10.1", features = ["server"] } futures = "0.3.21" log = "0.4.8" sp-runtime = { version = "6.0.0", path = "../../../../primitives/runtime" }