diff --git a/Cargo.lock b/Cargo.lock index 16e048f774230..7a5ef8e09ae7b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -218,20 +218,19 @@ dependencies = [ [[package]] name = "async-io" -version = "1.3.1" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9315f8f07556761c3e48fec2e6b276004acf426e6dc068b2c2251854d65ee0fd" +checksum = "a811e6a479f2439f0c04038796b5cfb3d2ad56c230e0f2d3f7b04d68cfee607b" dependencies = [ "concurrent-queue", - "fastrand", "futures-lite", "libc", "log 0.4.16", - "nb-connect", "once_cell", "parking", "polling", - "vec-arena", + "slab", + "socket2 0.4.4", "waker-fn", "winapi 0.3.9", ] @@ -254,6 +253,23 @@ dependencies = [ "event-listener", ] +[[package]] +name = "async-process" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83137067e3a2a6a06d67168e49e68a0957d215410473a740cea95a2425c0b7c6" +dependencies = [ + "async-io", + "blocking", + "cfg-if 1.0.0", + "event-listener", + "futures-lite", + "libc", + "once_cell", + "signal-hook", + "winapi 0.3.9", +] + [[package]] name = "async-std" version = "1.11.0" @@ -265,6 +281,7 @@ dependencies = [ "async-global-executor", "async-io", "async-lock", + "async-process", "crossbeam-utils 0.8.5", "futures-channel", "futures-core", @@ -284,15 +301,16 @@ dependencies = [ [[package]] name = "async-std-resolver" -version = "0.20.1" +version = "0.21.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f665c56111e244fe38e7708ee10948a4356ad6a548997c21f5a63a0f4e0edc4d" +checksum = "0f2f8a4a203be3325981310ab243a28e6e4ea55b6519bffce05d41ab60e09ad8" dependencies = [ "async-std", "async-trait", "futures-io", "futures-util", "pin-utils", + "socket2 0.4.4", "trust-dns-resolver", ] @@ -612,17 +630,6 @@ dependencies = [ "wyz", ] -[[package]] -name = "blake2" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10a5720225ef5daecf08657f23791354e1685a8c91a4c60c7f3d3b2892f978f4" -dependencies = [ - "crypto-mac 0.8.0", - "digest 0.9.0", - "opaque-debug 0.3.0", -] - [[package]] name = "blake2" version = "0.10.2" @@ -916,21 +923,21 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chacha20" -version = "0.7.1" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fee7ad89dc1128635074c268ee661f90c3f7e83d9fd12910608c36b47d6c3412" +checksum = "01b72a433d0cf2aef113ba70f62634c56fddb0f244e6377185c56a7cadbd8f91" dependencies = [ "cfg-if 1.0.0", "cipher", - "cpufeatures 0.1.5", + "cpufeatures 0.2.1", "zeroize", ] [[package]] name = "chacha20poly1305" -version = "0.8.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1580317203210c517b6d44794abfbe600698276db18127e37ad3e69bf5e848e5" +checksum = "3b84ed6d1d5f7aa9bdde921a5090e0ca4d934d250ea3b402a5fab3a994e28a2a" dependencies = [ "aead", "chacha20", @@ -1094,9 +1101,9 @@ checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" [[package]] name = "core-foundation" -version = "0.9.1" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a89e2ae426ea83155dccf10c0fa6b1463ef6d5fcb44cee0b224a408fa640a62" +checksum = "194a7a9e6de53fa55116934067c844d9d749312f75c6f6d0980e8c252f8c2146" dependencies = [ "core-foundation-sys", "libc", @@ -1104,9 +1111,18 @@ dependencies = [ [[package]] name = "core-foundation-sys" -version = "0.8.2" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea221b5284a47e40033bf9b66f35f984ec0ea2931eb03505246cd27a963f981b" +checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" + +[[package]] +name = "core2" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b49ba7ef1ad6107f8824dbe97de947cbaac53c44e7f9756a1fba0d37c1eec505" +dependencies = [ + "memchr", +] [[package]] name = "cpp_demangle" @@ -1528,6 +1544,19 @@ dependencies = [ "zeroize", ] +[[package]] +name = "curve25519-dalek" +version = "4.0.0-pre.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4033478fbf70d6acf2655ac70da91ee65852d69daf7a67bf7a2f518fb47aafcf" +dependencies = [ + "byteorder", + "digest 0.9.0", + "rand_core 0.6.2", + "subtle", + "zeroize", +] + [[package]] name = "darling" version = "0.13.0" @@ -1734,9 +1763,9 @@ checksum = "9ea835d29036a4087793836fa931b08837ad5e957da9e23886b29586fb9b6650" [[package]] name = "dtoa" -version = "0.4.8" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56899898ce76aaf4a0f24d914c97ea6ed976d42fec6ad33fcbb0a1103e07b2b0" +checksum = "5caaa75cbd2b960ff1e5392d2cfb1f44717fffe12fc1f32b7b5d1267f99732a6" [[package]] name = "dyn-clonable" @@ -1858,11 +1887,11 @@ checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" [[package]] name = "enum-as-inner" -version = "0.3.3" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c5f0096a91d210159eceb2ff5e1c4da18388a170e1e3ce948aac9c8fdbbf595" +checksum = "21cdad81446a7f7dc43f6a77409efeb9733d2fa65553efef6018ef257c959b73" dependencies = [ - "heck 0.3.2", + "heck 0.4.0", "proc-macro2", "quote", "syn", @@ -2598,13 +2627,13 @@ dependencies = [ [[package]] name = "futures-rustls" -version = "0.21.1" +version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a1387e07917c711fb4ee4f48ea0adb04a3c9739e53ef85bf43ae1edc2937a8b" +checksum = "e01fe9932a224b72b45336d96040aa86386d674a31d0af27d800ea7bc8ca97fe" dependencies = [ "futures-io", - "rustls 0.19.1", - "webpki 0.21.4", + "rustls 0.20.2", + "webpki 0.22.0", ] [[package]] @@ -3103,9 +3132,9 @@ dependencies = [ [[package]] name = "idna" -version = "0.2.2" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89829a5d69c23d348314a7ac337fe39173b61149a9864deabd260983aed48c21" +checksum = "418a0a6fab821475f634efe3ccc45c013f742efe03d853e8d3355d5cb850ecf8" dependencies = [ "matches", "unicode-bidi", @@ -3114,39 +3143,30 @@ dependencies = [ [[package]] name = "if-addrs" -version = "0.6.5" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28538916eb3f3976311f5dfbe67b5362d0add1293d0a9cad17debf86f8e3aa48" +checksum = "cbc0fa01ffc752e9dbc72818cdb072cd028b86be5e09dd04c5a643704fe101a9" dependencies = [ - "if-addrs-sys", "libc", "winapi 0.3.9", ] -[[package]] -name = "if-addrs-sys" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de74b9dd780476e837e5eb5ab7c88b49ed304126e412030a0adba99c8efe79ea" -dependencies = [ - "cc", - "libc", -] - [[package]] name = "if-watch" -version = "0.2.0" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a6d52908d4ea4ab2bc22474ba149bf1011c8e2c3ebc1ff593ae28ac44f494b6" +checksum = "ae8f4a3c3d4c89351ca83e120c1c00b27df945d38e05695668c9d4b4f7bc52f3" dependencies = [ "async-io", + "core-foundation", + "fnv", "futures 0.3.21", - "futures-lite", "if-addrs", "ipnet", - "libc", "log 0.4.16", - "winapi 0.3.9", + "rtnetlink", + "system-configuration", + "windows", ] [[package]] @@ -3191,9 +3211,9 @@ dependencies = [ [[package]] name = "instant" -version = "0.1.9" +version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61124eeebbd69b8190558df225adf7e4caafce0d743919e5d6b19652314ec5ec" +checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" dependencies = [ "cfg-if 1.0.0", ] @@ -3230,11 +3250,11 @@ checksum = "aa2f047c0a98b2f299aa5d6d7088443570faae494e9ae1305e48be000c9e0eb1" [[package]] name = "ipconfig" -version = "0.2.2" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7e2f18aece9709094573a9f24f483c4f65caa4298e2f7ae1b71cc65d853fad7" +checksum = "723519edce41262b05d4143ceb95050e4c614f483e78e9fd9e39a8275a84ad98" dependencies = [ - "socket2 0.3.19", + "socket2 0.4.4", "widestring", "winapi 0.3.9", "winreg", @@ -3242,9 +3262,9 @@ dependencies = [ [[package]] name = "ipnet" -version = "2.3.0" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47be2f14c678be2fdcab04ab1171db51b2762ce6f0a8ee87c8dd4a04ed216135" +checksum = "879d54834c8c76457ef4293a689b2a8c59b076067ad77b15efafbb05f92a592b" [[package]] name = "itertools" @@ -3451,7 +3471,7 @@ dependencies = [ "tokio-rustls 0.23.2", "tokio-util 0.7.1", "tracing", - "webpki-roots 0.22.2", + "webpki-roots", ] [[package]] @@ -3671,14 +3691,18 @@ checksum = "c7d73b3f436185384286bd8098d17ec07c9a7d2388a6599f824d8502b529702a" [[package]] name = "libp2p" -version = "0.40.0" +version = "0.44.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3bec54343492ba5940a6c555e512c6721139835d28c59bc22febece72dfd0d9d" +checksum = "475ce2ac4a9727e53a519f6ee05b38abfcba8f0d39c4d24f103d184e36fd5b0f" dependencies = [ "atomic", "bytes 1.1.0", "futures 0.3.21", + "futures-timer", + "getrandom 0.2.3", + "instant", "lazy_static", + "libp2p-autonat", "libp2p-core", "libp2p-deflate", "libp2p-dns", @@ -3704,17 +3728,36 @@ dependencies = [ "libp2p-websocket", "libp2p-yamux", "multiaddr", - "parking_lot 0.11.2", + "parking_lot 0.12.0", "pin-project 1.0.10", + "rand 0.7.3", "smallvec 1.8.0", - "wasm-timer", +] + +[[package]] +name = "libp2p-autonat" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a13b690e65046af6a09c0b27bd9508fa1cab0efce889de74b0b643b9d2a98f9a" +dependencies = [ + "async-trait", + "futures 0.3.21", + "futures-timer", + "instant", + "libp2p-core", + "libp2p-request-response", + "libp2p-swarm", + "log 0.4.16", + "prost", + "prost-build", + "rand 0.8.4", ] [[package]] name = "libp2p-core" -version = "0.30.0" +version = "0.32.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef22d9bba1e8bcb7ec300073e6802943fe8abb8190431842262b5f1c30abba1" +checksum = "db5b02602099fb75cb2d16f9ea860a320d6eb82ce41e95ab680912c454805cd5" dependencies = [ "asn1_der", "bs58", @@ -3723,32 +3766,33 @@ dependencies = [ "fnv", "futures 0.3.21", "futures-timer", + "instant", "lazy_static", "libsecp256k1", "log 0.4.16", "multiaddr", - "multihash 0.14.0", + "multihash 0.16.2", "multistream-select", - "parking_lot 0.11.2", + "parking_lot 0.12.0", "pin-project 1.0.10", "prost", "prost-build", "rand 0.8.4", "ring", "rw-stream-sink", - "sha2 0.9.8", + "sha2 0.10.2", "smallvec 1.8.0", "thiserror", - "unsigned-varint 0.7.0", + "unsigned-varint 0.7.1", "void", "zeroize", ] [[package]] name = "libp2p-deflate" -version = "0.30.0" +version = "0.32.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51a800adb195f33de63f4b17b63fe64cfc23bf2c6a0d3d0d5321328664e65197" +checksum = "6b1d37f042f748e224f04785d0e987ae09a2aa518d6401d82d412dad83e360ed" dependencies = [ "flate2", "futures 0.3.21", @@ -3757,9 +3801,9 @@ dependencies = [ [[package]] name = "libp2p-dns" -version = "0.30.0" +version = "0.32.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb8f89d15cb6e3c5bc22afff7513b11bab7856f2872d3cfba86f7f63a06bc498" +checksum = "066e33e854e10b5c93fc650458bf2179c7e0d143db260b0963e44a94859817f1" dependencies = [ "async-std-resolver", "futures 0.3.21", @@ -3771,9 +3815,9 @@ dependencies = [ [[package]] name = "libp2p-floodsub" -version = "0.31.0" +version = "0.35.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aab3d7210901ea51b7bae2b581aa34521797af8c4ec738c980bda4a06434067f" +checksum = "733d3ea6ebe7a7a85df2bc86678b93f24b015fae5fe3b3acc4c400e795a55d2d" dependencies = [ "cuckoofilter", "fnv", @@ -3789,9 +3833,9 @@ dependencies = [ [[package]] name = "libp2p-gossipsub" -version = "0.33.0" +version = "0.37.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfeead619eb5dac46e65acc78c535a60aaec803d1428cca6407c3a4fc74d698d" +checksum = "a90c989a7c0969c2ab63e898da9bc735e3be53fb4f376e9c045ce516bcc9f928" dependencies = [ "asynchronous-codec 0.6.0", "base64 0.13.0", @@ -3800,41 +3844,43 @@ dependencies = [ "fnv", "futures 0.3.21", "hex_fmt", + "instant", "libp2p-core", "libp2p-swarm", "log 0.4.16", + "prometheus-client", "prost", "prost-build", "rand 0.7.3", "regex", - "sha2 0.9.8", + "sha2 0.10.2", "smallvec 1.8.0", - "unsigned-varint 0.7.0", + "unsigned-varint 0.7.1", "wasm-timer", ] [[package]] name = "libp2p-identify" -version = "0.31.0" +version = "0.35.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cca1275574183f288ff8b72d535d5ffa5ea9292ef7829af8b47dcb197c7b0dcd" +checksum = "c5ef5a5b57904c7c33d6713ef918d239dc6b7553458f3475d87f8a18e9c651c8" dependencies = [ "futures 0.3.21", + "futures-timer", "libp2p-core", "libp2p-swarm", "log 0.4.16", - "lru 0.6.6", + "lru", "prost", "prost-build", "smallvec 1.8.0", - "wasm-timer", ] [[package]] name = "libp2p-kad" -version = "0.32.0" +version = "0.36.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2297dc0ca285f3a09d1368bde02449e539b46f94d32d53233f53f6625bcd3ba" +checksum = "564e6bd64d177446399ed835b9451a8825b07929d6daa6a94e6405592974725e" dependencies = [ "arrayvec 0.5.2", "asynchronous-codec 0.6.0", @@ -3842,25 +3888,27 @@ dependencies = [ "either", "fnv", "futures 0.3.21", + "futures-timer", + "instant", "libp2p-core", "libp2p-swarm", "log 0.4.16", "prost", "prost-build", "rand 0.7.3", - "sha2 0.9.8", + "sha2 0.10.2", "smallvec 1.8.0", + "thiserror", "uint", - "unsigned-varint 0.7.0", + "unsigned-varint 0.7.1", "void", - "wasm-timer", ] [[package]] name = "libp2p-mdns" -version = "0.32.0" +version = "0.36.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14c864b64bdc8a84ff3910a0df88e6535f256191a450870f1e7e10cbf8e64d45" +checksum = "611ae873c8e280ccfab0d57c7a13cac5644f364529e233114ff07863946058b0" dependencies = [ "async-io", "data-encoding", @@ -3879,23 +3927,25 @@ dependencies = [ [[package]] name = "libp2p-metrics" -version = "0.1.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4af432fcdd2f8ba4579b846489f8f0812cfd738ced2c0af39df9b1c48bbb6ab2" +checksum = "985be799bb3796e0c136c768208c3c06604a38430571906a13dcfeda225a3b9d" dependencies = [ "libp2p-core", + "libp2p-gossipsub", "libp2p-identify", "libp2p-kad", "libp2p-ping", + "libp2p-relay", "libp2p-swarm", - "open-metrics-client", + "prometheus-client", ] [[package]] name = "libp2p-mplex" -version = "0.30.0" +version = "0.32.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f2cd64ef597f40e14bfce0497f50ecb63dd6d201c61796daeb4227078834fbf" +checksum = "442eb0c9fff0bf22a34f015724b4143ce01877e079ed0963c722d94c07c72160" dependencies = [ "asynchronous-codec 0.6.0", "bytes 1.1.0", @@ -3903,17 +3953,17 @@ dependencies = [ "libp2p-core", "log 0.4.16", "nohash-hasher", - "parking_lot 0.11.2", + "parking_lot 0.12.0", "rand 0.7.3", "smallvec 1.8.0", - "unsigned-varint 0.7.0", + "unsigned-varint 0.7.1", ] [[package]] name = "libp2p-noise" -version = "0.33.0" +version = "0.35.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8772c7a99088221bb7ca9c5c0574bf55046a7ab4c319f3619b275f28c8fb87a" +checksum = "9dd7e0c94051cda67123be68cf6b65211ba3dde7277be9068412de3e7ffd63ef" dependencies = [ "bytes 1.1.0", "curve25519-dalek 3.0.2", @@ -3924,7 +3974,7 @@ dependencies = [ "prost", "prost-build", "rand 0.8.4", - "sha2 0.9.8", + "sha2 0.10.2", "snow", "static_assertions", "x25519-dalek", @@ -3933,24 +3983,25 @@ dependencies = [ [[package]] name = "libp2p-ping" -version = "0.31.0" +version = "0.35.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80ef7b0ec5cf06530d9eb6cf59ae49d46a2c45663bde31c25a12f682664adbcf" +checksum = "bf57a3c2e821331dda9fe612d4654d676ab6e33d18d9434a18cced72630df6ad" dependencies = [ "futures 0.3.21", + "futures-timer", + "instant", "libp2p-core", "libp2p-swarm", "log 0.4.16", "rand 0.7.3", "void", - "wasm-timer", ] [[package]] name = "libp2p-plaintext" -version = "0.30.0" +version = "0.32.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fba1a6ff33e4a274c89a3b1d78b9f34f32af13265cc5c46c16938262d4e945a" +checksum = "962c0fb0e7212fb96a69b87f2d09bcefd317935239bdc79cda900e7a8897a3fe" dependencies = [ "asynchronous-codec 0.6.0", "bytes 1.1.0", @@ -3959,7 +4010,7 @@ dependencies = [ "log 0.4.16", "prost", "prost-build", - "unsigned-varint 0.7.0", + "unsigned-varint 0.7.1", "void", ] @@ -3979,89 +4030,96 @@ dependencies = [ [[package]] name = "libp2p-relay" -version = "0.4.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2852b61c90fa8ce3c8fcc2aba76e6cefc20d648f9df29157d6b3a916278ef3e3" +checksum = "3aa754cb7bccef51ebc3c458c6bbcef89d83b578a9925438389be841527d408f" dependencies = [ "asynchronous-codec 0.6.0", "bytes 1.1.0", + "either", "futures 0.3.21", "futures-timer", + "instant", "libp2p-core", "libp2p-swarm", "log 0.4.16", "pin-project 1.0.10", "prost", "prost-build", - "rand 0.7.3", + "rand 0.8.4", "smallvec 1.8.0", - "unsigned-varint 0.7.0", + "static_assertions", + "thiserror", + "unsigned-varint 0.7.1", "void", - "wasm-timer", ] [[package]] name = "libp2p-rendezvous" -version = "0.1.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14a6d2b9e7677eff61dc3d2854876aaf3976d84a01ef6664b610c77a0c9407c5" +checksum = "bbd0baab894c5b84da510b915d53264d566c3c35889f09931fe9edbd2a773bee" dependencies = [ "asynchronous-codec 0.6.0", "bimap", "futures 0.3.21", + "futures-timer", + "instant", "libp2p-core", "libp2p-swarm", "log 0.4.16", "prost", "prost-build", "rand 0.8.4", - "sha2 0.9.8", + "sha2 0.10.2", "thiserror", - "unsigned-varint 0.7.0", + "unsigned-varint 0.7.1", "void", - "wasm-timer", ] [[package]] name = "libp2p-request-response" -version = "0.13.0" +version = "0.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a877a4ced6d46bf84677e1974e8cf61fb434af73b2e96fb48d6cb6223a4634d8" +checksum = "b5e6a6fc6c9ad95661f46989473b34bd2993d14a4de497ff3b2668a910d4b869" dependencies = [ "async-trait", "bytes 1.1.0", "futures 0.3.21", + "instant", "libp2p-core", "libp2p-swarm", "log 0.4.16", - "lru 0.7.5", "rand 0.7.3", "smallvec 1.8.0", - "unsigned-varint 0.7.0", - "wasm-timer", + "unsigned-varint 0.7.1", ] [[package]] name = "libp2p-swarm" -version = "0.31.0" +version = "0.35.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f5184a508f223bc100a12665517773fb8730e9f36fc09eefb670bf01b107ae9" +checksum = "8f0c69ad9e8f7c5fc50ad5ad9c7c8b57f33716532a2b623197f69f93e374d14c" dependencies = [ "either", + "fnv", "futures 0.3.21", + "futures-timer", + "instant", "libp2p-core", "log 0.4.16", + "pin-project 1.0.10", "rand 0.7.3", "smallvec 1.8.0", + "thiserror", "void", - "wasm-timer", ] [[package]] name = "libp2p-swarm-derive" -version = "0.25.0" +version = "0.27.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "072c290f727d39bdc4e9d6d1c847978693d25a673bd757813681e33e5f6c00c2" +checksum = "daf2fe8c80b43561355f4d51875273b5b6dfbac37952e8f64b1270769305c9d7" dependencies = [ "quote", "syn", @@ -4069,9 +4127,9 @@ dependencies = [ [[package]] name = "libp2p-tcp" -version = "0.30.0" +version = "0.32.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7399c5b6361ef525d41c11fcf51635724f832baf5819b30d3d873eabb4fbae4b" +checksum = "193447aa729c85aac2376828df76d171c1a589c9e6b58fcc7f9d9a020734122c" dependencies = [ "async-io", "futures 0.3.21", @@ -4086,9 +4144,9 @@ dependencies = [ [[package]] name = "libp2p-uds" -version = "0.30.0" +version = "0.32.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8b7563e46218165dfd60f64b96f7ce84590d75f53ecbdc74a7dd01450dc5973" +checksum = "24bdab114f7f2701757d6541266e1131b429bbae382008f207f2114ee4222dcb" dependencies = [ "async-std", "futures 0.3.21", @@ -4098,9 +4156,9 @@ dependencies = [ [[package]] name = "libp2p-wasm-ext" -version = "0.30.0" +version = "0.32.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1008a302b73c5020251f9708c653f5ed08368e530e247cc9cd2f109ff30042cf" +checksum = "4f6ea0f84a967ef59a16083f222c18115ae2e91db69809dce275df62e101b279" dependencies = [ "futures 0.3.21", "js-sys", @@ -4112,9 +4170,9 @@ dependencies = [ [[package]] name = "libp2p-websocket" -version = "0.31.0" +version = "0.34.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22e12df82d1ed64969371a9e65ea92b91064658604cc2576c2757f18ead9a1cf" +checksum = "c932834c3754501c368d1bf3d0fb458487a642b90fc25df082a3a2f3d3b32e37" dependencies = [ "either", "futures 0.3.21", @@ -4125,18 +4183,18 @@ dependencies = [ "rw-stream-sink", "soketto", "url 2.2.1", - "webpki-roots 0.21.0", + "webpki-roots", ] [[package]] name = "libp2p-yamux" -version = "0.34.0" +version = "0.36.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e7362abb8867d7187e7e93df17f460d554c997fc5c8ac57dc1259057f6889af" +checksum = "be902ebd89193cd020e89e89107726a38cfc0d16d18f613f4a37d046e92c7517" dependencies = [ "futures 0.3.21", "libp2p-core", - "parking_lot 0.11.2", + "parking_lot 0.12.0", "thiserror", "yamux", ] @@ -4323,15 +4381,6 @@ dependencies = [ "syn", ] -[[package]] -name = "lru" -version = "0.6.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ea2d928b485416e8908cff2d97d621db22b27f7b3b6729e438bcf42c671ba91" -dependencies = [ - "hashbrown 0.11.2", -] - [[package]] name = "lru" version = "0.7.5" @@ -4592,19 +4641,19 @@ checksum = "0debeb9fcf88823ea64d64e4a815ab1643f33127d995978e099942ce38f25238" [[package]] name = "multiaddr" -version = "0.13.0" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48ee4ea82141951ac6379f964f71b20876d43712bea8faf6dd1a375e08a46499" +checksum = "3c580bfdd8803cce319b047d239559a22f809094aaea4ac13902a1fdcfcd4261" dependencies = [ "arrayref", "bs58", "byteorder", "data-encoding", - "multihash 0.14.0", + "multihash 0.16.2", "percent-encoding 2.1.0", "serde", "static_assertions", - "unsigned-varint 0.7.0", + "unsigned-varint 0.7.1", "url 2.2.1", ] @@ -4630,7 +4679,7 @@ dependencies = [ "blake3", "digest 0.9.0", "generic-array 0.14.4", - "multihash-derive", + "multihash-derive 0.7.2", "sha2 0.9.8", "sha3 0.9.1", "unsigned-varint 0.5.1", @@ -4638,15 +4687,15 @@ dependencies = [ [[package]] name = "multihash" -version = "0.14.0" +version = "0.16.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "752a61cd890ff691b4411423d23816d5866dd5621e4d1c5687a53b94b5a979d8" +checksum = "e3db354f401db558759dfc1e568d010a5d4146f4d3f637be1275ec4a3cf09689" dependencies = [ - "digest 0.9.0", - "generic-array 0.14.4", - "multihash-derive", - "sha2 0.9.8", - "unsigned-varint 0.7.0", + "core2", + "digest 0.10.3", + "multihash-derive 0.8.0", + "sha2 0.10.2", + "unsigned-varint 0.7.1", ] [[package]] @@ -4663,6 +4712,20 @@ dependencies = [ "synstructure", ] +[[package]] +name = "multihash-derive" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc076939022111618a5026d3be019fd8b366e76314538ff9a1b59ffbcbf98bcd" +dependencies = [ + "proc-macro-crate 1.1.3", + "proc-macro-error", + "proc-macro2", + "quote", + "syn", + "synstructure", +] + [[package]] name = "multimap" version = "0.8.2" @@ -4671,16 +4734,16 @@ checksum = "1255076139a83bb467426e7f8d0134968a8118844faa755985e077cf31850333" [[package]] name = "multistream-select" -version = "0.10.2" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d91ec0a2440aaff5f78ec35631a7027d50386c6163aa975f7caa0d5da4b6ff8" +checksum = "363a84be6453a70e63513660f4894ef815daf88e3356bffcda9ca27d810ce83b" dependencies = [ "bytes 1.1.0", "futures 0.3.21", "log 0.4.16", "pin-project 1.0.10", "smallvec 1.8.0", - "unsigned-varint 0.7.0", + "unsigned-varint 0.7.1", ] [[package]] @@ -4740,24 +4803,92 @@ dependencies = [ ] [[package]] -name = "nb-connect" -version = "1.0.3" +name = "net2" +version = "0.2.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "670361df1bc2399ee1ff50406a0d422587dd3bb0da596e1978fe8e05dabddf4f" +checksum = "391630d12b68002ae1e25e8f974306474966550ad82dac6886fb8910c19568ae" dependencies = [ + "cfg-if 0.1.10", "libc", - "socket2 0.3.19", + "winapi 0.3.9", ] [[package]] -name = "net2" -version = "0.2.37" +name = "netlink-packet-core" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "391630d12b68002ae1e25e8f974306474966550ad82dac6886fb8910c19568ae" +checksum = "345b8ab5bd4e71a2986663e88c56856699d060e78e152e6e9d7966fcd5491297" dependencies = [ - "cfg-if 0.1.10", + "anyhow", + "byteorder", "libc", - "winapi 0.3.9", + "netlink-packet-utils", +] + +[[package]] +name = "netlink-packet-route" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "733ea73609acfd7fa7ddadfb7bf709b0471668c456ad9513685af543a06342b2" +dependencies = [ + "anyhow", + "bitflags", + "byteorder", + "libc", + "netlink-packet-core", + "netlink-packet-utils", +] + +[[package]] +name = "netlink-packet-utils" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25af9cf0dc55498b7bd94a1508af7a78706aa0ab715a73c5169273e03c84845e" +dependencies = [ + "anyhow", + "byteorder", + "paste 1.0.6", + "thiserror", +] + +[[package]] +name = "netlink-proto" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef8785b8141e8432aa45fceb922a7e876d7da3fad37fa7e7ec702ace3aa0826b" +dependencies = [ + "bytes 1.1.0", + "futures 0.3.21", + "log 0.4.16", + "netlink-packet-core", + "netlink-sys", + "tokio", +] + +[[package]] +name = "netlink-sys" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e4c9f9547a08241bee7b6558b9b98e1f290d187de8b7cfca2bbb4937bcaa8f8" +dependencies = [ + "async-io", + "bytes 1.1.0", + "futures 0.3.21", + "libc", + "log 0.4.16", +] + +[[package]] +name = "nix" +version = "0.22.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4916f159ed8e5de0082076562152a76b7a1f64a01fd9d1e0fea002c37624faf" +dependencies = [ + "bitflags", + "cc", + "cfg-if 1.0.0", + "libc", + "memoffset", ] [[package]] @@ -4825,7 +4956,7 @@ dependencies = [ "futures 0.3.21", "hex-literal", "log 0.4.16", - "nix", + "nix 0.23.1", "node-executor", "node-inspect", "node-primitives", @@ -5360,29 +5491,6 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" -[[package]] -name = "open-metrics-client" -version = "0.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7337d80c23c2d8b1349563981bc4fb531220733743ba8115454a67b181173f0d" -dependencies = [ - "dtoa", - "itoa 0.4.8", - "open-metrics-client-derive-text-encode", - "owning_ref", -] - -[[package]] -name = "open-metrics-client-derive-text-encode" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a15c83b586f00268c619c1cb3340ec1a6f59dd9ba1d9833a273a68e6d5cd8ffc" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "openssl" version = "0.10.35" @@ -7348,6 +7456,29 @@ dependencies = [ "thiserror", ] +[[package]] +name = "prometheus-client" +version = "0.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9a896938cc6018c64f279888b8c7559d3725210d5db9a3a1ee6bc7188d51d34" +dependencies = [ + "dtoa", + "itoa 1.0.1", + "owning_ref", + "prometheus-client-derive-text-encode", +] + +[[package]] +name = "prometheus-client-derive-text-encode" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8e12d01b9d66ad9eb4529c57666b6263fc1993cb30261d83ead658fdd932652" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "prost" version = "0.9.0" @@ -7988,6 +8119,21 @@ dependencies = [ "winapi 0.3.9", ] +[[package]] +name = "rtnetlink" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f54290e54521dac3de4149d83ddf9f62a359b3cc93bcb494a794a41e6f4744b" +dependencies = [ + "async-global-executor", + "futures 0.3.21", + "log 0.4.16", + "netlink-packet-route", + "netlink-proto", + "nix 0.22.3", + "thiserror", +] + [[package]] name = "rust-argon2" version = "0.8.3" @@ -8036,6 +8182,15 @@ dependencies = [ "semver 0.11.0", ] +[[package]] +name = "rustc_version" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" +dependencies = [ + "semver 1.0.4", +] + [[package]] name = "rustix" version = "0.33.5" @@ -8625,7 +8780,7 @@ dependencies = [ "env_logger 0.9.0", "hex-literal", "lazy_static", - "lru 0.7.5", + "lru", "parity-scale-codec", "parking_lot 0.12.0", "paste 1.0.6", @@ -8834,7 +8989,7 @@ dependencies = [ "linked-hash-map", "linked_hash_set", "log 0.4.16", - "lru 0.7.5", + "lru", "parity-scale-codec", "parking_lot 0.12.0", "pin-project 1.0.10", @@ -8878,7 +9033,7 @@ dependencies = [ "futures-timer", "libp2p", "log 0.4.16", - "lru 0.7.5", + "lru", "quickcheck", "sc-network", "sp-runtime", @@ -9697,6 +9852,16 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42a568c8f2cd051a4d283bd6eb0343ac214c1b0f1ac19f93e1175b2dee38c73d" +[[package]] +name = "signal-hook" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef33d6d0cd06e0840fba9985aab098c147e67e05cee14d412d3345ed14ff30ac" +dependencies = [ + "libc", + "signal-hook-registry", +] + [[package]] name = "signal-hook-registry" version = "1.3.0" @@ -9757,20 +9922,19 @@ checksum = "45456094d1983e2ee2a18fdfebce3189fa451699d0502cb8e3b49dba5ba41451" [[package]] name = "snow" -version = "0.8.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6142f7c25e94f6fd25a32c3348ec230df9109b463f59c8c7acc4bd34936babb7" +checksum = "774d05a3edae07ce6d68ea6984f3c05e9bba8927e3dd591e3b479e5b03213d0d" dependencies = [ "aes-gcm", - "blake2 0.9.1", + "blake2", "chacha20poly1305", - "rand 0.8.4", + "curve25519-dalek 4.0.0-pre.1", "rand_core 0.6.2", "ring", - "rustc_version 0.3.3", - "sha2 0.9.8", + "rustc_version 0.4.0", + "sha2 0.10.2", "subtle", - "x25519-dalek", ] [[package]] @@ -9831,7 +9995,7 @@ dependencies = [ name = "sp-api-proc-macro" version = "4.0.0-dev" dependencies = [ - "blake2 0.10.2", + "blake2", "proc-macro-crate 1.1.3", "proc-macro2", "quote", @@ -9950,7 +10114,7 @@ version = "4.0.0-dev" dependencies = [ "futures 0.3.21", "log 0.4.16", - "lru 0.7.5", + "lru", "parity-scale-codec", "parking_lot 0.12.0", "sp-api", @@ -10108,7 +10272,7 @@ dependencies = [ name = "sp-core-hashing" version = "4.0.0" dependencies = [ - "blake2 0.10.2", + "blake2", "byteorder", "digest 0.10.3", "sha2 0.10.2", @@ -11001,6 +11165,27 @@ dependencies = [ "unicode-xid", ] +[[package]] +name = "system-configuration" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d75182f12f490e953596550b65ee31bda7c8e043d9386174b353bda50838c3fd" +dependencies = [ + "bitflags", + "core-foundation", + "system-configuration-sys", +] + +[[package]] +name = "system-configuration-sys" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75fb188eb626b924683e3b95e3a48e63551fcfb51949de2f06a9d91dbee93c9" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "tap" version = "1.0.1" @@ -11450,7 +11635,7 @@ dependencies = [ "ahash", "lazy_static", "log 0.4.16", - "lru 0.7.5", + "lru", "tracing-core", ] @@ -11549,9 +11734,9 @@ dependencies = [ [[package]] name = "trust-dns-proto" -version = "0.20.1" +version = "0.21.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d57e219ba600dd96c2f6d82eb79645068e14edbc5c7e27514af40436b88150c" +checksum = "9c31f240f59877c3d4bb3b3ea0ec5a6a0cff07323580ff8c7a605cd7d08b255d" dependencies = [ "async-trait", "cfg-if 1.0.0", @@ -11560,7 +11745,7 @@ dependencies = [ "futures-channel", "futures-io", "futures-util", - "idna 0.2.2", + "idna 0.2.3", "ipnet", "lazy_static", "log 0.4.16", @@ -11573,9 +11758,9 @@ dependencies = [ [[package]] name = "trust-dns-resolver" -version = "0.20.1" +version = "0.21.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0437eea3a6da51acc1e946545ff53d5b8fb2611ff1c3bed58522dde100536ae" +checksum = "e4ba72c2ea84515690c9fcef4c6c660bb9df3036ed1051686de84605b74fd558" dependencies = [ "cfg-if 1.0.0", "futures-util", @@ -11583,7 +11768,7 @@ dependencies = [ "lazy_static", "log 0.4.16", "lru-cache", - "parking_lot 0.11.2", + "parking_lot 0.12.0", "resolv-conf", "smallvec 1.8.0", "thiserror", @@ -11768,9 +11953,9 @@ dependencies = [ [[package]] name = "unsigned-varint" -version = "0.7.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f8d425fafb8cd76bc3f22aace4af471d3156301d7508f2107e98fbeae10bc7f" +checksum = "d86a8dc7f45e4c1b0d30e43038c38f274e77af056aa5f74b93c2cf9eb3c1c836" dependencies = [ "asynchronous-codec 0.6.0", "bytes 1.1.0", @@ -11802,7 +11987,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ccd964113622c8e9322cfac19eb1004a07e636c545f325da085d5cdde6f1f8b" dependencies = [ "form_urlencoded", - "idna 0.2.2", + "idna 0.2.3", "matches", "percent-encoding 2.1.0", ] @@ -12468,15 +12653,6 @@ dependencies = [ "untrusted", ] -[[package]] -name = "webpki-roots" -version = "0.21.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82015b7e0b8bad8185994674a13a93306bea76cf5a16c5a181382fd3a5ec2376" -dependencies = [ - "webpki 0.21.4", -] - [[package]] name = "webpki-roots" version = "0.22.2" @@ -12548,9 +12724,9 @@ dependencies = [ [[package]] name = "widestring" -version = "0.4.3" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c168940144dd21fd8046987c16a46a33d5fc84eec29ef9dcddc2ac9e31526b7c" +checksum = "17882f045410753661207383517a6f62ec3dbeb6a4ed2acce01f0728238d1983" [[package]] name = "winapi" @@ -12595,43 +12771,86 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "windows" +version = "0.29.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aac7fef12f4b59cd0a29339406cc9203ab44e440ddff6b3f5a41455349fa9cf3" +dependencies = [ + "windows_aarch64_msvc 0.29.0", + "windows_i686_gnu 0.29.0", + "windows_i686_msvc 0.29.0", + "windows_x86_64_gnu 0.29.0", + "windows_x86_64_msvc 0.29.0", +] + [[package]] name = "windows-sys" version = "0.32.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3df6e476185f92a12c072be4a189a0210dcdcf512a1891d6dff9edb874deadc6" dependencies = [ - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_msvc", + "windows_aarch64_msvc 0.32.0", + "windows_i686_gnu 0.32.0", + "windows_i686_msvc 0.32.0", + "windows_x86_64_gnu 0.32.0", + "windows_x86_64_msvc 0.32.0", ] +[[package]] +name = "windows_aarch64_msvc" +version = "0.29.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3d027175d00b01e0cbeb97d6ab6ebe03b12330a35786cbaca5252b1c4bf5d9b" + [[package]] name = "windows_aarch64_msvc" version = "0.32.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d8e92753b1c443191654ec532f14c199742964a061be25d77d7a96f09db20bf5" +[[package]] +name = "windows_i686_gnu" +version = "0.29.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8793f59f7b8e8b01eda1a652b2697d87b93097198ae85f823b969ca5b89bba58" + [[package]] name = "windows_i686_gnu" version = "0.32.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a711c68811799e017b6038e0922cb27a5e2f43a2ddb609fe0b6f3eeda9de615" +[[package]] +name = "windows_i686_msvc" +version = "0.29.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8602f6c418b67024be2996c512f5f995de3ba417f4c75af68401ab8756796ae4" + [[package]] name = "windows_i686_msvc" version = "0.32.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "146c11bb1a02615db74680b32a68e2d61f553cc24c4eb5b4ca10311740e44172" +[[package]] +name = "windows_x86_64_gnu" +version = "0.29.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3d615f419543e0bd7d2b3323af0d86ff19cbc4f816e6453f36a2c2ce889c354" + [[package]] name = "windows_x86_64_gnu" version = "0.32.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c912b12f7454c6620635bbff3450962753834be2a594819bd5e945af18ec64bc" +[[package]] +name = "windows_x86_64_msvc" +version = "0.29.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11d95421d9ed3672c280884da53201a5c46b7b2765ca6faf34b0d71cf34a3561" + [[package]] name = "windows_x86_64_msvc" version = "0.32.0" @@ -12640,9 +12859,9 @@ checksum = "504a2476202769977a040c6364301a3f65d0cc9e3fb08600b2bda150a0488316" [[package]] name = "winreg" -version = "0.6.2" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2986deb581c4fe11b621998a5e53361efe6b48a151178d0cd9eeffa4dc6acc9" +checksum = "0120db82e8a1e0b9fb3345a539c478767c0048d842860994d96113d5b667bd69" dependencies = [ "winapi 0.3.9", ] @@ -12679,23 +12898,23 @@ dependencies = [ [[package]] name = "yamux" -version = "0.9.0" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7d9028f208dd5e63c614be69f115c1b53cacc1111437d4c765185856666c107" +checksum = "0c0608f53c1dc0bad505d03a34bbd49fbf2ad7b51eb036123e896365532745a1" dependencies = [ "futures 0.3.21", "log 0.4.16", "nohash-hasher", - "parking_lot 0.11.2", + "parking_lot 0.12.0", "rand 0.8.4", "static_assertions", ] [[package]] name = "zeroize" -version = "1.5.4" +version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7eb5728b8afd3f280a869ce1d4c554ffaed35f45c231fc41bfbd0381bef50317" +checksum = "d68d9dcec5f9b43a30d38c49f91dfedfaac384cb8f085faca366c26207dd1619" dependencies = [ "zeroize_derive", ] diff --git a/client/authority-discovery/Cargo.toml b/client/authority-discovery/Cargo.toml index effc8cd715e1d..0e107b19ce6ab 100644 --- a/client/authority-discovery/Cargo.toml +++ b/client/authority-discovery/Cargo.toml @@ -23,7 +23,7 @@ thiserror = "1.0" futures = "0.3.21" futures-timer = "3.0.1" ip_network = "0.4.1" -libp2p = { version = "0.40.0", default-features = false, features = ["kad"] } +libp2p = { version = "0.44.0", default-features = false, features = ["kad"] } log = "0.4.16" prometheus-endpoint = { package = "substrate-prometheus-endpoint", path = "../../utils/prometheus", version = "0.10.0-dev" } prost = "0.9" diff --git a/client/authority-discovery/src/worker.rs b/client/authority-discovery/src/worker.rs index 726c032281cd8..0912359501385 100644 --- a/client/authority-discovery/src/worker.rs +++ b/client/authority-discovery/src/worker.rs @@ -37,7 +37,7 @@ use codec::Decode; use ip_network::IpNetwork; use libp2p::{ core::multiaddr, - multihash::{Hasher, Multihash}, + multihash::{Multihash, MultihashDigest}, }; use log::{debug, error, log_enabled}; use prometheus_endpoint::{register, Counter, CounterVec, Gauge, Opts, U64}; @@ -638,7 +638,7 @@ where } fn hash_authority_id(id: &[u8]) -> sc_network::KademliaKey { - sc_network::KademliaKey::new(&libp2p::multihash::Sha2_256::digest(id)) + sc_network::KademliaKey::new(&libp2p::multihash::Code::Sha2_256.digest(id).digest()) } // Makes sure all values are the same and returns it diff --git a/client/cli/Cargo.toml b/client/cli/Cargo.toml index adf88b8c88a2c..0495f522c1ade 100644 --- a/client/cli/Cargo.toml +++ b/client/cli/Cargo.toml @@ -18,7 +18,7 @@ clap = { version = "3.1.6", features = ["derive"] } fdlimit = "0.2.1" futures = "0.3.21" hex = "0.4.2" -libp2p = "0.40.0" +libp2p = "0.44.0" log = "0.4.16" names = { version = "0.13.0", default-features = false } rand = "0.7.3" diff --git a/client/consensus/common/Cargo.toml b/client/consensus/common/Cargo.toml index f4f7626ab6b7e..2846a3e7898c5 100644 --- a/client/consensus/common/Cargo.toml +++ b/client/consensus/common/Cargo.toml @@ -14,7 +14,7 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] thiserror = "1.0.30" -libp2p = { version = "0.40.0", default-features = false } +libp2p = { version = "0.44.0", default-features = false } log = "0.4.16" futures = { version = "0.3.21", features = ["thread-pool"] } futures-timer = "3.0.1" diff --git a/client/network-gossip/Cargo.toml b/client/network-gossip/Cargo.toml index 2989ff5b51412..79e07b597c65d 100644 --- a/client/network-gossip/Cargo.toml +++ b/client/network-gossip/Cargo.toml @@ -17,7 +17,7 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] futures = "0.3.21" futures-timer = "3.0.1" -libp2p = { version = "0.40.0", default-features = false } +libp2p = { version = "0.44.0", default-features = false } log = "0.4.16" lru = "0.7.5" ahash = "0.7.6" diff --git a/client/network/Cargo.toml b/client/network/Cargo.toml index 6fe804ce52413..93b389d4361c1 100644 --- a/client/network/Cargo.toml +++ b/client/network/Cargo.toml @@ -61,12 +61,12 @@ unsigned-varint = { version = "0.6.0", features = [ "asynchronous_codec", ] } void = "1.0.2" -zeroize = "1.5.4" -libp2p = "0.40.0" +zeroize = "1.4.3" +libp2p = "0.44.0" [dev-dependencies] assert_matches = "1.3" -libp2p = { version = "0.40.0", default-features = false } +libp2p = { version = "0.44.0", default-features = false } quickcheck = "1.0.3" rand = "0.7.2" sp-test-primitives = { version = "2.0.0", path = "../../primitives/test-primitives" } diff --git a/client/network/src/behaviour.rs b/client/network/src/behaviour.rs index d0de50ef61897..f6a7e9eb87018 100644 --- a/client/network/src/behaviour.rs +++ b/client/network/src/behaviour.rs @@ -33,8 +33,8 @@ use libp2p::{ identify::IdentifyInfo, kad::record, swarm::{ - toggle::Toggle, NetworkBehaviour, NetworkBehaviourAction, NetworkBehaviourEventProcess, - PollParameters, + behaviour::toggle::Toggle, NetworkBehaviour, NetworkBehaviourAction, + NetworkBehaviourEventProcess, PollParameters, }, NetworkBehaviour, }; @@ -304,7 +304,7 @@ impl Behaviour { /// Start querying a record from the DHT. Will later produce either a `ValueFound` or a /// `ValueNotFound` event. - pub fn get_value(&mut self, key: &record::Key) { + pub fn get_value(&mut self, key: record::Key) { self.discovery.get_value(key); } @@ -519,7 +519,7 @@ impl Behaviour { &mut self, _cx: &mut Context, _: &mut impl PollParameters, - ) -> Poll, ::ProtocolsHandler>> + ) -> Poll, ::ConnectionHandler>> { if let Some(event) = self.events.pop_front() { return Poll::Ready(NetworkBehaviourAction::GenerateEvent(event)) diff --git a/client/network/src/bitswap.rs b/client/network/src/bitswap.rs index e7c37968b5f99..da80ab8cb3d33 100644 --- a/client/network/src/bitswap.rs +++ b/client/network/src/bitswap.rs @@ -194,10 +194,10 @@ impl Bitswap { } impl NetworkBehaviour for Bitswap { - type ProtocolsHandler = OneShotHandler; + type ConnectionHandler = OneShotHandler; type OutEvent = void::Void; - fn new_handler(&mut self) -> Self::ProtocolsHandler { + fn new_handler(&mut self) -> Self::ConnectionHandler { Default::default() } @@ -205,10 +205,6 @@ impl NetworkBehaviour for Bitswap { Vec::new() } - fn inject_connected(&mut self, _peer: &PeerId) {} - - fn inject_disconnected(&mut self, _peer: &PeerId) {} - fn inject_event(&mut self, peer: PeerId, _connection: ConnectionId, message: HandlerEvent) { let request = match message { HandlerEvent::ResponseSent => return, @@ -300,7 +296,7 @@ impl NetworkBehaviour for Bitswap { &mut self, _ctx: &mut Context, _: &mut impl PollParameters, - ) -> Poll> { + ) -> Poll> { if let Some((peer_id, message)) = self.ready_blocks.pop_front() { return Poll::Ready(NetworkBehaviourAction::NotifyHandler { peer_id, diff --git a/client/network/src/discovery.rs b/client/network/src/discovery.rs index cf75e2dcb4c65..a916ffda0794d 100644 --- a/client/network/src/discovery.rs +++ b/client/network/src/discovery.rs @@ -67,8 +67,8 @@ use libp2p::{ mdns::{Mdns, MdnsConfig, MdnsEvent}, multiaddr::Protocol, swarm::{ - protocols_handler::multi::IntoMultiHandler, DialError, IntoProtocolsHandler, - NetworkBehaviour, NetworkBehaviourAction, PollParameters, ProtocolsHandler, + handler::multi::IntoMultiHandler, ConnectionHandler, DialError, IntoConnectionHandler, + NetworkBehaviour, NetworkBehaviourAction, PollParameters, }, }; use log::{debug, error, info, trace, warn}; @@ -355,9 +355,9 @@ impl DiscoveryBehaviour { /// Start fetching a record from the DHT. /// /// A corresponding `ValueFound` or `ValueNotFound` event will later be generated. - pub fn get_value(&mut self, key: &record::Key) { + pub fn get_value(&mut self, key: record::Key) { for k in self.kademlias.values_mut() { - k.get_record(key, Quorum::One); + k.get_record(key.clone(), Quorum::One); } } @@ -433,7 +433,7 @@ impl DiscoveryBehaviour { &mut self, pid: ProtocolId, handler: KademliaHandlerProto, - ) -> ::ProtocolsHandler { + ) -> ::ConnectionHandler { let mut handlers: HashMap<_, _> = self .kademlias .iter_mut() @@ -498,10 +498,10 @@ pub enum DiscoveryOut { } impl NetworkBehaviour for DiscoveryBehaviour { - type ProtocolsHandler = IntoMultiHandler>; + type ConnectionHandler = IntoMultiHandler>; type OutEvent = DiscoveryOut; - fn new_handler(&mut self) -> Self::ProtocolsHandler { + fn new_handler(&mut self) -> Self::ConnectionHandler { let iter = self .kademlias .iter_mut() @@ -568,6 +568,7 @@ impl NetworkBehaviour for DiscoveryBehaviour { conn: &ConnectionId, endpoint: &ConnectedPoint, failed_addresses: Option<&Vec>, + other_established: usize, ) { self.num_connections += 1; for k in self.kademlias.values_mut() { @@ -577,37 +578,37 @@ impl NetworkBehaviour for DiscoveryBehaviour { conn, endpoint, failed_addresses, + other_established, ) } } - fn inject_connected(&mut self, peer_id: &PeerId) { - for k in self.kademlias.values_mut() { - NetworkBehaviour::inject_connected(k, peer_id) - } - } - fn inject_connection_closed( &mut self, - _peer_id: &PeerId, - _conn: &ConnectionId, - _endpoint: &ConnectedPoint, - _handler: ::Handler, + peer_id: &PeerId, + conn: &ConnectionId, + endpoint: &ConnectedPoint, + handler: ::Handler, + remaining_established: usize, ) { self.num_connections -= 1; - // NetworkBehaviour::inject_connection_closed on Kademlia does nothing. - } - - fn inject_disconnected(&mut self, peer_id: &PeerId) { - for k in self.kademlias.values_mut() { - NetworkBehaviour::inject_disconnected(k, peer_id) + for (pid, event) in handler.into_iter() { + if let Some(kad) = self.kademlias.get_mut(&pid) { + kad.inject_connection_closed(peer_id, conn, endpoint, event, remaining_established) + } else { + error!( + target: "sub-libp2p", + "inject_connection_closed: no kademlia instance registered for protocol {:?}", + pid, + ) + } } } fn inject_dial_failure( &mut self, peer_id: Option, - _: Self::ProtocolsHandler, + _: Self::ConnectionHandler, error: &DialError, ) { if let Some(peer_id) = peer_id { @@ -630,7 +631,7 @@ impl NetworkBehaviour for DiscoveryBehaviour { &mut self, peer_id: PeerId, connection: ConnectionId, - (pid, event): <::Handler as ProtocolsHandler>::OutEvent, + (pid, event): <::Handler as ConnectionHandler>::OutEvent, ) { if let Some(kad) = self.kademlias.get_mut(&pid) { return kad.inject_event(peer_id, connection, event) @@ -689,7 +690,7 @@ impl NetworkBehaviour for DiscoveryBehaviour { } } - fn inject_listen_failure(&mut self, _: &Multiaddr, _: &Multiaddr, _: Self::ProtocolsHandler) { + fn inject_listen_failure(&mut self, _: &Multiaddr, _: &Multiaddr, _: Self::ConnectionHandler) { // NetworkBehaviour::inject_listen_failure on Kademlia does nothing. } @@ -709,7 +710,7 @@ impl NetworkBehaviour for DiscoveryBehaviour { &mut self, cx: &mut Context, params: &mut impl PollParameters, - ) -> Poll> { + ) -> Poll> { // Immediately process the content of `discovered`. if let Some(ev) = self.pending_events.pop_front() { return Poll::Ready(NetworkBehaviourAction::GenerateEvent(ev)) @@ -770,12 +771,8 @@ impl NetworkBehaviour for DiscoveryBehaviour { let ev = DiscoveryOut::Discovered(peer); return Poll::Ready(NetworkBehaviourAction::GenerateEvent(ev)) }, - KademliaEvent::InboundPutRecordRequest { .. } | - KademliaEvent::InboundAddProviderRequest { .. } => { - debug_assert!(false, "We don't use kad filtering at the moment"); - }, KademliaEvent::PendingRoutablePeer { .. } | - KademliaEvent::InboundRequestServed { .. } => { + KademliaEvent::InboundRequest { .. } => { // We are not interested in this event at the moment. }, KademliaEvent::OutboundQueryCompleted { @@ -890,19 +887,10 @@ impl NetworkBehaviour for DiscoveryBehaviour { warn!(target: "sub-libp2p", "Libp2p => Unhandled Kademlia event: {:?}", e) }, }, - NetworkBehaviourAction::DialAddress { address, handler } => { - let pid = pid.clone(); - let handler = self.new_handler_with_replacement(pid, handler); - return Poll::Ready(NetworkBehaviourAction::DialAddress { address, handler }) - }, - NetworkBehaviourAction::DialPeer { peer_id, condition, handler } => { + NetworkBehaviourAction::Dial { opts, handler } => { let pid = pid.clone(); let handler = self.new_handler_with_replacement(pid, handler); - return Poll::Ready(NetworkBehaviourAction::DialPeer { - peer_id, - condition, - handler, - }) + return Poll::Ready(NetworkBehaviourAction::Dial { opts, handler }) }, NetworkBehaviourAction::NotifyHandler { peer_id, handler, event } => return Poll::Ready(NetworkBehaviourAction::NotifyHandler { @@ -941,10 +929,7 @@ impl NetworkBehaviour for DiscoveryBehaviour { }, MdnsEvent::Expired(_) => {}, }, - NetworkBehaviourAction::DialAddress { .. } => { - unreachable!("mDNS never dials!"); - }, - NetworkBehaviourAction::DialPeer { .. } => { + NetworkBehaviourAction::Dial { .. } => { unreachable!("mDNS never dials!"); }, NetworkBehaviourAction::NotifyHandler { event, .. } => match event {}, /* `event` is an enum with no variant */ @@ -995,7 +980,7 @@ impl MdnsWrapper { &mut self, cx: &mut Context<'_>, params: &mut impl PollParameters, - ) -> Poll::ProtocolsHandler>> { + ) -> Poll::ConnectionHandler>> { loop { match self { Self::Instantiating(fut) => diff --git a/client/network/src/network_state.rs b/client/network/src/network_state.rs index a5e2fbef421db..57073c57afa69 100644 --- a/client/network/src/network_state.rs +++ b/client/network/src/network_state.rs @@ -20,7 +20,10 @@ //! //! **Warning**: These APIs are not stable. -use libp2p::{core::ConnectedPoint, Multiaddr}; +use libp2p::{ + core::{ConnectedPoint, Endpoint as CoreEndpoint}, + Multiaddr, +}; use serde::{Deserialize, Serialize}; use std::{ collections::{HashMap, HashSet}, @@ -80,7 +83,7 @@ pub struct NotConnectedPeer { #[serde(rename_all = "camelCase")] pub enum PeerEndpoint { /// We are dialing the given address. - Dialing(Multiaddr), + Dialing(Multiaddr, Endpoint), /// We are listening. Listening { /// Local address of the connection. @@ -90,12 +93,32 @@ pub enum PeerEndpoint { }, } +/// Part of the `NetworkState` struct. Unstable. +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] +pub enum Endpoint { + /// The socket comes from a dialer. + Dialer, + /// The socket comes from a listener. + Listener, +} + impl From for PeerEndpoint { fn from(endpoint: ConnectedPoint) -> Self { match endpoint { - ConnectedPoint::Dialer { address } => Self::Dialing(address), + ConnectedPoint::Dialer { address, role_override } => + Self::Dialing(address, role_override.into()), ConnectedPoint::Listener { local_addr, send_back_addr } => Self::Listening { local_addr, send_back_addr }, } } } + +impl From for Endpoint { + fn from(endpoint: CoreEndpoint) -> Self { + match endpoint { + CoreEndpoint::Dialer => Self::Dialer, + CoreEndpoint::Listener => Self::Listener, + } + } +} diff --git a/client/network/src/peer_info.rs b/client/network/src/peer_info.rs index 378c258820ffb..c3e79437bdd06 100644 --- a/client/network/src/peer_info.rs +++ b/client/network/src/peer_info.rs @@ -28,8 +28,8 @@ use libp2p::{ identify::{Identify, IdentifyConfig, IdentifyEvent, IdentifyInfo}, ping::{Ping, PingConfig, PingEvent, PingSuccess}, swarm::{ - IntoProtocolsHandler, IntoProtocolsHandlerSelect, NetworkBehaviour, NetworkBehaviourAction, - PollParameters, ProtocolsHandler, + ConnectionHandler, IntoConnectionHandler, IntoConnectionHandlerSelect, NetworkBehaviour, + NetworkBehaviourAction, PollParameters, }, Multiaddr, }; @@ -170,14 +170,14 @@ pub enum PeerInfoEvent { } impl NetworkBehaviour for PeerInfoBehaviour { - type ProtocolsHandler = IntoProtocolsHandlerSelect< - ::ProtocolsHandler, - ::ProtocolsHandler, + type ConnectionHandler = IntoConnectionHandlerSelect< + ::ConnectionHandler, + ::ConnectionHandler, >; type OutEvent = PeerInfoEvent; - fn new_handler(&mut self) -> Self::ProtocolsHandler { - IntoProtocolsHandler::select(self.ping.new_handler(), self.identify.new_handler()) + fn new_handler(&mut self) -> Self::ConnectionHandler { + IntoConnectionHandler::select(self.ping.new_handler(), self.identify.new_handler()) } fn addresses_of_peer(&mut self, peer_id: &PeerId) -> Vec { @@ -195,11 +195,18 @@ impl NetworkBehaviour for PeerInfoBehaviour { ) { self.ping.inject_address_change(peer_id, conn, old, new); self.identify.inject_address_change(peer_id, conn, old, new); - } - fn inject_connected(&mut self, peer_id: &PeerId) { - self.ping.inject_connected(peer_id); - self.identify.inject_connected(peer_id); + if let Some(entry) = self.nodes_info.get_mut(peer_id) { + if let Some(endpoint) = entry.endpoints.iter_mut().find(|e| e == &old) { + *endpoint = new.clone(); + } else { + error!(target: "sub-libp2p", + "Unknown address change for peer {:?} from {:?} to {:?}", peer_id, old, new); + } + } else { + error!(target: "sub-libp2p", + "Unknown peer {:?} to change address from {:?} to {:?}", peer_id, old, new); + } } fn inject_connection_established( @@ -208,11 +215,22 @@ impl NetworkBehaviour for PeerInfoBehaviour { conn: &ConnectionId, endpoint: &ConnectedPoint, failed_addresses: Option<&Vec>, + other_established: usize, ) { - self.ping - .inject_connection_established(peer_id, conn, endpoint, failed_addresses); - self.identify - .inject_connection_established(peer_id, conn, endpoint, failed_addresses); + self.ping.inject_connection_established( + peer_id, + conn, + endpoint, + failed_addresses, + other_established, + ); + self.identify.inject_connection_established( + peer_id, + conn, + endpoint, + failed_addresses, + other_established, + ); match self.nodes_info.entry(*peer_id) { Entry::Vacant(e) => { e.insert(NodeInfo::new(endpoint.clone())); @@ -234,14 +252,29 @@ impl NetworkBehaviour for PeerInfoBehaviour { peer_id: &PeerId, conn: &ConnectionId, endpoint: &ConnectedPoint, - handler: ::Handler, + handler: ::Handler, + remaining_established: usize, ) { let (ping_handler, identity_handler) = handler.into_inner(); - self.identify - .inject_connection_closed(peer_id, conn, endpoint, identity_handler); - self.ping.inject_connection_closed(peer_id, conn, endpoint, ping_handler); + self.identify.inject_connection_closed( + peer_id, + conn, + endpoint, + identity_handler, + remaining_established, + ); + self.ping.inject_connection_closed( + peer_id, + conn, + endpoint, + ping_handler, + remaining_established, + ); if let Some(entry) = self.nodes_info.get_mut(peer_id) { + if remaining_established == 0 { + entry.info_expire = Some(Instant::now() + CACHE_EXPIRE); + } entry.endpoints.retain(|ep| ep != endpoint) } else { error!(target: "sub-libp2p", @@ -249,23 +282,11 @@ impl NetworkBehaviour for PeerInfoBehaviour { } } - fn inject_disconnected(&mut self, peer_id: &PeerId) { - self.ping.inject_disconnected(peer_id); - self.identify.inject_disconnected(peer_id); - - if let Some(entry) = self.nodes_info.get_mut(peer_id) { - entry.info_expire = Some(Instant::now() + CACHE_EXPIRE); - } else { - error!(target: "sub-libp2p", - "Disconnected from node we were not connected to {:?}", peer_id); - } - } - fn inject_event( &mut self, peer_id: PeerId, connection: ConnectionId, - event: <::Handler as ProtocolsHandler>::OutEvent, + event: <::Handler as ConnectionHandler>::OutEvent, ) { match event { EitherOutput::First(event) => self.ping.inject_event(peer_id, connection, event), @@ -276,7 +297,7 @@ impl NetworkBehaviour for PeerInfoBehaviour { fn inject_dial_failure( &mut self, peer_id: Option, - handler: Self::ProtocolsHandler, + handler: Self::ConnectionHandler, error: &libp2p::swarm::DialError, ) { let (ping_handler, identity_handler) = handler.into_inner(); @@ -313,7 +334,7 @@ impl NetworkBehaviour for PeerInfoBehaviour { &mut self, local_addr: &Multiaddr, send_back_addr: &Multiaddr, - handler: Self::ProtocolsHandler, + handler: Self::ConnectionHandler, ) { let (ping_handler, identity_handler) = handler.into_inner(); self.identify @@ -335,7 +356,7 @@ impl NetworkBehaviour for PeerInfoBehaviour { &mut self, cx: &mut Context, params: &mut impl PollParameters, - ) -> Poll> { + ) -> Poll> { loop { match self.ping.poll(cx, params) { Poll::Pending => break, @@ -344,19 +365,10 @@ impl NetworkBehaviour for PeerInfoBehaviour { self.handle_ping_report(&peer, rtt) } }, - Poll::Ready(NetworkBehaviourAction::DialAddress { address, handler }) => { + Poll::Ready(NetworkBehaviourAction::Dial { opts, handler }) => { let handler = - IntoProtocolsHandler::select(handler, self.identify.new_handler()); - return Poll::Ready(NetworkBehaviourAction::DialAddress { address, handler }) - }, - Poll::Ready(NetworkBehaviourAction::DialPeer { peer_id, condition, handler }) => { - let handler = - IntoProtocolsHandler::select(handler, self.identify.new_handler()); - return Poll::Ready(NetworkBehaviourAction::DialPeer { - peer_id, - condition, - handler, - }) + IntoConnectionHandler::select(handler, self.identify.new_handler()); + return Poll::Ready(NetworkBehaviourAction::Dial { opts, handler }) }, Poll::Ready(NetworkBehaviourAction::NotifyHandler { peer_id, handler, event }) => return Poll::Ready(NetworkBehaviourAction::NotifyHandler { @@ -392,17 +404,9 @@ impl NetworkBehaviour for PeerInfoBehaviour { IdentifyEvent::Pushed { .. } => {}, IdentifyEvent::Sent { .. } => {}, }, - Poll::Ready(NetworkBehaviourAction::DialAddress { address, handler }) => { - let handler = IntoProtocolsHandler::select(self.ping.new_handler(), handler); - return Poll::Ready(NetworkBehaviourAction::DialAddress { address, handler }) - }, - Poll::Ready(NetworkBehaviourAction::DialPeer { peer_id, condition, handler }) => { - let handler = IntoProtocolsHandler::select(self.ping.new_handler(), handler); - return Poll::Ready(NetworkBehaviourAction::DialPeer { - peer_id, - condition, - handler, - }) + Poll::Ready(NetworkBehaviourAction::Dial { opts, handler }) => { + let handler = IntoConnectionHandler::select(self.ping.new_handler(), handler); + return Poll::Ready(NetworkBehaviourAction::Dial { opts, handler }) }, Poll::Ready(NetworkBehaviourAction::NotifyHandler { peer_id, handler, event }) => return Poll::Ready(NetworkBehaviourAction::NotifyHandler { diff --git a/client/network/src/protocol.rs b/client/network/src/protocol.rs index 80694210e77dc..8497dfd940de0 100644 --- a/client/network/src/protocol.rs +++ b/client/network/src/protocol.rs @@ -36,8 +36,8 @@ use libp2p::{ }, request_response::OutboundFailure, swarm::{ - IntoProtocolsHandler, NetworkBehaviour, NetworkBehaviourAction, PollParameters, - ProtocolsHandler, + ConnectionHandler, IntoConnectionHandler, NetworkBehaviour, NetworkBehaviourAction, + PollParameters, }, Multiaddr, PeerId, }; @@ -1367,10 +1367,10 @@ pub enum CustomMessageOutcome { } impl NetworkBehaviour for Protocol { - type ProtocolsHandler = ::ProtocolsHandler; + type ConnectionHandler = ::ConnectionHandler; type OutEvent = CustomMessageOutcome; - fn new_handler(&mut self) -> Self::ProtocolsHandler { + fn new_handler(&mut self) -> Self::ConnectionHandler { self.behaviour.new_handler() } @@ -1384,9 +1384,15 @@ impl NetworkBehaviour for Protocol { conn: &ConnectionId, endpoint: &ConnectedPoint, failed_addresses: Option<&Vec>, + other_established: usize, ) { - self.behaviour - .inject_connection_established(peer_id, conn, endpoint, failed_addresses) + self.behaviour.inject_connection_established( + peer_id, + conn, + endpoint, + failed_addresses, + other_established, + ) } fn inject_connection_closed( @@ -1394,24 +1400,23 @@ impl NetworkBehaviour for Protocol { peer_id: &PeerId, conn: &ConnectionId, endpoint: &ConnectedPoint, - handler: ::Handler, + handler: ::Handler, + remaining_established: usize, ) { - self.behaviour.inject_connection_closed(peer_id, conn, endpoint, handler) - } - - fn inject_connected(&mut self, peer_id: &PeerId) { - self.behaviour.inject_connected(peer_id) - } - - fn inject_disconnected(&mut self, peer_id: &PeerId) { - self.behaviour.inject_disconnected(peer_id) + self.behaviour.inject_connection_closed( + peer_id, + conn, + endpoint, + handler, + remaining_established, + ) } fn inject_event( &mut self, peer_id: PeerId, connection: ConnectionId, - event: <::Handler as ProtocolsHandler>::OutEvent, + event: <::Handler as ConnectionHandler>::OutEvent, ) { self.behaviour.inject_event(peer_id, connection, event) } @@ -1420,7 +1425,7 @@ impl NetworkBehaviour for Protocol { &mut self, cx: &mut std::task::Context, params: &mut impl PollParameters, - ) -> Poll> { + ) -> Poll> { if let Some(message) = self.pending_messages.pop_front() { return Poll::Ready(NetworkBehaviourAction::GenerateEvent(message)) } @@ -1581,10 +1586,8 @@ impl NetworkBehaviour for Protocol { let event = match self.behaviour.poll(cx, params) { Poll::Pending => return Poll::Pending, Poll::Ready(NetworkBehaviourAction::GenerateEvent(ev)) => ev, - Poll::Ready(NetworkBehaviourAction::DialAddress { address, handler }) => - return Poll::Ready(NetworkBehaviourAction::DialAddress { address, handler }), - Poll::Ready(NetworkBehaviourAction::DialPeer { peer_id, condition, handler }) => - return Poll::Ready(NetworkBehaviourAction::DialPeer { peer_id, condition, handler }), + Poll::Ready(NetworkBehaviourAction::Dial { opts, handler }) => + return Poll::Ready(NetworkBehaviourAction::Dial { opts, handler }), Poll::Ready(NetworkBehaviourAction::NotifyHandler { peer_id, handler, event }) => return Poll::Ready(NetworkBehaviourAction::NotifyHandler { peer_id, @@ -1800,7 +1803,7 @@ impl NetworkBehaviour for Protocol { fn inject_dial_failure( &mut self, peer_id: Option, - handler: Self::ProtocolsHandler, + handler: Self::ConnectionHandler, error: &libp2p::swarm::DialError, ) { self.behaviour.inject_dial_failure(peer_id, handler, error); diff --git a/client/network/src/protocol/notifications/behaviour.rs b/client/network/src/protocol/notifications/behaviour.rs index b47216473970e..61f7db78c98b1 100644 --- a/client/network/src/protocol/notifications/behaviour.rs +++ b/client/network/src/protocol/notifications/behaviour.rs @@ -26,8 +26,8 @@ use futures::prelude::*; use libp2p::{ core::{connection::ConnectionId, ConnectedPoint, Multiaddr, PeerId}, swarm::{ - DialError, DialPeerCondition, IntoProtocolsHandler, NetworkBehaviour, - NetworkBehaviourAction, NotifyHandler, PollParameters, + DialError, IntoConnectionHandler, NetworkBehaviour, NetworkBehaviourAction, NotifyHandler, + PollParameters, }, }; use log::{error, trace, warn}; @@ -620,10 +620,8 @@ impl Notifications { set_id, ); trace!(target: "sub-libp2p", "Libp2p <= Dial {}", entry.key().0); - // The `DialPeerCondition` ensures that dial attempts are de-duplicated - self.events.push_back(NetworkBehaviourAction::DialPeer { - peer_id: entry.key().0.clone(), - condition: DialPeerCondition::Disconnected, + self.events.push_back(NetworkBehaviourAction::Dial { + opts: entry.key().0.clone().into(), handler, }); entry.insert(PeerState::Requested); @@ -657,10 +655,8 @@ impl Notifications { set_id, ); trace!(target: "sub-libp2p", "Libp2p <= Dial {:?}", occ_entry.key()); - // The `DialPeerCondition` ensures that dial attempts are de-duplicated - self.events.push_back(NetworkBehaviourAction::DialPeer { - peer_id: occ_entry.key().0.clone(), - condition: DialPeerCondition::Disconnected, + self.events.push_back(NetworkBehaviourAction::Dial { + opts: occ_entry.key().0.clone().into(), handler, }); *occ_entry.into_mut() = PeerState::Requested; @@ -1059,10 +1055,10 @@ impl Notifications { } impl NetworkBehaviour for Notifications { - type ProtocolsHandler = NotifsHandlerProto; + type ConnectionHandler = NotifsHandlerProto; type OutEvent = NotificationsOut; - fn new_handler(&mut self) -> Self::ProtocolsHandler { + fn new_handler(&mut self) -> Self::ConnectionHandler { NotifsHandlerProto::new(self.notif_protocols.clone()) } @@ -1070,14 +1066,13 @@ impl NetworkBehaviour for Notifications { Vec::new() } - fn inject_connected(&mut self, _: &PeerId) {} - fn inject_connection_established( &mut self, peer_id: &PeerId, conn: &ConnectionId, endpoint: &ConnectedPoint, _failed_addresses: Option<&Vec>, + _other_established: usize, ) { for set_id in (0..self.notif_protocols.len()).map(sc_peerset::SetId::from) { match self.peers.entry((*peer_id, set_id)).or_insert(PeerState::Poisoned) { @@ -1136,7 +1131,8 @@ impl NetworkBehaviour for Notifications { peer_id: &PeerId, conn: &ConnectionId, _endpoint: &ConnectedPoint, - _handler: ::Handler, + _handler: ::Handler, + _remaining_established: usize, ) { for set_id in (0..self.notif_protocols.len()).map(sc_peerset::SetId::from) { let mut entry = if let Entry::Occupied(entry) = self.peers.entry((*peer_id, set_id)) { @@ -1394,12 +1390,10 @@ impl NetworkBehaviour for Notifications { } } - fn inject_disconnected(&mut self, _peer_id: &PeerId) {} - fn inject_dial_failure( &mut self, peer_id: Option, - _: Self::ProtocolsHandler, + _: Self::ConnectionHandler, error: &DialError, ) { if let DialError::Transport(errors) = error { @@ -1989,7 +1983,7 @@ impl NetworkBehaviour for Notifications { &mut self, cx: &mut Context, _params: &mut impl PollParameters, - ) -> Poll> { + ) -> Poll> { if let Some(event) = self.events.pop_front() { return Poll::Ready(event) } @@ -2038,12 +2032,8 @@ impl NetworkBehaviour for Notifications { PeerState::PendingRequest { timer, .. } if *timer == delay_id => { trace!(target: "sub-libp2p", "Libp2p <= Dial {:?} now that ban has expired", peer_id); - // The `DialPeerCondition` ensures that dial attempts are de-duplicated - self.events.push_back(NetworkBehaviourAction::DialPeer { - peer_id, - condition: DialPeerCondition::Disconnected, - handler, - }); + self.events + .push_back(NetworkBehaviourAction::Dial { opts: peer_id.into(), handler }); *peer_state = PeerState::Requested; }, diff --git a/client/network/src/protocol/notifications/handler.rs b/client/network/src/protocol/notifications/handler.rs index 91225f54203af..510f72d4b0123 100644 --- a/client/network/src/protocol/notifications/handler.rs +++ b/client/network/src/protocol/notifications/handler.rs @@ -16,10 +16,10 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -//! Implementations of the `IntoProtocolsHandler` and `ProtocolsHandler` traits for both incoming +//! Implementations of the `IntoConnectionHandler` and `ConnectionHandler` traits for both incoming //! and outgoing substreams for all gossiping protocols. //! -//! This is the main implementation of `ProtocolsHandler` in this crate, that handles all the +//! This is the main implementation of `ConnectionHandler` in this crate, that handles all the //! gossiping protocols that are Substrate-related and outside of the scope of libp2p. //! //! # Usage @@ -74,8 +74,8 @@ use libp2p::{ ConnectedPoint, PeerId, }, swarm::{ - IntoProtocolsHandler, KeepAlive, NegotiatedSubstream, ProtocolsHandler, - ProtocolsHandlerEvent, ProtocolsHandlerUpgrErr, SubstreamProtocol, + ConnectionHandler, ConnectionHandlerEvent, ConnectionHandlerUpgrErr, IntoConnectionHandler, + KeepAlive, NegotiatedSubstream, SubstreamProtocol, }, }; use log::error; @@ -107,7 +107,7 @@ const OPEN_TIMEOUT: Duration = Duration::from_secs(10); /// open substreams. const INITIAL_KEEPALIVE_TIME: Duration = Duration::from_secs(5); -/// Implements the `IntoProtocolsHandler` trait of libp2p. +/// Implements the `IntoConnectionHandler` trait of libp2p. /// /// Every time a connection with a remote starts, an instance of this struct is created and /// sent to a background task dedicated to this connection. Once the connection is established, @@ -138,7 +138,7 @@ pub struct NotifsHandler { /// Events to return in priority from `poll`. events_queue: VecDeque< - ProtocolsHandlerEvent, + ConnectionHandlerEvent, >, } @@ -225,7 +225,7 @@ enum State { }, } -impl IntoProtocolsHandler for NotifsHandlerProto { +impl IntoConnectionHandler for NotifsHandlerProto { type Handler = NotifsHandler; fn inbound_protocol(&self) -> UpgradeCollec { @@ -475,7 +475,7 @@ impl NotifsHandlerProto { } } -impl ProtocolsHandler for NotifsHandler { +impl ConnectionHandler for NotifsHandler { type InEvent = NotifsHandlerIn; type OutEvent = NotifsHandlerOut; type Error = NotifsHandlerError; @@ -505,7 +505,7 @@ impl ProtocolsHandler for NotifsHandler { let mut protocol_info = &mut self.protocols[protocol_index]; match protocol_info.state { State::Closed { pending_opening } => { - self.events_queue.push_back(ProtocolsHandlerEvent::Custom( + self.events_queue.push_back(ConnectionHandlerEvent::Custom( NotifsHandlerOut::OpenDesiredByRemote { protocol_index }, )); @@ -573,7 +573,7 @@ impl ProtocolsHandler for NotifsHandler { in_substream: in_substream.take(), }; - self.events_queue.push_back(ProtocolsHandlerEvent::Custom( + self.events_queue.push_back(ConnectionHandlerEvent::Custom( NotifsHandlerOut::OpenResultOk { protocol_index, negotiated_fallback: new_open.negotiated_fallback, @@ -601,7 +601,7 @@ impl ProtocolsHandler for NotifsHandler { ); self.events_queue.push_back( - ProtocolsHandlerEvent::OutboundSubstreamRequest { + ConnectionHandlerEvent::OutboundSubstreamRequest { protocol: SubstreamProtocol::new(proto, protocol_index) .with_timeout(OPEN_TIMEOUT), }, @@ -622,7 +622,7 @@ impl ProtocolsHandler for NotifsHandler { ); self.events_queue.push_back( - ProtocolsHandlerEvent::OutboundSubstreamRequest { + ConnectionHandlerEvent::OutboundSubstreamRequest { protocol: SubstreamProtocol::new(proto, protocol_index) .with_timeout(OPEN_TIMEOUT), }, @@ -660,7 +660,7 @@ impl ProtocolsHandler for NotifsHandler { self.protocols[protocol_index].state = State::Closed { pending_opening: true }; - self.events_queue.push_back(ProtocolsHandlerEvent::Custom( + self.events_queue.push_back(ConnectionHandlerEvent::Custom( NotifsHandlerOut::OpenResultErr { protocol_index }, )); }, @@ -670,7 +670,7 @@ impl ProtocolsHandler for NotifsHandler { State::Closed { .. } => {}, } - self.events_queue.push_back(ProtocolsHandlerEvent::Custom( + self.events_queue.push_back(ConnectionHandlerEvent::Custom( NotifsHandlerOut::CloseResult { protocol_index }, )); }, @@ -680,7 +680,7 @@ impl ProtocolsHandler for NotifsHandler { fn inject_dial_upgrade_error( &mut self, num: usize, - _: ProtocolsHandlerUpgrErr, + _: ConnectionHandlerUpgrErr, ) { match self.protocols[num].state { State::Closed { ref mut pending_opening } | @@ -692,7 +692,7 @@ impl ProtocolsHandler for NotifsHandler { State::Opening { .. } => { self.protocols[num].state = State::Closed { pending_opening: false }; - self.events_queue.push_back(ProtocolsHandlerEvent::Custom( + self.events_queue.push_back(ConnectionHandlerEvent::Custom( NotifsHandlerOut::OpenResultErr { protocol_index: num }, )); }, @@ -717,7 +717,7 @@ impl ProtocolsHandler for NotifsHandler { &mut self, cx: &mut Context, ) -> Poll< - ProtocolsHandlerEvent< + ConnectionHandlerEvent< Self::OutboundProtocol, Self::OutboundOpenInfo, Self::OutEvent, @@ -741,7 +741,7 @@ impl ProtocolsHandler for NotifsHandler { // a substream is ready to send if there isn't actually something to send. match Pin::new(&mut *notifications_sink_rx).as_mut().poll_peek(cx) { Poll::Ready(Some(&NotificationsSinkMessage::ForceClose)) => - return Poll::Ready(ProtocolsHandlerEvent::Close( + return Poll::Ready(ConnectionHandlerEvent::Close( NotifsHandlerError::SyncNotificationsClogged, )), Poll::Ready(Some(&NotificationsSinkMessage::Notification { .. })) => {}, @@ -789,7 +789,7 @@ impl ProtocolsHandler for NotifsHandler { Poll::Ready(Err(_)) => { *out_substream = None; let event = NotifsHandlerOut::CloseDesired { protocol_index }; - return Poll::Ready(ProtocolsHandlerEvent::Custom(event)) + return Poll::Ready(ConnectionHandlerEvent::Custom(event)) }, }; }, @@ -815,7 +815,7 @@ impl ProtocolsHandler for NotifsHandler { Poll::Pending => {}, Poll::Ready(Some(Ok(message))) => { let event = NotifsHandlerOut::Notification { protocol_index, message }; - return Poll::Ready(ProtocolsHandlerEvent::Custom(event)) + return Poll::Ready(ConnectionHandlerEvent::Custom(event)) }, Poll::Ready(None) | Poll::Ready(Some(Err(_))) => *in_substream = None, }, @@ -827,7 +827,7 @@ impl ProtocolsHandler for NotifsHandler { Poll::Ready(Err(_)) => { self.protocols[protocol_index].state = State::Closed { pending_opening: *pending_opening }; - return Poll::Ready(ProtocolsHandlerEvent::Custom( + return Poll::Ready(ConnectionHandlerEvent::Custom( NotifsHandlerOut::CloseDesired { protocol_index }, )) }, diff --git a/client/network/src/protocol/notifications/tests.rs b/client/network/src/protocol/notifications/tests.rs index 73058598a1e3b..da12dbf216c4c 100644 --- a/client/network/src/protocol/notifications/tests.rs +++ b/client/network/src/protocol/notifications/tests.rs @@ -29,8 +29,8 @@ use libp2p::{ }, identity, noise, swarm::{ - DialError, IntoProtocolsHandler, NetworkBehaviour, NetworkBehaviourAction, PollParameters, - ProtocolsHandler, Swarm, SwarmEvent, + ConnectionHandler, DialError, IntoConnectionHandler, NetworkBehaviour, + NetworkBehaviourAction, PollParameters, Swarm, SwarmEvent, }, yamux, Multiaddr, PeerId, Transport, }; @@ -133,10 +133,10 @@ impl std::ops::DerefMut for CustomProtoWithAddr { } impl NetworkBehaviour for CustomProtoWithAddr { - type ProtocolsHandler = ::ProtocolsHandler; + type ConnectionHandler = ::ConnectionHandler; type OutEvent = ::OutEvent; - fn new_handler(&mut self) -> Self::ProtocolsHandler { + fn new_handler(&mut self) -> Self::ConnectionHandler { self.inner.new_handler() } @@ -150,23 +150,21 @@ impl NetworkBehaviour for CustomProtoWithAddr { list } - fn inject_connected(&mut self, peer_id: &PeerId) { - self.inner.inject_connected(peer_id) - } - - fn inject_disconnected(&mut self, peer_id: &PeerId) { - self.inner.inject_disconnected(peer_id) - } - fn inject_connection_established( &mut self, peer_id: &PeerId, conn: &ConnectionId, endpoint: &ConnectedPoint, failed_addresses: Option<&Vec>, + other_established: usize, ) { - self.inner - .inject_connection_established(peer_id, conn, endpoint, failed_addresses) + self.inner.inject_connection_established( + peer_id, + conn, + endpoint, + failed_addresses, + other_established, + ) } fn inject_connection_closed( @@ -174,16 +172,18 @@ impl NetworkBehaviour for CustomProtoWithAddr { peer_id: &PeerId, conn: &ConnectionId, endpoint: &ConnectedPoint, - handler: ::Handler, + handler: ::Handler, + remaining_established: usize, ) { - self.inner.inject_connection_closed(peer_id, conn, endpoint, handler) + self.inner + .inject_connection_closed(peer_id, conn, endpoint, handler, remaining_established) } fn inject_event( &mut self, peer_id: PeerId, connection: ConnectionId, - event: <::Handler as ProtocolsHandler>::OutEvent, + event: <::Handler as ConnectionHandler>::OutEvent, ) { self.inner.inject_event(peer_id, connection, event) } @@ -192,14 +192,14 @@ impl NetworkBehaviour for CustomProtoWithAddr { &mut self, cx: &mut Context, params: &mut impl PollParameters, - ) -> Poll> { + ) -> Poll> { self.inner.poll(cx, params) } fn inject_dial_failure( &mut self, peer_id: Option, - handler: Self::ProtocolsHandler, + handler: Self::ConnectionHandler, error: &DialError, ) { self.inner.inject_dial_failure(peer_id, handler, error) diff --git a/client/network/src/request_responses.rs b/client/network/src/request_responses.rs index 4613a15af9366..87d070bc469a3 100644 --- a/client/network/src/request_responses.rs +++ b/client/network/src/request_responses.rs @@ -49,8 +49,8 @@ use libp2p::{ RequestResponseConfig, RequestResponseEvent, RequestResponseMessage, ResponseChannel, }, swarm::{ - protocols_handler::multi::MultiHandler, IntoProtocolsHandler, NetworkBehaviour, - NetworkBehaviourAction, PollParameters, ProtocolsHandler, + handler::multi::MultiHandler, ConnectionHandler, IntoConnectionHandler, NetworkBehaviour, + NetworkBehaviourAction, PollParameters, }, }; use std::{ @@ -381,7 +381,7 @@ impl RequestResponsesBehaviour { &mut self, protocol: String, handler: RequestResponseHandler, - ) -> ::ProtocolsHandler { + ) -> ::ConnectionHandler { let mut handlers: HashMap<_, _> = self .protocols .iter_mut() @@ -400,11 +400,13 @@ impl RequestResponsesBehaviour { } impl NetworkBehaviour for RequestResponsesBehaviour { - type ProtocolsHandler = - MultiHandler as NetworkBehaviour>::ProtocolsHandler>; + type ConnectionHandler = MultiHandler< + String, + as NetworkBehaviour>::ConnectionHandler, + >; type OutEvent = Event; - fn new_handler(&mut self) -> Self::ProtocolsHandler { + fn new_handler(&mut self) -> Self::ConnectionHandler { let iter = self .protocols .iter_mut() @@ -426,6 +428,7 @@ impl NetworkBehaviour for RequestResponsesBehaviour { conn: &ConnectionId, endpoint: &ConnectedPoint, failed_addresses: Option<&Vec>, + other_established: usize, ) { for (p, _) in self.protocols.values_mut() { NetworkBehaviour::inject_connection_established( @@ -434,32 +437,35 @@ impl NetworkBehaviour for RequestResponsesBehaviour { conn, endpoint, failed_addresses, + other_established, ) } } - fn inject_connected(&mut self, peer_id: &PeerId) { - for (p, _) in self.protocols.values_mut() { - NetworkBehaviour::inject_connected(p, peer_id) - } - } - fn inject_connection_closed( &mut self, peer_id: &PeerId, conn: &ConnectionId, endpoint: &ConnectedPoint, - _handler: ::Handler, + handler: ::Handler, + remaining_established: usize, ) { - for (p, _) in self.protocols.values_mut() { - let handler = p.new_handler(); - NetworkBehaviour::inject_connection_closed(p, peer_id, conn, endpoint, handler); - } - } - - fn inject_disconnected(&mut self, peer_id: &PeerId) { - for (p, _) in self.protocols.values_mut() { - NetworkBehaviour::inject_disconnected(p, peer_id) + for (p_name, event) in handler.into_iter() { + if let Some((proto, _)) = self.protocols.get_mut(p_name.as_str()) { + proto.inject_connection_closed( + peer_id, + conn, + endpoint, + event, + remaining_established, + ) + } else { + log::error!( + target: "sub-libp2p", + "inject_connection_closed: no request-response instance registered for protocol {:?}", + p_name, + ) + } } } @@ -467,7 +473,7 @@ impl NetworkBehaviour for RequestResponsesBehaviour { &mut self, peer_id: PeerId, connection: ConnectionId, - (p_name, event): ::OutEvent, + (p_name, event): ::OutEvent, ) { if let Some((proto, _)) = self.protocols.get_mut(&*p_name) { return proto.inject_event(peer_id, connection, event) @@ -499,7 +505,7 @@ impl NetworkBehaviour for RequestResponsesBehaviour { fn inject_dial_failure( &mut self, peer_id: Option, - _: Self::ProtocolsHandler, + _: Self::ConnectionHandler, error: &libp2p::swarm::DialError, ) { for (p, _) in self.protocols.values_mut() { @@ -536,7 +542,7 @@ impl NetworkBehaviour for RequestResponsesBehaviour { &mut self, cx: &mut Context, params: &mut impl PollParameters, - ) -> Poll> { + ) -> Poll> { 'poll_all: loop { if let Some(message_request) = self.message_request.take() { // Now we can can poll `MessageRequest` until we get the reputation @@ -677,25 +683,15 @@ impl NetworkBehaviour for RequestResponsesBehaviour { // Other events generated by the underlying behaviour are transparently // passed through. - NetworkBehaviourAction::DialAddress { address, handler } => { - log::error!( - "The request-response isn't supposed to start dialing peers" - ); - let protocol = protocol.to_string(); - let handler = self.new_handler_with_replacement(protocol, handler); - return Poll::Ready(NetworkBehaviourAction::DialAddress { - address, - handler, - }) - }, - NetworkBehaviourAction::DialPeer { peer_id, condition, handler } => { + NetworkBehaviourAction::Dial { opts, handler } => { + if opts.get_peer_id().is_none() { + log::error!( + "The request-response isn't supposed to start dialing addresses" + ); + } let protocol = protocol.to_string(); let handler = self.new_handler_with_replacement(protocol, handler); - return Poll::Ready(NetworkBehaviourAction::DialPeer { - peer_id, - condition, - handler, - }) + return Poll::Ready(NetworkBehaviourAction::Dial { opts, handler }) }, NetworkBehaviourAction::NotifyHandler { peer_id, handler, event } => return Poll::Ready(NetworkBehaviourAction::NotifyHandler { @@ -1146,7 +1142,7 @@ mod tests { // this test, so they wouldn't connect to each other. { let dial_addr = swarms[1].1.clone(); - Swarm::dial_addr(&mut swarms[0].0, dial_addr).unwrap(); + Swarm::dial(&mut swarms[0].0, dial_addr).unwrap(); } let (mut swarm, _, peerset) = swarms.remove(0); @@ -1246,7 +1242,7 @@ mod tests { // this test, so they wouldn't connect to each other. { let dial_addr = swarms[1].1.clone(); - Swarm::dial_addr(&mut swarms[0].0, dial_addr).unwrap(); + Swarm::dial(&mut swarms[0].0, dial_addr).unwrap(); } // Running `swarm[0]` in the background until a `InboundRequest` event happens, @@ -1375,7 +1371,7 @@ mod tests { // Ask swarm 1 to dial swarm 2. There isn't any discovery mechanism in place in this test, // so they wouldn't connect to each other. - swarm_1.dial_addr(listen_add_2).unwrap(); + swarm_1.dial(listen_add_2).unwrap(); // Run swarm 2 in the background, receiving two requests. pool.spawner() diff --git a/client/network/src/service.rs b/client/network/src/service.rs index 7239c9f6f9e6a..e88e7924954b3 100644 --- a/client/network/src/service.rs +++ b/client/network/src/service.rs @@ -49,16 +49,12 @@ use crate::{ use codec::Encode as _; use futures::{channel::oneshot, prelude::*}; use libp2p::{ - core::{ - connection::{ConnectionError, ConnectionLimits, PendingConnectionError}, - either::EitherError, - upgrade, ConnectedPoint, Executor, - }, + core::{either::EitherError, upgrade, ConnectedPoint, Executor}, multiaddr, ping::Failure as PingFailure, swarm::{ - protocols_handler::NodeHandlerWrapperError, AddressScore, DialError, NetworkBehaviour, - SwarmBuilder, SwarmEvent, + AddressScore, ConnectionError, ConnectionLimits, DialError, NetworkBehaviour, + PendingConnectionError, SwarmBuilder, SwarmEvent, }, Multiaddr, PeerId, }; @@ -1531,7 +1527,7 @@ impl Future for NetworkWorker { ServiceToWorkerMsg::PropagateTransactions => this.tx_handler_controller.propagate_transactions(), ServiceToWorkerMsg::GetValue(key) => - this.network_service.behaviour_mut().get_value(&key), + this.network_service.behaviour_mut().get_value(key), ServiceToWorkerMsg::PutValue(key, value) => this.network_service.behaviour_mut().put_value(key, value), ServiceToWorkerMsg::SetReservedOnly(reserved_only) => this @@ -1897,21 +1893,18 @@ impl Future for NetworkWorker { }; let reason = match cause { Some(ConnectionError::IO(_)) => "transport-error", - Some(ConnectionError::Handler(NodeHandlerWrapperError::Handler( - EitherError::A(EitherError::A(EitherError::A(EitherError::B( - EitherError::A(PingFailure::Timeout), - )))), - ))) => "ping-timeout", - Some(ConnectionError::Handler(NodeHandlerWrapperError::Handler( - EitherError::A(EitherError::A(EitherError::A(EitherError::A( + Some(ConnectionError::Handler(EitherError::A(EitherError::A( + EitherError::A(EitherError::B(EitherError::A( + PingFailure::Timeout, + ))), + )))) => "ping-timeout", + Some(ConnectionError::Handler(EitherError::A(EitherError::A( + EitherError::A(EitherError::A( NotifsHandlerError::SyncNotificationsClogged, - )))), - ))) => "sync-notifications-clogged", - Some(ConnectionError::Handler(NodeHandlerWrapperError::Handler(_))) => - "protocol-error", - Some(ConnectionError::Handler( - NodeHandlerWrapperError::KeepAliveTimeout, - )) => "keep-alive-timeout", + )), + )))) => "sync-notifications-clogged", + Some(ConnectionError::Handler(_)) => "protocol-error", + Some(ConnectionError::KeepAliveTimeout) => "keep-alive-timeout", None => "actively-closed", }; metrics @@ -1946,10 +1939,12 @@ impl Future for NetworkWorker { ); if this.boot_node_ids.contains(&peer_id) { - if let DialError::InvalidPeerId = error { + if let DialError::WrongPeerId { obtained, endpoint } = &error { error!( - "💔 The bootnode you want to connect provided a different peer ID than the one you expect: `{}`.", + "💔 The bootnode you want to connect provided a different peer ID than the one you expect: `{}` with `{}`:`{:?}`.", peer_id, + obtained, + endpoint, ); } } @@ -1958,13 +1953,14 @@ impl Future for NetworkWorker { if let Some(metrics) = this.metrics.as_ref() { let reason = match error { DialError::ConnectionLimit(_) => Some("limit-reached"), - DialError::InvalidPeerId => Some("invalid-peer-id"), + DialError::InvalidPeerId(_) => Some("invalid-peer-id"), DialError::Transport(_) | DialError::ConnectionIo(_) => Some("transport-error"), DialError::Banned | DialError::LocalPeerId | DialError::NoAddresses | DialError::DialPeerConditionFalse(_) | + DialError::WrongPeerId { .. } | DialError::Aborted => None, // ignore them }; if let Some(reason) = reason { @@ -1998,7 +1994,7 @@ impl Future for NetworkWorker { if let Some(metrics) = this.metrics.as_ref() { let reason = match error { PendingConnectionError::ConnectionLimit(_) => Some("limit-reached"), - PendingConnectionError::InvalidPeerId => Some("invalid-peer-id"), + PendingConnectionError::WrongPeerId { .. } => Some("invalid-peer-id"), PendingConnectionError::Transport(_) | PendingConnectionError::IO(_) => Some("transport-error"), PendingConnectionError::Aborted => None, // ignore it diff --git a/client/network/test/Cargo.toml b/client/network/test/Cargo.toml index 642654bcb2de5..39297dd3ea295 100644 --- a/client/network/test/Cargo.toml +++ b/client/network/test/Cargo.toml @@ -20,7 +20,7 @@ parking_lot = "0.12.0" futures = "0.3.21" futures-timer = "3.0.1" rand = "0.7.2" -libp2p = { version = "0.40.0", default-features = false } +libp2p = { version = "0.44.0", default-features = false } sp-consensus = { version = "0.10.0-dev", path = "../../../primitives/consensus/common" } sc-consensus = { version = "0.10.0-dev", path = "../../consensus/common" } sc-client-api = { version = "4.0.0-dev", path = "../../api" } diff --git a/client/peerset/Cargo.toml b/client/peerset/Cargo.toml index 5cda0913da1a1..ee83d186b5417 100644 --- a/client/peerset/Cargo.toml +++ b/client/peerset/Cargo.toml @@ -15,7 +15,7 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] futures = "0.3.21" -libp2p = { version = "0.40.0", default-features = false } +libp2p = { version = "0.44.0", default-features = false } sc-utils = { version = "4.0.0-dev", path = "../utils"} log = "0.4.16" serde_json = "1.0.79" diff --git a/client/telemetry/Cargo.toml b/client/telemetry/Cargo.toml index bb517290cef51..4dfefd06ac737 100644 --- a/client/telemetry/Cargo.toml +++ b/client/telemetry/Cargo.toml @@ -18,7 +18,7 @@ targets = ["x86_64-unknown-linux-gnu"] parking_lot = "0.12.0" futures = "0.3.21" wasm-timer = "0.2.5" -libp2p = { version = "0.40.0", default-features = false, features = ["dns-async-std", "tcp-async-io", "wasm-ext", "websocket"] } +libp2p = { version = "0.44.0", default-features = false, features = ["dns-async-std", "tcp-async-io", "wasm-ext", "websocket"] } log = "0.4.16" pin-project = "1.0.10" rand = "0.7.2" diff --git a/client/telemetry/src/transport.rs b/client/telemetry/src/transport.rs index 23725b44a64dd..e21a2380be255 100644 --- a/client/telemetry/src/transport.rs +++ b/client/telemetry/src/transport.rs @@ -38,8 +38,13 @@ pub(crate) fn initialize_transport() -> Result { let item = libp2p::websocket::framed::OutgoingData::Binary(item); future::ready(Ok::<_, io::Error>(item)) }) - .try_filter(|item| future::ready(item.is_data())) - .map_ok(|data| data.into_bytes()); + .try_filter_map(|item| async move { + if let libp2p::websocket::framed::Incoming::Data(data) = item { + Ok(Some(data.into_bytes())) + } else { + Ok(None) + } + }); future::ready(Ok::<_, io::Error>(connec)) }) }; diff --git a/primitives/core/Cargo.toml b/primitives/core/Cargo.toml index d23579c8ca2c0..9fbdeb15a0366 100644 --- a/primitives/core/Cargo.toml +++ b/primitives/core/Cargo.toml @@ -32,7 +32,7 @@ substrate-bip39 = { version = "0.4.4", optional = true } tiny-bip39 = { version = "0.8.2", optional = true } regex = { version = "1.5.4", optional = true } num-traits = { version = "0.2.8", default-features = false } -zeroize = { version = "1.5.4", default-features = false } +zeroize = { version = "1.4.3", default-features = false } secrecy = { version = "0.8.0", default-features = false } lazy_static = { version = "1.4.0", default-features = false, optional = true } parking_lot = { version = "0.12.0", optional = true } diff --git a/utils/frame/benchmarking-cli/src/pallet/writer.rs b/utils/frame/benchmarking-cli/src/pallet/writer.rs index cd97b3efbd9db..81b20ad445cd0 100644 --- a/utils/frame/benchmarking-cli/src/pallet/writer.rs +++ b/utils/frame/benchmarking-cli/src/pallet/writer.rs @@ -311,7 +311,7 @@ pub fn write_results( // Check if there might be multiple instances benchmarked. if all_results.keys().any(|(p, i)| p == pallet && i != instance) { // Create new file: "path/to/pallet_name_instance_name.rs". - file_path.push(pallet.clone() + "_" + &instance.to_snake_case()); + file_path.push(pallet.clone() + "_" + instance.to_snake_case().as_str()); } else { // Create new file: "path/to/pallet_name.rs". file_path.push(pallet.clone());