From 3f7e94b9d9c12500bde5d371f5acfb42a72c87b5 Mon Sep 17 00:00:00 2001 From: Niklas Adolfsson Date: Tue, 6 Feb 2024 11:44:08 +0100 Subject: [PATCH 01/25] jsonrpsee v0.22 --- Cargo.lock | 403 +++++++++++++----- Cargo.toml | 5 + .../client/relay-chain-interface/Cargo.toml | 2 +- .../client/relay-chain-interface/src/lib.rs | 2 +- .../src/light_client_worker.rs | 9 +- .../src/reconnecting_ws_client.rs | 2 +- .../src/rpc_client.rs | 2 +- cumulus/parachain-template/node/Cargo.toml | 2 +- cumulus/polkadot-parachain/Cargo.toml | 2 +- cumulus/test/service/Cargo.toml | 2 +- polkadot/rpc/Cargo.toml | 2 +- substrate/bin/minimal/node/Cargo.toml | 2 +- substrate/bin/node-template/node/Cargo.toml | 2 +- substrate/bin/node/cli/Cargo.toml | 2 +- substrate/bin/node/rpc/Cargo.toml | 2 +- .../client/consensus/babe/rpc/Cargo.toml | 2 +- .../client/consensus/beefy/rpc/Cargo.toml | 2 +- .../client/consensus/grandpa/rpc/Cargo.toml | 2 +- .../client/consensus/manual-seal/Cargo.toml | 2 +- .../merkle-mountain-range/rpc/Cargo.toml | 2 +- substrate/client/rpc-api/Cargo.toml | 2 +- substrate/client/rpc-servers/Cargo.toml | 5 +- substrate/client/rpc-servers/src/lib.rs | 105 ++++- .../client/rpc-servers/src/middleware.rs | 226 ---------- .../rpc-servers/src/middleware/metrics.rs | 283 ++++++++++++ .../client/rpc-servers/src/middleware/mod.rs | 23 + substrate/client/rpc-spec-v2/Cargo.toml | 2 +- .../client/rpc-spec-v2/src/archive/tests.rs | 9 +- .../rpc-spec-v2/src/chain_head/tests.rs | 27 +- substrate/client/rpc/Cargo.toml | 2 +- substrate/client/rpc/src/author/tests.rs | 11 +- substrate/client/rpc/src/state/tests.rs | 4 +- substrate/client/rpc/src/system/tests.rs | 9 +- substrate/client/service/Cargo.toml | 2 +- substrate/client/service/src/lib.rs | 6 +- substrate/client/sync-state-rpc/Cargo.toml | 2 +- .../frame/transaction-payment/rpc/Cargo.toml | 2 +- .../frame/remote-externalities/Cargo.toml | 2 +- substrate/utils/frame/rpc/client/Cargo.toml | 2 +- substrate/utils/frame/rpc/client/src/lib.rs | 4 +- .../rpc/state-trie-migration-rpc/Cargo.toml | 3 +- substrate/utils/frame/rpc/support/Cargo.toml | 4 +- substrate/utils/frame/rpc/support/src/lib.rs | 2 +- substrate/utils/frame/rpc/system/Cargo.toml | 2 +- 44 files changed, 756 insertions(+), 434 deletions(-) delete mode 100644 substrate/client/rpc-servers/src/middleware.rs create mode 100644 substrate/client/rpc-servers/src/middleware/metrics.rs create mode 100644 substrate/client/rpc-servers/src/middleware/mod.rs diff --git a/Cargo.lock b/Cargo.lock index 8e2551f7cc9bc..f2196fe801669 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -86,16 +86,16 @@ dependencies = [ [[package]] name = "aes-gcm" -version = "0.9.4" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df5f85a83a7d8b0442b6aa7b504b8212c1733da07b98aae43d4bc21b2cb3cdf6" +checksum = "bc3be92e19a7ef47457b8e6f90707e12b6ac5d20c6f3866584fa3be0787d839f" dependencies = [ "aead 0.4.3", "aes 0.7.5", "cipher 0.3.0", - "ctr 0.8.0", + "ctr 0.7.0", "ghash 0.4.4", - "subtle 2.4.1", + "subtle 2.5.0", ] [[package]] @@ -109,7 +109,7 @@ dependencies = [ "cipher 0.4.4", "ctr 0.9.2", "ghash 0.5.0", - "subtle 2.4.1", + "subtle 2.5.0", ] [[package]] @@ -1099,7 +1099,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "81953c529336010edd6d8e358f886d9581267795c61b19475b71314bffa46d35" dependencies = [ "concurrent-queue", - "event-listener", + "event-listener 2.5.3", "futures-core", ] @@ -1109,7 +1109,7 @@ version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6fa3dc5f2a8564f07759c008b9109dc0d39de92a88d5588b8a5036d286383afb" dependencies = [ - "async-lock", + "async-lock 2.8.0", "async-task", "concurrent-queue", "fastrand 1.9.0", @@ -1123,7 +1123,7 @@ version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "279cf904654eeebfa37ac9bb1598880884924aab82e290aa65c9e77a0e142e06" dependencies = [ - "async-lock", + "async-lock 2.8.0", "autocfg", "blocking", "futures-lite", @@ -1135,7 +1135,7 @@ version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fc5b45d93ef0529756f812ca52e44c221b35341892d3dcc34132ac02f3dd2af" dependencies = [ - "async-lock", + "async-lock 2.8.0", "autocfg", "cfg-if", "concurrent-queue", @@ -1155,7 +1155,18 @@ version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "287272293e9d8c41773cec55e365490fe034813a2f172f502d6ddcf75b2f582b" dependencies = [ - "event-listener", + "event-listener 2.5.3", +] + +[[package]] +name = "async-lock" +version = "3.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d034b430882f8381900d3fe6f0aaa3ad94f2cb4ac519b429692a1bc2dda4ae7b" +dependencies = [ + "event-listener 4.0.3", + "event-listener-strategy", + "pin-project-lite 0.2.12", ] [[package]] @@ -1177,11 +1188,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a9d28b1d97e08915212e2e45310d47854eafa69600756fc735fb788f75199c9" dependencies = [ "async-io", - "async-lock", + "async-lock 2.8.0", "autocfg", "blocking", "cfg-if", - "event-listener", + "event-listener 2.5.3", "futures-lite", "rustix 0.37.23", "signal-hook", @@ -1580,7 +1591,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77231a1c8f801696fc0123ec6150ce92cffb8e164a02afb9c8ddee0e9b65ad65" dependencies = [ "async-channel", - "async-lock", + "async-lock 2.8.0", "async-task", "atomic-waker", "fastrand 1.9.0", @@ -3467,7 +3478,7 @@ checksum = "cf4c2f4e1afd912bc40bfd6fed5d9dc1f288e0ba01bfcc835cc5bc3eb13efe15" dependencies = [ "generic-array 0.14.7", "rand_core 0.6.4", - "subtle 2.4.1", + "subtle 2.5.0", "zeroize", ] @@ -3499,24 +3510,24 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b584a330336237c1eecd3e94266efb216c56ed91225d634cb2991c5f3fd1aeab" dependencies = [ "generic-array 0.14.7", - "subtle 2.4.1", + "subtle 2.5.0", ] [[package]] name = "crypto-mac" -version = "0.11.1" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1d1a86f49236c215f271d40892d5fc950490551400b02ef360692c29815c714" +checksum = "25fab6889090c8133f3deb8f73ba3c65a7f456f66436fc012a1b1e272b1e103e" dependencies = [ "generic-array 0.14.7", - "subtle 2.4.1", + "subtle 2.5.0", ] [[package]] name = "ctr" -version = "0.8.0" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "049bb91fb4aaf0e3c7efa6cd5ef877dbbbd15b39dad06d9948de4ec8a75761ea" +checksum = "a232f92a03f37dd7d7dd2adc67166c77e9cd88de5b019b9a9eecfaeaf7bfd481" dependencies = [ "cipher 0.3.0", ] @@ -4104,7 +4115,7 @@ dependencies = [ "async-trait", "cumulus-primitives-core", "futures", - "jsonrpsee-core", + "jsonrpsee-core 0.21.0", "parity-scale-codec", "polkadot-overseer", "sc-client-api", @@ -4164,7 +4175,7 @@ dependencies = [ "either", "futures", "futures-timer", - "jsonrpsee", + "jsonrpsee 0.20.3", "parity-scale-codec", "pin-project", "polkadot-overseer", @@ -4294,7 +4305,7 @@ dependencies = [ "frame-system", "frame-system-rpc-runtime-api", "futures", - "jsonrpsee", + "jsonrpsee 0.21.0", "pallet-im-online", "pallet-timestamp", "pallet-transaction-payment", @@ -4356,7 +4367,7 @@ dependencies = [ "byteorder", "digest 0.8.1", "rand_core 0.5.1", - "subtle 2.4.1", + "subtle 2.5.0", "zeroize", ] @@ -4369,7 +4380,7 @@ dependencies = [ "byteorder", "digest 0.9.0", "rand_core 0.5.1", - "subtle 2.4.1", + "subtle 2.5.0", "zeroize", ] @@ -4386,7 +4397,7 @@ dependencies = [ "fiat-crypto", "platforms", "rustc_version 0.4.0", - "subtle 2.4.1", + "subtle 2.5.0", "zeroize", ] @@ -4610,7 +4621,7 @@ dependencies = [ "block-buffer 0.10.4", "const-oid", "crypto-common", - "subtle 2.4.1", + "subtle 2.5.0", ] [[package]] @@ -4816,7 +4827,7 @@ dependencies = [ "rand_core 0.6.4", "serde", "sha2 0.10.7", - "subtle 2.4.1", + "subtle 2.5.0", "zeroize", ] @@ -4870,7 +4881,7 @@ dependencies = [ "pkcs8", "rand_core 0.6.4", "sec1", - "subtle 2.4.1", + "subtle 2.5.0", "zeroize", ] @@ -5098,6 +5109,27 @@ version = "2.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" +[[package]] +name = "event-listener" +version = "4.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67b215c49b2b248c855fb73579eb1f4f26c38ffdc12973e20e07b91d78d5646e" +dependencies = [ + "concurrent-queue", + "parking", + "pin-project-lite 0.2.12", +] + +[[package]] +name = "event-listener-strategy" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "958e4d70b6d5e81971bebec42271ec641e7ff4e170a6fa605f2b8a8b65cb97d3" +dependencies = [ + "event-listener 4.0.3", + "pin-project-lite 0.2.12", +] + [[package]] name = "exit-future" version = "0.2.0" @@ -5244,7 +5276,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" dependencies = [ "rand_core 0.6.4", - "subtle 2.4.1", + "subtle 2.5.0", ] [[package]] @@ -5602,7 +5634,7 @@ version = "0.35.0" dependencies = [ "futures", "indicatif", - "jsonrpsee", + "jsonrpsee 0.21.0", "log", "parity-scale-codec", "serde", @@ -5861,9 +5893,9 @@ checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" [[package]] name = "futures" -version = "0.3.28" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23342abe12aba583913b2e62f22225ff9c950774065e4bfb61a19cd9770fec40" +checksum = "645c6916888f6cb6350d2550b80fb63e734897a8498abe35cfb732b6487804b0" dependencies = [ "futures-channel", "futures-core", @@ -5892,9 +5924,9 @@ checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" [[package]] name = "futures-executor" -version = "0.3.28" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccecee823288125bd88b4d7f565c9e58e41858e47ab72e8ea2d64e93624386e0" +checksum = "a576fc72ae164fca6b9db127eaa9a9dda0d61316034f33a0a0d4eda41f02b01d" dependencies = [ "futures-core", "futures-task", @@ -6166,7 +6198,7 @@ checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" dependencies = [ "ff", "rand_core 0.6.4", - "subtle 2.4.1", + "subtle 2.5.0", ] [[package]] @@ -6319,7 +6351,7 @@ version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2a2a2320eb7ec0ebe8da8f744d7812d9fc4cb4d09344ac01898dbcb6a20ae69b" dependencies = [ - "crypto-mac 0.11.1", + "crypto-mac 0.11.0", "digest 0.9.0", ] @@ -6447,9 +6479,9 @@ dependencies = [ "hyper", "log", "rustls 0.21.6", - "rustls-native-certs", + "rustls-native-certs 0.6.3", "tokio", - "tokio-rustls", + "tokio-rustls 0.24.1", ] [[package]] @@ -6781,12 +6813,22 @@ version = "0.20.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "affdc52f7596ccb2d7645231fc6163bb314630c989b64998f3699a28b4d5d4dc" dependencies = [ - "jsonrpsee-core", + "jsonrpsee-core 0.20.3", + "jsonrpsee-types 0.20.3", + "jsonrpsee-ws-client 0.20.3", +] + +[[package]] +name = "jsonrpsee" +version = "0.21.0" +source = "git+https://github.com/paritytech/jsonrpsee?branch=master#8470f2bb8d2a2b5e3c5cfd07f138aeab9dfbe022" +dependencies = [ + "jsonrpsee-core 0.21.0", "jsonrpsee-http-client", "jsonrpsee-proc-macros", "jsonrpsee-server", - "jsonrpsee-types", - "jsonrpsee-ws-client", + "jsonrpsee-types 0.21.0", + "jsonrpsee-ws-client 0.21.0", "tokio", "tracing", ] @@ -6799,13 +6841,33 @@ checksum = "b5b005c793122d03217da09af68ba9383363caa950b90d3436106df8cabce935" dependencies = [ "futures-util", "http", - "jsonrpsee-core", + "jsonrpsee-core 0.20.3", "pin-project", - "rustls-native-certs", + "rustls-native-certs 0.6.3", "soketto", "thiserror", "tokio", - "tokio-rustls", + "tokio-rustls 0.24.1", + "tokio-util", + "tracing", + "url", +] + +[[package]] +name = "jsonrpsee-client-transport" +version = "0.21.0" +source = "git+https://github.com/paritytech/jsonrpsee?branch=master#8470f2bb8d2a2b5e3c5cfd07f138aeab9dfbe022" +dependencies = [ + "futures-util", + "http", + "jsonrpsee-core 0.21.0", + "pin-project", + "rustls-native-certs 0.7.0", + "rustls-pki-types", + "soketto", + "thiserror", + "tokio", + "tokio-rustls 0.25.0", "tokio-util", "tracing", "url", @@ -6818,35 +6880,55 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "da2327ba8df2fdbd5e897e2b5ed25ce7f299d345b9736b6828814c3dbd1fd47b" dependencies = [ "anyhow", - "async-lock", + "async-lock 2.8.0", + "async-trait", + "beef", + "futures-timer", + "futures-util", + "jsonrpsee-types 0.20.3", + "rustc-hash", + "serde", + "serde_json", + "thiserror", + "tokio", + "tracing", +] + +[[package]] +name = "jsonrpsee-core" +version = "0.21.0" +source = "git+https://github.com/paritytech/jsonrpsee?branch=master#8470f2bb8d2a2b5e3c5cfd07f138aeab9dfbe022" +dependencies = [ + "anyhow", + "async-lock 3.3.0", "async-trait", "beef", "futures-timer", "futures-util", "hyper", - "jsonrpsee-types", + "jsonrpsee-types 0.21.0", "parking_lot 0.12.1", + "pin-project", "rand", "rustc-hash", "serde", "serde_json", - "soketto", "thiserror", "tokio", + "tokio-stream", "tracing", ] [[package]] name = "jsonrpsee-http-client" -version = "0.20.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f80c17f62c7653ce767e3d7288b793dfec920f97067ceb189ebdd3570f2bc20" +version = "0.21.0" +source = "git+https://github.com/paritytech/jsonrpsee?branch=master#8470f2bb8d2a2b5e3c5cfd07f138aeab9dfbe022" dependencies = [ "async-trait", "hyper", "hyper-rustls", - "jsonrpsee-core", - "jsonrpsee-types", + "jsonrpsee-core 0.21.0", + "jsonrpsee-types 0.21.0", "serde", "serde_json", "thiserror", @@ -6858,12 +6940,11 @@ dependencies = [ [[package]] name = "jsonrpsee-proc-macros" -version = "0.20.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29110019693a4fa2dbda04876499d098fa16d70eba06b1e6e2b3f1b251419515" +version = "0.21.0" +source = "git+https://github.com/paritytech/jsonrpsee?branch=master#8470f2bb8d2a2b5e3c5cfd07f138aeab9dfbe022" dependencies = [ "heck", - "proc-macro-crate 1.3.1", + "proc-macro-crate 3.0.0", "proc-macro2", "quote", "syn 1.0.109", @@ -6871,15 +6952,15 @@ dependencies = [ [[package]] name = "jsonrpsee-server" -version = "0.20.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82c39a00449c9ef3f50b84fc00fc4acba20ef8f559f07902244abf4c15c5ab9c" +version = "0.21.0" +source = "git+https://github.com/paritytech/jsonrpsee?branch=master#8470f2bb8d2a2b5e3c5cfd07f138aeab9dfbe022" dependencies = [ "futures-util", "http", "hyper", - "jsonrpsee-core", - "jsonrpsee-types", + "jsonrpsee-core 0.21.0", + "jsonrpsee-types 0.21.0", + "pin-project", "route-recognizer", "serde", "serde_json", @@ -6906,6 +6987,18 @@ dependencies = [ "tracing", ] +[[package]] +name = "jsonrpsee-types" +version = "0.21.0" +source = "git+https://github.com/paritytech/jsonrpsee?branch=master#8470f2bb8d2a2b5e3c5cfd07f138aeab9dfbe022" +dependencies = [ + "anyhow", + "beef", + "serde", + "serde_json", + "thiserror", +] + [[package]] name = "jsonrpsee-ws-client" version = "0.20.3" @@ -6913,9 +7006,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bca9cb3933ccae417eb6b08c3448eb1cb46e39834e5b503e395e5e5bd08546c0" dependencies = [ "http", - "jsonrpsee-client-transport", - "jsonrpsee-core", - "jsonrpsee-types", + "jsonrpsee-client-transport 0.20.3", + "jsonrpsee-core 0.20.3", + "jsonrpsee-types 0.20.3", + "url", +] + +[[package]] +name = "jsonrpsee-ws-client" +version = "0.21.0" +source = "git+https://github.com/paritytech/jsonrpsee?branch=master#8470f2bb8d2a2b5e3c5cfd07f138aeab9dfbe022" +dependencies = [ + "http", + "jsonrpsee-client-transport 0.21.0", + "jsonrpsee-core 0.21.0", + "jsonrpsee-types 0.21.0", "url", ] @@ -7638,7 +7743,7 @@ checksum = "5be9b9bb642d8522a44d533eab56c16c738301965504753b03ad1de3425d5451" dependencies = [ "crunchy", "digest 0.9.0", - "subtle 2.4.1", + "subtle 2.5.0", ] [[package]] @@ -8051,7 +8156,7 @@ dependencies = [ "frame", "futures", "futures-timer", - "jsonrpsee", + "jsonrpsee 0.21.0", "minimal-runtime", "sc-basic-authorship", "sc-cli", @@ -8135,7 +8240,7 @@ dependencies = [ "rand", "rand_chacha 0.3.1", "rand_distr", - "subtle 2.4.1", + "subtle 2.5.0", "thiserror", "zeroize", ] @@ -8167,7 +8272,7 @@ dependencies = [ name = "mmr-rpc" version = "28.0.0" dependencies = [ - "jsonrpsee", + "jsonrpsee 0.21.0", "parity-scale-codec", "serde", "serde_json", @@ -8553,7 +8658,7 @@ dependencies = [ name = "node-rpc" version = "3.0.0-dev" dependencies = [ - "jsonrpsee", + "jsonrpsee 0.21.0", "mmr-rpc", "node-primitives", "pallet-transaction-payment-rpc", @@ -8601,7 +8706,7 @@ dependencies = [ "frame-benchmarking-cli", "frame-system", "futures", - "jsonrpsee", + "jsonrpsee 0.21.0", "node-template-runtime", "pallet-transaction-payment", "pallet-transaction-payment-rpc", @@ -10932,7 +11037,7 @@ dependencies = [ name = "pallet-transaction-payment-rpc" version = "30.0.0" dependencies = [ - "jsonrpsee", + "jsonrpsee 0.21.0", "pallet-transaction-payment-rpc-runtime-api", "parity-scale-codec", "sp-api", @@ -11197,7 +11302,7 @@ dependencies = [ "frame-benchmarking", "frame-benchmarking-cli", "futures", - "jsonrpsee", + "jsonrpsee 0.21.0", "log", "pallet-transaction-payment-rpc", "parachain-template-runtime", @@ -11520,7 +11625,7 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d95f5254224e617595d2cc3cc73ff0a5eaf2637519e25f03388154e9378b6ffa" dependencies = [ - "crypto-mac 0.11.1", + "crypto-mac 0.11.0", ] [[package]] @@ -12979,7 +13084,7 @@ dependencies = [ "futures", "glutton-westend-runtime", "hex-literal", - "jsonrpsee", + "jsonrpsee 0.21.0", "log", "nix 0.26.2", "pallet-transaction-payment", @@ -13098,7 +13203,7 @@ dependencies = [ name = "polkadot-rpc" version = "7.0.0" dependencies = [ - "jsonrpsee", + "jsonrpsee 0.21.0", "mmr-rpc", "pallet-transaction-payment-rpc", "polkadot-primitives", @@ -13835,7 +13940,7 @@ checksum = "048aeb476be11a4b6ca432ca569e375810de9294ae78f4774e78ea98a9246ede" dependencies = [ "cpufeatures", "opaque-debug 0.3.0", - "universal-hash 0.4.1", + "universal-hash 0.4.0", ] [[package]] @@ -13858,7 +13963,7 @@ dependencies = [ "cfg-if", "cpufeatures", "opaque-debug 0.3.0", - "universal-hash 0.4.1", + "universal-hash 0.4.0", ] [[package]] @@ -14681,12 +14786,12 @@ dependencies = [ "percent-encoding", "pin-project-lite 0.2.12", "rustls 0.21.6", - "rustls-pemfile", + "rustls-pemfile 1.0.3", "serde", "serde_json", "serde_urlencoded", "tokio", - "tokio-rustls", + "tokio-rustls 0.24.1", "tower-service", "url", "wasm-bindgen", @@ -14713,7 +14818,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2" dependencies = [ "hmac 0.12.1", - "subtle 2.4.1", + "subtle 2.5.0", ] [[package]] @@ -15194,10 +15299,24 @@ checksum = "1d1feddffcfcc0b33f5c6ce9a29e341e4cd59c3f78e7ee45f4a40c038b1d6cbb" dependencies = [ "log", "ring 0.16.20", - "rustls-webpki", + "rustls-webpki 0.101.4", "sct", ] +[[package]] +name = "rustls" +version = "0.22.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e87c9956bd9807afa1f77e0f7594af32566e830e088a5576d27c5b6f30f49d41" +dependencies = [ + "log", + "ring 0.17.7", + "rustls-pki-types", + "rustls-webpki 0.102.2", + "subtle 2.5.0", + "zeroize", +] + [[package]] name = "rustls-native-certs" version = "0.6.3" @@ -15205,7 +15324,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a9aace74cb666635c918e9c12bc0d348266037aa8eb599b5cba565709a8dff00" dependencies = [ "openssl-probe", - "rustls-pemfile", + "rustls-pemfile 1.0.3", + "schannel", + "security-framework", +] + +[[package]] +name = "rustls-native-certs" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f1fb85efa936c42c6d5fc28d2629bb51e4b2f4b8a5211e297d599cc5a093792" +dependencies = [ + "openssl-probe", + "rustls-pemfile 2.0.0", + "rustls-pki-types", "schannel", "security-framework", ] @@ -15219,6 +15351,22 @@ dependencies = [ "base64 0.21.2", ] +[[package]] +name = "rustls-pemfile" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35e4980fa29e4c4b212ffb3db068a564cbf560e51d3944b7c88bd8bf5bec64f4" +dependencies = [ + "base64 0.21.2", + "rustls-pki-types", +] + +[[package]] +name = "rustls-pki-types" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a716eb65e3158e90e17cd93d855216e27bde02745ab842f2cab4a39dba1bacf" + [[package]] name = "rustls-webpki" version = "0.101.4" @@ -15229,6 +15377,17 @@ dependencies = [ "untrusted 0.7.1", ] +[[package]] +name = "rustls-webpki" +version = "0.102.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "faaa0a62740bedb9b2ef5afa303da42764c012f743917351dc9a237ea1663610" +dependencies = [ + "ring 0.17.7", + "rustls-pki-types", + "untrusted 0.9.0", +] + [[package]] name = "rustversion" version = "1.0.14" @@ -15638,7 +15797,7 @@ name = "sc-consensus-babe-rpc" version = "0.34.0" dependencies = [ "futures", - "jsonrpsee", + "jsonrpsee 0.21.0", "sc-consensus", "sc-consensus-babe", "sc-consensus-epochs", @@ -15709,7 +15868,7 @@ name = "sc-consensus-beefy-rpc" version = "13.0.0" dependencies = [ "futures", - "jsonrpsee", + "jsonrpsee 0.21.0", "log", "parity-scale-codec", "parking_lot 0.12.1", @@ -15792,7 +15951,7 @@ version = "0.19.0" dependencies = [ "finality-grandpa", "futures", - "jsonrpsee", + "jsonrpsee 0.21.0", "log", "parity-scale-codec", "sc-block-builder", @@ -15818,7 +15977,7 @@ dependencies = [ "async-trait", "futures", "futures-timer", - "jsonrpsee", + "jsonrpsee 0.21.0", "log", "parity-scale-codec", "sc-basic-authorship", @@ -16328,7 +16487,7 @@ dependencies = [ "assert_matches", "env_logger 0.9.3", "futures", - "jsonrpsee", + "jsonrpsee 0.21.0", "log", "parity-scale-codec", "parking_lot 0.12.1", @@ -16367,7 +16526,7 @@ dependencies = [ name = "sc-rpc-api" version = "0.33.0" dependencies = [ - "jsonrpsee", + "jsonrpsee 0.21.0", "parity-scale-codec", "sc-chain-spec", "sc-mixnet", @@ -16386,9 +16545,12 @@ dependencies = [ name = "sc-rpc-server" version = "11.0.0" dependencies = [ + "futures", "http", - "jsonrpsee", + "hyper", + "jsonrpsee 0.21.0", "log", + "pin-project", "serde_json", "substrate-prometheus-endpoint", "tokio", @@ -16405,7 +16567,7 @@ dependencies = [ "futures", "futures-util", "hex", - "jsonrpsee", + "jsonrpsee 0.21.0", "log", "parity-scale-codec", "parking_lot 0.12.1", @@ -16456,7 +16618,7 @@ dependencies = [ "exit-future", "futures", "futures-timer", - "jsonrpsee", + "jsonrpsee 0.21.0", "log", "parity-scale-codec", "parking_lot 0.12.1", @@ -16593,7 +16755,7 @@ dependencies = [ name = "sc-sync-state-rpc" version = "0.34.0" dependencies = [ - "jsonrpsee", + "jsonrpsee 0.21.0", "parity-scale-codec", "sc-chain-spec", "sc-client-api", @@ -16833,7 +16995,7 @@ dependencies = [ "merlin 2.0.1", "rand_core 0.5.1", "sha2 0.8.2", - "subtle 2.4.1", + "subtle 2.5.0", "zeroize", ] @@ -16868,7 +17030,7 @@ dependencies = [ "rand_core 0.6.4", "serde_bytes", "sha2 0.10.7", - "subtle 2.4.1", + "subtle 2.5.0", "zeroize", ] @@ -16910,7 +17072,7 @@ dependencies = [ "der", "generic-array 0.14.7", "pkcs8", - "subtle 2.4.1", + "subtle 2.5.0", "zeroize", ] @@ -17430,7 +17592,7 @@ dependencies = [ "async-executor", "async-fs", "async-io", - "async-lock", + "async-lock 2.8.0", "async-net", "async-process", "blocking", @@ -17453,7 +17615,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0bb30cf57b7b5f6109ce17c3164445e2d6f270af2cb48f6e4d31c2967c9a9f5" dependencies = [ "arrayvec 0.7.4", - "async-lock", + "async-lock 2.8.0", "atomic-take", "base64 0.21.2", "bip39", @@ -17464,7 +17626,7 @@ dependencies = [ "derive_more", "ed25519-zebra 4.0.3", "either", - "event-listener", + "event-listener 2.5.3", "fnv", "futures-lite", "futures-util", @@ -17507,12 +17669,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "256b5bad1d6b49045e95fe87492ce73d5af81545d8b4d8318a872d2007024c33" dependencies = [ "async-channel", - "async-lock", + "async-lock 2.8.0", "base64 0.21.2", "blake2-rfc", "derive_more", "either", - "event-listener", + "event-listener 2.5.3", "fnv", "futures-channel", "futures-lite", @@ -17548,7 +17710,7 @@ version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c9d1425eb528a21de2755c75af4c9b5d57f50a0d4c3b7f1828a4cd03f8ba155" dependencies = [ - "aes-gcm 0.9.4", + "aes-gcm 0.9.2", "blake2 0.10.6", "chacha20poly1305", "curve25519-dalek 4.1.1", @@ -17556,7 +17718,7 @@ dependencies = [ "ring 0.16.20", "rustc_version 0.4.0", "sha2 0.10.7", - "subtle 2.4.1", + "subtle 2.5.0", ] [[package]] @@ -19152,7 +19314,7 @@ dependencies = [ "frame-system", "frame-system-rpc-runtime-api", "futures", - "jsonrpsee", + "jsonrpsee 0.21.0", "kitchensink-runtime", "log", "mmr-gadget", @@ -19397,7 +19559,7 @@ dependencies = [ "bitflags 1.3.2", "byteorder", "keccak", - "subtle 2.4.1", + "subtle 2.5.0", "zeroize", ] @@ -19508,7 +19670,7 @@ version = "29.0.0" dependencies = [ "frame-support", "frame-system", - "jsonrpsee", + "jsonrpsee 0.21.0", "parity-scale-codec", "sc-rpc-api", "scale-info", @@ -19526,7 +19688,7 @@ dependencies = [ "assert_matches", "frame-system-rpc-runtime-api", "futures", - "jsonrpsee", + "jsonrpsee 0.21.0", "log", "parity-scale-codec", "sc-rpc-api", @@ -19558,7 +19720,7 @@ name = "substrate-rpc-client" version = "0.33.0" dependencies = [ "async-trait", - "jsonrpsee", + "jsonrpsee 0.21.0", "log", "sc-rpc-api", "serde", @@ -19571,7 +19733,7 @@ dependencies = [ name = "substrate-state-trie-migration-rpc" version = "27.0.0" dependencies = [ - "jsonrpsee", + "jsonrpsee 0.21.0", "parity-scale-codec", "sc-client-api", "sc-rpc-api", @@ -19729,9 +19891,9 @@ checksum = "2d67a5a62ba6e01cb2192ff309324cb4875d0c451d55fe2319433abe7a05a8ee" [[package]] name = "subtle" -version = "2.4.1" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" +checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" [[package]] name = "subtle-ng" @@ -20311,6 +20473,17 @@ dependencies = [ "tokio", ] +[[package]] +name = "tokio-rustls" +version = "0.25.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "775e0c0f0adb3a2f22a00c4745d728b479985fc15ee7ca6a2608388c5569860f" +dependencies = [ + "rustls 0.22.2", + "rustls-pki-types", + "tokio", +] + [[package]] name = "tokio-stream" version = "0.1.14" @@ -20860,12 +21033,12 @@ checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" [[package]] name = "universal-hash" -version = "0.4.1" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f214e8f697e925001e66ec2c6e37a4ef93f0f78c2eed7814394e10c62025b05" +checksum = "8326b2c654932e3e4f9196e69d08fdf7cfd718e1dc6f66b347e6024a0c961402" dependencies = [ "generic-array 0.14.7", - "subtle 2.4.1", + "subtle 2.5.0", ] [[package]] @@ -20875,7 +21048,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fc1de2c688dc15305988b563c3854064043356019f97a4b46276fe734c4f07ea" dependencies = [ "crypto-common", - "subtle 2.4.1", + "subtle 2.5.0", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index e807171b24c46..ebfcf5ca7f0f3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -610,3 +610,8 @@ wasmi = { opt-level = 3 } x25519-dalek = { opt-level = 3 } yamux = { opt-level = 3 } zeroize = { opt-level = 3 } + +[patch.crates-io] +jsonrpsee = { git = "https://github.com/paritytech/jsonrpsee", branch = "master" } +jsonrpsee-core = { git = "https://github.com/paritytech/jsonrpsee", branch = "master" } + diff --git a/cumulus/client/relay-chain-interface/Cargo.toml b/cumulus/client/relay-chain-interface/Cargo.toml index 004d30f7f94f7..3346de8b5ee4c 100644 --- a/cumulus/client/relay-chain-interface/Cargo.toml +++ b/cumulus/client/relay-chain-interface/Cargo.toml @@ -22,5 +22,5 @@ sc-client-api = { path = "../../../substrate/client/api" } futures = "0.3.28" async-trait = "0.1.74" thiserror = "1.0.48" -jsonrpsee-core = "0.20.3" +jsonrpsee-core = "0.21" parity-scale-codec = "3.6.4" diff --git a/cumulus/client/relay-chain-interface/src/lib.rs b/cumulus/client/relay-chain-interface/src/lib.rs index 3dda61635804d..de5e7891b30da 100644 --- a/cumulus/client/relay-chain-interface/src/lib.rs +++ b/cumulus/client/relay-chain-interface/src/lib.rs @@ -22,7 +22,7 @@ use sc_client_api::StorageProof; use futures::Stream; use async_trait::async_trait; -use jsonrpsee_core::Error as JsonRpcError; +use jsonrpsee_core::ClientError as JsonRpcError; use parity_scale_codec::Error as CodecError; use sp_api::ApiError; diff --git a/cumulus/client/relay-chain-rpc-interface/src/light_client_worker.rs b/cumulus/client/relay-chain-rpc-interface/src/light_client_worker.rs index 6fd057e170b71..9a49b60281b3c 100644 --- a/cumulus/client/relay-chain-rpc-interface/src/light_client_worker.rs +++ b/cumulus/client/relay-chain-rpc-interface/src/light_client_worker.rs @@ -19,12 +19,9 @@ //! we treat the light-client as a normal JsonRPC target. use futures::{channel::mpsc::Sender, prelude::*, stream::FuturesUnordered}; -use jsonrpsee::core::{ - client::{ - Client as JsonRpseeClient, ClientBuilder, ClientT, ReceivedMessage, TransportReceiverT, - TransportSenderT, - }, - Error, +use jsonrpsee::core::client::{ + Client as JsonRpseeClient, ClientBuilder, ClientT, Error, ReceivedMessage, TransportReceiverT, + TransportSenderT, }; use smoldot_light::{ChainId, Client as SmoldotClient, JsonRpcResponses}; use std::{num::NonZeroU32, sync::Arc}; diff --git a/cumulus/client/relay-chain-rpc-interface/src/reconnecting_ws_client.rs b/cumulus/client/relay-chain-rpc-interface/src/reconnecting_ws_client.rs index 322bcc93dae6d..b716feef1c998 100644 --- a/cumulus/client/relay-chain-rpc-interface/src/reconnecting_ws_client.rs +++ b/cumulus/client/relay-chain-rpc-interface/src/reconnecting_ws_client.rs @@ -27,7 +27,7 @@ use jsonrpsee::{ core::{ client::{Client as JsonRpcClient, ClientT, Subscription}, params::ArrayParams, - Error as JsonRpseeError, JsonValue, + ClientError as JsonRpseeError, JsonValue, }, ws_client::WsClientBuilder, }; diff --git a/cumulus/client/relay-chain-rpc-interface/src/rpc_client.rs b/cumulus/client/relay-chain-rpc-interface/src/rpc_client.rs index c64fff77a29fd..a912997e947d1 100644 --- a/cumulus/client/relay-chain-rpc-interface/src/rpc_client.rs +++ b/cumulus/client/relay-chain-rpc-interface/src/rpc_client.rs @@ -19,7 +19,7 @@ use futures::channel::{ oneshot::Sender as OneshotSender, }; use jsonrpsee::{ - core::{params::ArrayParams, Error as JsonRpseeError}, + core::{params::ArrayParams, ClientError as JsonRpseeError}, rpc_params, }; use serde::de::DeserializeOwned; diff --git a/cumulus/parachain-template/node/Cargo.toml b/cumulus/parachain-template/node/Cargo.toml index c66c96056b956..28d22379e54a2 100644 --- a/cumulus/parachain-template/node/Cargo.toml +++ b/cumulus/parachain-template/node/Cargo.toml @@ -18,7 +18,7 @@ clap = { version = "4.4.18", features = ["derive"] } log = "0.4.20" codec = { package = "parity-scale-codec", version = "3.0.0" } serde = { version = "1.0.195", features = ["derive"] } -jsonrpsee = { version = "0.20.3", features = ["server"] } +jsonrpsee = { version = "0.21", features = ["server"] } futures = "0.3.28" serde_json = "1.0.111" diff --git a/cumulus/polkadot-parachain/Cargo.toml b/cumulus/polkadot-parachain/Cargo.toml index cc0bd47cc7733..0d55b54adfcea 100644 --- a/cumulus/polkadot-parachain/Cargo.toml +++ b/cumulus/polkadot-parachain/Cargo.toml @@ -38,7 +38,7 @@ coretime-rococo-runtime = { path = "../parachains/runtimes/coretime/coretime-roc coretime-westend-runtime = { path = "../parachains/runtimes/coretime/coretime-westend" } bridge-hub-westend-runtime = { path = "../parachains/runtimes/bridge-hubs/bridge-hub-westend" } penpal-runtime = { path = "../parachains/runtimes/testing/penpal" } -jsonrpsee = { version = "0.20.3", features = ["server"] } +jsonrpsee = { version = "0.21", features = ["server"] } people-rococo-runtime = { path = "../parachains/runtimes/people/people-rococo" } people-westend-runtime = { path = "../parachains/runtimes/people/people-westend" } parachains-common = { path = "../parachains/common" } diff --git a/cumulus/test/service/Cargo.toml b/cumulus/test/service/Cargo.toml index c17cdf35419a2..bf5aab2126f18 100644 --- a/cumulus/test/service/Cargo.toml +++ b/cumulus/test/service/Cargo.toml @@ -17,7 +17,7 @@ async-trait = "0.1.74" clap = { version = "4.4.18", features = ["derive"] } codec = { package = "parity-scale-codec", version = "3.0.0" } criterion = { version = "0.5.1", features = ["async_tokio"] } -jsonrpsee = { version = "0.20.3", features = ["server"] } +jsonrpsee = { version = "0.21", features = ["server"] } rand = "0.8.5" serde = { version = "1.0.195", features = ["derive"] } serde_json = "1.0.111" diff --git a/polkadot/rpc/Cargo.toml b/polkadot/rpc/Cargo.toml index 98ce2e482ce1a..a4677e10fc2f7 100644 --- a/polkadot/rpc/Cargo.toml +++ b/polkadot/rpc/Cargo.toml @@ -10,7 +10,7 @@ description = "Polkadot specific RPC functionality." workspace = true [dependencies] -jsonrpsee = { version = "0.20.3", features = ["server"] } +jsonrpsee = { version = "0.21", features = ["server"] } polkadot-primitives = { path = "../primitives" } sc-client-api = { path = "../../substrate/client/api" } sp-blockchain = { path = "../../substrate/primitives/blockchain" } diff --git a/substrate/bin/minimal/node/Cargo.toml b/substrate/bin/minimal/node/Cargo.toml index 34476a72954dd..97a2f01562aef 100644 --- a/substrate/bin/minimal/node/Cargo.toml +++ b/substrate/bin/minimal/node/Cargo.toml @@ -23,7 +23,7 @@ name = "minimal-node" clap = { version = "4.4.18", features = ["derive"] } futures = { version = "0.3.21", features = ["thread-pool"] } futures-timer = "3.0.1" -jsonrpsee = { version = "0.20.3", features = ["server"] } +jsonrpsee = { version = "0.21", features = ["server"] } serde_json = "1.0.111" sc-cli = { path = "../../../client/cli" } diff --git a/substrate/bin/node-template/node/Cargo.toml b/substrate/bin/node-template/node/Cargo.toml index da601a665e9c3..797470440def0 100644 --- a/substrate/bin/node-template/node/Cargo.toml +++ b/substrate/bin/node-template/node/Cargo.toml @@ -48,7 +48,7 @@ frame-system = { path = "../../../frame/system" } pallet-transaction-payment = { path = "../../../frame/transaction-payment", default-features = false } # These dependencies are used for the node template's RPCs -jsonrpsee = { version = "0.20.3", features = ["server"] } +jsonrpsee = { version = "0.21", features = ["server"] } sp-api = { path = "../../../primitives/api" } sc-rpc-api = { path = "../../../client/rpc-api" } sp-blockchain = { path = "../../../primitives/blockchain" } diff --git a/substrate/bin/node/cli/Cargo.toml b/substrate/bin/node/cli/Cargo.toml index 5dfe915b789d5..375bd06a7c890 100644 --- a/substrate/bin/node/cli/Cargo.toml +++ b/substrate/bin/node/cli/Cargo.toml @@ -44,7 +44,7 @@ array-bytes = "6.1" clap = { version = "4.4.18", features = ["derive"], optional = true } codec = { package = "parity-scale-codec", version = "3.6.1" } serde = { version = "1.0.195", features = ["derive"] } -jsonrpsee = { version = "0.20.3", features = ["server"] } +jsonrpsee = { version = "0.21", features = ["server"] } futures = "0.3.21" log = "0.4.17" rand = "0.8" diff --git a/substrate/bin/node/rpc/Cargo.toml b/substrate/bin/node/rpc/Cargo.toml index 63a30965a1606..92684e02fd193 100644 --- a/substrate/bin/node/rpc/Cargo.toml +++ b/substrate/bin/node/rpc/Cargo.toml @@ -16,7 +16,7 @@ workspace = true targets = ["x86_64-unknown-linux-gnu"] [dependencies] -jsonrpsee = { version = "0.20.3", features = ["server"] } +jsonrpsee = { version = "0.21", features = ["server"] } node-primitives = { path = "../primitives" } pallet-transaction-payment-rpc = { path = "../../../frame/transaction-payment/rpc" } mmr-rpc = { path = "../../../client/merkle-mountain-range/rpc" } diff --git a/substrate/client/consensus/babe/rpc/Cargo.toml b/substrate/client/consensus/babe/rpc/Cargo.toml index 2ca029444d078..0c572b5d316ca 100644 --- a/substrate/client/consensus/babe/rpc/Cargo.toml +++ b/substrate/client/consensus/babe/rpc/Cargo.toml @@ -16,7 +16,7 @@ workspace = true targets = ["x86_64-unknown-linux-gnu"] [dependencies] -jsonrpsee = { version = "0.20.3", features = ["client-core", "macros", "server"] } +jsonrpsee = { version = "0.21", features = ["client-core", "server", "macros"] } futures = "0.3.21" serde = { version = "1.0.195", features = ["derive"] } thiserror = "1.0" diff --git a/substrate/client/consensus/beefy/rpc/Cargo.toml b/substrate/client/consensus/beefy/rpc/Cargo.toml index 496aefac113ae..adbcc5d4be6a2 100644 --- a/substrate/client/consensus/beefy/rpc/Cargo.toml +++ b/substrate/client/consensus/beefy/rpc/Cargo.toml @@ -14,7 +14,7 @@ workspace = true [dependencies] codec = { package = "parity-scale-codec", version = "3.6.1", features = ["derive"] } futures = "0.3.21" -jsonrpsee = { version = "0.20.3", features = ["client-core", "macros", "server"] } +jsonrpsee = { version = "0.21", features = ["client-core", "server", "macros"] } log = "0.4" parking_lot = "0.12.1" serde = { version = "1.0.195", features = ["derive"] } diff --git a/substrate/client/consensus/grandpa/rpc/Cargo.toml b/substrate/client/consensus/grandpa/rpc/Cargo.toml index ae9ab5d9d0794..6b6ac2c927f6d 100644 --- a/substrate/client/consensus/grandpa/rpc/Cargo.toml +++ b/substrate/client/consensus/grandpa/rpc/Cargo.toml @@ -15,7 +15,7 @@ workspace = true [dependencies] finality-grandpa = { version = "0.16.2", features = ["derive-codec"] } futures = "0.3.16" -jsonrpsee = { version = "0.20.3", features = ["client-core", "macros", "server"] } +jsonrpsee = { version = "0.21", features = ["client-core", "server", "macros"] } log = "0.4.8" parity-scale-codec = { version = "3.6.1", features = ["derive"] } serde = { version = "1.0.195", features = ["derive"] } diff --git a/substrate/client/consensus/manual-seal/Cargo.toml b/substrate/client/consensus/manual-seal/Cargo.toml index 0094fb8780095..cbe615968e0a9 100644 --- a/substrate/client/consensus/manual-seal/Cargo.toml +++ b/substrate/client/consensus/manual-seal/Cargo.toml @@ -16,7 +16,7 @@ workspace = true targets = ["x86_64-unknown-linux-gnu"] [dependencies] -jsonrpsee = { version = "0.20.3", features = ["client-core", "macros", "server"] } +jsonrpsee = { version = "0.21", features = ["client-core", "server", "macros"] } assert_matches = "1.3.0" async-trait = "0.1.74" codec = { package = "parity-scale-codec", version = "3.6.1" } diff --git a/substrate/client/merkle-mountain-range/rpc/Cargo.toml b/substrate/client/merkle-mountain-range/rpc/Cargo.toml index 99467e5468f07..41fa59de00284 100644 --- a/substrate/client/merkle-mountain-range/rpc/Cargo.toml +++ b/substrate/client/merkle-mountain-range/rpc/Cargo.toml @@ -16,7 +16,7 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] codec = { package = "parity-scale-codec", version = "3.6.1" } -jsonrpsee = { version = "0.20.3", features = ["client-core", "macros", "server"] } +jsonrpsee = { version = "0.21", features = ["client-core", "macros", "server"] } serde = { version = "1.0.195", features = ["derive"] } sp-api = { path = "../../../primitives/api" } sp-blockchain = { path = "../../../primitives/blockchain" } diff --git a/substrate/client/rpc-api/Cargo.toml b/substrate/client/rpc-api/Cargo.toml index 8e781151ba8d8..e05f5dc3c0271 100644 --- a/substrate/client/rpc-api/Cargo.toml +++ b/substrate/client/rpc-api/Cargo.toml @@ -28,4 +28,4 @@ sp-core = { path = "../../primitives/core" } sp-rpc = { path = "../../primitives/rpc" } sp-runtime = { path = "../../primitives/runtime" } sp-version = { path = "../../primitives/version" } -jsonrpsee = { version = "0.20.3", features = ["client-core", "macros", "server"] } +jsonrpsee = { version = "0.21", features = ["client-core", "macros", "server"] } diff --git a/substrate/client/rpc-servers/Cargo.toml b/substrate/client/rpc-servers/Cargo.toml index b624a14e263ad..0b7a23394b0c5 100644 --- a/substrate/client/rpc-servers/Cargo.toml +++ b/substrate/client/rpc-servers/Cargo.toml @@ -16,7 +16,7 @@ workspace = true targets = ["x86_64-unknown-linux-gnu"] [dependencies] -jsonrpsee = { version = "0.20.3", features = ["server"] } +jsonrpsee = { version = "0.21", features = ["server"] } log = "0.4.17" serde_json = "1.0.111" tokio = { version = "1.22.0", features = ["parking_lot"] } @@ -24,3 +24,6 @@ prometheus-endpoint = { package = "substrate-prometheus-endpoint", path = "../.. tower-http = { version = "0.4.0", features = ["cors"] } tower = { version = "0.4.13", features = ["util"] } http = "0.2.8" +hyper = "0.14.27" +futures = "0.3.29" +pin-project = "1.1.3" diff --git a/substrate/client/rpc-servers/src/lib.rs b/substrate/client/rpc-servers/src/lib.rs index 5d8da190f6277..ccc759736245a 100644 --- a/substrate/client/rpc-servers/src/lib.rs +++ b/substrate/client/rpc-servers/src/lib.rs @@ -22,21 +22,33 @@ pub mod middleware; -use std::{error::Error as StdError, net::SocketAddr, time::Duration}; +use std::{convert::Infallible, error::Error as StdError, net::SocketAddr, time::Duration}; +use futures::FutureExt; use http::header::HeaderValue; +use hyper::{ + server::conn::AddrStream, + service::{make_service_fn, service_fn}, +}; use jsonrpsee::{ - server::middleware::{HostFilterLayer, ProxyGetRequestLayer}, + server::{ + middleware::{ + http::{HostFilterLayer, ProxyGetRequestLayer}, + rpc::RpcServiceBuilder, + }, + stop_channel, ws, PingConfig, + }, RpcModule, }; use tokio::net::TcpListener; +use tower::Service; use tower_http::cors::{AllowOrigin, CorsLayer}; -pub use crate::middleware::RpcMetrics; pub use jsonrpsee::core::{ id_providers::{RandomIntegerIdProvider, RandomStringIdProvider}, traits::IdProvider, }; +pub use middleware::{MetricsLayer, RpcMetrics}; const MEGABYTE: u32 = 1024 * 1024; @@ -92,7 +104,7 @@ pub async fn start_server( let local_addr = std_listener.local_addr().ok(); let host_filter = hosts_filtering(cors.is_some(), local_addr); - let middleware = tower::ServiceBuilder::new() + let http_middleware = tower::ServiceBuilder::new() .option_layer(host_filter) // Proxy `GET /health` requests to internal `system_health` method. .layer(ProxyGetRequestLayer::new("/health", "system_health")?) @@ -103,10 +115,14 @@ pub async fn start_server( .max_response_body_size(max_payload_out_mb.saturating_mul(MEGABYTE)) .max_connections(max_connections) .max_subscriptions_per_connection(max_subs_per_conn) - .ping_interval(Duration::from_secs(30)) - .set_middleware(middleware) + .enable_ws_ping( + PingConfig::new() + .ping_interval(Duration::from_secs(30)) + .inactive_limit(Duration::from_secs(50)), + ) + .set_http_middleware(http_middleware) .set_message_buffer_capacity(message_buffer_capacity) - .custom_tokio_runtime(tokio_handle); + .custom_tokio_runtime(tokio_handle.clone()); if let Some(provider) = id_provider { builder = builder.set_id_provider(provider); @@ -114,14 +130,71 @@ pub async fn start_server( builder = builder.set_id_provider(RandomStringIdProvider::new(16)); }; - let rpc_api = build_rpc_api(rpc_api); - let handle = if let Some(metrics) = metrics { - let server = builder.set_logger(metrics).build_from_tcp(std_listener)?; - server.start(rpc_api) - } else { - let server = builder.build_from_tcp(std_listener)?; - server.start(rpc_api) - }; + let methods = build_rpc_api(rpc_api); + let svc_builder = builder.to_service_builder().max_connections(max_connections); + + let (stop_handle, server_handle) = stop_channel(); + let stop_handle2 = stop_handle.clone(); + let methods = methods.clone(); + let metrics = metrics.clone(); + let tokio_handle = tokio_handle.clone(); + + let make_service = make_service_fn(move |_conn: &AddrStream| { + let stop_handle = stop_handle2.clone(); + let svc_builder = svc_builder.clone(); + let metrics = metrics.clone(); + let methods = methods.clone(); + let tokio_handle = tokio_handle.clone(); + + async move { + let stop_handle = stop_handle.clone(); + let svc_builder = svc_builder.clone(); + let stop_handle = stop_handle.clone(); + let tokio_handle = tokio_handle.clone(); + let metrics = metrics.clone(); + + Ok::<_, Infallible>(service_fn(move |req| { + let metrics = metrics.clone(); + let svc_builder = svc_builder.clone(); + let tokio_handle = tokio_handle.clone(); + + let is_websocket = ws::is_upgrade_request(&req); + let transport_label = if is_websocket { "ws" } else { "http" }; + + let metrics = metrics.map(|m| MetricsLayer::new(m, transport_label)); + let rpc_middleware = RpcServiceBuilder::new().option_layer(metrics.clone()); + let mut svc = svc_builder + .set_rpc_middleware(rpc_middleware) + .build(methods.clone(), stop_handle.clone()); + + async move { + if is_websocket { + let on_disconnect = svc.on_session_closed(); + + // Spawn a task to handle when the connection is closed. + tokio_handle.spawn(async move { + let now = std::time::Instant::now(); + metrics.as_ref().map(|m| m.ws_connect()); + on_disconnect.await; + metrics.as_ref().map(|m| m.ws_disconnect(now)); + }); + + svc.call(req).await + } else { + svc.call(req).await + } + } + .boxed() + })) + } + }); + + let server = hyper::Server::from_tcp(std_listener)?.serve(make_service); + + tokio::spawn(async move { + let graceful = server.with_graceful_shutdown(async move { stop_handle.shutdown().await }); + graceful.await.unwrap() + }); log::info!( "Running JSON-RPC server: addr={}, allowed origins={}", @@ -129,7 +202,7 @@ pub async fn start_server( format_cors(cors) ); - Ok(handle) + Ok(server_handle) } fn hosts_filtering(enabled: bool, addr: Option) -> Option { diff --git a/substrate/client/rpc-servers/src/middleware.rs b/substrate/client/rpc-servers/src/middleware.rs deleted file mode 100644 index fabb64eafa797..0000000000000 --- a/substrate/client/rpc-servers/src/middleware.rs +++ /dev/null @@ -1,226 +0,0 @@ -// This file is part of Substrate. - -// Copyright (C) Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0 - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -//! RPC middleware to collect prometheus metrics on RPC calls. - -use jsonrpsee::server::logger::{ - HttpRequest, Logger, MethodKind, Params, SuccessOrError, TransportProtocol, -}; -use prometheus_endpoint::{ - register, Counter, CounterVec, HistogramOpts, HistogramVec, Opts, PrometheusError, Registry, - U64, -}; -use std::net::SocketAddr; - -/// Histogram time buckets in microseconds. -const HISTOGRAM_BUCKETS: [f64; 11] = [ - 5.0, - 25.0, - 100.0, - 500.0, - 1_000.0, - 2_500.0, - 10_000.0, - 25_000.0, - 100_000.0, - 1_000_000.0, - 10_000_000.0, -]; - -/// Metrics for RPC middleware storing information about the number of requests started/completed, -/// calls started/completed and their timings. -#[derive(Debug, Clone)] -pub struct RpcMetrics { - /// Number of RPC requests received since the server started. - requests_started: CounterVec, - /// Number of RPC requests completed since the server started. - requests_finished: CounterVec, - /// Histogram over RPC execution times. - calls_time: HistogramVec, - /// Number of calls started. - calls_started: CounterVec, - /// Number of calls completed. - calls_finished: CounterVec, - /// Number of Websocket sessions opened. - ws_sessions_opened: Option>, - /// Number of Websocket sessions closed. - ws_sessions_closed: Option>, -} - -impl RpcMetrics { - /// Create an instance of metrics - pub fn new(metrics_registry: Option<&Registry>) -> Result, PrometheusError> { - if let Some(metrics_registry) = metrics_registry { - Ok(Some(Self { - requests_started: register( - CounterVec::new( - Opts::new( - "substrate_rpc_requests_started", - "Number of RPC requests (not calls) received by the server.", - ), - &["protocol"], - )?, - metrics_registry, - )?, - requests_finished: register( - CounterVec::new( - Opts::new( - "substrate_rpc_requests_finished", - "Number of RPC requests (not calls) processed by the server.", - ), - &["protocol"], - )?, - metrics_registry, - )?, - calls_time: register( - HistogramVec::new( - HistogramOpts::new( - "substrate_rpc_calls_time", - "Total time [μs] of processed RPC calls", - ) - .buckets(HISTOGRAM_BUCKETS.to_vec()), - &["protocol", "method"], - )?, - metrics_registry, - )?, - calls_started: register( - CounterVec::new( - Opts::new( - "substrate_rpc_calls_started", - "Number of received RPC calls (unique un-batched requests)", - ), - &["protocol", "method"], - )?, - metrics_registry, - )?, - calls_finished: register( - CounterVec::new( - Opts::new( - "substrate_rpc_calls_finished", - "Number of processed RPC calls (unique un-batched requests)", - ), - &["protocol", "method", "is_error"], - )?, - metrics_registry, - )?, - ws_sessions_opened: register( - Counter::new( - "substrate_rpc_sessions_opened", - "Number of persistent RPC sessions opened", - )?, - metrics_registry, - )? - .into(), - ws_sessions_closed: register( - Counter::new( - "substrate_rpc_sessions_closed", - "Number of persistent RPC sessions closed", - )?, - metrics_registry, - )? - .into(), - })) - } else { - Ok(None) - } - } -} - -impl Logger for RpcMetrics { - type Instant = std::time::Instant; - - fn on_connect( - &self, - _remote_addr: SocketAddr, - _request: &HttpRequest, - transport: TransportProtocol, - ) { - if let TransportProtocol::WebSocket = transport { - self.ws_sessions_opened.as_ref().map(|counter| counter.inc()); - } - } - - fn on_request(&self, transport: TransportProtocol) -> Self::Instant { - let transport_label = transport_label_str(transport); - let now = std::time::Instant::now(); - self.requests_started.with_label_values(&[transport_label]).inc(); - now - } - - fn on_call(&self, name: &str, params: Params, kind: MethodKind, transport: TransportProtocol) { - let transport_label = transport_label_str(transport); - log::trace!( - target: "rpc_metrics", - "[{}] on_call name={} params={:?} kind={}", - transport_label, - name, - params, - kind, - ); - self.calls_started.with_label_values(&[transport_label, name]).inc(); - } - - fn on_result( - &self, - name: &str, - success_or_error: SuccessOrError, - started_at: Self::Instant, - transport: TransportProtocol, - ) { - let transport_label = transport_label_str(transport); - let micros = started_at.elapsed().as_micros(); - log::debug!( - target: "rpc_metrics", - "[{}] {} call took {} μs", - transport_label, - name, - micros, - ); - self.calls_time.with_label_values(&[transport_label, name]).observe(micros as _); - - self.calls_finished - .with_label_values(&[ - transport_label, - name, - // the label "is_error", so `success` should be regarded as false - // and vice-versa to be registrered correctly. - if success_or_error.is_success() { "false" } else { "true" }, - ]) - .inc(); - } - - fn on_response(&self, result: &str, started_at: Self::Instant, transport: TransportProtocol) { - let transport_label = transport_label_str(transport); - log::trace!(target: "rpc_metrics", "[{}] on_response started_at={:?}", transport_label, started_at); - log::trace!(target: "rpc_metrics::extra", "[{}] result={:?}", transport_label, result); - self.requests_finished.with_label_values(&[transport_label]).inc(); - } - - fn on_disconnect(&self, _remote_addr: SocketAddr, transport: TransportProtocol) { - if let TransportProtocol::WebSocket = transport { - self.ws_sessions_closed.as_ref().map(|counter| counter.inc()); - } - } -} - -fn transport_label_str(t: TransportProtocol) -> &'static str { - match t { - TransportProtocol::Http => "http", - TransportProtocol::WebSocket => "ws", - } -} diff --git a/substrate/client/rpc-servers/src/middleware/metrics.rs b/substrate/client/rpc-servers/src/middleware/metrics.rs new file mode 100644 index 0000000000000..541a36216cf56 --- /dev/null +++ b/substrate/client/rpc-servers/src/middleware/metrics.rs @@ -0,0 +1,283 @@ +// This file is part of Substrate. + +// Copyright (C) Parity Technologies (UK) Ltd. +// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0 + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +//! RPC middleware to collect prometheus metrics on RPC calls. + +use std::{ + future::Future, + pin::Pin, + task::{Context, Poll}, + time::Instant, +}; + +use jsonrpsee::{ + server::middleware::rpc::RpcServiceT, types::Request, MethodResponse, +}; +use pin_project::pin_project; +use prometheus_endpoint::{ + register, Counter, CounterVec, HistogramOpts, HistogramVec, Opts, PrometheusError, Registry, + U64, +}; + +/// Histogram time buckets in microseconds. +const HISTOGRAM_BUCKETS: [f64; 11] = [ + 5.0, + 25.0, + 100.0, + 500.0, + 1_000.0, + 2_500.0, + 10_000.0, + 25_000.0, + 100_000.0, + 1_000_000.0, + 10_000_000.0, +]; + +/// Metrics for RPC middleware storing information about the number of requests started/completed, +/// calls started/completed and their timings. +#[derive(Debug, Clone)] +pub struct RpcMetrics { + /// Histogram over RPC execution times. + calls_time: HistogramVec, + /// Number of calls started. + calls_started: CounterVec, + /// Number of calls completed. + calls_finished: CounterVec, + /// Number of Websocket sessions opened. + ws_sessions_opened: Option>, + /// Number of Websocket sessions closed. + ws_sessions_closed: Option>, + /// Histogram over RPC websocket sessions. + ws_sessions_time: HistogramVec, +} + +impl RpcMetrics { + /// Create an instance of metrics + pub fn new(metrics_registry: Option<&Registry>) -> Result, PrometheusError> { + if let Some(metrics_registry) = metrics_registry { + Ok(Some(Self { + calls_time: register( + HistogramVec::new( + HistogramOpts::new( + "substrate_rpc_calls_time", + "Total time [μs] of processed RPC calls", + ) + .buckets(HISTOGRAM_BUCKETS.to_vec()), + &["protocol", "method"], + )?, + metrics_registry, + )?, + calls_started: register( + CounterVec::new( + Opts::new( + "substrate_rpc_calls_started", + "Number of received RPC calls (unique un-batched requests)", + ), + &["protocol", "method"], + )?, + metrics_registry, + )?, + calls_finished: register( + CounterVec::new( + Opts::new( + "substrate_rpc_calls_finished", + "Number of processed RPC calls (unique un-batched requests)", + ), + &["protocol", "method", "is_error"], + )?, + metrics_registry, + )?, + ws_sessions_opened: register( + Counter::new( + "substrate_rpc_sessions_opened", + "Number of persistent RPC sessions opened", + )?, + metrics_registry, + )? + .into(), + ws_sessions_closed: register( + Counter::new( + "substrate_rpc_sessions_closed", + "Number of persistent RPC sessions closed", + )?, + metrics_registry, + )? + .into(), + ws_sessions_time: register( + HistogramVec::new( + HistogramOpts::new( + "substrate_rpc_sessions_time", + "Time [s] for each websocket session", + ) + .buckets(HISTOGRAM_BUCKETS.to_vec()), + &["protocol"], + )?, + metrics_registry, + )?, + })) + } else { + Ok(None) + } + } + + pub(crate) fn ws_connect(&self) { + self.ws_sessions_opened.as_ref().map(|counter| counter.inc()); + } + + pub(crate) fn ws_disconnect(&self, now: Instant) { + let micros = now.elapsed().as_secs(); + + self.ws_sessions_closed.as_ref().map(|counter| counter.inc()); + self.ws_sessions_time.with_label_values(&["ws"]).observe(micros as _); + } +} + +/// Metrics layer. +#[derive(Clone)] +pub struct MetricsLayer { + inner: RpcMetrics, + transport_label: &'static str, +} + +impl MetricsLayer { + /// Create a new [`MetricsLayer`]. + pub fn new(metrics: RpcMetrics, transport_label: &'static str) -> Self { + Self { inner: metrics, transport_label } + } + + pub(crate) fn ws_connect(&self) { + self.inner.ws_connect(); + } + + pub(crate) fn ws_disconnect(&self, now: Instant) { + self.inner.ws_disconnect(now) + } +} + +impl tower::Layer for MetricsLayer { + type Service = Metrics; + + fn layer(&self, inner: S) -> Self::Service { + Metrics::new(inner, self.inner.clone(), self.transport_label) + } +} + +/// Metrics middleware. +#[derive(Clone)] +pub struct Metrics { + service: S, + metrics: RpcMetrics, + transport_label: &'static str, +} + +impl Metrics { + /// Create a new metrics middleware. + pub fn new(service: S, metrics: RpcMetrics, transport_label: &'static str) -> Metrics { + Metrics { service, metrics, transport_label } + } +} + +impl<'a, S> RpcServiceT<'a> for Metrics +where + S: Send + Sync + RpcServiceT<'a>, +{ + type Future = ResponseFuture<'a, S::Future>; + + fn call(&self, req: Request<'a>) -> Self::Future { + let now = Instant::now(); + + log::trace!( + target: "rpc_metrics", + "[{}] on_call name={} params={:?}", + self.transport_label, + req.method_name(), + req.params(), + ); + self.metrics + .calls_started + .with_label_values(&[self.transport_label, req.method_name()]) + .inc(); + + ResponseFuture { + fut: self.service.call(req.clone()), + metrics: self.metrics.clone(), + req, + now, + transport_label: self.transport_label, + } + } +} + +/// Response future for metrics. +#[pin_project] +pub struct ResponseFuture<'a, F> { + #[pin] + fut: F, + metrics: RpcMetrics, + req: Request<'a>, + now: Instant, + transport_label: &'static str, +} + +impl<'a, F> std::fmt::Debug for ResponseFuture<'a, F> { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.write_str("ResponseFuture") + } +} + +impl<'a, F: Future> Future for ResponseFuture<'a, F> { + type Output = F::Output; + + fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { + let this = self.project(); + + let res = this.fut.poll(cx); + if let Poll::Ready(rp) = &res { + let method_name = this.req.method_name(); + let transport_label = &this.transport_label; + let now = this.now; + let metrics = &this.metrics; + + log::trace!(target: "rpc_metrics", "[{transport_label}] on_response started_at={:?}", now); + log::trace!(target: "rpc_metrics::extra", "[{transport_label}] result={:?}", rp); + + let micros = now.elapsed().as_micros(); + log::debug!( + target: "rpc_metrics", + "[{transport_label}] {method_name} call took {} μs", + micros, + ); + metrics + .calls_time + .with_label_values(&[transport_label, method_name]) + .observe(micros as _); + metrics + .calls_finished + .with_label_values(&[ + transport_label, + method_name, + // the label "is_error", so `success` should be regarded as false + // and vice-versa to be registrered correctly. + if rp.is_success() { "false" } else { "true" }, + ]) + .inc(); + } + res + } +} diff --git a/substrate/client/rpc-servers/src/middleware/mod.rs b/substrate/client/rpc-servers/src/middleware/mod.rs new file mode 100644 index 0000000000000..1c1930582441b --- /dev/null +++ b/substrate/client/rpc-servers/src/middleware/mod.rs @@ -0,0 +1,23 @@ +// This file is part of Substrate. + +// Copyright (C) Parity Technologies (UK) Ltd. +// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0 + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +//! JSON-RPC specific middleware. + +pub mod metrics; + +pub use metrics::*; diff --git a/substrate/client/rpc-spec-v2/Cargo.toml b/substrate/client/rpc-spec-v2/Cargo.toml index 6d0e7e0784853..84fa3bdd25919 100644 --- a/substrate/client/rpc-spec-v2/Cargo.toml +++ b/substrate/client/rpc-spec-v2/Cargo.toml @@ -16,7 +16,7 @@ workspace = true targets = ["x86_64-unknown-linux-gnu"] [dependencies] -jsonrpsee = { version = "0.20.3", features = ["client-core", "macros", "server"] } +jsonrpsee = { version = "0.21", features = ["client-core", "macros", "server"] } # Internal chain structures for "chain_spec". sc-chain-spec = { path = "../chain-spec" } # Pool for submitting extrinsics required by "transaction" diff --git a/substrate/client/rpc-spec-v2/src/archive/tests.rs b/substrate/client/rpc-spec-v2/src/archive/tests.rs index 09b2410eac6e8..3f850a20ae514 100644 --- a/substrate/client/rpc-spec-v2/src/archive/tests.rs +++ b/substrate/client/rpc-spec-v2/src/archive/tests.rs @@ -31,10 +31,7 @@ use super::{ use assert_matches::assert_matches; use codec::{Decode, Encode}; -use jsonrpsee::{ - core::{EmptyServerParams as EmptyParams, Error}, - rpc_params, RpcModule, -}; +use jsonrpsee::{core::EmptyServerParams as EmptyParams, MethodsError as Error, RpcModule}; use sc_block_builder::BlockBuilderBuilder; use sc_client_api::ChildInfo; use sp_blockchain::HeaderBackend; @@ -294,7 +291,7 @@ async fn archive_call() { ) .await .unwrap_err(); - assert_matches!(err, Error::Call(err) if err.code() == 3001 && err.message().contains("Invalid parameter")); + assert_matches!(err, Error::JsonRpc(err) if err.code() == 3001 && err.message().contains("Invalid parameter")); // Pass an invalid parameters that cannot be decode. let err = api @@ -305,7 +302,7 @@ async fn archive_call() { ) .await .unwrap_err(); - assert_matches!(err, Error::Call(err) if err.code() == 3001 && err.message().contains("Invalid parameter")); + assert_matches!(err, Error::JsonRpc(err) if err.code() == 3001 && err.message().contains("Invalid parameter")); // Invalid hash. let result: MethodResult = api diff --git a/substrate/client/rpc-spec-v2/src/chain_head/tests.rs b/substrate/client/rpc-spec-v2/src/chain_head/tests.rs index 955a361e3eadb..e62f0a0f2fae5 100644 --- a/substrate/client/rpc-spec-v2/src/chain_head/tests.rs +++ b/substrate/client/rpc-spec-v2/src/chain_head/tests.rs @@ -27,8 +27,7 @@ use assert_matches::assert_matches; use codec::{Decode, Encode}; use futures::Future; use jsonrpsee::{ - core::{error::Error, server::Subscription as RpcSubscription}, - rpc_params, RpcModule, + core::server::Subscription as RpcSubscription, rpc_params, MethodsError as Error, RpcModule, }; use sc_block_builder::BlockBuilderBuilder; use sc_client_api::ChildInfo; @@ -359,7 +358,7 @@ async fn get_header() { .await .unwrap_err(); assert_matches!(err, - Error::Call(err) if err.code() == super::error::rpc_spec_v2::INVALID_BLOCK_ERROR && err.message() == "Invalid block hash" + Error::JsonRpc(ref err) if err.code() == super::error::rpc_spec_v2::INVALID_BLOCK_ERROR && err.message() == "Invalid block hash" ); // Obtain the valid header. @@ -388,7 +387,7 @@ async fn get_body() { .await .unwrap_err(); assert_matches!(err, - Error::Call(err) if err.code() == super::error::rpc_spec_v2::INVALID_BLOCK_ERROR && err.message() == "Invalid block hash" + Error::JsonRpc(ref err) if err.code() == super::error::rpc_spec_v2::INVALID_BLOCK_ERROR && err.message() == "Invalid block hash" ); // Valid call. @@ -473,7 +472,7 @@ async fn call_runtime() { .await .unwrap_err(); assert_matches!(err, - Error::Call(err) if err.code() == super::error::rpc_spec_v2::INVALID_BLOCK_ERROR && err.message() == "Invalid block hash" + Error::JsonRpc(ref err) if err.code() == super::error::rpc_spec_v2::INVALID_BLOCK_ERROR && err.message() == "Invalid block hash" ); // Pass an invalid parameters that cannot be decode. @@ -486,7 +485,7 @@ async fn call_runtime() { .await .unwrap_err(); assert_matches!(err, - Error::Call(err) if err.code() == super::error::json_rpc_spec::INVALID_PARAM_ERROR && err.message().contains("Invalid parameter") + Error::JsonRpc(err) if err.code() == super::error::json_rpc_spec::INVALID_PARAM_ERROR && err.message().contains("Invalid parameter") ); // Valid call. @@ -589,7 +588,7 @@ async fn call_runtime_without_flag() { .unwrap_err(); assert_matches!(err, - Error::Call(err) if err.code() == super::error::rpc_spec_v2::INVALID_RUNTIME_CALL && err.message().contains("subscription was started with `withRuntime` set to `false`") + Error::JsonRpc(ref err) if err.code() == super::error::rpc_spec_v2::INVALID_RUNTIME_CALL && err.message().contains("subscription was started with `withRuntime` set to `false`") ); } @@ -627,7 +626,7 @@ async fn get_storage_hash() { .await .unwrap_err(); assert_matches!(err, - Error::Call(err) if err.code() == super::error::rpc_spec_v2::INVALID_BLOCK_ERROR && err.message() == "Invalid block hash" + Error::JsonRpc(ref err) if err.code() == super::error::rpc_spec_v2::INVALID_BLOCK_ERROR && err.message() == "Invalid block hash" ); // Valid call without storage at the key. @@ -895,7 +894,7 @@ async fn get_storage_value() { .await .unwrap_err(); assert_matches!(err, - Error::Call(err) if err.code() == super::error::rpc_spec_v2::INVALID_BLOCK_ERROR && err.message() == "Invalid block hash" + Error::JsonRpc(ref err) if err.code() == super::error::rpc_spec_v2::INVALID_BLOCK_ERROR && err.message() == "Invalid block hash" ); // Valid call without storage at the key. @@ -1571,7 +1570,7 @@ async fn follow_with_unpin() { .await .unwrap_err(); assert_matches!(err, - Error::Call(err) if err.code() == super::error::rpc_spec_v2::INVALID_BLOCK_ERROR && err.message() == "Invalid block hash" + Error::JsonRpc(ref err) if err.code() == super::error::rpc_spec_v2::INVALID_BLOCK_ERROR && err.message() == "Invalid block hash" ); // To not exceed the number of pinned blocks, we need to unpin before the next import. @@ -1720,7 +1719,7 @@ async fn follow_with_multiple_unpin_hashes() { .await .unwrap_err(); assert_matches!(err, - Error::Call(err) if err.code() == super::error::rpc_spec_v2::INVALID_BLOCK_ERROR && err.message() == "Invalid block hash" + Error::JsonRpc(ref err) if err.code() == super::error::rpc_spec_v2::INVALID_BLOCK_ERROR && err.message() == "Invalid block hash" ); let _res: () = api @@ -1737,7 +1736,7 @@ async fn follow_with_multiple_unpin_hashes() { .await .unwrap_err(); assert_matches!(err, - Error::Call(err) if err.code() == super::error::rpc_spec_v2::INVALID_BLOCK_ERROR && err.message() == "Invalid block hash" + Error::JsonRpc(ref err) if err.code() == super::error::rpc_spec_v2::INVALID_BLOCK_ERROR && err.message() == "Invalid block hash" ); // Unpin multiple blocks. @@ -1755,7 +1754,7 @@ async fn follow_with_multiple_unpin_hashes() { .await .unwrap_err(); assert_matches!(err, - Error::Call(err) if err.code() == super::error::rpc_spec_v2::INVALID_BLOCK_ERROR && err.message() == "Invalid block hash" + Error::JsonRpc(ref err) if err.code() == super::error::rpc_spec_v2::INVALID_BLOCK_ERROR && err.message() == "Invalid block hash" ); let err = api @@ -1766,7 +1765,7 @@ async fn follow_with_multiple_unpin_hashes() { .await .unwrap_err(); assert_matches!(err, - Error::Call(err) if err.code() == super::error::rpc_spec_v2::INVALID_BLOCK_ERROR && err.message() == "Invalid block hash" + Error::JsonRpc(ref err) if err.code() == super::error::rpc_spec_v2::INVALID_BLOCK_ERROR && err.message() == "Invalid block hash" ); } diff --git a/substrate/client/rpc/Cargo.toml b/substrate/client/rpc/Cargo.toml index 6917eb0b551a9..8f4f28e2550bd 100644 --- a/substrate/client/rpc/Cargo.toml +++ b/substrate/client/rpc/Cargo.toml @@ -18,7 +18,7 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] codec = { package = "parity-scale-codec", version = "3.6.1" } futures = "0.3.21" -jsonrpsee = { version = "0.20.3", features = ["server"] } +jsonrpsee = { version = "0.21", features = ["server"] } log = "0.4.17" parking_lot = "0.12.1" serde_json = "1.0.111" diff --git a/substrate/client/rpc/src/author/tests.rs b/substrate/client/rpc/src/author/tests.rs index 471016a015da1..937870eb53fd9 100644 --- a/substrate/client/rpc/src/author/tests.rs +++ b/substrate/client/rpc/src/author/tests.rs @@ -21,10 +21,7 @@ use super::*; use crate::testing::{test_executor, timeout_secs}; use assert_matches::assert_matches; use codec::Encode; -use jsonrpsee::{ - core::{EmptyServerParams as EmptyParams, Error as RpcError}, - RpcModule, -}; +use jsonrpsee::{core::EmptyServerParams as EmptyParams, MethodsError as RpcError, RpcModule}; use sc_transaction_pool::{BasicPool, FullChainApi}; use sc_transaction_pool_api::TransactionStatus; use sp_core::{ @@ -103,7 +100,7 @@ async fn author_submit_transaction_should_not_cause_error() { assert_matches!( api.call::<_, H256>("author_submitExtrinsic", [xt]).await, - Err(RpcError::Call(err)) if err.message().contains("Already Imported") && err.code() == 1013 + Err(RpcError::JsonRpc(err)) if err.message().contains("Already Imported") && err.code() == 1013 ); } @@ -160,7 +157,7 @@ async fn author_should_return_watch_validation_error() { assert_matches!( failed_sub, - Err(RpcError::Call(err)) if err.message().contains("Invalid Transaction") && err.code() == 1010 + Err(RpcError::JsonRpc(err)) if err.message().contains("Invalid Transaction") && err.code() == 1010 ); } @@ -276,7 +273,7 @@ async fn author_has_session_keys() { assert_matches!( api.call::<_, bool>("author_hasSessionKeys", vec![Bytes::from(vec![1, 2, 3])]).await, - Err(RpcError::Call(err)) if err.message().contains("Session keys are not encoded correctly") + Err(RpcError::JsonRpc(err)) if err.message().contains("Session keys are not encoded correctly") ); } diff --git a/substrate/client/rpc/src/state/tests.rs b/substrate/client/rpc/src/state/tests.rs index 25a34faed9a66..96f4c1be960fa 100644 --- a/substrate/client/rpc/src/state/tests.rs +++ b/substrate/client/rpc/src/state/tests.rs @@ -21,7 +21,7 @@ use super::*; use crate::testing::{test_executor, timeout_secs}; use assert_matches::assert_matches; use futures::executor; -use jsonrpsee::core::{EmptyServerParams as EmptyParams, Error as RpcError}; +use jsonrpsee::{core::EmptyServerParams as EmptyParams, MethodsError as RpcError}; use sc_block_builder::BlockBuilderBuilder; use sc_rpc_api::DenyUnsafe; use sp_consensus::BlockOrigin; @@ -525,7 +525,7 @@ async fn wildcard_storage_subscriptions_are_rpc_unsafe() { let api_rpc = api.into_rpc(); let err = api_rpc.subscribe_unbounded("state_subscribeStorage", EmptyParams::new()).await; - assert_matches!(err, Err(RpcError::Call(e)) if e.message() == "RPC call is unsafe to be called externally"); + assert_matches!(err, Err(RpcError::JsonRpc(e)) if e.message() == "RPC call is unsafe to be called externally"); } #[tokio::test] diff --git a/substrate/client/rpc/src/system/tests.rs b/substrate/client/rpc/src/system/tests.rs index 21d13ccfafaa7..03967c63523c7 100644 --- a/substrate/client/rpc/src/system/tests.rs +++ b/substrate/client/rpc/src/system/tests.rs @@ -19,10 +19,7 @@ use super::{helpers::SyncState, *}; use assert_matches::assert_matches; use futures::prelude::*; -use jsonrpsee::{ - core::{EmptyServerParams as EmptyParams, Error as RpcError}, - RpcModule, -}; +use jsonrpsee::{core::EmptyServerParams as EmptyParams, MethodsError as RpcError, RpcModule}; use sc_network::{self, config::Role, PeerId}; use sc_rpc_api::system::helpers::PeerInfo; use sc_utils::mpsc::tracing_unbounded; @@ -311,7 +308,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::Call(err)) if err.message().contains("Peer id is missing from the address") + Err(RpcError::JsonRpc(err)) if err.message().contains("Peer id is missing from the address") ); } @@ -327,7 +324,7 @@ async fn system_network_remove_reserved() { assert_matches!( api(None).call::<_, String>("system_removeReservedPeer", bad_peer_id).await, - Err(RpcError::Call(err)) if err.message().contains("base-58 decode error: provided string contained invalid character '/' at byte 0") + Err(RpcError::JsonRpc(err)) if err.message().contains("base-58 decode error: provided string contained invalid character '/' at byte 0") ); } #[tokio::test] diff --git a/substrate/client/service/Cargo.toml b/substrate/client/service/Cargo.toml index 1c95112aa6b0e..1f16fe8c0807b 100644 --- a/substrate/client/service/Cargo.toml +++ b/substrate/client/service/Cargo.toml @@ -28,7 +28,7 @@ runtime-benchmarks = [ ] [dependencies] -jsonrpsee = { version = "0.20.3", features = ["server"] } +jsonrpsee = { version = "0.21", features = ["server"] } thiserror = "1.0.48" futures = "0.3.21" rand = "0.8.5" diff --git a/substrate/client/service/src/lib.rs b/substrate/client/service/src/lib.rs index a76e1544bfbb9..58c6d5cf37153 100644 --- a/substrate/client/service/src/lib.rs +++ b/substrate/client/service/src/lib.rs @@ -38,7 +38,7 @@ use std::{collections::HashMap, net::SocketAddr}; use codec::{Decode, Encode}; use futures::{pin_mut, FutureExt, StreamExt}; -use jsonrpsee::{core::Error as JsonRpseeError, RpcModule}; +use jsonrpsee::RpcModule; use log::{debug, error, warn}; use sc_client_api::{blockchain::HeaderBackend, BlockBackend, BlockchainEvents, ProofProvider}; use sc_network::{ @@ -109,7 +109,7 @@ impl RpcHandlers { pub async fn rpc_query( &self, json_query: &str, - ) -> Result<(String, tokio::sync::mpsc::Receiver), JsonRpseeError> { + ) -> Result<(String, tokio::sync::mpsc::Receiver), serde_json::Error> { // Because `tokio::sync::mpsc::channel` is used under the hood // it will panic if it's set to usize::MAX. // @@ -119,7 +119,7 @@ impl RpcHandlers { self.0 .raw_json_request(json_query, TOKIO_MPSC_MAX_SIZE) .await - .map(|(method_res, recv)| (method_res.result, recv)) + .map(|(method_res, recv)| (method_res.into_result(), recv)) } /// Provides access to the underlying `RpcModule` diff --git a/substrate/client/sync-state-rpc/Cargo.toml b/substrate/client/sync-state-rpc/Cargo.toml index 328ecd17f75b3..11c7b42f4af16 100644 --- a/substrate/client/sync-state-rpc/Cargo.toml +++ b/substrate/client/sync-state-rpc/Cargo.toml @@ -16,7 +16,7 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] codec = { package = "parity-scale-codec", version = "3.6.1" } -jsonrpsee = { version = "0.20.3", features = ["client-core", "macros", "server"] } +jsonrpsee = { version = "0.21", features = ["client-core", "macros", "server"] } serde = { version = "1.0.195", features = ["derive"] } serde_json = "1.0.111" thiserror = "1.0.48" diff --git a/substrate/frame/transaction-payment/rpc/Cargo.toml b/substrate/frame/transaction-payment/rpc/Cargo.toml index e7edf8a4b8792..43116c402fcfd 100644 --- a/substrate/frame/transaction-payment/rpc/Cargo.toml +++ b/substrate/frame/transaction-payment/rpc/Cargo.toml @@ -17,7 +17,7 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] codec = { package = "parity-scale-codec", version = "3.6.1" } -jsonrpsee = { version = "0.20.3", features = ["client-core", "macros", "server"] } +jsonrpsee = { version = "0.21", features = ["client-core", "macros", "server"] } pallet-transaction-payment-rpc-runtime-api = { path = "runtime-api" } sp-api = { path = "../../../primitives/api" } sp-blockchain = { path = "../../../primitives/blockchain" } diff --git a/substrate/utils/frame/remote-externalities/Cargo.toml b/substrate/utils/frame/remote-externalities/Cargo.toml index ff0b7572d334c..41462aacb6ec1 100644 --- a/substrate/utils/frame/remote-externalities/Cargo.toml +++ b/substrate/utils/frame/remote-externalities/Cargo.toml @@ -15,7 +15,7 @@ workspace = true targets = ["x86_64-unknown-linux-gnu"] [dependencies] -jsonrpsee = { version = "0.20.3", features = ["http-client"] } +jsonrpsee = { version = "0.21", features = ["http-client"] } codec = { package = "parity-scale-codec", version = "3.6.1" } log = "0.4.17" serde = "1.0.195" diff --git a/substrate/utils/frame/rpc/client/Cargo.toml b/substrate/utils/frame/rpc/client/Cargo.toml index a97bc77b00f53..ce1d311ab3c64 100644 --- a/substrate/utils/frame/rpc/client/Cargo.toml +++ b/substrate/utils/frame/rpc/client/Cargo.toml @@ -15,7 +15,7 @@ workspace = true targets = ["x86_64-unknown-linux-gnu"] [dependencies] -jsonrpsee = { version = "0.20.3", features = ["ws-client"] } +jsonrpsee = { version = "0.21", features = ["ws-client"] } sc-rpc-api = { path = "../../../../client/rpc-api" } async-trait = "0.1.74" serde = "1" diff --git a/substrate/utils/frame/rpc/client/src/lib.rs b/substrate/utils/frame/rpc/client/src/lib.rs index 9349ee2d357b2..221f260b15669 100644 --- a/substrate/utils/frame/rpc/client/src/lib.rs +++ b/substrate/utils/frame/rpc/client/src/lib.rs @@ -44,9 +44,9 @@ use std::collections::VecDeque; pub use jsonrpsee::{ core::{ - client::{ClientT, Subscription, SubscriptionClientT}, + client::{ClientT, Error, Subscription, SubscriptionClientT}, params::BatchRequestBuilder, - Error, RpcResult, + RpcResult, }, rpc_params, ws_client::{WsClient, WsClientBuilder}, diff --git a/substrate/utils/frame/rpc/state-trie-migration-rpc/Cargo.toml b/substrate/utils/frame/rpc/state-trie-migration-rpc/Cargo.toml index 83afff94a8dc0..49bfbfe75d5b7 100644 --- a/substrate/utils/frame/rpc/state-trie-migration-rpc/Cargo.toml +++ b/substrate/utils/frame/rpc/state-trie-migration-rpc/Cargo.toml @@ -23,7 +23,8 @@ sp-core = { path = "../../../../primitives/core" } sp-state-machine = { path = "../../../../primitives/state-machine" } sp-trie = { path = "../../../../primitives/trie" } trie-db = "0.28.0" -jsonrpsee = { version = "0.20.3", features = ["client-core", "macros", "server"] } + +jsonrpsee = { version = "0.21", features = ["client-core", "macros", "server"] } # Substrate Dependencies sc-client-api = { path = "../../../../client/api" } diff --git a/substrate/utils/frame/rpc/support/Cargo.toml b/substrate/utils/frame/rpc/support/Cargo.toml index 3750e3272c90d..8c50c6847713a 100644 --- a/substrate/utils/frame/rpc/support/Cargo.toml +++ b/substrate/utils/frame/rpc/support/Cargo.toml @@ -16,7 +16,7 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] codec = { package = "parity-scale-codec", version = "3.6.1" } -jsonrpsee = { version = "0.20.3", features = ["jsonrpsee-types"] } +jsonrpsee = { version = "0.21", features = ["jsonrpsee-types"] } serde = "1" frame-support = { path = "../../../../frame/support" } sc-rpc-api = { path = "../../../../client/rpc-api" } @@ -24,7 +24,7 @@ sp-storage = { path = "../../../../primitives/storage" } [dev-dependencies] scale-info = "2.10.0" -jsonrpsee = { version = "0.20.3", features = ["jsonrpsee-types", "ws-client"] } +jsonrpsee = { version = "0.21", features = ["jsonrpsee-types", "ws-client"] } tokio = "1.22.0" sp-core = { path = "../../../../primitives/core" } sp-runtime = { path = "../../../../primitives/runtime" } diff --git a/substrate/utils/frame/rpc/support/src/lib.rs b/substrate/utils/frame/rpc/support/src/lib.rs index e3ccbd6965893..425afdb6117f3 100644 --- a/substrate/utils/frame/rpc/support/src/lib.rs +++ b/substrate/utils/frame/rpc/support/src/lib.rs @@ -23,7 +23,7 @@ use codec::{DecodeAll, FullCodec, FullEncode}; use core::marker::PhantomData; use frame_support::storage::generator::{StorageDoubleMap, StorageMap, StorageValue}; -use jsonrpsee::core::Error as RpcError; +use jsonrpsee::core::ClientError as RpcError; use sc_rpc_api::state::StateApiClient; use serde::{de::DeserializeOwned, Serialize}; use sp_storage::{StorageData, StorageKey}; diff --git a/substrate/utils/frame/rpc/system/Cargo.toml b/substrate/utils/frame/rpc/system/Cargo.toml index 3f06ffe2bc2ee..2639121894dbf 100644 --- a/substrate/utils/frame/rpc/system/Cargo.toml +++ b/substrate/utils/frame/rpc/system/Cargo.toml @@ -17,7 +17,7 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] codec = { package = "parity-scale-codec", version = "3.6.1" } -jsonrpsee = { version = "0.20.3", features = ["client-core", "macros", "server"] } +jsonrpsee = { version = "0.21", features = ["client-core", "macros", "server"] } futures = "0.3.21" log = "0.4.17" frame-system-rpc-runtime-api = { path = "../../../../frame/system/rpc/runtime-api" } From 250f1093ab5853c516a7914dd78d2896bbe1493f Mon Sep 17 00:00:00 2001 From: Niklas Adolfsson Date: Tue, 6 Feb 2024 14:59:07 +0100 Subject: [PATCH 02/25] fix race in chainhead --- .../rpc-servers/src/middleware/metrics.rs | 4 +- .../client/rpc-spec-v2/src/chain_head/api.rs | 8 +- .../rpc-spec-v2/src/chain_head/chain_head.rs | 112 +++++++++++++----- 3 files changed, 85 insertions(+), 39 deletions(-) diff --git a/substrate/client/rpc-servers/src/middleware/metrics.rs b/substrate/client/rpc-servers/src/middleware/metrics.rs index 541a36216cf56..09cb61cba752d 100644 --- a/substrate/client/rpc-servers/src/middleware/metrics.rs +++ b/substrate/client/rpc-servers/src/middleware/metrics.rs @@ -25,9 +25,7 @@ use std::{ time::Instant, }; -use jsonrpsee::{ - server::middleware::rpc::RpcServiceT, types::Request, MethodResponse, -}; +use jsonrpsee::{server::middleware::rpc::RpcServiceT, types::Request, MethodResponse}; use pin_project::pin_project; use prometheus_endpoint::{ register, Counter, CounterVec, HistogramOpts, HistogramVec, Opts, PrometheusError, Registry, diff --git a/substrate/client/rpc-spec-v2/src/chain_head/api.rs b/substrate/client/rpc-spec-v2/src/chain_head/api.rs index 7c3b8d81c82ae..00000e1fb277b 100644 --- a/substrate/client/rpc-spec-v2/src/chain_head/api.rs +++ b/substrate/client/rpc-spec-v2/src/chain_head/api.rs @@ -26,7 +26,7 @@ use crate::{ }, common::events::StorageQuery, }; -use jsonrpsee::proc_macros::rpc; +use jsonrpsee::{proc_macros::rpc, server::ResponsePayload}; use sp_rpc::list::ListOrValue; #[rpc(client, server)] @@ -59,7 +59,7 @@ pub trait ChainHeadApi { &self, follow_subscription: String, hash: Hash, - ) -> Result; + ) -> ResponsePayload<'static, MethodResponse>; /// Retrieves the header of a pinned block. /// @@ -92,7 +92,7 @@ pub trait ChainHeadApi { hash: Hash, items: Vec>, child_trie: Option, - ) -> Result; + ) -> ResponsePayload<'static, MethodResponse>; /// Call into the Runtime API at a specified block's state. /// @@ -106,7 +106,7 @@ pub trait ChainHeadApi { hash: Hash, function: String, call_parameters: String, - ) -> Result; + ) -> ResponsePayload<'static, MethodResponse>; /// Unpin a block or multiple blocks reported by the `follow` method. /// diff --git a/substrate/client/rpc-spec-v2/src/chain_head/chain_head.rs b/substrate/client/rpc-spec-v2/src/chain_head/chain_head.rs index 0e207addcaeb7..a71c9eb50b1c9 100644 --- a/substrate/client/rpc-spec-v2/src/chain_head/chain_head.rs +++ b/substrate/client/rpc-spec-v2/src/chain_head/chain_head.rs @@ -36,7 +36,8 @@ use crate::{ use codec::Encode; use futures::future::FutureExt; use jsonrpsee::{ - core::async_trait, types::SubscriptionId, PendingSubscriptionSink, SubscriptionSink, + core::async_trait, server::ResponsePayload, types::SubscriptionId, MethodResponseFuture, + PendingSubscriptionSink, SubscriptionSink, }; use log::debug; use sc_client_api::{ @@ -218,16 +219,17 @@ where &self, follow_subscription: String, hash: Block::Hash, - ) -> Result { + ) -> ResponsePayload<'static, MethodResponse> { let mut block_guard = match self.subscriptions.lock_block(&follow_subscription, hash, 1) { Ok(block) => block, Err(SubscriptionManagementError::SubscriptionAbsent) | - Err(SubscriptionManagementError::ExceededLimits) => return Ok(MethodResponse::LimitReached), + Err(SubscriptionManagementError::ExceededLimits) => + return ResponsePayload::success(MethodResponse::LimitReached), Err(SubscriptionManagementError::BlockHashAbsent) => { // Block is not part of the subscription. - return Err(ChainHeadRpcError::InvalidBlock.into()) + return ResponsePayload::error(ChainHeadRpcError::InvalidBlock); }, - Err(_) => return Err(ChainHeadRpcError::InvalidBlock.into()), + Err(_) => return ResponsePayload::error(ChainHeadRpcError::InvalidBlock), }; let operation_id = block_guard.operation().operation_id(); @@ -254,7 +256,7 @@ where hash ); self.subscriptions.remove_subscription(&follow_subscription); - return Err(ChainHeadRpcError::InvalidBlock.into()) + return ResponsePayload::error(ChainHeadRpcError::InvalidBlock) }, Err(error) => FollowEvent::::OperationError(OperationError { operation_id: operation_id.clone(), @@ -262,8 +264,20 @@ where }), }; - let _ = block_guard.response_sender().unbounded_send(event); - Ok(MethodResponse::Started(MethodResponseStarted { operation_id, discarded_items: None })) + let (rp, rp_is_success) = method_started_response(operation_id, None); + + let fut = async move { + // Events should only by generated if the response + // was successful. + if rp_is_success.await.is_err() { + return; + } + let _ = block_guard.response_sender().unbounded_send(event); + }; + + self.executor.spawn("substrate-rpc-subscription", Some("rpc"), fut.boxed()); + + rp } fn chain_head_unstable_header( @@ -294,31 +308,40 @@ where hash: Block::Hash, items: Vec>, child_trie: Option, - ) -> Result { + ) -> ResponsePayload<'static, MethodResponse> { // Gain control over parameter parsing and returned error. - let items = items + let items = match items .into_iter() .map(|query| { let key = StorageKey(parse_hex_param(query.key)?); Ok(StorageQuery { key, query_type: query.query_type }) }) - .collect::, ChainHeadRpcError>>()?; + .collect::, ChainHeadRpcError>>() + { + Ok(items) => items, + Err(err) => { + return ResponsePayload::error(err); + }, + }; let child_trie = child_trie .map(|child_trie| parse_hex_param(child_trie)) - .transpose()? + .transpose() + .unwrap() .map(ChildInfo::new_default_from_vec); let mut block_guard = match self.subscriptions.lock_block(&follow_subscription, hash, items.len()) { Ok(block) => block, Err(SubscriptionManagementError::SubscriptionAbsent) | - Err(SubscriptionManagementError::ExceededLimits) => return Ok(MethodResponse::LimitReached), + Err(SubscriptionManagementError::ExceededLimits) => { + return ResponsePayload::success(MethodResponse::LimitReached); + }, Err(SubscriptionManagementError::BlockHashAbsent) => { // Block is not part of the subscription. - return Err(ChainHeadRpcError::InvalidBlock.into()) + return ResponsePayload::error(ChainHeadRpcError::InvalidBlock) }, - Err(_) => return Err(ChainHeadRpcError::InvalidBlock.into()), + Err(_) => return ResponsePayload::error(ChainHeadRpcError::InvalidBlock), }; let mut storage_client = ChainHeadStorage::::new( @@ -334,16 +357,21 @@ where let mut items = items; items.truncate(num_operations); + let (rp, rp_is_success) = method_started_response(operation_id, Some(discarded)); + let fut = async move { + // Events should only by generated if the response + // was successful. + if rp_is_success.await.is_err() { + return; + } storage_client.generate_events(block_guard, hash, items, child_trie).await; }; self.executor .spawn_blocking("substrate-rpc-subscription", Some("rpc"), fut.boxed()); - Ok(MethodResponse::Started(MethodResponseStarted { - operation_id, - discarded_items: Some(discarded), - })) + + rp } fn chain_head_unstable_call( @@ -352,29 +380,31 @@ where hash: Block::Hash, function: String, call_parameters: String, - ) -> Result { - let call_parameters = Bytes::from(parse_hex_param(call_parameters)?); + ) -> ResponsePayload<'static, MethodResponse> { + let call_parameters = match parse_hex_param(call_parameters) { + Ok(hex) => Bytes::from(hex), + Err(err) => return ResponsePayload::error(err), + }; let mut block_guard = match self.subscriptions.lock_block(&follow_subscription, hash, 1) { Ok(block) => block, Err(SubscriptionManagementError::SubscriptionAbsent) | Err(SubscriptionManagementError::ExceededLimits) => { // Invalid invalid subscription ID. - return Ok(MethodResponse::LimitReached) + return ResponsePayload::success(MethodResponse::LimitReached) }, Err(SubscriptionManagementError::BlockHashAbsent) => { // Block is not part of the subscription. - return Err(ChainHeadRpcError::InvalidBlock.into()) + return ResponsePayload::error(ChainHeadRpcError::InvalidBlock) }, - Err(_) => return Err(ChainHeadRpcError::InvalidBlock.into()), + Err(_) => return ResponsePayload::error(ChainHeadRpcError::InvalidBlock), }; // Reject subscription if with_runtime is false. if !block_guard.has_runtime() { - return Err(ChainHeadRpcError::InvalidRuntimeCall( + return ResponsePayload::error(ChainHeadRpcError::InvalidRuntimeCall( "The runtime updates flag must be set".to_string(), - ) - .into()) + )); } let operation_id = block_guard.operation().operation_id(); @@ -395,11 +425,20 @@ where }) }); - let _ = block_guard.response_sender().unbounded_send(event); - Ok(MethodResponse::Started(MethodResponseStarted { - operation_id: operation_id.clone(), - discarded_items: None, - })) + let (rp, rp_is_success) = method_started_response(operation_id, None); + + let fut = async move { + // Events should only by generated if the response + // was successful. + if rp_is_success.await.is_err() { + return; + } + let _ = block_guard.response_sender().unbounded_send(event); + }; + + self.executor.spawn("substrate-rpc-subscription", Some("rpc"), fut.boxed()); + + rp } fn chain_head_unstable_unpin( @@ -461,3 +500,12 @@ where Ok(()) } } + +fn method_started_response( + operation_id: String, + discarded_items: Option, +) -> (ResponsePayload<'static, MethodResponse>, MethodResponseFuture) { + let rp = MethodResponse::Started(MethodResponseStarted { operation_id, discarded_items }); + + ResponsePayload::success(rp).notify_on_completion() +} From 8bc7fd7953042302f81b4b879d5f40b4dd96b85e Mon Sep 17 00:00:00 2001 From: Niklas Adolfsson Date: Tue, 6 Feb 2024 15:38:12 +0100 Subject: [PATCH 03/25] fix some nits --- substrate/client/rpc-servers/src/lib.rs | 49 ++++++++++++------------- 1 file changed, 24 insertions(+), 25 deletions(-) diff --git a/substrate/client/rpc-servers/src/lib.rs b/substrate/client/rpc-servers/src/lib.rs index ccc759736245a..fc54b4e7361cd 100644 --- a/substrate/client/rpc-servers/src/lib.rs +++ b/substrate/client/rpc-servers/src/lib.rs @@ -36,9 +36,9 @@ use jsonrpsee::{ http::{HostFilterLayer, ProxyGetRequestLayer}, rpc::RpcServiceBuilder, }, - stop_channel, ws, PingConfig, + stop_channel, ws, PingConfig, StopHandle, TowerServiceBuilder, }, - RpcModule, + Methods, RpcModule, }; use tokio::net::TcpListener; use tower::Service; @@ -130,42 +130,32 @@ pub async fn start_server( builder = builder.set_id_provider(RandomStringIdProvider::new(16)); }; - let methods = build_rpc_api(rpc_api); - let svc_builder = builder.to_service_builder().max_connections(max_connections); - let (stop_handle, server_handle) = stop_channel(); - let stop_handle2 = stop_handle.clone(); - let methods = methods.clone(); - let metrics = metrics.clone(); - let tokio_handle = tokio_handle.clone(); + let cfg = PerConnection { + methods: build_rpc_api(rpc_api).into(), + service_builder: builder.to_service_builder().max_connections(max_connections), + metrics, + tokio_handle, + stop_handle: stop_handle.clone(), + }; let make_service = make_service_fn(move |_conn: &AddrStream| { - let stop_handle = stop_handle2.clone(); - let svc_builder = svc_builder.clone(); - let metrics = metrics.clone(); - let methods = methods.clone(); - let tokio_handle = tokio_handle.clone(); + let cfg = cfg.clone(); async move { - let stop_handle = stop_handle.clone(); - let svc_builder = svc_builder.clone(); - let stop_handle = stop_handle.clone(); - let tokio_handle = tokio_handle.clone(); - let metrics = metrics.clone(); + let cfg = cfg.clone(); Ok::<_, Infallible>(service_fn(move |req| { - let metrics = metrics.clone(); - let svc_builder = svc_builder.clone(); - let tokio_handle = tokio_handle.clone(); + let PerConnection { service_builder, metrics, tokio_handle, stop_handle, methods } = + cfg.clone(); let is_websocket = ws::is_upgrade_request(&req); let transport_label = if is_websocket { "ws" } else { "http" }; let metrics = metrics.map(|m| MetricsLayer::new(m, transport_label)); let rpc_middleware = RpcServiceBuilder::new().option_layer(metrics.clone()); - let mut svc = svc_builder - .set_rpc_middleware(rpc_middleware) - .build(methods.clone(), stop_handle.clone()); + let mut svc = + service_builder.set_rpc_middleware(rpc_middleware).build(methods, stop_handle); async move { if is_websocket { @@ -258,3 +248,12 @@ fn format_cors(maybe_cors: Option<&Vec>) -> String { format!("{:?}", ["*"]) } } + +#[derive(Clone)] +struct PerConnection { + methods: Methods, + stop_handle: StopHandle, + metrics: Option, + tokio_handle: tokio::runtime::Handle, + service_builder: TowerServiceBuilder, +} From b0769b7be0e11262703adda738a68af72e69ff38 Mon Sep 17 00:00:00 2001 From: Niklas Adolfsson Date: Tue, 6 Feb 2024 17:49:56 +0100 Subject: [PATCH 04/25] fix bad Cargo.toml fmt --- Cargo.toml | 1 - substrate/client/consensus/babe/rpc/Cargo.toml | 2 +- substrate/client/consensus/beefy/rpc/Cargo.toml | 2 +- substrate/client/consensus/grandpa/rpc/Cargo.toml | 2 +- substrate/client/consensus/manual-seal/Cargo.toml | 2 +- 5 files changed, 4 insertions(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index ebfcf5ca7f0f3..abfd440d42046 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -614,4 +614,3 @@ zeroize = { opt-level = 3 } [patch.crates-io] jsonrpsee = { git = "https://github.com/paritytech/jsonrpsee", branch = "master" } jsonrpsee-core = { git = "https://github.com/paritytech/jsonrpsee", branch = "master" } - diff --git a/substrate/client/consensus/babe/rpc/Cargo.toml b/substrate/client/consensus/babe/rpc/Cargo.toml index 0c572b5d316ca..6ae6de87a3bea 100644 --- a/substrate/client/consensus/babe/rpc/Cargo.toml +++ b/substrate/client/consensus/babe/rpc/Cargo.toml @@ -16,7 +16,7 @@ workspace = true targets = ["x86_64-unknown-linux-gnu"] [dependencies] -jsonrpsee = { version = "0.21", features = ["client-core", "server", "macros"] } +jsonrpsee = { version = "0.21", features = ["client-core", "macros", "server"] } futures = "0.3.21" serde = { version = "1.0.195", features = ["derive"] } thiserror = "1.0" diff --git a/substrate/client/consensus/beefy/rpc/Cargo.toml b/substrate/client/consensus/beefy/rpc/Cargo.toml index adbcc5d4be6a2..95a6e7b351ae8 100644 --- a/substrate/client/consensus/beefy/rpc/Cargo.toml +++ b/substrate/client/consensus/beefy/rpc/Cargo.toml @@ -14,7 +14,7 @@ workspace = true [dependencies] codec = { package = "parity-scale-codec", version = "3.6.1", features = ["derive"] } futures = "0.3.21" -jsonrpsee = { version = "0.21", features = ["client-core", "server", "macros"] } +jsonrpsee = { version = "0.21", features = ["client-core", "macros", "server"] } log = "0.4" parking_lot = "0.12.1" serde = { version = "1.0.195", features = ["derive"] } diff --git a/substrate/client/consensus/grandpa/rpc/Cargo.toml b/substrate/client/consensus/grandpa/rpc/Cargo.toml index 6b6ac2c927f6d..f49a08c570d9c 100644 --- a/substrate/client/consensus/grandpa/rpc/Cargo.toml +++ b/substrate/client/consensus/grandpa/rpc/Cargo.toml @@ -15,7 +15,7 @@ workspace = true [dependencies] finality-grandpa = { version = "0.16.2", features = ["derive-codec"] } futures = "0.3.16" -jsonrpsee = { version = "0.21", features = ["client-core", "server", "macros"] } +jsonrpsee = { version = "0.21", features = ["client-core", "macros", "server"] } log = "0.4.8" parity-scale-codec = { version = "3.6.1", features = ["derive"] } serde = { version = "1.0.195", features = ["derive"] } diff --git a/substrate/client/consensus/manual-seal/Cargo.toml b/substrate/client/consensus/manual-seal/Cargo.toml index cbe615968e0a9..27e92d251d5cf 100644 --- a/substrate/client/consensus/manual-seal/Cargo.toml +++ b/substrate/client/consensus/manual-seal/Cargo.toml @@ -16,7 +16,7 @@ workspace = true targets = ["x86_64-unknown-linux-gnu"] [dependencies] -jsonrpsee = { version = "0.21", features = ["client-core", "server", "macros"] } +jsonrpsee = { version = "0.21", features = ["client-core", "macros", "server"] } assert_matches = "1.3.0" async-trait = "0.1.74" codec = { package = "parity-scale-codec", version = "3.6.1" } From 3d16db8f9989d705ddb1de27e6ab82f3b0fd5796 Mon Sep 17 00:00:00 2001 From: Niklas Adolfsson Date: Tue, 6 Feb 2024 18:26:53 +0100 Subject: [PATCH 05/25] make test compile --- substrate/client/consensus/babe/rpc/src/lib.rs | 4 ++-- substrate/client/consensus/beefy/rpc/src/lib.rs | 4 ++-- substrate/client/consensus/grandpa/rpc/src/lib.rs | 6 +++--- substrate/client/rpc-spec-v2/src/archive/tests.rs | 4 +++- substrate/client/rpc/src/dev/tests.rs | 2 +- 5 files changed, 11 insertions(+), 9 deletions(-) diff --git a/substrate/client/consensus/babe/rpc/src/lib.rs b/substrate/client/consensus/babe/rpc/src/lib.rs index 307b1f955ba2e..6fde56d2a0e55 100644 --- a/substrate/client/consensus/babe/rpc/src/lib.rs +++ b/substrate/client/consensus/babe/rpc/src/lib.rs @@ -260,7 +260,7 @@ mod tests { let (response, _) = api.raw_json_request(request, 1).await.unwrap(); let expected = r#"{"jsonrpc":"2.0","result":{"5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY":{"primary":[0],"secondary":[1,2,4],"secondary_vrf":[]}},"id":1}"#; - assert_eq!(&response.result, expected); + assert_eq!(response.as_result(), expected); } #[tokio::test] @@ -272,6 +272,6 @@ mod tests { let (response, _) = api.raw_json_request(request, 1).await.unwrap(); let expected = r#"{"jsonrpc":"2.0","error":{"code":-32601,"message":"RPC call is unsafe to be called externally"},"id":1}"#; - assert_eq!(&response.result, expected); + assert_eq!(response.as_result(), expected); } } diff --git a/substrate/client/consensus/beefy/rpc/src/lib.rs b/substrate/client/consensus/beefy/rpc/src/lib.rs index 03c83e92716c7..c91f516465447 100644 --- a/substrate/client/consensus/beefy/rpc/src/lib.rs +++ b/substrate/client/consensus/beefy/rpc/src/lib.rs @@ -218,7 +218,7 @@ mod tests { while std::time::Instant::now() < deadline { let (response, _) = io.raw_json_request(request, 1).await.expect("RPC requests work"); if response.result != not_ready { - assert_eq!(response.result, expected); + assert_eq!(response.into_result(), expected); // Success return } @@ -249,7 +249,7 @@ mod tests { .unwrap(); let expected = r#"{"jsonrpc":"2.0","result":false,"id":1}"#; - assert_eq!(response.result, expected); + assert_eq!(response.into_result(), expected); } fn create_finality_proof() -> BeefyVersionedFinalityProof { diff --git a/substrate/client/consensus/grandpa/rpc/src/lib.rs b/substrate/client/consensus/grandpa/rpc/src/lib.rs index 878cefacc479a..7c833ea823843 100644 --- a/substrate/client/consensus/grandpa/rpc/src/lib.rs +++ b/substrate/client/consensus/grandpa/rpc/src/lib.rs @@ -273,7 +273,7 @@ mod tests { let request = r#"{"jsonrpc":"2.0","method":"grandpa_roundState","params":[],"id":0}"#; let (response, _) = rpc.raw_json_request(&request, 1).await.unwrap(); - assert_eq!(expected_response, response.result); + assert_eq!(expected_response, response.into_result()); } #[tokio::test] @@ -295,7 +295,7 @@ mod tests { let request = r#"{"jsonrpc":"2.0","method":"grandpa_roundState","params":[],"id":0}"#; let (response, _) = rpc.raw_json_request(&request, 1).await.unwrap(); - assert_eq!(expected_response, response.result); + assert_eq!(expected_response, response.into_result()); } #[tokio::test] @@ -317,7 +317,7 @@ mod tests { .unwrap(); let expected = r#"{"jsonrpc":"2.0","result":false,"id":1}"#; - assert_eq!(response.result, expected); + assert_eq!(response.into_result(), expected); } fn create_justification() -> GrandpaJustification { diff --git a/substrate/client/rpc-spec-v2/src/archive/tests.rs b/substrate/client/rpc-spec-v2/src/archive/tests.rs index 3f850a20ae514..1803ffa3a3183 100644 --- a/substrate/client/rpc-spec-v2/src/archive/tests.rs +++ b/substrate/client/rpc-spec-v2/src/archive/tests.rs @@ -31,7 +31,9 @@ use super::{ use assert_matches::assert_matches; use codec::{Decode, Encode}; -use jsonrpsee::{core::EmptyServerParams as EmptyParams, MethodsError as Error, RpcModule}; +use jsonrpsee::{ + core::EmptyServerParams as EmptyParams, rpc_params, MethodsError as Error, RpcModule, +}; use sc_block_builder::BlockBuilderBuilder; use sc_client_api::ChildInfo; use sp_blockchain::HeaderBackend; diff --git a/substrate/client/rpc/src/dev/tests.rs b/substrate/client/rpc/src/dev/tests.rs index 5eb4897056cc4..1e6bf6fd25ca8 100644 --- a/substrate/client/rpc/src/dev/tests.rs +++ b/substrate/client/rpc/src/dev/tests.rs @@ -100,7 +100,7 @@ async fn deny_unsafe_works() { let (resp, _) = api.raw_json_request(&request, 1).await.expect("Raw calls should succeed"); assert_eq!( - resp.result, + resp.into_result(), r#"{"jsonrpc":"2.0","error":{"code":-32601,"message":"RPC call is unsafe to be called externally"},"id":1}"# ); } From a7032d9cdc5a24c961e0e7a476c0aa8e32ad5419 Mon Sep 17 00:00:00 2001 From: Niklas Adolfsson Date: Wed, 7 Feb 2024 14:45:48 +0100 Subject: [PATCH 06/25] fix tests --- Cargo.lock | 16 ++++++++-------- Cargo.toml | 4 ++-- substrate/client/consensus/beefy/rpc/src/lib.rs | 16 +++++++--------- .../client/consensus/grandpa/rpc/src/lib.rs | 6 +++--- substrate/client/rpc/src/dev/tests.rs | 2 +- substrate/client/service/src/lib.rs | 2 +- 6 files changed, 22 insertions(+), 24 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f2196fe801669..898830ab1a32e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6821,7 +6821,7 @@ dependencies = [ [[package]] name = "jsonrpsee" version = "0.21.0" -source = "git+https://github.com/paritytech/jsonrpsee?branch=master#8470f2bb8d2a2b5e3c5cfd07f138aeab9dfbe022" +source = "git+https://github.com/paritytech/jsonrpsee?branch=na-adapt-rpc-module#74a4f8d5b99c2f7a6158c97f9b2a93aba723004d" dependencies = [ "jsonrpsee-core 0.21.0", "jsonrpsee-http-client", @@ -6856,7 +6856,7 @@ dependencies = [ [[package]] name = "jsonrpsee-client-transport" version = "0.21.0" -source = "git+https://github.com/paritytech/jsonrpsee?branch=master#8470f2bb8d2a2b5e3c5cfd07f138aeab9dfbe022" +source = "git+https://github.com/paritytech/jsonrpsee?branch=na-adapt-rpc-module#74a4f8d5b99c2f7a6158c97f9b2a93aba723004d" dependencies = [ "futures-util", "http", @@ -6897,7 +6897,7 @@ dependencies = [ [[package]] name = "jsonrpsee-core" version = "0.21.0" -source = "git+https://github.com/paritytech/jsonrpsee?branch=master#8470f2bb8d2a2b5e3c5cfd07f138aeab9dfbe022" +source = "git+https://github.com/paritytech/jsonrpsee?branch=na-adapt-rpc-module#74a4f8d5b99c2f7a6158c97f9b2a93aba723004d" dependencies = [ "anyhow", "async-lock 3.3.0", @@ -6922,7 +6922,7 @@ dependencies = [ [[package]] name = "jsonrpsee-http-client" version = "0.21.0" -source = "git+https://github.com/paritytech/jsonrpsee?branch=master#8470f2bb8d2a2b5e3c5cfd07f138aeab9dfbe022" +source = "git+https://github.com/paritytech/jsonrpsee?branch=na-adapt-rpc-module#74a4f8d5b99c2f7a6158c97f9b2a93aba723004d" dependencies = [ "async-trait", "hyper", @@ -6941,7 +6941,7 @@ dependencies = [ [[package]] name = "jsonrpsee-proc-macros" version = "0.21.0" -source = "git+https://github.com/paritytech/jsonrpsee?branch=master#8470f2bb8d2a2b5e3c5cfd07f138aeab9dfbe022" +source = "git+https://github.com/paritytech/jsonrpsee?branch=na-adapt-rpc-module#74a4f8d5b99c2f7a6158c97f9b2a93aba723004d" dependencies = [ "heck", "proc-macro-crate 3.0.0", @@ -6953,7 +6953,7 @@ dependencies = [ [[package]] name = "jsonrpsee-server" version = "0.21.0" -source = "git+https://github.com/paritytech/jsonrpsee?branch=master#8470f2bb8d2a2b5e3c5cfd07f138aeab9dfbe022" +source = "git+https://github.com/paritytech/jsonrpsee?branch=na-adapt-rpc-module#74a4f8d5b99c2f7a6158c97f9b2a93aba723004d" dependencies = [ "futures-util", "http", @@ -6990,7 +6990,7 @@ dependencies = [ [[package]] name = "jsonrpsee-types" version = "0.21.0" -source = "git+https://github.com/paritytech/jsonrpsee?branch=master#8470f2bb8d2a2b5e3c5cfd07f138aeab9dfbe022" +source = "git+https://github.com/paritytech/jsonrpsee?branch=na-adapt-rpc-module#74a4f8d5b99c2f7a6158c97f9b2a93aba723004d" dependencies = [ "anyhow", "beef", @@ -7015,7 +7015,7 @@ dependencies = [ [[package]] name = "jsonrpsee-ws-client" version = "0.21.0" -source = "git+https://github.com/paritytech/jsonrpsee?branch=master#8470f2bb8d2a2b5e3c5cfd07f138aeab9dfbe022" +source = "git+https://github.com/paritytech/jsonrpsee?branch=na-adapt-rpc-module#74a4f8d5b99c2f7a6158c97f9b2a93aba723004d" dependencies = [ "http", "jsonrpsee-client-transport 0.21.0", diff --git a/Cargo.toml b/Cargo.toml index abfd440d42046..c36a3f639e34e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -612,5 +612,5 @@ yamux = { opt-level = 3 } zeroize = { opt-level = 3 } [patch.crates-io] -jsonrpsee = { git = "https://github.com/paritytech/jsonrpsee", branch = "master" } -jsonrpsee-core = { git = "https://github.com/paritytech/jsonrpsee", branch = "master" } +jsonrpsee = { git = "https://github.com/paritytech/jsonrpsee", branch = "na-adapt-rpc-module" } +jsonrpsee-core = { git = "https://github.com/paritytech/jsonrpsee", branch = "na-adapt-rpc-module" } diff --git a/substrate/client/consensus/beefy/rpc/src/lib.rs b/substrate/client/consensus/beefy/rpc/src/lib.rs index c91f516465447..f01baee2d6ece 100644 --- a/substrate/client/consensus/beefy/rpc/src/lib.rs +++ b/substrate/client/consensus/beefy/rpc/src/lib.rs @@ -184,10 +184,10 @@ mod tests { async fn uninitialized_rpc_handler() { let (rpc, _) = setup_io_handler(); let request = r#"{"jsonrpc":"2.0","method":"beefy_getFinalizedHead","params":[],"id":1}"#; - let expected_response = r#"{"jsonrpc":"2.0","error":{"code":1,"message":"BEEFY RPC endpoint not ready"},"id":1}"#.to_string(); + let expected_response = r#"{"jsonrpc":"2.0","error":{"code":1,"message":"BEEFY RPC endpoint not ready"},"id":1}"#; let (response, _) = rpc.raw_json_request(&request, 1).await.unwrap(); - assert_eq!(expected_response, response.result); + assert_eq!(expected_response, response); } #[tokio::test] @@ -205,20 +205,18 @@ mod tests { \"jsonrpc\":\"2.0\",\ \"result\":\"0x2f0039e93a27221fcf657fb877a1d4f60307106113e885096cb44a461cd0afbf\",\ \"id\":1\ - }" - .to_string(); + }"; let not_ready = "{\ \"jsonrpc\":\"2.0\",\ \"error\":{\"code\":1,\"message\":\"BEEFY RPC endpoint not ready\"},\ \"id\":1\ - }" - .to_string(); + }"; let deadline = std::time::Instant::now() + std::time::Duration::from_secs(2); while std::time::Instant::now() < deadline { let (response, _) = io.raw_json_request(request, 1).await.expect("RPC requests work"); - if response.result != not_ready { - assert_eq!(response.into_result(), expected); + if response != not_ready { + assert_eq!(response, expected); // Success return } @@ -249,7 +247,7 @@ mod tests { .unwrap(); let expected = r#"{"jsonrpc":"2.0","result":false,"id":1}"#; - assert_eq!(response.into_result(), expected); + assert_eq!(response, expected); } fn create_finality_proof() -> BeefyVersionedFinalityProof { diff --git a/substrate/client/consensus/grandpa/rpc/src/lib.rs b/substrate/client/consensus/grandpa/rpc/src/lib.rs index 7c833ea823843..0557eab93e295 100644 --- a/substrate/client/consensus/grandpa/rpc/src/lib.rs +++ b/substrate/client/consensus/grandpa/rpc/src/lib.rs @@ -273,7 +273,7 @@ mod tests { let request = r#"{"jsonrpc":"2.0","method":"grandpa_roundState","params":[],"id":0}"#; let (response, _) = rpc.raw_json_request(&request, 1).await.unwrap(); - assert_eq!(expected_response, response.into_result()); + assert_eq!(expected_response, response); } #[tokio::test] @@ -295,7 +295,7 @@ mod tests { let request = r#"{"jsonrpc":"2.0","method":"grandpa_roundState","params":[],"id":0}"#; let (response, _) = rpc.raw_json_request(&request, 1).await.unwrap(); - assert_eq!(expected_response, response.into_result()); + assert_eq!(expected_response, response); } #[tokio::test] @@ -317,7 +317,7 @@ mod tests { .unwrap(); let expected = r#"{"jsonrpc":"2.0","result":false,"id":1}"#; - assert_eq!(response.into_result(), expected); + assert_eq!(response, expected); } fn create_justification() -> GrandpaJustification { diff --git a/substrate/client/rpc/src/dev/tests.rs b/substrate/client/rpc/src/dev/tests.rs index 1e6bf6fd25ca8..e8f9ba4990d25 100644 --- a/substrate/client/rpc/src/dev/tests.rs +++ b/substrate/client/rpc/src/dev/tests.rs @@ -100,7 +100,7 @@ async fn deny_unsafe_works() { let (resp, _) = api.raw_json_request(&request, 1).await.expect("Raw calls should succeed"); assert_eq!( - resp.into_result(), + resp, r#"{"jsonrpc":"2.0","error":{"code":-32601,"message":"RPC call is unsafe to be called externally"},"id":1}"# ); } diff --git a/substrate/client/service/src/lib.rs b/substrate/client/service/src/lib.rs index 58c6d5cf37153..dbf64187c942f 100644 --- a/substrate/client/service/src/lib.rs +++ b/substrate/client/service/src/lib.rs @@ -119,7 +119,7 @@ impl RpcHandlers { self.0 .raw_json_request(json_query, TOKIO_MPSC_MAX_SIZE) .await - .map(|(method_res, recv)| (method_res.into_result(), recv)) + .map(|(method_res, recv)| (method_res, recv)) } /// Provides access to the underlying `RpcModule` From be5052a92c6b51802ef12137cf9f233b6c15dc3d Mon Sep 17 00:00:00 2001 From: Niklas Adolfsson Date: Wed, 7 Feb 2024 16:12:44 +0100 Subject: [PATCH 07/25] jsonrpsee v0.22 --- Cargo.lock | 170 +++++++----------- Cargo.toml | 4 - .../relay-chain-rpc-interface/Cargo.toml | 2 +- cumulus/parachain-template/node/Cargo.toml | 2 +- cumulus/polkadot-parachain/Cargo.toml | 2 +- cumulus/test/service/Cargo.toml | 2 +- polkadot/rpc/Cargo.toml | 2 +- substrate/bin/minimal/node/Cargo.toml | 2 +- substrate/bin/node-template/node/Cargo.toml | 2 +- substrate/bin/node/cli/Cargo.toml | 2 +- substrate/bin/node/rpc/Cargo.toml | 2 +- .../client/consensus/babe/rpc/Cargo.toml | 2 +- .../client/consensus/beefy/rpc/Cargo.toml | 2 +- .../client/consensus/grandpa/rpc/Cargo.toml | 2 +- .../client/consensus/manual-seal/Cargo.toml | 2 +- .../merkle-mountain-range/rpc/Cargo.toml | 2 +- substrate/client/rpc-api/Cargo.toml | 2 +- substrate/client/rpc-servers/Cargo.toml | 2 +- substrate/client/rpc-spec-v2/Cargo.toml | 2 +- substrate/client/rpc/Cargo.toml | 2 +- substrate/client/service/Cargo.toml | 2 +- substrate/client/service/src/lib.rs | 1 - substrate/client/sync-state-rpc/Cargo.toml | 2 +- .../frame/transaction-payment/rpc/Cargo.toml | 2 +- .../frame/remote-externalities/Cargo.toml | 2 +- substrate/utils/frame/rpc/client/Cargo.toml | 2 +- .../rpc/state-trie-migration-rpc/Cargo.toml | 2 +- substrate/utils/frame/rpc/support/Cargo.toml | 4 +- substrate/utils/frame/rpc/system/Cargo.toml | 2 +- 29 files changed, 91 insertions(+), 138 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 898830ab1a32e..8ef124388e025 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4175,7 +4175,7 @@ dependencies = [ "either", "futures", "futures-timer", - "jsonrpsee 0.20.3", + "jsonrpsee", "parity-scale-codec", "pin-project", "polkadot-overseer", @@ -4305,7 +4305,7 @@ dependencies = [ "frame-system", "frame-system-rpc-runtime-api", "futures", - "jsonrpsee 0.21.0", + "jsonrpsee", "pallet-im-online", "pallet-timestamp", "pallet-transaction-payment", @@ -5634,7 +5634,7 @@ version = "0.35.0" dependencies = [ "futures", "indicatif", - "jsonrpsee 0.21.0", + "jsonrpsee", "log", "parity-scale-codec", "serde", @@ -6809,58 +6809,29 @@ checksum = "078e285eafdfb6c4b434e0d31e8cfcb5115b651496faca5749b88fafd4f23bfd" [[package]] name = "jsonrpsee" -version = "0.20.3" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "affdc52f7596ccb2d7645231fc6163bb314630c989b64998f3699a28b4d5d4dc" +checksum = "4a95f7cc23d5fab0cdeeaf6bad8c8f5e7a3aa7f0d211957ea78232b327ab27b0" dependencies = [ - "jsonrpsee-core 0.20.3", - "jsonrpsee-types 0.20.3", - "jsonrpsee-ws-client 0.20.3", -] - -[[package]] -name = "jsonrpsee" -version = "0.21.0" -source = "git+https://github.com/paritytech/jsonrpsee?branch=na-adapt-rpc-module#74a4f8d5b99c2f7a6158c97f9b2a93aba723004d" -dependencies = [ - "jsonrpsee-core 0.21.0", + "jsonrpsee-core 0.22.0", "jsonrpsee-http-client", "jsonrpsee-proc-macros", "jsonrpsee-server", - "jsonrpsee-types 0.21.0", - "jsonrpsee-ws-client 0.21.0", + "jsonrpsee-types 0.22.0", + "jsonrpsee-ws-client", "tokio", "tracing", ] [[package]] name = "jsonrpsee-client-transport" -version = "0.20.3" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5b005c793122d03217da09af68ba9383363caa950b90d3436106df8cabce935" -dependencies = [ - "futures-util", - "http", - "jsonrpsee-core 0.20.3", - "pin-project", - "rustls-native-certs 0.6.3", - "soketto", - "thiserror", - "tokio", - "tokio-rustls 0.24.1", - "tokio-util", - "tracing", - "url", -] - -[[package]] -name = "jsonrpsee-client-transport" -version = "0.21.0" -source = "git+https://github.com/paritytech/jsonrpsee?branch=na-adapt-rpc-module#74a4f8d5b99c2f7a6158c97f9b2a93aba723004d" +checksum = "6b1736cfa3845fd9f8f43751f2b8e0e83f7b6081e754502f7d63b6587692cc83" dependencies = [ "futures-util", "http", - "jsonrpsee-core 0.21.0", + "jsonrpsee-core 0.22.0", "pin-project", "rustls-native-certs 0.7.0", "rustls-pki-types", @@ -6875,29 +6846,25 @@ dependencies = [ [[package]] name = "jsonrpsee-core" -version = "0.20.3" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da2327ba8df2fdbd5e897e2b5ed25ce7f299d345b9736b6828814c3dbd1fd47b" +checksum = "776d009e2f591b78c038e0d053a796f94575d66ca4e77dd84bfc5e81419e436c" dependencies = [ "anyhow", - "async-lock 2.8.0", "async-trait", "beef", - "futures-timer", - "futures-util", - "jsonrpsee-types 0.20.3", - "rustc-hash", + "jsonrpsee-types 0.21.0", "serde", "serde_json", "thiserror", - "tokio", "tracing", ] [[package]] name = "jsonrpsee-core" -version = "0.21.0" -source = "git+https://github.com/paritytech/jsonrpsee?branch=na-adapt-rpc-module#74a4f8d5b99c2f7a6158c97f9b2a93aba723004d" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82030d038658974732103e623ba2e0abec03bbbe175b39c0a2fafbada60c5868" dependencies = [ "anyhow", "async-lock 3.3.0", @@ -6906,7 +6873,7 @@ dependencies = [ "futures-timer", "futures-util", "hyper", - "jsonrpsee-types 0.21.0", + "jsonrpsee-types 0.22.0", "parking_lot 0.12.1", "pin-project", "rand", @@ -6921,14 +6888,15 @@ dependencies = [ [[package]] name = "jsonrpsee-http-client" -version = "0.21.0" -source = "git+https://github.com/paritytech/jsonrpsee?branch=na-adapt-rpc-module#74a4f8d5b99c2f7a6158c97f9b2a93aba723004d" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "36a06ef0de060005fddf772d54597bb6a8b0413da47dcffd304b0306147b9678" dependencies = [ "async-trait", "hyper", "hyper-rustls", - "jsonrpsee-core 0.21.0", - "jsonrpsee-types 0.21.0", + "jsonrpsee-core 0.22.0", + "jsonrpsee-types 0.22.0", "serde", "serde_json", "thiserror", @@ -6940,8 +6908,9 @@ dependencies = [ [[package]] name = "jsonrpsee-proc-macros" -version = "0.21.0" -source = "git+https://github.com/paritytech/jsonrpsee?branch=na-adapt-rpc-module#74a4f8d5b99c2f7a6158c97f9b2a93aba723004d" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69fc56131589f82e57805f7338b87023db4aafef813555708b159787e34ad6bc" dependencies = [ "heck", "proc-macro-crate 3.0.0", @@ -6952,14 +6921,15 @@ dependencies = [ [[package]] name = "jsonrpsee-server" -version = "0.21.0" -source = "git+https://github.com/paritytech/jsonrpsee?branch=na-adapt-rpc-module#74a4f8d5b99c2f7a6158c97f9b2a93aba723004d" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d85be77fe5b2a94589e3164fb780017f7aff7d646b49278c0d0346af16975c8e" dependencies = [ "futures-util", "http", "hyper", - "jsonrpsee-core 0.21.0", - "jsonrpsee-types 0.21.0", + "jsonrpsee-core 0.22.0", + "jsonrpsee-types 0.22.0", "pin-project", "route-recognizer", "serde", @@ -6975,22 +6945,22 @@ dependencies = [ [[package]] name = "jsonrpsee-types" -version = "0.20.3" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5be0be325642e850ed0bdff426674d2e66b2b7117c9be23a7caef68a2902b7d9" +checksum = "3266dfb045c9174b24c77c2dfe0084914bb23a6b2597d70c9dc6018392e1cd1b" dependencies = [ "anyhow", "beef", "serde", "serde_json", "thiserror", - "tracing", ] [[package]] name = "jsonrpsee-types" -version = "0.21.0" -source = "git+https://github.com/paritytech/jsonrpsee?branch=na-adapt-rpc-module#74a4f8d5b99c2f7a6158c97f9b2a93aba723004d" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a48fdc1202eafc51c63e00406575e59493284ace8b8b61aa16f3a6db5d64f1a" dependencies = [ "anyhow", "beef", @@ -7001,26 +6971,14 @@ dependencies = [ [[package]] name = "jsonrpsee-ws-client" -version = "0.20.3" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bca9cb3933ccae417eb6b08c3448eb1cb46e39834e5b503e395e5e5bd08546c0" +checksum = "c5ce25d70a8e4d3cc574bbc3cad0137c326ad64b194793d5e7bbdd3fa4504181" dependencies = [ "http", - "jsonrpsee-client-transport 0.20.3", - "jsonrpsee-core 0.20.3", - "jsonrpsee-types 0.20.3", - "url", -] - -[[package]] -name = "jsonrpsee-ws-client" -version = "0.21.0" -source = "git+https://github.com/paritytech/jsonrpsee?branch=na-adapt-rpc-module#74a4f8d5b99c2f7a6158c97f9b2a93aba723004d" -dependencies = [ - "http", - "jsonrpsee-client-transport 0.21.0", - "jsonrpsee-core 0.21.0", - "jsonrpsee-types 0.21.0", + "jsonrpsee-client-transport", + "jsonrpsee-core 0.22.0", + "jsonrpsee-types 0.22.0", "url", ] @@ -8156,7 +8114,7 @@ dependencies = [ "frame", "futures", "futures-timer", - "jsonrpsee 0.21.0", + "jsonrpsee", "minimal-runtime", "sc-basic-authorship", "sc-cli", @@ -8272,7 +8230,7 @@ dependencies = [ name = "mmr-rpc" version = "28.0.0" dependencies = [ - "jsonrpsee 0.21.0", + "jsonrpsee", "parity-scale-codec", "serde", "serde_json", @@ -8658,7 +8616,7 @@ dependencies = [ name = "node-rpc" version = "3.0.0-dev" dependencies = [ - "jsonrpsee 0.21.0", + "jsonrpsee", "mmr-rpc", "node-primitives", "pallet-transaction-payment-rpc", @@ -8706,7 +8664,7 @@ dependencies = [ "frame-benchmarking-cli", "frame-system", "futures", - "jsonrpsee 0.21.0", + "jsonrpsee", "node-template-runtime", "pallet-transaction-payment", "pallet-transaction-payment-rpc", @@ -11037,7 +10995,7 @@ dependencies = [ name = "pallet-transaction-payment-rpc" version = "30.0.0" dependencies = [ - "jsonrpsee 0.21.0", + "jsonrpsee", "pallet-transaction-payment-rpc-runtime-api", "parity-scale-codec", "sp-api", @@ -11302,7 +11260,7 @@ dependencies = [ "frame-benchmarking", "frame-benchmarking-cli", "futures", - "jsonrpsee 0.21.0", + "jsonrpsee", "log", "pallet-transaction-payment-rpc", "parachain-template-runtime", @@ -13084,7 +13042,7 @@ dependencies = [ "futures", "glutton-westend-runtime", "hex-literal", - "jsonrpsee 0.21.0", + "jsonrpsee", "log", "nix 0.26.2", "pallet-transaction-payment", @@ -13203,7 +13161,7 @@ dependencies = [ name = "polkadot-rpc" version = "7.0.0" dependencies = [ - "jsonrpsee 0.21.0", + "jsonrpsee", "mmr-rpc", "pallet-transaction-payment-rpc", "polkadot-primitives", @@ -15797,7 +15755,7 @@ name = "sc-consensus-babe-rpc" version = "0.34.0" dependencies = [ "futures", - "jsonrpsee 0.21.0", + "jsonrpsee", "sc-consensus", "sc-consensus-babe", "sc-consensus-epochs", @@ -15868,7 +15826,7 @@ name = "sc-consensus-beefy-rpc" version = "13.0.0" dependencies = [ "futures", - "jsonrpsee 0.21.0", + "jsonrpsee", "log", "parity-scale-codec", "parking_lot 0.12.1", @@ -15951,7 +15909,7 @@ version = "0.19.0" dependencies = [ "finality-grandpa", "futures", - "jsonrpsee 0.21.0", + "jsonrpsee", "log", "parity-scale-codec", "sc-block-builder", @@ -15977,7 +15935,7 @@ dependencies = [ "async-trait", "futures", "futures-timer", - "jsonrpsee 0.21.0", + "jsonrpsee", "log", "parity-scale-codec", "sc-basic-authorship", @@ -16487,7 +16445,7 @@ dependencies = [ "assert_matches", "env_logger 0.9.3", "futures", - "jsonrpsee 0.21.0", + "jsonrpsee", "log", "parity-scale-codec", "parking_lot 0.12.1", @@ -16526,7 +16484,7 @@ dependencies = [ name = "sc-rpc-api" version = "0.33.0" dependencies = [ - "jsonrpsee 0.21.0", + "jsonrpsee", "parity-scale-codec", "sc-chain-spec", "sc-mixnet", @@ -16548,7 +16506,7 @@ dependencies = [ "futures", "http", "hyper", - "jsonrpsee 0.21.0", + "jsonrpsee", "log", "pin-project", "serde_json", @@ -16567,7 +16525,7 @@ dependencies = [ "futures", "futures-util", "hex", - "jsonrpsee 0.21.0", + "jsonrpsee", "log", "parity-scale-codec", "parking_lot 0.12.1", @@ -16618,7 +16576,7 @@ dependencies = [ "exit-future", "futures", "futures-timer", - "jsonrpsee 0.21.0", + "jsonrpsee", "log", "parity-scale-codec", "parking_lot 0.12.1", @@ -16755,7 +16713,7 @@ dependencies = [ name = "sc-sync-state-rpc" version = "0.34.0" dependencies = [ - "jsonrpsee 0.21.0", + "jsonrpsee", "parity-scale-codec", "sc-chain-spec", "sc-client-api", @@ -19314,7 +19272,7 @@ dependencies = [ "frame-system", "frame-system-rpc-runtime-api", "futures", - "jsonrpsee 0.21.0", + "jsonrpsee", "kitchensink-runtime", "log", "mmr-gadget", @@ -19670,7 +19628,7 @@ version = "29.0.0" dependencies = [ "frame-support", "frame-system", - "jsonrpsee 0.21.0", + "jsonrpsee", "parity-scale-codec", "sc-rpc-api", "scale-info", @@ -19688,7 +19646,7 @@ dependencies = [ "assert_matches", "frame-system-rpc-runtime-api", "futures", - "jsonrpsee 0.21.0", + "jsonrpsee", "log", "parity-scale-codec", "sc-rpc-api", @@ -19720,7 +19678,7 @@ name = "substrate-rpc-client" version = "0.33.0" dependencies = [ "async-trait", - "jsonrpsee 0.21.0", + "jsonrpsee", "log", "sc-rpc-api", "serde", @@ -19733,7 +19691,7 @@ dependencies = [ name = "substrate-state-trie-migration-rpc" version = "27.0.0" dependencies = [ - "jsonrpsee 0.21.0", + "jsonrpsee", "parity-scale-codec", "sc-client-api", "sc-rpc-api", diff --git a/Cargo.toml b/Cargo.toml index c36a3f639e34e..e807171b24c46 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -610,7 +610,3 @@ wasmi = { opt-level = 3 } x25519-dalek = { opt-level = 3 } yamux = { opt-level = 3 } zeroize = { opt-level = 3 } - -[patch.crates-io] -jsonrpsee = { git = "https://github.com/paritytech/jsonrpsee", branch = "na-adapt-rpc-module" } -jsonrpsee-core = { git = "https://github.com/paritytech/jsonrpsee", branch = "na-adapt-rpc-module" } diff --git a/cumulus/client/relay-chain-rpc-interface/Cargo.toml b/cumulus/client/relay-chain-rpc-interface/Cargo.toml index fef6f82537d7e..fc89cdd5a9e5c 100644 --- a/cumulus/client/relay-chain-rpc-interface/Cargo.toml +++ b/cumulus/client/relay-chain-rpc-interface/Cargo.toml @@ -33,7 +33,7 @@ tokio-util = { version = "0.7.8", features = ["compat"] } futures = "0.3.28" futures-timer = "3.0.2" parity-scale-codec = "3.6.4" -jsonrpsee = { version = "0.20.3", features = ["ws-client"] } +jsonrpsee = { version = "0.22", features = ["ws-client"] } tracing = "0.1.37" async-trait = "0.1.74" url = "2.4.0" diff --git a/cumulus/parachain-template/node/Cargo.toml b/cumulus/parachain-template/node/Cargo.toml index 28d22379e54a2..03071a4cf1512 100644 --- a/cumulus/parachain-template/node/Cargo.toml +++ b/cumulus/parachain-template/node/Cargo.toml @@ -18,7 +18,7 @@ clap = { version = "4.4.18", features = ["derive"] } log = "0.4.20" codec = { package = "parity-scale-codec", version = "3.0.0" } serde = { version = "1.0.195", features = ["derive"] } -jsonrpsee = { version = "0.21", features = ["server"] } +jsonrpsee = { version = "0.22", features = ["server"] } futures = "0.3.28" serde_json = "1.0.111" diff --git a/cumulus/polkadot-parachain/Cargo.toml b/cumulus/polkadot-parachain/Cargo.toml index 0d55b54adfcea..186ec13a9f548 100644 --- a/cumulus/polkadot-parachain/Cargo.toml +++ b/cumulus/polkadot-parachain/Cargo.toml @@ -38,7 +38,7 @@ coretime-rococo-runtime = { path = "../parachains/runtimes/coretime/coretime-roc coretime-westend-runtime = { path = "../parachains/runtimes/coretime/coretime-westend" } bridge-hub-westend-runtime = { path = "../parachains/runtimes/bridge-hubs/bridge-hub-westend" } penpal-runtime = { path = "../parachains/runtimes/testing/penpal" } -jsonrpsee = { version = "0.21", features = ["server"] } +jsonrpsee = { version = "0.22", features = ["server"] } people-rococo-runtime = { path = "../parachains/runtimes/people/people-rococo" } people-westend-runtime = { path = "../parachains/runtimes/people/people-westend" } parachains-common = { path = "../parachains/common" } diff --git a/cumulus/test/service/Cargo.toml b/cumulus/test/service/Cargo.toml index bf5aab2126f18..b710146ffe8e0 100644 --- a/cumulus/test/service/Cargo.toml +++ b/cumulus/test/service/Cargo.toml @@ -17,7 +17,7 @@ async-trait = "0.1.74" clap = { version = "4.4.18", features = ["derive"] } codec = { package = "parity-scale-codec", version = "3.0.0" } criterion = { version = "0.5.1", features = ["async_tokio"] } -jsonrpsee = { version = "0.21", features = ["server"] } +jsonrpsee = { version = "0.22", features = ["server"] } rand = "0.8.5" serde = { version = "1.0.195", features = ["derive"] } serde_json = "1.0.111" diff --git a/polkadot/rpc/Cargo.toml b/polkadot/rpc/Cargo.toml index a4677e10fc2f7..5af5e63b17538 100644 --- a/polkadot/rpc/Cargo.toml +++ b/polkadot/rpc/Cargo.toml @@ -10,7 +10,7 @@ description = "Polkadot specific RPC functionality." workspace = true [dependencies] -jsonrpsee = { version = "0.21", features = ["server"] } +jsonrpsee = { version = "0.22", features = ["server"] } polkadot-primitives = { path = "../primitives" } sc-client-api = { path = "../../substrate/client/api" } sp-blockchain = { path = "../../substrate/primitives/blockchain" } diff --git a/substrate/bin/minimal/node/Cargo.toml b/substrate/bin/minimal/node/Cargo.toml index 97a2f01562aef..2cea39d0df8e7 100644 --- a/substrate/bin/minimal/node/Cargo.toml +++ b/substrate/bin/minimal/node/Cargo.toml @@ -23,7 +23,7 @@ name = "minimal-node" clap = { version = "4.4.18", features = ["derive"] } futures = { version = "0.3.21", features = ["thread-pool"] } futures-timer = "3.0.1" -jsonrpsee = { version = "0.21", features = ["server"] } +jsonrpsee = { version = "0.22", features = ["server"] } serde_json = "1.0.111" sc-cli = { path = "../../../client/cli" } diff --git a/substrate/bin/node-template/node/Cargo.toml b/substrate/bin/node-template/node/Cargo.toml index 797470440def0..0dcf2fefc43c9 100644 --- a/substrate/bin/node-template/node/Cargo.toml +++ b/substrate/bin/node-template/node/Cargo.toml @@ -48,7 +48,7 @@ frame-system = { path = "../../../frame/system" } pallet-transaction-payment = { path = "../../../frame/transaction-payment", default-features = false } # These dependencies are used for the node template's RPCs -jsonrpsee = { version = "0.21", features = ["server"] } +jsonrpsee = { version = "0.22", features = ["server"] } sp-api = { path = "../../../primitives/api" } sc-rpc-api = { path = "../../../client/rpc-api" } sp-blockchain = { path = "../../../primitives/blockchain" } diff --git a/substrate/bin/node/cli/Cargo.toml b/substrate/bin/node/cli/Cargo.toml index 375bd06a7c890..fed725752244f 100644 --- a/substrate/bin/node/cli/Cargo.toml +++ b/substrate/bin/node/cli/Cargo.toml @@ -44,7 +44,7 @@ array-bytes = "6.1" clap = { version = "4.4.18", features = ["derive"], optional = true } codec = { package = "parity-scale-codec", version = "3.6.1" } serde = { version = "1.0.195", features = ["derive"] } -jsonrpsee = { version = "0.21", features = ["server"] } +jsonrpsee = { version = "0.22", features = ["server"] } futures = "0.3.21" log = "0.4.17" rand = "0.8" diff --git a/substrate/bin/node/rpc/Cargo.toml b/substrate/bin/node/rpc/Cargo.toml index 92684e02fd193..894dbf0da85ca 100644 --- a/substrate/bin/node/rpc/Cargo.toml +++ b/substrate/bin/node/rpc/Cargo.toml @@ -16,7 +16,7 @@ workspace = true targets = ["x86_64-unknown-linux-gnu"] [dependencies] -jsonrpsee = { version = "0.21", features = ["server"] } +jsonrpsee = { version = "0.22", features = ["server"] } node-primitives = { path = "../primitives" } pallet-transaction-payment-rpc = { path = "../../../frame/transaction-payment/rpc" } mmr-rpc = { path = "../../../client/merkle-mountain-range/rpc" } diff --git a/substrate/client/consensus/babe/rpc/Cargo.toml b/substrate/client/consensus/babe/rpc/Cargo.toml index 6ae6de87a3bea..49b4b1a4a6d83 100644 --- a/substrate/client/consensus/babe/rpc/Cargo.toml +++ b/substrate/client/consensus/babe/rpc/Cargo.toml @@ -16,7 +16,7 @@ workspace = true targets = ["x86_64-unknown-linux-gnu"] [dependencies] -jsonrpsee = { version = "0.21", features = ["client-core", "macros", "server"] } +jsonrpsee = { version = "0.22", features = ["client-core", "macros", "server"] } futures = "0.3.21" serde = { version = "1.0.195", features = ["derive"] } thiserror = "1.0" diff --git a/substrate/client/consensus/beefy/rpc/Cargo.toml b/substrate/client/consensus/beefy/rpc/Cargo.toml index 95a6e7b351ae8..b35a4d94c11bf 100644 --- a/substrate/client/consensus/beefy/rpc/Cargo.toml +++ b/substrate/client/consensus/beefy/rpc/Cargo.toml @@ -14,7 +14,7 @@ workspace = true [dependencies] codec = { package = "parity-scale-codec", version = "3.6.1", features = ["derive"] } futures = "0.3.21" -jsonrpsee = { version = "0.21", features = ["client-core", "macros", "server"] } +jsonrpsee = { version = "0.22", features = ["client-core", "macros", "server"] } log = "0.4" parking_lot = "0.12.1" serde = { version = "1.0.195", features = ["derive"] } diff --git a/substrate/client/consensus/grandpa/rpc/Cargo.toml b/substrate/client/consensus/grandpa/rpc/Cargo.toml index f49a08c570d9c..76fba9f9d7e26 100644 --- a/substrate/client/consensus/grandpa/rpc/Cargo.toml +++ b/substrate/client/consensus/grandpa/rpc/Cargo.toml @@ -15,7 +15,7 @@ workspace = true [dependencies] finality-grandpa = { version = "0.16.2", features = ["derive-codec"] } futures = "0.3.16" -jsonrpsee = { version = "0.21", features = ["client-core", "macros", "server"] } +jsonrpsee = { version = "0.22", features = ["client-core", "macros", "server"] } log = "0.4.8" parity-scale-codec = { version = "3.6.1", features = ["derive"] } serde = { version = "1.0.195", features = ["derive"] } diff --git a/substrate/client/consensus/manual-seal/Cargo.toml b/substrate/client/consensus/manual-seal/Cargo.toml index 27e92d251d5cf..6136d23a3462c 100644 --- a/substrate/client/consensus/manual-seal/Cargo.toml +++ b/substrate/client/consensus/manual-seal/Cargo.toml @@ -16,7 +16,7 @@ workspace = true targets = ["x86_64-unknown-linux-gnu"] [dependencies] -jsonrpsee = { version = "0.21", features = ["client-core", "macros", "server"] } +jsonrpsee = { version = "0.22", features = ["client-core", "macros", "server"] } assert_matches = "1.3.0" async-trait = "0.1.74" codec = { package = "parity-scale-codec", version = "3.6.1" } diff --git a/substrate/client/merkle-mountain-range/rpc/Cargo.toml b/substrate/client/merkle-mountain-range/rpc/Cargo.toml index 41fa59de00284..79286cf961d26 100644 --- a/substrate/client/merkle-mountain-range/rpc/Cargo.toml +++ b/substrate/client/merkle-mountain-range/rpc/Cargo.toml @@ -16,7 +16,7 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] codec = { package = "parity-scale-codec", version = "3.6.1" } -jsonrpsee = { version = "0.21", features = ["client-core", "macros", "server"] } +jsonrpsee = { version = "0.22", features = ["client-core", "macros", "server"] } serde = { version = "1.0.195", features = ["derive"] } sp-api = { path = "../../../primitives/api" } sp-blockchain = { path = "../../../primitives/blockchain" } diff --git a/substrate/client/rpc-api/Cargo.toml b/substrate/client/rpc-api/Cargo.toml index e05f5dc3c0271..45f47920e07b1 100644 --- a/substrate/client/rpc-api/Cargo.toml +++ b/substrate/client/rpc-api/Cargo.toml @@ -28,4 +28,4 @@ sp-core = { path = "../../primitives/core" } sp-rpc = { path = "../../primitives/rpc" } sp-runtime = { path = "../../primitives/runtime" } sp-version = { path = "../../primitives/version" } -jsonrpsee = { version = "0.21", features = ["client-core", "macros", "server"] } +jsonrpsee = { version = "0.22", features = ["client-core", "macros", "server"] } diff --git a/substrate/client/rpc-servers/Cargo.toml b/substrate/client/rpc-servers/Cargo.toml index 0b7a23394b0c5..c2a3dfea6c4f7 100644 --- a/substrate/client/rpc-servers/Cargo.toml +++ b/substrate/client/rpc-servers/Cargo.toml @@ -16,7 +16,7 @@ workspace = true targets = ["x86_64-unknown-linux-gnu"] [dependencies] -jsonrpsee = { version = "0.21", features = ["server"] } +jsonrpsee = { version = "0.22", features = ["server"] } log = "0.4.17" serde_json = "1.0.111" tokio = { version = "1.22.0", features = ["parking_lot"] } diff --git a/substrate/client/rpc-spec-v2/Cargo.toml b/substrate/client/rpc-spec-v2/Cargo.toml index 84fa3bdd25919..9074a6fd11ac7 100644 --- a/substrate/client/rpc-spec-v2/Cargo.toml +++ b/substrate/client/rpc-spec-v2/Cargo.toml @@ -16,7 +16,7 @@ workspace = true targets = ["x86_64-unknown-linux-gnu"] [dependencies] -jsonrpsee = { version = "0.21", features = ["client-core", "macros", "server"] } +jsonrpsee = { version = "0.22", features = ["client-core", "macros", "server"] } # Internal chain structures for "chain_spec". sc-chain-spec = { path = "../chain-spec" } # Pool for submitting extrinsics required by "transaction" diff --git a/substrate/client/rpc/Cargo.toml b/substrate/client/rpc/Cargo.toml index 8f4f28e2550bd..defa631d0e7f7 100644 --- a/substrate/client/rpc/Cargo.toml +++ b/substrate/client/rpc/Cargo.toml @@ -18,7 +18,7 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] codec = { package = "parity-scale-codec", version = "3.6.1" } futures = "0.3.21" -jsonrpsee = { version = "0.21", features = ["server"] } +jsonrpsee = { version = "0.22", features = ["server"] } log = "0.4.17" parking_lot = "0.12.1" serde_json = "1.0.111" diff --git a/substrate/client/service/Cargo.toml b/substrate/client/service/Cargo.toml index 1f16fe8c0807b..06e09fe6d5125 100644 --- a/substrate/client/service/Cargo.toml +++ b/substrate/client/service/Cargo.toml @@ -28,7 +28,7 @@ runtime-benchmarks = [ ] [dependencies] -jsonrpsee = { version = "0.21", features = ["server"] } +jsonrpsee = { version = "0.22", features = ["server"] } thiserror = "1.0.48" futures = "0.3.21" rand = "0.8.5" diff --git a/substrate/client/service/src/lib.rs b/substrate/client/service/src/lib.rs index dbf64187c942f..d239ede965d67 100644 --- a/substrate/client/service/src/lib.rs +++ b/substrate/client/service/src/lib.rs @@ -119,7 +119,6 @@ impl RpcHandlers { self.0 .raw_json_request(json_query, TOKIO_MPSC_MAX_SIZE) .await - .map(|(method_res, recv)| (method_res, recv)) } /// Provides access to the underlying `RpcModule` diff --git a/substrate/client/sync-state-rpc/Cargo.toml b/substrate/client/sync-state-rpc/Cargo.toml index 11c7b42f4af16..0d22bb105a683 100644 --- a/substrate/client/sync-state-rpc/Cargo.toml +++ b/substrate/client/sync-state-rpc/Cargo.toml @@ -16,7 +16,7 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] codec = { package = "parity-scale-codec", version = "3.6.1" } -jsonrpsee = { version = "0.21", features = ["client-core", "macros", "server"] } +jsonrpsee = { version = "0.22", features = ["client-core", "macros", "server"] } serde = { version = "1.0.195", features = ["derive"] } serde_json = "1.0.111" thiserror = "1.0.48" diff --git a/substrate/frame/transaction-payment/rpc/Cargo.toml b/substrate/frame/transaction-payment/rpc/Cargo.toml index 43116c402fcfd..6d7f632af8281 100644 --- a/substrate/frame/transaction-payment/rpc/Cargo.toml +++ b/substrate/frame/transaction-payment/rpc/Cargo.toml @@ -17,7 +17,7 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] codec = { package = "parity-scale-codec", version = "3.6.1" } -jsonrpsee = { version = "0.21", features = ["client-core", "macros", "server"] } +jsonrpsee = { version = "0.22", features = ["client-core", "macros", "server"] } pallet-transaction-payment-rpc-runtime-api = { path = "runtime-api" } sp-api = { path = "../../../primitives/api" } sp-blockchain = { path = "../../../primitives/blockchain" } diff --git a/substrate/utils/frame/remote-externalities/Cargo.toml b/substrate/utils/frame/remote-externalities/Cargo.toml index 41462aacb6ec1..2fb9d83f55557 100644 --- a/substrate/utils/frame/remote-externalities/Cargo.toml +++ b/substrate/utils/frame/remote-externalities/Cargo.toml @@ -15,7 +15,7 @@ workspace = true targets = ["x86_64-unknown-linux-gnu"] [dependencies] -jsonrpsee = { version = "0.21", features = ["http-client"] } +jsonrpsee = { version = "0.22", features = ["http-client"] } codec = { package = "parity-scale-codec", version = "3.6.1" } log = "0.4.17" serde = "1.0.195" diff --git a/substrate/utils/frame/rpc/client/Cargo.toml b/substrate/utils/frame/rpc/client/Cargo.toml index ce1d311ab3c64..6b085c75735a2 100644 --- a/substrate/utils/frame/rpc/client/Cargo.toml +++ b/substrate/utils/frame/rpc/client/Cargo.toml @@ -15,7 +15,7 @@ workspace = true targets = ["x86_64-unknown-linux-gnu"] [dependencies] -jsonrpsee = { version = "0.21", features = ["ws-client"] } +jsonrpsee = { version = "0.22", features = ["ws-client"] } sc-rpc-api = { path = "../../../../client/rpc-api" } async-trait = "0.1.74" serde = "1" diff --git a/substrate/utils/frame/rpc/state-trie-migration-rpc/Cargo.toml b/substrate/utils/frame/rpc/state-trie-migration-rpc/Cargo.toml index 49bfbfe75d5b7..b2004bfcacd63 100644 --- a/substrate/utils/frame/rpc/state-trie-migration-rpc/Cargo.toml +++ b/substrate/utils/frame/rpc/state-trie-migration-rpc/Cargo.toml @@ -24,7 +24,7 @@ sp-state-machine = { path = "../../../../primitives/state-machine" } sp-trie = { path = "../../../../primitives/trie" } trie-db = "0.28.0" -jsonrpsee = { version = "0.21", features = ["client-core", "macros", "server"] } +jsonrpsee = { version = "0.22", features = ["client-core", "macros", "server"] } # Substrate Dependencies sc-client-api = { path = "../../../../client/api" } diff --git a/substrate/utils/frame/rpc/support/Cargo.toml b/substrate/utils/frame/rpc/support/Cargo.toml index 8c50c6847713a..a4b0a7777fbf8 100644 --- a/substrate/utils/frame/rpc/support/Cargo.toml +++ b/substrate/utils/frame/rpc/support/Cargo.toml @@ -16,7 +16,7 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] codec = { package = "parity-scale-codec", version = "3.6.1" } -jsonrpsee = { version = "0.21", features = ["jsonrpsee-types"] } +jsonrpsee = { version = "0.22", features = ["jsonrpsee-types"] } serde = "1" frame-support = { path = "../../../../frame/support" } sc-rpc-api = { path = "../../../../client/rpc-api" } @@ -24,7 +24,7 @@ sp-storage = { path = "../../../../primitives/storage" } [dev-dependencies] scale-info = "2.10.0" -jsonrpsee = { version = "0.21", features = ["jsonrpsee-types", "ws-client"] } +jsonrpsee = { version = "0.22", features = ["jsonrpsee-types", "ws-client"] } tokio = "1.22.0" sp-core = { path = "../../../../primitives/core" } sp-runtime = { path = "../../../../primitives/runtime" } diff --git a/substrate/utils/frame/rpc/system/Cargo.toml b/substrate/utils/frame/rpc/system/Cargo.toml index 2639121894dbf..67849220ddf3a 100644 --- a/substrate/utils/frame/rpc/system/Cargo.toml +++ b/substrate/utils/frame/rpc/system/Cargo.toml @@ -17,7 +17,7 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] codec = { package = "parity-scale-codec", version = "3.6.1" } -jsonrpsee = { version = "0.21", features = ["client-core", "macros", "server"] } +jsonrpsee = { version = "0.22", features = ["client-core", "macros", "server"] } futures = "0.3.21" log = "0.4.17" frame-system-rpc-runtime-api = { path = "../../../../frame/system/rpc/runtime-api" } From 6326b347928e496454e1451741a5eb94370f1c67 Mon Sep 17 00:00:00 2001 From: Niklas Adolfsson Date: Wed, 7 Feb 2024 17:02:25 +0100 Subject: [PATCH 08/25] fix more nits --- substrate/client/consensus/babe/rpc/src/lib.rs | 4 ++-- substrate/client/service/src/lib.rs | 4 +--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/substrate/client/consensus/babe/rpc/src/lib.rs b/substrate/client/consensus/babe/rpc/src/lib.rs index 6fde56d2a0e55..8b183e7dfdcd3 100644 --- a/substrate/client/consensus/babe/rpc/src/lib.rs +++ b/substrate/client/consensus/babe/rpc/src/lib.rs @@ -260,7 +260,7 @@ mod tests { let (response, _) = api.raw_json_request(request, 1).await.unwrap(); let expected = r#"{"jsonrpc":"2.0","result":{"5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY":{"primary":[0],"secondary":[1,2,4],"secondary_vrf":[]}},"id":1}"#; - assert_eq!(response.as_result(), expected); + assert_eq!(response, expected); } #[tokio::test] @@ -272,6 +272,6 @@ mod tests { let (response, _) = api.raw_json_request(request, 1).await.unwrap(); let expected = r#"{"jsonrpc":"2.0","error":{"code":-32601,"message":"RPC call is unsafe to be called externally"},"id":1}"#; - assert_eq!(response.as_result(), expected); + assert_eq!(response, expected); } } diff --git a/substrate/client/service/src/lib.rs b/substrate/client/service/src/lib.rs index d239ede965d67..1fbfd14c3beba 100644 --- a/substrate/client/service/src/lib.rs +++ b/substrate/client/service/src/lib.rs @@ -116,9 +116,7 @@ impl RpcHandlers { // This limit is used to prevent panics and is large enough. const TOKIO_MPSC_MAX_SIZE: usize = tokio::sync::Semaphore::MAX_PERMITS; - self.0 - .raw_json_request(json_query, TOKIO_MPSC_MAX_SIZE) - .await + self.0.raw_json_request(json_query, TOKIO_MPSC_MAX_SIZE).await } /// Provides access to the underlying `RpcModule` From 6d088e19fc8a124d5a25dcf369bdc0c1c678edee Mon Sep 17 00:00:00 2001 From: Niklas Adolfsson Date: Wed, 7 Feb 2024 17:07:30 +0100 Subject: [PATCH 09/25] Update cumulus/client/relay-chain-interface/Cargo.toml --- cumulus/client/relay-chain-interface/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cumulus/client/relay-chain-interface/Cargo.toml b/cumulus/client/relay-chain-interface/Cargo.toml index 3346de8b5ee4c..5cdfff23ae170 100644 --- a/cumulus/client/relay-chain-interface/Cargo.toml +++ b/cumulus/client/relay-chain-interface/Cargo.toml @@ -22,5 +22,5 @@ sc-client-api = { path = "../../../substrate/client/api" } futures = "0.3.28" async-trait = "0.1.74" thiserror = "1.0.48" -jsonrpsee-core = "0.21" +jsonrpsee-core = "0.22" parity-scale-codec = "3.6.4" From b77a9927e3906a7b3834f5e9ed7c07d6c96a5abc Mon Sep 17 00:00:00 2001 From: Niklas Adolfsson Date: Wed, 7 Feb 2024 17:25:27 +0100 Subject: [PATCH 10/25] update Cargo.lock --- Cargo.lock | 51 +++++++++++---------------------------------------- 1 file changed, 11 insertions(+), 40 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0fe31d60af342..84f2af9211337 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4115,7 +4115,7 @@ dependencies = [ "async-trait", "cumulus-primitives-core", "futures", - "jsonrpsee-core 0.21.0", + "jsonrpsee-core", "parity-scale-codec", "polkadot-overseer", "sc-client-api", @@ -6813,11 +6813,11 @@ version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4a95f7cc23d5fab0cdeeaf6bad8c8f5e7a3aa7f0d211957ea78232b327ab27b0" dependencies = [ - "jsonrpsee-core 0.22.0", + "jsonrpsee-core", "jsonrpsee-http-client", "jsonrpsee-proc-macros", "jsonrpsee-server", - "jsonrpsee-types 0.22.0", + "jsonrpsee-types", "jsonrpsee-ws-client", "tokio", "tracing", @@ -6831,7 +6831,7 @@ checksum = "6b1736cfa3845fd9f8f43751f2b8e0e83f7b6081e754502f7d63b6587692cc83" dependencies = [ "futures-util", "http", - "jsonrpsee-core 0.22.0", + "jsonrpsee-core", "pin-project", "rustls-native-certs 0.7.0", "rustls-pki-types", @@ -6844,22 +6844,6 @@ dependencies = [ "url", ] -[[package]] -name = "jsonrpsee-core" -version = "0.21.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "776d009e2f591b78c038e0d053a796f94575d66ca4e77dd84bfc5e81419e436c" -dependencies = [ - "anyhow", - "async-trait", - "beef", - "jsonrpsee-types 0.21.0", - "serde", - "serde_json", - "thiserror", - "tracing", -] - [[package]] name = "jsonrpsee-core" version = "0.22.0" @@ -6873,7 +6857,7 @@ dependencies = [ "futures-timer", "futures-util", "hyper", - "jsonrpsee-types 0.22.0", + "jsonrpsee-types", "parking_lot 0.12.1", "pin-project", "rand", @@ -6895,8 +6879,8 @@ dependencies = [ "async-trait", "hyper", "hyper-rustls", - "jsonrpsee-core 0.22.0", - "jsonrpsee-types 0.22.0", + "jsonrpsee-core", + "jsonrpsee-types", "serde", "serde_json", "thiserror", @@ -6928,8 +6912,8 @@ dependencies = [ "futures-util", "http", "hyper", - "jsonrpsee-core 0.22.0", - "jsonrpsee-types 0.22.0", + "jsonrpsee-core", + "jsonrpsee-types", "pin-project", "route-recognizer", "serde", @@ -6943,19 +6927,6 @@ dependencies = [ "tracing", ] -[[package]] -name = "jsonrpsee-types" -version = "0.21.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3266dfb045c9174b24c77c2dfe0084914bb23a6b2597d70c9dc6018392e1cd1b" -dependencies = [ - "anyhow", - "beef", - "serde", - "serde_json", - "thiserror", -] - [[package]] name = "jsonrpsee-types" version = "0.22.0" @@ -6977,8 +6948,8 @@ checksum = "c5ce25d70a8e4d3cc574bbc3cad0137c326ad64b194793d5e7bbdd3fa4504181" dependencies = [ "http", "jsonrpsee-client-transport", - "jsonrpsee-core 0.22.0", - "jsonrpsee-types 0.22.0", + "jsonrpsee-core", + "jsonrpsee-types", "url", ] From 4802cc404d76b626f9c328351c695c3f5c0893d5 Mon Sep 17 00:00:00 2001 From: Niklas Adolfsson Date: Wed, 7 Feb 2024 20:08:41 +0100 Subject: [PATCH 11/25] fix rustdocs --- substrate/utils/frame/rpc/support/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/substrate/utils/frame/rpc/support/src/lib.rs b/substrate/utils/frame/rpc/support/src/lib.rs index 425afdb6117f3..8280c46aadf26 100644 --- a/substrate/utils/frame/rpc/support/src/lib.rs +++ b/substrate/utils/frame/rpc/support/src/lib.rs @@ -31,7 +31,7 @@ use sp_storage::{StorageData, StorageKey}; /// A typed query on chain state usable from an RPC client. /// /// ```no_run -/// # use jsonrpsee::core::Error as RpcError; +/// # use jsonrpsee::core::ClientError as RpcError; /// # use jsonrpsee::ws_client::WsClientBuilder; /// # use codec::Encode; /// # use frame_support::{construct_runtime, derive_impl, traits::ConstU32}; From 485393ff43b9a11a665b5bd1f074427abdfaa50d Mon Sep 17 00:00:00 2001 From: Niklas Adolfsson Date: Thu, 8 Feb 2024 11:00:34 +0100 Subject: [PATCH 12/25] remove needless box --- substrate/client/rpc-servers/src/lib.rs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/substrate/client/rpc-servers/src/lib.rs b/substrate/client/rpc-servers/src/lib.rs index fc54b4e7361cd..521ea52f95d44 100644 --- a/substrate/client/rpc-servers/src/lib.rs +++ b/substrate/client/rpc-servers/src/lib.rs @@ -24,7 +24,6 @@ pub mod middleware; use std::{convert::Infallible, error::Error as StdError, net::SocketAddr, time::Duration}; -use futures::FutureExt; use http::header::HeaderValue; use hyper::{ server::conn::AddrStream, @@ -168,13 +167,10 @@ pub async fn start_server( on_disconnect.await; metrics.as_ref().map(|m| m.ws_disconnect(now)); }); - - svc.call(req).await - } else { - svc.call(req).await } + + svc.call(req).await } - .boxed() })) } }); @@ -183,7 +179,7 @@ pub async fn start_server( tokio::spawn(async move { let graceful = server.with_graceful_shutdown(async move { stop_handle.shutdown().await }); - graceful.await.unwrap() + let _ = graceful.await; }); log::info!( From bdc42f6093969361e01bbfeaa0c12bb82ced1f8b Mon Sep 17 00:00:00 2001 From: Niklas Adolfsson Date: Thu, 8 Feb 2024 12:35:43 +0100 Subject: [PATCH 13/25] address grumbles --- .../rpc-spec-v2/src/chain_head/chain_head.rs | 31 +++++++++---------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/substrate/client/rpc-spec-v2/src/chain_head/chain_head.rs b/substrate/client/rpc-spec-v2/src/chain_head/chain_head.rs index a71c9eb50b1c9..1dfa850e2d5a4 100644 --- a/substrate/client/rpc-spec-v2/src/chain_head/chain_head.rs +++ b/substrate/client/rpc-spec-v2/src/chain_head/chain_head.rs @@ -264,12 +264,12 @@ where }), }; - let (rp, rp_is_success) = method_started_response(operation_id, None); + let (rp, rp_fut) = method_started_response(operation_id, None); let fut = async move { - // Events should only by generated if the response - // was successful. - if rp_is_success.await.is_err() { + // Events should only by generated + // if the response was successfully propagated. + if rp_fut.await.is_err() { return; } let _ = block_guard.response_sender().unbounded_send(event); @@ -324,11 +324,11 @@ where }, }; - let child_trie = child_trie - .map(|child_trie| parse_hex_param(child_trie)) - .transpose() - .unwrap() - .map(ChildInfo::new_default_from_vec); + let child_trie = match child_trie.map(|child_trie| parse_hex_param(child_trie)).transpose() + { + Ok(c) => c.map(ChildInfo::new_default_from_vec), + Err(e) => return ResponsePayload::error(e), + }; let mut block_guard = match self.subscriptions.lock_block(&follow_subscription, hash, items.len()) { @@ -360,8 +360,8 @@ where let (rp, rp_is_success) = method_started_response(operation_id, Some(discarded)); let fut = async move { - // Events should only by generated if the response - // was successful. + // Events should only by generated + // if the response was successfully propagated. if rp_is_success.await.is_err() { return; } @@ -425,12 +425,12 @@ where }) }); - let (rp, rp_is_success) = method_started_response(operation_id, None); + let (rp, rp_fut) = method_started_response(operation_id, None); let fut = async move { - // Events should only by generated if the response - // was successful. - if rp_is_success.await.is_err() { + // Events should only by generated + // if the response was successfully propagated. + if rp_fut.await.is_err() { return; } let _ = block_guard.response_sender().unbounded_send(event); @@ -506,6 +506,5 @@ fn method_started_response( discarded_items: Option, ) -> (ResponsePayload<'static, MethodResponse>, MethodResponseFuture) { let rp = MethodResponse::Started(MethodResponseStarted { operation_id, discarded_items }); - ResponsePayload::success(rp).notify_on_completion() } From 8bf3636ca72943587e3cd75328233ebfea4f0424 Mon Sep 17 00:00:00 2001 From: Niklas Adolfsson Date: Thu, 8 Feb 2024 12:41:35 +0100 Subject: [PATCH 14/25] Update substrate/client/rpc-servers/src/lib.rs --- substrate/client/rpc-servers/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/substrate/client/rpc-servers/src/lib.rs b/substrate/client/rpc-servers/src/lib.rs index 521ea52f95d44..a0683f19e1acb 100644 --- a/substrate/client/rpc-servers/src/lib.rs +++ b/substrate/client/rpc-servers/src/lib.rs @@ -132,7 +132,7 @@ pub async fn start_server( let (stop_handle, server_handle) = stop_channel(); let cfg = PerConnection { methods: build_rpc_api(rpc_api).into(), - service_builder: builder.to_service_builder().max_connections(max_connections), + service_builder: builder.to_service_builder(), metrics, tokio_handle, stop_handle: stop_handle.clone(), From 3a78c5444fbe8dafbbe223607c4f2c52fdfc4c47 Mon Sep 17 00:00:00 2001 From: Niklas Adolfsson Date: Thu, 8 Feb 2024 12:48:34 +0100 Subject: [PATCH 15/25] clarify breaking ws pings --- substrate/client/rpc-servers/src/lib.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/substrate/client/rpc-servers/src/lib.rs b/substrate/client/rpc-servers/src/lib.rs index a0683f19e1acb..14379861cb90a 100644 --- a/substrate/client/rpc-servers/src/lib.rs +++ b/substrate/client/rpc-servers/src/lib.rs @@ -117,7 +117,8 @@ pub async fn start_server( .enable_ws_ping( PingConfig::new() .ping_interval(Duration::from_secs(30)) - .inactive_limit(Duration::from_secs(50)), + .inactive_limit(Duration::from_secs(60)), + .max_failures(3) ) .set_http_middleware(http_middleware) .set_message_buffer_capacity(message_buffer_capacity) From 118480d250adc74bb98f95a469292f203a36b140 Mon Sep 17 00:00:00 2001 From: Niklas Adolfsson Date: Thu, 8 Feb 2024 13:11:03 +0100 Subject: [PATCH 16/25] fix nits --- substrate/client/rpc-servers/src/lib.rs | 4 ++-- substrate/client/rpc-servers/src/middleware/metrics.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/substrate/client/rpc-servers/src/lib.rs b/substrate/client/rpc-servers/src/lib.rs index 14379861cb90a..29b34b2945b13 100644 --- a/substrate/client/rpc-servers/src/lib.rs +++ b/substrate/client/rpc-servers/src/lib.rs @@ -117,8 +117,8 @@ pub async fn start_server( .enable_ws_ping( PingConfig::new() .ping_interval(Duration::from_secs(30)) - .inactive_limit(Duration::from_secs(60)), - .max_failures(3) + .inactive_limit(Duration::from_secs(60)) + .max_failures(3), ) .set_http_middleware(http_middleware) .set_message_buffer_capacity(message_buffer_capacity) diff --git a/substrate/client/rpc-servers/src/middleware/metrics.rs b/substrate/client/rpc-servers/src/middleware/metrics.rs index 09cb61cba752d..c2d1956c3b398 100644 --- a/substrate/client/rpc-servers/src/middleware/metrics.rs +++ b/substrate/client/rpc-servers/src/middleware/metrics.rs @@ -121,7 +121,7 @@ impl RpcMetrics { HistogramVec::new( HistogramOpts::new( "substrate_rpc_sessions_time", - "Time [s] for each websocket session", + "Total time [s] for each websocket session", ) .buckets(HISTOGRAM_BUCKETS.to_vec()), &["protocol"], From 6d96bd6304d5190c889acb7b449ef4506b308507 Mon Sep 17 00:00:00 2001 From: Niklas Adolfsson Date: Wed, 14 Feb 2024 13:03:14 +0100 Subject: [PATCH 17/25] add prdoc --- prdoc/pr_3230.prdoc | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 prdoc/pr_3230.prdoc diff --git a/prdoc/pr_3230.prdoc b/prdoc/pr_3230.prdoc new file mode 100644 index 0000000000000..f9e1bad0377ed --- /dev/null +++ b/prdoc/pr_3230.prdoc @@ -0,0 +1,14 @@ +# Schema: Polkadot SDK PRDoc Schema (prdoc) v1.0.0 +# See doc at https://raw.githubusercontent.com/paritytech/polkadot-sdk/master/prdoc/schema_user.json + +title: rpc server: remove prometheus metrics `substrate_rpc_requests_started/finished` and refactor WS ping/pongs. + +doc: + - audience: Node Operator + description: | + This commit updates the jsonrpc library to v0.22 and it has the following breaking changes: + - Remove prometheus RPC metrics `substrate_rpc_requests_started` and `substrate_rpc_requests_finished`. + - The RPC server now disconnects inactive peers that didn't acknowledge WebSocket + pings more than three times in time. + +crates: [] From 467f11b407dc9e43d6240fa9007ed08749d2d0e8 Mon Sep 17 00:00:00 2001 From: Niklas Adolfsson Date: Wed, 14 Feb 2024 13:11:19 +0100 Subject: [PATCH 18/25] improve prdoc --- prdoc/pr_3230.prdoc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/prdoc/pr_3230.prdoc b/prdoc/pr_3230.prdoc index f9e1bad0377ed..fdf9ac10c245e 100644 --- a/prdoc/pr_3230.prdoc +++ b/prdoc/pr_3230.prdoc @@ -6,9 +6,15 @@ title: rpc server: remove prometheus metrics `substrate_rpc_requests_started/fin doc: - audience: Node Operator description: | - This commit updates the jsonrpc library to v0.22 and it has the following breaking changes: + This updates the jsonrpc library to v0.22. + + Breaking changes: - Remove prometheus RPC metrics `substrate_rpc_requests_started` and `substrate_rpc_requests_finished`. - The RPC server now disconnects inactive peers that didn't acknowledge WebSocket pings more than three times in time. + Added: + - Add prometheus RPC `substrate_rpc_sessions_time` to collect how long time each WebSocket + session take. + crates: [] From 8a9e5c7c7fb008e4eb1e4e188a575e3adc0ec280 Mon Sep 17 00:00:00 2001 From: Niklas Adolfsson Date: Wed, 14 Feb 2024 13:22:00 +0100 Subject: [PATCH 19/25] fix prdoc --- prdoc/pr_3230.prdoc | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/prdoc/pr_3230.prdoc b/prdoc/pr_3230.prdoc index fdf9ac10c245e..4c908da9d9380 100644 --- a/prdoc/pr_3230.prdoc +++ b/prdoc/pr_3230.prdoc @@ -1,20 +1,19 @@ # Schema: Polkadot SDK PRDoc Schema (prdoc) v1.0.0 # See doc at https://raw.githubusercontent.com/paritytech/polkadot-sdk/master/prdoc/schema_user.json -title: rpc server: remove prometheus metrics `substrate_rpc_requests_started/finished` and refactor WS ping/pongs. +title: rpc server remove prometheus metrics substrate_rpc_requests_started/finished and refactor WS ping/pongs. doc: - audience: Node Operator description: | - This updates the jsonrpc library to v0.22. + Updates the jsonrpc library to v0.22 - Breaking changes: + Breaking changes: - Remove prometheus RPC metrics `substrate_rpc_requests_started` and `substrate_rpc_requests_finished`. - The RPC server now disconnects inactive peers that didn't acknowledge WebSocket pings more than three times in time. - Added: - - Add prometheus RPC `substrate_rpc_sessions_time` to collect how long time each WebSocket - session take. - -crates: [] + Added: + - Add prometheus RPC `substrate_rpc_sessions_time` to collect the duration for each WebSocket + session in seconds. +crates: [ ] From 1ad6d28be01b0f31c1b3111b2d052e661618c3ee Mon Sep 17 00:00:00 2001 From: Niklas Adolfsson Date: Wed, 14 Feb 2024 14:30:21 +0100 Subject: [PATCH 20/25] fix bad merge --- substrate/client/rpc-spec-v2/src/transaction/tests.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/substrate/client/rpc-spec-v2/src/transaction/tests.rs b/substrate/client/rpc-spec-v2/src/transaction/tests.rs index 45477494768ae..382f5adeae19e 100644 --- a/substrate/client/rpc-spec-v2/src/transaction/tests.rs +++ b/substrate/client/rpc-spec-v2/src/transaction/tests.rs @@ -24,7 +24,7 @@ use crate::{ use assert_matches::assert_matches; use codec::Encode; use futures::Future; -use jsonrpsee::{core::error::Error, rpc_params, RpcModule}; +use jsonrpsee::{rpc_params, MethodsError as Error, RpcModule}; use sc_transaction_pool::*; use sc_transaction_pool_api::{ChainEvent, MaintainedTransactionPool, TransactionPool}; use sp_core::{testing::TaskExecutor, traits::SpawnNamed}; @@ -194,7 +194,7 @@ async fn tx_broadcast_invalid_tx() { .await .unwrap_err(); assert_matches!(err, - Error::Call(err) if err.code() == super::error::json_rpc_spec::INVALID_PARAM_ERROR && err.message() == "Invalid params" + Error::JsonRpc(err) if err.code() == super::error::json_rpc_spec::INVALID_PARAM_ERROR && err.message() == "Invalid params" ); assert_eq!(0, pool.status().ready); @@ -219,7 +219,7 @@ async fn tx_broadcast_invalid_tx() { .await .unwrap_err(); assert_matches!(err, - Error::Call(err) if err.code() == super::error::json_rpc_spec::INVALID_PARAM_ERROR && err.message() == "Invalid operation id" + Error::JsonRpc(err) if err.code() == super::error::json_rpc_spec::INVALID_PARAM_ERROR && err.message() == "Invalid operation id" ); } @@ -233,6 +233,6 @@ async fn tx_invalid_stop() { .await .unwrap_err(); assert_matches!(err, - Error::Call(err) if err.code() == super::error::json_rpc_spec::INVALID_PARAM_ERROR && err.message() == "Invalid operation id" + Error::JsonRpc(err) if err.code() == super::error::json_rpc_spec::INVALID_PARAM_ERROR && err.message() == "Invalid operation id" ); } From 1a61781095608611200a41d51f5ff45c989f13a0 Mon Sep 17 00:00:00 2001 From: Niklas Adolfsson Date: Wed, 14 Feb 2024 14:34:06 +0100 Subject: [PATCH 21/25] Update prdoc/pr_3230.prdoc --- prdoc/pr_3230.prdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/prdoc/pr_3230.prdoc b/prdoc/pr_3230.prdoc index 4c908da9d9380..37e84592ca367 100644 --- a/prdoc/pr_3230.prdoc +++ b/prdoc/pr_3230.prdoc @@ -1,7 +1,7 @@ # Schema: Polkadot SDK PRDoc Schema (prdoc) v1.0.0 # See doc at https://raw.githubusercontent.com/paritytech/polkadot-sdk/master/prdoc/schema_user.json -title: rpc server remove prometheus metrics substrate_rpc_requests_started/finished and refactor WS ping/pongs. +title: rpc server remove prometheus metrics `substrate_rpc_requests_started/finished` and refactor WS ping/pongs. doc: - audience: Node Operator From 59361689bd5b30ac0ac17c8d2e37ce2103acf54d Mon Sep 17 00:00:00 2001 From: Niklas Adolfsson Date: Wed, 14 Feb 2024 14:36:09 +0100 Subject: [PATCH 22/25] Update prdoc/pr_3230.prdoc --- prdoc/pr_3230.prdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/prdoc/pr_3230.prdoc b/prdoc/pr_3230.prdoc index 37e84592ca367..1d8d7cff65cd2 100644 --- a/prdoc/pr_3230.prdoc +++ b/prdoc/pr_3230.prdoc @@ -6,7 +6,7 @@ title: rpc server remove prometheus metrics `substrate_rpc_requests_started/fini doc: - audience: Node Operator description: | - Updates the jsonrpc library to v0.22 + This PR updates the rpc server library to `jsonrpsee v0.22` to utilize new APIs. Breaking changes: - Remove prometheus RPC metrics `substrate_rpc_requests_started` and `substrate_rpc_requests_finished`. From 70b98a2b85bf4f79a00b701dfe8e790e4bddfdc6 Mon Sep 17 00:00:00 2001 From: Niklas Adolfsson Date: Wed, 14 Feb 2024 14:37:44 +0100 Subject: [PATCH 23/25] Update prdoc/pr_3230.prdoc --- prdoc/pr_3230.prdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/prdoc/pr_3230.prdoc b/prdoc/pr_3230.prdoc index 1d8d7cff65cd2..e6d32f918d391 100644 --- a/prdoc/pr_3230.prdoc +++ b/prdoc/pr_3230.prdoc @@ -15,5 +15,5 @@ doc: Added: - Add prometheus RPC `substrate_rpc_sessions_time` to collect the duration for each WebSocket - session in seconds. + session. crates: [ ] From 18b636e034803d55784946d38b119972805ea63e Mon Sep 17 00:00:00 2001 From: Niklas Adolfsson Date: Wed, 14 Feb 2024 15:16:02 +0100 Subject: [PATCH 24/25] improve subscription drop log --- substrate/client/rpc/src/utils.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/substrate/client/rpc/src/utils.rs b/substrate/client/rpc/src/utils.rs index b5ae4a2b6bc7f..6ec48efef846c 100644 --- a/substrate/client/rpc/src/utils.rs +++ b/substrate/client/rpc/src/utils.rs @@ -80,7 +80,7 @@ where Either::Left((Ok(sink), _)) => break sink, Either::Right((Some(msg), f)) => { if buf.push_back(msg).is_err() { - log::warn!(target: "rpc", "Subscription::accept failed buffer limit={} exceed; dropping subscription", buf.max_cap); + log::warn!(target: "rpc", "Subscription::accept failed buffer limit={} exceeded; dropping subscription", buf.max_cap); return } accept_fut = f; @@ -125,7 +125,13 @@ async fn inner_pipe_from_stream( // New item from the stream Either::Right((Either::Right((Some(v), n)), c)) => { if buf.push_back(v).is_err() { - log::warn!(target: "rpc", "Subscription buffer limit={} exceed; dropping subscription", buf.max_cap); + log::warn!( + target: "rpc", + "Subscription buffer limit={} exceeded for subscription={} conn_id={}; dropping subscription", + buf.max_cap, + sink.method_name(), + sink.connection_id() + ); return } From 0cbd07ac020eda204b69f34331feded9a1948f3b Mon Sep 17 00:00:00 2001 From: Niklas Adolfsson Date: Wed, 14 Feb 2024 22:52:03 +0100 Subject: [PATCH 25/25] fix merge nits --- substrate/client/rpc-spec-v2/src/chain_head/tests.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/substrate/client/rpc-spec-v2/src/chain_head/tests.rs b/substrate/client/rpc-spec-v2/src/chain_head/tests.rs index 06b387669f447..9544736d84c8e 100644 --- a/substrate/client/rpc-spec-v2/src/chain_head/tests.rs +++ b/substrate/client/rpc-spec-v2/src/chain_head/tests.rs @@ -1673,7 +1673,7 @@ async fn unpin_duplicate_hashes() { .await .unwrap_err(); assert_matches!(err, - Error::Call(err) if err.code() == super::error::rpc_spec_v2::INVALID_DUPLICATE_HASHES && err.message() == "Received duplicate hashes for the `chainHead_unpin` method" + Error::JsonRpc(err) if err.code() == super::error::rpc_spec_v2::INVALID_DUPLICATE_HASHES && err.message() == "Received duplicate hashes for the `chainHead_unpin` method" ); // Block tree: @@ -1708,7 +1708,7 @@ async fn unpin_duplicate_hashes() { .await .unwrap_err(); assert_matches!(err, - Error::Call(err) if err.code() == super::error::rpc_spec_v2::INVALID_DUPLICATE_HASHES && err.message() == "Received duplicate hashes for the `chainHead_unpin` method" + Error::JsonRpc(err) if err.code() == super::error::rpc_spec_v2::INVALID_DUPLICATE_HASHES && err.message() == "Received duplicate hashes for the `chainHead_unpin` method" ); // Can unpin blocks.