From 426cdce1fe8c95f5d14f1da9caae5b864064997b Mon Sep 17 00:00:00 2001 From: Niklas Adolfsson Date: Wed, 15 Sep 2021 12:18:53 +0200 Subject: [PATCH 1/6] add access control in the jsonrpsee servers --- Cargo.lock | 38 ++++++++++-------- bin/node-template/node/Cargo.toml | 2 +- bin/node/cli/Cargo.toml | 2 +- bin/node/rpc-client/Cargo.toml | 2 +- client/consensus/babe/rpc/Cargo.toml | 2 +- client/consensus/manual-seal/Cargo.toml | 2 +- client/finality-grandpa/rpc/Cargo.toml | 2 +- client/rpc-api/Cargo.toml | 2 +- client/rpc-api/src/lib.rs | 1 + client/rpc-servers/Cargo.toml | 2 +- client/rpc-servers/src/lib.rs | 43 +++++++++++++++------ client/rpc/Cargo.toml | 2 +- client/service/Cargo.toml | 2 +- client/service/src/builder.rs | 5 +-- client/sync-state-rpc/Cargo.toml | 3 +- frame/contracts/rpc/Cargo.toml | 3 +- frame/merkle-mountain-range/rpc/Cargo.toml | 3 +- frame/transaction-payment/rpc/Cargo.toml | 4 +- frame/transaction-payment/rpc/src/lib.rs | 11 ++++-- test-utils/test-runner/Cargo.toml | 2 +- utils/frame/remote-externalities/Cargo.toml | 6 +-- utils/frame/rpc/support/Cargo.toml | 2 +- utils/frame/rpc/system/Cargo.toml | 2 +- 23 files changed, 89 insertions(+), 54 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ba2946d462368..0647cc55f08c8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2781,28 +2781,28 @@ dependencies = [ [[package]] name = "jsonrpsee" version = "0.3.0" -source = "git+https://github.com/paritytech/jsonrpsee?branch=master#932304c4c8aa8b06e9ba18c6b3b95b6fa83cd94c" +source = "git+https://github.com/paritytech/jsonrpsee?branch=na-http-server-export-acl#8d66bd115afd927294d346cc8d10804643769917" dependencies = [ "jsonrpsee-http-client", "jsonrpsee-http-server", - "jsonrpsee-proc-macros 0.3.0 (git+https://github.com/paritytech/jsonrpsee?branch=master)", - "jsonrpsee-types 0.3.0 (git+https://github.com/paritytech/jsonrpsee?branch=master)", + "jsonrpsee-proc-macros 0.3.0 (git+https://github.com/paritytech/jsonrpsee?branch=na-http-server-export-acl)", + "jsonrpsee-types 0.3.0 (git+https://github.com/paritytech/jsonrpsee?branch=na-http-server-export-acl)", "jsonrpsee-utils", - "jsonrpsee-ws-client 0.3.0 (git+https://github.com/paritytech/jsonrpsee?branch=master)", + "jsonrpsee-ws-client 0.3.0 (git+https://github.com/paritytech/jsonrpsee?branch=na-http-server-export-acl)", "jsonrpsee-ws-server", ] [[package]] name = "jsonrpsee-http-client" version = "0.3.0" -source = "git+https://github.com/paritytech/jsonrpsee?branch=master#932304c4c8aa8b06e9ba18c6b3b95b6fa83cd94c" +source = "git+https://github.com/paritytech/jsonrpsee?branch=na-http-server-export-acl#8d66bd115afd927294d346cc8d10804643769917" dependencies = [ "async-trait", "fnv", "futures 0.3.16", "hyper", "hyper-rustls", - "jsonrpsee-types 0.3.0 (git+https://github.com/paritytech/jsonrpsee?branch=master)", + "jsonrpsee-types 0.3.0 (git+https://github.com/paritytech/jsonrpsee?branch=na-http-server-export-acl)", "jsonrpsee-utils", "log", "serde", @@ -2815,13 +2815,13 @@ dependencies = [ [[package]] name = "jsonrpsee-http-server" version = "0.3.0" -source = "git+https://github.com/paritytech/jsonrpsee?branch=master#932304c4c8aa8b06e9ba18c6b3b95b6fa83cd94c" +source = "git+https://github.com/paritytech/jsonrpsee?branch=na-http-server-export-acl#8d66bd115afd927294d346cc8d10804643769917" dependencies = [ "futures-channel", "futures-util", "globset", "hyper", - "jsonrpsee-types 0.3.0 (git+https://github.com/paritytech/jsonrpsee?branch=master)", + "jsonrpsee-types 0.3.0 (git+https://github.com/paritytech/jsonrpsee?branch=na-http-server-export-acl)", "jsonrpsee-utils", "lazy_static", "log", @@ -2850,10 +2850,11 @@ dependencies = [ [[package]] name = "jsonrpsee-proc-macros" version = "0.3.0" -source = "git+https://github.com/paritytech/jsonrpsee?branch=master#932304c4c8aa8b06e9ba18c6b3b95b6fa83cd94c" +source = "git+https://github.com/paritytech/jsonrpsee?branch=na-http-server-export-acl#8d66bd115afd927294d346cc8d10804643769917" dependencies = [ "Inflector", "bae", + "log", "proc-macro-crate", "proc-macro2", "quote", @@ -2881,7 +2882,7 @@ dependencies = [ [[package]] name = "jsonrpsee-types" version = "0.3.0" -source = "git+https://github.com/paritytech/jsonrpsee?branch=master#932304c4c8aa8b06e9ba18c6b3b95b6fa83cd94c" +source = "git+https://github.com/paritytech/jsonrpsee?branch=na-http-server-export-acl#8d66bd115afd927294d346cc8d10804643769917" dependencies = [ "anyhow", "async-trait", @@ -2899,13 +2900,13 @@ dependencies = [ [[package]] name = "jsonrpsee-utils" version = "0.3.0" -source = "git+https://github.com/paritytech/jsonrpsee?branch=master#932304c4c8aa8b06e9ba18c6b3b95b6fa83cd94c" +source = "git+https://github.com/paritytech/jsonrpsee?branch=na-http-server-export-acl#8d66bd115afd927294d346cc8d10804643769917" dependencies = [ "beef", "futures-channel", "futures-util", "hyper", - "jsonrpsee-types 0.3.0 (git+https://github.com/paritytech/jsonrpsee?branch=master)", + "jsonrpsee-types 0.3.0 (git+https://github.com/paritytech/jsonrpsee?branch=na-http-server-export-acl)", "log", "parking_lot 0.11.1", "rand 0.8.4", @@ -2942,12 +2943,12 @@ dependencies = [ [[package]] name = "jsonrpsee-ws-client" version = "0.3.0" -source = "git+https://github.com/paritytech/jsonrpsee?branch=master#932304c4c8aa8b06e9ba18c6b3b95b6fa83cd94c" +source = "git+https://github.com/paritytech/jsonrpsee?branch=na-http-server-export-acl#8d66bd115afd927294d346cc8d10804643769917" dependencies = [ "async-trait", "fnv", "futures 0.3.16", - "jsonrpsee-types 0.3.0 (git+https://github.com/paritytech/jsonrpsee?branch=master)", + "jsonrpsee-types 0.3.0 (git+https://github.com/paritytech/jsonrpsee?branch=na-http-server-export-acl)", "log", "pin-project 1.0.5", "rustls", @@ -2965,11 +2966,11 @@ dependencies = [ [[package]] name = "jsonrpsee-ws-server" version = "0.3.0" -source = "git+https://github.com/paritytech/jsonrpsee?branch=master#932304c4c8aa8b06e9ba18c6b3b95b6fa83cd94c" +source = "git+https://github.com/paritytech/jsonrpsee?branch=na-http-server-export-acl#8d66bd115afd927294d346cc8d10804643769917" dependencies = [ "futures-channel", "futures-util", - "jsonrpsee-types 0.3.0 (git+https://github.com/paritytech/jsonrpsee?branch=master)", + "jsonrpsee-types 0.3.0 (git+https://github.com/paritytech/jsonrpsee?branch=na-http-server-export-acl)", "jsonrpsee-utils", "log", "rustc-hash", @@ -4850,6 +4851,7 @@ name = "pallet-contracts-rpc" version = "4.0.0-dev" dependencies = [ "jsonrpsee", + "log", "pallet-contracts-primitives", "pallet-contracts-rpc-runtime-api", "parity-scale-codec", @@ -5159,6 +5161,7 @@ name = "pallet-mmr-rpc" version = "3.0.0" dependencies = [ "jsonrpsee", + "log", "pallet-mmr-primitives", "parity-scale-codec", "serde", @@ -5513,7 +5516,9 @@ dependencies = [ name = "pallet-transaction-payment-rpc" version = "4.0.0-dev" dependencies = [ + "anyhow", "jsonrpsee", + "log", "pallet-transaction-payment-rpc-runtime-api", "parity-scale-codec", "sp-api", @@ -7734,6 +7739,7 @@ version = "0.10.0-dev" dependencies = [ "anyhow", "jsonrpsee", + "log", "parity-scale-codec", "sc-chain-spec", "sc-client-api", diff --git a/bin/node-template/node/Cargo.toml b/bin/node-template/node/Cargo.toml index 796c20c9576ed..a2fe4824977ed 100644 --- a/bin/node-template/node/Cargo.toml +++ b/bin/node-template/node/Cargo.toml @@ -38,7 +38,7 @@ sp-runtime = { version = "4.0.0-dev", path = "../../../primitives/runtime" } sp-timestamp = { version = "4.0.0-dev", path = "../../../primitives/timestamp" } # These dependencies are used for the node template's RPCs -jsonrpsee = { git = "https://github.com/paritytech/jsonrpsee", branch = "master", features = ["server"] } +jsonrpsee = { git = "https://github.com/paritytech/jsonrpsee", branch = "na-http-server-export-acl", 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 171f9542785f7..cd67de6902734 100644 --- a/bin/node/cli/Cargo.toml +++ b/bin/node/cli/Cargo.toml @@ -34,7 +34,7 @@ crate-type = ["cdylib", "rlib"] [dependencies] # third-party dependencies -jsonrpsee = { git = "https://github.com/paritytech/jsonrpsee", branch = "master", features = ["server"] } +jsonrpsee = { git = "https://github.com/paritytech/jsonrpsee", branch = "na-http-server-export-acl", features = ["server"] } serde = { version = "1.0.126", features = ["derive"] } futures = "0.3.16" hex-literal = "0.3.1" diff --git a/bin/node/rpc-client/Cargo.toml b/bin/node/rpc-client/Cargo.toml index e368e812c183e..7a0de31e472ae 100644 --- a/bin/node/rpc-client/Cargo.toml +++ b/bin/node/rpc-client/Cargo.toml @@ -12,7 +12,7 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] futures = "0.3.16" -jsonrpsee = { git = "https://github.com/paritytech/jsonrpsee", branch = "master", features = ["client", "macros"] } +jsonrpsee = { git = "https://github.com/paritytech/jsonrpsee", branch = "na-http-server-export-acl", features = ["client", "macros"] } tokio = { version = "1.10", features = ["full"] } node-primitives = { version = "2.0.0", path = "../primitives" } sp-tracing = { version = "4.0.0-dev", path = "../../../primitives/tracing" } diff --git a/client/consensus/babe/rpc/Cargo.toml b/client/consensus/babe/rpc/Cargo.toml index 10bed97fe34bd..e0abf963a74e7 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 = { git = "https://github.com/paritytech/jsonrpsee", branch = "master", features = ["server"] } +jsonrpsee = { git = "https://github.com/paritytech/jsonrpsee", branch = "na-http-server-export-acl", features = ["server"] } 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 86a3e1d12df1a..cdd80e0c5b2be 100644 --- a/client/consensus/manual-seal/Cargo.toml +++ b/client/consensus/manual-seal/Cargo.toml @@ -16,7 +16,7 @@ targets = ["x86_64-unknown-linux-gnu"] derive_more = "0.99.2" futures = "0.3.9" -jsonrpsee = { git = "https://github.com/paritytech/jsonrpsee", branch = "master", features = ["server"] } +jsonrpsee = { git = "https://github.com/paritytech/jsonrpsee", branch = "na-http-server-export-acl", features = ["server"] } log = "0.4.8" codec = { package = "parity-scale-codec", version = "2.0.0" } serde = { version = "1.0", features = ["derive"] } diff --git a/client/finality-grandpa/rpc/Cargo.toml b/client/finality-grandpa/rpc/Cargo.toml index 96ff5d504eb8b..ef5937b02930b 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 = "4.0.0-dev", path = "../../../primitives/core" } sp-runtime = { version = "4.0.0-dev", path = "../../../primitives/runtime" } finality-grandpa = { version = "0.14.1", features = ["derive-codec"] } -jsonrpsee = { git = "https://github.com/paritytech/jsonrpsee", branch = "master", features = ["server"] } +jsonrpsee = { git = "https://github.com/paritytech/jsonrpsee", branch = "na-http-server-export-acl", features = ["server"] } futures = { version = "0.3.4", features = ["compat"] } serde = { version = "1.0.105", features = ["derive"] } serde_json = "1.0.50" diff --git a/client/rpc-api/Cargo.toml b/client/rpc-api/Cargo.toml index f5f83ebbe77a8..ee3d5ead6250d 100644 --- a/client/rpc-api/Cargo.toml +++ b/client/rpc-api/Cargo.toml @@ -26,7 +26,7 @@ sc-chain-spec = { path = "../chain-spec", version = "4.0.0-dev" } serde = { version = "1.0.126", features = ["derive"] } serde_json = "1.0.41" -jsonrpsee = { git = "https://github.com/paritytech/jsonrpsee", branch = "master", features = ["full"] } +jsonrpsee = { git = "https://github.com/paritytech/jsonrpsee", branch = "na-http-server-export-acl", features = ["full"] } sc-transaction-pool-api = { version = "4.0.0-dev", path = "../transaction-pool/api" } sp-rpc = { version = "4.0.0-dev", path = "../../primitives/rpc" } diff --git a/client/rpc-api/src/lib.rs b/client/rpc-api/src/lib.rs index 4b165867c83e1..ca0bd78467b3d 100644 --- a/client/rpc-api/src/lib.rs +++ b/client/rpc-api/src/lib.rs @@ -28,6 +28,7 @@ pub use policy::DenyUnsafe; pub mod author; pub mod chain; +/// Child state API pub mod child_state; pub mod offchain; pub mod state; diff --git a/client/rpc-servers/Cargo.toml b/client/rpc-servers/Cargo.toml index 96a3163738b86..78246778f963f 100644 --- a/client/rpc-servers/Cargo.toml +++ b/client/rpc-servers/Cargo.toml @@ -18,5 +18,5 @@ log = "0.4.8" prometheus-endpoint = { package = "substrate-prometheus-endpoint", path = "../../utils/prometheus", version = "0.9.0"} serde_json = "1.0.41" futures-channel = "0.3" -jsonrpsee = { git = "https://github.com/paritytech/jsonrpsee", branch = "master", features = ["server"] } +jsonrpsee = { git = "https://github.com/paritytech/jsonrpsee", branch = "na-http-server-export-acl", features = ["server"] } tokio = { version = "1.10", features = ["full"] } diff --git a/client/rpc-servers/src/lib.rs b/client/rpc-servers/src/lib.rs index 38056ce9f56a2..0df92be380842 100644 --- a/client/rpc-servers/src/lib.rs +++ b/client/rpc-servers/src/lib.rs @@ -21,7 +21,7 @@ #![warn(missing_docs)] use jsonrpsee::{ - http_server::{HttpServerBuilder, HttpStopHandle}, + http_server::{AccessControlBuilder, Host, HttpServerBuilder, HttpStopHandle}, ws_server::{WsServerBuilder, WsStopHandle}, RpcModule, }; @@ -90,7 +90,7 @@ pub type WsServer = WsStopHandle; /// Start HTTP server listening on given address. pub fn start_http( addr: std::net::SocketAddr, - _cors: Option<&Vec>, + cors: Option<&Vec>, maybe_max_payload_mb: Option, module: RpcModule, rt: tokio::runtime::Handle, @@ -99,8 +99,24 @@ pub fn start_http( .map(|mb| mb.saturating_mul(MEGABYTE)) .unwrap_or(RPC_MAX_PAYLOAD_DEFAULT); + let mut acl = AccessControlBuilder::new(); + + log::info!("starting JSONRPC HTTP server: addr={}, cors={:?}", addr, cors); + + if let Some(cors) = cors { + // Whitelist listening address. + let host = Host::parse(&format!("localhost:{}", addr.port())); + acl = acl.allow_host(host); + let host = Host::parse(&format!("127.0.0.1:{}", addr.port())); + acl = acl.allow_host(host); + for origin in cors { + acl = acl.cors_allow_origin(origin.into()); + } + }; + let server = HttpServerBuilder::default() .max_request_body_size(max_request_body_size as u32) + .set_access_control(acl.build()) .build(addr)?; let handle = server.stop_handle(); @@ -117,7 +133,7 @@ pub fn start_http( pub fn start_ws( addr: std::net::SocketAddr, max_connections: Option, - _cors: Option<&Vec>, + cors: Option<&Vec>, maybe_max_payload_mb: Option, module: RpcModule, rt: tokio::runtime::Handle, @@ -127,14 +143,19 @@ pub fn start_ws( .unwrap_or(RPC_MAX_PAYLOAD_DEFAULT); let max_connections = max_connections.unwrap_or(WS_MAX_CONNECTIONS); - let server = tokio::task::block_in_place(|| { - rt.block_on( - WsServerBuilder::default() - .max_request_body_size(max_request_body_size as u32) - .max_connections(max_connections as u64) - .build(addr), - ) - })?; + let mut builder = WsServerBuilder::default() + .max_request_body_size(max_request_body_size as u32) + .max_connections(max_connections as u64); + + log::info!("starting JSONRPC WS server: addr={}, cors={:?}", addr, cors); + + if let Some(cors) = cors { + // Whitelist listening address. + builder = builder.set_allowed_hosts([format!("localhost:{}", addr.port()), format!("127.0.0.1:{}", addr.port())])?; + builder = builder.set_allowed_origins(cors)?; + } + + let server = tokio::task::block_in_place(|| rt.block_on(builder.build(addr)))?; let handle = server.stop_handle(); let rpc_api = build_rpc_api(module); diff --git a/client/rpc/Cargo.toml b/client/rpc/Cargo.toml index 7b338492248a3..8e48d27e05078 100644 --- a/client/rpc/Cargo.toml +++ b/client/rpc/Cargo.toml @@ -38,7 +38,7 @@ sc-tracing = { version = "4.0.0-dev", path = "../tracing" } hash-db = { version = "0.15.2", default-features = false } parking_lot = "0.11.1" lazy_static = { version = "1.4.0", optional = true } -jsonrpsee = { git = "https://github.com/paritytech/jsonrpsee", branch = "master", features = ["server"] } +jsonrpsee = { git = "https://github.com/paritytech/jsonrpsee", branch = "na-http-server-export-acl", features = ["server"] } sc-transaction-pool-api = { version = "4.0.0-dev", path = "../transaction-pool/api" } [dev-dependencies] diff --git a/client/service/Cargo.toml b/client/service/Cargo.toml index bf0dc7380abf3..2f27d9df0b769 100644 --- a/client/service/Cargo.toml +++ b/client/service/Cargo.toml @@ -22,7 +22,7 @@ wasmtime = ["sc-executor/wasmtime"] test-helpers = [] [dependencies] -jsonrpsee = { git = "https://github.com/paritytech/jsonrpsee", branch = "master", features = ["server"] } +jsonrpsee = { git = "https://github.com/paritytech/jsonrpsee", branch = "na-http-server-export-acl", features = ["server"] } thiserror = "1.0.21" futures01 = { package = "futures", version = "0.1.29" } diff --git a/client/service/src/builder.rs b/client/service/src/builder.rs index c2ebaf9ece83d..8c1012a6ad0a5 100644 --- a/client/service/src/builder.rs +++ b/client/service/src/builder.rs @@ -656,7 +656,7 @@ fn init_telemetry>( // Maciej: This is very WIP, mocking the original `gen_handler`. All of the `jsonrpsee` // specific logic should be merged back to `gen_handler` down the road. fn gen_rpc_module( - _deny_unsafe: DenyUnsafe, + deny_unsafe: DenyUnsafe, spawn_handle: SpawnTaskHandle, client: Arc, on_demand: Option>>, @@ -690,9 +690,6 @@ where { const UNIQUE_METHOD_NAMES_PROOF: &str = "Method names are unique; qed"; - // TODO(niklasad1): fix CORS. - let deny_unsafe = DenyUnsafe::No; - let system_info = sc_rpc::system::SystemInfo { chain_name: config.chain_spec.name().into(), impl_name: config.impl_name.clone(), diff --git a/client/sync-state-rpc/Cargo.toml b/client/sync-state-rpc/Cargo.toml index 4a1a7946add19..df7a88e823815 100644 --- a/client/sync-state-rpc/Cargo.toml +++ b/client/sync-state-rpc/Cargo.toml @@ -15,7 +15,8 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] thiserror = "1.0.21" anyhow = "1" -jsonrpsee = { git = "https://github.com/paritytech/jsonrpsee", branch = "master", features = ["server"] } +jsonrpsee = { git = "https://github.com/paritytech/jsonrpsee", branch = "na-http-server-export-acl", features = ["server"] } +log = "0.4" sc-chain-spec = { version = "4.0.0-dev", path = "../chain-spec" } sc-client-api = { version = "4.0.0-dev", path = "../api" } diff --git a/frame/contracts/rpc/Cargo.toml b/frame/contracts/rpc/Cargo.toml index 856062029a2c7..8b6d85050a2a7 100644 --- a/frame/contracts/rpc/Cargo.toml +++ b/frame/contracts/rpc/Cargo.toml @@ -14,7 +14,8 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] codec = { package = "parity-scale-codec", version = "2" } -jsonrpsee = { git = "https://github.com/paritytech/jsonrpsee", branch = "master", features = ["server"] } +jsonrpsee = { git = "https://github.com/paritytech/jsonrpsee", branch = "na-http-server-export-acl", features = ["server"] } +log = "0.4" serde = { version = "1", features = ["derive"] } serde_json = "1" diff --git a/frame/merkle-mountain-range/rpc/Cargo.toml b/frame/merkle-mountain-range/rpc/Cargo.toml index d988b3de7d637..0f6f0b66b8244 100644 --- a/frame/merkle-mountain-range/rpc/Cargo.toml +++ b/frame/merkle-mountain-range/rpc/Cargo.toml @@ -14,9 +14,10 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] codec = { package = "parity-scale-codec", version = "2.0.0" } -jsonrpsee = { git = "https://github.com/paritytech/jsonrpsee", branch = "master", features = ["server"] } +jsonrpsee = { git = "https://github.com/paritytech/jsonrpsee", branch = "na-http-server-export-acl", features = ["server"] } serde_json = "1" serde = { version = "1.0.126", features = ["derive"] } +log = "0.4" sp-api = { version = "4.0.0-dev", path = "../../../primitives/api" } sp-blockchain = { version = "4.0.0-dev", path = "../../../primitives/blockchain" } diff --git a/frame/transaction-payment/rpc/Cargo.toml b/frame/transaction-payment/rpc/Cargo.toml index 0600c0f226200..daa291ab22b7f 100644 --- a/frame/transaction-payment/rpc/Cargo.toml +++ b/frame/transaction-payment/rpc/Cargo.toml @@ -13,9 +13,11 @@ readme = "README.md" targets = ["x86_64-unknown-linux-gnu"] [dependencies] +anyhow = "1" codec = { package = "parity-scale-codec", version = "2.0.0" } -jsonrpsee = { git = "https://github.com/paritytech/jsonrpsee", branch = "master", features = ["server"] } +jsonrpsee = { git = "https://github.com/paritytech/jsonrpsee", branch = "na-http-server-export-acl", features = ["server"] } +log = "0.4" sp-api = { version = "4.0.0-dev", path = "../../../primitives/api" } sp-blockchain = { version = "4.0.0-dev", path = "../../../primitives/blockchain" } diff --git a/frame/transaction-payment/rpc/src/lib.rs b/frame/transaction-payment/rpc/src/lib.rs index ee9c500ffc55f..9b1b85887ea91 100644 --- a/frame/transaction-payment/rpc/src/lib.rs +++ b/frame/transaction-payment/rpc/src/lib.rs @@ -19,6 +19,7 @@ use std::{convert::TryInto, sync::Arc}; +use anyhow::anyhow; use codec::{Codec, Decode}; use jsonrpsee::{ proc_macros::rpc, @@ -28,7 +29,6 @@ use jsonrpsee::{ JsonRpcResult, }, }; -pub use pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi as TransactionPaymentRuntimeApi; use pallet_transaction_payment_rpc_runtime_api::{FeeDetails, InclusionFee, RuntimeDispatchInfo}; use sp_api::ProvideRuntimeApi; use sp_blockchain::HeaderBackend; @@ -39,6 +39,8 @@ use sp_runtime::{ traits::{Block as BlockT, MaybeDisplay}, }; +pub use pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi as TransactionPaymentRuntimeApi; + #[rpc(client, server, namespace = "payment")] pub trait TransactionPaymentApi { #[method(name = "queryInfo")] @@ -109,8 +111,11 @@ where .query_fee_details(&at, uxt, encoded_len) .map_err(|api_err| CallError::from_std_error(api_err))?; - let try_into_rpc_balance = - |value: Balance| value.try_into().map_err(|_try_err| CallError::InvalidParams); + let try_into_rpc_balance = |value: Balance| { + value + .try_into() + .map_err(|_| anyhow!("{} doesn't fit in NumberOrHex representation", value)) + }; Ok(FeeDetails { inclusion_fee: if let Some(inclusion_fee) = fee_details.inclusion_fee { diff --git a/test-utils/test-runner/Cargo.toml b/test-utils/test-runner/Cargo.toml index 506a411adbf64..4d1f58e9b8801 100644 --- a/test-utils/test-runner/Cargo.toml +++ b/test-utils/test-runner/Cargo.toml @@ -51,5 +51,5 @@ futures = "0.3.16" tokio = { version = "1.10", features = ["signal"] } # Calling RPC -jsonrpsee = { git = "https://github.com/paritytech/jsonrpsee", branch = "master", features = ["server"] } +jsonrpsee = { git = "https://github.com/paritytech/jsonrpsee", branch = "na-http-server-export-acl", features = ["server"] } num-traits = "0.2.14" diff --git a/utils/frame/remote-externalities/Cargo.toml b/utils/frame/remote-externalities/Cargo.toml index 5296bf3ab8bb8..53c817504f88e 100644 --- a/utils/frame/remote-externalities/Cargo.toml +++ b/utils/frame/remote-externalities/Cargo.toml @@ -17,11 +17,11 @@ jsonrpsee-ws-client = { version = "0.3.0", default-features = false, features = "tokio1", ] } jsonrpsee-proc-macros = "0.3.0" -# jsonrpsee-ws-client = { git = "https://github.com/paritytech/jsonrpsee", branch = "master" } -# # jsonrpsee-ws-client = { git = "https://github.com/paritytech/jsonrpsee", branch = "master", default-features = false, features = [ +# jsonrpsee-ws-client = { git = "https://github.com/paritytech/jsonrpsee", branch = "na-http-server-export-acl" } +# # jsonrpsee-ws-client = { git = "https://github.com/paritytech/jsonrpsee", branch = "na-http-server-export-acl", default-features = false, features = [ # # "tokio02", # # ] } -# jsonrpsee-proc-macros = { git = "https://github.com/paritytech/jsonrpsee", branch = "master" } +# jsonrpsee-proc-macros = { git = "https://github.com/paritytech/jsonrpsee", branch = "na-http-server-export-acl" } env_logger = "0.9" log = "0.4.11" diff --git a/utils/frame/rpc/support/Cargo.toml b/utils/frame/rpc/support/Cargo.toml index 93ee6e3e8c892..65f648e319fde 100644 --- a/utils/frame/rpc/support/Cargo.toml +++ b/utils/frame/rpc/support/Cargo.toml @@ -16,7 +16,7 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] futures = "0.3.16" -jsonrpsee = { git = "https://github.com/paritytech/jsonrpsee", branch = "master", features = ["client", "types"] } +jsonrpsee = { git = "https://github.com/paritytech/jsonrpsee", branch = "na-http-server-export-acl", features = ["client", "types"] } codec = { package = "parity-scale-codec", version = "2.0.0" } serde = "1" frame-support = { version = "4.0.0-dev", path = "../../../../frame/support" } diff --git a/utils/frame/rpc/system/Cargo.toml b/utils/frame/rpc/system/Cargo.toml index 78699d4cdd0fd..e59eff9102d4b 100644 --- a/utils/frame/rpc/system/Cargo.toml +++ b/utils/frame/rpc/system/Cargo.toml @@ -19,7 +19,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 = { version = "0.3.4", features = ["compat"] } -jsonrpsee = { git = "https://github.com/paritytech/jsonrpsee", branch = "master", features = ["server"] } +jsonrpsee = { git = "https://github.com/paritytech/jsonrpsee", branch = "na-http-server-export-acl", features = ["server"] } log = "0.4.8" sp-runtime = { version = "4.0.0-dev", path = "../../../../primitives/runtime" } sp-api = { version = "4.0.0-dev", path = "../../../../primitives/api" } From a57b164637e731fb12398f709451ffec94abbaa0 Mon Sep 17 00:00:00 2001 From: Niklas Adolfsson Date: Wed, 15 Sep 2021 14:36:58 +0200 Subject: [PATCH 2/6] use master --- Cargo.lock | 32 ++++++++++----------- bin/node-template/node/Cargo.toml | 2 +- bin/node/cli/Cargo.toml | 2 +- bin/node/rpc-client/Cargo.toml | 2 +- client/consensus/babe/rpc/Cargo.toml | 2 +- client/consensus/manual-seal/Cargo.toml | 2 +- client/finality-grandpa/rpc/Cargo.toml | 2 +- client/rpc-api/Cargo.toml | 2 +- client/rpc-servers/Cargo.toml | 2 +- client/rpc/Cargo.toml | 2 +- client/service/Cargo.toml | 2 +- client/sync-state-rpc/Cargo.toml | 2 +- frame/contracts/rpc/Cargo.toml | 2 +- frame/merkle-mountain-range/rpc/Cargo.toml | 2 +- frame/transaction-payment/rpc/Cargo.toml | 2 +- test-utils/test-runner/Cargo.toml | 2 +- utils/frame/remote-externalities/Cargo.toml | 6 ++-- utils/frame/rpc/support/Cargo.toml | 2 +- utils/frame/rpc/system/Cargo.toml | 2 +- 19 files changed, 36 insertions(+), 36 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0647cc55f08c8..5b01481eaaa72 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2781,28 +2781,28 @@ dependencies = [ [[package]] name = "jsonrpsee" version = "0.3.0" -source = "git+https://github.com/paritytech/jsonrpsee?branch=na-http-server-export-acl#8d66bd115afd927294d346cc8d10804643769917" +source = "git+https://github.com/paritytech/jsonrpsee?branch=master#c13f97ba8bb5a5862dd0372053f5d9aa56531c3b" dependencies = [ "jsonrpsee-http-client", "jsonrpsee-http-server", - "jsonrpsee-proc-macros 0.3.0 (git+https://github.com/paritytech/jsonrpsee?branch=na-http-server-export-acl)", - "jsonrpsee-types 0.3.0 (git+https://github.com/paritytech/jsonrpsee?branch=na-http-server-export-acl)", + "jsonrpsee-proc-macros 0.3.0 (git+https://github.com/paritytech/jsonrpsee?branch=master)", + "jsonrpsee-types 0.3.0 (git+https://github.com/paritytech/jsonrpsee?branch=master)", "jsonrpsee-utils", - "jsonrpsee-ws-client 0.3.0 (git+https://github.com/paritytech/jsonrpsee?branch=na-http-server-export-acl)", + "jsonrpsee-ws-client 0.3.0 (git+https://github.com/paritytech/jsonrpsee?branch=master)", "jsonrpsee-ws-server", ] [[package]] name = "jsonrpsee-http-client" version = "0.3.0" -source = "git+https://github.com/paritytech/jsonrpsee?branch=na-http-server-export-acl#8d66bd115afd927294d346cc8d10804643769917" +source = "git+https://github.com/paritytech/jsonrpsee?branch=master#c13f97ba8bb5a5862dd0372053f5d9aa56531c3b" dependencies = [ "async-trait", "fnv", "futures 0.3.16", "hyper", "hyper-rustls", - "jsonrpsee-types 0.3.0 (git+https://github.com/paritytech/jsonrpsee?branch=na-http-server-export-acl)", + "jsonrpsee-types 0.3.0 (git+https://github.com/paritytech/jsonrpsee?branch=master)", "jsonrpsee-utils", "log", "serde", @@ -2815,13 +2815,13 @@ dependencies = [ [[package]] name = "jsonrpsee-http-server" version = "0.3.0" -source = "git+https://github.com/paritytech/jsonrpsee?branch=na-http-server-export-acl#8d66bd115afd927294d346cc8d10804643769917" +source = "git+https://github.com/paritytech/jsonrpsee?branch=master#c13f97ba8bb5a5862dd0372053f5d9aa56531c3b" dependencies = [ "futures-channel", "futures-util", "globset", "hyper", - "jsonrpsee-types 0.3.0 (git+https://github.com/paritytech/jsonrpsee?branch=na-http-server-export-acl)", + "jsonrpsee-types 0.3.0 (git+https://github.com/paritytech/jsonrpsee?branch=master)", "jsonrpsee-utils", "lazy_static", "log", @@ -2850,7 +2850,7 @@ dependencies = [ [[package]] name = "jsonrpsee-proc-macros" version = "0.3.0" -source = "git+https://github.com/paritytech/jsonrpsee?branch=na-http-server-export-acl#8d66bd115afd927294d346cc8d10804643769917" +source = "git+https://github.com/paritytech/jsonrpsee?branch=master#c13f97ba8bb5a5862dd0372053f5d9aa56531c3b" dependencies = [ "Inflector", "bae", @@ -2882,7 +2882,7 @@ dependencies = [ [[package]] name = "jsonrpsee-types" version = "0.3.0" -source = "git+https://github.com/paritytech/jsonrpsee?branch=na-http-server-export-acl#8d66bd115afd927294d346cc8d10804643769917" +source = "git+https://github.com/paritytech/jsonrpsee?branch=master#c13f97ba8bb5a5862dd0372053f5d9aa56531c3b" dependencies = [ "anyhow", "async-trait", @@ -2900,13 +2900,13 @@ dependencies = [ [[package]] name = "jsonrpsee-utils" version = "0.3.0" -source = "git+https://github.com/paritytech/jsonrpsee?branch=na-http-server-export-acl#8d66bd115afd927294d346cc8d10804643769917" +source = "git+https://github.com/paritytech/jsonrpsee?branch=master#c13f97ba8bb5a5862dd0372053f5d9aa56531c3b" dependencies = [ "beef", "futures-channel", "futures-util", "hyper", - "jsonrpsee-types 0.3.0 (git+https://github.com/paritytech/jsonrpsee?branch=na-http-server-export-acl)", + "jsonrpsee-types 0.3.0 (git+https://github.com/paritytech/jsonrpsee?branch=master)", "log", "parking_lot 0.11.1", "rand 0.8.4", @@ -2943,12 +2943,12 @@ dependencies = [ [[package]] name = "jsonrpsee-ws-client" version = "0.3.0" -source = "git+https://github.com/paritytech/jsonrpsee?branch=na-http-server-export-acl#8d66bd115afd927294d346cc8d10804643769917" +source = "git+https://github.com/paritytech/jsonrpsee?branch=master#c13f97ba8bb5a5862dd0372053f5d9aa56531c3b" dependencies = [ "async-trait", "fnv", "futures 0.3.16", - "jsonrpsee-types 0.3.0 (git+https://github.com/paritytech/jsonrpsee?branch=na-http-server-export-acl)", + "jsonrpsee-types 0.3.0 (git+https://github.com/paritytech/jsonrpsee?branch=master)", "log", "pin-project 1.0.5", "rustls", @@ -2966,11 +2966,11 @@ dependencies = [ [[package]] name = "jsonrpsee-ws-server" version = "0.3.0" -source = "git+https://github.com/paritytech/jsonrpsee?branch=na-http-server-export-acl#8d66bd115afd927294d346cc8d10804643769917" +source = "git+https://github.com/paritytech/jsonrpsee?branch=master#c13f97ba8bb5a5862dd0372053f5d9aa56531c3b" dependencies = [ "futures-channel", "futures-util", - "jsonrpsee-types 0.3.0 (git+https://github.com/paritytech/jsonrpsee?branch=na-http-server-export-acl)", + "jsonrpsee-types 0.3.0 (git+https://github.com/paritytech/jsonrpsee?branch=master)", "jsonrpsee-utils", "log", "rustc-hash", diff --git a/bin/node-template/node/Cargo.toml b/bin/node-template/node/Cargo.toml index a2fe4824977ed..796c20c9576ed 100644 --- a/bin/node-template/node/Cargo.toml +++ b/bin/node-template/node/Cargo.toml @@ -38,7 +38,7 @@ sp-runtime = { version = "4.0.0-dev", path = "../../../primitives/runtime" } sp-timestamp = { version = "4.0.0-dev", path = "../../../primitives/timestamp" } # These dependencies are used for the node template's RPCs -jsonrpsee = { git = "https://github.com/paritytech/jsonrpsee", branch = "na-http-server-export-acl", features = ["server"] } +jsonrpsee = { git = "https://github.com/paritytech/jsonrpsee", branch = "master", 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 cd67de6902734..171f9542785f7 100644 --- a/bin/node/cli/Cargo.toml +++ b/bin/node/cli/Cargo.toml @@ -34,7 +34,7 @@ crate-type = ["cdylib", "rlib"] [dependencies] # third-party dependencies -jsonrpsee = { git = "https://github.com/paritytech/jsonrpsee", branch = "na-http-server-export-acl", features = ["server"] } +jsonrpsee = { git = "https://github.com/paritytech/jsonrpsee", branch = "master", features = ["server"] } serde = { version = "1.0.126", features = ["derive"] } futures = "0.3.16" hex-literal = "0.3.1" diff --git a/bin/node/rpc-client/Cargo.toml b/bin/node/rpc-client/Cargo.toml index 7a0de31e472ae..e368e812c183e 100644 --- a/bin/node/rpc-client/Cargo.toml +++ b/bin/node/rpc-client/Cargo.toml @@ -12,7 +12,7 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] futures = "0.3.16" -jsonrpsee = { git = "https://github.com/paritytech/jsonrpsee", branch = "na-http-server-export-acl", features = ["client", "macros"] } +jsonrpsee = { git = "https://github.com/paritytech/jsonrpsee", branch = "master", features = ["client", "macros"] } tokio = { version = "1.10", features = ["full"] } node-primitives = { version = "2.0.0", path = "../primitives" } sp-tracing = { version = "4.0.0-dev", path = "../../../primitives/tracing" } diff --git a/client/consensus/babe/rpc/Cargo.toml b/client/consensus/babe/rpc/Cargo.toml index e0abf963a74e7..10bed97fe34bd 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 = { git = "https://github.com/paritytech/jsonrpsee", branch = "na-http-server-export-acl", features = ["server"] } +jsonrpsee = { git = "https://github.com/paritytech/jsonrpsee", branch = "master", features = ["server"] } 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 cdd80e0c5b2be..86a3e1d12df1a 100644 --- a/client/consensus/manual-seal/Cargo.toml +++ b/client/consensus/manual-seal/Cargo.toml @@ -16,7 +16,7 @@ targets = ["x86_64-unknown-linux-gnu"] derive_more = "0.99.2" futures = "0.3.9" -jsonrpsee = { git = "https://github.com/paritytech/jsonrpsee", branch = "na-http-server-export-acl", features = ["server"] } +jsonrpsee = { git = "https://github.com/paritytech/jsonrpsee", branch = "master", features = ["server"] } log = "0.4.8" codec = { package = "parity-scale-codec", version = "2.0.0" } serde = { version = "1.0", features = ["derive"] } diff --git a/client/finality-grandpa/rpc/Cargo.toml b/client/finality-grandpa/rpc/Cargo.toml index ef5937b02930b..96ff5d504eb8b 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 = "4.0.0-dev", path = "../../../primitives/core" } sp-runtime = { version = "4.0.0-dev", path = "../../../primitives/runtime" } finality-grandpa = { version = "0.14.1", features = ["derive-codec"] } -jsonrpsee = { git = "https://github.com/paritytech/jsonrpsee", branch = "na-http-server-export-acl", features = ["server"] } +jsonrpsee = { git = "https://github.com/paritytech/jsonrpsee", branch = "master", features = ["server"] } futures = { version = "0.3.4", features = ["compat"] } serde = { version = "1.0.105", features = ["derive"] } serde_json = "1.0.50" diff --git a/client/rpc-api/Cargo.toml b/client/rpc-api/Cargo.toml index ee3d5ead6250d..f5f83ebbe77a8 100644 --- a/client/rpc-api/Cargo.toml +++ b/client/rpc-api/Cargo.toml @@ -26,7 +26,7 @@ sc-chain-spec = { path = "../chain-spec", version = "4.0.0-dev" } serde = { version = "1.0.126", features = ["derive"] } serde_json = "1.0.41" -jsonrpsee = { git = "https://github.com/paritytech/jsonrpsee", branch = "na-http-server-export-acl", features = ["full"] } +jsonrpsee = { git = "https://github.com/paritytech/jsonrpsee", branch = "master", features = ["full"] } sc-transaction-pool-api = { version = "4.0.0-dev", path = "../transaction-pool/api" } sp-rpc = { version = "4.0.0-dev", path = "../../primitives/rpc" } diff --git a/client/rpc-servers/Cargo.toml b/client/rpc-servers/Cargo.toml index 78246778f963f..96a3163738b86 100644 --- a/client/rpc-servers/Cargo.toml +++ b/client/rpc-servers/Cargo.toml @@ -18,5 +18,5 @@ log = "0.4.8" prometheus-endpoint = { package = "substrate-prometheus-endpoint", path = "../../utils/prometheus", version = "0.9.0"} serde_json = "1.0.41" futures-channel = "0.3" -jsonrpsee = { git = "https://github.com/paritytech/jsonrpsee", branch = "na-http-server-export-acl", features = ["server"] } +jsonrpsee = { git = "https://github.com/paritytech/jsonrpsee", branch = "master", features = ["server"] } tokio = { version = "1.10", features = ["full"] } diff --git a/client/rpc/Cargo.toml b/client/rpc/Cargo.toml index 8e48d27e05078..7b338492248a3 100644 --- a/client/rpc/Cargo.toml +++ b/client/rpc/Cargo.toml @@ -38,7 +38,7 @@ sc-tracing = { version = "4.0.0-dev", path = "../tracing" } hash-db = { version = "0.15.2", default-features = false } parking_lot = "0.11.1" lazy_static = { version = "1.4.0", optional = true } -jsonrpsee = { git = "https://github.com/paritytech/jsonrpsee", branch = "na-http-server-export-acl", features = ["server"] } +jsonrpsee = { git = "https://github.com/paritytech/jsonrpsee", branch = "master", features = ["server"] } sc-transaction-pool-api = { version = "4.0.0-dev", path = "../transaction-pool/api" } [dev-dependencies] diff --git a/client/service/Cargo.toml b/client/service/Cargo.toml index 2f27d9df0b769..bf0dc7380abf3 100644 --- a/client/service/Cargo.toml +++ b/client/service/Cargo.toml @@ -22,7 +22,7 @@ wasmtime = ["sc-executor/wasmtime"] test-helpers = [] [dependencies] -jsonrpsee = { git = "https://github.com/paritytech/jsonrpsee", branch = "na-http-server-export-acl", features = ["server"] } +jsonrpsee = { git = "https://github.com/paritytech/jsonrpsee", branch = "master", features = ["server"] } thiserror = "1.0.21" futures01 = { package = "futures", version = "0.1.29" } diff --git a/client/sync-state-rpc/Cargo.toml b/client/sync-state-rpc/Cargo.toml index df7a88e823815..1ab8f539768c9 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.21" anyhow = "1" -jsonrpsee = { git = "https://github.com/paritytech/jsonrpsee", branch = "na-http-server-export-acl", features = ["server"] } +jsonrpsee = { git = "https://github.com/paritytech/jsonrpsee", branch = "master", features = ["server"] } log = "0.4" sc-chain-spec = { version = "4.0.0-dev", path = "../chain-spec" } diff --git a/frame/contracts/rpc/Cargo.toml b/frame/contracts/rpc/Cargo.toml index 8b6d85050a2a7..477c5ad55ebb1 100644 --- a/frame/contracts/rpc/Cargo.toml +++ b/frame/contracts/rpc/Cargo.toml @@ -14,7 +14,7 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] codec = { package = "parity-scale-codec", version = "2" } -jsonrpsee = { git = "https://github.com/paritytech/jsonrpsee", branch = "na-http-server-export-acl", features = ["server"] } +jsonrpsee = { git = "https://github.com/paritytech/jsonrpsee", branch = "master", features = ["server"] } log = "0.4" serde = { version = "1", features = ["derive"] } serde_json = "1" diff --git a/frame/merkle-mountain-range/rpc/Cargo.toml b/frame/merkle-mountain-range/rpc/Cargo.toml index 0f6f0b66b8244..c05329715a720 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 = "2.0.0" } -jsonrpsee = { git = "https://github.com/paritytech/jsonrpsee", branch = "na-http-server-export-acl", features = ["server"] } +jsonrpsee = { git = "https://github.com/paritytech/jsonrpsee", branch = "master", features = ["server"] } serde_json = "1" serde = { version = "1.0.126", features = ["derive"] } log = "0.4" diff --git a/frame/transaction-payment/rpc/Cargo.toml b/frame/transaction-payment/rpc/Cargo.toml index daa291ab22b7f..b3463eaa9e578 100644 --- a/frame/transaction-payment/rpc/Cargo.toml +++ b/frame/transaction-payment/rpc/Cargo.toml @@ -16,7 +16,7 @@ targets = ["x86_64-unknown-linux-gnu"] anyhow = "1" codec = { package = "parity-scale-codec", version = "2.0.0" } -jsonrpsee = { git = "https://github.com/paritytech/jsonrpsee", branch = "na-http-server-export-acl", features = ["server"] } +jsonrpsee = { git = "https://github.com/paritytech/jsonrpsee", branch = "master", features = ["server"] } log = "0.4" sp-api = { version = "4.0.0-dev", path = "../../../primitives/api" } diff --git a/test-utils/test-runner/Cargo.toml b/test-utils/test-runner/Cargo.toml index 4d1f58e9b8801..506a411adbf64 100644 --- a/test-utils/test-runner/Cargo.toml +++ b/test-utils/test-runner/Cargo.toml @@ -51,5 +51,5 @@ futures = "0.3.16" tokio = { version = "1.10", features = ["signal"] } # Calling RPC -jsonrpsee = { git = "https://github.com/paritytech/jsonrpsee", branch = "na-http-server-export-acl", features = ["server"] } +jsonrpsee = { git = "https://github.com/paritytech/jsonrpsee", branch = "master", features = ["server"] } num-traits = "0.2.14" diff --git a/utils/frame/remote-externalities/Cargo.toml b/utils/frame/remote-externalities/Cargo.toml index 53c817504f88e..5296bf3ab8bb8 100644 --- a/utils/frame/remote-externalities/Cargo.toml +++ b/utils/frame/remote-externalities/Cargo.toml @@ -17,11 +17,11 @@ jsonrpsee-ws-client = { version = "0.3.0", default-features = false, features = "tokio1", ] } jsonrpsee-proc-macros = "0.3.0" -# jsonrpsee-ws-client = { git = "https://github.com/paritytech/jsonrpsee", branch = "na-http-server-export-acl" } -# # jsonrpsee-ws-client = { git = "https://github.com/paritytech/jsonrpsee", branch = "na-http-server-export-acl", default-features = false, features = [ +# jsonrpsee-ws-client = { git = "https://github.com/paritytech/jsonrpsee", branch = "master" } +# # jsonrpsee-ws-client = { git = "https://github.com/paritytech/jsonrpsee", branch = "master", default-features = false, features = [ # # "tokio02", # # ] } -# jsonrpsee-proc-macros = { git = "https://github.com/paritytech/jsonrpsee", branch = "na-http-server-export-acl" } +# jsonrpsee-proc-macros = { git = "https://github.com/paritytech/jsonrpsee", branch = "master" } env_logger = "0.9" log = "0.4.11" diff --git a/utils/frame/rpc/support/Cargo.toml b/utils/frame/rpc/support/Cargo.toml index 65f648e319fde..93ee6e3e8c892 100644 --- a/utils/frame/rpc/support/Cargo.toml +++ b/utils/frame/rpc/support/Cargo.toml @@ -16,7 +16,7 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] futures = "0.3.16" -jsonrpsee = { git = "https://github.com/paritytech/jsonrpsee", branch = "na-http-server-export-acl", features = ["client", "types"] } +jsonrpsee = { git = "https://github.com/paritytech/jsonrpsee", branch = "master", features = ["client", "types"] } codec = { package = "parity-scale-codec", version = "2.0.0" } serde = "1" frame-support = { version = "4.0.0-dev", path = "../../../../frame/support" } diff --git a/utils/frame/rpc/system/Cargo.toml b/utils/frame/rpc/system/Cargo.toml index e59eff9102d4b..78699d4cdd0fd 100644 --- a/utils/frame/rpc/system/Cargo.toml +++ b/utils/frame/rpc/system/Cargo.toml @@ -19,7 +19,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 = { version = "0.3.4", features = ["compat"] } -jsonrpsee = { git = "https://github.com/paritytech/jsonrpsee", branch = "na-http-server-export-acl", features = ["server"] } +jsonrpsee = { git = "https://github.com/paritytech/jsonrpsee", branch = "master", features = ["server"] } log = "0.4.8" sp-runtime = { version = "4.0.0-dev", path = "../../../../primitives/runtime" } sp-api = { version = "4.0.0-dev", path = "../../../../primitives/api" } From 085d52de8f6be9c4394bb1a97a2cf9e73104ebed Mon Sep 17 00:00:00 2001 From: Niklas Adolfsson Date: Wed, 15 Sep 2021 14:54:09 +0200 Subject: [PATCH 3/6] fix nits --- client/rpc-servers/src/lib.rs | 5 ++++- client/service/src/builder.rs | 2 -- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/client/rpc-servers/src/lib.rs b/client/rpc-servers/src/lib.rs index 0df92be380842..b4faa3919181f 100644 --- a/client/rpc-servers/src/lib.rs +++ b/client/rpc-servers/src/lib.rs @@ -151,7 +151,10 @@ pub fn start_ws( if let Some(cors) = cors { // Whitelist listening address. - builder = builder.set_allowed_hosts([format!("localhost:{}", addr.port()), format!("127.0.0.1:{}", addr.port())])?; + builder = builder.set_allowed_hosts([ + format!("localhost:{}", addr.port()), + format!("127.0.0.1:{}", addr.port()), + ])?; builder = builder.set_allowed_origins(cors)?; } diff --git a/client/service/src/builder.rs b/client/service/src/builder.rs index 8c1012a6ad0a5..2a5f59b1e3590 100644 --- a/client/service/src/builder.rs +++ b/client/service/src/builder.rs @@ -592,8 +592,6 @@ where ), ); - // NOTE(niklasad1): we spawn jsonrpsee in seperate thread now. - // this will not shutdown the server. task_manager.keep_alive((config.base_path, rpc)); Ok(()) From b1d11b4171ce5c106a02d1b21cdee2b75635b480 Mon Sep 17 00:00:00 2001 From: Niklas Adolfsson Date: Wed, 15 Sep 2021 15:14:17 +0200 Subject: [PATCH 4/6] rpc runtime_version safe --- client/rpc/src/state/mod.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/client/rpc/src/state/mod.rs b/client/rpc/src/state/mod.rs index 88f0e70f6d4c8..2fa9b8b02af7b 100644 --- a/client/rpc/src/state/mod.rs +++ b/client/rpc/src/state/mod.rs @@ -296,7 +296,7 @@ where return Err(JsonRpseeError::to_call_error(Error::InvalidCount { value: count, max: STORAGE_KEYS_PAGED_MAX_COUNT, - })) + })); } self.backend .storage_keys_paged(block, prefix, count, start_key) @@ -342,7 +342,6 @@ where } async fn runtime_version(&self, at: Option) -> JsonRpcResult { - self.deny_unsafe.check_if_safe()?; self.backend .runtime_version(at) .await From a4a56d66164c2291ad0ad40e54e04277b5c24164 Mon Sep 17 00:00:00 2001 From: Niklas Adolfsson Date: Wed, 15 Sep 2021 15:42:31 +0200 Subject: [PATCH 5/6] fix nits --- client/rpc/src/offchain/mod.rs | 7 +++++-- client/rpc/src/state/mod.rs | 2 -- client/rpc/src/system/mod.rs | 2 -- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/client/rpc/src/offchain/mod.rs b/client/rpc/src/offchain/mod.rs index 72519f14e0320..63fc0e48a6be4 100644 --- a/client/rpc/src/offchain/mod.rs +++ b/client/rpc/src/offchain/mod.rs @@ -51,6 +51,8 @@ impl Offchain { #[async_trait] impl OffchainApiServer for Offchain { fn set_local_storage(&self, kind: StorageKind, key: Bytes, value: Bytes) -> JsonRpcResult<()> { + self.deny_unsafe.check_if_safe()?; + let prefix = match kind { StorageKind::PERSISTENT => sp_offchain::STORAGE_PREFIX, StorageKind::LOCAL => @@ -61,13 +63,14 @@ impl OffchainApiServer for Offchain { } fn get_local_storage(&self, kind: StorageKind, key: Bytes) -> JsonRpcResult> { + self.deny_unsafe.check_if_safe()?; + let prefix = match kind { StorageKind::PERSISTENT => sp_offchain::STORAGE_PREFIX, StorageKind::LOCAL => return Err(JsonRpseeError::to_call_error(Error::UnavailableStorageKind)), }; - let bytes: Option = self.storage.read().get(prefix, &*key).map(Into::into); - Ok(bytes) + Ok(self.storage.read().get(prefix, &*key).map(Into::into)) } } diff --git a/client/rpc/src/state/mod.rs b/client/rpc/src/state/mod.rs index 2fa9b8b02af7b..702b851e354e4 100644 --- a/client/rpc/src/state/mod.rs +++ b/client/rpc/src/state/mod.rs @@ -366,7 +366,6 @@ where keys: Vec, at: Option, ) -> JsonRpcResult>> { - self.deny_unsafe.check_if_safe()?; self.backend .query_storage_at(keys, at) .await @@ -378,7 +377,6 @@ where keys: Vec, block: Option, ) -> JsonRpcResult> { - self.deny_unsafe.check_if_safe()?; self.backend .read_proof(block, keys) .await diff --git a/client/rpc/src/system/mod.rs b/client/rpc/src/system/mod.rs index 95345e74709fb..94f7e63dfa287 100644 --- a/client/rpc/src/system/mod.rs +++ b/client/rpc/src/system/mod.rs @@ -164,14 +164,12 @@ impl SystemApiServer::Number> } async fn system_node_roles(&self) -> JsonRpcResult> { - self.deny_unsafe.check_if_safe()?; let (tx, rx) = oneshot::channel(); let _ = self.send_back.unbounded_send(Request::NodeRoles(tx)); rx.await.map_err(|e| JsonRpseeError::to_call_error(e)) } async fn system_sync_state(&self) -> JsonRpcResult::Number>> { - self.deny_unsafe.check_if_safe()?; let (tx, rx) = oneshot::channel(); let _ = self.send_back.unbounded_send(Request::SyncState(tx)); rx.await.map_err(|e| JsonRpseeError::to_call_error(e)) From fd3840dea6200aec6409eaf27c02cc49e40afcf2 Mon Sep 17 00:00:00 2001 From: Niklas Adolfsson Date: Wed, 15 Sep 2021 16:22:30 +0200 Subject: [PATCH 6/6] fix grumbles --- client/rpc-servers/src/lib.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/client/rpc-servers/src/lib.rs b/client/rpc-servers/src/lib.rs index b4faa3919181f..9e03400f833fa 100644 --- a/client/rpc-servers/src/lib.rs +++ b/client/rpc-servers/src/lib.rs @@ -101,7 +101,7 @@ pub fn start_http( let mut acl = AccessControlBuilder::new(); - log::info!("starting JSONRPC HTTP server: addr={}, cors={:?}", addr, cors); + log::info!("Starting JSONRPC HTTP server: addr={}, allowed origins={:?}", addr, cors); if let Some(cors) = cors { // Whitelist listening address. @@ -109,6 +109,8 @@ pub fn start_http( acl = acl.allow_host(host); let host = Host::parse(&format!("127.0.0.1:{}", addr.port())); acl = acl.allow_host(host); + + // Set allowed origins. for origin in cors { acl = acl.cors_allow_origin(origin.into()); } @@ -147,7 +149,7 @@ pub fn start_ws( .max_request_body_size(max_request_body_size as u32) .max_connections(max_connections as u64); - log::info!("starting JSONRPC WS server: addr={}, cors={:?}", addr, cors); + log::info!("Starting JSONRPC WS server: addr={}, allowed origins={:?}", addr, cors); if let Some(cors) = cors { // Whitelist listening address. @@ -155,6 +157,8 @@ pub fn start_ws( format!("localhost:{}", addr.port()), format!("127.0.0.1:{}", addr.port()), ])?; + + // Set allowed origins. builder = builder.set_allowed_origins(cors)?; }