diff --git a/Cargo.lock b/Cargo.lock index 8cb0e9c3094..54e6f03c9d5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -237,7 +237,7 @@ dependencies = [ "parking", "polling", "slab", - "socket2 0.4.2", + "socket2 0.4.4", "waker-fn", "winapi 0.3.9", ] @@ -288,7 +288,6 @@ dependencies = [ "async-global-executor", "async-io", "async-lock", - "async-process", "crossbeam-utils", "futures-channel", "futures-core", @@ -420,25 +419,18 @@ dependencies = [ "rustc-demangle", ] -[[package]] -name = "bae" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec107f431ee3d8a8e45e6dd117adab769556ef463959e77bf6a4888d5fd500cf" -dependencies = [ - "heck 0.3.3", - "proc-macro-error 0.4.12", - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "base-x" version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a4521f3e3d031370679b3b140beb36dfe4801b09ac77e30c61941f97df3ef28b" +[[package]] +name = "base16ct" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "349a06037c7bf932dd7e7d1f653678b2038b9ad46a74102f1fc7bd7872678cce" + [[package]] name = "base58" version = "0.2.0" @@ -451,6 +443,12 @@ version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" +[[package]] +name = "base64ct" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "71acf5509fc522cce1b100ac0121c635129bfd4d91cdf036bcc9b9935f97ccf5" + [[package]] name = "beef" version = "0.5.1" @@ -463,14 +461,15 @@ dependencies = [ [[package]] name = "beefy-gadget" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "beefy-primitives", "fnv", - "futures 0.3.19", + "futures 0.3.21", + "hex", "log", "parity-scale-codec", - "parking_lot 0.11.2", + "parking_lot 0.12.0", "sc-chain-spec", "sc-client-api", "sc-keystore", @@ -492,19 +491,18 @@ dependencies = [ [[package]] name = "beefy-gadget-rpc" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "beefy-gadget", "beefy-primitives", - "derive_more", - "futures 0.3.19", + "futures 0.3.21", "jsonrpc-core", "jsonrpc-core-client", "jsonrpc-derive", "jsonrpc-pubsub", "log", "parity-scale-codec", - "parking_lot 0.11.2", + "parking_lot 0.12.0", "sc-rpc", "sc-utils", "serde", @@ -516,12 +514,12 @@ dependencies = [ [[package]] name = "beefy-merkle-tree" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" [[package]] name = "beefy-primitives" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "parity-scale-codec", "scale-info", @@ -574,9 +572,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitvec" -version = "0.20.4" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7774144344a4faa177370406a7ff5f1da24303817368584c6206c8303eb07848" +checksum = "1489fcb93a5bb47da0462ca93ad252ad6af2145cce58d10d46a83931ba9f016b" dependencies = [ "funty", "radium", @@ -595,6 +593,15 @@ dependencies = [ "opaque-debug 0.3.0", ] +[[package]] +name = "blake2" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9cf849ee05b2ee5fba5e36f97ff8ec2533916700fc0758d40d92136a42f3388" +dependencies = [ + "digest 0.10.3", +] + [[package]] name = "blake2-rfc" version = "0.2.18" @@ -642,6 +649,20 @@ dependencies = [ "digest 0.9.0", ] +[[package]] +name = "blake3" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a08e53fc5a564bb15bfe6fae56bd71522205f1f91893f9c0116edad6496c183f" +dependencies = [ + "arrayref", + "arrayvec 0.7.2", + "cc", + "cfg-if 1.0.0", + "constant_time_eq", + "digest 0.10.3", +] + [[package]] name = "block-buffer" version = "0.7.3" @@ -741,6 +762,7 @@ dependencies = [ "frame-support", "smallvec", "sp-api", + "sp-runtime", "sp-std", "sp-version", ] @@ -807,6 +829,7 @@ dependencies = [ "frame-support", "smallvec", "sp-api", + "sp-runtime", "sp-std", "sp-version", ] @@ -969,12 +992,14 @@ dependencies = [ "pallet-transaction-payment", "parity-scale-codec", "scale-info", + "sp-api", "sp-core", "sp-runtime", "sp-state-machine", "sp-std", "sp-trie", "sp-version", + "static_assertions", ] [[package]] @@ -1041,6 +1066,17 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c4872d67bab6358e59559027aa3b9157c53d9358c51423c17554809a8858e0f8" +[[package]] +name = "bzip2-sys" +version = "0.1.11+1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "736a955f3fa7875102d57c82b8cac37ec45224a07fd32d58f9f7a186b6cd4cdc" +dependencies = [ + "cc", + "libc", + "pkg-config", +] + [[package]] name = "cache-padded" version = "1.1.1" @@ -1215,9 +1251,9 @@ dependencies = [ [[package]] name = "clap" -version = "3.0.12" +version = "3.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2afefa54b5c7dd40918dc1e09f213a171ab5937aadccab45e804780b238f9f43" +checksum = "d8c93436c21e4698bacadf42917db28b23017027a4deccb35dbe47a7e7840123" dependencies = [ "atty", "bitflags", @@ -1227,31 +1263,22 @@ dependencies = [ "os_str_bytes", "strsim 0.10.0", "termcolor", - "textwrap 0.14.2", + "textwrap 0.15.0", ] [[package]] name = "clap_derive" -version = "3.0.12" +version = "3.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fd2078197a22f338bd4fbf7d6387eb6f0d6a3c69e6cbc09f5c93e97321fd92a" +checksum = "da95d038ede1a964ce99f49cbe27a7fb538d1da595e4b4f70b8c8f338d17bf16" dependencies = [ "heck 0.4.0", - "proc-macro-error 1.0.4", + "proc-macro-error", "proc-macro2", "quote", "syn", ] -[[package]] -name = "cloudabi" -version = "0.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" -dependencies = [ - "bitflags", -] - [[package]] name = "concurrent-queue" version = "1.2.2" @@ -1262,10 +1289,10 @@ dependencies = [ ] [[package]] -name = "const_fn" -version = "0.4.8" +name = "const-oid" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f92cfa0fd5690b3cf8c1ef2cabbd9b7ef22fa53cf5e1f92b05103f6d5d1cf6e7" +checksum = "e4c78c047431fee22c1a7bb92e00ad095a02a983affe4d8a72e2a2c62c1b94f3" [[package]] name = "constant_time_eq" @@ -1470,13 +1497,26 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" +[[package]] +name = "crypto-bigint" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03c6a1d5fa1de37e071642dfa44ec552ca5b299adb128fab16138e24b548fd21" +dependencies = [ + "generic-array 0.14.4", + "rand_core 0.6.3", + "subtle", + "zeroize", +] + [[package]] name = "crypto-common" -version = "0.1.1" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "683d6b536309245c849479fba3da410962a43ed8e51c26b729208ec0ac2798d0" +checksum = "57952ca27b5e3606ff4dd79b0020231aaf9d6aa76dc05fd30137538c50bd3ce8" dependencies = [ "generic-array 0.14.4", + "typenum", ] [[package]] @@ -1505,7 +1545,7 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c1a816186fa68d9e426e3cb4ae4dff1fcd8e4a2c34b781bf7a822574a0d0aac8" dependencies = [ - "sct", + "sct 0.6.1", ] [[package]] @@ -1541,25 +1581,26 @@ dependencies = [ [[package]] name = "cumulus-client-cli" version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=master#a9630551c2cd877952ab769c862af4c81b0ccd3c" +source = "git+https://github.com/paritytech/cumulus?branch=master#4e952282914719fafd2df450993ccc2ce9395415" dependencies = [ - "clap 3.0.12", + "clap 3.1.6", "sc-cli", "sc-service", + "url 2.2.2", ] [[package]] name = "cumulus-client-collator" version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=master#a9630551c2cd877952ab769c862af4c81b0ccd3c" +source = "git+https://github.com/paritytech/cumulus?branch=master#4e952282914719fafd2df450993ccc2ce9395415" dependencies = [ "cumulus-client-consensus-common", "cumulus-client-network", "cumulus-primitives-core", "cumulus-relay-chain-interface", - "futures 0.3.19", + "futures 0.3.21", "parity-scale-codec", - "parking_lot 0.10.2", + "parking_lot 0.12.0", "polkadot-node-primitives", "polkadot-node-subsystem", "polkadot-overseer", @@ -1575,12 +1616,12 @@ dependencies = [ [[package]] name = "cumulus-client-consensus-aura" version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=master#a9630551c2cd877952ab769c862af4c81b0ccd3c" +source = "git+https://github.com/paritytech/cumulus?branch=master#4e952282914719fafd2df450993ccc2ce9395415" dependencies = [ "async-trait", "cumulus-client-consensus-common", "cumulus-primitives-core", - "futures 0.3.19", + "futures 0.3.21", "parity-scale-codec", "sc-client-api", "sc-consensus", @@ -1604,12 +1645,12 @@ dependencies = [ [[package]] name = "cumulus-client-consensus-common" version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=master#a9630551c2cd877952ab769c862af4c81b0ccd3c" +source = "git+https://github.com/paritytech/cumulus?branch=master#4e952282914719fafd2df450993ccc2ce9395415" dependencies = [ "async-trait", "cumulus-relay-chain-interface", "dyn-clone", - "futures 0.3.19", + "futures 0.3.21", "parity-scale-codec", "polkadot-primitives", "sc-client-api", @@ -1625,15 +1666,15 @@ dependencies = [ [[package]] name = "cumulus-client-network" version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=master#a9630551c2cd877952ab769c862af4c81b0ccd3c" +source = "git+https://github.com/paritytech/cumulus?branch=master#4e952282914719fafd2df450993ccc2ce9395415" dependencies = [ "async-trait", "cumulus-relay-chain-interface", "derive_more", - "futures 0.3.19", + "futures 0.3.21", "futures-timer", "parity-scale-codec", - "parking_lot 0.11.2", + "parking_lot 0.12.0", "polkadot-node-primitives", "polkadot-parachain", "polkadot-primitives", @@ -1650,18 +1691,18 @@ dependencies = [ [[package]] name = "cumulus-client-pov-recovery" version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=master#a9630551c2cd877952ab769c862af4c81b0ccd3c" +source = "git+https://github.com/paritytech/cumulus?branch=master#4e952282914719fafd2df450993ccc2ce9395415" dependencies = [ "cumulus-primitives-core", "cumulus-relay-chain-interface", - "futures 0.3.19", + "futures 0.3.21", "futures-timer", "parity-scale-codec", "polkadot-node-primitives", "polkadot-node-subsystem", "polkadot-overseer", "polkadot-primitives", - "rand 0.8.4", + "rand 0.8.5", "sc-client-api", "sc-consensus", "sp-api", @@ -1674,15 +1715,16 @@ dependencies = [ [[package]] name = "cumulus-client-service" version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=master#a9630551c2cd877952ab769c862af4c81b0ccd3c" +source = "git+https://github.com/paritytech/cumulus?branch=master#4e952282914719fafd2df450993ccc2ce9395415" dependencies = [ + "cumulus-client-cli", "cumulus-client-collator", "cumulus-client-consensus-common", "cumulus-client-pov-recovery", "cumulus-primitives-core", "cumulus-relay-chain-interface", "parity-scale-codec", - "parking_lot 0.10.2", + "parking_lot 0.12.0", "polkadot-overseer", "polkadot-primitives", "sc-chain-spec", @@ -1703,7 +1745,7 @@ dependencies = [ [[package]] name = "cumulus-pallet-aura-ext" version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=master#a9630551c2cd877952ab769c862af4c81b0ccd3c" +source = "git+https://github.com/paritytech/cumulus?branch=master#4e952282914719fafd2df450993ccc2ce9395415" dependencies = [ "frame-executive", "frame-support", @@ -1721,7 +1763,7 @@ dependencies = [ [[package]] name = "cumulus-pallet-dmp-queue" version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=master#a9630551c2cd877952ab769c862af4c81b0ccd3c" +source = "git+https://github.com/paritytech/cumulus?branch=master#4e952282914719fafd2df450993ccc2ce9395415" dependencies = [ "cumulus-primitives-core", "frame-support", @@ -1739,7 +1781,7 @@ dependencies = [ [[package]] name = "cumulus-pallet-parachain-system" version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=master#a9630551c2cd877952ab769c862af4c81b0ccd3c" +source = "git+https://github.com/paritytech/cumulus?branch=master#4e952282914719fafd2df450993ccc2ce9395415" dependencies = [ "cumulus-pallet-parachain-system-proc-macro", "cumulus-primitives-core", @@ -1769,9 +1811,9 @@ dependencies = [ [[package]] name = "cumulus-pallet-parachain-system-proc-macro" version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=master#a9630551c2cd877952ab769c862af4c81b0ccd3c" +source = "git+https://github.com/paritytech/cumulus?branch=master#4e952282914719fafd2df450993ccc2ce9395415" dependencies = [ - "proc-macro-crate 1.1.0", + "proc-macro-crate 1.1.3", "proc-macro2", "quote", "syn", @@ -1780,7 +1822,7 @@ dependencies = [ [[package]] name = "cumulus-pallet-xcm" version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=master#a9630551c2cd877952ab769c862af4c81b0ccd3c" +source = "git+https://github.com/paritytech/cumulus?branch=master#4e952282914719fafd2df450993ccc2ce9395415" dependencies = [ "cumulus-primitives-core", "frame-support", @@ -1797,7 +1839,7 @@ dependencies = [ [[package]] name = "cumulus-pallet-xcmp-queue" version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=master#a9630551c2cd877952ab769c862af4c81b0ccd3c" +source = "git+https://github.com/paritytech/cumulus?branch=master#4e952282914719fafd2df450993ccc2ce9395415" dependencies = [ "cumulus-primitives-core", "frame-support", @@ -1815,7 +1857,7 @@ dependencies = [ [[package]] name = "cumulus-primitives-core" version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=master#a9630551c2cd877952ab769c862af4c81b0ccd3c" +source = "git+https://github.com/paritytech/cumulus?branch=master#4e952282914719fafd2df450993ccc2ce9395415" dependencies = [ "frame-support", "parity-scale-codec", @@ -1831,7 +1873,7 @@ dependencies = [ [[package]] name = "cumulus-primitives-parachain-inherent" version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=master#a9630551c2cd877952ab769c862af4c81b0ccd3c" +source = "git+https://github.com/paritytech/cumulus?branch=master#4e952282914719fafd2df450993ccc2ce9395415" dependencies = [ "async-trait", "cumulus-primitives-core", @@ -1854,9 +1896,11 @@ dependencies = [ [[package]] name = "cumulus-primitives-timestamp" version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=master#a9630551c2cd877952ab769c862af4c81b0ccd3c" +source = "git+https://github.com/paritytech/cumulus?branch=master#4e952282914719fafd2df450993ccc2ce9395415" dependencies = [ "cumulus-primitives-core", + "futures 0.3.21", + "parity-scale-codec", "sp-inherents", "sp-std", "sp-timestamp", @@ -1865,7 +1909,7 @@ dependencies = [ [[package]] name = "cumulus-primitives-utility" version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=master#a9630551c2cd877952ab769c862af4c81b0ccd3c" +source = "git+https://github.com/paritytech/cumulus?branch=master#4e952282914719fafd2df450993ccc2ce9395415" dependencies = [ "cumulus-primitives-core", "frame-support", @@ -1880,58 +1924,61 @@ dependencies = [ ] [[package]] -name = "cumulus-relay-chain-interface" +name = "cumulus-relay-chain-inprocess-interface" version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=master#a9630551c2cd877952ab769c862af4c81b0ccd3c" +source = "git+https://github.com/paritytech/cumulus?branch=master#4e952282914719fafd2df450993ccc2ce9395415" dependencies = [ "async-trait", "cumulus-primitives-core", - "derive_more", - "futures 0.3.19", - "parking_lot 0.11.2", - "polkadot-overseer", + "cumulus-relay-chain-interface", + "futures 0.3.21", + "futures-timer", + "parking_lot 0.12.0", + "polkadot-client", + "polkadot-service", "sc-client-api", + "sc-consensus-babe", + "sc-network", "sc-service", + "sc-telemetry", + "sc-tracing", "sp-api", "sp-blockchain", + "sp-consensus", "sp-core", "sp-runtime", "sp-state-machine", - "thiserror", + "tracing", ] [[package]] -name = "cumulus-relay-chain-local" +name = "cumulus-relay-chain-interface" version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=master#a9630551c2cd877952ab769c862af4c81b0ccd3c" +source = "git+https://github.com/paritytech/cumulus?branch=master#4e952282914719fafd2df450993ccc2ce9395415" dependencies = [ "async-trait", "cumulus-primitives-core", - "cumulus-relay-chain-interface", - "futures 0.3.19", - "futures-timer", - "parking_lot 0.11.2", - "polkadot-client", + "derive_more", + "futures 0.3.21", + "jsonrpsee-core 0.9.0", + "parity-scale-codec", + "parking_lot 0.12.0", + "polkadot-overseer", "polkadot-service", "sc-client-api", - "sc-consensus-babe", - "sc-network", "sc-service", - "sc-telemetry", - "sc-tracing", "sp-api", "sp-blockchain", - "sp-consensus", "sp-core", "sp-runtime", "sp-state-machine", - "tracing", + "thiserror", ] [[package]] name = "cumulus-test-relay-sproof-builder" version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=master#a9630551c2cd877952ab769c862af4c81b0ccd3c" +source = "git+https://github.com/paritytech/cumulus?branch=master#4e952282914719fafd2df450993ccc2ce9395415" dependencies = [ "cumulus-primitives-core", "parity-scale-codec", @@ -1952,7 +1999,7 @@ dependencies = [ "openssl-probe", "openssl-sys", "schannel", - "socket2 0.4.2", + "socket2 0.4.4", "winapi 0.3.9", ] @@ -2024,6 +2071,15 @@ dependencies = [ "syn", ] +[[package]] +name = "der" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6919815d73839e7ad218de758883aae3a257ba6759ce7a9992501efbb53d705c" +dependencies = [ + "const-oid", +] + [[package]] name = "derivative" version = "2.2.0" @@ -2068,13 +2124,13 @@ dependencies = [ [[package]] name = "digest" -version = "0.10.1" +version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b697d66081d42af4fba142d56918a3cb21dc8eb63372c6b85d14f44fb9c5979b" +checksum = "f2fb860ca6fafa5552fb6d0e816a69c8e49f0908bf524e30a90d97c85892d506" dependencies = [ "block-buffer 0.10.0", "crypto-common", - "generic-array 0.14.4", + "subtle", ] [[package]] @@ -2118,12 +2174,6 @@ dependencies = [ "winapi 0.3.9", ] -[[package]] -name = "discard" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "212d0f5754cb6769937f4501cc0e67f4f4483c8d2c3e1e922ee9edbe4ab4c7c0" - [[package]] name = "dns-parser" version = "0.8.0" @@ -2179,6 +2229,17 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ee2626afccd7561a06cf1367e2950c4718ea04565e20fb5029b6c7d8ad09abcf" +[[package]] +name = "ecdsa" +version = "0.13.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0d69ae62e0ce582d56380743515fefaf1a8c70cec685d9677636d7e30ae9dc9" +dependencies = [ + "der", + "elliptic-curve", + "signature", +] + [[package]] name = "ed25519" version = "1.3.0" @@ -2208,6 +2269,24 @@ version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" +[[package]] +name = "elliptic-curve" +version = "0.11.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25b477563c2bfed38a3b7a60964c49e058b2510ad3f12ba3483fd8f62c2306d6" +dependencies = [ + "base16ct", + "crypto-bigint", + "der", + "ff", + "generic-array 0.14.4", + "group", + "rand_core 0.6.3", + "sec1", + "subtle", + "zeroize", +] + [[package]] name = "encoding_rs" version = "0.8.29" @@ -2327,45 +2406,42 @@ dependencies = [ ] [[package]] -name = "ethbloom" -version = "0.11.1" +name = "event-listener" +version = "2.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfb684ac8fa8f6c5759f788862bb22ec6fe3cb392f6bfd08e3c64b603661e3f8" -dependencies = [ - "crunchy", - "fixed-hash", - "impl-rlp", - "impl-serde", - "tiny-keccak", -] +checksum = "f7531096570974c3a9dcf9e4b8e1cede1ec26cf5046219fb3b9d897503b9be59" [[package]] -name = "ethereum-types" -version = "0.12.1" +name = "exit-future" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05136f7057fe789f06e6d41d07b34e6f70d8c86e5693b60f97aaa6553553bdaf" +checksum = "e43f2f1833d64e33f15592464d6fdd70f349dda7b1a53088eb83cd94014008c5" dependencies = [ - "ethbloom", - "fixed-hash", - "impl-rlp", - "impl-serde", - "primitive-types", - "uint", + "futures 0.3.21", ] [[package]] -name = "event-listener" -version = "2.5.1" +name = "expander" +version = "0.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7531096570974c3a9dcf9e4b8e1cede1ec26cf5046219fb3b9d897503b9be59" +checksum = "a718c0675c555c5f976fff4ea9e2c150fa06cefa201cadef87cfbf9324075881" +dependencies = [ + "blake3 1.3.1", + "fs-err", + "proc-macro2", + "quote", +] [[package]] -name = "exit-future" -version = "0.2.0" +name = "expander" +version = "0.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e43f2f1833d64e33f15592464d6fdd70f349dda7b1a53088eb83cd94014008c5" +checksum = "3774182a5df13c3d1690311ad32fbe913feef26baba609fa2dd5f72042bd2ab6" dependencies = [ - "futures 0.3.19", + "blake2 0.10.4", + "fs-err", + "proc-macro2", + "quote", ] [[package]] @@ -2389,6 +2465,31 @@ dependencies = [ "instant", ] +[[package]] +name = "fatality" +version = "0.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ad875162843b0d046276327afe0136e9ed3a23d5a754210fb6f1f33610d39ab" +dependencies = [ + "fatality-proc-macro", + "thiserror", +] + +[[package]] +name = "fatality-proc-macro" +version = "0.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f5aa1e3ae159e592ad222dc90c5acbad632b527779ba88486abe92782ab268bd" +dependencies = [ + "expander 0.0.4", + "indexmap", + "proc-macro-crate 1.1.3", + "proc-macro2", + "quote", + "syn", + "thiserror", +] + [[package]] name = "fdlimit" version = "0.2.1" @@ -2398,6 +2499,16 @@ dependencies = [ "libc", ] +[[package]] +name = "ff" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2958d04124b9f27f175eaeb9a9f383d026098aa837eadd8ba22c11f13a05b9e" +dependencies = [ + "rand_core 0.6.3", + "subtle", +] + [[package]] name = "file-per-thread-logger" version = "0.1.4" @@ -2410,12 +2521,12 @@ dependencies = [ [[package]] name = "finality-grandpa" -version = "0.14.4" +version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8ac3ff5224ef91f3c97e03eb1de2db82743427e91aaa5ac635f454f0b164f5a" +checksum = "d9def033d8505edf199f6a5d07aa7e6d2d6185b164293b77f0efd108f4f3e11d" dependencies = [ "either", - "futures 0.3.19", + "futures 0.3.21", "futures-timer", "log", "num-traits", @@ -2432,7 +2543,7 @@ dependencies = [ "async-trait", "backoff", "bp-header-chain", - "futures 0.3.19", + "futures 0.3.21", "log", "num-traits", "parking_lot 0.11.2", @@ -2446,7 +2557,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cfcf0ed7fe52a17a03854ec54a9f76d6d84508d1c0e66bc1793301c73fc8493c" dependencies = [ "byteorder", - "rand 0.8.4", + "rand 0.8.5", "rustc-hex", "static_assertions", ] @@ -2479,7 +2590,7 @@ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "fork-tree" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "parity-scale-codec", ] @@ -2497,7 +2608,7 @@ dependencies = [ [[package]] name = "frame-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "frame-support", "frame-system", @@ -2506,6 +2617,7 @@ dependencies = [ "parity-scale-codec", "paste", "scale-info", + "serde", "sp-api", "sp-application-crypto", "sp-io", @@ -2518,33 +2630,48 @@ dependencies = [ [[package]] name = "frame-benchmarking-cli" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "Inflector", "chrono", - "clap 3.0.12", + "clap 3.1.6", "frame-benchmarking", "frame-support", "handlebars", + "hash-db", + "hex", + "itertools", + "kvdb", "linked-hash-map", "log", + "memory-db", "parity-scale-codec", + "rand 0.8.5", "sc-cli", + "sc-client-api", "sc-client-db", "sc-executor", "sc-service", "serde", + "serde_json", + "serde_nanos", + "sp-api", + "sp-blockchain", "sp-core", + "sp-database", "sp-externalities", "sp-keystore", "sp-runtime", "sp-state-machine", + "sp-std", + "sp-storage", + "sp-trie", ] [[package]] name = "frame-election-provider-support" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "frame-support", "frame-system", @@ -2552,13 +2679,14 @@ dependencies = [ "scale-info", "sp-arithmetic", "sp-npos-elections", + "sp-runtime", "sp-std", ] [[package]] name = "frame-executive" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "frame-support", "frame-system", @@ -2573,9 +2701,9 @@ dependencies = [ [[package]] name = "frame-metadata" -version = "14.2.0" +version = "15.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37ed5e5c346de62ca5c184b4325a6600d1eaca210666e4606fe4e449574978d0" +checksum = "df6bb8542ef006ef0de09a5c4420787d79823c0ed7924225822362fd2bf2ff2d" dependencies = [ "cfg-if 1.0.0", "parity-scale-codec", @@ -2586,7 +2714,7 @@ dependencies = [ [[package]] name = "frame-support" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "bitflags", "frame-metadata", @@ -2615,7 +2743,7 @@ dependencies = [ [[package]] name = "frame-support-procedural" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "Inflector", "frame-support-procedural-tools", @@ -2627,10 +2755,10 @@ dependencies = [ [[package]] name = "frame-support-procedural-tools" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "frame-support-procedural-tools-derive", - "proc-macro-crate 1.1.0", + "proc-macro-crate 1.1.3", "proc-macro2", "quote", "syn", @@ -2639,7 +2767,7 @@ dependencies = [ [[package]] name = "frame-support-procedural-tools-derive" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "proc-macro2", "quote", @@ -2649,7 +2777,7 @@ dependencies = [ [[package]] name = "frame-system" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "frame-support", "log", @@ -2666,7 +2794,7 @@ dependencies = [ [[package]] name = "frame-system-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "frame-benchmarking", "frame-support", @@ -2681,7 +2809,7 @@ dependencies = [ [[package]] name = "frame-system-rpc-runtime-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "parity-scale-codec", "sp-api", @@ -2690,7 +2818,7 @@ dependencies = [ [[package]] name = "frame-try-runtime" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "frame-support", "sp-api", @@ -2726,6 +2854,12 @@ dependencies = [ "winapi 0.3.9", ] +[[package]] +name = "fs_extra" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2022715d62ab30faffd124d40b76f4134a550a87792276512b18d63272333394" + [[package]] name = "fuchsia-zircon" version = "0.3.3" @@ -2744,9 +2878,9 @@ checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" [[package]] name = "funty" -version = "1.1.0" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fed34cd105917e91daa4da6b3728c47b068749d6a62c59811f06ed2ac71d9da7" +checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" [[package]] name = "futures" @@ -2756,9 +2890,9 @@ checksum = "3a471a38ef8ed83cd6e40aa59c1ffe17db6855c18e3604d9c4ed8c08ebc28678" [[package]] name = "futures" -version = "0.3.19" +version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28560757fe2bb34e79f907794bb6b22ae8b0e5c669b638a1132f2592b19035b4" +checksum = "f73fe65f54d1e12b726f517d3e2135ca3125a437b6d998caf1962961f7172d9e" dependencies = [ "futures-channel", "futures-core", @@ -2771,9 +2905,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.19" +version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba3dda0b6588335f360afc675d0564c17a77a2bda81ca178a4b6081bd86c7f0b" +checksum = "c3083ce4b914124575708913bca19bfe887522d6e2e6d0952943f5eac4a74010" dependencies = [ "futures-core", "futures-sink", @@ -2781,15 +2915,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.19" +version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0c8ff0461b82559810cdccfde3215c3f373807f5e5232b71479bff7bb2583d7" +checksum = "0c09fd04b7e4073ac7156a9539b57a484a8ea920f79c7c675d05d289ab6110d3" [[package]] name = "futures-executor" -version = "0.3.19" +version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29d6d2ff5bb10fb95c85b8ce46538a2e5f5e7fdc755623a7d4529ab8a4ed9d2a" +checksum = "9420b90cfa29e327d0429f19be13e7ddb68fa1cccb09d65e5706b8c7a749b8a6" dependencies = [ "futures-core", "futures-task", @@ -2799,9 +2933,9 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.19" +version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1f9d34af5a1aac6fb380f735fe510746c38067c5bf16c7fd250280503c971b2" +checksum = "fc4045962a5a5e935ee2fdedaa4e08284547402885ab326734432bed5d12966b" [[package]] name = "futures-lite" @@ -2820,9 +2954,9 @@ dependencies = [ [[package]] name = "futures-macro" -version = "0.3.19" +version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6dbd947adfffb0efc70599b3ddcf7b5597bb5fa9e245eb99f62b3a5f7bb8bd3c" +checksum = "33c1e13800337f4d4d7a316bf45a567dbcb6ffe087f16424852d97e97a91f512" dependencies = [ "proc-macro2", "quote", @@ -2836,21 +2970,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3a1387e07917c711fb4ee4f48ea0adb04a3c9739e53ef85bf43ae1edc2937a8b" dependencies = [ "futures-io", - "rustls", - "webpki", + "rustls 0.19.1", + "webpki 0.21.4", ] [[package]] name = "futures-sink" -version = "0.3.19" +version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3055baccb68d74ff6480350f8d6eb8fcfa3aa11bdc1a1ae3afdd0514617d508" +checksum = "21163e139fa306126e6eedaf49ecdb4588f939600f0b1e770f4205ee4b7fa868" [[package]] name = "futures-task" -version = "0.3.19" +version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ee7c6485c30167ce4dfb83ac568a849fe53274c831081476ee13e0dce1aad72" +checksum = "57c66a976bf5909d801bbef33416c41372779507e7a6b3a5e25e4749c58f776a" [[package]] name = "futures-timer" @@ -2860,9 +2994,9 @@ checksum = "e64b03909df88034c26dc1547e8970b91f98bdb65165d6a4e9110d94263dbb2c" [[package]] name = "futures-util" -version = "0.3.19" +version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9b5cf40b47a271f77a8b1bec03ca09044d99d2372c0de244e66430761127164" +checksum = "d8b7abd5d659d9b90c8cba917f6ec750a74e2dc23902ef9cd4cc8c8b22e6036a" dependencies = [ "futures 0.1.31", "futures-channel", @@ -2973,6 +3107,17 @@ dependencies = [ "web-sys", ] +[[package]] +name = "group" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc5ac374b108929de78460075f3dc439fa66df9d8fc77e8f12caa5165fcf0c89" +dependencies = [ + "ff", + "rand_core 0.6.3", + "subtle", +] + [[package]] name = "h2" version = "0.3.10" @@ -3030,6 +3175,15 @@ dependencies = [ "ahash", ] +[[package]] +name = "hashbrown" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c21d40587b92fa6a6c6e3c1bdbf87d75511db5672f9c93175574b3a00df1758" +dependencies = [ + "ahash", +] + [[package]] name = "heck" version = "0.3.3" @@ -3191,7 +3345,7 @@ dependencies = [ "httpdate", "itoa 0.4.8", "pin-project-lite 0.2.7", - "socket2 0.4.2", + "socket2 0.4.4", "tokio", "tower-service", "tracing", @@ -3208,11 +3362,11 @@ dependencies = [ "futures-util", "hyper", "log", - "rustls", - "rustls-native-certs", + "rustls 0.19.1", + "rustls-native-certs 0.5.0", "tokio", - "tokio-rustls", - "webpki", + "tokio-rustls 0.22.0", + "webpki 0.21.4", ] [[package]] @@ -3265,7 +3419,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ae8ab7f67bad3240049cb24fb9cb0b4c2c6af4c245840917fbbdededeee91179" dependencies = [ "async-io", - "futures 0.3.19", + "futures 0.3.21", "futures-lite", "if-addrs", "ipnet", @@ -3276,22 +3430,13 @@ dependencies = [ [[package]] name = "impl-codec" -version = "0.5.1" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "161ebdfec3c8e3b52bf61c4f3550a1eea4f9579d10dc1b936f3171ebdcd6c443" +checksum = "ba6a270039626615617f3f36d15fc827041df3b78c439da2cadfa47455a77f2f" dependencies = [ "parity-scale-codec", ] -[[package]] -name = "impl-rlp" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f28220f89297a075ddc7245cd538076ee98b01f2a9c23a53a4f1105d5a322808" -dependencies = [ - "rlp", -] - [[package]] name = "impl-serde" version = "0.3.2" @@ -3303,9 +3448,9 @@ dependencies = [ [[package]] name = "impl-trait-for-tuples" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5dacb10c5b3bb92d46ba347505a9041e676bb20ad220101326bffb0c93031ee" +checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb" dependencies = [ "proc-macro2", "quote", @@ -3314,12 +3459,12 @@ dependencies = [ [[package]] name = "indexmap" -version = "1.7.0" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc633605454125dec4b66843673f01c7df2b89479b32e0ed634e43a91cff62a5" +checksum = "282a6247722caba404c065016bbfa522806e51714c34f5dfc3e4a3a46fcb4223" dependencies = [ "autocfg", - "hashbrown", + "hashbrown 0.11.2", "serde", ] @@ -3418,9 +3563,9 @@ dependencies = [ [[package]] name = "itertools" -version = "0.10.1" +version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69ddb889f9d0d08a67338271fa9b62996bc788c7796a5c18cf057420aaed5eaf" +checksum = "a9a9d19fa1e79b6215ff29b9d6880b706147f16e9b1dbb1e4e5947b5b02bc5e3" dependencies = [ "either", ] @@ -3475,7 +3620,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d2b99d4207e2a04fb4581746903c2bb7eb376f88de9c699d0f3e10feeac0cd3a" dependencies = [ "derive_more", - "futures 0.3.19", + "futures 0.3.21", "jsonrpc-core", "jsonrpc-pubsub", "log", @@ -3490,7 +3635,7 @@ version = "18.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "14f7f76aef2d054868398427f6c54943cf3d1caa9a7ec7d0c38d69df97a965eb" dependencies = [ - "futures 0.3.19", + "futures 0.3.21", "futures-executor", "futures-util", "log", @@ -3505,7 +3650,7 @@ version = "18.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b51da17abecbdab3e3d4f26b01c5ec075e88d3abe3ab3b05dc9aa69392764ec0" dependencies = [ - "futures 0.3.19", + "futures 0.3.21", "jsonrpc-client-transports", ] @@ -3527,7 +3672,7 @@ version = "18.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e1dea6e07251d9ce6a552abfb5d7ad6bc290a4596c8dcc3d795fae2bbdc1f3ff" dependencies = [ - "futures 0.3.19", + "futures 0.3.21", "hyper", "jsonrpc-core", "jsonrpc-server-utils", @@ -3543,7 +3688,7 @@ version = "18.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "382bb0206323ca7cda3dcd7e245cea86d37d02457a02a975e3378fb149a48845" dependencies = [ - "futures 0.3.19", + "futures 0.3.21", "jsonrpc-core", "jsonrpc-server-utils", "log", @@ -3558,7 +3703,7 @@ version = "18.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "240f87695e6c6f62fb37f05c02c04953cf68d6408b8c1c89de85c7a0125b1011" dependencies = [ - "futures 0.3.19", + "futures 0.3.21", "jsonrpc-core", "lazy_static", "log", @@ -3574,7 +3719,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fa4fdea130485b572c39a460d50888beb00afb3e35de23ccd7fad8ff19f0e0d4" dependencies = [ "bytes 1.1.0", - "futures 0.3.19", + "futures 0.3.21", "globset", "jsonrpc-core", "lazy_static", @@ -3591,7 +3736,7 @@ version = "18.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f892c7d766369475ab7b0669f417906302d7c0fb521285c0a0c92e52e7c8e946" dependencies = [ - "futures 0.3.19", + "futures 0.3.21", "jsonrpc-core", "jsonrpc-server-utils", "log", @@ -3606,57 +3751,98 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6373a33d987866ccfe1af4bc11b089dce941764313f9fd8b7cf13fcb51b72dc5" dependencies = [ - "jsonrpsee-proc-macros 0.4.1", "jsonrpsee-types 0.4.1", "jsonrpsee-utils", "jsonrpsee-ws-client 0.4.1", ] [[package]] -name = "jsonrpsee-proc-macros" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8edb341d35279b59c79d7fe9e060a51aec29d45af99cc7c72ea7caa350fa71a4" +name = "jsonrpsee" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05fd8cd6c6b1bbd06881d2cf88f1fc83cc36c98f2219090f839115fb4a956cb9" dependencies = [ - "Inflector", - "bae", - "proc-macro-crate 1.1.0", - "proc-macro2", - "quote", - "syn", + "jsonrpsee-core 0.8.0", + "jsonrpsee-proc-macros", + "jsonrpsee-types 0.8.0", + "jsonrpsee-ws-client 0.8.0", ] [[package]] -name = "jsonrpsee-proc-macros" -version = "0.4.1" +name = "jsonrpsee-client-transport" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d802063f7a3c867456955f9d2f15eb3ee0edb5ec9ec2b5526324756759221c0f" +checksum = "3303cdf246e6ab76e2866fb3d9acb6c76a068b1b28bd923a1b7a8122257ad7b5" dependencies = [ - "log", - "proc-macro-crate 1.1.0", - "proc-macro2", - "quote", - "syn", + "futures 0.3.21", + "http", + "jsonrpsee-core 0.8.0", + "jsonrpsee-types 0.8.0", + "pin-project 1.0.10", + "rustls-native-certs 0.6.1", + "soketto", + "thiserror", + "tokio", + "tokio-rustls 0.23.2", + "tokio-util", + "tracing", + "webpki-roots 0.22.2", ] [[package]] -name = "jsonrpsee-types" -version = "0.3.1" +name = "jsonrpsee-core" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4cc738fd55b676ada3271ef7c383a14a0867a2a88b0fa941311bf5fc0a29d498" +checksum = "f220b5a238dc7992b90f1144fbf6eaa585872c9376afe6fe6863ffead6191bf3" dependencies = [ + "anyhow", + "arrayvec 0.7.2", "async-trait", "beef", "futures-channel", "futures-util", "hyper", - "log", + "jsonrpsee-types 0.8.0", + "rustc-hash", + "serde", + "serde_json", + "soketto", + "thiserror", + "tokio", + "tracing", +] + +[[package]] +name = "jsonrpsee-core" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22abc3274b265dcefe2e26c4beecf9fda4fffa48cf94930443a6c73678f020d5" +dependencies = [ + "anyhow", + "arrayvec 0.7.2", + "async-trait", + "beef", + "futures-channel", + "hyper", + "jsonrpsee-types 0.9.0", "serde", "serde_json", - "soketto 0.6.0", + "soketto", "thiserror", ] +[[package]] +name = "jsonrpsee-proc-macros" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4299ebf790ea9de1cb72e73ff2ae44c723ef264299e5e2d5ef46a371eb3ac3d8" +dependencies = [ + "proc-macro-crate 1.1.3", + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "jsonrpsee-types" version = "0.4.1" @@ -3672,43 +3858,47 @@ dependencies = [ "log", "serde", "serde_json", - "soketto 0.7.1", + "soketto", "thiserror", ] [[package]] -name = "jsonrpsee-utils" -version = "0.4.1" +name = "jsonrpsee-types" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0109c4f972058f3b1925b73a17210aff7b63b65967264d0045d15ee88fe84f0c" +checksum = "c1b3f601bbbe45cd63f5407b6f7d7950e08a7d4f82aa699ff41a4a5e9e54df58" dependencies = [ - "arrayvec 0.7.2", + "anyhow", "beef", - "jsonrpsee-types 0.4.1", + "serde", + "serde_json", + "thiserror", + "tracing", ] [[package]] -name = "jsonrpsee-ws-client" -version = "0.3.1" +name = "jsonrpsee-types" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9841352dbecf4c2ed5dc71698df9f1660262ae4e0b610e968602529bdbcf7b30" +checksum = "9f4c45d2e2aa1db4c7d7d7dbaabc10a5b5258d99cd9d42fbfd5260b76f80c324" dependencies = [ - "async-trait", - "fnv", - "futures 0.3.19", - "jsonrpsee-types 0.3.1", - "log", - "pin-project 1.0.10", - "rustls", - "rustls-native-certs", + "anyhow", + "beef", "serde", "serde_json", - "soketto 0.6.0", "thiserror", - "tokio", - "tokio-rustls", - "tokio-util", - "url 2.2.2", + "tracing", +] + +[[package]] +name = "jsonrpsee-utils" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0109c4f972058f3b1925b73a17210aff7b63b65967264d0045d15ee88fe84f0c" +dependencies = [ + "arrayvec 0.7.2", + "beef", + "jsonrpsee-types 0.4.1", ] [[package]] @@ -3720,21 +3910,44 @@ dependencies = [ "arrayvec 0.7.2", "async-trait", "fnv", - "futures 0.3.19", + "futures 0.3.21", "http", "jsonrpsee-types 0.4.1", "log", "pin-project 1.0.10", - "rustls-native-certs", + "rustls-native-certs 0.5.0", "serde", "serde_json", - "soketto 0.7.1", + "soketto", "thiserror", "tokio", - "tokio-rustls", + "tokio-rustls 0.22.0", "tokio-util", ] +[[package]] +name = "jsonrpsee-ws-client" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aff425cee7c779e33920913bc695447416078ee6d119f443f3060feffa4e86b5" +dependencies = [ + "jsonrpsee-client-transport", + "jsonrpsee-core 0.8.0", + "jsonrpsee-types 0.8.0", +] + +[[package]] +name = "k256" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "587f53e46eb6dc82b53cda7ebf3ae3ad568ed987ced60962fc845f7fe22904e3" +dependencies = [ + "cfg-if 1.0.0", + "ecdsa", + "elliptic-curve", + "sec1", +] + [[package]] name = "keccak" version = "0.1.0" @@ -3753,8 +3966,8 @@ dependencies = [ [[package]] name = "kusama-runtime" -version = "0.9.13" -source = "git+https://github.com/paritytech/polkadot?branch=master#60df3c55c711c2872872d6220f98b2611340e051" +version = "0.9.18" +source = "git+https://github.com/paritytech/polkadot?branch=master#975e780ae0d988dc033f400ba822d14b326ee5b9" dependencies = [ "beefy-primitives", "bitvec", @@ -3836,8 +4049,8 @@ dependencies = [ [[package]] name = "kusama-runtime-constants" -version = "0.9.13" -source = "git+https://github.com/paritytech/polkadot?branch=master#60df3c55c711c2872872d6220f98b2611340e051" +version = "0.9.18" +source = "git+https://github.com/paritytech/polkadot?branch=master#975e780ae0d988dc033f400ba822d14b326ee5b9" dependencies = [ "frame-support", "polkadot-primitives", @@ -3857,9 +4070,9 @@ dependencies = [ [[package]] name = "kvdb" -version = "0.10.0" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45a3f58dc069ec0e205a27f5b45920722a46faed802a0541538241af6228f512" +checksum = "a301d8ecb7989d4a6e2c57a49baca77d353bdbf879909debe3f375fe25d61f86" dependencies = [ "parity-util-mem", "smallvec", @@ -3867,38 +4080,20 @@ dependencies = [ [[package]] name = "kvdb-memorydb" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3b6b85fc643f5acd0bffb2cc8a6d150209379267af0d41db72170021841f9f5" -dependencies = [ - "kvdb", - "parity-util-mem", - "parking_lot 0.11.2", -] - -[[package]] -name = "kvdb-rocksdb" -version = "0.12.1" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d169dbb316aa0fa185d02d847c047f1aa20e292cf1563d790c13536a2a732c8" +checksum = "ece7e668abd21387aeb6628130a6f4c802787f014fa46bc83221448322250357" dependencies = [ - "fs-swap", "kvdb", - "log", - "num_cpus", - "owning_ref", "parity-util-mem", - "parking_lot 0.11.2", - "regex", - "rocksdb", - "smallvec", + "parking_lot 0.12.0", ] [[package]] name = "kvdb-rocksdb" -version = "0.14.0" +version = "0.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b1b6ea8f2536f504b645ad78419c8246550e19d2c3419a167080ce08edee35a" +checksum = "a1e72a631a32527fafe22d0751c002e67d28173c49dcaecf79d1aaa323c520e9" dependencies = [ "fs-swap", "kvdb", @@ -3906,7 +4101,7 @@ dependencies = [ "num_cpus", "owning_ref", "parity-util-mem", - "parking_lot 0.11.2", + "parking_lot 0.12.0", "regex", "rocksdb", "smallvec", @@ -3926,9 +4121,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "libc" -version = "0.2.114" +version = "0.2.120" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0005d08a8f7b65fb8073cb697aa0b12b631ed251ce73d862ce50eeb52ce3b50" +checksum = "ad5c14e80759d0939d013e6ca49930e59fc53dd8e5009132f76240c179380c09" [[package]] name = "libloading" @@ -3974,7 +4169,7 @@ checksum = "3bec54343492ba5940a6c555e512c6721139835d28c59bc22febece72dfd0d9d" dependencies = [ "atomic", "bytes 1.1.0", - "futures 0.3.19", + "futures 0.3.21", "lazy_static", "libp2p-core", "libp2p-deflate", @@ -4009,17 +4204,18 @@ dependencies = [ [[package]] name = "libp2p-core" -version = "0.30.0" +version = "0.30.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef22d9bba1e8bcb7ec300073e6802943fe8abb8190431842262b5f1c30abba1" +checksum = "86aad7d54df283db817becded03e611137698a6509d4237a96881976a162340c" dependencies = [ "asn1_der", "bs58", "ed25519-dalek", "either", "fnv", - "futures 0.3.19", + "futures 0.3.21", "futures-timer", + "instant", "lazy_static", "libsecp256k1", "log", @@ -4030,7 +4226,7 @@ dependencies = [ "pin-project 1.0.10", "prost", "prost-build", - "rand 0.8.4", + "rand 0.8.5", "ring", "rw-stream-sink", "sha2 0.9.8", @@ -4048,7 +4244,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "51a800adb195f33de63f4b17b63fe64cfc23bf2c6a0d3d0d5321328664e65197" dependencies = [ "flate2", - "futures 0.3.19", + "futures 0.3.21", "libp2p-core", ] @@ -4059,7 +4255,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bb8f89d15cb6e3c5bc22afff7513b11bab7856f2872d3cfba86f7f63a06bc498" dependencies = [ "async-std-resolver", - "futures 0.3.19", + "futures 0.3.21", "libp2p-core", "log", "smallvec", @@ -4074,7 +4270,7 @@ checksum = "aab3d7210901ea51b7bae2b581aa34521797af8c4ec738c980bda4a06434067f" dependencies = [ "cuckoofilter", "fnv", - "futures 0.3.19", + "futures 0.3.21", "libp2p-core", "libp2p-swarm", "log", @@ -4095,7 +4291,7 @@ dependencies = [ "byteorder", "bytes 1.1.0", "fnv", - "futures 0.3.19", + "futures 0.3.21", "hex_fmt", "libp2p-core", "libp2p-swarm", @@ -4116,7 +4312,7 @@ version = "0.31.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cca1275574183f288ff8b72d535d5ffa5ea9292ef7829af8b47dcb197c7b0dcd" dependencies = [ - "futures 0.3.19", + "futures 0.3.21", "libp2p-core", "libp2p-swarm", "log", @@ -4138,7 +4334,7 @@ dependencies = [ "bytes 1.1.0", "either", "fnv", - "futures 0.3.19", + "futures 0.3.21", "libp2p-core", "libp2p-swarm", "log", @@ -4162,15 +4358,15 @@ dependencies = [ "async-io", "data-encoding", "dns-parser", - "futures 0.3.19", + "futures 0.3.21", "if-watch", "lazy_static", "libp2p-core", "libp2p-swarm", "log", - "rand 0.8.4", + "rand 0.8.5", "smallvec", - "socket2 0.4.2", + "socket2 0.4.4", "void", ] @@ -4196,7 +4392,7 @@ checksum = "7f2cd64ef597f40e14bfce0497f50ecb63dd6d201c61796daeb4227078834fbf" dependencies = [ "asynchronous-codec 0.6.0", "bytes 1.1.0", - "futures 0.3.19", + "futures 0.3.21", "libp2p-core", "log", "nohash-hasher", @@ -4214,13 +4410,13 @@ checksum = "a8772c7a99088221bb7ca9c5c0574bf55046a7ab4c319f3619b275f28c8fb87a" dependencies = [ "bytes 1.1.0", "curve25519-dalek 3.2.0", - "futures 0.3.19", + "futures 0.3.21", "lazy_static", "libp2p-core", "log", "prost", "prost-build", - "rand 0.8.4", + "rand 0.8.5", "sha2 0.9.8", "snow", "static_assertions", @@ -4234,7 +4430,7 @@ version = "0.31.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "80ef7b0ec5cf06530d9eb6cf59ae49d46a2c45663bde31c25a12f682664adbcf" dependencies = [ - "futures 0.3.19", + "futures 0.3.21", "libp2p-core", "libp2p-swarm", "log", @@ -4251,7 +4447,7 @@ checksum = "5fba1a6ff33e4a274c89a3b1d78b9f34f32af13265cc5c46c16938262d4e945a" dependencies = [ "asynchronous-codec 0.6.0", "bytes 1.1.0", - "futures 0.3.19", + "futures 0.3.21", "libp2p-core", "log", "prost", @@ -4266,12 +4462,12 @@ version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0f1a458bbda880107b5b36fcb9b5a1ef0c329685da0e203ed692a8ebe64cc92c" dependencies = [ - "futures 0.3.19", + "futures 0.3.21", "log", "pin-project 1.0.10", "rand 0.7.3", "salsa20", - "sha3", + "sha3 0.9.1", ] [[package]] @@ -4282,7 +4478,7 @@ checksum = "2852b61c90fa8ce3c8fcc2aba76e6cefc20d648f9df29157d6b3a916278ef3e3" dependencies = [ "asynchronous-codec 0.6.0", "bytes 1.1.0", - "futures 0.3.19", + "futures 0.3.21", "futures-timer", "libp2p-core", "libp2p-swarm", @@ -4305,13 +4501,13 @@ checksum = "14a6d2b9e7677eff61dc3d2854876aaf3976d84a01ef6664b610c77a0c9407c5" dependencies = [ "asynchronous-codec 0.6.0", "bimap", - "futures 0.3.19", + "futures 0.3.21", "libp2p-core", "libp2p-swarm", "log", "prost", "prost-build", - "rand 0.8.4", + "rand 0.8.5", "sha2 0.9.8", "thiserror", "unsigned-varint 0.7.1", @@ -4327,11 +4523,11 @@ checksum = "a877a4ced6d46bf84677e1974e8cf61fb434af73b2e96fb48d6cb6223a4634d8" dependencies = [ "async-trait", "bytes 1.1.0", - "futures 0.3.19", + "futures 0.3.21", "libp2p-core", "libp2p-swarm", "log", - "lru 0.7.2", + "lru 0.7.3", "rand 0.7.3", "smallvec", "unsigned-varint 0.7.1", @@ -4345,7 +4541,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f5184a508f223bc100a12665517773fb8730e9f36fc09eefb670bf01b107ae9" dependencies = [ "either", - "futures 0.3.19", + "futures 0.3.21", "libp2p-core", "log", "rand 0.7.3", @@ -4371,14 +4567,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7399c5b6361ef525d41c11fcf51635724f832baf5819b30d3d873eabb4fbae4b" dependencies = [ "async-io", - "futures 0.3.19", + "futures 0.3.21", "futures-timer", "if-watch", "ipnet", "libc", "libp2p-core", "log", - "socket2 0.4.2", + "socket2 0.4.4", ] [[package]] @@ -4388,7 +4584,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b8b7563e46218165dfd60f64b96f7ce84590d75f53ecbdc74a7dd01450dc5973" dependencies = [ "async-std", - "futures 0.3.19", + "futures 0.3.21", "libp2p-core", "log", ] @@ -4399,7 +4595,7 @@ version = "0.30.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1008a302b73c5020251f9708c653f5ed08368e530e247cc9cd2f109ff30042cf" dependencies = [ - "futures 0.3.19", + "futures 0.3.21", "js-sys", "libp2p-core", "parity-send-wrapper", @@ -4414,15 +4610,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "22e12df82d1ed64969371a9e65ea92b91064658604cc2576c2757f18ead9a1cf" dependencies = [ "either", - "futures 0.3.19", + "futures 0.3.21", "futures-rustls", "libp2p-core", "log", "quicksink", "rw-stream-sink", - "soketto 0.7.1", + "soketto", "url 2.2.2", - "webpki-roots", + "webpki-roots 0.21.1", ] [[package]] @@ -4431,7 +4627,7 @@ version = "0.34.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4e7362abb8867d7187e7e93df17f460d554c997fc5c8ac57dc1259057f6889af" dependencies = [ - "futures 0.3.19", + "futures 0.3.21", "libp2p-core", "parking_lot 0.11.2", "thiserror", @@ -4440,14 +4636,17 @@ dependencies = [ [[package]] name = "librocksdb-sys" -version = "6.20.3" +version = "0.6.1+6.28.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c309a9d2470844aceb9a4a098cf5286154d20596868b75a6b36357d2bb9ca25d" +checksum = "81bc587013734dadb7cf23468e531aa120788b87243648be42e2d3a072186291" dependencies = [ "bindgen", + "bzip2-sys", "cc", "glob", "libc", + "libz-sys", + "tikv-jemalloc-sys", ] [[package]] @@ -4463,7 +4662,7 @@ dependencies = [ "libsecp256k1-core", "libsecp256k1-gen-ecmult", "libsecp256k1-gen-genmult", - "rand 0.8.4", + "rand 0.8.5", "serde", "sha2 0.9.8", "typenum", @@ -4543,18 +4742,9 @@ checksum = "a261afc61b7a5e323933b402ca6a1765183687c614789b1e4db7762ed4230bca" [[package]] name = "lock_api" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4da24a77a3d8a6d4862d95f72e6fdb9c09a643ecdb402d754004a557f2bec75" -dependencies = [ - "scopeguard", -] - -[[package]] -name = "lock_api" -version = "0.4.5" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712a4d093c9976e24e7dbca41db895dabcbac38eb5f4045393d17a95bdfb1109" +checksum = "88943dd7ef4a2e5a4bfa2753aaab3013e34ce2533d1996fb18ef591e315e2b3b" dependencies = [ "scopeguard", ] @@ -4575,16 +4765,16 @@ version = "0.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ea2d928b485416e8908cff2d97d621db22b27f7b3b6729e438bcf42c671ba91" dependencies = [ - "hashbrown", + "hashbrown 0.11.2", ] [[package]] name = "lru" -version = "0.7.2" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "274353858935c992b13c0ca408752e2121da852d07dec7ce5f108c77dfa14d1f" +checksum = "fcb87f3080f6d1d69e8c564c0fcfde1d7aa8cc451ce40cae89479111f03bc0eb" dependencies = [ - "hashbrown", + "hashbrown 0.11.2", ] [[package]] @@ -4706,12 +4896,12 @@ dependencies = [ [[package]] name = "memory-db" -version = "0.28.0" +version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d505169b746dacf02f7d14d8c80b34edfd8212159c63d23c977739a0d960c626" +checksum = "6566c70c1016f525ced45d7b7f97730a2bafb037c788211d0c186ef5b2189f0a" dependencies = [ "hash-db", - "hashbrown", + "hashbrown 0.12.0", "parity-util-mem", ] @@ -4750,7 +4940,8 @@ dependencies = [ "async-trait", "bp-messages", "bp-runtime", - "futures 0.3.19", + "finality-relay", + "futures 0.3.21", "hex", "log", "num-traits", @@ -4761,11 +4952,11 @@ dependencies = [ [[package]] name = "metered-channel" -version = "0.9.13" -source = "git+https://github.com/paritytech/polkadot?branch=master#60df3c55c711c2872872d6220f98b2611340e051" +version = "0.9.18" +source = "git+https://github.com/paritytech/polkadot?branch=master#975e780ae0d988dc033f400ba822d14b326ee5b9" dependencies = [ "derive_more", - "futures 0.3.19", + "futures 0.3.21", "futures-timer", "thiserror", "tracing", @@ -4773,12 +4964,12 @@ dependencies = [ [[package]] name = "mick-jaeger" -version = "0.1.7" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd2c2cc134e57461f0898b0e921f0a7819b5e3f3a4335b9aa390ce81a5f36fb9" +checksum = "69672161530e8aeca1d1400fbf3f1a1747ff60ea604265a4e906c2442df20532" dependencies = [ - "futures 0.3.19", - "rand 0.8.4", + "futures 0.3.21", + "rand 0.8.5", "thrift", ] @@ -4791,7 +4982,7 @@ dependencies = [ "beefy-primitives", "bp-millau", "bp-runtime", - "clap 3.0.12", + "clap 3.1.6", "frame-benchmarking", "frame-benchmarking-cli", "jsonrpc-core", @@ -4878,6 +5069,7 @@ dependencies = [ "sp-transaction-pool", "sp-trie", "sp-version", + "static_assertions", "substrate-wasm-builder", ] @@ -4924,14 +5116,15 @@ dependencies = [ [[package]] name = "mio" -version = "0.7.14" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8067b404fe97c70829f082dec8bcf4f71225d7eaea1d8645349cb76fa06205cc" +checksum = "7ba42135c6a5917b9db9cd7b293e5409e1c6b041e6f9825e92e55a894c63b6f8" dependencies = [ "libc", "log", "miow 0.3.7", "ntapi", + "wasi 0.11.0+wasi-snapshot-preview1", "winapi 0.3.9", ] @@ -5011,12 +5204,12 @@ checksum = "4dac63698b887d2d929306ea48b63760431ff8a24fac40ddb22f9c7f49fb7cab" dependencies = [ "blake2b_simd", "blake2s_simd", - "blake3", + "blake3 0.3.8", "digest 0.9.0", "generic-array 0.14.4", "multihash-derive", "sha2 0.9.8", - "sha3", + "sha3 0.9.1", "unsigned-varint 0.5.1", ] @@ -5039,8 +5232,8 @@ version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "424f6e86263cd5294cbd7f1e95746b95aca0e0d66bff31e5a40d6baa87b4aa99" dependencies = [ - "proc-macro-crate 1.1.0", - "proc-macro-error 1.0.4", + "proc-macro-crate 1.1.3", + "proc-macro-error", "proc-macro2", "quote", "syn", @@ -5060,7 +5253,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "56a336acba8bc87c8876f6425407dbbe6c417bf478b22015f8fb0994ef3bc0ab" dependencies = [ "bytes 1.1.0", - "futures 0.3.19", + "futures 0.3.21", "log", "pin-project 1.0.10", "smallvec", @@ -5079,7 +5272,7 @@ dependencies = [ "num-complex", "num-rational 0.4.0", "num-traits", - "rand 0.8.4", + "rand 0.8.5", "rand_distr", "simba", "typenum", @@ -5102,7 +5295,7 @@ version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "10a8690bf09abf659851e58cd666c3d37ac6af07c2bd7a9e332cfba471715775" dependencies = [ - "rand 0.8.4", + "rand 0.8.5", ] [[package]] @@ -5119,10 +5312,9 @@ dependencies = [ [[package]] name = "node-inspect" version = "0.9.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ - "clap 3.0.12", - "derive_more", + "clap 3.1.6", "parity-scale-codec", "sc-cli", "sc-client-api", @@ -5131,6 +5323,7 @@ dependencies = [ "sp-blockchain", "sp-core", "sp-runtime", + "thiserror", ] [[package]] @@ -5248,6 +5441,15 @@ dependencies = [ "libc", ] +[[package]] +name = "num_threads" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97ba99ba6393e2c3734791401b66902d981cb03bf190af674ca69949b6d5fb15" +dependencies = [ + "libc", +] + [[package]] name = "object" version = "0.27.1" @@ -5349,7 +5551,7 @@ dependencies = [ [[package]] name = "pallet-aura" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "frame-support", "frame-system", @@ -5365,7 +5567,7 @@ dependencies = [ [[package]] name = "pallet-authority-discovery" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "frame-support", "frame-system", @@ -5381,7 +5583,7 @@ dependencies = [ [[package]] name = "pallet-authorship" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "frame-support", "frame-system", @@ -5396,7 +5598,7 @@ dependencies = [ [[package]] name = "pallet-babe" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "frame-benchmarking", "frame-support", @@ -5420,7 +5622,7 @@ dependencies = [ [[package]] name = "pallet-bags-list" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "frame-election-provider-support", "frame-support", @@ -5435,7 +5637,7 @@ dependencies = [ [[package]] name = "pallet-balances" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "frame-benchmarking", "frame-support", @@ -5450,7 +5652,7 @@ dependencies = [ [[package]] name = "pallet-beefy" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "beefy-primitives", "frame-support", @@ -5466,14 +5668,14 @@ dependencies = [ [[package]] name = "pallet-beefy-mmr" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "beefy-merkle-tree", "beefy-primitives", "frame-support", "frame-system", "hex", - "libsecp256k1", + "k256", "log", "pallet-beefy", "pallet-mmr", @@ -5491,7 +5693,7 @@ dependencies = [ [[package]] name = "pallet-bounties" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "frame-support", "frame-system", @@ -5596,7 +5798,7 @@ dependencies = [ [[package]] name = "pallet-collective" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "frame-benchmarking", "frame-support", @@ -5613,7 +5815,7 @@ dependencies = [ [[package]] name = "pallet-democracy" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "frame-benchmarking", "frame-support", @@ -5629,13 +5831,15 @@ dependencies = [ [[package]] name = "pallet-election-provider-multi-phase" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ + "frame-benchmarking", "frame-election-provider-support", "frame-support", "frame-system", "log", "parity-scale-codec", + "rand 0.7.3", "scale-info", "sp-arithmetic", "sp-core", @@ -5644,12 +5848,13 @@ dependencies = [ "sp-runtime", "sp-std", "static_assertions", + "strum 0.23.0", ] [[package]] name = "pallet-elections-phragmen" version = "5.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "frame-support", "frame-system", @@ -5666,7 +5871,7 @@ dependencies = [ [[package]] name = "pallet-gilt" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "frame-benchmarking", "frame-support", @@ -5681,7 +5886,7 @@ dependencies = [ [[package]] name = "pallet-grandpa" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "frame-benchmarking", "frame-support", @@ -5704,7 +5909,7 @@ dependencies = [ [[package]] name = "pallet-identity" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "enumflags2", "frame-benchmarking", @@ -5720,7 +5925,7 @@ dependencies = [ [[package]] name = "pallet-im-online" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "frame-support", "frame-system", @@ -5739,7 +5944,7 @@ dependencies = [ [[package]] name = "pallet-indices" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "frame-support", "frame-system", @@ -5755,7 +5960,7 @@ dependencies = [ [[package]] name = "pallet-membership" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "frame-benchmarking", "frame-support", @@ -5772,7 +5977,7 @@ dependencies = [ [[package]] name = "pallet-mmr" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "ckb-merkle-mountain-range", "frame-benchmarking", @@ -5790,7 +5995,7 @@ dependencies = [ [[package]] name = "pallet-mmr-primitives" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "frame-support", "frame-system", @@ -5806,7 +6011,7 @@ dependencies = [ [[package]] name = "pallet-mmr-rpc" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "jsonrpc-core", "jsonrpc-core-client", @@ -5823,7 +6028,7 @@ dependencies = [ [[package]] name = "pallet-multisig" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "frame-support", "frame-system", @@ -5837,7 +6042,7 @@ dependencies = [ [[package]] name = "pallet-nicks" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "frame-support", "frame-system", @@ -5851,7 +6056,7 @@ dependencies = [ [[package]] name = "pallet-offences" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "frame-support", "frame-system", @@ -5868,7 +6073,7 @@ dependencies = [ [[package]] name = "pallet-preimage" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "frame-benchmarking", "frame-support", @@ -5884,7 +6089,7 @@ dependencies = [ [[package]] name = "pallet-proxy" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "frame-support", "frame-system", @@ -5898,7 +6103,7 @@ dependencies = [ [[package]] name = "pallet-randomness-collective-flip" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "frame-support", "frame-system", @@ -5912,7 +6117,7 @@ dependencies = [ [[package]] name = "pallet-recovery" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "frame-support", "frame-system", @@ -5926,7 +6131,7 @@ dependencies = [ [[package]] name = "pallet-scheduler" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "frame-benchmarking", "frame-support", @@ -5942,7 +6147,7 @@ dependencies = [ [[package]] name = "pallet-session" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "frame-support", "frame-system", @@ -5978,7 +6183,7 @@ dependencies = [ [[package]] name = "pallet-society" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "frame-support", "frame-system", @@ -5992,7 +6197,7 @@ dependencies = [ [[package]] name = "pallet-staking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "frame-election-provider-support", "frame-support", @@ -6013,9 +6218,9 @@ dependencies = [ [[package]] name = "pallet-staking-reward-curve" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ - "proc-macro-crate 1.1.0", + "proc-macro-crate 1.1.3", "proc-macro2", "quote", "syn", @@ -6024,7 +6229,7 @@ dependencies = [ [[package]] name = "pallet-staking-reward-fn" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "log", "sp-arithmetic", @@ -6033,7 +6238,7 @@ dependencies = [ [[package]] name = "pallet-sudo" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "frame-support", "frame-system", @@ -6047,7 +6252,7 @@ dependencies = [ [[package]] name = "pallet-timestamp" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "frame-benchmarking", "frame-support", @@ -6065,7 +6270,7 @@ dependencies = [ [[package]] name = "pallet-tips" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "frame-support", "frame-system", @@ -6083,7 +6288,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "frame-support", "frame-system", @@ -6100,7 +6305,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment-rpc" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "jsonrpc-core", "jsonrpc-core-client", @@ -6117,7 +6322,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment-rpc-runtime-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "pallet-transaction-payment", "parity-scale-codec", @@ -6128,7 +6333,7 @@ dependencies = [ [[package]] name = "pallet-treasury" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "frame-support", "frame-system", @@ -6144,7 +6349,7 @@ dependencies = [ [[package]] name = "pallet-utility" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "frame-support", "frame-system", @@ -6159,7 +6364,7 @@ dependencies = [ [[package]] name = "pallet-vesting" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "frame-support", "frame-system", @@ -6172,8 +6377,8 @@ dependencies = [ [[package]] name = "pallet-xcm" -version = "0.9.13" -source = "git+https://github.com/paritytech/polkadot?branch=master#60df3c55c711c2872872d6220f98b2611340e051" +version = "0.9.18" +source = "git+https://github.com/paritytech/polkadot?branch=master#975e780ae0d988dc033f400ba822d14b326ee5b9" dependencies = [ "frame-support", "frame-system", @@ -6191,7 +6396,7 @@ dependencies = [ [[package]] name = "parachain-info" version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=master#a9630551c2cd877952ab769c862af4c81b0ccd3c" +source = "git+https://github.com/paritytech/cumulus?branch=master#4e952282914719fafd2df450993ccc2ce9395415" dependencies = [ "cumulus-primitives-core", "frame-support", @@ -6203,9 +6408,9 @@ dependencies = [ [[package]] name = "parity-db" -version = "0.3.5" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78a95abf24f1097c6e3181abbbbfc3630b3b5e681470940f719b69acb4911c7f" +checksum = "865edee5b792f537356d9e55cbc138e7f4718dc881a7ea45a18b37bf61c21e3d" dependencies = [ "blake2-rfc", "crc32fast", @@ -6216,15 +6421,15 @@ dependencies = [ "lz4", "memmap2 0.2.3", "parking_lot 0.11.2", - "rand 0.8.4", + "rand 0.8.5", "snap", ] [[package]] name = "parity-scale-codec" -version = "2.3.1" +version = "3.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "373b1a4c1338d9cd3d1fa53b3a11bdab5ab6bd80a20f7f7becd76953ae2be909" +checksum = "e8b44461635bbb1a0300f100a841e571e7d919c81c73075ef5d152ffdb521066" dependencies = [ "arrayvec 0.7.2", "bitvec", @@ -6236,11 +6441,11 @@ dependencies = [ [[package]] name = "parity-scale-codec-derive" -version = "2.3.1" +version = "3.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1557010476e0595c9b568d16dcfb81b93cdeb157612726f5170d31aa707bed27" +checksum = "c45ed1f39709f5a89338fab50e59816b2e8815f5bb58276e7ddf9afd495f73f8" dependencies = [ - "proc-macro-crate 1.1.0", + "proc-macro-crate 1.1.3", "proc-macro2", "quote", "syn", @@ -6258,7 +6463,7 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9981e32fb75e004cc148f5fb70342f393830e0a4aa62e3cc93b50976218d42b6" dependencies = [ - "futures 0.3.19", + "futures 0.3.21", "libc", "log", "rand 0.7.3", @@ -6268,17 +6473,15 @@ dependencies = [ [[package]] name = "parity-util-mem" -version = "0.10.2" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f4cb4e169446179cbc6b8b6320cc9fca49bd2e94e8db25f25f200a8ea774770" +checksum = "c32561d248d352148124f036cac253a644685a21dc9fea383eb4907d7bd35a8f" dependencies = [ "cfg-if 1.0.0", - "ethereum-types", - "hashbrown", + "hashbrown 0.12.0", "impl-trait-for-tuples", - "lru 0.6.6", "parity-util-mem-derive", - "parking_lot 0.11.2", + "parking_lot 0.12.0", "primitive-types", "smallvec", "winapi 0.3.9", @@ -6336,51 +6539,50 @@ checksum = "427c3892f9e783d91cc128285287e70a59e206ca452770ece88a76f7a3eddd72" [[package]] name = "parking_lot" -version = "0.10.2" +version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3a704eb390aafdc107b0e392f56a82b668e3a71366993b5340f5833fd62505e" +checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99" dependencies = [ - "lock_api 0.3.4", - "parking_lot_core 0.7.2", + "instant", + "lock_api", + "parking_lot_core 0.8.5", ] [[package]] name = "parking_lot" -version = "0.11.2" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99" +checksum = "87f5ec2493a61ac0506c0f4199f99070cbe83857b0337006a30f3e6719b8ef58" dependencies = [ - "instant", - "lock_api 0.4.5", - "parking_lot_core 0.8.5", + "lock_api", + "parking_lot_core 0.9.1", ] [[package]] name = "parking_lot_core" -version = "0.7.2" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d58c7c768d4ba344e3e8d72518ac13e259d7c7ade24167003b8488e10b6740a3" +checksum = "d76e8e1493bcac0d2766c42737f34458f1c8c50c0d23bcb24ea953affb273216" dependencies = [ - "cfg-if 0.1.10", - "cloudabi", + "cfg-if 1.0.0", + "instant", "libc", - "redox_syscall 0.1.57", + "redox_syscall", "smallvec", "winapi 0.3.9", ] [[package]] name = "parking_lot_core" -version = "0.8.5" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d76e8e1493bcac0d2766c42737f34458f1c8c50c0d23bcb24ea953affb273216" +checksum = "28141e0cc4143da2443301914478dc976a61ffdb3f043058310c70df2fed8954" dependencies = [ "cfg-if 1.0.0", - "instant", "libc", - "redox_syscall 0.2.10", + "redox_syscall", "smallvec", - "winapi 0.3.9", + "windows-sys", ] [[package]] @@ -6536,6 +6738,17 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" +[[package]] +name = "pkcs8" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7cabda3fb821068a9a4fab19a683eac3af12edf0f34b94a8be53c4972b8149d0" +dependencies = [ + "der", + "spki", + "zeroize", +] + [[package]] name = "pkg-config" version = "0.3.22" @@ -6550,10 +6763,10 @@ checksum = "e8d0eef3571242013a0d5dc84861c3ae4a652e56e12adf8bdc26ff5f8cb34c94" [[package]] name = "polkadot-approval-distribution" -version = "0.9.13" -source = "git+https://github.com/paritytech/polkadot?branch=master#60df3c55c711c2872872d6220f98b2611340e051" +version = "0.9.18" +source = "git+https://github.com/paritytech/polkadot?branch=master#975e780ae0d988dc033f400ba822d14b326ee5b9" dependencies = [ - "futures 0.3.19", + "futures 0.3.21", "polkadot-node-network-protocol", "polkadot-node-primitives", "polkadot-node-subsystem", @@ -6564,10 +6777,10 @@ dependencies = [ [[package]] name = "polkadot-availability-bitfield-distribution" -version = "0.9.13" -source = "git+https://github.com/paritytech/polkadot?branch=master#60df3c55c711c2872872d6220f98b2611340e051" +version = "0.9.18" +source = "git+https://github.com/paritytech/polkadot?branch=master#975e780ae0d988dc033f400ba822d14b326ee5b9" dependencies = [ - "futures 0.3.19", + "futures 0.3.21", "polkadot-node-network-protocol", "polkadot-node-subsystem", "polkadot-node-subsystem-util", @@ -6577,12 +6790,13 @@ dependencies = [ [[package]] name = "polkadot-availability-distribution" -version = "0.9.13" -source = "git+https://github.com/paritytech/polkadot?branch=master#60df3c55c711c2872872d6220f98b2611340e051" +version = "0.9.18" +source = "git+https://github.com/paritytech/polkadot?branch=master#975e780ae0d988dc033f400ba822d14b326ee5b9" dependencies = [ "derive_more", - "futures 0.3.19", - "lru 0.7.2", + "fatality", + "futures 0.3.21", + "lru 0.7.3", "parity-scale-codec", "polkadot-erasure-coding", "polkadot-node-network-protocol", @@ -6590,7 +6804,7 @@ dependencies = [ "polkadot-node-subsystem", "polkadot-node-subsystem-util", "polkadot-primitives", - "rand 0.8.4", + "rand 0.8.5", "sp-core", "sp-keystore", "thiserror", @@ -6599,11 +6813,12 @@ dependencies = [ [[package]] name = "polkadot-availability-recovery" -version = "0.9.13" -source = "git+https://github.com/paritytech/polkadot?branch=master#60df3c55c711c2872872d6220f98b2611340e051" +version = "0.9.18" +source = "git+https://github.com/paritytech/polkadot?branch=master#975e780ae0d988dc033f400ba822d14b326ee5b9" dependencies = [ - "futures 0.3.19", - "lru 0.7.2", + "fatality", + "futures 0.3.21", + "lru 0.7.3", "parity-scale-codec", "polkadot-erasure-coding", "polkadot-node-network-protocol", @@ -6611,7 +6826,7 @@ dependencies = [ "polkadot-node-subsystem", "polkadot-node-subsystem-util", "polkadot-primitives", - "rand 0.8.4", + "rand 0.8.5", "sc-network", "thiserror", "tracing", @@ -6619,12 +6834,12 @@ dependencies = [ [[package]] name = "polkadot-cli" -version = "0.9.13" -source = "git+https://github.com/paritytech/polkadot?branch=master#60df3c55c711c2872872d6220f98b2611340e051" +version = "0.9.18" +source = "git+https://github.com/paritytech/polkadot?branch=master#975e780ae0d988dc033f400ba822d14b326ee5b9" dependencies = [ - "clap 3.0.12", + "clap 3.1.6", "frame-benchmarking-cli", - "futures 0.3.19", + "futures 0.3.21", "log", "polkadot-node-core-pvf", "polkadot-node-metrics", @@ -6642,8 +6857,8 @@ dependencies = [ [[package]] name = "polkadot-client" -version = "0.9.13" -source = "git+https://github.com/paritytech/polkadot?branch=master#60df3c55c711c2872872d6220f98b2611340e051" +version = "0.9.18" +source = "git+https://github.com/paritytech/polkadot?branch=master#975e780ae0d988dc033f400ba822d14b326ee5b9" dependencies = [ "beefy-primitives", "frame-benchmarking", @@ -6672,12 +6887,12 @@ dependencies = [ [[package]] name = "polkadot-collator-protocol" -version = "0.9.13" -source = "git+https://github.com/paritytech/polkadot?branch=master#60df3c55c711c2872872d6220f98b2611340e051" +version = "0.9.18" +source = "git+https://github.com/paritytech/polkadot?branch=master#975e780ae0d988dc033f400ba822d14b326ee5b9" dependencies = [ "always-assert", - "derive_more", - "futures 0.3.19", + "fatality", + "futures 0.3.21", "futures-timer", "polkadot-node-network-protocol", "polkadot-node-primitives", @@ -6693,8 +6908,8 @@ dependencies = [ [[package]] name = "polkadot-core-primitives" -version = "0.9.13" -source = "git+https://github.com/paritytech/polkadot?branch=master#60df3c55c711c2872872d6220f98b2611340e051" +version = "0.9.18" +source = "git+https://github.com/paritytech/polkadot?branch=master#975e780ae0d988dc033f400ba822d14b326ee5b9" dependencies = [ "parity-scale-codec", "parity-util-mem", @@ -6706,12 +6921,13 @@ dependencies = [ [[package]] name = "polkadot-dispute-distribution" -version = "0.9.13" -source = "git+https://github.com/paritytech/polkadot?branch=master#60df3c55c711c2872872d6220f98b2611340e051" +version = "0.9.18" +source = "git+https://github.com/paritytech/polkadot?branch=master#975e780ae0d988dc033f400ba822d14b326ee5b9" dependencies = [ "derive_more", - "futures 0.3.19", - "lru 0.7.2", + "fatality", + "futures 0.3.21", + "lru 0.7.3", "parity-scale-codec", "polkadot-erasure-coding", "polkadot-node-network-protocol", @@ -6728,8 +6944,8 @@ dependencies = [ [[package]] name = "polkadot-erasure-coding" -version = "0.9.13" -source = "git+https://github.com/paritytech/polkadot?branch=master#60df3c55c711c2872872d6220f98b2611340e051" +version = "0.9.18" +source = "git+https://github.com/paritytech/polkadot?branch=master#975e780ae0d988dc033f400ba822d14b326ee5b9" dependencies = [ "parity-scale-codec", "polkadot-node-primitives", @@ -6742,16 +6958,16 @@ dependencies = [ [[package]] name = "polkadot-gossip-support" -version = "0.9.13" -source = "git+https://github.com/paritytech/polkadot?branch=master#60df3c55c711c2872872d6220f98b2611340e051" +version = "0.9.18" +source = "git+https://github.com/paritytech/polkadot?branch=master#975e780ae0d988dc033f400ba822d14b326ee5b9" dependencies = [ - "futures 0.3.19", + "futures 0.3.21", "futures-timer", "polkadot-node-network-protocol", "polkadot-node-subsystem", "polkadot-node-subsystem-util", "polkadot-primitives", - "rand 0.8.4", + "rand 0.8.5", "rand_chacha 0.3.1", "sc-network", "sp-application-crypto", @@ -6762,13 +6978,13 @@ dependencies = [ [[package]] name = "polkadot-network-bridge" -version = "0.9.13" -source = "git+https://github.com/paritytech/polkadot?branch=master#60df3c55c711c2872872d6220f98b2611340e051" +version = "0.9.18" +source = "git+https://github.com/paritytech/polkadot?branch=master#975e780ae0d988dc033f400ba822d14b326ee5b9" dependencies = [ "async-trait", - "futures 0.3.19", + "futures 0.3.21", "parity-scale-codec", - "parking_lot 0.11.2", + "parking_lot 0.12.0", "polkadot-node-network-protocol", "polkadot-node-subsystem", "polkadot-node-subsystem-util", @@ -6781,10 +6997,10 @@ dependencies = [ [[package]] name = "polkadot-node-collation-generation" -version = "0.9.13" -source = "git+https://github.com/paritytech/polkadot?branch=master#60df3c55c711c2872872d6220f98b2611340e051" +version = "0.9.18" +source = "git+https://github.com/paritytech/polkadot?branch=master#975e780ae0d988dc033f400ba822d14b326ee5b9" dependencies = [ - "futures 0.3.19", + "futures 0.3.21", "parity-scale-codec", "polkadot-erasure-coding", "polkadot-node-primitives", @@ -6799,15 +7015,15 @@ dependencies = [ [[package]] name = "polkadot-node-core-approval-voting" -version = "0.9.13" -source = "git+https://github.com/paritytech/polkadot?branch=master#60df3c55c711c2872872d6220f98b2611340e051" +version = "0.9.18" +source = "git+https://github.com/paritytech/polkadot?branch=master#975e780ae0d988dc033f400ba822d14b326ee5b9" dependencies = [ "bitvec", "derive_more", - "futures 0.3.19", + "futures 0.3.21", "futures-timer", "kvdb", - "lru 0.7.2", + "lru 0.7.3", "merlin", "parity-scale-codec", "polkadot-node-jaeger", @@ -6827,11 +7043,11 @@ dependencies = [ [[package]] name = "polkadot-node-core-av-store" -version = "0.9.13" -source = "git+https://github.com/paritytech/polkadot?branch=master#60df3c55c711c2872872d6220f98b2611340e051" +version = "0.9.18" +source = "git+https://github.com/paritytech/polkadot?branch=master#975e780ae0d988dc033f400ba822d14b326ee5b9" dependencies = [ "bitvec", - "futures 0.3.19", + "futures 0.3.21", "futures-timer", "kvdb", "parity-scale-codec", @@ -6847,11 +7063,11 @@ dependencies = [ [[package]] name = "polkadot-node-core-backing" -version = "0.9.13" -source = "git+https://github.com/paritytech/polkadot?branch=master#60df3c55c711c2872872d6220f98b2611340e051" +version = "0.9.18" +source = "git+https://github.com/paritytech/polkadot?branch=master#975e780ae0d988dc033f400ba822d14b326ee5b9" dependencies = [ "bitvec", - "futures 0.3.19", + "futures 0.3.21", "polkadot-erasure-coding", "polkadot-node-primitives", "polkadot-node-subsystem", @@ -6865,10 +7081,10 @@ dependencies = [ [[package]] name = "polkadot-node-core-bitfield-signing" -version = "0.9.13" -source = "git+https://github.com/paritytech/polkadot?branch=master#60df3c55c711c2872872d6220f98b2611340e051" +version = "0.9.18" +source = "git+https://github.com/paritytech/polkadot?branch=master#975e780ae0d988dc033f400ba822d14b326ee5b9" dependencies = [ - "futures 0.3.19", + "futures 0.3.21", "polkadot-node-subsystem", "polkadot-node-subsystem-util", "polkadot-primitives", @@ -6880,11 +7096,11 @@ dependencies = [ [[package]] name = "polkadot-node-core-candidate-validation" -version = "0.9.13" -source = "git+https://github.com/paritytech/polkadot?branch=master#60df3c55c711c2872872d6220f98b2611340e051" +version = "0.9.18" +source = "git+https://github.com/paritytech/polkadot?branch=master#975e780ae0d988dc033f400ba822d14b326ee5b9" dependencies = [ "async-trait", - "futures 0.3.19", + "futures 0.3.21", "parity-scale-codec", "polkadot-node-core-pvf", "polkadot-node-primitives", @@ -6898,10 +7114,10 @@ dependencies = [ [[package]] name = "polkadot-node-core-chain-api" -version = "0.9.13" -source = "git+https://github.com/paritytech/polkadot?branch=master#60df3c55c711c2872872d6220f98b2611340e051" +version = "0.9.18" +source = "git+https://github.com/paritytech/polkadot?branch=master#975e780ae0d988dc033f400ba822d14b326ee5b9" dependencies = [ - "futures 0.3.19", + "futures 0.3.21", "polkadot-node-subsystem", "polkadot-node-subsystem-util", "polkadot-primitives", @@ -6913,10 +7129,10 @@ dependencies = [ [[package]] name = "polkadot-node-core-chain-selection" -version = "0.9.13" -source = "git+https://github.com/paritytech/polkadot?branch=master#60df3c55c711c2872872d6220f98b2611340e051" +version = "0.9.18" +source = "git+https://github.com/paritytech/polkadot?branch=master#975e780ae0d988dc033f400ba822d14b326ee5b9" dependencies = [ - "futures 0.3.19", + "futures 0.3.21", "futures-timer", "kvdb", "parity-scale-codec", @@ -6930,12 +7146,13 @@ dependencies = [ [[package]] name = "polkadot-node-core-dispute-coordinator" -version = "0.9.13" -source = "git+https://github.com/paritytech/polkadot?branch=master#60df3c55c711c2872872d6220f98b2611340e051" +version = "0.9.18" +source = "git+https://github.com/paritytech/polkadot?branch=master#975e780ae0d988dc033f400ba822d14b326ee5b9" dependencies = [ - "futures 0.3.19", + "fatality", + "futures 0.3.21", "kvdb", - "lru 0.7.2", + "lru 0.7.3", "parity-scale-codec", "polkadot-node-primitives", "polkadot-node-subsystem", @@ -6948,11 +7165,11 @@ dependencies = [ [[package]] name = "polkadot-node-core-parachains-inherent" -version = "0.9.13" -source = "git+https://github.com/paritytech/polkadot?branch=master#60df3c55c711c2872872d6220f98b2611340e051" +version = "0.9.18" +source = "git+https://github.com/paritytech/polkadot?branch=master#975e780ae0d988dc033f400ba822d14b326ee5b9" dependencies = [ "async-trait", - "futures 0.3.19", + "futures 0.3.21", "futures-timer", "polkadot-node-subsystem", "polkadot-primitives", @@ -6965,38 +7182,38 @@ dependencies = [ [[package]] name = "polkadot-node-core-provisioner" -version = "0.9.13" -source = "git+https://github.com/paritytech/polkadot?branch=master#60df3c55c711c2872872d6220f98b2611340e051" +version = "0.9.18" +source = "git+https://github.com/paritytech/polkadot?branch=master#975e780ae0d988dc033f400ba822d14b326ee5b9" dependencies = [ "bitvec", - "futures 0.3.19", + "futures 0.3.21", "futures-timer", "polkadot-node-primitives", "polkadot-node-subsystem", "polkadot-node-subsystem-util", "polkadot-primitives", - "rand 0.8.4", + "rand 0.8.5", "thiserror", "tracing", ] [[package]] name = "polkadot-node-core-pvf" -version = "0.9.13" -source = "git+https://github.com/paritytech/polkadot?branch=master#60df3c55c711c2872872d6220f98b2611340e051" +version = "0.9.18" +source = "git+https://github.com/paritytech/polkadot?branch=master#975e780ae0d988dc033f400ba822d14b326ee5b9" dependencies = [ "always-assert", "assert_matches", "async-process", "async-std", - "futures 0.3.19", + "futures 0.3.21", "futures-timer", "parity-scale-codec", "pin-project 1.0.10", "polkadot-core-primitives", "polkadot-node-subsystem-util", "polkadot-parachain", - "rand 0.8.4", + "rand 0.8.5", "sc-executor", "sc-executor-common", "sc-executor-wasmtime", @@ -7012,10 +7229,10 @@ dependencies = [ [[package]] name = "polkadot-node-core-pvf-checker" -version = "0.9.13" -source = "git+https://github.com/paritytech/polkadot?branch=master#60df3c55c711c2872872d6220f98b2611340e051" +version = "0.9.18" +source = "git+https://github.com/paritytech/polkadot?branch=master#975e780ae0d988dc033f400ba822d14b326ee5b9" dependencies = [ - "futures 0.3.19", + "futures 0.3.21", "polkadot-node-primitives", "polkadot-node-subsystem", "polkadot-node-subsystem-util", @@ -7028,10 +7245,10 @@ dependencies = [ [[package]] name = "polkadot-node-core-runtime-api" -version = "0.9.13" -source = "git+https://github.com/paritytech/polkadot?branch=master#60df3c55c711c2872872d6220f98b2611340e051" +version = "0.9.18" +source = "git+https://github.com/paritytech/polkadot?branch=master#975e780ae0d988dc033f400ba822d14b326ee5b9" dependencies = [ - "futures 0.3.19", + "futures 0.3.21", "memory-lru", "parity-util-mem", "polkadot-node-subsystem", @@ -7046,15 +7263,15 @@ dependencies = [ [[package]] name = "polkadot-node-jaeger" -version = "0.9.13" -source = "git+https://github.com/paritytech/polkadot?branch=master#60df3c55c711c2872872d6220f98b2611340e051" +version = "0.9.18" +source = "git+https://github.com/paritytech/polkadot?branch=master#975e780ae0d988dc033f400ba822d14b326ee5b9" dependencies = [ "async-std", "lazy_static", "log", "mick-jaeger", "parity-scale-codec", - "parking_lot 0.11.2", + "parking_lot 0.12.0", "polkadot-node-primitives", "polkadot-primitives", "sc-network", @@ -7064,11 +7281,11 @@ dependencies = [ [[package]] name = "polkadot-node-metrics" -version = "0.9.13" -source = "git+https://github.com/paritytech/polkadot?branch=master#60df3c55c711c2872872d6220f98b2611340e051" +version = "0.9.18" +source = "git+https://github.com/paritytech/polkadot?branch=master#975e780ae0d988dc033f400ba822d14b326ee5b9" dependencies = [ "bs58", - "futures 0.3.19", + "futures 0.3.21", "futures-timer", "log", "metered-channel", @@ -7083,29 +7300,29 @@ dependencies = [ [[package]] name = "polkadot-node-network-protocol" -version = "0.9.13" -source = "git+https://github.com/paritytech/polkadot?branch=master#60df3c55c711c2872872d6220f98b2611340e051" +version = "0.9.18" +source = "git+https://github.com/paritytech/polkadot?branch=master#975e780ae0d988dc033f400ba822d14b326ee5b9" dependencies = [ "async-trait", - "derive_more", - "futures 0.3.19", + "fatality", + "futures 0.3.21", "parity-scale-codec", "polkadot-node-jaeger", "polkadot-node-primitives", "polkadot-primitives", "sc-authority-discovery", "sc-network", - "strum 0.23.0", + "strum 0.24.0", "thiserror", ] [[package]] name = "polkadot-node-primitives" -version = "0.9.13" -source = "git+https://github.com/paritytech/polkadot?branch=master#60df3c55c711c2872872d6220f98b2611340e051" +version = "0.9.18" +source = "git+https://github.com/paritytech/polkadot?branch=master#975e780ae0d988dc033f400ba822d14b326ee5b9" dependencies = [ "bounded-vec", - "futures 0.3.19", + "futures 0.3.21", "parity-scale-codec", "polkadot-parachain", "polkadot-primitives", @@ -7123,8 +7340,8 @@ dependencies = [ [[package]] name = "polkadot-node-subsystem" -version = "0.9.13" -source = "git+https://github.com/paritytech/polkadot?branch=master#60df3c55c711c2872872d6220f98b2611340e051" +version = "0.9.18" +source = "git+https://github.com/paritytech/polkadot?branch=master#975e780ae0d988dc033f400ba822d14b326ee5b9" dependencies = [ "polkadot-node-jaeger", "polkadot-node-subsystem-types", @@ -7133,11 +7350,11 @@ dependencies = [ [[package]] name = "polkadot-node-subsystem-types" -version = "0.9.13" -source = "git+https://github.com/paritytech/polkadot?branch=master#60df3c55c711c2872872d6220f98b2611340e051" +version = "0.9.18" +source = "git+https://github.com/paritytech/polkadot?branch=master#975e780ae0d988dc033f400ba822d14b326ee5b9" dependencies = [ "derive_more", - "futures 0.3.19", + "futures 0.3.21", "polkadot-node-jaeger", "polkadot-node-network-protocol", "polkadot-node-primitives", @@ -7152,16 +7369,21 @@ dependencies = [ [[package]] name = "polkadot-node-subsystem-util" -version = "0.9.13" -source = "git+https://github.com/paritytech/polkadot?branch=master#60df3c55c711c2872872d6220f98b2611340e051" +version = "0.9.18" +source = "git+https://github.com/paritytech/polkadot?branch=master#975e780ae0d988dc033f400ba822d14b326ee5b9" dependencies = [ "async-trait", "derive_more", - "futures 0.3.19", + "fatality", + "futures 0.3.21", "itertools", - "lru 0.7.2", + "kvdb", + "lru 0.7.3", "metered-channel", + "parity-db", "parity-scale-codec", + "parity-util-mem", + "parking_lot 0.11.2", "pin-project 1.0.10", "polkadot-node-jaeger", "polkadot-node-metrics", @@ -7170,7 +7392,7 @@ dependencies = [ "polkadot-node-subsystem", "polkadot-overseer", "polkadot-primitives", - "rand 0.8.4", + "rand 0.8.5", "sp-application-crypto", "sp-core", "sp-keystore", @@ -7180,14 +7402,14 @@ dependencies = [ [[package]] name = "polkadot-overseer" -version = "0.9.13" -source = "git+https://github.com/paritytech/polkadot?branch=master#60df3c55c711c2872872d6220f98b2611340e051" +version = "0.9.18" +source = "git+https://github.com/paritytech/polkadot?branch=master#975e780ae0d988dc033f400ba822d14b326ee5b9" dependencies = [ - "futures 0.3.19", + "futures 0.3.21", "futures-timer", - "lru 0.7.2", + "lru 0.7.3", "parity-util-mem", - "parking_lot 0.11.2", + "parking_lot 0.12.0", "polkadot-node-metrics", "polkadot-node-network-protocol", "polkadot-node-primitives", @@ -7201,11 +7423,11 @@ dependencies = [ [[package]] name = "polkadot-overseer-gen" -version = "0.9.13" -source = "git+https://github.com/paritytech/polkadot?branch=master#60df3c55c711c2872872d6220f98b2611340e051" +version = "0.9.18" +source = "git+https://github.com/paritytech/polkadot?branch=master#975e780ae0d988dc033f400ba822d14b326ee5b9" dependencies = [ "async-trait", - "futures 0.3.19", + "futures 0.3.21", "futures-timer", "metered-channel", "pin-project 1.0.10", @@ -7218,10 +7440,11 @@ dependencies = [ [[package]] name = "polkadot-overseer-gen-proc-macro" -version = "0.9.13" -source = "git+https://github.com/paritytech/polkadot?branch=master#60df3c55c711c2872872d6220f98b2611340e051" +version = "0.9.18" +source = "git+https://github.com/paritytech/polkadot?branch=master#975e780ae0d988dc033f400ba822d14b326ee5b9" dependencies = [ - "proc-macro-crate 1.1.0", + "expander 0.0.6", + "proc-macro-crate 1.1.3", "proc-macro2", "quote", "syn", @@ -7229,8 +7452,8 @@ dependencies = [ [[package]] name = "polkadot-parachain" -version = "0.9.13" -source = "git+https://github.com/paritytech/polkadot?branch=master#60df3c55c711c2872872d6220f98b2611340e051" +version = "0.9.18" +source = "git+https://github.com/paritytech/polkadot?branch=master#975e780ae0d988dc033f400ba822d14b326ee5b9" dependencies = [ "derive_more", "frame-support", @@ -7246,8 +7469,8 @@ dependencies = [ [[package]] name = "polkadot-performance-test" -version = "0.9.13" -source = "git+https://github.com/paritytech/polkadot?branch=master#60df3c55c711c2872872d6220f98b2611340e051" +version = "0.9.18" +source = "git+https://github.com/paritytech/polkadot?branch=master#975e780ae0d988dc033f400ba822d14b326ee5b9" dependencies = [ "env_logger 0.9.0", "kusama-runtime", @@ -7261,8 +7484,8 @@ dependencies = [ [[package]] name = "polkadot-primitives" -version = "0.9.13" -source = "git+https://github.com/paritytech/polkadot?branch=master#60df3c55c711c2872872d6220f98b2611340e051" +version = "0.9.18" +source = "git+https://github.com/paritytech/polkadot?branch=master#975e780ae0d988dc033f400ba822d14b326ee5b9" dependencies = [ "bitvec", "frame-system", @@ -7291,8 +7514,8 @@ dependencies = [ [[package]] name = "polkadot-rpc" -version = "0.9.13" -source = "git+https://github.com/paritytech/polkadot?branch=master#60df3c55c711c2872872d6220f98b2611340e051" +version = "0.9.18" +source = "git+https://github.com/paritytech/polkadot?branch=master#975e780ae0d988dc033f400ba822d14b326ee5b9" dependencies = [ "beefy-gadget", "beefy-gadget-rpc", @@ -7322,8 +7545,8 @@ dependencies = [ [[package]] name = "polkadot-runtime" -version = "0.9.13" -source = "git+https://github.com/paritytech/polkadot?branch=master#60df3c55c711c2872872d6220f98b2611340e051" +version = "0.9.18" +source = "git+https://github.com/paritytech/polkadot?branch=master#975e780ae0d988dc033f400ba822d14b326ee5b9" dependencies = [ "beefy-primitives", "bitvec", @@ -7401,8 +7624,8 @@ dependencies = [ [[package]] name = "polkadot-runtime-common" -version = "0.9.13" -source = "git+https://github.com/paritytech/polkadot?branch=master#60df3c55c711c2872872d6220f98b2611340e051" +version = "0.9.18" +source = "git+https://github.com/paritytech/polkadot?branch=master#975e780ae0d988dc033f400ba822d14b326ee5b9" dependencies = [ "beefy-primitives", "bitvec", @@ -7446,8 +7669,8 @@ dependencies = [ [[package]] name = "polkadot-runtime-constants" -version = "0.9.13" -source = "git+https://github.com/paritytech/polkadot?branch=master#60df3c55c711c2872872d6220f98b2611340e051" +version = "0.9.18" +source = "git+https://github.com/paritytech/polkadot?branch=master#975e780ae0d988dc033f400ba822d14b326ee5b9" dependencies = [ "frame-support", "polkadot-primitives", @@ -7458,8 +7681,8 @@ dependencies = [ [[package]] name = "polkadot-runtime-metrics" -version = "0.9.13" -source = "git+https://github.com/paritytech/polkadot?branch=master#60df3c55c711c2872872d6220f98b2611340e051" +version = "0.9.18" +source = "git+https://github.com/paritytech/polkadot?branch=master#975e780ae0d988dc033f400ba822d14b326ee5b9" dependencies = [ "bs58", "parity-scale-codec", @@ -7470,8 +7693,8 @@ dependencies = [ [[package]] name = "polkadot-runtime-parachains" -version = "0.9.13" -source = "git+https://github.com/paritytech/polkadot?branch=master#60df3c55c711c2872872d6220f98b2611340e051" +version = "0.9.18" +source = "git+https://github.com/paritytech/polkadot?branch=master#975e780ae0d988dc033f400ba822d14b326ee5b9" dependencies = [ "bitflags", "bitvec", @@ -7490,7 +7713,7 @@ dependencies = [ "parity-scale-codec", "polkadot-primitives", "polkadot-runtime-metrics", - "rand 0.8.4", + "rand 0.8.5", "rand_chacha 0.3.1", "rustc-hex", "scale-info", @@ -7510,23 +7733,24 @@ dependencies = [ [[package]] name = "polkadot-service" -version = "0.9.13" -source = "git+https://github.com/paritytech/polkadot?branch=master#60df3c55c711c2872872d6220f98b2611340e051" +version = "0.9.18" +source = "git+https://github.com/paritytech/polkadot?branch=master#975e780ae0d988dc033f400ba822d14b326ee5b9" dependencies = [ "async-trait", "beefy-gadget", "beefy-primitives", "frame-system-rpc-runtime-api", - "futures 0.3.19", + "futures 0.3.21", "hex-literal", "kvdb", - "kvdb-rocksdb 0.14.0", - "lru 0.7.2", + "kvdb-rocksdb", + "lru 0.7.3", "pallet-babe", "pallet-im-online", "pallet-mmr-primitives", "pallet-staking", "pallet-transaction-payment-rpc-runtime-api", + "parity-db", "polkadot-approval-distribution", "polkadot-availability-bitfield-distribution", "polkadot-availability-distribution", @@ -7607,12 +7831,12 @@ dependencies = [ [[package]] name = "polkadot-statement-distribution" -version = "0.9.13" -source = "git+https://github.com/paritytech/polkadot?branch=master#60df3c55c711c2872872d6220f98b2611340e051" +version = "0.9.18" +source = "git+https://github.com/paritytech/polkadot?branch=master#975e780ae0d988dc033f400ba822d14b326ee5b9" dependencies = [ "arrayvec 0.5.2", - "derive_more", - "futures 0.3.19", + "fatality", + "futures 0.3.21", "indexmap", "parity-scale-codec", "polkadot-node-network-protocol", @@ -7628,8 +7852,8 @@ dependencies = [ [[package]] name = "polkadot-statement-table" -version = "0.9.13" -source = "git+https://github.com/paritytech/polkadot?branch=master#60df3c55c711c2872872d6220f98b2611340e051" +version = "0.9.18" +source = "git+https://github.com/paritytech/polkadot?branch=master#975e780ae0d988dc033f400ba822d14b326ee5b9" dependencies = [ "parity-scale-codec", "polkadot-primitives", @@ -7638,8 +7862,8 @@ dependencies = [ [[package]] name = "polkadot-test-runtime" -version = "0.9.13" -source = "git+https://github.com/paritytech/polkadot?branch=master#60df3c55c711c2872872d6220f98b2611340e051" +version = "0.9.18" +source = "git+https://github.com/paritytech/polkadot?branch=master#975e780ae0d988dc033f400ba822d14b326ee5b9" dependencies = [ "beefy-primitives", "bitvec", @@ -7700,13 +7924,13 @@ dependencies = [ [[package]] name = "polkadot-test-service" -version = "0.9.13" -source = "git+https://github.com/paritytech/polkadot?branch=master#60df3c55c711c2872872d6220f98b2611340e051" +version = "0.9.18" +source = "git+https://github.com/paritytech/polkadot?branch=master#975e780ae0d988dc033f400ba822d14b326ee5b9" dependencies = [ "frame-benchmarking", "frame-system", "futures 0.1.31", - "futures 0.3.19", + "futures 0.3.21", "hex", "pallet-balances", "pallet-staking", @@ -7721,7 +7945,7 @@ dependencies = [ "polkadot-runtime-parachains", "polkadot-service", "polkadot-test-runtime", - "rand 0.8.4", + "rand 0.8.5", "sc-authority-discovery", "sc-chain-spec", "sc-cli", @@ -7796,13 +8020,12 @@ checksum = "ed0cfbc8191465bed66e1718596ee0b0b35d5ee1f41c5df2189d0fe8bde535ba" [[package]] name = "primitive-types" -version = "0.10.1" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05e4722c697a58a99d5d06a08c30821d7c082a4632198de1eaa5a6c22ef42373" +checksum = "e28720988bff275df1f51b171e1b2a18c30d194c4d2b61defdacecd625a5d94a" dependencies = [ "fixed-hash", "impl-codec", - "impl-rlp", "impl-serde", "scale-info", "uint", @@ -7819,50 +8042,24 @@ dependencies = [ [[package]] name = "proc-macro-crate" -version = "1.1.0" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ebace6889caf889b4d3f76becee12e90353f2b8c7d875534a71e5742f8f6f83" +checksum = "e17d47ce914bf4de440332250b0edd23ce48c005f59fab39d3335866b114f11a" dependencies = [ "thiserror", "toml", ] -[[package]] -name = "proc-macro-error" -version = "0.4.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18f33027081eba0a6d8aba6d1b1c3a3be58cbb12106341c2d5759fcd9b5277e7" -dependencies = [ - "proc-macro-error-attr 0.4.12", - "proc-macro2", - "quote", - "syn", - "version_check", -] - [[package]] name = "proc-macro-error" version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" dependencies = [ - "proc-macro-error-attr 1.0.4", - "proc-macro2", - "quote", - "syn", - "version_check", -] - -[[package]] -name = "proc-macro-error-attr" -version = "0.4.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a5b4b77fdb63c1eca72173d68d24501c54ab1269409f6b672c85deb18af69de" -dependencies = [ + "proc-macro-error-attr", "proc-macro2", "quote", "syn", - "syn-mid", "version_check", ] @@ -7877,12 +8074,6 @@ dependencies = [ "version_check", ] -[[package]] -name = "proc-macro-hack" -version = "0.5.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5" - [[package]] name = "proc-macro2" version = "1.0.36" @@ -8002,9 +8193,9 @@ dependencies = [ [[package]] name = "radium" -version = "0.6.2" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "643f8f41a8ebc4c5dc4515c82bb8abd397b527fc20fd681b7c011c2aee5d44fb" +checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" [[package]] name = "rand" @@ -8016,20 +8207,19 @@ dependencies = [ "libc", "rand_chacha 0.2.2", "rand_core 0.5.1", - "rand_hc 0.2.0", + "rand_hc", "rand_pcg", ] [[package]] name = "rand" -version = "0.8.4" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e7573632e6454cf6b99d7aac4ccca54be06da05aca2ef7423d22d27d4d4bcd8" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" dependencies = [ "libc", "rand_chacha 0.3.1", "rand_core 0.6.3", - "rand_hc 0.3.1", ] [[package]] @@ -8077,7 +8267,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "964d548f8e7d12e102ef183a0de7e98180c9f8729f555897a857b96e48122d2f" dependencies = [ "num-traits", - "rand 0.8.4", + "rand 0.8.5", ] [[package]] @@ -8089,15 +8279,6 @@ dependencies = [ "rand_core 0.5.1", ] -[[package]] -name = "rand_hc" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d51e9f596de227fda2ea6c84607f5558e196eeaf43c986b724ba4fb8fdf497e7" -dependencies = [ - "rand_core 0.6.3", -] - [[package]] name = "rand_pcg" version = "0.2.1" @@ -8138,12 +8319,6 @@ dependencies = [ "num_cpus", ] -[[package]] -name = "redox_syscall" -version = "0.1.57" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" - [[package]] name = "redox_syscall" version = "0.2.10" @@ -8160,7 +8335,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "528532f3d801c87aec9def2add9ca802fe569e44a544afe633765267840abe64" dependencies = [ "getrandom 0.2.3", - "redox_syscall 0.2.10", + "redox_syscall", ] [[package]] @@ -8209,9 +8384,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.5.4" +version = "1.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d07a8629359eb56f1e2fb1652bb04212c072a87ba68546a04065d525673ac461" +checksum = "1a11647b6b25ff05a515cb92c365cec08801e83423a235b51e231e1808747286" dependencies = [ "aho-corasick", "memchr", @@ -8371,9 +8546,8 @@ dependencies = [ "finality-relay", "frame-support", "frame-system", - "futures 0.3.19", - "jsonrpsee-proc-macros 0.3.1", - "jsonrpsee-ws-client 0.3.1", + "futures 0.3.21", + "jsonrpsee 0.8.0", "log", "num-traits", "pallet-balances", @@ -8386,6 +8560,7 @@ dependencies = [ "sc-chain-spec", "sc-rpc-api", "sc-transaction-pool-api", + "serde", "sp-core", "sp-finality-grandpa", "sp-rpc", @@ -8408,7 +8583,7 @@ dependencies = [ "backoff", "bp-runtime", "env_logger 0.8.4", - "futures 0.3.19", + "futures 0.3.21", "isahc", "jsonpath_lib", "log", @@ -8417,7 +8592,8 @@ dependencies = [ "substrate-prometheus-endpoint", "sysinfo", "thiserror", - "time 0.2.27", + "time 0.3.7", + "tokio", ] [[package]] @@ -8459,10 +8635,10 @@ dependencies = [ [[package]] name = "remote-externalities" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "env_logger 0.9.0", - "jsonrpsee", + "jsonrpsee 0.8.0", "log", "parity-scale-codec", "serde", @@ -8507,15 +8683,15 @@ dependencies = [ "beefy-primitives", "bp-rialto", "bp-runtime", - "clap 3.0.12", + "clap 3.1.6", "frame-benchmarking", "frame-benchmarking-cli", "frame-system-rpc-runtime-api", - "futures 0.3.19", + "futures 0.3.21", "jsonrpc-core", "kvdb", - "kvdb-rocksdb 0.12.1", - "lru 0.7.2", + "kvdb-rocksdb", + "lru 0.7.3", "node-inspect", "pallet-bridge-messages", "pallet-mmr-primitives", @@ -8570,7 +8746,7 @@ dependencies = [ name = "rialto-parachain-collator" version = "0.1.0" dependencies = [ - "clap 3.0.12", + "clap 3.1.6", "cumulus-client-cli", "cumulus-client-collator", "cumulus-client-consensus-aura", @@ -8579,8 +8755,8 @@ dependencies = [ "cumulus-client-service", "cumulus-primitives-core", "cumulus-primitives-parachain-inherent", + "cumulus-relay-chain-inprocess-interface", "cumulus-relay-chain-interface", - "cumulus-relay-chain-local", "derive_more", "frame-benchmarking", "frame-benchmarking-cli", @@ -8737,6 +8913,7 @@ dependencies = [ "sp-transaction-pool", "sp-trie", "sp-version", + "static_assertions", "substrate-wasm-builder", ] @@ -8756,20 +8933,10 @@ dependencies = [ ] [[package]] -name = "rlp" -version = "0.5.1" +name = "rocksdb" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "999508abb0ae792aabed2460c45b89106d97fe4adac593bdaef433c2605847b5" -dependencies = [ - "bytes 1.1.0", - "rustc-hex", -] - -[[package]] -name = "rocksdb" -version = "0.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a62eca5cacf2c8261128631bed9f045598d40bfbe4b29f5163f0f802f8f44a7" +checksum = "620f4129485ff1a7128d184bc687470c21c7951b64779ebc9cfdad3dcd920290" dependencies = [ "libc", "librocksdb-sys", @@ -8853,8 +9020,20 @@ dependencies = [ "base64", "log", "ring", - "sct", - "webpki", + "sct 0.6.1", + "webpki 0.21.4", +] + +[[package]] +name = "rustls" +version = "0.20.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fbfeb8d0ddb84706bc597a5574ab8912817c52a397f819e5b614e2265206921" +dependencies = [ + "log", + "ring", + "sct 0.7.0", + "webpki 0.22.0", ] [[package]] @@ -8864,11 +9043,32 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5a07b7c1885bd8ed3831c289b7870b13ef46fe0e856d288c30d9cc17d75a2092" dependencies = [ "openssl-probe", - "rustls", + "rustls 0.19.1", "schannel", "security-framework", ] +[[package]] +name = "rustls-native-certs" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ca9ebdfa27d3fc180e42879037b5338ab1c040c06affd00d8338598e7800943" +dependencies = [ + "openssl-probe", + "rustls-pemfile", + "schannel", + "security-framework", +] + +[[package]] +name = "rustls-pemfile" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5eebeaeb360c87bfb72e84abdb3447159c0eaececf1bef2aecd65a8be949d1c9" +dependencies = [ + "base64", +] + [[package]] name = "rustversion" version = "1.0.5" @@ -8881,7 +9081,7 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4da5fcb054c46f5a5dff833b129285a93d3f0179531735e6c866e8cc307d2020" dependencies = [ - "futures 0.3.19", + "futures 0.3.21", "pin-project 0.4.29", "static_assertions", ] @@ -8922,7 +9122,7 @@ dependencies = [ [[package]] name = "sc-allocator" version = "4.1.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "log", "sp-core", @@ -8933,11 +9133,10 @@ dependencies = [ [[package]] name = "sc-authority-discovery" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "async-trait", - "derive_more", - "futures 0.3.19", + "futures 0.3.21", "futures-timer", "ip_network", "libp2p", @@ -8955,14 +9154,15 @@ dependencies = [ "sp-keystore", "sp-runtime", "substrate-prometheus-endpoint", + "thiserror", ] [[package]] name = "sc-basic-authorship" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ - "futures 0.3.19", + "futures 0.3.21", "futures-timer", "log", "parity-scale-codec", @@ -8983,7 +9183,7 @@ dependencies = [ [[package]] name = "sc-block-builder" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "parity-scale-codec", "sc-client-api", @@ -8999,7 +9199,7 @@ dependencies = [ [[package]] name = "sc-chain-spec" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "impl-trait-for-tuples", "memmap2 0.5.0", @@ -9016,9 +9216,9 @@ dependencies = [ [[package]] name = "sc-chain-spec-derive" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ - "proc-macro-crate 1.1.0", + "proc-macro-crate 1.1.3", "proc-macro2", "quote", "syn", @@ -9027,12 +9227,12 @@ dependencies = [ [[package]] name = "sc-cli" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "chrono", - "clap 3.0.12", + "clap 3.1.6", "fdlimit", - "futures 0.3.19", + "futures 0.3.21", "hex", "libp2p", "log", @@ -9065,14 +9265,14 @@ dependencies = [ [[package]] name = "sc-client-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "fnv", - "futures 0.3.19", + "futures 0.3.21", "hash-db", "log", "parity-scale-codec", - "parking_lot 0.11.2", + "parking_lot 0.12.0", "sc-executor", "sc-transaction-pool-api", "sc-utils", @@ -9093,17 +9293,17 @@ dependencies = [ [[package]] name = "sc-client-db" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "hash-db", "kvdb", "kvdb-memorydb", - "kvdb-rocksdb 0.14.0", + "kvdb-rocksdb", "linked-hash-map", "log", "parity-db", "parity-scale-codec", - "parking_lot 0.11.2", + "parking_lot 0.12.0", "sc-client-api", "sc-state-db", "sp-arithmetic", @@ -9118,14 +9318,14 @@ dependencies = [ [[package]] name = "sc-consensus" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "async-trait", - "futures 0.3.19", + "futures 0.3.21", "futures-timer", "libp2p", "log", - "parking_lot 0.11.2", + "parking_lot 0.12.0", "sc-client-api", "sc-utils", "serde", @@ -9142,11 +9342,10 @@ dependencies = [ [[package]] name = "sc-consensus-aura" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "async-trait", - "derive_more", - "futures 0.3.19", + "futures 0.3.21", "log", "parity-scale-codec", "sc-block-builder", @@ -9166,24 +9365,24 @@ dependencies = [ "sp-keystore", "sp-runtime", "substrate-prometheus-endpoint", + "thiserror", ] [[package]] name = "sc-consensus-babe" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "async-trait", - "derive_more", "fork-tree", - "futures 0.3.19", + "futures 0.3.21", "log", "merlin", "num-bigint", "num-rational 0.2.4", "num-traits", "parity-scale-codec", - "parking_lot 0.11.2", + "parking_lot 0.12.0", "rand 0.7.3", "retain_mut", "sc-client-api", @@ -9209,15 +9408,15 @@ dependencies = [ "sp-runtime", "sp-version", "substrate-prometheus-endpoint", + "thiserror", ] [[package]] name = "sc-consensus-babe-rpc" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ - "derive_more", - "futures 0.3.19", + "futures 0.3.21", "jsonrpc-core", "jsonrpc-core-client", "jsonrpc-derive", @@ -9233,12 +9432,13 @@ dependencies = [ "sp-core", "sp-keystore", "sp-runtime", + "thiserror", ] [[package]] name = "sc-consensus-epochs" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "fork-tree", "parity-scale-codec", @@ -9251,10 +9451,10 @@ dependencies = [ [[package]] name = "sc-consensus-slots" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "async-trait", - "futures 0.3.19", + "futures 0.3.21", "futures-timer", "log", "parity-scale-codec", @@ -9276,7 +9476,7 @@ dependencies = [ [[package]] name = "sc-consensus-uncles" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "sc-client-api", "sp-authorship", @@ -9287,14 +9487,12 @@ dependencies = [ [[package]] name = "sc-executor" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "lazy_static", - "libsecp256k1", - "log", "lru 0.6.6", "parity-scale-codec", - "parking_lot 0.11.2", + "parking_lot 0.12.0", "sc-executor-common", "sc-executor-wasmi", "sc-executor-wasmtime", @@ -9309,15 +9507,15 @@ dependencies = [ "sp-trie", "sp-version", "sp-wasm-interface", + "tracing", "wasmi", ] [[package]] name = "sc-executor-common" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ - "derive_more", "environmental", "parity-scale-codec", "sc-allocator", @@ -9333,7 +9531,7 @@ dependencies = [ [[package]] name = "sc-executor-wasmi" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "log", "parity-scale-codec", @@ -9349,7 +9547,7 @@ dependencies = [ [[package]] name = "sc-executor-wasmtime" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "cfg-if 1.0.0", "libc", @@ -9367,19 +9565,20 @@ dependencies = [ [[package]] name = "sc-finality-grandpa" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ + "ahash", "async-trait", - "derive_more", "dyn-clone", "finality-grandpa", "fork-tree", - "futures 0.3.19", + "futures 0.3.21", "futures-timer", + "hex", "log", "parity-scale-codec", - "parking_lot 0.11.2", - "rand 0.8.4", + "parking_lot 0.12.0", + "rand 0.8.5", "sc-block-builder", "sc-chain-spec", "sc-client-api", @@ -9400,16 +9599,16 @@ dependencies = [ "sp-keystore", "sp-runtime", "substrate-prometheus-endpoint", + "thiserror", ] [[package]] name = "sc-finality-grandpa-rpc" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ - "derive_more", "finality-grandpa", - "futures 0.3.19", + "futures 0.3.21", "jsonrpc-core", "jsonrpc-core-client", "jsonrpc-derive", @@ -9424,15 +9623,16 @@ dependencies = [ "sp-blockchain", "sp-core", "sp-runtime", + "thiserror", ] [[package]] name = "sc-informant" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "ansi_term 0.12.1", - "futures 0.3.19", + "futures 0.3.21", "futures-timer", "log", "parity-util-mem", @@ -9446,34 +9646,32 @@ dependencies = [ [[package]] name = "sc-keystore" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "async-trait", - "derive_more", "hex", - "parking_lot 0.11.2", + "parking_lot 0.12.0", "serde_json", "sp-application-crypto", "sp-core", "sp-keystore", + "thiserror", ] [[package]] name = "sc-network" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ - "async-std", "async-trait", "asynchronous-codec 0.5.0", "bitflags", "bytes 1.1.0", "cid", - "derive_more", "either", "fnv", "fork-tree", - "futures 0.3.19", + "futures 0.3.21", "futures-timer", "hex", "ip_network", @@ -9481,9 +9679,9 @@ dependencies = [ "linked-hash-map", "linked_hash_set", "log", - "lru 0.7.2", + "lru 0.7.3", "parity-scale-codec", - "parking_lot 0.11.2", + "parking_lot 0.12.0", "pin-project 1.0.10", "prost", "prost-build", @@ -9512,13 +9710,14 @@ dependencies = [ [[package]] name = "sc-network-gossip" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ - "futures 0.3.19", + "ahash", + "futures 0.3.21", "futures-timer", "libp2p", "log", - "lru 0.7.2", + "lru 0.7.3", "sc-network", "sp-runtime", "substrate-prometheus-endpoint", @@ -9528,11 +9727,11 @@ dependencies = [ [[package]] name = "sc-offchain" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "bytes 1.1.0", "fnv", - "futures 0.3.19", + "futures 0.3.21", "futures-timer", "hex", "hyper", @@ -9540,7 +9739,7 @@ dependencies = [ "num_cpus", "once_cell", "parity-scale-codec", - "parking_lot 0.11.2", + "parking_lot 0.12.0", "rand 0.7.3", "sc-client-api", "sc-network", @@ -9556,9 +9755,9 @@ dependencies = [ [[package]] name = "sc-peerset" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ - "futures 0.3.19", + "futures 0.3.21", "libp2p", "log", "sc-utils", @@ -9569,7 +9768,7 @@ dependencies = [ [[package]] name = "sc-proposer-metrics" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "log", "substrate-prometheus-endpoint", @@ -9578,15 +9777,15 @@ dependencies = [ [[package]] name = "sc-rpc" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ - "futures 0.3.19", + "futures 0.3.21", "hash-db", "jsonrpc-core", "jsonrpc-pubsub", "log", "parity-scale-codec", - "parking_lot 0.11.2", + "parking_lot 0.12.0", "sc-block-builder", "sc-chain-spec", "sc-client-api", @@ -9609,16 +9808,16 @@ dependencies = [ [[package]] name = "sc-rpc-api" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ - "futures 0.3.19", + "futures 0.3.21", "jsonrpc-core", "jsonrpc-core-client", "jsonrpc-derive", "jsonrpc-pubsub", "log", "parity-scale-codec", - "parking_lot 0.11.2", + "parking_lot 0.12.0", "sc-chain-spec", "sc-transaction-pool-api", "serde", @@ -9634,9 +9833,9 @@ dependencies = [ [[package]] name = "sc-rpc-server" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ - "futures 0.3.19", + "futures 0.3.21", "jsonrpc-core", "jsonrpc-http-server", "jsonrpc-ipc-server", @@ -9651,12 +9850,12 @@ dependencies = [ [[package]] name = "sc-service" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "async-trait", "directories", "exit-future", - "futures 0.3.19", + "futures 0.3.21", "futures-timer", "hash-db", "jsonrpc-core", @@ -9664,7 +9863,7 @@ dependencies = [ "log", "parity-scale-codec", "parity-util-mem", - "parking_lot 0.11.2", + "parking_lot 0.12.0", "pin-project 1.0.10", "rand 0.7.3", "sc-block-builder", @@ -9715,13 +9914,13 @@ dependencies = [ [[package]] name = "sc-state-db" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "log", "parity-scale-codec", "parity-util-mem", "parity-util-mem-derive", - "parking_lot 0.11.2", + "parking_lot 0.12.0", "sc-client-api", "sp-core", ] @@ -9729,7 +9928,7 @@ dependencies = [ [[package]] name = "sc-sync-state-rpc" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "jsonrpc-core", "jsonrpc-core-client", @@ -9740,7 +9939,6 @@ dependencies = [ "sc-consensus-babe", "sc-consensus-epochs", "sc-finality-grandpa", - "sc-rpc-api", "serde", "serde_json", "sp-blockchain", @@ -9751,13 +9949,13 @@ dependencies = [ [[package]] name = "sc-telemetry" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "chrono", - "futures 0.3.19", + "futures 0.3.21", "libp2p", "log", - "parking_lot 0.11.2", + "parking_lot 0.12.0", "pin-project 1.0.10", "rand 0.7.3", "serde", @@ -9769,7 +9967,7 @@ dependencies = [ [[package]] name = "sc-tracing" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "ansi_term 0.12.1", "atty", @@ -9778,7 +9976,7 @@ dependencies = [ "libc", "log", "once_cell", - "parking_lot 0.11.2", + "parking_lot 0.12.0", "regex", "rustc-hash", "sc-client-api", @@ -9800,9 +9998,9 @@ dependencies = [ [[package]] name = "sc-tracing-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ - "proc-macro-crate 1.1.0", + "proc-macro-crate 1.1.3", "proc-macro2", "quote", "syn", @@ -9811,15 +10009,15 @@ dependencies = [ [[package]] name = "sc-transaction-pool" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ - "futures 0.3.19", + "futures 0.3.21", "futures-timer", "linked-hash-map", "log", "parity-scale-codec", "parity-util-mem", - "parking_lot 0.11.2", + "parking_lot 0.12.0", "retain_mut", "sc-client-api", "sc-transaction-pool-api", @@ -9838,10 +10036,9 @@ dependencies = [ [[package]] name = "sc-transaction-pool-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ - "derive_more", - "futures 0.3.19", + "futures 0.3.21", "log", "serde", "sp-blockchain", @@ -9852,20 +10049,21 @@ dependencies = [ [[package]] name = "sc-utils" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ - "futures 0.3.19", + "futures 0.3.21", "futures-timer", "lazy_static", - "parking_lot 0.11.2", + "log", + "parking_lot 0.12.0", "prometheus", ] [[package]] name = "scale-info" -version = "1.0.0" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c55b744399c25532d63a0d2789b109df8d46fc93752d46b0782991a931a782f" +checksum = "0563970d79bcbf3c537ce3ad36d859b30d36fc5b190efd227f1f7a84d7cf0d42" dependencies = [ "bitvec", "cfg-if 1.0.0", @@ -9877,11 +10075,11 @@ dependencies = [ [[package]] name = "scale-info-derive" -version = "1.0.0" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baeb2780690380592f86205aa4ee49815feb2acad8c2f59e6dd207148c3f1fcd" +checksum = "b7805950c36512db9e3251c970bb7ac425f326716941862205d612ab3b5e46e2" dependencies = [ - "proc-macro-crate 1.1.0", + "proc-macro-crate 1.1.3", "proc-macro2", "quote", "syn", @@ -9937,6 +10135,47 @@ dependencies = [ "untrusted", ] +[[package]] +name = "sct" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d53dcdb7c9f8158937a7981b48accfd39a43af418591a5d008c7b22b5e1b7ca4" +dependencies = [ + "ring", + "untrusted", +] + +[[package]] +name = "sec1" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08da66b8b0965a5555b6bd6639e68ccba85e1e2506f5fbb089e93f8a04e1a2d1" +dependencies = [ + "der", + "generic-array 0.14.4", + "pkcs8", + "subtle", + "zeroize", +] + +[[package]] +name = "secp256k1" +version = "0.21.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c42e6f1735c5f00f51e43e28d6634141f2bcad10931b2609ddd74a86d751260" +dependencies = [ + "secp256k1-sys", +] + +[[package]] +name = "secp256k1-sys" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "957da2573cde917463ece3570eab4a0b3f19de6f1646cde62e6fd3868f566036" +dependencies = [ + "cc", +] + [[package]] name = "secrecy" version = "0.8.0" @@ -10052,6 +10291,15 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_nanos" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e44969a61f5d316be20a42ff97816efb3b407a924d06824c3d8a49fa8450de0e" +dependencies = [ + "serde", +] + [[package]] name = "sha-1" version = "0.8.2" @@ -10077,12 +10325,6 @@ dependencies = [ "opaque-debug 0.3.0", ] -[[package]] -name = "sha1" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2579985fda508104f7587689507983eadd6a6e84dd35d6d115361f530916fa0d" - [[package]] name = "sha2" version = "0.8.2" @@ -10116,7 +10358,7 @@ checksum = "99c3bd8169c58782adad9290a9af5939994036b76187f7b4f0e6de91dbbfc0ec" dependencies = [ "cfg-if 1.0.0", "cpufeatures 0.2.1", - "digest 0.10.1", + "digest 0.10.3", ] [[package]] @@ -10131,6 +10373,16 @@ dependencies = [ "opaque-debug 0.3.0", ] +[[package]] +name = "sha3" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "881bf8156c87b6301fc5ca6b27f11eeb2761224c7081e69b409d5a1951a70c86" +dependencies = [ + "digest 0.10.3", + "keccak", +] + [[package]] name = "sharded-slab" version = "0.1.4" @@ -10170,6 +10422,9 @@ name = "signature" version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "02658e48d89f2bec991f9a78e69cfa4c316f8d6a6c4ec12fae1aeb263d486788" +dependencies = [ + "rand_core 0.6.3", +] [[package]] name = "simba" @@ -10191,8 +10446,8 @@ checksum = "9def91fd1e018fe007022791f865d0ccc9b3a0d5001e01aabb8b40e46000afb5" [[package]] name = "slot-range-helper" -version = "0.9.13" -source = "git+https://github.com/paritytech/polkadot?branch=master#60df3c55c711c2872872d6220f98b2611340e051" +version = "0.9.18" +source = "git+https://github.com/paritytech/polkadot?branch=master#975e780ae0d988dc033f400ba822d14b326ee5b9" dependencies = [ "enumn", "parity-scale-codec", @@ -10223,9 +10478,9 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.7.0" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ecab6c735a6bb4139c0caafd0cc3635748bbb3acf4550e8138122099251f309" +checksum = "f2dd574626839106c320a323308629dcb1acfc96e32a8cba364ddc61ac23ee83" [[package]] name = "snap" @@ -10240,9 +10495,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6142f7c25e94f6fd25a32c3348ec230df9109b463f59c8c7acc4bd34936babb7" dependencies = [ "aes-gcm", - "blake2", + "blake2 0.9.2", "chacha20poly1305", - "rand 0.8.4", + "rand 0.8.5", "rand_core 0.6.3", "ring", "rustc_version 0.3.3", @@ -10264,29 +10519,14 @@ dependencies = [ [[package]] name = "socket2" -version = "0.4.2" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5dc90fe6c7be1a323296982db1836d1ea9e47b6839496dde9a541bc496df3516" +checksum = "66d72b759436ae32898a2af0a14218dbf55efde3feeb170eb623637db85ee1e0" dependencies = [ "libc", "winapi 0.3.9", ] -[[package]] -name = "soketto" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a74e48087dbeed4833785c2f3352b59140095dc192dce966a3bfc155020a439f" -dependencies = [ - "base64", - "bytes 1.1.0", - "futures 0.3.19", - "httparse", - "log", - "rand 0.8.4", - "sha-1 0.9.8", -] - [[package]] name = "soketto" version = "0.7.1" @@ -10296,17 +10536,17 @@ dependencies = [ "base64", "bytes 1.1.0", "flate2", - "futures 0.3.19", + "futures 0.3.21", "httparse", "log", - "rand 0.8.4", + "rand 0.8.5", "sha-1 0.9.8", ] [[package]] name = "sp-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "hash-db", "log", @@ -10323,10 +10563,10 @@ dependencies = [ [[package]] name = "sp-api-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ - "blake2-rfc", - "proc-macro-crate 1.1.0", + "blake2 0.10.4", + "proc-macro-crate 1.1.3", "proc-macro2", "quote", "syn", @@ -10334,8 +10574,8 @@ dependencies = [ [[package]] name = "sp-application-crypto" -version = "4.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +version = "6.0.0" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "parity-scale-codec", "scale-info", @@ -10347,8 +10587,8 @@ dependencies = [ [[package]] name = "sp-arithmetic" -version = "4.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +version = "5.0.0" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "integer-sqrt", "num-traits", @@ -10363,7 +10603,7 @@ dependencies = [ [[package]] name = "sp-authority-discovery" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "parity-scale-codec", "scale-info", @@ -10376,7 +10616,7 @@ dependencies = [ [[package]] name = "sp-authorship" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "async-trait", "parity-scale-codec", @@ -10388,7 +10628,7 @@ dependencies = [ [[package]] name = "sp-block-builder" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "parity-scale-codec", "sp-api", @@ -10400,13 +10640,13 @@ dependencies = [ [[package]] name = "sp-blockchain" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ - "futures 0.3.19", + "futures 0.3.21", "log", - "lru 0.7.2", + "lru 0.7.3", "parity-scale-codec", - "parking_lot 0.11.2", + "parking_lot 0.12.0", "sp-api", "sp-consensus", "sp-database", @@ -10418,10 +10658,10 @@ dependencies = [ [[package]] name = "sp-consensus" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "async-trait", - "futures 0.3.19", + "futures 0.3.21", "futures-timer", "log", "parity-scale-codec", @@ -10437,7 +10677,7 @@ dependencies = [ [[package]] name = "sp-consensus-aura" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "async-trait", "parity-scale-codec", @@ -10455,7 +10695,7 @@ dependencies = [ [[package]] name = "sp-consensus-babe" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "async-trait", "merlin", @@ -10478,19 +10718,21 @@ dependencies = [ [[package]] name = "sp-consensus-slots" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "parity-scale-codec", "scale-info", "serde", "sp-arithmetic", "sp-runtime", + "sp-std", + "sp-timestamp", ] [[package]] name = "sp-consensus-vrf" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "parity-scale-codec", "schnorrkel", @@ -10501,8 +10743,8 @@ dependencies = [ [[package]] name = "sp-core" -version = "4.1.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +version = "6.0.0" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "base58", "bitflags", @@ -10510,7 +10752,7 @@ dependencies = [ "byteorder", "dyn-clonable", "ed25519-dalek", - "futures 0.3.19", + "futures 0.3.21", "hash-db", "hash256-std-hasher", "hex", @@ -10522,15 +10764,15 @@ dependencies = [ "num-traits", "parity-scale-codec", "parity-util-mem", - "parking_lot 0.11.2", + "parking_lot 0.12.0", "primitive-types", "rand 0.7.3", "regex", "scale-info", "schnorrkel", + "secp256k1", "secrecy", "serde", - "sha2 0.10.1", "sp-core-hashing", "sp-debug-derive", "sp-externalities", @@ -10541,8 +10783,6 @@ dependencies = [ "substrate-bip39", "thiserror", "tiny-bip39", - "tiny-keccak", - "twox-hash", "wasmi", "zeroize", ] @@ -10550,20 +10790,21 @@ dependencies = [ [[package]] name = "sp-core-hashing" version = "4.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ - "blake2-rfc", + "blake2 0.10.4", "byteorder", + "digest 0.10.3", "sha2 0.10.1", + "sha3 0.10.1", "sp-std", - "tiny-keccak", "twox-hash", ] [[package]] name = "sp-core-hashing-proc-macro" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +version = "5.0.0" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "proc-macro2", "quote", @@ -10574,16 +10815,16 @@ dependencies = [ [[package]] name = "sp-database" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "kvdb", - "parking_lot 0.11.2", + "parking_lot 0.12.0", ] [[package]] name = "sp-debug-derive" version = "4.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "proc-macro2", "quote", @@ -10592,8 +10833,8 @@ dependencies = [ [[package]] name = "sp-externalities" -version = "0.10.0" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +version = "0.12.0" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "environmental", "parity-scale-codec", @@ -10604,7 +10845,7 @@ dependencies = [ [[package]] name = "sp-finality-grandpa" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "finality-grandpa", "log", @@ -10622,7 +10863,7 @@ dependencies = [ [[package]] name = "sp-inherents" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "async-trait", "impl-trait-for-tuples", @@ -10635,15 +10876,16 @@ dependencies = [ [[package]] name = "sp-io" -version = "4.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +version = "6.0.0" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ - "futures 0.3.19", + "futures 0.3.21", "hash-db", "libsecp256k1", "log", "parity-scale-codec", - "parking_lot 0.11.2", + "parking_lot 0.12.0", + "secp256k1", "sp-core", "sp-externalities", "sp-keystore", @@ -10659,44 +10901,45 @@ dependencies = [ [[package]] name = "sp-keyring" -version = "4.1.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +version = "6.0.0" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "lazy_static", "sp-core", "sp-runtime", - "strum 0.22.0", + "strum 0.23.0", ] [[package]] name = "sp-keystore" -version = "0.10.0" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +version = "0.12.0" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "async-trait", - "derive_more", - "futures 0.3.19", + "futures 0.3.21", "merlin", "parity-scale-codec", - "parking_lot 0.11.2", + "parking_lot 0.12.0", "schnorrkel", "serde", "sp-core", "sp-externalities", + "thiserror", ] [[package]] name = "sp-maybe-compressed-blob" version = "4.1.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ + "thiserror", "zstd", ] [[package]] name = "sp-npos-elections" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "parity-scale-codec", "scale-info", @@ -10711,9 +10954,9 @@ dependencies = [ [[package]] name = "sp-npos-elections-solution-type" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ - "proc-macro-crate 1.1.0", + "proc-macro-crate 1.1.3", "proc-macro2", "quote", "syn", @@ -10722,7 +10965,7 @@ dependencies = [ [[package]] name = "sp-offchain" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "sp-api", "sp-core", @@ -10732,7 +10975,7 @@ dependencies = [ [[package]] name = "sp-panic-handler" version = "4.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "backtrace", "lazy_static", @@ -10741,8 +10984,8 @@ dependencies = [ [[package]] name = "sp-rpc" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +version = "6.0.0" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "rustc-hash", "serde", @@ -10751,8 +10994,8 @@ dependencies = [ [[package]] name = "sp-runtime" -version = "4.1.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +version = "6.0.0" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "either", "hash256-std-hasher", @@ -10773,8 +11016,8 @@ dependencies = [ [[package]] name = "sp-runtime-interface" -version = "4.1.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +version = "6.0.0" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "impl-trait-for-tuples", "parity-scale-codec", @@ -10790,11 +11033,11 @@ dependencies = [ [[package]] name = "sp-runtime-interface-proc-macro" -version = "4.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +version = "5.0.0" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "Inflector", - "proc-macro-crate 1.1.0", + "proc-macro-crate 1.1.3", "proc-macro2", "quote", "syn", @@ -10803,7 +11046,7 @@ dependencies = [ [[package]] name = "sp-serializer" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "serde", "serde_json", @@ -10812,7 +11055,7 @@ dependencies = [ [[package]] name = "sp-session" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "parity-scale-codec", "scale-info", @@ -10826,7 +11069,7 @@ dependencies = [ [[package]] name = "sp-staking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "parity-scale-codec", "scale-info", @@ -10836,14 +11079,14 @@ dependencies = [ [[package]] name = "sp-state-machine" -version = "0.10.0" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +version = "0.12.0" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "hash-db", "log", "num-traits", "parity-scale-codec", - "parking_lot 0.11.2", + "parking_lot 0.12.0", "rand 0.7.3", "smallvec", "sp-core", @@ -10860,12 +11103,12 @@ dependencies = [ [[package]] name = "sp-std" version = "4.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" [[package]] name = "sp-storage" -version = "4.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +version = "6.0.0" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "impl-serde", "parity-scale-codec", @@ -10878,7 +11121,7 @@ dependencies = [ [[package]] name = "sp-tasks" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "log", "sp-core", @@ -10891,7 +11134,7 @@ dependencies = [ [[package]] name = "sp-timestamp" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "async-trait", "futures-timer", @@ -10906,8 +11149,8 @@ dependencies = [ [[package]] name = "sp-tracing" -version = "4.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +version = "5.0.0" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "parity-scale-codec", "sp-std", @@ -10919,7 +11162,7 @@ dependencies = [ [[package]] name = "sp-transaction-pool" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "sp-api", "sp-runtime", @@ -10928,7 +11171,7 @@ dependencies = [ [[package]] name = "sp-transaction-storage-proof" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "async-trait", "log", @@ -10943,8 +11186,8 @@ dependencies = [ [[package]] name = "sp-trie" -version = "4.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +version = "6.0.0" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "hash-db", "memory-db", @@ -10952,14 +11195,15 @@ dependencies = [ "scale-info", "sp-core", "sp-std", + "thiserror", "trie-db", "trie-root", ] [[package]] name = "sp-version" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +version = "5.0.0" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "impl-serde", "parity-scale-codec", @@ -10976,7 +11220,7 @@ dependencies = [ [[package]] name = "sp-version-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "parity-scale-codec", "proc-macro2", @@ -10986,8 +11230,8 @@ dependencies = [ [[package]] name = "sp-wasm-interface" -version = "4.1.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +version = "6.0.0" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "impl-trait-for-tuples", "log", @@ -11003,6 +11247,16 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" +[[package]] +name = "spki" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44d01ac02a6ccf3e07db148d2be087da624fea0221a16152ed01f0496a6b0a27" +dependencies = [ + "base64ct", + "der", +] + [[package]] name = "ss58-registry" version = "1.12.0" @@ -11023,15 +11277,6 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" -[[package]] -name = "standback" -version = "0.2.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e113fb6f3de07a243d434a56ec6f186dfd51cb08448239fe7bcae73f87ff28ff" -dependencies = [ - "version_check", -] - [[package]] name = "static_assertions" version = "1.1.0" @@ -11073,58 +11318,9 @@ dependencies = [ "lazy_static", "nalgebra", "num-traits", - "rand 0.8.4", -] - -[[package]] -name = "stdweb" -version = "0.4.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d022496b16281348b52d0e30ae99e01a73d737b2f45d38fed4edf79f9325a1d5" -dependencies = [ - "discard", - "rustc_version 0.2.3", - "stdweb-derive", - "stdweb-internal-macros", - "stdweb-internal-runtime", - "wasm-bindgen", + "rand 0.8.5", ] -[[package]] -name = "stdweb-derive" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c87a60a40fccc84bef0652345bbbbbe20a605bf5d0ce81719fc476f5c03b50ef" -dependencies = [ - "proc-macro2", - "quote", - "serde", - "serde_derive", - "syn", -] - -[[package]] -name = "stdweb-internal-macros" -version = "0.2.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58fa5ff6ad0d98d1ffa8cb115892b6e69d67799f6763e162a1c9db421dc22e11" -dependencies = [ - "base-x", - "proc-macro2", - "quote", - "serde", - "serde_derive", - "serde_json", - "sha1", - "syn", -] - -[[package]] -name = "stdweb-internal-runtime" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "213701ba3370744dcd1a12960caa4843b3d68b4d1c0a5d575e0d65b2ee9d16c0" - [[package]] name = "storage-proof-fuzzer" version = "0.1.0" @@ -11170,7 +11366,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dcb5ae327f9cc13b68763b5749770cb9e048a99bd9dfdfa58d0cf05d5f64afe0" dependencies = [ "heck 0.3.3", - "proc-macro-error 1.0.4", + "proc-macro-error", "proc-macro2", "quote", "syn", @@ -11187,20 +11383,20 @@ dependencies = [ [[package]] name = "strum" -version = "0.22.0" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7ac893c7d471c8a21f31cfe213ec4f6d9afeed25537c772e08ef3f005f8729e" +checksum = "cae14b91c7d11c9a851d3fbc80a963198998c2a64eec840477fa92d8ce9b70bb" dependencies = [ - "strum_macros 0.22.0", + "strum_macros 0.23.1", ] [[package]] name = "strum" -version = "0.23.0" +version = "0.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cae14b91c7d11c9a851d3fbc80a963198998c2a64eec840477fa92d8ce9b70bb" +checksum = "e96acfc1b70604b8b2f1ffa4c57e59176c7dbb05d556c71ecd2f5498a1dee7f8" dependencies = [ - "strum_macros 0.23.1", + "strum_macros 0.24.0", ] [[package]] @@ -11217,23 +11413,24 @@ dependencies = [ [[package]] name = "strum_macros" -version = "0.22.0" +version = "0.23.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "339f799d8b549e3744c7ac7feb216383e4005d94bdb22561b3ab8f3b808ae9fb" +checksum = "5bb0dc7ee9c15cea6199cde9a127fa16a4c5819af85395457ad72d68edc85a38" dependencies = [ "heck 0.3.3", "proc-macro2", "quote", + "rustversion", "syn", ] [[package]] name = "strum_macros" -version = "0.23.1" +version = "0.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5bb0dc7ee9c15cea6199cde9a127fa16a4c5819af85395457ad72d68edc85a38" +checksum = "6878079b17446e4d3eba6192bb0a2950d5b14f0ed8424b852310e5a94345d0ef" dependencies = [ - "heck 0.3.3", + "heck 0.4.0", "proc-macro2", "quote", "rustversion", @@ -11256,7 +11453,7 @@ dependencies = [ [[package]] name = "substrate-build-script-utils" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "platforms", ] @@ -11264,10 +11461,10 @@ dependencies = [ [[package]] name = "substrate-frame-rpc-system" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "frame-system-rpc-runtime-api", - "futures 0.3.19", + "futures 0.3.21", "jsonrpc-core", "jsonrpc-core-client", "jsonrpc-derive", @@ -11286,14 +11483,13 @@ dependencies = [ [[package]] name = "substrate-prometheus-endpoint" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ - "async-std", - "derive_more", "futures-util", "hyper", "log", "prometheus", + "thiserror", "tokio", ] @@ -11314,6 +11510,7 @@ dependencies = [ "bp-rialto-parachain", "bp-rococo", "bp-runtime", + "bp-test-utils", "bp-token-swap", "bp-westend", "bp-wococo", @@ -11321,7 +11518,7 @@ dependencies = [ "finality-grandpa", "finality-relay", "frame-support", - "futures 0.3.19", + "futures 0.3.21", "hex", "hex-literal", "log", @@ -11340,7 +11537,7 @@ dependencies = [ "polkadot-primitives", "polkadot-runtime-common", "polkadot-runtime-parachains", - "rand 0.8.4", + "rand 0.8.5", "relay-kusama-client", "relay-millau-client", "relay-polkadot-client", @@ -11383,13 +11580,14 @@ dependencies = [ "finality-relay", "frame-support", "frame-system", - "futures 0.3.19", + "futures 0.3.21", "log", "messages-relay", "num-traits", "pallet-balances", "pallet-bridge-grandpa", "pallet-bridge-messages", + "pallet-transaction-payment", "parity-scale-codec", "relay-rococo-client", "relay-substrate-client", @@ -11405,10 +11603,10 @@ dependencies = [ [[package]] name = "substrate-test-client" version = "2.0.1" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "async-trait", - "futures 0.3.19", + "futures 0.3.21", "hex", "parity-scale-codec", "sc-client-api", @@ -11431,12 +11629,13 @@ dependencies = [ [[package]] name = "substrate-wasm-builder" version = "5.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ "ansi_term 0.12.1", "build-helper", "cargo_metadata", "sp-maybe-compressed-blob", + "strum 0.23.0", "tempfile", "toml", "walkdir", @@ -11451,26 +11650,15 @@ checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" [[package]] name = "syn" -version = "1.0.86" +version = "1.0.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a65b3f4ffa0092e9887669db0eae07941f023991ab58ea44da8fe8e2d511c6b" +checksum = "ebd69e719f31e88618baa1eaa6ee2de5c9a1c004f1e9ecdb58e8352a13f20a01" dependencies = [ "proc-macro2", "quote", "unicode-xid", ] -[[package]] -name = "syn-mid" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baa8e7560a164edb1621a55d18a0c59abf49d360f47aa7b821061dd7eea7fac9" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "synstructure" version = "0.12.6" @@ -11520,8 +11708,8 @@ checksum = "dac1c663cfc93810f88aed9b8941d48cabf856a1b111c29a40439018d870eb22" dependencies = [ "cfg-if 1.0.0", "libc", - "rand 0.8.4", - "redox_syscall 0.2.10", + "rand 0.8.5", + "redox_syscall", "remove_dir_all", "winapi 0.3.9", ] @@ -11537,8 +11725,8 @@ dependencies = [ [[package]] name = "test-runtime-constants" -version = "0.9.13" -source = "git+https://github.com/paritytech/polkadot?branch=master#60df3c55c711c2872872d6220f98b2611340e051" +version = "0.9.18" +source = "git+https://github.com/paritytech/polkadot?branch=master#975e780ae0d988dc033f400ba822d14b326ee5b9" dependencies = [ "frame-support", "polkadot-primitives", @@ -11558,9 +11746,9 @@ dependencies = [ [[package]] name = "textwrap" -version = "0.14.2" +version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0066c8d12af8b5acd21e00547c3797fde4e8677254a7ee429176ccebbe93dd80" +checksum = "b1141d4d61095b28419e22cb0bbf02755f5e54e0526f97f1e3d1d160e60885fb" [[package]] name = "thiserror" @@ -11584,9 +11772,9 @@ dependencies = [ [[package]] name = "thread_local" -version = "1.1.3" +version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8018d24e04c95ac8790716a5987d0fec4f8b27249ffa0f7d33f1369bdfb88cbd" +checksum = "5516c27b78311c50bf42c071425c560ac799b11c30b31f87e3081965fe5e0180" dependencies = [ "once_cell", ] @@ -11614,52 +11802,36 @@ dependencies = [ ] [[package]] -name = "time" -version = "0.1.44" +name = "tikv-jemalloc-sys" +version = "0.4.3+5.2.1-patched.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6db9e6914ab8b1ae1c260a4ae7a49b6c5611b40328a735b21862567685e73255" +checksum = "a1792ccb507d955b46af42c123ea8863668fae24d03721e40cad6a41773dbb49" dependencies = [ + "cc", + "fs_extra", "libc", - "wasi 0.10.0+wasi-snapshot-preview1", - "winapi 0.3.9", ] [[package]] name = "time" -version = "0.2.27" +version = "0.1.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4752a97f8eebd6854ff91f1c1824cd6160626ac4bd44287f7f4ea2035a02a242" +checksum = "6db9e6914ab8b1ae1c260a4ae7a49b6c5611b40328a735b21862567685e73255" dependencies = [ - "const_fn", "libc", - "standback", - "stdweb", - "time-macros", - "version_check", + "wasi 0.10.0+wasi-snapshot-preview1", "winapi 0.3.9", ] [[package]] -name = "time-macros" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "957e9c6e26f12cb6d0dd7fc776bb67a706312e7299aed74c8dd5b17ebb27e2f1" -dependencies = [ - "proc-macro-hack", - "time-macros-impl", -] - -[[package]] -name = "time-macros-impl" -version = "0.1.2" +name = "time" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd3c141a1b43194f3f56a1411225df8646c55781d5f26db825b3d98507eb482f" +checksum = "004cbc98f30fa233c61a38bc77e96a9106e65c88f2d3bef182ae952027e5753d" dependencies = [ - "proc-macro-hack", - "proc-macro2", - "quote", - "standback", - "syn", + "itoa 1.0.1", + "libc", + "num_threads", ] [[package]] @@ -11681,15 +11853,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "tiny-keccak" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c9d3793400a45f954c52e73d068316d76b6f4e36977e3fcebb13a2721e80237" -dependencies = [ - "crunchy", -] - [[package]] name = "tinyvec" version = "1.5.1" @@ -11707,18 +11870,20 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" [[package]] name = "tokio" -version = "1.15.0" +version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbbf1c778ec206785635ce8ad57fe52b3009ae9e0c9f574a728f3049d3e55838" +checksum = "2af73ac49756f3f7c01172e34a23e5d0216f6c32333757c2c61feb2bbff5a5ee" dependencies = [ "bytes 1.1.0", "libc", "memchr", - "mio 0.7.14", + "mio 0.8.1", "num_cpus", "once_cell", + "parking_lot 0.12.0", "pin-project-lite 0.2.7", "signal-hook-registry", + "socket2 0.4.4", "tokio-macros", "winapi 0.3.9", ] @@ -11740,9 +11905,20 @@ version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bc6844de72e57df1980054b38be3a9f4702aba4858be64dd700181a8a6d0e1b6" dependencies = [ - "rustls", + "rustls 0.19.1", + "tokio", + "webpki 0.21.4", +] + +[[package]] +name = "tokio-rustls" +version = "0.23.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a27d5f2b839802bd8267fa19b0530f5a08b9c08cd417976be2a65d130fe1c11b" +dependencies = [ + "rustls 0.20.4", "tokio", - "webpki", + "webpki 0.22.0", ] [[package]] @@ -11788,9 +11964,9 @@ checksum = "360dfd1d6d30e05fda32ace2c8c70e9c0a9da713275777f5a4dbb8a1893930c6" [[package]] name = "tracing" -version = "0.1.29" +version = "0.1.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "375a639232caf30edfc78e8d89b2d4c375515393e7af7e16f01cd96917fb2105" +checksum = "4a1bdf54a7c28a2bbf701e1d2233f6c77f473486b94bee4f9678da5a148dca7f" dependencies = [ "cfg-if 1.0.0", "log", @@ -11801,9 +11977,9 @@ dependencies = [ [[package]] name = "tracing-attributes" -version = "0.1.18" +version = "0.1.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4f480b8f81512e825f337ad51e94c1eb5d3bbdf2b363dcd01e2b19a9ffe3f8e" +checksum = "2e65ce065b4b5c53e73bb28912318cb8c9e9ad3921f1d669eb0e68b4c8143a2b" dependencies = [ "proc-macro2", "quote", @@ -11812,11 +11988,12 @@ dependencies = [ [[package]] name = "tracing-core" -version = "0.1.21" +version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f4ed65637b8390770814083d20756f87bfa2c21bf2f110babdc5438351746e4" +checksum = "aa31669fa42c09c34d94d8165dd2012e8ff3c66aca50f3bb226b68f216f2706c" dependencies = [ "lazy_static", + "valuable", ] [[package]] @@ -11875,12 +12052,12 @@ dependencies = [ [[package]] name = "trie-db" -version = "0.23.0" +version = "0.23.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3ddae50680c12ef75bfbf58416ca6622fa43d879553f6cb2ed1a817346e1ffe" +checksum = "d32d034c0d3db64b43c31de38e945f15b40cd4ca6d2dcfc26d4798ce8de4ab83" dependencies = [ "hash-db", - "hashbrown", + "hashbrown 0.12.0", "log", "rustc-hex", "smallvec", @@ -11912,7 +12089,7 @@ dependencies = [ "ipnet", "lazy_static", "log", - "rand 0.8.4", + "rand 0.8.5", "smallvec", "thiserror", "tinyvec", @@ -11947,10 +12124,10 @@ checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642" [[package]] name = "try-runtime-cli" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#31d90c202d6df9ce3837ee55587b604619a912ba" +source = "git+https://github.com/paritytech/substrate?branch=master#89fcb3e4f62d221d4e161a437768e77d6265889e" dependencies = [ - "clap 3.0.12", - "jsonrpsee", + "clap 3.1.6", + "jsonrpsee 0.4.1", "log", "parity-scale-codec", "remote-externalities", @@ -11982,7 +12159,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ee73e6e4924fe940354b8d4d98cad5231175d615cd855b758adc658c0aac6a0" dependencies = [ "cfg-if 1.0.0", - "rand 0.8.4", + "digest 0.10.3", + "rand 0.8.5", "static_assertions", ] @@ -12121,6 +12299,12 @@ dependencies = [ "percent-encoding 2.1.0", ] +[[package]] +name = "valuable" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" + [[package]] name = "value-bag" version = "1.0.0-alpha.8" @@ -12194,6 +12378,12 @@ version = "0.10.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + [[package]] name = "wasm-bindgen" version = "0.2.78" @@ -12286,7 +12476,7 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "be0ecb0db480561e9a7642b5d3e4187c128914e58aa84330b9493e3eb68c5e7f" dependencies = [ - "futures 0.3.19", + "futures 0.3.21", "js-sys", "parking_lot 0.11.2", "pin-utils", @@ -12458,7 +12648,7 @@ dependencies = [ "mach", "memoffset", "more-asserts", - "rand 0.8.4", + "rand 0.8.5", "region", "rustix", "thiserror", @@ -12498,13 +12688,32 @@ dependencies = [ "untrusted", ] +[[package]] +name = "webpki" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f095d78192e208183081cc07bc5515ef55216397af48b873e5edcd72637fa1bd" +dependencies = [ + "ring", + "untrusted", +] + [[package]] name = "webpki-roots" version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "aabe153544e473b775453675851ecc86863d2a81d786d741f6b76778f2a48940" dependencies = [ - "webpki", + "webpki 0.21.4", +] + +[[package]] +name = "webpki-roots" +version = "0.22.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "552ceb903e957524388c4d3475725ff2c8b7960922063af6ce53c9a43da07449" +dependencies = [ + "webpki 0.22.0", ] [[package]] @@ -12576,6 +12785,49 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "windows-sys" +version = "0.32.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3df6e476185f92a12c072be4a189a0210dcdcf512a1891d6dff9edb874deadc6" +dependencies = [ + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_msvc" +version = "0.32.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8e92753b1c443191654ec532f14c199742964a061be25d77d7a96f09db20bf5" + +[[package]] +name = "windows_i686_gnu" +version = "0.32.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a711c68811799e017b6038e0922cb27a5e2f43a2ddb609fe0b6f3eeda9de615" + +[[package]] +name = "windows_i686_msvc" +version = "0.32.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "146c11bb1a02615db74680b32a68e2d61f553cc24c4eb5b4ca10311740e44172" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.32.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c912b12f7454c6620635bbff3450962753834be2a594819bd5e945af18ec64bc" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.32.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "504a2476202769977a040c6364301a3f65d0cc9e3fb08600b2bda150a0488316" + [[package]] name = "winreg" version = "0.6.2" @@ -12597,9 +12849,12 @@ dependencies = [ [[package]] name = "wyz" -version = "0.2.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85e60b0d1b5f99db2556934e21937020776a5d31520bf169e851ac44e6420214" +checksum = "30b31594f29d27036c383b53b59ed3476874d518f0efb151b27a4c275141390e" +dependencies = [ + "tap", +] [[package]] name = "x25519-dalek" @@ -12614,8 +12869,8 @@ dependencies = [ [[package]] name = "xcm" -version = "0.9.13" -source = "git+https://github.com/paritytech/polkadot?branch=master#60df3c55c711c2872872d6220f98b2611340e051" +version = "0.9.18" +source = "git+https://github.com/paritytech/polkadot?branch=master#975e780ae0d988dc033f400ba822d14b326ee5b9" dependencies = [ "derivative", "impl-trait-for-tuples", @@ -12627,8 +12882,8 @@ dependencies = [ [[package]] name = "xcm-builder" -version = "0.9.13" -source = "git+https://github.com/paritytech/polkadot?branch=master#60df3c55c711c2872872d6220f98b2611340e051" +version = "0.9.18" +source = "git+https://github.com/paritytech/polkadot?branch=master#975e780ae0d988dc033f400ba822d14b326ee5b9" dependencies = [ "frame-support", "frame-system", @@ -12647,8 +12902,8 @@ dependencies = [ [[package]] name = "xcm-executor" -version = "0.9.13" -source = "git+https://github.com/paritytech/polkadot?branch=master#60df3c55c711c2872872d6220f98b2611340e051" +version = "0.9.18" +source = "git+https://github.com/paritytech/polkadot?branch=master#975e780ae0d988dc033f400ba822d14b326ee5b9" dependencies = [ "frame-support", "impl-trait-for-tuples", @@ -12665,7 +12920,7 @@ dependencies = [ [[package]] name = "xcm-procedural" version = "0.1.0" -source = "git+https://github.com/paritytech/polkadot?branch=master#60df3c55c711c2872872d6220f98b2611340e051" +source = "git+https://github.com/paritytech/polkadot?branch=master#975e780ae0d988dc033f400ba822d14b326ee5b9" dependencies = [ "Inflector", "proc-macro2", @@ -12679,11 +12934,11 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e7d9028f208dd5e63c614be69f115c1b53cacc1111437d4c765185856666c107" dependencies = [ - "futures 0.3.19", + "futures 0.3.21", "log", "nohash-hasher", "parking_lot 0.11.2", - "rand 0.8.4", + "rand 0.8.5", "static_assertions", ] diff --git a/Dockerfile b/Dockerfile index ff88c6a5a0a..bc51f76ba99 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,7 +8,7 @@ # # See the `deployments/README.md` for all the available `PROJECT` values. -FROM paritytech/bridges-ci:latest as builder +FROM docker.io/paritytech/bridges-ci:latest as builder WORKDIR /parity-bridges-common COPY . . @@ -19,7 +19,7 @@ RUN cargo build --release --verbose -p ${PROJECT} && \ # In this final stage we copy over the final binary and do some checks # to make sure that everything looks good. -FROM ubuntu:20.04 as runtime +FROM docker.io/library/ubuntu:20.04 as runtime # show backtraces ENV RUST_BACKTRACE 1 diff --git a/bin/millau/node/Cargo.toml b/bin/millau/node/Cargo.toml index 12a10ad6c22..3825b92b703 100644 --- a/bin/millau/node/Cargo.toml +++ b/bin/millau/node/Cargo.toml @@ -3,14 +3,14 @@ name = "millau-bridge-node" description = "Substrate node compatible with Millau runtime" version = "0.1.0" authors = ["Parity Technologies "] -edition = "2018" +edition = "2021" build = "build.rs" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/parity-bridges-common/" license = "GPL-3.0-or-later WITH Classpath-exception-2.0" [dependencies] -clap = { version = "3.0", features = ["derive"] } +clap = { version = "3.1", features = ["derive"] } jsonrpc-core = "18.0" serde_json = "1.0.59" diff --git a/bin/millau/node/src/service.rs b/bin/millau/node/src/service.rs index db64af878ff..15f88269aa9 100644 --- a/bin/millau/node/src/service.rs +++ b/bin/millau/node/src/service.rs @@ -37,7 +37,6 @@ use sc_finality_grandpa::SharedVoterState; use sc_keystore::LocalKeystore; use sc_service::{error::Error as ServiceError, Configuration, TaskManager}; use sc_telemetry::{Telemetry, TelemetryWorker}; -use sp_consensus::SlotData; use sp_consensus_aura::sr25519::AuthorityPair as AuraPair; use std::{sync::Arc, time::Duration}; @@ -141,7 +140,7 @@ pub fn new_partial( telemetry.as_ref().map(|x| x.handle()), )?; - let slot_duration = sc_consensus_aura::slot_duration(&*client)?.slot_duration(); + let slot_duration = sc_consensus_aura::slot_duration(&*client)?; let import_queue = sc_consensus_aura::import_queue::(ImportQueueParams { @@ -152,7 +151,7 @@ pub fn new_partial( let timestamp = sp_timestamp::InherentDataProvider::from_system_time(); let slot = - sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_duration( + sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_slot_duration( *timestamp, slot_duration, ); @@ -349,7 +348,6 @@ pub fn new_full(mut config: Configuration) -> Result sp_consensus::CanAuthorWithNativeVersion::new(client.executor().clone()); let slot_duration = sc_consensus_aura::slot_duration(&*client)?; - let raw_slot_duration = slot_duration.slot_duration(); let aura = sc_consensus_aura::start_aura::( StartAuraParams { @@ -362,9 +360,9 @@ pub fn new_full(mut config: Configuration) -> Result let timestamp = sp_timestamp::InherentDataProvider::from_system_time(); let slot = - sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_duration( + sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_slot_duration( *timestamp, - raw_slot_duration, + slot_duration, ); Ok((timestamp, slot)) diff --git a/bin/millau/runtime/Cargo.toml b/bin/millau/runtime/Cargo.toml index 4fe2f72a962..162404b77e7 100644 --- a/bin/millau/runtime/Cargo.toml +++ b/bin/millau/runtime/Cargo.toml @@ -2,16 +2,16 @@ name = "millau-runtime" version = "0.1.0" authors = ["Parity Technologies "] -edition = "2018" +edition = "2021" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/parity-bridges-common/" license = "GPL-3.0-or-later WITH Classpath-exception-2.0" [dependencies] hex-literal = "0.3" -codec = { package = "parity-scale-codec", version = "2.2.0", default-features = false, features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } libsecp256k1 = { version = "0.7", optional = true, default-features = false, features = ["hmac"] } -scale-info = { version = "1.0", default-features = false, features = ["derive"] } +scale-info = { version = "2.0.1", default-features = false, features = ["derive"] } serde = { version = "1.0", optional = true, features = ["derive"] } # Bridge dependencies @@ -65,6 +65,10 @@ sp-transaction-pool = { git = "https://github.com/paritytech/substrate", branch sp-trie = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } sp-version = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } +[dev-dependencies] +bridge-runtime-common = { path = "../../runtime-common", features = ["integrity-test"] } +static_assertions = "1.1" + [build-dependencies] substrate-wasm-builder = { git = "https://github.com/paritytech/substrate", branch = "master" } @@ -120,7 +124,7 @@ std = [ ] runtime-benchmarks = [ "bridge-runtime-common/runtime-benchmarks", - "frame-benchmarking", + "frame-benchmarking/runtime-benchmarks", "frame-support/runtime-benchmarks", "frame-system/runtime-benchmarks", "libsecp256k1", diff --git a/bin/millau/runtime/src/lib.rs b/bin/millau/runtime/src/lib.rs index e0c39036217..d2da5affb23 100644 --- a/bin/millau/runtime/src/lib.rs +++ b/bin/millau/runtime/src/lib.rs @@ -21,8 +21,6 @@ #![recursion_limit = "256"] // Runtime-generated enums #![allow(clippy::large_enum_variant)] -// Runtime-generated DecodeLimit::decode_all_With_depth_limit -#![allow(clippy::unnecessary_mut_passed)] // From construct_runtime macro #![allow(clippy::from_over_into)] @@ -52,7 +50,7 @@ use sp_runtime::{ create_runtime_str, generic, impl_opaque_keys, traits::{Block as BlockT, IdentityLookup, Keccak256, NumberFor, OpaqueKeys}, transaction_validity::{TransactionSource, TransactionValidity}, - ApplyExtrinsicResult, FixedPointNumber, MultiSignature, MultiSigner, Perquintill, + ApplyExtrinsicResult, FixedPointNumber, FixedU128, MultiSignature, MultiSigner, Perquintill, }; use sp_std::prelude::*; #[cfg(feature = "std")] @@ -456,10 +454,9 @@ impl pallet_bridge_messages::Config for Runtime { type MessageDeliveryAndDispatchPayment = pallet_bridge_messages::instant_payments::InstantCurrencyPayments< Runtime, - (), + WithRialtoMessagesInstance, pallet_balances::Pallet, GetDeliveryConfirmationTransactionFee, - RootAccountForPayments, >; type OnMessageAccepted = (); type OnDeliveryConfirmed = @@ -525,7 +522,7 @@ construct_runtime!( BridgeRialtoGrandpa: pallet_bridge_grandpa::{Pallet, Call, Storage}, BridgeDispatch: pallet_bridge_dispatch::{Pallet, Event}, BridgeRialtoMessages: pallet_bridge_messages::{Pallet, Call, Storage, Event, Config}, - BridgeRialtoTokenSwap: pallet_bridge_token_swap::{Pallet, Call, Storage, Event}, + BridgeRialtoTokenSwap: pallet_bridge_token_swap::{Pallet, Call, Storage, Event, Origin}, // Westend bridge modules. BridgeWestendGrandpa: pallet_bridge_grandpa::::{Pallet, Call, Config, Storage}, @@ -544,6 +541,7 @@ pub type SignedBlock = generic::SignedBlock; pub type BlockId = generic::BlockId; /// The SignedExtension to the basic transaction logic. pub type SignedExtra = ( + frame_system::CheckNonZeroSender, frame_system::CheckSpecVersion, frame_system::CheckTxVersion, frame_system::CheckGenesis, @@ -757,10 +755,12 @@ impl_runtime_apis! { fn estimate_message_delivery_and_dispatch_fee( _lane_id: bp_messages::LaneId, payload: ToRialtoMessagePayload, + rialto_to_this_conversion_rate: Option, ) -> Option { estimate_message_dispatch_and_delivery_fee::( &payload, WithRialtoMessageBridge::RELAYER_FEE_PERCENT, + rialto_to_this_conversion_rate, ).ok() } @@ -777,12 +777,6 @@ impl_runtime_apis! { } } - impl bp_rialto::FromRialtoInboundLaneApi for Runtime { - fn unrewarded_relayers_state(lane: bp_messages::LaneId) -> bp_messages::UnrewardedRelayersState { - BridgeRialtoMessages::inbound_unrewarded_relayers_state(lane) - } - } - #[cfg(feature = "runtime-benchmarks")] impl frame_benchmarking::Benchmark for Runtime { fn benchmark_metadata(extra: bool) -> ( @@ -860,7 +854,7 @@ impl_runtime_apis! { fn prepare_outbound_message( params: MessageParams, ) -> (rialto_messages::ToRialtoMessagePayload, Balance) { - prepare_outbound_message::(params) + (prepare_outbound_message::(params), Self::message_fee()) } fn prepare_message_proof( @@ -918,7 +912,6 @@ impl_runtime_apis! { add_benchmark!(params, batches, pallet_bridge_grandpa, BridgeRialtoGrandpa); add_benchmark!(params, batches, pallet_bridge_token_swap, BridgeRialtoTokenSwap); - if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) } Ok(batches) } } @@ -951,49 +944,6 @@ where #[cfg(test)] mod tests { use super::*; - use bp_runtime::Chain; - use bridge_runtime_common::messages; - - #[test] - fn ensure_millau_message_lane_weights_are_correct() { - type Weights = pallet_bridge_messages::weights::MillauWeight; - - pallet_bridge_messages::ensure_weights_are_correct::( - bp_millau::DEFAULT_MESSAGE_DELIVERY_TX_WEIGHT, - bp_millau::ADDITIONAL_MESSAGE_BYTE_DELIVERY_WEIGHT, - bp_millau::MAX_SINGLE_MESSAGE_DELIVERY_CONFIRMATION_TX_WEIGHT, - bp_millau::PAY_INBOUND_DISPATCH_FEE_WEIGHT, - DbWeight::get(), - ); - - let max_incoming_message_proof_size = bp_rialto::EXTRA_STORAGE_PROOF_SIZE.saturating_add( - messages::target::maximal_incoming_message_size(bp_millau::Millau::max_extrinsic_size()), - ); - pallet_bridge_messages::ensure_able_to_receive_message::( - bp_millau::Millau::max_extrinsic_size(), - bp_millau::Millau::max_extrinsic_weight(), - max_incoming_message_proof_size, - messages::target::maximal_incoming_message_dispatch_weight( - bp_millau::Millau::max_extrinsic_weight(), - ), - ); - - let max_incoming_inbound_lane_data_proof_size = - bp_messages::InboundLaneData::<()>::encoded_size_hint( - bp_millau::MAXIMAL_ENCODED_ACCOUNT_ID_SIZE, - bp_millau::MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX as _, - bp_millau::MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX as _, - ) - .unwrap_or(u32::MAX); - pallet_bridge_messages::ensure_able_to_receive_confirmation::( - bp_millau::Millau::max_extrinsic_size(), - bp_millau::Millau::max_extrinsic_weight(), - max_incoming_inbound_lane_data_proof_size, - bp_millau::MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX, - bp_millau::MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX, - DbWeight::get(), - ); - } #[test] fn call_size() { diff --git a/bin/millau/runtime/src/rialto_messages.rs b/bin/millau/runtime/src/rialto_messages.rs index 4403c423c2c..d925d805dd0 100644 --- a/bin/millau/runtime/src/rialto_messages.rs +++ b/bin/millau/runtime/src/rialto_messages.rs @@ -19,7 +19,7 @@ use crate::Runtime; use bp_messages::{ - source_chain::TargetHeaderChain, + source_chain::{SenderOrigin, TargetHeaderChain}, target_chain::{ProvedMessages, SourceHeaderChain}, InboundLaneData, LaneId, Message, MessageNonce, Parameter as MessagesParameter, }; @@ -91,11 +91,14 @@ impl MessageBridge for WithRialtoMessageBridge { type ThisChain = Millau; type BridgedChain = Rialto; - fn bridged_balance_to_this_balance(bridged_balance: bp_rialto::Balance) -> bp_millau::Balance { - bp_millau::Balance::try_from( - RialtoToMillauConversionRate::get().saturating_mul_int(bridged_balance), - ) - .unwrap_or(bp_millau::Balance::MAX) + fn bridged_balance_to_this_balance( + bridged_balance: bp_rialto::Balance, + bridged_to_this_conversion_rate_override: Option, + ) -> bp_millau::Balance { + let conversion_rate = bridged_to_this_conversion_rate_override + .unwrap_or_else(|| RialtoToMillauConversionRate::get()); + bp_millau::Balance::try_from(conversion_rate.saturating_mul_int(bridged_balance)) + .unwrap_or(bp_millau::Balance::MAX) } } @@ -113,12 +116,23 @@ impl messages::ChainWithMessages for Millau { } impl messages::ThisChainWithMessages for Millau { + type Origin = crate::Origin; type Call = crate::Call; - fn is_outbound_lane_enabled(lane: &LaneId) -> bool { - *lane == [0, 0, 0, 0] || - *lane == [0, 0, 0, 1] || - *lane == crate::TokenSwapMessagesLane::get() + fn is_message_accepted(send_origin: &Self::Origin, lane: &LaneId) -> bool { + // lanes 0x00000000 && 0x00000001 are accepting any paid messages, while + // `TokenSwapMessageLane` only accepts messages from token swap pallet + let token_swap_dedicated_lane = crate::TokenSwapMessagesLane::get(); + match *lane { + [0, 0, 0, 0] | [0, 0, 0, 1] => send_origin.linked_account().is_some(), + _ if *lane == token_swap_dedicated_lane => matches!( + send_origin.caller, + crate::OriginCaller::BridgeRialtoTokenSwap( + pallet_bridge_token_swap::RawOrigin::TokenSwap { .. } + ) + ), + _ => false, + } } fn maximal_pending_messages_at_outbound_lane() -> MessageNonce { @@ -274,6 +288,25 @@ impl SourceHeaderChain for Rialto { } } +impl SenderOrigin for crate::Origin { + fn linked_account(&self) -> Option { + match self.caller { + crate::OriginCaller::system(frame_system::RawOrigin::Signed(ref submitter)) => + Some(submitter.clone()), + crate::OriginCaller::system(frame_system::RawOrigin::Root) | + crate::OriginCaller::system(frame_system::RawOrigin::None) => + crate::RootAccountForPayments::get(), + crate::OriginCaller::BridgeRialtoTokenSwap( + pallet_bridge_token_swap::RawOrigin::TokenSwap { + ref swap_account_at_this_chain, + .. + }, + ) => Some(swap_account_at_this_chain.clone()), + _ => None, + } + } +} + /// Millau -> Rialto message lane pallet parameters. #[derive(RuntimeDebug, Clone, Encode, Decode, PartialEq, Eq, TypeInfo)] pub enum MillauToRialtoMessagesParameter { @@ -289,3 +322,107 @@ impl MessagesParameter for MillauToRialtoMessagesParameter { } } } + +#[cfg(test)] +mod tests { + use super::*; + use crate::{DbWeight, RialtoGrandpaInstance, Runtime, WithRialtoMessagesInstance}; + + use bp_runtime::Chain; + use bridge_runtime_common::{ + assert_complete_bridge_types, + integrity::{ + assert_complete_bridge_constants, AssertBridgeMessagesPalletConstants, + AssertBridgePalletNames, AssertChainConstants, AssertCompleteBridgeConstants, + }, + messages, + }; + + #[test] + fn ensure_millau_message_lane_weights_are_correct() { + type Weights = pallet_bridge_messages::weights::MillauWeight; + + pallet_bridge_messages::ensure_weights_are_correct::( + bp_millau::DEFAULT_MESSAGE_DELIVERY_TX_WEIGHT, + bp_millau::ADDITIONAL_MESSAGE_BYTE_DELIVERY_WEIGHT, + bp_millau::MAX_SINGLE_MESSAGE_DELIVERY_CONFIRMATION_TX_WEIGHT, + bp_millau::PAY_INBOUND_DISPATCH_FEE_WEIGHT, + DbWeight::get(), + ); + + let max_incoming_message_proof_size = bp_rialto::EXTRA_STORAGE_PROOF_SIZE.saturating_add( + messages::target::maximal_incoming_message_size(bp_millau::Millau::max_extrinsic_size()), + ); + pallet_bridge_messages::ensure_able_to_receive_message::( + bp_millau::Millau::max_extrinsic_size(), + bp_millau::Millau::max_extrinsic_weight(), + max_incoming_message_proof_size, + messages::target::maximal_incoming_message_dispatch_weight( + bp_millau::Millau::max_extrinsic_weight(), + ), + ); + + let max_incoming_inbound_lane_data_proof_size = + bp_messages::InboundLaneData::<()>::encoded_size_hint( + bp_millau::MAXIMAL_ENCODED_ACCOUNT_ID_SIZE, + bp_millau::MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX as _, + bp_millau::MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX as _, + ) + .unwrap_or(u32::MAX); + pallet_bridge_messages::ensure_able_to_receive_confirmation::( + bp_millau::Millau::max_extrinsic_size(), + bp_millau::Millau::max_extrinsic_weight(), + max_incoming_inbound_lane_data_proof_size, + bp_millau::MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX, + bp_millau::MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX, + DbWeight::get(), + ); + } + + #[test] + fn ensure_bridge_integrity() { + assert_complete_bridge_types!( + runtime: Runtime, + with_bridged_chain_grandpa_instance: RialtoGrandpaInstance, + with_bridged_chain_messages_instance: WithRialtoMessagesInstance, + bridge: WithRialtoMessageBridge, + this_chain: bp_millau::Millau, + bridged_chain: bp_rialto::Rialto, + this_chain_account_id_converter: bp_millau::AccountIdConverter + ); + + assert_complete_bridge_constants::< + Runtime, + RialtoGrandpaInstance, + WithRialtoMessagesInstance, + WithRialtoMessageBridge, + bp_millau::Millau, + >(AssertCompleteBridgeConstants { + this_chain_constants: AssertChainConstants { + block_length: bp_millau::BlockLength::get(), + block_weights: bp_millau::BlockWeights::get(), + }, + messages_pallet_constants: AssertBridgeMessagesPalletConstants { + max_unrewarded_relayers_in_bridged_confirmation_tx: + bp_rialto::MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX, + max_unconfirmed_messages_in_bridged_confirmation_tx: + bp_rialto::MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX, + bridged_chain_id: bp_runtime::RIALTO_CHAIN_ID, + }, + pallet_names: AssertBridgePalletNames { + with_this_chain_messages_pallet_name: bp_millau::WITH_MILLAU_MESSAGES_PALLET_NAME, + with_bridged_chain_grandpa_pallet_name: bp_rialto::WITH_RIALTO_GRANDPA_PALLET_NAME, + with_bridged_chain_messages_pallet_name: + bp_rialto::WITH_RIALTO_MESSAGES_PALLET_NAME, + }, + }); + + assert_eq!( + RialtoToMillauConversionRate::key().to_vec(), + bp_runtime::storage_parameter_key( + bp_millau::RIALTO_TO_MILLAU_CONVERSION_RATE_PARAMETER_NAME + ) + .0, + ); + } +} diff --git a/bin/rialto-parachain/node/Cargo.toml b/bin/rialto-parachain/node/Cargo.toml index 975d551b888..41021a35ed2 100644 --- a/bin/rialto-parachain/node/Cargo.toml +++ b/bin/rialto-parachain/node/Cargo.toml @@ -2,7 +2,7 @@ name = "rialto-parachain-collator" version = "0.1.0" authors = ["Parity Technologies "] -edition = "2018" +edition = "2021" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/parity-bridges-common/" license = "GPL-3.0-or-later WITH Classpath-exception-2.0" @@ -18,10 +18,10 @@ default = [] runtime-benchmarks = ['rialto-parachain-runtime/runtime-benchmarks'] [dependencies] -clap = { version = "3.0", features = ["derive"] } +clap = { version = "3.1", features = ["derive"] } derive_more = '0.99.2' log = '0.4.14' -codec = { package = 'parity-scale-codec', version = '2.0.0' } +codec = { package = 'parity-scale-codec', version = '3.0.0' } serde = { version = '1.0', features = ['derive'] } hex-literal = '0.3.1' @@ -81,7 +81,7 @@ cumulus-client-service = { git = "https://github.com/paritytech/cumulus", branch cumulus-primitives-core = { git = "https://github.com/paritytech/cumulus", branch = "master" } cumulus-primitives-parachain-inherent = { git = "https://github.com/paritytech/cumulus", branch = "master" } cumulus-relay-chain-interface = { git = "https://github.com/paritytech/cumulus", branch = "master" } -cumulus-relay-chain-local = { git = "https://github.com/paritytech/cumulus", branch = "master" } +cumulus-relay-chain-inprocess-interface = { git = "https://github.com/paritytech/cumulus", branch = "master" } # Polkadot dependencies polkadot-cli = { git = "https://github.com/paritytech/polkadot", branch = "master" } diff --git a/bin/rialto-parachain/node/src/cli.rs b/bin/rialto-parachain/node/src/cli.rs index 7abb72cb876..89d049f022e 100644 --- a/bin/rialto-parachain/node/src/cli.rs +++ b/bin/rialto-parachain/node/src/cli.rs @@ -15,7 +15,7 @@ // along with Parity Bridges Common. If not, see . use crate::chain_spec; -use clap::{AppSettings, Parser}; +use clap::Parser; use std::path::PathBuf; /// Sub-commands supported by the collator. @@ -94,11 +94,11 @@ pub struct ExportGenesisWasmCommand { } #[derive(Debug, Parser)] -#[clap(setting( - AppSettings::PropagateVersion | - AppSettings::ArgsNegateSubcommands | - AppSettings::SubcommandsNegateReqs, -))] +#[clap( + propagate_version = true, + args_conflicts_with_subcommands = true, + subcommand_negates_reqs = true +)] pub struct Cli { #[clap(subcommand)] pub subcommand: Option, diff --git a/bin/rialto-parachain/node/src/command.rs b/bin/rialto-parachain/node/src/command.rs index 9a69042a803..c47e742675d 100644 --- a/bin/rialto-parachain/node/src/command.rs +++ b/bin/rialto-parachain/node/src/command.rs @@ -265,6 +265,7 @@ pub fn run() -> Result<()> { }, None => { let runner = cli.create_runner(&cli.run.normalize())?; + let collator_options = cli.run.collator_options(); runner.run_node_until_exit(|config| async move { let para_id = @@ -278,7 +279,7 @@ pub fn run() -> Result<()> { let id = ParaId::from(cli.parachain_id.or(para_id).expect("Missing ParaId")); let parachain_account = - AccountIdConversion::::into_account(&id); + AccountIdConversion::::into_account(&id); let state_version = RelayChainCli::native_runtime_version(&config.chain_spec).state_version(); @@ -298,7 +299,7 @@ pub fn run() -> Result<()> { info!("Parachain genesis state: {}", genesis_state); info!("Is collating: {}", if config.role.is_authority() { "yes" } else { "no" }); - crate::service::start_node(config, polkadot_config, id) + crate::service::start_node(config, polkadot_config, collator_options, id) .await .map(|r| r.0) .map_err(Into::into) diff --git a/bin/rialto-parachain/node/src/service.rs b/bin/rialto-parachain/node/src/service.rs index 61f705086e9..a2299e17457 100644 --- a/bin/rialto-parachain/node/src/service.rs +++ b/bin/rialto-parachain/node/src/service.rs @@ -28,6 +28,7 @@ use std::{sync::Arc, time::Duration}; use rialto_parachain_runtime::RuntimeApi; // Cumulus Imports +use cumulus_client_cli::CollatorOptions; use cumulus_client_consensus_aura::{AuraConsensus, BuildAuraConsensusParams, SlotProportion}; use cumulus_client_consensus_common::ParachainConsensus; use cumulus_client_network::BlockAnnounceValidator; @@ -35,8 +36,8 @@ use cumulus_client_service::{ prepare_node_config, start_collator, start_full_node, StartCollatorParams, StartFullNodeParams, }; use cumulus_primitives_core::ParaId; -use cumulus_relay_chain_interface::RelayChainInterface; -use cumulus_relay_chain_local::build_relay_chain_interface; +use cumulus_relay_chain_inprocess_interface::build_inprocess_relay_chain; +use cumulus_relay_chain_interface::{RelayChainError, RelayChainInterface}; // Substrate Imports use sc_client_api::ExecutorProvider; @@ -45,7 +46,6 @@ use sc_network::NetworkService; use sc_service::{Configuration, PartialComponents, Role, TFullBackend, TFullClient, TaskManager}; use sc_telemetry::{Telemetry, TelemetryHandle, TelemetryWorker, TelemetryWorkerHandle}; use sp_api::ConstructRuntimeApi; -use sp_consensus::SlotData; use sp_keystore::SyncCryptoStorePtr; use sp_runtime::traits::BlakeTwo256; use substrate_prometheus_endpoint::Registry; @@ -195,6 +195,7 @@ where async fn start_node_impl( parachain_config: Configuration, polkadot_config: Configuration, + collator_options: CollatorOptions, id: ParaId, rpc_ext_builder: RB, build_import_queue: BIQ, @@ -270,12 +271,16 @@ where let (mut telemetry, telemetry_worker_handle) = params.other; let mut task_manager = params.task_manager; - let (relay_chain_interface, collator_key) = - build_relay_chain_interface(polkadot_config, telemetry_worker_handle, &mut task_manager) - .map_err(|e| match e { - polkadot_service::Error::Sub(x) => x, - s => format!("{}", s).into(), - })?; + let (relay_chain_interface, collator_key) = build_inprocess_relay_chain( + polkadot_config, + ¶chain_config, + telemetry_worker_handle, + &mut task_manager, + ) + .map_err(|e| match e { + RelayChainError::ServiceError(polkadot_service::Error::Sub(x)) => x, + s => s.to_string().into(), + })?; let client = params.client.clone(); let backend = params.backend.clone(); @@ -350,7 +355,7 @@ where spawner, parachain_consensus, import_queue, - collator_key, + collator_key: collator_key.expect("Command line arguments do not allow this. qed"), relay_chain_slot_duration, }; @@ -364,6 +369,7 @@ where relay_chain_interface, relay_chain_slot_duration, import_queue, + collator_options, }; start_full_node(params)?; @@ -405,9 +411,9 @@ pub fn parachain_build_import_queue( let time = sp_timestamp::InherentDataProvider::from_system_time(); let slot = - sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_duration( + sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_slot_duration( *time, - slot_duration.slot_duration(), + slot_duration, ); Ok((time, slot)) @@ -424,6 +430,7 @@ pub fn parachain_build_import_queue( pub async fn start_node( parachain_config: Configuration, polkadot_config: Configuration, + collator_options: CollatorOptions, id: ParaId, ) -> sc_service::error::Result<( TaskManager, @@ -432,6 +439,7 @@ pub async fn start_node( start_node_impl::( parachain_config, polkadot_config, + collator_options, id, |deny_unsafe, client, pool| { use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApi}; @@ -481,9 +489,9 @@ pub async fn start_node( ).await; let time = sp_timestamp::InherentDataProvider::from_system_time(); - let slot = sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_duration( + let slot = sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_slot_duration( *time, - slot_duration.slot_duration(), + slot_duration, ); let parachain_inherent = parachain_inherent.ok_or_else(|| { diff --git a/bin/rialto-parachain/runtime/Cargo.toml b/bin/rialto-parachain/runtime/Cargo.toml index 20ce70aba8f..1d0870fcbcd 100644 --- a/bin/rialto-parachain/runtime/Cargo.toml +++ b/bin/rialto-parachain/runtime/Cargo.toml @@ -2,7 +2,7 @@ name = "rialto-parachain-runtime" version = "0.1.0" authors = ["Parity Technologies "] -edition = "2018" +edition = "2021" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/parity-bridges-common/" license = "GPL-3.0-or-later WITH Classpath-exception-2.0" @@ -11,9 +11,9 @@ license = "GPL-3.0-or-later WITH Classpath-exception-2.0" substrate-wasm-builder = { git = "https://github.com/paritytech/substrate", branch = "master" } [dependencies] -codec = { package = 'parity-scale-codec', version = '2.0.0', default-features = false, features = ['derive']} +codec = { package = 'parity-scale-codec', version = '3.0.0', default-features = false, features = ['derive']} log = { version = "0.4.14", default-features = false } -scale-info = { version = "1.0", default-features = false, features = ["derive"] } +scale-info = { version = "2.0.1", default-features = false, features = ["derive"] } serde = { version = '1.0', optional = true, features = ['derive'] } # Bridge depedencies diff --git a/bin/rialto-parachain/runtime/src/lib.rs b/bin/rialto-parachain/runtime/src/lib.rs index e499c89f13a..646521f3293 100644 --- a/bin/rialto-parachain/runtime/src/lib.rs +++ b/bin/rialto-parachain/runtime/src/lib.rs @@ -42,7 +42,7 @@ use sp_version::RuntimeVersion; // A few exports that help ease life for downstream crates. pub use frame_support::{ - construct_runtime, match_type, parameter_types, + construct_runtime, match_types, parameter_types, traits::{Everything, IsInVec, Randomness}, weights::{ constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND}, @@ -86,6 +86,7 @@ pub type SignedBlock = generic::SignedBlock; pub type BlockId = generic::BlockId; /// The SignedExtension to the basic transaction logic. pub type SignedExtra = ( + frame_system::CheckNonZeroSender, frame_system::CheckSpecVersion, frame_system::CheckGenesis, frame_system::CheckEra, @@ -350,7 +351,7 @@ parameter_types! { pub const MaxAuthorities: u32 = 100_000; } -match_type! { +match_types! { pub type ParentOrParentsUnitPlurality: impl Contains = { MultiLocation { parents: 1, interior: Here } | MultiLocation { parents: 1, interior: X1(Plurality { id: BodyId::Unit, .. }) } @@ -423,6 +424,9 @@ impl cumulus_pallet_xcmp_queue::Config for Runtime { type ChannelInfo = ParachainSystem; type VersionWrapper = (); type ExecuteOverweightOrigin = EnsureRoot; + type ControllerOrigin = EnsureRoot; + type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin; + type WeightInfo = (); } impl cumulus_pallet_dmp_queue::Config for Runtime { @@ -613,7 +617,6 @@ impl_runtime_apis! { add_benchmark!(params, batches, pallet_balances, Balances); add_benchmark!(params, batches, pallet_timestamp, Timestamp); - if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) } Ok(batches) } } diff --git a/bin/rialto/node/Cargo.toml b/bin/rialto/node/Cargo.toml index 6c7bce4d4e0..e44ceb45faa 100644 --- a/bin/rialto/node/Cargo.toml +++ b/bin/rialto/node/Cargo.toml @@ -3,18 +3,18 @@ name = "rialto-bridge-node" description = "Substrate node compatible with Rialto runtime" version = "0.1.0" authors = ["Parity Technologies "] -edition = "2018" +edition = "2021" build = "build.rs" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/parity-bridges-common/" license = "GPL-3.0-or-later WITH Classpath-exception-2.0" [dependencies] -clap = { version = "3.0", features = ["derive"] } +clap = { version = "3.1", features = ["derive"] } futures = "0.3" jsonrpc-core = "18.0" -kvdb = "0.10" -kvdb-rocksdb = "0.12" +kvdb = "0.11" +kvdb-rocksdb = "0.15" lru = "0.7" serde_json = "1.0.59" thiserror = "1.0" diff --git a/bin/rialto/node/src/chain_spec.rs b/bin/rialto/node/src/chain_spec.rs index 6bfacba83a1..10315e33c85 100644 --- a/bin/rialto/node/src/chain_spec.rs +++ b/bin/rialto/node/src/chain_spec.rs @@ -16,7 +16,7 @@ use beefy_primitives::crypto::AuthorityId as BeefyId; use bp_rialto::derive_account_from_millau_id; -use polkadot_primitives::v1::{AssignmentId, ValidatorId}; +use polkadot_primitives::v2::{AssignmentId, ValidatorId}; use rialto_runtime::{ AccountId, BabeConfig, BalancesConfig, BeefyConfig, BridgeMillauMessagesConfig, ConfigurationConfig, GenesisConfig, GrandpaConfig, SessionConfig, SessionKeys, Signature, @@ -253,8 +253,8 @@ fn testnet_genesis( validation_upgrade_cooldown: 2u32, validation_upgrade_delay: 2, code_retention_period: 1200, - max_code_size: polkadot_primitives::v1::MAX_CODE_SIZE, - max_pov_size: polkadot_primitives::v1::MAX_POV_SIZE, + max_code_size: polkadot_primitives::v2::MAX_CODE_SIZE, + max_pov_size: polkadot_primitives::v2::MAX_POV_SIZE, max_head_data_size: 32 * 1024, group_rotation_frequency: 20, chain_availability_period: 4, @@ -263,7 +263,7 @@ fn testnet_genesis( max_upward_queue_size: 1024 * 1024, max_downward_message_size: 1024 * 1024, ump_service_total_weight: 100_000_000_000, - max_upward_message_size: 1024 * 1024, + max_upward_message_size: 50 * 1024, max_upward_message_num_per_candidate: 5, hrmp_sender_deposit: 0, hrmp_recipient_deposit: 0, diff --git a/bin/rialto/node/src/cli.rs b/bin/rialto/node/src/cli.rs index 20155a1469e..bb7f54998dd 100644 --- a/bin/rialto/node/src/cli.rs +++ b/bin/rialto/node/src/cli.rs @@ -14,7 +14,7 @@ // You should have received a copy of the GNU General Public License // along with Parity Bridges Common. If not, see . -use clap::{AppSettings, Parser}; +use clap::Parser; use sc_cli::RunCmd; #[derive(Debug, Parser)] @@ -70,11 +70,11 @@ pub enum Subcommand { Benchmark(frame_benchmarking_cli::BenchmarkCmd), /// FOR INTERNAL USE: analog of the "prepare-worker" command of the polkadot binary. - #[clap(name = "prepare-worker", setting = AppSettings::Hidden)] + #[clap(name = "prepare-worker", hide = true)] PvfPrepareWorker(ValidationWorkerCommand), /// FOR INTERNAL USE: analog of the "execute-worker" command of the polkadot binary. - #[clap(name = "execute-worker", setting = AppSettings::Hidden)] + #[clap(name = "execute-worker", hide = true)] PvfExecuteWorker(ValidationWorkerCommand), } diff --git a/bin/rialto/node/src/command.rs b/bin/rialto/node/src/command.rs index 1d81de2cb0c..da92837f06c 100644 --- a/bin/rialto/node/src/command.rs +++ b/bin/rialto/node/src/command.rs @@ -192,6 +192,7 @@ pub fn run() -> sc_cli::Result<()> { let jaeger_agent = None; let telemetry_worker_handle = None; let program_path = None; + let overseer_enable_anyways = false; polkadot_service::new_full::( config, @@ -201,6 +202,7 @@ pub fn run() -> sc_cli::Result<()> { jaeger_agent, telemetry_worker_handle, program_path, + overseer_enable_anyways, overseer_gen, ) .map(|full| full.task_manager) diff --git a/bin/rialto/runtime/Cargo.toml b/bin/rialto/runtime/Cargo.toml index 3c4ec1ebce1..59b9a8e9b57 100644 --- a/bin/rialto/runtime/Cargo.toml +++ b/bin/rialto/runtime/Cargo.toml @@ -2,17 +2,17 @@ name = "rialto-runtime" version = "0.1.0" authors = ["Parity Technologies "] -edition = "2018" +edition = "2021" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/parity-bridges-common/" license = "GPL-3.0-or-later WITH Classpath-exception-2.0" [dependencies] -codec = { package = "parity-scale-codec", version = "2.2.0", default-features = false, features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } hex-literal = "0.3" libsecp256k1 = { version = "0.7", optional = true, default-features = false, features = ["hmac"] } log = { version = "0.4.14", default-features = false } -scale-info = { version = "1.0", default-features = false, features = ["derive"] } +scale-info = { version = "2.0.1", default-features = false, features = ["derive"] } serde = { version = "1.0", optional = true, features = ["derive"] } # Bridge dependencies @@ -73,7 +73,9 @@ polkadot-runtime-common = { git = "https://github.com/paritytech/polkadot", bran polkadot-runtime-parachains = { git = "https://github.com/paritytech/polkadot", branch = "master", default-features = false } [dev-dependencies] +bridge-runtime-common = { path = "../../runtime-common", features = ["integrity-test"] } libsecp256k1 = { version = "0.7", features = ["hmac"] } +static_assertions = "1.1" [build-dependencies] substrate-wasm-builder = { git = "https://github.com/paritytech/substrate", branch = "master" } @@ -135,7 +137,7 @@ std = [ ] runtime-benchmarks = [ "bridge-runtime-common/runtime-benchmarks", - "frame-benchmarking", + "frame-benchmarking/runtime-benchmarks", "frame-support/runtime-benchmarks", "frame-system/runtime-benchmarks", "libsecp256k1", diff --git a/bin/rialto/runtime/src/lib.rs b/bin/rialto/runtime/src/lib.rs index 42d2d880e06..87cddf5e268 100644 --- a/bin/rialto/runtime/src/lib.rs +++ b/bin/rialto/runtime/src/lib.rs @@ -21,8 +21,6 @@ #![recursion_limit = "256"] // Runtime-generated enums #![allow(clippy::large_enum_variant)] -// Runtime-generated DecodeLimit::decode_all_With_depth_limit -#![allow(clippy::unnecessary_mut_passed)] // From construct_runtime macro #![allow(clippy::from_over_into)] @@ -53,7 +51,7 @@ use sp_runtime::{ create_runtime_str, generic, impl_opaque_keys, traits::{AccountIdLookup, Block as BlockT, Keccak256, NumberFor, OpaqueKeys}, transaction_validity::{TransactionSource, TransactionValidity}, - ApplyExtrinsicResult, FixedPointNumber, MultiSignature, MultiSigner, Perquintill, + ApplyExtrinsicResult, FixedPointNumber, FixedU128, MultiSignature, MultiSigner, Perquintill, }; use sp_std::{collections::btree_map::BTreeMap, prelude::*}; #[cfg(feature = "std")] @@ -457,10 +455,9 @@ impl pallet_bridge_messages::Config for Runtime { type MessageDeliveryAndDispatchPayment = pallet_bridge_messages::instant_payments::InstantCurrencyPayments< Runtime, - (), + WithMillauMessagesInstance, pallet_balances::Pallet, GetDeliveryConfirmationTransactionFee, - RootAccountForPayments, >; type OnMessageAccepted = (); type OnDeliveryConfirmed = (); @@ -535,6 +532,7 @@ pub type SignedBlock = generic::SignedBlock; pub type BlockId = generic::BlockId; /// The SignedExtension to the basic transaction logic. pub type SignedExtra = ( + frame_system::CheckNonZeroSender, frame_system::CheckSpecVersion, frame_system::CheckTxVersion, frame_system::CheckGenesis, @@ -718,55 +716,55 @@ impl_runtime_apis! { } impl polkadot_primitives::v2::ParachainHost for Runtime { - fn validators() -> Vec { - polkadot_runtime_parachains::runtime_api_impl::v1::validators::() + fn validators() -> Vec { + polkadot_runtime_parachains::runtime_api_impl::v2::validators::() } - fn validator_groups() -> (Vec>, polkadot_primitives::v1::GroupRotationInfo) { - polkadot_runtime_parachains::runtime_api_impl::v1::validator_groups::() + fn validator_groups() -> (Vec>, polkadot_primitives::v2::GroupRotationInfo) { + polkadot_runtime_parachains::runtime_api_impl::v2::validator_groups::() } - fn availability_cores() -> Vec> { - polkadot_runtime_parachains::runtime_api_impl::v1::availability_cores::() + fn availability_cores() -> Vec> { + polkadot_runtime_parachains::runtime_api_impl::v2::availability_cores::() } - fn persisted_validation_data(para_id: polkadot_primitives::v1::Id, assumption: polkadot_primitives::v1::OccupiedCoreAssumption) - -> Option> { - polkadot_runtime_parachains::runtime_api_impl::v1::persisted_validation_data::(para_id, assumption) + fn persisted_validation_data(para_id: polkadot_primitives::v2::Id, assumption: polkadot_primitives::v2::OccupiedCoreAssumption) + -> Option> { + polkadot_runtime_parachains::runtime_api_impl::v2::persisted_validation_data::(para_id, assumption) } fn assumed_validation_data( - para_id: polkadot_primitives::v1::Id, + para_id: polkadot_primitives::v2::Id, expected_persisted_validation_data_hash: Hash, - ) -> Option<(polkadot_primitives::v1::PersistedValidationData, polkadot_primitives::v1::ValidationCodeHash)> { - polkadot_runtime_parachains::runtime_api_impl::v1::assumed_validation_data::( + ) -> Option<(polkadot_primitives::v2::PersistedValidationData, polkadot_primitives::v2::ValidationCodeHash)> { + polkadot_runtime_parachains::runtime_api_impl::v2::assumed_validation_data::( para_id, expected_persisted_validation_data_hash, ) } fn check_validation_outputs( - para_id: polkadot_primitives::v1::Id, - outputs: polkadot_primitives::v1::CandidateCommitments, + para_id: polkadot_primitives::v2::Id, + outputs: polkadot_primitives::v2::CandidateCommitments, ) -> bool { - polkadot_runtime_parachains::runtime_api_impl::v1::check_validation_outputs::(para_id, outputs) + polkadot_runtime_parachains::runtime_api_impl::v2::check_validation_outputs::(para_id, outputs) } - fn session_index_for_child() -> polkadot_primitives::v1::SessionIndex { - polkadot_runtime_parachains::runtime_api_impl::v1::session_index_for_child::() + fn session_index_for_child() -> polkadot_primitives::v2::SessionIndex { + polkadot_runtime_parachains::runtime_api_impl::v2::session_index_for_child::() } - fn validation_code(para_id: polkadot_primitives::v1::Id, assumption: polkadot_primitives::v1::OccupiedCoreAssumption) - -> Option { - polkadot_runtime_parachains::runtime_api_impl::v1::validation_code::(para_id, assumption) + fn validation_code(para_id: polkadot_primitives::v2::Id, assumption: polkadot_primitives::v2::OccupiedCoreAssumption) + -> Option { + polkadot_runtime_parachains::runtime_api_impl::v2::validation_code::(para_id, assumption) } - fn candidate_pending_availability(para_id: polkadot_primitives::v1::Id) -> Option> { - polkadot_runtime_parachains::runtime_api_impl::v1::candidate_pending_availability::(para_id) + fn candidate_pending_availability(para_id: polkadot_primitives::v2::Id) -> Option> { + polkadot_runtime_parachains::runtime_api_impl::v2::candidate_pending_availability::(para_id) } - fn candidate_events() -> Vec> { - polkadot_runtime_parachains::runtime_api_impl::v1::candidate_events::(|ev| { + fn candidate_events() -> Vec> { + polkadot_runtime_parachains::runtime_api_impl::v2::candidate_events::(|ev| { match ev { Event::Inclusion(ev) => { Some(ev) @@ -776,46 +774,46 @@ impl_runtime_apis! { }) } - fn session_info(index: polkadot_primitives::v1::SessionIndex) -> Option { - polkadot_runtime_parachains::runtime_api_impl::v1::session_info::(index) + fn session_info(index: polkadot_primitives::v2::SessionIndex) -> Option { + polkadot_runtime_parachains::runtime_api_impl::v2::session_info::(index) } - fn dmq_contents(recipient: polkadot_primitives::v1::Id) -> Vec> { - polkadot_runtime_parachains::runtime_api_impl::v1::dmq_contents::(recipient) + fn dmq_contents(recipient: polkadot_primitives::v2::Id) -> Vec> { + polkadot_runtime_parachains::runtime_api_impl::v2::dmq_contents::(recipient) } fn inbound_hrmp_channels_contents( - recipient: polkadot_primitives::v1::Id - ) -> BTreeMap>> { - polkadot_runtime_parachains::runtime_api_impl::v1::inbound_hrmp_channels_contents::(recipient) + recipient: polkadot_primitives::v2::Id + ) -> BTreeMap>> { + polkadot_runtime_parachains::runtime_api_impl::v2::inbound_hrmp_channels_contents::(recipient) } - fn validation_code_by_hash(hash: polkadot_primitives::v1::ValidationCodeHash) -> Option { - polkadot_runtime_parachains::runtime_api_impl::v1::validation_code_by_hash::(hash) + fn validation_code_by_hash(hash: polkadot_primitives::v2::ValidationCodeHash) -> Option { + polkadot_runtime_parachains::runtime_api_impl::v2::validation_code_by_hash::(hash) } - fn on_chain_votes() -> Option> { - polkadot_runtime_parachains::runtime_api_impl::v1::on_chain_votes::() + fn on_chain_votes() -> Option> { + polkadot_runtime_parachains::runtime_api_impl::v2::on_chain_votes::() } - fn submit_pvf_check_statement(stmt: polkadot_primitives::v2::PvfCheckStatement, signature: polkadot_primitives::v1::ValidatorSignature) { - polkadot_runtime_parachains::runtime_api_impl::v1::submit_pvf_check_statement::(stmt, signature) + fn submit_pvf_check_statement(stmt: polkadot_primitives::v2::PvfCheckStatement, signature: polkadot_primitives::v2::ValidatorSignature) { + polkadot_runtime_parachains::runtime_api_impl::v2::submit_pvf_check_statement::(stmt, signature) } - fn pvfs_require_precheck() -> Vec { - polkadot_runtime_parachains::runtime_api_impl::v1::pvfs_require_precheck::() + fn pvfs_require_precheck() -> Vec { + polkadot_runtime_parachains::runtime_api_impl::v2::pvfs_require_precheck::() } - fn validation_code_hash(para_id: polkadot_primitives::v1::Id, assumption: polkadot_primitives::v1::OccupiedCoreAssumption) - -> Option + fn validation_code_hash(para_id: polkadot_primitives::v2::Id, assumption: polkadot_primitives::v2::OccupiedCoreAssumption) + -> Option { - polkadot_runtime_parachains::runtime_api_impl::v1::validation_code_hash::(para_id, assumption) + polkadot_runtime_parachains::runtime_api_impl::v2::validation_code_hash::(para_id, assumption) } } impl sp_authority_discovery::AuthorityDiscoveryApi for Runtime { fn authorities() -> Vec { - polkadot_runtime_parachains::runtime_api_impl::v1::relevant_authority_ids::() + polkadot_runtime_parachains::runtime_api_impl::v2::relevant_authority_ids::() } } @@ -882,10 +880,12 @@ impl_runtime_apis! { fn estimate_message_delivery_and_dispatch_fee( _lane_id: bp_messages::LaneId, payload: ToMillauMessagePayload, + millau_to_this_conversion_rate: Option, ) -> Option { estimate_message_dispatch_and_delivery_fee::( &payload, WithMillauMessageBridge::RELAYER_FEE_PERCENT, + millau_to_this_conversion_rate, ).ok() } @@ -901,12 +901,6 @@ impl_runtime_apis! { >(lane, begin, end) } } - - impl bp_millau::FromMillauInboundLaneApi for Runtime { - fn unrewarded_relayers_state(lane: bp_messages::LaneId) -> bp_messages::UnrewardedRelayersState { - BridgeMillauMessages::inbound_unrewarded_relayers_state(lane) - } - } } /// Millau account ownership digest from Rialto. @@ -936,49 +930,6 @@ where #[cfg(test)] mod tests { use super::*; - use bp_runtime::Chain; - use bridge_runtime_common::messages; - - #[test] - fn ensure_rialto_message_lane_weights_are_correct() { - type Weights = pallet_bridge_messages::weights::MillauWeight; - - pallet_bridge_messages::ensure_weights_are_correct::( - bp_rialto::DEFAULT_MESSAGE_DELIVERY_TX_WEIGHT, - bp_rialto::ADDITIONAL_MESSAGE_BYTE_DELIVERY_WEIGHT, - bp_rialto::MAX_SINGLE_MESSAGE_DELIVERY_CONFIRMATION_TX_WEIGHT, - bp_rialto::PAY_INBOUND_DISPATCH_FEE_WEIGHT, - DbWeight::get(), - ); - - let max_incoming_message_proof_size = bp_millau::EXTRA_STORAGE_PROOF_SIZE.saturating_add( - messages::target::maximal_incoming_message_size(bp_rialto::Rialto::max_extrinsic_size()), - ); - pallet_bridge_messages::ensure_able_to_receive_message::( - bp_rialto::Rialto::max_extrinsic_size(), - bp_rialto::Rialto::max_extrinsic_weight(), - max_incoming_message_proof_size, - messages::target::maximal_incoming_message_dispatch_weight( - bp_rialto::Rialto::max_extrinsic_weight(), - ), - ); - - let max_incoming_inbound_lane_data_proof_size = - bp_messages::InboundLaneData::<()>::encoded_size_hint( - bp_rialto::MAXIMAL_ENCODED_ACCOUNT_ID_SIZE, - bp_rialto::MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX as _, - bp_rialto::MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX as _, - ) - .unwrap_or(u32::MAX); - pallet_bridge_messages::ensure_able_to_receive_confirmation::( - bp_rialto::Rialto::max_extrinsic_size(), - bp_rialto::Rialto::max_extrinsic_weight(), - max_incoming_inbound_lane_data_proof_size, - bp_rialto::MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX, - bp_rialto::MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX, - DbWeight::get(), - ); - } #[test] fn call_size() { diff --git a/bin/rialto/runtime/src/millau_messages.rs b/bin/rialto/runtime/src/millau_messages.rs index 22d11c68be2..44348383f1d 100644 --- a/bin/rialto/runtime/src/millau_messages.rs +++ b/bin/rialto/runtime/src/millau_messages.rs @@ -19,7 +19,7 @@ use crate::Runtime; use bp_messages::{ - source_chain::TargetHeaderChain, + source_chain::{SenderOrigin, TargetHeaderChain}, target_chain::{ProvedMessages, SourceHeaderChain}, InboundLaneData, LaneId, Message, MessageNonce, Parameter as MessagesParameter, }; @@ -91,11 +91,14 @@ impl MessageBridge for WithMillauMessageBridge { type ThisChain = Rialto; type BridgedChain = Millau; - fn bridged_balance_to_this_balance(bridged_balance: bp_millau::Balance) -> bp_rialto::Balance { - bp_rialto::Balance::try_from( - MillauToRialtoConversionRate::get().saturating_mul_int(bridged_balance), - ) - .unwrap_or(bp_rialto::Balance::MAX) + fn bridged_balance_to_this_balance( + bridged_balance: bp_millau::Balance, + bridged_to_this_conversion_rate_override: Option, + ) -> bp_rialto::Balance { + let conversion_rate = bridged_to_this_conversion_rate_override + .unwrap_or_else(|| MillauToRialtoConversionRate::get()); + bp_rialto::Balance::try_from(conversion_rate.saturating_mul_int(bridged_balance)) + .unwrap_or(bp_rialto::Balance::MAX) } } @@ -113,10 +116,11 @@ impl messages::ChainWithMessages for Rialto { } impl messages::ThisChainWithMessages for Rialto { + type Origin = crate::Origin; type Call = crate::Call; - fn is_outbound_lane_enabled(lane: &LaneId) -> bool { - *lane == [0, 0, 0, 0] || *lane == [0, 0, 0, 1] + fn is_message_accepted(send_origin: &Self::Origin, lane: &LaneId) -> bool { + send_origin.linked_account().is_some() && (*lane == [0, 0, 0, 0] || *lane == [0, 0, 0, 1]) } fn maximal_pending_messages_at_outbound_lane() -> MessageNonce { @@ -272,6 +276,19 @@ impl SourceHeaderChain for Millau { } } +impl SenderOrigin for crate::Origin { + fn linked_account(&self) -> Option { + match self.caller { + crate::OriginCaller::system(frame_system::RawOrigin::Signed(ref submitter)) => + Some(submitter.clone()), + crate::OriginCaller::system(frame_system::RawOrigin::Root) | + crate::OriginCaller::system(frame_system::RawOrigin::None) => + crate::RootAccountForPayments::get(), + _ => None, + } + } +} + /// Rialto -> Millau message lane pallet parameters. #[derive(RuntimeDebug, Clone, Encode, Decode, PartialEq, Eq, TypeInfo)] pub enum RialtoToMillauMessagesParameter { @@ -291,15 +308,23 @@ impl MessagesParameter for RialtoToMillauMessagesParameter { #[cfg(test)] mod tests { use super::*; - use crate::{AccountId, Call, ExistentialDeposit, Runtime, SystemCall, SystemConfig, VERSION}; + use crate::{ + AccountId, Call, DbWeight, ExistentialDeposit, MillauGrandpaInstance, Runtime, SystemCall, + SystemConfig, WithMillauMessagesInstance, VERSION, + }; use bp_message_dispatch::CallOrigin; use bp_messages::{ target_chain::{DispatchMessage, DispatchMessageData, MessageDispatch}, MessageKey, }; - use bp_runtime::{derive_account_id, messages::DispatchFeePayment, SourceAccount}; - use bridge_runtime_common::messages::target::{ - FromBridgedChainEncodedMessageCall, FromBridgedChainMessagePayload, + use bp_runtime::{derive_account_id, messages::DispatchFeePayment, Chain, SourceAccount}; + use bridge_runtime_common::{ + assert_complete_bridge_types, + integrity::{ + assert_complete_bridge_constants, AssertBridgeMessagesPalletConstants, + AssertBridgePalletNames, AssertChainConstants, AssertCompleteBridgeConstants, + }, + messages::target::{FromBridgedChainEncodedMessageCall, FromBridgedChainMessagePayload}, }; use frame_support::{ traits::Currency, @@ -377,4 +402,157 @@ mod tests { ); }); } + + #[test] + fn ensure_rialto_message_lane_weights_are_correct() { + type Weights = pallet_bridge_messages::weights::MillauWeight; + + pallet_bridge_messages::ensure_weights_are_correct::( + bp_rialto::DEFAULT_MESSAGE_DELIVERY_TX_WEIGHT, + bp_rialto::ADDITIONAL_MESSAGE_BYTE_DELIVERY_WEIGHT, + bp_rialto::MAX_SINGLE_MESSAGE_DELIVERY_CONFIRMATION_TX_WEIGHT, + bp_rialto::PAY_INBOUND_DISPATCH_FEE_WEIGHT, + DbWeight::get(), + ); + + let max_incoming_message_proof_size = bp_millau::EXTRA_STORAGE_PROOF_SIZE.saturating_add( + messages::target::maximal_incoming_message_size(bp_rialto::Rialto::max_extrinsic_size()), + ); + pallet_bridge_messages::ensure_able_to_receive_message::( + bp_rialto::Rialto::max_extrinsic_size(), + bp_rialto::Rialto::max_extrinsic_weight(), + max_incoming_message_proof_size, + messages::target::maximal_incoming_message_dispatch_weight( + bp_rialto::Rialto::max_extrinsic_weight(), + ), + ); + + let max_incoming_inbound_lane_data_proof_size = + bp_messages::InboundLaneData::<()>::encoded_size_hint( + bp_rialto::MAXIMAL_ENCODED_ACCOUNT_ID_SIZE, + bp_rialto::MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX as _, + bp_rialto::MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX as _, + ) + .unwrap_or(u32::MAX); + pallet_bridge_messages::ensure_able_to_receive_confirmation::( + bp_rialto::Rialto::max_extrinsic_size(), + bp_rialto::Rialto::max_extrinsic_weight(), + max_incoming_inbound_lane_data_proof_size, + bp_rialto::MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX, + bp_rialto::MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX, + DbWeight::get(), + ); + } + + #[test] + fn ensure_bridge_integrity() { + assert_complete_bridge_types!( + runtime: Runtime, + with_bridged_chain_grandpa_instance: MillauGrandpaInstance, + with_bridged_chain_messages_instance: WithMillauMessagesInstance, + bridge: WithMillauMessageBridge, + this_chain: bp_rialto::Rialto, + bridged_chain: bp_millau::Millau, + this_chain_account_id_converter: bp_rialto::AccountIdConverter + ); + + assert_complete_bridge_constants::< + Runtime, + MillauGrandpaInstance, + WithMillauMessagesInstance, + WithMillauMessageBridge, + bp_rialto::Rialto, + >(AssertCompleteBridgeConstants { + this_chain_constants: AssertChainConstants { + block_length: bp_rialto::BlockLength::get(), + block_weights: bp_rialto::BlockWeights::get(), + }, + messages_pallet_constants: AssertBridgeMessagesPalletConstants { + max_unrewarded_relayers_in_bridged_confirmation_tx: + bp_millau::MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX, + max_unconfirmed_messages_in_bridged_confirmation_tx: + bp_millau::MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX, + bridged_chain_id: bp_runtime::MILLAU_CHAIN_ID, + }, + pallet_names: AssertBridgePalletNames { + with_this_chain_messages_pallet_name: bp_rialto::WITH_RIALTO_MESSAGES_PALLET_NAME, + with_bridged_chain_grandpa_pallet_name: bp_millau::WITH_MILLAU_GRANDPA_PALLET_NAME, + with_bridged_chain_messages_pallet_name: + bp_millau::WITH_MILLAU_MESSAGES_PALLET_NAME, + }, + }); + + assert_eq!( + MillauToRialtoConversionRate::key().to_vec(), + bp_runtime::storage_parameter_key( + bp_rialto::MILLAU_TO_RIALTO_CONVERSION_RATE_PARAMETER_NAME + ) + .0, + ); + } + + #[test] + #[ignore] + fn no_stack_overflow_when_decoding_nested_call_during_dispatch() { + // this test is normally ignored, because it only makes sense to run it in release mode + + let mut ext: sp_io::TestExternalities = + SystemConfig::default().build_storage::().unwrap().into(); + ext.execute_with(|| { + let bridge = MILLAU_CHAIN_ID; + + let mut call: Call = SystemCall::set_heap_pages { pages: 64 }.into(); + + for _i in 0..3000 { + call = Call::Sudo(pallet_sudo::Call::sudo { call: Box::new(call) }); + } + + let dispatch_weight = 500; + let dispatch_fee = ::WeightToFee::calc( + &dispatch_weight, + ); + assert!(dispatch_fee > 0); + + // create relayer account with minimal balance + let relayer_account: AccountId = [1u8; 32].into(); + let initial_amount = ExistentialDeposit::get(); + let _ = as Currency>::deposit_creating( + &relayer_account, + initial_amount, + ); + + // create dispatch account with minimal balance + dispatch fee + let dispatch_account = derive_account_id::< + ::SourceChainAccountId, + >(bridge, SourceAccount::Root); + let dispatch_account = + ::AccountIdConverter::convert( + dispatch_account, + ); + let _ = as Currency>::deposit_creating( + &dispatch_account, + initial_amount + dispatch_fee, + ); + + // dispatch message with intention to pay dispatch fee at the target chain + // + // this is where the stack overflow has happened before the fix has been applied + FromMillauMessageDispatch::dispatch( + &relayer_account, + DispatchMessage { + key: MessageKey { lane_id: Default::default(), nonce: 0 }, + data: DispatchMessageData { + payload: Ok(FromBridgedChainMessagePayload:: { + spec_version: VERSION.spec_version, + weight: dispatch_weight, + origin: CallOrigin::SourceRoot, + dispatch_fee_payment: DispatchFeePayment::AtTargetChain, + call: FromBridgedChainEncodedMessageCall::new(call.encode()), + }), + fee: 1, + }, + }, + ); + }); + } } diff --git a/bin/rialto/runtime/src/parachains.rs b/bin/rialto/runtime/src/parachains.rs index 9a316ef0e2a..20a9aeb28c0 100644 --- a/bin/rialto/runtime/src/parachains.rs +++ b/bin/rialto/runtime/src/parachains.rs @@ -23,7 +23,7 @@ use crate::{ use frame_support::{parameter_types, weights::Weight}; use frame_system::EnsureRoot; -use polkadot_primitives::v1::ValidatorIndex; +use polkadot_primitives::v2::ValidatorIndex; use polkadot_runtime_common::{paras_registrar, paras_sudo_wrapper, slots}; use polkadot_runtime_parachains::{ configuration as parachains_configuration, dmp as parachains_dmp, hrmp as parachains_hrmp, @@ -108,6 +108,7 @@ impl parachains_ump::Config for Runtime { type UmpSink = (); type FirstMessageFactorPercent = FirstMessageFactorPercent; type ExecuteOverweightOrigin = EnsureRoot; + type WeightInfo = parachains_ump::TestWeightInfo; } // required onboarding pallets. We're not going to use auctions or crowdloans, so they're missing diff --git a/bin/runtime-common/Cargo.toml b/bin/runtime-common/Cargo.toml index ed3bb32d170..abd84364ce2 100644 --- a/bin/runtime-common/Cargo.toml +++ b/bin/runtime-common/Cargo.toml @@ -2,16 +2,17 @@ name = "bridge-runtime-common" version = "0.1.0" authors = ["Parity Technologies "] -edition = "2018" +edition = "2021" homepage = "https://substrate.dev" repository = "https://github.com/paritytech/parity-bridges-common/" license = "GPL-3.0-or-later WITH Classpath-exception-2.0" [dependencies] -codec = { package = "parity-scale-codec", version = "2.2.0", default-features = false, features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } ed25519-dalek = { version = "1.0", default-features = false, optional = true } hash-db = { version = "0.15.2", default-features = false } -scale-info = { version = "1.0", default-features = false, features = ["derive"] } +scale-info = { version = "2.0.1", default-features = false, features = ["derive"] } +static_assertions = { version = "1.1", optional = true } # Bridge dependencies @@ -25,9 +26,10 @@ pallet-bridge-messages = { path = "../../modules/messages", default-features = f # Substrate dependencies frame-support = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } -frame-system = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false, optional = true } +frame-system = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false, optional = true } pallet-transaction-payment = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } +sp-api = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } sp-core = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } sp-state-machine = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false, optional = true } @@ -43,12 +45,14 @@ std = [ "bp-runtime/std", "codec/std", "frame-support/std", + "frame-system/std", "hash-db/std", "pallet-bridge-dispatch/std", "pallet-bridge-grandpa/std", "pallet-bridge-messages/std", "pallet-transaction-payment/std", "scale-info/std", + "sp-api/std", "sp-core/std", "sp-runtime/std", "sp-state-machine/std", @@ -57,10 +61,12 @@ std = [ ] runtime-benchmarks = [ "ed25519-dalek/u64_backend", - "frame-system", "pallet-balances", "pallet-bridge-grandpa/runtime-benchmarks", "pallet-bridge-messages/runtime-benchmarks", "sp-state-machine", "sp-version", ] +integrity-test = [ + "static_assertions", +] diff --git a/bin/runtime-common/README.md b/bin/runtime-common/README.md index 38a47bfdcc9..5f2298cd787 100644 --- a/bin/runtime-common/README.md +++ b/bin/runtime-common/README.md @@ -62,8 +62,11 @@ corresponding chain. There is single exception, though (it may be changed in the This trait represents this chain from bridge point of view. Let's review every method of this trait: -- `ThisChainWithMessages::is_outbound_lane_enabled`: is used to check whether given lane accepts - outbound messages. +- `ThisChainWithMessages::is_message_accepted`: is used to check whether given lane accepts + messages. The send-message origin is passed to the function, so you may e.g. verify that only + given pallet is able to send messages over selected lane. **IMPORTANT**: if you assume that the + message must be paid by the sender, you must ensure that the sender origin has linked the account + for paying message delivery and dispatch fee. - `ThisChainWithMessages::maximal_pending_messages_at_outbound_lane`: you should return maximal number of pending (undelivered) messages from this function. Returning small values would require diff --git a/bin/runtime-common/src/integrity.rs b/bin/runtime-common/src/integrity.rs new file mode 100644 index 00000000000..ab517566a0f --- /dev/null +++ b/bin/runtime-common/src/integrity.rs @@ -0,0 +1,331 @@ +// Copyright 2019-2021 Parity Technologies (UK) Ltd. +// This file is part of Parity Bridges Common. + +// Parity Bridges Common 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. + +// Parity Bridges Common 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 Parity Bridges Common. If not, see . + +//! Integrity tests for chain constants and pallets configuration. +//! +//! Most of the tests in this module assume that the bridge is using standard (see `crate::messages` +//! module for details) configuration. + +use crate::messages::MessageBridge; + +use bp_messages::MessageNonce; +use bp_runtime::{Chain, ChainId}; +use codec::Encode; +use frame_support::{storage::generator::StorageValue, traits::Get}; +use frame_system::limits; + +/// Macro that ensures that the runtime configuration and chain primitives crate are sharing +/// the same types (index, block number, hash, hasher, account id and header). +#[macro_export] +macro_rules! assert_chain_types( + ( runtime: $r:path, this_chain: $this:path ) => { + { + // if one of asserts fail, then either bridge isn't configured properly (or alternatively - non-standard + // configuration is used), or something has broke existing configuration (meaning that all bridged chains + // and relays will stop functioning) + use frame_system::Config as SystemConfig; + use static_assertions::assert_type_eq_all; + + assert_type_eq_all!(<$r as SystemConfig>::Index, bp_runtime::IndexOf<$this>); + assert_type_eq_all!(<$r as SystemConfig>::BlockNumber, bp_runtime::BlockNumberOf<$this>); + assert_type_eq_all!(<$r as SystemConfig>::Hash, bp_runtime::HashOf<$this>); + assert_type_eq_all!(<$r as SystemConfig>::Hashing, bp_runtime::HasherOf<$this>); + assert_type_eq_all!(<$r as SystemConfig>::AccountId, bp_runtime::AccountIdOf<$this>); + assert_type_eq_all!(<$r as SystemConfig>::Header, bp_runtime::HeaderOf<$this>); + } + } +); + +/// Macro that ensures that the bridge configuration and chain primitives crates are sharing +/// the same types (hash, account id, ...). +#[macro_export] +macro_rules! assert_bridge_types( + ( bridge: $bridge:path, this_chain: $this:path, bridged_chain: $bridged:path ) => { + { + // if one of this asserts fail, then all chains, bridged with this chain and bridge relays are now broken + // + // `frame_support::weights::Weight` is used here directly, because all chains we know are using this + // primitive (may be changed in the future) + use $crate::messages::{ + AccountIdOf, BalanceOf, BridgedChain, HashOf, SignatureOf, SignerOf, ThisChain, WeightOf, + }; + use static_assertions::assert_type_eq_all; + + assert_type_eq_all!(HashOf>, bp_runtime::HashOf<$this>); + assert_type_eq_all!(AccountIdOf>, bp_runtime::AccountIdOf<$this>); + assert_type_eq_all!(SignerOf>, bp_runtime::AccountPublicOf<$this>); + assert_type_eq_all!(SignatureOf>, bp_runtime::SignatureOf<$this>); + assert_type_eq_all!(WeightOf>, frame_support::weights::Weight); + assert_type_eq_all!(BalanceOf>, bp_runtime::BalanceOf<$this>); + + assert_type_eq_all!(HashOf>, bp_runtime::HashOf<$bridged>); + assert_type_eq_all!(AccountIdOf>, bp_runtime::AccountIdOf<$bridged>); + assert_type_eq_all!(SignerOf>, bp_runtime::AccountPublicOf<$bridged>); + assert_type_eq_all!(SignatureOf>, bp_runtime::SignatureOf<$bridged>); + assert_type_eq_all!(WeightOf>, frame_support::weights::Weight); + assert_type_eq_all!(BalanceOf>, bp_runtime::BalanceOf<$bridged>); + } + } +); + +/// Macro that ensures that the bridge GRANDPA pallet is configured properly to bridge with given +/// chain. +#[macro_export] +macro_rules! assert_bridge_grandpa_pallet_types( + ( runtime: $r:path, with_bridged_chain_grandpa_instance: $i:path, bridged_chain: $bridged:path ) => { + { + // if one of asserts fail, then either bridge isn't configured properly (or alternatively - non-standard + // configuration is used), or something has broke existing configuration (meaning that all bridged chains + // and relays will stop functioning) + use pallet_bridge_grandpa::Config as GrandpaConfig; + use static_assertions::assert_type_eq_all; + + assert_type_eq_all!(<$r as GrandpaConfig<$i>>::BridgedChain, $bridged); + } + } +); + +/// Macro that ensures that the bridge messages pallet is configured properly to bridge using given +/// configuration. +#[macro_export] +macro_rules! assert_bridge_messages_pallet_types( + ( + runtime: $r:path, + with_bridged_chain_messages_instance: $i:path, + bridge: $bridge:path, + this_chain_account_id_converter: $this_converter:path + ) => { + { + // if one of asserts fail, then either bridge isn't configured properly (or alternatively - non-standard + // configuration is used), or something has broke existing configuration (meaning that all bridged chains + // and relays will stop functioning) + use $crate::messages::{ + source::FromThisChainMessagePayload, + target::FromBridgedChainMessagePayload, + AccountIdOf, BalanceOf, BridgedChain, ThisChain, WeightOf, + }; + use pallet_bridge_messages::Config as MessagesConfig; + use static_assertions::assert_type_eq_all; + + assert_type_eq_all!(<$r as MessagesConfig<$i>>::OutboundPayload, FromThisChainMessagePayload<$bridge>); + assert_type_eq_all!(<$r as MessagesConfig<$i>>::OutboundMessageFee, BalanceOf>); + + assert_type_eq_all!(<$r as MessagesConfig<$i>>::InboundPayload, FromBridgedChainMessagePayload<$bridge>); + assert_type_eq_all!(<$r as MessagesConfig<$i>>::InboundMessageFee, BalanceOf>); + assert_type_eq_all!(<$r as MessagesConfig<$i>>::InboundRelayer, AccountIdOf>); + + assert_type_eq_all!(<$r as MessagesConfig<$i>>::AccountIdConverter, $this_converter); + + assert_type_eq_all!(<$r as MessagesConfig<$i>>::TargetHeaderChain, BridgedChain<$bridge>); + assert_type_eq_all!(<$r as MessagesConfig<$i>>::SourceHeaderChain, BridgedChain<$bridge>); + } + } +); + +/// Macro that combines four other macro calls - `assert_chain_types`, `assert_bridge_types`, +/// `assert_bridge_grandpa_pallet_types` and `assert_bridge_messages_pallet_types`. It may be used +/// at the chain that is implemeting complete standard messages bridge (i.e. with bridge GRANDPA and +/// messages pallets deployed). +#[macro_export] +macro_rules! assert_complete_bridge_types( + ( + runtime: $r:path, + with_bridged_chain_grandpa_instance: $gi:path, + with_bridged_chain_messages_instance: $mi:path, + bridge: $bridge:path, + this_chain: $this:path, + bridged_chain: $bridged:path, + this_chain_account_id_converter: $this_converter:path + ) => { + $crate::assert_chain_types!(runtime: $r, this_chain: $this); + $crate::assert_bridge_types!(bridge: $bridge, this_chain: $this, bridged_chain: $bridged); + $crate::assert_bridge_grandpa_pallet_types!( + runtime: $r, + with_bridged_chain_grandpa_instance: $gi, + bridged_chain: $bridged + ); + $crate::assert_bridge_messages_pallet_types!( + runtime: $r, + with_bridged_chain_messages_instance: $mi, + bridge: $bridge, + this_chain_account_id_converter: $this_converter + ); + } +); + +/// Parameters for asserting chain-related constants. +#[derive(Debug)] +pub struct AssertChainConstants { + /// Block length limits of the chain. + pub block_length: limits::BlockLength, + /// Block weight limits of the chain. + pub block_weights: limits::BlockWeights, +} + +/// Test that our hardcoded, chain-related constants, are matching chain runtime configuration. +/// +/// In particular, this test ensures that: +/// +/// 1) block weight limits are matching; +/// 2) block size limits are matching. +pub fn assert_chain_constants(params: AssertChainConstants) +where + R: frame_system::Config, + C: Chain, +{ + // we don't check runtime version here, because in our case we'll be building relay from one + // repo and runtime will live in another repo, along with outdated relay version. To avoid + // unneeded commits, let's not raise an error in case of version mismatch. + + // if one of following assert fails, it means that we may need to upgrade bridged chain and + // relay to use updated constants. If constants are now smaller than before, it may lead to + // undeliverable messages. + + // `BlockLength` struct is not implementing `PartialEq`, so we compare encoded values here. + assert_eq!( + R::BlockLength::get().encode(), + params.block_length.encode(), + "BlockLength from runtime ({:?}) differ from hardcoded: {:?}", + R::BlockLength::get(), + params.block_length, + ); + // `BlockWeights` struct is not implementing `PartialEq`, so we compare encoded values here + assert_eq!( + R::BlockWeights::get().encode(), + params.block_weights.encode(), + "BlockWeights from runtime ({:?}) differ from hardcoded: {:?}", + R::BlockWeights::get(), + params.block_weights, + ); +} + +/// Test that the constants, used in GRANDPA pallet configuration are valid. +pub fn assert_bridge_grandpa_pallet_constants() +where + R: pallet_bridge_grandpa::Config, + GI: 'static, +{ + assert!( + R::MaxRequests::get() > 0, + "MaxRequests ({}) must be larger than zero", + R::MaxRequests::get(), + ); +} + +/// Parameters for asserting messages pallet constants. +#[derive(Debug)] +pub struct AssertBridgeMessagesPalletConstants { + /// Maximal number of unrewarded relayer entries in a confirmation transaction at the bridged + /// chain. + pub max_unrewarded_relayers_in_bridged_confirmation_tx: MessageNonce, + /// Maximal number of unconfirmed messages in a confirmation transaction at the bridged chain. + pub max_unconfirmed_messages_in_bridged_confirmation_tx: MessageNonce, + /// Identifier of the bridged chain. + pub bridged_chain_id: ChainId, +} + +/// Test that the constants, used in messages pallet configuration are valid. +pub fn assert_bridge_messages_pallet_constants(params: AssertBridgeMessagesPalletConstants) +where + R: pallet_bridge_messages::Config, + MI: 'static, +{ + assert!( + R::MaxMessagesToPruneAtOnce::get() > 0, + "MaxMessagesToPruneAtOnce ({}) must be larger than zero", + R::MaxMessagesToPruneAtOnce::get(), + ); + assert!( + R::MaxUnrewardedRelayerEntriesAtInboundLane::get() <= params.max_unrewarded_relayers_in_bridged_confirmation_tx, + "MaxUnrewardedRelayerEntriesAtInboundLane ({}) must be <= than the hardcoded value for bridged chain: {}", + R::MaxUnrewardedRelayerEntriesAtInboundLane::get(), + params.max_unrewarded_relayers_in_bridged_confirmation_tx, + ); + assert!( + R::MaxUnconfirmedMessagesAtInboundLane::get() <= params.max_unconfirmed_messages_in_bridged_confirmation_tx, + "MaxUnrewardedRelayerEntriesAtInboundLane ({}) must be <= than the hardcoded value for bridged chain: {}", + R::MaxUnconfirmedMessagesAtInboundLane::get(), + params.max_unconfirmed_messages_in_bridged_confirmation_tx, + ); + assert_eq!(R::BridgedChainId::get(), params.bridged_chain_id); +} + +/// Parameters for asserting bridge pallet names. +#[derive(Debug)] +pub struct AssertBridgePalletNames<'a> { + /// Name of the messages pallet, deployed at the bridged chain and used to bridge with this + /// chain. + pub with_this_chain_messages_pallet_name: &'a str, + /// Name of the GRANDPA pallet, deployed at this chain and used to bridge with the bridged + /// chain. + pub with_bridged_chain_grandpa_pallet_name: &'a str, + /// Name of the messages pallet, deployed at this chain and used to bridge with the bridged + /// chain. + pub with_bridged_chain_messages_pallet_name: &'a str, +} + +/// Tests that bridge pallet names used in `construct_runtime!()` macro call are matching constants +/// from chain primitives crates. +pub fn assert_bridge_pallet_names(params: AssertBridgePalletNames) +where + B: MessageBridge, + R: pallet_bridge_grandpa::Config + pallet_bridge_messages::Config, + GI: 'static, + MI: 'static, +{ + assert_eq!(B::BRIDGED_MESSAGES_PALLET_NAME, params.with_this_chain_messages_pallet_name); + assert_eq!( + pallet_bridge_grandpa::PalletOwner::::storage_value_final_key().to_vec(), + bp_runtime::storage_value_key(params.with_bridged_chain_grandpa_pallet_name, "PalletOwner",).0, + ); + assert_eq!( + pallet_bridge_messages::PalletOwner::::storage_value_final_key().to_vec(), + bp_runtime::storage_value_key( + params.with_bridged_chain_messages_pallet_name, + "PalletOwner", + ) + .0, + ); +} + +/// Parameters for asserting complete standard messages bridge. +#[derive(Debug)] +pub struct AssertCompleteBridgeConstants<'a> { + /// Parameters to assert this chain constants. + pub this_chain_constants: AssertChainConstants, + /// Parameters to assert messages pallet constants. + pub messages_pallet_constants: AssertBridgeMessagesPalletConstants, + /// Parameters to assert pallet names constants. + pub pallet_names: AssertBridgePalletNames<'a>, +} + +/// All bridge-related constants tests for the complete standard messages bridge (i.e. with bridge +/// GRANDPA and messages pallets deployed). +pub fn assert_complete_bridge_constants(params: AssertCompleteBridgeConstants) +where + R: frame_system::Config + + pallet_bridge_grandpa::Config + + pallet_bridge_messages::Config, + GI: 'static, + MI: 'static, + B: MessageBridge, + This: Chain, +{ + assert_chain_constants::(params.this_chain_constants); + assert_bridge_grandpa_pallet_constants::(); + assert_bridge_messages_pallet_constants::(params.messages_pallet_constants); + assert_bridge_pallet_names::(params.pallet_names); +} diff --git a/bin/runtime-common/src/lib.rs b/bin/runtime-common/src/lib.rs index 66f2c6c3a01..c7fb98aba76 100644 --- a/bin/runtime-common/src/lib.rs +++ b/bin/runtime-common/src/lib.rs @@ -21,3 +21,6 @@ pub mod messages; pub mod messages_api; pub mod messages_benchmarking; + +#[cfg(feature = "integrity-test")] +pub mod integrity; diff --git a/bin/runtime-common/src/messages.rs b/bin/runtime-common/src/messages.rs index 47fb1c48f43..250b68ceffe 100644 --- a/bin/runtime-common/src/messages.rs +++ b/bin/runtime-common/src/messages.rs @@ -22,7 +22,7 @@ use bp_message_dispatch::MessageDispatch as _; use bp_messages::{ - source_chain::{LaneMessageVerifier, Sender}, + source_chain::LaneMessageVerifier, target_chain::{DispatchMessage, MessageDispatch, ProvedLaneMessages, ProvedMessages}, InboundLaneData, LaneId, Message, MessageData, MessageKey, MessageNonce, OutboundLaneData, }; @@ -30,7 +30,7 @@ use bp_runtime::{ messages::{DispatchFeePayment, MessageDispatchResult}, ChainId, Size, StorageProofChecker, }; -use codec::{Decode, Encode}; +use codec::{Decode, DecodeLimit, Encode}; use frame_support::{ traits::{Currency, ExistenceRequirement}, weights::{Weight, WeightToFeePolynomial}, @@ -70,6 +70,7 @@ pub trait MessageBridge { /// Convert Bridged chain balance into This chain balance. fn bridged_balance_to_this_balance( bridged_balance: BalanceOf>, + bridged_to_this_conversion_rate_override: Option, ) -> BalanceOf>; } @@ -110,11 +111,13 @@ pub struct MessageTransaction { /// This chain that has `pallet-bridge-messages` and `dispatch` modules. pub trait ThisChainWithMessages: ChainWithMessages { + /// Call origin on the chain. + type Origin; /// Call type on the chain. type Call: Encode + Decode; - /// Are we accepting any messages to the given lane? - fn is_outbound_lane_enabled(lane: &LaneId) -> bool; + /// Do we accept message sent by given origin to given lane? + fn is_message_accepted(origin: &Self::Origin, lane: &LaneId) -> bool; /// Maximal number of pending (not yet delivered) messages at This chain. /// @@ -172,6 +175,8 @@ pub type SignatureOf = ::Signature; pub type WeightOf = ::Weight; /// Type of balances that is used on the chain. pub type BalanceOf = ::Balance; +/// Type of origin that is used on the chain. +pub type OriginOf = ::Origin; /// Type of call that is used on this chain. pub type CallOf = ::Call; @@ -269,7 +274,8 @@ pub mod source { pub struct FromThisChainMessageVerifier(PhantomData); /// The error message returned from LaneMessageVerifier when outbound lane is disabled. - pub const OUTBOUND_LANE_DISABLED: &str = "The outbound message lane is disabled."; + pub const MESSAGE_REJECTED_BY_OUTBOUND_LANE: &str = + "The outbound message lane has rejected the message."; /// The error message returned from LaneMessageVerifier when too many pending messages at the /// lane. pub const TOO_MANY_PENDING_MESSAGES: &str = "Too many pending messages at the lane."; @@ -280,26 +286,30 @@ pub mod source { impl LaneMessageVerifier< + OriginOf>, AccountIdOf>, FromThisChainMessagePayload, BalanceOf>, > for FromThisChainMessageVerifier where B: MessageBridge, + // matches requirements from the `frame_system::Config::Origin` + OriginOf>: Clone + + Into>>, OriginOf>>>, AccountIdOf>: PartialEq + Clone, { type Error = &'static str; fn verify_message( - submitter: &Sender>>, + submitter: &OriginOf>, delivery_and_dispatch_fee: &BalanceOf>, lane: &LaneId, lane_outbound_data: &OutboundLaneData, payload: &FromThisChainMessagePayload, ) -> Result<(), Self::Error> { // reject message if lane is blocked - if !ThisChain::::is_outbound_lane_enabled(lane) { - return Err(OUTBOUND_LANE_DISABLED) + if !ThisChain::::is_message_accepted(submitter, lane) { + return Err(MESSAGE_REJECTED_BY_OUTBOUND_LANE) } // reject message if there are too many pending messages at this lane @@ -313,11 +323,29 @@ pub mod source { // Do the dispatch-specific check. We assume that the target chain uses // `Dispatch`, so we verify the message accordingly. - pallet_bridge_dispatch::verify_message_origin(submitter, payload) - .map_err(|_| BAD_ORIGIN)?; + let raw_origin_or_err: Result< + frame_system::RawOrigin>>, + OriginOf>, + > = submitter.clone().into(); + match raw_origin_or_err { + Ok(raw_origin) => + pallet_bridge_dispatch::verify_message_origin(&raw_origin, payload) + .map(drop) + .map_err(|_| BAD_ORIGIN)?, + Err(_) => { + // so what it means that we've failed to convert origin to the + // `frame_system::RawOrigin`? now it means that the custom pallet origin has + // been used to send the message. Do we need to verify it? The answer is no, + // because pallet may craft any origin (e.g. root) && we can't verify whether it + // is valid, or not. + }, + }; - let minimal_fee_in_this_tokens = - estimate_message_dispatch_and_delivery_fee::(payload, B::RELAYER_FEE_PERCENT)?; + let minimal_fee_in_this_tokens = estimate_message_dispatch_and_delivery_fee::( + payload, + B::RELAYER_FEE_PERCENT, + None, + )?; // compare with actual fee paid if *delivery_and_dispatch_fee < minimal_fee_in_this_tokens { @@ -371,6 +399,7 @@ pub mod source { pub fn estimate_message_dispatch_and_delivery_fee( payload: &FromThisChainMessagePayload, relayer_fee_percent: u32, + bridged_to_this_conversion_rate: Option, ) -> Result>, &'static str> { // the fee (in Bridged tokens) of all transactions that are made on the Bridged chain // @@ -391,8 +420,11 @@ pub mod source { ThisChain::::transaction_payment(confirmation_transaction); // minimal fee (in This tokens) is a sum of all required fees - let minimal_fee = B::bridged_balance_to_this_balance(delivery_transaction_fee) - .checked_add(&confirmation_transaction_fee); + let minimal_fee = B::bridged_balance_to_this_balance( + delivery_transaction_fee, + bridged_to_this_conversion_rate, + ) + .checked_add(&confirmation_transaction_fee); // before returning, add extra fee that is paid to the relayer (relayer interest) minimal_fee @@ -513,7 +545,11 @@ pub mod target { for Result { fn from(encoded_call: FromBridgedChainEncodedMessageCall) -> Self { - DecodedCall::decode(&mut &encoded_call.encoded_call[..]).map_err(drop) + DecodedCall::decode_with_depth_limit( + sp_api::MAX_EXTRINSIC_DEPTH, + &mut &encoded_call.encoded_call[..], + ) + .map_err(drop) } } @@ -798,8 +834,12 @@ mod tests { fn bridged_balance_to_this_balance( bridged_balance: BridgedChainBalance, + bridged_to_this_conversion_rate_override: Option, ) -> ThisChainBalance { - ThisChainBalance(bridged_balance.0 * BRIDGED_CHAIN_TO_THIS_CHAIN_BALANCE_RATE as u32) + let conversion_rate = bridged_to_this_conversion_rate_override + .map(|r| r.to_float() as u32) + .unwrap_or(BRIDGED_CHAIN_TO_THIS_CHAIN_BALANCE_RATE); + ThisChainBalance(bridged_balance.0 * conversion_rate) } } @@ -817,7 +857,10 @@ mod tests { type ThisChain = BridgedChain; type BridgedChain = ThisChain; - fn bridged_balance_to_this_balance(_this_balance: ThisChainBalance) -> BridgedChainBalance { + fn bridged_balance_to_this_balance( + _this_balance: ThisChainBalance, + _bridged_to_this_conversion_rate_override: Option, + ) -> BridgedChainBalance { unreachable!() } } @@ -835,6 +878,18 @@ mod tests { #[codec(index = 84)] Mint, } + #[derive(Clone, Debug)] + struct ThisChainOrigin(Result, ()>); + + impl From + for Result, ThisChainOrigin> + { + fn from( + origin: ThisChainOrigin, + ) -> Result, ThisChainOrigin> { + origin.clone().0.map_err(|_| origin) + } + } #[derive(Debug, PartialEq, Decode, Encode)] struct BridgedChainAccountId(u32); @@ -844,6 +899,18 @@ mod tests { struct BridgedChainSignature(u32); #[derive(Debug, PartialEq, Decode, Encode)] enum BridgedChainCall {} + #[derive(Clone, Debug)] + struct BridgedChainOrigin; + + impl From + for Result, BridgedChainOrigin> + { + fn from( + _origin: BridgedChainOrigin, + ) -> Result, BridgedChainOrigin> { + unreachable!() + } + } macro_rules! impl_wrapped_balance { ($name:ident) => { @@ -921,9 +988,10 @@ mod tests { } impl ThisChainWithMessages for ThisChain { + type Origin = ThisChainOrigin; type Call = ThisChainCall; - fn is_outbound_lane_enabled(lane: &LaneId) -> bool { + fn is_message_accepted(_send_origin: &Self::Origin, lane: &LaneId) -> bool { lane == TEST_LANE_ID } @@ -981,9 +1049,10 @@ mod tests { } impl ThisChainWithMessages for BridgedChain { + type Origin = BridgedChainOrigin; type Call = BridgedChainCall; - fn is_outbound_lane_enabled(_lane: &LaneId) -> bool { + fn is_message_accepted(_send_origin: &Self::Origin, _lane: &LaneId) -> bool { unreachable!() } @@ -1095,6 +1164,7 @@ mod tests { source::estimate_message_dispatch_and_delivery_fee::( &payload, OnThisChainBridge::RELAYER_FEE_PERCENT, + None, ), Ok(ThisChainBalance(EXPECTED_MINIMAL_FEE)), ); @@ -1106,6 +1176,7 @@ mod tests { source::estimate_message_dispatch_and_delivery_fee::( &payload_with_pay_on_target, OnThisChainBridge::RELAYER_FEE_PERCENT, + None, ) .expect( "estimate_message_dispatch_and_delivery_fee failed for pay-at-target-chain message", @@ -1120,7 +1191,7 @@ mod tests { // and now check that the verifier checks the fee assert_eq!( source::FromThisChainMessageVerifier::::verify_message( - &Sender::Root, + &ThisChainOrigin(Ok(frame_system::RawOrigin::Root)), &ThisChainBalance(1), TEST_LANE_ID, &test_lane_outbound_data(), @@ -1129,7 +1200,7 @@ mod tests { Err(source::TOO_LOW_FEE) ); assert!(source::FromThisChainMessageVerifier::::verify_message( - &Sender::Root, + &ThisChainOrigin(Ok(frame_system::RawOrigin::Root)), &ThisChainBalance(1_000_000), TEST_LANE_ID, &test_lane_outbound_data(), @@ -1152,7 +1223,7 @@ mod tests { // and now check that the verifier checks the fee assert_eq!( source::FromThisChainMessageVerifier::::verify_message( - &Sender::Signed(ThisChainAccountId(0)), + &ThisChainOrigin(Ok(frame_system::RawOrigin::Signed(ThisChainAccountId(0)))), &ThisChainBalance(1_000_000), TEST_LANE_ID, &test_lane_outbound_data(), @@ -1162,7 +1233,7 @@ mod tests { ); assert_eq!( source::FromThisChainMessageVerifier::::verify_message( - &Sender::None, + &ThisChainOrigin(Ok(frame_system::RawOrigin::None)), &ThisChainBalance(1_000_000), TEST_LANE_ID, &test_lane_outbound_data(), @@ -1171,7 +1242,7 @@ mod tests { Err(source::BAD_ORIGIN) ); assert!(source::FromThisChainMessageVerifier::::verify_message( - &Sender::Root, + &ThisChainOrigin(Ok(frame_system::RawOrigin::Root)), &ThisChainBalance(1_000_000), TEST_LANE_ID, &test_lane_outbound_data(), @@ -1194,7 +1265,7 @@ mod tests { // and now check that the verifier checks the fee assert_eq!( source::FromThisChainMessageVerifier::::verify_message( - &Sender::Signed(ThisChainAccountId(0)), + &ThisChainOrigin(Ok(frame_system::RawOrigin::Signed(ThisChainAccountId(0)))), &ThisChainBalance(1_000_000), TEST_LANE_ID, &test_lane_outbound_data(), @@ -1203,7 +1274,7 @@ mod tests { Err(source::BAD_ORIGIN) ); assert!(source::FromThisChainMessageVerifier::::verify_message( - &Sender::Signed(ThisChainAccountId(1)), + &ThisChainOrigin(Ok(frame_system::RawOrigin::Signed(ThisChainAccountId(1)))), &ThisChainBalance(1_000_000), TEST_LANE_ID, &test_lane_outbound_data(), @@ -1216,13 +1287,13 @@ mod tests { fn message_is_rejected_when_sent_using_disabled_lane() { assert_eq!( source::FromThisChainMessageVerifier::::verify_message( - &Sender::Root, + &ThisChainOrigin(Ok(frame_system::RawOrigin::Root)), &ThisChainBalance(1_000_000), b"dsbl", &test_lane_outbound_data(), ®ular_outbound_message_payload(), ), - Err(source::OUTBOUND_LANE_DISABLED) + Err(source::MESSAGE_REJECTED_BY_OUTBOUND_LANE) ); } @@ -1230,7 +1301,7 @@ mod tests { fn message_is_rejected_when_there_are_too_many_pending_messages_at_outbound_lane() { assert_eq!( source::FromThisChainMessageVerifier::::verify_message( - &Sender::Root, + &ThisChainOrigin(Ok(frame_system::RawOrigin::Root)), &ThisChainBalance(1_000_000), TEST_LANE_ID, &OutboundLaneData { @@ -1572,4 +1643,21 @@ mod tests { 100 + 50 * 10 + 777, ); } + + #[test] + fn conversion_rate_override_works() { + let payload = regular_outbound_message_payload(); + let regular_fee = source::estimate_message_dispatch_and_delivery_fee::( + &payload, + OnThisChainBridge::RELAYER_FEE_PERCENT, + None, + ); + let overrided_fee = source::estimate_message_dispatch_and_delivery_fee::( + &payload, + OnThisChainBridge::RELAYER_FEE_PERCENT, + Some(FixedU128::from_float((BRIDGED_CHAIN_TO_THIS_CHAIN_BALANCE_RATE * 2) as f64)), + ); + + assert!(regular_fee < overrided_fee); + } } diff --git a/bin/runtime-common/src/messages_benchmarking.rs b/bin/runtime-common/src/messages_benchmarking.rs index 12c270d8666..7c9f50e8ea0 100644 --- a/bin/runtime-common/src/messages_benchmarking.rs +++ b/bin/runtime-common/src/messages_benchmarking.rs @@ -43,10 +43,33 @@ use sp_std::{fmt::Debug, prelude::*}; use sp_trie::{record_all_keys, trie_types::TrieDBMutV1, LayoutV1, MemoryDB, Recorder, TrieMut}; use sp_version::RuntimeVersion; +/// Return this chain account, used to dispatch message. +pub fn dispatch_account() -> AccountIdOf> +where + B: MessageBridge, + SignerOf>: + From + IdentifyAccount>>, +{ + let this_raw_public = PublicKey::from(&dispatch_account_secret()); + let this_public: SignerOf> = + sp_core::ed25519::Public::from_raw(this_raw_public.to_bytes()).into(); + this_public.into_account() +} + +/// Return public key of this chain account, used to dispatch message. +pub fn dispatch_account_secret() -> SecretKey { + // key from the repo example (https://docs.rs/ed25519-dalek/1.0.1/ed25519_dalek/struct.SecretKey.html) + SecretKey::from_bytes(&[ + 157, 097, 177, 157, 239, 253, 090, 096, 186, 132, 074, 244, 146, 236, 044, 196, 068, 073, + 197, 105, 123, 050, 105, 025, 112, 059, 172, 003, 028, 174, 127, 096, + ]) + .expect("harcoded key is valid") +} + /// Prepare outbound message for the `send_message` call. pub fn prepare_outbound_message( params: MessageParams>>, -) -> (FromThisChainMessagePayload, BalanceOf>) +) -> FromThisChainMessagePayload where B: MessageBridge, BalanceOf>: From, @@ -54,14 +77,13 @@ where let message_payload = vec![0; params.size as usize]; let dispatch_origin = bp_message_dispatch::CallOrigin::SourceAccount(params.sender_account); - let message = FromThisChainMessagePayload:: { + FromThisChainMessagePayload:: { spec_version: 0, weight: params.size as _, origin: dispatch_origin, call: message_payload, dispatch_fee_payment: DispatchFeePayment::AtSourceChain, - }; - (message, pallet_bridge_messages::benchmarking::MESSAGE_FEE.into()) + } } /// Prepare proof of messages for the `receive_messages_proof` call. @@ -83,6 +105,7 @@ where FI: 'static, BH: Header>>, BHH: Hasher>>, + AccountIdOf>: PartialEq + sp_std::fmt::Debug, AccountIdOf>: From<[u8; 32]>, BalanceOf>: Debug + MaybeSerializeDeserialize, CallOf>: From> + GetDispatchInfo, @@ -117,6 +140,7 @@ where // if dispatch fee is paid at this chain, endow relayer account if params.dispatch_fee_payment == DispatchFeePayment::AtTargetChain { + assert_eq!(this_public.clone().into_account(), dispatch_account::()); pallet_balances::Pallet::::make_free_balance_be( &this_public.clone().into_account(), endow_amount, @@ -299,12 +323,7 @@ fn ed25519_sign( source_chain_id: ChainId, target_chain_id: ChainId, ) -> ([u8; 32], [u8; 64]) { - // key from the repo example (https://docs.rs/ed25519-dalek/1.0.1/ed25519_dalek/struct.SecretKey.html) - let target_secret = SecretKey::from_bytes(&[ - 157, 097, 177, 157, 239, 253, 090, 096, 186, 132, 074, 244, 146, 236, 044, 196, 068, 073, - 197, 105, 123, 050, 105, 025, 112, 059, 172, 003, 028, 174, 127, 096, - ]) - .expect("harcoded key is valid"); + let target_secret = dispatch_account_secret(); let target_public: PublicKey = (&target_secret).into(); let mut target_pair_bytes = [0u8; KEYPAIR_LENGTH]; diff --git a/ci.Dockerfile b/ci.Dockerfile index eec619a7983..b419f6be54d 100644 --- a/ci.Dockerfile +++ b/ci.Dockerfile @@ -1,7 +1,7 @@ # This file is a "runtime" part from a builder-pattern in Dockerfile, it's used in CI. # The only different part is that the compilation happens externally, # so COPY has a different source. -FROM ubuntu:20.04 +FROM docker.io/library/ubuntu:20.04 # show backtraces ENV RUST_BACKTRACE 1 diff --git a/deny.toml b/deny.toml index d22897182af..e5281e0e849 100644 --- a/deny.toml +++ b/deny.toml @@ -48,21 +48,17 @@ notice = "warn" # A list of advisory IDs to ignore. Note that ignored advisories will still # output a note when they are encountered. ignore = [ - # yaml-rust < clap. Not feasible to upgrade and also not possible to trigger in practice. - "RUSTSEC-2018-0006", "RUSTSEC-2020-0070", # Comes from honggfuzz via storage-proof-fuzzer: 'memmap' "RUSTSEC-2020-0077", - # Comes from time: 'stweb' (will be fixed in upcoming time 0.3) - "RUSTSEC-2020-0056", # net2 (origin: Substrate RPC crates) "RUSTSEC-2020-0016", - # Wasmtime (origin: Substrate executor crates) - "RUSTSEC-2021-0110", # time (origin: Substrate RPC + benchmarking crates) "RUSTSEC-2020-0071", # chrono (origin: Substrate benchmarking + cli + ...) "RUSTSEC-2020-0159", + # lru 0.6.6 (origin: libp2p) + "RUSTSEC-2021-0130", ] # Threshold for security vulnerabilities, any vulnerability with a CVSS score # lower than the range specified will be ignored. Note that ignored advisories diff --git a/deployments/BridgeDeps.Dockerfile b/deployments/BridgeDeps.Dockerfile index a18a94a7155..6d3b3fa1704 100644 --- a/deployments/BridgeDeps.Dockerfile +++ b/deployments/BridgeDeps.Dockerfile @@ -2,7 +2,7 @@ # # This image is meant to be used as a building block when building images for # the various components in the bridge repo, such as nodes and relayers. -FROM ubuntu:20.04 +FROM docker.io/library/ubuntu:20.04 ENV LAST_DEPS_UPDATE 2021-04-01 ENV DEBIAN_FRONTEND=noninteractive diff --git a/deployments/bridges/rialto-millau/dashboard/grafana/relay-millau-to-rialto-messages-dashboard.json b/deployments/bridges/rialto-millau/dashboard/grafana/relay-millau-to-rialto-messages-dashboard.json index 32f3e53d667..abce8bbc29a 100644 --- a/deployments/bridges/rialto-millau/dashboard/grafana/relay-millau-to-rialto-messages-dashboard.json +++ b/deployments/bridges/rialto-millau/dashboard/grafana/relay-millau-to-rialto-messages-dashboard.json @@ -64,11 +64,18 @@ "steppedLine": false, "targets": [ { - "expr": "label_replace(label_replace(Millau_to_Rialto_MessageLane_00000000_best_block_numbers{type=~\"target|target_at_source\"}, \"type\", \"At Rialto\", \"type\", \"target\"), \"type\", \"At Millau\", \"type\", \"target_at_source\")", + "expr": "Millau_to_Rialto_MessageLane_00000000_best_target_block_number", "instant": false, "interval": "", - "legendFormat": "{{type}}", + "legendFormat": "At Rialto", "refId": "A" + }, + { + "expr": "Millau_to_Rialto_MessageLane_00000000_best_target_at_source_block_number", + "instant": false, + "interval": "", + "legendFormat": "At Millau", + "refId": "B" } ], "thresholds": [], @@ -158,10 +165,16 @@ "steppedLine": false, "targets": [ { - "expr": "label_replace(label_replace(Millau_to_Rialto_MessageLane_00000000_best_block_numbers{type=~\"source|source_at_target\"}, \"type\", \"At Millau\", \"type\", \"source\"), \"type\", \"At Rialto\", \"type\", \"source_at_target\")", + "expr": "Millau_to_Rialto_MessageLane_00000000_best_source_block_number", "interval": "", - "legendFormat": "{{type}}", + "legendFormat": "At Millau", "refId": "A" + }, + { + "expr": "Millau_to_Rialto_MessageLane_00000000_best_source_at_target_block_number", + "interval": "", + "legendFormat": "At Rialto", + "refId": "B" } ], "thresholds": [], @@ -531,7 +544,7 @@ "refId": "A" }, { - "expr": "increase(Millau_to_Rialto_MessageLane_00000000_lane_state_nonces{type=\"target_latest_received\"}[1m])", + "expr": "increase(Millau_to_Rialto_MessageLane_00000000_lane_state_nonces{type=\"target_latest_received\"}[1m]) OR on() vector(0)", "interval": "", "legendFormat": "Messages delivered to Rialto in last 1m", "refId": "B" @@ -954,7 +967,7 @@ "refId": "A" }, { - "expr": "increase(Millau_to_Rialto_MessageLane_00000001_lane_state_nonces{type=\"target_latest_received\"}[10m])", + "expr": "increase(Millau_to_Rialto_MessageLane_00000001_lane_state_nonces{type=\"target_latest_received\"}[10m]) OR on() vector(0)", "hide": true, "interval": "", "legendFormat": "Messages generated in last 5 minutes", @@ -1097,7 +1110,7 @@ "refId": "A" }, { - "expr": "increase(Millau_to_Rialto_MessageLane_00000001_lane_state_nonces{type=\"source_latest_confirmed\"}[10m])", + "expr": "increase(Millau_to_Rialto_MessageLane_00000001_lane_state_nonces{type=\"source_latest_confirmed\"}[10m]) OR on() vector(0)", "hide": true, "interval": "", "legendFormat": "", @@ -1241,7 +1254,7 @@ "refId": "A" }, { - "expr": "increase(Millau_to_Rialto_MessageLane_73776170_lane_state_nonces{type=\"target_latest_received\"}[20m])", + "expr": "increase(Millau_to_Rialto_MessageLane_73776170_lane_state_nonces{type=\"target_latest_received\"}[20m]) OR on() vector(0)", "hide": true, "interval": "", "legendFormat": "Messages generated in last 5 minutes", @@ -1349,7 +1362,7 @@ "refId": "A" }, { - "expr": "increase(Millau_to_Rialto_MessageLane_73776170_lane_state_nonces{type=\"source_latest_confirmed\"}[10m])", + "expr": "increase(Millau_to_Rialto_MessageLane_73776170_lane_state_nonces{type=\"source_latest_confirmed\"}[10m]) OR on() vector(0)", "hide": true, "interval": "", "legendFormat": "", diff --git a/deployments/bridges/rialto-millau/dashboard/grafana/relay-rialto-to-millau-messages-dashboard.json b/deployments/bridges/rialto-millau/dashboard/grafana/relay-rialto-to-millau-messages-dashboard.json index eaca8610aec..4e3d314a3f4 100644 --- a/deployments/bridges/rialto-millau/dashboard/grafana/relay-rialto-to-millau-messages-dashboard.json +++ b/deployments/bridges/rialto-millau/dashboard/grafana/relay-rialto-to-millau-messages-dashboard.json @@ -64,11 +64,18 @@ "steppedLine": false, "targets": [ { - "expr": "label_replace(label_replace(Rialto_to_Millau_MessageLane_00000000_best_block_numbers{type=~\"target|target_at_source\"}, \"type\", \"At Millau\", \"type\", \"target\"), \"type\", \"At Rialto\", \"type\", \"target_at_source\")", + "expr": "Rialto_to_Millau_MessageLane_00000000_best_target_block_number", "instant": false, "interval": "", - "legendFormat": "{{type}}", + "legendFormat": "At Millau", "refId": "A" + }, + { + "expr": "Rialto_to_Millau_MessageLane_00000000_best_target_at_source_block_number", + "instant": false, + "interval": "", + "legendFormat": "At Rialto", + "refId": "B" } ], "thresholds": [], @@ -158,10 +165,16 @@ "steppedLine": false, "targets": [ { - "expr": "label_replace(label_replace(Rialto_to_Millau_MessageLane_00000000_best_block_numbers{type=~\"source|source_at_target\"}, \"type\", \"At Rialto\", \"type\", \"source\"), \"type\", \"At Millau\", \"type\", \"source_at_target\")", + "expr": "Rialto_to_Millau_MessageLane_00000000_best_source_block_number", "interval": "", - "legendFormat": "{{type}}", + "legendFormat": "At Rialto", "refId": "A" + }, + { + "expr": "Rialto_to_Millau_MessageLane_00000000_best_source_at_target_block_number", + "interval": "", + "legendFormat": "At Millau", + "refId": "B" } ], "thresholds": [], @@ -522,7 +535,7 @@ "refId": "A" }, { - "expr": "increase(Rialto_to_Millau_MessageLane_00000000_lane_state_nonces{type=\"target_latest_received\"}[1m])", + "expr": "increase(Rialto_to_Millau_MessageLane_00000000_lane_state_nonces{type=\"target_latest_received\"}[1m]) OR on() vector(0)", "interval": "", "legendFormat": "Messages delivered to Millau in last 1m", "refId": "B" @@ -945,7 +958,7 @@ "refId": "A" }, { - "expr": "increase(Rialto_to_Millau_MessageLane_00000001_lane_state_nonces{type=\"target_latest_received\"}[10m])", + "expr": "increase(Rialto_to_Millau_MessageLane_00000001_lane_state_nonces{type=\"target_latest_received\"}[10m]) OR on() vector(0)", "hide": true, "interval": "", "legendFormat": "Messages generated in last 5 minutes", @@ -1089,7 +1102,7 @@ "refId": "A" }, { - "expr": "increase(Rialto_to_Millau_MessageLane_00000001_lane_state_nonces{type=\"source_latest_confirmed\"}[10m])", + "expr": "increase(Rialto_to_Millau_MessageLane_00000001_lane_state_nonces{type=\"source_latest_confirmed\"}[10m]) OR on() vector(0)", "hide": true, "interval": "", "legendFormat": "", diff --git a/deployments/bridges/rialto-millau/dashboard/grafana/rialto-millau-maintenance-dashboard.json b/deployments/bridges/rialto-millau/dashboard/grafana/rialto-millau-maintenance-dashboard.json index ad84e977c1d..225e46fae3a 100644 --- a/deployments/bridges/rialto-millau/dashboard/grafana/rialto-millau-maintenance-dashboard.json +++ b/deployments/bridges/rialto-millau/dashboard/grafana/rialto-millau-maintenance-dashboard.json @@ -172,7 +172,7 @@ "targets": [ { "exemplar": true, - "expr": "kusama_to_base_conversion_rate{instance='relay-millau-rialto:9616'} / polkadot_to_base_conversion_rate{instance='relay-millau-rialto:9616'}", + "expr": "polkadot_to_base_conversion_rate{instance='relay-millau-rialto:9616'} / kusama_to_base_conversion_rate{instance='relay-millau-rialto:9616'}", "interval": "", "legendFormat": "Outside of runtime (actually Polkadot -> Kusama)", "refId": "A" @@ -384,7 +384,7 @@ "targets": [ { "exemplar": true, - "expr": "polkadot_to_base_conversion_rate{instance='relay-millau-rialto:9616'} / kusama_to_base_conversion_rate{instance='relay-millau-rialto:9616'}", + "expr": "kusama_to_base_conversion_rate{instance='relay-millau-rialto:9616'} / polkadot_to_base_conversion_rate{instance='relay-millau-rialto:9616'}", "interval": "", "legendFormat": "Outside of runtime (actually Kusama -> Polkadot)", "refId": "A" @@ -442,6 +442,64 @@ } }, { + "alert": { + "alertRuleTags": {}, + "conditions": [ + { + "evaluator": { + "params": [ + 1000 + ], + "type": "lt" + }, + "operator": { + "type": "and" + }, + "query": { + "params": [ + "A", + "5m", + "now" + ] + }, + "reducer": { + "params": [], + "type": "last" + }, + "type": "query" + }, + { + "evaluator": { + "params": [ + 1000 + ], + "type": "lt" + }, + "operator": { + "type": "or" + }, + "query": { + "params": [ + "B", + "5m", + "now" + ] + }, + "reducer": { + "params": [], + "type": "last" + }, + "type": "query" + } + ], + "executionErrorState": "alerting", + "for": "5m", + "frequency": "1m", + "handler": 1, + "name": "At-Rialto relay balances are too low", + "noDataState": "no_data", + "notifications": [] + }, "aliasColors": {}, "bars": false, "dashLength": 10, @@ -498,7 +556,15 @@ "refId": "B" } ], - "thresholds": [], + "thresholds": [ + { + "colorMode": "critical", + "fill": true, + "line": true, + "op": "lt", + "value": 1000 + } + ], "timeFrom": null, "timeRegions": [], "timeShift": null, @@ -540,6 +606,64 @@ } }, { + "alert": { + "alertRuleTags": {}, + "conditions": [ + { + "evaluator": { + "params": [ + 1000 + ], + "type": "lt" + }, + "operator": { + "type": "and" + }, + "query": { + "params": [ + "A", + "5m", + "now" + ] + }, + "reducer": { + "params": [], + "type": "last" + }, + "type": "query" + }, + { + "evaluator": { + "params": [ + 1000 + ], + "type": "lt" + }, + "operator": { + "type": "and" + }, + "query": { + "params": [ + "B", + "5m", + "now" + ] + }, + "reducer": { + "params": [], + "type": "last" + }, + "type": "query" + } + ], + "executionErrorState": "alerting", + "for": "5m", + "frequency": "1m", + "handler": 1, + "name": "At-Millau relay balances are too low", + "noDataState": "no_data", + "notifications": [] + }, "aliasColors": {}, "bars": false, "dashLength": 10, @@ -596,7 +720,15 @@ "refId": "B" } ], - "thresholds": [], + "thresholds": [ + { + "colorMode": "critical", + "fill": true, + "line": true, + "op": "lt", + "value": 1000 + } + ], "timeFrom": null, "timeRegions": [], "timeShift": null, @@ -636,6 +768,276 @@ "align": false, "alignLevel": null } + }, + { + "alert": { + "alertRuleTags": {}, + "conditions": [ + { + "evaluator": { + "params": [ + 0 + ], + "type": "gt" + }, + "operator": { + "type": "and" + }, + "query": { + "params": [ + "A", + "5m", + "now" + ] + }, + "reducer": { + "params": [], + "type": "max" + }, + "type": "query" + } + ], + "executionErrorState": "alerting", + "for": "5m", + "frequency": "1m", + "handler": 1, + "name": "Whether with-Rialto-grandpa-pallet and Rialto itself are on different forks alert", + "noDataState": "no_data", + "notifications": [] + }, + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "Prometheus", + "fieldConfig": { + "defaults": { + "custom": {} + }, + "overrides": [] + }, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 8, + "w": 12, + "x": 0, + "y": 24 + }, + "hiddenSeries": false, + "id": 11, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null", + "percentage": false, + "pluginVersion": "7.1.3", + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "Rialto_to_Millau_MessageLane_00000000_is_source_and_source_at_target_using_different_forks", + "interval": "", + "legendFormat": "On different forks?", + "refId": "A" + } + ], + "thresholds": [ + { + "colorMode": "critical", + "fill": true, + "line": true, + "op": "gt", + "value": 0 + } + ], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Whether with-Rialto-grandpa-pallet and Rialto itself are on different forks", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "alert": { + "alertRuleTags": {}, + "conditions": [ + { + "evaluator": { + "params": [ + 0 + ], + "type": "gt" + }, + "operator": { + "type": "and" + }, + "query": { + "params": [ + "A", + "5m", + "now" + ] + }, + "reducer": { + "params": [], + "type": "max" + }, + "type": "query" + } + ], + "executionErrorState": "alerting", + "for": "5m", + "frequency": "1m", + "handler": 1, + "name": "Whether with-Rialto-grandpa-pallet and Rialto itself are on different forks alert", + "noDataState": "no_data", + "notifications": [] + }, + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "Prometheus", + "fieldConfig": { + "defaults": { + "custom": {} + }, + "overrides": [] + }, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 8, + "w": 12, + "x": 12, + "y": 24 + }, + "hiddenSeries": false, + "id": 12, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null", + "percentage": false, + "pluginVersion": "7.1.3", + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "Millau_to_Rialto_MessageLane_00000000_is_source_and_source_at_target_using_different_forks", + "interval": "", + "legendFormat": "On different forks?", + "refId": "A" + } + ], + "thresholds": [ + { + "colorMode": "critical", + "fill": true, + "line": true, + "op": "gt", + "value": 0 + } + ], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Whether with-Millau-grandpa-pallet and Millau itself are on different forks", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } } ], "refresh": "10s", @@ -654,4 +1056,4 @@ "title": "Rialto+Millau maintenance dashboard", "uid": "7AuyrjlMz", "version": 1 -} \ No newline at end of file +} diff --git a/deployments/bridges/rialto-millau/entrypoints/relay-messages-to-millau-generator-entrypoint.sh b/deployments/bridges/rialto-millau/entrypoints/relay-messages-to-millau-generator-entrypoint.sh index 9cae01fc0c0..e20b3da7df8 100755 --- a/deployments/bridges/rialto-millau/entrypoints/relay-messages-to-millau-generator-entrypoint.sh +++ b/deployments/bridges/rialto-millau/entrypoints/relay-messages-to-millau-generator-entrypoint.sh @@ -34,16 +34,13 @@ LARGE_MESSAGES_TIME=0 # start sending message packs in a hour BUNCH_OF_MESSAGES_TIME=3600 -# give conversion rate updater some time to update Millau->Rialto conversion rate in Rialto -# (initially rate=1 and rational relayer won't deliver any messages if it'll be changed to larger value) -sleep 120 - while true do rand_sleep echo "Sending Remark from Rialto to Millau using Target Origin" $SEND_MESSAGE \ --lane $MESSAGE_LANE \ + --conversion-rate-override metric \ --origin Target \ remark @@ -51,6 +48,7 @@ do echo "Sending Remark from Rialto to Millau using Target Origin using secondary lane: $SECONDARY_MESSAGE_LANE" $SEND_MESSAGE \ --lane $SECONDARY_MESSAGE_LANE \ + --conversion-rate-override metric \ --origin Target \ --dispatch-fee-payment at-target-chain \ remark @@ -60,6 +58,7 @@ do echo "Sending Transfer from Rialto to Millau using Target Origin" $SEND_MESSAGE \ --lane $MESSAGE_LANE \ + --conversion-rate-override metric \ --origin Target \ transfer \ --amount 1000000000 \ @@ -69,6 +68,7 @@ do echo "Sending Remark from Rialto to Millau using Source Origin" $SEND_MESSAGE \ --lane $MESSAGE_LANE \ + --conversion-rate-override metric \ --origin Source \ remark @@ -76,6 +76,7 @@ do echo "Sending Transfer from Rialto to Millau using Source Origin" $SEND_MESSAGE \ --lane $MESSAGE_LANE \ + --conversion-rate-override metric \ --origin Source \ transfer \ --amount 1000000000 \ @@ -89,6 +90,7 @@ do echo "Sending Maximal Size Remark from Rialto to Millau using Target Origin" $SEND_MESSAGE \ --lane $MESSAGE_LANE \ + --conversion-rate-override metric \ --origin Target \ remark \ --remark-size=max @@ -97,6 +99,7 @@ do echo "Sending Maximal Dispatch Weight Remark from Rialto to Millau using Target Origin" $SEND_MESSAGE \ --lane $MESSAGE_LANE \ + --conversion-rate-override metric \ --origin Target \ --dispatch-weight=max \ remark @@ -105,6 +108,7 @@ do echo "Sending Maximal Size and Dispatch Weight Remark from Rialto to Millau using Target Origin" $SEND_MESSAGE \ --lane $MESSAGE_LANE \ + --conversion-rate-override metric \ --origin Target \ --dispatch-weight=max \ remark \ @@ -116,10 +120,21 @@ do if [ $SECONDS -ge $BUNCH_OF_MESSAGES_TIME ]; then BUNCH_OF_MESSAGES_TIME=$((SECONDS + 7200)) + SEND_MESSAGE_OUTPUT=`$SEND_MESSAGE --lane $MESSAGE_LANE --conversion-rate-override metric --origin Target remark 2>&1` + echo $SEND_MESSAGE_OUTPUT + ACTUAL_CONVERSION_RATE_REGEX="conversion rate override: ([0-9\.]+)" + if [[ $SEND_MESSAGE_OUTPUT =~ $ACTUAL_CONVERSION_RATE_REGEX ]]; then + ACTUAL_CONVERSION_RATE=${BASH_REMATCH[1]} + else + echo "Unable to find conversion rate in send-message output" + exit 1 + fi + for i in $(seq 1 $MAX_UNCONFIRMED_MESSAGES_AT_INBOUND_LANE); do $SEND_MESSAGE \ --lane $MESSAGE_LANE \ + --conversion-rate-override $ACTUAL_CONVERSION_RATE \ --origin Target \ remark done diff --git a/deployments/bridges/rialto-millau/entrypoints/relay-messages-to-rialto-generator-entrypoint.sh b/deployments/bridges/rialto-millau/entrypoints/relay-messages-to-rialto-generator-entrypoint.sh index ed733411f33..a8e032bbdfd 100755 --- a/deployments/bridges/rialto-millau/entrypoints/relay-messages-to-rialto-generator-entrypoint.sh +++ b/deployments/bridges/rialto-millau/entrypoints/relay-messages-to-rialto-generator-entrypoint.sh @@ -34,16 +34,13 @@ LARGE_MESSAGES_TIME=0 # start sending message packs in a hour BUNCH_OF_MESSAGES_TIME=3600 -# give conversion rate updater some time to update Rialto->Millau conversion rate in Millau -# (initially rate=1 and rational relayer won't deliver any messages if it'll be changed to larger value) -sleep 120 - while true do rand_sleep echo "Sending Remark from Millau to Rialto using Target Origin" $SEND_MESSAGE \ --lane $MESSAGE_LANE \ + --conversion-rate-override metric \ --origin Target \ remark @@ -51,6 +48,7 @@ do echo "Sending Remark from Millau to Rialto using Target Origin using secondary lane: $SECONDARY_MESSAGE_LANE" $SEND_MESSAGE \ --lane $SECONDARY_MESSAGE_LANE \ + --conversion-rate-override metric \ --origin Target \ --dispatch-fee-payment at-target-chain \ remark @@ -60,6 +58,7 @@ do echo "Sending Transfer from Millau to Rialto using Target Origin" $SEND_MESSAGE \ --lane $MESSAGE_LANE \ + --conversion-rate-override metric \ --origin Target \ transfer \ --amount 1000000000 \ @@ -69,6 +68,7 @@ do echo "Sending Remark from Millau to Rialto using Source Origin" $SEND_MESSAGE \ --lane $MESSAGE_LANE \ + --conversion-rate-override metric \ --origin Source \ remark @@ -76,6 +76,7 @@ do echo "Sending Transfer from Millau to Rialto using Source Origin" $SEND_MESSAGE \ --lane $MESSAGE_LANE \ + --conversion-rate-override metric \ --origin Source \ transfer \ --amount 1000000000 \ @@ -89,6 +90,7 @@ do echo "Sending Maximal Size Remark from Millau to Rialto using Target Origin" $SEND_MESSAGE \ --lane $MESSAGE_LANE \ + --conversion-rate-override metric \ --origin Target \ remark \ --remark-size=max @@ -97,6 +99,7 @@ do echo "Sending Maximal Dispatch Weight Remark from Millau to Rialto using Target Origin" $SEND_MESSAGE \ --lane $MESSAGE_LANE \ + --conversion-rate-override metric \ --origin Target \ --dispatch-weight=max \ remark @@ -105,6 +108,7 @@ do echo "Sending Maximal Size and Dispatch Weight Remark from Millau to Rialto using Target Origin" $SEND_MESSAGE \ --lane $MESSAGE_LANE \ + --conversion-rate-override metric \ --origin Target \ --dispatch-weight=max \ remark \ @@ -116,10 +120,21 @@ do if [ $SECONDS -ge $BUNCH_OF_MESSAGES_TIME ]; then BUNCH_OF_MESSAGES_TIME=$((SECONDS + 7200)) - for i in $(seq 1 $MAX_UNCONFIRMED_MESSAGES_AT_INBOUND_LANE); + SEND_MESSAGE_OUTPUT=`$SEND_MESSAGE --lane $MESSAGE_LANE --conversion-rate-override metric --origin Target remark 2>&1` + echo $SEND_MESSAGE_OUTPUT + ACTUAL_CONVERSION_RATE_REGEX="conversion rate override: ([0-9\.]+)" + if [[ $SEND_MESSAGE_OUTPUT =~ $ACTUAL_CONVERSION_RATE_REGEX ]]; then + ACTUAL_CONVERSION_RATE=${BASH_REMATCH[1]} + else + echo "Unable to find conversion rate in send-message output" + exit 1 + fi + + for i in $(seq 2 $MAX_UNCONFIRMED_MESSAGES_AT_INBOUND_LANE); do $SEND_MESSAGE \ --lane $MESSAGE_LANE \ + --conversion-rate-override $ACTUAL_CONVERSION_RATE \ --origin Target \ remark done diff --git a/deployments/bridges/rialto-millau/entrypoints/relay-token-swap-generator-entrypoint.sh b/deployments/bridges/rialto-millau/entrypoints/relay-token-swap-generator-entrypoint.sh index b773d61595d..010c0572d50 100755 --- a/deployments/bridges/rialto-millau/entrypoints/relay-token-swap-generator-entrypoint.sh +++ b/deployments/bridges/rialto-millau/entrypoints/relay-token-swap-generator-entrypoint.sh @@ -23,10 +23,6 @@ rand_sleep() { echo "Woke up at $NOW" } -# give conversion rate updater some time to update Rialto->Millau conversion rate in Millau -# (initially rate=1 and rational relayer won't deliver any messages if it'll be changed to larger value) -sleep 120 - while true do rand_sleep @@ -42,6 +38,8 @@ do --target-port $TARGET_PORT \ --target-signer //WithMillauTokenSwap \ --target-balance 200000 \ + --target-to-source-conversion-rate-override metric \ + --source-to-target-conversion-rate-override metric \ lock-until-block \ --blocks-before-expire 32 done diff --git a/deployments/bridges/westend-millau/dashboard/grafana/relay-westend-to-millau-headers-dashboard.json b/deployments/bridges/westend-millau/dashboard/grafana/relay-westend-to-millau-headers-dashboard.json index 1a3603512fd..682ac2c7786 100644 --- a/deployments/bridges/westend-millau/dashboard/grafana/relay-westend-to-millau-headers-dashboard.json +++ b/deployments/bridges/westend-millau/dashboard/grafana/relay-westend-to-millau-headers-dashboard.json @@ -99,7 +99,7 @@ "steppedLine": false, "targets": [ { - "expr": "max(Westend_to_Millau_Sync_best_block_numbers{node=\"source\"}) - max(Westend_to_Millau_Sync_best_block_numbers{node=\"target\"})", + "expr": "max(Westend_to_Millau_Sync_best_source_block_number) - max(Westend_to_Millau_Sync_best_source_at_target_block_number)", "format": "table", "instant": false, "interval": "", @@ -237,7 +237,7 @@ "steppedLine": false, "targets": [ { - "expr": "max_over_time(Westend_to_Millau_Sync_best_block_numbers{node=\"source\"}[10m])-min_over_time(Westend_to_Millau_Sync_best_block_numbers{node=\"source\"}[10m])", + "expr": "max_over_time(Westend_to_Millau_Sync_best_source_block_number[10m])-min_over_time(Westend_to_Millau_Sync_best_source_block_number[10m])", "interval": "", "legendFormat": "Number of new Headers on Westend (Last 10 Mins)", "refId": "A" @@ -341,13 +341,22 @@ "pluginVersion": "7.1.3", "targets": [ { - "expr": "Westend_to_Millau_Sync_best_block_numbers", + "expr": "Westend_to_Millau_Sync_best_source_block_number", "format": "time_series", "instant": true, "interval": "", "intervalFactor": 1, - "legendFormat": "Best Known Header on {{node}} Node", + "legendFormat": "Best Known Westend Header at Westend", "refId": "A" + }, + { + "expr": "Westend_to_Millau_Sync_best_source_at_target_block_number", + "format": "time_series", + "instant": true, + "interval": "", + "intervalFactor": 1, + "legendFormat": "Best Known Westend Header at Millau", + "refId": "B" } ], "timeFrom": null, @@ -513,61 +522,139 @@ "type": "gauge" }, { + "alert": { + "alertRuleTags": {}, + "conditions": [ + { + "evaluator": { + "params": [ + 0 + ], + "type": "gt" + }, + "operator": { + "type": "and" + }, + "query": { + "params": [ + "A", + "5m", + "now" + ] + }, + "reducer": { + "params": [], + "type": "max" + }, + "type": "query" + } + ], + "executionErrorState": "alerting", + "for": "5m", + "frequency": "1m", + "handler": 1, + "name": "Whether with-Westend-grandpa-pallet and Westend itself are on different forks alert", + "noDataState": "no_data", + "notifications": [] + }, + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, "datasource": "Prometheus", - "description": "", "fieldConfig": { "defaults": { - "custom": {}, - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - }, - { - "color": "red", - "value": 80 - } - ] - } + "custom": {} }, "overrides": [] }, + "fill": 1, + "fillGradient": 0, "gridPos": { "h": 10, "w": 12, "x": 0, "y": 14 }, - "id": 4, - "options": { - "displayMode": "gradient", - "orientation": "auto", - "reduceOptions": { - "calcs": [ - "mean" - ], - "fields": "", - "values": false - }, - "showUnfilled": true + "hiddenSeries": false, + "id": 18, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": false }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null", + "percentage": false, "pluginVersion": "7.1.3", + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, "targets": [ { - "expr": "Westend_to_Millau_Sync_blocks_in_state", - "instant": true, + "expr": "Westend_to_Millau_Sync_is_source_and_source_at_target_using_different_forks", "interval": "", - "legendFormat": "{{state}}", + "legendFormat": "On different forks?", "refId": "A" } ], + "thresholds": [ + { + "colorMode": "critical", + "fill": true, + "line": true, + "op": "gt", + "value": 0 + } + ], "timeFrom": null, + "timeRegions": [], "timeShift": null, - "title": "Queued Headers in Relay", - "type": "bargauge" + "title": "Whether with-Westend-grandpa-pallet and Westend itself are on different forks", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } }, { "aliasColors": {}, diff --git a/deployments/monitoring/GrafanaMatrix.Dockerfile b/deployments/monitoring/GrafanaMatrix.Dockerfile index 420e134716a..df80f700215 100644 --- a/deployments/monitoring/GrafanaMatrix.Dockerfile +++ b/deployments/monitoring/GrafanaMatrix.Dockerfile @@ -1,4 +1,4 @@ -FROM ruby:alpine +FROM docker.io/library/ruby:alpine RUN apk add --no-cache git diff --git a/fuzz/storage-proof/Cargo.toml b/fuzz/storage-proof/Cargo.toml index 2ab1d451b07..b406054bc6e 100644 --- a/fuzz/storage-proof/Cargo.toml +++ b/fuzz/storage-proof/Cargo.toml @@ -2,7 +2,7 @@ name = "storage-proof-fuzzer" version = "0.1.0" authors = ["Parity Technologies "] -edition = "2018" +edition = "2021" license = "GPL-3.0-or-later WITH Classpath-exception-2.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/fuzz/storage-proof/src/main.rs b/fuzz/storage-proof/src/main.rs index 3495e00999a..185d0e336c4 100644 --- a/fuzz/storage-proof/src/main.rs +++ b/fuzz/storage-proof/src/main.rs @@ -37,8 +37,7 @@ fn craft_known_storage_proof(input_vec: Vec<(Vec, Vec)>) -> (H256, Stora let vector_element_proof = StorageProof::new( prove_read(backend, input_vec.iter().map(|x| x.0.as_slice())) .unwrap() - .iter_nodes() - .collect(), + .iter_nodes(), ); (root, vector_element_proof) } diff --git a/modules/dispatch/Cargo.toml b/modules/dispatch/Cargo.toml index 7a8a34ab4c0..833d5cca77a 100644 --- a/modules/dispatch/Cargo.toml +++ b/modules/dispatch/Cargo.toml @@ -3,13 +3,13 @@ name = "pallet-bridge-dispatch" description = "A Substrate Runtime module that dispatches a bridge message, treating it simply as encoded Call" version = "0.1.0" authors = ["Parity Technologies "] -edition = "2018" +edition = "2021" license = "GPL-3.0-or-later WITH Classpath-exception-2.0" [dependencies] -codec = { package = "parity-scale-codec", version = "2.2.0", default-features = false } +codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false } log = { version = "0.4.14", default-features = false } -scale-info = { version = "1.0", default-features = false, features = ["derive"] } +scale-info = { version = "2.0.1", default-features = false, features = ["derive"] } # Bridge dependencies diff --git a/modules/grandpa/Cargo.toml b/modules/grandpa/Cargo.toml index e36b43585b9..eac80375da1 100644 --- a/modules/grandpa/Cargo.toml +++ b/modules/grandpa/Cargo.toml @@ -2,17 +2,17 @@ name = "pallet-bridge-grandpa" version = "0.1.0" authors = ["Parity Technologies "] -edition = "2018" +edition = "2021" license = "GPL-3.0-or-later WITH Classpath-exception-2.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -codec = { package = "parity-scale-codec", version = "2.2.0", default-features = false } -finality-grandpa = { version = "0.14.0", default-features = false } +codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false } +finality-grandpa = { version = "0.15.0", default-features = false } log = { version = "0.4.14", default-features = false } num-traits = { version = "0.2", default-features = false } -scale-info = { version = "1.0", default-features = false, features = ["derive"] } +scale-info = { version = "2.0.1", default-features = false, features = ["derive"] } serde = { version = "1.0", optional = true } # Bridge Dependencies @@ -58,5 +58,5 @@ std = [ ] runtime-benchmarks = [ "bp-test-utils", - "frame-benchmarking", + "frame-benchmarking/runtime-benchmarks", ] diff --git a/modules/grandpa/src/lib.rs b/modules/grandpa/src/lib.rs index a8267e65eb3..947bfdc7f63 100644 --- a/modules/grandpa/src/lib.rs +++ b/modules/grandpa/src/lib.rs @@ -300,7 +300,7 @@ pub mod pallet { /// runtime methods may still be used to do that (i.e. democracy::referendum to update halt /// flag directly or call the `halt_operations`). #[pallet::storage] - pub(super) type PalletOwner, I: 'static = ()> = + pub type PalletOwner, I: 'static = ()> = StorageValue<_, T::AccountId, OptionQuery>; /// If true, all pallet transactions are failed immediately. diff --git a/modules/messages/Cargo.toml b/modules/messages/Cargo.toml index 47fb4323bc1..804f323f10b 100644 --- a/modules/messages/Cargo.toml +++ b/modules/messages/Cargo.toml @@ -3,15 +3,15 @@ name = "pallet-bridge-messages" description = "Module that allows bridged chains to exchange messages using lane concept." version = "0.1.0" authors = ["Parity Technologies "] -edition = "2018" +edition = "2021" license = "GPL-3.0-or-later WITH Classpath-exception-2.0" [dependencies] -bitvec = { version = "0.20", default-features = false, features = ["alloc"] } -codec = { package = "parity-scale-codec", version = "2.2.0", default-features = false } +bitvec = { version = "1", default-features = false, features = ["alloc"] } +codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false } log = { version = "0.4.14", default-features = false } num-traits = { version = "0.2", default-features = false } -scale-info = { version = "1.0", default-features = false, features = ["derive"] } +scale-info = { version = "2.0.1", default-features = false, features = ["derive"] } serde = { version = "1.0.101", optional = true, features = ["derive"] } # Bridge dependencies @@ -51,5 +51,5 @@ std = [ "sp-std/std", ] runtime-benchmarks = [ - "frame-benchmarking", + "frame-benchmarking/runtime-benchmarks", ] diff --git a/modules/messages/src/benchmarking.rs b/modules/messages/src/benchmarking.rs index 288ef4b2e81..46a8150d034 100644 --- a/modules/messages/src/benchmarking.rs +++ b/modules/messages/src/benchmarking.rs @@ -32,9 +32,6 @@ use frame_support::{traits::Get, weights::Weight}; use frame_system::RawOrigin; use sp_std::{collections::vec_deque::VecDeque, convert::TryInto, ops::RangeInclusive, prelude::*}; -/// Fee paid by submitter for single message delivery. -pub const MESSAGE_FEE: u64 = 100_000_000_000; - const SEED: u32 = 0; /// Pallet we're benchmarking here. @@ -103,6 +100,10 @@ pub trait Config: crate::Config { fn account_balance(account: &Self::AccountId) -> Self::OutboundMessageFee; /// Create given account and give it enough balance for test purposes. fn endow_account(account: &Self::AccountId); + /// Fee paid by submitter for single message delivery. + fn message_fee() -> Self::OutboundMessageFee { + 100_000_000_000_000.into() + } /// Prepare message to send over lane. fn prepare_outbound_message( params: MessageParams, @@ -138,8 +139,10 @@ benchmarks_instance_pallet! { // added. send_minimal_message_worst_case { let lane_id = T::bench_lane_id(); + let relayers_fund_id = crate::relayer_fund_account_id::(); let sender = account("sender", 0, SEED); T::endow_account(&sender); + T::endow_account(&relayers_fund_id); // 'send' messages that are to be pruned when our message is sent for _nonce in 1..=T::MaxMessagesToPruneAtOnce::get() { @@ -169,8 +172,10 @@ benchmarks_instance_pallet! { // `(send_16_kb_message_worst_case - send_1_kb_message_worst_case) / 15`. send_1_kb_message_worst_case { let lane_id = T::bench_lane_id(); + let relayers_fund_id = crate::relayer_fund_account_id::(); let sender = account("sender", 0, SEED); T::endow_account(&sender); + T::endow_account(&relayers_fund_id); // 'send' messages that are to be pruned when our message is sent for _nonce in 1..=T::MaxMessagesToPruneAtOnce::get() { @@ -206,8 +211,10 @@ benchmarks_instance_pallet! { // `(send_16_kb_message_worst_case - send_1_kb_message_worst_case) / 15`. send_16_kb_message_worst_case { let lane_id = T::bench_lane_id(); + let relayers_fund_id = crate::relayer_fund_account_id::(); let sender = account("sender", 0, SEED); T::endow_account(&sender); + T::endow_account(&relayers_fund_id); // 'send' messages that are to be pruned when our message is sent for _nonce in 1..=T::MaxMessagesToPruneAtOnce::get() { @@ -239,8 +246,10 @@ benchmarks_instance_pallet! { // // Result of this benchmark is directly used by weight formula of the call. maximal_increase_message_fee { + let relayers_fund_id = crate::relayer_fund_account_id::(); let sender = account("sender", 42, SEED); T::endow_account(&sender); + T::endow_account(&relayers_fund_id); let additional_fee = T::account_balance(&sender); let lane_id = T::bench_lane_id(); @@ -258,8 +267,10 @@ benchmarks_instance_pallet! { increase_message_fee { let i in 0..T::maximal_message_size().try_into().unwrap_or_default(); + let relayers_fund_id = crate::relayer_fund_account_id::(); let sender = account("sender", 42, SEED); T::endow_account(&sender); + T::endow_account(&relayers_fund_id); let additional_fee = T::account_balance(&sender); let lane_id = T::bench_lane_id(); @@ -282,6 +293,7 @@ benchmarks_instance_pallet! { receive_single_message_proof { let relayer_id_on_source = T::bridged_relayer_id(); let relayer_id_on_target = account("relayer", 0, SEED); + T::endow_account(&relayer_id_on_target); // mark messages 1..=20 as delivered receive_messages::(20); @@ -316,6 +328,7 @@ benchmarks_instance_pallet! { receive_two_messages_proof { let relayer_id_on_source = T::bridged_relayer_id(); let relayer_id_on_target = account("relayer", 0, SEED); + T::endow_account(&relayer_id_on_target); // mark messages 1..=20 as delivered receive_messages::(20); @@ -350,6 +363,7 @@ benchmarks_instance_pallet! { receive_single_message_proof_with_outbound_lane_state { let relayer_id_on_source = T::bridged_relayer_id(); let relayer_id_on_target = account("relayer", 0, SEED); + T::endow_account(&relayer_id_on_target); // mark messages 1..=20 as delivered receive_messages::(20); @@ -385,6 +399,7 @@ benchmarks_instance_pallet! { receive_single_message_proof_1_kb { let relayer_id_on_source = T::bridged_relayer_id(); let relayer_id_on_target = account("relayer", 0, SEED); + T::endow_account(&relayer_id_on_target); // mark messages 1..=20 as delivered receive_messages::(20); @@ -419,6 +434,7 @@ benchmarks_instance_pallet! { receive_single_message_proof_16_kb { let relayer_id_on_source = T::bridged_relayer_id(); let relayer_id_on_target = account("relayer", 0, SEED); + T::endow_account(&relayer_id_on_target); // mark messages 1..=20 as delivered receive_messages::(20); @@ -452,6 +468,7 @@ benchmarks_instance_pallet! { receive_single_prepaid_message_proof { let relayer_id_on_source = T::bridged_relayer_id(); let relayer_id_on_target = account("relayer", 0, SEED); + T::endow_account(&relayer_id_on_target); // mark messages 1..=20 as delivered receive_messages::(20); @@ -506,7 +523,7 @@ benchmarks_instance_pallet! { verify { assert_eq!( T::account_balance(&relayer_id), - relayer_balance + MESSAGE_FEE.into(), + relayer_balance + T::message_fee(), ); } @@ -600,12 +617,12 @@ benchmarks_instance_pallet! { fn send_regular_message, I: 'static>() { let mut outbound_lane = outbound_lane::(T::bench_lane_id()); - outbound_lane.send_message(MessageData { payload: vec![], fee: MESSAGE_FEE.into() }); + outbound_lane.send_message(MessageData { payload: vec![], fee: T::message_fee() }); } fn send_regular_message_with_payload, I: 'static>(payload: Vec) { let mut outbound_lane = outbound_lane::(T::bench_lane_id()); - outbound_lane.send_message(MessageData { payload, fee: MESSAGE_FEE.into() }); + outbound_lane.send_message(MessageData { payload, fee: T::message_fee() }); } fn confirm_message_delivery, I: 'static>(nonce: MessageNonce) { diff --git a/modules/messages/src/instant_payments.rs b/modules/messages/src/instant_payments.rs index d67b82ade8d..2a620a95222 100644 --- a/modules/messages/src/instant_payments.rs +++ b/modules/messages/src/instant_payments.rs @@ -22,7 +22,7 @@ use crate::OutboundMessages; use bp_messages::{ - source_chain::{MessageDeliveryAndDispatchPayment, RelayersRewards, Sender}, + source_chain::{MessageDeliveryAndDispatchPayment, RelayersRewards, SenderOrigin}, LaneId, MessageKey, MessageNonce, UnrewardedRelayer, }; use codec::Encode; @@ -31,6 +31,10 @@ use num_traits::{SaturatingAdd, Zero}; use sp_runtime::traits::Saturating; use sp_std::{collections::vec_deque::VecDeque, fmt::Debug, ops::RangeInclusive}; +/// Error that occurs when message fee is non-zero, but payer is not defined. +const NON_ZERO_MESSAGE_FEE_CANT_BE_PAID_BY_NONE: &str = + "Non-zero message fee can't be paid by "; + /// Instant message payments made in given currency. /// /// The balance is initially reserved in a special `relayers-fund` account, and transferred @@ -44,42 +48,50 @@ use sp_std::{collections::vec_deque::VecDeque, fmt::Debug, ops::RangeInclusive}; /// to the relayer account. /// NOTE It's within relayer's interest to keep their balance above ED as well, to make sure they /// can receive the payment. -pub struct InstantCurrencyPayments { - _phantom: sp_std::marker::PhantomData<(T, I, Currency, GetConfirmationFee, RootAccount)>, +pub struct InstantCurrencyPayments { + _phantom: sp_std::marker::PhantomData<(T, I, Currency, GetConfirmationFee)>, } -impl - MessageDeliveryAndDispatchPayment - for InstantCurrencyPayments +impl + MessageDeliveryAndDispatchPayment + for InstantCurrencyPayments where T: frame_system::Config + crate::Config, I: 'static, + T::Origin: SenderOrigin, Currency: CurrencyT, Currency::Balance: From, GetConfirmationFee: Get, - RootAccount: Get>, { type Error = &'static str; fn pay_delivery_and_dispatch_fee( - submitter: &Sender, + submitter: &T::Origin, fee: &Currency::Balance, relayer_fund_account: &T::AccountId, ) -> Result<(), Self::Error> { + let submitter_account = match submitter.linked_account() { + Some(submitter_account) => submitter_account, + None if !fee.is_zero() => { + // if we'll accept some message that has declared that the `fee` has been paid but + // it isn't actually paid, then it'll lead to problems with delivery confirmation + // payments (see `pay_relayer_rewards` && `confirmation_relayer` in particular) + return Err(NON_ZERO_MESSAGE_FEE_CANT_BE_PAID_BY_NONE) + }, + None => { + // message lane verifier has accepted the message before, so this message + // is unpaid **by design** + // => let's just do nothing + return Ok(()) + }, + }; + if !frame_system::Pallet::::account_exists(relayer_fund_account) { return Err("The relayer fund account must exist for the message lanes pallet to work correctly."); } - let root_account = RootAccount::get(); - let account = match submitter { - Sender::Signed(submitter) => submitter, - Sender::Root | Sender::None => root_account - .as_ref() - .ok_or("Sending messages using Root or None origin is disallowed.")?, - }; - Currency::transfer( - account, + &submitter_account, relayer_fund_account, *fee, // it's fine for the submitter to go below Existential Deposit and die. @@ -226,7 +238,9 @@ fn pay_relayer_reward( #[cfg(test)] mod tests { use super::*; - use crate::mock::{run_test, AccountId as TestAccountId, Balance as TestBalance, TestRuntime}; + use crate::mock::{ + run_test, AccountId as TestAccountId, Balance as TestBalance, Origin, TestRuntime, + }; use bp_messages::source_chain::RelayerRewards; type Balances = pallet_balances::Pallet; @@ -245,6 +259,48 @@ mod tests { .collect() } + #[test] + fn pay_delivery_and_dispatch_fee_fails_on_non_zero_fee_and_unknown_payer() { + frame_support::parameter_types! { + const GetConfirmationFee: TestBalance = 0; + }; + + run_test(|| { + let result = InstantCurrencyPayments::< + TestRuntime, + (), + Balances, + GetConfirmationFee, + >::pay_delivery_and_dispatch_fee( + &Origin::root(), + &100, + &RELAYERS_FUND_ACCOUNT, + ); + assert_eq!(result, Err(NON_ZERO_MESSAGE_FEE_CANT_BE_PAID_BY_NONE)); + }); + } + + #[test] + fn pay_delivery_and_dispatch_succeeds_on_zero_fee_and_unknown_payer() { + frame_support::parameter_types! { + const GetConfirmationFee: TestBalance = 0; + }; + + run_test(|| { + let result = InstantCurrencyPayments::< + TestRuntime, + (), + Balances, + GetConfirmationFee, + >::pay_delivery_and_dispatch_fee( + &Origin::root(), + &0, + &RELAYERS_FUND_ACCOUNT, + ); + assert!(result.is_ok()); + }); + } + #[test] fn confirmation_relayer_is_rewarded_if_it_has_also_delivered_messages() { run_test(|| { diff --git a/modules/messages/src/lib.rs b/modules/messages/src/lib.rs index f37dc88481e..a344cedae24 100644 --- a/modules/messages/src/lib.rs +++ b/modules/messages/src/lib.rs @@ -170,12 +170,14 @@ pub mod pallet { type TargetHeaderChain: TargetHeaderChain; /// Message payload verifier. type LaneMessageVerifier: LaneMessageVerifier< + Self::Origin, Self::AccountId, Self::OutboundPayload, Self::OutboundMessageFee, >; /// Message delivery payment. type MessageDeliveryAndDispatchPayment: MessageDeliveryAndDispatchPayment< + Self::Origin, Self::AccountId, Self::OutboundMessageFee, >; @@ -276,16 +278,12 @@ pub mod pallet { payload: T::OutboundPayload, delivery_and_dispatch_fee: T::OutboundMessageFee, ) -> DispatchResultWithPostInfo { - crate::send_message::( - origin.into().map_err(|_| BadOrigin)?, - lane_id, - payload, - delivery_and_dispatch_fee, + crate::send_message::(origin, lane_id, payload, delivery_and_dispatch_fee).map( + |sent_message| PostDispatchInfo { + actual_weight: Some(sent_message.weight), + pays_fee: Pays::Yes, + }, ) - .map(|sent_message| PostDispatchInfo { - actual_weight: Some(sent_message.weight), - pays_fee: Pays::Yes, - }) } /// Pay additional fee for the message. @@ -313,17 +311,15 @@ pub mod pallet { ); // withdraw additional fee from submitter - let submitter = origin.into().map_err(|_| BadOrigin)?; T::MessageDeliveryAndDispatchPayment::pay_delivery_and_dispatch_fee( - &submitter, + &origin, &additional_fee, &relayer_fund_account_id::(), ) .map_err(|err| { log::trace!( target: "runtime::bridge-messages", - "Submitter {:?} can't pay additional fee {:?} for the message {:?}/{:?} to {:?}: {:?}", - submitter, + "Submitter can't pay additional fee {:?} for the message {:?}/{:?} to {:?}: {:?}", additional_fee, lane_id, nonce, @@ -764,21 +760,6 @@ pub mod pallet { ) -> Option> { OutboundMessages::::get(MessageKey { lane_id: lane, nonce }) } - - /// Get state of unrewarded relayers set. - pub fn inbound_unrewarded_relayers_state( - lane: bp_messages::LaneId, - ) -> bp_messages::UnrewardedRelayersState { - let relayers = InboundLanes::::get(&lane).relayers; - bp_messages::UnrewardedRelayersState { - unrewarded_relayer_entries: relayers.len() as _, - messages_in_oldest_entry: relayers - .front() - .map(|entry| 1 + entry.messages.end - entry.messages.begin) - .unwrap_or(0), - total_messages: total_unrewarded_messages(&relayers).unwrap_or(MessageNonce::MAX), - } - } } } @@ -795,6 +776,7 @@ pub fn relayer_fund_account_id bp_messages::source_chain::MessagesBridge< + T::Origin, T::AccountId, T::OutboundMessageFee, T::OutboundPayload, @@ -806,7 +788,7 @@ where type Error = sp_runtime::DispatchErrorWithPostInfo; fn send_message( - sender: bp_messages::source_chain::Sender, + sender: T::Origin, lane: LaneId, message: T::OutboundPayload, delivery_and_dispatch_fee: T::OutboundMessageFee, @@ -817,7 +799,7 @@ where /// Function that actually sends message. fn send_message, I: 'static>( - submitter: bp_messages::source_chain::Sender, + submitter: T::Origin, lane_id: LaneId, payload: T::OutboundPayload, delivery_and_dispatch_fee: T::OutboundMessageFee, @@ -871,9 +853,8 @@ fn send_message, I: 'static>( .map_err(|err| { log::trace!( target: "runtime::bridge-messages", - "Message to lane {:?} is rejected because submitter {:?} is unable to pay fee {:?}: {:?}", + "Message to lane {:?} is rejected because submitter is unable to pay fee {:?}: {:?}", lane_id, - submitter, delivery_and_dispatch_fee, err, ); @@ -1127,6 +1108,20 @@ mod tests { System::::reset_events(); } + fn inbound_unrewarded_relayers_state( + lane: bp_messages::LaneId, + ) -> bp_messages::UnrewardedRelayersState { + let relayers = InboundLanes::::get(&lane).relayers; + bp_messages::UnrewardedRelayersState { + unrewarded_relayer_entries: relayers.len() as _, + messages_in_oldest_entry: relayers + .front() + .map(|entry| 1 + entry.messages.end - entry.messages.begin) + .unwrap_or(0), + total_messages: total_unrewarded_messages(&relayers).unwrap_or(MessageNonce::MAX), + } + } + fn send_regular_message() -> Weight { get_ready_for_events(); @@ -1571,7 +1566,7 @@ mod tests { }, ); assert_eq!( - Pallet::::inbound_unrewarded_relayers_state(TEST_LANE_ID), + inbound_unrewarded_relayers_state(TEST_LANE_ID), UnrewardedRelayersState { unrewarded_relayer_entries: 2, messages_in_oldest_entry: 1, @@ -1606,7 +1601,7 @@ mod tests { }, ); assert_eq!( - Pallet::::inbound_unrewarded_relayers_state(TEST_LANE_ID), + inbound_unrewarded_relayers_state(TEST_LANE_ID), UnrewardedRelayersState { unrewarded_relayer_entries: 2, messages_in_oldest_entry: 1, diff --git a/modules/messages/src/mock.rs b/modules/messages/src/mock.rs index ef508147227..75dcce8df04 100644 --- a/modules/messages/src/mock.rs +++ b/modules/messages/src/mock.rs @@ -23,7 +23,7 @@ use bitvec::prelude::*; use bp_messages::{ source_chain::{ LaneMessageVerifier, MessageDeliveryAndDispatchPayment, OnDeliveryConfirmed, - OnMessageAccepted, Sender, TargetHeaderChain, + OnMessageAccepted, SenderOrigin, TargetHeaderChain, }, target_chain::{ DispatchMessage, MessageDispatch, ProvedLaneMessages, ProvedMessages, SourceHeaderChain, @@ -194,6 +194,16 @@ impl Config for TestRuntime { type BridgedChainId = TestBridgedChainId; } +impl SenderOrigin for Origin { + fn linked_account(&self) -> Option { + match self.caller { + OriginCaller::system(frame_system::RawOrigin::Signed(ref submitter)) => + Some(submitter.clone()), + _ => None, + } + } +} + impl Size for TestPayload { fn size_hint(&self) -> u32 { 16 + self.extra.len() as u32 @@ -294,11 +304,13 @@ impl TargetHeaderChain for TestTargetHeaderChain { #[derive(Debug, Default)] pub struct TestLaneMessageVerifier; -impl LaneMessageVerifier for TestLaneMessageVerifier { +impl LaneMessageVerifier + for TestLaneMessageVerifier +{ type Error = &'static str; fn verify_message( - _submitter: &Sender, + _submitter: &Origin, delivery_and_dispatch_fee: &TestMessageFee, _lane: &LaneId, _lane_outbound_data: &OutboundLaneData, @@ -324,8 +336,8 @@ impl TestMessageDeliveryAndDispatchPayment { /// Returns true if given fee has been paid by given submitter. pub fn is_fee_paid(submitter: AccountId, fee: TestMessageFee) -> bool { - frame_support::storage::unhashed::get(b":message-fee:") == - Some((Sender::Signed(submitter), fee)) + let raw_origin: Result, _> = Origin::signed(submitter).into(); + frame_support::storage::unhashed::get(b":message-fee:") == Some((raw_origin.unwrap(), fee)) } /// Returns true if given relayer has been rewarded with given balance. The reward-paid flag is @@ -336,13 +348,13 @@ impl TestMessageDeliveryAndDispatchPayment { } } -impl MessageDeliveryAndDispatchPayment +impl MessageDeliveryAndDispatchPayment for TestMessageDeliveryAndDispatchPayment { type Error = &'static str; fn pay_delivery_and_dispatch_fee( - submitter: &Sender, + submitter: &Origin, fee: &TestMessageFee, _relayer_fund_account: &AccountId, ) -> Result<(), Self::Error> { @@ -350,7 +362,8 @@ impl MessageDeliveryAndDispatchPayment return Err(TEST_ERROR) } - frame_support::storage::unhashed::put(b":message-fee:", &(submitter, fee)); + let raw_origin: Result, _> = submitter.clone().into(); + frame_support::storage::unhashed::put(b":message-fee:", &(raw_origin.unwrap(), fee)); Ok(()) } @@ -530,7 +543,7 @@ pub fn unrewarded_relayer( begin, end, dispatch_results: if end >= begin { - bitvec![Msb0, u8; 1; (end - begin + 1) as _] + bitvec![u8, Msb0; 1; (end - begin + 1) as _] } else { Default::default() }, diff --git a/modules/messages/src/outbound_lane.rs b/modules/messages/src/outbound_lane.rs index c05437596db..cfdc81acc31 100644 --- a/modules/messages/src/outbound_lane.rs +++ b/modules/messages/src/outbound_lane.rs @@ -260,7 +260,7 @@ mod tests { DeliveredMessages { begin: *nonces.start(), end: *nonces.end(), - dispatch_results: bitvec![Msb0, u8; 1; (nonces.end() - nonces.start() + 1) as _], + dispatch_results: bitvec![u8, Msb0; 1; (nonces.end() - nonces.start() + 1) as _], } } diff --git a/modules/shift-session-manager/Cargo.toml b/modules/shift-session-manager/Cargo.toml index 9e3e15fddf8..30a5618b115 100644 --- a/modules/shift-session-manager/Cargo.toml +++ b/modules/shift-session-manager/Cargo.toml @@ -3,12 +3,12 @@ name = "pallet-shift-session-manager" description = "A Substrate Runtime module that selects 2/3 of initial validators for every session" version = "0.1.0" authors = ["Parity Technologies "] -edition = "2018" +edition = "2021" license = "GPL-3.0-or-later WITH Classpath-exception-2.0" [dependencies] -codec = { package = "parity-scale-codec", version = "2.2.0", default-features = false } -scale-info = { version = "1.0", default-features = false, features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false } +scale-info = { version = "2.0.1", default-features = false, features = ["derive"] } # Substrate Dependencies diff --git a/modules/token-swap/Cargo.toml b/modules/token-swap/Cargo.toml index a6103f688c4..aad395fb7a3 100644 --- a/modules/token-swap/Cargo.toml +++ b/modules/token-swap/Cargo.toml @@ -3,13 +3,13 @@ name = "pallet-bridge-token-swap" description = "An Substrate pallet that allows parties on different chains (bridged using messages pallet) to swap their tokens" version = "0.1.0" authors = ["Parity Technologies "] -edition = "2018" +edition = "2021" license = "GPL-3.0-or-later WITH Classpath-exception-2.0" [dependencies] -codec = { package = "parity-scale-codec", version = "2.0.0", default-features = false } +codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false } log = { version = "0.4.14", default-features = false } -scale-info = { version = "1.0", default-features = false, features = ["derive"] } +scale-info = { version = "2.0.1", default-features = false, features = ["derive"] } serde = { version = "1.0", optional = true } # Bridge dependencies @@ -55,5 +55,5 @@ std = [ "sp-std/std", ] runtime-benchmarks = [ - "frame-benchmarking", + "frame-benchmarking/runtime-benchmarks", ] diff --git a/modules/token-swap/src/benchmarking.rs b/modules/token-swap/src/benchmarking.rs index c68fb6b6428..878cb20993a 100644 --- a/modules/token-swap/src/benchmarking.rs +++ b/modules/token-swap/src/benchmarking.rs @@ -18,7 +18,7 @@ use crate::{ swap_account_id, target_account_at_this_chain, BridgedAccountIdOf, BridgedAccountPublicOf, - BridgedAccountSignatureOf, BridgedBalanceOf, Call, Pallet, ThisChainBalance, + BridgedAccountSignatureOf, BridgedBalanceOf, Call, Origin, Pallet, ThisChainBalance, TokenSwapCreationOf, TokenSwapOf, }; @@ -43,6 +43,7 @@ pub trait Config: crate::Config { benchmarks_instance_pallet! { where_clause { where + Origin: Into, BridgedAccountPublicOf: Decode + Parameter, BridgedAccountSignatureOf: Decode, } diff --git a/modules/token-swap/src/lib.rs b/modules/token-swap/src/lib.rs index 32fd2db3c7c..e46a4bc2dd0 100644 --- a/modules/token-swap/src/lib.rs +++ b/modules/token-swap/src/lib.rs @@ -70,16 +70,18 @@ use bp_runtime::{messages::DispatchFeePayment, ChainId}; use bp_token_swap::{ RawBridgedTransferCall, TokenSwap, TokenSwapCreation, TokenSwapState, TokenSwapType, }; -use codec::Encode; +use codec::{Decode, Encode}; use frame_support::{ fail, traits::{Currency, ExistenceRequirement}, weights::PostDispatchInfo, + RuntimeDebug, }; +use scale_info::TypeInfo; use sp_core::H256; use sp_io::hashing::blake2_256; use sp_runtime::traits::{Convert, Saturating}; -use sp_std::boxed::Box; +use sp_std::{boxed::Box, marker::PhantomData}; use weights::WeightInfo; pub use weights_ext::WeightInfoExt; @@ -95,6 +97,24 @@ pub mod weights_ext; pub use pallet::*; +/// Name of the `PendingSwaps` storage map. +pub const PENDING_SWAPS_MAP_NAME: &str = "PendingSwaps"; + +/// Origin for the token swap pallet. +#[derive(PartialEq, Eq, Clone, RuntimeDebug, Encode, Decode, TypeInfo)] +pub enum RawOrigin { + /// The call is originated by the token swap account. + TokenSwap { + /// Id of the account that has started the swap. + source_account_at_this_chain: AccountId, + /// Id of the account that holds the funds during this swap. The message fee is paid from + /// this account funds. + swap_account_at_this_chain: AccountId, + }, + /// Dummy to manage the fact we have instancing. + _Phantom(PhantomData), +} + // comes from #[pallet::event] #[allow(clippy::unused_unit)] #[frame_support::pallet] @@ -123,6 +143,7 @@ pub mod pallet { type OutboundMessageLaneId: Get; /// Messages bridge with Bridged chain. type MessagesBridge: MessagesBridge< + Self::Origin, Self::AccountId, >::Balance, MessagePayloadOf, @@ -189,6 +210,7 @@ pub mod pallet { impl, I: 'static> Pallet where BridgedAccountPublicOf: Parameter, + Origin: Into, { /// Start token swap procedure. /// @@ -310,7 +332,11 @@ pub mod pallet { // `Currency::transfer` call on the bridged chain, but no checks are made - it is // the transaction submitter to ensure it is valid. let send_message_result = T::MessagesBridge::send_message( - bp_messages::source_chain::Sender::from(Some(swap_account.clone())), + RawOrigin::TokenSwap { + source_account_at_this_chain: swap.source_account_at_this_chain.clone(), + swap_account_at_this_chain: swap_account.clone(), + } + .into(), T::OutboundMessageLaneId::get(), bp_message_dispatch::MessagePayload { spec_version: bridged_chain_spec_version, @@ -513,6 +539,10 @@ pub mod pallet { InvalidClaimant, } + /// Origin for the token swap pallet. + #[pallet::origin] + pub type Origin = RawOrigin<::AccountId, I>; + /// Pending token swaps states. #[pallet::storage] pub type PendingSwaps, I: 'static = ()> = @@ -685,7 +715,7 @@ mod tests { fn start_test_swap() { assert_ok!(Pallet::::create_swap( - Origin::signed(THIS_CHAIN_ACCOUNT), + mock::Origin::signed(THIS_CHAIN_ACCOUNT), test_swap(), Box::new(TokenSwapCreation { target_public_at_bridged_chain: bridged_chain_account_public(), @@ -710,7 +740,7 @@ mod tests { run_test(|| { assert_noop!( Pallet::::create_swap( - Origin::signed(THIS_CHAIN_ACCOUNT + 1), + mock::Origin::signed(THIS_CHAIN_ACCOUNT + 1), test_swap(), Box::new(test_swap_creation()), ), @@ -726,7 +756,7 @@ mod tests { swap.source_balance_at_this_chain = ExistentialDeposit::get() - 1; assert_noop!( Pallet::::create_swap( - Origin::signed(THIS_CHAIN_ACCOUNT), + mock::Origin::signed(THIS_CHAIN_ACCOUNT), swap, Box::new(test_swap_creation()), ), @@ -742,7 +772,7 @@ mod tests { swap.source_balance_at_this_chain = THIS_CHAIN_ACCOUNT_BALANCE + 1; assert_noop!( Pallet::::create_swap( - Origin::signed(THIS_CHAIN_ACCOUNT), + mock::Origin::signed(THIS_CHAIN_ACCOUNT), swap, Box::new(test_swap_creation()), ), @@ -760,7 +790,7 @@ mod tests { swap_creation.bridged_currency_transfer = transfer; assert_noop!( Pallet::::create_swap( - Origin::signed(THIS_CHAIN_ACCOUNT), + mock::Origin::signed(THIS_CHAIN_ACCOUNT), test_swap(), Box::new(swap_creation), ), @@ -773,14 +803,14 @@ mod tests { fn create_swap_fails_if_swap_is_active() { run_test(|| { assert_ok!(Pallet::::create_swap( - Origin::signed(THIS_CHAIN_ACCOUNT), + mock::Origin::signed(THIS_CHAIN_ACCOUNT), test_swap(), Box::new(test_swap_creation()), )); assert_noop!( Pallet::::create_swap( - Origin::signed(THIS_CHAIN_ACCOUNT), + mock::Origin::signed(THIS_CHAIN_ACCOUNT), test_swap(), Box::new(test_swap_creation()), ), @@ -795,7 +825,7 @@ mod tests { frame_system::Pallet::::set_block_number(CAN_START_BLOCK_NUMBER + 1); assert_noop!( Pallet::::create_swap( - Origin::signed(THIS_CHAIN_ACCOUNT), + mock::Origin::signed(THIS_CHAIN_ACCOUNT), test_swap(), Box::new(test_swap_creation()), ), @@ -809,7 +839,7 @@ mod tests { run_test(|| { frame_system::Pallet::::set_block_number(CAN_START_BLOCK_NUMBER); assert_ok!(Pallet::::create_swap( - Origin::signed(THIS_CHAIN_ACCOUNT), + mock::Origin::signed(THIS_CHAIN_ACCOUNT), test_swap(), Box::new(test_swap_creation()), )); @@ -823,7 +853,7 @@ mod tests { frame_system::Pallet::::reset_events(); assert_ok!(Pallet::::create_swap( - Origin::signed(THIS_CHAIN_ACCOUNT), + mock::Origin::signed(THIS_CHAIN_ACCOUNT), test_swap(), Box::new(test_swap_creation()), )); @@ -855,7 +885,7 @@ mod tests { run_test(|| { assert_noop!( Pallet::::claim_swap( - Origin::signed( + mock::Origin::signed( 1 + target_account_at_this_chain::(&test_swap()) ), test_swap(), @@ -872,7 +902,9 @@ mod tests { assert_noop!( Pallet::::claim_swap( - Origin::signed(target_account_at_this_chain::(&test_swap())), + mock::Origin::signed(target_account_at_this_chain::( + &test_swap() + )), test_swap(), ), Error::::SwapIsPending @@ -887,7 +919,9 @@ mod tests { assert_noop!( Pallet::::claim_swap( - Origin::signed(target_account_at_this_chain::(&test_swap())), + mock::Origin::signed(target_account_at_this_chain::( + &test_swap() + )), test_swap(), ), Error::::SwapIsFailed @@ -900,7 +934,9 @@ mod tests { run_test(|| { assert_noop!( Pallet::::claim_swap( - Origin::signed(target_account_at_this_chain::(&test_swap())), + mock::Origin::signed(target_account_at_this_chain::( + &test_swap() + )), test_swap(), ), Error::::SwapIsInactive @@ -916,7 +952,9 @@ mod tests { assert_noop!( Pallet::::claim_swap( - Origin::signed(target_account_at_this_chain::(&test_swap())), + mock::Origin::signed(target_account_at_this_chain::( + &test_swap() + )), test_swap(), ), Error::::FailedToTransferFromSwapAccount @@ -934,7 +972,9 @@ mod tests { assert_noop!( Pallet::::claim_swap( - Origin::signed(target_account_at_this_chain::(&test_swap())), + mock::Origin::signed(target_account_at_this_chain::( + &test_swap() + )), test_swap(), ), Error::::SwapIsTemporaryLocked @@ -952,7 +992,7 @@ mod tests { frame_system::Pallet::::reset_events(); assert_ok!(Pallet::::claim_swap( - Origin::signed(target_account_at_this_chain::(&test_swap())), + mock::Origin::signed(target_account_at_this_chain::(&test_swap())), test_swap(), )); @@ -988,7 +1028,7 @@ mod tests { assert_noop!( Pallet::::cancel_swap( - Origin::signed(THIS_CHAIN_ACCOUNT + 1), + mock::Origin::signed(THIS_CHAIN_ACCOUNT + 1), test_swap() ), Error::::MismatchedSwapSourceOrigin @@ -1002,7 +1042,10 @@ mod tests { start_test_swap(); assert_noop!( - Pallet::::cancel_swap(Origin::signed(THIS_CHAIN_ACCOUNT), test_swap()), + Pallet::::cancel_swap( + mock::Origin::signed(THIS_CHAIN_ACCOUNT), + test_swap() + ), Error::::SwapIsPending ); }); @@ -1015,7 +1058,10 @@ mod tests { receive_test_swap_confirmation(true); assert_noop!( - Pallet::::cancel_swap(Origin::signed(THIS_CHAIN_ACCOUNT), test_swap()), + Pallet::::cancel_swap( + mock::Origin::signed(THIS_CHAIN_ACCOUNT), + test_swap() + ), Error::::SwapIsConfirmed ); }); @@ -1025,7 +1071,10 @@ mod tests { fn cancel_swap_fails_if_swap_is_inactive() { run_test(|| { assert_noop!( - Pallet::::cancel_swap(Origin::signed(THIS_CHAIN_ACCOUNT), test_swap()), + Pallet::::cancel_swap( + mock::Origin::signed(THIS_CHAIN_ACCOUNT), + test_swap() + ), Error::::SwapIsInactive ); }); @@ -1042,7 +1091,10 @@ mod tests { ); assert_noop!( - Pallet::::cancel_swap(Origin::signed(THIS_CHAIN_ACCOUNT), test_swap()), + Pallet::::cancel_swap( + mock::Origin::signed(THIS_CHAIN_ACCOUNT), + test_swap() + ), Error::::FailedToTransferFromSwapAccount ); }); @@ -1058,7 +1110,7 @@ mod tests { frame_system::Pallet::::reset_events(); assert_ok!(Pallet::::cancel_swap( - Origin::signed(THIS_CHAIN_ACCOUNT), + mock::Origin::signed(THIS_CHAIN_ACCOUNT), test_swap() )); diff --git a/modules/token-swap/src/mock.rs b/modules/token-swap/src/mock.rs index 78b8a3381d3..ece7b16acc9 100644 --- a/modules/token-swap/src/mock.rs +++ b/modules/token-swap/src/mock.rs @@ -56,7 +56,7 @@ frame_support::construct_runtime! { { System: frame_system::{Pallet, Call, Config, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Event}, - TokenSwap: pallet_bridge_token_swap::{Pallet, Call, Event}, + TokenSwap: pallet_bridge_token_swap::{Pallet, Call, Event, Origin}, } } @@ -154,18 +154,23 @@ impl bp_runtime::Chain for BridgedChain { pub struct TestMessagesBridge; -impl MessagesBridge> for TestMessagesBridge { +impl MessagesBridge> + for TestMessagesBridge +{ type Error = (); fn send_message( - sender: frame_system::RawOrigin, + sender: Origin, lane: LaneId, message: MessagePayloadOf, delivery_and_dispatch_fee: Balance, ) -> Result { - assert_ne!(sender, frame_system::RawOrigin::Signed(THIS_CHAIN_ACCOUNT)); assert_eq!(lane, OutboundMessageLaneId::get()); assert_eq!(delivery_and_dispatch_fee, SWAP_DELIVERY_AND_DISPATCH_FEE); + match sender.caller { + OriginCaller::TokenSwap(_) => (), + _ => panic!("unexpected origin"), + } match message.call[0] { OK_TRANSFER_CALL => Ok(SendMessageArtifacts { nonce: MESSAGE_NONCE, weight: 0 }), BAD_TRANSFER_CALL => Err(()), diff --git a/primitives/chain-kusama/Cargo.toml b/primitives/chain-kusama/Cargo.toml index 6ff860357c7..a676b565c33 100644 --- a/primitives/chain-kusama/Cargo.toml +++ b/primitives/chain-kusama/Cargo.toml @@ -3,7 +3,7 @@ name = "bp-kusama" description = "Primitives of Kusama runtime." version = "0.1.0" authors = ["Parity Technologies "] -edition = "2018" +edition = "2021" license = "GPL-3.0-or-later WITH Classpath-exception-2.0" [dependencies] @@ -19,6 +19,7 @@ bp-runtime = { path = "../runtime", default-features = false } frame-support = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } sp-api = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } +sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } sp-std = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } sp-version = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } @@ -30,6 +31,7 @@ std = [ "bp-runtime/std", "frame-support/std", "sp-api/std", + "sp-runtime/std", "sp-std/std", "sp-version/std", ] diff --git a/primitives/chain-kusama/src/lib.rs b/primitives/chain-kusama/src/lib.rs index 953da9f4f09..a0a5990ca08 100644 --- a/primitives/chain-kusama/src/lib.rs +++ b/primitives/chain-kusama/src/lib.rs @@ -17,13 +17,12 @@ #![cfg_attr(not(feature = "std"), no_std)] // RuntimeApi generated functions #![allow(clippy::too_many_arguments)] -// Runtime-generated DecodeLimit::decode_all_with_depth_limit -#![allow(clippy::unnecessary_mut_passed)] -use bp_messages::{LaneId, MessageDetails, MessageNonce, UnrewardedRelayersState}; +use bp_messages::{LaneId, MessageDetails, MessageNonce}; use frame_support::weights::{ WeightToFeeCoefficient, WeightToFeeCoefficients, WeightToFeePolynomial, }; +use sp_runtime::FixedU128; use sp_std::prelude::*; use sp_version::RuntimeVersion; @@ -37,10 +36,10 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: sp_version::create_runtime_str!("kusama"), impl_name: sp_version::create_runtime_str!("parity-kusama"), authoring_version: 2, - spec_version: 9140, + spec_version: 9180, impl_version: 0, apis: sp_version::create_apis_vec![[]], - transaction_version: 8, + transaction_version: 11, state_version: 0, }; @@ -87,9 +86,14 @@ pub const WITH_KUSAMA_GRANDPA_PALLET_NAME: &str = "BridgeKusamaGrandpa"; /// Name of the With-Kusama messages pallet instance that is deployed at bridged chains. pub const WITH_KUSAMA_MESSAGES_PALLET_NAME: &str = "BridgeKusamaMessages"; +/// Name of the transaction payment pallet at the Kusama runtime. +pub const TRANSACTION_PAYMENT_PALLET_NAME: &str = "TransactionPayment"; + /// Name of the DOT->KSM conversion rate stored in the Kusama runtime. pub const POLKADOT_TO_KUSAMA_CONVERSION_RATE_PARAMETER_NAME: &str = "PolkadotToKusamaConversionRate"; +/// Name of the Polkadot fee multiplier parameter, stored in the Polkadot runtime. +pub const POLKADOT_FEE_MULTIPLIER_PARAMETER_NAME: &str = "PolkadotFeeMultiplier"; /// Name of the `KusamaFinalityApi::best_finalized` runtime method. pub const BEST_FINALIZED_KUSAMA_HEADER_METHOD: &str = "KusamaFinalityApi_best_finalized"; @@ -101,10 +105,6 @@ pub const TO_KUSAMA_ESTIMATE_MESSAGE_FEE_METHOD: &str = /// Name of the `ToKusamaOutboundLaneApi::message_details` runtime method. pub const TO_KUSAMA_MESSAGE_DETAILS_METHOD: &str = "ToKusamaOutboundLaneApi_message_details"; -/// Name of the `FromKusamaInboundLaneApi::unrewarded_relayers_state` runtime method. -pub const FROM_KUSAMA_UNREWARDED_RELAYERS_STATE: &str = - "FromKusamaInboundLaneApi_unrewarded_relayers_state"; - sp_api::decl_runtime_apis! { /// API for querying information about the finalized Kusama headers. /// @@ -132,6 +132,7 @@ sp_api::decl_runtime_apis! { fn estimate_message_delivery_and_dispatch_fee( lane_id: LaneId, payload: OutboundPayload, + kusama_to_this_conversion_rate: Option, ) -> Option; /// Returns dispatch weight, encoded payload size and delivery+dispatch fee of all /// messages in given inclusive range. @@ -144,13 +145,4 @@ sp_api::decl_runtime_apis! { end: MessageNonce, ) -> Vec>; } - - /// Inbound message lane API for messages sent by Kusama chain. - /// - /// This API is implemented by runtimes that are receiving messages from Kusama chain, not the - /// Kusama runtime itself. - pub trait FromKusamaInboundLaneApi { - /// State of the unrewarded relayers set at given lane. - fn unrewarded_relayers_state(lane: LaneId) -> UnrewardedRelayersState; - } } diff --git a/primitives/chain-millau/Cargo.toml b/primitives/chain-millau/Cargo.toml index f1e17fe96f5..0aaeb5b6bf9 100644 --- a/primitives/chain-millau/Cargo.toml +++ b/primitives/chain-millau/Cargo.toml @@ -3,7 +3,7 @@ name = "bp-millau" description = "Primitives of Millau runtime." version = "0.1.0" authors = ["Parity Technologies "] -edition = "2018" +edition = "2021" license = "GPL-3.0-or-later WITH Classpath-exception-2.0" [dependencies] @@ -14,10 +14,10 @@ bp-messages = { path = "../messages", default-features = false } bp-runtime = { path = "../runtime", default-features = false } fixed-hash = { version = "0.7.0", default-features = false } hash256-std-hasher = { version = "0.15.2", default-features = false } -impl-codec = { version = "0.5.1", default-features = false } +impl-codec = { version = "0.6", default-features = false } impl-serde = { version = "0.3.1", optional = true } -parity-util-mem = { version = "0.10", default-features = false, features = ["primitive-types"] } -scale-info = { version = "1.0", default-features = false, features = ["derive"] } +parity-util-mem = { version = "0.11", default-features = false, features = ["primitive-types"] } +scale-info = { version = "2.0.1", default-features = false, features = ["derive"] } serde = { version = "1.0", optional = true, features = ["derive"] } # Substrate Based Dependencies diff --git a/primitives/chain-millau/src/lib.rs b/primitives/chain-millau/src/lib.rs index d83b4ea433a..ff8d5385953 100644 --- a/primitives/chain-millau/src/lib.rs +++ b/primitives/chain-millau/src/lib.rs @@ -17,12 +17,10 @@ #![cfg_attr(not(feature = "std"), no_std)] // RuntimeApi generated functions #![allow(clippy::too_many_arguments)] -// Runtime-generated DecodeLimit::decode_all_With_depth_limit -#![allow(clippy::unnecessary_mut_passed)] mod millau_hash; -use bp_messages::{LaneId, MessageDetails, MessageNonce, UnrewardedRelayersState}; +use bp_messages::{LaneId, MessageDetails, MessageNonce}; use bp_runtime::Chain; use frame_support::{ weights::{constants::WEIGHT_PER_SECOND, DispatchClass, IdentityFee, Weight}, @@ -33,7 +31,7 @@ use scale_info::TypeInfo; use sp_core::{storage::StateVersion, Hasher as HasherT}; use sp_runtime::{ traits::{Convert, IdentifyAccount, Verify}, - MultiSignature, MultiSigner, Perbill, + FixedU128, MultiSignature, MultiSigner, Perbill, }; use sp_std::prelude::*; use sp_trie::{LayoutV0, LayoutV1, TrieConfiguration}; @@ -284,10 +282,6 @@ pub const TO_MILLAU_ESTIMATE_MESSAGE_FEE_METHOD: &str = /// Name of the `ToMillauOutboundLaneApi::message_details` runtime method. pub const TO_MILLAU_MESSAGE_DETAILS_METHOD: &str = "ToMillauOutboundLaneApi_message_details"; -/// Name of the `FromMillauInboundLaneApi::unrewarded_relayers_state` runtime method. -pub const FROM_MILLAU_UNREWARDED_RELAYERS_STATE: &str = - "FromMillauInboundLaneApi_unrewarded_relayers_state"; - sp_api::decl_runtime_apis! { /// API for querying information about the finalized Millau headers. /// @@ -315,6 +309,7 @@ sp_api::decl_runtime_apis! { fn estimate_message_delivery_and_dispatch_fee( lane_id: LaneId, payload: OutboundPayload, + millau_to_this_conversion_rate: Option, ) -> Option; /// Returns dispatch weight, encoded payload size and delivery+dispatch fee of all /// messages in given inclusive range. @@ -327,15 +322,6 @@ sp_api::decl_runtime_apis! { end: MessageNonce, ) -> Vec>; } - - /// Inbound message lane API for messages sent by Millau chain. - /// - /// This API is implemented by runtimes that are receiving messages from Millau chain, not the - /// Millau runtime itself. - pub trait FromMillauInboundLaneApi { - /// State of the unrewarded relayers set at given lane. - fn unrewarded_relayers_state(lane: LaneId) -> UnrewardedRelayersState; - } } #[cfg(test)] diff --git a/primitives/chain-polkadot/Cargo.toml b/primitives/chain-polkadot/Cargo.toml index 917c7f97478..738899b658c 100644 --- a/primitives/chain-polkadot/Cargo.toml +++ b/primitives/chain-polkadot/Cargo.toml @@ -3,7 +3,7 @@ name = "bp-polkadot" description = "Primitives of Polkadot runtime." version = "0.1.0" authors = ["Parity Technologies "] -edition = "2018" +edition = "2021" license = "GPL-3.0-or-later WITH Classpath-exception-2.0" [dependencies] @@ -19,6 +19,7 @@ bp-runtime = { path = "../runtime", default-features = false } frame-support = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } sp-api = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } +sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } sp-std = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } sp-version = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } @@ -30,6 +31,7 @@ std = [ "bp-runtime/std", "frame-support/std", "sp-api/std", + "sp-runtime/std", "sp-std/std", "sp-version/std", ] diff --git a/primitives/chain-polkadot/src/lib.rs b/primitives/chain-polkadot/src/lib.rs index 02c201b7205..d95e29c8b0c 100644 --- a/primitives/chain-polkadot/src/lib.rs +++ b/primitives/chain-polkadot/src/lib.rs @@ -17,13 +17,12 @@ #![cfg_attr(not(feature = "std"), no_std)] // RuntimeApi generated functions #![allow(clippy::too_many_arguments)] -// Runtime-generated DecodeLimit::decode_all_with_depth_limit -#![allow(clippy::unnecessary_mut_passed)] -use bp_messages::{LaneId, MessageDetails, MessageNonce, UnrewardedRelayersState}; +use bp_messages::{LaneId, MessageDetails, MessageNonce}; use frame_support::weights::{ WeightToFeeCoefficient, WeightToFeeCoefficients, WeightToFeePolynomial, }; +use sp_runtime::FixedU128; use sp_std::prelude::*; use sp_version::RuntimeVersion; @@ -37,10 +36,10 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: sp_version::create_runtime_str!("polkadot"), impl_name: sp_version::create_runtime_str!("parity-polkadot"), authoring_version: 0, - spec_version: 9140, + spec_version: 9180, impl_version: 0, apis: sp_version::create_apis_vec![[]], - transaction_version: 9, + transaction_version: 12, state_version: 0, }; @@ -87,9 +86,14 @@ pub const WITH_POLKADOT_GRANDPA_PALLET_NAME: &str = "BridgePolkadotGrandpa"; /// Name of the With-Polkadot messages pallet instance that is deployed at bridged chains. pub const WITH_POLKADOT_MESSAGES_PALLET_NAME: &str = "BridgePolkadotMessages"; -/// Name of the KSM->DOT conversion rate stored in the Polkadot runtime. +/// Name of the transaction payment pallet at the Polkadot runtime. +pub const TRANSACTION_PAYMENT_PALLET_NAME: &str = "TransactionPayment"; + +/// Name of the KSM->DOT conversion rate parameter, stored in the Polkadot runtime. pub const KUSAMA_TO_POLKADOT_CONVERSION_RATE_PARAMETER_NAME: &str = "KusamaToPolkadotConversionRate"; +/// Name of the Kusama fee multiplier parameter, stored in the Polkadot runtime. +pub const KUSAMA_FEE_MULTIPLIER_PARAMETER_NAME: &str = "KusamaFeeMultiplier"; /// Name of the `PolkadotFinalityApi::best_finalized` runtime method. pub const BEST_FINALIZED_POLKADOT_HEADER_METHOD: &str = "PolkadotFinalityApi_best_finalized"; @@ -101,10 +105,6 @@ pub const TO_POLKADOT_ESTIMATE_MESSAGE_FEE_METHOD: &str = /// Name of the `ToPolkadotOutboundLaneApi::message_details` runtime method. pub const TO_POLKADOT_MESSAGE_DETAILS_METHOD: &str = "ToPolkadotOutboundLaneApi_message_details"; -/// Name of the `FromPolkadotInboundLaneApi::unrewarded_relayers_state` runtime method. -pub const FROM_POLKADOT_UNREWARDED_RELAYERS_STATE: &str = - "FromPolkadotInboundLaneApi_unrewarded_relayers_state"; - sp_api::decl_runtime_apis! { /// API for querying information about the finalized Polkadot headers. /// @@ -132,6 +132,7 @@ sp_api::decl_runtime_apis! { fn estimate_message_delivery_and_dispatch_fee( lane_id: LaneId, payload: OutboundPayload, + polkadot_to_this_conversion_rate: Option, ) -> Option; /// Returns dispatch weight, encoded payload size and delivery+dispatch fee of all /// messages in given inclusive range. @@ -144,13 +145,4 @@ sp_api::decl_runtime_apis! { end: MessageNonce, ) -> Vec>; } - - /// Inbound message lane API for messages sent by Polkadot chain. - /// - /// This API is implemented by runtimes that are receiving messages from Polkadot chain, not the - /// Polkadot runtime itself. - pub trait FromPolkadotInboundLaneApi { - /// State of the unrewarded relayers set at given lane. - fn unrewarded_relayers_state(lane: LaneId) -> UnrewardedRelayersState; - } } diff --git a/primitives/chain-rialto-parachain/Cargo.toml b/primitives/chain-rialto-parachain/Cargo.toml index 034188631b8..a15c4092957 100644 --- a/primitives/chain-rialto-parachain/Cargo.toml +++ b/primitives/chain-rialto-parachain/Cargo.toml @@ -3,7 +3,7 @@ name = "bp-rialto-parachain" description = "Primitives of Rialto parachain runtime." version = "0.1.0" authors = ["Parity Technologies "] -edition = "2018" +edition = "2021" license = "GPL-3.0-or-later WITH Classpath-exception-2.0" [dependencies] diff --git a/primitives/chain-rialto-parachain/src/lib.rs b/primitives/chain-rialto-parachain/src/lib.rs index 786226cf93c..f3f449c7af3 100644 --- a/primitives/chain-rialto-parachain/src/lib.rs +++ b/primitives/chain-rialto-parachain/src/lib.rs @@ -17,8 +17,6 @@ #![cfg_attr(not(feature = "std"), no_std)] // RuntimeApi generated functions #![allow(clippy::too_many_arguments)] -// Runtime-generated DecodeLimit::decode_all_With_depth_limit -#![allow(clippy::unnecessary_mut_passed)] use bp_runtime::Chain; use frame_support::{ diff --git a/primitives/chain-rialto/Cargo.toml b/primitives/chain-rialto/Cargo.toml index d16ac59484f..663f9076657 100644 --- a/primitives/chain-rialto/Cargo.toml +++ b/primitives/chain-rialto/Cargo.toml @@ -3,7 +3,7 @@ name = "bp-rialto" description = "Primitives of Rialto runtime." version = "0.1.0" authors = ["Parity Technologies "] -edition = "2018" +edition = "2021" license = "GPL-3.0-or-later WITH Classpath-exception-2.0" [dependencies] diff --git a/primitives/chain-rialto/src/lib.rs b/primitives/chain-rialto/src/lib.rs index 0adb703c136..4bf20489bc8 100644 --- a/primitives/chain-rialto/src/lib.rs +++ b/primitives/chain-rialto/src/lib.rs @@ -17,10 +17,8 @@ #![cfg_attr(not(feature = "std"), no_std)] // RuntimeApi generated functions #![allow(clippy::too_many_arguments)] -// Runtime-generated DecodeLimit::decode_all_With_depth_limit -#![allow(clippy::unnecessary_mut_passed)] -use bp_messages::{LaneId, MessageDetails, MessageNonce, UnrewardedRelayersState}; +use bp_messages::{LaneId, MessageDetails, MessageNonce}; use bp_runtime::Chain; use frame_support::{ weights::{constants::WEIGHT_PER_SECOND, DispatchClass, IdentityFee, Weight}, @@ -30,7 +28,7 @@ use frame_system::limits; use sp_core::Hasher as HasherT; use sp_runtime::{ traits::{BlakeTwo256, Convert, IdentifyAccount, Verify}, - MultiSignature, MultiSigner, Perbill, + FixedU128, MultiSignature, MultiSigner, Perbill, }; use sp_std::prelude::*; @@ -250,10 +248,6 @@ pub const TO_RIALTO_ESTIMATE_MESSAGE_FEE_METHOD: &str = /// Name of the `ToRialtoOutboundLaneApi::message_details` runtime method. pub const TO_RIALTO_MESSAGE_DETAILS_METHOD: &str = "ToRialtoOutboundLaneApi_message_details"; -/// Name of the `FromRialtoInboundLaneApi::unrewarded_relayers_state` runtime method. -pub const FROM_RIALTO_UNREWARDED_RELAYERS_STATE: &str = - "FromRialtoInboundLaneApi_unrewarded_relayers_state"; - sp_api::decl_runtime_apis! { /// API for querying information about the finalized Rialto headers. /// @@ -281,6 +275,7 @@ sp_api::decl_runtime_apis! { fn estimate_message_delivery_and_dispatch_fee( lane_id: LaneId, payload: OutboundPayload, + rialto_to_this_conversion_rate: Option, ) -> Option; /// Returns dispatch weight, encoded payload size and delivery+dispatch fee of all /// messages in given inclusive range. @@ -293,15 +288,6 @@ sp_api::decl_runtime_apis! { end: MessageNonce, ) -> Vec>; } - - /// Inbound message lane API for messages sent by Rialto chain. - /// - /// This API is implemented by runtimes that are receiving messages from Rialto chain, not the - /// Rialto runtime itself. - pub trait FromRialtoInboundLaneApi { - /// State of the unrewarded relayers set at given lane. - fn unrewarded_relayers_state(lane: LaneId) -> UnrewardedRelayersState; - } } #[cfg(test)] diff --git a/primitives/chain-rococo/Cargo.toml b/primitives/chain-rococo/Cargo.toml index 6e1189b05f3..814cd09bf17 100644 --- a/primitives/chain-rococo/Cargo.toml +++ b/primitives/chain-rococo/Cargo.toml @@ -3,11 +3,11 @@ name = "bp-rococo" description = "Primitives of Rococo runtime." version = "0.1.0" authors = ["Parity Technologies "] -edition = "2018" +edition = "2021" license = "GPL-3.0-or-later WITH Classpath-exception-2.0" [dependencies] -parity-scale-codec = { version = "2.2.0", default-features = false, features = ["derive"] } +parity-scale-codec = { version = "3.0.0", default-features = false, features = ["derive"] } smallvec = "1.7" # Bridge Dependencies diff --git a/primitives/chain-rococo/src/lib.rs b/primitives/chain-rococo/src/lib.rs index a47f0277ef5..127e75d5f8b 100644 --- a/primitives/chain-rococo/src/lib.rs +++ b/primitives/chain-rococo/src/lib.rs @@ -17,13 +17,12 @@ #![cfg_attr(not(feature = "std"), no_std)] // RuntimeApi generated functions #![allow(clippy::too_many_arguments)] -// Runtime-generated DecodeLimit::decode_all_with_depth_limit -#![allow(clippy::unnecessary_mut_passed)] -use bp_messages::{LaneId, MessageDetails, MessageNonce, UnrewardedRelayersState}; +use bp_messages::{LaneId, MessageDetails, MessageNonce}; use frame_support::weights::{ Weight, WeightToFeeCoefficient, WeightToFeeCoefficients, WeightToFeePolynomial, }; +use sp_runtime::FixedU128; use sp_std::prelude::*; use sp_version::RuntimeVersion; @@ -37,14 +36,14 @@ pub type Rococo = PolkadotLike; /// /// Note that since this is a target sessions may change before/after this time depending on network /// conditions. -pub const SESSION_LENGTH: BlockNumber = 1 * time_units::HOURS; +pub const SESSION_LENGTH: BlockNumber = time_units::HOURS; // NOTE: This needs to be kept up to date with the Rococo runtime found in the Polkadot repo. pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: sp_version::create_runtime_str!("rococo"), impl_name: sp_version::create_runtime_str!("parity-rococo-v2.0"), authoring_version: 0, - spec_version: 9140, + spec_version: 9180, impl_version: 0, apis: sp_version::create_apis_vec![[]], transaction_version: 0, @@ -90,10 +89,6 @@ pub const TO_ROCOCO_ESTIMATE_MESSAGE_FEE_METHOD: &str = /// Name of the `ToRococoOutboundLaneApi::message_details` runtime method. pub const TO_ROCOCO_MESSAGE_DETAILS_METHOD: &str = "ToRococoOutboundLaneApi_message_details"; -/// Name of the `FromRococoInboundLaneApi::unrewarded_relayers_state` runtime method. -pub const FROM_ROCOCO_UNREWARDED_RELAYERS_STATE: &str = - "FromRococoInboundLaneApi_unrewarded_relayers_state"; - /// Existential deposit on Rococo. pub const EXISTENTIAL_DEPOSIT: Balance = 1_000_000_000_000 / 100; @@ -133,6 +128,7 @@ sp_api::decl_runtime_apis! { fn estimate_message_delivery_and_dispatch_fee( lane_id: LaneId, payload: OutboundPayload, + rococo_to_this_conversion_rate: Option, ) -> Option; /// Returns dispatch weight, encoded payload size and delivery+dispatch fee of all /// messages in given inclusive range. @@ -145,13 +141,4 @@ sp_api::decl_runtime_apis! { end: MessageNonce, ) -> Vec>; } - - /// Inbound message lane API for messages sent by Rococo chain. - /// - /// This API is implemented by runtimes that are receiving messages from Rococo chain, not the - /// Rococo runtime itself. - pub trait FromRococoInboundLaneApi { - /// State of the unrewarded relayers set at given lane. - fn unrewarded_relayers_state(lane: LaneId) -> UnrewardedRelayersState; - } } diff --git a/primitives/chain-westend/Cargo.toml b/primitives/chain-westend/Cargo.toml index cc2e912cea5..ee6e2b9be99 100644 --- a/primitives/chain-westend/Cargo.toml +++ b/primitives/chain-westend/Cargo.toml @@ -3,12 +3,12 @@ name = "bp-westend" description = "Primitives of Westend runtime." version = "0.1.0" authors = ["Parity Technologies "] -edition = "2018" +edition = "2021" license = "GPL-3.0-or-later WITH Classpath-exception-2.0" [dependencies] -parity-scale-codec = { version = "2.2.0", default-features = false, features = ["derive"] } -scale-info = { version = "1.0", default-features = false, features = ["derive"] } +parity-scale-codec = { version = "3.0.0", default-features = false, features = ["derive"] } +scale-info = { version = "2.0.1", default-features = false, features = ["derive"] } smallvec = "1.7" # Bridge Dependencies diff --git a/primitives/chain-westend/src/lib.rs b/primitives/chain-westend/src/lib.rs index af0ad27c9bc..c7ebe4b00fd 100644 --- a/primitives/chain-westend/src/lib.rs +++ b/primitives/chain-westend/src/lib.rs @@ -17,8 +17,6 @@ #![cfg_attr(not(feature = "std"), no_std)] // RuntimeApi generated functions #![allow(clippy::too_many_arguments)] -// Runtime-generated DecodeLimit::decode_all_with_depth_limit -#![allow(clippy::unnecessary_mut_passed)] use frame_support::weights::{ WeightToFeeCoefficient, WeightToFeeCoefficients, WeightToFeePolynomial, diff --git a/primitives/chain-wococo/Cargo.toml b/primitives/chain-wococo/Cargo.toml index d99783695ad..633cdd15c1f 100644 --- a/primitives/chain-wococo/Cargo.toml +++ b/primitives/chain-wococo/Cargo.toml @@ -3,11 +3,11 @@ name = "bp-wococo" description = "Primitives of Wococo runtime." version = "0.1.0" authors = ["Parity Technologies "] -edition = "2018" +edition = "2021" license = "GPL-3.0-or-later WITH Classpath-exception-2.0" [dependencies] -parity-scale-codec = { version = "2.2.0", default-features = false, features = ["derive"] } +parity-scale-codec = { version = "3.0.0", default-features = false, features = ["derive"] } # Bridge Dependencies bp-messages = { path = "../messages", default-features = false } diff --git a/primitives/chain-wococo/src/lib.rs b/primitives/chain-wococo/src/lib.rs index a05a2ad46a9..f39543114c7 100644 --- a/primitives/chain-wococo/src/lib.rs +++ b/primitives/chain-wococo/src/lib.rs @@ -17,10 +17,9 @@ #![cfg_attr(not(feature = "std"), no_std)] // RuntimeApi generated functions #![allow(clippy::too_many_arguments)] -// Runtime-generated DecodeLimit::decode_all_with_depth_limit -#![allow(clippy::unnecessary_mut_passed)] -use bp_messages::{LaneId, MessageDetails, MessageNonce, UnrewardedRelayersState}; +use bp_messages::{LaneId, MessageDetails, MessageNonce}; +use sp_runtime::FixedU128; use sp_std::prelude::*; pub use bp_polkadot_core::*; @@ -35,7 +34,7 @@ pub type Wococo = PolkadotLike; /// /// Note that since this is a target sessions may change before/after this time depending on network /// conditions. -pub const SESSION_LENGTH: BlockNumber = 1 * time_units::MINUTES; +pub const SESSION_LENGTH: BlockNumber = time_units::MINUTES; // We use this to get the account on Wococo (target) which is derived from Rococo's (source) // account. @@ -59,10 +58,6 @@ pub const TO_WOCOCO_ESTIMATE_MESSAGE_FEE_METHOD: &str = /// Name of the `ToWococoOutboundLaneApi::message_details` runtime method. pub const TO_WOCOCO_MESSAGE_DETAILS_METHOD: &str = "ToWococoOutboundLaneApi_message_details"; -/// Name of the `FromWococoInboundLaneApi::unrewarded_relayers_state` runtime method. -pub const FROM_WOCOCO_UNREWARDED_RELAYERS_STATE: &str = - "FromWococoInboundLaneApi_unrewarded_relayers_state"; - sp_api::decl_runtime_apis! { /// API for querying information about the finalized Wococo headers. /// @@ -90,6 +85,7 @@ sp_api::decl_runtime_apis! { fn estimate_message_delivery_and_dispatch_fee( lane_id: LaneId, payload: OutboundPayload, + wococo_to_this_conversion_rate: Option, ) -> Option; /// Returns dispatch weight, encoded payload size and delivery+dispatch fee of all /// messages in given inclusive range. @@ -102,13 +98,4 @@ sp_api::decl_runtime_apis! { end: MessageNonce, ) -> Vec>; } - - /// Inbound message lane API for messages sent by Wococo chain. - /// - /// This API is implemented by runtimes that are receiving messages from Wococo chain, not the - /// Wococo runtime itself. - pub trait FromWococoInboundLaneApi { - /// State of the unrewarded relayers set at given lane. - fn unrewarded_relayers_state(lane: LaneId) -> UnrewardedRelayersState; - } } diff --git a/primitives/header-chain/Cargo.toml b/primitives/header-chain/Cargo.toml index d4a7d30f90f..7cd688d0d81 100644 --- a/primitives/header-chain/Cargo.toml +++ b/primitives/header-chain/Cargo.toml @@ -3,13 +3,13 @@ name = "bp-header-chain" description = "A common interface for describing what a bridge pallet should be able to do." version = "0.1.0" authors = ["Parity Technologies "] -edition = "2018" +edition = "2021" license = "GPL-3.0-or-later WITH Classpath-exception-2.0" [dependencies] -codec = { package = "parity-scale-codec", version = "2.2.0", default-features = false } -finality-grandpa = { version = "0.14.0", default-features = false } -scale-info = { version = "1.0", default-features = false, features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false } +finality-grandpa = { version = "0.15.0", default-features = false } +scale-info = { version = "2.0.1", default-features = false, features = ["derive"] } serde = { version = "1.0", optional = true } # Bridge dependencies diff --git a/primitives/message-dispatch/Cargo.toml b/primitives/message-dispatch/Cargo.toml index 9897b319978..39b2d00111e 100644 --- a/primitives/message-dispatch/Cargo.toml +++ b/primitives/message-dispatch/Cargo.toml @@ -3,13 +3,13 @@ name = "bp-message-dispatch" description = "Primitives of bridge messages dispatch modules." version = "0.1.0" authors = ["Parity Technologies "] -edition = "2018" +edition = "2021" license = "GPL-3.0-or-later WITH Classpath-exception-2.0" [dependencies] bp-runtime = { path = "../runtime", default-features = false } -codec = { package = "parity-scale-codec", version = "2.2.0", default-features = false } -scale-info = { version = "1.0", default-features = false, features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false } +scale-info = { version = "2.0.1", default-features = false, features = ["derive"] } # Substrate Dependencies diff --git a/primitives/messages/Cargo.toml b/primitives/messages/Cargo.toml index 5afa25fb301..2a84f74d225 100644 --- a/primitives/messages/Cargo.toml +++ b/primitives/messages/Cargo.toml @@ -3,14 +3,14 @@ name = "bp-messages" description = "Primitives of messages module." version = "0.1.0" authors = ["Parity Technologies "] -edition = "2018" +edition = "2021" license = "GPL-3.0-or-later WITH Classpath-exception-2.0" [dependencies] -bitvec = { version = "0.20", default-features = false, features = ["alloc"] } -codec = { package = "parity-scale-codec", version = "2.2.0", default-features = false, features = ["derive", "bit-vec"] } +bitvec = { version = "1", default-features = false, features = ["alloc"] } +codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive", "bit-vec"] } impl-trait-for-tuples = "0.2" -scale-info = { version = "1.0", default-features = false, features = ["bit-vec", "derive"] } +scale-info = { version = "2.0.1", default-features = false, features = ["bit-vec", "derive"] } serde = { version = "1.0", optional = true, features = ["derive"] } # Bridge dependencies @@ -31,6 +31,7 @@ hex-literal = "0.3" [features] default = ["std"] std = [ + "bitvec/std", "bp-runtime/std", "codec/std", "frame-support/std", diff --git a/primitives/messages/src/lib.rs b/primitives/messages/src/lib.rs index 691ed57794d..a4f204d238f 100644 --- a/primitives/messages/src/lib.rs +++ b/primitives/messages/src/lib.rs @@ -194,7 +194,7 @@ pub struct MessageDetails { } /// Bit vector of message dispatch results. -pub type DispatchResultsBitVec = BitVec; +pub type DispatchResultsBitVec = BitVec; /// Unrewarded relayer entry stored in the inbound lane data. /// @@ -225,11 +225,9 @@ impl DeliveredMessages { /// Create new `DeliveredMessages` struct that confirms delivery of single nonce with given /// dispatch result. pub fn new(nonce: MessageNonce, dispatch_result: bool) -> Self { - DeliveredMessages { - begin: nonce, - end: nonce, - dispatch_results: bitvec![Msb0, u8; if dispatch_result { 1 } else { 0 }], - } + let mut dispatch_results = BitVec::with_capacity(1); + dispatch_results.push(if dispatch_result { true } else { false }); + DeliveredMessages { begin: nonce, end: nonce, dispatch_results } } /// Return total count of delivered messages. @@ -368,7 +366,7 @@ mod tests { messages: DeliveredMessages::new(i as _, true), }; entry.messages.dispatch_results = bitvec![ - Msb0, u8; + u8, Msb0; 1; (messages_count / relayer_entries) as _ ]; @@ -394,7 +392,7 @@ mod tests { #[test] fn message_dispatch_result_works() { let delivered_messages = - DeliveredMessages { begin: 100, end: 150, dispatch_results: bitvec![Msb0, u8; 1; 151] }; + DeliveredMessages { begin: 100, end: 150, dispatch_results: bitvec![u8, Msb0; 1; 151] }; assert!(!delivered_messages.contains_message(99)); assert!(delivered_messages.contains_message(100)); diff --git a/primitives/messages/src/source_chain.rs b/primitives/messages/src/source_chain.rs index 1ff05abf131..fa7b3bb85ed 100644 --- a/primitives/messages/src/source_chain.rs +++ b/primitives/messages/src/source_chain.rs @@ -28,7 +28,21 @@ use sp_std::{ }; /// The sender of the message on the source chain. -pub type Sender = frame_system::RawOrigin; +pub trait SenderOrigin { + /// Return id of the account that is sending this message. + /// + /// In regular messages configuration, when regular message is sent you'll always get `Some(_)` + /// from this call. This is the account that is paying send costs. However, there are some + /// examples when `None` may be returned from the call: + /// + /// - if the send-message call origin is either `frame_system::RawOrigin::Root` or + /// `frame_system::RawOrigin::None` and your configuration forbids such messages; + /// - if your configuration allows 'unpaid' messages sent by pallets. Then the pallet may just + /// use its own defined origin (not linked to any account) and the message will be accepted. + /// This may be useful for pallets that are sending important system-wide information (like + /// update of runtime version). + fn linked_account(&self) -> Option; +} /// Relayers rewards, grouped by relayer account id. pub type RelayersRewards = BTreeMap>; @@ -82,14 +96,14 @@ pub trait TargetHeaderChain { /// Lane3 until some block, ...), then it may be built using this verifier. /// /// Any fee requirements should also be enforced here. -pub trait LaneMessageVerifier { +pub trait LaneMessageVerifier { /// Error type. type Error: Debug + Into<&'static str>; /// Verify message payload and return Ok(()) if message is valid and allowed to be sent over the /// lane. fn verify_message( - submitter: &Sender, + submitter: &SenderOrigin, delivery_and_dispatch_fee: &Fee, lane: &LaneId, outbound_data: &OutboundLaneData, @@ -110,14 +124,14 @@ pub trait LaneMessageVerifier { /// So to be sure that any non-altruist relayer would agree to deliver message, submitter /// should set `delivery_and_dispatch_fee` to at least (equivalent of): sum of fees from (2) /// to (4) above, plus some interest for the relayer. -pub trait MessageDeliveryAndDispatchPayment { +pub trait MessageDeliveryAndDispatchPayment { /// Error type. type Error: Debug + Into<&'static str>; /// Withhold/write-off delivery_and_dispatch_fee from submitter account to /// some relayers-fund account. fn pay_delivery_and_dispatch_fee( - submitter: &Sender, + submitter: &SenderOrigin, fee: &Balance, relayer_fund_account: &AccountId, ) -> Result<(), Self::Error>; @@ -145,7 +159,7 @@ pub struct SendMessageArtifacts { } /// Messages bridge API to be used from other pallets. -pub trait MessagesBridge { +pub trait MessagesBridge { /// Error type. type Error: Debug; @@ -153,7 +167,7 @@ pub trait MessagesBridge { /// /// Returns unique message nonce or error if send has failed. fn send_message( - sender: Sender, + sender: SenderOrigin, lane: LaneId, message: Payload, delivery_and_dispatch_fee: Balance, @@ -164,13 +178,13 @@ pub trait MessagesBridge { #[derive(RuntimeDebug, PartialEq)] pub struct NoopMessagesBridge; -impl MessagesBridge - for NoopMessagesBridge +impl + MessagesBridge for NoopMessagesBridge { type Error = &'static str; fn send_message( - _sender: Sender, + _sender: SenderOrigin, _lane: LaneId, _message: Payload, _delivery_and_dispatch_fee: Balance, @@ -245,13 +259,13 @@ impl TargetHeaderChain for ForbidOutboun } } -impl LaneMessageVerifier - for ForbidOutboundMessages +impl + LaneMessageVerifier for ForbidOutboundMessages { type Error = &'static str; fn verify_message( - _submitter: &Sender, + _submitter: &SenderOrigin, _delivery_and_dispatch_fee: &Fee, _lane: &LaneId, _outbound_data: &OutboundLaneData, @@ -261,13 +275,13 @@ impl LaneMessageVerifier } } -impl MessageDeliveryAndDispatchPayment - for ForbidOutboundMessages +impl + MessageDeliveryAndDispatchPayment for ForbidOutboundMessages { type Error = &'static str; fn pay_delivery_and_dispatch_fee( - _submitter: &Sender, + _submitter: &SenderOrigin, _fee: &Balance, _relayer_fund_account: &AccountId, ) -> Result<(), Self::Error> { diff --git a/primitives/polkadot-core/Cargo.toml b/primitives/polkadot-core/Cargo.toml index f05edd0d91b..1542a784ef5 100644 --- a/primitives/polkadot-core/Cargo.toml +++ b/primitives/polkadot-core/Cargo.toml @@ -3,12 +3,12 @@ name = "bp-polkadot-core" description = "Primitives of Polkadot-like runtime." version = "0.1.0" authors = ["Parity Technologies "] -edition = "2018" +edition = "2021" license = "GPL-3.0-or-later WITH Classpath-exception-2.0" [dependencies] -parity-scale-codec = { version = "2.2.0", default-features = false, features = ["derive"] } -scale-info = { version = "1.0", default-features = false, features = ["derive"] } +parity-scale-codec = { version = "3.0.0", default-features = false, features = ["derive"] } +scale-info = { version = "2.0.1", default-features = false, features = ["derive"] } # Bridge Dependencies diff --git a/primitives/polkadot-core/src/lib.rs b/primitives/polkadot-core/src/lib.rs index 50e84234374..79db07b82cb 100644 --- a/primitives/polkadot-core/src/lib.rs +++ b/primitives/polkadot-core/src/lib.rs @@ -17,7 +17,7 @@ #![cfg_attr(not(feature = "std"), no_std)] use bp_messages::MessageNonce; -use bp_runtime::Chain; +use bp_runtime::{Chain, EncodedOrDecodedCall}; use frame_support::{ dispatch::Dispatchable, parameter_types, @@ -228,25 +228,34 @@ pub type SignedBlock = generic::SignedBlock; pub type Balance = u128; /// Unchecked Extrinsic type. -pub type UncheckedExtrinsic = - generic::UncheckedExtrinsic>; +pub type UncheckedExtrinsic = generic::UncheckedExtrinsic< + AccountAddress, + EncodedOrDecodedCall, + Signature, + SignedExtensions, +>; /// Account address, used by the Polkadot-like chain. pub type Address = MultiAddress; /// A type of the data encoded as part of the transaction. -pub type SignedExtra = ((), (), (), sp_runtime::generic::Era, Compact, (), Compact); +pub type SignedExtra = + ((), (), (), (), sp_runtime::generic::Era, Compact, (), Compact); /// Parameters which are part of the payload used to produce transaction signature, /// but don't end up in the transaction itself (i.e. inherent part of the runtime). -pub type AdditionalSigned = (u32, u32, Hash, Hash, (), (), ()); +pub type AdditionalSigned = ((), u32, u32, Hash, Hash, (), (), ()); /// A simplified version of signed extensions meant for producing signed transactions /// and signed payload in the client code. #[derive(PartialEq, Eq, Clone, RuntimeDebug, TypeInfo)] pub struct SignedExtensions { encode_payload: SignedExtra, - additional_signed: AdditionalSigned, + // It may be set to `None` if extensions are decoded. We are never reconstructing transactions + // (and it makes no sense to do that) => decoded version of `SignedExtensions` is only used to + // read fields of `encode_payload`. And when resigning transaction, we're reconstructing + // `SignedExtensions` from the scratch. + additional_signed: Option, _data: sp_std::marker::PhantomData, } @@ -258,9 +267,13 @@ impl parity_scale_codec::Encode for SignedExtensions { impl parity_scale_codec::Decode for SignedExtensions { fn decode( - _input: &mut I, + input: &mut I, ) -> Result { - unimplemented!("SignedExtensions are never meant to be decoded, they are only used to create transaction"); + SignedExtra::decode(input).map(|encode_payload| SignedExtensions { + encode_payload, + additional_signed: None, + _data: Default::default(), + }) } } @@ -275,6 +288,7 @@ impl SignedExtensions { ) -> Self { Self { encode_payload: ( + (), // non-zero sender (), // spec version (), // tx version (), // genesis @@ -283,7 +297,8 @@ impl SignedExtensions { (), // Check weight tip.into(), // transaction payment / tip (compact encoding) ), - additional_signed: ( + additional_signed: Some(( + (), spec_version, transaction_version, genesis_hash, @@ -291,7 +306,7 @@ impl SignedExtensions { (), (), (), - ), + )), _data: Default::default(), } } @@ -300,12 +315,12 @@ impl SignedExtensions { impl SignedExtensions { /// Return signer nonce, used to craft transaction. pub fn nonce(&self) -> Nonce { - self.encode_payload.4.into() + self.encode_payload.5.into() } /// Return transaction tip. pub fn tip(&self) -> Balance { - self.encode_payload.6.into() + self.encode_payload.7.into() } } @@ -331,17 +346,23 @@ where fn additional_signed( &self, ) -> Result { - Ok(self.additional_signed) + // we shall not ever see this error in relay, because we are never signing decoded + // transactions. Instead we're constructing and signing new transactions. So the error code + // is kinda random here + self.additional_signed + .ok_or(frame_support::unsigned::TransactionValidityError::Unknown( + frame_support::unsigned::UnknownTransaction::Custom(0xFF), + )) } fn pre_dispatch( self, - who: &Self::AccountId, - call: &Self::Call, - info: &DispatchInfoOf, - len: usize, + _who: &Self::AccountId, + _call: &Self::Call, + _info: &DispatchInfoOf, + _len: usize, ) -> Result { - Ok(self.validate(who, call, info, len).map(|_| ())?) + Ok(()) } } diff --git a/primitives/runtime/Cargo.toml b/primitives/runtime/Cargo.toml index 7cc165fb4e9..085cfb9dbc6 100644 --- a/primitives/runtime/Cargo.toml +++ b/primitives/runtime/Cargo.toml @@ -3,14 +3,14 @@ name = "bp-runtime" description = "Primitives that may be used at (bridges) runtime level." version = "0.1.0" authors = ["Parity Technologies "] -edition = "2018" +edition = "2021" license = "GPL-3.0-or-later WITH Classpath-exception-2.0" [dependencies] -codec = { package = "parity-scale-codec", version = "2.2.0", default-features = false } +codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false } hash-db = { version = "0.15.2", default-features = false } num-traits = { version = "0.2", default-features = false } -scale-info = { version = "1.0", default-features = false, features = ["derive"] } +scale-info = { version = "2.0.1", default-features = false, features = ["derive"] } # Substrate Dependencies diff --git a/primitives/runtime/src/chain.rs b/primitives/runtime/src/chain.rs index 30e754b5702..5a7fafe9f67 100644 --- a/primitives/runtime/src/chain.rs +++ b/primitives/runtime/src/chain.rs @@ -14,6 +14,7 @@ // You should have received a copy of the GNU General Public License // along with Parity Bridges Common. If not, see . +use codec::{Decode, Encode}; use frame_support::{weights::Weight, Parameter}; use num_traits::{AsPrimitive, Bounded, CheckedSub, Saturating, SaturatingAdd, Zero}; use sp_runtime::{ @@ -23,7 +24,69 @@ use sp_runtime::{ }, FixedPointOperand, }; -use sp_std::{convert::TryFrom, fmt::Debug, hash::Hash, str::FromStr}; +use sp_std::{convert::TryFrom, fmt::Debug, hash::Hash, str::FromStr, vec, vec::Vec}; + +/// Chain call, that is either SCALE-encoded, or decoded. +#[derive(Debug, Clone, PartialEq)] +pub enum EncodedOrDecodedCall { + /// The call that is SCALE-encoded. + /// + /// This variant is used when we the chain runtime is not bundled with the relay, but + /// we still need the represent call in some RPC calls or transactions. + Encoded(Vec), + /// The decoded call. + Decoded(ChainCall), +} + +impl EncodedOrDecodedCall { + /// Returns decoded call. + pub fn to_decoded(&self) -> Result { + match self { + Self::Encoded(ref encoded_call) => + ChainCall::decode(&mut &encoded_call[..]).map_err(Into::into), + Self::Decoded(ref decoded_call) => Ok(decoded_call.clone()), + } + } + + /// Converts self to decoded call. + pub fn into_decoded(self) -> Result { + match self { + Self::Encoded(encoded_call) => + ChainCall::decode(&mut &encoded_call[..]).map_err(Into::into), + Self::Decoded(decoded_call) => Ok(decoded_call), + } + } +} + +impl From for EncodedOrDecodedCall { + fn from(call: ChainCall) -> EncodedOrDecodedCall { + EncodedOrDecodedCall::Decoded(call) + } +} + +impl Decode for EncodedOrDecodedCall { + fn decode(input: &mut I) -> Result { + // having encoded version is better than decoded, because decoding isn't required + // everywhere and for mocked calls it may lead to **unneeded** errors + match input.remaining_len()? { + Some(remaining_len) => { + let mut encoded_call = vec![0u8; remaining_len]; + input.read(&mut encoded_call)?; + Ok(EncodedOrDecodedCall::Encoded(encoded_call)) + }, + None => Ok(EncodedOrDecodedCall::Decoded(ChainCall::decode(input)?)), + } + } +} + +impl Encode for EncodedOrDecodedCall { + fn encode(&self) -> Vec { + match *self { + Self::Encoded(ref encoded_call) => encoded_call.clone(), + Self::Decoded(ref decoded_call) => decoded_call.encode(), + } + } +} /// Minimal Substrate-based chain representation that may be used from no_std environment. pub trait Chain: Send + Sync + 'static { diff --git a/primitives/runtime/src/lib.rs b/primitives/runtime/src/lib.rs index c01e7bb305a..1d8a40339ab 100644 --- a/primitives/runtime/src/lib.rs +++ b/primitives/runtime/src/lib.rs @@ -22,11 +22,11 @@ use codec::Encode; use frame_support::{RuntimeDebug, StorageHasher}; use sp_core::{hash::H256, storage::StorageKey}; use sp_io::hashing::blake2_256; -use sp_std::{convert::TryFrom, vec::Vec}; +use sp_std::{convert::TryFrom, vec, vec::Vec}; pub use chain::{ - AccountIdOf, AccountPublicOf, BalanceOf, BlockNumberOf, Chain, HashOf, HasherOf, HeaderOf, - IndexOf, SignatureOf, TransactionEraOf, + AccountIdOf, AccountPublicOf, BalanceOf, BlockNumberOf, Chain, EncodedOrDecodedCall, HashOf, + HasherOf, HeaderOf, IndexOf, SignatureOf, TransactionEraOf, }; pub use frame_support::storage::storage_prefix as storage_value_final_key; pub use storage_proof::{Error as StorageProofError, StorageProofChecker}; @@ -229,7 +229,7 @@ pub fn storage_map_final_key( /// This is how a storage key of storage parameter (`parameter_types! { storage Param: bool = false; /// }`) is computed. /// -/// Copied from `frame_support::parameter_types` macro +/// Copied from `frame_support::parameter_types` macro. pub fn storage_parameter_key(parameter_name: &str) -> StorageKey { let mut buffer = Vec::with_capacity(1 + parameter_name.len() + 1); buffer.push(b':'); @@ -238,6 +238,20 @@ pub fn storage_parameter_key(parameter_name: &str) -> StorageKey { StorageKey(sp_io::hashing::twox_128(&buffer).to_vec()) } +/// This is how a storage key of storage value is computed. +/// +/// Copied from `frame_support::storage::storage_prefix`. +pub fn storage_value_key(pallet_prefix: &str, value_name: &str) -> StorageKey { + let pallet_hash = sp_io::hashing::twox_128(pallet_prefix.as_bytes()); + let storage_hash = sp_io::hashing::twox_128(value_name.as_bytes()); + + let mut final_key = vec![0u8; 32]; + final_key[..16].copy_from_slice(&pallet_hash); + final_key[16..].copy_from_slice(&storage_hash); + + StorageKey(final_key) +} + #[cfg(test)] mod tests { use super::*; @@ -249,4 +263,17 @@ mod tests { StorageKey(hex_literal::hex!("58942375551bb0af1682f72786b59d04").to_vec()), ); } + + #[test] + fn storage_value_key_works() { + assert_eq!( + storage_value_key("PalletTransactionPayment", "NextFeeMultiplier"), + StorageKey( + hex_literal::hex!( + "f0e954dfcca51a255ab12c60c789256a3f2edf3bdf381debe331ab7446addfdc" + ) + .to_vec() + ), + ); + } } diff --git a/primitives/runtime/src/storage_proof.rs b/primitives/runtime/src/storage_proof.rs index 177b0f8664e..4a99ab6210f 100644 --- a/primitives/runtime/src/storage_proof.rs +++ b/primitives/runtime/src/storage_proof.rs @@ -88,8 +88,7 @@ pub fn craft_valid_storage_proof() -> (sp_core::H256, StorageProof) { let proof = StorageProof::new( prove_read(backend, &[&b"key1"[..], &b"key2"[..], &b"key22"[..]]) .unwrap() - .iter_nodes() - .collect(), + .iter_nodes(), ); (root, proof) diff --git a/primitives/test-utils/Cargo.toml b/primitives/test-utils/Cargo.toml index 3876f0200a9..6da5c7c0f4b 100644 --- a/primitives/test-utils/Cargo.toml +++ b/primitives/test-utils/Cargo.toml @@ -2,14 +2,14 @@ name = "bp-test-utils" version = "0.1.0" authors = ["Parity Technologies "] -edition = "2018" +edition = "2021" license = "GPL-3.0-or-later WITH Classpath-exception-2.0" [dependencies] bp-header-chain = { path = "../header-chain", default-features = false } -codec = { package = "parity-scale-codec", version = "2.2.0", default-features = false } +codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false } ed25519-dalek = { version = "1.0", default-features = false, features = ["u64_backend"] } -finality-grandpa = { version = "0.14.0", default-features = false } +finality-grandpa = { version = "0.15.0", default-features = false } sp-application-crypto = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } sp-finality-grandpa = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } diff --git a/primitives/token-swap/Cargo.toml b/primitives/token-swap/Cargo.toml index 4048ef5288b..9097856f853 100644 --- a/primitives/token-swap/Cargo.toml +++ b/primitives/token-swap/Cargo.toml @@ -3,12 +3,12 @@ name = "bp-token-swap" description = "Primitives of the pallet-bridge-token-swap pallet" version = "0.1.0" authors = ["Parity Technologies "] -edition = "2018" +edition = "2021" license = "GPL-3.0-or-later WITH Classpath-exception-2.0" [dependencies] -codec = { package = "parity-scale-codec", version = "2.0.0", default-features = false } -scale-info = { version = "1.0", default-features = false, features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false } +scale-info = { version = "2.0.1", default-features = false, features = ["derive"] } # Bridge Dependencies diff --git a/relays/bin-substrate/Cargo.toml b/relays/bin-substrate/Cargo.toml index 0bfff98d186..fb8ff467d04 100644 --- a/relays/bin-substrate/Cargo.toml +++ b/relays/bin-substrate/Cargo.toml @@ -2,14 +2,14 @@ name = "substrate-relay" version = "1.0.1" authors = ["Parity Technologies "] -edition = "2018" +edition = "2021" license = "GPL-3.0-or-later WITH Classpath-exception-2.0" [dependencies] anyhow = "1.0" async-std = "1.9.0" async-trait = "0.1.42" -codec = { package = "parity-scale-codec", version = "2.2.0" } +codec = { package = "parity-scale-codec", version = "3.0.0" } futures = "0.3.12" hex = "0.4" log = "0.4.14" @@ -31,15 +31,16 @@ bp-polkadot = { path = "../../primitives/chain-polkadot" } bp-rialto = { path = "../../primitives/chain-rialto" } bp-rialto-parachain = { path = "../../primitives/chain-rialto-parachain" } bp-rococo = { path = "../../primitives/chain-rococo" } -bp-token-swap = { path = "../../primitives/token-swap" } -bp-wococo = { path = "../../primitives/chain-wococo" } bp-runtime = { path = "../../primitives/runtime" } +bp-token-swap = { path = "../../primitives/token-swap" } bp-westend = { path = "../../primitives/chain-westend" } +bp-wococo = { path = "../../primitives/chain-wococo" } bridge-runtime-common = { path = "../../bin/runtime-common" } finality-relay = { path = "../finality" } messages-relay = { path = "../messages" } millau-runtime = { path = "../../bin/millau/runtime" } pallet-bridge-dispatch = { path = "../../modules/dispatch" } +pallet-bridge-grandpa = { path = "../../modules/grandpa" } pallet-bridge-messages = { path = "../../modules/messages" } pallet-bridge-token-swap = { path = "../../modules/token-swap" } relay-kusama-client = { path = "../client-kusama" } @@ -73,8 +74,9 @@ polkadot-runtime-common = { git = "https://github.com/paritytech/polkadot", bran polkadot-runtime-parachains = { git = "https://github.com/paritytech/polkadot", branch = "master" } [dev-dependencies] +bp-test-utils = { path = "../../primitives/test-utils" } hex-literal = "0.3" pallet-bridge-grandpa = { path = "../../modules/grandpa" } sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "master" } tempfile = "3.2" -finality-grandpa = { version = "0.14.0" } +finality-grandpa = { version = "0.15.0" } diff --git a/relays/bin-substrate/src/chains/kusama.rs b/relays/bin-substrate/src/chains/kusama.rs index 5a65426c9dc..9cdc6cd125e 100644 --- a/relays/bin-substrate/src/chains/kusama.rs +++ b/relays/bin-substrate/src/chains/kusama.rs @@ -14,6 +14,9 @@ // You should have received a copy of the GNU General Public License // along with Parity Bridges Common. If not, see . +use anyhow::anyhow; +use bp_message_dispatch::{CallOrigin, MessagePayload}; +use bp_runtime::EncodedOrDecodedCall; use codec::Decode; use frame_support::weights::{DispatchClass, DispatchInfo, Pays, Weight}; use relay_kusama_client::Kusama; @@ -21,8 +24,10 @@ use sp_version::RuntimeVersion; use crate::cli::{ bridge, - encode_call::{Call, CliEncodeCall}, - encode_message, CliChain, + encode_call::{self, Call, CliEncodeCall}, + encode_message, + send_message::{self, DispatchFeePayment}, + CliChain, }; /// Weight of the `system::remark` call at Kusama. @@ -32,13 +37,15 @@ use crate::cli::{ pub(crate) const SYSTEM_REMARK_CALL_WEIGHT: Weight = 2 * 1_345_000; impl CliEncodeCall for Kusama { - fn encode_call(call: &Call) -> anyhow::Result { + fn encode_call(call: &Call) -> anyhow::Result> { Ok(match call { + Call::Raw { data } => EncodedOrDecodedCall::Encoded(data.0.clone()), Call::Remark { remark_payload, .. } => relay_kusama_client::runtime::Call::System( relay_kusama_client::runtime::SystemCall::remark( remark_payload.as_ref().map(|x| x.0.clone()).unwrap_or_default(), ), - ), + ) + .into(), Call::BridgeSendMessage { lane, payload, fee, bridge_instance_index } => match *bridge_instance_index { bridge::KUSAMA_TO_POLKADOT_INDEX => { @@ -48,6 +55,7 @@ impl CliEncodeCall for Kusama { lane.0, payload, fee.0, ), ) + .into() }, _ => anyhow::bail!( "Unsupported target bridge pallet with instance index: {}", @@ -58,13 +66,11 @@ impl CliEncodeCall for Kusama { }) } - fn get_dispatch_info( - call: &relay_kusama_client::runtime::Call, - ) -> anyhow::Result { + fn get_dispatch_info(call: &EncodedOrDecodedCall) -> anyhow::Result { match *call { - relay_kusama_client::runtime::Call::System( + EncodedOrDecodedCall::Decoded(relay_kusama_client::runtime::Call::System( relay_kusama_client::runtime::SystemCall::remark(_), - ) => Ok(DispatchInfo { + )) => Ok(DispatchInfo { weight: crate::chains::kusama::SYSTEM_REMARK_CALL_WEIGHT, class: DispatchClass::Normal, pays_fee: Pays::Yes, @@ -78,7 +84,12 @@ impl CliChain for Kusama { const RUNTIME_VERSION: RuntimeVersion = bp_kusama::VERSION; type KeyPair = sp_core::sr25519::Pair; - type MessagePayload = (); + type MessagePayload = MessagePayload< + bp_kusama::AccountId, + bp_polkadot::AccountPublic, + bp_polkadot::Signature, + Vec, + >; fn ss58_format() -> u16 { sp_core::crypto::Ss58AddressFormat::from( @@ -88,8 +99,37 @@ impl CliChain for Kusama { } fn encode_message( - _message: encode_message::MessagePayload, + message: encode_message::MessagePayload, ) -> anyhow::Result { - anyhow::bail!("Sending messages from Kusama is not yet supported.") + match message { + encode_message::MessagePayload::Raw { data } => MessagePayload::decode(&mut &*data.0) + .map_err(|e| anyhow!("Failed to decode Kusama's MessagePayload: {:?}", e)), + encode_message::MessagePayload::Call { mut call, mut sender, dispatch_weight } => { + type Source = Kusama; + type Target = relay_polkadot_client::Polkadot; + + sender.enforce_chain::(); + let spec_version = Target::RUNTIME_VERSION.spec_version; + let origin = CallOrigin::SourceAccount(sender.raw_id()); + encode_call::preprocess_call::( + &mut call, + bridge::KUSAMA_TO_POLKADOT_INDEX, + ); + let call = Target::encode_call(&call)?; + let dispatch_weight = dispatch_weight.map(Ok).unwrap_or_else(|| { + Err(anyhow::format_err!( + "Please specify dispatch weight of the encoded Polkadot call" + )) + })?; + + Ok(send_message::message_payload( + spec_version, + dispatch_weight, + origin, + &call, + DispatchFeePayment::AtSourceChain, + )) + }, + } } } diff --git a/relays/bin-substrate/src/chains/kusama_headers_to_polkadot.rs b/relays/bin-substrate/src/chains/kusama_headers_to_polkadot.rs index f3a2d553045..0c0ba2272c7 100644 --- a/relays/bin-substrate/src/chains/kusama_headers_to_polkadot.rs +++ b/relays/bin-substrate/src/chains/kusama_headers_to_polkadot.rs @@ -24,8 +24,13 @@ use substrate_relay_helper::{finality_pipeline::SubstrateFinalitySyncPipeline, T /// relay as gone wild. /// /// Actual value, returned by `maximal_balance_decrease_per_day_is_sane` test is approximately 21 -/// DOT, but let's round up to 30 DOT here. -pub(crate) const MAXIMAL_BALANCE_DECREASE_PER_DAY: bp_polkadot::Balance = 30_000_000_000; +/// DOT, and initial value of this constant was rounded up to 30 DOT. But for actual Kusama <> +/// Polkadot deployment we'll be using the same account for delivering finality (free for mandatory +/// headers) and messages. It means that we can't predict maximal loss. But to protect funds against +/// relay/deployment issues, let's limit it so something that is much larger than this estimation - +/// e.g. to 100 DOT. +// TODO: https://github.com/paritytech/parity-bridges-common/issues/1307 +pub(crate) const MAXIMAL_BALANCE_DECREASE_PER_DAY: bp_polkadot::Balance = 100 * 10_000_000_000; /// Description of Kusama -> Polkadot finalized headers bridge. #[derive(Clone, Debug)] diff --git a/relays/bin-substrate/src/chains/kusama_messages_to_polkadot.rs b/relays/bin-substrate/src/chains/kusama_messages_to_polkadot.rs index 82a3206b0d9..9a71fbe3c62 100644 --- a/relays/bin-substrate/src/chains/kusama_messages_to_polkadot.rs +++ b/relays/bin-substrate/src/chains/kusama_messages_to_polkadot.rs @@ -16,14 +16,11 @@ //! Kusama-to-Polkadot messages sync entrypoint. -use codec::Encode; use frame_support::weights::Weight; -use sp_core::{Bytes, Pair}; use messages_relay::relay_strategy::MixStrategy; use relay_kusama_client::Kusama; use relay_polkadot_client::Polkadot; -use relay_substrate_client::{Client, SignParam, TransactionSignScheme, UnsignedTransaction}; use substrate_relay_helper::messages_lane::SubstrateMessageLane; /// Description of Kusama -> Polkadot messages bridge. @@ -41,6 +38,13 @@ substrate_relay_helper::generate_mocked_receive_message_delivery_proof_call_buil relay_kusama_client::runtime::Call::BridgePolkadotMessages, relay_kusama_client::runtime::BridgePolkadotMessagesCall::receive_messages_delivery_proof ); +substrate_relay_helper::generate_mocked_update_conversion_rate_call_builder!( + Kusama, + KusamaMessagesToPolkadotUpdateConversionRateCallBuilder, + relay_kusama_client::runtime::Call::BridgePolkadotMessages, + relay_kusama_client::runtime::BridgePolkadotMessagesCall::update_pallet_parameter, + relay_kusama_client::runtime::BridgePolkadotMessagesParameter::PolkadotToKusamaConversionRate +); impl SubstrateMessageLane for KusamaMessagesToPolkadot { const SOURCE_TO_TARGET_CONVERSION_RATE_PARAMETER_NAME: Option<&'static str> = @@ -48,6 +52,16 @@ impl SubstrateMessageLane for KusamaMessagesToPolkadot { const TARGET_TO_SOURCE_CONVERSION_RATE_PARAMETER_NAME: Option<&'static str> = Some(bp_kusama::POLKADOT_TO_KUSAMA_CONVERSION_RATE_PARAMETER_NAME); + const SOURCE_FEE_MULTIPLIER_PARAMETER_NAME: Option<&'static str> = + Some(bp_polkadot::KUSAMA_FEE_MULTIPLIER_PARAMETER_NAME); + const TARGET_FEE_MULTIPLIER_PARAMETER_NAME: Option<&'static str> = + Some(bp_kusama::POLKADOT_FEE_MULTIPLIER_PARAMETER_NAME); + + const AT_SOURCE_TRANSACTION_PAYMENT_PALLET_NAME: Option<&'static str> = + Some(bp_kusama::TRANSACTION_PAYMENT_PALLET_NAME); + const AT_TARGET_TRANSACTION_PAYMENT_PALLET_NAME: Option<&'static str> = + Some(bp_polkadot::TRANSACTION_PAYMENT_PALLET_NAME); + type SourceChain = Kusama; type TargetChain = Polkadot; @@ -58,42 +72,8 @@ impl SubstrateMessageLane for KusamaMessagesToPolkadot { type ReceiveMessagesDeliveryProofCallBuilder = KusamaMessagesToPolkadotReceiveMessagesDeliveryProofCallBuilder; - type RelayStrategy = MixStrategy; -} + type TargetToSourceChainConversionRateUpdateBuilder = + KusamaMessagesToPolkadotUpdateConversionRateCallBuilder; -/// Update Polkadot -> Kusama conversion rate, stored in Kusama runtime storage. -pub(crate) async fn update_polkadot_to_kusama_conversion_rate( - client: Client, - signer: ::AccountKeyPair, - updated_rate: f64, -) -> anyhow::Result<()> { - let genesis_hash = *client.genesis_hash(); - let signer_id = (*signer.public().as_array_ref()).into(); - let (spec_version, transaction_version) = client.simple_runtime_version().await?; - client - .submit_signed_extrinsic(signer_id, move |_, transaction_nonce| { - Bytes( - Kusama::sign_transaction(SignParam { - spec_version, - transaction_version, - genesis_hash, - signer, - era: relay_substrate_client::TransactionEra::immortal(), - unsigned: UnsignedTransaction::new( - relay_kusama_client::runtime::Call::BridgePolkadotMessages( - relay_kusama_client::runtime::BridgePolkadotMessagesCall::update_pallet_parameter( - relay_kusama_client::runtime::BridgePolkadotMessagesParameter::PolkadotToKusamaConversionRate( - sp_runtime::FixedU128::from_float(updated_rate), - ) - ) - ), - transaction_nonce, - ), - }) - .encode(), - ) - }) - .await - .map(drop) - .map_err(|err| anyhow::format_err!("{:?}", err)) + type RelayStrategy = MixStrategy; } diff --git a/relays/bin-substrate/src/chains/millau.rs b/relays/bin-substrate/src/chains/millau.rs index 3d599c2e545..1fc1e8308ef 100644 --- a/relays/bin-substrate/src/chains/millau.rs +++ b/relays/bin-substrate/src/chains/millau.rs @@ -25,24 +25,27 @@ use crate::cli::{ }; use anyhow::anyhow; use bp_message_dispatch::{CallOrigin, MessagePayload}; +use bp_runtime::EncodedOrDecodedCall; use codec::Decode; use frame_support::weights::{DispatchInfo, GetDispatchInfo}; use relay_millau_client::Millau; use sp_version::RuntimeVersion; impl CliEncodeCall for Millau { - fn encode_call(call: &Call) -> anyhow::Result { + fn encode_call(call: &Call) -> anyhow::Result> { Ok(match call { - Call::Raw { data } => Decode::decode(&mut &*data.0)?, + Call::Raw { data } => Self::Call::decode(&mut &*data.0)?.into(), Call::Remark { remark_payload, .. } => millau_runtime::Call::System(millau_runtime::SystemCall::remark { remark: remark_payload.as_ref().map(|x| x.0.clone()).unwrap_or_default(), - }), + }) + .into(), Call::Transfer { recipient, amount } => millau_runtime::Call::Balances(millau_runtime::BalancesCall::transfer { dest: recipient.raw_id(), value: amount.cast(), - }), + }) + .into(), Call::BridgeSendMessage { lane, payload, fee, bridge_instance_index } => match *bridge_instance_index { bridge::MILLAU_TO_RIALTO_INDEX => { @@ -54,6 +57,7 @@ impl CliEncodeCall for Millau { delivery_and_dispatch_fee: fee.cast(), }, ) + .into() }, _ => anyhow::bail!( "Unsupported target bridge pallet with instance index: {}", @@ -63,8 +67,8 @@ impl CliEncodeCall for Millau { }) } - fn get_dispatch_info(call: &millau_runtime::Call) -> anyhow::Result { - Ok(call.get_dispatch_info()) + fn get_dispatch_info(call: &EncodedOrDecodedCall) -> anyhow::Result { + Ok(call.to_decoded()?.get_dispatch_info()) } } @@ -90,7 +94,7 @@ impl CliChain for Millau { match message { encode_message::MessagePayload::Raw { data } => MessagePayload::decode(&mut &*data.0) .map_err(|e| anyhow!("Failed to decode Millau's MessagePayload: {:?}", e)), - encode_message::MessagePayload::Call { mut call, mut sender } => { + encode_message::MessagePayload::Call { mut call, mut sender, dispatch_weight } => { type Source = Millau; type Target = relay_rialto_client::Rialto; @@ -102,11 +106,13 @@ impl CliChain for Millau { bridge::MILLAU_TO_RIALTO_INDEX, ); let call = Target::encode_call(&call)?; - let weight = call.get_dispatch_info().weight; + let dispatch_weight = dispatch_weight.map(Ok).unwrap_or_else(|| { + call.to_decoded().map(|call| call.get_dispatch_info().weight) + })?; Ok(send_message::message_payload( spec_version, - weight, + dispatch_weight, origin, &call, DispatchFeePayment::AtSourceChain, diff --git a/relays/bin-substrate/src/chains/millau_messages_to_rialto.rs b/relays/bin-substrate/src/chains/millau_messages_to_rialto.rs index a4966029435..f20669e6c7a 100644 --- a/relays/bin-substrate/src/chains/millau_messages_to_rialto.rs +++ b/relays/bin-substrate/src/chains/millau_messages_to_rialto.rs @@ -16,13 +16,9 @@ //! Millau-to-Rialto messages sync entrypoint. -use codec::Encode; -use sp_core::{Bytes, Pair}; - use messages_relay::relay_strategy::MixStrategy; use relay_millau_client::Millau; use relay_rialto_client::Rialto; -use relay_substrate_client::{Client, SignParam, TransactionSignScheme, UnsignedTransaction}; use substrate_relay_helper::messages_lane::{ DirectReceiveMessagesDeliveryProofCallBuilder, DirectReceiveMessagesProofCallBuilder, SubstrateMessageLane, @@ -31,6 +27,13 @@ use substrate_relay_helper::messages_lane::{ /// Description of Millau -> Rialto messages bridge. #[derive(Clone, Debug)] pub struct MillauMessagesToRialto; +substrate_relay_helper::generate_direct_update_conversion_rate_call_builder!( + Millau, + MillauMessagesToRialtoUpdateConversionRateCallBuilder, + millau_runtime::Runtime, + millau_runtime::WithRialtoMessagesInstance, + millau_runtime::rialto_messages::MillauToRialtoMessagesParameter::RialtoToMillauConversionRate +); impl SubstrateMessageLane for MillauMessagesToRialto { const SOURCE_TO_TARGET_CONVERSION_RATE_PARAMETER_NAME: Option<&'static str> = @@ -38,6 +41,11 @@ impl SubstrateMessageLane for MillauMessagesToRialto { const TARGET_TO_SOURCE_CONVERSION_RATE_PARAMETER_NAME: Option<&'static str> = Some(bp_millau::RIALTO_TO_MILLAU_CONVERSION_RATE_PARAMETER_NAME); + const SOURCE_FEE_MULTIPLIER_PARAMETER_NAME: Option<&'static str> = None; + const TARGET_FEE_MULTIPLIER_PARAMETER_NAME: Option<&'static str> = None; + const AT_SOURCE_TRANSACTION_PAYMENT_PALLET_NAME: Option<&'static str> = None; + const AT_TARGET_TRANSACTION_PAYMENT_PALLET_NAME: Option<&'static str> = None; + type SourceChain = Millau; type TargetChain = Rialto; @@ -55,41 +63,8 @@ impl SubstrateMessageLane for MillauMessagesToRialto { millau_runtime::WithRialtoMessagesInstance, >; - type RelayStrategy = MixStrategy; -} + type TargetToSourceChainConversionRateUpdateBuilder = + MillauMessagesToRialtoUpdateConversionRateCallBuilder; -/// Update Rialto -> Millau conversion rate, stored in Millau runtime storage. -pub(crate) async fn update_rialto_to_millau_conversion_rate( - client: Client, - signer: ::AccountKeyPair, - updated_rate: f64, -) -> anyhow::Result<()> { - let genesis_hash = *client.genesis_hash(); - let signer_id = (*signer.public().as_array_ref()).into(); - let (spec_version, transaction_version) = client.simple_runtime_version().await?; - client - .submit_signed_extrinsic(signer_id, move |_, transaction_nonce| { - Bytes( - Millau::sign_transaction(SignParam { - spec_version, - transaction_version, - genesis_hash, - signer, - era: relay_substrate_client::TransactionEra::immortal(), - unsigned: UnsignedTransaction::new( - millau_runtime::MessagesCall::update_pallet_parameter { - parameter: millau_runtime::rialto_messages::MillauToRialtoMessagesParameter::RialtoToMillauConversionRate( - sp_runtime::FixedU128::from_float(updated_rate), - ), - } - .into(), - transaction_nonce, - ), - }) - .encode(), - ) - }) - .await - .map(drop) - .map_err(|err| anyhow::format_err!("{:?}", err)) + type RelayStrategy = MixStrategy; } diff --git a/relays/bin-substrate/src/chains/mod.rs b/relays/bin-substrate/src/chains/mod.rs index e2a7a9a2b1e..16901143e19 100644 --- a/relays/bin-substrate/src/chains/mod.rs +++ b/relays/bin-substrate/src/chains/mod.rs @@ -210,8 +210,9 @@ mod tests { genesis_hash: Default::default(), signer: sp_keyring::AccountKeyring::Alice.pair(), era: relay_substrate_client::TransactionEra::immortal(), - unsigned: UnsignedTransaction::new(rialto_call.clone(), 0), - }); + unsigned: UnsignedTransaction::new(rialto_call.clone().into(), 0), + }) + .unwrap(); let extra_bytes_in_transaction = rialto_tx.encode().len() - rialto_call.encode().len(); assert!( bp_rialto::TX_EXTRA_BYTES as usize >= extra_bytes_in_transaction, @@ -231,8 +232,9 @@ mod tests { genesis_hash: Default::default(), signer: sp_keyring::AccountKeyring::Alice.pair(), era: relay_substrate_client::TransactionEra::immortal(), - unsigned: UnsignedTransaction::new(millau_call.clone(), 0), - }); + unsigned: UnsignedTransaction::new(millau_call.clone().into(), 0), + }) + .unwrap(); let extra_bytes_in_transaction = millau_tx.encode().len() - millau_call.encode().len(); assert!( bp_millau::TX_EXTRA_BYTES as usize >= extra_bytes_in_transaction, diff --git a/relays/bin-substrate/src/chains/polkadot.rs b/relays/bin-substrate/src/chains/polkadot.rs index 16d44f46873..7ae1cbc4777 100644 --- a/relays/bin-substrate/src/chains/polkadot.rs +++ b/relays/bin-substrate/src/chains/polkadot.rs @@ -14,6 +14,9 @@ // You should have received a copy of the GNU General Public License // along with Parity Bridges Common. If not, see . +use anyhow::anyhow; +use bp_message_dispatch::{CallOrigin, MessagePayload}; +use bp_runtime::EncodedOrDecodedCall; use codec::Decode; use frame_support::weights::{DispatchClass, DispatchInfo, Pays, Weight}; use relay_polkadot_client::Polkadot; @@ -21,8 +24,10 @@ use sp_version::RuntimeVersion; use crate::cli::{ bridge, - encode_call::{Call, CliEncodeCall}, - encode_message, CliChain, + encode_call::{self, Call, CliEncodeCall}, + encode_message, + send_message::{self, DispatchFeePayment}, + CliChain, }; /// Weight of the `system::remark` call at Polkadot. @@ -32,13 +37,15 @@ use crate::cli::{ pub(crate) const SYSTEM_REMARK_CALL_WEIGHT: Weight = 2 * 1_345_000; impl CliEncodeCall for Polkadot { - fn encode_call(call: &Call) -> anyhow::Result { + fn encode_call(call: &Call) -> anyhow::Result> { Ok(match call { + Call::Raw { data } => EncodedOrDecodedCall::Encoded(data.0.clone()), Call::Remark { remark_payload, .. } => relay_polkadot_client::runtime::Call::System( relay_polkadot_client::runtime::SystemCall::remark( remark_payload.as_ref().map(|x| x.0.clone()).unwrap_or_default(), ), - ), + ) + .into(), Call::BridgeSendMessage { lane, payload, fee, bridge_instance_index } => match *bridge_instance_index { bridge::POLKADOT_TO_KUSAMA_INDEX => { @@ -48,6 +55,7 @@ impl CliEncodeCall for Polkadot { lane.0, payload, fee.0, ), ) + .into() }, _ => anyhow::bail!( "Unsupported target bridge pallet with instance index: {}", @@ -58,13 +66,11 @@ impl CliEncodeCall for Polkadot { }) } - fn get_dispatch_info( - call: &relay_polkadot_client::runtime::Call, - ) -> anyhow::Result { + fn get_dispatch_info(call: &EncodedOrDecodedCall) -> anyhow::Result { match *call { - relay_polkadot_client::runtime::Call::System( + EncodedOrDecodedCall::Decoded(relay_polkadot_client::runtime::Call::System( relay_polkadot_client::runtime::SystemCall::remark(_), - ) => Ok(DispatchInfo { + )) => Ok(DispatchInfo { weight: crate::chains::polkadot::SYSTEM_REMARK_CALL_WEIGHT, class: DispatchClass::Normal, pays_fee: Pays::Yes, @@ -78,7 +84,12 @@ impl CliChain for Polkadot { const RUNTIME_VERSION: RuntimeVersion = bp_polkadot::VERSION; type KeyPair = sp_core::sr25519::Pair; - type MessagePayload = (); + type MessagePayload = MessagePayload< + bp_polkadot::AccountId, + bp_kusama::AccountPublic, + bp_kusama::Signature, + Vec, + >; fn ss58_format() -> u16 { sp_core::crypto::Ss58AddressFormat::from( @@ -88,8 +99,37 @@ impl CliChain for Polkadot { } fn encode_message( - _message: encode_message::MessagePayload, + message: encode_message::MessagePayload, ) -> anyhow::Result { - anyhow::bail!("Sending messages from Polkadot is not yet supported.") + match message { + encode_message::MessagePayload::Raw { data } => MessagePayload::decode(&mut &*data.0) + .map_err(|e| anyhow!("Failed to decode Polkadot's MessagePayload: {:?}", e)), + encode_message::MessagePayload::Call { mut call, mut sender, dispatch_weight } => { + type Source = Polkadot; + type Target = relay_kusama_client::Kusama; + + sender.enforce_chain::(); + let spec_version = Target::RUNTIME_VERSION.spec_version; + let origin = CallOrigin::SourceAccount(sender.raw_id()); + encode_call::preprocess_call::( + &mut call, + bridge::POLKADOT_TO_KUSAMA_INDEX, + ); + let call = Target::encode_call(&call)?; + let dispatch_weight = dispatch_weight.map(Ok).unwrap_or_else(|| { + Err(anyhow::format_err!( + "Please specify dispatch weight of the encoded Kusama call" + )) + })?; + + Ok(send_message::message_payload( + spec_version, + dispatch_weight, + origin, + &call, + DispatchFeePayment::AtSourceChain, + )) + }, + } } } diff --git a/relays/bin-substrate/src/chains/polkadot_headers_to_kusama.rs b/relays/bin-substrate/src/chains/polkadot_headers_to_kusama.rs index 27bcb245789..6d118b07caa 100644 --- a/relays/bin-substrate/src/chains/polkadot_headers_to_kusama.rs +++ b/relays/bin-substrate/src/chains/polkadot_headers_to_kusama.rs @@ -24,8 +24,13 @@ use substrate_relay_helper::{finality_pipeline::SubstrateFinalitySyncPipeline, T /// relay as gone wild. /// /// Actual value, returned by `maximal_balance_decrease_per_day_is_sane` test is approximately 0.001 -/// KSM, but let's round up to 0.1 KSM here. -pub(crate) const MAXIMAL_BALANCE_DECREASE_PER_DAY: bp_polkadot::Balance = 100_000_000_000; +/// KSM, and initial value of this constant was rounded up to 0.1 KSM. But for actual Kusama <> +/// Polkadot deployment we'll be using the same account for delivering finality (free for mandatory +/// headers) and messages. It means that we can't predict maximal loss. But to protect funds against +/// relay/deployment issues, let's limit it so something that is much larger than this estimation - +/// e.g. to 2 KSM. +// TODO: https://github.com/paritytech/parity-bridges-common/issues/1307 +pub(crate) const MAXIMAL_BALANCE_DECREASE_PER_DAY: bp_kusama::Balance = 2 * 1_000_000_000_000; /// Description of Polkadot -> Kusama finalized headers bridge. #[derive(Clone, Debug)] diff --git a/relays/bin-substrate/src/chains/polkadot_messages_to_kusama.rs b/relays/bin-substrate/src/chains/polkadot_messages_to_kusama.rs index 5eeb0df3f12..9c4a4640eb9 100644 --- a/relays/bin-substrate/src/chains/polkadot_messages_to_kusama.rs +++ b/relays/bin-substrate/src/chains/polkadot_messages_to_kusama.rs @@ -16,14 +16,10 @@ //! Polkadot-to-Kusama messages sync entrypoint. -use codec::Encode; -use sp_core::{Bytes, Pair}; - use frame_support::weights::Weight; use messages_relay::relay_strategy::MixStrategy; use relay_kusama_client::Kusama; use relay_polkadot_client::Polkadot; -use relay_substrate_client::{Client, SignParam, TransactionSignScheme, UnsignedTransaction}; use substrate_relay_helper::messages_lane::SubstrateMessageLane; /// Description of Polkadot -> Kusama messages bridge. @@ -41,6 +37,13 @@ substrate_relay_helper::generate_mocked_receive_message_delivery_proof_call_buil relay_polkadot_client::runtime::Call::BridgeKusamaMessages, relay_polkadot_client::runtime::BridgeKusamaMessagesCall::receive_messages_delivery_proof ); +substrate_relay_helper::generate_mocked_update_conversion_rate_call_builder!( + Polkadot, + PolkadotMessagesToKusamaUpdateConversionRateCallBuilder, + relay_polkadot_client::runtime::Call::BridgeKusamaMessages, + relay_polkadot_client::runtime::BridgeKusamaMessagesCall::update_pallet_parameter, + relay_polkadot_client::runtime::BridgeKusamaMessagesParameter::KusamaToPolkadotConversionRate +); impl SubstrateMessageLane for PolkadotMessagesToKusama { const SOURCE_TO_TARGET_CONVERSION_RATE_PARAMETER_NAME: Option<&'static str> = @@ -48,6 +51,16 @@ impl SubstrateMessageLane for PolkadotMessagesToKusama { const TARGET_TO_SOURCE_CONVERSION_RATE_PARAMETER_NAME: Option<&'static str> = Some(bp_polkadot::KUSAMA_TO_POLKADOT_CONVERSION_RATE_PARAMETER_NAME); + const SOURCE_FEE_MULTIPLIER_PARAMETER_NAME: Option<&'static str> = + Some(bp_kusama::POLKADOT_FEE_MULTIPLIER_PARAMETER_NAME); + const TARGET_FEE_MULTIPLIER_PARAMETER_NAME: Option<&'static str> = + Some(bp_polkadot::KUSAMA_FEE_MULTIPLIER_PARAMETER_NAME); + + const AT_SOURCE_TRANSACTION_PAYMENT_PALLET_NAME: Option<&'static str> = + Some(bp_polkadot::TRANSACTION_PAYMENT_PALLET_NAME); + const AT_TARGET_TRANSACTION_PAYMENT_PALLET_NAME: Option<&'static str> = + Some(bp_kusama::TRANSACTION_PAYMENT_PALLET_NAME); + type SourceChain = Polkadot; type TargetChain = Kusama; @@ -58,42 +71,8 @@ impl SubstrateMessageLane for PolkadotMessagesToKusama { type ReceiveMessagesDeliveryProofCallBuilder = PolkadotMessagesToKusamaReceiveMessagesDeliveryProofCallBuilder; - type RelayStrategy = MixStrategy; -} + type TargetToSourceChainConversionRateUpdateBuilder = + PolkadotMessagesToKusamaUpdateConversionRateCallBuilder; -/// Update Kusama -> Polkadot conversion rate, stored in Polkadot runtime storage. -pub(crate) async fn update_kusama_to_polkadot_conversion_rate( - client: Client, - signer: ::AccountKeyPair, - updated_rate: f64, -) -> anyhow::Result<()> { - let genesis_hash = *client.genesis_hash(); - let signer_id = (*signer.public().as_array_ref()).into(); - let (spec_version, transaction_version) = client.simple_runtime_version().await?; - client - .submit_signed_extrinsic(signer_id, move |_, transaction_nonce| { - Bytes( - Polkadot::sign_transaction(SignParam { - spec_version, - transaction_version, - genesis_hash, - signer, - era: relay_substrate_client::TransactionEra::immortal(), - unsigned: UnsignedTransaction::new( - relay_polkadot_client::runtime::Call::BridgeKusamaMessages( - relay_polkadot_client::runtime::BridgeKusamaMessagesCall::update_pallet_parameter( - relay_polkadot_client::runtime::BridgeKusamaMessagesParameter::KusamaToPolkadotConversionRate( - sp_runtime::FixedU128::from_float(updated_rate), - ) - ) - ), - transaction_nonce, - ) - }) - .encode(), - ) - }) - .await - .map(drop) - .map_err(|err| anyhow::format_err!("{:?}", err)) + type RelayStrategy = MixStrategy; } diff --git a/relays/bin-substrate/src/chains/rialto.rs b/relays/bin-substrate/src/chains/rialto.rs index 8931c5112da..8f26a64a4e3 100644 --- a/relays/bin-substrate/src/chains/rialto.rs +++ b/relays/bin-substrate/src/chains/rialto.rs @@ -25,24 +25,27 @@ use crate::cli::{ }; use anyhow::anyhow; use bp_message_dispatch::{CallOrigin, MessagePayload}; +use bp_runtime::EncodedOrDecodedCall; use codec::Decode; use frame_support::weights::{DispatchInfo, GetDispatchInfo}; use relay_rialto_client::Rialto; use sp_version::RuntimeVersion; impl CliEncodeCall for Rialto { - fn encode_call(call: &Call) -> anyhow::Result { + fn encode_call(call: &Call) -> anyhow::Result> { Ok(match call { - Call::Raw { data } => Decode::decode(&mut &*data.0)?, + Call::Raw { data } => Self::Call::decode(&mut &*data.0)?.into(), Call::Remark { remark_payload, .. } => rialto_runtime::Call::System(rialto_runtime::SystemCall::remark { remark: remark_payload.as_ref().map(|x| x.0.clone()).unwrap_or_default(), - }), + }) + .into(), Call::Transfer { recipient, amount } => rialto_runtime::Call::Balances(rialto_runtime::BalancesCall::transfer { dest: recipient.raw_id().into(), value: amount.0, - }), + }) + .into(), Call::BridgeSendMessage { lane, payload, fee, bridge_instance_index } => match *bridge_instance_index { bridge::RIALTO_TO_MILLAU_INDEX => { @@ -54,6 +57,7 @@ impl CliEncodeCall for Rialto { delivery_and_dispatch_fee: fee.0, }, ) + .into() }, _ => anyhow::bail!( "Unsupported target bridge pallet with instance index: {}", @@ -63,8 +67,8 @@ impl CliEncodeCall for Rialto { }) } - fn get_dispatch_info(call: &rialto_runtime::Call) -> anyhow::Result { - Ok(call.get_dispatch_info()) + fn get_dispatch_info(call: &EncodedOrDecodedCall) -> anyhow::Result { + Ok(call.to_decoded()?.get_dispatch_info()) } } @@ -89,7 +93,7 @@ impl CliChain for Rialto { match message { encode_message::MessagePayload::Raw { data } => MessagePayload::decode(&mut &*data.0) .map_err(|e| anyhow!("Failed to decode Rialto's MessagePayload: {:?}", e)), - encode_message::MessagePayload::Call { mut call, mut sender } => { + encode_message::MessagePayload::Call { mut call, mut sender, dispatch_weight } => { type Source = Rialto; type Target = relay_millau_client::Millau; @@ -101,11 +105,13 @@ impl CliChain for Rialto { bridge::RIALTO_TO_MILLAU_INDEX, ); let call = Target::encode_call(&call)?; - let weight = call.get_dispatch_info().weight; + let dispatch_weight = dispatch_weight.map(Ok).unwrap_or_else(|| { + call.to_decoded().map(|call| call.get_dispatch_info().weight) + })?; Ok(send_message::message_payload( spec_version, - weight, + dispatch_weight, origin, &call, DispatchFeePayment::AtSourceChain, diff --git a/relays/bin-substrate/src/chains/rialto_messages_to_millau.rs b/relays/bin-substrate/src/chains/rialto_messages_to_millau.rs index 4c7ad8e6219..d34f4714644 100644 --- a/relays/bin-substrate/src/chains/rialto_messages_to_millau.rs +++ b/relays/bin-substrate/src/chains/rialto_messages_to_millau.rs @@ -16,13 +16,9 @@ //! Rialto-to-Millau messages sync entrypoint. -use codec::Encode; -use sp_core::{Bytes, Pair}; - use messages_relay::relay_strategy::MixStrategy; use relay_millau_client::Millau; use relay_rialto_client::Rialto; -use relay_substrate_client::{Client, SignParam, TransactionSignScheme, UnsignedTransaction}; use substrate_relay_helper::messages_lane::{ DirectReceiveMessagesDeliveryProofCallBuilder, DirectReceiveMessagesProofCallBuilder, SubstrateMessageLane, @@ -31,6 +27,13 @@ use substrate_relay_helper::messages_lane::{ /// Description of Rialto -> Millau messages bridge. #[derive(Clone, Debug)] pub struct RialtoMessagesToMillau; +substrate_relay_helper::generate_direct_update_conversion_rate_call_builder!( + Rialto, + RialtoMessagesToMillauUpdateConversionRateCallBuilder, + rialto_runtime::Runtime, + rialto_runtime::WithMillauMessagesInstance, + rialto_runtime::millau_messages::RialtoToMillauMessagesParameter::MillauToRialtoConversionRate +); impl SubstrateMessageLane for RialtoMessagesToMillau { const SOURCE_TO_TARGET_CONVERSION_RATE_PARAMETER_NAME: Option<&'static str> = @@ -38,6 +41,11 @@ impl SubstrateMessageLane for RialtoMessagesToMillau { const TARGET_TO_SOURCE_CONVERSION_RATE_PARAMETER_NAME: Option<&'static str> = Some(bp_rialto::MILLAU_TO_RIALTO_CONVERSION_RATE_PARAMETER_NAME); + const SOURCE_FEE_MULTIPLIER_PARAMETER_NAME: Option<&'static str> = None; + const TARGET_FEE_MULTIPLIER_PARAMETER_NAME: Option<&'static str> = None; + const AT_SOURCE_TRANSACTION_PAYMENT_PALLET_NAME: Option<&'static str> = None; + const AT_TARGET_TRANSACTION_PAYMENT_PALLET_NAME: Option<&'static str> = None; + type SourceChain = Rialto; type TargetChain = Millau; @@ -55,41 +63,8 @@ impl SubstrateMessageLane for RialtoMessagesToMillau { rialto_runtime::WithMillauMessagesInstance, >; - type RelayStrategy = MixStrategy; -} + type TargetToSourceChainConversionRateUpdateBuilder = + RialtoMessagesToMillauUpdateConversionRateCallBuilder; -/// Update Millau -> Rialto conversion rate, stored in Rialto runtime storage. -pub(crate) async fn update_millau_to_rialto_conversion_rate( - client: Client, - signer: ::AccountKeyPair, - updated_rate: f64, -) -> anyhow::Result<()> { - let genesis_hash = *client.genesis_hash(); - let signer_id = (*signer.public().as_array_ref()).into(); - let (spec_version, transaction_version) = client.simple_runtime_version().await?; - client - .submit_signed_extrinsic(signer_id, move |_, transaction_nonce| { - Bytes( - Rialto::sign_transaction(SignParam { - spec_version, - transaction_version, - genesis_hash, - signer, - era: relay_substrate_client::TransactionEra::immortal(), - unsigned: UnsignedTransaction::new( - rialto_runtime::MessagesCall::update_pallet_parameter { - parameter: rialto_runtime::millau_messages::RialtoToMillauMessagesParameter::MillauToRialtoConversionRate( - sp_runtime::FixedU128::from_float(updated_rate), - ), - } - .into(), - transaction_nonce, - ) - }) - .encode(), - ) - }) - .await - .map(drop) - .map_err(|err| anyhow::format_err!("{:?}", err)) + type RelayStrategy = MixStrategy; } diff --git a/relays/bin-substrate/src/chains/rialto_parachain.rs b/relays/bin-substrate/src/chains/rialto_parachain.rs index da400a4dafd..0ed39faa543 100644 --- a/relays/bin-substrate/src/chains/rialto_parachain.rs +++ b/relays/bin-substrate/src/chains/rialto_parachain.rs @@ -21,34 +21,37 @@ use crate::cli::{ encode_message, CliChain, }; use bp_message_dispatch::MessagePayload; +use bp_runtime::EncodedOrDecodedCall; use codec::Decode; use frame_support::weights::{DispatchInfo, GetDispatchInfo}; use relay_rialto_parachain_client::RialtoParachain; use sp_version::RuntimeVersion; impl CliEncodeCall for RialtoParachain { - fn encode_call(call: &Call) -> anyhow::Result { + fn encode_call(call: &Call) -> anyhow::Result> { Ok(match call { - Call::Raw { data } => Decode::decode(&mut &*data.0)?, + Call::Raw { data } => Self::Call::decode(&mut &*data.0)?.into(), Call::Remark { remark_payload, .. } => rialto_parachain_runtime::Call::System( rialto_parachain_runtime::SystemCall::remark { remark: remark_payload.as_ref().map(|x| x.0.clone()).unwrap_or_default(), }, - ), + ) + .into(), Call::Transfer { recipient, amount } => rialto_parachain_runtime::Call::Balances( rialto_parachain_runtime::BalancesCall::transfer { dest: recipient.raw_id().into(), value: amount.0, }, - ), + ) + .into(), Call::BridgeSendMessage { .. } => { anyhow::bail!("Bridge messages are not (yet) supported here",) }, }) } - fn get_dispatch_info(call: &rialto_parachain_runtime::Call) -> anyhow::Result { - Ok(call.get_dispatch_info()) + fn get_dispatch_info(call: &EncodedOrDecodedCall) -> anyhow::Result { + Ok(call.to_decoded()?.get_dispatch_info()) } } diff --git a/relays/bin-substrate/src/chains/rococo.rs b/relays/bin-substrate/src/chains/rococo.rs index ef49899ec79..ceef4c1f532 100644 --- a/relays/bin-substrate/src/chains/rococo.rs +++ b/relays/bin-substrate/src/chains/rococo.rs @@ -15,6 +15,8 @@ // along with Parity Bridges Common. If not, see . use anyhow::anyhow; +use bp_message_dispatch::{CallOrigin, MessagePayload}; +use bp_runtime::EncodedOrDecodedCall; use codec::Decode; use frame_support::weights::{DispatchClass, DispatchInfo, Pays, Weight}; use relay_rococo_client::Rococo; @@ -22,8 +24,10 @@ use sp_version::RuntimeVersion; use crate::cli::{ bridge, - encode_call::{Call, CliEncodeCall}, - encode_message, CliChain, + encode_call::{self, Call, CliEncodeCall}, + encode_message, + send_message::{self, DispatchFeePayment}, + CliChain, }; /// Weight of the `system::remark` call at Rococo. @@ -33,13 +37,15 @@ use crate::cli::{ pub(crate) const SYSTEM_REMARK_CALL_WEIGHT: Weight = 2 * 1_345_000; impl CliEncodeCall for Rococo { - fn encode_call(call: &Call) -> anyhow::Result { + fn encode_call(call: &Call) -> anyhow::Result> { Ok(match call { + Call::Raw { data } => EncodedOrDecodedCall::Encoded(data.0.clone()), Call::Remark { remark_payload, .. } => relay_rococo_client::runtime::Call::System( relay_rococo_client::runtime::SystemCall::remark( remark_payload.as_ref().map(|x| x.0.clone()).unwrap_or_default(), ), - ), + ) + .into(), Call::BridgeSendMessage { lane, payload, fee, bridge_instance_index } => match *bridge_instance_index { bridge::ROCOCO_TO_WOCOCO_INDEX => { @@ -49,6 +55,7 @@ impl CliEncodeCall for Rococo { lane.0, payload, fee.0, ), ) + .into() }, _ => anyhow::bail!( "Unsupported target bridge pallet with instance index: {}", @@ -59,13 +66,11 @@ impl CliEncodeCall for Rococo { }) } - fn get_dispatch_info( - call: &relay_rococo_client::runtime::Call, - ) -> anyhow::Result { + fn get_dispatch_info(call: &EncodedOrDecodedCall) -> anyhow::Result { match *call { - relay_rococo_client::runtime::Call::System( + EncodedOrDecodedCall::Decoded(relay_rococo_client::runtime::Call::System( relay_rococo_client::runtime::SystemCall::remark(_), - ) => Ok(DispatchInfo { + )) => Ok(DispatchInfo { weight: SYSTEM_REMARK_CALL_WEIGHT, class: DispatchClass::Normal, pays_fee: Pays::Yes, @@ -79,15 +84,49 @@ impl CliChain for Rococo { const RUNTIME_VERSION: RuntimeVersion = bp_rococo::VERSION; type KeyPair = sp_core::sr25519::Pair; - type MessagePayload = (); + type MessagePayload = MessagePayload< + bp_rococo::AccountId, + bp_wococo::AccountPublic, + bp_wococo::Signature, + Vec, + >; fn ss58_format() -> u16 { 42 } fn encode_message( - _message: encode_message::MessagePayload, + message: encode_message::MessagePayload, ) -> anyhow::Result { - Err(anyhow!("Sending messages from Rococo is not yet supported.")) + match message { + encode_message::MessagePayload::Raw { data } => MessagePayload::decode(&mut &*data.0) + .map_err(|e| anyhow!("Failed to decode Rococo's MessagePayload: {:?}", e)), + encode_message::MessagePayload::Call { mut call, mut sender, dispatch_weight } => { + type Source = Rococo; + type Target = relay_wococo_client::Wococo; + + sender.enforce_chain::(); + let spec_version = Target::RUNTIME_VERSION.spec_version; + let origin = CallOrigin::SourceAccount(sender.raw_id()); + encode_call::preprocess_call::( + &mut call, + bridge::ROCOCO_TO_WOCOCO_INDEX, + ); + let call = Target::encode_call(&call)?; + let dispatch_weight = dispatch_weight.map(Ok).unwrap_or_else(|| { + Err(anyhow::format_err!( + "Please specify dispatch weight of the encoded Wococo call" + )) + })?; + + Ok(send_message::message_payload( + spec_version, + dispatch_weight, + origin, + &call, + DispatchFeePayment::AtSourceChain, + )) + }, + } } } diff --git a/relays/bin-substrate/src/chains/rococo_messages_to_wococo.rs b/relays/bin-substrate/src/chains/rococo_messages_to_wococo.rs index a85789bb1be..4e67c87fa8c 100644 --- a/relays/bin-substrate/src/chains/rococo_messages_to_wococo.rs +++ b/relays/bin-substrate/src/chains/rococo_messages_to_wococo.rs @@ -42,6 +42,11 @@ impl SubstrateMessageLane for RococoMessagesToWococo { const SOURCE_TO_TARGET_CONVERSION_RATE_PARAMETER_NAME: Option<&'static str> = None; const TARGET_TO_SOURCE_CONVERSION_RATE_PARAMETER_NAME: Option<&'static str> = None; + const SOURCE_FEE_MULTIPLIER_PARAMETER_NAME: Option<&'static str> = None; + const TARGET_FEE_MULTIPLIER_PARAMETER_NAME: Option<&'static str> = None; + const AT_SOURCE_TRANSACTION_PAYMENT_PALLET_NAME: Option<&'static str> = None; + const AT_TARGET_TRANSACTION_PAYMENT_PALLET_NAME: Option<&'static str> = None; + type SourceChain = Rococo; type TargetChain = Wococo; @@ -52,5 +57,7 @@ impl SubstrateMessageLane for RococoMessagesToWococo { type ReceiveMessagesDeliveryProofCallBuilder = RococoMessagesToWococoReceiveMessagesDeliveryProofCallBuilder; + type TargetToSourceChainConversionRateUpdateBuilder = (); + type RelayStrategy = MixStrategy; } diff --git a/relays/bin-substrate/src/chains/wococo.rs b/relays/bin-substrate/src/chains/wococo.rs index 2acc8af4845..46dec2a3c90 100644 --- a/relays/bin-substrate/src/chains/wococo.rs +++ b/relays/bin-substrate/src/chains/wococo.rs @@ -15,6 +15,8 @@ // along with Parity Bridges Common. If not, see . use anyhow::anyhow; +use bp_message_dispatch::{CallOrigin, MessagePayload}; +use bp_runtime::EncodedOrDecodedCall; use codec::Decode; use frame_support::weights::{DispatchClass, DispatchInfo, Pays}; use relay_wococo_client::Wococo; @@ -22,18 +24,22 @@ use sp_version::RuntimeVersion; use crate::cli::{ bridge, - encode_call::{Call, CliEncodeCall}, - encode_message, CliChain, + encode_call::{self, Call, CliEncodeCall}, + encode_message, + send_message::{self, DispatchFeePayment}, + CliChain, }; impl CliEncodeCall for Wococo { - fn encode_call(call: &Call) -> anyhow::Result { + fn encode_call(call: &Call) -> anyhow::Result> { Ok(match call { + Call::Raw { data } => EncodedOrDecodedCall::Encoded(data.0.clone()), Call::Remark { remark_payload, .. } => relay_wococo_client::runtime::Call::System( relay_wococo_client::runtime::SystemCall::remark( remark_payload.as_ref().map(|x| x.0.clone()).unwrap_or_default(), ), - ), + ) + .into(), Call::BridgeSendMessage { lane, payload, fee, bridge_instance_index } => match *bridge_instance_index { bridge::WOCOCO_TO_ROCOCO_INDEX => { @@ -43,6 +49,7 @@ impl CliEncodeCall for Wococo { lane.0, payload, fee.0, ), ) + .into() }, _ => anyhow::bail!( "Unsupported target bridge pallet with instance index: {}", @@ -53,18 +60,16 @@ impl CliEncodeCall for Wococo { }) } - fn get_dispatch_info( - call: &relay_wococo_client::runtime::Call, - ) -> anyhow::Result { + fn get_dispatch_info(call: &EncodedOrDecodedCall) -> anyhow::Result { match *call { - relay_wococo_client::runtime::Call::System( + EncodedOrDecodedCall::Decoded(relay_wococo_client::runtime::Call::System( relay_wococo_client::runtime::SystemCall::remark(_), - ) => Ok(DispatchInfo { + )) => Ok(DispatchInfo { weight: crate::chains::rococo::SYSTEM_REMARK_CALL_WEIGHT, class: DispatchClass::Normal, pays_fee: Pays::Yes, }), - _ => anyhow::bail!("Unsupported Rococo call: {:?}", call), + _ => anyhow::bail!("Unsupported Wococo call: {:?}", call), } } } @@ -73,15 +78,49 @@ impl CliChain for Wococo { const RUNTIME_VERSION: RuntimeVersion = bp_wococo::VERSION; type KeyPair = sp_core::sr25519::Pair; - type MessagePayload = (); + type MessagePayload = MessagePayload< + bp_wococo::AccountId, + bp_rococo::AccountPublic, + bp_rococo::Signature, + Vec, + >; fn ss58_format() -> u16 { 42 } fn encode_message( - _message: encode_message::MessagePayload, + message: encode_message::MessagePayload, ) -> anyhow::Result { - Err(anyhow!("Sending messages from Wococo is not yet supported.")) + match message { + encode_message::MessagePayload::Raw { data } => MessagePayload::decode(&mut &*data.0) + .map_err(|e| anyhow!("Failed to decode Wococo's MessagePayload: {:?}", e)), + encode_message::MessagePayload::Call { mut call, mut sender, dispatch_weight } => { + type Source = Wococo; + type Target = relay_rococo_client::Rococo; + + sender.enforce_chain::(); + let spec_version = Target::RUNTIME_VERSION.spec_version; + let origin = CallOrigin::SourceAccount(sender.raw_id()); + encode_call::preprocess_call::( + &mut call, + bridge::WOCOCO_TO_ROCOCO_INDEX, + ); + let call = Target::encode_call(&call)?; + let dispatch_weight = dispatch_weight.map(Ok).unwrap_or_else(|| { + Err(anyhow::format_err!( + "Please specify dispatch weight of the encoded Rococo call" + )) + })?; + + Ok(send_message::message_payload( + spec_version, + dispatch_weight, + origin, + &call, + DispatchFeePayment::AtSourceChain, + )) + }, + } } } diff --git a/relays/bin-substrate/src/chains/wococo_messages_to_rococo.rs b/relays/bin-substrate/src/chains/wococo_messages_to_rococo.rs index 7c599e41394..2c44803f2c0 100644 --- a/relays/bin-substrate/src/chains/wococo_messages_to_rococo.rs +++ b/relays/bin-substrate/src/chains/wococo_messages_to_rococo.rs @@ -43,6 +43,11 @@ impl SubstrateMessageLane for WococoMessagesToRococo { const SOURCE_TO_TARGET_CONVERSION_RATE_PARAMETER_NAME: Option<&'static str> = None; const TARGET_TO_SOURCE_CONVERSION_RATE_PARAMETER_NAME: Option<&'static str> = None; + const SOURCE_FEE_MULTIPLIER_PARAMETER_NAME: Option<&'static str> = None; + const TARGET_FEE_MULTIPLIER_PARAMETER_NAME: Option<&'static str> = None; + const AT_SOURCE_TRANSACTION_PAYMENT_PALLET_NAME: Option<&'static str> = None; + const AT_TARGET_TRANSACTION_PAYMENT_PALLET_NAME: Option<&'static str> = None; + type SourceChain = Wococo; type TargetChain = Rococo; @@ -53,5 +58,7 @@ impl SubstrateMessageLane for WococoMessagesToRococo { type ReceiveMessagesDeliveryProofCallBuilder = WococoMessagesToRococoReceiveMessagesDeliveryProofCallBuilder; + type TargetToSourceChainConversionRateUpdateBuilder = (); + type RelayStrategy = MixStrategy; } diff --git a/relays/bin-substrate/src/cli/bridge.rs b/relays/bin-substrate/src/cli/bridge.rs index ea16c92c920..2eb836a84a7 100644 --- a/relays/bin-substrate/src/cli/bridge.rs +++ b/relays/bin-substrate/src/cli/bridge.rs @@ -77,11 +77,6 @@ macro_rules! select_full_bridge { #[allow(unused_imports)] use millau_runtime::millau_to_rialto_account_ownership_digest as account_ownership_digest; - #[allow(dead_code)] - const SOURCE_RUNTIME_VERSION: Option = Some(millau_runtime::VERSION); - #[allow(dead_code)] - const TARGET_RUNTIME_VERSION: Option = Some(rialto_runtime::VERSION); - $generic } FullBridge::RialtoToMillau => { @@ -105,11 +100,6 @@ macro_rules! select_full_bridge { #[allow(unused_imports)] use rialto_runtime::rialto_to_millau_account_ownership_digest as account_ownership_digest; - #[allow(dead_code)] - const SOURCE_RUNTIME_VERSION: Option = Some(rialto_runtime::VERSION); - #[allow(dead_code)] - const TARGET_RUNTIME_VERSION: Option = Some(millau_runtime::VERSION); - $generic } FullBridge::RococoToWococo => { @@ -132,11 +122,6 @@ macro_rules! select_full_bridge { #[allow(unused_imports)] use relay_rococo_client::runtime::rococo_to_wococo_account_ownership_digest as account_ownership_digest; - #[allow(dead_code)] - const SOURCE_RUNTIME_VERSION: Option = Some(bp_rococo::VERSION); - #[allow(dead_code)] - const TARGET_RUNTIME_VERSION: Option = Some(bp_wococo::VERSION); - $generic } FullBridge::WococoToRococo => { @@ -159,11 +144,6 @@ macro_rules! select_full_bridge { #[allow(unused_imports)] use relay_wococo_client::runtime::wococo_to_rococo_account_ownership_digest as account_ownership_digest; - #[allow(dead_code)] - const SOURCE_RUNTIME_VERSION: Option = Some(bp_wococo::VERSION); - #[allow(dead_code)] - const TARGET_RUNTIME_VERSION: Option = Some(bp_rococo::VERSION); - $generic } FullBridge::KusamaToPolkadot => { @@ -186,11 +166,6 @@ macro_rules! select_full_bridge { #[allow(unused_imports)] use relay_kusama_client::runtime::kusama_to_polkadot_account_ownership_digest as account_ownership_digest; - #[allow(dead_code)] - const SOURCE_RUNTIME_VERSION: Option = Some(bp_kusama::VERSION); - #[allow(dead_code)] - const TARGET_RUNTIME_VERSION: Option = Some(bp_polkadot::VERSION); - $generic } FullBridge::PolkadotToKusama => { @@ -213,11 +188,6 @@ macro_rules! select_full_bridge { #[allow(unused_imports)] use relay_polkadot_client::runtime::polkadot_to_kusama_account_ownership_digest as account_ownership_digest; - #[allow(dead_code)] - const SOURCE_RUNTIME_VERSION: Option = Some(bp_polkadot::VERSION); - #[allow(dead_code)] - const TARGET_RUNTIME_VERSION: Option = Some(bp_kusama::VERSION); - $generic } } diff --git a/relays/bin-substrate/src/cli/encode_call.rs b/relays/bin-substrate/src/cli/encode_call.rs index 707e7837830..e288e2c13d6 100644 --- a/relays/bin-substrate/src/cli/encode_call.rs +++ b/relays/bin-substrate/src/cli/encode_call.rs @@ -20,6 +20,7 @@ use crate::{ }, select_full_bridge, }; +use bp_runtime::EncodedOrDecodedCall; use frame_support::weights::DispatchInfo; use relay_substrate_client::Chain; use structopt::StructOpt; @@ -85,10 +86,10 @@ pub enum Call { pub trait CliEncodeCall: Chain { /// Encode a CLI call. - fn encode_call(call: &Call) -> anyhow::Result; + fn encode_call(call: &Call) -> anyhow::Result>; /// Get dispatch info for the call. - fn get_dispatch_info(call: &Self::Call) -> anyhow::Result; + fn get_dispatch_info(call: &EncodedOrDecodedCall) -> anyhow::Result; } impl EncodeCall { @@ -100,7 +101,10 @@ impl EncodeCall { let encoded = HexBytes::encode(&call); log::info!(target: "bridge", "Generated {} call: {:#?}", Source::NAME, call); - log::info!(target: "bridge", "Weight of {} call: {}", Source::NAME, Source::get_dispatch_info(&call)?.weight); + log::info!(target: "bridge", "Weight of {} call: {}", Source::NAME, Source::get_dispatch_info(&call) + .map(|dispatch_info| format!("{}", dispatch_info.weight)) + .unwrap_or_else(|_| "".to_string()) + ); log::info!(target: "bridge", "Encoded {} call: {:?}", Source::NAME, encoded); Ok(encoded) diff --git a/relays/bin-substrate/src/cli/encode_message.rs b/relays/bin-substrate/src/cli/encode_message.rs index ee77fc4a46e..677fc29ef15 100644 --- a/relays/bin-substrate/src/cli/encode_message.rs +++ b/relays/bin-substrate/src/cli/encode_message.rs @@ -18,6 +18,7 @@ use crate::{ cli::{bridge::FullBridge, AccountId, CliChain, HexBytes}, select_full_bridge, }; +use frame_support::weights::Weight; use structopt::StructOpt; use strum::VariantNames; @@ -37,6 +38,12 @@ pub enum MessagePayload { /// SS58 encoded Source account that will send the payload. #[structopt(long)] sender: AccountId, + /// Weight of the call. + /// + /// It must be specified if the chain runtime is not bundled with the relay, or if + /// you want to override bundled weight. + #[structopt(long)] + dispatch_weight: Option, }, } @@ -97,6 +104,8 @@ mod tests { "call", "--sender", &sender, + "--dispatch-weight", + "42", "remark", "--remark-size", "12", @@ -106,6 +115,6 @@ mod tests { let hex = encode_message.encode().unwrap(); // then - assert_eq!(format!("{:?}", hex), "0x01000000000000000000000002d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d003c000130000000000000000000000000"); + assert_eq!(format!("{:?}", hex), "0x010000002a0000000000000002d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d003c000130000000000000000000000000"); } } diff --git a/relays/bin-substrate/src/cli/estimate_fee.rs b/relays/bin-substrate/src/cli/estimate_fee.rs index 18e7341fc96..bab625314e8 100644 --- a/relays/bin-substrate/src/cli/estimate_fee.rs +++ b/relays/bin-substrate/src/cli/estimate_fee.rs @@ -15,17 +15,22 @@ // along with Parity Bridges Common. If not, see . use crate::{ - cli::{bridge::FullBridge, Balance, CliChain, HexBytes, HexLaneId, SourceConnectionParams}, + cli::{ + bridge::FullBridge, relay_headers_and_messages::CONVERSION_RATE_ALLOWED_DIFFERENCE_RATIO, + Balance, CliChain, HexBytes, HexLaneId, SourceConnectionParams, + }, select_full_bridge, }; use bp_runtime::BalanceOf; use codec::{Decode, Encode}; use relay_substrate_client::Chain; +use sp_runtime::FixedU128; use structopt::StructOpt; use strum::VariantNames; +use substrate_relay_helper::helpers::tokens_conversion_rate_from_metrics; /// Estimate Delivery & Dispatch Fee command. -#[derive(StructOpt, Debug, PartialEq, Eq)] +#[derive(StructOpt, Debug, PartialEq)] pub struct EstimateFee { /// A bridge instance to encode call for. #[structopt(possible_values = FullBridge::VARIANTS, case_insensitive = true)] @@ -35,24 +40,54 @@ pub struct EstimateFee { /// Hex-encoded id of lane that will be delivering the message. #[structopt(long, default_value = "00000000")] lane: HexLaneId, + /// A way to override conversion rate between bridge tokens. + /// + /// If not specified, conversion rate from runtime storage is used. It may be obsolete and + /// your message won't be relayed. + #[structopt(long)] + conversion_rate_override: Option, /// Payload to send over the bridge. #[structopt(flatten)] payload: crate::cli::encode_message::MessagePayload, } +/// A way to override conversion rate between bridge tokens. +#[derive(Debug, Clone, Copy, PartialEq)] +pub enum ConversionRateOverride { + /// The actual conversion rate is computed in the same way how rate metric works. + Metric, + /// The actual conversion rate is specified explicitly. + Explicit(f64), +} + +impl std::str::FromStr for ConversionRateOverride { + type Err = String; + + fn from_str(s: &str) -> Result { + if s.to_lowercase() == "metric" { + return Ok(ConversionRateOverride::Metric) + } + + f64::from_str(s) + .map(ConversionRateOverride::Explicit) + .map_err(|e| format!("Failed to parse '{:?}'. Expected 'metric' or explicit value", e)) + } +} + impl EstimateFee { /// Run the command. pub async fn run(self) -> anyhow::Result<()> { - let Self { source, bridge, lane, payload } = self; + let Self { source, bridge, lane, conversion_rate_override, payload } = self; select_full_bridge!(bridge, { - let source_client = source.to_client::(SOURCE_RUNTIME_VERSION).await?; + let source_client = source.to_client::().await?; let lane = lane.into(); let payload = Source::encode_message(payload).map_err(|e| anyhow::format_err!("{:?}", e))?; - let fee: BalanceOf = estimate_message_delivery_and_dispatch_fee( + let fee = estimate_message_delivery_and_dispatch_fee::( &source_client, + conversion_rate_override, ESTIMATE_MESSAGE_FEE_METHOD, lane, payload, @@ -66,16 +101,114 @@ impl EstimateFee { } } -pub(crate) async fn estimate_message_delivery_and_dispatch_fee( - client: &relay_substrate_client::Client, +/// The caller may provide target to source tokens conversion rate override to use in fee +/// computation. +pub(crate) async fn estimate_message_delivery_and_dispatch_fee< + Source: Chain, + Target: Chain, + P: Clone + Encode, +>( + client: &relay_substrate_client::Client, + conversion_rate_override: Option, estimate_fee_method: &str, lane: bp_messages::LaneId, payload: P, -) -> anyhow::Result { +) -> anyhow::Result> { + // actual conversion rate CAN be lesser than the rate stored in the runtime. So we may try to + // pay lesser fee for the message delivery. But in this case, message may be rejected by the + // lane. So we MUST use the larger of two fees - one computed with stored fee and the one + // computed with actual fee. + + let conversion_rate_override = + match (conversion_rate_override, Source::TOKEN_ID, Target::TOKEN_ID) { + (Some(ConversionRateOverride::Explicit(v)), _, _) => { + let conversion_rate_override = FixedU128::from_float(v); + log::info!( + target: "bridge", + "{} -> {} conversion rate override: {:?} (explicit)", + Target::NAME, + Source::NAME, + conversion_rate_override.to_float(), + ); + Some(conversion_rate_override) + }, + ( + Some(ConversionRateOverride::Metric), + Some(source_token_id), + Some(target_token_id), + ) => { + let conversion_rate_override = + tokens_conversion_rate_from_metrics(target_token_id, source_token_id).await?; + // So we have current actual conversion rate and rate that is stored in the runtime. + // And we may simply choose the maximal of these. But what if right now there's + // rate update transaction on the way, that is updating rate to 10 seconds old + // actual rate, which is bigger than the current rate? Then our message will be + // rejected. + // + // So let's increase the actual rate by the same value that the conversion rate + // updater is using. + let increased_conversion_rate_override = FixedU128::from_float( + conversion_rate_override * (1.0 + CONVERSION_RATE_ALLOWED_DIFFERENCE_RATIO), + ); + log::info!( + target: "bridge", + "{} -> {} conversion rate override: {} (value from metric - {})", + Target::NAME, + Source::NAME, + increased_conversion_rate_override.to_float(), + conversion_rate_override, + ); + Some(increased_conversion_rate_override) + }, + _ => None, + }; + + let without_override = do_estimate_message_delivery_and_dispatch_fee( + client, + estimate_fee_method, + lane, + payload.clone(), + None, + ) + .await?; + let with_override = do_estimate_message_delivery_and_dispatch_fee( + client, + estimate_fee_method, + lane, + payload.clone(), + conversion_rate_override, + ) + .await?; + let maximal_fee = std::cmp::max(without_override, with_override); + + log::info!( + target: "bridge", + "Estimated message fee: {:?} = max of {:?} (without rate override) and {:?} (with override to {:?})", + maximal_fee, + without_override, + with_override, + conversion_rate_override, + ); + + Ok(maximal_fee) +} + +/// Estimate message delivery and dispatch fee with given conversion rate override. +async fn do_estimate_message_delivery_and_dispatch_fee( + client: &relay_substrate_client::Client, + estimate_fee_method: &str, + lane: bp_messages::LaneId, + payload: P, + conversion_rate_override: Option, +) -> anyhow::Result> { let encoded_response = client - .state_call(estimate_fee_method.into(), (lane, payload).encode().into(), None) + .state_call( + estimate_fee_method.into(), + (lane, payload, conversion_rate_override).encode().into(), + None, + ) .await?; - let decoded_response: Option = Decode::decode(&mut &encoded_response.0[..]) + let decoded_response: Option> = Decode::decode(&mut &encoded_response.0[..]) .map_err(relay_substrate_client::Error::ResponseParseFailed)?; let fee = decoded_response.ok_or_else(|| { anyhow::format_err!("Unable to decode fee from: {:?}", HexBytes(encoded_response.to_vec())) @@ -100,9 +233,13 @@ mod tests { "rialto-to-millau", "--source-port", "1234", + "--conversion-rate-override", + "42.5", "call", "--sender", &alice, + "--dispatch-weight", + "42", "remark", "--remark-payload", "1234", @@ -114,6 +251,7 @@ mod tests { EstimateFee { bridge: FullBridge::RialtoToMillau, lane: HexLaneId([0, 0, 0, 0]), + conversion_rate_override: Some(ConversionRateOverride::Explicit(42.5)), source: SourceConnectionParams { source_host: "127.0.0.1".into(), source_port: 1234, @@ -129,7 +267,8 @@ mod tests { call: encode_call::Call::Remark { remark_payload: Some(HexBytes(vec![0x12, 0x34])), remark_size: None, - } + }, + dispatch_weight: Some(42), } } ); diff --git a/relays/bin-substrate/src/cli/init_bridge.rs b/relays/bin-substrate/src/cli/init_bridge.rs index 50be6c87ccc..a0129ce9baa 100644 --- a/relays/bin-substrate/src/cli/init_bridge.rs +++ b/relays/bin-substrate/src/cli/init_bridge.rs @@ -56,10 +56,6 @@ macro_rules! select_bridge { InitBridgeName::MillauToRialto => { type Source = relay_millau_client::Millau; type Target = relay_rialto_client::Rialto; - const SOURCE_RUNTIME_VERSION: Option = - Some(millau_runtime::VERSION); - const TARGET_RUNTIME_VERSION: Option = - Some(rialto_runtime::VERSION); fn encode_init_bridge( init_data: InitializationData<::Header>, @@ -78,10 +74,6 @@ macro_rules! select_bridge { InitBridgeName::RialtoToMillau => { type Source = relay_rialto_client::Rialto; type Target = relay_millau_client::Millau; - const SOURCE_RUNTIME_VERSION: Option = - Some(rialto_runtime::VERSION); - const TARGET_RUNTIME_VERSION: Option = - Some(millau_runtime::VERSION); fn encode_init_bridge( init_data: InitializationData<::Header>, @@ -100,10 +92,6 @@ macro_rules! select_bridge { InitBridgeName::WestendToMillau => { type Source = relay_westend_client::Westend; type Target = relay_millau_client::Millau; - const SOURCE_RUNTIME_VERSION: Option = - Some(bp_westend::VERSION); - const TARGET_RUNTIME_VERSION: Option = - Some(millau_runtime::VERSION); fn encode_init_bridge( init_data: InitializationData<::Header>, @@ -126,10 +114,6 @@ macro_rules! select_bridge { InitBridgeName::RococoToWococo => { type Source = relay_rococo_client::Rococo; type Target = relay_wococo_client::Wococo; - const SOURCE_RUNTIME_VERSION: Option = - Some(bp_rococo::VERSION); - const TARGET_RUNTIME_VERSION: Option = - Some(bp_wococo::VERSION); fn encode_init_bridge( init_data: InitializationData<::Header>, @@ -146,10 +130,6 @@ macro_rules! select_bridge { InitBridgeName::WococoToRococo => { type Source = relay_wococo_client::Wococo; type Target = relay_rococo_client::Rococo; - const SOURCE_RUNTIME_VERSION: Option = - Some(bp_wococo::VERSION); - const TARGET_RUNTIME_VERSION: Option = - Some(bp_rococo::VERSION); fn encode_init_bridge( init_data: InitializationData<::Header>, @@ -166,10 +146,6 @@ macro_rules! select_bridge { InitBridgeName::KusamaToPolkadot => { type Source = relay_kusama_client::Kusama; type Target = relay_polkadot_client::Polkadot; - const SOURCE_RUNTIME_VERSION: Option = - Some(bp_kusama::VERSION); - const TARGET_RUNTIME_VERSION: Option = - Some(bp_polkadot::VERSION); fn encode_init_bridge( init_data: InitializationData<::Header>, @@ -186,10 +162,6 @@ macro_rules! select_bridge { InitBridgeName::PolkadotToKusama => { type Source = relay_polkadot_client::Polkadot; type Target = relay_kusama_client::Kusama; - const SOURCE_RUNTIME_VERSION: Option = - Some(bp_polkadot::VERSION); - const TARGET_RUNTIME_VERSION: Option = - Some(bp_kusama::VERSION); fn encode_init_bridge( init_data: InitializationData<::Header>, @@ -211,8 +183,8 @@ impl InitBridge { /// Run the command. pub async fn run(self) -> anyhow::Result<()> { select_bridge!(self.bridge, { - let source_client = self.source.to_client::(SOURCE_RUNTIME_VERSION).await?; - let target_client = self.target.to_client::(TARGET_RUNTIME_VERSION).await?; + let source_client = self.source.to_client::().await?; + let target_client = self.target.to_client::().await?; let target_sign = self.target_sign.to_keypair::()?; let (spec_version, transaction_version) = @@ -222,7 +194,7 @@ impl InitBridge { target_client.clone(), target_sign.public().into(), move |transaction_nonce, initialization_data| { - Bytes( + Ok(Bytes( Target::sign_transaction(SignParam { spec_version, transaction_version, @@ -230,12 +202,12 @@ impl InitBridge { signer: target_sign, era: relay_substrate_client::TransactionEra::immortal(), unsigned: UnsignedTransaction::new( - encode_init_bridge(initialization_data), + encode_init_bridge(initialization_data).into(), transaction_nonce, ), - }) + })? .encode(), - ) + )) }, ) .await; diff --git a/relays/bin-substrate/src/cli/mod.rs b/relays/bin-substrate/src/cli/mod.rs index ae169f773ef..df57537f588 100644 --- a/relays/bin-substrate/src/cli/mod.rs +++ b/relays/bin-substrate/src/cli/mod.rs @@ -35,6 +35,7 @@ pub(crate) mod send_message; mod derive_account; mod init_bridge; mod register_parachain; +mod reinit_bridge; mod relay_headers; mod relay_headers_and_messages; mod relay_messages; @@ -71,6 +72,11 @@ pub enum Command { /// /// Sends initialization transaction to bootstrap the bridge with current finalized block data. InitBridge(init_bridge::InitBridge), + /// Reinitialize on-chain bridge pallet with current header data. + /// + /// Sends all missing mandatory headers to bootstrap the bridge with current finalized block + /// data. + ReinitBridge(reinit_bridge::ReinitBridge), /// Send custom message over the bridge. /// /// Allows interacting with the bridge by sending messages over `Messages` component. @@ -126,6 +132,7 @@ impl Command { Self::RelayMessages(arg) => arg.run().await?, Self::RelayHeadersAndMessages(arg) => arg.run().await?, Self::InitBridge(arg) => arg.run().await?, + Self::ReinitBridge(arg) => arg.run().await?, Self::SendMessage(arg) => arg.run().await?, Self::EncodeCall(arg) => arg.run().await?, Self::EncodeMessage(arg) => arg.run().await?, @@ -541,11 +548,10 @@ macro_rules! declare_chain_options { /// Convert connection params into Substrate client. pub async fn to_client( &self, - bundle_runtime_version: Option ) -> anyhow::Result> { let chain_runtime_version = self .[<$chain_prefix _runtime_version>] - .into_runtime_version(bundle_runtime_version)?; + .into_runtime_version(Some(Chain::RUNTIME_VERSION))?; Ok(relay_substrate_client::Client::new(relay_substrate_client::ConnectionParams { host: self.[<$chain_prefix _host>].clone(), port: self.[<$chain_prefix _port>], @@ -562,14 +568,13 @@ macro_rules! declare_chain_options { #[allow(dead_code)] pub async fn selected_chain_spec_version( &self, - bundle_runtime_version: Option, ) -> anyhow::Result { let chain_runtime_version = self .[<$chain_prefix _runtime_version>] - .into_runtime_version(bundle_runtime_version.clone())?; + .into_runtime_version(Some(Chain::RUNTIME_VERSION))?; Ok(match chain_runtime_version { ChainRuntimeVersion::Auto => self - .to_client::(bundle_runtime_version) + .to_client::() .await? .simple_runtime_version() .await? diff --git a/relays/bin-substrate/src/cli/register_parachain.rs b/relays/bin-substrate/src/cli/register_parachain.rs index d42e10d708f..c761a5dd1a6 100644 --- a/relays/bin-substrate/src/cli/register_parachain.rs +++ b/relays/bin-substrate/src/cli/register_parachain.rs @@ -84,11 +84,6 @@ macro_rules! select_bridge { use bp_rialto::{PARAS_PALLET_NAME, PARAS_REGISTRAR_PALLET_NAME}; - const RELAY_CHAIN_RUNTIME_VERSION: Option = - Some(rialto_runtime::VERSION); - const PARA_CHAIN_RUNTIME_VERSION: Option = - Some(rialto_parachain_runtime::VERSION); - $generic }, } @@ -99,13 +94,9 @@ impl RegisterParachain { /// Run the command. pub async fn run(self) -> anyhow::Result<()> { select_bridge!(self.parachain, { - let relay_client = self - .relay_connection - .to_client::(RELAY_CHAIN_RUNTIME_VERSION) - .await?; + let relay_client = self.relay_connection.to_client::().await?; let relay_sign = self.relay_sign.to_keypair::()?; - let para_client = - self.para_connection.to_client::(PARA_CHAIN_RUNTIME_VERSION).await?; + let para_client = self.para_connection.to_client::().await?; // hopefully we're the only actor that is registering parachain right now // => read next parachain id @@ -116,8 +107,8 @@ impl RegisterParachain { let para_id: ParaId = relay_client .storage_value(StorageKey(para_id_key.to_vec()), None) .await? - .unwrap_or(polkadot_primitives::v1::LOWEST_PUBLIC_ID) - .max(polkadot_primitives::v1::LOWEST_PUBLIC_ID); + .unwrap_or(polkadot_primitives::v2::LOWEST_PUBLIC_ID) + .max(polkadot_primitives::v2::LOWEST_PUBLIC_ID); log::info!(target: "bridge", "Going to reserve parachain id: {:?}", para_id); // step 1: reserve a parachain id @@ -132,7 +123,7 @@ impl RegisterParachain { .submit_and_watch_signed_extrinsic( relay_sudo_account.clone(), move |_, transaction_nonce| { - Bytes( + Ok(Bytes( Relaychain::sign_transaction(SignParam { spec_version, transaction_version, @@ -140,12 +131,12 @@ impl RegisterParachain { signer: reserve_parachain_signer, era: relay_substrate_client::TransactionEra::immortal(), unsigned: UnsignedTransaction::new( - reserve_parachain_id_call, + reserve_parachain_id_call.into(), transaction_nonce, ), - }) + })? .encode(), - ) + )) }, ) .await?, @@ -181,7 +172,7 @@ impl RegisterParachain { .submit_and_watch_signed_extrinsic( relay_sudo_account.clone(), move |_, transaction_nonce| { - Bytes( + Ok(Bytes( Relaychain::sign_transaction(SignParam { spec_version, transaction_version, @@ -189,12 +180,12 @@ impl RegisterParachain { signer: register_parathread_signer, era: relay_substrate_client::TransactionEra::immortal(), unsigned: UnsignedTransaction::new( - register_parathread_call, + register_parathread_call.into(), transaction_nonce, ), - }) + })? .encode(), - ) + )) }, ) .await?, @@ -243,17 +234,20 @@ impl RegisterParachain { let force_lease_signer = relay_sign.clone(); relay_client .submit_signed_extrinsic(relay_sudo_account.clone(), move |_, transaction_nonce| { - Bytes( + Ok(Bytes( Relaychain::sign_transaction(SignParam { spec_version, transaction_version, genesis_hash: relay_genesis_hash, signer: force_lease_signer, era: relay_substrate_client::TransactionEra::immortal(), - unsigned: UnsignedTransaction::new(force_lease_call, transaction_nonce), - }) + unsigned: UnsignedTransaction::new( + force_lease_call.into(), + transaction_nonce, + ), + })? .encode(), - ) + )) }) .await?; log::info!(target: "bridge", "Registered parachain leases: {:?}. Waiting for onboarding", para_id); diff --git a/relays/bin-substrate/src/cli/reinit_bridge.rs b/relays/bin-substrate/src/cli/reinit_bridge.rs new file mode 100644 index 00000000000..89470872cb2 --- /dev/null +++ b/relays/bin-substrate/src/cli/reinit_bridge.rs @@ -0,0 +1,553 @@ +// Copyright 2019-2021 Parity Technologies (UK) Ltd. +// This file is part of Parity Bridges Common. + +// Parity Bridges Common 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. + +// Parity Bridges Common 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 Parity Bridges Common. If not, see . + +use crate::{ + chains::{ + kusama_headers_to_polkadot::KusamaFinalityToPolkadot, + polkadot_headers_to_kusama::PolkadotFinalityToKusama, + }, + cli::{ + swap_tokens::wait_until_transaction_is_finalized, SourceConnectionParams, + TargetConnectionParams, TargetSigningParams, + }, +}; +use bp_header_chain::justification::GrandpaJustification; +use bp_runtime::Chain; +use codec::Encode; +use finality_relay::{SourceClient, SourceHeader}; +use frame_support::weights::Weight; +use num_traits::One; +use pallet_bridge_grandpa::weights::WeightInfo; +use relay_substrate_client::{ + AccountIdOf, BlockNumberOf, Chain as _, Client, Error as SubstrateError, HeaderOf, SignParam, + SyncHeader, TransactionEra, TransactionSignScheme, UnsignedTransaction, +}; +use sp_core::{Bytes, Pair}; +use std::convert::{TryFrom, TryInto}; +use structopt::StructOpt; +use strum::{EnumString, EnumVariantNames, VariantNames}; +use substrate_relay_helper::{ + finality_pipeline::SubstrateFinalitySyncPipeline, finality_source::SubstrateFinalitySource, + finality_target::SubstrateFinalityTarget, messages_source::read_client_state, + TransactionParams, +}; + +/// Reinitialize bridge pallet. +#[derive(Debug, PartialEq, StructOpt)] +pub struct ReinitBridge { + /// A bridge instance to reinitialize. + #[structopt(possible_values = ReinitBridgeName::VARIANTS, case_insensitive = true)] + bridge: ReinitBridgeName, + #[structopt(flatten)] + source: SourceConnectionParams, + #[structopt(flatten)] + target: TargetConnectionParams, + #[structopt(flatten)] + target_sign: TargetSigningParams, +} + +#[derive(Debug, EnumString, EnumVariantNames, PartialEq)] +#[strum(serialize_all = "kebab_case")] +/// Bridge to initialize. +pub enum ReinitBridgeName { + KusamaToPolkadot, + PolkadotToKusama, +} + +macro_rules! select_bridge { + ($bridge: expr, $generic: tt) => { + match $bridge { + ReinitBridgeName::KusamaToPolkadot => { + use relay_polkadot_client::runtime; + + type Finality = KusamaFinalityToPolkadot; + type Call = runtime::Call; + + fn submit_finality_proof_call( + header_and_proof: HeaderAndProof, + ) -> runtime::Call { + runtime::Call::BridgeKusamaGrandpa( + runtime::BridgeKusamaGrandpaCall::submit_finality_proof( + Box::new(header_and_proof.0.into_inner()), + header_and_proof.1, + ), + ) + } + + fn set_pallet_operation_mode_call(operational: bool) -> runtime::Call { + runtime::Call::BridgeKusamaGrandpa( + runtime::BridgeKusamaGrandpaCall::set_operational(operational), + ) + } + + fn batch_all_call(calls: Vec) -> runtime::Call { + runtime::Call::Utility(runtime::UtilityCall::batch_all(calls)) + } + + $generic + }, + ReinitBridgeName::PolkadotToKusama => { + use relay_kusama_client::runtime; + + type Finality = PolkadotFinalityToKusama; + type Call = runtime::Call; + + fn submit_finality_proof_call( + header_and_proof: HeaderAndProof, + ) -> runtime::Call { + runtime::Call::BridgePolkadotGrandpa( + runtime::BridgePolkadotGrandpaCall::submit_finality_proof( + Box::new(header_and_proof.0.into_inner()), + header_and_proof.1, + ), + ) + } + + fn set_pallet_operation_mode_call(operational: bool) -> runtime::Call { + runtime::Call::BridgePolkadotGrandpa( + runtime::BridgePolkadotGrandpaCall::set_operational(operational), + ) + } + + fn batch_all_call(calls: Vec) -> runtime::Call { + runtime::Call::Utility(runtime::UtilityCall::batch_all(calls)) + } + + $generic + }, + } + }; +} + +impl ReinitBridge { + /// Run the command. + pub async fn run(self) -> anyhow::Result<()> { + select_bridge!(self.bridge, { + type Source = ::SourceChain; + type Target = ::TargetChain; + + let source_client = self.source.to_client::().await?; + let target_client = self.target.to_client::().await?; + let target_sign = self.target_sign.to_keypair::()?; + let transaction_params = TransactionParams { + signer: target_sign, + mortality: self.target_sign.target_transactions_mortality, + }; + + let finality_source = + SubstrateFinalitySource::::new(source_client.clone(), None); + let finality_target = SubstrateFinalityTarget::::new( + target_client.clone(), + transaction_params.clone(), + ); + + // this subcommand assumes that the pallet at the target chain is halted + ensure_pallet_operating_mode(&finality_target, false).await?; + + // we can't call `finality_target.best_finalized_source_block_id()`, because pallet is + // halted and the call will fail => just use what it uses internally + let current_number = + best_source_block_number_at_target::(&target_client).await?; + let target_number = finality_source.best_finalized_block_number().await?; + log::info!( + target: "bridge", + "Best finalized {} header: at {}: {}, at {}: {}", + Source::NAME, + Source::NAME, + target_number, + Target::NAME, + current_number, + ); + + // prepare list of mandatory headers from the range `(current_number; target_number]` + let headers_to_submit = find_mandatory_headers_in_range( + &finality_source, + (current_number + 1, target_number), + ) + .await?; + let latest_andatory_header_number = headers_to_submit.last().map(|(h, _)| h.number()); + log::info!( + target: "bridge", + "Missing {} mandatory {} headers at {}", + headers_to_submit.len(), + Source::NAME, + Target::NAME, + ); + + // split all mandatory headers into batches + let headers_batches = + make_mandatory_headers_batches::(headers_to_submit, |(_, proof)| { + // we don't have an access to the Kusama/Polkadot chain runtimes here, so we'll + // be using Millau weights. It isn't super-critical, unless real weights are + // magnitude higher or so + pallet_bridge_grandpa::weights::MillauWeight::::submit_finality_proof( + proof.commit.precommits.len().try_into().unwrap_or(u32::MAX), + proof.votes_ancestries.len().try_into().unwrap_or(u32::MAX), + ) + }); + log::info!( + target: "bridge", + "We're going to submit {} transactions to {} node", + headers_batches.len(), + Target::NAME, + ); + + // each batch is submitted as a separate transaction + let signer_account_id: AccountIdOf = transaction_params.signer.public().into(); + let genesis_hash = *target_client.genesis_hash(); + let (spec_version, transaction_version) = + target_client.simple_runtime_version().await?; + let last_batch_index = headers_batches.len() - 1; + for (i, headers_batch) in headers_batches.into_iter().enumerate() { + let is_last_batch = i == last_batch_index; + let expected_number = + headers_batch.last().expect("all batches are non-empty").0.number(); + let transaction_params = transaction_params.clone(); + log::info!( + target: "bridge", + "Going to submit transaction that updates best {} header at {} to {}", + Source::NAME, + Target::NAME, + expected_number, + ); + + // prepare `batch_all` call + let mut batch_calls = Vec::with_capacity(headers_batch.len() + 2); + // the first call is always resumes pallet operation + batch_calls.push(set_pallet_operation_mode_call(true)); + // followed by submit-finality-proofs calls + for header_and_proof in headers_batch { + batch_calls.push(submit_finality_proof_call(header_and_proof)); + } + // if it isn't the last batch, we shall halt pallet again + if !is_last_batch { + batch_calls.push(set_pallet_operation_mode_call(false)); + } + let submit_batch_call = batch_all_call(batch_calls); + + let batch_transaction_events = target_client + .submit_and_watch_signed_extrinsic( + signer_account_id.clone(), + move |best_block_id, transaction_nonce| { + Ok(Bytes( + Target::sign_transaction(SignParam { + spec_version, + transaction_version, + genesis_hash, + signer: transaction_params.signer.clone(), + era: TransactionEra::new( + best_block_id, + transaction_params.mortality, + ), + unsigned: UnsignedTransaction::new( + submit_batch_call.into(), + transaction_nonce, + ), + })? + .encode(), + )) + }, + ) + .await?; + wait_until_transaction_is_finalized::(batch_transaction_events).await?; + + // verify that the best finalized header at target has been updated + let current_number = + best_source_block_number_at_target::(&target_client).await?; + if current_number != expected_number { + return Err(anyhow::format_err!( + "Transaction has failed to update best {} header at {} to {}. It is {}", + Source::NAME, + Target::NAME, + expected_number, + current_number, + )) + } + + // verify that the pallet is still halted (or operational if it is the last batch) + ensure_pallet_operating_mode(&finality_target, is_last_batch).await?; + } + + if let Some(latest_andatory_header_number) = latest_andatory_header_number { + log::info!( + target: "bridge", + "Successfully updated best {} header at {} to {}. Pallet is now operational", + Source::NAME, + Target::NAME, + latest_andatory_header_number, + ); + } + + Ok(()) + }) + } +} + +/// Mandatory header and its finality proof. +type HeaderAndProof

= ( + SyncHeader::SourceChain>>, + GrandpaJustification::SourceChain>>, +); +/// Vector of mandatory headers and their finality proofs. +type HeadersAndProofs

= Vec>; + +/// Returns best finalized source header number known to the bridge GRANDPA pallet at the target +/// chain. +/// +/// This function works even if bridge GRANDPA pallet at the target chain is halted. +async fn best_source_block_number_at_target( + target_client: &Client, +) -> anyhow::Result> { + Ok(read_client_state::( + target_client, + None, + P::SourceChain::BEST_FINALIZED_HEADER_ID_METHOD, + ) + .await? + .best_finalized_peer_at_best_self + .0) +} + +/// Verify that the bridge GRANDPA pallet at the target chain is either halted, or operational. +async fn ensure_pallet_operating_mode( + finality_target: &SubstrateFinalityTarget

, + operational: bool, +) -> anyhow::Result<()> { + match (operational, finality_target.ensure_pallet_active().await) { + (true, Ok(())) => Ok(()), + (false, Err(SubstrateError::BridgePalletIsHalted)) => Ok(()), + _ => + return Err(anyhow::format_err!( + "Bridge GRANDPA pallet at {} is expected to be {}, but it isn't", + P::TargetChain::NAME, + if operational { "operational" } else { "halted" }, + )), + } +} + +/// Returns list of all mandatory headers in given range. +async fn find_mandatory_headers_in_range( + finality_source: &SubstrateFinalitySource

, + range: (BlockNumberOf, BlockNumberOf), +) -> anyhow::Result> { + let mut mandatory_headers = Vec::new(); + let mut current = range.0; + while current <= range.1 { + let (header, proof) = finality_source.header_and_finality_proof(current).await?; + if header.is_mandatory() { + match proof { + Some(proof) => mandatory_headers.push((header, proof)), + None => + return Err(anyhow::format_err!( + "Missing GRANDPA justification for {} header {}", + P::SourceChain::NAME, + current, + )), + } + } + + current += One::one(); + } + + Ok(mandatory_headers) +} + +/// Given list of mandatory headers, prepare batches of headers, so that every batch may fit into +/// single transaction. +fn make_mandatory_headers_batches< + P: SubstrateFinalitySyncPipeline, + F: Fn(&HeaderAndProof

) -> Weight, +>( + mut headers_to_submit: HeadersAndProofs

, + submit_header_weight: F, +) -> Vec> { + // now that we have all mandatory headers, let's prepare transactions + // (let's keep all our transactions below 2/3 of max tx size/weight to have some reserve + // for utility overhead + for halting transaction) + let maximal_tx_size = P::TargetChain::max_extrinsic_size() * 2 / 3; + let maximal_tx_weight = P::TargetChain::max_extrinsic_weight() * 2 / 3; + let mut current_batch_size: u32 = 0; + let mut current_batch_weight: Weight = 0; + let mut batches = Vec::new(); + let mut i = 0; + while i < headers_to_submit.len() { + let header_and_proof_size = + headers_to_submit[i].0.encode().len() + headers_to_submit[i].1.encode().len(); + let header_and_proof_weight = submit_header_weight(&headers_to_submit[i]); + + let new_batch_size = current_batch_size + .saturating_add(u32::try_from(header_and_proof_size).unwrap_or(u32::MAX)); + let new_batch_weight = current_batch_weight.saturating_add(header_and_proof_weight); + + let is_exceeding_tx_size = new_batch_size > maximal_tx_size; + let is_exceeding_tx_weight = new_batch_weight > maximal_tx_weight; + let is_new_batch_required = is_exceeding_tx_size || is_exceeding_tx_weight; + + if is_new_batch_required { + // if `i` is 0 and we're here, it is a weird situation: even single header submission is + // larger than we've planned for a bunch of headers. Let's be optimistic and hope that + // the tx will still succeed. + let spit_off_index = std::cmp::max(i, 1); + let remaining_headers_to_submit = headers_to_submit.split_off(spit_off_index); + batches.push(headers_to_submit); + + // we'll reiterate the same header again => so set `current_*` to zero + current_batch_size = 0; + current_batch_weight = 0; + headers_to_submit = remaining_headers_to_submit; + i = 0; + } else { + current_batch_size = new_batch_size; + current_batch_weight = new_batch_weight; + i += 1; + } + } + if !headers_to_submit.is_empty() { + batches.push(headers_to_submit); + } + batches +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::cli::{RuntimeVersionType, SourceRuntimeVersionParams, TargetRuntimeVersionParams}; + use bp_test_utils::{make_default_justification, test_header}; + use relay_polkadot_client::Polkadot; + use sp_runtime::{traits::Header as _, DigestItem}; + + fn make_header_and_justification( + i: u32, + size: u32, + ) -> (SyncHeader, GrandpaJustification) { + let size = size as usize; + let mut header: bp_kusama::Header = test_header(i); + let justification = make_default_justification(&header); + let actual_size = header.encode().len() + justification.encode().len(); + // additional digest means some additional bytes, so let's decrease `additional_digest_size` + // a bit + let additional_digest_size = size.saturating_sub(actual_size).saturating_sub(100); + header.digest_mut().push(DigestItem::Other(vec![0u8; additional_digest_size])); + let justification = make_default_justification(&header); + println!("{} {}", size, header.encode().len() + justification.encode().len()); + (header.into(), justification) + } + + #[test] + fn should_parse_cli_options() { + // when + let res = ReinitBridge::from_iter(vec![ + "reinit-bridge", + "kusama-to-polkadot", + "--source-host", + "127.0.0.1", + "--source-port", + "42", + "--target-host", + "127.0.0.1", + "--target-port", + "43", + "--target-signer", + "//Alice", + ]); + + // then + assert_eq!( + res, + ReinitBridge { + bridge: ReinitBridgeName::KusamaToPolkadot, + source: SourceConnectionParams { + source_host: "127.0.0.1".into(), + source_port: 42, + source_secure: false, + source_runtime_version: SourceRuntimeVersionParams { + source_version_mode: RuntimeVersionType::Bundle, + source_spec_version: None, + source_transaction_version: None, + } + }, + target: TargetConnectionParams { + target_host: "127.0.0.1".into(), + target_port: 43, + target_secure: false, + target_runtime_version: TargetRuntimeVersionParams { + target_version_mode: RuntimeVersionType::Bundle, + target_spec_version: None, + target_transaction_version: None, + } + }, + target_sign: TargetSigningParams { + target_signer: Some("//Alice".into()), + target_signer_password: None, + target_signer_file: None, + target_signer_password_file: None, + target_transactions_mortality: None, + }, + } + ); + } + + #[test] + fn make_mandatory_headers_batches_and_empty_headers() { + let batches = make_mandatory_headers_batches::(vec![], |_| 0); + assert!(batches.is_empty()); + } + + #[test] + fn make_mandatory_headers_batches_with_single_batch() { + let headers_to_submit = + vec![make_header_and_justification(10, Polkadot::max_extrinsic_size() / 3)]; + let batches = + make_mandatory_headers_batches::(headers_to_submit, |_| 0); + assert_eq!(batches.into_iter().map(|x| x.len()).collect::>(), vec![1],); + } + + #[test] + fn make_mandatory_headers_batches_group_by_size() { + let headers_to_submit = vec![ + make_header_and_justification(10, Polkadot::max_extrinsic_size() / 3), + make_header_and_justification(20, Polkadot::max_extrinsic_size() / 3), + make_header_and_justification(30, Polkadot::max_extrinsic_size() * 2 / 3), + make_header_and_justification(40, Polkadot::max_extrinsic_size()), + ]; + let batches = + make_mandatory_headers_batches::(headers_to_submit, |_| 0); + assert_eq!(batches.into_iter().map(|x| x.len()).collect::>(), vec![2, 1, 1],); + } + + #[test] + fn make_mandatory_headers_batches_group_by_weight() { + let headers_to_submit = vec![ + make_header_and_justification(10, 0), + make_header_and_justification(20, 0), + make_header_and_justification(30, 0), + make_header_and_justification(40, 0), + ]; + let batches = make_mandatory_headers_batches::( + headers_to_submit, + |(header, _)| { + if header.number() == 10 || header.number() == 20 { + Polkadot::max_extrinsic_weight() / 3 + } else if header.number() == 30 { + Polkadot::max_extrinsic_weight() * 2 / 3 + } else { + Polkadot::max_extrinsic_weight() + } + }, + ); + assert_eq!(batches.into_iter().map(|x| x.len()).collect::>(), vec![2, 1, 1],); + } +} diff --git a/relays/bin-substrate/src/cli/relay_headers.rs b/relays/bin-substrate/src/cli/relay_headers.rs index e3c7fe76d3c..45034aba4b5 100644 --- a/relays/bin-substrate/src/cli/relay_headers.rs +++ b/relays/bin-substrate/src/cli/relay_headers.rs @@ -64,10 +64,6 @@ macro_rules! select_bridge { type Source = relay_millau_client::Millau; type Target = relay_rialto_client::Rialto; type Finality = crate::chains::millau_headers_to_rialto::MillauFinalityToRialto; - const SOURCE_RUNTIME_VERSION: Option = - Some(millau_runtime::VERSION); - const TARGET_RUNTIME_VERSION: Option = - Some(rialto_runtime::VERSION); $generic }, @@ -75,10 +71,6 @@ macro_rules! select_bridge { type Source = relay_rialto_client::Rialto; type Target = relay_millau_client::Millau; type Finality = crate::chains::rialto_headers_to_millau::RialtoFinalityToMillau; - const SOURCE_RUNTIME_VERSION: Option = - Some(rialto_runtime::VERSION); - const TARGET_RUNTIME_VERSION: Option = - Some(millau_runtime::VERSION); $generic }, @@ -86,10 +78,6 @@ macro_rules! select_bridge { type Source = relay_westend_client::Westend; type Target = relay_millau_client::Millau; type Finality = crate::chains::westend_headers_to_millau::WestendFinalityToMillau; - const SOURCE_RUNTIME_VERSION: Option = - Some(bp_westend::VERSION); - const TARGET_RUNTIME_VERSION: Option = - Some(millau_runtime::VERSION); $generic }, @@ -97,10 +85,6 @@ macro_rules! select_bridge { type Source = relay_rococo_client::Rococo; type Target = relay_wococo_client::Wococo; type Finality = crate::chains::rococo_headers_to_wococo::RococoFinalityToWococo; - const SOURCE_RUNTIME_VERSION: Option = - Some(bp_rococo::VERSION); - const TARGET_RUNTIME_VERSION: Option = - Some(bp_wococo::VERSION); $generic }, @@ -108,10 +92,6 @@ macro_rules! select_bridge { type Source = relay_wococo_client::Wococo; type Target = relay_rococo_client::Rococo; type Finality = crate::chains::wococo_headers_to_rococo::WococoFinalityToRococo; - const SOURCE_RUNTIME_VERSION: Option = - Some(bp_wococo::VERSION); - const TARGET_RUNTIME_VERSION: Option = - Some(bp_rococo::VERSION); $generic }, @@ -119,10 +99,6 @@ macro_rules! select_bridge { type Source = relay_kusama_client::Kusama; type Target = relay_polkadot_client::Polkadot; type Finality = crate::chains::kusama_headers_to_polkadot::KusamaFinalityToPolkadot; - const SOURCE_RUNTIME_VERSION: Option = - Some(bp_kusama::VERSION); - const TARGET_RUNTIME_VERSION: Option = - Some(bp_polkadot::VERSION); $generic }, @@ -130,10 +106,6 @@ macro_rules! select_bridge { type Source = relay_polkadot_client::Polkadot; type Target = relay_kusama_client::Kusama; type Finality = crate::chains::polkadot_headers_to_kusama::PolkadotFinalityToKusama; - const SOURCE_RUNTIME_VERSION: Option = - Some(bp_polkadot::VERSION); - const TARGET_RUNTIME_VERSION: Option = - Some(bp_kusama::VERSION); $generic }, @@ -145,8 +117,8 @@ impl RelayHeaders { /// Run the command. pub async fn run(self) -> anyhow::Result<()> { select_bridge!(self.bridge, { - let source_client = self.source.to_client::(SOURCE_RUNTIME_VERSION).await?; - let target_client = self.target.to_client::(TARGET_RUNTIME_VERSION).await?; + let source_client = self.source.to_client::().await?; + let target_client = self.target.to_client::().await?; let target_transactions_mortality = self.target_sign.target_transactions_mortality; let target_sign = self.target_sign.to_keypair::()?; diff --git a/relays/bin-substrate/src/cli/relay_headers_and_messages.rs b/relays/bin-substrate/src/cli/relay_headers_and_messages.rs index 11220af3e7e..4ff6ee0947c 100644 --- a/relays/bin-substrate/src/cli/relay_headers_and_messages.rs +++ b/relays/bin-substrate/src/cli/relay_headers_and_messages.rs @@ -50,7 +50,7 @@ use crate::{ /// stored and real conversion rates. If it is large enough (e.g. > than 10 percents, which is 0.1), /// then rational relayers may stop relaying messages because they were submitted using /// lesser conversion rate. -const CONVERSION_RATE_ALLOWED_DIFFERENCE_RATIO: f64 = 0.05; +pub(crate) const CONVERSION_RATE_ALLOWED_DIFFERENCE_RATIO: f64 = 0.05; /// Start headers+messages relayer process. #[derive(StructOpt)] @@ -133,24 +133,9 @@ macro_rules! select_bridge { type LeftAccountIdConverter = bp_millau::AccountIdConverter; type RightAccountIdConverter = bp_rialto::AccountIdConverter; - const MAX_MISSING_LEFT_HEADERS_AT_RIGHT: bp_millau::BlockNumber = - bp_millau::SESSION_LENGTH; - const MAX_MISSING_RIGHT_HEADERS_AT_LEFT: bp_rialto::BlockNumber = - bp_rialto::SESSION_LENGTH; - const LEFT_RUNTIME_VERSION: Option = - Some(millau_runtime::VERSION); - const RIGHT_RUNTIME_VERSION: Option = - Some(rialto_runtime::VERSION); - use crate::chains::{ - millau_messages_to_rialto::{ - update_rialto_to_millau_conversion_rate as update_right_to_left_conversion_rate, - MillauMessagesToRialto as LeftToRightMessageLane, - }, - rialto_messages_to_millau::{ - update_millau_to_rialto_conversion_rate as update_left_to_right_conversion_rate, - RialtoMessagesToMillau as RightToLeftMessageLane, - }, + millau_messages_to_rialto::MillauMessagesToRialto as LeftToRightMessageLane, + rialto_messages_to_millau::RialtoMessagesToMillau as RightToLeftMessageLane, }; async fn left_create_account( @@ -185,37 +170,11 @@ macro_rules! select_bridge { type LeftAccountIdConverter = bp_rococo::AccountIdConverter; type RightAccountIdConverter = bp_wococo::AccountIdConverter; - const MAX_MISSING_LEFT_HEADERS_AT_RIGHT: bp_rococo::BlockNumber = - bp_rococo::SESSION_LENGTH; - const MAX_MISSING_RIGHT_HEADERS_AT_LEFT: bp_wococo::BlockNumber = - bp_wococo::SESSION_LENGTH; - - const LEFT_RUNTIME_VERSION: Option = - Some(bp_rococo::VERSION); - const RIGHT_RUNTIME_VERSION: Option = - Some(bp_wococo::VERSION); - use crate::chains::{ rococo_messages_to_wococo::RococoMessagesToWococo as LeftToRightMessageLane, wococo_messages_to_rococo::WococoMessagesToRococo as RightToLeftMessageLane, }; - async fn update_right_to_left_conversion_rate( - _client: Client, - _signer: ::AccountKeyPair, - _updated_rate: f64, - ) -> anyhow::Result<()> { - Err(anyhow::format_err!("Conversion rate is not supported by this bridge")) - } - - async fn update_left_to_right_conversion_rate( - _client: Client, - _signer: ::AccountKeyPair, - _updated_rate: f64, - ) -> anyhow::Result<()> { - Err(anyhow::format_err!("Conversion rate is not supported by this bridge")) - } - async fn left_create_account( left_client: Client, left_sign: ::AccountKeyPair, @@ -268,25 +227,9 @@ macro_rules! select_bridge { type LeftAccountIdConverter = bp_kusama::AccountIdConverter; type RightAccountIdConverter = bp_polkadot::AccountIdConverter; - const MAX_MISSING_LEFT_HEADERS_AT_RIGHT: bp_kusama::BlockNumber = - bp_kusama::SESSION_LENGTH; - const MAX_MISSING_RIGHT_HEADERS_AT_LEFT: bp_polkadot::BlockNumber = - bp_polkadot::SESSION_LENGTH; - - const LEFT_RUNTIME_VERSION: Option = - Some(bp_kusama::VERSION); - const RIGHT_RUNTIME_VERSION: Option = - Some(bp_polkadot::VERSION); - use crate::chains::{ - kusama_messages_to_polkadot::{ - update_polkadot_to_kusama_conversion_rate as update_right_to_left_conversion_rate, - KusamaMessagesToPolkadot as LeftToRightMessageLane, - }, - polkadot_messages_to_kusama::{ - update_kusama_to_polkadot_conversion_rate as update_left_to_right_conversion_rate, - PolkadotMessagesToKusama as RightToLeftMessageLane, - }, + kusama_messages_to_polkadot::KusamaMessagesToPolkadot as LeftToRightMessageLane, + polkadot_messages_to_kusama::PolkadotMessagesToKusama as RightToLeftMessageLane, }; async fn left_create_account( @@ -349,12 +292,12 @@ impl RelayHeadersAndMessages { select_bridge!(self, { let params: Params = self.into(); - let left_client = params.left.to_client::(LEFT_RUNTIME_VERSION).await?; + let left_client = params.left.to_client::().await?; let left_transactions_mortality = params.left_sign.transactions_mortality()?; let left_sign = params.left_sign.to_keypair::()?; let left_messages_pallet_owner = params.left_messages_pallet_owner.to_keypair::()?; - let right_client = params.right.to_client::(RIGHT_RUNTIME_VERSION).await?; + let right_client = params.right.to_client::().await?; let right_transactions_mortality = params.right_sign.transactions_mortality()?; let right_sign = params.right_sign.to_keypair::()?; let right_messages_pallet_owner = @@ -383,7 +326,15 @@ impl RelayHeadersAndMessages { Left::NAME ) }; - substrate_relay_helper::conversion_rate_update::run_conversion_rate_update_loop( + substrate_relay_helper::conversion_rate_update::run_conversion_rate_update_loop::< + LeftToRightMessageLane, + Left, + >( + left_client.clone(), + TransactionParams { + signer: left_messages_pallet_owner.clone(), + mortality: left_transactions_mortality, + }, left_to_right_metrics .target_to_source_conversion_rate .as_ref() @@ -400,21 +351,6 @@ impl RelayHeadersAndMessages { .ok_or_else(format_err)? .shared_value_ref(), CONVERSION_RATE_ALLOWED_DIFFERENCE_RATIO, - move |new_rate| { - log::info!( - target: "bridge", - "Going to update {} -> {} (on {}) conversion rate to {}.", - Right::NAME, - Left::NAME, - Left::NAME, - new_rate, - ); - update_right_to_left_conversion_rate( - left_client.clone(), - left_messages_pallet_owner.clone(), - new_rate, - ) - }, ); } if let Some(right_messages_pallet_owner) = right_messages_pallet_owner.clone() { @@ -426,38 +362,31 @@ impl RelayHeadersAndMessages { Right::NAME ) }; - substrate_relay_helper::conversion_rate_update::run_conversion_rate_update_loop( + substrate_relay_helper::conversion_rate_update::run_conversion_rate_update_loop::< + RightToLeftMessageLane, + Right, + >( + right_client.clone(), + TransactionParams { + signer: right_messages_pallet_owner.clone(), + mortality: right_transactions_mortality, + }, right_to_left_metrics .target_to_source_conversion_rate .as_ref() .ok_or_else(format_err)? .shared_value_ref(), - left_to_right_metrics - .source_to_base_conversion_rate + right_to_left_metrics + .target_to_base_conversion_rate .as_ref() .ok_or_else(format_err)? .shared_value_ref(), - left_to_right_metrics - .target_to_base_conversion_rate + right_to_left_metrics + .source_to_base_conversion_rate .as_ref() .ok_or_else(format_err)? .shared_value_ref(), CONVERSION_RATE_ALLOWED_DIFFERENCE_RATIO, - move |new_rate| { - log::info!( - target: "bridge", - "Going to update {} -> {} (on {}) conversion rate to {}.", - Left::NAME, - Right::NAME, - Right::NAME, - new_rate, - ); - update_left_to_right_conversion_rate( - right_client.clone(), - right_messages_pallet_owner.clone(), - new_rate, - ) - }, ); } @@ -543,14 +472,12 @@ impl RelayHeadersAndMessages { left_client.clone(), right_client.clone(), left_to_right_transaction_params, - MAX_MISSING_LEFT_HEADERS_AT_RIGHT, params.shared.only_mandatory_headers, ); let right_to_left_on_demand_headers = OnDemandHeadersRelay::new::( right_client.clone(), left_client.clone(), right_to_left_transaction_params, - MAX_MISSING_RIGHT_HEADERS_AT_LEFT, params.shared.only_mandatory_headers, ); @@ -631,17 +558,17 @@ where let (spec_version, transaction_version) = client.simple_runtime_version().await?; client .submit_signed_extrinsic(sign.public().into(), move |_, transaction_nonce| { - Bytes( + Ok(Bytes( C::sign_transaction(SignParam { spec_version, transaction_version, genesis_hash, signer: sign, era: relay_substrate_client::TransactionEra::immortal(), - unsigned: UnsignedTransaction::new(call, transaction_nonce), - }) + unsigned: UnsignedTransaction::new(call.into(), transaction_nonce), + })? .encode(), - ) + )) }) .await .map(drop) diff --git a/relays/bin-substrate/src/cli/relay_messages.rs b/relays/bin-substrate/src/cli/relay_messages.rs index 521d00d50a9..45087fad5eb 100644 --- a/relays/bin-substrate/src/cli/relay_messages.rs +++ b/relays/bin-substrate/src/cli/relay_messages.rs @@ -75,10 +75,10 @@ impl RelayMessages { /// Run the command. pub async fn run(self) -> anyhow::Result<()> { select_full_bridge!(self.bridge, { - let source_client = self.source.to_client::(SOURCE_RUNTIME_VERSION).await?; + let source_client = self.source.to_client::().await?; let source_sign = self.source_sign.to_keypair::()?; let source_transactions_mortality = self.source_sign.transactions_mortality()?; - let target_client = self.target.to_client::(TARGET_RUNTIME_VERSION).await?; + let target_client = self.target.to_client::().await?; let target_sign = self.target_sign.to_keypair::()?; let target_transactions_mortality = self.target_sign.transactions_mortality()?; let relayer_mode = self.relayer_mode.into(); diff --git a/relays/bin-substrate/src/cli/resubmit_transactions.rs b/relays/bin-substrate/src/cli/resubmit_transactions.rs index 8b021df8637..f92c035082c 100644 --- a/relays/bin-substrate/src/cli/resubmit_transactions.rs +++ b/relays/bin-substrate/src/cli/resubmit_transactions.rs @@ -19,10 +19,10 @@ use crate::cli::{Balance, TargetConnectionParams, TargetSigningParams}; use codec::{Decode, Encode}; use num_traits::{One, Zero}; use relay_substrate_client::{ - BlockWithJustification, Chain, Client, Error as SubstrateError, HeaderOf, SignParam, - TransactionSignScheme, + BlockWithJustification, Chain, Client, Error as SubstrateError, HeaderIdOf, HeaderOf, + SignParam, TransactionSignScheme, }; -use relay_utils::FailedClient; +use relay_utils::{FailedClient, HeaderId}; use sp_core::Bytes; use sp_runtime::{ traits::{Hash, Header as HeaderT}, @@ -30,6 +30,7 @@ use sp_runtime::{ }; use structopt::StructOpt; use strum::{EnumString, EnumVariantNames, VariantNames}; +use substrate_relay_helper::TransactionParams; /// Start resubmit transactions process. #[derive(StructOpt)] @@ -91,24 +92,18 @@ macro_rules! select_bridge { RelayChain::Millau => { type Target = relay_millau_client::Millau; type TargetSign = relay_millau_client::Millau; - const TARGET_RUNTIME_VERSION: Option = - Some(millau_runtime::VERSION); $generic }, RelayChain::Kusama => { type Target = relay_kusama_client::Kusama; type TargetSign = relay_kusama_client::Kusama; - const TARGET_RUNTIME_VERSION: Option = - Some(bp_kusama::VERSION); $generic }, RelayChain::Polkadot => { type Target = relay_polkadot_client::Polkadot; type TargetSign = relay_polkadot_client::Polkadot; - const TARGET_RUNTIME_VERSION: Option = - Some(bp_polkadot::VERSION); $generic }, @@ -121,14 +116,17 @@ impl ResubmitTransactions { pub async fn run(self) -> anyhow::Result<()> { select_bridge!(self.chain, { let relay_loop_name = format!("ResubmitTransactions{}", Target::NAME); - let client = self.target.to_client::(TARGET_RUNTIME_VERSION).await?; - let key_pair = self.target_sign.to_keypair::()?; + let client = self.target.to_client::().await?; + let transaction_params = TransactionParams { + signer: self.target_sign.to_keypair::()?, + mortality: self.target_sign.target_transactions_mortality, + }; relay_utils::relay_loop((), client) .run(relay_loop_name, move |_, client, _| { run_until_connection_lost::( client, - key_pair.clone(), + transaction_params.clone(), Context { strategy: self.strategy, best_header: HeaderOf::::new( @@ -219,13 +217,14 @@ impl Context { /// Run resubmit transactions loop. async fn run_until_connection_lost>( client: Client, - key_pair: S::AccountKeyPair, + transaction_params: TransactionParams, mut context: Context, ) -> Result<(), FailedClient> { loop { async_std::task::sleep(C::AVERAGE_BLOCK_INTERVAL).await; - let result = run_loop_iteration::(client.clone(), key_pair.clone(), context).await; + let result = + run_loop_iteration::(client.clone(), transaction_params.clone(), context).await; context = match result { Ok(context) => context, Err(error) => { @@ -244,20 +243,21 @@ async fn run_until_connection_lost /// Run single loop iteration. async fn run_loop_iteration>( client: Client, - key_pair: S::AccountKeyPair, + transaction_params: TransactionParams, mut context: Context, ) -> Result, SubstrateError> { // correct best header is required for all other actions context.best_header = client.best_header().await?; // check if there's queued transaction, signed by given author - let original_transaction = match lookup_signer_transaction::(&client, &key_pair).await? { - Some(original_transaction) => original_transaction, - None => { - log::trace!(target: "bridge", "No {} transactions from required signer in the txpool", C::NAME); - return Ok(context) - }, - }; + let original_transaction = + match lookup_signer_transaction::(&client, &transaction_params.signer).await? { + Some(original_transaction) => original_transaction, + None => { + log::trace!(target: "bridge", "No {} transactions from required signer in the txpool", C::NAME); + return Ok(context) + }, + }; let original_transaction_hash = C::Hasher::hash(&original_transaction.encode()); let context = context.notice_transaction(original_transaction_hash); @@ -287,8 +287,8 @@ async fn run_loop_iteration>( // update transaction tip let (is_updated, updated_transaction) = update_transaction_tip::( &client, - &key_pair, - context.best_header.hash(), + &transaction_params, + HeaderId(*context.best_header.number(), context.best_header.hash()), original_transaction, context.tip_step, context.tip_limit, @@ -404,15 +404,15 @@ fn select_transaction_from_queue( /// Try to find appropriate tip for transaction so that its priority is larger than given. async fn update_transaction_tip>( client: &Client, - key_pair: &S::AccountKeyPair, - at_block: C::Hash, + transaction_params: &TransactionParams, + at_block: HeaderIdOf, tx: S::SignedTransaction, tip_step: C::Balance, tip_limit: C::Balance, target_priority: TransactionPriority, ) -> Result<(bool, S::SignedTransaction), SubstrateError> { let stx = format!("{:?}", tx); - let mut current_priority = client.validate_transaction(at_block, tx.clone()).await??.priority; + let mut current_priority = client.validate_transaction(at_block.1, tx.clone()).await??.priority; let mut unsigned_tx = S::parse_transaction(tx).ok_or_else(|| { SubstrateError::Custom(format!("Failed to parse {} transaction {}", C::NAME, stx,)) })?; @@ -437,15 +437,15 @@ async fn update_transaction_tip>( unsigned_tx.tip = next_tip; current_priority = client .validate_transaction( - at_block, + at_block.1, S::sign_transaction(SignParam { spec_version, transaction_version, genesis_hash: *client.genesis_hash(), - signer: key_pair.clone(), + signer: transaction_params.signer.clone(), era: relay_substrate_client::TransactionEra::immortal(), unsigned: unsigned_tx.clone(), - }), + })?, ) .await?? .priority; @@ -465,10 +465,13 @@ async fn update_transaction_tip>( spec_version, transaction_version, genesis_hash: *client.genesis_hash(), - signer: key_pair.clone(), - era: relay_substrate_client::TransactionEra::immortal(), + signer: transaction_params.signer.clone(), + era: relay_substrate_client::TransactionEra::new( + at_block, + transaction_params.mortality, + ), unsigned: unsigned_tx, - }), + })?, )) } diff --git a/relays/bin-substrate/src/cli/send_message.rs b/relays/bin-substrate/src/cli/send_message.rs index e3597f766b7..ddb1ff59b5d 100644 --- a/relays/bin-substrate/src/cli/send_message.rs +++ b/relays/bin-substrate/src/cli/send_message.rs @@ -17,12 +17,12 @@ use crate::cli::{ bridge::FullBridge, encode_call::{self, CliEncodeCall}, - estimate_fee::estimate_message_delivery_and_dispatch_fee, - Balance, CliChain, ExplicitOrMaximal, HexBytes, HexLaneId, Origins, SourceConnectionParams, + estimate_fee::{estimate_message_delivery_and_dispatch_fee, ConversionRateOverride}, + Balance, ExplicitOrMaximal, HexBytes, HexLaneId, Origins, SourceConnectionParams, SourceSigningParams, TargetConnectionParams, TargetSigningParams, }; use bp_message_dispatch::{CallOrigin, MessagePayload}; -use bp_runtime::{BalanceOf, Chain as _}; +use bp_runtime::Chain as _; use codec::Encode; use frame_support::weights::Weight; use relay_substrate_client::{Chain, SignParam, TransactionSignScheme, UnsignedTransaction}; @@ -66,6 +66,12 @@ pub struct SendMessage { /// Hex-encoded lane id. Defaults to `00000000`. #[structopt(long, default_value = "00000000")] lane: HexLaneId, + /// A way to override conversion rate between bridge tokens. + /// + /// If not specified, conversion rate from runtime storage is used. It may be obsolete and + /// your message won't be relayed. + #[structopt(long)] + conversion_rate_override: Option, /// Where dispatch fee is paid? #[structopt( long, @@ -116,17 +122,18 @@ impl SendMessage { encode_call::preprocess_call::(message, bridge.bridge_instance_index()); let target_call = Target::encode_call(message)?; - let target_spec_version = self - .target - .selected_chain_spec_version::(Some(Target::RUNTIME_VERSION)) - .await?; + let target_spec_version = self.target.selected_chain_spec_version::().await?; let payload = { let target_call_weight = prepare_call_dispatch_weight( dispatch_weight, - ExplicitOrMaximal::Explicit(Target::get_dispatch_info(&target_call)?.weight), + || { + Ok(ExplicitOrMaximal::Explicit( + Target::get_dispatch_info(&target_call)?.weight, + )) + }, compute_maximal_message_dispatch_weight(Target::max_extrinsic_weight()), - ); + )?; let source_sender_public: MultiSigner = source_sign.public().into(); let source_account_id = source_sender_public.into_account(); @@ -164,15 +171,17 @@ impl SendMessage { crate::select_full_bridge!(self.bridge, { let payload = self.encode_payload().await?; - let source_client = self.source.to_client::(SOURCE_RUNTIME_VERSION).await?; + let source_client = self.source.to_client::().await?; let source_sign = self.source_sign.to_keypair::()?; let lane = self.lane.clone().into(); + let conversion_rate_override = self.conversion_rate_override; let fee = match self.fee { Some(fee) => fee, None => Balance( - estimate_message_delivery_and_dispatch_fee::, _, _>( + estimate_message_delivery_and_dispatch_fee::( &source_client, + conversion_rate_override, ESTIMATE_MESSAGE_FEE_METHOD, lane, payload.clone(), @@ -181,6 +190,7 @@ impl SendMessage { ), }; let dispatch_weight = payload.weight; + let payload_len = payload.encode().len(); let send_message_call = Source::encode_call(&encode_call::Call::BridgeSendMessage { bridge_instance_index: self.bridge.bridge_instance_index(), lane: self.lane, @@ -200,7 +210,7 @@ impl SendMessage { signer: source_sign.clone(), era: relay_substrate_client::TransactionEra::immortal(), unsigned: UnsignedTransaction::new(send_message_call.clone(), 0), - }) + })? .encode(), )) .await?; @@ -213,7 +223,7 @@ impl SendMessage { signer: source_sign.clone(), era: relay_substrate_client::TransactionEra::immortal(), unsigned: UnsignedTransaction::new(send_message_call, transaction_nonce), - }) + })? .encode(); log::info!( @@ -221,7 +231,7 @@ impl SendMessage { "Sending message to {}. Lane: {:?}. Size: {}. Dispatch weight: {}. Fee: {}", Target::NAME, lane, - signed_source_call.len(), + payload_len, dispatch_weight, fee, ); @@ -241,7 +251,7 @@ impl SendMessage { HexBytes::encode(&signed_source_call) ); - Bytes(signed_source_call) + Ok(Bytes(signed_source_call)) }) .await?; }); @@ -252,12 +262,16 @@ impl SendMessage { fn prepare_call_dispatch_weight( user_specified_dispatch_weight: &Option>, - weight_from_pre_dispatch_call: ExplicitOrMaximal, + weight_from_pre_dispatch_call: impl Fn() -> anyhow::Result>, maximal_allowed_weight: Weight, -) -> Weight { - match user_specified_dispatch_weight.clone().unwrap_or(weight_from_pre_dispatch_call) { - ExplicitOrMaximal::Explicit(weight) => weight, - ExplicitOrMaximal::Maximal => maximal_allowed_weight, +) -> anyhow::Result { + match user_specified_dispatch_weight + .clone() + .map(Ok) + .unwrap_or_else(weight_from_pre_dispatch_call)? + { + ExplicitOrMaximal::Explicit(weight) => Ok(weight), + ExplicitOrMaximal::Maximal => Ok(maximal_allowed_weight), } } @@ -299,6 +313,7 @@ pub(crate) fn compute_maximal_message_dispatch_weight(maximal_extrinsic_weight: #[cfg(test)] mod tests { use super::*; + use crate::cli::CliChain; use hex_literal::hex; #[async_std::test] @@ -311,6 +326,8 @@ mod tests { "1234", "--source-signer", "//Alice", + "--conversion-rate-override", + "0.75", "remark", "--remark-payload", "1234", @@ -348,6 +365,8 @@ mod tests { "Target", "--target-signer", "//Bob", + "--conversion-rate-override", + "metric", "remark", "--remark-payload", "1234", diff --git a/relays/bin-substrate/src/cli/swap_tokens.rs b/relays/bin-substrate/src/cli/swap_tokens.rs index 16ec0d6a6fa..0758deddfd1 100644 --- a/relays/bin-substrate/src/cli/swap_tokens.rs +++ b/relays/bin-substrate/src/cli/swap_tokens.rs @@ -36,8 +36,8 @@ use sp_core::{blake2_256, storage::StorageKey, Bytes, Pair, U256}; use sp_runtime::traits::{Convert, Header as HeaderT}; use crate::cli::{ - Balance, CliChain, SourceConnectionParams, SourceSigningParams, TargetConnectionParams, - TargetSigningParams, + estimate_fee::ConversionRateOverride, Balance, CliChain, SourceConnectionParams, + SourceSigningParams, TargetConnectionParams, TargetSigningParams, }; /// Swap tokens. @@ -65,6 +65,18 @@ pub struct SwapTokens { /// Target chain balance that target signer wants to swap. #[structopt(long)] target_balance: Balance, + /// A way to override conversion rate from target to source tokens. + /// + /// If not specified, conversion rate from runtime storage is used. It may be obsolete and + /// your message won't be relayed. + #[structopt(long)] + target_to_source_conversion_rate_override: Option, + /// A way to override conversion rate from source to target tokens. + /// + /// If not specified, conversion rate from runtime storage is used. It may be obsolete and + /// your message won't be relayed. + #[structopt(long)] + source_to_target_conversion_rate_override: Option, } /// Token swap type. @@ -101,11 +113,6 @@ macro_rules! select_bridge { const SOURCE_SPEC_VERSION: u32 = millau_runtime::VERSION.spec_version; const TARGET_SPEC_VERSION: u32 = rialto_runtime::VERSION.spec_version; - const SOURCE_RUNTIME_VERSION: Option = - Some(millau_runtime::VERSION); - const TARGET_RUNTIME_VERSION: Option = - Some(rialto_runtime::VERSION); - type FromSwapToThisAccountIdConverter = bp_rialto::AccountIdConverter; use bp_millau::{ @@ -134,10 +141,14 @@ impl SwapTokens { /// Run the command. pub async fn run(self) -> anyhow::Result<()> { select_bridge!(self.bridge, { - let source_client = self.source.to_client::(SOURCE_RUNTIME_VERSION).await?; + let source_client = self.source.to_client::().await?; let source_sign = self.source_sign.to_keypair::()?; - let target_client = self.target.to_client::(TARGET_RUNTIME_VERSION).await?; + let target_client = self.target.to_client::().await?; let target_sign = self.target_sign.to_keypair::()?; + let target_to_source_conversion_rate_override = + self.target_to_source_conversion_rate_override; + let source_to_target_conversion_rate_override = + self.source_to_target_conversion_rate_override; // names of variables in this function are matching names used by the // `pallet-bridge-token-swap` @@ -203,9 +214,14 @@ impl SwapTokens { // prepare `create_swap` call let target_public_at_bridged_chain: AccountPublicOf = target_sign.public().into(); - let swap_delivery_and_dispatch_fee: BalanceOf = - crate::cli::estimate_fee::estimate_message_delivery_and_dispatch_fee( + let swap_delivery_and_dispatch_fee = + crate::cli::estimate_fee::estimate_message_delivery_and_dispatch_fee::< + Source, + Target, + _, + >( &source_client, + target_to_source_conversion_rate_override.clone(), ESTIMATE_SOURCE_TO_TARGET_MESSAGE_FEE_METHOD, SOURCE_TO_TARGET_LANE_ID, bp_message_dispatch::MessagePayload { @@ -245,7 +261,7 @@ impl SwapTokens { .submit_and_watch_signed_extrinsic( accounts.source_account_at_this_chain.clone(), move |_, transaction_nonce| { - Bytes( + Ok(Bytes( Source::sign_transaction(SignParam { spec_version, transaction_version, @@ -253,12 +269,12 @@ impl SwapTokens { signer: create_swap_signer, era: relay_substrate_client::TransactionEra::immortal(), unsigned: UnsignedTransaction::new( - create_swap_call, + create_swap_call.into(), transaction_nonce, ), - }) + })? .encode(), - ) + )) }, ) .await?, @@ -347,7 +363,7 @@ impl SwapTokens { // if is_transfer_succeeded { - log::info!(target: "bridge", "Claiming the swap swap"); + log::info!(target: "bridge", "Claiming the swap"); // prepare `claim_swap` message that will be sent over the bridge let claim_swap_call: CallOf = @@ -361,9 +377,14 @@ impl SwapTokens { dispatch_fee_payment: bp_runtime::messages::DispatchFeePayment::AtSourceChain, call: claim_swap_call.encode(), }; - let claim_swap_delivery_and_dispatch_fee: BalanceOf = - crate::cli::estimate_fee::estimate_message_delivery_and_dispatch_fee( + let claim_swap_delivery_and_dispatch_fee = + crate::cli::estimate_fee::estimate_message_delivery_and_dispatch_fee::< + Target, + Source, + _, + >( &target_client, + source_to_target_conversion_rate_override.clone(), ESTIMATE_TARGET_TO_SOURCE_MESSAGE_FEE_METHOD, TARGET_TO_SOURCE_LANE_ID, claim_swap_message.clone(), @@ -386,7 +407,7 @@ impl SwapTokens { .submit_and_watch_signed_extrinsic( accounts.target_account_at_bridged_chain.clone(), move |_, transaction_nonce| { - Bytes( + Ok(Bytes( Target::sign_transaction(SignParam { spec_version, transaction_version, @@ -394,12 +415,12 @@ impl SwapTokens { signer: target_sign, era: relay_substrate_client::TransactionEra::immortal(), unsigned: UnsignedTransaction::new( - send_message_call, + send_message_call.into(), transaction_nonce, ), - }) + })? .encode(), - ) + )) }, ) .await?, @@ -430,7 +451,7 @@ impl SwapTokens { .submit_and_watch_signed_extrinsic( accounts.source_account_at_this_chain.clone(), move |_, transaction_nonce| { - Bytes( + Ok(Bytes( Source::sign_transaction(SignParam { spec_version, transaction_version, @@ -438,12 +459,12 @@ impl SwapTokens { signer: source_sign, era: relay_substrate_client::TransactionEra::immortal(), unsigned: UnsignedTransaction::new( - cancel_swap_call, + cancel_swap_call.into(), transaction_nonce, ), - }) + })? .encode(), - ) + )) }, ) .await?, @@ -758,6 +779,8 @@ mod tests { swap_type: TokenSwapType::NoLock, source_balance: Balance(8000000000), target_balance: Balance(9000000000), + target_to_source_conversion_rate_override: None, + source_to_target_conversion_rate_override: None, } ); } @@ -783,6 +806,10 @@ mod tests { "//Bob", "--target-balance", "9000000000", + "--target-to-source-conversion-rate-override", + "metric", + "--source-to-target-conversion-rate-override", + "84.56", "lock-until-block", "--blocks-before-expire", "1", @@ -832,6 +859,10 @@ mod tests { }, source_balance: Balance(8000000000), target_balance: Balance(9000000000), + target_to_source_conversion_rate_override: Some(ConversionRateOverride::Metric), + source_to_target_conversion_rate_override: Some(ConversionRateOverride::Explicit( + 84.56 + )), } ); } diff --git a/relays/client-kusama/Cargo.toml b/relays/client-kusama/Cargo.toml index a48d82f641b..35c24c1089e 100644 --- a/relays/client-kusama/Cargo.toml +++ b/relays/client-kusama/Cargo.toml @@ -2,14 +2,14 @@ name = "relay-kusama-client" version = "0.1.0" authors = ["Parity Technologies "] -edition = "2018" +edition = "2021" license = "GPL-3.0-or-later WITH Classpath-exception-2.0" [dependencies] -codec = { package = "parity-scale-codec", version = "2.2.0" } +codec = { package = "parity-scale-codec", version = "3.0.0" } relay-substrate-client = { path = "../client-substrate" } relay-utils = { path = "../utils" } -scale-info = { version = "1.0", features = ["derive"] } +scale-info = { version = "2.0.1", features = ["derive"] } # Bridge dependencies diff --git a/relays/client-kusama/src/lib.rs b/relays/client-kusama/src/lib.rs index 982bf88d82a..e228f2dc24d 100644 --- a/relays/client-kusama/src/lib.rs +++ b/relays/client-kusama/src/lib.rs @@ -20,8 +20,8 @@ use bp_messages::MessageNonce; use codec::Encode; use frame_support::weights::Weight; use relay_substrate_client::{ - Chain, ChainBase, ChainWithBalances, ChainWithGrandpa, ChainWithMessages, SignParam, - TransactionSignScheme, UnsignedTransaction, + Chain, ChainBase, ChainWithBalances, ChainWithGrandpa, ChainWithMessages, + Error as SubstrateError, SignParam, TransactionSignScheme, UnsignedTransaction, }; use sp_core::{storage::StorageKey, Pair}; use sp_runtime::{generic::SignedPayload, traits::IdentifyAccount}; @@ -79,8 +79,6 @@ impl ChainWithMessages for Kusama { bp_kusama::WITH_KUSAMA_MESSAGES_PALLET_NAME; const TO_CHAIN_MESSAGE_DETAILS_METHOD: &'static str = bp_kusama::TO_KUSAMA_MESSAGE_DETAILS_METHOD; - const FROM_CHAIN_UNREWARDED_RELAYERS_STATE: &'static str = - bp_kusama::FROM_KUSAMA_UNREWARDED_RELAYERS_STATE; const PAY_INBOUND_DISPATCH_FEE_WEIGHT_AT_CHAIN: Weight = bp_kusama::PAY_INBOUND_DISPATCH_FEE_WEIGHT; const MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX: MessageNonce = @@ -101,7 +99,7 @@ impl TransactionSignScheme for Kusama { type AccountKeyPair = sp_core::sr25519::Pair; type SignedTransaction = crate::runtime::UncheckedExtrinsic; - fn sign_transaction(param: SignParam) -> Self::SignedTransaction { + fn sign_transaction(param: SignParam) -> Result { let raw_payload = SignedPayload::new( param.unsigned.call.clone(), bp_kusama::SignedExtensions::new( @@ -119,12 +117,12 @@ impl TransactionSignScheme for Kusama { let signer: sp_runtime::MultiSigner = param.signer.public().into(); let (call, extra, _) = raw_payload.deconstruct(); - bp_kusama::UncheckedExtrinsic::new_signed( + Ok(bp_kusama::UncheckedExtrinsic::new_signed( call, sp_runtime::MultiAddress::Id(signer.into_account()), signature.into(), extra, - ) + )) } fn is_signed(tx: &Self::SignedTransaction) -> bool { diff --git a/relays/client-kusama/src/runtime.rs b/relays/client-kusama/src/runtime.rs index 6d0ab5462d7..59a919e6cb9 100644 --- a/relays/client-kusama/src/runtime.rs +++ b/relays/client-kusama/src/runtime.rs @@ -70,6 +70,9 @@ pub enum Call { /// Balances pallet. #[codec(index = 4)] Balances(BalancesCall), + /// Utility pallet. + #[codec(index = 24)] + Utility(UtilityCall), /// Polkadot bridge pallet. #[codec(index = 110)] BridgePolkadotGrandpa(BridgePolkadotGrandpaCall), @@ -102,6 +105,8 @@ pub enum BridgePolkadotGrandpaCall { ), #[codec(index = 1)] initialize(bp_header_chain::InitializationData<::Header>), + #[codec(index = 3)] + set_operational(bool), } #[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)] @@ -136,6 +141,13 @@ pub enum BridgePolkadotMessagesCall { ), } +#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)] +#[allow(non_camel_case_types)] +pub enum UtilityCall { + #[codec(index = 2)] + batch_all(Vec), +} + #[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)] pub enum BridgePolkadotMessagesParameter { #[codec(index = 0)] diff --git a/relays/client-millau/Cargo.toml b/relays/client-millau/Cargo.toml index da3d4e7fe1d..98932433455 100644 --- a/relays/client-millau/Cargo.toml +++ b/relays/client-millau/Cargo.toml @@ -2,11 +2,11 @@ name = "relay-millau-client" version = "0.1.0" authors = ["Parity Technologies "] -edition = "2018" +edition = "2021" license = "GPL-3.0-or-later WITH Classpath-exception-2.0" [dependencies] -codec = { package = "parity-scale-codec", version = "2.2.0" } +codec = { package = "parity-scale-codec", version = "3.0.0" } relay-substrate-client = { path = "../client-substrate" } relay-utils = { path = "../utils" } diff --git a/relays/client-millau/src/lib.rs b/relays/client-millau/src/lib.rs index 3c159907f7d..eae9d9b4586 100644 --- a/relays/client-millau/src/lib.rs +++ b/relays/client-millau/src/lib.rs @@ -20,8 +20,8 @@ use bp_messages::MessageNonce; use codec::{Compact, Decode, Encode}; use frame_support::weights::Weight; use relay_substrate_client::{ - BalanceOf, Chain, ChainBase, ChainWithBalances, ChainWithGrandpa, ChainWithMessages, IndexOf, - SignParam, TransactionSignScheme, UnsignedTransaction, + BalanceOf, Chain, ChainBase, ChainWithBalances, ChainWithGrandpa, ChainWithMessages, + Error as SubstrateError, IndexOf, SignParam, TransactionSignScheme, UnsignedTransaction, }; use sp_core::{storage::StorageKey, Pair}; use sp_runtime::{generic::SignedPayload, traits::IdentifyAccount}; @@ -31,7 +31,7 @@ use std::time::Duration; pub type HeaderId = relay_utils::HeaderId; /// Millau chain definition. -#[derive(Debug, Clone, Copy)] +#[derive(Debug, Clone, Copy, PartialEq)] pub struct Millau; impl ChainBase for Millau { @@ -63,8 +63,6 @@ impl ChainWithMessages for Millau { bp_millau::WITH_MILLAU_MESSAGES_PALLET_NAME; const TO_CHAIN_MESSAGE_DETAILS_METHOD: &'static str = bp_millau::TO_MILLAU_MESSAGE_DETAILS_METHOD; - const FROM_CHAIN_UNREWARDED_RELAYERS_STATE: &'static str = - bp_millau::FROM_MILLAU_UNREWARDED_RELAYERS_STATE; const PAY_INBOUND_DISPATCH_FEE_WEIGHT_AT_CHAIN: Weight = bp_millau::PAY_INBOUND_DISPATCH_FEE_WEIGHT; const MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX: MessageNonce = @@ -103,10 +101,11 @@ impl TransactionSignScheme for Millau { type AccountKeyPair = sp_core::sr25519::Pair; type SignedTransaction = millau_runtime::UncheckedExtrinsic; - fn sign_transaction(param: SignParam) -> Self::SignedTransaction { + fn sign_transaction(param: SignParam) -> Result { let raw_payload = SignedPayload::from_raw( param.unsigned.call.clone(), ( + frame_system::CheckNonZeroSender::::new(), frame_system::CheckSpecVersion::::new(), frame_system::CheckTxVersion::::new(), frame_system::CheckGenesis::::new(), @@ -116,6 +115,7 @@ impl TransactionSignScheme for Millau { pallet_transaction_payment::ChargeTransactionPayment::::from(param.unsigned.tip), ), ( + (), param.spec_version, param.transaction_version, param.genesis_hash, @@ -129,12 +129,12 @@ impl TransactionSignScheme for Millau { let signer: sp_runtime::MultiSigner = param.signer.public().into(); let (call, extra, _) = raw_payload.deconstruct(); - millau_runtime::UncheckedExtrinsic::new_signed( - call, + Ok(millau_runtime::UncheckedExtrinsic::new_signed( + call.into_decoded()?, signer.into_account(), signature.into(), extra, - ) + )) } fn is_signed(tx: &Self::SignedTransaction) -> bool { @@ -153,9 +153,9 @@ impl TransactionSignScheme for Millau { fn parse_transaction(tx: Self::SignedTransaction) -> Option> { let extra = &tx.signature.as_ref()?.2; Some(UnsignedTransaction { - call: tx.function, - nonce: Compact::>::decode(&mut &extra.4.encode()[..]).ok()?.into(), - tip: Compact::>::decode(&mut &extra.6.encode()[..]) + call: tx.function.into(), + nonce: Compact::>::decode(&mut &extra.5.encode()[..]).ok()?.into(), + tip: Compact::>::decode(&mut &extra.7.encode()[..]) .ok()? .into(), }) @@ -167,3 +167,32 @@ pub type SigningParams = sp_core::sr25519::Pair; /// Millau header type used in headers sync. pub type SyncHeader = relay_substrate_client::SyncHeader; + +#[cfg(test)] +mod tests { + use super::*; + use relay_substrate_client::TransactionEra; + + #[test] + fn parse_transaction_works() { + let unsigned = UnsignedTransaction { + call: millau_runtime::Call::System(millau_runtime::SystemCall::remark { + remark: b"Hello world!".to_vec(), + }) + .into(), + nonce: 777, + tip: 888, + }; + let signed_transaction = Millau::sign_transaction(SignParam { + spec_version: 42, + transaction_version: 50000, + genesis_hash: [42u8; 64].into(), + signer: sp_core::sr25519::Pair::from_seed_slice(&[1u8; 32]).unwrap(), + era: TransactionEra::immortal(), + unsigned: unsigned.clone(), + }) + .unwrap(); + let parsed_transaction = Millau::parse_transaction(signed_transaction).unwrap(); + assert_eq!(parsed_transaction, unsigned); + } +} diff --git a/relays/client-polkadot/Cargo.toml b/relays/client-polkadot/Cargo.toml index ff774865794..96cfa2ce1ba 100644 --- a/relays/client-polkadot/Cargo.toml +++ b/relays/client-polkadot/Cargo.toml @@ -2,14 +2,14 @@ name = "relay-polkadot-client" version = "0.1.0" authors = ["Parity Technologies "] -edition = "2018" +edition = "2021" license = "GPL-3.0-or-later WITH Classpath-exception-2.0" [dependencies] -codec = { package = "parity-scale-codec", version = "2.2.0" } +codec = { package = "parity-scale-codec", version = "3.0.0" } relay-substrate-client = { path = "../client-substrate" } relay-utils = { path = "../utils" } -scale-info = { version = "1.0", features = ["derive"] } +scale-info = { version = "2.0.1", features = ["derive"] } # Bridge dependencies diff --git a/relays/client-polkadot/src/lib.rs b/relays/client-polkadot/src/lib.rs index 6671b8c7228..d4ada45e36c 100644 --- a/relays/client-polkadot/src/lib.rs +++ b/relays/client-polkadot/src/lib.rs @@ -20,8 +20,8 @@ use bp_messages::MessageNonce; use codec::Encode; use frame_support::weights::Weight; use relay_substrate_client::{ - Chain, ChainBase, ChainWithBalances, ChainWithGrandpa, ChainWithMessages, SignParam, - TransactionSignScheme, UnsignedTransaction, + Chain, ChainBase, ChainWithBalances, ChainWithGrandpa, ChainWithMessages, + Error as SubstrateError, SignParam, TransactionSignScheme, UnsignedTransaction, }; use sp_core::{storage::StorageKey, Pair}; use sp_runtime::{generic::SignedPayload, traits::IdentifyAccount}; @@ -80,8 +80,6 @@ impl ChainWithMessages for Polkadot { bp_polkadot::WITH_POLKADOT_MESSAGES_PALLET_NAME; const TO_CHAIN_MESSAGE_DETAILS_METHOD: &'static str = bp_polkadot::TO_POLKADOT_MESSAGE_DETAILS_METHOD; - const FROM_CHAIN_UNREWARDED_RELAYERS_STATE: &'static str = - bp_polkadot::FROM_POLKADOT_UNREWARDED_RELAYERS_STATE; const PAY_INBOUND_DISPATCH_FEE_WEIGHT_AT_CHAIN: Weight = bp_polkadot::PAY_INBOUND_DISPATCH_FEE_WEIGHT; const MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX: MessageNonce = @@ -102,7 +100,7 @@ impl TransactionSignScheme for Polkadot { type AccountKeyPair = sp_core::sr25519::Pair; type SignedTransaction = crate::runtime::UncheckedExtrinsic; - fn sign_transaction(param: SignParam) -> Self::SignedTransaction { + fn sign_transaction(param: SignParam) -> Result { let raw_payload = SignedPayload::new( param.unsigned.call.clone(), bp_polkadot::SignedExtensions::new( @@ -120,12 +118,12 @@ impl TransactionSignScheme for Polkadot { let signer: sp_runtime::MultiSigner = param.signer.public().into(); let (call, extra, _) = raw_payload.deconstruct(); - bp_polkadot::UncheckedExtrinsic::new_signed( + Ok(bp_polkadot::UncheckedExtrinsic::new_signed( call, sp_runtime::MultiAddress::Id(signer.into_account()), signature.into(), extra, - ) + )) } fn is_signed(tx: &Self::SignedTransaction) -> bool { diff --git a/relays/client-polkadot/src/runtime.rs b/relays/client-polkadot/src/runtime.rs index 8b125a37843..fa45115a6b5 100644 --- a/relays/client-polkadot/src/runtime.rs +++ b/relays/client-polkadot/src/runtime.rs @@ -70,6 +70,9 @@ pub enum Call { /// Balances pallet. #[codec(index = 5)] Balances(BalancesCall), + /// Utility pallet. + #[codec(index = 26)] + Utility(UtilityCall), /// Kusama bridge pallet. #[codec(index = 110)] BridgeKusamaGrandpa(BridgeKusamaGrandpaCall), @@ -102,6 +105,8 @@ pub enum BridgeKusamaGrandpaCall { ), #[codec(index = 1)] initialize(bp_header_chain::InitializationData<::Header>), + #[codec(index = 3)] + set_operational(bool), } #[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)] @@ -136,6 +141,13 @@ pub enum BridgeKusamaMessagesCall { ), } +#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)] +#[allow(non_camel_case_types)] +pub enum UtilityCall { + #[codec(index = 2)] + batch_all(Vec), +} + #[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)] pub enum BridgeKusamaMessagesParameter { #[codec(index = 0)] diff --git a/relays/client-rialto-parachain/Cargo.toml b/relays/client-rialto-parachain/Cargo.toml index e4518c68776..ebc28560643 100644 --- a/relays/client-rialto-parachain/Cargo.toml +++ b/relays/client-rialto-parachain/Cargo.toml @@ -2,7 +2,7 @@ name = "relay-rialto-parachain-client" version = "0.1.0" authors = ["Parity Technologies "] -edition = "2018" +edition = "2021" license = "GPL-3.0-or-later WITH Classpath-exception-2.0" [dependencies] diff --git a/relays/client-rialto/Cargo.toml b/relays/client-rialto/Cargo.toml index 483812ca808..37c55dd5f15 100644 --- a/relays/client-rialto/Cargo.toml +++ b/relays/client-rialto/Cargo.toml @@ -2,11 +2,11 @@ name = "relay-rialto-client" version = "0.1.0" authors = ["Parity Technologies "] -edition = "2018" +edition = "2021" license = "GPL-3.0-or-later WITH Classpath-exception-2.0" [dependencies] -codec = { package = "parity-scale-codec", version = "2.2.0" } +codec = { package = "parity-scale-codec", version = "3.0.0" } relay-substrate-client = { path = "../client-substrate" } relay-utils = { path = "../utils" } diff --git a/relays/client-rialto/src/lib.rs b/relays/client-rialto/src/lib.rs index 4062a36b0d7..858227e8083 100644 --- a/relays/client-rialto/src/lib.rs +++ b/relays/client-rialto/src/lib.rs @@ -20,8 +20,8 @@ use bp_messages::MessageNonce; use codec::{Compact, Decode, Encode}; use frame_support::weights::Weight; use relay_substrate_client::{ - BalanceOf, Chain, ChainBase, ChainWithBalances, ChainWithGrandpa, ChainWithMessages, IndexOf, - SignParam, TransactionSignScheme, UnsignedTransaction, + BalanceOf, Chain, ChainBase, ChainWithBalances, ChainWithGrandpa, ChainWithMessages, + Error as SubstrateError, IndexOf, SignParam, TransactionSignScheme, UnsignedTransaction, }; use sp_core::{storage::StorageKey, Pair}; use sp_runtime::{generic::SignedPayload, traits::IdentifyAccount}; @@ -31,7 +31,7 @@ use std::time::Duration; pub type HeaderId = relay_utils::HeaderId; /// Rialto chain definition -#[derive(Debug, Clone, Copy)] +#[derive(Debug, Clone, Copy, PartialEq)] pub struct Rialto; impl ChainBase for Rialto { @@ -78,8 +78,6 @@ impl ChainWithMessages for Rialto { bp_rialto::WITH_RIALTO_MESSAGES_PALLET_NAME; const TO_CHAIN_MESSAGE_DETAILS_METHOD: &'static str = bp_rialto::TO_RIALTO_MESSAGE_DETAILS_METHOD; - const FROM_CHAIN_UNREWARDED_RELAYERS_STATE: &'static str = - bp_rialto::FROM_RIALTO_UNREWARDED_RELAYERS_STATE; const PAY_INBOUND_DISPATCH_FEE_WEIGHT_AT_CHAIN: Weight = bp_rialto::PAY_INBOUND_DISPATCH_FEE_WEIGHT; const MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX: MessageNonce = @@ -103,10 +101,11 @@ impl TransactionSignScheme for Rialto { type AccountKeyPair = sp_core::sr25519::Pair; type SignedTransaction = rialto_runtime::UncheckedExtrinsic; - fn sign_transaction(param: SignParam) -> Self::SignedTransaction { + fn sign_transaction(param: SignParam) -> Result { let raw_payload = SignedPayload::from_raw( param.unsigned.call.clone(), ( + frame_system::CheckNonZeroSender::::new(), frame_system::CheckSpecVersion::::new(), frame_system::CheckTxVersion::::new(), frame_system::CheckGenesis::::new(), @@ -116,6 +115,7 @@ impl TransactionSignScheme for Rialto { pallet_transaction_payment::ChargeTransactionPayment::::from(param.unsigned.tip), ), ( + (), param.spec_version, param.transaction_version, param.genesis_hash, @@ -129,12 +129,12 @@ impl TransactionSignScheme for Rialto { let signer: sp_runtime::MultiSigner = param.signer.public().into(); let (call, extra, _) = raw_payload.deconstruct(); - rialto_runtime::UncheckedExtrinsic::new_signed( - call, + Ok(rialto_runtime::UncheckedExtrinsic::new_signed( + call.into_decoded()?, signer.into_account().into(), signature.into(), extra, - ) + )) } fn is_signed(tx: &Self::SignedTransaction) -> bool { @@ -151,9 +151,9 @@ impl TransactionSignScheme for Rialto { fn parse_transaction(tx: Self::SignedTransaction) -> Option> { let extra = &tx.signature.as_ref()?.2; Some(UnsignedTransaction { - call: tx.function, - nonce: Compact::>::decode(&mut &extra.4.encode()[..]).ok()?.into(), - tip: Compact::>::decode(&mut &extra.6.encode()[..]) + call: tx.function.into(), + nonce: Compact::>::decode(&mut &extra.5.encode()[..]).ok()?.into(), + tip: Compact::>::decode(&mut &extra.7.encode()[..]) .ok()? .into(), }) @@ -165,3 +165,32 @@ pub type SigningParams = sp_core::sr25519::Pair; /// Rialto header type used in headers sync. pub type SyncHeader = relay_substrate_client::SyncHeader; + +#[cfg(test)] +mod tests { + use super::*; + use relay_substrate_client::TransactionEra; + + #[test] + fn parse_transaction_works() { + let unsigned = UnsignedTransaction { + call: rialto_runtime::Call::System(rialto_runtime::SystemCall::remark { + remark: b"Hello world!".to_vec(), + }) + .into(), + nonce: 777, + tip: 888, + }; + let signed_transaction = Rialto::sign_transaction(SignParam { + spec_version: 42, + transaction_version: 50000, + genesis_hash: [42u8; 32].into(), + signer: sp_core::sr25519::Pair::from_seed_slice(&[1u8; 32]).unwrap(), + era: TransactionEra::immortal(), + unsigned: unsigned.clone(), + }) + .unwrap(); + let parsed_transaction = Rialto::parse_transaction(signed_transaction).unwrap(); + assert_eq!(parsed_transaction, unsigned); + } +} diff --git a/relays/client-rococo/Cargo.toml b/relays/client-rococo/Cargo.toml index 28e97d3bf0c..2b78684a853 100644 --- a/relays/client-rococo/Cargo.toml +++ b/relays/client-rococo/Cargo.toml @@ -2,14 +2,14 @@ name = "relay-rococo-client" version = "0.1.0" authors = ["Parity Technologies "] -edition = "2018" +edition = "2021" license = "GPL-3.0-or-later WITH Classpath-exception-2.0" [dependencies] -codec = { package = "parity-scale-codec", version = "2.2.0" } +codec = { package = "parity-scale-codec", version = "3.0.0" } relay-substrate-client = { path = "../client-substrate" } relay-utils = { path = "../utils" } -scale-info = { version = "1.0", features = ["derive"] } +scale-info = { version = "2.0.1", features = ["derive"] } # Bridge dependencies diff --git a/relays/client-rococo/src/lib.rs b/relays/client-rococo/src/lib.rs index 56ca95606a8..f63041df9ed 100644 --- a/relays/client-rococo/src/lib.rs +++ b/relays/client-rococo/src/lib.rs @@ -20,8 +20,8 @@ use bp_messages::MessageNonce; use codec::Encode; use frame_support::weights::Weight; use relay_substrate_client::{ - Chain, ChainBase, ChainWithBalances, ChainWithGrandpa, ChainWithMessages, SignParam, - TransactionSignScheme, UnsignedTransaction, + Chain, ChainBase, ChainWithBalances, ChainWithGrandpa, ChainWithMessages, + Error as SubstrateError, SignParam, TransactionSignScheme, UnsignedTransaction, }; use sp_core::{storage::StorageKey, Pair}; use sp_runtime::{generic::SignedPayload, traits::IdentifyAccount}; @@ -82,8 +82,6 @@ impl ChainWithMessages for Rococo { bp_rococo::WITH_ROCOCO_MESSAGES_PALLET_NAME; const TO_CHAIN_MESSAGE_DETAILS_METHOD: &'static str = bp_rococo::TO_ROCOCO_MESSAGE_DETAILS_METHOD; - const FROM_CHAIN_UNREWARDED_RELAYERS_STATE: &'static str = - bp_rococo::FROM_ROCOCO_UNREWARDED_RELAYERS_STATE; const PAY_INBOUND_DISPATCH_FEE_WEIGHT_AT_CHAIN: Weight = bp_rococo::PAY_INBOUND_DISPATCH_FEE_WEIGHT; const MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX: MessageNonce = @@ -104,7 +102,7 @@ impl TransactionSignScheme for Rococo { type AccountKeyPair = sp_core::sr25519::Pair; type SignedTransaction = crate::runtime::UncheckedExtrinsic; - fn sign_transaction(param: SignParam) -> Self::SignedTransaction { + fn sign_transaction(param: SignParam) -> Result { let raw_payload = SignedPayload::new( param.unsigned.call.clone(), bp_rococo::SignedExtensions::new( @@ -122,12 +120,12 @@ impl TransactionSignScheme for Rococo { let signer: sp_runtime::MultiSigner = param.signer.public().into(); let (call, extra, _) = raw_payload.deconstruct(); - bp_rococo::UncheckedExtrinsic::new_signed( + Ok(bp_rococo::UncheckedExtrinsic::new_signed( call, sp_runtime::MultiAddress::Id(signer.into_account()), signature.into(), extra, - ) + )) } fn is_signed(tx: &Self::SignedTransaction) -> bool { diff --git a/relays/client-substrate/Cargo.toml b/relays/client-substrate/Cargo.toml index b6a702829fa..dad864965e2 100644 --- a/relays/client-substrate/Cargo.toml +++ b/relays/client-substrate/Cargo.toml @@ -2,19 +2,19 @@ name = "relay-substrate-client" version = "0.1.0" authors = ["Parity Technologies "] -edition = "2018" +edition = "2021" license = "GPL-3.0-or-later WITH Classpath-exception-2.0" [dependencies] async-std = { version = "1.6.5", features = ["attributes"] } async-trait = "0.1.40" -codec = { package = "parity-scale-codec", version = "2.2.0" } -jsonrpsee-proc-macros = "0.3.1" -jsonrpsee-ws-client = "0.3.1" +codec = { package = "parity-scale-codec", version = "3.0.0" } +jsonrpsee = { version = "0.8", features = ["macros", "ws-client"] } log = "0.4.11" num-traits = "0.2" rand = "0.7" -tokio = "1.8" +serde = { version = "1.0" } +tokio = { version = "1.8", features = ["rt-multi-thread"] } thiserror = "1.0.26" # Bridge dependencies diff --git a/relays/client-substrate/src/chain.rs b/relays/client-substrate/src/chain.rs index 24b0127f3a7..60adfb0a88a 100644 --- a/relays/client-substrate/src/chain.rs +++ b/relays/client-substrate/src/chain.rs @@ -15,10 +15,10 @@ // along with Parity Bridges Common. If not, see . use bp_messages::MessageNonce; -use bp_runtime::{Chain as ChainBase, HashOf, TransactionEraOf}; +use bp_runtime::{Chain as ChainBase, EncodedOrDecodedCall, HashOf, TransactionEraOf}; use codec::{Codec, Encode}; use frame_support::weights::{Weight, WeightToFeePolynomial}; -use jsonrpsee_ws_client::types::{DeserializeOwned, Serialize}; +use jsonrpsee::core::{DeserializeOwned, Serialize}; use num_traits::Zero; use sc_transaction_pool_api::TransactionStatus; use sp_core::{storage::StorageKey, Pair}; @@ -91,10 +91,6 @@ pub trait ChainWithMessages: Chain { /// The method is provided by the runtime that is bridged with this `ChainWithMessages`. const TO_CHAIN_MESSAGE_DETAILS_METHOD: &'static str; - /// Name of the `FromInboundLaneApi::unrewarded_relayers_state` runtime - /// method. The method is provided by the runtime that is bridged with this `ChainWithMessages`. - const FROM_CHAIN_UNREWARDED_RELAYERS_STATE: &'static str; - /// Additional weight of the dispatch fee payment if dispatch is paid at the target chain /// and this `ChainWithMessages` is the target chain. const PAY_INBOUND_DISPATCH_FEE_WEIGHT_AT_CHAIN: Weight; @@ -138,10 +134,10 @@ pub trait BlockWithJustification

{ } /// Transaction before it is signed. -#[derive(Clone, Debug)] +#[derive(Clone, Debug, PartialEq)] pub struct UnsignedTransaction { /// Runtime call of this transaction. - pub call: C::Call, + pub call: EncodedOrDecodedCall, /// Transaction nonce. pub nonce: C::Index, /// Tip included into transaction. @@ -150,7 +146,7 @@ pub struct UnsignedTransaction { impl UnsignedTransaction { /// Create new unsigned transaction with given call, nonce and zero tip. - pub fn new(call: C::Call, nonce: C::Index) -> Self { + pub fn new(call: EncodedOrDecodedCall, nonce: C::Index) -> Self { Self { call, nonce, tip: Zero::zero() } } @@ -174,7 +170,7 @@ pub trait TransactionSignScheme { type SignedTransaction: Clone + Debug + Codec + Send + 'static; /// Create transaction for given runtime call, signed by given account. - fn sign_transaction(param: SignParam) -> Self::SignedTransaction + fn sign_transaction(param: SignParam) -> Result where Self: Sized; diff --git a/relays/client-substrate/src/client.rs b/relays/client-substrate/src/client.rs index 685f938d18a..1e48bc33396 100644 --- a/relays/client-substrate/src/client.rs +++ b/relays/client-substrate/src/client.rs @@ -18,8 +18,9 @@ use crate::{ chain::{Chain, ChainWithBalances, TransactionStatusOf}, - rpc::Substrate, - ConnectionParams, Error, HashOf, HeaderIdOf, Result, + rpc::SubstrateClient, + AccountIdOf, BlockNumberOf, ConnectionParams, Error, HashOf, HeaderIdOf, HeaderOf, IndexOf, + Result, }; use async_std::sync::{Arc, Mutex}; @@ -27,12 +28,10 @@ use async_trait::async_trait; use codec::{Decode, Encode}; use frame_system::AccountInfo; use futures::{SinkExt, StreamExt}; -use jsonrpsee_ws_client::{ - types::{ - self as jsonrpsee_types, traits::SubscriptionClient, v2::params::JsonRpcParams, - DeserializeOwned, - }, - WsClient as RpcClient, WsClientBuilder as RpcClientBuilder, +use jsonrpsee::{ + core::{client::SubscriptionClientT, DeserializeOwned}, + types::params::ParamsSer, + ws_client::{WsClient as RpcClient, WsClientBuilder as RpcClientBuilder}, }; use num_traits::{Bounded, CheckedSub, One, Zero}; use pallet_balances::AccountData; @@ -154,7 +153,15 @@ impl Client { let genesis_hash_client = client.clone(); let genesis_hash = tokio .spawn(async move { - Substrate::::chain_get_block_hash(&*genesis_hash_client, number).await + SubstrateClient::< + AccountIdOf, + BlockNumberOf, + HashOf, + HeaderOf, + IndexOf, + C::SignedBlock, + >::chain_get_block_hash(&*genesis_hash_client, Some(number)) + .await }) .await??; @@ -210,7 +217,15 @@ impl Client { /// Returns true if client is connected to at least one peer and is in synced state. pub async fn ensure_synced(&self) -> Result<()> { self.jsonrpsee_execute(|client| async move { - let health = Substrate::::system_health(&*client).await?; + let health = SubstrateClient::< + AccountIdOf, + BlockNumberOf, + HashOf, + HeaderOf, + IndexOf, + C::SignedBlock, + >::system_health(&*client) + .await?; let is_synced = !health.is_syncing && (!health.should_have_peers || health.peers > 0); if is_synced { Ok(()) @@ -229,7 +244,15 @@ impl Client { /// Return hash of the best finalized block. pub async fn best_finalized_header_hash(&self) -> Result { self.jsonrpsee_execute(|client| async move { - Ok(Substrate::::chain_get_finalized_head(&*client).await?) + Ok(SubstrateClient::< + AccountIdOf, + BlockNumberOf, + HashOf, + HeaderOf, + IndexOf, + C::SignedBlock, + >::chain_get_finalized_head(&*client) + .await?) }) .await } @@ -245,7 +268,15 @@ impl Client { C::Header: DeserializeOwned, { self.jsonrpsee_execute(|client| async move { - Ok(Substrate::::chain_get_header(&*client, None).await?) + Ok(SubstrateClient::< + AccountIdOf, + BlockNumberOf, + HashOf, + HeaderOf, + IndexOf, + C::SignedBlock, + >::chain_get_header(&*client, None) + .await?) }) .await } @@ -253,7 +284,15 @@ impl Client { /// Get a Substrate block from its hash. pub async fn get_block(&self, block_hash: Option) -> Result { self.jsonrpsee_execute(move |client| async move { - Ok(Substrate::::chain_get_block(&*client, block_hash).await?) + Ok(SubstrateClient::< + AccountIdOf, + BlockNumberOf, + HashOf, + HeaderOf, + IndexOf, + C::SignedBlock, + >::chain_get_block(&*client, block_hash) + .await?) }) .await } @@ -264,7 +303,15 @@ impl Client { C::Header: DeserializeOwned, { self.jsonrpsee_execute(move |client| async move { - Ok(Substrate::::chain_get_header(&*client, block_hash).await?) + Ok(SubstrateClient::< + AccountIdOf, + BlockNumberOf, + HashOf, + HeaderOf, + IndexOf, + C::SignedBlock, + >::chain_get_header(&*client, Some(block_hash)) + .await?) }) .await } @@ -272,7 +319,15 @@ impl Client { /// Get a Substrate block hash by its number. pub async fn block_hash_by_number(&self, number: C::BlockNumber) -> Result { self.jsonrpsee_execute(move |client| async move { - Ok(Substrate::::chain_get_block_hash(&*client, number).await?) + Ok(SubstrateClient::< + AccountIdOf, + BlockNumberOf, + HashOf, + HeaderOf, + IndexOf, + C::SignedBlock, + >::chain_get_block_hash(&*client, Some(number)) + .await?) }) .await } @@ -290,7 +345,15 @@ impl Client { /// Return runtime version. pub async fn runtime_version(&self) -> Result { self.jsonrpsee_execute(move |client| async move { - Ok(Substrate::::state_runtime_version(&*client).await?) + Ok(SubstrateClient::< + AccountIdOf, + BlockNumberOf, + HashOf, + HeaderOf, + IndexOf, + C::SignedBlock, + >::state_runtime_version(&*client) + .await?) }) .await } @@ -316,7 +379,15 @@ impl Client { block_hash: Option, ) -> Result> { self.jsonrpsee_execute(move |client| async move { - Ok(Substrate::::state_get_storage(&*client, storage_key, block_hash).await?) + Ok(SubstrateClient::< + AccountIdOf, + BlockNumberOf, + HashOf, + HeaderOf, + IndexOf, + C::SignedBlock, + >::state_get_storage(&*client, storage_key, block_hash) + .await?) }) .await } @@ -328,10 +399,16 @@ impl Client { { self.jsonrpsee_execute(move |client| async move { let storage_key = C::account_info_storage_key(&account); - let encoded_account_data = - Substrate::::state_get_storage(&*client, storage_key, None) - .await? - .ok_or(Error::AccountDoesNotExist)?; + let encoded_account_data = SubstrateClient::< + AccountIdOf, + BlockNumberOf, + HashOf, + HeaderOf, + IndexOf, + C::SignedBlock, + >::state_get_storage(&*client, storage_key, None) + .await? + .ok_or(Error::AccountDoesNotExist)?; let decoded_account_data = AccountInfo::>::decode( &mut &encoded_account_data.0[..], ) @@ -346,7 +423,15 @@ impl Client { /// Note: It's the caller's responsibility to make sure `account` is a valid SS58 address. pub async fn next_account_index(&self, account: C::AccountId) -> Result { self.jsonrpsee_execute(move |client| async move { - Ok(Substrate::::system_account_next_index(&*client, account).await?) + Ok(SubstrateClient::< + AccountIdOf, + BlockNumberOf, + HashOf, + HeaderOf, + IndexOf, + C::SignedBlock, + >::system_account_next_index(&*client, account) + .await?) }) .await } @@ -356,7 +441,15 @@ impl Client { /// Note: The given transaction needs to be SCALE encoded beforehand. pub async fn submit_unsigned_extrinsic(&self, transaction: Bytes) -> Result { self.jsonrpsee_execute(move |client| async move { - let tx_hash = Substrate::::author_submit_extrinsic(&*client, transaction).await?; + let tx_hash = SubstrateClient::< + AccountIdOf, + BlockNumberOf, + HashOf, + HeaderOf, + IndexOf, + C::SignedBlock, + >::author_submit_extrinsic(&*client, transaction) + .await?; log::trace!(target: "bridge", "Sent transaction to Substrate node: {:?}", tx_hash); Ok(tx_hash) }) @@ -373,7 +466,7 @@ impl Client { pub async fn submit_signed_extrinsic( &self, extrinsic_signer: C::AccountId, - prepare_extrinsic: impl FnOnce(HeaderIdOf, C::Index) -> Bytes + Send + 'static, + prepare_extrinsic: impl FnOnce(HeaderIdOf, C::Index) -> Result + Send + 'static, ) -> Result { let _guard = self.submit_signed_extrinsic_lock.lock().await; let transaction_nonce = self.next_account_index(extrinsic_signer).await?; @@ -390,8 +483,16 @@ impl Client { }; self.jsonrpsee_execute(move |client| async move { - let extrinsic = prepare_extrinsic(best_header_id, transaction_nonce); - let tx_hash = Substrate::::author_submit_extrinsic(&*client, extrinsic).await?; + let extrinsic = prepare_extrinsic(best_header_id, transaction_nonce)?; + let tx_hash = SubstrateClient::< + AccountIdOf, + BlockNumberOf, + HashOf, + HeaderOf, + IndexOf, + C::SignedBlock, + >::author_submit_extrinsic(&*client, extrinsic) + .await?; log::trace!(target: "bridge", "Sent transaction to {} node: {:?}", C::NAME, tx_hash); Ok(tx_hash) }) @@ -403,7 +504,7 @@ impl Client { pub async fn submit_and_watch_signed_extrinsic( &self, extrinsic_signer: C::AccountId, - prepare_extrinsic: impl FnOnce(HeaderIdOf, C::Index) -> Bytes + Send + 'static, + prepare_extrinsic: impl FnOnce(HeaderIdOf, C::Index) -> Result + Send + 'static, ) -> Result>> { let _guard = self.submit_signed_extrinsic_lock.lock().await; let transaction_nonce = self.next_account_index(extrinsic_signer).await?; @@ -411,13 +512,13 @@ impl Client { let best_header_id = HeaderId(*best_header.number(), best_header.hash()); let subscription = self .jsonrpsee_execute(move |client| async move { - let extrinsic = prepare_extrinsic(best_header_id, transaction_nonce); + let extrinsic = prepare_extrinsic(best_header_id, transaction_nonce)?; let tx_hash = C::Hasher::hash(&extrinsic.0); let subscription = client .subscribe( "author_submitAndWatchExtrinsic", - JsonRpcParams::Array(vec![jsonrpsee_types::to_json_value(extrinsic) - .map_err(|e| Error::RpcError(e.into()))?]), + Some(ParamsSer::Array(vec![jsonrpsee::core::to_json_value(extrinsic) + .map_err(|e| Error::RpcError(e.into()))?])), "author_unwatchExtrinsic", ) .await?; @@ -438,7 +539,15 @@ impl Client { /// Returns pending extrinsics from transaction pool. pub async fn pending_extrinsics(&self) -> Result> { self.jsonrpsee_execute(move |client| async move { - Ok(Substrate::::author_pending_extrinsics(&*client).await?) + Ok(SubstrateClient::< + AccountIdOf, + BlockNumberOf, + HashOf, + HeaderOf, + IndexOf, + C::SignedBlock, + >::author_pending_extrinsics(&*client) + .await?) }) .await } @@ -453,8 +562,15 @@ impl Client { let call = SUB_API_TXPOOL_VALIDATE_TRANSACTION.to_string(); let data = Bytes((TransactionSource::External, transaction, at_block).encode()); - let encoded_response = - Substrate::::state_call(&*client, call, data, Some(at_block)).await?; + let encoded_response = SubstrateClient::< + AccountIdOf, + BlockNumberOf, + HashOf, + HeaderOf, + IndexOf, + C::SignedBlock, + >::state_call(&*client, call, data, Some(at_block)) + .await?; let validity = TransactionValidity::decode(&mut &encoded_response.0[..]) .map_err(Error::ResponseParseFailed)?; @@ -469,8 +585,15 @@ impl Client { transaction: Bytes, ) -> Result> { self.jsonrpsee_execute(move |client| async move { - let fee_details = - Substrate::::payment_query_fee_details(&*client, transaction, None).await?; + let fee_details = SubstrateClient::< + AccountIdOf, + BlockNumberOf, + HashOf, + HeaderOf, + IndexOf, + C::SignedBlock, + >::payment_query_fee_details(&*client, transaction, None) + .await?; let inclusion_fee = fee_details .inclusion_fee .map(|inclusion_fee| InclusionFee { @@ -502,8 +625,15 @@ impl Client { let call = SUB_API_GRANDPA_AUTHORITIES.to_string(); let data = Bytes(Vec::new()); - let encoded_response = - Substrate::::state_call(&*client, call, data, Some(block)).await?; + let encoded_response = SubstrateClient::< + AccountIdOf, + BlockNumberOf, + HashOf, + HeaderOf, + IndexOf, + C::SignedBlock, + >::state_call(&*client, call, data, Some(block)) + .await?; let authority_list = encoded_response.0; Ok(authority_list) @@ -519,9 +649,16 @@ impl Client { at_block: Option, ) -> Result { self.jsonrpsee_execute(move |client| async move { - Substrate::::state_call(&*client, method, data, at_block) - .await - .map_err(Into::into) + SubstrateClient::< + AccountIdOf, + BlockNumberOf, + HashOf, + HeaderOf, + IndexOf, + C::SignedBlock, + >::state_call(&*client, method, data, at_block) + .await + .map_err(Into::into) }) .await } @@ -533,10 +670,19 @@ impl Client { at_block: C::Hash, ) -> Result { self.jsonrpsee_execute(move |client| async move { - Substrate::::state_prove_storage(&*client, keys, Some(at_block)) - .await - .map(|proof| StorageProof::new(proof.proof.into_iter().map(|b| b.0).collect())) - .map_err(Into::into) + SubstrateClient::< + AccountIdOf, + BlockNumberOf, + HashOf, + HeaderOf, + IndexOf, + C::SignedBlock, + >::state_prove_storage(&*client, keys, Some(at_block)) + .await + .map(|proof| { + StorageProof::new(proof.proof.into_iter().map(|b| b.0).collect::>()) + }) + .map_err(Into::into) }) .await } @@ -544,7 +690,15 @@ impl Client { /// Return `tokenDecimals` property from the set of chain properties. pub async fn token_decimals(&self) -> Result> { self.jsonrpsee_execute(move |client| async move { - let system_properties = Substrate::::system_properties(&*client).await?; + let system_properties = SubstrateClient::< + AccountIdOf, + BlockNumberOf, + HashOf, + HeaderOf, + IndexOf, + C::SignedBlock, + >::system_properties(&*client) + .await?; Ok(system_properties.get("tokenDecimals").and_then(|v| v.as_u64())) }) .await @@ -557,7 +711,7 @@ impl Client { Ok(client .subscribe( "grandpa_subscribeJustifications", - JsonRpcParams::NoParams, + None, "grandpa_unsubscribeJustifications", ) .await?) @@ -597,32 +751,32 @@ impl Subscription { async fn background_worker( chain_name: String, item_type: String, - mut subscription: jsonrpsee_types::Subscription, + mut subscription: jsonrpsee::core::client::Subscription, mut sender: futures::channel::mpsc::Sender>, ) { loop { match subscription.next().await { - Ok(Some(item)) => + Some(Ok(item)) => if sender.send(Some(item)).await.is_err() { break }, - Ok(None) => { + Some(Err(e)) => { log::trace!( target: "bridge", - "{} {} subscription stream has returned None. Stream needs to be restarted.", + "{} {} subscription stream has returned '{:?}'. Stream needs to be restarted.", chain_name, item_type, + e, ); let _ = sender.send(None).await; break }, - Err(e) => { + None => { log::trace!( target: "bridge", - "{} {} subscription stream has returned '{:?}'. Stream needs to be restarted.", + "{} {} subscription stream has returned None. Stream needs to be restarted.", chain_name, item_type, - e, ); let _ = sender.send(None).await; break diff --git a/relays/client-substrate/src/error.rs b/relays/client-substrate/src/error.rs index 309531dd260..e698f2596c5 100644 --- a/relays/client-substrate/src/error.rs +++ b/relays/client-substrate/src/error.rs @@ -16,7 +16,7 @@ //! Substrate node RPC errors. -use jsonrpsee_ws_client::types::Error as RpcError; +use jsonrpsee::core::Error as RpcError; use relay_utils::MaybeConnectionError; use sc_rpc_api::system::Health; use sp_runtime::transaction_validity::TransactionValidityError; diff --git a/relays/client-substrate/src/rpc.rs b/relays/client-substrate/src/rpc.rs index b792347d7a2..a0172d1e550 100644 --- a/relays/client-substrate/src/rpc.rs +++ b/relays/client-substrate/src/rpc.rs @@ -16,8 +16,7 @@ //! The most generic Substrate node RPC interface. -use crate::chain::Chain; - +use jsonrpsee::{core::RpcResult, proc_macros::rpc}; use pallet_transaction_payment_rpc_runtime_api::FeeDetails; use sc_rpc_api::{state::ReadProof, system::Health}; use sp_core::{ @@ -27,35 +26,51 @@ use sp_core::{ use sp_rpc::number::NumberOrHex; use sp_version::RuntimeVersion; -jsonrpsee_proc_macros::rpc_client_api! { - pub(crate) Substrate { - #[rpc(method = "system_health", positional_params)] - fn system_health() -> Health; - #[rpc(method = "system_properties", positional_params)] - fn system_properties() -> sc_chain_spec::Properties; - #[rpc(method = "chain_getHeader", positional_params)] - fn chain_get_header(block_hash: Option) -> C::Header; - #[rpc(method = "chain_getFinalizedHead", positional_params)] - fn chain_get_finalized_head() -> C::Hash; - #[rpc(method = "chain_getBlock", positional_params)] - fn chain_get_block(block_hash: Option) -> C::SignedBlock; - #[rpc(method = "chain_getBlockHash", positional_params)] - fn chain_get_block_hash(block_number: Option) -> C::Hash; - #[rpc(method = "system_accountNextIndex", positional_params)] - fn system_account_next_index(account_id: C::AccountId) -> C::Index; - #[rpc(method = "author_submitExtrinsic", positional_params)] - fn author_submit_extrinsic(extrinsic: Bytes) -> C::Hash; - #[rpc(method = "author_pendingExtrinsics", positional_params)] - fn author_pending_extrinsics() -> Vec; - #[rpc(method = "state_call", positional_params)] - fn state_call(method: String, data: Bytes, at_block: Option) -> Bytes; - #[rpc(method = "state_getStorage", positional_params)] - fn state_get_storage(key: StorageKey, at_block: Option) -> Option; - #[rpc(method = "state_getReadProof", positional_params)] - fn state_prove_storage(keys: Vec, hash: Option) -> ReadProof; - #[rpc(method = "state_getRuntimeVersion", positional_params)] - fn state_runtime_version() -> RuntimeVersion; - #[rpc(method = "payment_queryFeeDetails", positional_params)] - fn payment_query_fee_details(extrinsic: Bytes, at_block: Option) -> FeeDetails; - } +#[rpc(client)] +pub(crate) trait Substrate { + #[method(name = "system_health", param_kind = array)] + async fn system_health(&self) -> RpcResult; + #[method(name = "system_properties", param_kind = array)] + async fn system_properties(&self) -> RpcResult; + #[method(name = "chain_getHeader", param_kind = array)] + async fn chain_get_header(&self, block_hash: Option) -> RpcResult
; + #[method(name = "chain_getFinalizedHead", param_kind = array)] + async fn chain_get_finalized_head(&self) -> RpcResult; + #[method(name = "chain_getBlock", param_kind = array)] + async fn chain_get_block(&self, block_hash: Option) -> RpcResult; + #[method(name = "chain_getBlockHash", param_kind = array)] + async fn chain_get_block_hash(&self, block_number: Option) -> RpcResult; + #[method(name = "system_accountNextIndex", param_kind = array)] + async fn system_account_next_index(&self, account_id: AccountId) -> RpcResult; + #[method(name = "author_submitExtrinsic", param_kind = array)] + async fn author_submit_extrinsic(&self, extrinsic: Bytes) -> RpcResult; + #[method(name = "author_pendingExtrinsics", param_kind = array)] + async fn author_pending_extrinsics(&self) -> RpcResult>; + #[method(name = "state_call", param_kind = array)] + async fn state_call( + &self, + method: String, + data: Bytes, + at_block: Option, + ) -> RpcResult; + #[method(name = "state_getStorage", param_kind = array)] + async fn state_get_storage( + &self, + key: StorageKey, + at_block: Option, + ) -> RpcResult>; + #[method(name = "state_getReadProof", param_kind = array)] + async fn state_prove_storage( + &self, + keys: Vec, + hash: Option, + ) -> RpcResult>; + #[method(name = "state_getRuntimeVersion", param_kind = array)] + async fn state_runtime_version(&self) -> RpcResult; + #[method(name = "payment_queryFeeDetails", param_kind = array)] + async fn payment_query_fee_details( + &self, + extrinsic: Bytes, + at_block: Option, + ) -> RpcResult>; } diff --git a/relays/client-substrate/src/sync_header.rs b/relays/client-substrate/src/sync_header.rs index ed3de6289ce..e45e6b4197a 100644 --- a/relays/client-substrate/src/sync_header.rs +++ b/relays/client-substrate/src/sync_header.rs @@ -44,7 +44,11 @@ impl
From
for SyncHeader
{ } } -impl FinalitySourceHeader for SyncHeader
{ +impl FinalitySourceHeader for SyncHeader
{ + fn hash(&self) -> Header::Hash { + self.0.hash() + } + fn number(&self) -> Header::Number { *self.0.number() } diff --git a/relays/client-westend/Cargo.toml b/relays/client-westend/Cargo.toml index 9bbb0b6fb13..d38aa162994 100644 --- a/relays/client-westend/Cargo.toml +++ b/relays/client-westend/Cargo.toml @@ -2,11 +2,11 @@ name = "relay-westend-client" version = "0.1.0" authors = ["Parity Technologies "] -edition = "2018" +edition = "2021" license = "GPL-3.0-or-later WITH Classpath-exception-2.0" [dependencies] -codec = { package = "parity-scale-codec", version = "2.2.0" } +codec = { package = "parity-scale-codec", version = "3.0.0" } relay-substrate-client = { path = "../client-substrate" } relay-utils = { path = "../utils" } diff --git a/relays/client-wococo/Cargo.toml b/relays/client-wococo/Cargo.toml index ea46c3c898b..6845ac34c84 100644 --- a/relays/client-wococo/Cargo.toml +++ b/relays/client-wococo/Cargo.toml @@ -2,14 +2,14 @@ name = "relay-wococo-client" version = "0.1.0" authors = ["Parity Technologies "] -edition = "2018" +edition = "2021" license = "GPL-3.0-or-later WITH Classpath-exception-2.0" [dependencies] -codec = { package = "parity-scale-codec", version = "2.2.0" } +codec = { package = "parity-scale-codec", version = "3.0.0" } relay-substrate-client = { path = "../client-substrate" } relay-utils = { path = "../utils" } -scale-info = { version = "1.0", default-features = false, features = ["derive"] } +scale-info = { version = "2.0.1", default-features = false, features = ["derive"] } # Bridge dependencies bridge-runtime-common = { path = "../../bin/runtime-common" } diff --git a/relays/client-wococo/src/lib.rs b/relays/client-wococo/src/lib.rs index fd45fc0dc18..485ca1bd62f 100644 --- a/relays/client-wococo/src/lib.rs +++ b/relays/client-wococo/src/lib.rs @@ -20,8 +20,8 @@ use bp_messages::MessageNonce; use codec::Encode; use frame_support::weights::Weight; use relay_substrate_client::{ - Chain, ChainBase, ChainWithBalances, ChainWithGrandpa, ChainWithMessages, SignParam, - TransactionSignScheme, UnsignedTransaction, + Chain, ChainBase, ChainWithBalances, ChainWithGrandpa, ChainWithMessages, + Error as SubstrateError, SignParam, TransactionSignScheme, UnsignedTransaction, }; use sp_core::{storage::StorageKey, Pair}; use sp_runtime::{generic::SignedPayload, traits::IdentifyAccount}; @@ -82,8 +82,6 @@ impl ChainWithMessages for Wococo { bp_wococo::WITH_WOCOCO_MESSAGES_PALLET_NAME; const TO_CHAIN_MESSAGE_DETAILS_METHOD: &'static str = bp_wococo::TO_WOCOCO_MESSAGE_DETAILS_METHOD; - const FROM_CHAIN_UNREWARDED_RELAYERS_STATE: &'static str = - bp_wococo::FROM_WOCOCO_UNREWARDED_RELAYERS_STATE; const PAY_INBOUND_DISPATCH_FEE_WEIGHT_AT_CHAIN: Weight = bp_wococo::PAY_INBOUND_DISPATCH_FEE_WEIGHT; const MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX: MessageNonce = @@ -104,7 +102,7 @@ impl TransactionSignScheme for Wococo { type AccountKeyPair = sp_core::sr25519::Pair; type SignedTransaction = crate::runtime::UncheckedExtrinsic; - fn sign_transaction(param: SignParam) -> Self::SignedTransaction { + fn sign_transaction(param: SignParam) -> Result { let raw_payload = SignedPayload::new( param.unsigned.call.clone(), bp_wococo::SignedExtensions::new( @@ -122,12 +120,12 @@ impl TransactionSignScheme for Wococo { let signer: sp_runtime::MultiSigner = param.signer.public().into(); let (call, extra, _) = raw_payload.deconstruct(); - bp_wococo::UncheckedExtrinsic::new_signed( + Ok(bp_wococo::UncheckedExtrinsic::new_signed( call, sp_runtime::MultiAddress::Id(signer.into_account()), signature.into(), extra, - ) + )) } fn is_signed(tx: &Self::SignedTransaction) -> bool { diff --git a/relays/finality/Cargo.toml b/relays/finality/Cargo.toml index 645ac10775b..cc5ae54be33 100644 --- a/relays/finality/Cargo.toml +++ b/relays/finality/Cargo.toml @@ -2,7 +2,7 @@ name = "finality-relay" version = "0.1.0" authors = ["Parity Technologies "] -edition = "2018" +edition = "2021" license = "GPL-3.0-or-later WITH Classpath-exception-2.0" description = "Finality proofs relay" diff --git a/relays/finality/src/finality_loop.rs b/relays/finality/src/finality_loop.rs index 320b44d310f..c29a5d5fec2 100644 --- a/relays/finality/src/finality_loop.rs +++ b/relays/finality/src/finality_loop.rs @@ -29,7 +29,7 @@ use futures::{select, Future, FutureExt, Stream, StreamExt}; use num_traits::{One, Saturating}; use relay_utils::{ metrics::MetricsParams, relay_loop::Client as RelayClient, retry_backoff, FailedClient, - MaybeConnectionError, + HeaderId, MaybeConnectionError, }; use std::{ pin::Pin, @@ -87,7 +87,9 @@ pub trait SourceClient: RelayClient { #[async_trait] pub trait TargetClient: RelayClient { /// Get best finalized source block number. - async fn best_finalized_source_block_number(&self) -> Result; + async fn best_finalized_source_block_id( + &self, + ) -> Result, Self::Error>; /// Submit header finality proof. async fn submit_finality_proof( @@ -114,7 +116,11 @@ pub async fn run( let exit_signal = exit_signal.shared(); relay_utils::relay_loop(source_client, target_client) .with_metrics(metrics_params) - .loop_metric(SyncLoopMetrics::new(Some(&metrics_prefix::

()))?)? + .loop_metric(SyncLoopMetrics::new( + Some(&metrics_prefix::

()), + "source", + "source_at_target", + )?)? .expose() .await? .run(metrics_prefix::

(), move |source_client, target_client, metrics| { @@ -169,7 +175,7 @@ where /// Information about transaction that we have submitted. #[derive(Debug, Clone)] -struct Transaction { +pub(crate) struct Transaction { /// Time when we have submitted this transaction. pub time: Instant, /// The number of the header we have submitted. @@ -181,7 +187,7 @@ pub(crate) struct RestartableFinalityProofsStream { /// Flag that the stream needs to be restarted. pub(crate) needs_restart: bool, /// The stream itself. - stream: Pin>, + pub(crate) stream: Pin>, } #[cfg(test)] @@ -192,15 +198,16 @@ impl From for RestartableFinalityProofsStream { } /// Finality synchronization loop state. -struct FinalityLoopState<'a, P: FinalitySyncPipeline, FinalityProofsStream> { +pub(crate) struct FinalityLoopState<'a, P: FinalitySyncPipeline, FinalityProofsStream> { /// Synchronization loop progress. - progress: &'a mut (Instant, Option), + pub(crate) progress: &'a mut (Instant, Option), /// Finality proofs stream. - finality_proofs_stream: &'a mut RestartableFinalityProofsStream, + pub(crate) finality_proofs_stream: + &'a mut RestartableFinalityProofsStream, /// Recent finality proofs that we have read from the stream. - recent_finality_proofs: &'a mut FinalityProofs

, + pub(crate) recent_finality_proofs: &'a mut FinalityProofs

, /// Last transaction that we have submitted to the target node. - last_transaction: Option>, + pub(crate) last_transaction: Option>, } async fn run_until_connection_lost( @@ -280,7 +287,7 @@ async fn run_until_connection_lost( } } -async fn run_loop_iteration( +pub(crate) async fn run_loop_iteration( source_client: &SC, target_client: &TC, state: FinalityLoopState<'_, P, SC::FinalityProofsStream>, @@ -295,13 +302,31 @@ where // read best source headers ids from source and target nodes let best_number_at_source = source_client.best_finalized_block_number().await.map_err(Error::Source)?; - let best_number_at_target = target_client - .best_finalized_source_block_number() + let best_id_at_target = + target_client.best_finalized_source_block_id().await.map_err(Error::Target)?; + let best_number_at_target = best_id_at_target.0; + + let different_hash_at_source = ensure_same_fork::(&best_id_at_target, source_client) .await - .map_err(Error::Target)?; + .map_err(Error::Source)?; + let using_same_fork = different_hash_at_source.is_none(); + if let Some(ref different_hash_at_source) = different_hash_at_source { + log::error!( + target: "bridge", + "Source node ({}) and pallet at target node ({}) have different headers at the same height {:?}: \ + at-source {:?} vs at-target {:?}", + P::SOURCE_NAME, + P::TARGET_NAME, + best_number_at_target, + different_hash_at_source, + best_id_at_target.1, + ); + } + if let Some(ref metrics_sync) = *metrics_sync { metrics_sync.update_best_block_at_source(best_number_at_source); metrics_sync.update_best_block_at_target(best_number_at_target); + metrics_sync.update_using_same_fork(using_same_fork); } *state.progress = print_sync_progress::

(*state.progress, best_number_at_source, best_number_at_target); @@ -427,6 +452,22 @@ where Ok(selected_finality_proof) } +/// Ensures that both clients are on the same fork. +/// +/// Returns `Some(_)` with header has at the source client if headers are different. +async fn ensure_same_fork>( + best_id_at_target: &HeaderId, + source_client: &SC, +) -> Result, SC::Error> { + let header_at_source = source_client.header_and_finality_proof(best_id_at_target.0).await?.0; + let header_hash_at_source = header_at_source.hash(); + Ok(if best_id_at_target.1 == header_hash_at_source { + None + } else { + Some(header_hash_at_source) + }) +} + /// Finality proof that has been selected by the `read_missing_headers` function. pub(crate) enum SelectedFinalityProof { /// Mandatory header and its proof has been selected. We shall submit proof for this header. diff --git a/relays/finality/src/finality_loop_tests.rs b/relays/finality/src/finality_loop_tests.rs index 915b7ee6766..478d8e1be65 100644 --- a/relays/finality/src/finality_loop_tests.rs +++ b/relays/finality/src/finality_loop_tests.rs @@ -20,10 +20,12 @@ use crate::{ finality_loop::{ - prune_recent_finality_proofs, read_finality_proofs_from_stream, run, - select_better_recent_finality_proof, select_header_to_submit, FinalityProofs, - FinalitySyncParams, RestartableFinalityProofsStream, SourceClient, TargetClient, + prune_recent_finality_proofs, read_finality_proofs_from_stream, run, run_loop_iteration, + select_better_recent_finality_proof, select_header_to_submit, FinalityLoopState, + FinalityProofs, FinalitySyncParams, RestartableFinalityProofsStream, SourceClient, + TargetClient, }, + sync_loop_metrics::SyncLoopMetrics, FinalityProof, FinalitySyncPipeline, SourceHeader, }; @@ -31,12 +33,18 @@ use async_trait::async_trait; use futures::{FutureExt, Stream, StreamExt}; use parking_lot::Mutex; use relay_utils::{ - metrics::MetricsParams, relay_loop::Client as RelayClient, MaybeConnectionError, + metrics::MetricsParams, relay_loop::Client as RelayClient, HeaderId, MaybeConnectionError, +}; +use std::{ + collections::HashMap, + pin::Pin, + sync::Arc, + time::{Duration, Instant}, }; -use std::{collections::HashMap, pin::Pin, sync::Arc, time::Duration}; type IsMandatory = bool; type TestNumber = u64; +type TestHash = u64; #[derive(Debug, Clone)] enum TestError { @@ -56,16 +64,20 @@ impl FinalitySyncPipeline for TestFinalitySyncPipeline { const SOURCE_NAME: &'static str = "TestSource"; const TARGET_NAME: &'static str = "TestTarget"; - type Hash = u64; + type Hash = TestHash; type Number = TestNumber; type Header = TestSourceHeader; type FinalityProof = TestFinalityProof; } #[derive(Debug, Clone, PartialEq)] -struct TestSourceHeader(IsMandatory, TestNumber); +struct TestSourceHeader(IsMandatory, TestNumber, TestHash); + +impl SourceHeader for TestSourceHeader { + fn hash(&self) -> TestHash { + self.2 + } -impl SourceHeader for TestSourceHeader { fn number(&self) -> TestNumber { self.1 } @@ -90,7 +102,7 @@ struct ClientsData { source_headers: HashMap)>, source_proofs: Vec, - target_best_block_number: TestNumber, + target_best_block_id: HeaderId, target_headers: Vec<(TestSourceHeader, TestFinalityProof)>, } @@ -152,10 +164,12 @@ impl RelayClient for TestTargetClient { #[async_trait] impl TargetClient for TestTargetClient { - async fn best_finalized_source_block_number(&self) -> Result { + async fn best_finalized_source_block_id( + &self, + ) -> Result, TestError> { let mut data = self.data.lock(); (self.on_method_call)(&mut *data); - Ok(data.target_best_block_number) + Ok(data.target_best_block_id) } async fn submit_finality_proof( @@ -165,7 +179,7 @@ impl TargetClient for TestTargetClient { ) -> Result<(), TestError> { let mut data = self.data.lock(); (self.on_method_call)(&mut *data); - data.target_best_block_number = header.number(); + data.target_best_block_id = HeaderId(header.number(), header.hash()); data.target_headers.push((header, proof)); Ok(()) } @@ -187,7 +201,7 @@ fn prepare_test_clients( source_headers, source_proofs: vec![TestFinalityProof(12), TestFinalityProof(14)], - target_best_block_number: 5, + target_best_block_id: HeaderId(5, 5), target_headers: vec![], })); ( @@ -199,6 +213,15 @@ fn prepare_test_clients( ) } +fn test_sync_params() -> FinalitySyncParams { + FinalitySyncParams { + tick: Duration::from_secs(0), + recent_finality_proofs_limit: 1024, + stall_timeout: Duration::from_secs(1), + only_mandatory_headers: false, + } +} + fn run_sync_loop( state_function: impl Fn(&mut ClientsData) -> bool + Send + Sync + 'static, ) -> ClientsData { @@ -207,21 +230,17 @@ fn run_sync_loop( exit_sender, state_function, vec![ - (6, (TestSourceHeader(false, 6), None)), - (7, (TestSourceHeader(false, 7), Some(TestFinalityProof(7)))), - (8, (TestSourceHeader(true, 8), Some(TestFinalityProof(8)))), - (9, (TestSourceHeader(false, 9), Some(TestFinalityProof(9)))), - (10, (TestSourceHeader(false, 10), None)), + (5, (TestSourceHeader(false, 5, 5), None)), + (6, (TestSourceHeader(false, 6, 6), None)), + (7, (TestSourceHeader(false, 7, 7), Some(TestFinalityProof(7)))), + (8, (TestSourceHeader(true, 8, 8), Some(TestFinalityProof(8)))), + (9, (TestSourceHeader(false, 9, 9), Some(TestFinalityProof(9)))), + (10, (TestSourceHeader(false, 10, 10), None)), ] .into_iter() .collect(), ); - let sync_params = FinalitySyncParams { - tick: Duration::from_secs(0), - recent_finality_proofs_limit: 1024, - stall_timeout: Duration::from_secs(1), - only_mandatory_headers: false, - }; + let sync_params = test_sync_params(); let clients_data = source_client.data.clone(); let _ = async_std::task::block_on(run( @@ -246,38 +265,38 @@ fn finality_sync_loop_works() { // // once this ^^^ is done, we generate more blocks && read proof for blocks 12 and 14 from // the stream - if data.target_best_block_number == 9 { + if data.target_best_block_id.0 == 9 { data.source_best_block_number = 14; - data.source_headers.insert(11, (TestSourceHeader(false, 11), None)); + data.source_headers.insert(11, (TestSourceHeader(false, 11, 11), None)); data.source_headers - .insert(12, (TestSourceHeader(false, 12), Some(TestFinalityProof(12)))); - data.source_headers.insert(13, (TestSourceHeader(false, 13), None)); + .insert(12, (TestSourceHeader(false, 12, 12), Some(TestFinalityProof(12)))); + data.source_headers.insert(13, (TestSourceHeader(false, 13, 13), None)); data.source_headers - .insert(14, (TestSourceHeader(false, 14), Some(TestFinalityProof(14)))); + .insert(14, (TestSourceHeader(false, 14, 14), Some(TestFinalityProof(14)))); } // once this ^^^ is done, we generate more blocks && read persistent proof for block 16 - if data.target_best_block_number == 14 { + if data.target_best_block_id.0 == 14 { data.source_best_block_number = 17; - data.source_headers.insert(15, (TestSourceHeader(false, 15), None)); + data.source_headers.insert(15, (TestSourceHeader(false, 15, 15), None)); data.source_headers - .insert(16, (TestSourceHeader(false, 16), Some(TestFinalityProof(16)))); - data.source_headers.insert(17, (TestSourceHeader(false, 17), None)); + .insert(16, (TestSourceHeader(false, 16, 16), Some(TestFinalityProof(16)))); + data.source_headers.insert(17, (TestSourceHeader(false, 17, 17), None)); } - data.target_best_block_number == 16 + data.target_best_block_id.0 == 16 }); assert_eq!( client_data.target_headers, vec![ // before adding 11..14: finality proof for mandatory header#8 - (TestSourceHeader(true, 8), TestFinalityProof(8)), + (TestSourceHeader(true, 8, 8), TestFinalityProof(8)), // before adding 11..14: persistent finality proof for non-mandatory header#9 - (TestSourceHeader(false, 9), TestFinalityProof(9)), + (TestSourceHeader(false, 9, 9), TestFinalityProof(9)), // after adding 11..14: ephemeral finality proof for non-mandatory header#14 - (TestSourceHeader(false, 14), TestFinalityProof(14)), + (TestSourceHeader(false, 14, 14), TestFinalityProof(14)), // after adding 15..17: persistent finality proof for non-mandatory header#16 - (TestSourceHeader(false, 16), TestFinalityProof(16)), + (TestSourceHeader(false, 16, 16), TestFinalityProof(16)), ], ); } @@ -291,11 +310,11 @@ fn run_only_mandatory_headers_mode_test( exit_sender, |_| false, vec![ - (6, (TestSourceHeader(false, 6), Some(TestFinalityProof(6)))), - (7, (TestSourceHeader(false, 7), Some(TestFinalityProof(7)))), - (8, (TestSourceHeader(has_mandatory_headers, 8), Some(TestFinalityProof(8)))), - (9, (TestSourceHeader(false, 9), Some(TestFinalityProof(9)))), - (10, (TestSourceHeader(false, 10), Some(TestFinalityProof(10)))), + (6, (TestSourceHeader(false, 6, 6), Some(TestFinalityProof(6)))), + (7, (TestSourceHeader(false, 7, 7), Some(TestFinalityProof(7)))), + (8, (TestSourceHeader(has_mandatory_headers, 8, 8), Some(TestFinalityProof(8)))), + (9, (TestSourceHeader(false, 9, 9), Some(TestFinalityProof(9)))), + (10, (TestSourceHeader(false, 10, 10), Some(TestFinalityProof(10)))), ] .into_iter() .collect(), @@ -322,7 +341,7 @@ fn select_header_to_submit_skips_non_mandatory_headers_when_only_mandatory_heade assert_eq!(run_only_mandatory_headers_mode_test(true, false), None); assert_eq!( run_only_mandatory_headers_mode_test(false, false), - Some((TestSourceHeader(false, 10), TestFinalityProof(10))), + Some((TestSourceHeader(false, 10, 10), TestFinalityProof(10))), ); } @@ -330,11 +349,11 @@ fn select_header_to_submit_skips_non_mandatory_headers_when_only_mandatory_heade fn select_header_to_submit_selects_mandatory_headers_when_only_mandatory_headers_are_required() { assert_eq!( run_only_mandatory_headers_mode_test(true, true), - Some((TestSourceHeader(true, 8), TestFinalityProof(8))), + Some((TestSourceHeader(true, 8, 8), TestFinalityProof(8))), ); assert_eq!( run_only_mandatory_headers_mode_test(false, true), - Some((TestSourceHeader(true, 8), TestFinalityProof(8))), + Some((TestSourceHeader(true, 8, 8), TestFinalityProof(8))), ); } @@ -345,63 +364,74 @@ fn select_better_recent_finality_proof_works() { select_better_recent_finality_proof::( &[(5, TestFinalityProof(5))], &mut vec![], - Some((TestSourceHeader(false, 2), TestFinalityProof(2))), + Some((TestSourceHeader(false, 2, 2), TestFinalityProof(2))), ), - Some((TestSourceHeader(false, 2), TestFinalityProof(2))), + Some((TestSourceHeader(false, 2, 2), TestFinalityProof(2))), ); // if there are no recent finality proofs, nothing is changed assert_eq!( select_better_recent_finality_proof::( &[], - &mut vec![TestSourceHeader(false, 5)], - Some((TestSourceHeader(false, 2), TestFinalityProof(2))), + &mut vec![TestSourceHeader(false, 5, 5)], + Some((TestSourceHeader(false, 2, 2), TestFinalityProof(2))), ), - Some((TestSourceHeader(false, 2), TestFinalityProof(2))), + Some((TestSourceHeader(false, 2, 2), TestFinalityProof(2))), ); // if there's no intersection between recent finality proofs and unjustified headers, nothing is // changed - let mut unjustified_headers = vec![TestSourceHeader(false, 9), TestSourceHeader(false, 10)]; + let mut unjustified_headers = + vec![TestSourceHeader(false, 9, 9), TestSourceHeader(false, 10, 10)]; assert_eq!( select_better_recent_finality_proof::( &[(1, TestFinalityProof(1)), (4, TestFinalityProof(4))], &mut unjustified_headers, - Some((TestSourceHeader(false, 2), TestFinalityProof(2))), + Some((TestSourceHeader(false, 2, 2), TestFinalityProof(2))), ), - Some((TestSourceHeader(false, 2), TestFinalityProof(2))), + Some((TestSourceHeader(false, 2, 2), TestFinalityProof(2))), ); // if there's intersection between recent finality proofs and unjustified headers, but there are // no proofs in this intersection, nothing is changed - let mut unjustified_headers = - vec![TestSourceHeader(false, 8), TestSourceHeader(false, 9), TestSourceHeader(false, 10)]; + let mut unjustified_headers = vec![ + TestSourceHeader(false, 8, 8), + TestSourceHeader(false, 9, 9), + TestSourceHeader(false, 10, 10), + ]; assert_eq!( select_better_recent_finality_proof::( &[(7, TestFinalityProof(7)), (11, TestFinalityProof(11))], &mut unjustified_headers, - Some((TestSourceHeader(false, 2), TestFinalityProof(2))), + Some((TestSourceHeader(false, 2, 2), TestFinalityProof(2))), ), - Some((TestSourceHeader(false, 2), TestFinalityProof(2))), + Some((TestSourceHeader(false, 2, 2), TestFinalityProof(2))), ); assert_eq!( unjustified_headers, - vec![TestSourceHeader(false, 8), TestSourceHeader(false, 9), TestSourceHeader(false, 10)] + vec![ + TestSourceHeader(false, 8, 8), + TestSourceHeader(false, 9, 9), + TestSourceHeader(false, 10, 10) + ] ); // if there's intersection between recent finality proofs and unjustified headers and there's // a proof in this intersection: // - this better (last from intersection) proof is selected; // - 'obsolete' unjustified headers are pruned. - let mut unjustified_headers = - vec![TestSourceHeader(false, 8), TestSourceHeader(false, 9), TestSourceHeader(false, 10)]; + let mut unjustified_headers = vec![ + TestSourceHeader(false, 8, 8), + TestSourceHeader(false, 9, 9), + TestSourceHeader(false, 10, 10), + ]; assert_eq!( select_better_recent_finality_proof::( &[(7, TestFinalityProof(7)), (9, TestFinalityProof(9))], &mut unjustified_headers, - Some((TestSourceHeader(false, 2), TestFinalityProof(2))), + Some((TestSourceHeader(false, 2, 2), TestFinalityProof(2))), ), - Some((TestSourceHeader(false, 9), TestFinalityProof(9))), + Some((TestSourceHeader(false, 9, 9), TestFinalityProof(9))), ); } @@ -475,3 +505,45 @@ fn prune_recent_finality_proofs_works() { prune_recent_finality_proofs::(20, &mut recent_finality_proofs, 2); assert_eq!(&original_recent_finality_proofs[5..], recent_finality_proofs,); } + +#[test] +fn different_forks_at_source_and_at_target_are_detected() { + let (exit_sender, _exit_receiver) = futures::channel::mpsc::unbounded(); + let (source_client, target_client) = prepare_test_clients( + exit_sender, + |_| false, + vec![ + (5, (TestSourceHeader(false, 5, 42), None)), + (6, (TestSourceHeader(false, 6, 6), None)), + (7, (TestSourceHeader(false, 7, 7), None)), + (8, (TestSourceHeader(false, 8, 8), None)), + (9, (TestSourceHeader(false, 9, 9), None)), + (10, (TestSourceHeader(false, 10, 10), None)), + ] + .into_iter() + .collect(), + ); + + let mut progress = (Instant::now(), None); + let mut finality_proofs_stream = RestartableFinalityProofsStream { + needs_restart: false, + stream: Box::pin(futures::stream::iter(vec![]).boxed()), + }; + let mut recent_finality_proofs = Vec::new(); + let metrics_sync = SyncLoopMetrics::new(None, "source", "target").unwrap(); + async_std::task::block_on(run_loop_iteration::( + &source_client, + &target_client, + FinalityLoopState { + progress: &mut progress, + finality_proofs_stream: &mut finality_proofs_stream, + recent_finality_proofs: &mut recent_finality_proofs, + last_transaction: None, + }, + &test_sync_params(), + &Some(metrics_sync.clone()), + )) + .unwrap(); + + assert!(!metrics_sync.is_using_same_fork()); +} diff --git a/relays/finality/src/lib.rs b/relays/finality/src/lib.rs index 6421d13b787..49be64ff74d 100644 --- a/relays/finality/src/lib.rs +++ b/relays/finality/src/lib.rs @@ -19,8 +19,9 @@ //! are still submitted to the target node, but are treated as auxiliary data as we are not trying //! to submit all source headers to the target node. -pub use crate::finality_loop::{ - metrics_prefix, run, FinalitySyncParams, SourceClient, TargetClient, +pub use crate::{ + finality_loop::{metrics_prefix, run, FinalitySyncParams, SourceClient, TargetClient}, + sync_loop_metrics::SyncLoopMetrics, }; use bp_header_chain::FinalityProof; @@ -42,13 +43,15 @@ pub trait FinalitySyncPipeline: 'static + Clone + Debug + Send + Sync { /// Headers we're syncing are identified by this number. type Number: relay_utils::BlockNumberBase; /// Type of header that we're syncing. - type Header: SourceHeader; + type Header: SourceHeader; /// Finality proof type. type FinalityProof: FinalityProof; } /// Header that we're receiving from source node. -pub trait SourceHeader: Clone + Debug + PartialEq + Send + Sync { +pub trait SourceHeader: Clone + Debug + PartialEq + Send + Sync { + /// Returns hash of header. + fn hash(&self) -> Hash; /// Returns number of header. fn number(&self) -> Number; /// Returns true if this header needs to be submitted to target node. diff --git a/relays/finality/src/sync_loop_metrics.rs b/relays/finality/src/sync_loop_metrics.rs index 1f65dac17c0..a003a47d890 100644 --- a/relays/finality/src/sync_loop_metrics.rs +++ b/relays/finality/src/sync_loop_metrics.rs @@ -16,49 +16,71 @@ //! Metrics for headers synchronization relay loop. -use relay_utils::metrics::{ - metric_name, register, GaugeVec, Metric, Opts, PrometheusError, Registry, U64, -}; +use relay_utils::metrics::{metric_name, register, IntGauge, Metric, PrometheusError, Registry}; /// Headers sync metrics. #[derive(Clone)] pub struct SyncLoopMetrics { - /// Best syncing headers at "source" and "target" nodes. - best_block_numbers: GaugeVec, + /// Best syncing header at the source. + best_source_block_number: IntGauge, + /// Best syncing header at the target. + best_target_block_number: IntGauge, + /// Flag that has `0` value when best source headers at the source node and at-target-chain + /// are matching and `1` otherwise. + using_different_forks: IntGauge, } impl SyncLoopMetrics { /// Create and register headers loop metrics. - pub fn new(prefix: Option<&str>) -> Result { + pub fn new( + prefix: Option<&str>, + at_source_chain_label: &str, + at_target_chain_label: &str, + ) -> Result { Ok(SyncLoopMetrics { - best_block_numbers: GaugeVec::new( - Opts::new( - metric_name(prefix, "best_block_numbers"), - "Best block numbers on source and target nodes", - ), - &["node"], + best_source_block_number: IntGauge::new( + metric_name(prefix, &format!("best_{}_block_number", at_source_chain_label)), + format!("Best block number at the {}", at_source_chain_label), + )?, + best_target_block_number: IntGauge::new( + metric_name(prefix, &format!("best_{}_block_number", at_target_chain_label)), + format!("Best block number at the {}", at_target_chain_label), + )?, + using_different_forks: IntGauge::new( + metric_name(prefix, &format!("is_{}_and_{}_using_different_forks", at_source_chain_label, at_target_chain_label)), + "Whether the best finalized source block at target node is different (value 1) from the \ + corresponding block at the source node", )?, }) } + /// Returns current value of the using-same-fork flag. + #[cfg(test)] + pub(crate) fn is_using_same_fork(&self) -> bool { + self.using_different_forks.get() == 0 + } + /// Update best block number at source. pub fn update_best_block_at_source>(&self, source_best_number: Number) { - self.best_block_numbers - .with_label_values(&["source"]) - .set(source_best_number.into()); + self.best_source_block_number.set(source_best_number.into()); } /// Update best block number at target. pub fn update_best_block_at_target>(&self, target_best_number: Number) { - self.best_block_numbers - .with_label_values(&["target"]) - .set(target_best_number.into()); + self.best_target_block_number.set(target_best_number.into()); + } + + /// Update using-same-fork flag. + pub fn update_using_same_fork(&self, using_same_fork: bool) { + self.using_different_forks.set(if using_same_fork { 0 } else { 1 }) } } impl Metric for SyncLoopMetrics { fn register(&self, registry: &Registry) -> Result<(), PrometheusError> { - register(self.best_block_numbers.clone(), registry)?; + register(self.best_source_block_number.clone(), registry)?; + register(self.best_target_block_number.clone(), registry)?; + register(self.using_different_forks.clone(), registry)?; Ok(()) } } diff --git a/relays/lib-substrate-relay/Cargo.toml b/relays/lib-substrate-relay/Cargo.toml index 5733e398f37..e2cabf52f44 100644 --- a/relays/lib-substrate-relay/Cargo.toml +++ b/relays/lib-substrate-relay/Cargo.toml @@ -2,7 +2,7 @@ name = "substrate-relay-helper" version = "0.1.0" authors = ["Parity Technologies "] -edition = "2018" +edition = "2021" license = "GPL-3.0-or-later WITH Classpath-exception-2.0" [dependencies] @@ -10,18 +10,17 @@ anyhow = "1.0" thiserror = "1.0.26" async-std = "1.9.0" async-trait = "0.1.42" -codec = { package = "parity-scale-codec", version = "2.2.0" } +codec = { package = "parity-scale-codec", version = "3.0.0" } futures = "0.3.12" num-traits = "0.2" log = "0.4.14" - # Bridge dependencies bp-header-chain = { path = "../../primitives/header-chain" } bridge-runtime-common = { path = "../../bin/runtime-common" } -finality-grandpa = { version = "0.14.0" } +finality-grandpa = { version = "0.15.0" } finality-relay = { path = "../finality" } relay-utils = { path = "../utils" } messages-relay = { path = "../messages" } @@ -47,6 +46,7 @@ bp-millau = { path = "../../primitives/chain-millau" } bp-rialto = { path = "../../primitives/chain-rialto" } bp-rococo = { path = "../../primitives/chain-rococo" } bp-wococo = { path = "../../primitives/chain-wococo" } +pallet-transaction-payment = { git = "https://github.com/paritytech/substrate", branch = "master" } relay-rococo-client = { path = "../client-rococo" } relay-wococo-client = { path = "../client-wococo" } rialto-runtime = { path = "../../bin/rialto/runtime" } diff --git a/relays/lib-substrate-relay/src/conversion_rate_update.rs b/relays/lib-substrate-relay/src/conversion_rate_update.rs index 93458457d34..469bc558993 100644 --- a/relays/lib-substrate-relay/src/conversion_rate_update.rs +++ b/relays/lib-substrate-relay/src/conversion_rate_update.rs @@ -16,39 +16,143 @@ //! Tools for updating conversion rate that is stored in the runtime storage. +use crate::{messages_lane::SubstrateMessageLane, TransactionParams}; + +use codec::Encode; +use relay_substrate_client::{ + transaction_stall_timeout, AccountIdOf, AccountKeyPairOf, CallOf, Chain, Client, SignParam, + TransactionEra, TransactionSignScheme, UnsignedTransaction, +}; use relay_utils::metrics::F64SharedRef; -use std::{future::Future, time::Duration}; +use sp_core::{Bytes, Pair}; +use std::time::{Duration, Instant}; /// Duration between updater iterations. const SLEEP_DURATION: Duration = Duration::from_secs(60); +/// Duration which will almost never expire. Since changing conversion rate may require manual +/// intervention (e.g. if call is made through `multisig` pallet), we don't want relayer to +/// resubmit transaction often. +const ALMOST_NEVER_DURATION: Duration = Duration::from_secs(60 * 60 * 24 * 30); + /// Update-conversion-rate transaction status. #[derive(Debug, Clone, Copy, PartialEq)] enum TransactionStatus { /// We have not submitted any transaction recently. Idle, /// We have recently submitted transaction that should update conversion rate. - Submitted(f64), + Submitted(Instant, f64), +} + +/// Different ways of building 'update conversion rate' calls. +pub trait UpdateConversionRateCallBuilder { + /// Given conversion rate, build call that updates conversion rate in given chain runtime + /// storage. + fn build_update_conversion_rate_call(conversion_rate: f64) -> anyhow::Result>; +} + +impl UpdateConversionRateCallBuilder for () { + fn build_update_conversion_rate_call(_conversion_rate: f64) -> anyhow::Result> { + Err(anyhow::format_err!("Conversion rate update is not supported at {}", C::NAME)) + } +} + +/// Macro that generates `UpdateConversionRateCallBuilder` implementation for the case when +/// you have a direct access to the source chain runtime. +#[rustfmt::skip] +#[macro_export] +macro_rules! generate_direct_update_conversion_rate_call_builder { + ( + $source_chain:ident, + $mocked_builder:ident, + $runtime:ty, + $instance:ty, + $parameter:path + ) => { + pub struct $mocked_builder; + + impl $crate::conversion_rate_update::UpdateConversionRateCallBuilder<$source_chain> + for $mocked_builder + { + fn build_update_conversion_rate_call( + conversion_rate: f64, + ) -> anyhow::Result> { + Ok(pallet_bridge_messages::Call::update_pallet_parameter::<$runtime, $instance> { + parameter: $parameter(sp_runtime::FixedU128::from_float(conversion_rate)), + }.into()) + } + } + }; +} + +/// Macro that generates `UpdateConversionRateCallBuilder` implementation for the case when +/// you only have an access to the mocked version of source chain runtime. In this case you +/// should provide "name" of the call variant for the bridge messages calls, the "name" of +/// the variant for the `update_pallet_parameter` call within that first option and the name +/// of the conversion rate parameter itself. +#[rustfmt::skip] +#[macro_export] +macro_rules! generate_mocked_update_conversion_rate_call_builder { + ( + $source_chain:ident, + $mocked_builder:ident, + $bridge_messages:path, + $update_pallet_parameter:path, + $parameter:path + ) => { + pub struct $mocked_builder; + + impl $crate::conversion_rate_update::UpdateConversionRateCallBuilder<$source_chain> + for $mocked_builder + { + fn build_update_conversion_rate_call( + conversion_rate: f64, + ) -> anyhow::Result> { + Ok($bridge_messages($update_pallet_parameter($parameter( + sp_runtime::FixedU128::from_float(conversion_rate), + )))) + } + } + }; } /// Run infinite conversion rate updater loop. /// /// The loop is maintaining the Left -> Right conversion rate, used as `RightTokens = LeftTokens * /// Rate`. -pub fn run_conversion_rate_update_loop< - SubmitConversionRateFuture: Future> + Send + 'static, ->( +pub fn run_conversion_rate_update_loop( + client: Client, + transaction_params: TransactionParams>, left_to_right_stored_conversion_rate: F64SharedRef, left_to_base_conversion_rate: F64SharedRef, right_to_base_conversion_rate: F64SharedRef, max_difference_ratio: f64, - submit_conversion_rate: impl Fn(f64) -> SubmitConversionRateFuture + Send + 'static, -) { +) where + Lane: SubstrateMessageLane, + Sign: TransactionSignScheme, + AccountIdOf: From< as Pair>::Public>, +{ + let stall_timeout = transaction_stall_timeout( + transaction_params.mortality, + Lane::SourceChain::AVERAGE_BLOCK_INTERVAL, + ALMOST_NEVER_DURATION, + ); + + log::info!( + target: "bridge", + "Starting {} -> {} conversion rate (on {}) update loop. Stall timeout: {}s", + Lane::TargetChain::NAME, + Lane::SourceChain::NAME, + Lane::SourceChain::NAME, + stall_timeout.as_secs(), + ); + async_std::task::spawn(async move { let mut transaction_status = TransactionStatus::Idle; loop { async_std::task::sleep(SLEEP_DURATION).await; let maybe_new_conversion_rate = maybe_select_new_conversion_rate( + stall_timeout, &mut transaction_status, &left_to_right_stored_conversion_rate, &left_to_base_conversion_rate, @@ -57,13 +161,32 @@ pub fn run_conversion_rate_update_loop< ) .await; if let Some((prev_conversion_rate, new_conversion_rate)) = maybe_new_conversion_rate { - let submit_conversion_rate_future = submit_conversion_rate(new_conversion_rate); - match submit_conversion_rate_future.await { + log::info!( + target: "bridge", + "Going to update {} -> {} (on {}) conversion rate to {}.", + Lane::TargetChain::NAME, + Lane::SourceChain::NAME, + Lane::SourceChain::NAME, + new_conversion_rate, + ); + + let result = update_target_to_source_conversion_rate::( + client.clone(), + transaction_params.clone(), + new_conversion_rate, + ) + .await; + match result { Ok(()) => { - transaction_status = TransactionStatus::Submitted(prev_conversion_rate); + transaction_status = + TransactionStatus::Submitted(Instant::now(), prev_conversion_rate); }, Err(error) => { - log::trace!(target: "bridge", "Failed to submit conversion rate update transaction: {:?}", error); + log::error!( + target: "bridge", + "Failed to submit conversion rate update transaction: {:?}", + error, + ); }, } } @@ -73,6 +196,7 @@ pub fn run_conversion_rate_update_loop< /// Select new conversion rate to submit to the node. async fn maybe_select_new_conversion_rate( + stall_timeout: Duration, transaction_status: &mut TransactionStatus, left_to_right_stored_conversion_rate: &F64SharedRef, left_to_base_conversion_rate: &F64SharedRef, @@ -83,7 +207,18 @@ async fn maybe_select_new_conversion_rate( (*left_to_right_stored_conversion_rate.read().await)?; match *transaction_status { TransactionStatus::Idle => (), - TransactionStatus::Submitted(previous_left_to_right_stored_conversion_rate) => { + TransactionStatus::Submitted(submitted_at, _) + if Instant::now() - submitted_at > stall_timeout => + { + log::error!( + target: "bridge", + "Conversion rate update transaction has been lost and loop stalled. Restarting", + ); + + // we assume that our transaction has been lost + *transaction_status = TransactionStatus::Idle; + }, + TransactionStatus::Submitted(_, previous_left_to_right_stored_conversion_rate) => { // we can't compare float values from different sources directly, so we only care // whether the stored rate has been changed or not. If it has been changed, then we // assume that our proposal has been accepted. @@ -106,7 +241,7 @@ async fn maybe_select_new_conversion_rate( let left_to_base_conversion_rate = (*left_to_base_conversion_rate.read().await)?; let right_to_base_conversion_rate = (*right_to_base_conversion_rate.read().await)?; let actual_left_to_right_conversion_rate = - right_to_base_conversion_rate / left_to_base_conversion_rate; + left_to_base_conversion_rate / right_to_base_conversion_rate; let rate_difference = (actual_left_to_right_conversion_rate - left_to_right_stored_conversion_rate).abs(); @@ -118,11 +253,50 @@ async fn maybe_select_new_conversion_rate( Some((left_to_right_stored_conversion_rate, actual_left_to_right_conversion_rate)) } +/// Update Target -> Source tokens conversion rate, stored in the Source runtime storage. +pub async fn update_target_to_source_conversion_rate( + client: Client, + transaction_params: TransactionParams>, + updated_rate: f64, +) -> anyhow::Result<()> +where + Lane: SubstrateMessageLane, + Sign: TransactionSignScheme, + AccountIdOf: From< as Pair>::Public>, +{ + let genesis_hash = *client.genesis_hash(); + let signer_id = transaction_params.signer.public().into(); + let (spec_version, transaction_version) = client.simple_runtime_version().await?; + let call = + Lane::TargetToSourceChainConversionRateUpdateBuilder::build_update_conversion_rate_call( + updated_rate, + )?; + client + .submit_signed_extrinsic(signer_id, move |best_block_id, transaction_nonce| { + Ok(Bytes( + Sign::sign_transaction(SignParam { + spec_version, + transaction_version, + genesis_hash, + signer: transaction_params.signer, + era: TransactionEra::new(best_block_id, transaction_params.mortality), + unsigned: UnsignedTransaction::new(call.into(), transaction_nonce).into(), + })? + .encode(), + )) + }) + .await + .map(drop) + .map_err(|err| anyhow::format_err!("{:?}", err)) +} + #[cfg(test)] mod tests { use super::*; use async_std::sync::{Arc, RwLock}; + const TEST_STALL_TIMEOUT: Duration = Duration::from_secs(60); + fn test_maybe_select_new_conversion_rate( mut transaction_status: TransactionStatus, stored_conversion_rate: Option, @@ -134,6 +308,7 @@ mod tests { let left_to_base_conversion_rate = Arc::new(RwLock::new(left_to_base_conversion_rate)); let right_to_base_conversion_rate = Arc::new(RwLock::new(right_to_base_conversion_rate)); let result = async_std::task::block_on(maybe_select_new_conversion_rate( + TEST_STALL_TIMEOUT, &mut transaction_status, &stored_conversion_rate, &left_to_base_conversion_rate, @@ -145,15 +320,10 @@ mod tests { #[test] fn rate_is_not_updated_when_transaction_is_submitted() { + let status = TransactionStatus::Submitted(Instant::now(), 10.0); assert_eq!( - test_maybe_select_new_conversion_rate( - TransactionStatus::Submitted(10.0), - Some(10.0), - Some(1.0), - Some(1.0), - 0.0 - ), - (None, TransactionStatus::Submitted(10.0)), + test_maybe_select_new_conversion_rate(status, Some(10.0), Some(1.0), Some(1.0), 0.0), + (None, status), ); } @@ -161,7 +331,7 @@ mod tests { fn transaction_state_is_changed_to_idle_when_stored_rate_shanges() { assert_eq!( test_maybe_select_new_conversion_rate( - TransactionStatus::Submitted(1.0), + TransactionStatus::Submitted(Instant::now(), 1.0), Some(10.0), Some(1.0), Some(1.0), @@ -229,15 +399,42 @@ mod tests { #[test] fn transaction_is_submitted_when_difference_is_above_threshold() { + let left_to_right_stored_conversion_rate = 1.0; + let left_to_base_conversion_rate = 18f64; + let right_to_base_conversion_rate = 180f64; + + assert!(left_to_base_conversion_rate < right_to_base_conversion_rate); + assert_eq!( test_maybe_select_new_conversion_rate( TransactionStatus::Idle, - Some(1.0), - Some(1.0), - Some(1.03), + Some(left_to_right_stored_conversion_rate), + Some(left_to_base_conversion_rate), + Some(right_to_base_conversion_rate), 0.02 ), - (Some((1.0, 1.03)), TransactionStatus::Idle), + ( + Some(( + left_to_right_stored_conversion_rate, + left_to_base_conversion_rate / right_to_base_conversion_rate, + )), + TransactionStatus::Idle + ), + ); + } + + #[test] + fn transaction_expires() { + let status = TransactionStatus::Submitted(Instant::now() - TEST_STALL_TIMEOUT / 2, 10.0); + assert_eq!( + test_maybe_select_new_conversion_rate(status, Some(10.0), Some(1.0), Some(1.0), 0.0), + (None, status), + ); + + let status = TransactionStatus::Submitted(Instant::now() - TEST_STALL_TIMEOUT * 2, 10.0); + assert_eq!( + test_maybe_select_new_conversion_rate(status, Some(10.0), Some(1.0), Some(1.0), 0.0), + (Some((10.0, 1.0)), TransactionStatus::Idle), ); } } diff --git a/relays/lib-substrate-relay/src/finality_pipeline.rs b/relays/lib-substrate-relay/src/finality_pipeline.rs index 84fb8661016..3daf8d11440 100644 --- a/relays/lib-substrate-relay/src/finality_pipeline.rs +++ b/relays/lib-substrate-relay/src/finality_pipeline.rs @@ -65,7 +65,7 @@ pub trait SubstrateFinalitySyncPipeline: 'static + Clone + Debug + Send + Sync { /// Adapter that allows all `SubstrateFinalitySyncPipeline` to act as `FinalitySyncPipeline`. #[derive(Clone, Debug)] -pub(crate) struct FinalitySyncPipelineAdapter { +pub struct FinalitySyncPipelineAdapter { _phantom: PhantomData

, } diff --git a/relays/lib-substrate-relay/src/finality_target.rs b/relays/lib-substrate-relay/src/finality_target.rs index 9a92c88a234..4c581417104 100644 --- a/relays/lib-substrate-relay/src/finality_target.rs +++ b/relays/lib-substrate-relay/src/finality_target.rs @@ -30,8 +30,8 @@ use bp_header_chain::{justification::GrandpaJustification, storage_keys::is_halt use codec::Encode; use finality_relay::TargetClient; use relay_substrate_client::{ - AccountIdOf, AccountKeyPairOf, BlockNumberOf, Chain, ChainWithGrandpa, Client, Error, HashOf, - HeaderOf, SignParam, SyncHeader, TransactionEra, TransactionSignScheme, UnsignedTransaction, + AccountIdOf, AccountKeyPairOf, Chain, ChainWithGrandpa, Client, Error, HeaderIdOf, HeaderOf, + SignParam, SyncHeader, TransactionEra, TransactionSignScheme, UnsignedTransaction, }; use relay_utils::relay_loop::Client as RelayClient; use sp_core::{Bytes, Pair}; @@ -52,7 +52,7 @@ impl SubstrateFinalityTarget

{ } /// Ensure that the GRANDPA pallet at target chain is active. - async fn ensure_pallet_active(&self) -> Result<(), Error> { + pub async fn ensure_pallet_active(&self) -> Result<(), Error> { let is_halted = self .client .storage_value(is_halted_key(P::SourceChain::WITH_CHAIN_GRANDPA_PALLET_NAME), None) @@ -90,23 +90,20 @@ where AccountIdOf: From< as Pair>::Public>, P::TransactionSignScheme: TransactionSignScheme, { - async fn best_finalized_source_block_number( - &self, - ) -> Result, Error> { + async fn best_finalized_source_block_id(&self) -> Result, Error> { // we can't continue to relay finality if target node is out of sync, because // it may have already received (some of) headers that we're going to relay self.client.ensure_synced().await?; // we can't relay finality if GRANDPA pallet at target chain is halted self.ensure_pallet_active().await?; - Ok(crate::messages_source::read_client_state::< - P::TargetChain, - HashOf, - BlockNumberOf, - >(&self.client, P::SourceChain::BEST_FINALIZED_HEADER_ID_METHOD) + Ok(crate::messages_source::read_client_state::( + &self.client, + None, + P::SourceChain::BEST_FINALIZED_HEADER_ID_METHOD, + ) .await? - .best_finalized_peer_at_best_self - .0) + .best_finalized_peer_at_best_self) } async fn submit_finality_proof( @@ -123,17 +120,17 @@ where .submit_signed_extrinsic( self.transaction_params.signer.public().into(), move |best_block_id, transaction_nonce| { - Bytes( + Ok(Bytes( P::TransactionSignScheme::sign_transaction(SignParam { spec_version, transaction_version, genesis_hash, signer: transaction_params.signer.clone(), era: TransactionEra::new(best_block_id, transaction_params.mortality), - unsigned: UnsignedTransaction::new(call, transaction_nonce), - }) + unsigned: UnsignedTransaction::new(call.into(), transaction_nonce), + })? .encode(), - ) + )) }, ) .await diff --git a/relays/lib-substrate-relay/src/headers_initialize.rs b/relays/lib-substrate-relay/src/headers_initialize.rs index 8713663dd82..0e1371c53c8 100644 --- a/relays/lib-substrate-relay/src/headers_initialize.rs +++ b/relays/lib-substrate-relay/src/headers_initialize.rs @@ -31,7 +31,9 @@ use bp_header_chain::{ use codec::Decode; use finality_grandpa::voter_set::VoterSet; use num_traits::{One, Zero}; -use relay_substrate_client::{BlockNumberOf, Chain, ChainWithGrandpa, Client, HashOf}; +use relay_substrate_client::{ + BlockNumberOf, Chain, ChainWithGrandpa, Client, Error as SubstrateError, HashOf, +}; use sp_core::Bytes; use sp_finality_grandpa::AuthorityList as GrandpaAuthoritiesSet; use sp_runtime::traits::Header as HeaderT; @@ -41,7 +43,10 @@ pub async fn initialize( source_client: Client, target_client: Client, target_transactions_signer: TargetChain::AccountId, - prepare_initialize_transaction: impl FnOnce(TargetChain::Index, InitializationData) -> Bytes + prepare_initialize_transaction: impl FnOnce( + TargetChain::Index, + InitializationData, + ) -> Result + Send + 'static, ) { @@ -77,7 +82,10 @@ async fn do_initialize( source_client: Client, target_client: Client, target_transactions_signer: TargetChain::AccountId, - prepare_initialize_transaction: impl FnOnce(TargetChain::Index, InitializationData) -> Bytes + prepare_initialize_transaction: impl FnOnce( + TargetChain::Index, + InitializationData, + ) -> Result + Send + 'static, ) -> Result< diff --git a/relays/lib-substrate-relay/src/helpers.rs b/relays/lib-substrate-relay/src/helpers.rs index f95a8e0aba3..80359b1c2a9 100644 --- a/relays/lib-substrate-relay/src/helpers.rs +++ b/relays/lib-substrate-relay/src/helpers.rs @@ -16,14 +16,91 @@ //! Substrate relay helpers -use relay_utils::metrics::{FloatJsonValueMetric, PrometheusError}; +use relay_utils::metrics::{FloatJsonValueMetric, PrometheusError, StandaloneMetric}; /// Creates standalone token price metric. pub fn token_price_metric(token_id: &str) -> Result { FloatJsonValueMetric::new( format!("https://api.coingecko.com/api/v3/simple/price?ids={}&vs_currencies=btc", token_id), format!("$.{}.btc", token_id), - format!("{}_to_base_conversion_rate", token_id.replace("-", "_")), + format!("{}_to_base_conversion_rate", token_id.replace('-', "_")), format!("Rate used to convert from {} to some BASE tokens", token_id.to_uppercase()), ) } + +/// Compute conversion rate between two tokens immediately, without spawning any metrics. +/// +/// Returned rate may be used in expression: `from_tokens * rate -> to_tokens`. +pub async fn tokens_conversion_rate_from_metrics( + from_token_id: &str, + to_token_id: &str, +) -> anyhow::Result { + let from_token_metric = token_price_metric(from_token_id)?; + from_token_metric.update().await; + let to_token_metric = token_price_metric(to_token_id)?; + to_token_metric.update().await; + + let from_token_value = *from_token_metric.shared_value_ref().read().await; + let to_token_value = *to_token_metric.shared_value_ref().read().await; + // `FloatJsonValueMetric` guarantees that the value is positive && normal, so no additional + // checks required here + match (from_token_value, to_token_value) { + (Some(from_token_value), Some(to_token_value)) => + Ok(tokens_conversion_rate(from_token_value, to_token_value)), + _ => Err(anyhow::format_err!( + "Failed to compute conversion rate from {} to {}", + from_token_id, + to_token_id, + )), + } +} + +/// Compute conversion rate between two tokens, given token prices. +/// +/// Returned rate may be used in expression: `from_tokens * rate -> to_tokens`. +/// +/// Both prices are assumed to be normal and non-negative. +pub fn tokens_conversion_rate(from_token_value: f64, to_token_value: f64) -> f64 { + from_token_value / to_token_value +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn rialto_to_millau_conversion_rate_is_correct() { + let rialto_price = 18.18; + let millau_price = 136.35; + assert!(rialto_price < millau_price); + + let conversion_rate = tokens_conversion_rate(rialto_price, millau_price); + let rialto_amount = 100.0; + let millau_amount = rialto_amount * conversion_rate; + assert!( + rialto_amount > millau_amount, + "{} RLT * {} = {} MLU", + rialto_amount, + conversion_rate, + millau_amount, + ); + } + + #[test] + fn millau_to_rialto_conversion_rate_is_correct() { + let rialto_price = 18.18; + let millau_price = 136.35; + assert!(rialto_price < millau_price); + + let conversion_rate = tokens_conversion_rate(millau_price, rialto_price); + let millau_amount = 100.0; + let rialto_amount = millau_amount * conversion_rate; + assert!( + rialto_amount > millau_amount, + "{} MLU * {} = {} RLT", + millau_amount, + conversion_rate, + rialto_amount, + ); + } +} diff --git a/relays/lib-substrate-relay/src/messages_lane.rs b/relays/lib-substrate-relay/src/messages_lane.rs index 380d1c9624f..fadf5e62245 100644 --- a/relays/lib-substrate-relay/src/messages_lane.rs +++ b/relays/lib-substrate-relay/src/messages_lane.rs @@ -17,6 +17,7 @@ //! Tools for supporting message lanes between two Substrate-based chains. use crate::{ + conversion_rate_update::UpdateConversionRateCallBuilder, messages_metrics::StandaloneMessagesMetrics, messages_source::{SubstrateMessagesProof, SubstrateMessagesSource}, messages_target::{SubstrateMessagesDeliveryProof, SubstrateMessagesTarget}, @@ -43,19 +44,37 @@ use std::{convert::TryFrom, fmt::Debug, marker::PhantomData}; /// Substrate -> Substrate messages synchronization pipeline. pub trait SubstrateMessageLane: 'static + Clone + Debug + Send + Sync { - /// Name of the source -> target tokens conversion rate parameter name. + /// Name of the source -> target tokens conversion rate parameter. /// /// The parameter is stored at the target chain and the storage key is computed using /// `bp_runtime::storage_parameter_key` function. If value is unknown, it is assumed /// to be 1. const SOURCE_TO_TARGET_CONVERSION_RATE_PARAMETER_NAME: Option<&'static str>; - /// Name of the target -> source tokens conversion rate parameter name. + /// Name of the target -> source tokens conversion rate parameter. /// /// The parameter is stored at the source chain and the storage key is computed using /// `bp_runtime::storage_parameter_key` function. If value is unknown, it is assumed /// to be 1. const TARGET_TO_SOURCE_CONVERSION_RATE_PARAMETER_NAME: Option<&'static str>; + /// Name of the source chain fee multiplier parameter. + /// + /// The parameter is stored at the target chain and the storage key is computed using + /// `bp_runtime::storage_parameter_key` function. If value is unknown, it is assumed + /// to be 1. + const SOURCE_FEE_MULTIPLIER_PARAMETER_NAME: Option<&'static str>; + /// Name of the target chain fee multiplier parameter. + /// + /// The parameter is stored at the source chain and the storage key is computed using + /// `bp_runtime::storage_parameter_key` function. If value is unknown, it is assumed + /// to be 1. + const TARGET_FEE_MULTIPLIER_PARAMETER_NAME: Option<&'static str>; + + /// Name of the transaction payment pallet, deployed at the source chain. + const AT_SOURCE_TRANSACTION_PAYMENT_PALLET_NAME: Option<&'static str>; + /// Name of the transaction payment pallet, deployed at the target chain. + const AT_TARGET_TRANSACTION_PAYMENT_PALLET_NAME: Option<&'static str>; + /// Messages of this chain are relayed to the `TargetChain`. type SourceChain: ChainWithMessages; /// Messages from the `SourceChain` are dispatched on this chain. @@ -71,6 +90,13 @@ pub trait SubstrateMessageLane: 'static + Clone + Debug + Send + Sync { /// How receive messages delivery proof call is built? type ReceiveMessagesDeliveryProofCallBuilder: ReceiveMessagesDeliveryProofCallBuilder; + /// `TargetChain` tokens to `SourceChain` tokens conversion rate update builder. + /// + /// If not applicable to this bridge, you may use `()` here. + type TargetToSourceChainConversionRateUpdateBuilder: UpdateConversionRateCallBuilder< + Self::SourceChain, + >; + /// Message relay strategy. type RelayStrategy: RelayStrategy; } @@ -216,13 +242,15 @@ where }, }, SubstrateMessagesSource::

::new( - source_client, + source_client.clone(), + target_client.clone(), params.lane_id, params.source_transaction_params, params.target_to_source_headers_relay, ), SubstrateMessagesTarget::

::new( target_client, + source_client, params.lane_id, relayer_id_at_source, params.target_transaction_params, diff --git a/relays/lib-substrate-relay/src/messages_metrics.rs b/relays/lib-substrate-relay/src/messages_metrics.rs index 00686ac4fd5..b165892fda1 100644 --- a/relays/lib-substrate-relay/src/messages_metrics.rs +++ b/relays/lib-substrate-relay/src/messages_metrics.rs @@ -16,7 +16,7 @@ //! Tools for supporting message lanes between two Substrate-based chains. -use crate::messages_lane::SubstrateMessageLane; +use crate::{helpers::tokens_conversion_rate, messages_lane::SubstrateMessageLane}; use codec::Decode; use frame_system::AccountInfo; @@ -34,6 +34,9 @@ use sp_core::storage::StorageData; use sp_runtime::{FixedPointNumber, FixedU128}; use std::{convert::TryFrom, fmt::Debug, marker::PhantomData}; +/// Name of the `NextFeeMultiplier` storage value within the transaction payment pallet. +const NEXT_FEE_MULTIPLIER_VALUE_NAME: &str = "NextFeeMultiplier"; + /// Shared references to the standalone metrics of the message lane relay loop. #[derive(Debug, Clone)] pub struct StandaloneMessagesMetrics { @@ -53,6 +56,15 @@ pub struct StandaloneMessagesMetrics { /// Target tokens to source tokens conversion rate metric. This rate is stored by the source /// chain. pub target_to_source_conversion_rate: Option>, + + /// Actual source chain fee multiplier. + pub source_fee_multiplier: Option>, + /// Source chain fee multiplier, stored at the target chain. + pub source_fee_multiplier_at_target: Option>, + /// Actual target chain fee multiplier. + pub target_fee_multiplier: Option>, + /// Target chain fee multiplier, stored at the target chain. + pub target_fee_multiplier_at_source: Option>, } impl StandaloneMessagesMetrics { @@ -66,6 +78,10 @@ impl StandaloneMessagesMetrics { target_to_base_conversion_rate: self.source_to_base_conversion_rate, source_to_target_conversion_rate: self.target_to_source_conversion_rate, target_to_source_conversion_rate: self.source_to_target_conversion_rate, + source_fee_multiplier: self.target_fee_multiplier, + source_fee_multiplier_at_target: self.target_fee_multiplier_at_source, + target_fee_multiplier: self.source_fee_multiplier, + target_fee_multiplier_at_source: self.source_fee_multiplier_at_target, } } @@ -86,24 +102,28 @@ impl StandaloneMessagesMetrics { if let Some(m) = self.target_to_source_conversion_rate { m.register_and_spawn(&metrics.registry)?; } + if let Some(m) = self.source_fee_multiplier { + m.register_and_spawn(&metrics.registry)?; + } + if let Some(m) = self.source_fee_multiplier_at_target { + m.register_and_spawn(&metrics.registry)?; + } + if let Some(m) = self.target_fee_multiplier { + m.register_and_spawn(&metrics.registry)?; + } + if let Some(m) = self.target_fee_multiplier_at_source { + m.register_and_spawn(&metrics.registry)?; + } Ok(metrics) } /// Return conversion rate from target to source tokens. pub async fn target_to_source_conversion_rate(&self) -> Option { - Self::compute_target_to_source_conversion_rate( - *self.target_to_base_conversion_rate.as_ref()?.shared_value_ref().read().await, - *self.source_to_base_conversion_rate.as_ref()?.shared_value_ref().read().await, - ) - } - - /// Return conversion rate from target to source tokens, given conversion rates from - /// target/source tokens to some base token. - fn compute_target_to_source_conversion_rate( - target_to_base_conversion_rate: Option, - source_to_base_conversion_rate: Option, - ) -> Option { - Some(source_to_base_conversion_rate? / target_to_base_conversion_rate?) + let from_token_value = + (*self.target_to_base_conversion_rate.as_ref()?.shared_value_ref().read().await)?; + let to_token_value = + (*self.source_to_base_conversion_rate.as_ref()?.shared_value_ref().read().await)?; + Some(tokens_conversion_rate(from_token_value, to_token_value)) } } @@ -144,7 +164,7 @@ pub fn standalone_metrics( .map(|key| { FloatStorageValueMetric::new( FixedU128OrOne::default(), - target_client, + target_client.clone(), key, format!( "{}_{}_to_{}_conversion_rate", @@ -167,7 +187,7 @@ pub fn standalone_metrics( .map(|key| { FloatStorageValueMetric::new( FixedU128OrOne::default(), - source_client, + source_client.clone(), key, format!( "{}_{}_to_{}_conversion_rate", @@ -185,6 +205,68 @@ pub fn standalone_metrics( .map(Some) }) .unwrap_or(Ok(None))?, + source_fee_multiplier: P::AT_SOURCE_TRANSACTION_PAYMENT_PALLET_NAME + .map(|pallet| bp_runtime::storage_value_key(pallet, NEXT_FEE_MULTIPLIER_VALUE_NAME)) + .map(|key| { + log::trace!(target: "bridge", "{}_fee_multiplier", P::SourceChain::NAME); + FloatStorageValueMetric::new( + FixedU128OrOne::default(), + source_client.clone(), + key, + format!("{}_fee_multiplier", P::SourceChain::NAME,), + format!("{} fee multiplier", P::SourceChain::NAME,), + ) + .map(Some) + }) + .unwrap_or(Ok(None))?, + source_fee_multiplier_at_target: P::SOURCE_FEE_MULTIPLIER_PARAMETER_NAME + .map(bp_runtime::storage_parameter_key) + .map(|key| { + FloatStorageValueMetric::new( + FixedU128OrOne::default(), + target_client.clone(), + key, + format!("{}_{}_fee_multiplier", P::TargetChain::NAME, P::SourceChain::NAME,), + format!( + "{} fee multiplier stored at {}", + P::SourceChain::NAME, + P::TargetChain::NAME, + ), + ) + .map(Some) + }) + .unwrap_or(Ok(None))?, + target_fee_multiplier: P::AT_TARGET_TRANSACTION_PAYMENT_PALLET_NAME + .map(|pallet| bp_runtime::storage_value_key(pallet, NEXT_FEE_MULTIPLIER_VALUE_NAME)) + .map(|key| { + log::trace!(target: "bridge", "{}_fee_multiplier", P::TargetChain::NAME); + FloatStorageValueMetric::new( + FixedU128OrOne::default(), + target_client, + key, + format!("{}_fee_multiplier", P::TargetChain::NAME,), + format!("{} fee multiplier", P::TargetChain::NAME,), + ) + .map(Some) + }) + .unwrap_or(Ok(None))?, + target_fee_multiplier_at_source: P::TARGET_FEE_MULTIPLIER_PARAMETER_NAME + .map(bp_runtime::storage_parameter_key) + .map(|key| { + FloatStorageValueMetric::new( + FixedU128OrOne::default(), + source_client, + key, + format!("{}_{}_fee_multiplier", P::SourceChain::NAME, P::TargetChain::NAME,), + format!( + "{} fee multiplier stored at {}", + P::TargetChain::NAME, + P::SourceChain::NAME, + ), + ) + .map(Some) + }) + .unwrap_or(Ok(None))?, }) } @@ -286,14 +368,8 @@ fn convert_to_token_balance(balance: u128, token_decimals: u32) -> FixedU128 { #[cfg(test)] mod tests { use super::*; - - #[async_std::test] - async fn target_to_source_conversion_rate_works() { - assert_eq!( - StandaloneMessagesMetrics::::compute_target_to_source_conversion_rate(Some(183.15), Some(12.32)), - Some(12.32 / 183.15), - ); - } + use frame_support::storage::generator::StorageValue; + use sp_core::storage::StorageKey; #[test] fn token_decimals_used_properly() { @@ -302,4 +378,12 @@ mod tests { let dots = convert_to_token_balance(plancks, token_decimals); assert_eq!(dots, FixedU128::saturating_from_rational(425, 10)); } + + #[test] + fn next_fee_multiplier_storage_key_is_correct() { + assert_eq!( + bp_runtime::storage_value_key("TransactionPayment", NEXT_FEE_MULTIPLIER_VALUE_NAME), + StorageKey(pallet_transaction_payment::NextFeeMultiplier::::storage_value_final_key().to_vec()), + ); + } } diff --git a/relays/lib-substrate-relay/src/messages_source.rs b/relays/lib-substrate-relay/src/messages_source.rs index de2306be3fe..77dd2aed05b 100644 --- a/relays/lib-substrate-relay/src/messages_source.rs +++ b/relays/lib-substrate-relay/src/messages_source.rs @@ -46,7 +46,7 @@ use messages_relay::{ }; use num_traits::{Bounded, Zero}; use relay_substrate_client::{ - AccountIdOf, AccountKeyPairOf, BalanceOf, Chain, ChainWithMessages, Client, + AccountIdOf, AccountKeyPairOf, BalanceOf, BlockNumberOf, Chain, ChainWithMessages, Client, Error as SubstrateError, HashOf, HeaderIdOf, IndexOf, SignParam, TransactionEra, TransactionSignScheme, UnsignedTransaction, }; @@ -62,7 +62,8 @@ pub type SubstrateMessagesProof = (Weight, FromBridgedChainMessagesProof { - client: Client, + source_client: Client, + target_client: Client, lane_id: LaneId, transaction_params: TransactionParams>, target_to_source_headers_relay: Option>, @@ -71,13 +72,15 @@ pub struct SubstrateMessagesSource { impl SubstrateMessagesSource

{ /// Create new Substrate headers source. pub fn new( - client: Client, + source_client: Client, + target_client: Client, lane_id: LaneId, transaction_params: TransactionParams>, target_to_source_headers_relay: Option>, ) -> Self { SubstrateMessagesSource { - client, + source_client, + target_client, lane_id, transaction_params, target_to_source_headers_relay, @@ -89,7 +92,7 @@ impl SubstrateMessagesSource

{ &self, id: SourceHeaderIdOf>, ) -> Result, SubstrateError> { - self.client + self.source_client .storage_value( outbound_lane_data_key( P::TargetChain::WITH_CHAIN_MESSAGES_PALLET_NAME, @@ -102,14 +105,15 @@ impl SubstrateMessagesSource

{ /// Ensure that the messages pallet at source chain is active. async fn ensure_pallet_active(&self) -> Result<(), SubstrateError> { - ensure_messages_pallet_active::(&self.client).await + ensure_messages_pallet_active::(&self.source_client).await } } impl Clone for SubstrateMessagesSource

{ fn clone(&self) -> Self { Self { - client: self.client.clone(), + source_client: self.source_client.clone(), + target_client: self.target_client.clone(), lane_id: self.lane_id, transaction_params: self.transaction_params.clone(), target_to_source_headers_relay: self.target_to_source_headers_relay.clone(), @@ -122,7 +126,8 @@ impl RelayClient for SubstrateMessagesSource

{ type Error = SubstrateError; async fn reconnect(&mut self) -> Result<(), SubstrateError> { - self.client.reconnect().await + self.source_client.reconnect().await?; + self.target_client.reconnect().await } } @@ -136,15 +141,15 @@ where async fn state(&self) -> Result>, SubstrateError> { // we can't continue to deliver confirmations if source node is out of sync, because // it may have already received confirmations that we're going to deliver - self.client.ensure_synced().await?; + self.source_client.ensure_synced().await?; // we can't relay confirmations if messages pallet at source chain is halted self.ensure_pallet_active().await?; - read_client_state::< - _, - as MessageLane>::TargetHeaderHash, - as MessageLane>::TargetHeaderNumber, - >(&self.client, P::TargetChain::BEST_FINALIZED_HEADER_ID_METHOD) + read_client_state( + &self.source_client, + Some(&self.target_client), + P::TargetChain::BEST_FINALIZED_HEADER_ID_METHOD, + ) .await } @@ -183,7 +188,7 @@ where SubstrateError, > { let encoded_response = self - .client + .source_client .state_call( P::TargetChain::TO_CHAIN_MESSAGE_DETAILS_METHOD.into(), Bytes((self.lane_id, nonces.start(), nonces.end()).encode()), @@ -230,7 +235,12 @@ where )); } - let proof = self.client.prove_storage(storage_keys, id.1).await?.iter_nodes().collect(); + let proof = self + .source_client + .prove_storage(storage_keys, id.1) + .await? + .iter_nodes() + .collect(); let proof = FromBridgedChainMessagesProof { bridged_header_hash: id.1, storage_proof: proof, @@ -246,10 +256,11 @@ where _generated_at_block: TargetHeaderIdOf>, proof: as MessageLane>::MessagesReceivingProof, ) -> Result<(), SubstrateError> { - let genesis_hash = *self.client.genesis_hash(); + let genesis_hash = *self.source_client.genesis_hash(); let transaction_params = self.transaction_params.clone(); - let (spec_version, transaction_version) = self.client.simple_runtime_version().await?; - self.client + let (spec_version, transaction_version) = + self.source_client.simple_runtime_version().await?; + self.source_client .submit_signed_extrinsic( self.transaction_params.signer.public().into(), move |best_block_id, transaction_nonce| { @@ -278,24 +289,28 @@ where async fn estimate_confirmation_transaction( &self, ) -> as MessageLane>::SourceChainBalance { - let runtime_version = match self.client.runtime_version().await { + let runtime_version = match self.source_client.runtime_version().await { Ok(v) => v, Err(_) => return BalanceOf::::max_value(), }; - self.client - .estimate_extrinsic_fee(make_messages_delivery_proof_transaction::

( + async { + let dummy_tx = make_messages_delivery_proof_transaction::

( runtime_version.spec_version, runtime_version.transaction_version, - self.client.genesis_hash(), + self.source_client.genesis_hash(), &self.transaction_params, HeaderId(Default::default(), Default::default()), Zero::zero(), prepare_dummy_messages_delivery_proof::(), false, - )) - .await - .map(|fee| fee.inclusion_fee()) - .unwrap_or_else(|_| BalanceOf::::max_value()) + )?; + self.source_client + .estimate_extrinsic_fee(dummy_tx) + .await + .map(|fee| fee.inclusion_fee()) + } + .await + .unwrap_or_else(|_| BalanceOf::::max_value()) } } @@ -319,6 +334,7 @@ where } /// Make messages delivery proof transaction from given proof. +#[allow(clippy::too_many_arguments)] fn make_messages_delivery_proof_transaction( spec_version: u32, transaction_version: u32, @@ -328,7 +344,7 @@ fn make_messages_delivery_proof_transaction( transaction_nonce: IndexOf, proof: SubstrateMessagesDeliveryProof, trace_call: bool, -) -> Bytes +) -> Result where P::SourceTransactionSignScheme: TransactionSignScheme, { @@ -336,17 +352,17 @@ where P::ReceiveMessagesDeliveryProofCallBuilder::build_receive_messages_delivery_proof_call( proof, trace_call, ); - Bytes( + Ok(Bytes( P::SourceTransactionSignScheme::sign_transaction(SignParam { spec_version, transaction_version, genesis_hash: *source_genesis_hash, signer: source_transaction_params.signer.clone(), era: TransactionEra::new(source_best_block_id, source_transaction_params.mortality), - unsigned: UnsignedTransaction::new(call, transaction_nonce), - }) + unsigned: UnsignedTransaction::new(call.into(), transaction_nonce), + })? .encode(), - ) + )) } /// Prepare 'dummy' messages delivery proof that will compose the delivery confirmation transaction. @@ -381,19 +397,19 @@ fn prepare_dummy_messages_delivery_proof( /// This function assumes that the chain that is followed by the `self_client` has /// bridge GRANDPA pallet deployed and it provides `best_finalized_header_id_method_name` /// runtime API to read the best finalized Bridged chain header. -pub async fn read_client_state( +/// +/// If `peer_client` is `None`, the value of `actual_best_finalized_peer_at_best_self` will +/// always match the `best_finalized_peer_at_best_self`. +pub async fn read_client_state( self_client: &Client, + peer_client: Option<&Client>, best_finalized_header_id_method_name: &str, -) -> Result< - ClientState, HeaderId>, - SubstrateError, -> +) -> Result, HeaderIdOf>, SubstrateError> where SelfChain: Chain, SelfChain::Header: DeserializeOwned, SelfChain::Index: DeserializeOwned, - BridgedHeaderHash: Decode, - BridgedHeaderNumber: Decode, + PeerChain: Chain, { // let's read our state first: we need best finalized header hash on **this** chain let self_best_finalized_header_hash = self_client.best_finalized_header_hash().await?; @@ -415,16 +431,27 @@ where Some(self_best_hash), ) .await?; - let decoded_best_finalized_peer_on_self: (BridgedHeaderNumber, BridgedHeaderHash) = + let decoded_best_finalized_peer_on_self: (BlockNumberOf, HashOf) = Decode::decode(&mut &encoded_best_finalized_peer_on_self.0[..]) .map_err(SubstrateError::ResponseParseFailed)?; let peer_on_self_best_finalized_id = HeaderId(decoded_best_finalized_peer_on_self.0, decoded_best_finalized_peer_on_self.1); + // read actual header, matching the `peer_on_self_best_finalized_id` from the peer chain + let actual_peer_on_self_best_finalized_id = match peer_client { + Some(peer_client) => { + let actual_peer_on_self_best_finalized = + peer_client.header_by_number(peer_on_self_best_finalized_id.0).await?; + HeaderId(peer_on_self_best_finalized_id.0, actual_peer_on_self_best_finalized.hash()) + }, + None => peer_on_self_best_finalized_id, + }; + Ok(ClientState { best_self: self_best_id, best_finalized_self: self_best_finalized_id, best_finalized_peer_at_best_self: peer_on_self_best_finalized_id, + actual_best_finalized_peer_at_best_self: actual_peer_on_self_best_finalized_id, }) } diff --git a/relays/lib-substrate-relay/src/messages_target.rs b/relays/lib-substrate-relay/src/messages_target.rs index 5336e065a92..869a1d28028 100644 --- a/relays/lib-substrate-relay/src/messages_target.rs +++ b/relays/lib-substrate-relay/src/messages_target.rs @@ -28,13 +28,13 @@ use crate::{ use async_trait::async_trait; use bp_messages::{ - storage_keys::inbound_lane_data_key, InboundLaneData, LaneId, MessageNonce, - UnrewardedRelayersState, + storage_keys::inbound_lane_data_key, total_unrewarded_messages, InboundLaneData, LaneId, + MessageNonce, UnrewardedRelayersState, }; use bridge_runtime_common::messages::{ source::FromBridgedChainMessagesDeliveryProof, target::FromBridgedChainMessagesProof, }; -use codec::{Decode, Encode}; +use codec::Encode; use frame_support::weights::{Weight, WeightToFeePolynomial}; use messages_relay::{ message_lane::{MessageLane, SourceHeaderIdOf, TargetHeaderIdOf}, @@ -49,7 +49,7 @@ use relay_substrate_client::{ use relay_utils::{relay_loop::Client as RelayClient, HeaderId}; use sp_core::{Bytes, Pair}; use sp_runtime::{traits::Saturating, FixedPointNumber, FixedU128}; -use std::{convert::TryFrom, ops::RangeInclusive}; +use std::{collections::VecDeque, convert::TryFrom, ops::RangeInclusive}; /// Message receiving proof returned by the target Substrate node. pub type SubstrateMessagesDeliveryProof = @@ -57,7 +57,8 @@ pub type SubstrateMessagesDeliveryProof = /// Substrate client as Substrate messages target. pub struct SubstrateMessagesTarget { - client: Client, + target_client: Client, + source_client: Client, lane_id: LaneId, relayer_id_at_source: AccountIdOf, transaction_params: TransactionParams>, @@ -68,7 +69,8 @@ pub struct SubstrateMessagesTarget { impl SubstrateMessagesTarget

{ /// Create new Substrate headers target. pub fn new( - client: Client, + target_client: Client, + source_client: Client, lane_id: LaneId, relayer_id_at_source: AccountIdOf, transaction_params: TransactionParams>, @@ -76,7 +78,8 @@ impl SubstrateMessagesTarget

{ source_to_target_headers_relay: Option>, ) -> Self { SubstrateMessagesTarget { - client, + target_client, + source_client, lane_id, relayer_id_at_source, transaction_params, @@ -90,7 +93,7 @@ impl SubstrateMessagesTarget

{ &self, id: TargetHeaderIdOf>, ) -> Result>>, SubstrateError> { - self.client + self.target_client .storage_value( inbound_lane_data_key( P::SourceChain::WITH_CHAIN_MESSAGES_PALLET_NAME, @@ -103,14 +106,15 @@ impl SubstrateMessagesTarget

{ /// Ensure that the messages pallet at target chain is active. async fn ensure_pallet_active(&self) -> Result<(), SubstrateError> { - ensure_messages_pallet_active::(&self.client).await + ensure_messages_pallet_active::(&self.target_client).await } } impl Clone for SubstrateMessagesTarget

{ fn clone(&self) -> Self { Self { - client: self.client.clone(), + target_client: self.target_client.clone(), + source_client: self.source_client.clone(), lane_id: self.lane_id, relayer_id_at_source: self.relayer_id_at_source.clone(), transaction_params: self.transaction_params.clone(), @@ -125,7 +129,8 @@ impl RelayClient for SubstrateMessagesTarget

{ type Error = SubstrateError; async fn reconnect(&mut self) -> Result<(), SubstrateError> { - self.client.reconnect().await + self.target_client.reconnect().await?; + self.source_client.reconnect().await } } @@ -140,15 +145,15 @@ where async fn state(&self) -> Result>, SubstrateError> { // we can't continue to deliver messages if target node is out of sync, because // it may have already received (some of) messages that we're going to deliver - self.client.ensure_synced().await?; + self.target_client.ensure_synced().await?; // we can't relay messages if messages pallet at target chain is halted self.ensure_pallet_active().await?; - read_client_state::< - _, - as MessageLane>::SourceHeaderHash, - as MessageLane>::SourceHeaderNumber, - >(&self.client, P::SourceChain::BEST_FINALIZED_HEADER_ID_METHOD) + read_client_state( + &self.target_client, + Some(&self.source_client), + P::SourceChain::BEST_FINALIZED_HEADER_ID_METHOD, + ) .await } @@ -183,17 +188,19 @@ where id: TargetHeaderIdOf>, ) -> Result<(TargetHeaderIdOf>, UnrewardedRelayersState), SubstrateError> { - let encoded_response = self - .client - .state_call( - P::SourceChain::FROM_CHAIN_UNREWARDED_RELAYERS_STATE.into(), - Bytes(self.lane_id.encode()), - Some(id.1), - ) - .await?; - let unrewarded_relayers_state: UnrewardedRelayersState = - Decode::decode(&mut &encoded_response.0[..]) - .map_err(SubstrateError::ResponseParseFailed)?; + let relayers = self + .inbound_lane_data(id) + .await? + .map(|data| data.relayers) + .unwrap_or_else(|| VecDeque::new()); + let unrewarded_relayers_state = bp_messages::UnrewardedRelayersState { + unrewarded_relayer_entries: relayers.len() as _, + messages_in_oldest_entry: relayers + .front() + .map(|entry| 1 + entry.messages.end - entry.messages.begin) + .unwrap_or(0), + total_messages: total_unrewarded_messages(&relayers).unwrap_or(MessageNonce::MAX), + }; Ok((id, unrewarded_relayers_state)) } @@ -213,7 +220,7 @@ where &self.lane_id, ); let proof = self - .client + .target_client .prove_storage(vec![inbound_data_key], id.1) .await? .iter_nodes() @@ -232,12 +239,13 @@ where nonces: RangeInclusive, proof: as MessageLane>::MessagesProof, ) -> Result, SubstrateError> { - let genesis_hash = *self.client.genesis_hash(); + let genesis_hash = *self.target_client.genesis_hash(); let transaction_params = self.transaction_params.clone(); let relayer_id_at_source = self.relayer_id_at_source.clone(); let nonces_clone = nonces.clone(); - let (spec_version, transaction_version) = self.client.simple_runtime_version().await?; - self.client + let (spec_version, transaction_version) = + self.target_client.simple_runtime_version().await?; + self.target_client .submit_signed_extrinsic( self.transaction_params.signer.public().into(), move |best_block_id, transaction_nonce| { @@ -281,12 +289,13 @@ where )) })?; - let (spec_version, transaction_version) = self.client.simple_runtime_version().await?; + let (spec_version, transaction_version) = + self.target_client.simple_runtime_version().await?; // Prepare 'dummy' delivery transaction - we only care about its length and dispatch weight. let delivery_tx = make_messages_delivery_transaction::

( spec_version, transaction_version, - self.client.genesis_hash(), + self.target_client.genesis_hash(), &self.transaction_params, HeaderId(Default::default(), Default::default()), Zero::zero(), @@ -298,8 +307,8 @@ where total_size, ), false, - ); - let delivery_tx_fee = self.client.estimate_extrinsic_fee(delivery_tx).await?; + )?; + let delivery_tx_fee = self.target_client.estimate_extrinsic_fee(delivery_tx).await?; let inclusion_fee_in_target_tokens = delivery_tx_fee.inclusion_fee(); // The pre-dispatch cost of delivery transaction includes additional fee to cover dispatch @@ -321,27 +330,27 @@ where let expected_refund_in_target_tokens = if total_prepaid_nonces != 0 { const WEIGHT_DIFFERENCE: Weight = 100; - let (spec_version, transaction_version) = self.client.simple_runtime_version().await?; + let (spec_version, transaction_version) = + self.target_client.simple_runtime_version().await?; let larger_dispatch_weight = total_dispatch_weight.saturating_add(WEIGHT_DIFFERENCE); - let larger_delivery_tx_fee = self - .client - .estimate_extrinsic_fee(make_messages_delivery_transaction::

( - spec_version, - transaction_version, - self.client.genesis_hash(), - &self.transaction_params, - HeaderId(Default::default(), Default::default()), - Zero::zero(), - self.relayer_id_at_source.clone(), + let dummy_tx = make_messages_delivery_transaction::

( + spec_version, + transaction_version, + self.target_client.genesis_hash(), + &self.transaction_params, + HeaderId(Default::default(), Default::default()), + Zero::zero(), + self.relayer_id_at_source.clone(), + nonces.clone(), + prepare_dummy_messages_proof::( nonces.clone(), - prepare_dummy_messages_proof::( - nonces.clone(), - larger_dispatch_weight, - total_size, - ), - false, - )) - .await?; + larger_dispatch_weight, + total_size, + ), + false, + )?; + let larger_delivery_tx_fee = + self.target_client.estimate_extrinsic_fee(dummy_tx).await?; compute_prepaid_messages_refund::( total_prepaid_nonces, @@ -402,7 +411,7 @@ fn make_messages_delivery_transaction( nonces: RangeInclusive, proof: SubstrateMessagesProof, trace_call: bool, -) -> Bytes +) -> Result where P::TargetTransactionSignScheme: TransactionSignScheme, { @@ -415,17 +424,17 @@ where dispatch_weight, trace_call, ); - Bytes( + Ok(Bytes( P::TargetTransactionSignScheme::sign_transaction(SignParam { spec_version, transaction_version, genesis_hash: *target_genesis_hash, signer: target_transaction_params.signer.clone(), era: TransactionEra::new(target_best_block_id, target_transaction_params.mortality), - unsigned: UnsignedTransaction::new(call, transaction_nonce), - }) + unsigned: UnsignedTransaction::new(call.into(), transaction_nonce), + })? .encode(), - ) + )) } /// Prepare 'dummy' messages proof that will compose the delivery transaction. diff --git a/relays/lib-substrate-relay/src/on_demand_headers.rs b/relays/lib-substrate-relay/src/on_demand_headers.rs index 2e8a6db7983..c1401a28a6d 100644 --- a/relays/lib-substrate-relay/src/on_demand_headers.rs +++ b/relays/lib-substrate-relay/src/on_demand_headers.rs @@ -18,7 +18,7 @@ use async_std::sync::{Arc, Mutex}; use futures::{select, FutureExt}; -use num_traits::{CheckedSub, One, Zero}; +use num_traits::{One, Zero}; use finality_relay::{FinalitySyncParams, SourceHeader, TargetClient as FinalityTargetClient}; use relay_substrate_client::{ @@ -55,7 +55,6 @@ impl OnDemandHeadersRelay { source_client: Client, target_client: Client, target_transaction_params: TransactionParams>, - maximal_headers_difference: BlockNumberOf, only_mandatory_headers: bool, ) -> Self where @@ -73,7 +72,6 @@ impl OnDemandHeadersRelay { source_client, target_client, target_transaction_params, - maximal_headers_difference, only_mandatory_headers, required_header_number, ) @@ -105,7 +103,6 @@ async fn background_task( source_client: Client, target_client: Client, target_transaction_params: TransactionParams>, - maximal_headers_difference: BlockNumberOf, only_mandatory_headers: bool, required_header_number: RequiredHeaderNumberRef, ) where @@ -165,15 +162,28 @@ async fn background_task( } // submit mandatory header if some headers are missing + let best_finalized_source_header_at_source_fmt = + format!("{:?}", best_finalized_source_header_at_source); let best_finalized_source_header_at_target_fmt = format!("{:?}", best_finalized_source_header_at_target); + let required_header_number_value = *required_header_number.lock().await; let mandatory_scan_range = mandatory_headers_scan_range::( best_finalized_source_header_at_source.ok(), best_finalized_source_header_at_target.ok(), - maximal_headers_difference, - &required_header_number, + required_header_number_value, ) .await; + + log::trace!( + target: "bridge", + "Mandatory headers scan range in {}: ({:?}, {:?}, {:?}) -> {:?}", + relay_task_name, + required_header_number_value, + best_finalized_source_header_at_source_fmt, + best_finalized_source_header_at_target_fmt, + mandatory_scan_range, + ); + if let Some(mandatory_scan_range) = mandatory_scan_range { let relay_mandatory_header_result = relay_mandatory_header_from_range( &finality_source, @@ -227,6 +237,25 @@ async fn background_task( // start/restart relay if restart_relay { + let stall_timeout = relay_substrate_client::transaction_stall_timeout( + target_transactions_mortality, + P::TargetChain::AVERAGE_BLOCK_INTERVAL, + STALL_TIMEOUT, + ); + + log::info!( + target: "bridge", + "Starting {} relay\n\t\ + Only mandatory headers: {}\n\t\ + Tx mortality: {:?} (~{}m)\n\t\ + Stall timeout: {:?}", + relay_task_name, + only_mandatory_headers, + target_transactions_mortality, + stall_timeout.as_secs_f64() / 60.0f64, + stall_timeout, + ); + finality_relay_task.set( finality_relay::run( finality_source.clone(), @@ -237,11 +266,7 @@ async fn background_task( P::TargetChain::AVERAGE_BLOCK_INTERVAL, ), recent_finality_proofs_limit: RECENT_FINALITY_PROOFS_LIMIT, - stall_timeout: relay_substrate_client::transaction_stall_timeout( - target_transactions_mortality, - P::TargetChain::AVERAGE_BLOCK_INTERVAL, - STALL_TIMEOUT, - ), + stall_timeout, only_mandatory_headers, }, MetricsParams::disabled(), @@ -260,11 +285,8 @@ async fn background_task( async fn mandatory_headers_scan_range( best_finalized_source_header_at_source: Option, best_finalized_source_header_at_target: Option, - maximal_headers_difference: C::BlockNumber, - required_header_number: &RequiredHeaderNumberRef, + required_header_number: BlockNumberOf, ) -> Option<(C::BlockNumber, C::BlockNumber)> { - let required_header_number = *required_header_number.lock().await; - // if we have been unable to read header number from the target, then let's assume // that it is the same as required header number. Otherwise we risk submitting // unneeded transactions @@ -276,23 +298,8 @@ async fn mandatory_headers_scan_range( let best_finalized_source_header_at_source = best_finalized_source_header_at_source.unwrap_or(best_finalized_source_header_at_target); - // if there are too many source headers missing from the target node, sync mandatory - // headers to target - // - // why do we need that? When complex headers+messages relay is used, it'll normally only relay - // headers when there are undelivered messages/confirmations. But security model of the - // `pallet-bridge-grandpa` module relies on the fact that headers are synced in real-time and - // that it'll see authorities-change header before unbonding period will end for previous - // authorities set. - let current_headers_difference = best_finalized_source_header_at_source - .checked_sub(&best_finalized_source_header_at_target) - .unwrap_or_else(Zero::zero); - if current_headers_difference <= maximal_headers_difference { - return None - } - - // if relay is already asked to sync headers, don't do anything yet - if required_header_number > best_finalized_source_header_at_target { + // if relay is already asked to sync more headers than we have at source, don't do anything yet + if required_header_number >= best_finalized_source_header_at_source { return None } @@ -375,16 +382,20 @@ where From< as sp_core::Pair>::Public>, P::TransactionSignScheme: TransactionSignScheme, { - finality_target.best_finalized_source_block_number().await.map_err(|error| { - log::error!( - target: "bridge", - "Failed to read best finalized source header from target in {} relay: {:?}", - relay_task_name, - error, - ); + finality_target + .best_finalized_source_block_id() + .await + .map_err(|error| { + log::error!( + target: "bridge", + "Failed to read best finalized source header from target in {} relay: {:?}", + relay_task_name, + error, + ); - error - }) + error + }) + .map(|id| id.0) } /// Read first mandatory header in given inclusive range. @@ -423,29 +434,18 @@ mod tests { const AT_TARGET: Option = Some(1); #[async_std::test] - async fn mandatory_headers_scan_range_selects_range_if_too_many_headers_are_missing() { + async fn mandatory_headers_scan_range_selects_range_if_some_headers_are_missing() { assert_eq!( - mandatory_headers_scan_range::( - AT_SOURCE, - AT_TARGET, - 5, - &Arc::new(Mutex::new(0)) - ) - .await, + mandatory_headers_scan_range::(AT_SOURCE, AT_TARGET, 0,).await, Some((AT_TARGET.unwrap() + 1, AT_SOURCE.unwrap())), ); } #[async_std::test] - async fn mandatory_headers_scan_range_selects_nothing_if_enough_headers_are_relayed() { + async fn mandatory_headers_scan_range_selects_nothing_if_already_queued() { assert_eq!( - mandatory_headers_scan_range::( - AT_SOURCE, - AT_TARGET, - 10, - &Arc::new(Mutex::new(0)) - ) - .await, + mandatory_headers_scan_range::(AT_SOURCE, AT_TARGET, AT_SOURCE.unwrap(),) + .await, None, ); } diff --git a/relays/messages/Cargo.toml b/relays/messages/Cargo.toml index b11f00b957a..b3357994b12 100644 --- a/relays/messages/Cargo.toml +++ b/relays/messages/Cargo.toml @@ -2,7 +2,7 @@ name = "messages-relay" version = "0.1.0" authors = ["Parity Technologies "] -edition = "2018" +edition = "2021" license = "GPL-3.0-or-later WITH Classpath-exception-2.0" [dependencies] @@ -18,6 +18,7 @@ parking_lot = "0.11.0" bp-messages = { path = "../../primitives/messages" } bp-runtime = { path = "../../primitives/runtime" } +finality-relay = { path = "../finality" } relay-utils = { path = "../utils" } sp-arithmetic = { git = "https://github.com/paritytech/substrate", branch = "master" } diff --git a/relays/messages/src/message_lane_loop.rs b/relays/messages/src/message_lane_loop.rs index 6cdb2b1aa5a..c1778d5d11e 100644 --- a/relays/messages/src/message_lane_loop.rs +++ b/relays/messages/src/message_lane_loop.rs @@ -233,6 +233,9 @@ pub struct ClientState { /// Best finalized header id of the peer chain read at the best block of this chain (at /// `best_finalized_self`). pub best_finalized_peer_at_best_self: PeerHeaderId, + /// Header id of the peer chain with the number, matching the + /// `best_finalized_peer_at_best_self`. + pub actual_best_finalized_peer_at_best_self: PeerHeaderId, } /// State of source client in one-way message lane. @@ -843,12 +846,14 @@ pub(crate) mod tests { best_self: HeaderId(0, 0), best_finalized_self: HeaderId(0, 0), best_finalized_peer_at_best_self: HeaderId(0, 0), + actual_best_finalized_peer_at_best_self: HeaderId(0, 0), }, source_latest_generated_nonce: 1, target_state: ClientState { best_self: HeaderId(0, 0), best_finalized_self: HeaderId(0, 0), best_finalized_peer_at_best_self: HeaderId(0, 0), + actual_best_finalized_peer_at_best_self: HeaderId(0, 0), }, target_latest_received_nonce: 0, ..Default::default() @@ -888,12 +893,14 @@ pub(crate) mod tests { best_self: HeaderId(10, 10), best_finalized_self: HeaderId(10, 10), best_finalized_peer_at_best_self: HeaderId(0, 0), + actual_best_finalized_peer_at_best_self: HeaderId(0, 0), }, source_latest_generated_nonce: 10, target_state: ClientState { best_self: HeaderId(0, 0), best_finalized_self: HeaderId(0, 0), best_finalized_peer_at_best_self: HeaderId(0, 0), + actual_best_finalized_peer_at_best_self: HeaderId(0, 0), }, target_latest_received_nonce: 0, ..Default::default() diff --git a/relays/messages/src/metrics.rs b/relays/messages/src/metrics.rs index eac2f703692..4decb7e092e 100644 --- a/relays/messages/src/metrics.rs +++ b/relays/messages/src/metrics.rs @@ -22,6 +22,7 @@ use crate::{ }; use bp_messages::MessageNonce; +use finality_relay::SyncLoopMetrics; use relay_utils::metrics::{ metric_name, register, GaugeVec, Metric, Opts, PrometheusError, Registry, U64, }; @@ -31,8 +32,10 @@ use relay_utils::metrics::{ /// Cloning only clones references. #[derive(Clone)] pub struct MessageLaneLoopMetrics { + /// Best finalized block numbers - "source", "source_at_target", "target_at_source". + source_to_target_finality_metrics: SyncLoopMetrics, /// Best finalized block numbers - "source", "target", "source_at_target", "target_at_source". - best_block_numbers: GaugeVec, + target_to_source_finality_metrics: SyncLoopMetrics, /// Lane state nonces: "source_latest_generated", "source_latest_confirmed", /// "target_latest_received", "target_latest_confirmed". lane_state_nonces: GaugeVec, @@ -42,12 +45,15 @@ impl MessageLaneLoopMetrics { /// Create and register messages loop metrics. pub fn new(prefix: Option<&str>) -> Result { Ok(MessageLaneLoopMetrics { - best_block_numbers: GaugeVec::new( - Opts::new( - metric_name(prefix, "best_block_numbers"), - "Best finalized block numbers", - ), - &["type"], + source_to_target_finality_metrics: SyncLoopMetrics::new( + prefix, + "source", + "source_at_target", + )?, + target_to_source_finality_metrics: SyncLoopMetrics::new( + prefix, + "target", + "target_at_source", )?, lane_state_nonces: GaugeVec::new( Opts::new(metric_name(prefix, "lane_state_nonces"), "Nonces of the lane state"), @@ -58,22 +64,28 @@ impl MessageLaneLoopMetrics { /// Update source client state metrics. pub fn update_source_state(&self, source_client_state: SourceClientState

) { - self.best_block_numbers - .with_label_values(&["source"]) - .set(source_client_state.best_self.0.into()); - self.best_block_numbers - .with_label_values(&["target_at_source"]) - .set(source_client_state.best_finalized_peer_at_best_self.0.into()); + self.source_to_target_finality_metrics + .update_best_block_at_source(source_client_state.best_self.0.into()); + self.target_to_source_finality_metrics.update_best_block_at_target( + source_client_state.best_finalized_peer_at_best_self.0.into(), + ); + self.target_to_source_finality_metrics.update_using_same_fork( + source_client_state.best_finalized_peer_at_best_self.1 == + source_client_state.actual_best_finalized_peer_at_best_self.1, + ); } /// Update target client state metrics. pub fn update_target_state(&self, target_client_state: TargetClientState

) { - self.best_block_numbers - .with_label_values(&["target"]) - .set(target_client_state.best_self.0.into()); - self.best_block_numbers - .with_label_values(&["source_at_target"]) - .set(target_client_state.best_finalized_peer_at_best_self.0.into()); + self.target_to_source_finality_metrics + .update_best_block_at_source(target_client_state.best_self.0.into()); + self.source_to_target_finality_metrics.update_best_block_at_target( + target_client_state.best_finalized_peer_at_best_self.0.into(), + ); + self.source_to_target_finality_metrics.update_using_same_fork( + target_client_state.best_finalized_peer_at_best_self.1 == + target_client_state.actual_best_finalized_peer_at_best_self.1, + ); } /// Update latest generated nonce at source. @@ -119,7 +131,8 @@ impl MessageLaneLoopMetrics { impl Metric for MessageLaneLoopMetrics { fn register(&self, registry: &Registry) -> Result<(), PrometheusError> { - register(self.best_block_numbers.clone(), registry)?; + self.source_to_target_finality_metrics.register(registry)?; + self.target_to_source_finality_metrics.register(registry)?; register(self.lane_state_nonces.clone(), registry)?; Ok(()) } diff --git a/relays/utils/Cargo.toml b/relays/utils/Cargo.toml index a08c3b3d688..bb69849da26 100644 --- a/relays/utils/Cargo.toml +++ b/relays/utils/Cargo.toml @@ -2,7 +2,7 @@ name = "relay-utils" version = "0.1.0" authors = ["Parity Technologies "] -edition = "2018" +edition = "2021" license = "GPL-3.0-or-later WITH Classpath-exception-2.0" [dependencies] @@ -19,7 +19,8 @@ log = "0.4.11" num-traits = "0.2" serde_json = "1.0" sysinfo = "0.15" -time = "0.2" +time = { version = "0.3", features = ["formatting", "local-offset", "std"] } +tokio = { version = "1.8", features = ["rt"] } thiserror = "1.0.26" # Bridge dependencies diff --git a/relays/utils/src/initialize.rs b/relays/utils/src/initialize.rs index 8c13a4d61cb..ad69a766e62 100644 --- a/relays/utils/src/initialize.rs +++ b/relays/utils/src/initialize.rs @@ -29,15 +29,21 @@ pub fn initialize_relay() { /// Initialize Relay logger instance. pub fn initialize_logger(with_timestamp: bool) { + let format = time::format_description::parse( + "[year]-[month]-[day] \ + [hour repr:24]:[minute]:[second] [offset_hour sign:mandatory]", + ) + .expect("static format string is valid"); + let mut builder = env_logger::Builder::new(); builder.filter_level(log::LevelFilter::Warn); builder.filter_module("bridge", log::LevelFilter::Info); builder.parse_default_env(); if with_timestamp { builder.format(move |buf, record| { - let timestamp = time::OffsetDateTime::try_now_local() - .unwrap_or_else(|_| time::OffsetDateTime::now_utc()) - .format("%Y-%m-%d %H:%M:%S %z"); + let timestamp = time::OffsetDateTime::now_local() + .unwrap_or_else(|_| time::OffsetDateTime::now_utc()); + let timestamp = timestamp.format(&format).unwrap_or_else(|_| timestamp.to_string()); let log_level = color_level(record.level()); let log_target = color_target(record.target()); diff --git a/relays/utils/src/metrics.rs b/relays/utils/src/metrics.rs index 805fe70bfe8..084f72e7950 100644 --- a/relays/utils/src/metrics.rs +++ b/relays/utils/src/metrics.rs @@ -18,7 +18,7 @@ pub use float_json_value::FloatJsonValueMetric; pub use global::GlobalMetrics; pub use substrate_prometheus_endpoint::{ prometheus::core::{Atomic, Collector}, - register, Counter, CounterVec, Gauge, GaugeVec, Opts, PrometheusError, Registry, F64, U64, + register, Counter, CounterVec, Gauge, GaugeVec, Opts, PrometheusError, Registry, F64, I64, U64, }; use async_std::sync::{Arc, RwLock}; @@ -30,6 +30,8 @@ mod global; /// Shared reference to `f64` value that is updated by the metric. pub type F64SharedRef = Arc>>; +/// Int gauge metric type. +pub type IntGauge = Gauge; /// Unparsed address that needs to be used to expose Prometheus metrics. #[derive(Debug, Clone)] diff --git a/relays/utils/src/relay_loop.rs b/relays/utils/src/relay_loop.rs index a992aaaf57e..521a6345d3e 100644 --- a/relays/utils/src/relay_loop.rs +++ b/relays/utils/src/relay_loop.rs @@ -187,12 +187,32 @@ impl LoopMetrics { let registry = self.registry; async_std::task::spawn(async move { - let result = init_prometheus(socket_addr, registry).await; - log::trace!( - target: "bridge-metrics", - "Prometheus endpoint has exited with result: {:?}", - result, - ); + let runtime = + match tokio::runtime::Builder::new_current_thread().enable_all().build() { + Ok(runtime) => runtime, + Err(err) => { + log::trace!( + target: "bridge-metrics", + "Failed to create tokio runtime. Prometheus meterics are not available: {:?}", + err, + ); + return + }, + }; + + let _ = runtime.block_on(async move { + log::trace!( + target: "bridge-metrics", + "Starting prometheus endpoint at: {:?}", + socket_addr, + ); + let result = init_prometheus(socket_addr, registry).await; + log::trace!( + target: "bridge-metrics", + "Prometheus endpoint has exited with result: {:?}", + result, + ); + }); }); } diff --git a/scripts/dump-logs.sh b/scripts/dump-logs.sh old mode 100644 new mode 100755 index 02aa4af2f75..e5a3a403ada --- a/scripts/dump-logs.sh +++ b/scripts/dump-logs.sh @@ -28,7 +28,7 @@ SERVICES=(\ for SVC in ${SERVICES[*]} do SHORT_NAME="${SVC//deployments_/}" - docker logs $SVC &> $SHORT_NAME.log + docker logs $SVC &> $SHORT_NAME.log | true done cd -