diff --git a/polkadot/Cargo.lock b/polkadot/Cargo.lock index eb9ef2b19a..9463440019 100644 --- a/polkadot/Cargo.lock +++ b/polkadot/Cargo.lock @@ -25,6 +25,61 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "567b077b825e468cc974f0020d4082ee6e03132512f207ef1a02fd5d00d1f32d" +[[package]] +name = "aead" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4cf01b9b56e767bb57b94ebf91a58b338002963785cdd7013e21c0d4679471e4" +dependencies = [ + "generic-array", +] + +[[package]] +name = "aes" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "54eb1d8fe354e5fc611daf4f2ea97dd45a765f4f1e4512306ec183ae2e8f20c9" +dependencies = [ + "aes-soft", + "aesni", + "block-cipher-trait", +] + +[[package]] +name = "aes-gcm" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "834a6bda386024dbb7c8fc51322856c10ffe69559f972261c868485f5759c638" +dependencies = [ + "aead", + "aes", + "block-cipher-trait", + "ghash", + "subtle 2.2.3", + "zeroize", +] + +[[package]] +name = "aes-soft" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfd7e7ae3f9a1fb5c03b389fc6bb9a51400d0c13053f0dca698c832bfd893a0d" +dependencies = [ + "block-cipher-trait", + "byteorder", + "opaque-debug", +] + +[[package]] +name = "aesni" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f70a6b5f971e473091ab7cfb5ffac6cde81666c4556751d8d5620ead8abf100" +dependencies = [ + "block-cipher-trait", + "opaque-debug", +] + [[package]] name = "ahash" version = "0.2.18" @@ -201,6 +256,17 @@ dependencies = [ "webpki-roots 0.19.0", ] +[[package]] +name = "async-trait" +version = "0.1.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a265e3abeffdce30b2e26b7a11b222fe37c6067404001b434101457d0385eb92" +dependencies = [ + "proc-macro2 1.0.18", + "quote 1.0.7", + "syn 1.0.31", +] + [[package]] name = "atty" version = "0.2.14" @@ -368,6 +434,15 @@ dependencies = [ "generic-array", ] +[[package]] +name = "block-cipher-trait" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c924d49bd09e7c06003acda26cd9742e796e34282ec6c1189404dee0c1f4774" +dependencies = [ + "generic-array", +] + [[package]] name = "block-padding" version = "0.1.5" @@ -478,12 +553,26 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" [[package]] -name = "chacha20-poly1305-aead" -version = "0.1.2" +name = "chacha20" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77d2058ba29594f69c75e8a9018e0485e3914ca5084e3613cd64529042f5423b" +checksum = "f6a7ae4c498f8447d86baef0fa0831909333f558866fabcb21600625ac5a31c7" dependencies = [ - "constant_time_eq", + "stream-cipher", + "zeroize", +] + +[[package]] +name = "chacha20poly1305" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48901293601228db2131606f741db33561f7576b5d19c99cd66222380a7dc863" +dependencies = [ + "aead", + "chacha20", + "poly1305", + "stream-cipher", + "zeroize", ] [[package]] @@ -1172,7 +1261,7 @@ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "fork-tree" version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "parity-scale-codec", ] @@ -1180,7 +1269,7 @@ dependencies = [ [[package]] name = "frame-benchmarking" version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "frame-support", "frame-system", @@ -1197,7 +1286,7 @@ dependencies = [ [[package]] name = "frame-benchmarking-cli" version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "frame-benchmarking", "parity-scale-codec", @@ -1215,7 +1304,7 @@ dependencies = [ [[package]] name = "frame-executive" version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "frame-support", "frame-system", @@ -1230,7 +1319,7 @@ dependencies = [ [[package]] name = "frame-metadata" version = "11.0.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "parity-scale-codec", "serde", @@ -1241,7 +1330,7 @@ dependencies = [ [[package]] name = "frame-support" version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "bitmask", "frame-metadata", @@ -1266,7 +1355,7 @@ dependencies = [ [[package]] name = "frame-support-procedural" version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "frame-support-procedural-tools", "proc-macro2 1.0.18", @@ -1277,7 +1366,7 @@ dependencies = [ [[package]] name = "frame-support-procedural-tools" version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "frame-support-procedural-tools-derive", "proc-macro-crate", @@ -1289,7 +1378,7 @@ dependencies = [ [[package]] name = "frame-support-procedural-tools-derive" version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "proc-macro2 1.0.18", "quote 1.0.7", @@ -1299,7 +1388,7 @@ dependencies = [ [[package]] name = "frame-system" version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "frame-support", "impl-trait-for-tuples", @@ -1315,7 +1404,7 @@ dependencies = [ [[package]] name = "frame-system-benchmarking" version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "frame-benchmarking", "frame-support", @@ -1329,7 +1418,7 @@ dependencies = [ [[package]] name = "frame-system-rpc-runtime-api" version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "parity-scale-codec", "sp-api", @@ -1559,6 +1648,18 @@ dependencies = [ "pin-project", ] +[[package]] +name = "futures_codec" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce54d63f8b0c75023ed920d46fd71d0cbbb830b0ee012726b5b4f506fb6dea5b" +dependencies = [ + "bytes 0.5.4", + "futures 0.3.5", + "memchr", + "pin-project", +] + [[package]] name = "gcc" version = "0.3.55" @@ -1608,6 +1709,15 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "ghash" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f0930ed19a7184089ea46d2fedead2f6dc2b674c5db4276b7da336c7cd83252" +dependencies = [ + "polyval", +] + [[package]] name = "gimli" version = "0.20.0" @@ -2435,9 +2545,9 @@ checksum = "c7d73b3f436185384286bd8098d17ec07c9a7d2388a6599f824d8502b529702a" [[package]] name = "libp2p" -version = "0.19.1" +version = "0.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "057eba5432d3e740e313c6e13c9153d0cb76b4f71bfc2e5242ae5bdb7d41af67" +checksum = "db81113df355dea9dddfcb01cd867555298dca29d915f25d1b1a0aad2e29338b" dependencies = [ "bytes 0.5.4", "futures 0.3.5", @@ -2457,7 +2567,7 @@ dependencies = [ "libp2p-websocket", "libp2p-yamux", "multihash", - "parity-multiaddr 0.9.0", + "parity-multiaddr 0.9.1", "parking_lot 0.10.2", "pin-project", "smallvec 1.4.0", @@ -2466,9 +2576,9 @@ dependencies = [ [[package]] name = "libp2p-core" -version = "0.19.1" +version = "0.19.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f5e30dcd8cb13a02ad534e214da234eca1595a76b5788b645dfa5c734d2124b" +checksum = "3a0387b930c3d4c2533dc4893c1e0394185ddcc019846121b1b27491e45a2c08" dependencies = [ "asn1_der", "bs58", @@ -2482,7 +2592,7 @@ dependencies = [ "log 0.4.8", "multihash", "multistream-select", - "parity-multiaddr 0.9.0", + "parity-multiaddr 0.9.1", "parking_lot 0.10.2", "pin-project", "prost", @@ -2493,7 +2603,7 @@ dependencies = [ "sha2", "smallvec 1.4.0", "thiserror", - "unsigned-varint", + "unsigned-varint 0.4.0", "void", "zeroize", ] @@ -2521,9 +2631,9 @@ dependencies = [ [[package]] name = "libp2p-identify" -version = "0.19.1" +version = "0.19.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6438ed8ca240c7635c9caa3be6c5258bc0058553ae97ba81737f04e5d33804f5" +checksum = "62f76075b170d908bae616f550ade410d9d27c013fa69042551dbfc757c7c094" dependencies = [ "futures 0.3.5", "libp2p-core", @@ -2537,16 +2647,16 @@ dependencies = [ [[package]] name = "libp2p-kad" -version = "0.19.0" +version = "0.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41d6c1d5100973527ae70d82687465b17049c1b717a7964de38b8e65000878ff" +checksum = "f7c819a5425b2eb3416d67e9c868c5c1e922b6658655e06b9eeafaa41304b876" dependencies = [ "arrayvec 0.5.1", "bytes 0.5.4", "either", "fnv", "futures 0.3.5", - "futures_codec", + "futures_codec 0.4.1", "libp2p-core", "libp2p-swarm", "log 0.4.8", @@ -2557,16 +2667,16 @@ dependencies = [ "sha2", "smallvec 1.4.0", "uint", - "unsigned-varint", + "unsigned-varint 0.4.0", "void", "wasm-timer", ] [[package]] name = "libp2p-mdns" -version = "0.19.1" +version = "0.19.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51b00163d13f705aae67c427bea0575f8aaf63da6524f9bd4a5a093b8bda0b38" +checksum = "7f55b2d4b80986e5bf158270ab23268ec0e7f644ece5436fbaabc5155472f357" dependencies = [ "async-std", "data-encoding", @@ -2586,25 +2696,25 @@ dependencies = [ [[package]] name = "libp2p-mplex" -version = "0.19.1" +version = "0.19.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34ce63313ad4bce2d76e54c292a1293ea47a0ebbe16708f1513fa62184992f53" +checksum = "be7d913a4cd57de2013257ec73f07d77bfce390b370023e2d59083e5ca079864" dependencies = [ "bytes 0.5.4", "fnv", "futures 0.3.5", - "futures_codec", + "futures_codec 0.4.1", "libp2p-core", "log 0.4.8", "parking_lot 0.10.2", - "unsigned-varint", + "unsigned-varint 0.4.0", ] [[package]] name = "libp2p-noise" -version = "0.19.0" +version = "0.19.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84fd504e27b0eadd451e06b67694ef714bd8374044e7db339bb0cdb83755ddf4" +checksum = "a03db664653369f46ee03fcec483a378c20195089bb43a26cb9fb0058009ac88" dependencies = [ "curve25519-dalek", "futures 0.3.5", @@ -2623,9 +2733,9 @@ dependencies = [ [[package]] name = "libp2p-ping" -version = "0.19.2" +version = "0.19.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffb3c4f9273313357d4977799aec69f581cfe9568854919c5b8066018ccf59f5" +checksum = "b8dedd34e35a9728d52d59ef36a218e411359a353f9011b2574b86ee790978f6" dependencies = [ "futures 0.3.5", "libp2p-core", @@ -2638,9 +2748,9 @@ dependencies = [ [[package]] name = "libp2p-swarm" -version = "0.19.0" +version = "0.19.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4a8101a0e0d5f04562137a476bf5f5423cd5bdab2f7e43a75909668e63cb102" +checksum = "ce53ff4d127cf8b39adf84dbd381ca32d49bd85788cee08e6669da2495993930" dependencies = [ "futures 0.3.5", "libp2p-core", @@ -2653,9 +2763,9 @@ dependencies = [ [[package]] name = "libp2p-tcp" -version = "0.19.1" +version = "0.19.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "309f95fce9bec755eff5406f8b822fd3969990830c2b54f752e1fc181d5ace3e" +checksum = "9481500c5774c62e8c413e9535b3f33a0e3dbacf2da63b8d3056c686a9df4146" dependencies = [ "async-std", "futures 0.3.5", @@ -2683,12 +2793,11 @@ dependencies = [ [[package]] name = "libp2p-websocket" -version = "0.19.0" +version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "085fbe4c05c4116c2164ab4d5a521eb6e00516c444f61b3ee9f68c7b1e53580b" +checksum = "7e4440551bf6519e0a684cd859ea809aec6d798f686e0d6ed03a28c3e76849b8" dependencies = [ "async-tls", - "bytes 0.5.4", "either", "futures 0.3.5", "libp2p-core", @@ -2704,9 +2813,9 @@ dependencies = [ [[package]] name = "libp2p-yamux" -version = "0.19.0" +version = "0.19.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b305d3a8981e68f11c0e17f2d11d5c52fae95e0d7c283f9e462b5b2dab413b2" +checksum = "8da33e7b5f49c75c6a8afb0b8d1e229f5fa48be9f39bd14cdbc21459a02ac6fc" dependencies = [ "futures 0.3.5", "libp2p-core", @@ -3014,7 +3123,7 @@ dependencies = [ "sha-1", "sha2", "sha3", - "unsigned-varint", + "unsigned-varint 0.3.3", ] [[package]] @@ -3025,16 +3134,16 @@ checksum = "d8883adfde9756c1d30b0f519c9b8c502a94b41ac62f696453c37c7fc0a958ce" [[package]] name = "multistream-select" -version = "0.8.1" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "991c33683908c588b8f2cf66c221d8f390818c1bdcd13fce55208408e027a796" +checksum = "c9157e87afbc2ef0d84cc0345423d715f445edde00141c93721c162de35a05e5" dependencies = [ "bytes 0.5.4", "futures 0.3.5", "log 0.4.8", "pin-project", "smallvec 1.4.0", - "unsigned-varint", + "unsigned-varint 0.4.0", ] [[package]] @@ -3266,7 +3375,7 @@ dependencies = [ [[package]] name = "pallet-authority-discovery" version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "frame-support", "frame-system", @@ -3282,7 +3391,7 @@ dependencies = [ [[package]] name = "pallet-authorship" version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "frame-support", "frame-system", @@ -3297,7 +3406,7 @@ dependencies = [ [[package]] name = "pallet-babe" version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "frame-support", "frame-system", @@ -3319,7 +3428,7 @@ dependencies = [ [[package]] name = "pallet-balances" version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "frame-benchmarking", "frame-support", @@ -3333,7 +3442,7 @@ dependencies = [ [[package]] name = "pallet-collective" version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "frame-benchmarking", "frame-support", @@ -3349,7 +3458,7 @@ dependencies = [ [[package]] name = "pallet-democracy" version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "frame-benchmarking", "frame-support", @@ -3364,7 +3473,7 @@ dependencies = [ [[package]] name = "pallet-elections-phragmen" version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "frame-benchmarking", "frame-support", @@ -3379,7 +3488,7 @@ dependencies = [ [[package]] name = "pallet-finality-tracker" version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "frame-support", "frame-system", @@ -3395,7 +3504,7 @@ dependencies = [ [[package]] name = "pallet-grandpa" version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "frame-support", "frame-system", @@ -3415,7 +3524,7 @@ dependencies = [ [[package]] name = "pallet-identity" version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "enumflags2", "frame-benchmarking", @@ -3431,7 +3540,7 @@ dependencies = [ [[package]] name = "pallet-im-online" version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "frame-benchmarking", "frame-support", @@ -3451,7 +3560,7 @@ dependencies = [ [[package]] name = "pallet-indices" version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "frame-support", "frame-system", @@ -3467,7 +3576,7 @@ dependencies = [ [[package]] name = "pallet-membership" version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "frame-support", "frame-system", @@ -3481,7 +3590,7 @@ dependencies = [ [[package]] name = "pallet-multisig" version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "frame-support", "frame-system", @@ -3496,7 +3605,7 @@ dependencies = [ [[package]] name = "pallet-nicks" version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "frame-support", "frame-system", @@ -3510,7 +3619,7 @@ dependencies = [ [[package]] name = "pallet-offences" version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "frame-support", "frame-system", @@ -3525,7 +3634,7 @@ dependencies = [ [[package]] name = "pallet-offences-benchmarking" version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "frame-benchmarking", "frame-support", @@ -3546,7 +3655,7 @@ dependencies = [ [[package]] name = "pallet-proxy" version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "frame-support", "frame-system", @@ -3561,7 +3670,7 @@ dependencies = [ [[package]] name = "pallet-randomness-collective-flip" version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "frame-support", "frame-system", @@ -3574,7 +3683,7 @@ dependencies = [ [[package]] name = "pallet-recovery" version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "enumflags2", "frame-support", @@ -3589,7 +3698,7 @@ dependencies = [ [[package]] name = "pallet-scheduler" version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "frame-benchmarking", "frame-support", @@ -3604,7 +3713,7 @@ dependencies = [ [[package]] name = "pallet-session" version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "frame-support", "frame-system", @@ -3624,7 +3733,7 @@ dependencies = [ [[package]] name = "pallet-session-benchmarking" version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "frame-benchmarking", "frame-support", @@ -3638,7 +3747,7 @@ dependencies = [ [[package]] name = "pallet-society" version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "frame-support", "frame-system", @@ -3652,7 +3761,7 @@ dependencies = [ [[package]] name = "pallet-staking" version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "frame-benchmarking", "frame-support", @@ -3674,7 +3783,7 @@ dependencies = [ [[package]] name = "pallet-staking-reward-curve" version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "proc-macro-crate", "proc-macro2 1.0.18", @@ -3685,7 +3794,7 @@ dependencies = [ [[package]] name = "pallet-sudo" version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "frame-support", "frame-system", @@ -3699,7 +3808,7 @@ dependencies = [ [[package]] name = "pallet-timestamp" version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "frame-benchmarking", "frame-support", @@ -3717,7 +3826,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment" version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "frame-support", "frame-system", @@ -3732,7 +3841,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment-rpc" version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "jsonrpc-core", "jsonrpc-core-client", @@ -3750,7 +3859,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment-rpc-runtime-api" version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "frame-support", "parity-scale-codec", @@ -3763,7 +3872,7 @@ dependencies = [ [[package]] name = "pallet-treasury" version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "frame-benchmarking", "frame-support", @@ -3778,7 +3887,7 @@ dependencies = [ [[package]] name = "pallet-utility" version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "frame-benchmarking", "frame-support", @@ -3794,7 +3903,7 @@ dependencies = [ [[package]] name = "pallet-vesting" version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "enumflags2", "frame-benchmarking", @@ -3834,15 +3943,15 @@ dependencies = [ "percent-encoding 2.1.0", "serde", "static_assertions", - "unsigned-varint", + "unsigned-varint 0.3.3", "url 2.1.1", ] [[package]] name = "parity-multiaddr" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12ca96399f4a01aa89c59220c4f52ac371940eb4e53e3ce990da796f364bdf69" +checksum = "cc20af3143a62c16e7c9e92ea5c6ae49f7d271d97d4d8fe73afc28f0514a3d0f" dependencies = [ "arrayref", "bs58", @@ -3852,7 +3961,7 @@ dependencies = [ "percent-encoding 2.1.0", "serde", "static_assertions", - "unsigned-varint", + "unsigned-varint 0.4.0", "url 2.1.1", ] @@ -3868,7 +3977,7 @@ dependencies = [ "sha-1", "sha2", "sha3", - "unsigned-varint", + "unsigned-varint 0.3.3", ] [[package]] @@ -4250,6 +4359,25 @@ dependencies = [ "wasm-timer", ] +[[package]] +name = "polkadot-network-bridge" +version = "0.1.0" +dependencies = [ + "assert_matches", + "futures 0.3.5", + "futures-timer 3.0.2", + "log 0.4.8", + "parity-scale-codec", + "parking_lot 0.10.2", + "polkadot-node-primitives", + "polkadot-node-subsystem", + "polkadot-primitives", + "polkadot-subsystem-test-helpers", + "sc-network", + "sp-runtime", + "streamunordered", +] + [[package]] name = "polkadot-network-test" version = "0.8.13" @@ -4272,9 +4400,21 @@ dependencies = [ ] [[package]] -name = "polkadot-node-messages" +name = "polkadot-node-primitives" version = "0.1.0" dependencies = [ + "async-trait", + "parity-scale-codec", + "polkadot-primitives", + "polkadot-statement-table", + "sp-runtime", +] + +[[package]] +name = "polkadot-node-subsystem" +version = "0.1.0" +dependencies = [ + "async-trait", "futures 0.3.5", "polkadot-node-primitives", "polkadot-primitives", @@ -4282,26 +4422,17 @@ dependencies = [ "sc-network", ] -[[package]] -name = "polkadot-node-primitives" -version = "0.1.0" -dependencies = [ - "parity-scale-codec", - "polkadot-primitives", - "polkadot-statement-table", - "sp-runtime", -] - [[package]] name = "polkadot-overseer" version = "0.1.0" dependencies = [ + "async-trait", "femme", "futures 0.3.5", "futures-timer 3.0.2", "kv-log-macro", "log 0.4.8", - "polkadot-node-messages", + "polkadot-node-subsystem", "polkadot-primitives", "sc-client-api", "streamunordered", @@ -4613,6 +4744,7 @@ dependencies = [ "parity-scale-codec", "parking_lot 0.9.0", "polkadot-network", + "polkadot-node-subsystem", "polkadot-overseer", "polkadot-primitives", "polkadot-rpc", @@ -4662,6 +4794,16 @@ dependencies = [ "sp-core", ] +[[package]] +name = "polkadot-subsystem-test-helpers" +version = "0.1.0" +dependencies = [ + "async-trait", + "futures 0.3.5", + "parking_lot 0.10.2", + "polkadot-node-subsystem", +] + [[package]] name = "polkadot-test-runtime" version = "0.8.13" @@ -4777,6 +4919,25 @@ dependencies = [ "tokio 0.2.21", ] +[[package]] +name = "poly1305" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5829f50f48e9ddb79f3f7c3097029d0caee30f8286accb241416df603b080b8" +dependencies = [ + "universal-hash", +] + +[[package]] +name = "polyval" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ec3341498978de3bfd12d1b22f1af1de22818f5473a11e8a6ef997989e3a212" +dependencies = [ + "cfg-if", + "universal-hash", +] + [[package]] name = "ppv-lite86" version = "0.2.8" @@ -5531,7 +5692,7 @@ dependencies = [ [[package]] name = "sc-authority-discovery" version = "0.8.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "bytes 0.5.4", "derive_more 0.99.8", @@ -5558,7 +5719,7 @@ dependencies = [ [[package]] name = "sc-basic-authorship" version = "0.8.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "futures 0.3.5", "futures-timer 3.0.2", @@ -5582,7 +5743,7 @@ dependencies = [ [[package]] name = "sc-block-builder" version = "0.8.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "parity-scale-codec", "sc-client-api", @@ -5598,7 +5759,7 @@ dependencies = [ [[package]] name = "sc-chain-spec" version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "impl-trait-for-tuples", "sc-chain-spec-derive", @@ -5614,7 +5775,7 @@ dependencies = [ [[package]] name = "sc-chain-spec-derive" version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "proc-macro-crate", "proc-macro2 1.0.18", @@ -5625,7 +5786,7 @@ dependencies = [ [[package]] name = "sc-cli" version = "0.8.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "ansi_term 0.12.1", "atty", @@ -5665,7 +5826,7 @@ dependencies = [ [[package]] name = "sc-client-api" version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "derive_more 0.99.8", "fnv", @@ -5701,7 +5862,7 @@ dependencies = [ [[package]] name = "sc-client-db" version = "0.8.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "blake2-rfc", "hash-db", @@ -5730,7 +5891,7 @@ dependencies = [ [[package]] name = "sc-consensus" version = "0.8.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "sc-client-api", "sp-blockchain", @@ -5741,7 +5902,7 @@ dependencies = [ [[package]] name = "sc-consensus-babe" version = "0.8.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "derive_more 0.99.8", "fork-tree", @@ -5783,7 +5944,7 @@ dependencies = [ [[package]] name = "sc-consensus-babe-rpc" version = "0.8.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "derive_more 0.99.8", "futures 0.3.5", @@ -5807,7 +5968,7 @@ dependencies = [ [[package]] name = "sc-consensus-epochs" version = "0.8.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "fork-tree", "parity-scale-codec", @@ -5820,7 +5981,7 @@ dependencies = [ [[package]] name = "sc-consensus-slots" version = "0.8.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "futures 0.3.5", "futures-timer 3.0.2", @@ -5842,7 +6003,7 @@ dependencies = [ [[package]] name = "sc-consensus-uncles" version = "0.8.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "log 0.4.8", "sc-client-api", @@ -5856,7 +6017,7 @@ dependencies = [ [[package]] name = "sc-executor" version = "0.8.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "derive_more 0.99.8", "lazy_static", @@ -5884,7 +6045,7 @@ dependencies = [ [[package]] name = "sc-executor-common" version = "0.8.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "derive_more 0.99.8", "log 0.4.8", @@ -5901,7 +6062,7 @@ dependencies = [ [[package]] name = "sc-executor-wasmi" version = "0.8.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "log 0.4.8", "parity-scale-codec", @@ -5916,7 +6077,7 @@ dependencies = [ [[package]] name = "sc-executor-wasmtime" version = "0.8.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "cranelift-codegen", "cranelift-wasm", @@ -5937,7 +6098,7 @@ dependencies = [ [[package]] name = "sc-finality-grandpa" version = "0.8.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "assert_matches", "derive_more 0.99.8", @@ -5975,7 +6136,7 @@ dependencies = [ [[package]] name = "sc-finality-grandpa-rpc" version = "0.8.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "derive_more 0.99.8", "finality-grandpa", @@ -5992,7 +6153,7 @@ dependencies = [ [[package]] name = "sc-informant" version = "0.8.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "ansi_term 0.12.1", "futures 0.3.5", @@ -6011,7 +6172,7 @@ dependencies = [ [[package]] name = "sc-keystore" version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "derive_more 0.99.8", "hex", @@ -6027,7 +6188,7 @@ dependencies = [ [[package]] name = "sc-light" version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "hash-db", "lazy_static", @@ -6046,7 +6207,7 @@ dependencies = [ [[package]] name = "sc-network" version = "0.8.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "bitflags", "bs58", @@ -6058,7 +6219,7 @@ dependencies = [ "fork-tree", "futures 0.3.5", "futures-timer 3.0.2", - "futures_codec", + "futures_codec 0.3.4", "hex", "ip_network", "libp2p", @@ -6089,7 +6250,7 @@ dependencies = [ "sp-utils", "substrate-prometheus-endpoint", "thiserror", - "unsigned-varint", + "unsigned-varint 0.3.3", "void", "wasm-timer", "zeroize", @@ -6098,7 +6259,7 @@ dependencies = [ [[package]] name = "sc-network-gossip" version = "0.8.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "futures 0.3.5", "futures-timer 3.0.2", @@ -6113,7 +6274,7 @@ dependencies = [ [[package]] name = "sc-network-test" version = "0.8.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "env_logger", "futures 0.3.5", @@ -6140,7 +6301,7 @@ dependencies = [ [[package]] name = "sc-offchain" version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "bytes 0.5.4", "fnv", @@ -6167,7 +6328,7 @@ dependencies = [ [[package]] name = "sc-peerset" version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "futures 0.3.5", "libp2p", @@ -6180,7 +6341,7 @@ dependencies = [ [[package]] name = "sc-proposer-metrics" version = "0.8.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "log 0.4.8", "substrate-prometheus-endpoint", @@ -6189,7 +6350,7 @@ dependencies = [ [[package]] name = "sc-rpc" version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "futures 0.3.5", "hash-db", @@ -6221,7 +6382,7 @@ dependencies = [ [[package]] name = "sc-rpc-api" version = "0.8.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "derive_more 0.99.8", "futures 0.3.5", @@ -6245,7 +6406,7 @@ dependencies = [ [[package]] name = "sc-rpc-server" version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "jsonrpc-core", "jsonrpc-http-server", @@ -6261,7 +6422,7 @@ dependencies = [ [[package]] name = "sc-service" version = "0.8.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "derive_more 0.99.8", "directories", @@ -6324,7 +6485,7 @@ dependencies = [ [[package]] name = "sc-state-db" version = "0.8.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "log 0.4.8", "parity-scale-codec", @@ -6338,9 +6499,8 @@ dependencies = [ [[package]] name = "sc-telemetry" version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ - "bytes 0.5.4", "futures 0.3.5", "futures-timer 3.0.2", "libp2p", @@ -6360,7 +6520,7 @@ dependencies = [ [[package]] name = "sc-tracing" version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "erased-serde", "log 0.4.8", @@ -6377,7 +6537,7 @@ dependencies = [ [[package]] name = "sc-transaction-graph" version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "derive_more 0.99.8", "futures 0.3.5", @@ -6397,7 +6557,7 @@ dependencies = [ [[package]] name = "sc-transaction-pool" version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "derive_more 0.99.8", "futures 0.3.5", @@ -6589,12 +6749,6 @@ dependencies = [ "opaque-debug", ] -[[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" @@ -6733,13 +6887,13 @@ checksum = "c7cb5678e1615754284ec264d9bb5b4c27d2018577fd90ac0ceb578591ed5ee4" [[package]] name = "snow" -version = "0.6.2" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afb767eee7d257ba202f0b9b08673bc13b22281632ef45267b19f13100accd2f" +checksum = "ce0f91be479494dd92e69d9971bd23ed27037dd1c94fcf558f6c6e74e6afa654" dependencies = [ - "arrayref", - "blake2-rfc", - "chacha20-poly1305-aead", + "aes-gcm", + "blake2", + "chacha20poly1305", "rand 0.7.3", "rand_core 0.5.1", "ring", @@ -6763,28 +6917,24 @@ dependencies = [ [[package]] name = "soketto" -version = "0.3.2" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c9dab3f95c9ebdf3a88268c19af668f637a3c5039c2c56ff2d40b1b2d64a25b" +checksum = "85457366ae0c6ce56bf05a958aef14cd38513c236568618edbcd9a8c52cb80b0" dependencies = [ - "base64 0.11.0", + "base64 0.12.2", "bytes 0.5.4", "flate2", "futures 0.3.5", - "http 0.2.1", "httparse", "log 0.4.8", "rand 0.7.3", - "sha1", - "smallvec 1.4.0", - "static_assertions", - "thiserror", + "sha-1", ] [[package]] name = "sp-allocator" version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "derive_more 0.99.8", "log 0.4.8", @@ -6796,7 +6946,7 @@ dependencies = [ [[package]] name = "sp-api" version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "hash-db", "parity-scale-codec", @@ -6811,7 +6961,7 @@ dependencies = [ [[package]] name = "sp-api-proc-macro" version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "blake2-rfc", "proc-macro-crate", @@ -6823,7 +6973,7 @@ dependencies = [ [[package]] name = "sp-application-crypto" version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "parity-scale-codec", "serde", @@ -6835,7 +6985,7 @@ dependencies = [ [[package]] name = "sp-arithmetic" version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "integer-sqrt", "num-traits 0.2.12", @@ -6848,7 +6998,7 @@ dependencies = [ [[package]] name = "sp-authority-discovery" version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "parity-scale-codec", "sp-api", @@ -6860,7 +7010,7 @@ dependencies = [ [[package]] name = "sp-authorship" version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "parity-scale-codec", "sp-inherents", @@ -6871,7 +7021,7 @@ dependencies = [ [[package]] name = "sp-block-builder" version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "parity-scale-codec", "sp-api", @@ -6883,7 +7033,7 @@ dependencies = [ [[package]] name = "sp-blockchain" version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "derive_more 0.99.8", "log 0.4.8", @@ -6899,7 +7049,7 @@ dependencies = [ [[package]] name = "sp-chain-spec" version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "serde", "serde_json", @@ -6908,7 +7058,7 @@ dependencies = [ [[package]] name = "sp-consensus" version = "0.8.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "derive_more 0.99.8", "futures 0.3.5", @@ -6932,7 +7082,7 @@ dependencies = [ [[package]] name = "sp-consensus-aura" version = "0.8.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "parity-scale-codec", "sp-api", @@ -6946,7 +7096,7 @@ dependencies = [ [[package]] name = "sp-consensus-babe" version = "0.8.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "merlin", "parity-scale-codec", @@ -6964,7 +7114,7 @@ dependencies = [ [[package]] name = "sp-consensus-vrf" version = "0.8.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "parity-scale-codec", "schnorrkel", @@ -6976,7 +7126,7 @@ dependencies = [ [[package]] name = "sp-core" version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "base58", "blake2-rfc", @@ -7018,7 +7168,7 @@ dependencies = [ [[package]] name = "sp-database" version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "kvdb", "parking_lot 0.10.2", @@ -7027,7 +7177,7 @@ dependencies = [ [[package]] name = "sp-debug-derive" version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "proc-macro2 1.0.18", "quote 1.0.7", @@ -7037,7 +7187,7 @@ dependencies = [ [[package]] name = "sp-externalities" version = "0.8.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "environmental", "parity-scale-codec", @@ -7048,7 +7198,7 @@ dependencies = [ [[package]] name = "sp-finality-grandpa" version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "finality-grandpa", "log 0.4.8", @@ -7064,7 +7214,7 @@ dependencies = [ [[package]] name = "sp-finality-tracker" version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "parity-scale-codec", "sp-inherents", @@ -7074,7 +7224,7 @@ dependencies = [ [[package]] name = "sp-inherents" version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "derive_more 0.99.8", "parity-scale-codec", @@ -7086,7 +7236,7 @@ dependencies = [ [[package]] name = "sp-io" version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "futures 0.3.5", "hash-db", @@ -7107,7 +7257,7 @@ dependencies = [ [[package]] name = "sp-keyring" version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "lazy_static", "sp-core", @@ -7118,7 +7268,7 @@ dependencies = [ [[package]] name = "sp-npos-elections" version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "parity-scale-codec", "serde", @@ -7130,7 +7280,7 @@ dependencies = [ [[package]] name = "sp-npos-elections-compact" version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "proc-macro-crate", "proc-macro2 1.0.18", @@ -7141,7 +7291,7 @@ dependencies = [ [[package]] name = "sp-offchain" version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "sp-api", "sp-core", @@ -7151,7 +7301,7 @@ dependencies = [ [[package]] name = "sp-panic-handler" version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "backtrace", "log 0.4.8", @@ -7160,7 +7310,7 @@ dependencies = [ [[package]] name = "sp-rpc" version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "serde", "sp-core", @@ -7169,7 +7319,7 @@ dependencies = [ [[package]] name = "sp-runtime" version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "either", "hash256-std-hasher", @@ -7191,7 +7341,7 @@ dependencies = [ [[package]] name = "sp-runtime-interface" version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "parity-scale-codec", "primitive-types", @@ -7206,7 +7356,7 @@ dependencies = [ [[package]] name = "sp-runtime-interface-proc-macro" version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "Inflector", "proc-macro-crate", @@ -7218,7 +7368,7 @@ dependencies = [ [[package]] name = "sp-serializer" version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "serde", "serde_json", @@ -7227,7 +7377,7 @@ dependencies = [ [[package]] name = "sp-session" version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "parity-scale-codec", "sp-api", @@ -7240,7 +7390,7 @@ dependencies = [ [[package]] name = "sp-staking" version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "parity-scale-codec", "sp-runtime", @@ -7250,7 +7400,7 @@ dependencies = [ [[package]] name = "sp-state-machine" version = "0.8.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "hash-db", "itertools 0.9.0", @@ -7271,12 +7421,12 @@ dependencies = [ [[package]] name = "sp-std" version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" [[package]] name = "sp-storage" version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "impl-serde 0.2.3", "ref-cast", @@ -7288,7 +7438,7 @@ dependencies = [ [[package]] name = "sp-timestamp" version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "impl-trait-for-tuples", "parity-scale-codec", @@ -7302,7 +7452,7 @@ dependencies = [ [[package]] name = "sp-tracing" version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "log 0.4.8", "rental", @@ -7312,7 +7462,7 @@ dependencies = [ [[package]] name = "sp-transaction-pool" version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "derive_more 0.99.8", "futures 0.3.5", @@ -7328,7 +7478,7 @@ dependencies = [ [[package]] name = "sp-trie" version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "hash-db", "memory-db", @@ -7342,7 +7492,7 @@ dependencies = [ [[package]] name = "sp-utils" version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "futures 0.3.5", "futures-core", @@ -7354,7 +7504,7 @@ dependencies = [ [[package]] name = "sp-version" version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "impl-serde 0.2.3", "parity-scale-codec", @@ -7366,7 +7516,7 @@ dependencies = [ [[package]] name = "sp-wasm-interface" version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "impl-trait-for-tuples", "parity-scale-codec", @@ -7401,6 +7551,15 @@ dependencies = [ "rand 0.5.6", ] +[[package]] +name = "stream-cipher" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8131256a5896cabcf5eb04f4d6dacbe1aefda854b0d9896e09cb58829ec5638c" +dependencies = [ + "generic-array", +] + [[package]] name = "streamunordered" version = "0.5.1" @@ -7497,7 +7656,7 @@ dependencies = [ [[package]] name = "substrate-browser-utils" version = "0.8.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "chrono", "clear_on_drop", @@ -7524,7 +7683,7 @@ dependencies = [ [[package]] name = "substrate-build-script-utils" version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "platforms", ] @@ -7532,7 +7691,7 @@ dependencies = [ [[package]] name = "substrate-frame-rpc-system" version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "frame-system-rpc-runtime-api", "futures 0.3.5", @@ -7555,7 +7714,7 @@ dependencies = [ [[package]] name = "substrate-prometheus-endpoint" version = "0.8.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "async-std", "derive_more 0.99.8", @@ -7569,7 +7728,7 @@ dependencies = [ [[package]] name = "substrate-test-client" version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "futures 0.3.5", "hash-db", @@ -7591,7 +7750,7 @@ dependencies = [ [[package]] name = "substrate-test-runtime" version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "cfg-if", "frame-executive", @@ -7631,7 +7790,7 @@ dependencies = [ [[package]] name = "substrate-test-runtime-client" version = "2.0.0-rc4" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" dependencies = [ "futures 0.3.5", "parity-scale-codec", @@ -7652,7 +7811,7 @@ dependencies = [ [[package]] name = "substrate-wasm-builder-runner" version = "1.0.6" -source = "git+https://github.com/paritytech/substrate#93a6a53061b9ecb8660c291ab43d083cf51c1f89" +source = "git+https://github.com/paritytech/substrate#e8f901868997be15635cba9b21a99b212009adc8" [[package]] name = "substrate-wasm-builder-runner" @@ -8504,6 +8663,16 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" +[[package]] +name = "universal-hash" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df0c900f2f9b4116803415878ff48b63da9edb268668e08cf9292d7503114a01" +dependencies = [ + "generic-array", + "subtle 2.2.3", +] + [[package]] name = "unsigned-varint" version = "0.3.3" @@ -8513,7 +8682,17 @@ dependencies = [ "bytes 0.5.4", "futures-io", "futures-util", - "futures_codec", + "futures_codec 0.3.4", +] + +[[package]] +name = "unsigned-varint" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "669d776983b692a906c881fcd0cfb34271a48e197e4d6cb8df32b05bfc3d3fa5" +dependencies = [ + "bytes 0.5.4", + "futures_codec 0.4.1", ] [[package]] diff --git a/polkadot/Cargo.toml b/polkadot/Cargo.toml index 34f9f14e4e..4a72ae8dc6 100644 --- a/polkadot/Cargo.toml +++ b/polkadot/Cargo.toml @@ -42,10 +42,12 @@ members = [ "service", "validation", - "node/messages", + "node/network/bridge", "node/overseer", "node/primitives", "node/service", + "node/subsystem", + "node/test-helpers/subsystem", "parachain/test-parachains", "parachain/test-parachains/adder", diff --git a/polkadot/cli/src/browser.rs b/polkadot/cli/src/browser.rs index 6f3a400084..becd340530 100644 --- a/polkadot/cli/src/browser.rs +++ b/polkadot/cli/src/browser.rs @@ -46,8 +46,8 @@ async fn start_inner(chain_spec: String, log_level: String) -> Result Option { @@ -75,6 +74,16 @@ impl SubstrateCli for Cli { path => Box::new(service::PolkadotChainSpec::from_json_file(std::path::PathBuf::from(path))?), }) } + + fn native_runtime_version(spec: &Box) -> &'static RuntimeVersion { + if spec.is_kusama() { + &service::kusama_runtime::VERSION + } else if spec.is_westend() { + &service::westend_runtime::VERSION + } else { + &service::polkadot_runtime::VERSION + } + } } /// Parses polkadot specific CLI arguments and run the service. @@ -116,56 +125,44 @@ pub fn run() -> Result<()> { info!(" KUSAMA FOUNDATION "); info!("----------------------------"); - runtime.run_node( - |config| { - service::kusama_new_light(config) - }, - |config| { - service::kusama_new_full( - config, - None, - None, - authority_discovery_enabled, - 6000, - grandpa_pause, - ).map(|(s, _, _)| s) - }, - service::KusamaExecutor::native_version().runtime_version - ) + runtime.run_node_until_exit(|config| match config.role { + Role::Light => service::kusama_new_light(config) + .map(|(components, _)| components), + _ => service::kusama_new_full( + config, + None, + None, + authority_discovery_enabled, + 6000, + grandpa_pause, + ).map(|(components, _, _)| components) + }) } else if chain_spec.is_westend() { - runtime.run_node( - |config| { - service::westend_new_light(config) - }, - |config| { - service::westend_new_full( - config, - None, - None, - authority_discovery_enabled, - 6000, - grandpa_pause, - ).map(|(s, _, _)| s) - }, - service::WestendExecutor::native_version().runtime_version - ) + runtime.run_node_until_exit(|config| match config.role { + Role::Light => service::westend_new_light(config) + .map(|(components, _)| components), + _ => service::westend_new_full( + config, + None, + None, + authority_discovery_enabled, + 6000, + grandpa_pause, + ).map(|(components, _, _)| components) + }) } else { - runtime.run_node( - |config| { - service::polkadot_new_light(config) - }, - |config| { - service::polkadot_new_full( - config, - None, - None, - authority_discovery_enabled, - 6000, - grandpa_pause, - ).map(|(s, _, _)| s) - }, - service::PolkadotExecutor::native_version().runtime_version - ) + runtime.run_node_until_exit(|config| match config.role { + Role::Light => service::polkadot_new_light(config) + .map(|(components, _)| components), + _ => service::polkadot_new_full( + config, + None, + None, + authority_discovery_enabled, + 6000, + grandpa_pause, + ).map(|(components, _, _)| components) + }) } }, Some(Subcommand::Base(subcommand)) => { diff --git a/polkadot/cli/src/lib.rs b/polkadot/cli/src/lib.rs index be2f3c6cd6..385a24d364 100644 --- a/polkadot/cli/src/lib.rs +++ b/polkadot/cli/src/lib.rs @@ -28,14 +28,14 @@ mod command; #[cfg(not(feature = "service-rewr"))] pub use service::{ - AbstractService, ProvideRuntimeApi, CoreApi, ParachainHost, IdentifyVariant, + ProvideRuntimeApi, CoreApi, ParachainHost, IdentifyVariant, Block, self, RuntimeApiCollection, TFullClient }; #[cfg(feature = "service-rewr")] pub use service_new::{ self as service, - AbstractService, ProvideRuntimeApi, CoreApi, ParachainHost, IdentifyVariant, + ProvideRuntimeApi, CoreApi, ParachainHost, IdentifyVariant, Block, self, RuntimeApiCollection, TFullClient }; diff --git a/polkadot/collator/src/lib.rs b/polkadot/collator/src/lib.rs index 063bdb1735..f790d70557 100644 --- a/polkadot/collator/src/lib.rs +++ b/polkadot/collator/src/lib.rs @@ -63,7 +63,7 @@ use polkadot_primitives::{ } }; use polkadot_cli::{ - ProvideRuntimeApi, AbstractService, ParachainHost, IdentifyVariant, + ProvideRuntimeApi, ParachainHost, IdentifyVariant, service::{self, Role} }; pub use polkadot_cli::service::Configuration; @@ -81,6 +81,7 @@ use polkadot_service_new::{ self as polkadot_service, Error as ServiceError, FullNodeHandles, PolkadotClient, }; +use sc_service::SpawnTaskHandle; const COLLATION_TIMEOUT: Duration = Duration::from_secs(30); @@ -236,8 +237,8 @@ fn build_collator_service( #[cfg(not(feature = "service-rewr"))] -fn build_collator_service( - spawner: SP, +fn build_collator_service( + spawner: SpawnTaskHandle, handles: FullNodeHandles, client: Arc, para_id: ParaId, @@ -265,7 +266,6 @@ fn build_collator_service( P::ParachainContext: Send + 'static, ::ProduceCandidate: Send, Extrinsic: service::Codec + Send + Sync + 'static, - SP: Spawn + Clone + Send + Sync + 'static, { let polkadot_network = handles.polkadot_network .ok_or_else(|| "Collator cannot run when Polkadot-specific networking has not been started")?; @@ -278,7 +278,7 @@ fn build_collator_service( let parachain_context = match build_parachain_context.build( client.clone(), - spawner, + spawner.clone(), polkadot_network.clone(), ) { Ok(ctx) => ctx, @@ -359,7 +359,7 @@ fn build_collator_service( let future = silenced.map(drop); - tokio::spawn(future); + spawner.spawn("collation-work", future); } }.boxed(); @@ -386,7 +386,7 @@ where } if config.chain_spec.is_kusama() { - let (service, client, handlers) = service::kusama_new_full( + let (task_manager, client, handlers) = service::kusama_new_full( config, Some((key.public(), para_id)), None, @@ -394,7 +394,7 @@ where 6000, None, )?; - let spawn_handle = service.spawn_task_handle(); + let spawn_handle = task_manager.spawn_handle(); build_collator_service( spawn_handle, handlers, @@ -404,7 +404,7 @@ where build_parachain_context )?.await; } else if config.chain_spec.is_westend() { - let (service, client, handlers) = service::westend_new_full( + let (task_manager, client, handlers) = service::westend_new_full( config, Some((key.public(), para_id)), None, @@ -412,7 +412,7 @@ where 6000, None, )?; - let spawn_handle = service.spawn_task_handle(); + let spawn_handle = task_manager.spawn_handle(); build_collator_service( spawn_handle, handlers, @@ -422,7 +422,7 @@ where build_parachain_context )?.await; } else { - let (service, client, handles) = service::polkadot_new_full( + let (task_manager, client, handles) = service::polkadot_new_full( config, Some((key.public(), para_id)), None, @@ -430,7 +430,7 @@ where 6000, None, )?; - let spawn_handle = service.spawn_task_handle(); + let spawn_handle = task_manager.spawn_handle(); build_collator_service( spawn_handle, handles, diff --git a/polkadot/network/test/src/block_import.rs b/polkadot/network/test/src/block_import.rs index ce4c9f8ba0..ec848609cd 100644 --- a/polkadot/network/test/src/block_import.rs +++ b/polkadot/network/test/src/block_import.rs @@ -60,7 +60,7 @@ fn import_single_good_block_works() { let mut expected_aux = ImportedAux::default(); expected_aux.is_new_best = true; - match import_single_block(&mut polkadot_test_runtime_client::new(), BlockOrigin::File, block, &mut PassThroughVerifier(true)) { + match import_single_block(&mut polkadot_test_runtime_client::new(), BlockOrigin::File, block, &mut PassThroughVerifier::new(true)) { Ok(BlockImportResult::ImportedUnknown(ref num, ref aux, ref org)) if *num == number as u32 && *aux == expected_aux && *org == Some(peer_id) => {} r @ _ => panic!("{:?}", r) @@ -70,7 +70,7 @@ fn import_single_good_block_works() { #[test] fn import_single_good_known_block_is_ignored() { let (mut client, _hash, number, _, block) = prepare_good_block(); - match import_single_block(&mut client, BlockOrigin::File, block, &mut PassThroughVerifier(true)) { + match import_single_block(&mut client, BlockOrigin::File, block, &mut PassThroughVerifier::new(true)) { Ok(BlockImportResult::ImportedKnown(ref n)) if *n == number as u32 => {} _ => panic!() } @@ -80,7 +80,7 @@ fn import_single_good_known_block_is_ignored() { fn import_single_good_block_without_header_fails() { let (_, _, _, peer_id, mut block) = prepare_good_block(); block.header = None; - match import_single_block(&mut polkadot_test_runtime_client::new(), BlockOrigin::File, block, &mut PassThroughVerifier(true)) { + match import_single_block(&mut polkadot_test_runtime_client::new(), BlockOrigin::File, block, &mut PassThroughVerifier::new(true)) { Err(BlockImportError::IncompleteHeader(ref org)) if *org == Some(peer_id) => {} _ => panic!() } @@ -91,7 +91,7 @@ fn async_import_queue_drops() { let executor = sp_core::testing::SpawnBlockingExecutor::new(); // Perform this test multiple times since it exhibits non-deterministic behavior. for _ in 0..100 { - let verifier = PassThroughVerifier(true); + let verifier = PassThroughVerifier::new(true); let queue = BasicQueue::new( verifier, diff --git a/polkadot/network/test/src/lib.rs b/polkadot/network/test/src/lib.rs index c48bfabdfb..f8afc4fb0c 100644 --- a/polkadot/network/test/src/lib.rs +++ b/polkadot/network/test/src/lib.rs @@ -600,7 +600,7 @@ pub trait TestNetFactory: Sized { transaction_pool: Arc::new(EmptyTransactionPool), protocol_id: ProtocolId::from(&b"test-protocol-name"[..]), import_queue, - block_announce_validator: Box::new(DefaultBlockAnnounceValidator::new(client.clone())), + block_announce_validator: Box::new(DefaultBlockAnnounceValidator), metrics_registry: None, }).unwrap(); @@ -677,7 +677,7 @@ pub trait TestNetFactory: Sized { transaction_pool: Arc::new(EmptyTransactionPool), protocol_id: ProtocolId::from(&b"test-protocol-name"[..]), import_queue, - block_announce_validator: Box::new(DefaultBlockAnnounceValidator::new(client.clone())), + block_announce_validator: Box::new(DefaultBlockAnnounceValidator), metrics_registry: None, }).unwrap(); @@ -804,7 +804,7 @@ impl TestNetFactory for TestNet { fn make_verifier(&self, _client: PeersClient, _config: &ProtocolConfig, _peer_data: &()) -> Self::Verifier { - PassThroughVerifier(false) + PassThroughVerifier::new(false) } fn peer(&mut self, i: usize) -> &mut Peer<()> { diff --git a/polkadot/node/network/bridge/Cargo.toml b/polkadot/node/network/bridge/Cargo.toml new file mode 100644 index 0000000000..4f6c8631e2 --- /dev/null +++ b/polkadot/node/network/bridge/Cargo.toml @@ -0,0 +1,22 @@ +[package] +name = "polkadot-network-bridge" +version = "0.1.0" +authors = ["Parity Technologies "] +edition = "2018" + +[dependencies] +futures = "0.3.5" +log = "0.4.8" +futures-timer = "3.0.2" +streamunordered = "0.5.1" +polkadot-primitives = { path = "../../../primitives" } +node-primitives = { package = "polkadot-node-primitives", path = "../../primitives" } +parity-scale-codec = "1.3.0" +sc-network = { git = "https://github.com/paritytech/substrate", branch = "master" } +sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master" } +polkadot-subsystem = { package = "polkadot-node-subsystem", path = "../../subsystem" } + +[dev-dependencies] +parking_lot = "0.10.0" +subsystem-test = { package = "polkadot-subsystem-test-helpers", path = "../../test-helpers/subsystem" } +assert_matches = "1.3.0" diff --git a/polkadot/node/network/bridge/src/lib.rs b/polkadot/node/network/bridge/src/lib.rs new file mode 100644 index 0000000000..6f90779afe --- /dev/null +++ b/polkadot/node/network/bridge/src/lib.rs @@ -0,0 +1,904 @@ +// Copyright 2020 Parity Technologies (UK) Ltd. +// This file is part of Polkadot. + +// Polkadot 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. + +// Polkadot 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 Polkadot. If not, see . + +//! The Network Bridge Subsystem - protocol multiplexer for Polkadot. + +use parity_scale_codec::{Encode, Decode}; +use futures::prelude::*; +use futures::future::BoxFuture; +use futures::stream::BoxStream; + +use sc_network::{ + ObservedRole, ReputationChange, PeerId, + Event as NetworkEvent, +}; +use sp_runtime::ConsensusEngineId; + +use polkadot_subsystem::{ + FromOverseer, OverseerSignal, Subsystem, SubsystemContext, SpawnedSubsystem, SubsystemError, + SubsystemResult, +}; +use polkadot_subsystem::messages::{NetworkBridgeEvent, NetworkBridgeMessage, AllMessages}; +use node_primitives::{ProtocolId, View}; +use polkadot_primitives::{Block, Hash}; + +use std::collections::btree_map::{BTreeMap, Entry as BEntry}; +use std::collections::hash_map::{HashMap, Entry as HEntry}; +use std::pin::Pin; +use std::sync::Arc; + +/// The maximum amount of heads a peer is allowed to have in their view at any time. +/// +/// We use the same limit to compute the view sent to peers locally. +const MAX_VIEW_HEADS: usize = 5; + +/// The engine ID of the polkadot network protocol. +pub const POLKADOT_ENGINE_ID: ConsensusEngineId = *b"dot2"; +/// The protocol name. +pub const POLKADOT_PROTOCOL_NAME: &[u8] = b"/polkadot/2"; + +const MALFORMED_MESSAGE_COST: ReputationChange + = ReputationChange::new(-500, "Malformed Network-bridge message"); +const UNKNOWN_PROTO_COST: ReputationChange + = ReputationChange::new(-50, "Message sent to unknown protocol"); +const MALFORMED_VIEW_COST: ReputationChange + = ReputationChange::new(-500, "Malformed view"); + +/// Messages received on the network. +#[derive(Debug, Encode, Decode, Clone)] +pub enum WireMessage { + /// A message from a peer on a specific protocol. + #[codec(index = "1")] + ProtocolMessage(ProtocolId, Vec), + /// A view update from a peer. + #[codec(index = "2")] + ViewUpdate(View), +} + +/// Information about the notifications protocol. Should be used during network configuration +/// or shortly after startup to register the protocol with the network service. +pub fn notifications_protocol_info() -> (ConsensusEngineId, std::borrow::Cow<'static, [u8]>) { + (POLKADOT_ENGINE_ID, POLKADOT_PROTOCOL_NAME.into()) +} + +/// An action to be carried out by the network. +#[derive(PartialEq)] +pub enum NetworkAction { + /// Note a change in reputation for a peer. + ReputationChange(PeerId, ReputationChange), + /// Write a notification to a given peer. + WriteNotification(PeerId, Vec), +} + +/// An abstraction over networking for the purposes of this subsystem. +pub trait Network: Send + 'static { + /// Get a stream of all events occurring on the network. This may include events unrelated + /// to the Polkadot protocol - the user of this function should filter only for events related + /// to the [`POLKADOT_ENGINE_ID`](POLKADOT_ENGINE_ID). + fn event_stream(&mut self) -> BoxStream<'static, NetworkEvent>; + + /// Get access to an underlying sink for all network actions. + fn action_sink<'a>(&'a mut self) -> Pin< + Box + Send + 'a> + >; + + /// Report a given peer as either beneficial (+) or costly (-) according to the given scalar. + fn report_peer(&mut self, who: PeerId, cost_benefit: ReputationChange) + -> BoxFuture> + { + async move { + self.action_sink().send(NetworkAction::ReputationChange(who, cost_benefit)).await + }.boxed() + } + + /// Write a notification to a peer on the [`POLKADOT_ENGINE_ID`](POLKADOT_ENGINE_ID) topic. + fn write_notification(&mut self, who: PeerId, message: Vec) + -> BoxFuture> + { + async move { + self.action_sink().send(NetworkAction::WriteNotification(who, message)).await + }.boxed() + } +} + +impl Network for Arc> { + fn event_stream(&mut self) -> BoxStream<'static, NetworkEvent> { + sc_network::NetworkService::event_stream(self, "polkadot-network-bridge").boxed() + } + + fn action_sink<'a>(&'a mut self) + -> Pin + Send + 'a>> + { + use futures::task::{Poll, Context}; + + // wrapper around a NetworkService to make it act like a sink. + struct ActionSink<'b>(&'b sc_network::NetworkService); + + impl<'b> Sink for ActionSink<'b> { + type Error = SubsystemError; + + fn poll_ready(self: Pin<&mut Self>, _: &mut Context) -> Poll> { + Poll::Ready(Ok(())) + } + + fn start_send(self: Pin<&mut Self>, action: NetworkAction) -> SubsystemResult<()> { + match action { + NetworkAction::ReputationChange(peer, cost_benefit) => self.0.report_peer( + peer, + cost_benefit, + ), + NetworkAction::WriteNotification(peer, message) => self.0.write_notification( + peer, + POLKADOT_ENGINE_ID, + message, + ), + } + + Ok(()) + } + + fn poll_flush(self: Pin<&mut Self>, _: &mut Context) -> Poll> { + Poll::Ready(Ok(())) + } + + fn poll_close(self: Pin<&mut Self>, _: &mut Context) -> Poll> { + Poll::Ready(Ok(())) + } + } + + Box::pin(ActionSink(&**self)) + } +} + +/// The network bridge subsystem. +pub struct NetworkBridge(N); + +impl NetworkBridge { + /// Create a new network bridge subsystem with underlying network service. + /// + /// This assumes that the network service has had the notifications protocol for the network + /// bridge already registered. See [`notifications_protocol_info`](notifications_protocol_info). + pub fn new(net_service: N) -> Self { + NetworkBridge(net_service) + } +} + +impl Subsystem for NetworkBridge + where + Net: Network, + Context: SubsystemContext, +{ + fn start(self, ctx: Context) -> SpawnedSubsystem { + // Swallow error because failure is fatal to the node and we log with more precision + // within `run_network`. + SpawnedSubsystem(run_network(self.0, ctx).map(|_| ()).boxed()) + } +} + +struct PeerData { + /// Latest view sent by the peer. + view: View, + /// The role of the peer. + role: ObservedRole, +} + +#[derive(Debug)] +enum Action { + RegisterEventProducer(ProtocolId, fn(NetworkBridgeEvent) -> AllMessages), + SendMessage(Vec, ProtocolId, Vec), + ReportPeer(PeerId, ReputationChange), + StartWork(Hash), + StopWork(Hash), + + PeerConnected(PeerId, ObservedRole), + PeerDisconnected(PeerId), + PeerMessages(PeerId, Vec), + + Abort, +} + +fn action_from_overseer_message( + res: polkadot_subsystem::SubsystemResult>, +) -> Action { + match res { + Ok(FromOverseer::Signal(OverseerSignal::StartWork(relay_parent))) + => Action::StartWork(relay_parent), + Ok(FromOverseer::Signal(OverseerSignal::StopWork(relay_parent))) + => Action::StopWork(relay_parent), + Ok(FromOverseer::Signal(OverseerSignal::Conclude)) => Action::Abort, + Ok(FromOverseer::Communication { msg }) => match msg { + NetworkBridgeMessage::RegisterEventProducer(protocol_id, message_producer) + => Action::RegisterEventProducer(protocol_id, message_producer), + NetworkBridgeMessage::ReportPeer(peer, rep) => Action::ReportPeer(peer, rep), + NetworkBridgeMessage::SendMessage(peers, protocol, message) + => Action::SendMessage(peers, protocol, message), + }, + Err(e) => { + log::warn!("Shutting down Network Bridge due to error {:?}", e); + Action::Abort + } + } +} + +fn action_from_network_message(event: Option) -> Option { + match event { + None => { + log::info!("Shutting down Network Bridge: underlying event stream concluded"); + Some(Action::Abort) + } + Some(NetworkEvent::Dht(_)) => None, + Some(NetworkEvent::NotificationStreamOpened { remote, engine_id, role }) => { + if engine_id == POLKADOT_ENGINE_ID { + Some(Action::PeerConnected(remote, role)) + } else { + None + } + } + Some(NetworkEvent::NotificationStreamClosed { remote, engine_id }) => { + if engine_id == POLKADOT_ENGINE_ID { + Some(Action::PeerDisconnected(remote)) + } else { + None + } + } + Some(NetworkEvent::NotificationsReceived { remote, messages }) => { + let v: Result, _> = messages.iter() + .filter(|(engine_id, _)| engine_id == &POLKADOT_ENGINE_ID) + .map(|(_, msg_bytes)| WireMessage::decode(&mut msg_bytes.as_ref())) + .collect(); + + match v { + Err(_) => Some(Action::ReportPeer(remote, MALFORMED_MESSAGE_COST)), + Ok(v) => if v.is_empty() { + None + } else { + Some(Action::PeerMessages(remote, v)) + } + } + } + } +} + +fn construct_view(live_heads: &[Hash]) -> View { + View(live_heads.iter().rev().take(MAX_VIEW_HEADS).cloned().collect()) +} + +async fn dispatch_update_to_all( + update: NetworkBridgeEvent, + event_producers: impl IntoIterator AllMessages>, + ctx: &mut impl SubsystemContext, +) -> polkadot_subsystem::SubsystemResult<()> { + // collect messages here to avoid the borrow lasting across await boundary. + let messages: Vec<_> = event_producers.into_iter() + .map(|producer| producer(update.clone())) + .collect(); + + ctx.send_messages(messages).await +} + +async fn update_view( + peers: &HashMap, + live_heads: &[Hash], + net: &mut impl Network, + local_view: &mut View, +) -> SubsystemResult> { + let new_view = construct_view(live_heads); + if *local_view == new_view { return Ok(None) } + *local_view = new_view.clone(); + + let message = WireMessage::ViewUpdate(new_view.clone()).encode(); + + let notifications = peers.keys().cloned() + .map(move |peer| Ok(NetworkAction::WriteNotification(peer, message.clone()))); + + net.action_sink().send_all(&mut stream::iter(notifications)).await?; + + Ok(Some(NetworkBridgeEvent::OurViewChange(local_view.clone()))) +} + +async fn run_network( + mut net: N, + mut ctx: impl SubsystemContext, +) -> SubsystemResult<()> { + let mut event_stream = net.event_stream().fuse(); + + // Most recent heads are at the back. + let mut live_heads = Vec::with_capacity(MAX_VIEW_HEADS); + let mut local_view = View(Vec::new()); + + let mut peers: HashMap = HashMap::new(); + let mut event_producers = BTreeMap::new(); + + loop { + let action = { + let subsystem_next = ctx.recv().fuse(); + let mut net_event_next = event_stream.next().fuse(); + futures::pin_mut!(subsystem_next); + + let action = futures::select! { + subsystem_msg = subsystem_next => Some(action_from_overseer_message(subsystem_msg)), + net_event = net_event_next => action_from_network_message(net_event), + }; + + match action { + Some(a) => a, + None => continue, + } + }; + + match action { + Action::RegisterEventProducer(protocol_id, event_producer) => { + // insert only if none present. + if let BEntry::Vacant(entry) = event_producers.entry(protocol_id) { + let event_producer = entry.insert(event_producer); + + // send the event producer information on all connected peers. + let mut messages = Vec::with_capacity(peers.len() * 2); + for (peer, data) in &peers { + messages.push(event_producer( + NetworkBridgeEvent::PeerConnected(peer.clone(), data.role.clone()) + )); + + messages.push(event_producer( + NetworkBridgeEvent::PeerViewChange(peer.clone(), data.view.clone()) + )); + } + + ctx.send_messages(messages).await?; + } + } + Action::SendMessage(peers, protocol, message) => { + let mut message_producer = stream::iter({ + let n_peers = peers.len(); + let mut message = Some( + WireMessage::ProtocolMessage(protocol, message).encode() + ); + + peers.iter().cloned().enumerate().map(move |(i, peer)| { + // optimization: avoid cloning the message for the last peer in the + // list. The message payload can be quite large. If the underlying + // network used `Bytes` this would not be necessary. + let message = if i == n_peers - 1 { + message.take() + .expect("Only taken in last iteration of loop, never afterwards; qed") + } else { + message.as_ref() + .expect("Only taken in last iteration of loop, we are not there yet; qed") + .clone() + }; + + Ok(NetworkAction::WriteNotification(peer, message)) + }) + }); + + net.action_sink().send_all(&mut message_producer).await?; + } + Action::ReportPeer(peer, rep) => { + net.report_peer(peer, rep).await?; + } + Action::StartWork(relay_parent) => { + live_heads.push(relay_parent); + if let Some(view_update) + = update_view(&peers, &live_heads, &mut net, &mut local_view).await? + { + if let Err(e) = dispatch_update_to_all( + view_update, + event_producers.values(), + &mut ctx, + ).await { + log::warn!("Aborting - Failure to dispatch messages to overseer"); + return Err(e) + } + } + } + Action::StopWork(relay_parent) => { + live_heads.retain(|h| h != &relay_parent); + if let Some(view_update) + = update_view(&peers, &live_heads, &mut net, &mut local_view).await? + { + if let Err(e) = dispatch_update_to_all( + view_update, + event_producers.values(), + &mut ctx, + ).await { + log::warn!("Aborting - Failure to dispatch messages to overseer"); + return Err(e) + } + } + } + + Action::PeerConnected(peer, role) => { + match peers.entry(peer.clone()) { + HEntry::Occupied(_) => continue, + HEntry::Vacant(vacant) => { + vacant.insert(PeerData { + view: View(Vec::new()), + role: role.clone(), + }); + + if let Err(e) = dispatch_update_to_all( + NetworkBridgeEvent::PeerConnected(peer, role), + event_producers.values(), + &mut ctx, + ).await { + log::warn!("Aborting - Failure to dispatch messages to overseer"); + return Err(e) + } + } + } + } + Action::PeerDisconnected(peer) => { + if peers.remove(&peer).is_some() { + if let Err(e) = dispatch_update_to_all( + NetworkBridgeEvent::PeerDisconnected(peer), + event_producers.values(), + &mut ctx, + ).await { + log::warn!("Aborting - Failure to dispatch messages to overseer"); + return Err(e) + } + } + }, + Action::PeerMessages(peer, messages) => { + let peer_data = match peers.get_mut(&peer) { + None => continue, + Some(d) => d, + }; + + let mut outgoing_messages = Vec::with_capacity(messages.len()); + for message in messages { + match message { + WireMessage::ViewUpdate(new_view) => { + if new_view.0.len() > MAX_VIEW_HEADS { + net.report_peer( + peer.clone(), + MALFORMED_VIEW_COST, + ).await?; + + continue + } + + if new_view == peer_data.view { continue } + peer_data.view = new_view; + + let update = NetworkBridgeEvent::PeerViewChange( + peer.clone(), + peer_data.view.clone(), + ); + + outgoing_messages.extend( + event_producers.values().map(|producer| producer(update.clone())) + ); + } + WireMessage::ProtocolMessage(protocol, message) => { + let message = match event_producers.get(&protocol) { + Some(producer) => Some(producer( + NetworkBridgeEvent::PeerMessage(peer.clone(), message) + )), + None => { + net.report_peer( + peer.clone(), + UNKNOWN_PROTO_COST, + ).await?; + + None + } + }; + + if let Some(message) = message { + outgoing_messages.push(message); + } + } + } + } + + let send_messages = ctx.send_messages(outgoing_messages); + if let Err(e) = send_messages.await { + log::warn!("Aborting - Failure to dispatch messages to overseer"); + return Err(e) + } + }, + + Action::Abort => return Ok(()), + } + } +} + +#[cfg(test)] +mod tests { + use super::*; + use futures::channel::mpsc; + use futures::executor::{self, ThreadPool}; + + use std::sync::Arc; + use parking_lot::Mutex; + use assert_matches::assert_matches; + + use polkadot_subsystem::messages::{StatementDistributionMessage, BitfieldDistributionMessage}; + use subsystem_test::{SingleItemSink, SingleItemStream}; + + // The subsystem's view of the network - only supports a single call to `event_stream`. + struct TestNetwork { + net_events: Arc>>>, + action_tx: mpsc::UnboundedSender, + } + + // The test's view of the network. This receives updates from the subsystem in the form + // of `NetworkAction`s. + struct TestNetworkHandle { + action_rx: mpsc::UnboundedReceiver, + net_tx: SingleItemSink, + } + + fn new_test_network() -> ( + TestNetwork, + TestNetworkHandle, + ) { + let (net_tx, net_rx) = subsystem_test::single_item_sink(); + let (action_tx, action_rx) = mpsc::unbounded(); + + ( + TestNetwork { + net_events: Arc::new(Mutex::new(Some(net_rx))), + action_tx, + }, + TestNetworkHandle { + action_rx, + net_tx, + }, + ) + } + + impl Network for TestNetwork { + fn event_stream(&mut self) -> BoxStream<'static, NetworkEvent> { + self.net_events.lock() + .take() + .expect("Subsystem made more than one call to `event_stream`") + .boxed() + } + + fn action_sink<'a>(&'a mut self) + -> Pin + Send + 'a>> + { + Box::pin((&mut self.action_tx).sink_map_err(Into::into)) + } + } + + impl TestNetworkHandle { + // Get the next network action. + async fn next_network_action(&mut self) -> NetworkAction { + self.action_rx.next().await.expect("subsystem concluded early") + } + + // Wait for the next N network actions. + async fn next_network_actions(&mut self, n: usize) -> Vec { + let mut v = Vec::with_capacity(n); + for _ in 0..n { + v.push(self.next_network_action().await); + } + + v + } + + async fn connect_peer(&mut self, peer: PeerId, role: ObservedRole) { + self.send_network_event(NetworkEvent::NotificationStreamOpened { + remote: peer, + engine_id: POLKADOT_ENGINE_ID, + role, + }).await; + } + + async fn disconnect_peer(&mut self, peer: PeerId) { + self.send_network_event(NetworkEvent::NotificationStreamClosed { + remote: peer, + engine_id: POLKADOT_ENGINE_ID, + }).await; + } + + async fn peer_message(&mut self, peer: PeerId, message: Vec) { + self.send_network_event(NetworkEvent::NotificationsReceived { + remote: peer, + messages: vec![(POLKADOT_ENGINE_ID, message.into())], + }).await; + } + + async fn send_network_event(&mut self, event: NetworkEvent) { + self.net_tx.send(event).await.expect("subsystem concluded early"); + } + } + + // network actions are sensitive to ordering of `PeerId`s within a `HashMap`, so + // we need to use this to prevent fragile reliance on peer ordering. + fn network_actions_contains(actions: &[NetworkAction], action: &NetworkAction) -> bool { + actions.iter().find(|&x| x == action).is_some() + } + + struct TestHarness { + network_handle: TestNetworkHandle, + virtual_overseer: subsystem_test::TestSubsystemContextHandle, + } + + fn test_harness>(test: impl FnOnce(TestHarness) -> T) { + let pool = ThreadPool::new().unwrap(); + + let (network, network_handle) = new_test_network(); + let (context, virtual_overseer) = subsystem_test::make_subsystem_context(pool); + + let network_bridge = run_network( + network, + context, + ) + .map_err(|_| panic!("subsystem execution failed")) + .map(|_| ()); + + let test_fut = test(TestHarness { + network_handle, + virtual_overseer, + }); + + futures::pin_mut!(test_fut); + futures::pin_mut!(network_bridge); + + executor::block_on(future::select(test_fut, network_bridge)); + } + + #[test] + fn sends_view_updates_to_peers() { + test_harness(|test_harness| async move { + let TestHarness { mut network_handle, mut virtual_overseer } = test_harness; + + let peer_a = PeerId::random(); + let peer_b = PeerId::random(); + + network_handle.connect_peer(peer_a.clone(), ObservedRole::Full).await; + network_handle.connect_peer(peer_b.clone(), ObservedRole::Full).await; + + let hash_a = Hash::from([1; 32]); + + virtual_overseer.send(FromOverseer::Signal(OverseerSignal::StartWork(hash_a))).await; + + let actions = network_handle.next_network_actions(2).await; + let wire_message = WireMessage::ViewUpdate(View(vec![hash_a])).encode(); + assert!(network_actions_contains( + &actions, + &NetworkAction::WriteNotification(peer_a, wire_message.clone()), + )); + + assert!(network_actions_contains( + &actions, + &NetworkAction::WriteNotification(peer_b, wire_message.clone()), + )); + }); + } + + #[test] + fn peer_view_updates_sent_via_overseer() { + test_harness(|test_harness| async move { + let TestHarness { + mut network_handle, + mut virtual_overseer, + } = test_harness; + + let peer = PeerId::random(); + + let proto_statement = *b"abcd"; + let proto_bitfield = *b"wxyz"; + + network_handle.connect_peer(peer.clone(), ObservedRole::Full).await; + + virtual_overseer.send(FromOverseer::Communication { + msg: NetworkBridgeMessage::RegisterEventProducer( + proto_statement, + |event| AllMessages::StatementDistribution( + StatementDistributionMessage::NetworkBridgeUpdate(event) + ) + ), + }).await; + + virtual_overseer.send(FromOverseer::Communication { + msg: NetworkBridgeMessage::RegisterEventProducer( + proto_bitfield, + |event| AllMessages::BitfieldDistribution( + BitfieldDistributionMessage::NetworkBridgeUpdate(event) + ) + ), + }).await; + + let view = View(vec![Hash::from([1u8; 32])]); + + // bridge will inform about all previously-connected peers. + { + assert_matches!( + virtual_overseer.recv().await, + AllMessages::StatementDistribution( + StatementDistributionMessage::NetworkBridgeUpdate( + NetworkBridgeEvent::PeerConnected(p, ObservedRole::Full) + ) + ) if p == peer + ); + + assert_matches!( + virtual_overseer.recv().await, + AllMessages::StatementDistribution( + StatementDistributionMessage::NetworkBridgeUpdate( + NetworkBridgeEvent::PeerViewChange(p, v) + ) + ) if p == peer && v == View(Default::default()) + ); + + assert_matches!( + virtual_overseer.recv().await, + AllMessages::BitfieldDistribution( + BitfieldDistributionMessage::NetworkBridgeUpdate( + NetworkBridgeEvent::PeerConnected(p, ObservedRole::Full) + ) + ) if p == peer + ); + + assert_matches!( + virtual_overseer.recv().await, + AllMessages::BitfieldDistribution( + BitfieldDistributionMessage::NetworkBridgeUpdate( + NetworkBridgeEvent::PeerViewChange(p, v) + ) + ) if p == peer && v == View(Default::default()) + ); + } + + network_handle.peer_message( + peer.clone(), + WireMessage::ViewUpdate(view.clone()).encode(), + ).await; + + // statement distribution message comes first because handlers are ordered by + // protocol ID. + + assert_matches!( + virtual_overseer.recv().await, + AllMessages::StatementDistribution( + StatementDistributionMessage::NetworkBridgeUpdate( + NetworkBridgeEvent::PeerViewChange(p, v) + ) + ) => { + assert_eq!(p, peer); + assert_eq!(v, view); + } + ); + + assert_matches!( + virtual_overseer.recv().await, + AllMessages::BitfieldDistribution( + BitfieldDistributionMessage::NetworkBridgeUpdate( + NetworkBridgeEvent::PeerViewChange(p, v) + ) + ) => { + assert_eq!(p, peer); + assert_eq!(v, view); + } + ); + }); + } + + #[test] + fn peer_messages_sent_via_overseer() { + test_harness(|test_harness| async move { + let TestHarness { + mut network_handle, + mut virtual_overseer, + } = test_harness; + + let peer = PeerId::random(); + + let proto_statement = *b"abcd"; + let proto_bitfield = *b"wxyz"; + + network_handle.connect_peer(peer.clone(), ObservedRole::Full).await; + + virtual_overseer.send(FromOverseer::Communication { + msg: NetworkBridgeMessage::RegisterEventProducer( + proto_statement, + |event| AllMessages::StatementDistribution( + StatementDistributionMessage::NetworkBridgeUpdate(event) + ) + ), + }).await; + + virtual_overseer.send(FromOverseer::Communication { + msg: NetworkBridgeMessage::RegisterEventProducer( + proto_bitfield, + |event| AllMessages::BitfieldDistribution( + BitfieldDistributionMessage::NetworkBridgeUpdate(event) + ) + ), + }).await; + + // bridge will inform about all previously-connected peers. + { + assert_matches!( + virtual_overseer.recv().await, + AllMessages::StatementDistribution( + StatementDistributionMessage::NetworkBridgeUpdate( + NetworkBridgeEvent::PeerConnected(p, ObservedRole::Full) + ) + ) if p == peer + ); + + assert_matches!( + virtual_overseer.recv().await, + AllMessages::StatementDistribution( + StatementDistributionMessage::NetworkBridgeUpdate( + NetworkBridgeEvent::PeerViewChange(p, v) + ) + ) if p == peer && v == View(Default::default()) + ); + + assert_matches!( + virtual_overseer.recv().await, + AllMessages::BitfieldDistribution( + BitfieldDistributionMessage::NetworkBridgeUpdate( + NetworkBridgeEvent::PeerConnected(p, ObservedRole::Full) + ) + ) if p == peer + ); + + assert_matches!( + virtual_overseer.recv().await, + AllMessages::BitfieldDistribution( + BitfieldDistributionMessage::NetworkBridgeUpdate( + NetworkBridgeEvent::PeerViewChange(p, v) + ) + ) if p == peer && v == View(Default::default()) + ); + } + + let payload = vec![1, 2, 3]; + + network_handle.peer_message( + peer.clone(), + WireMessage::ProtocolMessage(proto_statement, payload.clone()).encode(), + ).await; + + network_handle.disconnect_peer(peer.clone()).await; + + // statement distribution message comes first because handlers are ordered by + // protocol ID, and then a disconnection event comes - indicating that the message + // was only sent to the correct protocol. + + assert_matches!( + virtual_overseer.recv().await, + AllMessages::StatementDistribution( + StatementDistributionMessage::NetworkBridgeUpdate( + NetworkBridgeEvent::PeerMessage(p, m) + ) + ) => { + assert_eq!(p, peer); + assert_eq!(m, payload); + } + ); + + assert_matches!( + virtual_overseer.recv().await, + AllMessages::StatementDistribution( + StatementDistributionMessage::NetworkBridgeUpdate( + NetworkBridgeEvent::PeerDisconnected(p) + ) + ) => { + assert_eq!(p, peer); + } + ); + }); + } +} diff --git a/polkadot/node/overseer/Cargo.toml b/polkadot/node/overseer/Cargo.toml index 88626e2e05..6c6ce304e6 100644 --- a/polkadot/node/overseer/Cargo.toml +++ b/polkadot/node/overseer/Cargo.toml @@ -11,7 +11,8 @@ futures-timer = "3.0.2" streamunordered = "0.5.1" polkadot-primitives = { path = "../../primitives" } client = { package = "sc-client-api", git = "https://github.com/paritytech/substrate", branch = "master" } -messages = { package = "polkadot-node-messages", path = "../messages" } +polkadot-subsystem = { package = "polkadot-node-subsystem", path = "../subsystem" } +async-trait = "0.1" [dev-dependencies] futures = { version = "0.3.5", features = ["thread-pool"] } diff --git a/polkadot/node/overseer/examples/minimal-example.rs b/polkadot/node/overseer/examples/minimal-example.rs index 77b99a3a3b..cdef0340d0 100644 --- a/polkadot/node/overseer/examples/minimal-example.rs +++ b/polkadot/node/overseer/examples/minimal-example.rs @@ -28,16 +28,17 @@ use futures_timer::Delay; use kv_log_macro as log; use polkadot_primitives::parachain::{BlockData, PoVBlock}; -use polkadot_overseer::{Overseer, Subsystem, SubsystemContext, SpawnedSubsystem}; +use polkadot_overseer::Overseer; -use messages::{ - AllMessages, CandidateBackingMessage, FromOverseer, CandidateValidationMessage +use polkadot_subsystem::{Subsystem, SubsystemContext, SpawnedSubsystem, FromOverseer}; +use polkadot_subsystem::messages::{ + AllMessages, CandidateBackingMessage, CandidateValidationMessage }; struct Subsystem1; impl Subsystem1 { - async fn run(mut ctx: SubsystemContext) { + async fn run(mut ctx: impl SubsystemContext) { loop { match ctx.try_recv().await { Ok(Some(msg)) => { @@ -56,7 +57,7 @@ impl Subsystem1 { Delay::new(Duration::from_secs(1)).await; let (tx, _) = oneshot::channel(); - ctx.send_msg(AllMessages::CandidateValidation( + ctx.send_message(AllMessages::CandidateValidation( CandidateValidationMessage::Validate( Default::default(), Default::default(), @@ -70,8 +71,10 @@ impl Subsystem1 { } } -impl Subsystem for Subsystem1 { - fn start(&mut self, ctx: SubsystemContext) -> SpawnedSubsystem { +impl Subsystem for Subsystem1 + where C: SubsystemContext +{ + fn start(self, ctx: C) -> SpawnedSubsystem { SpawnedSubsystem(Box::pin(async move { Self::run(ctx).await; })) @@ -81,7 +84,7 @@ impl Subsystem for Subsystem1 { struct Subsystem2; impl Subsystem2 { - async fn run(mut ctx: SubsystemContext) { + async fn run(mut ctx: impl SubsystemContext) { ctx.spawn(Box::pin(async { loop { log::info!("Job tick"); @@ -105,8 +108,10 @@ impl Subsystem2 { } } -impl Subsystem for Subsystem2 { - fn start(&mut self, ctx: SubsystemContext) -> SpawnedSubsystem { +impl Subsystem for Subsystem2 + where C: SubsystemContext +{ + fn start(self, ctx: C) -> SpawnedSubsystem { SpawnedSubsystem(Box::pin(async move { Self::run(ctx).await; })) @@ -124,8 +129,8 @@ fn main() { let (overseer, _handler) = Overseer::new( vec![], - Box::new(Subsystem2), - Box::new(Subsystem1), + Subsystem2, + Subsystem1, spawner, ).unwrap(); let overseer_fut = overseer.run().fuse(); diff --git a/polkadot/node/overseer/src/lib.rs b/polkadot/node/overseer/src/lib.rs index 0d3c9b7b50..706ba58a5e 100644 --- a/polkadot/node/overseer/src/lib.rs +++ b/polkadot/node/overseer/src/lib.rs @@ -65,8 +65,8 @@ use futures::channel::{mpsc, oneshot}; use futures::{ pending, poll, select, future::{BoxFuture, RemoteHandle}, - stream::FuturesUnordered, - task::{Spawn, SpawnError, SpawnExt}, + stream::{self, FuturesUnordered}, + task::{Spawn, SpawnExt}, Future, FutureExt, SinkExt, StreamExt, }; use futures_timer::Delay; @@ -75,50 +75,14 @@ use streamunordered::{StreamYield, StreamUnordered}; use polkadot_primitives::{Block, BlockNumber, Hash}; use client::{BlockImportNotification, BlockchainEvents, FinalityNotification}; -pub use messages::{ - OverseerSignal, CandidateValidationMessage, CandidateBackingMessage, AllMessages, - FromOverseer, +use polkadot_subsystem::messages::{ + CandidateValidationMessage, CandidateBackingMessage, AllMessages +}; +pub use polkadot_subsystem::{ + Subsystem, SubsystemContext, OverseerSignal, FromOverseer, SubsystemError, SubsystemResult, + SpawnedSubsystem, }; -/// An error type that describes faults that may happen -/// -/// These are: -/// * Channels being closed -/// * Subsystems dying when they are not expected to -/// * Subsystems not dying when they are told to die -/// * etc. -#[derive(Debug)] -pub struct SubsystemError; - -impl From for SubsystemError { - fn from(_: mpsc::SendError) -> Self { - Self - } -} - -impl From for SubsystemError { - fn from(_: oneshot::Canceled) -> Self { - Self - } -} - -impl From for SubsystemError { - fn from(_: SpawnError) -> Self { - Self - } -} - -/// A `Result` type that wraps [`SubsystemError`]. -/// -/// [`SubsystemError`]: struct.SubsystemError.html -pub type SubsystemResult = Result; - -/// An asynchronous subsystem task that runs inside and being overseen by the [`Overseer`]. -/// -/// In essence it's just a newtype wrapping a `BoxFuture`. -/// -/// [`Overseer`]: struct.Overseer.html -pub struct SpawnedSubsystem(pub BoxFuture<'static, ()>); // A capacity of bounded channels inside the overseer. const CHANNEL_CAPACITY: usize = 1024; @@ -278,7 +242,7 @@ impl Debug for ToOverseer { /// A running instance of some [`Subsystem`]. /// /// [`Subsystem`]: trait.Subsystem.html -struct SubsystemInstance { +struct SubsystemInstance { tx: mpsc::Sender>, } @@ -289,17 +253,17 @@ struct SubsystemInstance { /// [`Overseer`]: struct.Overseer.html /// [`Subsystem`]: trait.Subsystem.html /// [`SubsystemJob`]: trait.SubsystemJob.html -pub struct SubsystemContext{ +#[derive(Debug)] +pub struct OverseerSubsystemContext{ rx: mpsc::Receiver>, tx: mpsc::Sender, } -impl SubsystemContext { - /// Try to asyncronously receive a message. - /// - /// This has to be used with caution, if you loop over this without - /// using `pending!()` macro you will end up with a busy loop! - pub async fn try_recv(&mut self) -> Result>, ()> { +#[async_trait::async_trait] +impl SubsystemContext for OverseerSubsystemContext { + type Message = M; + + async fn try_recv(&mut self) -> Result>, ()> { match poll!(self.rx.next()) { Poll::Ready(Some(msg)) => Ok(Some(msg)), Poll::Ready(None) => Err(()), @@ -307,13 +271,11 @@ impl SubsystemContext { } } - /// Receive a message. - pub async fn recv(&mut self) -> SubsystemResult> { + async fn recv(&mut self) -> SubsystemResult> { self.rx.next().await.ok_or(SubsystemError) } - /// Spawn a child task on the executor. - pub async fn spawn(&mut self, s: Pin + Send>>) -> SubsystemResult<()> { + async fn spawn(&mut self, s: Pin + Send>>) -> SubsystemResult<()> { let (tx, rx) = oneshot::channel(); self.tx.send(ToOverseer::SpawnJob { s, @@ -323,33 +285,25 @@ impl SubsystemContext { rx.await? } - /// Send a direct message to some other `Subsystem`, routed based on message type. - pub async fn send_msg(&mut self, msg: AllMessages) -> SubsystemResult<()> { + async fn send_message(&mut self, msg: AllMessages) -> SubsystemResult<()> { self.tx.send(ToOverseer::SubsystemMessage(msg)).await?; Ok(()) } - fn new(rx: mpsc::Receiver>, tx: mpsc::Sender) -> Self { - Self { - rx, - tx, - } + async fn send_messages(&mut self, msgs: T) -> SubsystemResult<()> + where T: IntoIterator + Send, T::IntoIter: Send + { + let mut msgs = stream::iter(msgs.into_iter().map(ToOverseer::SubsystemMessage).map(Ok)); + self.tx.send_all(&mut msgs).await?; + + Ok(()) } } -/// A trait that describes the [`Subsystem`]s that can run on the [`Overseer`]. -/// -/// It is generic over the message type circulating in the system. -/// The idea that we want some type contaning persistent state that -/// can spawn actually running subsystems when asked to. -/// -/// [`Overseer`]: struct.Overseer.html -/// [`Subsystem`]: trait.Subsystem.html -pub trait Subsystem { - /// Start this `Subsystem` and return `SpawnedSubsystem`. - fn start(&mut self, ctx: SubsystemContext) -> SpawnedSubsystem; -} +/// A subsystem compatible with the overseer - one which can be run in the context of the +/// overseer. +pub type CompatibleSubsystem = Box> + Send>; /// A subsystem that we oversee. /// @@ -359,8 +313,7 @@ pub trait Subsystem { /// /// [`Subsystem`]: trait.Subsystem.html #[allow(dead_code)] -struct OverseenSubsystem { - subsystem: Box + Send>, +struct OverseenSubsystem { instance: Option>, } @@ -441,16 +394,20 @@ where /// # use std::time::Duration; /// # use futures::{executor, pin_mut, select, FutureExt}; /// # use futures_timer::Delay; - /// # use polkadot_overseer::{ - /// # Overseer, Subsystem, SpawnedSubsystem, SubsystemContext, - /// # CandidateValidationMessage, CandidateBackingMessage, + /// # use polkadot_overseer::Overseer; + /// # use polkadot_subsystem::{ + /// # Subsystem, SpawnedSubsystem, SubsystemContext, + /// # messages::{CandidateValidationMessage, CandidateBackingMessage}, /// # }; /// /// struct ValidationSubsystem; - /// impl Subsystem for ValidationSubsystem { + /// + /// impl Subsystem for ValidationSubsystem + /// where C: SubsystemContext + /// { /// fn start( - /// &mut self, - /// mut ctx: SubsystemContext, + /// self, + /// mut ctx: C, /// ) -> SpawnedSubsystem { /// SpawnedSubsystem(Box::pin(async move { /// loop { @@ -461,10 +418,12 @@ where /// } /// /// struct CandidateBackingSubsystem; - /// impl Subsystem for CandidateBackingSubsystem { + /// impl Subsystem for CandidateBackingSubsystem + /// where C: SubsystemContext + /// { /// fn start( - /// &mut self, - /// mut ctx: SubsystemContext, + /// self, + /// mut ctx: C, /// ) -> SpawnedSubsystem { /// SpawnedSubsystem(Box::pin(async move { /// loop { @@ -478,8 +437,8 @@ where /// let spawner = executor::ThreadPool::new().unwrap(); /// let (overseer, _handler) = Overseer::new( /// vec![], - /// Box::new(ValidationSubsystem), - /// Box::new(CandidateBackingSubsystem), + /// ValidationSubsystem, + /// CandidateBackingSubsystem, /// spawner, /// ).unwrap(); /// @@ -498,8 +457,8 @@ where /// ``` pub fn new( leaves: impl IntoIterator, - validation: Box + Send>, - candidate_backing: Box + Send>, + validation: impl Subsystem> + Send, + candidate_backing: impl Subsystem> + Send, mut s: S, ) -> SubsystemResult<(Self, OverseerHandler)> { let (events_tx, events_rx) = mpsc::channel(CHANNEL_CAPACITY); @@ -680,6 +639,12 @@ where let _ = s.tx.send(FromOverseer::Communication { msg }).await; } } + _ => { + // TODO: temporary catch-all until all subsystems are integrated with overseer. + // The overseer is not complete until this is an exhaustive match with all + // messages targeting an included subsystem. + // https://github.com/paritytech/polkadot/issues/1317 + } } } @@ -688,15 +653,15 @@ where } } -fn spawn( +fn spawn( spawner: &mut S, futures: &mut FuturesUnordered>, streams: &mut StreamUnordered>, - mut s: Box + Send>, + s: impl Subsystem>, ) -> SubsystemResult> { let (to_tx, to_rx) = mpsc::channel(CHANNEL_CAPACITY); let (from_tx, from_rx) = mpsc::channel(CHANNEL_CAPACITY); - let ctx = SubsystemContext::new(to_rx, from_tx); + let ctx = OverseerSubsystemContext { rx: to_rx, tx: from_tx }; let f = s.start(ctx); let handle = spawner.spawn_with_handle(f.0)?; @@ -709,7 +674,6 @@ fn spawn( }); Ok(OverseenSubsystem { - subsystem: s, instance, }) } @@ -723,9 +687,11 @@ mod tests { struct TestSubsystem1(mpsc::Sender); - impl Subsystem for TestSubsystem1 { - fn start(&mut self, mut ctx: SubsystemContext) -> SpawnedSubsystem { - let mut sender = self.0.clone(); + impl Subsystem for TestSubsystem1 + where C: SubsystemContext + { + fn start(self, mut ctx: C) -> SpawnedSubsystem { + let mut sender = self.0; SpawnedSubsystem(Box::pin(async move { let mut i = 0; loop { @@ -746,14 +712,18 @@ mod tests { struct TestSubsystem2(mpsc::Sender); - impl Subsystem for TestSubsystem2 { - fn start(&mut self, mut ctx: SubsystemContext) -> SpawnedSubsystem { + impl Subsystem for TestSubsystem2 + where C: SubsystemContext + { + fn start(self, mut ctx: C) -> SpawnedSubsystem { + let sender = self.0.clone(); SpawnedSubsystem(Box::pin(async move { + let _sender = sender; let mut c: usize = 0; loop { if c < 10 { let (tx, _) = oneshot::channel(); - ctx.send_msg( + ctx.send_message( AllMessages::CandidateValidation( CandidateValidationMessage::Validate( Default::default(), @@ -786,8 +756,10 @@ mod tests { struct TestSubsystem4; - impl Subsystem for TestSubsystem4 { - fn start(&mut self, mut _ctx: SubsystemContext) -> SpawnedSubsystem { + impl Subsystem for TestSubsystem4 + where C: SubsystemContext + { + fn start(self, mut _ctx: C) -> SpawnedSubsystem { SpawnedSubsystem(Box::pin(async move { // Do nothing and exit. })) @@ -805,8 +777,8 @@ mod tests { let (overseer, mut handler) = Overseer::new( vec![], - Box::new(TestSubsystem1(s1_tx)), - Box::new(TestSubsystem2(s2_tx)), + TestSubsystem1(s1_tx), + TestSubsystem2(s2_tx), spawner, ).unwrap(); let overseer_fut = overseer.run().fuse(); @@ -855,8 +827,8 @@ mod tests { let (s1_tx, _) = mpsc::channel(64); let (overseer, _handle) = Overseer::new( vec![], - Box::new(TestSubsystem1(s1_tx)), - Box::new(TestSubsystem4), + TestSubsystem1(s1_tx), + TestSubsystem4, spawner, ).unwrap(); let overseer_fut = overseer.run().fuse(); @@ -871,8 +843,10 @@ mod tests { struct TestSubsystem5(mpsc::Sender); - impl Subsystem for TestSubsystem5 { - fn start(&mut self, mut ctx: SubsystemContext) -> SpawnedSubsystem { + impl Subsystem for TestSubsystem5 + where C: SubsystemContext + { + fn start(self, mut ctx: C) -> SpawnedSubsystem { let mut sender = self.0.clone(); SpawnedSubsystem(Box::pin(async move { @@ -895,8 +869,10 @@ mod tests { struct TestSubsystem6(mpsc::Sender); - impl Subsystem for TestSubsystem6 { - fn start(&mut self, mut ctx: SubsystemContext) -> SpawnedSubsystem { + impl Subsystem for TestSubsystem6 + where C: SubsystemContext + { + fn start(self, mut ctx: C) -> SpawnedSubsystem { let mut sender = self.0.clone(); SpawnedSubsystem(Box::pin(async move { @@ -949,8 +925,8 @@ mod tests { let (overseer, mut handler) = Overseer::new( vec![first_block], - Box::new(TestSubsystem5(tx_5)), - Box::new(TestSubsystem6(tx_6)), + TestSubsystem5(tx_5), + TestSubsystem6(tx_6), spawner, ).unwrap(); @@ -1034,8 +1010,8 @@ mod tests { // start with two forks of different height. let (overseer, mut handler) = Overseer::new( vec![first_block, second_block], - Box::new(TestSubsystem5(tx_5)), - Box::new(TestSubsystem6(tx_6)), + TestSubsystem5(tx_5), + TestSubsystem6(tx_6), spawner, ).unwrap(); diff --git a/polkadot/node/primitives/Cargo.toml b/polkadot/node/primitives/Cargo.toml index f317565b2e..b2bc9231ae 100644 --- a/polkadot/node/primitives/Cargo.toml +++ b/polkadot/node/primitives/Cargo.toml @@ -10,3 +10,4 @@ polkadot-primitives = { path = "../../primitives" } polkadot-statement-table = { path = "../../statement-table" } parity-scale-codec = { version = "1.3.0", default-features = false, features = ["derive"] } runtime_primitives = { package = "sp-runtime", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } +async-trait = "0.1" diff --git a/polkadot/node/primitives/src/lib.rs b/polkadot/node/primitives/src/lib.rs index bd43748ab2..527e6aaea2 100644 --- a/polkadot/node/primitives/src/lib.rs +++ b/polkadot/node/primitives/src/lib.rs @@ -64,6 +64,7 @@ impl EncodeAs for Statement { pub type SignedFullStatement = Signed; /// A misbehaviour report. +#[derive(Debug)] pub enum MisbehaviorReport { /// These validator nodes disagree on this candidate's validity, please figure it out /// @@ -79,3 +80,12 @@ pub enum MisbehaviorReport { /// This peer has seconded more than one parachain candidate for this relay parent head DoubleVote(CandidateReceipt, SignedFullStatement, SignedFullStatement), } + +/// A unique identifier for a network protocol. +pub type ProtocolId = [u8; 4]; + +/// A succinct representation of a peer's view. This consists of a bounded amount of chain heads. +/// +/// Up to `N` (5?) chain heads. +#[derive(Debug, Clone, PartialEq, Eq, Encode, Decode)] +pub struct View(pub Vec); diff --git a/polkadot/node/service/Cargo.toml b/polkadot/node/service/Cargo.toml index 74069f0233..f1a56acfad 100644 --- a/polkadot/node/service/Cargo.toml +++ b/polkadot/node/service/Cargo.toml @@ -15,6 +15,7 @@ hex-literal = "0.2.1" polkadot-primitives = { path = "../../primitives" } polkadot-runtime = { path = "../../runtime/polkadot" } polkadot-overseer = { path = "../overseer" } +polkadot-subsystem = { package = "polkadot-node-subsystem", path = "../subsystem" } kusama-runtime = { path = "../../runtime/kusama" } westend-runtime = { path = "../../runtime/westend" } polkadot-network = { path = "../../network", optional = true } diff --git a/polkadot/node/service/src/lib.rs b/polkadot/node/service/src/lib.rs index 620850b3bd..c798d3e9aa 100644 --- a/polkadot/node/service/src/lib.rs +++ b/polkadot/node/service/src/lib.rs @@ -29,15 +29,15 @@ use grandpa::{self, FinalityProofProvider as GrandpaFinalityProofProvider}; use sc_executor::native_executor_instance; use log::info; use sp_blockchain::HeaderBackend; -use polkadot_overseer::{ - self as overseer, - BlockInfo, Overseer, OverseerHandler, Subsystem, SubsystemContext, SpawnedSubsystem, - CandidateValidationMessage, CandidateBackingMessage, +use polkadot_overseer::{self as overseer, BlockInfo, Overseer, OverseerHandler}; +use polkadot_subsystem::{ + Subsystem, SubsystemContext, SpawnedSubsystem, + messages::{CandidateValidationMessage, CandidateBackingMessage}, }; pub use service::{ - AbstractService, Role, PruningMode, TransactionPoolOptions, Error, RuntimeGenesis, + Role, PruningMode, TransactionPoolOptions, Error, RuntimeGenesis, TFullClient, TLightClient, TFullBackend, TLightBackend, TFullCallExecutor, TLightCallExecutor, - Configuration, ChainSpec, ServiceBuilderCommand, + Configuration, ChainSpec, ServiceBuilderCommand, ServiceComponents, TaskManager, }; pub use service::config::{DatabaseConfig, PrometheusConfig}; pub use sc_executor::NativeExecutionDispatch; @@ -269,8 +269,10 @@ macro_rules! new_full_start { struct CandidateValidationSubsystem; -impl Subsystem for CandidateValidationSubsystem { - fn start(&mut self, mut ctx: SubsystemContext) -> SpawnedSubsystem { +impl Subsystem for CandidateValidationSubsystem + where C: SubsystemContext +{ + fn start(self, mut ctx: C) -> SpawnedSubsystem { SpawnedSubsystem(Box::pin(async move { while let Ok(_) = ctx.recv().await {} })) @@ -279,8 +281,10 @@ impl Subsystem for CandidateValidationSubsystem { struct CandidateBackingSubsystem; -impl Subsystem for CandidateBackingSubsystem { - fn start(&mut self, mut ctx: SubsystemContext) -> SpawnedSubsystem { +impl Subsystem for CandidateBackingSubsystem + where C: SubsystemContext +{ + fn start(self, mut ctx: C) -> SpawnedSubsystem { SpawnedSubsystem(Box::pin(async move { while let Ok(_) = ctx.recv().await {} })) @@ -291,8 +295,8 @@ fn real_overseer( leaves: impl IntoIterator, s: S, ) -> Result<(Overseer, OverseerHandler), ServiceError> { - let validation = Box::new(CandidateValidationSubsystem); - let candidate_backing = Box::new(CandidateBackingSubsystem); + let validation = CandidateValidationSubsystem; + let candidate_backing = CandidateBackingSubsystem; Overseer::new(leaves, validation, candidate_backing, s) .map_err(|e| ServiceError::Other(format!("Failed to create an Overseer: {:?}", e))) } @@ -321,7 +325,10 @@ macro_rules! new_full { let (builder, mut import_setup, inherent_data_providers, mut rpc_setup) = new_full_start!($config, $runtime, $dispatch); - let service = builder + let ServiceComponents { + client, network, select_chain, keystore, transaction_pool, prometheus_registry, + task_manager, telemetry_on_connect_sinks, .. + } = builder .with_finality_proof_provider(|client, backend| { let provider = client as Arc>; Ok(Arc::new(GrandpaFinalityProofProvider::new(backend, provider)) as _) @@ -334,11 +341,9 @@ macro_rules! new_full { let shared_voter_state = rpc_setup.take() .expect("The SharedVoterState is present for Full Services or setup failed before. qed"); - let client = service.client(); - - let overseer_client = service.client(); - let spawner = service.spawn_task_handle(); - let leaves: Vec<_> = service.select_chain().ok_or(ServiceError::SelectChainRequired)? + let overseer_client = client.clone(); + let spawner = task_manager.spawn_handle(); + let leaves: Vec<_> = select_chain.clone().ok_or(ServiceError::SelectChainRequired)? .leaves() .unwrap_or_else(|_| vec![]) .into_iter() @@ -356,7 +361,7 @@ macro_rules! new_full { let (overseer, handler) = real_overseer(leaves, spawner)?; - service.spawn_essential_task_handle().spawn("overseer", Box::pin(async move { + task_manager.spawn_essential_handle().spawn_blocking("overseer", Box::pin(async move { use futures::{pin_mut, select, FutureExt}; let forward = overseer::forward_events(overseer_client, handler); @@ -377,24 +382,24 @@ macro_rules! new_full { })); if role.is_authority() { - let select_chain = service.select_chain().ok_or(ServiceError::SelectChainRequired)?; + let select_chain = select_chain.ok_or(ServiceError::SelectChainRequired)?; let can_author_with = consensus_common::CanAuthorWithNativeVersion::new(client.executor().clone()); // TODO: custom proposer (https://github.com/paritytech/polkadot/issues/1248) let proposer = sc_basic_authorship::ProposerFactory::new( client.clone(), - service.transaction_pool(), + transaction_pool, None, ); let babe_config = babe::BabeParams { - keystore: service.keystore(), + keystore: keystore.clone(), client: client.clone(), select_chain, block_import, env: proposer, - sync_oracle: service.network(), + sync_oracle: network.clone(), inherent_data_providers: inherent_data_providers.clone(), force_authoring, babe_link, @@ -402,13 +407,13 @@ macro_rules! new_full { }; let babe = babe::start_babe(babe_config)?; - service.spawn_essential_task_handle().spawn_blocking("babe", babe); + task_manager.spawn_essential_handle().spawn_blocking("babe", babe); } // if the node isn't actively participating in consensus then it doesn't // need a keystore, regardless of which protocol we use below. let keystore = if is_authority { - Some(service.keystore() as BareCryptoStorePtr) + Some(keystore.clone() as BareCryptoStorePtr) } else { None }; @@ -454,15 +459,15 @@ macro_rules! new_full { let grandpa_config = grandpa::GrandpaParams { config, link: link_half, - network: service.network(), + network: network.clone(), inherent_data_providers: inherent_data_providers.clone(), - telemetry_on_connect: Some(service.telemetry_on_connect_stream()), + telemetry_on_connect: Some(telemetry_on_connect_sinks.on_connect_stream()), voting_rule, - prometheus_registry: service.prometheus_registry(), + prometheus_registry: prometheus_registry, shared_voter_state, }; - service.spawn_essential_task_handle().spawn_blocking( + task_manager.spawn_essential_handle().spawn_blocking( "grandpa-voter", grandpa::run_grandpa_voter(grandpa_config)? ); @@ -470,11 +475,11 @@ macro_rules! new_full { grandpa::setup_disabled_grandpa( client.clone(), &inherent_data_providers, - service.network(), + network.clone(), )?; } - (service, client) + (task_manager, client) }} } @@ -566,6 +571,7 @@ macro_rules! new_light { Ok(polkadot_rpc::create_light(light_deps)) })? .build_light() + .map(|ServiceComponents { task_manager, .. }| task_manager) }} } @@ -595,7 +601,7 @@ pub fn polkadot_new_full( grandpa_pause: Option<(u32, u32)>, ) -> Result<( - impl AbstractService, + TaskManager, Arc, @@ -604,7 +610,7 @@ pub fn polkadot_new_full( FullNodeHandles, ), ServiceError> { - let (service, client) = new_full!( + let (components, client) = new_full!( config, collating_for, authority_discovery_enabled, @@ -613,7 +619,7 @@ pub fn polkadot_new_full( PolkadotExecutor, ); - Ok((service, client, FullNodeHandles)) + Ok((components, client, FullNodeHandles)) } /// Create a new Kusama service for a full node. @@ -626,7 +632,7 @@ pub fn kusama_new_full( _slot_duration: u64, grandpa_pause: Option<(u32, u32)>, ) -> Result<( - impl AbstractService, + TaskManager, Arc, @@ -636,7 +642,7 @@ pub fn kusama_new_full( FullNodeHandles, ), ServiceError> { - let (service, client) = new_full!( + let (components, client) = new_full!( config, collating_for, authority_discovery_enabled, @@ -645,7 +651,7 @@ pub fn kusama_new_full( KusamaExecutor, ); - Ok((service, client, FullNodeHandles)) + Ok((components, client, FullNodeHandles)) } /// Create a new Kusama service for a full node. @@ -659,7 +665,7 @@ pub fn westend_new_full( grandpa_pause: Option<(u32, u32)>, ) -> Result<( - impl AbstractService, + TaskManager, Arc, @@ -668,7 +674,7 @@ pub fn westend_new_full( FullNodeHandles, ), ServiceError> { - let (service, client) = new_full!( + let (components, client) = new_full!( config, collating_for, authority_discovery_enabled, @@ -677,45 +683,23 @@ pub fn westend_new_full( WestendExecutor, ); - Ok((service, client, FullNodeHandles)) + Ok((components, client, FullNodeHandles)) } /// Create a new Polkadot service for a light client. -pub fn polkadot_new_light(mut config: Configuration) -> Result< - impl AbstractService< - Block = Block, - RuntimeApi = polkadot_runtime::RuntimeApi, - Backend = TLightBackend, - SelectChain = LongestChain, Block>, - CallExecutor = TLightCallExecutor, - >, ServiceError> +pub fn polkadot_new_light(mut config: Configuration) -> Result { new_light!(config, polkadot_runtime::RuntimeApi, PolkadotExecutor) } /// Create a new Kusama service for a light client. -pub fn kusama_new_light(mut config: Configuration) -> Result< - impl AbstractService< - Block = Block, - RuntimeApi = kusama_runtime::RuntimeApi, - Backend = TLightBackend, - SelectChain = LongestChain, Block>, - CallExecutor = TLightCallExecutor, - >, ServiceError> +pub fn kusama_new_light(mut config: Configuration) -> Result { new_light!(config, kusama_runtime::RuntimeApi, KusamaExecutor) } /// Create a new Westend service for a light client. -pub fn westend_new_light(mut config: Configuration, ) -> Result< - impl AbstractService< - Block = Block, - RuntimeApi = westend_runtime::RuntimeApi, - Backend = TLightBackend, - SelectChain = LongestChain, Block>, - CallExecutor = TLightCallExecutor - >, - ServiceError> +pub fn westend_new_light(mut config: Configuration, ) -> Result { new_light!(config, westend_runtime::RuntimeApi, KusamaExecutor) } diff --git a/polkadot/node/messages/Cargo.toml b/polkadot/node/subsystem/Cargo.toml similarity index 77% rename from polkadot/node/messages/Cargo.toml rename to polkadot/node/subsystem/Cargo.toml index 9edb5a0519..43712319cb 100644 --- a/polkadot/node/messages/Cargo.toml +++ b/polkadot/node/subsystem/Cargo.toml @@ -1,9 +1,9 @@ [package] -name = "polkadot-node-messages" +name = "polkadot-node-subsystem" version = "0.1.0" authors = ["Parity Technologies "] edition = "2018" -description = "Message types used by Subsystems" +description = "Subsystem traits and message definitions" [dependencies] polkadot-primitives = { path = "../../primitives" } @@ -11,3 +11,4 @@ polkadot-statement-table = { path = "../../statement-table" } polkadot-node-primitives = { path = "../primitives" } sc-network = { git = "https://github.com/paritytech/substrate", branch = "master" } futures = "0.3.5" +async-trait = "0.1" diff --git a/polkadot/node/subsystem/src/lib.rs b/polkadot/node/subsystem/src/lib.rs new file mode 100644 index 0000000000..fd32d7cfdb --- /dev/null +++ b/polkadot/node/subsystem/src/lib.rs @@ -0,0 +1,150 @@ +// Copyright 2017-2020 Parity Technologies (UK) Ltd. +// This file is part of Polkadot. + +// Polkadot 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. + +// Polkadot 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 Polkadot. If not, see . + +//! Subsystem trait definitions and message types. +//! +//! Node-side logic for Polkadot is mostly comprised of Subsystems, which are discrete components +//! that communicate via message-passing. They are coordinated by an overseer, provided by a +//! separate crate. + +use std::pin::Pin; + +use futures::prelude::*; +use futures::channel::{mpsc, oneshot}; +use futures::future::BoxFuture; + +use polkadot_primitives::Hash; +use async_trait::async_trait; + +use crate::messages::AllMessages; + +pub mod messages; + +/// Signals sent by an overseer to a subsystem. +#[derive(PartialEq, Clone, Debug)] +pub enum OverseerSignal { + /// `Subsystem` should start working on block-based work, given by the relay-chain block hash. + StartWork(Hash), + /// `Subsystem` should stop working on block-based work specified by the relay-chain block hash. + StopWork(Hash), + /// Conclude the work of the `Overseer` and all `Subsystem`s. + Conclude, +} + +/// A message type that a subsystem receives from an overseer. +/// It wraps signals from an overseer and messages that are circulating +/// between subsystems. +/// +/// It is generic over over the message type `M` that a particular `Subsystem` may use. +#[derive(Debug)] +pub enum FromOverseer { + /// Signal from the `Overseer`. + Signal(OverseerSignal), + + /// Some other `Subsystem`'s message. + Communication { + msg: M, + }, +} + +/// An error type that describes faults that may happen +/// +/// These are: +/// * Channels being closed +/// * Subsystems dying when they are not expected to +/// * Subsystems not dying when they are told to die +/// * etc. +#[derive(Debug)] +pub struct SubsystemError; + +impl From for SubsystemError { + fn from(_: mpsc::SendError) -> Self { + Self + } +} + +impl From for SubsystemError { + fn from(_: oneshot::Canceled) -> Self { + Self + } +} + +impl From for SubsystemError { + fn from(_: futures::task::SpawnError) -> Self { + Self + } +} + +impl From for SubsystemError { + fn from(e: std::convert::Infallible) -> Self { + match e {} + } +} + +/// An asynchronous subsystem task.. +/// +/// In essence it's just a newtype wrapping a `BoxFuture`. +pub struct SpawnedSubsystem(pub BoxFuture<'static, ()>); + +/// A `Result` type that wraps [`SubsystemError`]. +/// +/// [`SubsystemError`]: struct.SubsystemError.html +pub type SubsystemResult = Result; + +/// A context type that is given to the [`Subsystem`] upon spawning. +/// It can be used by [`Subsystem`] to communicate with other [`Subsystem`]s +/// or spawn jobs. +/// +/// [`Overseer`]: struct.Overseer.html +/// [`SubsystemJob`]: trait.SubsystemJob.html +#[async_trait] +pub trait SubsystemContext: Send + 'static { + /// The message type of this context. Subsystems launched with this context will expect + /// to receive messages of this type. + type Message: Send; + + /// Try to asynchronously receive a message. + /// + /// This has to be used with caution, if you loop over this without + /// using `pending!()` macro you will end up with a busy loop! + async fn try_recv(&mut self) -> Result>, ()>; + + /// Receive a message. + async fn recv(&mut self) -> SubsystemResult>; + + /// Spawn a child task on the executor. + async fn spawn(&mut self, s: Pin + Send>>) -> SubsystemResult<()>; + + /// Send a direct message to some other `Subsystem`, routed based on message type. + async fn send_message(&mut self, msg: AllMessages) -> SubsystemResult<()>; + + /// Send multiple direct messages to other `Subsystem`s, routed based on message type. + async fn send_messages(&mut self, msgs: T) -> SubsystemResult<()> + where T: IntoIterator + Send, T::IntoIter: Send; +} + +/// A trait that describes the [`Subsystem`]s that can run on the [`Overseer`]. +/// +/// It is generic over the message type circulating in the system. +/// The idea that we want some type contaning persistent state that +/// can spawn actually running subsystems when asked to. +/// +/// [`Overseer`]: struct.Overseer.html +/// [`Subsystem`]: trait.Subsystem.html +pub trait Subsystem { + /// Start this `Subsystem` and return `SpawnedSubsystem`. + fn start(self, ctx: C) -> SpawnedSubsystem; +} diff --git a/polkadot/node/messages/src/lib.rs b/polkadot/node/subsystem/src/messages.rs similarity index 87% rename from polkadot/node/messages/src/lib.rs rename to polkadot/node/subsystem/src/messages.rs index 3a413f2c67..c225813490 100644 --- a/polkadot/node/messages/src/lib.rs +++ b/polkadot/node/subsystem/src/messages.rs @@ -24,27 +24,16 @@ use futures::channel::{mpsc, oneshot}; -use sc_network::{ObservedRole, ReputationChange, PeerId, config::ProtocolId}; +use sc_network::{ObservedRole, ReputationChange, PeerId}; use polkadot_primitives::{BlockNumber, Hash, Signature}; use polkadot_primitives::parachain::{ AbridgedCandidateReceipt, PoVBlock, ErasureChunk, BackedCandidate, Id as ParaId, SignedAvailabilityBitfield, SigningContext, ValidatorId, ValidationCode, ValidatorIndex, }; use polkadot_node_primitives::{ - MisbehaviorReport, SignedFullStatement, + MisbehaviorReport, SignedFullStatement, View, ProtocolId, }; -/// Signals sent by an overseer to a subsystem. -#[derive(PartialEq, Clone, Debug)] -pub enum OverseerSignal { - /// `Subsystem` should start working on block-based work, given by the relay-chain block hash. - StartWork(Hash), - /// `Subsystem` should stop working on block-based work specified by the relay-chain block hash. - StopWork(Hash), - /// Conclude the work of the `Overseer` and all `Subsystem`s. - Conclude, -} - /// A notification of a new backed candidate. #[derive(Debug)] pub struct NewBackedCandidate(pub BackedCandidate); @@ -90,12 +79,8 @@ pub enum CandidateValidationMessage { ), } -/// Chain heads. -/// -/// Up to `N` (5?) chain heads. -pub struct View(pub Vec); - /// Events from network. +#[derive(Debug, Clone)] pub enum NetworkBridgeEvent { /// A peer has connected. PeerConnected(PeerId, ObservedRole), @@ -114,7 +99,8 @@ pub enum NetworkBridgeEvent { } /// Messages received by the network bridge subsystem. -pub enum NetworkBridgeSubsystemMessage { +#[derive(Debug)] +pub enum NetworkBridgeMessage { /// Register an event producer on startup. RegisterEventProducer(ProtocolId, fn(NetworkBridgeEvent) -> AllMessages), @@ -126,6 +112,7 @@ pub enum NetworkBridgeSubsystemMessage { } /// Availability Distribution Message. +#[derive(Debug)] pub enum AvailabilityDistributionMessage { /// Distribute an availability chunk to other validators. DistributeChunk(Hash, ErasureChunk), @@ -138,6 +125,7 @@ pub enum AvailabilityDistributionMessage { } /// Bitfield distribution message. +#[derive(Debug)] pub enum BitfieldDistributionMessage { /// Distribute a bitfield via gossip to other validators. DistributeBitfield(Hash, SignedAvailabilityBitfield), @@ -147,6 +135,7 @@ pub enum BitfieldDistributionMessage { } /// Availability store subsystem message. +#[derive(Debug)] pub enum AvailabilityStoreMessage { /// Query a `PoVBlock` from the AV store. QueryPoV(Hash, oneshot::Sender>), @@ -159,6 +148,7 @@ pub enum AvailabilityStoreMessage { } /// A request to the Runtime API subsystem. +#[derive(Debug)] pub enum RuntimeApiRequest { /// Get the current validator set. Validators(oneshot::Sender>), @@ -171,19 +161,24 @@ pub enum RuntimeApiRequest { } /// A message to the Runtime API subsystem. +#[derive(Debug)] pub enum RuntimeApiMessage { /// Make a request of the runtime API against the post-state of the given relay-parent. Request(Hash, RuntimeApiRequest), } /// Statement distribution message. +#[derive(Debug)] pub enum StatementDistributionMessage { /// We have originated a signed statement in the context of /// given relay-parent hash and it should be distributed to other validators. Share(Hash, SignedFullStatement), + /// Event from the network bridge. + NetworkBridgeUpdate(NetworkBridgeEvent), } /// This data becomes intrinsics or extrinsics which should be included in a future relay chain block. +#[derive(Debug)] pub enum ProvisionableData { /// This bitfield indicates the availability of various candidate blocks. Bitfield(Hash, SignedAvailabilityBitfield), @@ -198,6 +193,7 @@ pub enum ProvisionableData { /// Message to the Provisioner. /// /// In all cases, the Hash is that of the relay parent. +#[derive(Debug)] pub enum ProvisionerMessage { /// This message allows potential block authors to be kept updated with all new authorship data /// as it becomes available. @@ -213,20 +209,18 @@ pub enum AllMessages { CandidateValidation(CandidateValidationMessage), /// Message for the candidate backing subsystem. CandidateBacking(CandidateBackingMessage), -} - -/// A message type that a subsystem receives from an overseer. -/// It wraps signals from an overseer and messages that are circulating -/// between subsystems. -/// -/// It is generic over over the message type `M` that a particular `Subsystem` may use. -#[derive(Debug)] -pub enum FromOverseer { - /// Signal from the `Overseer`. - Signal(OverseerSignal), - - /// Some other `Subsystem`'s message. - Communication { - msg: M, - }, + /// Message for the candidate selection subsystem. + CandidateSelection(CandidateSelectionMessage), + /// Message for the statement distribution subsystem. + StatementDistribution(StatementDistributionMessage), + /// Message for the availability distribution subsystem. + AvailabilityDistribution(AvailabilityDistributionMessage), + /// Message for the bitfield distribution subsystem. + BitfieldDistribution(BitfieldDistributionMessage), + /// Message for the Provisioner subsystem. + Provisioner(ProvisionerMessage), + /// Message for the Runtime API subsystem. + RuntimeApi(RuntimeApiMessage), + /// Message for the availability store subsystem. + AvailabilityStore(AvailabilityStoreMessage), } diff --git a/polkadot/node/test-helpers/subsystem/Cargo.toml b/polkadot/node/test-helpers/subsystem/Cargo.toml new file mode 100644 index 0000000000..0fc26a24ea --- /dev/null +++ b/polkadot/node/test-helpers/subsystem/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "polkadot-subsystem-test-helpers" +version = "0.1.0" +authors = ["Parity Technologies "] +edition = "2018" +description = "Helpers for testing subsystems" + +[dependencies] +futures = "0.3.5" +async-trait = "0.1" +polkadot-subsystem = { package = "polkadot-node-subsystem", path = "../../subsystem" } +parking_lot = "0.10.0" diff --git a/polkadot/node/test-helpers/subsystem/src/lib.rs b/polkadot/node/test-helpers/subsystem/src/lib.rs new file mode 100644 index 0000000000..c99a33c78d --- /dev/null +++ b/polkadot/node/test-helpers/subsystem/src/lib.rs @@ -0,0 +1,229 @@ +// Copyright 2017-2020 Parity Technologies (UK) Ltd. +// This file is part of Polkadot. + +// Polkadot 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. + +// Polkadot 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 Polkadot. If not, see . + +//! Utilities for testing subsystems. + +use polkadot_subsystem::{SubsystemContext, FromOverseer, SubsystemResult, SubsystemError}; +use polkadot_subsystem::messages::AllMessages; + +use futures::prelude::*; +use futures::channel::mpsc; +use futures::task::{Spawn, SpawnExt}; +use futures::poll; +use parking_lot::Mutex; + +use std::convert::Infallible; +use std::pin::Pin; +use std::sync::Arc; +use std::task::{Context, Poll, Waker}; + +enum SinkState { + Empty { + read_waker: Option, + }, + Item { + item: T, + ready_waker: Option, + flush_waker: Option, + }, +} + +/// The sink half of a single-item sink that does not resolve until the item has been read. +pub struct SingleItemSink(Arc>>); + +/// The stream half of a single-item sink. +pub struct SingleItemStream(Arc>>); + +impl Sink for SingleItemSink { + type Error = Infallible; + + fn poll_ready( + self: Pin<&mut Self>, + cx: &mut Context, + ) -> Poll> { + let mut state = self.0.lock(); + match *state { + SinkState::Empty { .. } => Poll::Ready(Ok(())), + SinkState::Item { ref mut ready_waker, .. } => { + *ready_waker = Some(cx.waker().clone()); + Poll::Pending + } + } + } + + fn start_send( + self: Pin<&mut Self>, + item: T, + ) -> Result<(), Infallible> { + let mut state = self.0.lock(); + + match *state { + SinkState::Empty { ref mut read_waker } => { + if let Some(waker) = read_waker.take() { + waker.wake(); + } + } + _ => panic!("start_send called outside of empty sink state ensured by poll_ready"), + } + + *state = SinkState::Item { + item, + ready_waker: None, + flush_waker: None, + }; + + Ok(()) + } + + fn poll_flush( + self: Pin<&mut Self>, + cx: &mut Context, + ) -> Poll> { + let mut state = self.0.lock(); + match *state { + SinkState::Empty { .. } => Poll::Ready(Ok(())), + SinkState::Item { ref mut flush_waker, .. } => { + *flush_waker = Some(cx.waker().clone()); + Poll::Pending + } + } + } + + fn poll_close( + self: Pin<&mut Self>, + cx: &mut Context, + ) -> Poll> { + self.poll_flush(cx) + } +} + +impl Stream for SingleItemStream { + type Item = T; + + fn poll_next(self: Pin<&mut Self>, cx: &mut Context) -> Poll> { + let mut state = self.0.lock(); + + let read_waker = Some(cx.waker().clone()); + + match std::mem::replace(&mut *state, SinkState::Empty { read_waker }) { + SinkState::Empty { .. } => Poll::Pending, + SinkState::Item { item, ready_waker, flush_waker } => { + if let Some(waker) = ready_waker { + waker.wake(); + } + + if let Some(waker) = flush_waker { + waker.wake(); + } + + Poll::Ready(Some(item)) + } + } + } +} + +/// Create a single-item Sink/Stream pair. +/// +/// The sink's send methods resolve at the point which the stream reads the item, +/// not when the item is buffered. +pub fn single_item_sink() -> (SingleItemSink, SingleItemStream) { + let inner = Arc::new(Mutex::new(SinkState::Empty { read_waker: None })); + ( + SingleItemSink(inner.clone()), + SingleItemStream(inner), + ) +} + +/// A test subsystem context. +pub struct TestSubsystemContext { + tx: mpsc::UnboundedSender, + rx: SingleItemStream>, + spawn: S, +} + +#[async_trait::async_trait] +impl SubsystemContext for TestSubsystemContext { + type Message = M; + + async fn try_recv(&mut self) -> Result>, ()> { + match poll!(self.rx.next()) { + Poll::Ready(Some(msg)) => Ok(Some(msg)), + Poll::Ready(None) => Err(()), + Poll::Pending => Ok(None), + } + } + + async fn recv(&mut self) -> SubsystemResult> { + self.rx.next().await.ok_or(SubsystemError) + } + + async fn spawn(&mut self, s: Pin + Send>>) -> SubsystemResult<()> { + self.spawn.spawn(s).map_err(Into::into) + } + + async fn send_message(&mut self, msg: AllMessages) -> SubsystemResult<()> { + self.tx.send(msg).await.expect("test overseer no longer live"); + Ok(()) + } + + async fn send_messages(&mut self, msgs: T) -> SubsystemResult<()> + where T: IntoIterator + Send, T::IntoIter: Send + { + let mut iter = stream::iter(msgs.into_iter().map(Ok)); + self.tx.send_all(&mut iter).await.expect("test overseer no longer live"); + + Ok(()) + } +} + +/// A handle for interacting with the subsystem context. +pub struct TestSubsystemContextHandle { + tx: SingleItemSink>, + rx: mpsc::UnboundedReceiver, +} + +impl TestSubsystemContextHandle { + /// Send a message or signal to the subsystem. This resolves at the point in time where the + /// subsystem has _read_ the message. + pub async fn send(&mut self, from_overseer: FromOverseer) { + self.tx.send(from_overseer).await.expect("Test subsystem no longer live"); + } + + /// Receive the next message from the subsystem. + pub async fn recv(&mut self) -> AllMessages { + self.rx.next().await.expect("Test subsystem no longer live") + } +} + +/// Make a test subsystem context. +pub fn make_subsystem_context(spawn: S) + -> (TestSubsystemContext, TestSubsystemContextHandle) +{ + let (overseer_tx, overseer_rx) = single_item_sink(); + let (all_messages_tx, all_messages_rx) = mpsc::unbounded(); + + ( + TestSubsystemContext { + tx: all_messages_tx, + rx: overseer_rx, + spawn, + }, + TestSubsystemContextHandle { + tx: overseer_tx, + rx: all_messages_rx + }, + ) +} diff --git a/polkadot/primitives/src/inclusion_inherent.rs b/polkadot/primitives/src/inclusion_inherent.rs new file mode 100644 index 0000000000..ca3f5ec23a --- /dev/null +++ b/polkadot/primitives/src/inclusion_inherent.rs @@ -0,0 +1,23 @@ +// Copyright 2017-2020 Parity Technologies (UK) Ltd. +// This file is part of Polkadot. + +// Polkadot 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. + +// Polkadot 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 Polkadot. If not, see . + +//! Inclusion Inherent primitives define types and constants which can be imported +//! without needing to import the entire inherent module. + +use inherents::InherentIdentifier; + +/// Unique identifier for the Inclusion Inherent +pub const INHERENT_IDENTIFIER: InherentIdentifier = *b"inclusn0"; diff --git a/polkadot/primitives/src/lib.rs b/polkadot/primitives/src/lib.rs index 9167d9910e..24ed6e1eb3 100644 --- a/polkadot/primitives/src/lib.rs +++ b/polkadot/primitives/src/lib.rs @@ -23,6 +23,7 @@ use runtime_primitives::{generic, MultiSignature}; pub use runtime_primitives::traits::{BlakeTwo256, Hash as HashT, Verify, IdentifyAccount}; +pub mod inclusion_inherent; pub mod parachain; pub use parity_scale_codec::Compact; diff --git a/polkadot/primitives/src/parachain.rs b/polkadot/primitives/src/parachain.rs index a24cb5b612..52306174be 100644 --- a/polkadot/primitives/src/parachain.rs +++ b/polkadot/primitives/src/parachain.rs @@ -722,6 +722,12 @@ pub type SignedAvailabilityBitfield = Signed; #[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug)] pub struct SignedAvailabilityBitfields(pub Vec); +impl From> for SignedAvailabilityBitfields { + fn from(fields: Vec) -> SignedAvailabilityBitfields { + SignedAvailabilityBitfields(fields) + } +} + /// A backed (or backable, depending on context) candidate. // TODO: yes, this is roughly the same as AttestedCandidate. // After https://github.com/paritytech/polkadot/issues/1250 diff --git a/polkadot/runtime/kusama/src/lib.rs b/polkadot/runtime/kusama/src/lib.rs index daa19477b5..366f9e33ef 100644 --- a/polkadot/runtime/kusama/src/lib.rs +++ b/polkadot/runtime/kusama/src/lib.rs @@ -886,10 +886,11 @@ impl proxy::Trait for Runtime { pub struct CustomOnRuntimeUpgrade; impl frame_support::traits::OnRuntimeUpgrade for CustomOnRuntimeUpgrade { fn on_runtime_upgrade() -> frame_support::weights::Weight { + treasury::Module::::migrate_retract_tip_for_tip_new(); if scheduler::Module::::migrate_v1_to_t2() { ::MaximumBlockWeight::get() } else { - ::DbWeight::get().reads(1) + ::DbWeight::get().reads(1) + 500_000_000 } } } diff --git a/polkadot/runtime/parachains/src/inclusion_inherent.rs b/polkadot/runtime/parachains/src/inclusion_inherent.rs index 46fe1fee46..ac092f6b48 100644 --- a/polkadot/runtime/parachains/src/inclusion_inherent.rs +++ b/polkadot/runtime/parachains/src/inclusion_inherent.rs @@ -23,18 +23,23 @@ use sp_std::prelude::*; use primitives::{ + inclusion_inherent, parachain::{BackedCandidate, SignedAvailabilityBitfields}, }; use frame_support::{ - decl_storage, decl_module, decl_error, ensure, + decl_error, decl_module, decl_storage, ensure, dispatch::DispatchResult, weights::{DispatchClass, Weight}, traits::Get, }; use system::ensure_none; -use crate::{inclusion, scheduler::{self, FreedReason}}; +use crate::{ + inclusion, + scheduler::{self, FreedReason}, +}; +use inherents::{InherentIdentifier, InherentData, MakeFatalError, ProvideInherent}; -pub trait Trait: inclusion::Trait + scheduler::Trait { } +pub trait Trait: inclusion::Trait + scheduler::Trait {} decl_storage! { trait Store for Module as ParaInclusionInherent { @@ -118,3 +123,23 @@ decl_module! { } } } + +impl ProvideInherent for Module { + type Call = Call; + type Error = MakeFatalError<()>; + const INHERENT_IDENTIFIER: InherentIdentifier = inclusion_inherent::INHERENT_IDENTIFIER; + + fn create_inherent(data: &InherentData) -> Option { + data.get_data(&Self::INHERENT_IDENTIFIER) + .expect("inclusion inherent data failed to decode") + .map(|(signed_bitfields, backed_candidates): (SignedAvailabilityBitfields, Vec>)| { + // Sanity check: session changes can invalidate an inherent, and we _really_ don't want that to happen. + // See github.com/paritytech/polkadot/issues/1327 + if Self::inclusion(system::RawOrigin::None.into(), signed_bitfields.clone(), backed_candidates.clone()).is_ok() { + Call::inclusion(signed_bitfields, backed_candidates) + } else { + Call::inclusion(Vec::new().into(), Vec::new()) + } + }) + } +} diff --git a/polkadot/service/src/lib.rs b/polkadot/service/src/lib.rs index 82e8460437..5cf371ebec 100644 --- a/polkadot/service/src/lib.rs +++ b/polkadot/service/src/lib.rs @@ -30,9 +30,9 @@ use grandpa::{self, FinalityProofProvider as GrandpaFinalityProofProvider}; use sc_executor::native_executor_instance; use log::info; pub use service::{ - AbstractService, Role, PruningMode, TransactionPoolOptions, Error, RuntimeGenesis, + Role, PruningMode, TransactionPoolOptions, Error, RuntimeGenesis, RpcHandlers, TFullClient, TLightClient, TFullBackend, TLightBackend, TFullCallExecutor, TLightCallExecutor, - Configuration, ChainSpec, ServiceBuilderCommand, + Configuration, ChainSpec, ServiceBuilderCommand, ServiceComponents, TaskManager, }; pub use service::config::{DatabaseConfig, PrometheusConfig}; pub use sc_executor::NativeExecutionDispatch; @@ -298,7 +298,10 @@ macro_rules! new_full { let (builder, mut import_setup, inherent_data_providers, mut rpc_setup) = new_full_start!($config, $runtime, $dispatch); - let service = builder + let ServiceComponents { + client, network, select_chain, keystore, transaction_pool, prometheus_registry, + task_manager, telemetry_on_connect_sinks, .. + } = builder .with_finality_proof_provider(|client, backend| { let provider = client as Arc>; Ok(Arc::new(GrandpaFinalityProofProvider::new(backend, provider)) as _) @@ -311,16 +314,10 @@ macro_rules! new_full { let shared_voter_state = rpc_setup.take() .expect("The SharedVoterState is present for Full Services or setup failed before. qed"); - let client = service.client(); let known_oracle = client.clone(); let mut handles = FullNodeHandles::default(); - let select_chain = if let Some(select_chain) = service.select_chain() { - select_chain - } else { - info!("The node cannot start as an authority because it can't select chain."); - return Ok((service, client, handles)); - }; + let select_chain = select_chain.ok_or(ServiceError::SelectChainRequired)?; let gossip_validator_select_chain = select_chain.clone(); let is_known = move |block_hash: &Hash| { @@ -343,13 +340,13 @@ macro_rules! new_full { }; let polkadot_network_service = network_protocol::start( - service.network(), + network.clone(), network_protocol::Config { collating_for: $collating_for, }, (is_known, client.clone()), client.clone(), - service.spawn_task_handle(), + task_manager.spawn_handle(), ).map_err(|e| format!("Could not spawn network worker: {:?}", e))?; let authority_handles = if is_collator || role.is_authority() { @@ -380,14 +377,14 @@ macro_rules! new_full { client: client.clone(), network: polkadot_network_service.clone(), collators: polkadot_network_service.clone(), - spawner: service.spawn_task_handle(), + spawner: task_manager.spawn_handle(), availability_store: availability_store.clone(), select_chain: select_chain.clone(), - keystore: service.keystore(), + keystore: keystore.clone(), max_block_data_size, }.build(); - service.spawn_essential_task_handle().spawn("validation-service", Box::pin(validation_service)); + task_manager.spawn_essential_handle().spawn("validation-service", Box::pin(validation_service)); handles.validation_service_handle = Some(validation_service_handle.clone()); @@ -403,30 +400,29 @@ macro_rules! new_full { let proposer = consensus::ProposerFactory::new( client.clone(), - service.transaction_pool(), + transaction_pool, validation_service_handle, slot_duration, - service.prometheus_registry().as_ref(), + prometheus_registry.as_ref(), ); - let select_chain = service.select_chain().ok_or(ServiceError::SelectChainRequired)?; let can_author_with = consensus_common::CanAuthorWithNativeVersion::new(client.executor().clone()); let block_import = availability_store.block_import( block_import, client.clone(), - service.spawn_task_handle(), - service.keystore(), + task_manager.spawn_handle(), + keystore.clone(), )?; let babe_config = babe::BabeParams { - keystore: service.keystore(), + keystore: keystore.clone(), client: client.clone(), select_chain, block_import, env: proposer, - sync_oracle: service.network(), + sync_oracle: network.clone(), inherent_data_providers: inherent_data_providers.clone(), force_authoring, babe_link, @@ -434,7 +430,7 @@ macro_rules! new_full { }; let babe = babe::start_babe(babe_config)?; - service.spawn_essential_task_handle().spawn_blocking("babe", babe); + task_manager.spawn_essential_handle().spawn_blocking("babe", babe); } if matches!(role, Role::Authority{..} | Role::Sentry{..}) { @@ -443,7 +439,7 @@ macro_rules! new_full { Role::Authority { ref sentry_nodes } => ( sentry_nodes.clone(), authority_discovery::Role::Authority ( - service.keystore(), + keystore.clone(), ), ), Role::Sentry {..} => ( @@ -453,29 +449,28 @@ macro_rules! new_full { _ => unreachable!("Due to outer matches! constraint; qed."), }; - let network = service.network(); let network_event_stream = network.event_stream("authority-discovery"); let dht_event_stream = network_event_stream.filter_map(|e| async move { match e { Event::Dht(e) => Some(e), _ => None, }}).boxed(); let authority_discovery = authority_discovery::AuthorityDiscovery::new( - service.client(), - network, + client.clone(), + network.clone(), sentries, dht_event_stream, authority_discovery_role, - service.prometheus_registry(), + prometheus_registry.clone(), ); - service.spawn_task_handle().spawn("authority-discovery", authority_discovery); + task_manager.spawn_handle().spawn("authority-discovery", authority_discovery); } } // if the node isn't actively participating in consensus then it doesn't // need a keystore, regardless of which protocol we use below. let keystore = if is_authority { - Some(service.keystore() as BareCryptoStorePtr) + Some(keystore as BareCryptoStorePtr) } else { None }; @@ -521,15 +516,15 @@ macro_rules! new_full { let grandpa_config = grandpa::GrandpaParams { config, link: link_half, - network: service.network(), + network: network.clone(), inherent_data_providers: inherent_data_providers.clone(), - telemetry_on_connect: Some(service.telemetry_on_connect_stream()), + telemetry_on_connect: Some(telemetry_on_connect_sinks.on_connect_stream()), voting_rule, - prometheus_registry: service.prometheus_registry(), + prometheus_registry: prometheus_registry.clone(), shared_voter_state, }; - service.spawn_essential_task_handle().spawn_blocking( + task_manager.spawn_essential_handle().spawn_blocking( "grandpa-voter", grandpa::run_grandpa_voter(grandpa_config)? ); @@ -537,12 +532,12 @@ macro_rules! new_full { grandpa::setup_disabled_grandpa( client.clone(), &inherent_data_providers, - service.network(), + network.clone(), )?; } handles.polkadot_network = Some(polkadot_network_service); - (service, client, handles) + (task_manager, client, handles) }} } @@ -632,6 +627,9 @@ macro_rules! new_light { Ok(polkadot_rpc::create_light(light_deps)) })? .build_light() + .map(|ServiceComponents { task_manager, rpc_handlers, .. }| { + (task_manager, rpc_handlers) + }) }} } @@ -661,7 +659,7 @@ pub fn polkadot_new_full( grandpa_pause: Option<(u32, u32)>, ) -> Result<( - impl AbstractService, + TaskManager, Arc, @@ -694,7 +692,7 @@ pub fn kusama_new_full( slot_duration: u64, grandpa_pause: Option<(u32, u32)>, ) -> Result<( - impl AbstractService, + TaskManager, Arc, @@ -729,7 +727,7 @@ pub fn westend_new_full( grandpa_pause: Option<(u32, u32)>, ) -> Result<( - impl AbstractService, + TaskManager, Arc, @@ -765,40 +763,24 @@ pub struct FullNodeHandles { /// Create a new Polkadot service for a light client. pub fn polkadot_new_light(mut config: Configuration) -> Result< - impl AbstractService< - Block = Block, - RuntimeApi = polkadot_runtime::RuntimeApi, - Backend = TLightBackend, - SelectChain = LongestChain, Block>, - CallExecutor = TLightCallExecutor, - >, ServiceError> + (TaskManager, Arc), ServiceError +> { new_light!(config, polkadot_runtime::RuntimeApi, PolkadotExecutor) } /// Create a new Kusama service for a light client. pub fn kusama_new_light(mut config: Configuration) -> Result< - impl AbstractService< - Block = Block, - RuntimeApi = kusama_runtime::RuntimeApi, - Backend = TLightBackend, - SelectChain = LongestChain, Block>, - CallExecutor = TLightCallExecutor, - >, ServiceError> + (TaskManager, Arc), ServiceError +> { new_light!(config, kusama_runtime::RuntimeApi, KusamaExecutor) } /// Create a new Westend service for a light client. pub fn westend_new_light(mut config: Configuration, ) -> Result< - impl AbstractService< - Block = Block, - RuntimeApi = westend_runtime::RuntimeApi, - Backend = TLightBackend, - SelectChain = LongestChain, Block>, - CallExecutor = TLightCallExecutor - >, - ServiceError> + (TaskManager, Arc), ServiceError +> { new_light!(config, westend_runtime::RuntimeApi, KusamaExecutor) }