diff --git a/Cargo.lock b/Cargo.lock index b4b2f14fb725..dd9fe26c8135 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -125,14 +125,15 @@ dependencies = [ [[package]] name = "ahash" -version = "0.8.3" +version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f" +checksum = "77c3a9648d43b9cd48db467b3f87fdd6e146bcc88ab0180006cef2179fe11d01" dependencies = [ "cfg-if", "getrandom 0.2.10", "once_cell", "version_check", + "zerocopy", ] [[package]] @@ -164,7 +165,7 @@ dependencies = [ "hex-literal", "itoa", "proptest", - "rand 0.8.5", + "rand", "ruint", "serde", "tiny-keccak", @@ -190,7 +191,7 @@ checksum = "c0391754c09fab4eae3404d19d0d297aa1c670c1775ab51d8a5312afeca23157" dependencies = [ "proc-macro2", "quote", - "syn 2.0.41", + "syn 2.0.48", ] [[package]] @@ -205,7 +206,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.41", + "syn 2.0.48", "syn-solidity", "tiny-keccak", ] @@ -269,9 +270,9 @@ dependencies = [ [[package]] name = "anstream" -version = "0.6.4" +version = "0.6.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ab91ebe16eb252986481c5b62f6098f3b698a45e34b5b98200cf20dd2484a44" +checksum = "4cd2405b3ac1faab2990b74d728624cd9fd115651fcecc7c2d8daf01376275ba" dependencies = [ "anstyle", "anstyle-parse", @@ -332,16 +333,16 @@ dependencies = [ [[package]] name = "aquamarine" -version = "0.3.2" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df752953c49ce90719c7bf1fc587bc8227aed04732ea0c0f85e5397d7fdbd1a1" +checksum = "21cc1548309245035eb18aa7f0967da6bc65587005170c56e6ef2788a4cf3f4e" dependencies = [ "include_dir", "itertools 0.10.5", "proc-macro-error", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.48", ] [[package]] @@ -684,7 +685,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1df2c09229cbc5a028b1d70e00fdb2acee28b1055dfb5ca73eea49c5a25c4e7c" dependencies = [ "num-traits", - "rand 0.8.5", + "rand", ] [[package]] @@ -694,7 +695,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94893f1e0c6eeab764ade8dc4c0db24caf4fe7cbbaafc0eba0a9030f447b5185" dependencies = [ "num-traits", - "rand 0.8.5", + "rand", "rayon", ] @@ -863,6 +864,7 @@ dependencies = [ "cumulus-pallet-session-benchmarking", "cumulus-pallet-xcm", "cumulus-pallet-xcmp-queue", + "cumulus-primitives-aura", "cumulus-primitives-core", "cumulus-primitives-utility", "frame-benchmarking", @@ -1065,6 +1067,7 @@ dependencies = [ "frame-support", "frame-system", "hex-literal", + "pallet-asset-conversion", "pallet-assets", "pallet-balances", "pallet-collator-selection", @@ -1225,7 +1228,7 @@ checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" dependencies = [ "proc-macro2", "quote", - "syn 2.0.41", + "syn 2.0.48", ] [[package]] @@ -1242,7 +1245,7 @@ checksum = "a66537f1bb974b254c98ed142ff995236e81b9d0fe4db0575f46612cb15eb0f9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.41", + "syn 2.0.48", ] [[package]] @@ -1310,7 +1313,7 @@ dependencies = [ "cfg-if", "libc", "miniz_oxide", - "object 0.32.0", + "object 0.32.2", "rustc-demangle", ] @@ -1369,9 +1372,9 @@ checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" [[package]] name = "basic-toml" -version = "0.1.4" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7bfc506e7a2370ec239e1d072507b2a80c833083699d3c6fa176fbb4de8448c6" +checksum = "2db21524cad41c5591204d22d75e1970a2d1f71060214ca931dc7d5afe2c14e5" dependencies = [ "serde", ] @@ -1424,7 +1427,7 @@ dependencies = [ "regex", "rustc-hash", "shlex", - "syn 2.0.41", + "syn 2.0.48", ] [[package]] @@ -1434,7 +1437,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "93f2635620bf0b9d4576eb7bb9a38a55df78bd1205d26fa994b25911a69f212f" dependencies = [ "bitcoin_hashes", - "rand 0.8.5", + "rand", "rand_core 0.6.4", "serde", "unicode-normalization", @@ -1972,6 +1975,7 @@ dependencies = [ "frame-support", "hex", "hex-literal", + "pallet-asset-conversion", "pallet-assets", "pallet-balances", "pallet-bridge-messages", @@ -1980,6 +1984,7 @@ dependencies = [ "parachains-common", "parity-scale-codec", "penpal-runtime", + "rococo-system-emulated-network", "rococo-westend-system-emulated-network", "scale-info", "snowbridge-core", @@ -2163,6 +2168,7 @@ dependencies = [ "cumulus-pallet-xcmp-queue", "emulated-integration-tests-common", "frame-support", + "pallet-asset-conversion", "pallet-assets", "pallet-balances", "pallet-bridge-messages", @@ -2635,9 +2641,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.4.11" +version = "4.4.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfaff671f6b22ca62406885ece523383b9b64022e341e53e009a62ebc47a45f2" +checksum = "1e578d6ec4194633722ccf9544794b71b1385c3c027efe0c55db226fc880865c" dependencies = [ "clap_builder", "clap_derive 4.4.7", @@ -2654,9 +2660,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.4.11" +version = "4.4.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a216b506622bb1d316cd51328dce24e07bdff4a6128a47c7e7fad11878d5adbb" +checksum = "4df4df40ec50c46000231c914968278b1eb05098cf8f1b3a518a95030e71d1c7" dependencies = [ "anstream", "anstyle", @@ -2671,7 +2677,7 @@ version = "4.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "586a385f7ef2f8b4d86bddaa0c094794e7ccbfe5ffef1f434fe928143fc783a5" dependencies = [ - "clap 4.4.11", + "clap 4.4.18", ] [[package]] @@ -2696,7 +2702,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.41", + "syn 2.0.48", ] [[package]] @@ -2878,12 +2884,12 @@ dependencies = [ [[package]] name = "comfy-table" -version = "7.0.1" +version = "7.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ab77dbd8adecaf3f0db40581631b995f312a8a5ae3aa9993188bb8f23d83a5b" +checksum = "7c64043d6c7b7a4c58e39e7efccfdea7b93d885a795d0c054a69dbbf4dd52686" dependencies = [ - "strum", - "strum_macros", + "strum 0.25.0", + "strum_macros 0.25.3", "unicode-width", ] @@ -2920,15 +2926,25 @@ dependencies = [ [[package]] name = "console" -version = "0.15.7" +version = "0.15.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c926e00cc70edefdc64d3a5ff31cc65bb97a3460097762bd23afb4d8145fccf8" +checksum = "0e1f83fc076bd6dd27517eacdf25fef6c4dfe5f1d7448bafaaf3a26f13b5e4eb" dependencies = [ "encode_unicode", "lazy_static", "libc", "unicode-width", - "windows-sys 0.45.0", + "windows-sys 0.52.0", +] + +[[package]] +name = "console_error_panic_hook" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a06aeb73f470f66dcdbf7223caeebb85984942f22f1adb2a088cf9668146bbbc" +dependencies = [ + "cfg-if", + "wasm-bindgen", ] [[package]] @@ -3279,7 +3295,7 @@ dependencies = [ "gimli 0.27.3", "hashbrown 0.13.2", "log", - "regalloc2", + "regalloc2 0.6.1", "smallvec", "target-lexicon", ] @@ -3399,7 +3415,7 @@ dependencies = [ "anes", "cast", "ciborium", - "clap 4.4.11", + "clap 4.4.18", "criterion-plot", "futures", "is-terminal", @@ -3562,7 +3578,7 @@ dependencies = [ name = "cumulus-client-cli" version = "0.1.0" dependencies = [ - "clap 4.4.11", + "clap 4.4.18", "parity-scale-codec", "sc-chain-spec", "sc-cli", @@ -3612,9 +3628,9 @@ dependencies = [ "cumulus-client-collator", "cumulus-client-consensus-common", "cumulus-client-consensus-proposer", + "cumulus-client-parachain-inherent", "cumulus-primitives-aura", "cumulus-primitives-core", - "cumulus-primitives-parachain-inherent", "cumulus-relay-chain-interface", "futures", "parity-scale-codec", @@ -3746,6 +3762,29 @@ dependencies = [ "url", ] +[[package]] +name = "cumulus-client-parachain-inherent" +version = "0.1.0" +dependencies = [ + "async-trait", + "cumulus-primitives-core", + "cumulus-primitives-parachain-inherent", + "cumulus-relay-chain-interface", + "cumulus-test-relay-sproof-builder", + "parity-scale-codec", + "sc-client-api", + "scale-info", + "sp-api", + "sp-crypto-hashing", + "sp-inherents", + "sp-runtime", + "sp-state-machine", + "sp-std 8.0.0", + "sp-storage 13.0.0", + "sp-trie", + "tracing", +] + [[package]] name = "cumulus-client-pov-recovery" version = "0.1.0" @@ -3762,7 +3801,7 @@ dependencies = [ "polkadot-overseer", "polkadot-primitives", "portpicker", - "rand 0.8.5", + "rand", "sc-cli", "sc-client-api", "sc-consensus", @@ -3870,10 +3909,11 @@ dependencies = [ "parity-scale-codec", "polkadot-parachain-primitives", "polkadot-runtime-parachains", - "rand 0.8.5", + "rand", "sc-client-api", "scale-info", "sp-core", + "sp-crypto-hashing", "sp-externalities 0.19.0", "sp-inherents", "sp-io", @@ -3893,10 +3933,10 @@ dependencies = [ name = "cumulus-pallet-parachain-system-proc-macro" version = "0.1.0" dependencies = [ - "proc-macro-crate 2.0.1", + "proc-macro-crate 3.0.0", "proc-macro2", "quote", - "syn 2.0.41", + "syn 2.0.48", ] [[package]] @@ -4019,20 +4059,14 @@ version = "0.1.0" dependencies = [ "async-trait", "cumulus-primitives-core", - "cumulus-relay-chain-interface", - "cumulus-test-relay-sproof-builder", "parity-scale-codec", - "sc-client-api", "scale-info", - "sp-api", "sp-core", "sp-inherents", "sp-runtime", "sp-state-machine", "sp-std 8.0.0", - "sp-storage 13.0.0", "sp-trie", - "tracing", ] [[package]] @@ -4066,6 +4100,7 @@ dependencies = [ "cumulus-primitives-core", "frame-support", "log", + "pallet-asset-conversion", "pallet-xcm-benchmarks", "parity-scale-codec", "polkadot-runtime-common", @@ -4177,7 +4212,7 @@ dependencies = [ "parity-scale-codec", "pin-project", "polkadot-overseer", - "rand 0.8.5", + "rand", "sc-client-api", "sc-rpc-api", "sc-service", @@ -4284,16 +4319,16 @@ name = "cumulus-test-service" version = "0.1.0" dependencies = [ "async-trait", - "clap 4.4.11", + "clap 4.4.18", "criterion 0.5.1", "cumulus-client-cli", "cumulus-client-consensus-common", "cumulus-client-consensus-relay-chain", + "cumulus-client-parachain-inherent", "cumulus-client-pov-recovery", "cumulus-client-service", "cumulus-pallet-parachain-system", "cumulus-primitives-core", - "cumulus-primitives-parachain-inherent", "cumulus-relay-chain-inprocess-interface", "cumulus-relay-chain-interface", "cumulus-relay-chain-minimal-node", @@ -4316,7 +4351,7 @@ dependencies = [ "polkadot-service", "polkadot-test-service", "portpicker", - "rand 0.8.5", + "rand", "rococo-parachain-runtime", "sc-basic-authorship", "sc-block-builder", @@ -4407,7 +4442,7 @@ checksum = "83fdaf97f4804dcebfa5862639bc9ce4121e82140bec2a987ac5140294865b5b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.41", + "syn 2.0.48", ] [[package]] @@ -4447,7 +4482,7 @@ dependencies = [ "proc-macro2", "quote", "scratch", - "syn 2.0.41", + "syn 2.0.48", ] [[package]] @@ -4464,7 +4499,7 @@ checksum = "50c49547d73ba8dcfd4ad7325d64c6d5391ff4224d498fc39a6f3f49825a530d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.41", + "syn 2.0.48", ] [[package]] @@ -4474,7 +4509,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "edd72493923899c6f10c641bdbdeddc7183d6396641d99c1a0d1597f37f92e28" dependencies = [ "cfg-if", - "hashbrown 0.14.0", + "hashbrown 0.14.3", "lock_api", "once_cell", "parking_lot_core 0.9.8", @@ -4672,7 +4707,7 @@ checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.41", + "syn 2.0.48", ] [[package]] @@ -4733,7 +4768,7 @@ dependencies = [ "proc-macro2", "quote", "regex", - "syn 2.0.41", + "syn 2.0.48", "termcolor", "toml 0.7.8", "walkdir", @@ -4851,7 +4886,7 @@ checksum = "7d9ce6874da5d4415896cd45ffbc4d1cfc0c4f9c079427bd870742c30f2f65a9" dependencies = [ "curve25519-dalek 4.1.1", "ed25519", - "hashbrown 0.14.0", + "hashbrown 0.14.3", "hex", "rand_core 0.6.4", "sha2 0.10.7", @@ -4961,7 +4996,7 @@ checksum = "5e9a1f9f7d83e59740248a6e14ecf93929ade55027844dfcea78beafccc15745" dependencies = [ "proc-macro2", "quote", - "syn 2.0.41", + "syn 2.0.48", ] [[package]] @@ -4972,7 +5007,7 @@ checksum = "c2ad8cef1d801a4686bfd8919f0b30eac4c8e48968c437a6405ded4fb5272d2b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.41", + "syn 2.0.48", ] [[package]] @@ -5065,8 +5100,8 @@ dependencies = [ [[package]] name = "ethabi-decode" -version = "1.0.0" -source = "git+https://github.com/Snowfork/ethabi-decode.git?branch=master#5c01c8a0f2d0e4eccf600507cd573b27555b1d9d" +version = "1.4.0" +source = "git+https://github.com/snowfork/ethabi-decode.git?branch=master#7d215837b626650bd9a076821e57ad488101301f" dependencies = [ "ethereum-types", "tiny-keccak", @@ -5140,7 +5175,7 @@ dependencies = [ "fs-err", "proc-macro2", "quote", - "syn 2.0.41", + "syn 2.0.48", ] [[package]] @@ -5165,6 +5200,12 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" +[[package]] +name = "fallible-iterator" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2acce4a10f12dc2fb14a218589d4f1f62ef011b2d0cc4b3cb1bba8e94da14649" + [[package]] name = "fastrand" version = "1.9.0" @@ -5306,7 +5347,7 @@ dependencies = [ "num-traits", "parity-scale-codec", "parking_lot 0.12.1", - "rand 0.8.5", + "rand", "scale-info", ] @@ -5329,7 +5370,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "835c052cb0c08c1acf6ffd71c022172e18723949c8282f2b9f27efbc51e64534" dependencies = [ "byteorder", - "rand 0.8.5", + "rand", "rustc-hex", "static_assertions", ] @@ -5462,7 +5503,7 @@ dependencies = [ "Inflector", "array-bytes 6.1.0", "chrono", - "clap 4.4.11", + "clap 4.4.18", "comfy-table", "frame-benchmarking", "frame-support", @@ -5474,7 +5515,7 @@ dependencies = [ "linked-hash-map", "log", "parity-scale-codec", - "rand 0.8.5", + "rand", "rand_pcg", "sc-block-builder", "sc-cli", @@ -5523,12 +5564,12 @@ dependencies = [ "frame-election-provider-support", "frame-support", "parity-scale-codec", - "proc-macro-crate 2.0.1", + "proc-macro-crate 3.0.0", "proc-macro2", "quote", "scale-info", "sp-arithmetic", - "syn 2.0.41", + "syn 2.0.48", "trybuild", ] @@ -5540,7 +5581,7 @@ dependencies = [ "frame-support", "frame-system", "parity-scale-codec", - "rand 0.8.5", + "rand", "scale-info", "sp-arithmetic", "sp-core", @@ -5554,13 +5595,13 @@ dependencies = [ name = "frame-election-solution-type-fuzzer" version = "2.0.0-alpha.5" dependencies = [ - "clap 4.4.11", + "clap 4.4.18", "frame-election-provider-solution-type", "frame-election-provider-support", "frame-support", "honggfuzz", "parity-scale-codec", - "rand 0.8.5", + "rand", "scale-info", "sp-arithmetic", "sp-npos-elections", @@ -5612,6 +5653,7 @@ dependencies = [ "parity-scale-codec", "serde", "sp-core", + "sp-crypto-hashing", "sp-io", "sp-runtime", "sp-state-machine", @@ -5649,7 +5691,8 @@ dependencies = [ "sp-api", "sp-arithmetic", "sp-core", - "sp-core-hashing-proc-macro", + "sp-crypto-hashing", + "sp-crypto-hashing-proc-macro", "sp-debug-derive 8.0.0", "sp-genesis-builder", "sp-inherents", @@ -5680,8 +5723,8 @@ dependencies = [ "proc-macro2", "quote", "regex", - "sp-core-hashing", - "syn 2.0.41", + "sp-crypto-hashing", + "syn 2.0.48", ] [[package]] @@ -5689,10 +5732,10 @@ name = "frame-support-procedural-tools" version = "4.0.0-dev" dependencies = [ "frame-support-procedural-tools-derive", - "proc-macro-crate 2.0.1", + "proc-macro-crate 3.0.0", "proc-macro2", "quote", - "syn 2.0.41", + "syn 2.0.48", ] [[package]] @@ -5701,7 +5744,7 @@ version = "3.0.0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.41", + "syn 2.0.48", ] [[package]] @@ -5879,9 +5922,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.28" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "955518d47e09b25bbebc7a18df10b81f0c766eaf4c4f1cccef2fca5f2a4fb5f2" +checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" dependencies = [ "futures-core", "futures-sink", @@ -5889,9 +5932,9 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.28" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bca583b7e26f571124fe5b7561d49cb2868d79116cfa0eefce955557c6fee8c" +checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" [[package]] name = "futures-executor" @@ -5907,9 +5950,9 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.28" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fff74096e71ed47f8e023204cfd0aa1289cd54ae5430a9523be060cdb849964" +checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" [[package]] name = "futures-lite" @@ -5928,13 +5971,13 @@ dependencies = [ [[package]] name = "futures-macro" -version = "0.3.28" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" +checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.41", + "syn 2.0.48", ] [[package]] @@ -5950,15 +5993,15 @@ dependencies = [ [[package]] name = "futures-sink" -version = "0.3.28" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f43be4fe21a13b9781a69afa4985b0f6ee0e1afab2c6f454a8cf30e2b2237b6e" +checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" [[package]] name = "futures-task" -version = "0.3.28" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76d3d132be6c0e6aa1534069c705a74a5997a356c0dc2f86a47765e5617c5b65" +checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" [[package]] name = "futures-timer" @@ -5968,9 +6011,9 @@ checksum = "e64b03909df88034c26dc1547e8970b91f98bdb65165d6a4e9110d94263dbb2c" [[package]] name = "futures-util" -version = "0.3.28" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26b01e40b772d54cf6c6d721c1d1abd0647a0106a12ecaa1c186273392a69533" +checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" dependencies = [ "futures-channel", "futures-core", @@ -6064,7 +6107,7 @@ version = "0.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6ea1015b5a70616b688dc230cfe50c8af89d972cb132d5a622814d29773b10b9" dependencies = [ - "rand 0.8.5", + "rand", "rand_core 0.6.4", ] @@ -6094,7 +6137,7 @@ version = "0.27.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6c80984affa11d98d1b88b66ac8853f143217b399d3c74116778ff8fdb4ed2e" dependencies = [ - "fallible-iterator", + "fallible-iterator 0.2.0", "indexmap 1.9.3", "stable_deref_trait", ] @@ -6104,6 +6147,10 @@ name = "gimli" version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6fb8d784f27acf97159b40fc4db5ecd8aa23b9ad5ef69cdd136d3bc80665f0c0" +dependencies = [ + "fallible-iterator 0.3.0", + "stable_deref_trait", +] [[package]] name = "glob" @@ -6111,19 +6158,6 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" -[[package]] -name = "globset" -version = "0.4.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "759c97c1e17c55525b57192c06a267cda0ac5210b222d6b82189a2338fa1c13d" -dependencies = [ - "aho-corasick", - "bstr", - "fnv", - "log", - "regex", -] - [[package]] name = "glutton-westend-runtime" version = "1.0.0" @@ -6182,9 +6216,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.3.21" +version = "0.3.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91fc23aa11be92976ef4729127f1a74adf36d8436f7816b185d18df956790833" +checksum = "bb2c4422095b67ee78da96fbb51a4cc413b3b25883c7717ff7ca1ab31022c9c9" dependencies = [ "bytes", "fnv", @@ -6192,7 +6226,7 @@ dependencies = [ "futures-sink", "futures-util", "http", - "indexmap 1.9.3", + "indexmap 2.0.0", "slab", "tokio", "tokio-util", @@ -6249,16 +6283,16 @@ version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" dependencies = [ - "ahash 0.8.3", + "ahash 0.8.7", ] [[package]] name = "hashbrown" -version = "0.14.0" +version = "0.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c6201b9ff9fd90a5a3bac2e56a830d0caa509576f0e503818ee82c181b3437a" +checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" dependencies = [ - "ahash 0.8.3", + "ahash 0.8.7", "allocator-api2", "serde", ] @@ -6269,7 +6303,7 @@ version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e8094feaf31ff591f651a2664fb9cfd92bba7a60ce3197265e9482ebe753c8f7" dependencies = [ - "hashbrown 0.14.0", + "hashbrown 0.14.3", ] [[package]] @@ -6362,7 +6396,7 @@ checksum = "848e9c511092e0daa0a35a63e8e6e475a3e8f870741448b9f6028d69b142f18e" dependencies = [ "arbitrary", "lazy_static", - "memmap2", + "memmap2 0.5.10", "rustc_version 0.4.0", ] @@ -6461,7 +6495,6 @@ dependencies = [ "rustls-native-certs", "tokio", "tokio-rustls", - "webpki-roots 0.23.1", ] [[package]] @@ -6629,7 +6662,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d5477fe2230a79769d8dc68e0eabf5437907c0457a5614a9e8dddb67f65eb65d" dependencies = [ "equivalent", - "hashbrown 0.14.0", + "hashbrown 0.14.3", ] [[package]] @@ -6800,9 +6833,9 @@ dependencies = [ [[package]] name = "jsonrpsee" -version = "0.16.3" +version = "0.20.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "367a292944c07385839818bb71c8d76611138e2dedb0677d035b8da21d29c78b" +checksum = "affdc52f7596ccb2d7645231fc6163bb314630c989b64998f3699a28b4d5d4dc" dependencies = [ "jsonrpsee-core", "jsonrpsee-http-client", @@ -6810,19 +6843,19 @@ dependencies = [ "jsonrpsee-server", "jsonrpsee-types", "jsonrpsee-ws-client", + "tokio", "tracing", ] [[package]] name = "jsonrpsee-client-transport" -version = "0.16.3" +version = "0.20.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8b3815d9f5d5de348e5f162b316dc9cdf4548305ebb15b4eb9328e66cf27d7a" +checksum = "b5b005c793122d03217da09af68ba9383363caa950b90d3436106df8cabce935" dependencies = [ "futures-util", "http", "jsonrpsee-core", - "jsonrpsee-types", "pin-project", "rustls-native-certs", "soketto", @@ -6831,28 +6864,25 @@ dependencies = [ "tokio-rustls", "tokio-util", "tracing", - "webpki-roots 0.25.2", + "url", ] [[package]] name = "jsonrpsee-core" -version = "0.16.3" +version = "0.20.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b5dde66c53d6dcdc8caea1874a45632ec0fcf5b437789f1e45766a1512ce803" +checksum = "da2327ba8df2fdbd5e897e2b5ed25ce7f299d345b9736b6828814c3dbd1fd47b" dependencies = [ "anyhow", - "arrayvec 0.7.4", "async-lock", "async-trait", "beef", - "futures-channel", "futures-timer", "futures-util", - "globset", "hyper", "jsonrpsee-types", "parking_lot 0.12.1", - "rand 0.8.5", + "rand", "rustc-hash", "serde", "serde_json", @@ -6864,28 +6894,29 @@ dependencies = [ [[package]] name = "jsonrpsee-http-client" -version = "0.16.3" +version = "0.20.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e5f9fabdd5d79344728521bb65e3106b49ec405a78b66fbff073b72b389fa43" +checksum = "5f80c17f62c7653ce767e3d7288b793dfec920f97067ceb189ebdd3570f2bc20" dependencies = [ "async-trait", "hyper", "hyper-rustls", "jsonrpsee-core", "jsonrpsee-types", - "rustc-hash", "serde", "serde_json", "thiserror", "tokio", + "tower", "tracing", + "url", ] [[package]] name = "jsonrpsee-proc-macros" -version = "0.16.3" +version = "0.20.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44e8ab85614a08792b9bff6c8feee23be78c98d0182d4c622c05256ab553892a" +checksum = "29110019693a4fa2dbda04876499d098fa16d70eba06b1e6e2b3f1b251419515" dependencies = [ "heck", "proc-macro-crate 1.3.1", @@ -6896,19 +6927,20 @@ dependencies = [ [[package]] name = "jsonrpsee-server" -version = "0.16.3" +version = "0.20.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf4d945a6008c9b03db3354fb3c83ee02d2faa9f2e755ec1dfb69c3551b8f4ba" +checksum = "82c39a00449c9ef3f50b84fc00fc4acba20ef8f559f07902244abf4c15c5ab9c" dependencies = [ - "futures-channel", "futures-util", "http", "hyper", "jsonrpsee-core", "jsonrpsee-types", + "route-recognizer", "serde", "serde_json", "soketto", + "thiserror", "tokio", "tokio-stream", "tokio-util", @@ -6918,9 +6950,9 @@ dependencies = [ [[package]] name = "jsonrpsee-types" -version = "0.16.3" +version = "0.20.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "245ba8e5aa633dd1c1e4fae72bce06e71f42d34c14a2767c6b4d173b57bee5e5" +checksum = "5be0be325642e850ed0bdff426674d2e66b2b7117c9be23a7caef68a2902b7d9" dependencies = [ "anyhow", "beef", @@ -6932,14 +6964,15 @@ dependencies = [ [[package]] name = "jsonrpsee-ws-client" -version = "0.16.3" +version = "0.20.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e1b3975ed5d73f456478681a417128597acd6a2487855fdb7b4a3d4d195bf5e" +checksum = "bca9cb3933ccae417eb6b08c3448eb1cb46e39834e5b503e395e5e5bd08546c0" dependencies = [ "http", "jsonrpsee-client-transport", "jsonrpsee-core", "jsonrpsee-types", + "url", ] [[package]] @@ -7007,6 +7040,8 @@ dependencies = [ "pallet-babe", "pallet-bags-list", "pallet-balances", + "pallet-beefy", + "pallet-beefy-mmr", "pallet-bounties", "pallet-broker", "pallet-child-bounties", @@ -7080,6 +7115,7 @@ dependencies = [ "sp-authority-discovery", "sp-block-builder", "sp-consensus-babe", + "sp-consensus-beefy", "sp-consensus-grandpa", "sp-core", "sp-genesis-builder", @@ -7152,15 +7188,6 @@ dependencies = [ "thiserror", ] -[[package]] -name = "layout-rs" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1164ef87cb9607c2d887216eca79f0fc92895affe1789bba805dd38d829584e0" -dependencies = [ - "log", -] - [[package]] name = "lazy_static" version = "1.4.0" @@ -7181,9 +7208,9 @@ checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67" [[package]] name = "libc" -version = "0.2.149" +version = "0.2.152" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a08173bc88b7955d1b3145aa561539096c421ac8debde8cbc3612ec635fee29b" +checksum = "13e3bf6590cbc649f4d1a3eefc9d5d6eb746f5200ffb04e5e142700b8faa56e7" [[package]] name = "libflate" @@ -7309,7 +7336,7 @@ dependencies = [ "parking_lot 0.12.1", "pin-project", "quick-protobuf", - "rand 0.8.5", + "rand", "rw-stream-sink", "smallvec", "thiserror", @@ -7365,7 +7392,7 @@ dependencies = [ "multiaddr", "multihash 0.17.0", "quick-protobuf", - "rand 0.8.5", + "rand", "sha2 0.10.7", "thiserror", "zeroize", @@ -7390,7 +7417,7 @@ dependencies = [ "libp2p-swarm", "log", "quick-protobuf", - "rand 0.8.5", + "rand", "sha2 0.10.7", "smallvec", "thiserror", @@ -7412,7 +7439,7 @@ dependencies = [ "libp2p-identity", "libp2p-swarm", "log", - "rand 0.8.5", + "rand", "smallvec", "socket2 0.4.9", "tokio", @@ -7448,7 +7475,7 @@ dependencies = [ "log", "once_cell", "quick-protobuf", - "rand 0.8.5", + "rand", "sha2 0.10.7", "snow", "static_assertions", @@ -7470,7 +7497,7 @@ dependencies = [ "libp2p-core", "libp2p-swarm", "log", - "rand 0.8.5", + "rand", "void", ] @@ -7490,7 +7517,7 @@ dependencies = [ "log", "parking_lot 0.12.1", "quinn-proto", - "rand 0.8.5", + "rand", "rustls 0.20.8", "thiserror", "tokio", @@ -7508,7 +7535,7 @@ dependencies = [ "libp2p-core", "libp2p-identity", "libp2p-swarm", - "rand 0.8.5", + "rand", "smallvec", ] @@ -7527,7 +7554,7 @@ dependencies = [ "libp2p-identity", "libp2p-swarm-derive", "log", - "rand 0.8.5", + "rand", "smallvec", "tokio", "void", @@ -7653,7 +7680,7 @@ dependencies = [ "libsecp256k1-core", "libsecp256k1-gen-ecmult", "libsecp256k1-gen-genmult", - "rand 0.8.5", + "rand", "serde", "sha2 0.9.9", "typenum", @@ -7871,7 +7898,7 @@ dependencies = [ "macro_magic_core", "macro_magic_macros", "quote", - "syn 2.0.41", + "syn 2.0.48", ] [[package]] @@ -7885,7 +7912,7 @@ dependencies = [ "macro_magic_core_macros", "proc-macro2", "quote", - "syn 2.0.41", + "syn 2.0.48", ] [[package]] @@ -7896,7 +7923,7 @@ checksum = "9ea73aa640dc01d62a590d48c0c3521ed739d53b27f919b25c3551e233481654" dependencies = [ "proc-macro2", "quote", - "syn 2.0.41", + "syn 2.0.48", ] [[package]] @@ -7907,7 +7934,7 @@ checksum = "ef9d79ae96aaba821963320eb2b6e34d17df1e5a83d8a1985c29cc5be59577b3" dependencies = [ "macro_magic_core", "quote", - "syn 2.0.41", + "syn 2.0.48", ] [[package]] @@ -7931,6 +7958,15 @@ dependencies = [ "regex-automata 0.1.10", ] +[[package]] +name = "matchers" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558" +dependencies = [ + "regex-automata 0.1.10", +] + [[package]] name = "matches" version = "0.1.10" @@ -7971,6 +8007,15 @@ dependencies = [ "libc", ] +[[package]] +name = "memmap2" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "45fd3a57831bf88bc63f8cebc0cf956116276e97fef3966103e96416209f7c92" +dependencies = [ + "libc", +] + [[package]] name = "memoffset" version = "0.7.1" @@ -8038,7 +8083,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "69672161530e8aeca1d1400fbf3f1a1747ff60ea604265a4e906c2442df20532" dependencies = [ "futures", - "rand 0.8.5", + "rand", "thrift", ] @@ -8051,7 +8096,7 @@ dependencies = [ "hex", "lazy_static", "parity-scale-codec", - "rand 0.8.5", + "rand", "scale-info", "zeroize", ] @@ -8072,7 +8117,7 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" name = "minimal-node" version = "4.0.0-dev" dependencies = [ - "clap 4.4.11", + "clap 4.4.18", "frame", "futures", "futures-timer", @@ -8157,7 +8202,7 @@ dependencies = [ "lioness", "log", "parking_lot 0.12.1", - "rand 0.8.5", + "rand", "rand_chacha 0.3.1", "rand_distr", "subtle 2.4.1", @@ -8192,7 +8237,6 @@ dependencies = [ name = "mmr-rpc" version = "4.0.0-dev" dependencies = [ - "anyhow", "jsonrpsee", "parity-scale-codec", "serde", @@ -8414,7 +8458,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7bddcd3bf5144b6392de80e04c347cd7fab2508f6df16a85fc496ecd5cec39bc" dependencies = [ "clap 3.2.25", - "rand 0.8.5", + "rand", ] [[package]] @@ -8536,7 +8580,7 @@ name = "node-bench" version = "0.9.0-dev" dependencies = [ "array-bytes 6.1.0", - "clap 4.4.11", + "clap 4.4.18", "derive_more", "fs_extra", "futures", @@ -8549,7 +8593,7 @@ dependencies = [ "node-primitives", "node-testing", "parity-db", - "rand 0.8.5", + "rand", "sc-basic-authorship", "sc-client-api", "sc-transaction-pool", @@ -8587,6 +8631,8 @@ dependencies = [ "sc-client-api", "sc-consensus-babe", "sc-consensus-babe-rpc", + "sc-consensus-beefy", + "sc-consensus-beefy-rpc", "sc-consensus-grandpa", "sc-consensus-grandpa-rpc", "sc-mixnet", @@ -8611,7 +8657,7 @@ dependencies = [ name = "node-runtime-generate-bags" version = "3.0.0" dependencies = [ - "clap 4.4.11", + "clap 4.4.18", "generate-bags", "kitchensink-runtime", ] @@ -8620,7 +8666,7 @@ dependencies = [ name = "node-template" version = "4.0.0-dev" dependencies = [ - "clap 4.4.11", + "clap 4.4.18", "frame-benchmarking", "frame-benchmarking-cli", "frame-system", @@ -8664,7 +8710,7 @@ dependencies = [ name = "node-template-release" version = "3.0.0" dependencies = [ - "clap 4.4.11", + "clap 4.4.18", "flate2", "fs_extra", "glob", @@ -8740,6 +8786,7 @@ dependencies = [ "sp-blockchain", "sp-consensus", "sp-core", + "sp-crypto-hashing", "sp-inherents", "sp-io", "sp-keyring", @@ -8778,6 +8825,16 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "61807f77802ff30975e01f4f071c8ba10c022052f98b3294119f3e615d13e5be" +[[package]] +name = "nu-ansi-term" +version = "0.46.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84" +dependencies = [ + "overload", + "winapi", +] + [[package]] name = "num" version = "0.4.1" @@ -8895,9 +8952,9 @@ dependencies = [ [[package]] name = "object" -version = "0.32.0" +version = "0.32.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77ac5bbd07aea88c60a577a1ce218075ffd59208b2d7ca97adf9bfc5aeb21ebe" +checksum = "a6a622008b6e321afc04970976f62ee297fdbaa6f95318ca343e3eebb9648441" dependencies = [ "memchr", ] @@ -8949,9 +9006,9 @@ checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" [[package]] name = "orchestra" -version = "0.3.3" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46d78e1deb2a8d54fc1f063a544130db4da31dfe4d5d3b493186424910222a76" +checksum = "5edee0c1917703f8a28cd229cf6a5c91a7ee34be139ced16509ac5b53b9d0c51" dependencies = [ "async-trait", "dyn-clonable", @@ -8966,16 +9023,13 @@ dependencies = [ [[package]] name = "orchestra-proc-macro" -version = "0.3.3" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d035b1f968d91a826f2e34a9d6d02cb2af5aa7ca39ebd27922d850ab4b2dd2c6" +checksum = "4f60e64a3808b5bb2786b9da09fc70714952aabcdd0eeba6f1718e3dbc34ad5b" dependencies = [ - "anyhow", "expander 2.0.0", - "fs-err", "indexmap 2.0.0", "itertools 0.11.0", - "layout-rs", "petgraph", "proc-macro-crate 1.3.1", "proc-macro2", @@ -8992,22 +9046,18 @@ dependencies = [ "num-traits", ] -[[package]] -name = "os_pipe" -version = "1.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ae859aa07428ca9a929b936690f8b12dc5f11dd8c6992a18ca93919f28bc177" -dependencies = [ - "libc", - "windows-sys 0.48.0", -] - [[package]] name = "os_str_bytes" version = "6.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4d5d9eb14b174ee9aa2ef96dc2b94637a2d4b6e7cb873c7e171f0c20c6cf3eac" +[[package]] +name = "overload" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" + [[package]] name = "owo-colors" version = "3.5.0" @@ -9029,7 +9079,7 @@ dependencies = [ "parity-scale-codec", "scale-info", "sp-core", - "sp-core-hashing", + "sp-crypto-hashing", "sp-io", "sp-runtime", "sp-std 8.0.0", @@ -9250,7 +9300,7 @@ dependencies = [ "frame-election-provider-support", "honggfuzz", "pallet-bags-list", - "rand 0.8.5", + "rand", ] [[package]] @@ -9496,7 +9546,7 @@ dependencies = [ "pallet-session", "pallet-timestamp", "parity-scale-codec", - "rand 0.8.5", + "rand", "scale-info", "sp-consensus-aura", "sp-core", @@ -9564,7 +9614,7 @@ dependencies = [ "pallet-utility", "parity-scale-codec", "pretty_assertions", - "rand 0.8.5", + "rand", "rand_pcg", "scale-info", "serde", @@ -9578,7 +9628,7 @@ dependencies = [ "sp-tracing 10.0.0", "staging-xcm", "staging-xcm-builder", - "wasm-instrument 0.4.0", + "wasm-instrument", "wasmi", "wat", ] @@ -9588,20 +9638,16 @@ name = "pallet-contracts-fixtures" version = "1.0.0" dependencies = [ "anyhow", - "cfg-if", "frame-system", "parity-wasm", + "polkavm-linker", "sp-runtime", "tempfile", - "toml 0.8.2", + "toml 0.8.8", "twox-hash", "wat", ] -[[package]] -name = "pallet-contracts-fixtures-common" -version = "1.0.0" - [[package]] name = "pallet-contracts-mock-network" version = "1.0.0" @@ -9646,7 +9692,7 @@ version = "4.0.0-dev" dependencies = [ "proc-macro2", "quote", - "syn 2.0.41", + "syn 2.0.48", ] [[package]] @@ -9656,6 +9702,7 @@ dependencies = [ "bitflags 1.3.2", "parity-scale-codec", "paste", + "polkavm-derive", "scale-info", ] @@ -9784,7 +9831,7 @@ dependencies = [ "pallet-election-provider-support-benchmarking", "parity-scale-codec", "parking_lot 0.12.1", - "rand 0.8.5", + "rand", "scale-info", "sp-arithmetic", "sp-core", @@ -9793,7 +9840,7 @@ dependencies = [ "sp-runtime", "sp-std 8.0.0", "sp-tracing 10.0.0", - "strum", + "strum 0.24.1", ] [[package]] @@ -10016,11 +10063,13 @@ dependencies = [ "frame-benchmarking", "frame-support", "frame-system", + "log", "pallet-balances", "parity-scale-codec", "scale-info", "sp-core", "sp-io", + "sp-keystore", "sp-runtime", "sp-std 8.0.0", ] @@ -10120,12 +10169,13 @@ dependencies = [ "frame-system", "log", "parity-scale-codec", - "rand 0.8.5", + "rand", "rand_distr", "scale-info", "serde", "sp-arithmetic", "sp-core", + "sp-crypto-hashing", "sp-io", "sp-runtime", "sp-std 8.0.0", @@ -10334,7 +10384,7 @@ dependencies = [ "honggfuzz", "log", "pallet-nomination-pools", - "rand 0.8.5", + "rand", "sp-io", "sp-runtime", "sp-tracing 10.0.0", @@ -10652,6 +10702,7 @@ dependencies = [ "scale-info", "sp-consensus-sassafras", "sp-core", + "sp-crypto-hashing", "sp-io", "sp-runtime", "sp-std 8.0.0", @@ -10727,7 +10778,7 @@ dependencies = [ "pallet-staking-reward-curve", "pallet-timestamp", "parity-scale-codec", - "rand 0.8.5", + "rand", "scale-info", "sp-core", "sp-io", @@ -10763,6 +10814,7 @@ dependencies = [ "scale-info", "sp-arithmetic", "sp-core", + "sp-crypto-hashing", "sp-io", "sp-runtime", "sp-std 8.0.0", @@ -10802,11 +10854,11 @@ dependencies = [ name = "pallet-staking-reward-curve" version = "4.0.0-dev" dependencies = [ - "proc-macro-crate 2.0.1", + "proc-macro-crate 3.0.0", "proc-macro2", "quote", "sp-runtime", - "syn 2.0.41", + "syn 2.0.48", ] [[package]] @@ -11212,7 +11264,7 @@ dependencies = [ name = "parachain-template-node" version = "0.1.0" dependencies = [ - "clap 4.4.11", + "clap 4.4.18", "color-print", "cumulus-client-cli", "cumulus-client-collator", @@ -11340,6 +11392,7 @@ dependencies = [ "pallet-balances", "pallet-collator-selection", "pallet-message-queue", + "pallet-xcm", "parity-scale-codec", "polkadot-core-primitives", "polkadot-primitives", @@ -11354,6 +11407,7 @@ dependencies = [ "staging-parachain-info", "staging-xcm", "staging-xcm-builder", + "staging-xcm-executor", "substrate-wasm-builder", "westend-runtime-constants", ] @@ -11410,9 +11464,9 @@ dependencies = [ "libc", "log", "lz4", - "memmap2", + "memmap2 0.5.10", "parking_lot 0.12.1", - "rand 0.8.5", + "rand", "siphasher", "snap", ] @@ -11663,83 +11717,299 @@ dependencies = [ ] [[package]] -name = "percent-encoding" -version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" - -[[package]] -name = "pest" -version = "2.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1acb4a4365a13f749a93f1a094a7805e5cfa0955373a9de860d962eaa3a5fe5a" -dependencies = [ - "thiserror", - "ucd-trie", -] - -[[package]] -name = "pest_derive" -version = "2.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "666d00490d4ac815001da55838c500eafb0320019bbaa44444137c48b443a853" -dependencies = [ - "pest", - "pest_generator", -] - -[[package]] -name = "pest_generator" -version = "2.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68ca01446f50dbda87c1786af8770d535423fa8a53aec03b8f4e3d7eb10e0929" -dependencies = [ - "pest", - "pest_meta", - "proc-macro2", - "quote", - "syn 2.0.41", -] - -[[package]] -name = "pest_meta" -version = "2.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56af0a30af74d0445c0bf6d9d051c979b516a1a5af790d251daee76005420a48" +name = "people-rococo-emulated-chain" +version = "0.1.0" dependencies = [ - "once_cell", - "pest", - "sha2 0.10.7", + "cumulus-primitives-core", + "emulated-integration-tests-common", + "frame-support", + "parachains-common", + "people-rococo-runtime", + "rococo-emulated-chain", + "serde_json", + "sp-core", + "sp-runtime", ] [[package]] -name = "petgraph" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1d3afd2628e69da2be385eb6f2fd57c8ac7977ceeff6dc166ff1657b0e386a9" +name = "people-rococo-integration-tests" +version = "0.1.0" dependencies = [ - "fixedbitset", - "indexmap 2.0.0", + "assert_matches", + "asset-test-utils", + "emulated-integration-tests-common", + "frame-support", + "pallet-asset-conversion", + "pallet-assets", + "pallet-balances", + "pallet-identity", + "pallet-message-queue", + "pallet-xcm", + "parachains-common", + "parity-scale-codec", + "penpal-runtime", + "people-rococo-runtime", + "polkadot-primitives", + "polkadot-runtime-common", + "rococo-runtime", + "rococo-runtime-constants", + "rococo-system-emulated-network", + "sp-runtime", + "staging-xcm", + "staging-xcm-executor", ] [[package]] -name = "pin-project" -version = "1.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fda4ed1c6c173e3fc7a83629421152e01d7b1f9b7f65fb301e490e8cfc656422" +name = "people-rococo-runtime" +version = "0.1.0" dependencies = [ - "pin-project-internal", -] - -[[package]] -name = "pin-project-internal" -version = "1.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" + "cumulus-pallet-aura-ext", + "cumulus-pallet-dmp-queue", + "cumulus-pallet-parachain-system", + "cumulus-pallet-session-benchmarking", + "cumulus-pallet-xcm", + "cumulus-pallet-xcmp-queue", + "cumulus-primitives-core", + "cumulus-primitives-utility", + "enumflags2", + "frame-benchmarking", + "frame-executive", + "frame-support", + "frame-system", + "frame-system-benchmarking", + "frame-system-rpc-runtime-api", + "frame-try-runtime", + "hex-literal", + "log", + "pallet-aura", + "pallet-authorship", + "pallet-balances", + "pallet-collator-selection", + "pallet-identity", + "pallet-message-queue", + "pallet-multisig", + "pallet-session", + "pallet-timestamp", + "pallet-transaction-payment", + "pallet-transaction-payment-rpc-runtime-api", + "pallet-utility", + "pallet-xcm", + "pallet-xcm-benchmarks", + "parachains-common", + "parity-scale-codec", + "polkadot-core-primitives", + "polkadot-parachain-primitives", + "polkadot-runtime-common", + "rococo-runtime-constants", + "scale-info", + "serde", + "smallvec", + "sp-api", + "sp-block-builder", + "sp-consensus-aura", + "sp-core", + "sp-genesis-builder", + "sp-inherents", + "sp-offchain", + "sp-runtime", + "sp-session", + "sp-std 8.0.0", + "sp-storage 13.0.0", + "sp-transaction-pool", + "sp-version", + "staging-parachain-info", + "staging-xcm", + "staging-xcm-builder", + "staging-xcm-executor", + "substrate-wasm-builder", +] + +[[package]] +name = "people-westend-emulated-chain" +version = "0.1.0" +dependencies = [ + "cumulus-primitives-core", + "emulated-integration-tests-common", + "frame-support", + "parachains-common", + "people-westend-runtime", + "serde_json", + "sp-core", + "sp-runtime", + "westend-emulated-chain", +] + +[[package]] +name = "people-westend-integration-tests" +version = "0.1.0" +dependencies = [ + "assert_matches", + "asset-test-utils", + "emulated-integration-tests-common", + "frame-support", + "pallet-asset-conversion", + "pallet-assets", + "pallet-balances", + "pallet-identity", + "pallet-message-queue", + "pallet-xcm", + "parachains-common", + "parity-scale-codec", + "penpal-runtime", + "people-westend-runtime", + "polkadot-primitives", + "polkadot-runtime-common", + "sp-runtime", + "staging-xcm", + "staging-xcm-executor", + "westend-runtime", + "westend-runtime-constants", + "westend-system-emulated-network", +] + +[[package]] +name = "people-westend-runtime" +version = "0.1.0" +dependencies = [ + "cumulus-pallet-aura-ext", + "cumulus-pallet-dmp-queue", + "cumulus-pallet-parachain-system", + "cumulus-pallet-session-benchmarking", + "cumulus-pallet-xcm", + "cumulus-pallet-xcmp-queue", + "cumulus-primitives-core", + "cumulus-primitives-utility", + "enumflags2", + "frame-benchmarking", + "frame-executive", + "frame-support", + "frame-system", + "frame-system-benchmarking", + "frame-system-rpc-runtime-api", + "frame-try-runtime", + "hex-literal", + "log", + "pallet-aura", + "pallet-authorship", + "pallet-balances", + "pallet-collator-selection", + "pallet-identity", + "pallet-message-queue", + "pallet-multisig", + "pallet-session", + "pallet-timestamp", + "pallet-transaction-payment", + "pallet-transaction-payment-rpc-runtime-api", + "pallet-utility", + "pallet-xcm", + "pallet-xcm-benchmarks", + "parachains-common", + "parity-scale-codec", + "polkadot-core-primitives", + "polkadot-parachain-primitives", + "polkadot-runtime-common", + "scale-info", + "serde", + "smallvec", + "sp-api", + "sp-block-builder", + "sp-consensus-aura", + "sp-core", + "sp-genesis-builder", + "sp-inherents", + "sp-offchain", + "sp-runtime", + "sp-session", + "sp-std 8.0.0", + "sp-storage 13.0.0", + "sp-transaction-pool", + "sp-version", + "staging-parachain-info", + "staging-xcm", + "staging-xcm-builder", + "staging-xcm-executor", + "substrate-wasm-builder", + "westend-runtime-constants", +] + +[[package]] +name = "percent-encoding" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" + +[[package]] +name = "pest" +version = "2.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1acb4a4365a13f749a93f1a094a7805e5cfa0955373a9de860d962eaa3a5fe5a" +dependencies = [ + "thiserror", + "ucd-trie", +] + +[[package]] +name = "pest_derive" +version = "2.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "666d00490d4ac815001da55838c500eafb0320019bbaa44444137c48b443a853" +dependencies = [ + "pest", + "pest_generator", +] + +[[package]] +name = "pest_generator" +version = "2.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68ca01446f50dbda87c1786af8770d535423fa8a53aec03b8f4e3d7eb10e0929" +dependencies = [ + "pest", + "pest_meta", + "proc-macro2", + "quote", + "syn 2.0.48", +] + +[[package]] +name = "pest_meta" +version = "2.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56af0a30af74d0445c0bf6d9d051c979b516a1a5af790d251daee76005420a48" +dependencies = [ + "once_cell", + "pest", + "sha2 0.10.7", +] + +[[package]] +name = "petgraph" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1d3afd2628e69da2be385eb6f2fd57c8ac7977ceeff6dc166ff1657b0e386a9" +dependencies = [ + "fixedbitset", + "indexmap 2.0.0", +] + +[[package]] +name = "pin-project" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fda4ed1c6c173e3fc7a83629421152e01d7b1f9b7f65fb301e490e8cfc656422" +dependencies = [ + "pin-project-internal", +] + +[[package]] +name = "pin-project-internal" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4359fd9c9171ec6e8c62926d6faaf553a8dc3f64e1507e76da7911b4f6a04405" dependencies = [ "proc-macro2", "quote", - "syn 2.0.41", + "syn 2.0.48", ] [[package]] @@ -11812,7 +12082,7 @@ dependencies = [ [[package]] name = "polkadot" -version = "1.5.0" +version = "1.6.0" dependencies = [ "assert_cmd", "color-eyre", @@ -11851,7 +12121,7 @@ dependencies = [ "polkadot-node-subsystem-util", "polkadot-primitives", "polkadot-primitives-test-helpers", - "rand 0.8.5", + "rand", "rand_chacha 0.3.1", "rand_core 0.6.4", "schnorrkel 0.11.4", @@ -11877,7 +12147,7 @@ dependencies = [ "polkadot-node-subsystem-test-helpers", "polkadot-node-subsystem-util", "polkadot-primitives", - "rand 0.8.5", + "rand", "rand_chacha 0.3.1", "sp-application-crypto", "sp-authority-discovery", @@ -11905,7 +12175,7 @@ dependencies = [ "polkadot-node-subsystem-util", "polkadot-primitives", "polkadot-primitives-test-helpers", - "rand 0.8.5", + "rand", "sc-network", "schnellru", "sp-core", @@ -11936,7 +12206,7 @@ dependencies = [ "polkadot-node-subsystem-util", "polkadot-primitives", "polkadot-primitives-test-helpers", - "rand 0.8.5", + "rand", "sc-network", "schnellru", "sp-application-crypto", @@ -11952,7 +12222,7 @@ name = "polkadot-cli" version = "1.1.0" dependencies = [ "cfg-if", - "clap 4.4.11", + "clap 4.4.18", "frame-benchmarking-cli", "futures", "log", @@ -12028,7 +12298,7 @@ dependencies = [ "fatality", "futures", "futures-timer", - "indexmap 1.9.3", + "indexmap 2.0.0", "lazy_static", "parity-scale-codec", "polkadot-erasure-coding", @@ -12079,7 +12349,7 @@ dependencies = [ "polkadot-node-subsystem-util", "polkadot-primitives", "quickcheck", - "rand 0.8.5", + "rand", "rand_chacha 0.3.1", "sc-network", "sc-network-common", @@ -12087,6 +12357,7 @@ dependencies = [ "sp-authority-discovery", "sp-consensus-babe", "sp-core", + "sp-crypto-hashing", "sp-keyring", "sp-keystore", "sp-tracing 10.0.0", @@ -12169,7 +12440,7 @@ dependencies = [ "polkadot-overseer", "polkadot-primitives", "polkadot-primitives-test-helpers", - "rand 0.8.5", + "rand", "rand_chacha 0.3.1", "rand_core 0.6.4", "sc-keystore", @@ -12419,6 +12690,7 @@ name = "polkadot-node-core-pvf" version = "1.0.0" dependencies = [ "always-assert", + "array-bytes 6.1.0", "assert_matches", "blake3", "cfg-if", @@ -12441,7 +12713,7 @@ dependencies = [ "polkadot-parachain-primitives", "polkadot-primitives", "procfs", - "rand 0.8.5", + "rand", "rococo-runtime", "rusty-fork", "sc-sysinfo", @@ -12490,6 +12762,7 @@ dependencies = [ "futures", "landlock", "libc", + "nix 0.27.1", "parity-scale-codec", "polkadot-parachain-primitives", "polkadot-primitives", @@ -12498,10 +12771,10 @@ dependencies = [ "sc-executor-wasmtime", "seccompiler", "sp-core", + "sp-crypto-hashing", "sp-externalities 0.19.0", "sp-io", "sp-tracing 10.0.0", - "substrate-build-script-utils", "tempfile", "thiserror", "tracing-gum", @@ -12511,10 +12784,10 @@ dependencies = [ name = "polkadot-node-core-pvf-execute-worker" version = "1.0.0" dependencies = [ + "cfg-if", "cpu-time", "libc", "nix 0.27.1", - "os_pipe", "parity-scale-codec", "polkadot-node-core-pvf-common", "polkadot-parachain-primitives", @@ -12531,7 +12804,6 @@ dependencies = [ "criterion 0.4.0", "libc", "nix 0.27.1", - "os_pipe", "parity-scale-codec", "polkadot-node-core-pvf-common", "polkadot-primitives", @@ -12625,11 +12897,11 @@ dependencies = [ "polkadot-node-jaeger", "polkadot-node-primitives", "polkadot-primitives", - "rand 0.8.5", + "rand", "rand_chacha 0.3.1", "sc-authority-discovery", "sc-network", - "strum", + "strum 0.24.1", "thiserror", "tracing-gum", ] @@ -12733,7 +13005,7 @@ dependencies = [ "log", "parity-db", "parity-scale-codec", - "parking_lot 0.11.2", + "parking_lot 0.12.1", "pin-project", "polkadot-node-jaeger", "polkadot-node-metrics", @@ -12746,7 +13018,7 @@ dependencies = [ "polkadot-primitives", "polkadot-primitives-test-helpers", "prioritized-metered-channel", - "rand 0.8.5", + "rand", "sc-client-api", "schnellru", "sp-application-crypto", @@ -12785,7 +13057,7 @@ dependencies = [ [[package]] name = "polkadot-parachain-bin" -version = "1.5.0" +version = "1.6.0" dependencies = [ "assert_cmd", "asset-hub-rococo-runtime", @@ -12793,7 +13065,7 @@ dependencies = [ "async-trait", "bridge-hub-rococo-runtime", "bridge-hub-westend-runtime", - "clap 4.4.11", + "clap 4.4.18", "collectives-westend-runtime", "color-print", "contracts-rococo-runtime", @@ -12805,10 +13077,10 @@ dependencies = [ "cumulus-client-consensus-common", "cumulus-client-consensus-proposer", "cumulus-client-consensus-relay-chain", + "cumulus-client-parachain-inherent", "cumulus-client-service", "cumulus-primitives-aura", "cumulus-primitives-core", - "cumulus-primitives-parachain-inherent", "cumulus-relay-chain-interface", "frame-benchmarking", "frame-benchmarking-cli", @@ -12827,6 +13099,8 @@ dependencies = [ "parachains-common", "parity-scale-codec", "penpal-runtime", + "people-rococo-runtime", + "people-westend-runtime", "polkadot-cli", "polkadot-primitives", "polkadot-service", @@ -12923,7 +13197,7 @@ name = "polkadot-primitives-test-helpers" version = "1.0.0" dependencies = [ "polkadot-primitives", - "rand 0.8.5", + "rand", "sp-application-crypto", "sp-core", "sp-keyring", @@ -12948,6 +13222,7 @@ dependencies = [ "sc-consensus-grandpa", "sc-consensus-grandpa-rpc", "sc-rpc", + "sc-rpc-spec-v2", "sc-sync-state-rpc", "sc-transaction-pool-api", "sp-api", @@ -12979,6 +13254,7 @@ dependencies = [ "pallet-authorship", "pallet-babe", "pallet-balances", + "pallet-broker", "pallet-election-provider-multi-phase", "pallet-fast-unstake", "pallet-identity", @@ -13049,6 +13325,7 @@ dependencies = [ "pallet-authorship", "pallet-babe", "pallet-balances", + "pallet-broker", "pallet-message-queue", "pallet-session", "pallet-staking", @@ -13060,7 +13337,7 @@ dependencies = [ "polkadot-primitives", "polkadot-primitives-test-helpers", "polkadot-runtime-metrics", - "rand 0.8.5", + "rand", "rand_chacha 0.3.1", "rustc-hex", "sc-keystore", @@ -13069,7 +13346,9 @@ dependencies = [ "serde_json", "sp-api", "sp-application-crypto", + "sp-arithmetic", "sp-core", + "sp-crypto-hashing", "sp-inherents", "sp-io", "sp-keyring", @@ -13260,7 +13539,7 @@ dependencies = [ "fatality", "futures", "futures-timer", - "indexmap 1.9.3", + "indexmap 2.0.0", "parity-scale-codec", "polkadot-node-network-protocol", "polkadot-node-primitives", @@ -13298,7 +13577,7 @@ version = "1.0.0" dependencies = [ "assert_matches", "async-trait", - "clap 4.4.11", + "clap 4.4.18", "clap-num", "color-eyre", "colored", @@ -13325,7 +13604,7 @@ dependencies = [ "prometheus", "pyroscope", "pyroscope_pprofrs", - "rand 0.8.5", + "rand", "sc-keystore", "sc-network", "sc-service", @@ -13375,7 +13654,7 @@ version = "1.0.0" dependencies = [ "assert_matches", "async-trait", - "clap 4.4.11", + "clap 4.4.18", "color-eyre", "futures", "futures-timer", @@ -13393,7 +13672,7 @@ dependencies = [ "polkadot-node-subsystem-types", "polkadot-node-subsystem-util", "polkadot-primitives", - "rand 0.8.5", + "rand", "sp-core", "sp-keystore", "substrate-build-script-utils", @@ -13486,7 +13765,7 @@ dependencies = [ "polkadot-runtime-parachains", "polkadot-service", "polkadot-test-runtime", - "rand 0.8.5", + "rand", "sc-authority-discovery", "sc-chain-spec", "sc-cli", @@ -13522,12 +13801,61 @@ dependencies = [ name = "polkadot-voter-bags" version = "1.0.0" dependencies = [ - "clap 4.4.11", + "clap 4.4.18", "generate-bags", "sp-io", "westend-runtime", ] +[[package]] +name = "polkavm-common" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fecd2caacfc4a7ee34243758dd7348859e6dec73f5e5df059890f5742ee46f0e" + +[[package]] +name = "polkavm-common" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88b4e215c80fe876147f3d58158d5dfeae7dabdd6047e175af77095b78d0035c" + +[[package]] +name = "polkavm-derive" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db65a500d4adf574893c726ae365e37e4fbb7f2cbd403f6eaa1b665457456adc" +dependencies = [ + "polkavm-derive-impl", + "syn 2.0.48", +] + +[[package]] +name = "polkavm-derive-impl" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c99f4e7a9ff434ef9c885b874c99d824c3a5693bf5e3e8569bb1d2245a8c1b7f" +dependencies = [ + "polkavm-common 0.4.0", + "proc-macro2", + "quote", + "syn 2.0.48", +] + +[[package]] +name = "polkavm-linker" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a5a668bb33c7f0b5f4ca91adb1e1e71cf4930fef5e6909f46c2180d65cce37d0" +dependencies = [ + "gimli 0.28.0", + "hashbrown 0.14.3", + "log", + "object 0.32.2", + "polkavm-common 0.5.0", + "regalloc2 0.9.3", + "rustc-demangle", +] + [[package]] name = "polling" version = "2.8.0" @@ -13602,7 +13930,7 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "be97d76faf1bfab666e1375477b23fde79eccf0276e9b63b92a39d676a889ba9" dependencies = [ - "rand 0.8.5", + "rand", ] [[package]] @@ -13700,7 +14028,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c64d9ba0963cdcea2e1b2230fbae2bab30eb25a174be395c41e764bfb65dd62" dependencies = [ "proc-macro2", - "syn 2.0.41", + "syn 2.0.48", ] [[package]] @@ -13720,9 +14048,9 @@ dependencies = [ [[package]] name = "prioritized-metered-channel" -version = "0.5.1" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e99f0c89bd88f393aab44a4ab949351f7bc7e7e1179d11ecbfe50cbe4c47e342" +checksum = "a172e6cc603231f2cf004232eabcecccc0da53ba576ab286ef7baa0cfc7927ad" dependencies = [ "coarsetime", "crossbeam-queue", @@ -13746,12 +14074,11 @@ dependencies = [ [[package]] name = "proc-macro-crate" -version = "2.0.1" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97dc5fea232fc28d2f597b37c4876b348a40e33f3b02cc975c8d006d78d94b1a" +checksum = "6b2685dd208a3771337d8d386a89840f0f43cd68be8dae90a5f8c2384effc9cd" dependencies = [ - "toml_datetime", - "toml_edit 0.20.2", + "toml_edit 0.21.0", ] [[package]] @@ -13792,14 +14119,14 @@ checksum = "9b698b0b09d40e9b7c1a47b132d66a8b54bcd20583d9b6d06e4535e383b4405c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.41", + "syn 2.0.48", ] [[package]] name = "proc-macro2" -version = "1.0.69" +version = "1.0.75" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da" +checksum = "907a61bd0f64c2f29cd1cf1dc34d05176426a3f504a78010f08416ddb7b13708" dependencies = [ "unicode-ident", ] @@ -13864,7 +14191,7 @@ checksum = "440f724eba9f6996b75d63681b0a92b06947f1457076d503a4d2e2c8f56442b8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.41", + "syn 2.0.48", ] [[package]] @@ -13890,7 +14217,7 @@ dependencies = [ "bitflags 2.4.0", "lazy_static", "num-traits", - "rand 0.8.5", + "rand", "rand_chacha 0.3.1", "rand_xorshift", "regex-syntax 0.8.2", @@ -13906,7 +14233,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b82eaa1d779e9a4bc1c3217db8ffbeabaae1dca241bf70183242128d48681cd" dependencies = [ "bytes", - "prost-derive", + "prost-derive 0.11.9", +] + +[[package]] +name = "prost" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "146c289cda302b98a28d40c8b3b90498d6e526dd24ac2ecea73e4e491685b94a" +dependencies = [ + "bytes", + "prost-derive 0.12.3", ] [[package]] @@ -13923,7 +14260,7 @@ dependencies = [ "multimap", "petgraph", "prettyplease 0.1.25", - "prost", + "prost 0.11.9", "prost-types", "regex", "syn 1.0.109", @@ -13944,13 +14281,26 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "prost-derive" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "efb6c9a1dd1def8e2124d17e83a20af56f1570d6c2d2bd9e266ccb768df3840e" +dependencies = [ + "anyhow", + "itertools 0.11.0", + "proc-macro2", + "quote", + "syn 2.0.48", +] + [[package]] name = "prost-types" version = "0.11.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "213622a1460818959ac1181aaeb2dc9c7f63df720db7d788b3e24eacd1983e13" dependencies = [ - "prost", + "prost 0.11.9", ] [[package]] @@ -13973,7 +14323,7 @@ dependencies = [ "libflate", "log", "names", - "prost", + "prost 0.11.9", "reqwest", "thiserror", "url", @@ -14028,7 +14378,7 @@ checksum = "588f6378e4dd99458b60ec275b4477add41ce4fa9f64dcba6f15adccb19b50d6" dependencies = [ "env_logger 0.8.4", "log", - "rand 0.8.5", + "rand", ] [[package]] @@ -14049,7 +14399,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c956be1b23f4261676aed05a0046e204e8a6836e50203902683a718af0797989" dependencies = [ "bytes", - "rand 0.8.5", + "rand", "ring 0.16.20", "rustc-hash", "rustls 0.20.8", @@ -14062,31 +14412,18 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.33" +version = "1.0.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" +checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" dependencies = [ "proc-macro2", ] -[[package]] -name = "radium" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" - -[[package]] -name = "rand" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" -dependencies = [ - "getrandom 0.1.16", - "libc", - "rand_chacha 0.2.2", - "rand_core 0.5.1", - "rand_hc", -] +[[package]] +name = "radium" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" [[package]] name = "rand" @@ -14144,16 +14481,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32cb0b9bc82b0a0876c2dd994a7e7a2683d3e7390ca40e6886785ef0c7e3ee31" dependencies = [ "num-traits", - "rand 0.8.5", -] - -[[package]] -name = "rand_hc" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" -dependencies = [ - "rand_core 0.5.1", + "rand", ] [[package]] @@ -14282,7 +14610,7 @@ checksum = "7f7473c2cfcf90008193dd0e3e16599455cb601a9fce322b5bb55de799664925" dependencies = [ "proc-macro2", "quote", - "syn 2.0.41", + "syn 2.0.48", ] [[package]] @@ -14297,6 +14625,19 @@ dependencies = [ "smallvec", ] +[[package]] +name = "regalloc2" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad156d539c879b7a24a363a2016d77961786e71f48f2e2fc8302a92abd2429a6" +dependencies = [ + "hashbrown 0.13.2", + "log", + "rustc-hash", + "slice-group-by", + "smallvec", +] + [[package]] name = "regex" version = "1.10.2" @@ -14351,7 +14692,7 @@ checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" name = "remote-ext-tests-bags-list" version = "1.0.0" dependencies = [ - "clap 4.4.11", + "clap 4.4.18", "frame-system", "log", "pallet-bags-list-remote-tests", @@ -14447,11 +14788,25 @@ dependencies = [ "libc", "once_cell", "spin 0.5.2", - "untrusted", + "untrusted 0.7.1", "web-sys", "winapi", ] +[[package]] +name = "ring" +version = "0.17.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "688c63d65483050968b2a8937f7995f443e27041a0f7700aa59b0822aedebb74" +dependencies = [ + "cc", + "getrandom 0.2.10", + "libc", + "spin 0.9.8", + "untrusted 0.9.0", + "windows-sys 0.48.0", +] + [[package]] name = "ripemd" version = "0.1.3" @@ -14683,6 +15038,7 @@ dependencies = [ "bridge-hub-rococo-emulated-chain", "emulated-integration-tests-common", "penpal-emulated-chain", + "people-rococo-emulated-chain", "rococo-emulated-chain", ] @@ -14700,6 +15056,12 @@ dependencies = [ "westend-emulated-chain", ] +[[package]] +name = "route-recognizer" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "afab94fb28594581f62d981211a9a4d53cc8130bbcbbb89a0440d9b8e81a7746" + [[package]] name = "rpassword" version = "7.2.0" @@ -14752,7 +15114,7 @@ dependencies = [ "parity-scale-codec", "primitive-types", "proptest", - "rand 0.8.5", + "rand", "rlp", "ruint-macro", "serde", @@ -14881,7 +15243,7 @@ checksum = "1d1feddffcfcc0b33f5c6ce9a29e341e4cd59c3f78e7ee45f4a40c038b1d6cbb" dependencies = [ "log", "ring 0.16.20", - "rustls-webpki 0.101.4", + "rustls-webpki", "sct", ] @@ -14906,16 +15268,6 @@ dependencies = [ "base64 0.21.2", ] -[[package]] -name = "rustls-webpki" -version = "0.100.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e98ff011474fa39949b7e5c0428f9b4937eda7da7848bbb947786b7be0b27dab" -dependencies = [ - "ring 0.16.20", - "untrusted", -] - [[package]] name = "rustls-webpki" version = "0.101.4" @@ -14923,7 +15275,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7d93931baf2d282fff8d3a532bbfd7653f734643161b87e3e01e59a04439bf0d" dependencies = [ "ring 0.16.20", - "untrusted", + "untrusted 0.7.1", ] [[package]] @@ -15022,10 +15374,10 @@ dependencies = [ "multihash 0.18.1", "multihash-codetable", "parity-scale-codec", - "prost", + "prost 0.12.3", "prost-build", "quickcheck", - "rand 0.8.5", + "rand", "sc-client-api", "sc-network", "sp-api", @@ -15088,7 +15440,7 @@ dependencies = [ "array-bytes 6.1.0", "docify", "log", - "memmap2", + "memmap2 0.9.3", "parity-scale-codec", "sc-chain-spec-derive", "sc-client-api", @@ -15101,6 +15453,7 @@ dependencies = [ "sp-blockchain", "sp-consensus-babe", "sp-core", + "sp-crypto-hashing", "sp-genesis-builder", "sp-io", "sp-keyring", @@ -15113,10 +15466,10 @@ dependencies = [ name = "sc-chain-spec-derive" version = "4.0.0-dev" dependencies = [ - "proc-macro-crate 2.0.1", + "proc-macro-crate 3.0.0", "proc-macro2", "quote", - "syn 2.0.41", + "syn 2.0.48", ] [[package]] @@ -15126,7 +15479,7 @@ dependencies = [ "array-bytes 6.1.0", "bip39", "chrono", - "clap 4.4.11", + "clap 4.4.18", "fdlimit", "futures", "futures-timer", @@ -15135,7 +15488,7 @@ dependencies = [ "log", "names", "parity-scale-codec", - "rand 0.8.5", + "rand", "regex", "rpassword", "sc-client-api", @@ -15208,7 +15561,7 @@ dependencies = [ "parity-scale-codec", "parking_lot 0.12.1", "quickcheck", - "rand 0.8.5", + "rand", "sc-client-api", "sc-state-db", "schnellru", @@ -15316,6 +15669,7 @@ dependencies = [ "sp-consensus-babe", "sp-consensus-slots", "sp-core", + "sp-crypto-hashing", "sp-inherents", "sp-keyring", "sp-keystore", @@ -15385,6 +15739,7 @@ dependencies = [ "sp-consensus-beefy", "sp-consensus-grandpa", "sp-core", + "sp-crypto-hashing", "sp-keyring", "sp-keystore", "sp-mmr-primitives", @@ -15435,7 +15790,7 @@ dependencies = [ name = "sc-consensus-grandpa" version = "0.10.0-dev" dependencies = [ - "ahash 0.8.3", + "ahash 0.8.7", "array-bytes 6.1.0", "assert_matches", "async-trait", @@ -15447,7 +15802,7 @@ dependencies = [ "log", "parity-scale-codec", "parking_lot 0.12.1", - "rand 0.8.5", + "rand", "sc-block-builder", "sc-chain-spec", "sc-client-api", @@ -15469,6 +15824,7 @@ dependencies = [ "sp-consensus", "sp-consensus-grandpa", "sp-core", + "sp-crypto-hashing", "sp-keyring", "sp-keystore", "sp-runtime", @@ -15608,6 +15964,7 @@ dependencies = [ "schnellru", "sp-api", "sp-core", + "sp-crypto-hashing", "sp-externalities 0.19.0", "sp-io", "sp-maybe-compressed-blob", @@ -15622,7 +15979,7 @@ dependencies = [ "substrate-test-runtime", "tempfile", "tracing", - "tracing-subscriber", + "tracing-subscriber 0.2.25", "wat", ] @@ -15634,7 +15991,7 @@ dependencies = [ "sp-maybe-compressed-blob", "sp-wasm-interface 14.0.0", "thiserror", - "wasm-instrument 0.3.0", + "wasm-instrument", ] [[package]] @@ -15743,7 +16100,7 @@ dependencies = [ "parking_lot 0.12.1", "partial_sort", "pin-project", - "rand 0.8.5", + "rand", "sc-client-api", "sc-network-common", "sc-network-light", @@ -15781,7 +16138,7 @@ dependencies = [ "futures", "libp2p-identity", "log", - "prost", + "prost 0.12.3", "prost-build", "sc-block-builder", "sc-client-api", @@ -15789,7 +16146,7 @@ dependencies = [ "sc-network", "sp-blockchain", "sp-consensus", - "sp-core", + "sp-crypto-hashing", "sp-runtime", "substrate-test-runtime", "substrate-test-runtime-client", @@ -15819,7 +16176,7 @@ dependencies = [ name = "sc-network-gossip" version = "0.10.0-dev" dependencies = [ - "ahash 0.8.3", + "ahash 0.8.7", "async-trait", "futures", "futures-timer", @@ -15848,7 +16205,7 @@ dependencies = [ "libp2p-identity", "log", "parity-scale-codec", - "prost", + "prost 0.12.3", "prost-build", "sc-client-api", "sc-network", @@ -15890,7 +16247,7 @@ dependencies = [ "log", "mockall", "parity-scale-codec", - "prost", + "prost 0.12.3", "prost-build", "quickcheck", "sc-block-builder", @@ -15926,7 +16283,7 @@ dependencies = [ "libp2p", "log", "parking_lot 0.12.1", - "rand 0.8.5", + "rand", "sc-block-builder", "sc-client-api", "sc-consensus", @@ -15982,7 +16339,7 @@ dependencies = [ "once_cell", "parity-scale-codec", "parking_lot 0.12.1", - "rand 0.8.5", + "rand", "sc-block-builder", "sc-client-api", "sc-client-db", @@ -16041,6 +16398,7 @@ dependencies = [ "sp-blockchain", "sp-consensus", "sp-core", + "sp-crypto-hashing", "sp-io", "sp-keystore", "sp-offchain", @@ -16051,6 +16409,7 @@ dependencies = [ "sp-version", "substrate-test-runtime-client", "tokio", + "tracing-subscriber 0.3.18", ] [[package]] @@ -16103,6 +16462,7 @@ dependencies = [ "sc-block-builder", "sc-chain-spec", "sc-client-api", + "sc-rpc", "sc-service", "sc-transaction-pool-api", "sc-utils", @@ -16150,7 +16510,7 @@ dependencies = [ "parity-scale-codec", "parking_lot 0.12.1", "pin-project", - "rand 0.8.5", + "rand", "sc-chain-spec", "sc-client-api", "sc-client-db", @@ -16270,10 +16630,9 @@ dependencies = [ name = "sc-storage-monitor" version = "0.1.0" dependencies = [ - "clap 4.4.11", + "clap 4.4.18", "fs4", "log", - "sc-client-db", "sp-core", "thiserror", "tokio", @@ -16305,13 +16664,14 @@ dependencies = [ "futures", "libc", "log", - "rand 0.8.5", + "rand", "rand_pcg", "regex", "sc-telemetry", "serde", "serde_json", "sp-core", + "sp-crypto-hashing", "sp-io", "sp-runtime", "sp-std 8.0.0", @@ -16327,7 +16687,7 @@ dependencies = [ "log", "parking_lot 0.12.1", "pin-project", - "rand 0.8.5", + "rand", "sc-utils", "serde", "serde_json", @@ -16361,18 +16721,18 @@ dependencies = [ "sp-tracing 10.0.0", "thiserror", "tracing", - "tracing-log", - "tracing-subscriber", + "tracing-log 0.1.3", + "tracing-subscriber 0.2.25", ] [[package]] name = "sc-tracing-proc-macro" version = "4.0.0-dev" dependencies = [ - "proc-macro-crate 2.0.1", + "proc-macro-crate 3.0.0", "proc-macro2", "quote", - "syn 2.0.41", + "syn 2.0.48", ] [[package]] @@ -16398,6 +16758,7 @@ dependencies = [ "sp-blockchain", "sp-consensus", "sp-core", + "sp-crypto-hashing", "sp-runtime", "sp-tracing 10.0.0", "sp-transaction-pool", @@ -16504,7 +16865,7 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "772575a524feeb803e5b0fcbc6dd9f367e579488197c94c6e4023aad2305774d" dependencies = [ - "ahash 0.8.3", + "ahash 0.8.7", "cfg-if", "hashbrown 0.13.2", ] @@ -16518,9 +16879,7 @@ dependencies = [ "arrayref", "arrayvec 0.5.2", "curve25519-dalek 2.1.3", - "getrandom 0.1.16", "merlin 2.0.1", - "rand 0.7.3", "rand_core 0.5.1", "sha2 0.8.2", "subtle 2.4.1", @@ -16562,6 +16921,12 @@ dependencies = [ "zeroize", ] +[[package]] +name = "scoped-tls" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1cf6437eb19a8f4a6cc0f7dca544973b0b78843adbfeb3683d1a94a0024a294" + [[package]] name = "scopeguard" version = "1.2.0" @@ -16581,7 +16946,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d53dcdb7c9f8158937a7981b48accfd39a43af418591a5d008c7b22b5e1b7ca4" dependencies = [ "ring 0.16.20", - "untrusted", + "untrusted 0.7.1", ] [[package]] @@ -16751,9 +17116,9 @@ checksum = "f97841a747eef040fcd2e7b3b9a220a7205926e60488e673d9e4926d27772ce5" [[package]] name = "serde" -version = "1.0.193" +version = "1.0.195" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25dd9975e68d0cb5aa1120c288333fc98731bd1dd12f561e468ea4728c042b89" +checksum = "63261df402c67811e9ac6def069e4786148c4563f4b50fd4bf30aa370d626b02" dependencies = [ "serde_derive", ] @@ -16778,13 +17143,13 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.193" +version = "1.0.195" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3" +checksum = "46fe8f8603d81ba86327b23a2e9cdf49e1255fb94a4c5f297f6ee0547178ea2c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.41", + "syn 2.0.48", ] [[package]] @@ -16809,9 +17174,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.108" +version = "1.0.111" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d1c7e3eac408d115102c4c24ad393e0821bb3a5df4d506a80f85f7a742a526b" +checksum = "176e46fa42316f18edd598015a5166857fc835ec732f5215eac6b7bdbf0a84f4" dependencies = [ "itoa", "ryu", @@ -16841,9 +17206,9 @@ dependencies = [ [[package]] name = "serde_yaml" -version = "0.9.27" +version = "0.9.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3cc7a1570e38322cfe4154732e5110f887ea57e22b76f4bfd32b5bdd3368666c" +checksum = "b1bf28c79a99f70ee1f1d83d10c875d2e70618417fda01ad1785e027579d9d38" dependencies = [ "indexmap 2.0.0", "itoa", @@ -16874,7 +17239,7 @@ checksum = "91d129178576168c589c9ec973feedf7d3126c01ac2bf08795109aa35b69fb8f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.41", + "syn 2.0.48", ] [[package]] @@ -17006,9 +17371,9 @@ dependencies = [ [[package]] name = "shlex" -version = "1.1.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43b2853a4d09f215c24cc5489c992ce46052d359b5109343cbafbf26bc62f8a3" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" [[package]] name = "signal-hook" @@ -17100,9 +17465,9 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.11.0" +version = "1.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62bb4feee49fdd9f707ef802e22365a35de4b7b299de4763d44bfea899442ff9" +checksum = "4dccd0940a2dcdf68d092b8cbab7dc0ad8fa938bf95787e1b916b0e3d0e8e970" [[package]] name = "smol" @@ -17152,7 +17517,7 @@ dependencies = [ "fnv", "futures-lite", "futures-util", - "hashbrown 0.14.0", + "hashbrown 0.14.3", "hex", "hmac 0.12.1", "itertools 0.11.0", @@ -17166,7 +17531,7 @@ dependencies = [ "pbkdf2 0.12.2", "pin-project", "poly1305 0.8.0", - "rand 0.8.5", + "rand", "rand_chacha 0.3.1", "ruzstd", "schnorrkel 0.10.2", @@ -17201,7 +17566,7 @@ dependencies = [ "futures-channel", "futures-lite", "futures-util", - "hashbrown 0.14.0", + "hashbrown 0.14.3", "hex", "itertools 0.11.0", "log", @@ -17209,7 +17574,7 @@ dependencies = [ "no-std-net", "parking_lot 0.12.1", "pin-project", - "rand 0.8.5", + "rand", "rand_chacha 0.3.1", "serde", "serde_json", @@ -17251,6 +17616,7 @@ dependencies = [ "frame-support", "frame-system", "hex", + "hex-literal", "milagro_bls", "parity-scale-codec", "rlp", @@ -17273,6 +17639,7 @@ dependencies = [ "ethabi-decode", "frame-support", "frame-system", + "hex", "hex-literal", "parity-scale-codec", "polkadot-parachain-primitives", @@ -17298,24 +17665,32 @@ dependencies = [ "hex-literal", "parity-bytes", "parity-scale-codec", + "rand", "rlp", "rustc-hex", "scale-info", "serde", "serde-big-array", + "serde_json", "sp-core", "sp-io", "sp-runtime", "sp-std 8.0.0", + "wasm-bindgen-test", ] [[package]] name = "snowbridge-outbound-queue-merkle-tree" version = "0.9.0" dependencies = [ + "array-bytes 4.2.0", + "env_logger 0.9.3", + "hex", + "hex-literal", "parity-scale-codec", "scale-info", "sp-core", + "sp-crypto-hashing", "sp-runtime", ] @@ -17346,14 +17721,17 @@ dependencies = [ "log", "pallet-timestamp", "parity-scale-codec", + "rand", "rlp", "scale-info", "serde", + "serde_json", "snowbridge-beacon-primitives", "snowbridge-core", "snowbridge-ethereum", "sp-core", "sp-io", + "sp-keyring", "sp-runtime", "sp-std 8.0.0", "ssz_rs", @@ -17381,9 +17759,11 @@ dependencies = [ "snowbridge-beacon-primitives", "snowbridge-core", "snowbridge-ethereum", + "snowbridge-pallet-ethereum-client", "snowbridge-router-primitives", "sp-core", "sp-io", + "sp-keyring", "sp-runtime", "sp-std 8.0.0", "staging-xcm", @@ -17401,6 +17781,7 @@ dependencies = [ "frame-support", "frame-system", "hex-literal", + "pallet-message-queue", "parity-scale-codec", "scale-info", "serde", @@ -17409,6 +17790,7 @@ dependencies = [ "sp-arithmetic", "sp-core", "sp-io", + "sp-keyring", "sp-runtime", "sp-std 8.0.0", "staging-xcm", @@ -17422,12 +17804,19 @@ dependencies = [ "frame-benchmarking", "frame-support", "frame-system", + "hex", + "hex-literal", "log", + "pallet-balances", + "pallet-message-queue", "parity-scale-codec", + "polkadot-primitives", "scale-info", "snowbridge-core", + "snowbridge-pallet-outbound-queue", "sp-core", "sp-io", + "sp-keyring", "sp-runtime", "sp-std 8.0.0", "staging-xcm", @@ -17445,6 +17834,7 @@ dependencies = [ "hex-literal", "log", "parity-scale-codec", + "rustc-hex", "scale-info", "serde", "snowbridge-core", @@ -17464,10 +17854,8 @@ dependencies = [ "frame-support", "frame-system", "log", - "parity-scale-codec", "snowbridge-core", "sp-arithmetic", - "sp-std 8.0.0", "staging-xcm", "staging-xcm-builder", "staging-xcm-executor", @@ -17478,6 +17866,8 @@ name = "snowbridge-runtime-test-common" version = "0.9.0" dependencies = [ "assets-common", + "bridge-hub-test-utils", + "bridge-runtime-common", "cumulus-pallet-aura-ext", "cumulus-pallet-dmp-queue", "cumulus-pallet-parachain-system", @@ -17533,6 +17923,7 @@ dependencies = [ "sp-genesis-builder", "sp-inherents", "sp-io", + "sp-keyring", "sp-offchain", "sp-runtime", "sp-session", @@ -17544,6 +17935,7 @@ dependencies = [ "staging-xcm", "staging-xcm-builder", "staging-xcm-executor", + "static_assertions", ] [[package]] @@ -17591,7 +17983,7 @@ dependencies = [ "http", "httparse", "log", - "rand 0.8.5", + "rand", "sha-1 0.9.8", ] @@ -17624,10 +18016,10 @@ dependencies = [ "assert_matches", "blake2 0.10.6", "expander 2.0.0", - "proc-macro-crate 2.0.1", + "proc-macro-crate 3.0.0", "proc-macro2", "quote", - "syn 2.0.41", + "syn 2.0.48", ] [[package]] @@ -17685,10 +18077,10 @@ dependencies = [ "num-traits", "parity-scale-codec", "primitive-types", - "rand 0.8.5", + "rand", "scale-info", "serde", - "sp-core", + "sp-crypto-hashing", "sp-std 8.0.0", "static_assertions", ] @@ -17822,11 +18214,12 @@ dependencies = [ "sp-api", "sp-application-crypto", "sp-core", + "sp-crypto-hashing", "sp-io", "sp-mmr-primitives", "sp-runtime", "sp-std 8.0.0", - "strum", + "strum 0.24.1", "w3f-bls", ] @@ -17911,7 +18304,7 @@ dependencies = [ "parking_lot 0.12.1", "paste", "primitive-types", - "rand 0.8.5", + "rand", "regex", "scale-info", "schnorrkel 0.11.4", @@ -17919,8 +18312,7 @@ dependencies = [ "secrecy", "serde", "serde_json", - "sp-core-hashing", - "sp-core-hashing-proc-macro", + "sp-crypto-hashing", "sp-debug-derive 8.0.0", "sp-externalities 0.19.0", "sp-runtime-interface 17.0.0", @@ -17946,23 +18338,16 @@ dependencies = [ [[package]] name = "sp-core-hashing" -version = "9.0.0" +version = "15.0.0" dependencies = [ - "blake2b_simd", - "byteorder", - "digest 0.10.7", - "sha2 0.10.7", - "sha3", - "twox-hash", + "sp-crypto-hashing", ] [[package]] name = "sp-core-hashing-proc-macro" -version = "9.0.0" +version = "15.0.0" dependencies = [ - "quote", - "sp-core-hashing", - "syn 2.0.41", + "sp-crypto-hashing-proc-macro", ] [[package]] @@ -18006,6 +18391,29 @@ dependencies = [ "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk)", ] +[[package]] +name = "sp-crypto-hashing" +version = "0.1.0" +dependencies = [ + "blake2b_simd", + "byteorder", + "criterion 0.4.0", + "digest 0.10.7", + "sha2 0.10.7", + "sha3", + "sp-crypto-hashing-proc-macro", + "twox-hash", +] + +[[package]] +name = "sp-crypto-hashing-proc-macro" +version = "0.1.0" +dependencies = [ + "quote", + "sp-crypto-hashing", + "syn 2.0.48", +] + [[package]] name = "sp-database" version = "4.0.0-dev" @@ -18020,7 +18428,7 @@ version = "8.0.0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.41", + "syn 2.0.48", ] [[package]] @@ -18030,7 +18438,7 @@ source = "git+https://github.com/paritytech/polkadot-sdk#82912acb33a9030c0ef3bf5 dependencies = [ "proc-macro2", "quote", - "syn 2.0.41", + "syn 2.0.48", ] [[package]] @@ -18090,6 +18498,7 @@ dependencies = [ "rustversion", "secp256k1", "sp-core", + "sp-crypto-hashing", "sp-externalities 0.19.0", "sp-keystore", "sp-runtime-interface 17.0.0", @@ -18107,7 +18516,7 @@ version = "24.0.0" dependencies = [ "sp-core", "sp-runtime", - "strum", + "strum 0.24.1", ] [[package]] @@ -18116,7 +18525,7 @@ version = "0.27.0" dependencies = [ "parity-scale-codec", "parking_lot 0.12.1", - "rand 0.8.5", + "rand", "rand_chacha 0.2.2", "sp-core", "sp-externalities 0.19.0", @@ -18175,7 +18584,7 @@ name = "sp-npos-elections" version = "4.0.0-dev" dependencies = [ "parity-scale-codec", - "rand 0.8.5", + "rand", "scale-info", "serde", "sp-arithmetic", @@ -18189,9 +18598,9 @@ dependencies = [ name = "sp-npos-elections-fuzzer" version = "2.0.0-alpha.5" dependencies = [ - "clap 4.4.11", + "clap 4.4.18", "honggfuzz", - "rand 0.8.5", + "rand", "sp-npos-elections", "sp-runtime", ] @@ -18235,7 +18644,7 @@ dependencies = [ "log", "parity-scale-codec", "paste", - "rand 0.8.5", + "rand", "scale-info", "serde", "serde_json", @@ -18300,10 +18709,10 @@ version = "11.0.0" dependencies = [ "Inflector", "expander 2.0.0", - "proc-macro-crate 2.0.1", + "proc-macro-crate 3.0.0", "proc-macro2", "quote", - "syn 2.0.41", + "syn 2.0.48", ] [[package]] @@ -18315,7 +18724,7 @@ dependencies = [ "proc-macro-crate 1.3.1", "proc-macro2", "quote", - "syn 2.0.41", + "syn 2.0.48", ] [[package]] @@ -18394,7 +18803,7 @@ dependencies = [ "parity-scale-codec", "parking_lot 0.12.1", "pretty_assertions", - "rand 0.8.5", + "rand", "smallvec", "sp-core", "sp-externalities 0.19.0", @@ -18416,12 +18825,13 @@ dependencies = [ "ed25519-dalek", "hkdf", "parity-scale-codec", - "rand 0.8.5", + "rand", "scale-info", "sha2 0.10.7", "sp-api", "sp-application-crypto", "sp-core", + "sp-crypto-hashing", "sp-externalities 0.19.0", "sp-runtime", "sp-runtime-interface 17.0.0", @@ -18497,7 +18907,7 @@ dependencies = [ "sp-std 8.0.0", "tracing", "tracing-core", - "tracing-subscriber", + "tracing-subscriber 0.2.25", ] [[package]] @@ -18509,7 +18919,7 @@ dependencies = [ "sp-std 8.0.0 (git+https://github.com/paritytech/polkadot-sdk)", "tracing", "tracing-core", - "tracing-subscriber", + "tracing-subscriber 0.2.25", ] [[package]] @@ -18538,7 +18948,7 @@ dependencies = [ name = "sp-trie" version = "22.0.0" dependencies = [ - "ahash 0.8.3", + "ahash 0.8.7", "array-bytes 6.1.0", "criterion 0.4.0", "hash-db", @@ -18547,7 +18957,7 @@ dependencies = [ "nohash-hasher", "parity-scale-codec", "parking_lot 0.12.1", - "rand 0.8.5", + "rand", "scale-info", "schnellru", "sp-core", @@ -18571,7 +18981,7 @@ dependencies = [ "parity-wasm", "scale-info", "serde", - "sp-core-hashing-proc-macro", + "sp-crypto-hashing-proc-macro", "sp-runtime", "sp-std 8.0.0", "sp-version-proc-macro", @@ -18586,7 +18996,7 @@ dependencies = [ "proc-macro2", "quote", "sp-version", - "syn 2.0.41", + "syn 2.0.48", ] [[package]] @@ -18649,7 +19059,7 @@ checksum = "08615eea740067d9899969bc2891c68a19c315cb1f66640af9a9ecb91b13bcab" dependencies = [ "lazy_static", "maplit", - "strum", + "strum 0.24.1", ] [[package]] @@ -18710,7 +19120,7 @@ checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" name = "staging-chain-spec-builder" version = "2.0.0" dependencies = [ - "clap 4.4.11", + "clap 4.4.18", "log", "sc-chain-spec", "serde_json", @@ -18723,7 +19133,7 @@ version = "3.0.0-dev" dependencies = [ "array-bytes 6.1.0", "assert_cmd", - "clap 4.4.11", + "clap 4.4.18", "clap_complete", "criterion 0.4.0", "frame-benchmarking", @@ -18735,6 +19145,7 @@ dependencies = [ "jsonrpsee", "kitchensink-runtime", "log", + "mmr-gadget", "nix 0.26.2", "node-primitives", "node-rpc", @@ -18754,7 +19165,7 @@ dependencies = [ "pallet-treasury", "parity-scale-codec", "platforms", - "rand 0.8.5", + "rand", "regex", "sc-authority-discovery", "sc-basic-authorship", @@ -18765,6 +19176,7 @@ dependencies = [ "sc-client-db", "sc-consensus", "sc-consensus-babe", + "sc-consensus-beefy", "sc-consensus-epochs", "sc-consensus-grandpa", "sc-consensus-slots", @@ -18796,14 +19208,17 @@ dependencies = [ "sp-blockchain", "sp-consensus", "sp-consensus-babe", + "sp-consensus-beefy", "sp-consensus-grandpa", "sp-core", + "sp-crypto-hashing", "sp-externalities 0.19.0", "sp-inherents", "sp-io", "sp-keyring", "sp-keystore", "sp-mixnet", + "sp-mmr-primitives", "sp-runtime", "sp-state-machine", "sp-statement-store", @@ -18828,7 +19243,7 @@ dependencies = [ name = "staging-node-inspect" version = "0.9.0-dev" dependencies = [ - "clap 4.4.11", + "clap 4.4.18", "parity-scale-codec", "sc-cli", "sc-client-api", @@ -18862,6 +19277,7 @@ version = "1.0.0" name = "staging-xcm" version = "1.0.0" dependencies = [ + "array-bytes 6.1.0", "bounded-collections", "derivative", "environmental", @@ -19012,9 +19428,15 @@ version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "063e6045c0e62079840579a7e47a355ae92f60eb74daaf156fb1e84ba164e63f" dependencies = [ - "strum_macros", + "strum_macros 0.24.3", ] +[[package]] +name = "strum" +version = "0.25.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "290d54ea6f91c969195bdbcd7442c8c2a2ba87da8bf60a7ee86a235d4bc1e125" + [[package]] name = "strum_macros" version = "0.24.3" @@ -19028,19 +19450,32 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "strum_macros" +version = "0.25.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23dc1fa9ac9c169a78ba62f0b841814b7abae11bdd047b9c58f893439e309ea0" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "rustversion", + "syn 2.0.48", +] + [[package]] name = "subkey" version = "3.0.0" dependencies = [ - "clap 4.4.11", + "clap 4.4.18", "sc-cli", ] [[package]] name = "substrate-bip39" -version = "0.4.4" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49eee6965196b32f882dd2ee85a92b1dbead41b04e53907f269de3b0dc04733c" +checksum = "e620c7098893ba667438b47169c00aacdd9e7c10e042250ce2b60b087ec97328" dependencies = [ "hmac 0.11.0", "pbkdf2 0.8.0", @@ -19074,7 +19509,7 @@ dependencies = [ name = "substrate-frame-cli" version = "4.0.0-dev" dependencies = [ - "clap 4.4.11", + "clap 4.4.18", "frame-support", "frame-system", "sc-cli", @@ -19187,6 +19622,7 @@ dependencies = [ "sp-keystore", "sp-runtime", "sp-state-machine", + "tokio", ] [[package]] @@ -19220,6 +19656,7 @@ dependencies = [ "sp-consensus-babe", "sp-consensus-grandpa", "sp-core", + "sp-crypto-hashing", "sp-externalities 0.19.0", "sp-genesis-builder", "sp-inherents", @@ -19285,15 +19722,15 @@ dependencies = [ name = "substrate-wasm-builder" version = "5.0.0-dev" dependencies = [ - "ansi_term", "build-helper", "cargo_metadata", + "console", "filetime", "parity-wasm", "sp-maybe-compressed-blob", - "strum", + "strum 0.24.1", "tempfile", - "toml 0.8.2", + "toml 0.8.8", "walkdir", "wasm-opt", ] @@ -19391,7 +19828,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "167a4ffd7c35c143fd1030aa3c2caf76ba42220bd5a6b5f4781896434723b8c3" dependencies = [ "debugid", - "memmap2", + "memmap2 0.5.10", "stable_deref_trait", "uuid", ] @@ -19420,9 +19857,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.41" +version = "2.0.48" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44c8b28c477cc3bf0e7966561e3460130e1255f7a1cf71931075f1c5e7a7e269" +checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f" dependencies = [ "proc-macro2", "quote", @@ -19438,7 +19875,7 @@ dependencies = [ "paste", "proc-macro2", "quote", - "syn 2.0.41", + "syn 2.0.48", ] [[package]] @@ -19552,7 +19989,7 @@ dependencies = [ name = "test-parachain-adder-collator" version = "1.0.0" dependencies = [ - "clap 4.4.11", + "clap 4.4.18", "futures", "futures-timer", "log", @@ -19600,7 +20037,7 @@ dependencies = [ name = "test-parachain-undying-collator" version = "1.0.0" dependencies = [ - "clap 4.4.11", + "clap 4.4.18", "futures", "futures-timer", "log", @@ -19689,7 +20126,7 @@ checksum = "266b2e40bc00e5a6c09c3584011e08b06f123c00362c92b975ba9843aaaa14b8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.41", + "syn 2.0.48", ] [[package]] @@ -19850,7 +20287,7 @@ checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.41", + "syn 2.0.48", ] [[package]] @@ -19860,7 +20297,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f57eb36ecbe0fc510036adff84824dd3c24bb781e21bfa67b69d556aa85214f" dependencies = [ "pin-project", - "rand 0.8.5", + "rand", "tokio", ] @@ -19949,21 +20386,21 @@ dependencies = [ [[package]] name = "toml" -version = "0.8.2" +version = "0.8.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "185d8ab0dfbb35cf1399a6344d8484209c088f75f8f68230da55d48d95d43e3d" +checksum = "a1a195ec8c9da26928f773888e0742ca3ca1040c6cd859c919c9f59c1954ab35" dependencies = [ "serde", "serde_spanned", "toml_datetime", - "toml_edit 0.20.2", + "toml_edit 0.21.0", ] [[package]] name = "toml_datetime" -version = "0.6.3" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" +checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1" dependencies = [ "serde", ] @@ -19983,9 +20420,9 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.20.2" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "396e4d48bbb2b7554c944bde63101b5ae446cff6ec4a24227428f15eb72ef338" +checksum = "d34d383cd00a163b4a5b85053df514d45bc330f6de7737edfe0a93311d1eaa03" dependencies = [ "indexmap 2.0.0", "serde", @@ -20000,6 +20437,10 @@ version = "0.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c" dependencies = [ + "futures-core", + "futures-util", + "pin-project", + "pin-project-lite 0.2.12", "tower-layer", "tower-service", "tracing", @@ -20056,7 +20497,7 @@ checksum = "5f4f31f56159e98206da9efd823404b79b6ef3143b4a7ab76e67b1751b25a4ab" dependencies = [ "proc-macro2", "quote", - "syn 2.0.41", + "syn 2.0.48", ] [[package]] @@ -20095,10 +20536,10 @@ version = "1.0.0" dependencies = [ "assert_matches", "expander 2.0.0", - "proc-macro-crate 2.0.1", + "proc-macro-crate 3.0.0", "proc-macro2", "quote", - "syn 2.0.41", + "syn 2.0.48", ] [[package]] @@ -20112,6 +20553,17 @@ dependencies = [ "tracing-core", ] +[[package]] +name = "tracing-log" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee855f1f400bd0e5c02d150ae5de3840039a3f54b025156404e34c23c03f47c3" +dependencies = [ + "log", + "once_cell", + "tracing-core", +] + [[package]] name = "tracing-serde" version = "0.1.3" @@ -20131,7 +20583,7 @@ dependencies = [ "ansi_term", "chrono", "lazy_static", - "matchers", + "matchers 0.0.1", "parking_lot 0.11.2", "regex", "serde", @@ -20141,10 +20593,28 @@ dependencies = [ "thread_local", "tracing", "tracing-core", - "tracing-log", + "tracing-log 0.1.3", "tracing-serde", ] +[[package]] +name = "tracing-subscriber" +version = "0.3.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad0f048c97dbd9faa9b7df56362b8ebcaa52adb06b498c050d2f4e32f90a7a8b" +dependencies = [ + "matchers 0.1.0", + "nu-ansi-term", + "once_cell", + "regex", + "sharded-slab", + "smallvec", + "thread_local", + "tracing", + "tracing-core", + "tracing-log 0.2.0", +] + [[package]] name = "trie-bench" version = "0.38.0" @@ -20209,7 +20679,7 @@ dependencies = [ "idna 0.2.3", "ipnet", "lazy_static", - "rand 0.8.5", + "rand", "smallvec", "socket2 0.4.9", "thiserror", @@ -20251,7 +20721,7 @@ version = "0.10.0-dev" dependencies = [ "assert_cmd", "async-trait", - "clap 4.4.11", + "clap 4.4.18", "frame-remote-externalities", "frame-try-runtime", "hex", @@ -20288,9 +20758,9 @@ dependencies = [ [[package]] name = "trybuild" -version = "1.0.83" +version = "1.0.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6df60d81823ed9c520ee897489573da4b1d79ffbe006b8134f46de1a1aa03555" +checksum = "76de4f783e610194f6c98bfd53f9fc52bb2e0d02c947621e8a0f4ecc799b2880" dependencies = [ "basic-toml", "dissimilar", @@ -20320,7 +20790,7 @@ dependencies = [ "http", "httparse", "log", - "rand 0.8.5", + "rand", "sha-1 0.10.1", "thiserror", "url", @@ -20335,7 +20805,7 @@ checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675" dependencies = [ "cfg-if", "digest 0.10.7", - "rand 0.8.5", + "rand", "static_assertions", ] @@ -20424,9 +20894,9 @@ dependencies = [ [[package]] name = "unsafe-libyaml" -version = "0.2.9" +version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f28467d3e1d3c6586d8f25fa243f544f5800fec42d97032474e17222c2b75cfa" +checksum = "ab4c90930b95a82d00dc9e9ac071b4991924390d46cbd0dfe566148667605e4b" [[package]] name = "unsigned-varint" @@ -20446,6 +20916,12 @@ version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" +[[package]] +name = "untrusted" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" + [[package]] name = "url" version = "2.4.0" @@ -20550,7 +21026,7 @@ dependencies = [ "arrayref", "constcat", "digest 0.10.7", - "rand 0.8.5", + "rand", "rand_chacha 0.3.1", "rand_core 0.6.4", "sha2 0.10.7", @@ -20576,9 +21052,9 @@ checksum = "9d5b2c62b4012a3e1eca5a7e077d13b3bf498c4073e33ccd58626607748ceeca" [[package]] name = "walkdir" -version = "2.3.3" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36df944cda56c7d8d8b7496af378e6b16de9284591917d307c9b4d313c44e698" +checksum = "d71d857dc86794ca4c280d616f7da00d2dbfd8cd788846559a6813e6aa4b54ee" dependencies = [ "same-file", "winapi-util", @@ -20628,7 +21104,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.41", + "syn 2.0.48", "wasm-bindgen-shared", ] @@ -20662,7 +21138,7 @@ checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.41", + "syn 2.0.48", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -20674,21 +21150,36 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ca6ad05a4870b2bf5fe995117d3728437bd27d7cd5f06f13c17443ef369775a1" [[package]] -name = "wasm-encoder" -version = "0.31.1" +name = "wasm-bindgen-test" +version = "0.3.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41763f20eafed1399fff1afb466496d3a959f58241436cfdc17e3f5ca954de16" +checksum = "6e6e302a7ea94f83a6d09e78e7dc7d9ca7b186bc2829c24a22d0753efd680671" dependencies = [ - "leb128", + "console_error_panic_hook", + "js-sys", + "scoped-tls", + "wasm-bindgen", + "wasm-bindgen-futures", + "wasm-bindgen-test-macro", ] [[package]] -name = "wasm-instrument" -version = "0.3.0" +name = "wasm-bindgen-test-macro" +version = "0.3.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa1dafb3e60065305741e83db35c6c2584bb3725b692b5b66148a38d72ace6cd" +checksum = "ecb993dd8c836930ed130e020e77d9b2e65dd0fbab1b67c790b0f5d80b11a575" dependencies = [ - "parity-wasm", + "proc-macro2", + "quote", +] + +[[package]] +name = "wasm-encoder" +version = "0.31.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41763f20eafed1399fff1afb466496d3a959f58241436cfdc17e3f5ca954de16" +dependencies = [ + "leb128", ] [[package]] @@ -20708,8 +21199,8 @@ checksum = "fc942673e7684671f0c5708fc18993569d184265fd5223bb51fc8e5b9b6cfd52" dependencies = [ "anyhow", "libc", - "strum", - "strum_macros", + "strum 0.24.1", + "strum_macros 0.24.3", "tempfile", "thiserror", "wasm-opt-cxx-sys", @@ -20980,7 +21471,7 @@ dependencies = [ "memfd", "memoffset 0.8.0", "paste", - "rand 0.8.5", + "rand", "rustix 0.36.15", "wasmtime-asm-macros", "wasmtime-environ", @@ -21033,12 +21524,12 @@ dependencies = [ [[package]] name = "webpki" -version = "0.22.0" +version = "0.22.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f095d78192e208183081cc07bc5515ef55216397af48b873e5edcd72637fa1bd" +checksum = "ed63aea5ce73d0ff405984102c42de94fc55a6b75765d621c65262469b3c9b53" dependencies = [ - "ring 0.16.20", - "untrusted", + "ring 0.17.7", + "untrusted 0.9.0", ] [[package]] @@ -21050,15 +21541,6 @@ dependencies = [ "webpki", ] -[[package]] -name = "webpki-roots" -version = "0.23.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b03058f88386e5ff5310d9111d53f48b17d732b401aeb83a8d5190f2ac459338" -dependencies = [ - "rustls-webpki 0.100.2", -] - [[package]] name = "webpki-roots" version = "0.25.2" @@ -21220,6 +21702,7 @@ dependencies = [ "collectives-westend-emulated-chain", "emulated-integration-tests-common", "penpal-emulated-chain", + "people-westend-emulated-chain", "westend-emulated-chain", ] @@ -21321,6 +21804,15 @@ dependencies = [ "windows-targets 0.48.5", ] +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets 0.52.0", +] + [[package]] name = "windows-targets" version = "0.42.2" @@ -21351,6 +21843,21 @@ dependencies = [ "windows_x86_64_msvc 0.48.5", ] +[[package]] +name = "windows-targets" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd" +dependencies = [ + "windows_aarch64_gnullvm 0.52.0", + "windows_aarch64_msvc 0.52.0", + "windows_i686_gnu 0.52.0", + "windows_i686_msvc 0.52.0", + "windows_x86_64_gnu 0.52.0", + "windows_x86_64_gnullvm 0.52.0", + "windows_x86_64_msvc 0.52.0", +] + [[package]] name = "windows_aarch64_gnullvm" version = "0.42.2" @@ -21363,6 +21870,12 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea" + [[package]] name = "windows_aarch64_msvc" version = "0.34.0" @@ -21381,6 +21894,12 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef" + [[package]] name = "windows_i686_gnu" version = "0.34.0" @@ -21399,6 +21918,12 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" +[[package]] +name = "windows_i686_gnu" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313" + [[package]] name = "windows_i686_msvc" version = "0.34.0" @@ -21417,6 +21942,12 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" +[[package]] +name = "windows_i686_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a" + [[package]] name = "windows_x86_64_gnu" version = "0.34.0" @@ -21435,6 +21966,12 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd" + [[package]] name = "windows_x86_64_gnullvm" version = "0.42.2" @@ -21447,6 +21984,12 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e" + [[package]] name = "windows_x86_64_msvc" version = "0.34.0" @@ -21465,6 +22008,12 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" + [[package]] name = "winnow" version = "0.5.15" @@ -21567,6 +22116,7 @@ dependencies = [ "polkadot-runtime-parachains", "sp-arithmetic", "sp-core", + "sp-crypto-hashing", "sp-io", "sp-runtime", "sp-std 8.0.0", @@ -21605,7 +22155,7 @@ dependencies = [ "proc-macro2", "quote", "staging-xcm", - "syn 2.0.41", + "syn 2.0.48", "trybuild", ] @@ -21689,7 +22239,7 @@ dependencies = [ "log", "nohash-hasher", "parking_lot 0.12.1", - "rand 0.8.5", + "rand", "static_assertions", ] @@ -21708,6 +22258,26 @@ dependencies = [ "time", ] +[[package]] +name = "zerocopy" +version = "0.7.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74d4d3961e53fa4c9a25a8637fc2bfaf2595b3d3ae34875568a5cf64787716be" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.7.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.48", +] + [[package]] name = "zeroize" version = "1.6.0" @@ -21725,7 +22295,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.41", + "syn 2.0.48", ] [[package]] diff --git a/cumulus/client/relay-chain-interface/Cargo.toml b/cumulus/client/relay-chain-interface/Cargo.toml index 5100119a2e49..c003f52a9180 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.16.2" +jsonrpsee-core = "0.20.3" parity-scale-codec = "3.6.4" diff --git a/cumulus/client/relay-chain-rpc-interface/Cargo.toml b/cumulus/client/relay-chain-rpc-interface/Cargo.toml index 515c8ead32aa..e27dd4376ec0 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.16.2", features = ["ws-client"] } +jsonrpsee = { version = "0.20.3", 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 c12ee72f5cb3..c66c96056b95 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.16.2", features = ["server"] } +jsonrpsee = { version = "0.20.3", features = ["server"] } futures = "0.3.28" serde_json = "1.0.111" diff --git a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/xcm_config.rs b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/xcm_config.rs index 9e1affb533a3..91a3337804c9 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/xcm_config.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/xcm_config.rs @@ -236,20 +236,14 @@ impl MatchesLocalAndForeignAssetsLocation { fn is_local(location: &xcm::v3::Location) -> bool { use assets_common::fungible_conversion::MatchesLocation; - let latest_location: Location = if let Ok(location) = (*location).try_into() { - location - } else { - return false; - }; + let latest_location: Location = + if let Ok(location) = (*location).try_into() { location } else { return false }; TrustBackedAssetsConvertedConcreteId::contains(&latest_location) } fn is_foreign(location: &xcm::v3::Location) -> bool { use assets_common::fungible_conversion::MatchesLocation; - let latest_location: Location = if let Ok(location) = (*location).try_into() { - location - } else { - return false; - }; + let latest_location: Location = + if let Ok(location) = (*location).try_into() { location } else { return false }; ForeignAssetsConvertedConcreteId::contains(&latest_location) } } diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs index 0f4ce360ee48..df9baa11554a 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs @@ -231,21 +231,15 @@ impl MatchesLocalAndForeignAssetsLocation { fn is_local(location: &xcm::v3::Location) -> bool { use assets_common::fungible_conversion::MatchesLocation; - let latest_location: Location = if let Ok(location) = (*location).try_into() { - location - } else { - return false; - }; + let latest_location: Location = + if let Ok(location) = (*location).try_into() { location } else { return false }; TrustBackedAssetsConvertedConcreteId::contains(&latest_location) } fn is_foreign(location: &xcm::v3::Location) -> bool { use assets_common::fungible_conversion::MatchesLocation; - let latest_location: Location = if let Ok(location) = (*location).try_into() { - location - } else { - return false; - }; + let latest_location: Location = + if let Ok(location) = (*location).try_into() { location } else { return false }; ForeignAssetsConvertedConcreteId::contains(&latest_location) } } diff --git a/cumulus/polkadot-parachain/Cargo.toml b/cumulus/polkadot-parachain/Cargo.toml index 0a40816fc0b9..5d5aa5ec8127 100644 --- a/cumulus/polkadot-parachain/Cargo.toml +++ b/cumulus/polkadot-parachain/Cargo.toml @@ -38,9 +38,9 @@ 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"] } people-rococo-runtime = { path = "../parachains/runtimes/people/people-rococo" } people-westend-runtime = { path = "../parachains/runtimes/people/people-westend" } -jsonrpsee = { version = "0.16.2", features = ["server"] } parachains-common = { path = "../parachains/common" } # Substrate diff --git a/cumulus/test/service/Cargo.toml b/cumulus/test/service/Cargo.toml index dcd70ca97e8b..c17cdf35419a 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.16.2", features = ["server"] } +jsonrpsee = { version = "0.20.3", features = ["server"] } rand = "0.8.5" serde = { version = "1.0.195", features = ["derive"] } serde_json = "1.0.111" diff --git a/cumulus/test/service/src/lib.rs b/cumulus/test/service/src/lib.rs index 37ea984ac87a..2bd6fa43f76c 100644 --- a/cumulus/test/service/src/lib.rs +++ b/cumulus/test/service/src/lib.rs @@ -799,6 +799,7 @@ pub fn node_config( rpc_id_provider: None, rpc_max_subs_per_conn: Default::default(), rpc_port: 9945, + rpc_message_buffer_capacity: Default::default(), prometheus_config: None, telemetry_endpoints: None, default_heap_pages: None, diff --git a/docs/sdk/src/guides/your_first_pallet/mod.rs b/docs/sdk/src/guides/your_first_pallet/mod.rs index ea23af51ec9d..29cdda36ed15 100644 --- a/docs/sdk/src/guides/your_first_pallet/mod.rs +++ b/docs/sdk/src/guides/your_first_pallet/mod.rs @@ -365,7 +365,7 @@ pub mod pallet { // ensure sender has enough balance, and if so, calculate what is left after `amount`. let sender_balance = Balances::::get(&sender).ok_or("NonExistentAccount")?; if sender_balance < amount { - return Err("InsufficientBalance".into()); + return Err("InsufficientBalance".into()) } let reminder = sender_balance - amount; diff --git a/polkadot/node/test/service/src/lib.rs b/polkadot/node/test/service/src/lib.rs index e9423d513bf0..3ef969566b2d 100644 --- a/polkadot/node/test/service/src/lib.rs +++ b/polkadot/node/test/service/src/lib.rs @@ -182,6 +182,7 @@ pub fn node_config( rpc_id_provider: None, rpc_max_subs_per_conn: Default::default(), rpc_port: 9944, + rpc_message_buffer_capacity: Default::default(), prometheus_config: None, telemetry_endpoints: None, default_heap_pages: None, diff --git a/polkadot/rpc/Cargo.toml b/polkadot/rpc/Cargo.toml index dcb7a13f6f31..84594b14b645 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.16.2", features = ["server"] } +jsonrpsee = { version = "0.20.3", features = ["server"] } polkadot-primitives = { path = "../primitives" } sc-client-api = { path = "../../substrate/client/api" } sp-blockchain = { path = "../../substrate/primitives/blockchain" } diff --git a/polkadot/xcm/procedural/src/v2.rs b/polkadot/xcm/procedural/src/v2.rs index 1a2f281a4982..6878f7755cc7 100644 --- a/polkadot/xcm/procedural/src/v2.rs +++ b/polkadot/xcm/procedural/src/v2.rs @@ -189,7 +189,7 @@ pub mod junctions { pub fn generate_conversion_functions(input: proc_macro::TokenStream) -> Result { if !input.is_empty() { - return Err(syn::Error::new(Span::call_site(), "No arguments expected")); + return Err(syn::Error::new(Span::call_site(), "No arguments expected")) } let from_slice_syntax = generate_conversion_from_slice_syntax(); diff --git a/polkadot/xcm/xcm-builder/src/matches_location.rs b/polkadot/xcm/xcm-builder/src/matches_location.rs index a96df9e92de3..1664c2477290 100644 --- a/polkadot/xcm/xcm-builder/src/matches_location.rs +++ b/polkadot/xcm/xcm-builder/src/matches_location.rs @@ -25,16 +25,9 @@ use xcm::latest::{InteriorLocation, Location, NetworkId}; pub struct StartsWith(sp_std::marker::PhantomData<(T, L)>); impl, L: TryInto + Clone> Contains for StartsWith { fn contains(location: &L) -> bool { - let latest_location: Location = if let Ok(location) = (*location).clone().try_into() { - location - } else { - return false; - }; - let latest_t = if let Ok(location) = T::get().try_into() { - location - } else { - return false; - }; + let latest_location: Location = + if let Ok(location) = (*location).clone().try_into() { location } else { return false }; + let latest_t = if let Ok(location) = T::get().try_into() { location } else { return false }; latest_location.starts_with(&latest_t) } } diff --git a/polkadot/xcm/xcm-executor/src/traits/asset_transfer.rs b/polkadot/xcm/xcm-executor/src/traits/asset_transfer.rs index 1fca84f36e22..5da3d1da37c8 100644 --- a/polkadot/xcm/xcm-executor/src/traits/asset_transfer.rs +++ b/polkadot/xcm/xcm-executor/src/traits/asset_transfer.rs @@ -85,3 +85,12 @@ pub trait XcmAssetTransfers { } } } + +impl XcmAssetTransfers for () { + type IsReserve = (); + type IsTeleporter = (); + type AssetTransactor = (); + fn determine_for(_: &Asset, _: &Location) -> Result { + return Err(Error::UnknownReserve); + } +} diff --git a/prdoc/pr_1313.prdoc b/prdoc/pr_1313.prdoc new file mode 100644 index 000000000000..0ee91da41a9a --- /dev/null +++ b/prdoc/pr_1313.prdoc @@ -0,0 +1,18 @@ +# 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: backpressured JSON-RPC server (upgrade jsonrpsee) + +doc: + - audience: Node Operator + description: | + Modifies the jsonrpc server to be "backpressured" and it's possible to configure + how many messages can be "buffered" via the CLI `--rpc_message_buffer_capacity`. + + Major changes in this PR: + - The subscriptions are now bounded and if subscription can't keep up with the server it is dropped + - CLI: add parameter to configure the jsonrpc server bounded message buffer (default is 64) + - Add our own subscription helper to deal with the unbounded streams in substrate + +crates: +- name: sc-rpc-server diff --git a/substrate/bin/minimal/node/Cargo.toml b/substrate/bin/minimal/node/Cargo.toml index cc00988dcfef..6be5b6d80ca1 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.16.2", features = ["server"] } +jsonrpsee = { version = "0.20.3", 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 36c2f9f8b706..da601a665e9c 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.16.2", features = ["server"] } +jsonrpsee = { version = "0.20.3", 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 6803d2def43b..5dfe915b789d 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.16.2", features = ["server"] } +jsonrpsee = { version = "0.20.3", features = ["server"] } futures = "0.3.21" log = "0.4.17" rand = "0.8" diff --git a/substrate/bin/node/cli/benches/block_production.rs b/substrate/bin/node/cli/benches/block_production.rs index f59a125e1c05..c17c12dfef13 100644 --- a/substrate/bin/node/cli/benches/block_production.rs +++ b/substrate/bin/node/cli/benches/block_production.rs @@ -83,6 +83,7 @@ fn new_node(tokio_handle: Handle) -> node_cli::service::NewFullBase { rpc_id_provider: Default::default(), rpc_max_subs_per_conn: Default::default(), rpc_port: 9944, + rpc_message_buffer_capacity: Default::default(), prometheus_config: None, telemetry_endpoints: None, default_heap_pages: None, diff --git a/substrate/bin/node/cli/benches/transaction_pool.rs b/substrate/bin/node/cli/benches/transaction_pool.rs index 1cf71f8872f3..0d0d3a072d89 100644 --- a/substrate/bin/node/cli/benches/transaction_pool.rs +++ b/substrate/bin/node/cli/benches/transaction_pool.rs @@ -79,6 +79,7 @@ fn new_node(tokio_handle: Handle) -> node_cli::service::NewFullBase { rpc_id_provider: Default::default(), rpc_max_subs_per_conn: Default::default(), rpc_port: 9944, + rpc_message_buffer_capacity: Default::default(), prometheus_config: None, telemetry_endpoints: None, default_heap_pages: None, diff --git a/substrate/bin/node/rpc/Cargo.toml b/substrate/bin/node/rpc/Cargo.toml index 66bd6e9a0a53..63a30965a160 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.16.2", features = ["server"] } +jsonrpsee = { version = "0.20.3", 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/cli/src/commands/run_cmd.rs b/substrate/client/cli/src/commands/run_cmd.rs index 4ac10a03cd44..f7b0fc510491 100644 --- a/substrate/client/cli/src/commands/run_cmd.rs +++ b/substrate/client/cli/src/commands/run_cmd.rs @@ -25,7 +25,7 @@ use crate::{ }, CliConfiguration, PrometheusParams, RuntimeParams, TelemetryParams, RPC_DEFAULT_MAX_CONNECTIONS, RPC_DEFAULT_MAX_REQUEST_SIZE_MB, RPC_DEFAULT_MAX_RESPONSE_SIZE_MB, - RPC_DEFAULT_MAX_SUBS_PER_CONN, + RPC_DEFAULT_MAX_SUBS_PER_CONN, RPC_DEFAULT_MESSAGE_CAPACITY_PER_CONN, }; use clap::Parser; use regex::Regex; @@ -102,9 +102,20 @@ pub struct RunCmd { #[arg(long, value_name = "COUNT", default_value_t = RPC_DEFAULT_MAX_CONNECTIONS)] pub rpc_max_connections: u32, - /// Specify browser *origins* allowed to access the HTTP and WS RPC servers. + /// The number of messages the RPC server is allowed to keep in memory. /// - /// A comma-separated list of origins (`protocol://domain` or special `null` + /// If the buffer becomes full then the server will not process + /// new messages until the connected client start reading the + /// underlying messages. + /// + /// This applies per connection which includes both + /// JSON-RPC methods calls and subscriptions. + #[arg(long, default_value_t = RPC_DEFAULT_MESSAGE_CAPACITY_PER_CONN)] + pub rpc_message_buffer_capacity_per_connection: u32, + + /// Specify browser *origins* allowed to access the HTTP & WS RPC servers. + /// + /// A comma-separated list of origins (protocol://domain or special `null` /// value). Value of `all` will disable origin validation. Default is to /// allow localhost and origins. When running in /// `--dev` mode the default is to allow all origins. diff --git a/substrate/client/cli/src/config.rs b/substrate/client/cli/src/config.rs index 170173c8c28b..defcc4a8a690 100644 --- a/substrate/client/cli/src/config.rs +++ b/substrate/client/cli/src/config.rs @@ -52,8 +52,11 @@ pub const RPC_DEFAULT_MAX_SUBS_PER_CONN: u32 = 1024; pub const RPC_DEFAULT_MAX_REQUEST_SIZE_MB: u32 = 15; /// The default max response size in MB. pub const RPC_DEFAULT_MAX_RESPONSE_SIZE_MB: u32 = 15; -/// The default number of connection.. +/// The default concurrent connection limit. pub const RPC_DEFAULT_MAX_CONNECTIONS: u32 = 100; +/// The default number of messages the RPC server +/// is allowed to keep in memory per connection. +pub const RPC_DEFAULT_MESSAGE_CAPACITY_PER_CONN: u32 = 64; /// Default configuration values used by Substrate /// @@ -330,6 +333,11 @@ pub trait CliConfiguration: Sized { Ok(RPC_DEFAULT_MAX_SUBS_PER_CONN) } + /// The number of messages the RPC server is allowed to keep in memory per connection. + fn rpc_buffer_capacity_per_connection(&self) -> Result { + Ok(RPC_DEFAULT_MESSAGE_CAPACITY_PER_CONN) + } + /// Get the prometheus configuration (`None` if disabled) /// /// By default this is `None`. @@ -501,6 +509,7 @@ pub trait CliConfiguration: Sized { rpc_id_provider: None, rpc_max_subs_per_conn: self.rpc_max_subscriptions_per_connection()?, rpc_port: DCV::rpc_listen_port(), + rpc_message_buffer_capacity: self.rpc_buffer_capacity_per_connection()?, prometheus_config: self .prometheus_config(DCV::prometheus_listen_port(), &chain_spec)?, telemetry_endpoints, diff --git a/substrate/client/cli/src/runner.rs b/substrate/client/cli/src/runner.rs index 1707a76cbe78..e37c8ab0e551 100644 --- a/substrate/client/cli/src/runner.rs +++ b/substrate/client/cli/src/runner.rs @@ -269,6 +269,7 @@ mod tests { rpc_max_response_size: Default::default(), rpc_id_provider: Default::default(), rpc_max_subs_per_conn: Default::default(), + rpc_message_buffer_capacity: Default::default(), rpc_port: 9944, prometheus_config: None, telemetry_endpoints: None, diff --git a/substrate/client/consensus/babe/rpc/Cargo.toml b/substrate/client/consensus/babe/rpc/Cargo.toml index 753f8fbc821d..87b39f1f9ca6 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.16.2", features = ["client-core", "macros", "server"] } +jsonrpsee = { version = "0.20.3", 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/babe/rpc/src/lib.rs b/substrate/client/consensus/babe/rpc/src/lib.rs index bffe026ea6ef..307b1f955ba2 100644 --- a/substrate/client/consensus/babe/rpc/src/lib.rs +++ b/substrate/client/consensus/babe/rpc/src/lib.rs @@ -22,15 +22,15 @@ use std::{collections::HashMap, sync::Arc}; use futures::TryFutureExt; use jsonrpsee::{ - core::{async_trait, Error as JsonRpseeError, RpcResult}, + core::async_trait, proc_macros::rpc, - types::{error::CallError, ErrorObject}, + types::{ErrorObject, ErrorObjectOwned}, }; use serde::{Deserialize, Serialize}; use sc_consensus_babe::{authorship, BabeWorkerHandle}; use sc_consensus_epochs::Epoch as EpochT; -use sc_rpc_api::DenyUnsafe; +use sc_rpc_api::{DenyUnsafe, UnsafeRpcError}; use sp_api::ProvideRuntimeApi; use sp_application_crypto::AppCrypto; use sp_blockchain::{Error as BlockChainError, HeaderBackend, HeaderMetadata}; @@ -48,7 +48,7 @@ pub trait BabeApi { /// Returns data about which slots (primary or secondary) can be claimed in the current epoch /// with the keys in the keystore. #[method(name = "babe_epochAuthorship")] - async fn epoch_authorship(&self) -> RpcResult>; + async fn epoch_authorship(&self) -> Result, Error>; } /// Provides RPC methods for interacting with Babe. @@ -89,7 +89,7 @@ where C::Api: BabeRuntimeApi, SC: SelectChain + Clone + 'static, { - async fn epoch_authorship(&self) -> RpcResult> { + async fn epoch_authorship(&self) -> Result, Error> { self.deny_unsafe.check_if_safe()?; let best_header = self.select_chain.best_chain().map_err(Error::SelectChain).await?; @@ -147,7 +147,7 @@ where } /// Holds information about the `slot`'s that can be claimed by a given key. -#[derive(Default, Debug, Deserialize, Serialize)] +#[derive(Clone, Default, Debug, Deserialize, Serialize)] pub struct EpochAuthorship { /// the array of primary slots that can be claimed primary: Vec, @@ -166,20 +166,26 @@ pub enum Error { /// Failed to fetch epoch data. #[error("Failed to fetch epoch data")] FetchEpoch, + /// Consensus error + #[error(transparent)] + Consensus(#[from] ConsensusError), + /// Errors that can be formatted as a String + #[error("{0}")] + StringError(String), + /// Call to an unsafe RPC was denied. + #[error(transparent)] + UnsafeRpcCalled(#[from] UnsafeRpcError), } -impl From for JsonRpseeError { +impl From for ErrorObjectOwned { fn from(error: Error) -> Self { - let error_code = match error { - Error::SelectChain(_) => 1, - Error::FetchEpoch => 2, - }; - - JsonRpseeError::Call(CallError::Custom(ErrorObject::owned( - BABE_ERROR + error_code, - error.to_string(), - Some(format!("{:?}", error)), - ))) + match error { + Error::SelectChain(e) => ErrorObject::owned(BABE_ERROR + 1, e.to_string(), None::<()>), + Error::FetchEpoch => ErrorObject::owned(BABE_ERROR + 2, error.to_string(), None::<()>), + Error::Consensus(e) => ErrorObject::owned(BABE_ERROR + 3, e.to_string(), None::<()>), + Error::StringError(e) => ErrorObject::owned(BABE_ERROR + 4, e, None::<()>), + Error::UnsafeRpcCalled(e) => e.into(), + } } } @@ -251,7 +257,7 @@ mod tests { let api = babe_rpc.into_rpc(); let request = r#"{"jsonrpc":"2.0","method":"babe_epochAuthorship","params": [],"id":1}"#; - let (response, _) = api.raw_json_request(request).await.unwrap(); + 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); @@ -263,7 +269,7 @@ mod tests { let api = babe_rpc.into_rpc(); let request = r#"{"jsonrpc":"2.0","method":"babe_epochAuthorship","params":[],"id":1}"#; - let (response, _) = api.raw_json_request(request).await.unwrap(); + 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); diff --git a/substrate/client/consensus/beefy/rpc/Cargo.toml b/substrate/client/consensus/beefy/rpc/Cargo.toml index 198d3d816422..a13da724eaef 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.16.2", features = ["client-core", "macros", "server"] } +jsonrpsee = { version = "0.20.3", 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/beefy/rpc/src/lib.rs b/substrate/client/consensus/beefy/rpc/src/lib.rs index f5c0ff32627d..03c83e92716c 100644 --- a/substrate/client/consensus/beefy/rpc/src/lib.rs +++ b/substrate/client/consensus/beefy/rpc/src/lib.rs @@ -23,15 +23,15 @@ use parking_lot::RwLock; use std::sync::Arc; -use sc_rpc::SubscriptionTaskExecutor; +use sc_rpc::{utils::pipe_from_stream, SubscriptionTaskExecutor}; use sp_runtime::traits::Block as BlockT; use futures::{task::SpawnError, FutureExt, StreamExt}; use jsonrpsee::{ - core::{async_trait, Error as JsonRpseeError, RpcResult}, + core::async_trait, proc_macros::rpc, - types::{error::CallError, ErrorObject, SubscriptionResult}, - SubscriptionSink, + types::{ErrorObject, ErrorObjectOwned}, + PendingSubscriptionSink, }; use log::warn; @@ -69,15 +69,11 @@ impl From for ErrorCode { } } -impl From for JsonRpseeError { +impl From for ErrorObjectOwned { fn from(error: Error) -> Self { let message = error.to_string(); let code = ErrorCode::from(error); - JsonRpseeError::Call(CallError::Custom(ErrorObject::owned( - code as i32, - message, - None::<()>, - ))) + ErrorObject::owned(code as i32, message, None::<()>) } } @@ -98,7 +94,7 @@ pub trait BeefyApi { /// in the network or if the client is still initializing or syncing with the network. /// In such case an error would be returned. #[method(name = "beefy_getFinalizedHead")] - async fn latest_finalized(&self) -> RpcResult; + async fn latest_finalized(&self) -> Result; } /// Implements the BeefyApi RPC trait for interacting with BEEFY. @@ -138,27 +134,17 @@ impl BeefyApiServer SubscriptionResult { + fn subscribe_justifications(&self, pending: PendingSubscriptionSink) { let stream = self .finality_proof_stream .subscribe(100_000) .map(|vfp| notification::EncodedVersionedFinalityProof::new::(vfp)); - let fut = async move { - sink.pipe_from_stream(stream).await; - }; - - self.executor.spawn("substrate-rpc-subscription", Some("rpc"), fut.boxed()); - Ok(()) + sc_rpc::utils::spawn_subscription_task(&self.executor, pipe_from_stream(pending, stream)); } - async fn latest_finalized(&self) -> RpcResult { - self.beefy_best_block - .read() - .as_ref() - .cloned() - .ok_or(Error::EndpointNotReady) - .map_err(Into::into) + async fn latest_finalized(&self) -> Result { + self.beefy_best_block.read().as_ref().cloned().ok_or(Error::EndpointNotReady) } } @@ -167,7 +153,7 @@ mod tests { use super::*; use codec::{Decode, Encode}; - use jsonrpsee::{types::EmptyServerParams as EmptyParams, RpcModule}; + use jsonrpsee::{core::EmptyServerParams as EmptyParams, RpcModule}; use sc_consensus_beefy::{ communication::notification::BeefyVersionedFinalityProofSender, justification::BeefyVersionedFinalityProof, @@ -199,7 +185,7 @@ mod tests { 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 (response, _) = rpc.raw_json_request(&request).await.unwrap(); + let (response, _) = rpc.raw_json_request(&request, 1).await.unwrap(); assert_eq!(expected_response, response.result); } @@ -230,13 +216,13 @@ mod tests { 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).await.expect("RPC requests work"); + let (response, _) = io.raw_json_request(request, 1).await.expect("RPC requests work"); if response.result != not_ready { assert_eq!(response.result, expected); // Success return } - std::thread::sleep(std::time::Duration::from_millis(50)) + tokio::time::sleep(std::time::Duration::from_millis(50)).await; } panic!( @@ -249,7 +235,7 @@ mod tests { let (rpc, _) = setup_io_handler(); // Subscribe call. let _sub = rpc - .subscribe("beefy_subscribeJustifications", EmptyParams::new()) + .subscribe_unbounded("beefy_subscribeJustifications", EmptyParams::new()) .await .unwrap(); @@ -257,6 +243,7 @@ mod tests { let (response, _) = rpc .raw_json_request( r#"{"jsonrpc":"2.0","method":"beefy_unsubscribeJustifications","params":["FOO"],"id":1}"#, + 1, ) .await .unwrap(); @@ -284,7 +271,7 @@ mod tests { // Subscribe let mut sub = rpc - .subscribe("beefy_subscribeJustifications", EmptyParams::new()) + .subscribe_unbounded("beefy_subscribeJustifications", EmptyParams::new()) .await .unwrap(); diff --git a/substrate/client/consensus/common/src/block_import.rs b/substrate/client/consensus/common/src/block_import.rs index a451692ad478..d91851aea62c 100644 --- a/substrate/client/consensus/common/src/block_import.rs +++ b/substrate/client/consensus/common/src/block_import.rs @@ -43,7 +43,7 @@ pub enum ImportResult { } /// Auxiliary data associated with an imported block result. -#[derive(Debug, Default, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)] pub struct ImportedAux { /// Only the header has been imported. Block body verification was skipped. pub header_only: bool, diff --git a/substrate/client/consensus/grandpa/rpc/Cargo.toml b/substrate/client/consensus/grandpa/rpc/Cargo.toml index 9cfc9616cbc0..b4c538908150 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.16.2", features = ["client-core", "macros", "server"] } +jsonrpsee = { version = "0.20.3", 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/grandpa/rpc/src/error.rs b/substrate/client/consensus/grandpa/rpc/src/error.rs index 4884380cd22d..795077804a4b 100644 --- a/substrate/client/consensus/grandpa/rpc/src/error.rs +++ b/substrate/client/consensus/grandpa/rpc/src/error.rs @@ -16,10 +16,7 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -use jsonrpsee::{ - core::Error as JsonRpseeError, - types::error::{CallError, ErrorObject}, -}; +use jsonrpsee::types::error::{ErrorObject, ErrorObjectOwned}; #[derive(Debug, thiserror::Error)] /// Top-level error type for the RPC handler @@ -61,15 +58,11 @@ impl From for ErrorCode { } } -impl From for JsonRpseeError { +impl From for ErrorObjectOwned { fn from(error: Error) -> Self { let message = error.to_string(); let code = ErrorCode::from(error); - JsonRpseeError::Call(CallError::Custom(ErrorObject::owned( - code as i32, - message, - None::<()>, - ))) + ErrorObject::owned(code as i32, message, None::<()>) } } diff --git a/substrate/client/consensus/grandpa/rpc/src/finality.rs b/substrate/client/consensus/grandpa/rpc/src/finality.rs index f8ec01781ac6..93f6c46e411e 100644 --- a/substrate/client/consensus/grandpa/rpc/src/finality.rs +++ b/substrate/client/consensus/grandpa/rpc/src/finality.rs @@ -21,7 +21,7 @@ use serde::{Deserialize, Serialize}; use sc_consensus_grandpa::FinalityProofProvider; use sp_runtime::traits::{Block as BlockT, NumberFor}; -#[derive(Serialize, Deserialize)] +#[derive(Clone, Serialize, Deserialize)] pub struct EncodedFinalityProof(pub sp_core::Bytes); /// Local trait mainly to allow mocking in tests. diff --git a/substrate/client/consensus/grandpa/rpc/src/lib.rs b/substrate/client/consensus/grandpa/rpc/src/lib.rs index a7daefaab8eb..878cefacc479 100644 --- a/substrate/client/consensus/grandpa/rpc/src/lib.rs +++ b/substrate/client/consensus/grandpa/rpc/src/lib.rs @@ -19,15 +19,13 @@ //! RPC API for GRANDPA. #![warn(missing_docs)] -use futures::{FutureExt, StreamExt}; +use futures::StreamExt; use log::warn; use std::sync::Arc; use jsonrpsee::{ - core::{async_trait, RpcResult}, + core::{async_trait, server::PendingSubscriptionSink}, proc_macros::rpc, - types::SubscriptionResult, - SubscriptionSink, }; mod error; @@ -35,13 +33,13 @@ mod finality; mod notification; mod report; -use sc_consensus_grandpa::GrandpaJustificationStream; -use sc_rpc::SubscriptionTaskExecutor; -use sp_runtime::traits::{Block as BlockT, NumberFor}; - +use error::Error; use finality::{EncodedFinalityProof, RpcFinalityProofProvider}; use notification::JustificationNotification; use report::{ReportAuthoritySet, ReportVoterState, ReportedRoundStates}; +use sc_consensus_grandpa::GrandpaJustificationStream; +use sc_rpc::{utils::pipe_from_stream, SubscriptionTaskExecutor}; +use sp_runtime::traits::{Block as BlockT, NumberFor}; /// Provides RPC methods for interacting with GRANDPA. #[rpc(client, server)] @@ -49,7 +47,7 @@ pub trait GrandpaApi { /// Returns the state of the current best round state as well as the /// ongoing background rounds. #[method(name = "grandpa_roundState")] - async fn round_state(&self) -> RpcResult; + async fn round_state(&self) -> Result; /// Returns the block most recently finalized by Grandpa, alongside /// side its justification. @@ -63,7 +61,7 @@ pub trait GrandpaApi { /// Prove finality for the given block number by returning the Justification for the last block /// in the set and all the intermediary headers to link them together. #[method(name = "grandpa_proveFinality")] - async fn prove_finality(&self, block: Number) -> RpcResult>; + async fn prove_finality(&self, block: Number) -> Result, Error>; } /// Provides RPC methods for interacting with GRANDPA. @@ -99,36 +97,28 @@ where Block: BlockT, ProofProvider: RpcFinalityProofProvider + Send + Sync + 'static, { - async fn round_state(&self) -> RpcResult { - ReportedRoundStates::from(&self.authority_set, &self.voter_state).map_err(Into::into) + async fn round_state(&self) -> Result { + ReportedRoundStates::from(&self.authority_set, &self.voter_state) } - fn subscribe_justifications(&self, mut sink: SubscriptionSink) -> SubscriptionResult { + fn subscribe_justifications(&self, pending: PendingSubscriptionSink) { let stream = self.justification_stream.subscribe(100_000).map( |x: sc_consensus_grandpa::GrandpaJustification| { JustificationNotification::from(x) }, ); - let fut = async move { - sink.pipe_from_stream(stream).await; - }; - - self.executor.spawn("substrate-rpc-subscription", Some("rpc"), fut.boxed()); - Ok(()) + sc_rpc::utils::spawn_subscription_task(&self.executor, pipe_from_stream(pending, stream)); } async fn prove_finality( &self, block: NumberFor, - ) -> RpcResult> { - self.finality_proof_provider - .rpc_prove_finality(block) - .map_err(|e| { - warn!("Error proving finality: {}", e); - error::Error::ProveFinalityFailed(e) - }) - .map_err(Into::into) + ) -> Result, Error> { + self.finality_proof_provider.rpc_prove_finality(block).map_err(|e| { + warn!("Error proving finality: {}", e); + error::Error::ProveFinalityFailed(e) + }) } } @@ -137,17 +127,15 @@ mod tests { use super::*; use std::{collections::HashSet, convert::TryInto, sync::Arc}; - use jsonrpsee::{ - types::{EmptyServerParams as EmptyParams, SubscriptionId}, - RpcModule, - }; + use jsonrpsee::{core::EmptyServerParams as EmptyParams, types::SubscriptionId, RpcModule}; use parity_scale_codec::{Decode, Encode}; use sc_block_builder::BlockBuilderBuilder; use sc_consensus_grandpa::{ report, AuthorityId, FinalityProof, GrandpaJustification, GrandpaJustificationSender, }; + use sc_rpc::testing::test_executor; use sp_blockchain::HeaderBackend; - use sp_core::{crypto::ByteArray, testing::TaskExecutor}; + use sp_core::crypto::ByteArray; use sp_keyring::Ed25519Keyring; use sp_runtime::traits::{Block as BlockT, Header as HeaderT}; use substrate_test_runtime_client::{ @@ -264,7 +252,7 @@ mod tests { { let (justification_sender, justification_stream) = GrandpaJustificationStream::channel(); let finality_proof_provider = Arc::new(TestFinalityProofProvider { finality_proof }); - let executor = Arc::new(TaskExecutor::default()); + let executor = test_executor(); let rpc = Grandpa::new( executor, @@ -283,7 +271,7 @@ mod tests { let (rpc, _) = setup_io_handler(EmptyVoterState); let expected_response = r#"{"jsonrpc":"2.0","error":{"code":1,"message":"GRANDPA RPC endpoint not ready"},"id":0}"#.to_string(); let request = r#"{"jsonrpc":"2.0","method":"grandpa_roundState","params":[],"id":0}"#; - let (response, _) = rpc.raw_json_request(&request).await.unwrap(); + let (response, _) = rpc.raw_json_request(&request, 1).await.unwrap(); assert_eq!(expected_response, response.result); } @@ -306,7 +294,7 @@ mod tests { },\"id\":0}".to_string(); let request = r#"{"jsonrpc":"2.0","method":"grandpa_roundState","params":[],"id":0}"#; - let (response, _) = rpc.raw_json_request(&request).await.unwrap(); + let (response, _) = rpc.raw_json_request(&request, 1).await.unwrap(); assert_eq!(expected_response, response.result); } @@ -315,7 +303,7 @@ mod tests { let (rpc, _) = setup_io_handler(TestVoterState); // Subscribe call. let _sub = rpc - .subscribe("grandpa_subscribeJustifications", EmptyParams::new()) + .subscribe_unbounded("grandpa_subscribeJustifications", EmptyParams::new()) .await .unwrap(); @@ -323,6 +311,7 @@ mod tests { let (response, _) = rpc .raw_json_request( r#"{"jsonrpc":"2.0","method":"grandpa_unsubscribeJustifications","params":["FOO"],"id":1}"#, + 1, ) .await .unwrap(); @@ -385,7 +374,7 @@ mod tests { let (rpc, justification_sender) = setup_io_handler(TestVoterState); let mut sub = rpc - .subscribe("grandpa_subscribeJustifications", EmptyParams::new()) + .subscribe_unbounded("grandpa_subscribeJustifications", EmptyParams::new()) .await .unwrap(); diff --git a/substrate/client/consensus/grandpa/rpc/src/report.rs b/substrate/client/consensus/grandpa/rpc/src/report.rs index ae4fd76d2857..b41d090afac8 100644 --- a/substrate/client/consensus/grandpa/rpc/src/report.rs +++ b/substrate/client/consensus/grandpa/rpc/src/report.rs @@ -57,21 +57,21 @@ impl ReportVoterState for SharedVoterState { } } -#[derive(Serialize, Deserialize)] +#[derive(Clone, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] struct Prevotes { current_weight: u32, missing: BTreeSet, } -#[derive(Serialize, Deserialize)] +#[derive(Clone, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] struct Precommits { current_weight: u32, missing: BTreeSet, } -#[derive(Serialize, Deserialize)] +#[derive(Clone, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] struct RoundState { round: u32, @@ -111,7 +111,7 @@ impl RoundState { /// The state of the current best round, as well as the background rounds in a /// form suitable for serialization. -#[derive(Serialize, Deserialize)] +#[derive(Clone, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct ReportedRoundStates { set_id: u32, diff --git a/substrate/client/consensus/manual-seal/Cargo.toml b/substrate/client/consensus/manual-seal/Cargo.toml index 77cd88dfc194..be6bca10257e 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.16.2", features = ["client-core", "macros", "server"] } +jsonrpsee = { version = "0.20.3", 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/consensus/manual-seal/src/error.rs b/substrate/client/consensus/manual-seal/src/error.rs index eeae1d153e81..d7bb00eff6b7 100644 --- a/substrate/client/consensus/manual-seal/src/error.rs +++ b/substrate/client/consensus/manual-seal/src/error.rs @@ -20,10 +20,7 @@ //! This is suitable for a testing environment. use futures::channel::{mpsc::SendError, oneshot}; -use jsonrpsee::{ - core::Error as JsonRpseeError, - types::error::{CallError, ErrorObject}, -}; +use jsonrpsee::types::error::{ErrorObject, ErrorObjectOwned}; use sc_consensus::ImportResult; use sp_blockchain::Error as BlockchainError; use sp_consensus::Error as ConsensusError; @@ -106,8 +103,8 @@ impl Error { } } -impl From for JsonRpseeError { +impl From for ErrorObjectOwned { fn from(err: Error) -> Self { - CallError::Custom(ErrorObject::owned(err.to_code(), err.to_string(), None::<()>)).into() + ErrorObject::owned(err.to_code(), err.to_string(), None::<()>) } } diff --git a/substrate/client/consensus/manual-seal/src/rpc.rs b/substrate/client/consensus/manual-seal/src/rpc.rs index c0b3af69bedf..6018c3ab092a 100644 --- a/substrate/client/consensus/manual-seal/src/rpc.rs +++ b/substrate/client/consensus/manual-seal/src/rpc.rs @@ -23,10 +23,7 @@ use futures::{ channel::{mpsc, oneshot}, SinkExt, }; -use jsonrpsee::{ - core::{async_trait, Error as JsonRpseeError, RpcResult}, - proc_macros::rpc, -}; +use jsonrpsee::{core::async_trait, proc_macros::rpc}; use sc_consensus::ImportedAux; use serde::{Deserialize, Serialize}; use sp_runtime::EncodedJustification; @@ -74,7 +71,7 @@ pub trait ManualSealApi { create_empty: bool, finalize: bool, parent_hash: Option, - ) -> RpcResult>; + ) -> Result, Error>; /// Instructs the manual-seal authorship task to finalize a block #[method(name = "engine_finalizeBlock")] @@ -82,7 +79,7 @@ pub trait ManualSealApi { &self, hash: Hash, justification: Option, - ) -> RpcResult; + ) -> Result; } /// A struct that implements the [`ManualSealApiServer`]. @@ -91,7 +88,7 @@ pub struct ManualSeal { } /// return type of `engine_createBlock` -#[derive(Debug, Deserialize, Serialize, PartialEq, Eq)] +#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq)] pub struct CreatedBlock { /// hash of the created block. pub hash: Hash, @@ -115,7 +112,7 @@ impl ManualSealApiServer for ManualSeal { create_empty: bool, finalize: bool, parent_hash: Option, - ) -> RpcResult> { + ) -> Result, Error> { let mut sink = self.import_block_channel.clone(); let (sender, receiver) = oneshot::channel(); // NOTE: this sends a Result over the channel. @@ -131,7 +128,7 @@ impl ManualSealApiServer for ManualSeal { match receiver.await { Ok(Ok(rx)) => Ok(rx), Ok(Err(e)) => Err(e.into()), - Err(e) => Err(JsonRpseeError::to_call_error(e)), + Err(e) => Err(e.into()), } } @@ -139,12 +136,12 @@ impl ManualSealApiServer for ManualSeal { &self, hash: Hash, justification: Option, - ) -> RpcResult { + ) -> Result { let mut sink = self.import_block_channel.clone(); let (sender, receiver) = oneshot::channel(); let command = EngineCommand::FinalizeBlock { hash, sender: Some(sender), justification }; sink.send(command).await?; - receiver.await.map(|_| true).map_err(|e| JsonRpseeError::to_call_error(e)) + receiver.await.map(|_| true).map_err(Into::into) } } diff --git a/substrate/client/merkle-mountain-range/rpc/Cargo.toml b/substrate/client/merkle-mountain-range/rpc/Cargo.toml index 8eb48d65f81e..dc95eebf4b73 100644 --- a/substrate/client/merkle-mountain-range/rpc/Cargo.toml +++ b/substrate/client/merkle-mountain-range/rpc/Cargo.toml @@ -16,14 +16,13 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] codec = { package = "parity-scale-codec", version = "3.6.1" } -jsonrpsee = { version = "0.16.2", features = ["client-core", "macros", "server"] } +jsonrpsee = { version = "0.20.3", features = ["client-core", "macros", "server"] } serde = { version = "1.0.195", features = ["derive"] } sp-api = { path = "../../../primitives/api" } sp-blockchain = { path = "../../../primitives/blockchain" } sp-core = { path = "../../../primitives/core" } sp-mmr-primitives = { path = "../../../primitives/merkle-mountain-range" } sp-runtime = { path = "../../../primitives/runtime" } -anyhow = "1" [dev-dependencies] serde_json = "1.0.111" diff --git a/substrate/client/merkle-mountain-range/rpc/src/lib.rs b/substrate/client/merkle-mountain-range/rpc/src/lib.rs index 1653749ffab9..b4da9848de54 100644 --- a/substrate/client/merkle-mountain-range/rpc/src/lib.rs +++ b/substrate/client/merkle-mountain-range/rpc/src/lib.rs @@ -26,7 +26,7 @@ use codec::{Codec, Decode, Encode}; use jsonrpsee::{ core::{async_trait, RpcResult}, proc_macros::rpc, - types::error::{CallError, ErrorObject}, + types::{error::ErrorObject, ErrorObjectOwned}, }; use serde::{Deserialize, Serialize}; @@ -189,11 +189,9 @@ where fn verify_proof(&self, proof: LeavesProof<::Hash>) -> RpcResult { let mut api = self.client.runtime_api(); - let leaves = Decode::decode(&mut &proof.leaves.0[..]) - .map_err(|e| CallError::InvalidParams(anyhow::Error::new(e)))?; + let leaves = Decode::decode(&mut &proof.leaves.0[..]).map_err(invalid_params)?; - let decoded_proof = Decode::decode(&mut &proof.proof.0[..]) - .map_err(|e| CallError::InvalidParams(anyhow::Error::new(e)))?; + let decoded_proof = Decode::decode(&mut &proof.proof.0[..]).map_err(invalid_params)?; api.register_extension(OffchainDbExt::new(self.offchain_db.clone())); @@ -211,11 +209,9 @@ where ) -> RpcResult { let api = self.client.runtime_api(); - let leaves = Decode::decode(&mut &proof.leaves.0[..]) - .map_err(|e| CallError::InvalidParams(anyhow::Error::new(e)))?; + let leaves = Decode::decode(&mut &proof.leaves.0[..]).map_err(invalid_params)?; - let decoded_proof = Decode::decode(&mut &proof.proof.0[..]) - .map_err(|e| CallError::InvalidParams(anyhow::Error::new(e)))?; + let decoded_proof = Decode::decode(&mut &proof.proof.0[..]).map_err(invalid_params)?; api.verify_proof_stateless(proof.block_hash, mmr_root, leaves, decoded_proof) .map_err(runtime_error_into_rpc_error)? @@ -226,7 +222,7 @@ where } /// Converts an mmr-specific error into a [`CallError`]. -fn mmr_error_into_rpc_error(err: MmrError) -> CallError { +fn mmr_error_into_rpc_error(err: MmrError) -> ErrorObjectOwned { let error_code = MMR_ERROR + match err { MmrError::LeafNotFound => 1, @@ -237,16 +233,20 @@ fn mmr_error_into_rpc_error(err: MmrError) -> CallError { _ => 0, }; - CallError::Custom(ErrorObject::owned(error_code, err.to_string(), Some(format!("{:?}", err)))) + ErrorObject::owned(error_code, err.to_string(), Some(format!("{:?}", err))) } /// Converts a runtime trap into a [`CallError`]. -fn runtime_error_into_rpc_error(err: impl std::fmt::Debug) -> CallError { - CallError::Custom(ErrorObject::owned( - RUNTIME_ERROR, - "Runtime trapped", - Some(format!("{:?}", err)), - )) +fn runtime_error_into_rpc_error(err: impl std::fmt::Debug) -> ErrorObjectOwned { + ErrorObject::owned(RUNTIME_ERROR, "Runtime trapped", Some(format!("{:?}", err))) +} + +fn invalid_params(e: impl std::error::Error) -> ErrorObjectOwned { + ErrorObject::owned( + jsonrpsee::types::error::ErrorCode::InvalidParams.code(), + e.to_string(), + None::<()>, + ) } #[cfg(test)] diff --git a/substrate/client/network/sync/src/strategy.rs b/substrate/client/network/sync/src/strategy.rs index ee99252fc911..dbfb4188ec3f 100644 --- a/substrate/client/network/sync/src/strategy.rs +++ b/substrate/client/network/sync/src/strategy.rs @@ -469,7 +469,7 @@ where Ok(chain_sync) => chain_sync, Err(e) => { error!(target: LOG_TARGET, "Failed to start `ChainSync`."); - return Err(e); + return Err(e) }, }; // Let `ChainSync` know about connected peers. diff --git a/substrate/client/rpc-api/Cargo.toml b/substrate/client/rpc-api/Cargo.toml index 062d25408a14..bd0fd87bb9e9 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.16.2", features = ["client-core", "macros", "server"] } +jsonrpsee = { version = "0.20.3", features = ["client-core", "macros", "server"] } diff --git a/substrate/client/rpc-api/src/author/error.rs b/substrate/client/rpc-api/src/author/error.rs index 648dbb295d8d..0ccd82fc0b64 100644 --- a/substrate/client/rpc-api/src/author/error.rs +++ b/substrate/client/rpc-api/src/author/error.rs @@ -18,10 +18,7 @@ //! Authoring RPC module errors. -use jsonrpsee::{ - core::Error as JsonRpseeError, - types::error::{CallError, ErrorObject}, -}; +use jsonrpsee::types::error::{ErrorObject, ErrorObjectOwned}; use sp_runtime::transaction_validity::InvalidTransaction; /// Author RPC Result type. @@ -86,98 +83,104 @@ const POOL_NO_TAGS: i32 = POOL_INVALID_TX + 9; const POOL_INVALID_BLOCK_ID: i32 = POOL_INVALID_TX + 10; /// The pool is not accepting future transactions. const POOL_FUTURE_TX: i32 = POOL_INVALID_TX + 11; +/// Other error. +const OTHER_ERR: i32 = BASE_ERROR + 40; -impl From for JsonRpseeError { - fn from(e: Error) -> Self { +impl From for ErrorObjectOwned { + fn from(e: Error) -> ErrorObjectOwned { use sc_transaction_pool_api::error::Error as PoolError; match e { - Error::BadFormat(e) => CallError::Custom(ErrorObject::owned( + Error::BadFormat(e) => ErrorObject::owned( BAD_FORMAT, format!("Extrinsic has invalid format: {}", e), None::<()>, - )), - Error::Verification(e) => CallError::Custom(ErrorObject::owned( + ), + Error::Verification(e) => ErrorObject::owned( VERIFICATION_ERROR, format!("Verification Error: {}", e), Some(format!("{:?}", e)), - )), + ), Error::Pool(PoolError::InvalidTransaction(InvalidTransaction::Custom(e))) => { - CallError::Custom(ErrorObject::owned( + ErrorObject::owned( POOL_INVALID_TX, "Invalid Transaction", Some(format!("Custom error: {}", e)), - )) + ) }, Error::Pool(PoolError::InvalidTransaction(e)) => { let msg: &str = e.into(); - CallError::Custom(ErrorObject::owned( + ErrorObject::owned( POOL_INVALID_TX, "Invalid Transaction", Some(msg), - )) + ) }, Error::Pool(PoolError::UnknownTransaction(e)) => { - CallError::Custom(ErrorObject::owned( + ErrorObject::owned( POOL_UNKNOWN_VALIDITY, "Unknown Transaction Validity", Some(format!("{:?}", e)), - )) + ) }, Error::Pool(PoolError::TemporarilyBanned) => - CallError::Custom(ErrorObject::owned( + ErrorObject::owned( POOL_TEMPORARILY_BANNED, "Transaction is temporarily banned", None::<()>, - )), + ), Error::Pool(PoolError::AlreadyImported(hash)) => - CallError::Custom(ErrorObject::owned( + ErrorObject::owned( POOL_ALREADY_IMPORTED, "Transaction Already Imported", Some(format!("{:?}", hash)), - )), - Error::Pool(PoolError::TooLowPriority { old, new }) => CallError::Custom(ErrorObject::owned( + ), + Error::Pool(PoolError::TooLowPriority { old, new }) => ErrorObject::owned( POOL_TOO_LOW_PRIORITY, format!("Priority is too low: ({} vs {})", old, new), Some("The transaction has too low priority to replace another transaction already in the pool.") - )), + ), Error::Pool(PoolError::CycleDetected) => - CallError::Custom(ErrorObject::owned( + ErrorObject::owned( POOL_CYCLE_DETECTED, "Cycle Detected", None::<()> - )), - Error::Pool(PoolError::ImmediatelyDropped) => CallError::Custom(ErrorObject::owned( + ), + Error::Pool(PoolError::ImmediatelyDropped) => ErrorObject::owned( POOL_IMMEDIATELY_DROPPED, "Immediately Dropped", Some("The transaction couldn't enter the pool because of the limit"), - )), - Error::Pool(PoolError::Unactionable) => CallError::Custom(ErrorObject::owned( + ), + Error::Pool(PoolError::Unactionable) => ErrorObject::owned( POOL_UNACTIONABLE, "Unactionable", Some("The transaction is unactionable since it is not propagable and \ the local node does not author blocks") - )), - Error::Pool(PoolError::NoTagsProvided) => CallError::Custom(ErrorObject::owned( + ), + Error::Pool(PoolError::NoTagsProvided) => ErrorObject::owned( POOL_NO_TAGS, "No tags provided", Some("Transaction does not provide any tags, so the pool can't identify it") - )), + ), Error::Pool(PoolError::InvalidBlockId(_)) => - CallError::Custom(ErrorObject::owned( + ErrorObject::owned( POOL_INVALID_BLOCK_ID, "The provided block ID is not valid", None::<()> - )), + ), Error::Pool(PoolError::RejectedFutureTransaction) => { - CallError::Custom(ErrorObject::owned( + ErrorObject::owned( POOL_FUTURE_TX, "The pool is not accepting future transactions", None::<()>, - )) + ) }, Error::UnsafeRpcCalled(e) => e.into(), - e => CallError::Failed(e.into()), - }.into() + other => ErrorObject::owned( + OTHER_ERR, + other.to_string(), + None::<()>, + ) + } } } diff --git a/substrate/client/rpc-api/src/author/mod.rs b/substrate/client/rpc-api/src/author/mod.rs index 55881e62152e..cfc56f4130ab 100644 --- a/substrate/client/rpc-api/src/author/mod.rs +++ b/substrate/client/rpc-api/src/author/mod.rs @@ -18,27 +18,28 @@ //! Substrate block-author/full-node API. -use jsonrpsee::{core::RpcResult, proc_macros::rpc}; -use sc_transaction_pool_api::TransactionStatus; -use sp_core::Bytes; - pub mod error; pub mod hash; +use error::Error; +use jsonrpsee::proc_macros::rpc; +use sc_transaction_pool_api::TransactionStatus; +use sp_core::Bytes; + /// Substrate authoring RPC API #[rpc(client, server)] pub trait AuthorApi { /// Submit hex-encoded extrinsic for inclusion in block. #[method(name = "author_submitExtrinsic")] - async fn submit_extrinsic(&self, extrinsic: Bytes) -> RpcResult; + async fn submit_extrinsic(&self, extrinsic: Bytes) -> Result; /// Insert a key into the keystore. #[method(name = "author_insertKey")] - fn insert_key(&self, key_type: String, suri: String, public: Bytes) -> RpcResult<()>; + fn insert_key(&self, key_type: String, suri: String, public: Bytes) -> Result<(), Error>; /// Generate new session keys and returns the corresponding public keys. #[method(name = "author_rotateKeys")] - fn rotate_keys(&self) -> RpcResult; + fn rotate_keys(&self) -> Result; /// Checks if the keystore has private keys for the given session public keys. /// @@ -46,24 +47,24 @@ pub trait AuthorApi { /// /// Returns `true` iff all private keys could be found. #[method(name = "author_hasSessionKeys")] - fn has_session_keys(&self, session_keys: Bytes) -> RpcResult; + fn has_session_keys(&self, session_keys: Bytes) -> Result; /// Checks if the keystore has private keys for the given public key and key type. /// /// Returns `true` if a private key could be found. #[method(name = "author_hasKey")] - fn has_key(&self, public_key: Bytes, key_type: String) -> RpcResult; + fn has_key(&self, public_key: Bytes, key_type: String) -> Result; /// Returns all pending extrinsics, potentially grouped by sender. #[method(name = "author_pendingExtrinsics")] - fn pending_extrinsics(&self) -> RpcResult>; + fn pending_extrinsics(&self) -> Result, Error>; /// Remove given extrinsic from the pool and temporarily ban it to prevent reimporting. #[method(name = "author_removeExtrinsic")] fn remove_extrinsic( &self, bytes_or_hash: Vec>, - ) -> RpcResult>; + ) -> Result, Error>; /// Submit an extrinsic to watch. /// diff --git a/substrate/client/rpc-api/src/chain/error.rs b/substrate/client/rpc-api/src/chain/error.rs index 652192942588..ff3593557bdb 100644 --- a/substrate/client/rpc-api/src/chain/error.rs +++ b/substrate/client/rpc-api/src/chain/error.rs @@ -18,10 +18,7 @@ //! Error helpers for Chain RPC module. -use jsonrpsee::{ - core::Error as JsonRpseeError, - types::error::{CallError, ErrorObject}, -}; +use jsonrpsee::types::{error::ErrorObject, ErrorObjectOwned}; /// Chain RPC Result type. pub type Result = std::result::Result; @@ -39,12 +36,11 @@ pub enum Error { /// Base error code for all chain errors. const BASE_ERROR: i32 = crate::error::base::CHAIN; -impl From for JsonRpseeError { - fn from(e: Error) -> Self { +impl From for ErrorObjectOwned { + fn from(e: Error) -> ErrorObjectOwned { match e { - Error::Other(message) => - CallError::Custom(ErrorObject::owned(BASE_ERROR + 1, message, None::<()>)).into(), - e => e.into(), + Error::Other(message) => ErrorObject::owned(BASE_ERROR + 1, message, None::<()>), + e => ErrorObject::owned(BASE_ERROR + 2, e.to_string(), None::<()>), } } } diff --git a/substrate/client/rpc-api/src/chain/mod.rs b/substrate/client/rpc-api/src/chain/mod.rs index f215cd978f03..e53c2bc5510a 100644 --- a/substrate/client/rpc-api/src/chain/mod.rs +++ b/substrate/client/rpc-api/src/chain/mod.rs @@ -18,20 +18,21 @@ //! Substrate blockchain API. -use jsonrpsee::{core::RpcResult, proc_macros::rpc}; -use sp_rpc::{list::ListOrValue, number::NumberOrHex}; - pub mod error; +use error::Error; +use jsonrpsee::proc_macros::rpc; +use sp_rpc::{list::ListOrValue, number::NumberOrHex}; + #[rpc(client, server)] pub trait ChainApi { /// Get header. #[method(name = "chain_getHeader", blocking)] - fn header(&self, hash: Option) -> RpcResult>; + fn header(&self, hash: Option) -> Result, Error>; /// Get header and body of a block. #[method(name = "chain_getBlock", blocking)] - fn block(&self, hash: Option) -> RpcResult>; + fn block(&self, hash: Option) -> Result, Error>; /// Get hash of the n-th block in the canon chain. /// @@ -40,11 +41,11 @@ pub trait ChainApi { fn block_hash( &self, hash: Option>, - ) -> RpcResult>>; + ) -> Result>, Error>; /// Get hash of the last finalized block in the canon chain. #[method(name = "chain_getFinalizedHead", aliases = ["chain_getFinalisedHead"], blocking)] - fn finalized_head(&self) -> RpcResult; + fn finalized_head(&self) -> Result; /// All head subscription. #[subscription( diff --git a/substrate/client/rpc-api/src/child_state/mod.rs b/substrate/client/rpc-api/src/child_state/mod.rs index a184677a721b..70f304ea8e02 100644 --- a/substrate/client/rpc-api/src/child_state/mod.rs +++ b/substrate/client/rpc-api/src/child_state/mod.rs @@ -17,8 +17,8 @@ // along with this program. If not, see . //! Substrate child state API -use crate::state::ReadProof; -use jsonrpsee::{core::RpcResult, proc_macros::rpc}; +use crate::state::{Error, ReadProof}; +use jsonrpsee::proc_macros::rpc; use sp_core::storage::{PrefixedStorageKey, StorageData, StorageKey}; /// Substrate child state API @@ -35,7 +35,7 @@ pub trait ChildStateApi { child_storage_key: PrefixedStorageKey, prefix: StorageKey, hash: Option, - ) -> RpcResult>; + ) -> Result, Error>; /// Returns the keys with prefix from a child storage with pagination support. /// Up to `count` keys will be returned. @@ -48,7 +48,7 @@ pub trait ChildStateApi { count: u32, start_key: Option, hash: Option, - ) -> RpcResult>; + ) -> Result, Error>; /// Returns a child storage entry at a specific block's state. #[method(name = "childstate_getStorage", blocking)] @@ -57,7 +57,7 @@ pub trait ChildStateApi { child_storage_key: PrefixedStorageKey, key: StorageKey, hash: Option, - ) -> RpcResult>; + ) -> Result, Error>; /// Returns child storage entries for multiple keys at a specific block's state. #[method(name = "childstate_getStorageEntries", blocking)] @@ -66,7 +66,7 @@ pub trait ChildStateApi { child_storage_key: PrefixedStorageKey, keys: Vec, hash: Option, - ) -> RpcResult>>; + ) -> Result>, Error>; /// Returns the hash of a child storage entry at a block's state. #[method(name = "childstate_getStorageHash", blocking)] @@ -75,7 +75,7 @@ pub trait ChildStateApi { child_storage_key: PrefixedStorageKey, key: StorageKey, hash: Option, - ) -> RpcResult>; + ) -> Result, Error>; /// Returns the size of a child storage entry at a block's state. #[method(name = "childstate_getStorageSize", blocking)] @@ -84,7 +84,7 @@ pub trait ChildStateApi { child_storage_key: PrefixedStorageKey, key: StorageKey, hash: Option, - ) -> RpcResult>; + ) -> Result, Error>; /// Returns proof of storage for child key entries at a specific block's state. #[method(name = "state_getChildReadProof", blocking)] @@ -93,5 +93,5 @@ pub trait ChildStateApi { child_storage_key: PrefixedStorageKey, keys: Vec, hash: Option, - ) -> RpcResult>; + ) -> Result, Error>; } diff --git a/substrate/client/rpc-api/src/dev/error.rs b/substrate/client/rpc-api/src/dev/error.rs index 8e4ddb55e35d..f70e368b8738 100644 --- a/substrate/client/rpc-api/src/dev/error.rs +++ b/substrate/client/rpc-api/src/dev/error.rs @@ -18,10 +18,10 @@ //! Error helpers for Dev RPC module. -use jsonrpsee::{ - core::Error as JsonRpseeError, - types::error::{CallError, ErrorObject}, -}; +use jsonrpsee::types::error::{ErrorObject, ErrorObjectOwned}; + +/// Dev RPC Result type. +pub type Result = std::result::Result; /// Dev RPC errors. #[derive(Debug, thiserror::Error)] @@ -46,21 +46,16 @@ pub enum Error { /// Base error code for all dev errors. const BASE_ERROR: i32 = crate::error::base::DEV; -impl From for JsonRpseeError { +impl From for ErrorObjectOwned { fn from(e: Error) -> Self { let msg = e.to_string(); match e { - Error::BlockQueryError(_) => - CallError::Custom(ErrorObject::owned(BASE_ERROR + 1, msg, None::<()>)), - Error::BlockExecutionFailed => - CallError::Custom(ErrorObject::owned(BASE_ERROR + 3, msg, None::<()>)), - Error::WitnessCompactionFailed => - CallError::Custom(ErrorObject::owned(BASE_ERROR + 4, msg, None::<()>)), - Error::ProofExtractionFailed => - CallError::Custom(ErrorObject::owned(BASE_ERROR + 5, msg, None::<()>)), + Error::BlockQueryError(_) => ErrorObject::owned(BASE_ERROR + 1, msg, None::<()>), + Error::BlockExecutionFailed => ErrorObject::owned(BASE_ERROR + 3, msg, None::<()>), + Error::WitnessCompactionFailed => ErrorObject::owned(BASE_ERROR + 4, msg, None::<()>), + Error::ProofExtractionFailed => ErrorObject::owned(BASE_ERROR + 5, msg, None::<()>), Error::UnsafeRpcCalled(e) => e.into(), } - .into() } } diff --git a/substrate/client/rpc-api/src/dev/mod.rs b/substrate/client/rpc-api/src/dev/mod.rs index bc7216199dd7..5bee6df73ba9 100644 --- a/substrate/client/rpc-api/src/dev/mod.rs +++ b/substrate/client/rpc-api/src/dev/mod.rs @@ -23,7 +23,8 @@ pub mod error; use codec::{Decode, Encode}; -use jsonrpsee::{core::RpcResult, proc_macros::rpc}; +use error::Error; +use jsonrpsee::proc_macros::rpc; use scale_info::TypeInfo; use serde::{Deserialize, Serialize}; @@ -59,5 +60,5 @@ pub trait DevApi { /// at the queried node. If either the specified block or the parent is pruned, /// this function will return `None`. #[method(name = "dev_getBlockStats")] - fn block_stats(&self, block_hash: Hash) -> RpcResult>; + fn block_stats(&self, block_hash: Hash) -> Result, Error>; } diff --git a/substrate/client/rpc-api/src/lib.rs b/substrate/client/rpc-api/src/lib.rs index 32120d37902d..451ebdf7fc00 100644 --- a/substrate/client/rpc-api/src/lib.rs +++ b/substrate/client/rpc-api/src/lib.rs @@ -25,7 +25,7 @@ mod error; mod policy; -pub use policy::DenyUnsafe; +pub use policy::{DenyUnsafe, UnsafeRpcError}; pub mod author; pub mod chain; diff --git a/substrate/client/rpc-api/src/mixnet/error.rs b/substrate/client/rpc-api/src/mixnet/error.rs index 0dde5f32e613..22352256f91e 100644 --- a/substrate/client/rpc-api/src/mixnet/error.rs +++ b/substrate/client/rpc-api/src/mixnet/error.rs @@ -18,7 +18,7 @@ //! Mixnet RPC module errors. -use jsonrpsee::types::error::{CallError, ErrorObject}; +use jsonrpsee::types::error::{ErrorObject, ErrorObjectOwned}; use sc_mixnet::{PostErr, RemoteErr, TopologyErr}; /// Mixnet RPC error type. @@ -27,7 +27,7 @@ pub struct Error(pub sc_mixnet::Error); /// Base code for all mixnet errors. const BASE_ERROR: i32 = crate::error::base::MIXNET; -impl From for jsonrpsee::core::Error { +impl From for ErrorObjectOwned { fn from(err: Error) -> Self { let code = match err.0 { sc_mixnet::Error::ServiceUnavailable => BASE_ERROR + 1, @@ -43,6 +43,6 @@ impl From for jsonrpsee::core::Error { sc_mixnet::Error::Remote(RemoteErr::Other(_)) => BASE_ERROR + 200, sc_mixnet::Error::Remote(RemoteErr::Decode(_)) => BASE_ERROR + 201, }; - CallError::Custom(ErrorObject::owned(code, err.0.to_string(), None::<()>)).into() + ErrorObject::owned(code, err.0.to_string(), None::<()>) } } diff --git a/substrate/client/rpc-api/src/mixnet/mod.rs b/substrate/client/rpc-api/src/mixnet/mod.rs index bc478cf3bf33..8bd3362ca613 100644 --- a/substrate/client/rpc-api/src/mixnet/mod.rs +++ b/substrate/client/rpc-api/src/mixnet/mod.rs @@ -20,12 +20,13 @@ pub mod error; -use jsonrpsee::{core::RpcResult, proc_macros::rpc}; +use error::Error; +use jsonrpsee::proc_macros::rpc; use sp_core::Bytes; #[rpc(client, server)] pub trait MixnetApi { /// Submit encoded extrinsic over the mixnet for inclusion in block. #[method(name = "mixnet_submitExtrinsic")] - async fn submit_extrinsic(&self, extrinsic: Bytes) -> RpcResult<()>; + async fn submit_extrinsic(&self, extrinsic: Bytes) -> Result<(), Error>; } diff --git a/substrate/client/rpc-api/src/offchain/error.rs b/substrate/client/rpc-api/src/offchain/error.rs index 679e10008973..ae5771981ea9 100644 --- a/substrate/client/rpc-api/src/offchain/error.rs +++ b/substrate/client/rpc-api/src/offchain/error.rs @@ -18,10 +18,7 @@ //! Offchain RPC errors. -use jsonrpsee::{ - core::Error as JsonRpseeError, - types::error::{CallError, ErrorObject}, -}; +use jsonrpsee::types::error::{ErrorObject, ErrorObjectOwned}; /// Offchain RPC Result type. pub type Result = std::result::Result; @@ -40,15 +37,14 @@ pub enum Error { /// Base error code for all offchain errors. const BASE_ERROR: i32 = crate::error::base::OFFCHAIN; -impl From for JsonRpseeError { +impl From for ErrorObjectOwned { fn from(e: Error) -> Self { match e { - Error::UnavailableStorageKind => CallError::Custom(ErrorObject::owned( + Error::UnavailableStorageKind => ErrorObject::owned( BASE_ERROR + 1, "This storage kind is not available yet", None::<()>, - )) - .into(), + ), Error::UnsafeRpcCalled(e) => e.into(), } } diff --git a/substrate/client/rpc-api/src/offchain/mod.rs b/substrate/client/rpc-api/src/offchain/mod.rs index cd42d6db3508..469e22d2b3fa 100644 --- a/substrate/client/rpc-api/src/offchain/mod.rs +++ b/substrate/client/rpc-api/src/offchain/mod.rs @@ -18,19 +18,20 @@ //! Substrate offchain API. -use jsonrpsee::{core::RpcResult, proc_macros::rpc}; -use sp_core::{offchain::StorageKind, Bytes}; - pub mod error; +use error::Error; +use jsonrpsee::proc_macros::rpc; +use sp_core::{offchain::StorageKind, Bytes}; + /// Substrate offchain RPC API #[rpc(client, server)] pub trait OffchainApi { /// Set offchain local storage under given key and prefix. #[method(name = "offchain_localStorageSet")] - fn set_local_storage(&self, kind: StorageKind, key: Bytes, value: Bytes) -> RpcResult<()>; + fn set_local_storage(&self, kind: StorageKind, key: Bytes, value: Bytes) -> Result<(), Error>; /// Get offchain local storage under given key and prefix. #[method(name = "offchain_localStorageGet")] - fn get_local_storage(&self, kind: StorageKind, key: Bytes) -> RpcResult>; + fn get_local_storage(&self, kind: StorageKind, key: Bytes) -> Result, Error>; } diff --git a/substrate/client/rpc-api/src/policy.rs b/substrate/client/rpc-api/src/policy.rs index 799898fb7cf5..c0847de89d2c 100644 --- a/substrate/client/rpc-api/src/policy.rs +++ b/substrate/client/rpc-api/src/policy.rs @@ -21,13 +21,7 @@ //! Contains a `DenyUnsafe` type that can be used to deny potentially unsafe //! RPC when accessed externally. -use jsonrpsee::{ - core::Error as JsonRpseeError, - types::{ - error::{CallError, ErrorCode}, - ErrorObject, - }, -}; +use jsonrpsee::types::{error::ErrorCode, ErrorObject, ErrorObjectOwned}; /// Signifies whether a potentially unsafe RPC should be denied. #[derive(Clone, Copy, Debug)] @@ -61,18 +55,8 @@ impl std::fmt::Display for UnsafeRpcError { impl std::error::Error for UnsafeRpcError {} -impl From for CallError { - fn from(e: UnsafeRpcError) -> CallError { - CallError::Custom(ErrorObject::owned( - ErrorCode::MethodNotFound.code(), - e.to_string(), - None::<()>, - )) - } -} - -impl From for JsonRpseeError { - fn from(e: UnsafeRpcError) -> JsonRpseeError { - JsonRpseeError::Call(e.into()) +impl From for ErrorObjectOwned { + fn from(e: UnsafeRpcError) -> ErrorObjectOwned { + ErrorObject::owned(ErrorCode::MethodNotFound.code(), e.to_string(), None::<()>) } } diff --git a/substrate/client/rpc-api/src/state/error.rs b/substrate/client/rpc-api/src/state/error.rs index 9857784e3545..f2396c63815c 100644 --- a/substrate/client/rpc-api/src/state/error.rs +++ b/substrate/client/rpc-api/src/state/error.rs @@ -18,10 +18,8 @@ //! State RPC errors. -use jsonrpsee::{ - core::Error as JsonRpseeError, - types::error::{CallError, ErrorObject}, -}; +use jsonrpsee::types::error::{ErrorObject, ErrorObjectOwned}; + /// State RPC Result type. pub type Result = std::result::Result; @@ -57,16 +55,14 @@ pub enum Error { /// Base code for all state errors. const BASE_ERROR: i32 = crate::error::base::STATE; -impl From for JsonRpseeError { - fn from(e: Error) -> Self { +impl From for ErrorObjectOwned { + fn from(e: Error) -> ErrorObjectOwned { match e { Error::InvalidBlockRange { .. } => - CallError::Custom(ErrorObject::owned(BASE_ERROR + 1, e.to_string(), None::<()>)) - .into(), + ErrorObject::owned(BASE_ERROR + 1, e.to_string(), None::<()>), Error::InvalidCount { .. } => - CallError::Custom(ErrorObject::owned(BASE_ERROR + 2, e.to_string(), None::<()>)) - .into(), - e => Self::to_call_error(e), + ErrorObject::owned(BASE_ERROR + 2, e.to_string(), None::<()>), + e => ErrorObject::owned(BASE_ERROR + 3, e.to_string(), None::<()>), } } } diff --git a/substrate/client/rpc-api/src/state/helpers.rs b/substrate/client/rpc-api/src/state/helpers.rs index de20ee6f1bdf..58b79ab64ea3 100644 --- a/substrate/client/rpc-api/src/state/helpers.rs +++ b/substrate/client/rpc-api/src/state/helpers.rs @@ -22,7 +22,7 @@ use serde::{Deserialize, Serialize}; use sp_core::Bytes; /// ReadProof struct returned by the RPC -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct ReadProof { /// Block hash used to generate the proof diff --git a/substrate/client/rpc-api/src/state/mod.rs b/substrate/client/rpc-api/src/state/mod.rs index 4acc64def2bd..e38e383c4c15 100644 --- a/substrate/client/rpc-api/src/state/mod.rs +++ b/substrate/client/rpc-api/src/state/mod.rs @@ -18,7 +18,7 @@ //! Substrate state API. -use jsonrpsee::{core::RpcResult, proc_macros::rpc}; +use jsonrpsee::proc_macros::rpc; use sp_core::{ storage::{StorageChangeSet, StorageData, StorageKey}, Bytes, @@ -29,18 +29,23 @@ pub mod error; pub mod helpers; pub use self::helpers::ReadProof; +pub use error::Error; /// Substrate state API #[rpc(client, server)] pub trait StateApi { /// Call a method from the runtime API at a block's state. #[method(name = "state_call", aliases = ["state_callAt"], blocking)] - fn call(&self, name: String, bytes: Bytes, hash: Option) -> RpcResult; + fn call(&self, name: String, bytes: Bytes, hash: Option) -> Result; /// Returns the keys with prefix, leave empty to get all the keys. #[method(name = "state_getKeys", blocking)] #[deprecated(since = "2.0.0", note = "Please use `getKeysPaged` with proper paging support")] - fn storage_keys(&self, prefix: StorageKey, hash: Option) -> RpcResult>; + fn storage_keys( + &self, + prefix: StorageKey, + hash: Option, + ) -> Result, Error>; /// Returns the keys with prefix, leave empty to get all the keys #[method(name = "state_getPairs", blocking)] @@ -48,7 +53,7 @@ pub trait StateApi { &self, prefix: StorageKey, hash: Option, - ) -> RpcResult>; + ) -> Result, Error>; /// Returns the keys with prefix with pagination support. /// Up to `count` keys will be returned. @@ -60,27 +65,28 @@ pub trait StateApi { count: u32, start_key: Option, hash: Option, - ) -> RpcResult>; + ) -> Result, Error>; /// Returns a storage entry at a specific block's state. #[method(name = "state_getStorage", aliases = ["state_getStorageAt"], blocking)] - fn storage(&self, key: StorageKey, hash: Option) -> RpcResult>; + fn storage(&self, key: StorageKey, hash: Option) -> Result, Error>; /// Returns the hash of a storage entry at a block's state. #[method(name = "state_getStorageHash", aliases = ["state_getStorageHashAt"], blocking)] - fn storage_hash(&self, key: StorageKey, hash: Option) -> RpcResult>; + fn storage_hash(&self, key: StorageKey, hash: Option) -> Result, Error>; /// Returns the size of a storage entry at a block's state. #[method(name = "state_getStorageSize", aliases = ["state_getStorageSizeAt"])] - async fn storage_size(&self, key: StorageKey, hash: Option) -> RpcResult>; + async fn storage_size(&self, key: StorageKey, hash: Option) + -> Result, Error>; /// Returns the runtime metadata as an opaque blob. #[method(name = "state_getMetadata", blocking)] - fn metadata(&self, hash: Option) -> RpcResult; + fn metadata(&self, hash: Option) -> Result; /// Get the runtime version. #[method(name = "state_getRuntimeVersion", aliases = ["chain_getRuntimeVersion"], blocking)] - fn runtime_version(&self, hash: Option) -> RpcResult; + fn runtime_version(&self, hash: Option) -> Result; /// Query historical storage entries (by key) starting from a block given as the second /// parameter. @@ -95,7 +101,7 @@ pub trait StateApi { keys: Vec, block: Hash, hash: Option, - ) -> RpcResult>>; + ) -> Result>, Error>; /// Query storage entries (by key) at a block hash given as the second parameter. /// NOTE: Each StorageChangeSet in the result corresponds to exactly one element -- @@ -105,11 +111,15 @@ pub trait StateApi { &self, keys: Vec, at: Option, - ) -> RpcResult>>; + ) -> Result>, Error>; /// Returns proof of storage entries at a specific block's state. #[method(name = "state_getReadProof", blocking)] - fn read_proof(&self, keys: Vec, hash: Option) -> RpcResult>; + fn read_proof( + &self, + keys: Vec, + hash: Option, + ) -> Result, Error>; /// New runtime version subscription #[subscription( @@ -288,5 +298,5 @@ pub trait StateApi { targets: Option, storage_keys: Option, methods: Option, - ) -> RpcResult; + ) -> Result; } diff --git a/substrate/client/rpc-api/src/statement/error.rs b/substrate/client/rpc-api/src/statement/error.rs index 8438cc3ec9e9..f8041864faca 100644 --- a/substrate/client/rpc-api/src/statement/error.rs +++ b/substrate/client/rpc-api/src/statement/error.rs @@ -18,10 +18,7 @@ //! Statement RPC errors. -use jsonrpsee::{ - core::Error as JsonRpseeError, - types::error::{CallError, ErrorObject}, -}; +use jsonrpsee::types::error::{ErrorObject, ErrorObjectOwned}; /// Statement RPC Result type. pub type Result = std::result::Result; @@ -40,15 +37,14 @@ pub enum Error { /// Base error code for all statement errors. const BASE_ERROR: i32 = crate::error::base::STATEMENT; -impl From for JsonRpseeError { +impl From for ErrorObjectOwned { fn from(e: Error) -> Self { match e { - Error::StatementStore(message) => CallError::Custom(ErrorObject::owned( + Error::StatementStore(message) => ErrorObject::owned( BASE_ERROR + 1, format!("Statement store error: {message}"), None::<()>, - )) - .into(), + ), Error::UnsafeRpcCalled(e) => e.into(), } } diff --git a/substrate/client/rpc-api/src/system/error.rs b/substrate/client/rpc-api/src/system/error.rs index 713ade9210d3..1e826a75ae62 100644 --- a/substrate/client/rpc-api/src/system/error.rs +++ b/substrate/client/rpc-api/src/system/error.rs @@ -19,9 +19,9 @@ //! System RPC module errors. use crate::system::helpers::Health; -use jsonrpsee::{ - core::Error as JsonRpseeError, - types::error::{CallError, ErrorObject}, +use jsonrpsee::types::{ + error::{ErrorCode, ErrorObject}, + ErrorObjectOwned, }; /// System RPC Result type. @@ -36,6 +36,12 @@ pub enum Error { /// Peer argument is malformatted. #[error("{0}")] MalformattedPeerArg(String), + /// Call to an unsafe RPC was denied. + #[error(transparent)] + UnsafeRpcCalled(#[from] crate::policy::UnsafeRpcError), + /// Internal error. + #[error("{0}")] + Internal(String), } // Base code for all system errors. @@ -45,17 +51,16 @@ const NOT_HEALTHY_ERROR: i32 = BASE_ERROR + 1; // Peer argument is malformatted. const MALFORMATTED_PEER_ARG_ERROR: i32 = BASE_ERROR + 2; -impl From for JsonRpseeError { - fn from(e: Error) -> Self { +impl From for ErrorObjectOwned { + fn from(e: Error) -> ErrorObjectOwned { match e { Error::NotHealthy(ref h) => - CallError::Custom(ErrorObject::owned(NOT_HEALTHY_ERROR, e.to_string(), Some(h))), - Error::MalformattedPeerArg(e) => CallError::Custom(ErrorObject::owned( - MALFORMATTED_PEER_ARG_ERROR + 2, - e, - None::<()>, - )), + ErrorObject::owned(NOT_HEALTHY_ERROR, e.to_string(), Some(h)), + Error::MalformattedPeerArg(e) => + ErrorObject::owned(MALFORMATTED_PEER_ARG_ERROR, e, None::<()>), + Error::UnsafeRpcCalled(e) => e.into(), + Error::Internal(e) => + ErrorObjectOwned::owned(ErrorCode::InternalError.code(), e, None::<()>), } - .into() } } diff --git a/substrate/client/rpc-api/src/system/helpers.rs b/substrate/client/rpc-api/src/system/helpers.rs index ad56dc385009..ed642e0679eb 100644 --- a/substrate/client/rpc-api/src/system/helpers.rs +++ b/substrate/client/rpc-api/src/system/helpers.rs @@ -38,7 +38,7 @@ pub struct SystemInfo { } /// Health struct returned by the RPC -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct Health { /// Number of connected peers @@ -58,7 +58,7 @@ impl fmt::Display for Health { } /// Network Peer information -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct PeerInfo { /// Peer ID @@ -72,7 +72,7 @@ pub struct PeerInfo { } /// The role the node is running as -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] pub enum NodeRole { /// The node is a full node Full, @@ -81,7 +81,7 @@ pub enum NodeRole { } /// The state of the syncing of the node. -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct SyncState { /// Height of the block at which syncing started. diff --git a/substrate/client/rpc-api/src/system/mod.rs b/substrate/client/rpc-api/src/system/mod.rs index bf2e92bc27a0..c38fa8f3d817 100644 --- a/substrate/client/rpc-api/src/system/mod.rs +++ b/substrate/client/rpc-api/src/system/mod.rs @@ -18,38 +18,36 @@ //! Substrate system API. -use jsonrpsee::{ - core::{JsonValue, RpcResult}, - proc_macros::rpc, -}; - -pub use self::helpers::{Health, NodeRole, PeerInfo, SyncState, SystemInfo}; - pub mod error; pub mod helpers; +use jsonrpsee::{core::JsonValue, proc_macros::rpc}; + +pub use self::helpers::{Health, NodeRole, PeerInfo, SyncState, SystemInfo}; +pub use error::Error; + /// Substrate system RPC API #[rpc(client, server)] pub trait SystemApi { /// Get the node's implementation name. Plain old string. #[method(name = "system_name")] - fn system_name(&self) -> RpcResult; + fn system_name(&self) -> Result; /// Get the node implementation's version. Should be a semver string. #[method(name = "system_version")] - fn system_version(&self) -> RpcResult; + fn system_version(&self) -> Result; /// Get the chain's name. Given as a string identifier. #[method(name = "system_chain")] - fn system_chain(&self) -> RpcResult; + fn system_chain(&self) -> Result; /// Get the chain's type. #[method(name = "system_chainType")] - fn system_type(&self) -> RpcResult; + fn system_type(&self) -> Result; /// Get a custom set of properties as a JSON object, defined in the chain spec. #[method(name = "system_properties")] - fn system_properties(&self) -> RpcResult; + fn system_properties(&self) -> Result; /// Return health status of the node. /// @@ -57,22 +55,22 @@ pub trait SystemApi { /// - connected to some peers (unless running in dev mode) /// - not performing a major sync #[method(name = "system_health")] - async fn system_health(&self) -> RpcResult; + async fn system_health(&self) -> Result; /// Returns the base58-encoded PeerId of the node. #[method(name = "system_localPeerId")] - async fn system_local_peer_id(&self) -> RpcResult; + async fn system_local_peer_id(&self) -> Result; /// Returns the multi-addresses that the local node is listening on /// /// The addresses include a trailing `/p2p/` with the local PeerId, and are thus suitable to /// be passed to `addReservedPeer` or as a bootnode address for example. #[method(name = "system_localListenAddresses")] - async fn system_local_listen_addresses(&self) -> RpcResult>; + async fn system_local_listen_addresses(&self) -> Result, Error>; /// Returns currently connected peers #[method(name = "system_peers")] - async fn system_peers(&self) -> RpcResult>>; + async fn system_peers(&self) -> Result>, Error>; /// Returns current state of the network. /// @@ -81,7 +79,7 @@ pub trait SystemApi { // TODO: the future of this call is uncertain: https://github.com/paritytech/substrate/issues/1890 // https://github.com/paritytech/substrate/issues/5541 #[method(name = "system_unstable_networkState")] - async fn system_network_state(&self) -> RpcResult; + async fn system_network_state(&self) -> Result; /// Adds a reserved peer. Returns the empty string or an error. The string /// parameter should encode a `p2p` multiaddr. @@ -89,25 +87,25 @@ pub trait SystemApi { /// `/ip4/198.51.100.19/tcp/30333/p2p/QmSk5HQbn6LhUwDiNMseVUjuRYhEtYj4aUZ6WfWoGURpdV` /// is an example of a valid, passing multiaddr with PeerId attached. #[method(name = "system_addReservedPeer")] - async fn system_add_reserved_peer(&self, peer: String) -> RpcResult<()>; + async fn system_add_reserved_peer(&self, peer: String) -> Result<(), Error>; /// Remove a reserved peer. Returns the empty string or an error. The string /// should encode only the PeerId e.g. `QmSk5HQbn6LhUwDiNMseVUjuRYhEtYj4aUZ6WfWoGURpdV`. #[method(name = "system_removeReservedPeer")] - async fn system_remove_reserved_peer(&self, peer_id: String) -> RpcResult<()>; + async fn system_remove_reserved_peer(&self, peer_id: String) -> Result<(), Error>; /// Returns the list of reserved peers #[method(name = "system_reservedPeers")] - async fn system_reserved_peers(&self) -> RpcResult>; + async fn system_reserved_peers(&self) -> Result, Error>; /// Returns the roles the node is running as. #[method(name = "system_nodeRoles")] - async fn system_node_roles(&self) -> RpcResult>; + async fn system_node_roles(&self) -> Result, Error>; /// Returns the state of the syncing of the node: starting block, current best block, highest /// known block. #[method(name = "system_syncState")] - async fn system_sync_state(&self) -> RpcResult>; + async fn system_sync_state(&self) -> Result, Error>; /// Adds the supplied directives to the current log filter /// @@ -115,9 +113,9 @@ pub trait SystemApi { /// /// `sync=debug,state=trace` #[method(name = "system_addLogFilter")] - fn system_add_log_filter(&self, directives: String) -> RpcResult<()>; + fn system_add_log_filter(&self, directives: String) -> Result<(), Error>; /// Resets the log filter to Substrate defaults #[method(name = "system_resetLogFilter")] - fn system_reset_log_filter(&self) -> RpcResult<()>; + fn system_reset_log_filter(&self) -> Result<(), Error>; } diff --git a/substrate/client/rpc-servers/Cargo.toml b/substrate/client/rpc-servers/Cargo.toml index 60d999863cab..5b5610837ae9 100644 --- a/substrate/client/rpc-servers/Cargo.toml +++ b/substrate/client/rpc-servers/Cargo.toml @@ -16,11 +16,11 @@ workspace = true targets = ["x86_64-unknown-linux-gnu"] [dependencies] -jsonrpsee = { version = "0.16.2", features = ["server"] } +jsonrpsee = { version = "0.20.3", features = ["server"] } log = "0.4.17" serde_json = "1.0.111" tokio = { version = "1.22.0", features = ["parking_lot"] } prometheus-endpoint = { package = "substrate-prometheus-endpoint", path = "../../utils/prometheus" } tower-http = { version = "0.4.0", features = ["cors"] } -tower = "0.4.13" +tower = { version = "0.4.13", features = ["util"] } http = "0.2.8" diff --git a/substrate/client/rpc-servers/src/lib.rs b/substrate/client/rpc-servers/src/lib.rs index dc625c3d6c4c..5d8da190f627 100644 --- a/substrate/client/rpc-servers/src/lib.rs +++ b/substrate/client/rpc-servers/src/lib.rs @@ -22,15 +22,14 @@ pub mod middleware; +use std::{error::Error as StdError, net::SocketAddr, time::Duration}; + use http::header::HeaderValue; use jsonrpsee::{ - server::{ - middleware::proxy_get_request::ProxyGetRequestLayer, AllowHosts, ServerBuilder, - ServerHandle, - }, + server::middleware::{HostFilterLayer, ProxyGetRequestLayer}, RpcModule, }; -use std::{error::Error as StdError, net::SocketAddr}; +use tokio::net::TcpListener; use tower_http::cors::{AllowOrigin, CorsLayer}; pub use crate::middleware::RpcMetrics; @@ -42,7 +41,7 @@ pub use jsonrpsee::core::{ const MEGABYTE: u32 = 1024 * 1024; /// Type alias for the JSON-RPC server. -pub type Server = ServerHandle; +pub type Server = jsonrpsee::server::ServerHandle; /// RPC server configuration. #[derive(Debug)] @@ -61,6 +60,8 @@ pub struct Config<'a, M: Send + Sync + 'static> { pub max_payload_out_mb: u32, /// Metrics. pub metrics: Option, + /// Message buffer size + pub message_buffer_capacity: u32, /// RPC API. pub rpc_api: RpcModule, /// Subscription ID provider. @@ -72,7 +73,7 @@ pub struct Config<'a, M: Send + Sync + 'static> { /// Start RPC server listening on given address. pub async fn start_server( config: Config<'_, M>, -) -> Result> { +) -> Result> { let Config { addrs, cors, @@ -81,26 +82,30 @@ pub async fn start_server( max_connections, max_subs_per_conn, metrics, + message_buffer_capacity, id_provider, tokio_handle, rpc_api, } = config; - let host_filter = hosts_filtering(cors.is_some(), &addrs); + let std_listener = TcpListener::bind(addrs.as_slice()).await?.into_std()?; + let local_addr = std_listener.local_addr().ok(); + let host_filter = hosts_filtering(cors.is_some(), local_addr); let middleware = tower::ServiceBuilder::new() + .option_layer(host_filter) // Proxy `GET /health` requests to internal `system_health` method. .layer(ProxyGetRequestLayer::new("/health", "system_health")?) .layer(try_into_cors(cors)?); - let mut builder = ServerBuilder::new() + let mut builder = jsonrpsee::server::Server::builder() .max_request_body_size(max_payload_in_mb.saturating_mul(MEGABYTE)) .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(std::time::Duration::from_secs(30)) - .set_host_filtering(host_filter) + .ping_interval(Duration::from_secs(30)) .set_middleware(middleware) + .set_message_buffer_capacity(message_buffer_capacity) .custom_tokio_runtime(tokio_handle); if let Some(provider) = id_provider { @@ -110,36 +115,34 @@ pub async fn start_server( }; let rpc_api = build_rpc_api(rpc_api); - let (handle, addr) = if let Some(metrics) = metrics { - let server = builder.set_logger(metrics).build(&addrs[..]).await?; - let addr = server.local_addr(); - (server.start(rpc_api)?, addr) + 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(&addrs[..]).await?; - let addr = server.local_addr(); - (server.start(rpc_api)?, addr) + let server = builder.build_from_tcp(std_listener)?; + server.start(rpc_api) }; log::info!( "Running JSON-RPC server: addr={}, allowed origins={}", - addr.map_or_else(|_| "unknown".to_string(), |a| a.to_string()), + local_addr.map_or_else(|| "unknown".to_string(), |a| a.to_string()), format_cors(cors) ); Ok(handle) } -fn hosts_filtering(enabled: bool, addrs: &[SocketAddr]) -> AllowHosts { +fn hosts_filtering(enabled: bool, addr: Option) -> Option { + // If the local_addr failed, fallback to wildcard. + let port = addr.map_or("*".to_string(), |p| p.port().to_string()); + if enabled { - // NOTE The listening addresses are whitelisted by default. - let mut hosts = Vec::with_capacity(addrs.len() * 2); - for addr in addrs { - hosts.push(format!("localhost:{}", addr.port()).into()); - hosts.push(format!("127.0.0.1:{}", addr.port()).into()); - } - AllowHosts::Only(hosts) + // NOTE: The listening addresses are whitelisted by default. + let hosts = + [format!("localhost:{port}"), format!("127.0.0.1:{port}"), format!("[::1]:{port}")]; + Some(HostFilterLayer::new(hosts).expect("Valid hosts; qed")) } else { - AllowHosts::Any + None } } @@ -151,9 +154,9 @@ fn build_rpc_api(mut rpc_api: RpcModule) -> RpcModu rpc_api .register_method("rpc_methods", move |_, _| { - Ok(serde_json::json!({ + serde_json::json!({ "methods": available_methods, - })) + }) }) .expect("infallible all other methods have their own address space; qed"); diff --git a/substrate/client/rpc-servers/src/middleware.rs b/substrate/client/rpc-servers/src/middleware.rs index c3e17c7852f1..fabb64eafa79 100644 --- a/substrate/client/rpc-servers/src/middleware.rs +++ b/substrate/client/rpc-servers/src/middleware.rs @@ -18,7 +18,9 @@ //! RPC middleware to collect prometheus metrics on RPC calls. -use jsonrpsee::server::logger::{HttpRequest, Logger, MethodKind, Params, TransportProtocol}; +use jsonrpsee::server::logger::{ + HttpRequest, Logger, MethodKind, Params, SuccessOrError, TransportProtocol, +}; use prometheus_endpoint::{ register, Counter, CounterVec, HistogramOpts, HistogramVec, Opts, PrometheusError, Registry, U64, @@ -176,7 +178,7 @@ impl Logger for RpcMetrics { fn on_result( &self, name: &str, - success: bool, + success_or_error: SuccessOrError, started_at: Self::Instant, transport: TransportProtocol, ) { @@ -197,7 +199,7 @@ impl Logger for RpcMetrics { name, // the label "is_error", so `success` should be regarded as false // and vice-versa to be registrered correctly. - if success { "false" } else { "true" }, + if success_or_error.is_success() { "false" } else { "true" }, ]) .inc(); } diff --git a/substrate/client/rpc-spec-v2/Cargo.toml b/substrate/client/rpc-spec-v2/Cargo.toml index 17412f883ca1..e665ddd4f6bc 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.16.2", features = ["client-core", "macros", "server"] } +jsonrpsee = { version = "0.20.3", features = ["client-core", "macros", "server"] } # Internal chain structures for "chain_spec". sc-chain-spec = { path = "../chain-spec" } # Pool for submitting extrinsics required by "transaction" @@ -29,6 +29,7 @@ sp-blockchain = { path = "../../primitives/blockchain" } sp-version = { path = "../../primitives/version" } sc-client-api = { path = "../api" } sc-utils = { path = "../utils" } +sc-rpc = { path = "../rpc" } codec = { package = "parity-scale-codec", version = "3.6.1" } thiserror = "1.0" serde = "1.0" diff --git a/substrate/client/rpc-spec-v2/src/archive/error.rs b/substrate/client/rpc-spec-v2/src/archive/error.rs index b858212399ce..d631c3fb8e89 100644 --- a/substrate/client/rpc-spec-v2/src/archive/error.rs +++ b/substrate/client/rpc-spec-v2/src/archive/error.rs @@ -18,10 +18,7 @@ //! Error helpers for `archive` RPC module. -use jsonrpsee::{ - core::Error as RpcError, - types::error::{CallError, ErrorObject}, -}; +use jsonrpsee::types::error::ErrorObject; /// ChainHead RPC errors. #[derive(Debug, thiserror::Error)] @@ -58,9 +55,3 @@ impl From for ErrorObject<'static> { .into() } } - -impl From for RpcError { - fn from(e: Error) -> Self { - CallError::Custom(e.into()).into() - } -} diff --git a/substrate/client/rpc-spec-v2/src/archive/tests.rs b/substrate/client/rpc-spec-v2/src/archive/tests.rs index 45da8e588e62..108395eb91a7 100644 --- a/substrate/client/rpc-spec-v2/src/archive/tests.rs +++ b/substrate/client/rpc-spec-v2/src/archive/tests.rs @@ -29,10 +29,8 @@ use super::{archive::Archive, *}; use assert_matches::assert_matches; use codec::{Decode, Encode}; use jsonrpsee::{ - core::error::Error, - rpc_params, - types::{error::CallError, EmptyServerParams as EmptyParams}, - RpcModule, + core::{EmptyServerParams as EmptyParams, Error}, + rpc_params, RpcModule, }; use sc_block_builder::BlockBuilderBuilder; use sc_client_api::ChildInfo; @@ -289,7 +287,7 @@ async fn archive_call() { ) .await .unwrap_err(); - assert_matches!(err, Error::Call(CallError::Custom(ref err)) if err.code() == 3001 && err.message().contains("Invalid parameter")); + assert_matches!(err, Error::Call(err) if err.code() == 3001 && err.message().contains("Invalid parameter")); // Pass an invalid parameters that cannot be decode. let err = api @@ -300,7 +298,7 @@ async fn archive_call() { ) .await .unwrap_err(); - assert_matches!(err, Error::Call(CallError::Custom(ref err)) if err.code() == 3001 && err.message().contains("Invalid parameter")); + assert_matches!(err, Error::Call(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/api.rs b/substrate/client/rpc-spec-v2/src/chain_head/api.rs index 3d6091b91bd2..7c3b8d81c82a 100644 --- a/substrate/client/rpc-spec-v2/src/chain_head/api.rs +++ b/substrate/client/rpc-spec-v2/src/chain_head/api.rs @@ -20,10 +20,13 @@ //! API trait of the chain head. use crate::{ - chain_head::event::{FollowEvent, MethodResponse}, + chain_head::{ + error::Error, + event::{FollowEvent, MethodResponse}, + }, common::events::StorageQuery, }; -use jsonrpsee::{core::RpcResult, proc_macros::rpc}; +use jsonrpsee::proc_macros::rpc; use sp_rpc::list::ListOrValue; #[rpc(client, server)] @@ -56,7 +59,7 @@ pub trait ChainHeadApi { &self, follow_subscription: String, hash: Hash, - ) -> RpcResult; + ) -> Result; /// Retrieves the header of a pinned block. /// @@ -75,7 +78,7 @@ pub trait ChainHeadApi { &self, follow_subscription: String, hash: Hash, - ) -> RpcResult>; + ) -> Result, Error>; /// Returns storage entries at a specific block's state. /// @@ -89,7 +92,7 @@ pub trait ChainHeadApi { hash: Hash, items: Vec>, child_trie: Option, - ) -> RpcResult; + ) -> Result; /// Call into the Runtime API at a specified block's state. /// @@ -103,7 +106,7 @@ pub trait ChainHeadApi { hash: Hash, function: String, call_parameters: String, - ) -> RpcResult; + ) -> Result; /// Unpin a block or multiple blocks reported by the `follow` method. /// @@ -120,7 +123,7 @@ pub trait ChainHeadApi { &self, follow_subscription: String, hash_or_hashes: ListOrValue, - ) -> RpcResult<()>; + ) -> Result<(), Error>; /// Resumes a storage fetch started with `chainHead_storage` after it has generated an /// `operationWaitingForContinue` event. @@ -133,7 +136,7 @@ pub trait ChainHeadApi { &self, follow_subscription: String, operation_id: String, - ) -> RpcResult<()>; + ) -> Result<(), Error>; /// Stops an operation started with chainHead_unstable_body, chainHead_unstable_call, or /// chainHead_unstable_storage. If the operation was still in progress, this interrupts it. If @@ -147,5 +150,5 @@ pub trait ChainHeadApi { &self, follow_subscription: String, operation_id: String, - ) -> RpcResult<()>; + ) -> Result<(), Error>; } 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 6e4d6ade9659..0e207addcaeb 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,15 +36,14 @@ use crate::{ use codec::Encode; use futures::future::FutureExt; use jsonrpsee::{ - core::{async_trait, RpcResult}, - types::{SubscriptionEmptyError, SubscriptionId, SubscriptionResult}, - SubscriptionSink, + core::async_trait, types::SubscriptionId, PendingSubscriptionSink, SubscriptionSink, }; use log::debug; use sc_client_api::{ Backend, BlockBackend, BlockchainEvents, CallExecutor, ChildInfo, ExecutorProvider, StorageKey, StorageProvider, }; +use sc_rpc::utils::to_sub_message; use sp_api::CallApiAt; use sp_blockchain::{Error as BlockChainError, HeaderBackend, HeaderMetadata}; use sp_core::{traits::CallContext, Bytes}; @@ -136,27 +135,13 @@ impl, Block: BlockT, Client> ChainHead { _phantom: PhantomData, } } +} - /// Accept the subscription and return the subscription ID on success. - fn accept_subscription( - &self, - sink: &mut SubscriptionSink, - ) -> Result { - // The subscription must be accepted before it can provide a valid subscription ID. - sink.accept()?; - - let Some(sub_id) = sink.subscription_id() else { - // This can only happen if the subscription was not accepted. - return Err(SubscriptionEmptyError) - }; - - // Get the string representation for the subscription. - let sub_id = match sub_id { - SubscriptionId::Num(num) => num.to_string(), - SubscriptionId::Str(id) => id.into_owned().into(), - }; - - Ok(sub_id) +/// Helper to convert the `subscription ID` to a string. +pub fn read_subscription_id_as_string(sink: &SubscriptionSink) -> String { + match sink.subscription_id() { + SubscriptionId::Num(n) => n.to_string(), + SubscriptionId::Str(s) => s.into_owned().into(), } } @@ -190,35 +175,28 @@ where + StorageProvider + 'static, { - fn chain_head_unstable_follow( - &self, - mut sink: SubscriptionSink, - with_runtime: bool, - ) -> SubscriptionResult { - let sub_id = match self.accept_subscription(&mut sink) { - Ok(sub_id) => sub_id, - Err(err) => { - sink.close(ChainHeadRpcError::InternalError( - "Cannot generate subscription ID".into(), - )); - return Err(err) - }, - }; - // Keep track of the subscription. - let Some(sub_data) = self.subscriptions.insert_subscription(sub_id.clone(), with_runtime) - else { - // Inserting the subscription can only fail if the JsonRPSee - // generated a duplicate subscription ID. - debug!(target: LOG_TARGET, "[follow][id={:?}] Subscription already accepted", sub_id); - let _ = sink.send(&FollowEvent::::Stop); - return Ok(()) - }; - debug!(target: LOG_TARGET, "[follow][id={:?}] Subscription accepted", sub_id); - + fn chain_head_unstable_follow(&self, pending: PendingSubscriptionSink, with_runtime: bool) { let subscriptions = self.subscriptions.clone(); let backend = self.backend.clone(); let client = self.client.clone(); + let fut = async move { + let Ok(sink) = pending.accept().await else { return }; + + let sub_id = read_subscription_id_as_string(&sink); + + // Keep track of the subscription. + let Some(sub_data) = subscriptions.insert_subscription(sub_id.clone(), with_runtime) + else { + // Inserting the subscription can only fail if the JsonRPSee + // generated a duplicate subscription ID. + debug!(target: LOG_TARGET, "[follow][id={:?}] Subscription already accepted", sub_id); + let msg = to_sub_message(&sink, &FollowEvent::::Stop); + let _ = sink.send(msg).await; + return + }; + debug!(target: LOG_TARGET, "[follow][id={:?}] Subscription accepted", sub_id); + let mut chain_head_follow = ChainHeadFollower::new( client, backend, @@ -234,14 +212,13 @@ where }; self.executor.spawn("substrate-rpc-subscription", Some("rpc"), fut.boxed()); - Ok(()) } fn chain_head_unstable_body( &self, follow_subscription: String, hash: Block::Hash, - ) -> RpcResult { + ) -> Result { let mut block_guard = match self.subscriptions.lock_block(&follow_subscription, hash, 1) { Ok(block) => block, Err(SubscriptionManagementError::SubscriptionAbsent) | @@ -293,7 +270,7 @@ where &self, follow_subscription: String, hash: Block::Hash, - ) -> RpcResult> { + ) -> Result, ChainHeadRpcError> { let _block_guard = match self.subscriptions.lock_block(&follow_subscription, hash, 1) { Ok(block) => block, Err(SubscriptionManagementError::SubscriptionAbsent) | @@ -309,7 +286,6 @@ where .header(hash) .map(|opt_header| opt_header.map(|h| hex_string(&h.encode()))) .map_err(|err| ChainHeadRpcError::InternalError(err.to_string())) - .map_err(Into::into) } fn chain_head_unstable_storage( @@ -318,7 +294,7 @@ where hash: Block::Hash, items: Vec>, child_trie: Option, - ) -> RpcResult { + ) -> Result { // Gain control over parameter parsing and returned error. let items = items .into_iter() @@ -376,7 +352,7 @@ where hash: Block::Hash, function: String, call_parameters: String, - ) -> RpcResult { + ) -> Result { let call_parameters = Bytes::from(parse_hex_param(call_parameters)?); let mut block_guard = match self.subscriptions.lock_block(&follow_subscription, hash, 1) { @@ -420,14 +396,17 @@ where }); let _ = block_guard.response_sender().unbounded_send(event); - Ok(MethodResponse::Started(MethodResponseStarted { operation_id, discarded_items: None })) + Ok(MethodResponse::Started(MethodResponseStarted { + operation_id: operation_id.clone(), + discarded_items: None, + })) } fn chain_head_unstable_unpin( &self, follow_subscription: String, hash_or_hashes: ListOrValue, - ) -> RpcResult<()> { + ) -> Result<(), ChainHeadRpcError> { let result = match hash_or_hashes { ListOrValue::Value(hash) => self.subscriptions.unpin_blocks(&follow_subscription, [hash]), @@ -443,9 +422,9 @@ where }, Err(SubscriptionManagementError::BlockHashAbsent) => { // Block is not part of the subscription. - Err(ChainHeadRpcError::InvalidBlock.into()) + Err(ChainHeadRpcError::InvalidBlock) }, - Err(_) => Err(ChainHeadRpcError::InvalidBlock.into()), + Err(_) => Err(ChainHeadRpcError::InvalidBlock), } } @@ -453,7 +432,7 @@ where &self, follow_subscription: String, operation_id: String, - ) -> RpcResult<()> { + ) -> Result<(), ChainHeadRpcError> { let Some(operation) = self.subscriptions.get_operation(&follow_subscription, &operation_id) else { return Ok(()) @@ -471,7 +450,7 @@ where &self, follow_subscription: String, operation_id: String, - ) -> RpcResult<()> { + ) -> Result<(), ChainHeadRpcError> { let Some(operation) = self.subscriptions.get_operation(&follow_subscription, &operation_id) else { return Ok(()) diff --git a/substrate/client/rpc-spec-v2/src/chain_head/chain_head_follow.rs b/substrate/client/rpc-spec-v2/src/chain_head/chain_head_follow.rs index b981e69f2e47..e94374aebd91 100644 --- a/substrate/client/rpc-spec-v2/src/chain_head/chain_head_follow.rs +++ b/substrate/client/rpc-spec-v2/src/chain_head/chain_head_follow.rs @@ -24,7 +24,7 @@ use crate::chain_head::{ BestBlockChanged, Finalized, FollowEvent, Initialized, NewBlock, RuntimeEvent, RuntimeVersionEvent, }, - subscription::{InsertedSubscriptionData, SubscriptionManagement, SubscriptionManagementError}, + subscription::{SubscriptionManagement, SubscriptionManagementError}, }; use futures::{ channel::oneshot, @@ -36,6 +36,7 @@ use log::{debug, error}; use sc_client_api::{ Backend, BlockBackend, BlockImportNotification, BlockchainEvents, FinalityNotification, }; +use sc_rpc::utils::to_sub_message; use sp_api::CallApiAt; use sp_blockchain::{ Backend as BlockChainBackend, Error as BlockChainError, HeaderBackend, HeaderMetadata, Info, @@ -43,6 +44,8 @@ use sp_blockchain::{ use sp_runtime::traits::{Block as BlockT, Header as HeaderT, NumberFor}; use std::{collections::HashSet, sync::Arc}; +use super::subscription::InsertedSubscriptionData; + /// Generates the events of the `chainHead_follow` method. pub struct ChainHeadFollower, Block: BlockT, Client> { /// Substrate client. @@ -500,7 +503,7 @@ where startup_point: &StartupPoint, mut stream: EventStream, mut to_ignore: HashSet, - mut sink: SubscriptionSink, + sink: SubscriptionSink, rx_stop: oneshot::Receiver<()>, ) where EventStream: Stream> + Unpin, @@ -529,35 +532,23 @@ where self.sub_id, err ); - let _ = sink.send(&FollowEvent::::Stop); + let msg = to_sub_message(&sink, &FollowEvent::::Stop); + let _ = sink.send(msg).await; return }, }; for event in events { - let result = sink.send(&event); - - // Migration note: the new version of jsonrpsee returns Result<(), DisconnectError> - // The logic from `Err(err)` should be moved when building the new - // `SubscriptionMessage`. - - // For now, jsonrpsee returns: - // Ok(true): message sent - // Ok(false): client disconnected or subscription closed - // Err(err): serder serialization error of the event - if let Err(err) = result { + let msg = to_sub_message(&sink, &event); + if let Err(err) = sink.send(msg).await { // Failed to submit event. debug!( target: LOG_TARGET, "[follow][id={:?}] Failed to send event {:?}", self.sub_id, err ); - let _ = sink.send(&FollowEvent::::Stop); - return - } - - if let Ok(false) = result { - // Client disconnected or subscription was closed. + let msg = to_sub_message(&sink, &FollowEvent::::Stop); + let _ = sink.send(msg).await; return } } @@ -568,13 +559,14 @@ where // If we got here either the substrate streams have closed // or the `Stop` receiver was triggered. - let _ = sink.send(&FollowEvent::::Stop); + let msg = to_sub_message(&sink, &FollowEvent::::Stop); + let _ = sink.send(msg).await; } /// Generate the block events for the `chainHead_follow` method. pub async fn generate_events( &mut self, - mut sink: SubscriptionSink, + sink: SubscriptionSink, sub_data: InsertedSubscriptionData, ) { // Register for the new block and finalized notifications. @@ -602,7 +594,8 @@ where self.sub_id, err ); - let _ = sink.send(&FollowEvent::::Stop); + let msg = to_sub_message(&sink, &FollowEvent::::Stop); + let _ = sink.send(msg).await; return }, }; diff --git a/substrate/client/rpc-spec-v2/src/chain_head/error.rs b/substrate/client/rpc-spec-v2/src/chain_head/error.rs index a9b7d7f96e49..bf290edb29ee 100644 --- a/substrate/client/rpc-spec-v2/src/chain_head/error.rs +++ b/substrate/client/rpc-spec-v2/src/chain_head/error.rs @@ -18,10 +18,7 @@ //! Error helpers for `chainHead` RPC module. -use jsonrpsee::{ - core::Error as RpcError, - types::error::{CallError, ErrorObject}, -}; +use jsonrpsee::types::error::ErrorObject; /// ChainHead RPC errors. #[derive(Debug, thiserror::Error)] @@ -81,9 +78,3 @@ impl From for ErrorObject<'static> { } } } - -impl From for RpcError { - fn from(e: Error) -> Self { - CallError::Custom(e.into()).into() - } -} 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 4859793a8e2f..955a361e3ead 100644 --- a/substrate/client/rpc-spec-v2/src/chain_head/tests.rs +++ b/substrate/client/rpc-spec-v2/src/chain_head/tests.rs @@ -27,10 +27,8 @@ use assert_matches::assert_matches; use codec::{Decode, Encode}; use futures::Future; use jsonrpsee::{ - core::{error::Error, server::rpc_module::Subscription as RpcSubscription}, - rpc_params, - types::error::CallError, - RpcModule, + core::{error::Error, server::Subscription as RpcSubscription}, + rpc_params, RpcModule, }; use sc_block_builder::BlockBuilderBuilder; use sc_client_api::ChildInfo; @@ -120,7 +118,7 @@ async fn setup_api() -> ( ) .into_rpc(); - let mut sub = api.subscribe("chainHead_unstable_follow", [true]).await.unwrap(); + let mut sub = api.subscribe_unbounded("chainHead_unstable_follow", [true]).await.unwrap(); let sub_id = sub.subscription_id(); let sub_id = serde_json::to_string(&sub_id).unwrap(); @@ -171,7 +169,7 @@ async fn follow_subscription_produces_blocks() { .into_rpc(); let finalized_hash = client.info().finalized_hash; - let mut sub = api.subscribe("chainHead_unstable_follow", [false]).await.unwrap(); + let mut sub = api.subscribe_unbounded("chainHead_unstable_follow", [false]).await.unwrap(); // Initialized must always be reported first. let event: FollowEvent = get_next_event(&mut sub).await; @@ -239,7 +237,7 @@ async fn follow_with_runtime() { .into_rpc(); let finalized_hash = client.info().finalized_hash; - let mut sub = api.subscribe("chainHead_unstable_follow", [true]).await.unwrap(); + let mut sub = api.subscribe_unbounded("chainHead_unstable_follow", [true]).await.unwrap(); // Initialized must always be reported first. let event: FollowEvent = get_next_event(&mut sub).await; @@ -361,7 +359,7 @@ async fn get_header() { .await .unwrap_err(); assert_matches!(err, - Error::Call(CallError::Custom(ref err)) if err.code() == super::error::rpc_spec_v2::INVALID_BLOCK_ERROR && err.message() == "Invalid block hash" + Error::Call(err) if err.code() == super::error::rpc_spec_v2::INVALID_BLOCK_ERROR && err.message() == "Invalid block hash" ); // Obtain the valid header. @@ -390,7 +388,7 @@ async fn get_body() { .await .unwrap_err(); assert_matches!(err, - Error::Call(CallError::Custom(ref err)) if err.code() == super::error::rpc_spec_v2::INVALID_BLOCK_ERROR && err.message() == "Invalid block hash" + Error::Call(err) if err.code() == super::error::rpc_spec_v2::INVALID_BLOCK_ERROR && err.message() == "Invalid block hash" ); // Valid call. @@ -475,7 +473,7 @@ async fn call_runtime() { .await .unwrap_err(); assert_matches!(err, - Error::Call(CallError::Custom(ref err)) if err.code() == super::error::rpc_spec_v2::INVALID_BLOCK_ERROR && err.message() == "Invalid block hash" + Error::Call(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. @@ -488,7 +486,7 @@ async fn call_runtime() { .await .unwrap_err(); assert_matches!(err, - Error::Call(CallError::Custom(ref err)) if err.code() == super::error::json_rpc_spec::INVALID_PARAM_ERROR && err.message().contains("Invalid parameter") + Error::Call(err) if err.code() == super::error::json_rpc_spec::INVALID_PARAM_ERROR && err.message().contains("Invalid parameter") ); // Valid call. @@ -550,7 +548,7 @@ async fn call_runtime_without_flag() { ) .into_rpc(); - let mut sub = api.subscribe("chainHead_unstable_follow", [false]).await.unwrap(); + let mut sub = api.subscribe_unbounded("chainHead_unstable_follow", [false]).await.unwrap(); let sub_id = sub.subscription_id(); let sub_id = serde_json::to_string(&sub_id).unwrap(); @@ -591,7 +589,7 @@ async fn call_runtime_without_flag() { .unwrap_err(); assert_matches!(err, - Error::Call(CallError::Custom(ref err)) if err.code() == super::error::rpc_spec_v2::INVALID_RUNTIME_CALL && err.message().contains("subscription was started with `withRuntime` set to `false`") + 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`") ); } @@ -629,7 +627,7 @@ async fn get_storage_hash() { .await .unwrap_err(); assert_matches!(err, - Error::Call(CallError::Custom(ref err)) if err.code() == super::error::rpc_spec_v2::INVALID_BLOCK_ERROR && err.message() == "Invalid block hash" + Error::Call(err) if err.code() == super::error::rpc_spec_v2::INVALID_BLOCK_ERROR && err.message() == "Invalid block hash" ); // Valid call without storage at the key. @@ -897,7 +895,7 @@ async fn get_storage_value() { .await .unwrap_err(); assert_matches!(err, - Error::Call(CallError::Custom(ref err)) if err.code() == super::error::rpc_spec_v2::INVALID_BLOCK_ERROR && err.message() == "Invalid block hash" + Error::Call(err) if err.code() == super::error::rpc_spec_v2::INVALID_BLOCK_ERROR && err.message() == "Invalid block hash" ); // Valid call without storage at the key. @@ -1209,11 +1207,12 @@ async fn separate_operation_ids_for_subscriptions() { .into_rpc(); // Create two separate subscriptions. - let mut sub_first = api.subscribe("chainHead_unstable_follow", [true]).await.unwrap(); + let mut sub_first = api.subscribe_unbounded("chainHead_unstable_follow", [true]).await.unwrap(); let sub_id_first = sub_first.subscription_id(); let sub_id_first = serde_json::to_string(&sub_id_first).unwrap(); - let mut sub_second = api.subscribe("chainHead_unstable_follow", [true]).await.unwrap(); + let mut sub_second = + api.subscribe_unbounded("chainHead_unstable_follow", [true]).await.unwrap(); let sub_id_second = sub_second.subscription_id(); let sub_id_second = serde_json::to_string(&sub_id_second).unwrap(); @@ -1341,7 +1340,7 @@ async fn follow_generates_initial_blocks() { let block_2_f_hash = block_2_f.header.hash(); client.import(BlockOrigin::Own, block_2_f.clone()).await.unwrap(); - let mut sub = api.subscribe("chainHead_unstable_follow", [false]).await.unwrap(); + let mut sub = api.subscribe_unbounded("chainHead_unstable_follow", [false]).await.unwrap(); // Initialized must always be reported first. let event: FollowEvent = get_next_event(&mut sub).await; @@ -1450,7 +1449,7 @@ async fn follow_exceeding_pinned_blocks() { ) .into_rpc(); - let mut sub = api.subscribe("chainHead_unstable_follow", [false]).await.unwrap(); + let mut sub = api.subscribe_unbounded("chainHead_unstable_follow", [false]).await.unwrap(); let block = BlockBuilderBuilder::new(&*client) .on_parent_block(client.chain_info().genesis_hash) @@ -1526,7 +1525,7 @@ async fn follow_with_unpin() { ) .into_rpc(); - let mut sub = api.subscribe("chainHead_unstable_follow", [false]).await.unwrap(); + let mut sub = api.subscribe_unbounded("chainHead_unstable_follow", [false]).await.unwrap(); let sub_id = sub.subscription_id(); let sub_id = serde_json::to_string(&sub_id).unwrap(); @@ -1572,7 +1571,7 @@ async fn follow_with_unpin() { .await .unwrap_err(); assert_matches!(err, - Error::Call(CallError::Custom(ref err)) if err.code() == super::error::rpc_spec_v2::INVALID_BLOCK_ERROR && err.message() == "Invalid block hash" + Error::Call(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. @@ -1637,7 +1636,7 @@ async fn follow_with_multiple_unpin_hashes() { ) .into_rpc(); - let mut sub = api.subscribe("chainHead_unstable_follow", [false]).await.unwrap(); + let mut sub = api.subscribe_unbounded("chainHead_unstable_follow", [false]).await.unwrap(); let sub_id = sub.subscription_id(); let sub_id = serde_json::to_string(&sub_id).unwrap(); @@ -1721,7 +1720,7 @@ async fn follow_with_multiple_unpin_hashes() { .await .unwrap_err(); assert_matches!(err, - Error::Call(CallError::Custom(ref err)) if err.code() == super::error::rpc_spec_v2::INVALID_BLOCK_ERROR && err.message() == "Invalid block hash" + Error::Call(err) if err.code() == super::error::rpc_spec_v2::INVALID_BLOCK_ERROR && err.message() == "Invalid block hash" ); let _res: () = api @@ -1738,7 +1737,7 @@ async fn follow_with_multiple_unpin_hashes() { .await .unwrap_err(); assert_matches!(err, - Error::Call(CallError::Custom(ref err)) if err.code() == super::error::rpc_spec_v2::INVALID_BLOCK_ERROR && err.message() == "Invalid block hash" + Error::Call(err) if err.code() == super::error::rpc_spec_v2::INVALID_BLOCK_ERROR && err.message() == "Invalid block hash" ); // Unpin multiple blocks. @@ -1756,7 +1755,7 @@ async fn follow_with_multiple_unpin_hashes() { .await .unwrap_err(); assert_matches!(err, - Error::Call(CallError::Custom(ref err)) if err.code() == super::error::rpc_spec_v2::INVALID_BLOCK_ERROR && err.message() == "Invalid block hash" + Error::Call(err) if err.code() == super::error::rpc_spec_v2::INVALID_BLOCK_ERROR && err.message() == "Invalid block hash" ); let err = api @@ -1767,7 +1766,7 @@ async fn follow_with_multiple_unpin_hashes() { .await .unwrap_err(); assert_matches!(err, - Error::Call(CallError::Custom(ref err)) if err.code() == super::error::rpc_spec_v2::INVALID_BLOCK_ERROR && err.message() == "Invalid block hash" + Error::Call(err) if err.code() == super::error::rpc_spec_v2::INVALID_BLOCK_ERROR && err.message() == "Invalid block hash" ); } @@ -1791,7 +1790,7 @@ async fn follow_prune_best_block() { .into_rpc(); let finalized_hash = client.info().finalized_hash; - let mut sub = api.subscribe("chainHead_unstable_follow", [false]).await.unwrap(); + let mut sub = api.subscribe_unbounded("chainHead_unstable_follow", [false]).await.unwrap(); // Initialized must always be reported first. let event: FollowEvent = get_next_event(&mut sub).await; @@ -2051,7 +2050,7 @@ async fn follow_forks_pruned_block() { // Block 2_f and 3_f are not pruned, pruning happens at height (N - 1). client.finalize_block(block_3_hash, None).unwrap(); - let mut sub = api.subscribe("chainHead_unstable_follow", [false]).await.unwrap(); + let mut sub = api.subscribe_unbounded("chainHead_unstable_follow", [false]).await.unwrap(); // Initialized must always be reported first. let event: FollowEvent = get_next_event(&mut sub).await; @@ -2205,7 +2204,7 @@ async fn follow_report_multiple_pruned_block() { let block_3_f = block_builder.build().unwrap().block; let block_3_f_hash = block_3_f.hash(); client.import(BlockOrigin::Own, block_3_f.clone()).await.unwrap(); - let mut sub = api.subscribe("chainHead_unstable_follow", [false]).await.unwrap(); + let mut sub = api.subscribe_unbounded("chainHead_unstable_follow", [false]).await.unwrap(); // Initialized must always be reported first. let event: FollowEvent = get_next_event(&mut sub).await; @@ -2388,7 +2387,7 @@ async fn pin_block_references() { } } - let mut sub = api.subscribe("chainHead_unstable_follow", [false]).await.unwrap(); + let mut sub = api.subscribe_unbounded("chainHead_unstable_follow", [false]).await.unwrap(); let sub_id = sub.subscription_id(); let sub_id = serde_json::to_string(&sub_id).unwrap(); @@ -2520,7 +2519,7 @@ async fn follow_finalized_before_new_block() { let block_1_hash = block_1.header.hash(); client.import(BlockOrigin::Own, block_1.clone()).await.unwrap(); - let mut sub = api.subscribe("chainHead_unstable_follow", [false]).await.unwrap(); + let mut sub = api.subscribe_unbounded("chainHead_unstable_follow", [false]).await.unwrap(); // Trigger the `FinalizedNotification` for block 1 before the `BlockImportNotification`, and // expect for the `chainHead` to generate `NewBlock`, `BestBlock` and `Finalized` events. @@ -2622,7 +2621,7 @@ async fn ensure_operation_limits_works() { ) .into_rpc(); - let mut sub = api.subscribe("chainHead_unstable_follow", [true]).await.unwrap(); + let mut sub = api.subscribe_unbounded("chainHead_unstable_follow", [true]).await.unwrap(); let sub_id = sub.subscription_id(); let sub_id = serde_json::to_string(&sub_id).unwrap(); @@ -2726,7 +2725,7 @@ async fn check_continue_operation() { ) .into_rpc(); - let mut sub = api.subscribe("chainHead_unstable_follow", [true]).await.unwrap(); + let mut sub = api.subscribe_unbounded("chainHead_unstable_follow", [true]).await.unwrap(); let sub_id = sub.subscription_id(); let sub_id = serde_json::to_string(&sub_id).unwrap(); @@ -2908,7 +2907,7 @@ async fn stop_storage_operation() { ) .into_rpc(); - let mut sub = api.subscribe("chainHead_unstable_follow", [true]).await.unwrap(); + let mut sub = api.subscribe_unbounded("chainHead_unstable_follow", [true]).await.unwrap(); let sub_id = sub.subscription_id(); let sub_id = serde_json::to_string(&sub_id).unwrap(); diff --git a/substrate/client/rpc-spec-v2/src/chain_spec/tests.rs b/substrate/client/rpc-spec-v2/src/chain_spec/tests.rs index 9326fd5f3b73..3abd9a548a1e 100644 --- a/substrate/client/rpc-spec-v2/src/chain_spec/tests.rs +++ b/substrate/client/rpc-spec-v2/src/chain_spec/tests.rs @@ -17,7 +17,7 @@ // along with this program. If not, see . use super::*; -use jsonrpsee::{types::EmptyServerParams as EmptyParams, RpcModule}; +use jsonrpsee::{core::EmptyServerParams as EmptyParams, RpcModule}; use sc_chain_spec::Properties; const CHAIN_NAME: &'static str = "TEST_CHAIN_NAME"; diff --git a/substrate/client/rpc-spec-v2/src/lib.rs b/substrate/client/rpc-spec-v2/src/lib.rs index 23ed422cff17..fa822fd446ba 100644 --- a/substrate/client/rpc-spec-v2/src/lib.rs +++ b/substrate/client/rpc-spec-v2/src/lib.rs @@ -37,7 +37,7 @@ pub mod transaction; pub type SubscriptionTaskExecutor = std::sync::Arc; /// The result of an RPC method. -#[derive(Debug, Deserialize, Serialize, PartialEq)] +#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)] #[serde(untagged)] pub enum MethodResult { /// Method generated a result. diff --git a/substrate/client/rpc-spec-v2/src/transaction/transaction.rs b/substrate/client/rpc-spec-v2/src/transaction/transaction.rs index fe16310aeffa..b2cfa36c9c99 100644 --- a/substrate/client/rpc-spec-v2/src/transaction/transaction.rs +++ b/substrate/client/rpc-spec-v2/src/transaction/transaction.rs @@ -29,27 +29,21 @@ use crate::{ }, SubscriptionTaskExecutor, }; -use jsonrpsee::{ - core::async_trait, - types::{ - error::{CallError, ErrorObject}, - SubscriptionResult, - }, - SubscriptionSink, -}; +use jsonrpsee::{core::async_trait, types::error::ErrorObject, PendingSubscriptionSink}; use sc_transaction_pool_api::{ error::IntoPoolError, BlockHash, TransactionFor, TransactionPool, TransactionSource, TransactionStatus, }; use std::sync::Arc; +use sc_rpc::utils::pipe_from_stream; use sp_api::ProvideRuntimeApi; use sp_blockchain::HeaderBackend; use sp_core::Bytes; use sp_runtime::traits::Block as BlockT; use codec::Decode; -use futures::{FutureExt, StreamExt, TryFutureExt}; +use futures::{StreamExt, TryFutureExt}; /// An API for transaction RPC calls. pub struct Transaction { @@ -90,52 +84,53 @@ where ::Hash: Unpin, Client: HeaderBackend + ProvideRuntimeApi + Send + Sync + 'static, { - fn submit_and_watch(&self, mut sink: SubscriptionSink, xt: Bytes) -> SubscriptionResult { - // This is the only place where the RPC server can return an error for this - // subscription. Other defects must be signaled as events to the sink. - let decoded_extrinsic = match TransactionFor::::decode(&mut &xt[..]) { - Ok(decoded_extrinsic) => decoded_extrinsic, - Err(e) => { - let err = CallError::Custom(ErrorObject::owned( - BAD_FORMAT, - format!("Extrinsic has invalid format: {}", e), - None::<()>, - )); - let _ = sink.reject(err); - return Ok(()) - }, - }; + fn submit_and_watch(&self, pending: PendingSubscriptionSink, xt: Bytes) { + let client = self.client.clone(); + let pool = self.pool.clone(); - let best_block_hash = self.client.info().best_hash; + let fut = async move { + // This is the only place where the RPC server can return an error for this + // subscription. Other defects must be signaled as events to the sink. + let decoded_extrinsic = match TransactionFor::::decode(&mut &xt[..]) { + Ok(decoded_extrinsic) => decoded_extrinsic, + Err(e) => { + let err = ErrorObject::owned( + BAD_FORMAT, + format!("Extrinsic has invalid format: {}", e), + None::<()>, + ); + let _ = pending.reject(err).await; + return + }, + }; - let submit = self - .pool - .submit_and_watch(best_block_hash, TX_SOURCE, decoded_extrinsic) - .map_err(|e| { - e.into_pool_error() - .map(Error::from) - .unwrap_or_else(|e| Error::Verification(Box::new(e))) - }); + let best_block_hash = client.info().best_hash; + + let submit = pool + .submit_and_watch(best_block_hash, TX_SOURCE, decoded_extrinsic) + .map_err(|e| { + e.into_pool_error() + .map(Error::from) + .unwrap_or_else(|e| Error::Verification(Box::new(e))) + }); - let fut = async move { match submit.await { Ok(stream) => { let mut state = TransactionState::new(); let stream = - stream.filter_map(|event| async move { state.handle_event(event) }); - sink.pipe_from_stream(stream.boxed()).await; + stream.filter_map(move |event| async move { state.handle_event(event) }); + pipe_from_stream(pending, stream.boxed()).await; }, Err(err) => { // We have not created an `Watcher` for the tx. Make sure the // error is still propagated as an event. let event: TransactionEvent<::Hash> = err.into(); - sink.pipe_from_stream(futures::stream::once(async { event }).boxed()).await; + pipe_from_stream(pending, futures::stream::once(async { event }).boxed()).await; }, }; }; - self.executor.spawn("substrate-rpc-subscription", Some("rpc"), fut.boxed()); - Ok(()) + sc_rpc::utils::spawn_subscription_task(&self.executor, fut); } } diff --git a/substrate/client/rpc/Cargo.toml b/substrate/client/rpc/Cargo.toml index 2b4366b7cfc6..5fc4d9becc21 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.16.2", features = ["server"] } +jsonrpsee = { version = "0.20.3", features = ["server"] } log = "0.4.17" parking_lot = "0.12.1" serde_json = "1.0.111" @@ -40,7 +40,6 @@ sp-runtime = { path = "../../primitives/runtime" } sp-session = { path = "../../primitives/session" } sp-version = { path = "../../primitives/version" } sp-statement-store = { path = "../../primitives/statement-store" } - tokio = "1.22.0" [dev-dependencies] @@ -56,6 +55,7 @@ tokio = "1.22.0" sp-io = { path = "../../primitives/io" } substrate-test-runtime-client = { path = "../../test-utils/runtime/client" } pretty_assertions = "1.2.1" +tracing-subscriber = { version = "0.3", features = ["env-filter"] } [features] test-helpers = [] diff --git a/substrate/client/rpc/src/author/mod.rs b/substrate/client/rpc/src/author/mod.rs index 55d0a504aa67..975f66406a6a 100644 --- a/substrate/client/rpc/src/author/mod.rs +++ b/substrate/client/rpc/src/author/mod.rs @@ -23,15 +23,14 @@ mod tests; use std::sync::Arc; -use crate::SubscriptionTaskExecutor; +use crate::{ + utils::{pipe_from_stream, spawn_subscription_task}, + SubscriptionTaskExecutor, +}; use codec::{Decode, Encode}; -use futures::{FutureExt, TryFutureExt}; -use jsonrpsee::{ - core::{async_trait, Error as JsonRpseeError, RpcResult}, - types::SubscriptionResult, - SubscriptionSink, -}; +use futures::TryFutureExt; +use jsonrpsee::{core::async_trait, types::ErrorObject, PendingSubscriptionSink}; use sc_rpc_api::DenyUnsafe; use sc_transaction_pool_api::{ error::IntoPoolError, BlockHash, InPoolTransaction, TransactionFor, TransactionPool, @@ -91,7 +90,7 @@ where P::Hash: Unpin, ::Hash: Unpin, { - async fn submit_extrinsic(&self, ext: Bytes) -> RpcResult> { + async fn submit_extrinsic(&self, ext: Bytes) -> Result> { let xt = match Decode::decode(&mut &ext[..]) { Ok(xt) => xt, Err(err) => return Err(Error::Client(Box::new(err)).into()), @@ -105,7 +104,7 @@ where }) } - fn insert_key(&self, key_type: String, suri: String, public: Bytes) -> RpcResult<()> { + fn insert_key(&self, key_type: String, suri: String, public: Bytes) -> Result<()> { self.deny_unsafe.check_if_safe()?; let key_type = key_type.as_str().try_into().map_err(|_| Error::BadKeyType)?; @@ -115,7 +114,7 @@ where Ok(()) } - fn rotate_keys(&self) -> RpcResult { + fn rotate_keys(&self) -> Result { self.deny_unsafe.check_if_safe()?; let best_block_hash = self.client.info().best_hash; @@ -129,7 +128,7 @@ where .map_err(|api_err| Error::Client(Box::new(api_err)).into()) } - fn has_session_keys(&self, session_keys: Bytes) -> RpcResult { + fn has_session_keys(&self, session_keys: Bytes) -> Result { self.deny_unsafe.check_if_safe()?; let best_block_hash = self.client.info().best_hash; @@ -143,21 +142,21 @@ where Ok(self.keystore.has_keys(&keys)) } - fn has_key(&self, public_key: Bytes, key_type: String) -> RpcResult { + fn has_key(&self, public_key: Bytes, key_type: String) -> Result { self.deny_unsafe.check_if_safe()?; let key_type = key_type.as_str().try_into().map_err(|_| Error::BadKeyType)?; Ok(self.keystore.has_keys(&[(public_key.to_vec(), key_type)])) } - fn pending_extrinsics(&self) -> RpcResult> { + fn pending_extrinsics(&self) -> Result> { Ok(self.pool.ready().map(|tx| tx.data().encode().into()).collect()) } fn remove_extrinsic( &self, bytes_or_hash: Vec>>, - ) -> RpcResult>> { + ) -> Result>> { self.deny_unsafe.check_if_safe()?; let hashes = bytes_or_hash .into_iter() @@ -178,13 +177,13 @@ where .collect()) } - fn watch_extrinsic(&self, mut sink: SubscriptionSink, xt: Bytes) -> SubscriptionResult { + fn watch_extrinsic(&self, pending: PendingSubscriptionSink, xt: Bytes) { let best_block_hash = self.client.info().best_hash; let dxt = match TransactionFor::

::decode(&mut &xt[..]).map_err(|e| Error::from(e)) { Ok(dxt) => dxt, Err(e) => { - let _ = sink.reject(JsonRpseeError::from(e)); - return Ok(()) + spawn_subscription_task(&self.executor, pending.reject(e)); + return }, }; @@ -198,15 +197,14 @@ where let stream = match submit.await { Ok(stream) => stream, Err(err) => { - let _ = sink.reject(JsonRpseeError::from(err)); + let _ = pending.reject(ErrorObject::from(err)).await; return }, }; - sink.pipe_from_stream(stream).await; + pipe_from_stream(pending, stream).await; }; - self.executor.spawn("substrate-rpc-subscription", Some("rpc"), fut.boxed()); - Ok(()) + spawn_subscription_task(&self.executor, fut); } } diff --git a/substrate/client/rpc/src/author/tests.rs b/substrate/client/rpc/src/author/tests.rs index 3e3db4b03b3d..471016a015da 100644 --- a/substrate/client/rpc/src/author/tests.rs +++ b/substrate/client/rpc/src/author/tests.rs @@ -22,8 +22,7 @@ use crate::testing::{test_executor, timeout_secs}; use assert_matches::assert_matches; use codec::Encode; use jsonrpsee::{ - core::Error as RpcError, - types::{error::CallError, EmptyServerParams as EmptyParams}, + core::{EmptyServerParams as EmptyParams, Error as RpcError}, RpcModule, }; use sc_transaction_pool::{BasicPool, FullChainApi}; @@ -104,7 +103,7 @@ async fn author_submit_transaction_should_not_cause_error() { assert_matches!( api.call::<_, H256>("author_submitExtrinsic", [xt]).await, - Err(RpcError::Call(CallError::Custom(err))) if err.message().contains("Already Imported") && err.code() == 1013 + Err(RpcError::Call(err)) if err.message().contains("Already Imported") && err.code() == 1013 ); } @@ -119,7 +118,7 @@ async fn author_should_watch_extrinsic() { true, ); - let mut sub = api.subscribe("author_submitAndWatchExtrinsic", [xt]).await.unwrap(); + let mut sub = api.subscribe_unbounded("author_submitAndWatchExtrinsic", [xt]).await.unwrap(); let (tx, sub_id) = timeout_secs(10, sub.next::>()) .await .unwrap() @@ -157,11 +156,11 @@ async fn author_should_return_watch_validation_error() { let invalid_xt = ExtrinsicBuilder::new_fill_block(Perbill::from_percent(100)).build(); let api = TestSetup::into_rpc(); - let failed_sub = api.subscribe(METHOD, [to_hex(&invalid_xt.encode(), true)]).await; + let failed_sub = api.subscribe_unbounded(METHOD, [to_hex(&invalid_xt.encode(), true)]).await; assert_matches!( failed_sub, - Err(RpcError::Call(CallError::Custom(err))) if err.message().contains("Invalid Transaction") && err.code() == 1010 + Err(RpcError::Call(err)) if err.message().contains("Invalid Transaction") && err.code() == 1010 ); } @@ -277,7 +276,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(CallError::Custom(err))) if err.message().contains("Session keys are not encoded correctly") + Err(RpcError::Call(err)) if err.message().contains("Session keys are not encoded correctly") ); } diff --git a/substrate/client/rpc/src/chain/chain_full.rs b/substrate/client/rpc/src/chain/chain_full.rs index a88291eb7bd3..515c0f62c8ad 100644 --- a/substrate/client/rpc/src/chain/chain_full.rs +++ b/substrate/client/rpc/src/chain/chain_full.rs @@ -19,14 +19,17 @@ //! Blockchain API backend for full nodes. use super::{client_err, ChainBackend, Error}; -use crate::SubscriptionTaskExecutor; +use crate::{ + utils::{pipe_from_stream, spawn_subscription_task}, + SubscriptionTaskExecutor, +}; use std::{marker::PhantomData, sync::Arc}; use futures::{ - future::{self, FutureExt}, + future::{self}, stream::{self, Stream, StreamExt}, }; -use jsonrpsee::SubscriptionSink; +use jsonrpsee::{core::async_trait, PendingSubscriptionSink}; use sc_client_api::{BlockBackend, BlockchainEvents}; use sp_blockchain::HeaderBackend; use sp_runtime::{generic::SignedBlock, traits::Block as BlockT}; @@ -48,6 +51,7 @@ impl FullChain { } } +#[async_trait] impl ChainBackend for FullChain where Block: BlockT + 'static, @@ -66,11 +70,11 @@ where self.client.block(self.unwrap_or_best(hash)).map_err(client_err) } - fn subscribe_all_heads(&self, sink: SubscriptionSink) { + fn subscribe_all_heads(&self, pending: PendingSubscriptionSink) { subscribe_headers( &self.client, &self.executor, - sink, + pending, || self.client().info().best_hash, || { self.client() @@ -80,11 +84,11 @@ where ) } - fn subscribe_new_heads(&self, sink: SubscriptionSink) { + fn subscribe_new_heads(&self, pending: PendingSubscriptionSink) { subscribe_headers( &self.client, &self.executor, - sink, + pending, || self.client().info().best_hash, || { self.client() @@ -95,11 +99,11 @@ where ) } - fn subscribe_finalized_heads(&self, sink: SubscriptionSink) { + fn subscribe_finalized_heads(&self, pending: PendingSubscriptionSink) { subscribe_headers( &self.client, &self.executor, - sink, + pending, || self.client().info().finalized_hash, || { self.client() @@ -114,7 +118,7 @@ where fn subscribe_headers( client: &Arc, executor: &SubscriptionTaskExecutor, - mut sink: SubscriptionSink, + pending: PendingSubscriptionSink, best_block_hash: G, stream: F, ) where @@ -139,9 +143,5 @@ fn subscribe_headers( // duplicates at the beginning of the stream though. let stream = stream::iter(maybe_header).chain(stream()); - let fut = async move { - sink.pipe_from_stream(stream).await; - }; - - executor.spawn("substrate-rpc-subscription", Some("rpc"), fut.boxed()); + spawn_subscription_task(executor, pipe_from_stream(pending, stream)); } diff --git a/substrate/client/rpc/src/chain/mod.rs b/substrate/client/rpc/src/chain/mod.rs index 2b5994f217df..1c74db8642e6 100644 --- a/substrate/client/rpc/src/chain/mod.rs +++ b/substrate/client/rpc/src/chain/mod.rs @@ -27,7 +27,7 @@ use std::sync::Arc; use crate::SubscriptionTaskExecutor; -use jsonrpsee::{core::RpcResult, types::SubscriptionResult, SubscriptionSink}; +use jsonrpsee::{core::async_trait, PendingSubscriptionSink}; use sc_client_api::BlockchainEvents; use sp_rpc::{list::ListOrValue, number::NumberOrHex}; use sp_runtime::{ @@ -42,6 +42,7 @@ pub use sc_rpc_api::chain::*; use sp_blockchain::HeaderBackend; /// Blockchain backend API +#[async_trait] trait ChainBackend: Send + Sync + 'static where Block: BlockT + 'static, @@ -91,13 +92,13 @@ where } /// All new head subscription - fn subscribe_all_heads(&self, sink: SubscriptionSink); + fn subscribe_all_heads(&self, pending: PendingSubscriptionSink); /// New best head subscription - fn subscribe_new_heads(&self, sink: SubscriptionSink); + fn subscribe_new_heads(&self, pending: PendingSubscriptionSink); /// Finalized head subscription - fn subscribe_finalized_heads(&self, sink: SubscriptionSink); + fn subscribe_finalized_heads(&self, pending: PendingSubscriptionSink); } /// Create new state API that works on full node. @@ -118,6 +119,7 @@ pub struct Chain { backend: Box>, } +#[async_trait] impl ChainApiServer, Block::Hash, Block::Header, SignedBlock> for Chain where @@ -125,20 +127,20 @@ where Block::Header: Unpin, Client: HeaderBackend + BlockchainEvents + 'static, { - fn header(&self, hash: Option) -> RpcResult> { - self.backend.header(hash).map_err(Into::into) + fn header(&self, hash: Option) -> Result, Error> { + self.backend.header(hash) } - fn block(&self, hash: Option) -> RpcResult>> { - self.backend.block(hash).map_err(Into::into) + fn block(&self, hash: Option) -> Result>, Error> { + self.backend.block(hash) } fn block_hash( &self, number: Option>, - ) -> RpcResult>> { + ) -> Result>, Error> { match number { - None => self.backend.block_hash(None).map(ListOrValue::Value).map_err(Into::into), + None => self.backend.block_hash(None).map(ListOrValue::Value), Some(ListOrValue::Value(number)) => self .backend .block_hash(Some(number)) @@ -152,23 +154,20 @@ where } } - fn finalized_head(&self) -> RpcResult { - self.backend.finalized_head().map_err(Into::into) + fn finalized_head(&self) -> Result { + self.backend.finalized_head() } - fn subscribe_all_heads(&self, sink: SubscriptionSink) -> SubscriptionResult { - self.backend.subscribe_all_heads(sink); - Ok(()) + fn subscribe_all_heads(&self, pending: PendingSubscriptionSink) { + self.backend.subscribe_all_heads(pending); } - fn subscribe_new_heads(&self, sink: SubscriptionSink) -> SubscriptionResult { - self.backend.subscribe_new_heads(sink); - Ok(()) + fn subscribe_new_heads(&self, pending: PendingSubscriptionSink) { + self.backend.subscribe_new_heads(pending) } - fn subscribe_finalized_heads(&self, sink: SubscriptionSink) -> SubscriptionResult { - self.backend.subscribe_finalized_heads(sink); - Ok(()) + fn subscribe_finalized_heads(&self, pending: PendingSubscriptionSink) { + self.backend.subscribe_finalized_heads(pending) } } diff --git a/substrate/client/rpc/src/chain/tests.rs b/substrate/client/rpc/src/chain/tests.rs index cff5bf39811c..afb81f709f7d 100644 --- a/substrate/client/rpc/src/chain/tests.rs +++ b/substrate/client/rpc/src/chain/tests.rs @@ -19,7 +19,7 @@ use super::*; use crate::testing::{test_executor, timeout_secs}; use assert_matches::assert_matches; -use jsonrpsee::types::EmptyServerParams as EmptyParams; +use jsonrpsee::core::EmptyServerParams as EmptyParams; use sc_block_builder::BlockBuilderBuilder; use sp_consensus::BlockOrigin; use sp_rpc::list::ListOrValue; @@ -252,7 +252,7 @@ async fn test_head_subscription(method: &str) { let mut sub = { let api = new_full(client.clone(), test_executor()).into_rpc(); - let sub = api.subscribe(method, EmptyParams::new()).await.unwrap(); + let sub = api.subscribe_unbounded(method, EmptyParams::new()).await.unwrap(); let block = BlockBuilderBuilder::new(&*client) .on_parent_block(client.chain_info().best_hash) .with_parent_block_number(client.chain_info().best_number) diff --git a/substrate/client/rpc/src/dev/mod.rs b/substrate/client/rpc/src/dev/mod.rs index 4d2e8618d553..424ef72b694e 100644 --- a/substrate/client/rpc/src/dev/mod.rs +++ b/substrate/client/rpc/src/dev/mod.rs @@ -22,7 +22,6 @@ #[cfg(test)] mod tests; -use jsonrpsee::core::RpcResult; use sc_client_api::{BlockBackend, HeaderBackend}; use sc_rpc_api::{dev::error::Error, DenyUnsafe}; use sp_api::{ApiExt, Core, ProvideRuntimeApi}; @@ -65,7 +64,7 @@ where + 'static, Client::Api: Core, { - fn block_stats(&self, hash: Block::Hash) -> RpcResult> { + fn block_stats(&self, hash: Block::Hash) -> Result, Error> { self.deny_unsafe.check_if_safe()?; let block = { diff --git a/substrate/client/rpc/src/dev/tests.rs b/substrate/client/rpc/src/dev/tests.rs index 448d16274f27..5eb4897056cc 100644 --- a/substrate/client/rpc/src/dev/tests.rs +++ b/substrate/client/rpc/src/dev/tests.rs @@ -97,7 +97,7 @@ async fn deny_unsafe_works() { "{{\"jsonrpc\":\"2.0\",\"method\":\"dev_getBlockStats\",\"params\":[{}],\"id\":1}}", best_hash_param ); - let (resp, _) = api.raw_json_request(&request).await.expect("Raw calls should succeed"); + let (resp, _) = api.raw_json_request(&request, 1).await.expect("Raw calls should succeed"); assert_eq!( resp.result, diff --git a/substrate/client/rpc/src/lib.rs b/substrate/client/rpc/src/lib.rs index 94fdb2d734ff..b40d0341e321 100644 --- a/substrate/client/rpc/src/lib.rs +++ b/substrate/client/rpc/src/lib.rs @@ -39,6 +39,7 @@ pub mod offchain; pub mod state; pub mod statement; pub mod system; +pub mod utils; #[cfg(any(test, feature = "test-helpers"))] pub mod testing; diff --git a/substrate/client/rpc/src/mixnet/mod.rs b/substrate/client/rpc/src/mixnet/mod.rs index 3f3d9c5aa452..64875c6fe764 100644 --- a/substrate/client/rpc/src/mixnet/mod.rs +++ b/substrate/client/rpc/src/mixnet/mod.rs @@ -18,7 +18,7 @@ //! Substrate mixnet API. -use jsonrpsee::core::{async_trait, RpcResult}; +use jsonrpsee::core::async_trait; use sc_mixnet::Api; use sc_rpc_api::mixnet::error::Error; pub use sc_rpc_api::mixnet::MixnetApiServer; @@ -36,7 +36,7 @@ impl Mixnet { #[async_trait] impl MixnetApiServer for Mixnet { - async fn submit_extrinsic(&self, extrinsic: Bytes) -> RpcResult<()> { + async fn submit_extrinsic(&self, extrinsic: Bytes) -> Result<(), Error> { // We only hold the lock while pushing the request into the requests channel let fut = { let mut api = self.0.lock().await; diff --git a/substrate/client/rpc/src/offchain/mod.rs b/substrate/client/rpc/src/offchain/mod.rs index de711accdcc1..661673866053 100644 --- a/substrate/client/rpc/src/offchain/mod.rs +++ b/substrate/client/rpc/src/offchain/mod.rs @@ -22,7 +22,7 @@ mod tests; use self::error::Error; -use jsonrpsee::core::{async_trait, Error as JsonRpseeError, RpcResult}; +use jsonrpsee::core::async_trait; use parking_lot::RwLock; /// Re-export the API for backward compatibility. pub use sc_rpc_api::offchain::*; @@ -50,23 +50,23 @@ impl Offchain { #[async_trait] impl OffchainApiServer for Offchain { - fn set_local_storage(&self, kind: StorageKind, key: Bytes, value: Bytes) -> RpcResult<()> { + fn set_local_storage(&self, kind: StorageKind, key: Bytes, value: Bytes) -> Result<(), Error> { self.deny_unsafe.check_if_safe()?; let prefix = match kind { StorageKind::PERSISTENT => sp_offchain::STORAGE_PREFIX, - StorageKind::LOCAL => return Err(JsonRpseeError::from(Error::UnavailableStorageKind)), + StorageKind::LOCAL => return Err(Error::UnavailableStorageKind), }; self.storage.write().set(prefix, &key, &value); Ok(()) } - fn get_local_storage(&self, kind: StorageKind, key: Bytes) -> RpcResult> { + fn get_local_storage(&self, kind: StorageKind, key: Bytes) -> Result, Error> { self.deny_unsafe.check_if_safe()?; let prefix = match kind { StorageKind::PERSISTENT => sp_offchain::STORAGE_PREFIX, - StorageKind::LOCAL => return Err(JsonRpseeError::from(Error::UnavailableStorageKind)), + StorageKind::LOCAL => return Err(Error::UnavailableStorageKind), }; Ok(self.storage.read().get(prefix, &key).map(Into::into)) diff --git a/substrate/client/rpc/src/offchain/tests.rs b/substrate/client/rpc/src/offchain/tests.rs index 62a846d0887c..7758fac7fabd 100644 --- a/substrate/client/rpc/src/offchain/tests.rs +++ b/substrate/client/rpc/src/offchain/tests.rs @@ -39,7 +39,6 @@ fn local_storage_should_work() { #[test] fn offchain_calls_considered_unsafe() { - use jsonrpsee::types::error::CallError; let storage = InMemOffchainStorage::default(); let offchain = Offchain::new(storage, DenyUnsafe::Yes); let key = Bytes(b"offchain_storage".to_vec()); @@ -47,14 +46,14 @@ fn offchain_calls_considered_unsafe() { assert_matches!( offchain.set_local_storage(StorageKind::PERSISTENT, key.clone(), value.clone()), - Err(JsonRpseeError::Call(CallError::Custom(err))) => { - assert_eq!(err.message(), "RPC call is unsafe to be called externally") + Err(Error::UnsafeRpcCalled(e)) => { + assert_eq!(e.to_string(), "RPC call is unsafe to be called externally") } ); assert_matches!( offchain.get_local_storage(StorageKind::PERSISTENT, key), - Err(JsonRpseeError::Call(CallError::Custom(err))) => { - assert_eq!(err.message(), "RPC call is unsafe to be called externally") + Err(Error::UnsafeRpcCalled(e)) => { + assert_eq!(e.to_string(), "RPC call is unsafe to be called externally") } ); } diff --git a/substrate/client/rpc/src/state/mod.rs b/substrate/client/rpc/src/state/mod.rs index 057661d6ec7f..c9a41e25eda8 100644 --- a/substrate/client/rpc/src/state/mod.rs +++ b/substrate/client/rpc/src/state/mod.rs @@ -24,32 +24,23 @@ mod utils; #[cfg(test)] mod tests; -use std::sync::Arc; - use crate::SubscriptionTaskExecutor; - -use jsonrpsee::{ - core::{async_trait, server::rpc_module::SubscriptionSink, Error as JsonRpseeError, RpcResult}, - types::SubscriptionResult, +use jsonrpsee::{core::async_trait, PendingSubscriptionSink}; +use sc_client_api::{ + Backend, BlockBackend, BlockchainEvents, ExecutorProvider, ProofProvider, StorageProvider, }; - use sc_rpc_api::DenyUnsafe; +use sp_api::{CallApiAt, Metadata, ProvideRuntimeApi}; +use sp_blockchain::{HeaderBackend, HeaderMetadata}; use sp_core::{ storage::{PrefixedStorageKey, StorageChangeSet, StorageData, StorageKey}, Bytes, }; use sp_runtime::traits::Block as BlockT; use sp_version::RuntimeVersion; +use std::sync::Arc; -use sp_api::{CallApiAt, Metadata, ProvideRuntimeApi}; - -use self::error::Error; - -use sc_client_api::{ - Backend, BlockBackend, BlockchainEvents, ExecutorProvider, ProofProvider, StorageProvider, -}; pub use sc_rpc_api::{child_state::*, state::*}; -use sp_blockchain::{HeaderBackend, HeaderMetadata}; const STORAGE_KEYS_PAGED_MAX_COUNT: u32 = 1000; @@ -158,10 +149,15 @@ where ) -> Result; /// New runtime version subscription - fn subscribe_runtime_version(&self, sink: SubscriptionSink); + fn subscribe_runtime_version(&self, pending: PendingSubscriptionSink); /// New storage subscription - fn subscribe_storage(&self, sink: SubscriptionSink, keys: Option>); + fn subscribe_storage( + &self, + pending: PendingSubscriptionSink, + keys: Option>, + deny_unsafe: DenyUnsafe, + ); } /// Create new state API that works on full node. @@ -207,7 +203,12 @@ where Block: BlockT + 'static, Client: Send + Sync + 'static, { - fn call(&self, method: String, data: Bytes, block: Option) -> RpcResult { + fn call( + &self, + method: String, + data: Bytes, + block: Option, + ) -> Result { self.backend.call(block, method, data).map_err(Into::into) } @@ -215,7 +216,7 @@ where &self, key_prefix: StorageKey, block: Option, - ) -> RpcResult> { + ) -> Result, Error> { self.backend.storage_keys(block, key_prefix).map_err(Into::into) } @@ -223,7 +224,7 @@ where &self, key_prefix: StorageKey, block: Option, - ) -> RpcResult> { + ) -> Result, Error> { self.deny_unsafe.check_if_safe()?; self.backend.storage_pairs(block, key_prefix).map_err(Into::into) } @@ -234,12 +235,9 @@ where count: u32, start_key: Option, block: Option, - ) -> RpcResult> { + ) -> Result, Error> { if count > STORAGE_KEYS_PAGED_MAX_COUNT { - return Err(JsonRpseeError::from(Error::InvalidCount { - value: count, - max: STORAGE_KEYS_PAGED_MAX_COUNT, - })) + return Err(Error::InvalidCount { value: count, max: STORAGE_KEYS_PAGED_MAX_COUNT }) } self.backend .storage_keys_paged(block, prefix, count, start_key) @@ -250,7 +248,7 @@ where &self, key: StorageKey, block: Option, - ) -> RpcResult> { + ) -> Result, Error> { self.backend.storage(block, key).map_err(Into::into) } @@ -258,7 +256,7 @@ where &self, key: StorageKey, block: Option, - ) -> RpcResult> { + ) -> Result, Error> { self.backend.storage_hash(block, key).map_err(Into::into) } @@ -266,18 +264,18 @@ where &self, key: StorageKey, block: Option, - ) -> RpcResult> { + ) -> Result, Error> { self.backend .storage_size(block, key, self.deny_unsafe) .await .map_err(Into::into) } - fn metadata(&self, block: Option) -> RpcResult { + fn metadata(&self, block: Option) -> Result { self.backend.metadata(block).map_err(Into::into) } - fn runtime_version(&self, at: Option) -> RpcResult { + fn runtime_version(&self, at: Option) -> Result { self.backend.runtime_version(at).map_err(Into::into) } @@ -286,7 +284,7 @@ where keys: Vec, from: Block::Hash, to: Option, - ) -> RpcResult>> { + ) -> Result>, Error> { self.deny_unsafe.check_if_safe()?; self.backend.query_storage(from, to, keys).map_err(Into::into) } @@ -295,7 +293,7 @@ where &self, keys: Vec, at: Option, - ) -> RpcResult>> { + ) -> Result>, Error> { self.backend.query_storage_at(keys, at).map_err(Into::into) } @@ -303,7 +301,7 @@ where &self, keys: Vec, block: Option, - ) -> RpcResult> { + ) -> Result, Error> { self.backend.read_proof(block, keys).map_err(Into::into) } @@ -318,32 +316,19 @@ where targets: Option, storage_keys: Option, methods: Option, - ) -> RpcResult { + ) -> Result { self.deny_unsafe.check_if_safe()?; self.backend .trace_block(block, targets, storage_keys, methods) .map_err(Into::into) } - fn subscribe_runtime_version(&self, sink: SubscriptionSink) -> SubscriptionResult { - self.backend.subscribe_runtime_version(sink); - Ok(()) + fn subscribe_runtime_version(&self, pending: PendingSubscriptionSink) { + self.backend.subscribe_runtime_version(pending) } - fn subscribe_storage( - &self, - mut sink: SubscriptionSink, - keys: Option>, - ) -> SubscriptionResult { - if keys.is_none() { - if let Err(err) = self.deny_unsafe.check_if_safe() { - let _ = sink.reject(JsonRpseeError::from(err)); - return Ok(()) - } - } - - self.backend.subscribe_storage(sink, keys); - Ok(()) + fn subscribe_storage(&self, pending: PendingSubscriptionSink, keys: Option>) { + self.backend.subscribe_storage(pending, keys, self.deny_unsafe) } } @@ -430,7 +415,7 @@ where storage_key: PrefixedStorageKey, key_prefix: StorageKey, block: Option, - ) -> RpcResult> { + ) -> Result, Error> { self.backend.storage_keys(block, storage_key, key_prefix).map_err(Into::into) } @@ -441,7 +426,7 @@ where count: u32, start_key: Option, block: Option, - ) -> RpcResult> { + ) -> Result, Error> { self.backend .storage_keys_paged(block, storage_key, prefix, count, start_key) .map_err(Into::into) @@ -452,7 +437,7 @@ where storage_key: PrefixedStorageKey, key: StorageKey, block: Option, - ) -> RpcResult> { + ) -> Result, Error> { self.backend.storage(block, storage_key, key).map_err(Into::into) } @@ -461,7 +446,7 @@ where storage_key: PrefixedStorageKey, keys: Vec, block: Option, - ) -> RpcResult>> { + ) -> Result>, Error> { self.backend.storage_entries(block, storage_key, keys).map_err(Into::into) } @@ -470,7 +455,7 @@ where storage_key: PrefixedStorageKey, key: StorageKey, block: Option, - ) -> RpcResult> { + ) -> Result, Error> { self.backend.storage_hash(block, storage_key, key).map_err(Into::into) } @@ -479,7 +464,7 @@ where storage_key: PrefixedStorageKey, key: StorageKey, block: Option, - ) -> RpcResult> { + ) -> Result, Error> { self.backend.storage_size(block, storage_key, key).map_err(Into::into) } @@ -488,7 +473,7 @@ where child_storage_key: PrefixedStorageKey, keys: Vec, block: Option, - ) -> RpcResult> { + ) -> Result, Error> { self.backend .read_child_proof(block, child_storage_key, keys) .map_err(Into::into) diff --git a/substrate/client/rpc/src/state/state_full.rs b/substrate/client/rpc/src/state/state_full.rs index 9604d9165f98..bda678c1b45e 100644 --- a/substrate/client/rpc/src/state/state_full.rs +++ b/substrate/client/rpc/src/state/state_full.rs @@ -25,13 +25,13 @@ use super::{ error::{Error, Result}, ChildStateBackend, StateBackend, }; -use crate::{DenyUnsafe, SubscriptionTaskExecutor}; - -use futures::{future, stream, FutureExt, StreamExt}; -use jsonrpsee::{ - core::{async_trait, Error as JsonRpseeError}, - SubscriptionSink, +use crate::{ + utils::{pipe_from_stream, spawn_subscription_task}, + DenyUnsafe, SubscriptionTaskExecutor, }; + +use futures::{future, stream, StreamExt}; +use jsonrpsee::{core::async_trait, types::ErrorObject, PendingSubscriptionSink}; use sc_client_api::{ Backend, BlockBackend, BlockchainEvents, CallExecutor, ExecutorProvider, ProofProvider, StorageProvider, @@ -371,9 +371,7 @@ where .map_err(client_err) } - fn subscribe_runtime_version(&self, mut sink: SubscriptionSink) { - let client = self.client.clone(); - + fn subscribe_runtime_version(&self, pending: PendingSubscriptionSink) { let initial = match self .block_or_best(None) .and_then(|block| self.client.runtime_version_at(block).map_err(Into::into)) @@ -381,12 +379,13 @@ where { Ok(initial) => initial, Err(e) => { - let _ = sink.reject(JsonRpseeError::from(e)); + spawn_subscription_task(&self.executor, pending.reject(e)); return }, }; let mut previous_version = initial.clone(); + let client = self.client.clone(); // A stream of new versions let version_stream = client @@ -406,24 +405,33 @@ where }); let stream = futures::stream::once(future::ready(initial)).chain(version_stream); - - let fut = async move { - sink.pipe_from_stream(stream).await; - }; - - self.executor.spawn("substrate-rpc-subscription", Some("rpc"), fut.boxed()); + spawn_subscription_task(&self.executor, pipe_from_stream(pending, stream)); } - fn subscribe_storage(&self, mut sink: SubscriptionSink, keys: Option>) { + fn subscribe_storage( + &self, + pending: PendingSubscriptionSink, + keys: Option>, + deny_unsafe: DenyUnsafe, + ) { + if keys.is_none() { + if let Err(err) = deny_unsafe.check_if_safe() { + spawn_subscription_task(&self.executor, pending.reject(ErrorObject::from(err))); + return + } + } + let stream = match self.client.storage_changes_notification_stream(keys.as_deref(), None) { Ok(stream) => stream, Err(blockchain_err) => { - let _ = sink.reject(JsonRpseeError::from(Error::Client(Box::new(blockchain_err)))); + spawn_subscription_task( + &self.executor, + pending.reject(Error::Client(Box::new(blockchain_err))), + ); return }, }; - // initial values let initial = stream::iter(keys.map(|keys| { let block = self.client.info().best_hash; let changes = keys @@ -436,7 +444,6 @@ where StorageChangeSet { block, changes } })); - // let storage_stream = stream.map(|(block, changes)| StorageChangeSet { let storage_stream = stream.map(|storage_notif| StorageChangeSet { block: storage_notif.block, changes: storage_notif @@ -450,11 +457,7 @@ where .chain(storage_stream) .filter(|storage| future::ready(!storage.changes.is_empty())); - let fut = async move { - sink.pipe_from_stream(stream).await; - }; - - self.executor.spawn("substrate-rpc-subscription", Some("rpc"), fut.boxed()); + spawn_subscription_task(&self.executor, pipe_from_stream(pending, stream)); } fn trace_block( diff --git a/substrate/client/rpc/src/state/tests.rs b/substrate/client/rpc/src/state/tests.rs index 663d511d43e7..25a34faed9a6 100644 --- a/substrate/client/rpc/src/state/tests.rs +++ b/substrate/client/rpc/src/state/tests.rs @@ -21,10 +21,7 @@ use super::*; use crate::testing::{test_executor, timeout_secs}; use assert_matches::assert_matches; use futures::executor; -use jsonrpsee::{ - core::Error as RpcError, - types::{error::CallError as RpcCallError, EmptyServerParams as EmptyParams, ErrorObject}, -}; +use jsonrpsee::core::{EmptyServerParams as EmptyParams, Error as RpcError}; use sc_block_builder::BlockBuilderBuilder; use sc_rpc_api::DenyUnsafe; use sp_consensus::BlockOrigin; @@ -42,6 +39,14 @@ fn prefixed_storage_key() -> PrefixedStorageKey { child_info.prefixed_storage_key() } +fn init_logger() { + use tracing_subscriber::{EnvFilter, FmtSubscriber}; + + let _ = FmtSubscriber::builder() + .with_env_filter(EnvFilter::from_default_env()) + .try_init(); +} + #[tokio::test] async fn should_return_storage() { const KEY: &[u8] = b":mock"; @@ -200,22 +205,25 @@ async fn should_call_contract() { let genesis_hash = client.genesis_hash(); let (client, _child) = new_full(client, test_executor(), DenyUnsafe::No); - use jsonrpsee::{core::Error, types::error::CallError}; - assert_matches!( client.call("balanceOf".into(), Bytes(vec![1, 2, 3]), Some(genesis_hash).into()), - Err(Error::Call(CallError::Failed(_))) + Err(Error::Client(_)) ) } #[tokio::test] async fn should_notify_about_storage_changes() { + init_logger(); + let mut sub = { let mut client = Arc::new(substrate_test_runtime_client::new()); let (api, _child) = new_full(client.clone(), test_executor(), DenyUnsafe::No); let api_rpc = api.into_rpc(); - let sub = api_rpc.subscribe("state_subscribeStorage", EmptyParams::new()).await.unwrap(); + let sub = api_rpc + .subscribe_unbounded("state_subscribeStorage", EmptyParams::new()) + .await + .unwrap(); // Cause a change: let mut builder = BlockBuilderBuilder::new(&*client) @@ -241,11 +249,12 @@ async fn should_notify_about_storage_changes() { // NOTE: previous versions of the subscription code used to return an empty value for the // "initial" storage change here assert_matches!(timeout_secs(1, sub.next::>()).await, Ok(Some(_))); - assert_matches!(timeout_secs(1, sub.next::>()).await, Ok(None)); } #[tokio::test] async fn should_send_initial_storage_changes_and_notifications() { + init_logger(); + let mut sub = { let mut client = Arc::new(substrate_test_runtime_client::new()); let (api, _child) = new_full(client.clone(), test_executor(), DenyUnsafe::No); @@ -263,7 +272,10 @@ async fn should_send_initial_storage_changes_and_notifications() { let api_rpc = api.into_rpc(); let sub = api_rpc - .subscribe("state_subscribeStorage", [[StorageKey(alice_balance_key)]]) + .subscribe_unbounded( + "state_subscribeStorage", + [[StorageKey(alice_balance_key.to_vec())]], + ) .await .unwrap(); @@ -288,9 +300,6 @@ async fn should_send_initial_storage_changes_and_notifications() { assert_matches!(timeout_secs(1, sub.next::>()).await, Ok(Some(_))); assert_matches!(timeout_secs(1, sub.next::>()).await, Ok(Some(_))); - - // No more messages to follow - assert_matches!(timeout_secs(1, sub.next::>()).await, Ok(None)); } #[tokio::test] @@ -393,108 +402,48 @@ async fn should_query_storage() { assert_eq!(result.unwrap(), expected); // Inverted range. - let result = api.query_storage(keys.clone(), block1_hash, Some(genesis_hash)); - - assert_eq!( - result.map_err(|e| e.to_string()), - Err(RpcError::Call(RpcCallError::Custom(ErrorObject::owned( - 4001, - Error::InvalidBlockRange { - from: format!("1 ({:?})", block1_hash), - to: format!("0 ({:?})", genesis_hash), - details: "from number > to number".to_owned(), - } - .to_string(), - None::<()>, - )))) - .map_err(|e| e.to_string()) + assert_matches!( + api.query_storage(keys.clone(), block1_hash, Some(genesis_hash)), + Err(Error::InvalidBlockRange { from, to, details }) if from == format!("1 ({:?})", block1_hash) && to == format!("0 ({:?})", genesis_hash) && details == "from number > to number".to_owned() ); let random_hash1 = H256::random(); let random_hash2 = H256::random(); // Invalid second hash. - let result = api.query_storage(keys.clone(), genesis_hash, Some(random_hash1)); - - assert_eq!( - result.map_err(|e| e.to_string()), - Err(RpcError::Call(RpcCallError::Custom(ErrorObject::owned( - 4001, - Error::InvalidBlockRange { - from: format!("{:?}", genesis_hash), - to: format!("{:?}", Some(random_hash1)), - details: format!( - "UnknownBlock: Header was not found in the database: {:?}", - random_hash1 - ), - } - .to_string(), - None::<()>, - )))) - .map_err(|e| e.to_string()) + assert_matches!( + api.query_storage(keys.clone(), genesis_hash, Some(random_hash1)), + Err(Error::InvalidBlockRange { from, to, details }) if from == format!("{:?}", genesis_hash) && to == format!("{:?}", Some(random_hash1)) && details == format!( + "UnknownBlock: Header was not found in the database: {:?}", + random_hash1 + ) ); // Invalid first hash with Some other hash. - let result = api.query_storage(keys.clone(), random_hash1, Some(genesis_hash)); - - assert_eq!( - result.map_err(|e| e.to_string()), - Err(RpcError::Call(RpcCallError::Custom(ErrorObject::owned( - 4001, - Error::InvalidBlockRange { - from: format!("{:?}", random_hash1), - to: format!("{:?}", Some(genesis_hash)), - details: format!( - "UnknownBlock: Header was not found in the database: {:?}", - random_hash1 - ), - } - .to_string(), - None::<()>, - )))) - .map_err(|e| e.to_string()), + assert_matches!( + api.query_storage(keys.clone(), random_hash1, Some(genesis_hash)), + Err(Error::InvalidBlockRange { from, to, details }) if from == format!("{:?}", random_hash1) && to == format!("{:?}", Some(genesis_hash)) && details == format!( + "UnknownBlock: Header was not found in the database: {:?}", + random_hash1 + ) ); // Invalid first hash with None. - let result = api.query_storage(keys.clone(), random_hash1, None); - - assert_eq!( - result.map_err(|e| e.to_string()), - Err(RpcError::Call(RpcCallError::Custom(ErrorObject::owned( - 4001, - Error::InvalidBlockRange { - from: format!("{:?}", random_hash1), - to: format!("{:?}", Some(block2_hash)), // Best block hash. - details: format!( - "UnknownBlock: Header was not found in the database: {:?}", - random_hash1 - ), - } - .to_string(), - None::<()>, - )))) - .map_err(|e| e.to_string()), + assert_matches!( + api.query_storage(keys.clone(), random_hash1, None), + Err(Error::InvalidBlockRange { from, to, details }) if from == format!("{:?}", random_hash1) && to == format!("{:?}", Some(block2_hash)) && details == format!( + "UnknownBlock: Header was not found in the database: {:?}", + random_hash1 + ) ); // Both hashes invalid. - let result = api.query_storage(keys.clone(), random_hash1, Some(random_hash2)); - - assert_eq!( - result.map_err(|e| e.to_string()), - Err(RpcError::Call(RpcCallError::Custom(ErrorObject::owned( - 4001, - Error::InvalidBlockRange { - from: format!("{:?}", random_hash1), // First hash not found. - to: format!("{:?}", Some(random_hash2)), - details: format!( - "UnknownBlock: Header was not found in the database: {:?}", - random_hash1 - ), - } - .to_string(), - None::<()> - )))) - .map_err(|e| e.to_string()), + assert_matches!( + api.query_storage(keys.clone(), random_hash1, Some(random_hash2)), + Err(Error::InvalidBlockRange { from, to, details }) if from == format!("{:?}", random_hash1) && to == format!("{:?}", Some(random_hash2)) && details == format!( + "UnknownBlock: Header was not found in the database: {:?}", + random_hash1 + ) ); // single block range @@ -548,7 +497,7 @@ async fn should_notify_on_runtime_version_initially() { let api_rpc = api.into_rpc(); let sub = api_rpc - .subscribe("state_subscribeRuntimeVersion", EmptyParams::new()) + .subscribe_unbounded("state_subscribeRuntimeVersion", EmptyParams::new()) .await .unwrap(); @@ -557,9 +506,6 @@ async fn should_notify_on_runtime_version_initially() { // assert initial version sent. assert_matches!(timeout_secs(10, sub.next::()).await, Ok(Some(_))); - - sub.close(); - assert_matches!(timeout_secs(10, sub.next::()).await, Ok(None)); } #[test] @@ -572,12 +518,14 @@ fn should_deserialize_storage_key() { #[tokio::test] async fn wildcard_storage_subscriptions_are_rpc_unsafe() { + init_logger(); + let client = Arc::new(substrate_test_runtime_client::new()); let (api, _child) = new_full(client, test_executor(), DenyUnsafe::Yes); let api_rpc = api.into_rpc(); - let err = api_rpc.subscribe("state_subscribeStorage", EmptyParams::new()).await; - assert_matches!(err, Err(RpcError::Call(RpcCallError::Custom(e))) if e.message() == "RPC call is unsafe to be called externally"); + 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"); } #[tokio::test] @@ -587,7 +535,7 @@ async fn concrete_storage_subscriptions_are_rpc_safe() { let api_rpc = api.into_rpc(); let key = StorageKey(STORAGE_KEY.to_vec()); - let sub = api_rpc.subscribe("state_subscribeStorage", [[key]]).await; + let sub = api_rpc.subscribe_unbounded("state_subscribeStorage", [[key]]).await; assert!(sub.is_ok()); } diff --git a/substrate/client/rpc/src/system/mod.rs b/substrate/client/rpc/src/system/mod.rs index 0da4f8d0e211..8c7510c64cb5 100644 --- a/substrate/client/rpc/src/system/mod.rs +++ b/substrate/client/rpc/src/system/mod.rs @@ -22,17 +22,12 @@ mod tests; use futures::channel::oneshot; -use jsonrpsee::{ - core::{async_trait, error::Error as JsonRpseeError, JsonValue, RpcResult}, - types::error::{CallError, ErrorCode, ErrorObject}, -}; +use jsonrpsee::core::{async_trait, JsonValue}; use sc_rpc_api::DenyUnsafe; use sc_tracing::logging; use sc_utils::mpsc::TracingUnboundedSender; use sp_runtime::traits::{self, Header as HeaderT}; -use self::error::Result; - pub use self::helpers::{Health, NodeRole, PeerInfo, SyncState, SystemInfo}; pub use sc_rpc_api::system::*; @@ -57,9 +52,9 @@ pub enum Request { /// Must return the state of the network. NetworkState(oneshot::Sender), /// Must return any potential parse error. - NetworkAddReservedPeer(String, oneshot::Sender>), + NetworkAddReservedPeer(String, oneshot::Sender>), /// Must return any potential parse error. - NetworkRemoveReservedPeer(String, oneshot::Sender>), + NetworkRemoveReservedPeer(String, oneshot::Sender>), /// Must return the list of reserved peers NetworkReservedPeers(oneshot::Sender>), /// Must return the node role. @@ -84,121 +79,109 @@ impl System { #[async_trait] impl SystemApiServer::Number> for System { - fn system_name(&self) -> RpcResult { + fn system_name(&self) -> Result { Ok(self.info.impl_name.clone()) } - fn system_version(&self) -> RpcResult { + fn system_version(&self) -> Result { Ok(self.info.impl_version.clone()) } - fn system_chain(&self) -> RpcResult { + fn system_chain(&self) -> Result { Ok(self.info.chain_name.clone()) } - fn system_type(&self) -> RpcResult { + fn system_type(&self) -> Result { Ok(self.info.chain_type.clone()) } - fn system_properties(&self) -> RpcResult { + fn system_properties(&self) -> Result { Ok(self.info.properties.clone()) } - async fn system_health(&self) -> RpcResult { + async fn system_health(&self) -> Result { let (tx, rx) = oneshot::channel(); let _ = self.send_back.unbounded_send(Request::Health(tx)); - rx.await.map_err(|e| JsonRpseeError::to_call_error(e)) + rx.await.map_err(|e| Error::Internal(e.to_string())) } - async fn system_local_peer_id(&self) -> RpcResult { + async fn system_local_peer_id(&self) -> Result { let (tx, rx) = oneshot::channel(); let _ = self.send_back.unbounded_send(Request::LocalPeerId(tx)); - rx.await.map_err(|e| JsonRpseeError::to_call_error(e)) + rx.await.map_err(|e| Error::Internal(e.to_string())) } - async fn system_local_listen_addresses(&self) -> RpcResult> { + async fn system_local_listen_addresses(&self) -> Result, Error> { let (tx, rx) = oneshot::channel(); let _ = self.send_back.unbounded_send(Request::LocalListenAddresses(tx)); - rx.await.map_err(|e| JsonRpseeError::to_call_error(e)) + rx.await.map_err(|e| Error::Internal(e.to_string())) } async fn system_peers( &self, - ) -> RpcResult::Number>>> { + ) -> Result::Number>>, Error> { self.deny_unsafe.check_if_safe()?; let (tx, rx) = oneshot::channel(); let _ = self.send_back.unbounded_send(Request::Peers(tx)); - rx.await.map_err(|e| JsonRpseeError::to_call_error(e)) + rx.await.map_err(|e| Error::Internal(e.to_string())) } - async fn system_network_state(&self) -> RpcResult { + async fn system_network_state(&self) -> Result { self.deny_unsafe.check_if_safe()?; let (tx, rx) = oneshot::channel(); let _ = self.send_back.unbounded_send(Request::NetworkState(tx)); - rx.await.map_err(|e| JsonRpseeError::to_call_error(e)) + rx.await.map_err(|e| Error::Internal(e.to_string())) } - async fn system_add_reserved_peer(&self, peer: String) -> RpcResult<()> { + async fn system_add_reserved_peer(&self, peer: String) -> Result<(), Error> { self.deny_unsafe.check_if_safe()?; let (tx, rx) = oneshot::channel(); let _ = self.send_back.unbounded_send(Request::NetworkAddReservedPeer(peer, tx)); match rx.await { Ok(Ok(())) => Ok(()), - Ok(Err(e)) => Err(JsonRpseeError::from(e)), - Err(e) => Err(JsonRpseeError::to_call_error(e)), + Ok(Err(e)) => Err(e), + Err(e) => Err(Error::Internal(e.to_string())), } } - async fn system_remove_reserved_peer(&self, peer: String) -> RpcResult<()> { + async fn system_remove_reserved_peer(&self, peer: String) -> Result<(), Error> { self.deny_unsafe.check_if_safe()?; let (tx, rx) = oneshot::channel(); let _ = self.send_back.unbounded_send(Request::NetworkRemoveReservedPeer(peer, tx)); match rx.await { Ok(Ok(())) => Ok(()), - Ok(Err(e)) => Err(JsonRpseeError::from(e)), - Err(e) => Err(JsonRpseeError::to_call_error(e)), + Ok(Err(e)) => Err(e), + Err(e) => Err(Error::Internal(e.to_string())), } } - async fn system_reserved_peers(&self) -> RpcResult> { + async fn system_reserved_peers(&self) -> Result, Error> { let (tx, rx) = oneshot::channel(); let _ = self.send_back.unbounded_send(Request::NetworkReservedPeers(tx)); - rx.await.map_err(|e| JsonRpseeError::to_call_error(e)) + rx.await.map_err(|e| Error::Internal(e.to_string())) } - async fn system_node_roles(&self) -> RpcResult> { + async fn system_node_roles(&self) -> Result, Error> { let (tx, rx) = oneshot::channel(); let _ = self.send_back.unbounded_send(Request::NodeRoles(tx)); - rx.await.map_err(|e| JsonRpseeError::to_call_error(e)) + rx.await.map_err(|e| Error::Internal(e.to_string())) } - async fn system_sync_state(&self) -> RpcResult::Number>> { + async fn system_sync_state(&self) -> Result::Number>, Error> { let (tx, rx) = oneshot::channel(); let _ = self.send_back.unbounded_send(Request::SyncState(tx)); - rx.await.map_err(|e| JsonRpseeError::to_call_error(e)) + rx.await.map_err(|e| Error::Internal(e.to_string())) } - fn system_add_log_filter(&self, directives: String) -> RpcResult<()> { + fn system_add_log_filter(&self, directives: String) -> Result<(), Error> { self.deny_unsafe.check_if_safe()?; logging::add_directives(&directives); - logging::reload_filter().map_err(|e| { - JsonRpseeError::Call(CallError::Custom(ErrorObject::owned( - ErrorCode::InternalError.code(), - e, - None::<()>, - ))) - }) + logging::reload_filter().map_err(|e| Error::Internal(e)) } - fn system_reset_log_filter(&self) -> RpcResult<()> { + fn system_reset_log_filter(&self) -> Result<(), Error> { self.deny_unsafe.check_if_safe()?; - logging::reset_log_filter().map_err(|e| { - JsonRpseeError::Call(CallError::Custom(ErrorObject::owned( - ErrorCode::InternalError.code(), - e, - None::<()>, - ))) - }) + logging::reset_log_filter().map_err(|e| Error::Internal(e)) } } diff --git a/substrate/client/rpc/src/system/tests.rs b/substrate/client/rpc/src/system/tests.rs index b6bfec7736b0..21d13ccfafaa 100644 --- a/substrate/client/rpc/src/system/tests.rs +++ b/substrate/client/rpc/src/system/tests.rs @@ -20,8 +20,7 @@ use super::{helpers::SyncState, *}; use assert_matches::assert_matches; use futures::prelude::*; use jsonrpsee::{ - core::Error as RpcError, - types::{error::CallError, EmptyServerParams as EmptyParams}, + core::{EmptyServerParams as EmptyParams, Error as RpcError}, RpcModule, }; use sc_network::{self, config::Role, PeerId}; @@ -312,7 +311,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(CallError::Custom(err))) if err.message().contains("Peer id is missing from the address") + Err(RpcError::Call(err)) if err.message().contains("Peer id is missing from the address") ); } @@ -328,7 +327,7 @@ async fn system_network_remove_reserved() { assert_matches!( api(None).call::<_, String>("system_removeReservedPeer", bad_peer_id).await, - Err(RpcError::Call(CallError::Custom(err))) if err.message().contains("base-58 decode error: provided string contained invalid character '/' at byte 0") + Err(RpcError::Call(err)) if err.message().contains("base-58 decode error: provided string contained invalid character '/' at byte 0") ); } #[tokio::test] diff --git a/substrate/client/rpc/src/testing.rs b/substrate/client/rpc/src/testing.rs index 6b6e1906d44d..e04f80a7b9e6 100644 --- a/substrate/client/rpc/src/testing.rs +++ b/substrate/client/rpc/src/testing.rs @@ -20,11 +20,50 @@ use std::{future::Future, sync::Arc}; -use sp_core::testing::TaskExecutor; +/// A task executor that can be used for running RPC tests. +/// +/// Warning: the tokio runtime must be initialized before calling this. +#[derive(Clone)] +pub struct TokioTestExecutor(tokio::runtime::Handle); + +impl TokioTestExecutor { + /// Create a new instance of `Self`. + pub fn new() -> Self { + Self(tokio::runtime::Handle::current()) + } +} + +impl Default for TokioTestExecutor { + fn default() -> Self { + Self::new() + } +} + +impl sp_core::traits::SpawnNamed for TokioTestExecutor { + fn spawn_blocking( + &self, + _name: &'static str, + _group: Option<&'static str>, + future: futures::future::BoxFuture<'static, ()>, + ) { + let handle = self.0.clone(); + self.0.spawn_blocking(move || { + handle.block_on(future); + }); + } + fn spawn( + &self, + _name: &'static str, + _group: Option<&'static str>, + future: futures::future::BoxFuture<'static, ()>, + ) { + self.0.spawn(future); + } +} /// Executor for testing. -pub fn test_executor() -> Arc { - Arc::new(TaskExecutor::default()) +pub fn test_executor() -> Arc { + Arc::new(TokioTestExecutor::default()) } /// Wrap a future in a timeout a little more concisely diff --git a/substrate/client/rpc/src/utils.rs b/substrate/client/rpc/src/utils.rs new file mode 100644 index 000000000000..b5ae4a2b6bc7 --- /dev/null +++ b/substrate/client/rpc/src/utils.rs @@ -0,0 +1,228 @@ +// 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 helpers. + +use crate::SubscriptionTaskExecutor; +use futures::{ + future::{self, Either, Fuse, FusedFuture}, + Future, FutureExt, Stream, StreamExt, +}; +use jsonrpsee::{PendingSubscriptionSink, SubscriptionMessage, SubscriptionSink}; +use sp_runtime::Serialize; +use std::collections::VecDeque; + +const DEFAULT_BUF_SIZE: usize = 16; + +/// A simple bounded VecDeque. +struct BoundedVecDeque { + inner: VecDeque, + max_cap: usize, +} + +impl BoundedVecDeque { + /// Create a new bounded VecDeque. + fn new() -> Self { + Self { inner: VecDeque::with_capacity(DEFAULT_BUF_SIZE), max_cap: DEFAULT_BUF_SIZE } + } + + fn push_back(&mut self, item: T) -> Result<(), ()> { + if self.inner.len() >= self.max_cap { + Err(()) + } else { + self.inner.push_back(item); + Ok(()) + } + } + + fn pop_front(&mut self) -> Option { + self.inner.pop_front() + } +} + +/// Feed items to the subscription from the underlying stream. +/// +/// This is bounded because the underlying streams in substrate are +/// unbounded and if the subscription can't keep with stream it can +/// cause the buffer to become very large and consume lots of memory. +/// +/// In such cases the subscription is dropped. +pub async fn pipe_from_stream(pending: PendingSubscriptionSink, mut stream: S) +where + S: Stream + Unpin + Send + 'static, + T: Serialize + Send + 'static, +{ + let mut buf = BoundedVecDeque::new(); + let accept_fut = pending.accept(); + + futures::pin_mut!(accept_fut); + + // Poll the stream while waiting for the subscription to be accepted + // + // If the `max_cap` is exceeded then the subscription is dropped. + let sink = loop { + match future::select(accept_fut, stream.next()).await { + 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); + return + } + accept_fut = f; + }, + // The connection was closed or the stream was closed. + _ => return, + } + }; + + inner_pipe_from_stream(sink, stream, buf).await +} + +async fn inner_pipe_from_stream( + sink: SubscriptionSink, + mut stream: S, + mut buf: BoundedVecDeque, +) where + S: Stream + Unpin + Send + 'static, + T: Serialize + Send + 'static, +{ + let mut next_fut = Box::pin(Fuse::terminated()); + let mut next_item = stream.next(); + let closed = sink.closed(); + + futures::pin_mut!(closed); + + loop { + if next_fut.is_terminated() { + if let Some(v) = buf.pop_front() { + let val = to_sub_message(&sink, &v); + next_fut.set(async { sink.send(val).await }.fuse()); + } + } + + match future::select(closed, future::select(next_fut, next_item)).await { + // Send operation finished. + Either::Right((Either::Left((_, n)), c)) => { + next_item = n; + closed = c; + next_fut = Box::pin(Fuse::terminated()); + }, + // 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); + return + } + + next_fut = n; + closed = c; + next_item = stream.next(); + }, + // Stream "finished". + // + // Process remaining items and terminate. + Either::Right((Either::Right((None, pending_fut)), _)) => { + if pending_fut.await.is_err() { + return; + } + + while let Some(v) = buf.pop_front() { + let val = to_sub_message(&sink, &v); + if sink.send(val).await.is_err() { + return; + } + } + + return; + }, + // Subscription was closed. + Either::Left(_) => return, + } + } +} + +/// Builds a subscription message. +/// +/// # Panics +/// +/// This function panics `Serialize` fails and it is treated a bug. +pub fn to_sub_message(sink: &SubscriptionSink, result: &impl Serialize) -> SubscriptionMessage { + SubscriptionMessage::new(sink.method_name(), sink.subscription_id(), result) + .expect("Serialize infallible; qed") +} + +/// Helper for spawning non-blocking rpc subscription task. +pub fn spawn_subscription_task( + executor: &SubscriptionTaskExecutor, + fut: impl Future + Send + 'static, +) { + executor.spawn("substrate-rpc-subscription", Some("rpc"), fut.boxed()); +} + +#[cfg(test)] +mod tests { + use super::pipe_from_stream; + use futures::StreamExt; + use jsonrpsee::{core::EmptyServerParams, RpcModule, Subscription}; + + async fn subscribe() -> Subscription { + let mut module = RpcModule::new(()); + module + .register_subscription("sub", "my_sub", "unsub", |_, pending, _| async move { + let stream = futures::stream::iter([0; 16]); + pipe_from_stream(pending, stream).await; + Ok(()) + }) + .unwrap(); + + module.subscribe("sub", EmptyServerParams::new(), 1).await.unwrap() + } + + #[tokio::test] + async fn pipe_from_stream_works() { + let mut sub = subscribe().await; + let mut rx = 0; + + while let Some(Ok(_)) = sub.next::().await { + rx += 1; + } + + assert_eq!(rx, 16); + } + + #[tokio::test] + async fn pipe_from_stream_is_bounded() { + let (tx, mut rx) = futures::channel::mpsc::unbounded::<()>(); + + let mut module = RpcModule::new(tx); + module + .register_subscription("sub", "my_sub", "unsub", |_, pending, ctx| async move { + let stream = futures::stream::iter([0; 32]); + pipe_from_stream(pending, stream).await; + _ = ctx.unbounded_send(()); + Ok(()) + }) + .unwrap(); + + let mut sub = module.subscribe("sub", EmptyServerParams::new(), 1).await.unwrap(); + + // When the 17th item arrives the subscription is dropped + _ = rx.next().await.unwrap(); + assert!(sub.next::().await.is_none()); + } +} diff --git a/substrate/client/service/Cargo.toml b/substrate/client/service/Cargo.toml index 576a8aac8e49..b011d3bdb947 100644 --- a/substrate/client/service/Cargo.toml +++ b/substrate/client/service/Cargo.toml @@ -28,7 +28,7 @@ runtime-benchmarks = [ ] [dependencies] -jsonrpsee = { version = "0.16.2", features = ["server"] } +jsonrpsee = { version = "0.20.3", features = ["server"] } thiserror = "1.0.48" futures = "0.3.21" rand = "0.8.5" diff --git a/substrate/client/service/src/config.rs b/substrate/client/service/src/config.rs index c2ce67df7eaf..3e68f5b58def 100644 --- a/substrate/client/service/src/config.rs +++ b/substrate/client/service/src/config.rs @@ -100,6 +100,8 @@ pub struct Configuration { pub rpc_max_subs_per_conn: u32, /// JSON-RPC server default port. pub rpc_port: u16, + /// The number of messages the JSON-RPC server is allowed to keep in memory. + pub rpc_message_buffer_capacity: u32, /// Prometheus endpoint configuration. `None` if disabled. pub prometheus_config: Option, /// Telemetry service URL. `None` if disabled. diff --git a/substrate/client/service/src/lib.rs b/substrate/client/service/src/lib.rs index bec1044daab4..875cb9ca79e2 100644 --- a/substrate/client/service/src/lib.rs +++ b/substrate/client/service/src/lib.rs @@ -37,7 +37,7 @@ mod task_manager; use std::{collections::HashMap, net::SocketAddr}; use codec::{Decode, Encode}; -use futures::{channel::mpsc, pin_mut, FutureExt, StreamExt}; +use futures::{pin_mut, FutureExt, StreamExt}; use jsonrpsee::{core::Error as JsonRpseeError, RpcModule}; use log::{debug, error, warn}; use sc_client_api::{blockchain::HeaderBackend, BlockBackend, BlockchainEvents, ProofProvider}; @@ -109,9 +109,15 @@ impl RpcHandlers { pub async fn rpc_query( &self, json_query: &str, - ) -> Result<(String, mpsc::UnboundedReceiver), JsonRpseeError> { + ) -> Result<(String, tokio::sync::mpsc::Receiver), JsonRpseeError> { + // Because `tokio::sync::mpsc::channel` is used under the hood + // it will panic if it's set to usize::MAX. + // + // 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) + .raw_json_request(json_query, TOKIO_MPSC_MAX_SIZE) .await .map(|(method_res, recv)| (method_res.result, recv)) } @@ -394,6 +400,7 @@ where max_payload_in_mb: config.rpc_max_request_size, max_payload_out_mb: config.rpc_max_response_size, max_subs_per_conn: config.rpc_max_subs_per_conn, + message_buffer_capacity: config.rpc_message_buffer_capacity, rpc_api: gen_rpc_module(deny_unsafe(addr, &config.rpc_methods))?, metrics, id_provider: rpc_id_provider, diff --git a/substrate/client/service/test/src/lib.rs b/substrate/client/service/test/src/lib.rs index 456df73459a3..9b88300bf530 100644 --- a/substrate/client/service/test/src/lib.rs +++ b/substrate/client/service/test/src/lib.rs @@ -253,6 +253,7 @@ fn node_config< rpc_id_provider: Default::default(), rpc_max_subs_per_conn: Default::default(), rpc_port: 9944, + rpc_message_buffer_capacity: Default::default(), prometheus_config: None, telemetry_endpoints: None, default_heap_pages: None, diff --git a/substrate/client/sync-state-rpc/Cargo.toml b/substrate/client/sync-state-rpc/Cargo.toml index b3de9585ab45..6073c2ca0c09 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.16.2", features = ["client-core", "macros", "server"] } +jsonrpsee = { version = "0.20.3", 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/client/sync-state-rpc/src/lib.rs b/substrate/client/sync-state-rpc/src/lib.rs index dda8a7edfa9b..cb737cc6c52b 100644 --- a/substrate/client/sync-state-rpc/src/lib.rs +++ b/substrate/client/sync-state-rpc/src/lib.rs @@ -44,9 +44,9 @@ use std::sync::Arc; use jsonrpsee::{ - core::{async_trait, Error as JsonRpseeError, RpcResult}, + core::async_trait, proc_macros::rpc, - types::{error::CallError, ErrorObject}, + types::{ErrorObject, ErrorObjectOwned}, }; use sc_client_api::StorageData; @@ -80,13 +80,13 @@ pub enum Error { LightSyncStateExtensionNotFound, } -impl From> for JsonRpseeError { +impl From> for ErrorObjectOwned { fn from(error: Error) -> Self { let message = match error { Error::JsonRpc(s) => s, _ => error.to_string(), }; - CallError::Custom(ErrorObject::owned(1, message, None::<()>)).into() + ErrorObject::owned(1, message, None::<()>) } } @@ -126,10 +126,10 @@ pub struct LightSyncState { /// An api for sync state RPC calls. #[rpc(client, server)] -pub trait SyncStateApi { +pub trait SyncStateApi { /// Returns the JSON serialized chainspec running the node, with a sync state. #[method(name = "sync_state_genSyncSpec")] - async fn system_gen_sync_spec(&self, raw: bool) -> RpcResult; + async fn system_gen_sync_spec(&self, raw: bool) -> Result>; } /// An api for sync state RPC calls. @@ -188,12 +188,12 @@ where } #[async_trait] -impl SyncStateApiServer for SyncState +impl SyncStateApiServer for SyncState where Block: BlockT, Backend: HeaderBackend + sc_client_api::AuxStore + 'static, { - async fn system_gen_sync_spec(&self, raw: bool) -> RpcResult { + async fn system_gen_sync_spec(&self, raw: bool) -> Result> { let current_sync_state = self.build_sync_state().await?; let mut chain_spec = self.chain_spec.cloned_box(); @@ -202,10 +202,11 @@ where ) .ok_or(Error::::LightSyncStateExtensionNotFound)?; - let val = serde_json::to_value(¤t_sync_state)?; + let val = serde_json::to_value(¤t_sync_state) + .map_err(|e| Error::::JsonRpc(e.to_string()))?; *extension = Some(val); let json_str = chain_spec.as_json(raw).map_err(|e| Error::::JsonRpc(e))?; - serde_json::from_str(&json_str).map_err(Into::into) + serde_json::from_str(&json_str).map_err(|e| Error::::JsonRpc(e.to_string())) } } diff --git a/substrate/frame/support/src/traits/tokens/fungible/regular.rs b/substrate/frame/support/src/traits/tokens/fungible/regular.rs index f15c3418d0ac..0157b08bd137 100644 --- a/substrate/frame/support/src/traits/tokens/fungible/regular.rs +++ b/substrate/frame/support/src/traits/tokens/fungible/regular.rs @@ -321,7 +321,7 @@ where let _extra = Self::can_withdraw(source, amount).into_result(preservation != Expendable)?; Self::can_deposit(dest, amount, Extant).into_result()?; if source == dest { - return Ok(amount); + return Ok(amount) } Self::decrease_balance(source, amount, BestEffort, preservation, Polite)?; diff --git a/substrate/frame/transaction-payment/rpc/Cargo.toml b/substrate/frame/transaction-payment/rpc/Cargo.toml index 5a574a944d82..162c4ce77f72 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.16.2", features = ["client-core", "macros", "server"] } +jsonrpsee = { version = "0.20.3", 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/frame/transaction-payment/rpc/src/lib.rs b/substrate/frame/transaction-payment/rpc/src/lib.rs index 7f8ed4b80267..f5323cf852e9 100644 --- a/substrate/frame/transaction-payment/rpc/src/lib.rs +++ b/substrate/frame/transaction-payment/rpc/src/lib.rs @@ -21,9 +21,12 @@ use std::{convert::TryInto, sync::Arc}; use codec::{Codec, Decode}; use jsonrpsee::{ - core::{Error as JsonRpseeError, RpcResult}, + core::RpcResult, proc_macros::rpc, - types::error::{CallError, ErrorCode, ErrorObject}, + types::{ + error::{ErrorCode, ErrorObject}, + ErrorObjectOwned, + }, }; use pallet_transaction_payment_rpc_runtime_api::{FeeDetails, InclusionFee, RuntimeDispatchInfo}; use sp_api::ProvideRuntimeApi; @@ -100,19 +103,15 @@ where let encoded_len = encoded_xt.len() as u32; let uxt: Block::Extrinsic = Decode::decode(&mut &*encoded_xt).map_err(|e| { - CallError::Custom(ErrorObject::owned( + ErrorObject::owned( Error::DecodeError.into(), "Unable to query dispatch info.", Some(format!("{:?}", e)), - )) + ) })?; - fn map_err(error: impl ToString, desc: &'static str) -> CallError { - CallError::Custom(ErrorObject::owned( - Error::RuntimeError.into(), - desc, - Some(error.to_string()), - )) + fn map_err(error: impl ToString, desc: &'static str) -> ErrorObjectOwned { + ErrorObject::owned(Error::RuntimeError.into(), desc, Some(error.to_string())) } let res = api @@ -137,27 +136,27 @@ where let encoded_len = encoded_xt.len() as u32; let uxt: Block::Extrinsic = Decode::decode(&mut &*encoded_xt).map_err(|e| { - CallError::Custom(ErrorObject::owned( + ErrorObject::owned( Error::DecodeError.into(), "Unable to query fee details.", Some(format!("{:?}", e)), - )) + ) })?; let fee_details = api.query_fee_details(at_hash, uxt, encoded_len).map_err(|e| { - CallError::Custom(ErrorObject::owned( + ErrorObject::owned( Error::RuntimeError.into(), "Unable to query fee details.", Some(e.to_string()), - )) + ) })?; let try_into_rpc_balance = |value: Balance| { value.try_into().map_err(|_| { - JsonRpseeError::Call(CallError::Custom(ErrorObject::owned( + ErrorObject::owned( ErrorCode::InvalidParams.code(), format!("{} doesn't fit in NumberOrHex representation", value), None::<()>, - ))) + ) }) }; diff --git a/substrate/frame/transaction-payment/src/types.rs b/substrate/frame/transaction-payment/src/types.rs index cbe85309b856..25cecc58a63a 100644 --- a/substrate/frame/transaction-payment/src/types.rs +++ b/substrate/frame/transaction-payment/src/types.rs @@ -94,7 +94,7 @@ impl FeeDetails { /// Information related to a dispatchable's class, weight, and fee that can be queried from the /// runtime. #[derive(Eq, PartialEq, Encode, Decode, Default, TypeInfo)] -#[cfg_attr(feature = "std", derive(Debug, Serialize, Deserialize))] +#[cfg_attr(feature = "std", derive(Debug, Serialize, Deserialize, Clone))] #[cfg_attr(feature = "std", serde(rename_all = "camelCase"))] #[cfg_attr( feature = "std", diff --git a/substrate/primitives/core/Cargo.toml b/substrate/primitives/core/Cargo.toml index a167f12929eb..ce38d201d94c 100644 --- a/substrate/primitives/core/Cargo.toml +++ b/substrate/primitives/core/Cargo.toml @@ -27,7 +27,7 @@ hash-db = { version = "0.16.0", default-features = false } hash256-std-hasher = { version = "0.15.2", default-features = false } bs58 = { version = "0.5.0", default-features = false, optional = true } rand = { version = "0.8.5", features = ["small_rng"], optional = true } -substrate-bip39 = { version = "0.4.4", optional = true } +substrate-bip39 = { version = "0.4.5", optional = true } bip39 = { version = "2.0.0", default-features = false } zeroize = { version = "1.4.3", default-features = false } secrecy = { version = "0.8.0", default-features = false } diff --git a/substrate/primitives/rpc/src/list.rs b/substrate/primitives/rpc/src/list.rs index 860e5161b97c..f1b06f3d2231 100644 --- a/substrate/primitives/rpc/src/list.rs +++ b/substrate/primitives/rpc/src/list.rs @@ -29,7 +29,7 @@ use serde::{Deserialize, Serialize}; /// /// Also it's nice to be able to maintain backward compatibility for methods that /// were initially taking a value and now we want to expand them to take a list. -#[derive(Serialize, Deserialize, Debug, PartialEq)] +#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)] #[serde(untagged)] pub enum ListOrValue { /// A list of values of given type. diff --git a/substrate/primitives/storage/src/lib.rs b/substrate/primitives/storage/src/lib.rs index 3528d0558f53..79c090cabf8d 100644 --- a/substrate/primitives/storage/src/lib.rs +++ b/substrate/primitives/storage/src/lib.rs @@ -178,7 +178,7 @@ pub struct Storage { /// Storage change set #[derive(RuntimeDebug)] -#[cfg_attr(feature = "serde", derive(Serialize, Deserialize, PartialEq, Eq))] +#[cfg_attr(feature = "serde", derive(Serialize, Deserialize, PartialEq, Eq, Clone))] #[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] pub struct StorageChangeSet { /// Block hash diff --git a/substrate/test-utils/client/Cargo.toml b/substrate/test-utils/client/Cargo.toml index 79071e19e281..14f55f645465 100644 --- a/substrate/test-utils/client/Cargo.toml +++ b/substrate/test-utils/client/Cargo.toml @@ -39,3 +39,4 @@ sp-keyring = { path = "../../primitives/keyring" } sp-keystore = { path = "../../primitives/keystore" } sp-runtime = { path = "../../primitives/runtime" } sp-state-machine = { path = "../../primitives/state-machine" } +tokio = { version = "1.22.0", features = ["sync"] } diff --git a/substrate/test-utils/client/src/lib.rs b/substrate/test-utils/client/src/lib.rs index f383f7c3dc3e..e3f06e275635 100644 --- a/substrate/test-utils/client/src/lib.rs +++ b/substrate/test-utils/client/src/lib.rs @@ -284,7 +284,7 @@ pub struct RpcTransactionOutput { /// The output string of the transaction if any. pub result: String, /// An async receiver if data will be returned via a callback. - pub receiver: futures::channel::mpsc::UnboundedReceiver, + pub receiver: tokio::sync::mpsc::Receiver, } impl std::fmt::Debug for RpcTransactionOutput { @@ -344,7 +344,7 @@ impl RpcHandlersExt for RpcHandlers { pub(crate) fn parse_rpc_result( result: String, - receiver: futures::channel::mpsc::UnboundedReceiver, + receiver: tokio::sync::mpsc::Receiver, ) -> Result { let json: serde_json::Value = serde_json::from_str(&result).expect("the result can only be a JSONRPC string; qed"); @@ -398,7 +398,7 @@ where mod tests { #[test] fn parses_error_properly() { - let (_, rx) = futures::channel::mpsc::unbounded(); + let (_, rx) = tokio::sync::mpsc::channel(1); assert!(super::parse_rpc_result( r#"{ "jsonrpc": "2.0", @@ -410,7 +410,7 @@ mod tests { ) .is_ok()); - let (_, rx) = futures::channel::mpsc::unbounded(); + let (_, rx) = tokio::sync::mpsc::channel(1); let error = super::parse_rpc_result( r#"{ "jsonrpc": "2.0", @@ -428,7 +428,7 @@ mod tests { assert_eq!(error.message, "Method not found"); assert!(error.data.is_none()); - let (_, rx) = futures::channel::mpsc::unbounded(); + let (_, rx) = tokio::sync::mpsc::channel(1); let error = super::parse_rpc_result( r#"{ "jsonrpc": "2.0", diff --git a/substrate/utils/frame/remote-externalities/Cargo.toml b/substrate/utils/frame/remote-externalities/Cargo.toml index ae5d0097d5e6..f8e695112289 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.16.2", features = ["http-client"] } +jsonrpsee = { version = "0.20.3", 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/remote-externalities/src/lib.rs b/substrate/utils/frame/remote-externalities/src/lib.rs index ce6b25da80e0..47c0508485cd 100644 --- a/substrate/utils/frame/remote-externalities/src/lib.rs +++ b/substrate/utils/frame/remote-externalities/src/lib.rs @@ -189,7 +189,8 @@ impl Transport { uri.clone() }; let http_client = HttpClientBuilder::default() - .max_request_body_size(u32::MAX) + .max_request_size(u32::MAX) + .max_response_size(u32::MAX) .request_timeout(std::time::Duration::from_secs(60 * 5)) .build(uri) .map_err(|e| { diff --git a/substrate/utils/frame/rpc/client/Cargo.toml b/substrate/utils/frame/rpc/client/Cargo.toml index 1e8a298726eb..6477339f348a 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.16.2", features = ["ws-client"] } +jsonrpsee = { version = "0.20.3", 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 a6a667bef568..9349ee2d357b 100644 --- a/substrate/utils/frame/rpc/client/src/lib.rs +++ b/substrate/utils/frame/rpc/client/src/lib.rs @@ -61,10 +61,11 @@ pub use sc_rpc_api::{ /// Create a new `WebSocket` connection with shared settings. pub async fn ws_client(uri: impl AsRef) -> Result { WsClientBuilder::default() - .max_request_body_size(u32::MAX) + .max_request_size(u32::MAX) + .max_response_size(u32::MAX) .request_timeout(std::time::Duration::from_secs(60 * 10)) .connection_timeout(std::time::Duration::from_secs(60)) - .max_notifs_per_subscription(1024) + .max_buffer_capacity_per_subscription(1024) .build(uri) .await .map_err(|e| format!("`WsClientBuilder` failed to build: {:?}", e)) 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 6cd99e5a6fed..86336336f0f7 100644 --- a/substrate/utils/frame/rpc/state-trie-migration-rpc/Cargo.toml +++ b/substrate/utils/frame/rpc/state-trie-migration-rpc/Cargo.toml @@ -23,8 +23,7 @@ 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.16.2", features = ["client-core", "macros", "server"] } +jsonrpsee = { version = "0.20.3", features = ["client-core", "macros", "server"] } # Substrate Dependencies sc-client-api = { path = "../../../../client/api" } diff --git a/substrate/utils/frame/rpc/state-trie-migration-rpc/src/lib.rs b/substrate/utils/frame/rpc/state-trie-migration-rpc/src/lib.rs index d1175fdea907..f45258ea593d 100644 --- a/substrate/utils/frame/rpc/state-trie-migration-rpc/src/lib.rs +++ b/substrate/utils/frame/rpc/state-trie-migration-rpc/src/lib.rs @@ -18,9 +18,9 @@ //! Rpc for state migration. use jsonrpsee::{ - core::{Error as JsonRpseeError, RpcResult}, + core::RpcResult, proc_macros::rpc, - types::error::{CallError, ErrorCode, ErrorObject}, + types::error::{ErrorCode, ErrorObject, ErrorObjectOwned}, }; use sc_rpc_api::DenyUnsafe; use serde::{Deserialize, Serialize}; @@ -112,7 +112,7 @@ where } /// Current state migration status. -#[derive(Serialize, Deserialize)] +#[derive(Serialize, Deserialize, Clone)] #[serde(rename_all = "camelCase")] #[serde(deny_unknown_fields)] pub struct MigrationStatusResult { @@ -168,10 +168,10 @@ where } } -fn error_into_rpc_err(err: impl std::fmt::Display) -> JsonRpseeError { - JsonRpseeError::Call(CallError::Custom(ErrorObject::owned( +fn error_into_rpc_err(err: impl std::fmt::Display) -> ErrorObjectOwned { + ErrorObject::owned( ErrorCode::InternalError.code(), "Error while checking migration state", Some(err.to_string()), - ))) + ) } diff --git a/substrate/utils/frame/rpc/support/Cargo.toml b/substrate/utils/frame/rpc/support/Cargo.toml index 1cc6d8e98b36..b39b6df05e51 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.16.2", features = ["jsonrpsee-types"] } +jsonrpsee = { version = "0.20.3", 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.16.2", features = ["jsonrpsee-types", "ws-client"] } +jsonrpsee = { version = "0.20.3", 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 84c3265c93d3..a7ca7455c550 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.16.2", features = ["client-core", "macros", "server"] } +jsonrpsee = { version = "0.20.3", features = ["client-core", "macros", "server"] } futures = "0.3.21" log = "0.4.17" frame-system-rpc-runtime-api = { path = "../../../../frame/system/rpc/runtime-api" } diff --git a/substrate/utils/frame/rpc/system/src/lib.rs b/substrate/utils/frame/rpc/system/src/lib.rs index f467a8798904..bb0592599b2a 100644 --- a/substrate/utils/frame/rpc/system/src/lib.rs +++ b/substrate/utils/frame/rpc/system/src/lib.rs @@ -23,7 +23,7 @@ use codec::{self, Codec, Decode, Encode}; use jsonrpsee::{ core::{async_trait, RpcResult}, proc_macros::rpc, - types::error::{CallError, ErrorObject}, + types::error::ErrorObject, }; use sc_rpc_api::DenyUnsafe; @@ -103,11 +103,11 @@ where let best = self.client.info().best_hash; let nonce = api.account_nonce(best, account.clone()).map_err(|e| { - CallError::Custom(ErrorObject::owned( + ErrorObject::owned( Error::RuntimeError.into(), "Unable to query nonce.", Some(e.to_string()), - )) + ) })?; Ok(adjust_nonce(&*self.pool, account, nonce)) } @@ -125,28 +125,28 @@ where let uxt: ::Extrinsic = Decode::decode(&mut &*extrinsic).map_err(|e| { - CallError::Custom(ErrorObject::owned( + ErrorObject::owned( Error::DecodeError.into(), "Unable to dry run extrinsic", Some(e.to_string()), - )) + ) })?; let api_version = api .api_version::>(best_hash) .map_err(|e| { - CallError::Custom(ErrorObject::owned( + ErrorObject::owned( Error::RuntimeError.into(), "Unable to dry run extrinsic.", Some(e.to_string()), - )) + ) })? .ok_or_else(|| { - CallError::Custom(ErrorObject::owned( + ErrorObject::owned( Error::RuntimeError.into(), "Unable to dry run extrinsic.", Some(format!("Could not find `BlockBuilder` api for block `{:?}`.", best_hash)), - )) + ) })?; let result = if api_version < 6 { @@ -154,19 +154,19 @@ where api.apply_extrinsic_before_version_6(best_hash, uxt) .map(legacy::byte_sized_error::convert_to_latest) .map_err(|e| { - CallError::Custom(ErrorObject::owned( + ErrorObject::owned( Error::RuntimeError.into(), "Unable to dry run extrinsic.", Some(e.to_string()), - )) + ) })? } else { api.apply_extrinsic(best_hash, uxt).map_err(|e| { - CallError::Custom(ErrorObject::owned( + ErrorObject::owned( Error::RuntimeError.into(), "Unable to dry run extrinsic.", Some(e.to_string()), - )) + ) })? }; @@ -216,7 +216,6 @@ mod tests { use assert_matches::assert_matches; use futures::executor::block_on; - use jsonrpsee::{core::Error as JsonRpseeError, types::error::CallError}; use sc_transaction_pool::BasicPool; use sp_runtime::{ transaction_validity::{InvalidTransaction, TransactionValidityError}, @@ -274,7 +273,7 @@ mod tests { // when let res = accounts.dry_run(vec![].into(), None).await; - assert_matches!(res, Err(JsonRpseeError::Call(CallError::Custom(e))) => { + assert_matches!(res, Err(e) => { assert!(e.message().contains("RPC call is unsafe to be called externally")); }); }