mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-09 20:11:09 +00:00
Upgrade jsonrpsee to v0.4.1 (#10022)
* Upgrade jsonrpsee to v0.4.1 * remove needless BlockT trait bound * use default wss port in URL * Fix try_runtime build * Partially fix for "remote-tests" feature * Review feedback * fmt * Sort out trait bounds for benches * Fmt * fmt again? * fmt with nightly-2021-09-13 * Upgrade try-runtime as well * fmt Co-authored-by: Niklas Adolfsson <niklasadolfsson1@gmail.com>
This commit is contained in:
Generated
+51
-79
@@ -144,9 +144,9 @@ checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "arrayvec"
|
name = "arrayvec"
|
||||||
version = "0.7.0"
|
version = "0.7.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "5a2f58b0bb10c380af2b26e57212856b8c9a59e0925b4c20f4a174a49734eaf7"
|
checksum = "be4dc07131ffa69b8072d35f5007352af944213cde02545e2103680baed38fcd"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "asn1_der"
|
name = "asn1_der"
|
||||||
@@ -419,19 +419,6 @@ dependencies = [
|
|||||||
"rustc-demangle",
|
"rustc-demangle",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "bae"
|
|
||||||
version = "0.1.6"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "ec107f431ee3d8a8e45e6dd117adab769556ef463959e77bf6a4888d5fd500cf"
|
|
||||||
dependencies = [
|
|
||||||
"heck",
|
|
||||||
"proc-macro-error 0.4.12",
|
|
||||||
"proc-macro2",
|
|
||||||
"quote",
|
|
||||||
"syn",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "base-x"
|
name = "base-x"
|
||||||
version = "0.2.8"
|
version = "0.2.8"
|
||||||
@@ -477,9 +464,9 @@ checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "beef"
|
name = "beef"
|
||||||
version = "0.5.0"
|
version = "0.5.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "6736e2428df2ca2848d846c43e88745121a6654696e349ce0054a420815a7409"
|
checksum = "bed554bd50246729a1ec158d08aa3235d1b69d94ad120ebe187e28894787e736"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"serde",
|
"serde",
|
||||||
]
|
]
|
||||||
@@ -1634,7 +1621,7 @@ dependencies = [
|
|||||||
"bitflags",
|
"bitflags",
|
||||||
"byteorder",
|
"byteorder",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
"proc-macro-error 1.0.4",
|
"proc-macro-error",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn",
|
"syn",
|
||||||
@@ -3141,13 +3128,24 @@ dependencies = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "jsonrpsee-proc-macros"
|
name = "jsonrpsee"
|
||||||
version = "0.3.1"
|
version = "0.4.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "8edb341d35279b59c79d7fe9e060a51aec29d45af99cc7c72ea7caa350fa71a4"
|
checksum = "6373a33d987866ccfe1af4bc11b089dce941764313f9fd8b7cf13fcb51b72dc5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"Inflector",
|
"jsonrpsee-proc-macros",
|
||||||
"bae",
|
"jsonrpsee-types",
|
||||||
|
"jsonrpsee-utils",
|
||||||
|
"jsonrpsee-ws-client",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "jsonrpsee-proc-macros"
|
||||||
|
version = "0.4.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d802063f7a3c867456955f9d2f15eb3ee0edb5ec9ec2b5526324756759221c0f"
|
||||||
|
dependencies = [
|
||||||
|
"log 0.4.14",
|
||||||
"proc-macro-crate 1.0.0",
|
"proc-macro-crate 1.0.0",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
@@ -3156,10 +3154,11 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "jsonrpsee-types"
|
name = "jsonrpsee-types"
|
||||||
version = "0.3.1"
|
version = "0.4.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "4cc738fd55b676ada3271ef7c383a14a0867a2a88b0fa941311bf5fc0a29d498"
|
checksum = "62f778cf245158fbd8f5d50823a2e9e4c708a40be164766bd35e9fb1d86715b2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"anyhow",
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"beef",
|
"beef",
|
||||||
"futures-channel",
|
"futures-channel",
|
||||||
@@ -3168,32 +3167,43 @@ dependencies = [
|
|||||||
"log 0.4.14",
|
"log 0.4.14",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"soketto 0.6.0",
|
"soketto 0.7.0",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "jsonrpsee-ws-client"
|
name = "jsonrpsee-utils"
|
||||||
version = "0.3.1"
|
version = "0.4.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9841352dbecf4c2ed5dc71698df9f1660262ae4e0b610e968602529bdbcf7b30"
|
checksum = "0109c4f972058f3b1925b73a17210aff7b63b65967264d0045d15ee88fe84f0c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"arrayvec 0.7.1",
|
||||||
|
"beef",
|
||||||
|
"jsonrpsee-types",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "jsonrpsee-ws-client"
|
||||||
|
version = "0.4.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "559aa56fc402af206c00fc913dc2be1d9d788dcde045d14df141a535245d35ef"
|
||||||
|
dependencies = [
|
||||||
|
"arrayvec 0.7.1",
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"fnv",
|
"fnv",
|
||||||
"futures 0.3.16",
|
"futures 0.3.16",
|
||||||
|
"http",
|
||||||
"jsonrpsee-types",
|
"jsonrpsee-types",
|
||||||
"log 0.4.14",
|
"log 0.4.14",
|
||||||
"pin-project 1.0.8",
|
"pin-project 1.0.8",
|
||||||
"rustls",
|
|
||||||
"rustls-native-certs",
|
"rustls-native-certs",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"soketto 0.6.0",
|
"soketto 0.7.0",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
"tokio",
|
"tokio",
|
||||||
"tokio-rustls",
|
"tokio-rustls",
|
||||||
"tokio-util",
|
"tokio-util",
|
||||||
"url 2.2.1",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -4353,7 +4363,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "424f6e86263cd5294cbd7f1e95746b95aca0e0d66bff31e5a40d6baa87b4aa99"
|
checksum = "424f6e86263cd5294cbd7f1e95746b95aca0e0d66bff31e5a40d6baa87b4aa99"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro-crate 1.0.0",
|
"proc-macro-crate 1.0.0",
|
||||||
"proc-macro-error 1.0.4",
|
"proc-macro-error",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn",
|
"syn",
|
||||||
@@ -6249,7 +6259,7 @@ version = "2.3.1"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "373b1a4c1338d9cd3d1fa53b3a11bdab5ab6bd80a20f7f7becd76953ae2be909"
|
checksum = "373b1a4c1338d9cd3d1fa53b3a11bdab5ab6bd80a20f7f7becd76953ae2be909"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"arrayvec 0.7.0",
|
"arrayvec 0.7.1",
|
||||||
"bitvec 0.20.2",
|
"bitvec 0.20.2",
|
||||||
"byte-slice-cast",
|
"byte-slice-cast",
|
||||||
"impl-trait-for-tuples",
|
"impl-trait-for-tuples",
|
||||||
@@ -6742,45 +6752,19 @@ dependencies = [
|
|||||||
"toml",
|
"toml",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "proc-macro-error"
|
|
||||||
version = "0.4.12"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "18f33027081eba0a6d8aba6d1b1c3a3be58cbb12106341c2d5759fcd9b5277e7"
|
|
||||||
dependencies = [
|
|
||||||
"proc-macro-error-attr 0.4.12",
|
|
||||||
"proc-macro2",
|
|
||||||
"quote",
|
|
||||||
"syn",
|
|
||||||
"version_check 0.9.2",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "proc-macro-error"
|
name = "proc-macro-error"
|
||||||
version = "1.0.4"
|
version = "1.0.4"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c"
|
checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro-error-attr 1.0.4",
|
"proc-macro-error-attr",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn",
|
"syn",
|
||||||
"version_check 0.9.2",
|
"version_check 0.9.2",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "proc-macro-error-attr"
|
|
||||||
version = "0.4.12"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "8a5b4b77fdb63c1eca72173d68d24501c54ab1269409f6b672c85deb18af69de"
|
|
||||||
dependencies = [
|
|
||||||
"proc-macro2",
|
|
||||||
"quote",
|
|
||||||
"syn",
|
|
||||||
"syn-mid",
|
|
||||||
"version_check 0.9.2",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "proc-macro-error-attr"
|
name = "proc-macro-error-attr"
|
||||||
version = "1.0.4"
|
version = "1.0.4"
|
||||||
@@ -7365,8 +7349,7 @@ version = "0.10.0-dev"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"env_logger 0.9.0",
|
"env_logger 0.9.0",
|
||||||
"frame-support",
|
"frame-support",
|
||||||
"jsonrpsee-proc-macros",
|
"jsonrpsee",
|
||||||
"jsonrpsee-ws-client",
|
|
||||||
"log 0.4.14",
|
"log 0.4.14",
|
||||||
"pallet-elections-phragmen",
|
"pallet-elections-phragmen",
|
||||||
"parity-scale-codec",
|
"parity-scale-codec",
|
||||||
@@ -9157,9 +9140,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "soketto"
|
name = "soketto"
|
||||||
version = "0.6.0"
|
version = "0.7.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "a74e48087dbeed4833785c2f3352b59140095dc192dce966a3bfc155020a439f"
|
checksum = "083624472e8817d44d02c0e55df043737ff11f279af924abdf93845717c2b75c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"base64 0.13.0",
|
"base64 0.13.0",
|
||||||
"bytes 1.0.1",
|
"bytes 1.0.1",
|
||||||
@@ -10062,7 +10045,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "134d838a2c9943ac3125cf6df165eda53493451b719f3255b2a26b85f772d0ba"
|
checksum = "134d838a2c9943ac3125cf6df165eda53493451b719f3255b2a26b85f772d0ba"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"heck",
|
"heck",
|
||||||
"proc-macro-error 1.0.4",
|
"proc-macro-error",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn",
|
"syn",
|
||||||
@@ -10355,17 +10338,6 @@ dependencies = [
|
|||||||
"unicode-xid",
|
"unicode-xid",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "syn-mid"
|
|
||||||
version = "0.5.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "baa8e7560a164edb1621a55d18a0c59abf49d360f47aa7b821061dd7eea7fac9"
|
|
||||||
dependencies = [
|
|
||||||
"proc-macro2",
|
|
||||||
"quote",
|
|
||||||
"syn",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "synstructure"
|
name = "synstructure"
|
||||||
version = "0.12.4"
|
version = "0.12.4"
|
||||||
@@ -10974,7 +10946,7 @@ checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642"
|
|||||||
name = "try-runtime-cli"
|
name = "try-runtime-cli"
|
||||||
version = "0.10.0-dev"
|
version = "0.10.0-dev"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"jsonrpsee-ws-client",
|
"jsonrpsee",
|
||||||
"log 0.4.14",
|
"log 0.4.14",
|
||||||
"parity-scale-codec",
|
"parity-scale-codec",
|
||||||
"remote-externalities",
|
"remote-externalities",
|
||||||
@@ -11447,7 +11419,7 @@ version = "1.0.2"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d8b86dcd2c3efdb8390728a2b56f762db07789aaa5aa872a9dc776ba3a7912ed"
|
checksum = "d8b86dcd2c3efdb8390728a2b56f762db07789aaa5aa872a9dc776ba3a7912ed"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro-error 1.0.4",
|
"proc-macro-error",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn",
|
"syn",
|
||||||
|
|||||||
@@ -130,7 +130,7 @@ async-std = { version = "1.10.0", features = ["attributes"] }
|
|||||||
soketto = "0.4.2"
|
soketto = "0.4.2"
|
||||||
criterion = { version = "0.3.5", features = [ "async_tokio" ] }
|
criterion = { version = "0.3.5", features = [ "async_tokio" ] }
|
||||||
tokio = { version = "1.10", features = ["macros", "time"] }
|
tokio = { version = "1.10", features = ["macros", "time"] }
|
||||||
jsonrpsee-ws-client = { version = "0.3.1", default-features = false, features = ["tokio1"] }
|
jsonrpsee-ws-client = "0.4.1"
|
||||||
wait-timeout = "0.2"
|
wait-timeout = "0.2"
|
||||||
remote-externalities = { path = "../../../utils/frame/remote-externalities" }
|
remote-externalities = { path = "../../../utils/frame/remote-externalities" }
|
||||||
pallet-timestamp = { version = "4.0.0-dev", path = "../../../frame/timestamp" }
|
pallet-timestamp = { version = "4.0.0-dev", path = "../../../frame/timestamp" }
|
||||||
|
|||||||
@@ -21,11 +21,11 @@ use frame_election_provider_support::SortedListProvider;
|
|||||||
use frame_support::traits::PalletInfoAccess;
|
use frame_support::traits::PalletInfoAccess;
|
||||||
use pallet_staking::Nominators;
|
use pallet_staking::Nominators;
|
||||||
use remote_externalities::{Builder, Mode, OnlineConfig};
|
use remote_externalities::{Builder, Mode, OnlineConfig};
|
||||||
use sp_runtime::traits::Block as BlockT;
|
use sp_runtime::{traits::Block as BlockT, DeserializeOwned};
|
||||||
|
|
||||||
/// Test voter bags migration. `currency_unit` is the number of planks per the the runtimes `UNITS`
|
/// Test voter bags migration. `currency_unit` is the number of planks per the the runtimes `UNITS`
|
||||||
/// (i.e. number of decimal places per DOT, KSM etc)
|
/// (i.e. number of decimal places per DOT, KSM etc)
|
||||||
pub async fn execute<Runtime: RuntimeT, Block: BlockT>(
|
pub async fn execute<Runtime: RuntimeT, Block: BlockT + DeserializeOwned>(
|
||||||
currency_unit: u64,
|
currency_unit: u64,
|
||||||
currency_name: &'static str,
|
currency_name: &'static str,
|
||||||
ws_url: String,
|
ws_url: String,
|
||||||
|
|||||||
@@ -22,11 +22,11 @@ use frame_support::{
|
|||||||
traits::{Get, PalletInfoAccess},
|
traits::{Get, PalletInfoAccess},
|
||||||
};
|
};
|
||||||
use remote_externalities::{Builder, Mode, OnlineConfig};
|
use remote_externalities::{Builder, Mode, OnlineConfig};
|
||||||
use sp_runtime::traits::Block as BlockT;
|
use sp_runtime::{traits::Block as BlockT, DeserializeOwned};
|
||||||
use sp_std::prelude::*;
|
use sp_std::prelude::*;
|
||||||
|
|
||||||
/// Execute the sanity check of the bags-list.
|
/// Execute the sanity check of the bags-list.
|
||||||
pub async fn execute<Runtime: crate::RuntimeT, Block: BlockT>(
|
pub async fn execute<Runtime: crate::RuntimeT, Block: BlockT + DeserializeOwned>(
|
||||||
currency_unit: u64,
|
currency_unit: u64,
|
||||||
currency_name: &'static str,
|
currency_name: &'static str,
|
||||||
ws_url: String,
|
ws_url: String,
|
||||||
|
|||||||
@@ -18,10 +18,10 @@
|
|||||||
|
|
||||||
use frame_support::traits::PalletInfoAccess;
|
use frame_support::traits::PalletInfoAccess;
|
||||||
use remote_externalities::{Builder, Mode, OnlineConfig};
|
use remote_externalities::{Builder, Mode, OnlineConfig};
|
||||||
use sp_runtime::traits::Block as BlockT;
|
use sp_runtime::{traits::Block as BlockT, DeserializeOwned};
|
||||||
|
|
||||||
/// Execute create a snapshot from pallet-staking.
|
/// Execute create a snapshot from pallet-staking.
|
||||||
pub async fn execute<Runtime: crate::RuntimeT, Block: BlockT>(
|
pub async fn execute<Runtime: crate::RuntimeT, Block: BlockT + DeserializeOwned>(
|
||||||
voter_limit: Option<usize>,
|
voter_limit: Option<usize>,
|
||||||
currency_unit: u64,
|
currency_unit: u64,
|
||||||
ws_url: String,
|
ws_url: String,
|
||||||
|
|||||||
@@ -225,7 +225,7 @@ impl Parse for PalletDeclaration {
|
|||||||
{
|
{
|
||||||
return Err(input.error(
|
return Err(input.error(
|
||||||
"Unexpected tokens, expected one of `::$ident` `::{`, `exclude_parts`, `use_parts`, `=`, `,`",
|
"Unexpected tokens, expected one of `::$ident` `::{`, `exclude_parts`, `use_parts`, `=`, `,`",
|
||||||
))
|
));
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -13,10 +13,7 @@ readme = "README.md"
|
|||||||
targets = ["x86_64-unknown-linux-gnu"]
|
targets = ["x86_64-unknown-linux-gnu"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
jsonrpsee-ws-client = { version = "0.3.1", default-features = false, features = [
|
jsonrpsee = { version = "0.4.1", features = ["ws-client", "macros"] }
|
||||||
"tokio1",
|
|
||||||
]}
|
|
||||||
jsonrpsee-proc-macros = "0.3.1"
|
|
||||||
|
|
||||||
env_logger = "0.9"
|
env_logger = "0.9"
|
||||||
log = "0.4.11"
|
log = "0.4.11"
|
||||||
|
|||||||
@@ -21,7 +21,16 @@
|
|||||||
//! based chain, or a local state snapshot file.
|
//! based chain, or a local state snapshot file.
|
||||||
|
|
||||||
use codec::{Decode, Encode};
|
use codec::{Decode, Encode};
|
||||||
use jsonrpsee_ws_client::{types::v2::params::JsonRpcParams, WsClient, WsClientBuilder};
|
|
||||||
|
use jsonrpsee::{
|
||||||
|
proc_macros::rpc,
|
||||||
|
rpc_params,
|
||||||
|
types::{traits::Client, Error as RpcError},
|
||||||
|
ws_client::{WsClient, WsClientBuilder},
|
||||||
|
};
|
||||||
|
|
||||||
|
use log::*;
|
||||||
|
use serde::de::DeserializeOwned;
|
||||||
use sp_core::{
|
use sp_core::{
|
||||||
hashing::twox_128,
|
hashing::twox_128,
|
||||||
hexdisplay::HexDisplay,
|
hexdisplay::HexDisplay,
|
||||||
@@ -39,23 +48,25 @@ pub mod rpc_api;
|
|||||||
type KeyPair = (StorageKey, StorageData);
|
type KeyPair = (StorageKey, StorageData);
|
||||||
|
|
||||||
const LOG_TARGET: &str = "remote-ext";
|
const LOG_TARGET: &str = "remote-ext";
|
||||||
const DEFAULT_TARGET: &str = "wss://rpc.polkadot.io";
|
const DEFAULT_TARGET: &str = "wss://rpc.polkadot.io:443";
|
||||||
const BATCH_SIZE: usize = 1000;
|
const BATCH_SIZE: usize = 1000;
|
||||||
|
|
||||||
jsonrpsee_proc_macros::rpc_client_api! {
|
#[rpc(client)]
|
||||||
RpcApi<B: BlockT> {
|
pub trait RpcApi<Hash> {
|
||||||
#[rpc(method = "state_getStorage", positional_params)]
|
#[method(name = "state_getStorage")]
|
||||||
fn get_storage(prefix: StorageKey, hash: Option<B::Hash>) -> StorageData;
|
fn get_storage(&self, prefix: StorageKey, hash: Option<Hash>) -> Result<StorageData, RpcError>;
|
||||||
#[rpc(method = "state_getKeysPaged", positional_params)]
|
|
||||||
fn get_keys_paged(
|
#[method(name = "state_getKeysPaged")]
|
||||||
prefix: Option<StorageKey>,
|
fn get_keys_paged(
|
||||||
count: u32,
|
&self,
|
||||||
start_key: Option<StorageKey>,
|
prefix: Option<StorageKey>,
|
||||||
hash: Option<B::Hash>,
|
count: u32,
|
||||||
) -> Vec<StorageKey>;
|
start_key: Option<StorageKey>,
|
||||||
#[rpc(method = "chain_getFinalizedHead", positional_params)]
|
hash: Option<Hash>,
|
||||||
fn finalized_head() -> B::Hash;
|
) -> Result<Vec<StorageKey>, RpcError>;
|
||||||
}
|
|
||||||
|
#[method(name = "chain_getFinalizedHead")]
|
||||||
|
fn finalized_head(&self) -> Result<Hash, RpcError>;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The execution mode.
|
/// The execution mode.
|
||||||
@@ -183,7 +194,7 @@ pub struct Builder<B: BlockT> {
|
|||||||
|
|
||||||
// NOTE: ideally we would use `DefaultNoBound` here, but not worth bringing in frame-support for
|
// NOTE: ideally we would use `DefaultNoBound` here, but not worth bringing in frame-support for
|
||||||
// that.
|
// that.
|
||||||
impl<B: BlockT> Default for Builder<B> {
|
impl<B: BlockT + DeserializeOwned> Default for Builder<B> {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
mode: Default::default(),
|
mode: Default::default(),
|
||||||
@@ -196,7 +207,7 @@ impl<B: BlockT> Default for Builder<B> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Mode methods
|
// Mode methods
|
||||||
impl<B: BlockT> Builder<B> {
|
impl<B: BlockT + DeserializeOwned> Builder<B> {
|
||||||
fn as_online(&self) -> &OnlineConfig<B> {
|
fn as_online(&self) -> &OnlineConfig<B> {
|
||||||
match &self.mode {
|
match &self.mode {
|
||||||
Mode::Online(config) => &config,
|
Mode::Online(config) => &config,
|
||||||
@@ -215,25 +226,23 @@ impl<B: BlockT> Builder<B> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// RPC methods
|
// RPC methods
|
||||||
impl<B: BlockT> Builder<B> {
|
impl<B: BlockT + DeserializeOwned> Builder<B> {
|
||||||
async fn rpc_get_storage(
|
async fn rpc_get_storage(
|
||||||
&self,
|
&self,
|
||||||
key: StorageKey,
|
key: StorageKey,
|
||||||
maybe_at: Option<B::Hash>,
|
maybe_at: Option<B::Hash>,
|
||||||
) -> Result<StorageData, &'static str> {
|
) -> Result<StorageData, &'static str> {
|
||||||
log::trace!(target: LOG_TARGET, "rpc: get_storage");
|
trace!(target: LOG_TARGET, "rpc: get_storage");
|
||||||
RpcApi::<B>::get_storage(self.as_online().rpc_client(), key, maybe_at)
|
self.as_online().rpc_client().get_storage(key, maybe_at).await.map_err(|e| {
|
||||||
.await
|
error!("Error = {:?}", e);
|
||||||
.map_err(|e| {
|
"rpc get_storage failed."
|
||||||
log::error!(target: LOG_TARGET, "Error = {:?}", e);
|
})
|
||||||
"rpc get_storage failed."
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
/// Get the latest finalized head.
|
/// Get the latest finalized head.
|
||||||
async fn rpc_get_head(&self) -> Result<B::Hash, &'static str> {
|
async fn rpc_get_head(&self) -> Result<B::Hash, &'static str> {
|
||||||
log::trace!(target: LOG_TARGET, "rpc: finalized_head");
|
trace!(target: LOG_TARGET, "rpc: finalized_head");
|
||||||
RpcApi::<B>::finalized_head(self.as_online().rpc_client()).await.map_err(|e| {
|
self.as_online().rpc_client().finalized_head().await.map_err(|e| {
|
||||||
log::error!(target: LOG_TARGET, "Error = {:?}", e);
|
error!("Error = {:?}", e);
|
||||||
"rpc finalized_head failed."
|
"rpc finalized_head failed."
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -248,18 +257,15 @@ impl<B: BlockT> Builder<B> {
|
|||||||
let mut last_key: Option<StorageKey> = None;
|
let mut last_key: Option<StorageKey> = None;
|
||||||
let mut all_keys: Vec<StorageKey> = vec![];
|
let mut all_keys: Vec<StorageKey> = vec![];
|
||||||
let keys = loop {
|
let keys = loop {
|
||||||
let page = RpcApi::<B>::get_keys_paged(
|
let page = self
|
||||||
self.as_online().rpc_client(),
|
.as_online()
|
||||||
Some(prefix.clone()),
|
.rpc_client()
|
||||||
PAGE,
|
.get_keys_paged(Some(prefix.clone()), PAGE, last_key.clone(), Some(at))
|
||||||
last_key.clone(),
|
.await
|
||||||
Some(at),
|
.map_err(|e| {
|
||||||
)
|
error!(target: LOG_TARGET, "Error = {:?}", e);
|
||||||
.await
|
"rpc get_keys failed"
|
||||||
.map_err(|e| {
|
})?;
|
||||||
log::error!(target: LOG_TARGET, "Error = {:?}", e);
|
|
||||||
"rpc get_keys failed"
|
|
||||||
})?;
|
|
||||||
let page_len = page.len();
|
let page_len = page.len();
|
||||||
all_keys.extend(page);
|
all_keys.extend(page);
|
||||||
|
|
||||||
@@ -291,8 +297,6 @@ impl<B: BlockT> Builder<B> {
|
|||||||
prefix: StorageKey,
|
prefix: StorageKey,
|
||||||
at: B::Hash,
|
at: B::Hash,
|
||||||
) -> Result<Vec<KeyPair>, &'static str> {
|
) -> Result<Vec<KeyPair>, &'static str> {
|
||||||
use jsonrpsee_ws_client::types::traits::Client;
|
|
||||||
use serde_json::to_value;
|
|
||||||
let keys = self.get_keys_paged(prefix, at).await?;
|
let keys = self.get_keys_paged(prefix, at).await?;
|
||||||
let keys_count = keys.len();
|
let keys_count = keys.len();
|
||||||
log::debug!(target: LOG_TARGET, "Querying a total of {} keys", keys.len());
|
log::debug!(target: LOG_TARGET, "Querying a total of {} keys", keys.len());
|
||||||
@@ -303,15 +307,7 @@ impl<B: BlockT> Builder<B> {
|
|||||||
let batch = chunk_keys
|
let batch = chunk_keys
|
||||||
.iter()
|
.iter()
|
||||||
.cloned()
|
.cloned()
|
||||||
.map(|key| {
|
.map(|key| ("state_getStorage", rpc_params![key, at]))
|
||||||
(
|
|
||||||
"state_getStorage",
|
|
||||||
JsonRpcParams::Array(vec![
|
|
||||||
to_value(key).expect("json serialization will work; qed."),
|
|
||||||
to_value(at).expect("json serialization will work; qed."),
|
|
||||||
]),
|
|
||||||
)
|
|
||||||
})
|
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
let values = client.batch_request::<Option<StorageData>>(batch).await.map_err(|e| {
|
let values = client.batch_request::<Option<StorageData>>(batch).await.map_err(|e| {
|
||||||
log::error!(
|
log::error!(
|
||||||
@@ -348,7 +344,7 @@ impl<B: BlockT> Builder<B> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Internal methods
|
// Internal methods
|
||||||
impl<B: BlockT> Builder<B> {
|
impl<B: BlockT + DeserializeOwned> Builder<B> {
|
||||||
/// Save the given data as state snapshot.
|
/// Save the given data as state snapshot.
|
||||||
fn save_state_snapshot(&self, data: &[KeyPair], path: &Path) -> Result<(), &'static str> {
|
fn save_state_snapshot(&self, data: &[KeyPair], path: &Path) -> Result<(), &'static str> {
|
||||||
log::debug!(target: LOG_TARGET, "writing to state snapshot file {:?}", path);
|
log::debug!(target: LOG_TARGET, "writing to state snapshot file {:?}", path);
|
||||||
@@ -489,7 +485,7 @@ impl<B: BlockT> Builder<B> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Public methods
|
// Public methods
|
||||||
impl<B: BlockT> Builder<B> {
|
impl<B: BlockT + DeserializeOwned> Builder<B> {
|
||||||
/// Create a new builder.
|
/// Create a new builder.
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Default::default()
|
Default::default()
|
||||||
@@ -625,7 +621,7 @@ mod tests {
|
|||||||
#[cfg(all(test, feature = "remote-test"))]
|
#[cfg(all(test, feature = "remote-test"))]
|
||||||
mod remote_tests {
|
mod remote_tests {
|
||||||
use super::test_prelude::*;
|
use super::test_prelude::*;
|
||||||
|
use pallet_elections_phragmen::Members;
|
||||||
const REMOTE_INACCESSIBLE: &'static str = "Can't reach the remote node. Is it running?";
|
const REMOTE_INACCESSIBLE: &'static str = "Can't reach the remote node. Is it running?";
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
@@ -697,7 +693,6 @@ mod remote_tests {
|
|||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn sanity_check_decoding() {
|
async fn sanity_check_decoding() {
|
||||||
use pallet_elections_phragmen::SeatHolder;
|
|
||||||
use sp_core::crypto::Ss58Codec;
|
use sp_core::crypto::Ss58Codec;
|
||||||
|
|
||||||
type AccountId = sp_runtime::AccountId32;
|
type AccountId = sp_runtime::AccountId32;
|
||||||
@@ -722,7 +717,7 @@ mod remote_tests {
|
|||||||
let gav_polkadot =
|
let gav_polkadot =
|
||||||
AccountId::from_ss58check("13RDY9nrJpyTDBSUdBw12dGwhk19sGwsrVZ2bxkzYHBSagP2")
|
AccountId::from_ss58check("13RDY9nrJpyTDBSUdBw12dGwhk19sGwsrVZ2bxkzYHBSagP2")
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let members = Members::get().unwrap();
|
let members = Members::get();
|
||||||
assert!(members
|
assert!(members
|
||||||
.iter()
|
.iter()
|
||||||
.map(|s| s.who.clone())
|
.map(|s| s.who.clone())
|
||||||
|
|||||||
@@ -18,9 +18,10 @@
|
|||||||
//! WS RPC API for one off RPC calls to a substrate node.
|
//! WS RPC API for one off RPC calls to a substrate node.
|
||||||
// TODO: Consolidate one off RPC calls https://github.com/paritytech/substrate/issues/8988
|
// TODO: Consolidate one off RPC calls https://github.com/paritytech/substrate/issues/8988
|
||||||
|
|
||||||
use jsonrpsee_ws_client::{
|
use jsonrpsee::{
|
||||||
types::{traits::Client, v2::params::JsonRpcParams},
|
rpc_params,
|
||||||
WsClient, WsClientBuilder,
|
types::traits::Client,
|
||||||
|
ws_client::{WsClient, WsClientBuilder},
|
||||||
};
|
};
|
||||||
use sp_runtime::{
|
use sp_runtime::{
|
||||||
generic::SignedBlock,
|
generic::SignedBlock,
|
||||||
@@ -34,11 +35,10 @@ where
|
|||||||
Block::Header: serde::de::DeserializeOwned,
|
Block::Header: serde::de::DeserializeOwned,
|
||||||
S: AsRef<str>,
|
S: AsRef<str>,
|
||||||
{
|
{
|
||||||
let params = vec![hash_to_json::<Block>(at)?];
|
|
||||||
let client = build_client(from).await?;
|
let client = build_client(from).await?;
|
||||||
|
|
||||||
client
|
client
|
||||||
.request::<Block::Header>("chain_getHeader", JsonRpcParams::Array(params))
|
.request::<Block::Header>("chain_getHeader", rpc_params!(at))
|
||||||
.await
|
.await
|
||||||
.map_err(|e| format!("chain_getHeader request failed: {:?}", e))
|
.map_err(|e| format!("chain_getHeader request failed: {:?}", e))
|
||||||
}
|
}
|
||||||
@@ -52,7 +52,7 @@ where
|
|||||||
let client = build_client(from).await?;
|
let client = build_client(from).await?;
|
||||||
|
|
||||||
client
|
client
|
||||||
.request::<Block::Hash>("chain_getFinalizedHead", JsonRpcParams::NoParams)
|
.request::<Block::Hash>("chain_getFinalizedHead", None)
|
||||||
.await
|
.await
|
||||||
.map_err(|e| format!("chain_getFinalizedHead request failed: {:?}", e))
|
.map_err(|e| format!("chain_getFinalizedHead request failed: {:?}", e))
|
||||||
}
|
}
|
||||||
@@ -64,22 +64,15 @@ where
|
|||||||
Block: BlockT + serde::de::DeserializeOwned,
|
Block: BlockT + serde::de::DeserializeOwned,
|
||||||
Block::Header: HeaderT,
|
Block::Header: HeaderT,
|
||||||
{
|
{
|
||||||
let params = vec![hash_to_json::<Block>(at)?];
|
|
||||||
let client = build_client(from).await?;
|
let client = build_client(from).await?;
|
||||||
let signed_block = client
|
let signed_block = client
|
||||||
.request::<SignedBlock<Block>>("chain_getBlock", JsonRpcParams::Array(params))
|
.request::<SignedBlock<Block>>("chain_getBlock", rpc_params!(at))
|
||||||
.await
|
.await
|
||||||
.map_err(|e| format!("chain_getBlock request failed: {:?}", e))?;
|
.map_err(|e| format!("chain_getBlock request failed: {:?}", e))?;
|
||||||
|
|
||||||
Ok(signed_block.block)
|
Ok(signed_block.block)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Convert a block hash to a serde json value.
|
|
||||||
fn hash_to_json<Block: BlockT>(hash: Block::Hash) -> Result<serde_json::Value, String> {
|
|
||||||
serde_json::to_value(hash)
|
|
||||||
.map_err(|e| format!("Block hash could not be converted to JSON: {:?}", e))
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Build a website client that connects to `from`.
|
/// Build a website client that connects to `from`.
|
||||||
async fn build_client<S: AsRef<str>>(from: S) -> Result<WsClient, String> {
|
async fn build_client<S: AsRef<str>>(from: S) -> Result<WsClient, String> {
|
||||||
WsClientBuilder::default()
|
WsClientBuilder::default()
|
||||||
@@ -99,13 +92,9 @@ where
|
|||||||
Block: BlockT + serde::de::DeserializeOwned,
|
Block: BlockT + serde::de::DeserializeOwned,
|
||||||
Block::Header: HeaderT,
|
Block::Header: HeaderT,
|
||||||
{
|
{
|
||||||
let params = if let Some(at) = at { vec![hash_to_json::<Block>(at)?] } else { vec![] };
|
|
||||||
let client = build_client(from).await?;
|
let client = build_client(from).await?;
|
||||||
client
|
client
|
||||||
.request::<sp_version::RuntimeVersion>(
|
.request::<sp_version::RuntimeVersion>("state_getRuntimeVersion", rpc_params!(at))
|
||||||
"state_getRuntimeVersion",
|
|
||||||
JsonRpcParams::Array(params),
|
|
||||||
)
|
|
||||||
.await
|
.await
|
||||||
.map_err(|e| format!("state_getRuntimeVersion request failed: {:?}", e))
|
.map_err(|e| format!("state_getRuntimeVersion request failed: {:?}", e))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,6 +31,4 @@ sp-externalities = { version = "0.10.0-dev", path = "../../../../primitives/exte
|
|||||||
sp-version = { version = "4.0.0-dev", path = "../../../../primitives/version" }
|
sp-version = { version = "4.0.0-dev", path = "../../../../primitives/version" }
|
||||||
|
|
||||||
remote-externalities = { version = "0.10.0-dev", path = "../../remote-externalities" }
|
remote-externalities = { version = "0.10.0-dev", path = "../../remote-externalities" }
|
||||||
jsonrpsee-ws-client = { version = "0.3.1", default-features = false, features = [
|
jsonrpsee = { version = "0.4.1", default-features = false, features = ["ws-client"]}
|
||||||
"tokio1",
|
|
||||||
]}
|
|
||||||
|
|||||||
@@ -19,9 +19,9 @@ use crate::{
|
|||||||
build_executor, ensure_matching_spec, extract_code, full_extensions, local_spec, parse,
|
build_executor, ensure_matching_spec, extract_code, full_extensions, local_spec, parse,
|
||||||
state_machine_call, SharedParams, LOG_TARGET,
|
state_machine_call, SharedParams, LOG_TARGET,
|
||||||
};
|
};
|
||||||
use jsonrpsee_ws_client::{
|
use jsonrpsee::{
|
||||||
types::{traits::SubscriptionClient, v2::params::JsonRpcParams, Subscription},
|
types::{traits::SubscriptionClient, Subscription},
|
||||||
WsClientBuilder,
|
ws_client::WsClientBuilder,
|
||||||
};
|
};
|
||||||
use parity_scale_codec::Decode;
|
use parity_scale_codec::Decode;
|
||||||
use remote_externalities::{rpc_api, Builder, Mode, OnlineConfig};
|
use remote_externalities::{rpc_api, Builder, Mode, OnlineConfig};
|
||||||
@@ -72,7 +72,7 @@ where
|
|||||||
|
|
||||||
log::info!(target: LOG_TARGET, "subscribing to {:?} / {:?}", SUB, UN_SUB);
|
log::info!(target: LOG_TARGET, "subscribing to {:?} / {:?}", SUB, UN_SUB);
|
||||||
let mut subscription: Subscription<Block::Header> =
|
let mut subscription: Subscription<Block::Header> =
|
||||||
client.subscribe(&SUB, JsonRpcParams::NoParams, &UN_SUB).await.unwrap();
|
client.subscribe(&SUB, None, &UN_SUB).await.unwrap();
|
||||||
|
|
||||||
let (code_key, code) = extract_code(&config.chain_spec)?;
|
let (code_key, code) = extract_code(&config.chain_spec)?;
|
||||||
let executor = build_executor::<ExecDispatch>(&shared, &config);
|
let executor = build_executor::<ExecDispatch>(&shared, &config);
|
||||||
|
|||||||
@@ -281,7 +281,10 @@ use sp_core::{
|
|||||||
};
|
};
|
||||||
use sp_externalities::Extensions;
|
use sp_externalities::Extensions;
|
||||||
use sp_keystore::{testing::KeyStore, KeystoreExt};
|
use sp_keystore::{testing::KeyStore, KeystoreExt};
|
||||||
use sp_runtime::traits::{Block as BlockT, NumberFor};
|
use sp_runtime::{
|
||||||
|
traits::{Block as BlockT, NumberFor},
|
||||||
|
DeserializeOwned,
|
||||||
|
};
|
||||||
use sp_state_machine::{OverlayedChanges, StateMachine};
|
use sp_state_machine::{OverlayedChanges, StateMachine};
|
||||||
use std::{fmt::Debug, path::PathBuf, str::FromStr};
|
use std::{fmt::Debug, path::PathBuf, str::FromStr};
|
||||||
|
|
||||||
@@ -464,7 +467,7 @@ pub enum State {
|
|||||||
|
|
||||||
impl State {
|
impl State {
|
||||||
/// Create the [`remote_externalities::Builder`] from self.
|
/// Create the [`remote_externalities::Builder`] from self.
|
||||||
pub(crate) fn builder<Block: BlockT>(&self) -> sc_cli::Result<Builder<Block>>
|
pub(crate) fn builder<Block: BlockT + DeserializeOwned>(&self) -> sc_cli::Result<Builder<Block>>
|
||||||
where
|
where
|
||||||
Block::Hash: FromStr,
|
Block::Hash: FromStr,
|
||||||
<Block::Hash as FromStr>::Err: Debug,
|
<Block::Hash as FromStr>::Err: Debug,
|
||||||
|
|||||||
Reference in New Issue
Block a user