From 3102dbdf4a9ab26477a38c3931f76a5eb67f5d0c Mon Sep 17 00:00:00 2001 From: Anton Kaliaev Date: Wed, 21 Jun 2023 14:32:13 +0300 Subject: [PATCH 01/42] update libp2p to 0.52.0 --- Cargo.lock | 626 ++++++++++++++---- Cargo.toml | 4 + client/network/Cargo.toml | 2 +- client/network/src/behaviour.rs | 2 +- client/network/src/discovery.rs | 12 +- client/network/src/peer_info.rs | 24 +- client/network/src/protocol.rs | 3 +- .../src/protocol/notifications/behaviour.rs | 4 +- .../src/protocol/notifications/handler.rs | 16 +- .../src/protocol/notifications/tests.rs | 4 +- client/network/src/request_responses.rs | 3 +- client/network/src/service.rs | 33 +- client/network/src/transport.rs | 1 + 13 files changed, 549 insertions(+), 185 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 37f18f2cd2d77..12e872624135b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -302,7 +302,7 @@ dependencies = [ "serde", "serde_derive", "serde_json", - "sha2 0.10.6", + "sha2 0.10.7", ] [[package]] @@ -537,9 +537,9 @@ checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" [[package]] name = "arrayvec" -version = "0.7.2" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8da52d66c7071e2e3fa2a1e5c6d088fec47b593032b254f5e980de8ea54454d6" +checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" [[package]] name = "asn1-rs" @@ -656,7 +656,7 @@ dependencies = [ "polling", "rustix 0.37.19", "slab", - "socket2", + "socket2 0.4.9", "waker-fn", ] @@ -894,7 +894,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c2f0dc9a68c6317d884f97cc36cf5a3d20ba14ce404227df55e1af708ab04bc" dependencies = [ "arrayref", - "arrayvec 0.7.2", + "arrayvec 0.7.4", "constant_time_eq", ] @@ -905,7 +905,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6637f448b9e61dfadbdcbae9a885fadee1f3eaffb1f8d3c1965d3ade8bdfd44f" dependencies = [ "arrayref", - "arrayvec 0.7.2", + "arrayvec 0.7.4", "constant_time_eq", ] @@ -916,7 +916,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42ae2468a89544a466886840aa467a25b766499f4f04bf7d9fcd10ecee9fccef" dependencies = [ "arrayref", - "arrayvec 0.7.2", + "arrayvec 0.7.4", "cc", "cfg-if", "constant_time_eq", @@ -995,6 +995,15 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "771fe0050b883fcc3ea2359b1a96bcfbc090b7116eae7c3c512c7a083fdf23d3" +[[package]] +name = "bs58" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f5353f36341f7451062466f0b755b96ac3a9547e4d7f6b70d603fc721a7d7896" +dependencies = [ + "tinyvec", +] + [[package]] name = "bstr" version = "1.5.0" @@ -3541,7 +3550,7 @@ dependencies = [ "httpdate", "itoa", "pin-project-lite 0.2.9", - "socket2", + "socket2 0.4.9", "tokio", "tower-service", "tracing", @@ -3561,7 +3570,7 @@ dependencies = [ "rustls-native-certs", "tokio", "tokio-rustls 0.23.4", - "webpki-roots", + "webpki-roots 0.22.6", ] [[package]] @@ -3797,7 +3806,7 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bd302af1b90f2463a98fa5ad469fc212c8e3175a41c3068601bfa2727591c5be" dependencies = [ - "socket2", + "socket2 0.4.9", "widestring", "winapi", "winreg", @@ -3887,7 +3896,7 @@ dependencies = [ "tokio-rustls 0.23.4", "tokio-util", "tracing", - "webpki-roots", + "webpki-roots 0.22.6", ] [[package]] @@ -3897,7 +3906,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a4e70b4439a751a5de7dd5ed55eacff78ebf4ffe0fc009cb1ebb11417f5b536b" dependencies = [ "anyhow", - "arrayvec 0.7.2", + "arrayvec 0.7.4", "async-lock", "async-trait", "beef", @@ -4008,7 +4017,7 @@ dependencies = [ "ecdsa 0.16.7", "elliptic-curve 0.13.5", "once_cell", - "sha2 0.10.6", + "sha2 0.10.7", ] [[package]] @@ -4229,26 +4238,51 @@ dependencies = [ "futures-timer", "getrandom 0.2.9", "instant", - "libp2p-allow-block-list", - "libp2p-connection-limits", - "libp2p-core", - "libp2p-dns", - "libp2p-identify", - "libp2p-identity", - "libp2p-kad", - "libp2p-mdns", - "libp2p-metrics", - "libp2p-noise", - "libp2p-ping", + "libp2p-allow-block-list 0.1.1", + "libp2p-connection-limits 0.1.0", + "libp2p-core 0.39.2", + "libp2p-dns 0.39.0", + "libp2p-identity 0.1.2", + "libp2p-kad 0.43.3", + "libp2p-mdns 0.43.1", + "libp2p-metrics 0.12.0", "libp2p-quic", - "libp2p-request-response", - "libp2p-swarm", - "libp2p-tcp", + "libp2p-swarm 0.42.2", + "libp2p-tcp 0.39.0", "libp2p-wasm-ext", "libp2p-webrtc", - "libp2p-websocket", + "libp2p-websocket 0.41.0", + "multiaddr 0.17.1", + "pin-project", +] + +[[package]] +name = "libp2p" +version = "0.52.0" +source = "git+https://github.com/melekes/rust-libp2p.git?branch=anton/upgrade-webrtc-to-0.8.0#63452cf7709b8b48303ba7b2251e169d97d48da9" +dependencies = [ + "bytes", + "futures", + "futures-timer", + "getrandom 0.2.9", + "instant", + "libp2p-allow-block-list 0.2.0", + "libp2p-connection-limits 0.2.0", + "libp2p-core 0.40.0", + "libp2p-dns 0.40.0", + "libp2p-identify", + "libp2p-identity 0.2.0", + "libp2p-kad 0.44.0", + "libp2p-mdns 0.44.0", + "libp2p-metrics 0.13.0", + "libp2p-noise 0.43.0", + "libp2p-ping", + "libp2p-request-response", + "libp2p-swarm 0.43.0", + "libp2p-tcp 0.40.0", + "libp2p-websocket 0.42.0", "libp2p-yamux", - "multiaddr", + "multiaddr 0.18.0", "pin-project", ] @@ -4258,9 +4292,20 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "510daa05efbc25184458db837f6f9a5143888f1caa742426d92e1833ddd38a50" dependencies = [ - "libp2p-core", - "libp2p-identity", - "libp2p-swarm", + "libp2p-core 0.39.2", + "libp2p-identity 0.1.2", + "libp2p-swarm 0.42.2", + "void", +] + +[[package]] +name = "libp2p-allow-block-list" +version = "0.2.0" +source = "git+https://github.com/melekes/rust-libp2p.git?branch=anton/upgrade-webrtc-to-0.8.0#63452cf7709b8b48303ba7b2251e169d97d48da9" +dependencies = [ + "libp2p-core 0.40.0", + "libp2p-identity 0.2.0", + "libp2p-swarm 0.43.0", "void", ] @@ -4270,9 +4315,20 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4caa33f1d26ed664c4fe2cca81a08c8e07d4c1c04f2f4ac7655c2dd85467fda0" dependencies = [ - "libp2p-core", - "libp2p-identity", - "libp2p-swarm", + "libp2p-core 0.39.2", + "libp2p-identity 0.1.2", + "libp2p-swarm 0.42.2", + "void", +] + +[[package]] +name = "libp2p-connection-limits" +version = "0.2.0" +source = "git+https://github.com/melekes/rust-libp2p.git?branch=anton/upgrade-webrtc-to-0.8.0#63452cf7709b8b48303ba7b2251e169d97d48da9" +dependencies = [ + "libp2p-core 0.40.0", + "libp2p-identity 0.2.0", + "libp2p-swarm 0.43.0", "void", ] @@ -4287,17 +4343,44 @@ dependencies = [ "futures", "futures-timer", "instant", - "libp2p-identity", + "libp2p-identity 0.1.2", "log", - "multiaddr", + "multiaddr 0.17.1", "multihash 0.17.0", - "multistream-select", + "multistream-select 0.12.1", + "once_cell", + "parking_lot 0.12.1", + "pin-project", + "quick-protobuf", + "rand 0.8.5", + "rw-stream-sink 0.3.0", + "smallvec", + "thiserror", + "unsigned-varint", + "void", +] + +[[package]] +name = "libp2p-core" +version = "0.40.0" +source = "git+https://github.com/melekes/rust-libp2p.git?branch=anton/upgrade-webrtc-to-0.8.0#63452cf7709b8b48303ba7b2251e169d97d48da9" +dependencies = [ + "either", + "fnv", + "futures", + "futures-timer", + "instant", + "libp2p-identity 0.2.0", + "log", + "multiaddr 0.18.0", + "multihash 0.19.0", + "multistream-select 0.13.0", "once_cell", "parking_lot 0.12.1", "pin-project", "quick-protobuf", "rand 0.8.5", - "rw-stream-sink", + "rw-stream-sink 0.4.0", "smallvec", "thiserror", "unsigned-varint", @@ -4311,7 +4394,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "146ff7034daae62077c415c2376b8057368042df6ab95f5432ad5e88568b1554" dependencies = [ "futures", - "libp2p-core", + "libp2p-core 0.39.2", + "log", + "parking_lot 0.12.1", + "smallvec", + "trust-dns-resolver", +] + +[[package]] +name = "libp2p-dns" +version = "0.40.0" +source = "git+https://github.com/melekes/rust-libp2p.git?branch=anton/upgrade-webrtc-to-0.8.0#63452cf7709b8b48303ba7b2251e169d97d48da9" +dependencies = [ + "futures", + "libp2p-core 0.40.0", + "libp2p-identity 0.2.0", "log", "parking_lot 0.12.1", "smallvec", @@ -4320,21 +4417,20 @@ dependencies = [ [[package]] name = "libp2p-identify" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5455f472243e63b9c497ff320ded0314254a9eb751799a39c283c6f20b793f3c" +version = "0.43.0" +source = "git+https://github.com/melekes/rust-libp2p.git?branch=anton/upgrade-webrtc-to-0.8.0#63452cf7709b8b48303ba7b2251e169d97d48da9" dependencies = [ "asynchronous-codec", "either", "futures", "futures-timer", - "libp2p-core", - "libp2p-identity", - "libp2p-swarm", + "libp2p-core 0.40.0", + "libp2p-identity 0.2.0", + "libp2p-swarm 0.43.0", "log", "lru", "quick-protobuf", - "quick-protobuf-codec", + "quick-protobuf-codec 0.2.0", "smallvec", "thiserror", "void", @@ -4346,14 +4442,31 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9e2d584751cecb2aabaa56106be6be91338a60a0f4e420cf2af639204f596fc1" dependencies = [ - "bs58", + "bs58 0.4.0", "ed25519-dalek", "log", - "multiaddr", + "multiaddr 0.17.1", "multihash 0.17.0", "quick-protobuf", "rand 0.8.5", - "sha2 0.10.6", + "sha2 0.10.7", + "thiserror", + "zeroize", +] + +[[package]] +name = "libp2p-identity" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93a7b3534b84fe89985d8076246806c845e716d0cdac50925dcf65caf49ab3c0" +dependencies = [ + "bs58 0.5.0", + "ed25519-dalek", + "log", + "multihash 0.19.0", + "quick-protobuf", + "rand 0.8.5", + "sha2 0.10.7", "thiserror", "zeroize", ] @@ -4364,7 +4477,34 @@ version = "0.43.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "39d5ef876a2b2323d63c258e63c2f8e36f205fe5a11f0b3095d59635650790ff" dependencies = [ - "arrayvec 0.7.2", + "arrayvec 0.7.4", + "asynchronous-codec", + "bytes", + "either", + "fnv", + "futures", + "futures-timer", + "instant", + "libp2p-core 0.39.2", + "libp2p-identity 0.1.2", + "libp2p-swarm 0.42.2", + "log", + "quick-protobuf", + "rand 0.8.5", + "sha2 0.10.7", + "smallvec", + "thiserror", + "uint", + "unsigned-varint", + "void", +] + +[[package]] +name = "libp2p-kad" +version = "0.44.0" +source = "git+https://github.com/melekes/rust-libp2p.git?branch=anton/upgrade-webrtc-to-0.8.0#63452cf7709b8b48303ba7b2251e169d97d48da9" +dependencies = [ + "arrayvec 0.7.4", "asynchronous-codec", "bytes", "either", @@ -4372,13 +4512,13 @@ dependencies = [ "futures", "futures-timer", "instant", - "libp2p-core", - "libp2p-identity", - "libp2p-swarm", + "libp2p-core 0.40.0", + "libp2p-identity 0.2.0", + "libp2p-swarm 0.43.0", "log", "quick-protobuf", "rand 0.8.5", - "sha2 0.10.6", + "sha2 0.10.7", "smallvec", "thiserror", "uint", @@ -4395,13 +4535,33 @@ dependencies = [ "data-encoding", "futures", "if-watch", - "libp2p-core", - "libp2p-identity", - "libp2p-swarm", + "libp2p-core 0.39.2", + "libp2p-identity 0.1.2", + "libp2p-swarm 0.42.2", "log", "rand 0.8.5", "smallvec", - "socket2", + "socket2 0.4.9", + "tokio", + "trust-dns-proto", + "void", +] + +[[package]] +name = "libp2p-mdns" +version = "0.44.0" +source = "git+https://github.com/melekes/rust-libp2p.git?branch=anton/upgrade-webrtc-to-0.8.0#63452cf7709b8b48303ba7b2251e169d97d48da9" +dependencies = [ + "data-encoding", + "futures", + "if-watch", + "libp2p-core 0.40.0", + "libp2p-identity 0.2.0", + "libp2p-swarm 0.43.0", + "log", + "rand 0.8.5", + "smallvec", + "socket2 0.5.3", "tokio", "trust-dns-proto", "void", @@ -4413,12 +4573,26 @@ version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a42ec91e227d7d0dafa4ce88b333cdf5f277253873ab087555c92798db2ddd46" dependencies = [ - "libp2p-core", + "libp2p-core 0.39.2", + "libp2p-kad 0.43.3", + "libp2p-swarm 0.42.2", + "prometheus-client 0.19.0", +] + +[[package]] +name = "libp2p-metrics" +version = "0.13.0" +source = "git+https://github.com/melekes/rust-libp2p.git?branch=anton/upgrade-webrtc-to-0.8.0#63452cf7709b8b48303ba7b2251e169d97d48da9" +dependencies = [ + "instant", + "libp2p-core 0.40.0", "libp2p-identify", - "libp2p-kad", + "libp2p-identity 0.2.0", + "libp2p-kad 0.44.0", "libp2p-ping", - "libp2p-swarm", - "prometheus-client", + "libp2p-swarm 0.43.0", + "once_cell", + "prometheus-client 0.21.1", ] [[package]] @@ -4430,13 +4604,37 @@ dependencies = [ "bytes", "curve25519-dalek 3.2.0", "futures", - "libp2p-core", - "libp2p-identity", + "libp2p-core 0.39.2", + "libp2p-identity 0.1.2", + "log", + "once_cell", + "quick-protobuf", + "rand 0.8.5", + "sha2 0.10.7", + "snow", + "static_assertions", + "thiserror", + "x25519-dalek 1.1.1", + "zeroize", +] + +[[package]] +name = "libp2p-noise" +version = "0.43.0" +source = "git+https://github.com/melekes/rust-libp2p.git?branch=anton/upgrade-webrtc-to-0.8.0#63452cf7709b8b48303ba7b2251e169d97d48da9" +dependencies = [ + "bytes", + "curve25519-dalek 3.2.0", + "futures", + "libp2p-core 0.40.0", + "libp2p-identity 0.2.0", "log", + "multiaddr 0.18.0", + "multihash 0.19.0", "once_cell", "quick-protobuf", "rand 0.8.5", - "sha2 0.10.6", + "sha2 0.10.7", "snow", "static_assertions", "thiserror", @@ -4446,16 +4644,16 @@ dependencies = [ [[package]] name = "libp2p-ping" -version = "0.42.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e57759c19c28a73ef1eb3585ca410cefb72c1a709fcf6de1612a378e4219202" +version = "0.43.0" +source = "git+https://github.com/melekes/rust-libp2p.git?branch=anton/upgrade-webrtc-to-0.8.0#63452cf7709b8b48303ba7b2251e169d97d48da9" dependencies = [ "either", "futures", "futures-timer", "instant", - "libp2p-core", - "libp2p-swarm", + "libp2p-core 0.40.0", + "libp2p-identity 0.2.0", + "libp2p-swarm 0.43.0", "log", "rand 0.8.5", "void", @@ -4471,8 +4669,8 @@ dependencies = [ "futures", "futures-timer", "if-watch", - "libp2p-core", - "libp2p-identity", + "libp2p-core 0.39.2", + "libp2p-identity 0.1.2", "libp2p-tls", "log", "parking_lot 0.12.1", @@ -4485,18 +4683,19 @@ dependencies = [ [[package]] name = "libp2p-request-response" -version = "0.24.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ffdb374267d42dc5ed5bc53f6e601d4a64ac5964779c6e40bb9e4f14c1e30d5" +version = "0.25.0" +source = "git+https://github.com/melekes/rust-libp2p.git?branch=anton/upgrade-webrtc-to-0.8.0#63452cf7709b8b48303ba7b2251e169d97d48da9" dependencies = [ "async-trait", "futures", "instant", - "libp2p-core", - "libp2p-identity", - "libp2p-swarm", + "libp2p-core 0.40.0", + "libp2p-identity 0.2.0", + "libp2p-swarm 0.43.0", + "log", "rand 0.8.5", "smallvec", + "void", ] [[package]] @@ -4510,10 +4709,31 @@ dependencies = [ "futures", "futures-timer", "instant", - "libp2p-core", - "libp2p-identity", + "libp2p-core 0.39.2", + "libp2p-identity 0.1.2", + "log", + "rand 0.8.5", + "smallvec", + "tokio", + "void", +] + +[[package]] +name = "libp2p-swarm" +version = "0.43.0" +source = "git+https://github.com/melekes/rust-libp2p.git?branch=anton/upgrade-webrtc-to-0.8.0#63452cf7709b8b48303ba7b2251e169d97d48da9" +dependencies = [ + "either", + "fnv", + "futures", + "futures-timer", + "instant", + "libp2p-core 0.40.0", + "libp2p-identity 0.2.0", "libp2p-swarm-derive", "log", + "multistream-select 0.13.0", + "once_cell", "rand 0.8.5", "smallvec", "tokio", @@ -4522,13 +4742,14 @@ dependencies = [ [[package]] name = "libp2p-swarm-derive" -version = "0.32.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fba456131824ab6acd4c7bf61e9c0f0a3014b5fc9868ccb8e10d344594cdc4f" +version = "0.33.0" +source = "git+https://github.com/melekes/rust-libp2p.git?branch=anton/upgrade-webrtc-to-0.8.0#63452cf7709b8b48303ba7b2251e169d97d48da9" dependencies = [ "heck", + "proc-macro-warning", + "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.18", ] [[package]] @@ -4541,9 +4762,25 @@ dependencies = [ "futures-timer", "if-watch", "libc", - "libp2p-core", + "libp2p-core 0.39.2", + "log", + "socket2 0.4.9", + "tokio", +] + +[[package]] +name = "libp2p-tcp" +version = "0.40.0" +source = "git+https://github.com/melekes/rust-libp2p.git?branch=anton/upgrade-webrtc-to-0.8.0#63452cf7709b8b48303ba7b2251e169d97d48da9" +dependencies = [ + "futures", + "futures-timer", + "if-watch", + "libc", + "libp2p-core 0.40.0", + "libp2p-identity 0.2.0", "log", - "socket2", + "socket2 0.5.3", "tokio", ] @@ -4555,8 +4792,8 @@ checksum = "ff08d13d0dc66e5e9ba6279c1de417b84fa0d0adc3b03e5732928c180ec02781" dependencies = [ "futures", "futures-rustls", - "libp2p-core", - "libp2p-identity", + "libp2p-core 0.39.2", + "libp2p-identity 0.1.2", "rcgen 0.10.0", "ring", "rustls 0.20.8", @@ -4574,7 +4811,7 @@ checksum = "77dff9d32353a5887adb86c8afc1de1a94d9e8c3bc6df8b2201d7cdf5c848f43" dependencies = [ "futures", "js-sys", - "libp2p-core", + "libp2p-core 0.39.2", "parity-send-wrapper", "wasm-bindgen", "wasm-bindgen-futures", @@ -4593,13 +4830,13 @@ dependencies = [ "futures-timer", "hex", "if-watch", - "libp2p-core", - "libp2p-identity", - "libp2p-noise", + "libp2p-core 0.39.2", + "libp2p-identity 0.1.2", + "libp2p-noise 0.42.2", "log", "multihash 0.17.0", "quick-protobuf", - "quick-protobuf-codec", + "quick-protobuf-codec 0.1.0", "rand 0.8.5", "rcgen 0.9.3", "serde", @@ -4620,24 +4857,42 @@ dependencies = [ "either", "futures", "futures-rustls", - "libp2p-core", + "libp2p-core 0.39.2", + "log", + "parking_lot 0.12.1", + "quicksink", + "rw-stream-sink 0.3.0", + "soketto", + "url", + "webpki-roots 0.22.6", +] + +[[package]] +name = "libp2p-websocket" +version = "0.42.0" +source = "git+https://github.com/melekes/rust-libp2p.git?branch=anton/upgrade-webrtc-to-0.8.0#63452cf7709b8b48303ba7b2251e169d97d48da9" +dependencies = [ + "either", + "futures", + "futures-rustls", + "libp2p-core 0.40.0", + "libp2p-identity 0.2.0", "log", "parking_lot 0.12.1", "quicksink", - "rw-stream-sink", + "rw-stream-sink 0.4.0", "soketto", "url", - "webpki-roots", + "webpki-roots 0.23.1", ] [[package]] name = "libp2p-yamux" -version = "0.43.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4dcd21d950662700a385d4c6d68e2f5f54d778e97068cdd718522222ef513bda" +version = "0.44.0" +source = "git+https://github.com/melekes/rust-libp2p.git?branch=anton/upgrade-webrtc-to-0.8.0#63452cf7709b8b48303ba7b2251e169d97d48da9" dependencies = [ "futures", - "libp2p-core", + "libp2p-core 0.40.0", "log", "thiserror", "yamux", @@ -4792,9 +5047,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.18" +version = "0.4.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "518ef76f2f87365916b142844c16d8fefd85039bc5699050210a7778ee1cd1de" +checksum = "b06a4cde4c0f271a446782e3eff8de789548ce57dbc8eca9292c27f4a42004b4" [[package]] name = "lru" @@ -5137,6 +5392,25 @@ dependencies = [ "url", ] +[[package]] +name = "multiaddr" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92a651988b3ed3ad1bc8c87d016bb92f6f395b84ed1db9b926b32b1fc5a2c8b5" +dependencies = [ + "arrayref", + "byteorder", + "data-encoding", + "libp2p-identity 0.2.0", + "multibase", + "multihash 0.19.0", + "percent-encoding", + "serde", + "static_assertions", + "unsigned-varint", + "url", +] + [[package]] name = "multibase" version = "0.9.1" @@ -5160,7 +5434,7 @@ dependencies = [ "core2", "digest 0.10.7", "multihash-derive", - "sha2 0.10.6", + "sha2 0.10.7", "sha3", "unsigned-varint", ] @@ -5174,7 +5448,17 @@ dependencies = [ "core2", "digest 0.10.7", "multihash-derive", - "sha2 0.10.6", + "sha2 0.10.7", + "unsigned-varint", +] + +[[package]] +name = "multihash" +version = "0.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2fd59dcc2bbe70baabeac52cd22ae52c55eefe6c38ff11a9439f16a350a939f2" +dependencies = [ + "core2", "unsigned-varint", ] @@ -5212,6 +5496,19 @@ dependencies = [ "unsigned-varint", ] +[[package]] +name = "multistream-select" +version = "0.13.0" +source = "git+https://github.com/melekes/rust-libp2p.git?branch=anton/upgrade-webrtc-to-0.8.0#63452cf7709b8b48303ba7b2251e169d97d48da9" +dependencies = [ + "bytes", + "futures", + "log", + "pin-project", + "smallvec", + "unsigned-varint", +] + [[package]] name = "nalgebra" version = "0.32.2" @@ -5776,7 +6073,7 @@ version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a652d9771a63711fd3c3deb670acfbe5c30a4072e664d7a3bf5a9e1056ac72c3" dependencies = [ - "arrayvec 0.7.2", + "arrayvec 0.7.4", "itoa", ] @@ -5928,7 +6225,7 @@ checksum = "51f44edd08f51e2ade572f141051021c5af22677e42b7dd28a88155151c33594" dependencies = [ "ecdsa 0.14.8", "elliptic-curve 0.12.3", - "sha2 0.10.6", + "sha2 0.10.7", ] [[package]] @@ -5939,7 +6236,7 @@ checksum = "dfc8c5bf642dde52bb9e87c0ecd8ca5a76faac2eeed98dedb7c717997e1080aa" dependencies = [ "ecdsa 0.14.8", "elliptic-curve 0.12.3", - "sha2 0.10.6", + "sha2 0.10.7", ] [[package]] @@ -7664,7 +7961,7 @@ version = "3.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5ddb756ca205bd108aee3c62c6d3c994e1df84a59b9d6d4a5ea42ee1fd5a9a28" dependencies = [ - "arrayvec 0.7.2", + "arrayvec 0.7.4", "bitvec", "byte-slice-cast", "bytes", @@ -7852,7 +8149,7 @@ checksum = "745a452f8eb71e39ffd8ee32b3c5f51d03845f99786fa9b68db6ff509c505411" dependencies = [ "once_cell", "pest", - "sha2 0.10.6", + "sha2 0.10.7", ] [[package]] @@ -8194,6 +8491,18 @@ dependencies = [ "prometheus-client-derive-encode", ] +[[package]] +name = "prometheus-client" +version = "0.21.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78c2f43e8969d51935d2a7284878ae053ba30034cd563f673cde37ba5205685e" +dependencies = [ + "dtoa", + "itoa", + "parking_lot 0.12.1", + "prometheus-client-derive-encode", +] + [[package]] name = "prometheus-client-derive-encode" version = "0.4.1" @@ -8296,6 +8605,18 @@ dependencies = [ "unsigned-varint", ] +[[package]] +name = "quick-protobuf-codec" +version = "0.2.0" +source = "git+https://github.com/melekes/rust-libp2p.git?branch=anton/upgrade-webrtc-to-0.8.0#63452cf7709b8b48303ba7b2251e169d97d48da9" +dependencies = [ + "asynchronous-codec", + "bytes", + "quick-protobuf", + "thiserror", + "unsigned-varint", +] + [[package]] name = "quickcheck" version = "1.0.3" @@ -8871,6 +9192,16 @@ dependencies = [ "static_assertions", ] +[[package]] +name = "rw-stream-sink" +version = "0.4.0" +source = "git+https://github.com/melekes/rust-libp2p.git?branch=anton/upgrade-webrtc-to-0.8.0#63452cf7709b8b48303ba7b2251e169d97d48da9" +dependencies = [ + "futures", + "pin-project", + "static_assertions", +] + [[package]] name = "ryu" version = "1.0.13" @@ -8922,7 +9253,7 @@ dependencies = [ "futures", "futures-timer", "ip_network", - "libp2p", + "libp2p 0.51.3", "log", "multihash 0.17.0", "parity-scale-codec", @@ -9024,7 +9355,7 @@ dependencies = [ "fdlimit", "futures", "futures-timer", - "libp2p-identity", + "libp2p-identity 0.1.2", "log", "names", "parity-scale-codec", @@ -9125,7 +9456,7 @@ dependencies = [ "async-trait", "futures", "futures-timer", - "libp2p-identity", + "libp2p-identity 0.1.2", "log", "mockall", "parking_lot 0.12.1", @@ -9601,12 +9932,12 @@ dependencies = [ "futures", "futures-timer", "ip_network", - "libp2p", + "libp2p 0.52.0", "linked_hash_set", "log", "lru", "mockall", - "multistream-select", + "multistream-select 0.12.1", "parity-scale-codec", "parking_lot 0.12.1", "partial_sort", @@ -9650,7 +9981,7 @@ dependencies = [ "async-channel", "cid", "futures", - "libp2p-identity", + "libp2p-identity 0.1.2", "log", "prost", "prost-build", @@ -9680,7 +10011,7 @@ dependencies = [ "bytes", "futures", "futures-timer", - "libp2p-identity", + "libp2p-identity 0.1.2", "parity-scale-codec", "prost-build", "sc-consensus", @@ -9704,7 +10035,7 @@ dependencies = [ "ahash 0.8.3", "futures", "futures-timer", - "libp2p", + "libp2p 0.51.3", "log", "lru", "quickcheck", @@ -9724,7 +10055,7 @@ dependencies = [ "array-bytes 4.2.0", "async-channel", "futures", - "libp2p-identity", + "libp2p-identity 0.1.2", "log", "parity-scale-codec", "prost", @@ -9745,7 +10076,7 @@ dependencies = [ "array-bytes 4.2.0", "async-channel", "futures", - "libp2p", + "libp2p 0.51.3", "log", "parity-scale-codec", "pin-project", @@ -9767,7 +10098,7 @@ dependencies = [ "fork-tree", "futures", "futures-timer", - "libp2p", + "libp2p 0.51.3", "log", "lru", "mockall", @@ -9803,7 +10134,7 @@ dependencies = [ "async-trait", "futures", "futures-timer", - "libp2p", + "libp2p 0.51.3", "log", "parking_lot 0.12.1", "rand 0.8.5", @@ -9833,7 +10164,7 @@ version = "0.10.0-dev" dependencies = [ "array-bytes 4.2.0", "futures", - "libp2p", + "libp2p 0.51.3", "log", "parity-scale-codec", "sc-network", @@ -9856,7 +10187,7 @@ dependencies = [ "hyper", "hyper-rustls 0.24.0", "lazy_static", - "libp2p", + "libp2p 0.51.3", "num_cpus", "once_cell", "parity-scale-codec", @@ -10203,7 +10534,7 @@ version = "4.0.0-dev" dependencies = [ "chrono", "futures", - "libp2p", + "libp2p 0.51.3", "log", "parking_lot 0.12.1", "pin-project", @@ -10630,9 +10961,9 @@ dependencies = [ [[package]] name = "sha2" -version = "0.10.6" +version = "0.10.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82e6b795fe2e3b1e845bafcb27aa35405c4d47cdfc92af5fc8d3002f76cebdc0" +checksum = "479fb9d862239e610720565ca91403019f2f00410f1864c5aa7479b950a76ed8" dependencies = [ "cfg-if", "cpufeatures", @@ -10752,7 +11083,7 @@ dependencies = [ "rand_core 0.6.4", "ring", "rustc_version 0.4.0", - "sha2 0.10.6", + "sha2 0.10.7", "subtle", ] @@ -10766,6 +11097,16 @@ dependencies = [ "winapi", ] +[[package]] +name = "socket2" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2538b18701741680e0322a2302176d3253a35388e2e62f172f64f4f16605f877" +dependencies = [ + "libc", + "windows-sys 0.48.0", +] + [[package]] name = "soketto" version = "0.7.1" @@ -11146,7 +11487,7 @@ dependencies = [ "bitflags", "blake2", "bounded-collections", - "bs58", + "bs58 0.4.0", "criterion", "dyn-clonable", "ed25519-zebra", @@ -11193,7 +11534,7 @@ dependencies = [ "blake2b_simd", "byteorder", "digest 0.10.7", - "sha2 0.10.6", + "sha2 0.10.7", "sha3", "sp-std", "twox-hash", @@ -12417,7 +12758,7 @@ dependencies = [ "pbkdf2 0.11.0", "rand 0.8.5", "rustc-hash", - "sha2 0.10.6", + "sha2 0.10.7", "thiserror", "unicode-normalization", "wasm-bindgen", @@ -12472,7 +12813,7 @@ dependencies = [ "parking_lot 0.12.1", "pin-project-lite 0.2.9", "signal-hook-registry", - "socket2", + "socket2 0.4.9", "tokio-macros", "windows-sys 0.48.0", ] @@ -12816,7 +13157,7 @@ dependencies = [ "lazy_static", "rand 0.8.5", "smallvec", - "socket2", + "socket2 0.4.9", "thiserror", "tinyvec", "tokio", @@ -13106,7 +13447,7 @@ dependencies = [ "rand 0.8.5", "rand_chacha 0.3.1", "rand_core 0.6.4", - "sha2 0.10.6", + "sha2 0.10.7", "sha3", "thiserror", "zeroize", @@ -13422,7 +13763,7 @@ dependencies = [ "log", "rustix 0.36.14", "serde", - "sha2 0.10.6", + "sha2 0.10.7", "toml 0.5.11", "windows-sys 0.45.0", "zstd 0.11.2+zstd.1.5.2", @@ -13626,6 +13967,15 @@ dependencies = [ "webpki 0.22.0", ] +[[package]] +name = "webpki-roots" +version = "0.23.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b03058f88386e5ff5310d9111d53f48b17d732b401aeb83a8d5190f2ac459338" +dependencies = [ + "rustls-webpki", +] + [[package]] name = "webrtc" version = "0.6.0" @@ -13649,7 +13999,7 @@ dependencies = [ "sdp", "serde", "serde_json", - "sha2 0.10.6", + "sha2 0.10.7", "stun", "thiserror", "time 0.3.21", @@ -13712,7 +14062,7 @@ dependencies = [ "sec1 0.3.0", "serde", "sha1", - "sha2 0.10.6", + "sha2 0.10.7", "signature 1.6.4", "subtle", "thiserror", @@ -13754,7 +14104,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f08dfd7a6e3987e255c4dbe710dde5d94d0f0574f8a21afa95d171376c143106" dependencies = [ "log", - "socket2", + "socket2 0.4.9", "thiserror", "tokio", "webrtc-util", diff --git a/Cargo.toml b/Cargo.toml index ce93421bc9ff1..428772eccbba6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -337,3 +337,7 @@ inherits = "release" lto = "fat" # https://doc.rust-lang.org/rustc/codegen-options/index.html#codegen-units codegen-units = 1 + +# FIXME: remove +[patch.crates-io] +libp2p = { version = "0.52.0", git = "https://github.com/melekes/rust-libp2p.git", branch = "anton/upgrade-webrtc-to-0.8.0" } \ No newline at end of file diff --git a/client/network/Cargo.toml b/client/network/Cargo.toml index be8112327eb80..3c071f017b96b 100644 --- a/client/network/Cargo.toml +++ b/client/network/Cargo.toml @@ -25,7 +25,7 @@ fnv = "1.0.6" futures = "0.3.21" futures-timer = "3.0.2" ip_network = "0.4.1" -libp2p = { version = "0.51.3", features = ["dns", "identify", "kad", "macros", "mdns", "noise", "ping", "tcp", "tokio", "yamux", "websocket", "request-response"] } +libp2p = { version = "0.52.0", features = ["dns", "identify", "kad", "macros", "mdns", "noise", "ping", "tcp", "tokio", "yamux", "websocket", "request-response"] } linked_hash_set = "0.1.3" log = "0.4.17" lru = "0.10.0" diff --git a/client/network/src/behaviour.rs b/client/network/src/behaviour.rs index a4c19c47c3a80..191382c5da2f9 100644 --- a/client/network/src/behaviour.rs +++ b/client/network/src/behaviour.rs @@ -42,7 +42,7 @@ pub use crate::request_responses::{InboundFailure, OutboundFailure, RequestId, R /// General behaviour of the network. Combines all protocols together. #[derive(NetworkBehaviour)] -#[behaviour(out_event = "BehaviourOut")] +#[behaviour(to_swarm = "BehaviourOut")] pub struct Behaviour { /// All the substrate-specific protocols. substrate: Protocol, diff --git a/client/network/src/discovery.rs b/client/network/src/discovery.rs index 708406bd15340..e2c1f8c602c13 100644 --- a/client/network/src/discovery.rs +++ b/client/network/src/discovery.rs @@ -55,17 +55,16 @@ use ip_network::IpNetwork; use libp2p::{ core::{Endpoint, Multiaddr}, kad::{ - handler::KademliaHandler, record::store::{MemoryStore, RecordStore}, GetClosestPeersError, GetRecordOk, Kademlia, KademliaBucketInserts, KademliaConfig, - KademliaEvent, QueryId, QueryResult, Quorum, Record, RecordKey, + KademliaEvent, KademliaHandler, QueryId, QueryResult, Quorum, Record, RecordKey, }, mdns::{self, tokio::Behaviour as TokioMdns}, multiaddr::Protocol, swarm::{ behaviour::{ toggle::{Toggle, ToggleConnectionHandler}, - DialFailure, FromSwarm, NewExternalAddr, + DialFailure, FromSwarm, NewExternalAddrCandidate, }, ConnectionDenied, ConnectionId, DialError, NetworkBehaviour, PollParameters, THandler, THandlerInEvent, THandlerOutEvent, ToSwarm, @@ -483,7 +482,6 @@ pub enum DiscoveryOut { impl NetworkBehaviour for DiscoveryBehaviour { type ConnectionHandler = ToggleConnectionHandler>; - type OutEvent = DiscoveryOut; fn handle_established_inbound_connection( &mut self, @@ -625,7 +623,7 @@ impl NetworkBehaviour for DiscoveryBehaviour { FromSwarm::ExpiredListenAddr(e) => { self.kademlia.on_swarm_event(FromSwarm::ExpiredListenAddr(e)); }, - FromSwarm::NewExternalAddr(e @ NewExternalAddr { addr }) => { + FromSwarm::NewExternalAddrCandidate(e @ NewExternalAddrCandidate { addr }) => { let new_addr = addr.clone().with(Protocol::P2p(self.local_peer_id.into())); if Self::can_add_to_dht(addr) { @@ -640,7 +638,7 @@ impl NetworkBehaviour for DiscoveryBehaviour { } } - self.kademlia.on_swarm_event(FromSwarm::NewExternalAddr(e)); + self.kademlia.on_swarm_event(FromSwarm::NewExternalAddrCandidate(e)); }, FromSwarm::AddressChange(e) => { self.kademlia.on_swarm_event(FromSwarm::AddressChange(e)); @@ -664,7 +662,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(ToSwarm::GenerateEvent(ev)) diff --git a/client/network/src/peer_info.rs b/client/network/src/peer_info.rs index aab3fc9487e8c..8df7fbf462b0a 100644 --- a/client/network/src/peer_info.rs +++ b/client/network/src/peer_info.rs @@ -31,13 +31,13 @@ use libp2p::{ Info as IdentifyInfo, }, identity::PublicKey, - ping::{Behaviour as Ping, Config as PingConfig, Event as PingEvent, Success as PingSuccess}, + ping::{Behaviour as Ping, Config as PingConfig, Event as PingEvent}, swarm::{ behaviour::{ AddressChange, ConnectionClosed, ConnectionEstablished, DialFailure, FromSwarm, ListenFailure, }, - ConnectionDenied, ConnectionHandler, ConnectionId, IntoConnectionHandlerSelect, + ConnectionDenied, ConnectionHandler, ConnectionHandlerSelect, ConnectionId, NetworkBehaviour, PollParameters, THandler, THandlerInEvent, THandlerOutEvent, ToSwarm, }, Multiaddr, PeerId, @@ -121,13 +121,18 @@ impl PeerInfoBehaviour { /// Inserts a ping time in the cache. Has no effect if we don't have any entry for that node, /// which shouldn't happen. - fn handle_ping_report(&mut self, peer_id: &PeerId, ping_time: Duration) { - trace!(target: "sub-libp2p", "Ping time with {:?}: {:?}", peer_id, ping_time); + fn handle_ping_report( + &mut self, + peer_id: &PeerId, + ping_time: Duration, + connection: ConnectionId, + ) { + trace!(target: "sub-libp2p", "Ping time with {:?} via {}: {:?}", peer_id, connection, ping_time); if let Some(entry) = self.nodes_info.get_mut(peer_id) { entry.latest_ping = Some(ping_time); } else { error!(target: "sub-libp2p", - "Received ping from node we're not connected to {:?}", peer_id); + "Received ping from node we're not connected to {:?} ({})", peer_id, connection); } } @@ -181,11 +186,10 @@ pub enum PeerInfoEvent { } impl NetworkBehaviour for PeerInfoBehaviour { - type ConnectionHandler = IntoConnectionHandlerSelect< + type ConnectionHandler = ConnectionHandlerSelect< ::ConnectionHandler, ::ConnectionHandler, >; - type OutEvent = PeerInfoEvent; fn handle_pending_inbound_connection( &mut self, @@ -408,13 +412,13 @@ 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, Poll::Ready(ToSwarm::GenerateEvent(ev)) => { - if let PingEvent { peer, result: Ok(PingSuccess::Ping { rtt }) } = ev { - self.handle_ping_report(&peer, rtt) + if let PingEvent { peer, result: Ok(rtt), connection } = ev { + self.handle_ping_report(&peer, rtt, connection) } }, Poll::Ready(ToSwarm::Dial { opts }) => return Poll::Ready(ToSwarm::Dial { opts }), diff --git a/client/network/src/protocol.rs b/client/network/src/protocol.rs index e57bc3e520be4..3591601aa2576 100644 --- a/client/network/src/protocol.rs +++ b/client/network/src/protocol.rs @@ -353,7 +353,6 @@ pub enum CustomMessageOutcome { impl NetworkBehaviour for Protocol { type ConnectionHandler = ::ConnectionHandler; - type OutEvent = CustomMessageOutcome; fn handle_established_inbound_connection( &mut self, @@ -414,7 +413,7 @@ impl NetworkBehaviour for Protocol { &mut self, cx: &mut std::task::Context, params: &mut impl PollParameters, - ) -> Poll>> { + ) -> Poll>> { while let Poll::Ready(Some(validation_result)) = self.sync_substream_validations.poll_next_unpin(cx) { diff --git a/client/network/src/protocol/notifications/behaviour.rs b/client/network/src/protocol/notifications/behaviour.rs index 42233288afe08..1df4809f7a064 100644 --- a/client/network/src/protocol/notifications/behaviour.rs +++ b/client/network/src/protocol/notifications/behaviour.rs @@ -999,7 +999,7 @@ impl Notifications { impl NetworkBehaviour for Notifications { type ConnectionHandler = NotifsHandler; - type OutEvent = NotificationsOut; + type ToSwarm = NotificationsOut; fn handle_pending_inbound_connection( &mut self, @@ -2006,7 +2006,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) } diff --git a/client/network/src/protocol/notifications/handler.rs b/client/network/src/protocol/notifications/handler.rs index 0ac2e250a2ea3..06c69de6e8bc7 100644 --- a/client/network/src/protocol/notifications/handler.rs +++ b/client/network/src/protocol/notifications/handler.rs @@ -74,8 +74,8 @@ use futures::{ use libp2p::{ core::ConnectedPoint, swarm::{ - handler::ConnectionEvent, ConnectionHandler, ConnectionHandlerEvent, KeepAlive, - NegotiatedSubstream, SubstreamProtocol, + handler::ConnectionEvent, ConnectionHandler, ConnectionHandlerEvent, KeepAlive, Stream, + SubstreamProtocol, }, PeerId, }; @@ -189,7 +189,7 @@ enum State { /// emitted. OpenDesiredByRemote { /// Substream opened by the remote and that hasn't been accepted/rejected yet. - in_substream: NotificationsInSubstream, + in_substream: NotificationsInSubstream, /// See [`State::Closed::pending_opening`]. pending_opening: bool, @@ -202,7 +202,7 @@ enum State { /// be emitted when transitionning to respectively [`State::Open`] or [`State::Closed`]. Opening { /// Substream opened by the remote. If `Some`, has been accepted. - in_substream: Option>, + in_substream: Option>, }, /// Protocol is in the "Open" state. @@ -224,14 +224,14 @@ enum State { /// Always `Some` on transition to [`State::Open`]. Switched to `None` only if the remote /// closed the substream. If `None`, a [`NotifsHandlerOut::CloseDesired`] event has been /// emitted. - out_substream: Option>, + out_substream: Option>, /// Substream opened by the remote. /// /// Contrary to the `out_substream` field, operations continue as normal even if the /// substream has been closed by the remote. A `None` is treated the same way as if there /// was an idle substream. - in_substream: Option>, + in_substream: Option>, }, } @@ -435,8 +435,6 @@ pub enum NotifsHandlerError { } impl ConnectionHandler for NotifsHandler { - type InEvent = NotifsHandlerIn; - type OutEvent = NotifsHandlerOut; type Error = NotifsHandlerError; type InboundProtocol = UpgradeCollec; type OutboundProtocol = NotificationsOut; @@ -684,7 +682,7 @@ impl ConnectionHandler for NotifsHandler { ConnectionHandlerEvent< Self::OutboundProtocol, Self::OutboundOpenInfo, - Self::OutEvent, + Self::ToSwarm, Self::Error, >, > { diff --git a/client/network/src/protocol/notifications/tests.rs b/client/network/src/protocol/notifications/tests.rs index 0c2eb89262f93..ddeea495a2737 100644 --- a/client/network/src/protocol/notifications/tests.rs +++ b/client/network/src/protocol/notifications/tests.rs @@ -151,7 +151,7 @@ impl std::ops::DerefMut for CustomProtoWithAddr { impl NetworkBehaviour for CustomProtoWithAddr { type ConnectionHandler = ::ConnectionHandler; - type OutEvent = ::OutEvent; + type ToSwarm = ::ToSwarm; fn handle_pending_inbound_connection( &mut self, @@ -229,7 +229,7 @@ impl NetworkBehaviour for CustomProtoWithAddr { &mut self, cx: &mut Context, params: &mut impl PollParameters, - ) -> Poll>> { + ) -> Poll>> { self.inner.poll(cx, params) } } diff --git a/client/network/src/request_responses.rs b/client/network/src/request_responses.rs index 44e6f588ab520..8b9c8f2902319 100644 --- a/client/network/src/request_responses.rs +++ b/client/network/src/request_responses.rs @@ -403,7 +403,6 @@ impl RequestResponsesBehaviour { impl NetworkBehaviour for RequestResponsesBehaviour { type ConnectionHandler = MultiHandler as NetworkBehaviour>::ConnectionHandler>; - type OutEvent = Event; fn handle_pending_inbound_connection( &mut self, @@ -568,7 +567,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 diff --git a/client/network/src/service.rs b/client/network/src/service.rs index 62ff5ae42466b..758211abe2b9a 100644 --- a/client/network/src/service.rs +++ b/client/network/src/service.rs @@ -1555,8 +1555,14 @@ where } } }, - SwarmEvent::ConnectionClosed { peer_id, cause, endpoint, num_established } => { - debug!(target: "sub-libp2p", "Libp2p => Disconnected({:?}, {:?})", peer_id, cause); + SwarmEvent::ConnectionClosed { + connection_id, + peer_id, + cause, + endpoint, + num_established, + } => { + debug!(target: "sub-libp2p", "Libp2p => Disconnected({:?} via {}, {:?})", peer_id, connection_id, cause); if let Some(metrics) = self.metrics.as_ref() { let direction = match endpoint { ConnectedPoint::Dialer { .. } => "out", @@ -1594,12 +1600,12 @@ where metrics.listeners_local_addresses.dec(); } }, - SwarmEvent::OutgoingConnectionError { peer_id, error } => { + SwarmEvent::OutgoingConnectionError { connection_id, peer_id, error } => { if let Some(peer_id) = peer_id { trace!( target: "sub-libp2p", - "Libp2p => Failed to reach {:?}: {}", - peer_id, error, + "Libp2p => Failed to reach {:?} via {}: {}", + peer_id, connection_id, error, ); if self.boot_node_ids.contains(&peer_id) { @@ -1643,18 +1649,23 @@ where SwarmEvent::Dialing(peer_id) => { trace!(target: "sub-libp2p", "Libp2p => Dialing({:?})", peer_id) }, - SwarmEvent::IncomingConnection { local_addr, send_back_addr } => { - trace!(target: "sub-libp2p", "Libp2p => IncomingConnection({},{}))", - local_addr, send_back_addr); + SwarmEvent::IncomingConnection { connection_id, local_addr, send_back_addr } => { + trace!(target: "sub-libp2p", "Libp2p => IncomingConnection({},{},{}))", + connection_id, local_addr, send_back_addr); if let Some(metrics) = self.metrics.as_ref() { metrics.incoming_connections_total.inc(); } }, - SwarmEvent::IncomingConnectionError { local_addr, send_back_addr, error } => { + SwarmEvent::IncomingConnectionError { + connection_id, + local_addr, + send_back_addr, + error, + } => { debug!( target: "sub-libp2p", - "Libp2p => IncomingConnectionError({},{}): {}", - local_addr, send_back_addr, error, + "Libp2p => IncomingConnectionError({},{},{}): {}", + connection_id, local_addr, send_back_addr, error, ); if let Some(metrics) = self.metrics.as_ref() { #[allow(deprecated)] diff --git a/client/network/src/transport.rs b/client/network/src/transport.rs index 4136b34fc0e8e..caac795424998 100644 --- a/client/network/src/transport.rs +++ b/client/network/src/transport.rs @@ -27,6 +27,7 @@ use libp2p::{ }, dns, identity, noise, tcp, websocket, PeerId, Transport, TransportExt, }; +use libp2p_webrtc::tokio::{Certificate as WebRTCCertificate, Transport as WebRTCTransport}; use std::{sync::Arc, time::Duration}; pub use libp2p::bandwidth::BandwidthSinks; From 54778bd20ea7a4cf51cbc2645527f9ef12c85ecb Mon Sep 17 00:00:00 2001 From: Anton Kaliaev Date: Wed, 21 Jun 2023 16:25:56 +0300 Subject: [PATCH 02/42] proto name now must implement `AsRef` --- client/network/src/discovery.rs | 75 ++++++----- .../src/protocol/notifications/handler.rs | 89 ++++++------ .../protocol/notifications/upgrade/collec.rs | 12 +- client/network/src/request_responses.rs | 127 ++++++++++-------- client/network/src/service.rs | 119 ++++++++-------- client/network/src/transport.rs | 1 - client/network/src/types.rs | 8 +- 7 files changed, 234 insertions(+), 197 deletions(-) diff --git a/client/network/src/discovery.rs b/client/network/src/discovery.rs index e2c1f8c602c13..6db265d70dedd 100644 --- a/client/network/src/discovery.rs +++ b/client/network/src/discovery.rs @@ -57,7 +57,7 @@ use libp2p::{ kad::{ record::store::{MemoryStore, RecordStore}, GetClosestPeersError, GetRecordOk, Kademlia, KademliaBucketInserts, KademliaConfig, - KademliaEvent, KademliaHandler, QueryId, QueryResult, Quorum, Record, RecordKey, + KademliaEvent, QueryId, QueryResult, Quorum, Record, RecordKey, }, mdns::{self, tokio::Behaviour as TokioMdns}, multiaddr::Protocol, @@ -317,7 +317,7 @@ impl DiscoveryBehaviour { pub fn add_known_address(&mut self, peer_id: PeerId, addr: Multiaddr) { let addrs_list = self.ephemeral_addresses.entry(peer_id).or_default(); if addrs_list.contains(&addr) { - return + return; } if let Some(k) = self.kademlia.as_mut() { @@ -345,7 +345,7 @@ impl DiscoveryBehaviour { target: "sub-libp2p", "Ignoring self-reported non-global address {} from {}.", addr, peer_id ); - return + return; } if let Some(matching_protocol) = supported_protocols @@ -428,8 +428,9 @@ impl DiscoveryBehaviour { let ip = match addr.iter().next() { Some(Protocol::Ip4(ip)) => IpNetwork::from(ip), Some(Protocol::Ip6(ip)) => IpNetwork::from(ip), - Some(Protocol::Dns(_)) | Some(Protocol::Dns4(_)) | Some(Protocol::Dns6(_)) => - return true, + Some(Protocol::Dns(_)) | Some(Protocol::Dns4(_)) | Some(Protocol::Dns6(_)) => { + return true + }, _ => return false, }; ip.is_global() @@ -665,7 +666,7 @@ impl NetworkBehaviour for DiscoveryBehaviour { ) -> Poll>> { // Immediately process the content of `discovered`. if let Some(ev) = self.pending_events.pop_front() { - return Poll::Ready(ToSwarm::GenerateEvent(ev)) + return Poll::Ready(ToSwarm::GenerateEvent(ev)); } // Poll the stream that fires when we need to start a random Kademlia query. @@ -699,7 +700,7 @@ impl NetworkBehaviour for DiscoveryBehaviour { if actually_started { let ev = DiscoveryOut::RandomKademliaStarted; - return Poll::Ready(ToSwarm::GenerateEvent(ev)) + return Poll::Ready(ToSwarm::GenerateEvent(ev)); } } } @@ -710,18 +711,18 @@ impl NetworkBehaviour for DiscoveryBehaviour { ToSwarm::GenerateEvent(ev) => match ev { KademliaEvent::RoutingUpdated { peer, .. } => { let ev = DiscoveryOut::Discovered(peer); - return Poll::Ready(ToSwarm::GenerateEvent(ev)) + return Poll::Ready(ToSwarm::GenerateEvent(ev)); }, KademliaEvent::UnroutablePeer { peer, .. } => { let ev = DiscoveryOut::UnroutablePeer(peer); - return Poll::Ready(ToSwarm::GenerateEvent(ev)) + return Poll::Ready(ToSwarm::GenerateEvent(ev)); }, KademliaEvent::RoutablePeer { peer, .. } => { let ev = DiscoveryOut::Discovered(peer); - return Poll::Ready(ToSwarm::GenerateEvent(ev)) + return Poll::Ready(ToSwarm::GenerateEvent(ev)); }, - KademliaEvent::PendingRoutablePeer { .. } | - KademliaEvent::InboundRequest { .. } => { + KademliaEvent::PendingRoutablePeer { .. } + | KademliaEvent::InboundRequest { .. } => { // We are not interested in this event at the moment. }, KademliaEvent::OutboundQueryProgressed { @@ -787,7 +788,7 @@ impl NetworkBehaviour for DiscoveryBehaviour { // We always need to remove the record to not leak any data! if let Some(record) = self.records_to_publish.remove(&id) { if cache_candidates.is_empty() { - continue + continue; } // Put the record to the `cache_candidates` that are nearest to @@ -801,7 +802,7 @@ impl NetworkBehaviour for DiscoveryBehaviour { } } - continue + continue; }, Err(e @ libp2p::kad::GetRecordError::NotFound { .. }) => { trace!( @@ -826,7 +827,7 @@ impl NetworkBehaviour for DiscoveryBehaviour { ) }, }; - return Poll::Ready(ToSwarm::GenerateEvent(ev)) + return Poll::Ready(ToSwarm::GenerateEvent(ev)); }, KademliaEvent::OutboundQueryProgressed { result: QueryResult::PutRecord(res), @@ -834,8 +835,9 @@ impl NetworkBehaviour for DiscoveryBehaviour { .. } => { let ev = match res { - Ok(ok) => - DiscoveryOut::ValuePut(ok.key, stats.duration().unwrap_or_default()), + Ok(ok) => { + DiscoveryOut::ValuePut(ok.key, stats.duration().unwrap_or_default()) + }, Err(e) => { debug!( target: "sub-libp2p", @@ -848,7 +850,7 @@ impl NetworkBehaviour for DiscoveryBehaviour { ) }, }; - return Poll::Ready(ToSwarm::GenerateEvent(ev)) + return Poll::Ready(ToSwarm::GenerateEvent(ev)); }, KademliaEvent::OutboundQueryProgressed { result: QueryResult::RepublishRecord(res), @@ -871,12 +873,15 @@ impl NetworkBehaviour for DiscoveryBehaviour { }, }, ToSwarm::Dial { opts } => return Poll::Ready(ToSwarm::Dial { opts }), - ToSwarm::NotifyHandler { peer_id, handler, event } => - return Poll::Ready(ToSwarm::NotifyHandler { peer_id, handler, event }), - ToSwarm::ReportObservedAddr { address, score } => - return Poll::Ready(ToSwarm::ReportObservedAddr { address, score }), - ToSwarm::CloseConnection { peer_id, connection } => - return Poll::Ready(ToSwarm::CloseConnection { peer_id, connection }), + ToSwarm::NotifyHandler { peer_id, handler, event } => { + return Poll::Ready(ToSwarm::NotifyHandler { peer_id, handler, event }) + }, + ToSwarm::ReportObservedAddr { address, score } => { + return Poll::Ready(ToSwarm::ReportObservedAddr { address, score }) + }, + ToSwarm::CloseConnection { peer_id, connection } => { + return Poll::Ready(ToSwarm::CloseConnection { peer_id, connection }) + }, } } @@ -887,13 +892,13 @@ impl NetworkBehaviour for DiscoveryBehaviour { ToSwarm::GenerateEvent(event) => match event { mdns::Event::Discovered(list) => { if self.num_connections >= self.discovery_only_if_under_num { - continue + continue; } self.pending_events .extend(list.map(|(peer_id, _)| DiscoveryOut::Discovered(peer_id))); if let Some(ev) = self.pending_events.pop_front() { - return Poll::Ready(ToSwarm::GenerateEvent(ev)) + return Poll::Ready(ToSwarm::GenerateEvent(ev)); } }, mdns::Event::Expired(_) => {}, @@ -904,10 +909,12 @@ impl NetworkBehaviour for DiscoveryBehaviour { ToSwarm::NotifyHandler { event, .. } => match event {}, /* `event` is an */ // enum with no // variant - ToSwarm::ReportObservedAddr { address, score } => - return Poll::Ready(ToSwarm::ReportObservedAddr { address, score }), - ToSwarm::CloseConnection { peer_id, connection } => - return Poll::Ready(ToSwarm::CloseConnection { peer_id, connection }), + ToSwarm::ReportObservedAddr { address, score } => { + return Poll::Ready(ToSwarm::ReportObservedAddr { address, score }) + }, + ToSwarm::CloseConnection { peer_id, connection } => { + return Poll::Ready(ToSwarm::CloseConnection { peer_id, connection }) + }, } } } @@ -1034,8 +1041,8 @@ mod tests { match e { SwarmEvent::Behaviour(behavior) => { match behavior { - DiscoveryOut::UnroutablePeer(other) | - DiscoveryOut::Discovered(other) => { + DiscoveryOut::UnroutablePeer(other) + | DiscoveryOut::Discovered(other) => { // Call `add_self_reported_address` to simulate identify // happening. let addr = swarms @@ -1075,12 +1082,12 @@ mod tests { // ignore non Behaviour events _ => {}, } - continue 'polling + continue 'polling; }, _ => {}, } } - break + break; } if to_discover.iter().all(|l| l.is_empty()) { diff --git a/client/network/src/protocol/notifications/handler.rs b/client/network/src/protocol/notifications/handler.rs index 06c69de6e8bc7..a1120ea5f4e36 100644 --- a/client/network/src/protocol/notifications/handler.rs +++ b/client/network/src/protocol/notifications/handler.rs @@ -486,13 +486,13 @@ impl ConnectionHandler for NotifsHandler { // in mind that it is invalid for the remote to open multiple such // substreams, and therefore sending a "RST" is the most correct thing // to do. - return + return; }, - State::Opening { ref mut in_substream, .. } | - State::Open { ref mut in_substream, .. } => { + State::Opening { ref mut in_substream, .. } + | State::Open { ref mut in_substream, .. } => { if in_substream.is_some() { // Same remark as above. - return + return; } // Create `handshake_message` on a separate line to be sure that the @@ -507,8 +507,8 @@ impl ConnectionHandler for NotifsHandler { let (new_open, protocol_index) = (outbound.protocol, outbound.info); match self.protocols[protocol_index].state { - State::Closed { ref mut pending_opening } | - State::OpenDesiredByRemote { ref mut pending_opening, .. } => { + State::Closed { ref mut pending_opening } + | State::OpenDesiredByRemote { ref mut pending_opening, .. } => { debug_assert!(*pending_opening); *pending_opening = false; }, @@ -551,8 +551,8 @@ impl ConnectionHandler for NotifsHandler { [dial_upgrade_error.info] .state { - State::Closed { ref mut pending_opening } | - State::OpenDesiredByRemote { ref mut pending_opening, .. } => { + State::Closed { ref mut pending_opening } + | State::OpenDesiredByRemote { ref mut pending_opening, .. } => { debug_assert!(*pending_opening); *pending_opening = false; }, @@ -667,7 +667,7 @@ impl ConnectionHandler for NotifsHandler { fn connection_keep_alive(&self) -> KeepAlive { // `Yes` if any protocol has some activity. if self.protocols.iter().any(|p| !matches!(p.state, State::Closed { .. })) { - return KeepAlive::Yes + return KeepAlive::Yes; } // A grace period of `INITIAL_KEEPALIVE_TIME` must be given to leave time for the remote @@ -682,12 +682,12 @@ impl ConnectionHandler for NotifsHandler { ConnectionHandlerEvent< Self::OutboundProtocol, Self::OutboundOpenInfo, - Self::ToSwarm, + Self::ToBehaviour, Self::Error, >, > { if let Some(ev) = self.events_queue.pop_front() { - return Poll::Ready(ev) + return Poll::Ready(ev); } // For each open substream, try send messages from `notifications_sink_rx` to the @@ -702,10 +702,11 @@ impl ConnectionHandler for NotifsHandler { // available in `notifications_sink_rx`. This avoids waking up the task when // 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)) => + Poll::Ready(Some(&NotificationsSinkMessage::ForceClose)) => { return Poll::Ready(ConnectionHandlerEvent::Close( NotifsHandlerError::SyncNotificationsClogged, - )), + )) + }, Poll::Ready(Some(&NotificationsSinkMessage::Notification { .. })) => {}, Poll::Ready(None) | Poll::Pending => break, } @@ -719,14 +720,15 @@ impl ConnectionHandler for NotifsHandler { // Now that the substream is ready for a message, grab what to send. let message = match notifications_sink_rx.poll_next_unpin(cx) { - Poll::Ready(Some(NotificationsSinkMessage::Notification { message })) => - message, - Poll::Ready(Some(NotificationsSinkMessage::ForceClose)) | - Poll::Ready(None) | - Poll::Pending => { + Poll::Ready(Some(NotificationsSinkMessage::Notification { message })) => { + message + }, + Poll::Ready(Some(NotificationsSinkMessage::ForceClose)) + | Poll::Ready(None) + | Poll::Pending => { // Should never be reached, as per `poll_peek` above. debug_assert!(false); - break + break; }, }; @@ -751,15 +753,15 @@ impl ConnectionHandler for NotifsHandler { Poll::Ready(Err(_)) => { *out_substream = None; let event = NotifsHandlerOut::CloseDesired { protocol_index }; - return Poll::Ready(ConnectionHandlerEvent::Custom(event)) + return Poll::Ready(ConnectionHandlerEvent::Custom(event)); }, }; }, - State::Closed { .. } | - State::Opening { .. } | - State::Open { out_substream: None, .. } | - State::OpenDesiredByRemote { .. } => {}, + State::Closed { .. } + | State::Opening { .. } + | State::Open { out_substream: None, .. } + | State::OpenDesiredByRemote { .. } => {}, } } @@ -768,21 +770,22 @@ impl ConnectionHandler for NotifsHandler { // Inbound substreams being closed is always tolerated, except for the // `OpenDesiredByRemote` state which might need to be switched back to `Closed`. match &mut self.protocols[protocol_index].state { - State::Closed { .. } | - State::Open { in_substream: None, .. } | - State::Opening { in_substream: None } => {}, + State::Closed { .. } + | State::Open { in_substream: None, .. } + | State::Opening { in_substream: None } => {}, - State::Open { in_substream: in_substream @ Some(_), .. } => + State::Open { in_substream: in_substream @ Some(_), .. } => { match Stream::poll_next(Pin::new(in_substream.as_mut().unwrap()), cx) { Poll::Pending => {}, Poll::Ready(Some(Ok(message))) => { let event = NotifsHandlerOut::Notification { protocol_index, message }; - return Poll::Ready(ConnectionHandlerEvent::Custom(event)) + return Poll::Ready(ConnectionHandlerEvent::Custom(event)); }, Poll::Ready(None) | Poll::Ready(Some(Err(_))) => *in_substream = None, - }, + } + }, - State::OpenDesiredByRemote { in_substream, pending_opening } => + State::OpenDesiredByRemote { in_substream, pending_opening } => { match NotificationsInSubstream::poll_process(Pin::new(in_substream), cx) { Poll::Pending => {}, Poll::Ready(Ok(void)) => match void {}, @@ -791,11 +794,12 @@ impl ConnectionHandler for NotifsHandler { State::Closed { pending_opening: *pending_opening }; return Poll::Ready(ConnectionHandlerEvent::Custom( NotifsHandlerOut::CloseDesired { protocol_index }, - )) + )); }, - }, + } + }, - State::Opening { in_substream: in_substream @ Some(_), .. } => + State::Opening { in_substream: in_substream @ Some(_), .. } => { match NotificationsInSubstream::poll_process( Pin::new(in_substream.as_mut().unwrap()), cx, @@ -803,7 +807,8 @@ impl ConnectionHandler for NotifsHandler { Poll::Pending => {}, Poll::Ready(Ok(void)) => match void {}, Poll::Ready(Err(_)) => *in_substream = None, - }, + } + }, } } @@ -899,12 +904,13 @@ pub mod tests { let substream = if let Some(info) = self.connections.get_mut(&(peer, set)) { info } else { - return None + return None; }; futures::future::poll_fn(|cx| match substream.notifications.poll_next_unpin(cx) { - Poll::Ready(Some(NotificationsSinkMessage::Notification { message })) => - Poll::Ready(Some(message)), + Poll::Ready(Some(NotificationsSinkMessage::Notification { message })) => { + Poll::Ready(Some(message)) + }, Poll::Pending => Poll::Ready(None), Poll::Ready(Some(NotificationsSinkMessage::ForceClose)) | Poll::Ready(None) => { panic!("sink closed") @@ -984,8 +990,9 @@ pub mod tests { ) -> Poll> { match self.rx.poll_recv(cx) { Poll::Ready(Some(data)) => self.rx_buffer.extend_from_slice(&data), - Poll::Ready(None) => - return Poll::Ready(Err(std::io::ErrorKind::UnexpectedEof.into())), + Poll::Ready(None) => { + return Poll::Ready(Err(std::io::ErrorKind::UnexpectedEof.into())) + }, _ => {}, } @@ -994,7 +1001,7 @@ pub mod tests { buf[..nsize].copy_from_slice(&data[..]); if nsize > 0 { - return Poll::Ready(Ok(nsize)) + return Poll::Ready(Ok(nsize)); } Poll::Pending diff --git a/client/network/src/protocol/notifications/upgrade/collec.rs b/client/network/src/protocol/notifications/upgrade/collec.rs index 791821b3f75da..2b26410fbe8b6 100644 --- a/client/network/src/protocol/notifications/upgrade/collec.rs +++ b/client/network/src/protocol/notifications/upgrade/collec.rs @@ -17,7 +17,7 @@ // along with this program. If not, see . use futures::prelude::*; -use libp2p::core::upgrade::{InboundUpgrade, ProtocolName, UpgradeInfo}; +use libp2p::core::upgrade::{InboundUpgrade, UpgradeInfo}; use std::{ iter::FromIterator, pin::Pin, @@ -76,9 +76,9 @@ where #[derive(Debug, Clone, PartialEq)] pub struct ProtoNameWithUsize(T, usize); -impl ProtocolName for ProtoNameWithUsize { - fn protocol_name(&self) -> &[u8] { - self.0.protocol_name() +impl> AsRef for ProtoNameWithUsize { + fn as_ref(&self) -> &str { + self.0.as_ref() } } @@ -104,13 +104,13 @@ impl>, O, E> Future for FutWithUsize { mod tests { use super::*; use crate::types::ProtocolName as ProtoName; - use libp2p::core::upgrade::{ProtocolName, UpgradeInfo}; + use libp2p::core::upgrade::UpgradeInfo; // TODO: move to mocks mockall::mock! { pub ProtocolUpgrade {} - impl UpgradeInfo for ProtocolUpgrade { + impl> UpgradeInfo for ProtocolUpgrade { type Info = T; type InfoIter = vec::IntoIter; fn protocol_info(&self) -> vec::IntoIter; diff --git a/client/network/src/request_responses.rs b/client/network/src/request_responses.rs index 8b9c8f2902319..ee9e9d988bea2 100644 --- a/client/network/src/request_responses.rs +++ b/client/network/src/request_responses.rs @@ -332,10 +332,6 @@ impl RequestResponsesBehaviour { }; let rq_rp = Behaviour::new( - GenericCodec { - max_request_size: protocol.max_request_size, - max_response_size: protocol.max_response_size, - }, iter::once(protocol.name.as_bytes().to_vec()) .chain(protocol.fallback_names.iter().map(|name| name.as_bytes().to_vec())) .zip(iter::repeat(protocol_support)), @@ -344,7 +340,9 @@ impl RequestResponsesBehaviour { match protocols.entry(protocol.name) { Entry::Vacant(e) => e.insert((rq_rp, protocol.inbound_queue)), - Entry::Occupied(e) => return Err(RegisterError::DuplicateProtocol(e.key().clone())), + Entry::Occupied(e) => { + return Err(RegisterError::DuplicateProtocol(e.key().clone())) + }, }; } @@ -474,17 +472,18 @@ impl NetworkBehaviour for RequestResponsesBehaviour { fn on_swarm_event(&mut self, event: FromSwarm) { match event { - FromSwarm::ConnectionEstablished(e) => + FromSwarm::ConnectionEstablished(e) => { for (p, _) in self.protocols.values_mut() { NetworkBehaviour::on_swarm_event(p, FromSwarm::ConnectionEstablished(e)); - }, + } + }, FromSwarm::ConnectionClosed(ConnectionClosed { peer_id, connection_id, endpoint, handler, remaining_established, - }) => + }) => { for (p_name, p_handler) in handler.into_iter() { if let Some((proto, _)) = self.protocols.get_mut(p_name.as_str()) { proto.on_swarm_event(FromSwarm::ConnectionClosed(ConnectionClosed { @@ -501,47 +500,58 @@ impl NetworkBehaviour for RequestResponsesBehaviour { p_name, ) } - }, - FromSwarm::DialFailure(e) => + } + }, + FromSwarm::DialFailure(e) => { for (p, _) in self.protocols.values_mut() { NetworkBehaviour::on_swarm_event(p, FromSwarm::DialFailure(e)); - }, - FromSwarm::ListenerClosed(e) => + } + }, + FromSwarm::ListenerClosed(e) => { for (p, _) in self.protocols.values_mut() { NetworkBehaviour::on_swarm_event(p, FromSwarm::ListenerClosed(e)); - }, - FromSwarm::ListenFailure(e) => + } + }, + FromSwarm::ListenFailure(e) => { for (p, _) in self.protocols.values_mut() { NetworkBehaviour::on_swarm_event(p, FromSwarm::ListenFailure(e)); - }, - FromSwarm::ListenerError(e) => + } + }, + FromSwarm::ListenerError(e) => { for (p, _) in self.protocols.values_mut() { NetworkBehaviour::on_swarm_event(p, FromSwarm::ListenerError(e)); - }, - FromSwarm::ExpiredExternalAddr(e) => + } + }, + FromSwarm::ExpiredExternalAddr(e) => { for (p, _) in self.protocols.values_mut() { NetworkBehaviour::on_swarm_event(p, FromSwarm::ExpiredExternalAddr(e)); - }, - FromSwarm::NewListener(e) => + } + }, + FromSwarm::NewListener(e) => { for (p, _) in self.protocols.values_mut() { NetworkBehaviour::on_swarm_event(p, FromSwarm::NewListener(e)); - }, - FromSwarm::ExpiredListenAddr(e) => + } + }, + FromSwarm::ExpiredListenAddr(e) => { for (p, _) in self.protocols.values_mut() { NetworkBehaviour::on_swarm_event(p, FromSwarm::ExpiredListenAddr(e)); - }, - FromSwarm::NewExternalAddr(e) => + } + }, + FromSwarm::NewExternalAddr(e) => { for (p, _) in self.protocols.values_mut() { NetworkBehaviour::on_swarm_event(p, FromSwarm::NewExternalAddr(e)); - }, - FromSwarm::AddressChange(e) => + } + }, + FromSwarm::AddressChange(e) => { for (p, _) in self.protocols.values_mut() { NetworkBehaviour::on_swarm_event(p, FromSwarm::AddressChange(e)); - }, - FromSwarm::NewListenAddr(e) => + } + }, + FromSwarm::NewListenAddr(e) => { for (p, _) in self.protocols.values_mut() { NetworkBehaviour::on_swarm_event(p, FromSwarm::NewListenAddr(e)); - }, + } + }, } } @@ -553,7 +563,7 @@ impl NetworkBehaviour for RequestResponsesBehaviour { ) { let p_name = event.0; if let Some((proto, _)) = self.protocols.get_mut(p_name.as_str()) { - return proto.on_connection_handler_event(peer_id, connection_id, event.1) + return proto.on_connection_handler_event(peer_id, connection_id, event.1); } else { log::warn!( target: "sub-libp2p", @@ -596,7 +606,7 @@ impl NetworkBehaviour for RequestResponsesBehaviour { resp_builder, get_peer_reputation, }); - return Poll::Pending + return Poll::Pending; }, Poll::Ready(reputation) => { // Once we get the reputation we can continue processing the request. @@ -612,7 +622,7 @@ impl NetworkBehaviour for RequestResponsesBehaviour { peer, reputation, ); - continue 'poll_all + continue 'poll_all; } let (tx, rx) = oneshot::channel(); @@ -653,7 +663,7 @@ impl NetworkBehaviour for RequestResponsesBehaviour { // This `continue` makes sure that `pending_responses` gets polled // after we have added the new element. - continue 'poll_all + continue 'poll_all; }, } } @@ -695,7 +705,7 @@ impl NetworkBehaviour for RequestResponsesBehaviour { return Poll::Ready(ToSwarm::GenerateEvent(Event::ReputationChanges { peer, changes: reputation_changes, - })) + })); } } @@ -714,18 +724,21 @@ impl NetworkBehaviour for RequestResponsesBehaviour { "The request-response isn't supposed to start dialing addresses" ); } - return Poll::Ready(ToSwarm::Dial { opts }) + return Poll::Ready(ToSwarm::Dial { opts }); }, - ToSwarm::NotifyHandler { peer_id, handler, event } => + ToSwarm::NotifyHandler { peer_id, handler, event } => { return Poll::Ready(ToSwarm::NotifyHandler { peer_id, handler, event: ((*protocol).to_string(), event), - }), - ToSwarm::ReportObservedAddr { address, score } => - return Poll::Ready(ToSwarm::ReportObservedAddr { address, score }), - ToSwarm::CloseConnection { peer_id, connection } => - return Poll::Ready(ToSwarm::CloseConnection { peer_id, connection }), + }) + }, + ToSwarm::ReportObservedAddr { address, score } => { + return Poll::Ready(ToSwarm::ReportObservedAddr { address, score }) + }, + ToSwarm::CloseConnection { peer_id, connection } => { + return Poll::Ready(ToSwarm::CloseConnection { peer_id, connection }) + }, }; match ev { @@ -755,7 +768,7 @@ impl NetworkBehaviour for RequestResponsesBehaviour { // This `continue` makes sure that `message_request` gets polled // after we have added the new element. - continue 'poll_all + continue 'poll_all; }, // Received a response from a remote to one of our requests. @@ -781,7 +794,7 @@ impl NetworkBehaviour for RequestResponsesBehaviour { request_id, ); debug_assert!(false); - continue + continue; }, }; @@ -792,7 +805,7 @@ impl NetworkBehaviour for RequestResponsesBehaviour { result: delivered, }; - return Poll::Ready(ToSwarm::GenerateEvent(out)) + return Poll::Ready(ToSwarm::GenerateEvent(out)); }, // One of our requests has failed. @@ -827,7 +840,7 @@ impl NetworkBehaviour for RequestResponsesBehaviour { request_id, ); debug_assert!(false); - continue + continue; }, }; @@ -838,7 +851,7 @@ impl NetworkBehaviour for RequestResponsesBehaviour { result: Err(RequestFailure::Network(error)), }; - return Poll::Ready(ToSwarm::GenerateEvent(out)) + return Poll::Ready(ToSwarm::GenerateEvent(out)); }, // An inbound request failed, either while reading the request or due to @@ -854,7 +867,7 @@ impl NetworkBehaviour for RequestResponsesBehaviour { protocol: protocol.clone(), result: Err(ResponseFailure::Network(error)), }; - return Poll::Ready(ToSwarm::GenerateEvent(out)) + return Poll::Ready(ToSwarm::GenerateEvent(out)); }, // A response to an inbound request has been sent. @@ -883,13 +896,13 @@ impl NetworkBehaviour for RequestResponsesBehaviour { result: Ok(arrival_time), }; - return Poll::Ready(ToSwarm::GenerateEvent(out)) + return Poll::Ready(ToSwarm::GenerateEvent(out)); }, }; } } - break Poll::Pending + break Poll::Pending; } } } @@ -941,7 +954,7 @@ impl Codec for GenericCodec { return Err(io::Error::new( io::ErrorKind::InvalidInput, format!("Request size exceeds limit: {} > {}", length, self.max_request_size), - )) + )); } // Read the payload. @@ -968,7 +981,9 @@ impl Codec for GenericCodec { Ok(l) => l, Err(unsigned_varint::io::ReadError::Io(err)) if matches!(err.kind(), io::ErrorKind::UnexpectedEof) => - return Ok(Err(())), + { + return Ok(Err(())) + }, Err(err) => return Err(io::Error::new(io::ErrorKind::InvalidInput, err)), }; @@ -976,7 +991,7 @@ impl Codec for GenericCodec { return Err(io::Error::new( io::ErrorKind::InvalidInput, format!("Response size exceeds limit: {} > {}", length, self.max_response_size), - )) + )); } // Read the payload. @@ -1196,7 +1211,7 @@ mod tests { }, SwarmEvent::Behaviour(Event::RequestFinished { result, .. }) => { result.unwrap(); - break + break; }, _ => {}, } @@ -1265,7 +1280,7 @@ mod tests { match swarm.select_next_some().await { SwarmEvent::Behaviour(Event::InboundRequest { result, .. }) => { assert!(result.is_ok()); - break + break; }, _ => {}, } @@ -1299,7 +1314,7 @@ mod tests { }, SwarmEvent::Behaviour(Event::RequestFinished { result, .. }) => { assert!(result.is_err()); - break + break; }, _ => {}, } @@ -1468,7 +1483,7 @@ mod tests { num_responses += 1; result.unwrap(); if num_responses == 2 { - break + break; } }, _ => {}, diff --git a/client/network/src/service.rs b/client/network/src/service.rs index 758211abe2b9a..f96b4579a6ce5 100644 --- a/client/network/src/service.rs +++ b/client/network/src/service.rs @@ -55,17 +55,16 @@ use crate::{ use either::Either; use futures::{channel::oneshot, prelude::*}; -#[allow(deprecated)] use libp2p::{ - connection_limits::Exceeded, + connection_limits::{ConnectionLimits, Exceeded}, core::{upgrade, ConnectedPoint, Endpoint}, identify::Info as IdentifyInfo, kad::record::Key as KademliaKey, multiaddr, ping::Failure as PingFailure, swarm::{ - AddressScore, ConnectionError, ConnectionId, ConnectionLimits, DialError, Executor, - ListenError, NetworkBehaviour, Swarm, SwarmBuilder, SwarmEvent, THandlerErr, + ConnectionError, ConnectionId, DialError, Executor, ListenError, NetworkBehaviour, Swarm, + SwarmBuilder, SwarmEvent, THandlerErr, }, Multiaddr, PeerId, }; @@ -351,8 +350,9 @@ where match result { Ok(b) => b, - Err(crate::request_responses::RegisterError::DuplicateProtocol(proto)) => - return Err(Error::DuplicateRequestResponseProtocol { protocol: proto }), + Err(crate::request_responses::RegisterError::DuplicateProtocol(proto)) => { + return Err(Error::DuplicateRequestResponseProtocol { protocol: proto }) + }, } }; @@ -410,11 +410,7 @@ where // Add external addresses. for addr in &network_config.public_addresses { - Swarm::>::add_external_address( - &mut swarm, - addr.clone(), - AddressScore::Infinite, - ); + Swarm::>::add_external_address(&mut swarm, addr.clone()); } let external_addresses = Arc::new(Mutex::new(Vec::new())); @@ -523,7 +519,7 @@ where addrs.into_iter().collect() } else { error!(target: "sub-libp2p", "Was not able to get known addresses for {:?}", peer_id); - return None + return None; }; let endpoint = if let Some(e) = @@ -533,7 +529,7 @@ where } else { error!(target: "sub-libp2p", "Found state inconsistency between custom protocol \ and debug information about {:?}", peer_id); - return None + return None; }; Some(( @@ -806,7 +802,7 @@ where fn add_reserved_peer(&self, peer: MultiaddrWithPeerId) -> Result<(), String> { // Make sure the local peer ID is never added to the PSM. if peer.peer_id == self.local_peer_id { - return Err("Local peer ID cannot be added as a reserved peer.".to_string()) + return Err("Local peer ID cannot be added as a reserved peer.".to_string()); } let _ = self @@ -832,7 +828,7 @@ where for (peer_id, addr) in peers_addrs.into_iter() { // Make sure the local peer ID is never added to the PSM. if peer_id == self.local_peer_id { - return Err("Local peer ID cannot be added as a reserved peer.".to_string()) + return Err("Local peer ID cannot be added as a reserved peer.".to_string()); } peers.insert(peer_id); @@ -861,7 +857,7 @@ where for (peer_id, addr) in peers.into_iter() { // Make sure the local peer ID is never added to the PSM. if peer_id == self.local_peer_id { - return Err("Local peer ID cannot be added as a reserved peer.".to_string()) + return Err("Local peer ID cannot be added as a reserved peer.".to_string()); } if !addr.is_empty() { @@ -921,7 +917,7 @@ where "Attempted to send notification on missing or closed substream: {}, {:?}", target, protocol, ); - return + return; } }; @@ -953,7 +949,7 @@ where if let Some(sink) = peers_notifications_sinks.get(&(target, protocol.clone())) { sink.clone() } else { - return Err(NotificationSenderError::Closed) + return Err(NotificationSenderError::Closed); } }; @@ -1232,10 +1228,12 @@ where /// Process the next message coming from the `NetworkService`. fn handle_worker_message(&mut self, msg: ServiceToWorkerMsg) { match msg { - ServiceToWorkerMsg::GetValue(key) => - self.network_service.behaviour_mut().get_value(key), - ServiceToWorkerMsg::PutValue(key, value) => - self.network_service.behaviour_mut().put_value(key, value), + ServiceToWorkerMsg::GetValue(key) => { + self.network_service.behaviour_mut().get_value(key) + }, + ServiceToWorkerMsg::PutValue(key, value) => { + self.network_service.behaviour_mut().put_value(key, value) + }, ServiceToWorkerMsg::SetReservedOnly(reserved_only) => self .network_service .behaviour_mut() @@ -1271,8 +1269,9 @@ where .behaviour_mut() .user_protocol_mut() .remove_set_reserved_peer(protocol, peer_id), - ServiceToWorkerMsg::AddKnownAddress(peer_id, addr) => - self.network_service.behaviour_mut().add_known_address(peer_id, addr), + ServiceToWorkerMsg::AddKnownAddress(peer_id, addr) => { + self.network_service.behaviour_mut().add_known_address(peer_id, addr) + }, ServiceToWorkerMsg::EventStream(sender) => self.event_streams.push(sender), ServiceToWorkerMsg::Request { target, @@ -1325,18 +1324,23 @@ where }, Err(err) => { let reason = match err { - ResponseFailure::Network(InboundFailure::Timeout) => - Some("timeout"), + ResponseFailure::Network(InboundFailure::Timeout) => { + Some("timeout") + }, ResponseFailure::Network(InboundFailure::UnsupportedProtocols) => // `UnsupportedProtocols` is reported for every single // inbound request whenever a request with an unsupported // protocol is received. This is not reported in order to // avoid confusions. - None, - ResponseFailure::Network(InboundFailure::ResponseOmission) => - Some("busy-omitted"), - ResponseFailure::Network(InboundFailure::ConnectionClosed) => - Some("connection-closed"), + { + None + }, + ResponseFailure::Network(InboundFailure::ResponseOmission) => { + Some("busy-omitted") + }, + ResponseFailure::Network(InboundFailure::ConnectionClosed) => { + Some("connection-closed") + }, }; if let Some(reason) = reason { @@ -1354,7 +1358,7 @@ where duration, result, .. - }) => + }) => { if let Some(metrics) = self.metrics.as_ref() { match result { Ok(_) => { @@ -1369,13 +1373,16 @@ where RequestFailure::UnknownProtocol => "unknown-protocol", RequestFailure::Refused => "refused", RequestFailure::Obsolete => "obsolete", - RequestFailure::Network(OutboundFailure::DialFailure) => - "dial-failure", + RequestFailure::Network(OutboundFailure::DialFailure) => { + "dial-failure" + }, RequestFailure::Network(OutboundFailure::Timeout) => "timeout", - RequestFailure::Network(OutboundFailure::ConnectionClosed) => - "connection-closed", - RequestFailure::Network(OutboundFailure::UnsupportedProtocols) => - "unsupported", + RequestFailure::Network(OutboundFailure::ConnectionClosed) => { + "connection-closed" + }, + RequestFailure::Network(OutboundFailure::UnsupportedProtocols) => { + "unsupported" + }, }; metrics @@ -1384,7 +1391,8 @@ where .inc(); }, } - }, + } + }, SwarmEvent::Behaviour(BehaviourOut::ReputationChanges { peer, changes }) => { for change in changes { self.network_service.behaviour().user_protocol().report_peer(peer, change); @@ -1625,21 +1633,22 @@ where if let Some(metrics) = self.metrics.as_ref() { #[allow(deprecated)] let reason = match error { - DialError::Denied { cause } => + DialError::Denied { cause } => { if cause.downcast::().is_ok() { Some("limit-reached") } else { None - }, + } + }, DialError::ConnectionLimit(_) => Some("limit-reached"), - DialError::InvalidPeerId(_) | - DialError::WrongPeerId { .. } | - DialError::LocalPeerId { .. } => Some("invalid-peer-id"), + DialError::InvalidPeerId(_) + | DialError::WrongPeerId { .. } + | DialError::LocalPeerId { .. } => Some("invalid-peer-id"), DialError::Transport(_) => Some("transport-error"), - DialError::Banned | - DialError::NoAddresses | - DialError::DialPeerConditionFalse(_) | - DialError::Aborted => None, // ignore them + DialError::Banned + | DialError::NoAddresses + | DialError::DialPeerConditionFalse(_) + | DialError::Aborted => None, // ignore them }; if let Some(reason) = reason { metrics.pending_connections_errors_total.with_label_values(&[reason]).inc(); @@ -1670,15 +1679,17 @@ where if let Some(metrics) = self.metrics.as_ref() { #[allow(deprecated)] let reason = match error { - ListenError::Denied { cause } => + ListenError::Denied { cause } => { if cause.downcast::().is_ok() { Some("limit-reached") } else { None - }, + } + }, ListenError::ConnectionLimit(_) => Some("limit-reached"), - ListenError::WrongPeerId { .. } | ListenError::LocalPeerId { .. } => - Some("invalid-peer-id"), + ListenError::WrongPeerId { .. } | ListenError::LocalPeerId { .. } => { + Some("invalid-peer-id") + }, ListenError::Transport(_) => Some("transport-error"), ListenError::Aborted => None, // ignore it }; @@ -1754,7 +1765,7 @@ fn ensure_addresses_consistent_with_transport<'a>( return Err(Error::AddressesForAnotherTransport { transport: transport.clone(), addresses, - }) + }); } } else { let addresses: Vec<_> = addresses @@ -1766,7 +1777,7 @@ fn ensure_addresses_consistent_with_transport<'a>( return Err(Error::AddressesForAnotherTransport { transport: transport.clone(), addresses, - }) + }); } } diff --git a/client/network/src/transport.rs b/client/network/src/transport.rs index caac795424998..4136b34fc0e8e 100644 --- a/client/network/src/transport.rs +++ b/client/network/src/transport.rs @@ -27,7 +27,6 @@ use libp2p::{ }, dns, identity, noise, tcp, websocket, PeerId, Transport, TransportExt, }; -use libp2p_webrtc::tokio::{Certificate as WebRTCCertificate, Transport as WebRTCTransport}; use std::{sync::Arc, time::Duration}; pub use libp2p::bandwidth::BandwidthSinks; diff --git a/client/network/src/types.rs b/client/network/src/types.rs index b0e32ae109149..5444a1e060311 100644 --- a/client/network/src/types.rs +++ b/client/network/src/types.rs @@ -18,8 +18,6 @@ //! `sc-network` type definitions -use libp2p::core::upgrade; - use std::{ borrow::Borrow, fmt, @@ -92,9 +90,9 @@ impl fmt::Display for ProtocolName { } } -impl upgrade::ProtocolName for ProtocolName { - fn protocol_name(&self) -> &[u8] { - (self as &str).as_bytes() +impl AsRef for ProtocolName { + fn as_ref(&self) -> &str { + self as &str } } From 839641b24b643439d6897b62075634009be1d379 Mon Sep 17 00:00:00 2001 From: Anton Kaliaev Date: Wed, 21 Jun 2023 16:29:55 +0300 Subject: [PATCH 03/42] update libp2p version everywhere --- Cargo.lock | 1730 ++---------------------- Cargo.toml | 6 +- client/authority-discovery/Cargo.toml | 2 +- client/network-gossip/Cargo.toml | 2 +- client/network/statement/Cargo.toml | 2 +- client/network/sync/Cargo.toml | 2 +- client/network/test/Cargo.toml | 2 +- client/network/transactions/Cargo.toml | 2 +- client/offchain/Cargo.toml | 2 +- client/telemetry/Cargo.toml | 2 +- 10 files changed, 159 insertions(+), 1593 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 12e872624135b..08d8454bfbfd4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -27,15 +27,6 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" -[[package]] -name = "aead" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fc95d1bdb8e6666b2b217308eeeb09f2d6728d104be3e31916cc74d15420331" -dependencies = [ - "generic-array 0.14.7", -] - [[package]] name = "aead" version = "0.4.3" @@ -43,28 +34,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b613b8e1e3cf911a086f53f03bf286f52fd7a7258e4fa606f0ef220d39d8877" dependencies = [ "generic-array 0.14.7", - "rand_core 0.6.4", -] - -[[package]] -name = "aead" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d122413f284cf2d62fb1b7db97e02edb8cda96d769b16e443a4f6195e35662b0" -dependencies = [ - "crypto-common", - "generic-array 0.14.7", -] - -[[package]] -name = "aes" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "884391ef1066acaa41e766ba8f596341b96e93ce34f9a43e7d24bf0a0eaf0561" -dependencies = [ - "aes-soft", - "aesni", - "cipher 0.2.5", ] [[package]] @@ -74,70 +43,25 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9e8b47f52ea9bae42228d07ec09eb676433d7c4ed1ebdf0f1d1c29ed446f1ab8" dependencies = [ "cfg-if", - "cipher 0.3.0", + "cipher", "cpufeatures", "opaque-debug 0.3.0", ] -[[package]] -name = "aes" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "433cfd6710c9986c576a25ca913c39d66a6474107b406f34f91d4a8923395241" -dependencies = [ - "cfg-if", - "cipher 0.4.4", - "cpufeatures", -] - [[package]] name = "aes-gcm" version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "df5f85a83a7d8b0442b6aa7b504b8212c1733da07b98aae43d4bc21b2cb3cdf6" dependencies = [ - "aead 0.4.3", - "aes 0.7.5", - "cipher 0.3.0", - "ctr 0.8.0", - "ghash 0.4.4", - "subtle", -] - -[[package]] -name = "aes-gcm" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "209b47e8954a928e1d72e86eca7000ebb6655fe1436d33eefc2201cad027e237" -dependencies = [ - "aead 0.5.2", - "aes 0.8.2", - "cipher 0.4.4", - "ctr 0.9.2", - "ghash 0.5.0", + "aead", + "aes", + "cipher", + "ctr", + "ghash", "subtle", ] -[[package]] -name = "aes-soft" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be14c7498ea50828a38d0e24a765ed2effe92a705885b57d029cd67d45744072" -dependencies = [ - "cipher 0.2.5", - "opaque-debug 0.3.0", -] - -[[package]] -name = "aesni" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea2e11f5e94c2f7d386164cc2aa1f97823fed6f259e486940a71c174dd01b0ce" -dependencies = [ - "cipher 0.2.5", - "opaque-debug 0.3.0", -] - [[package]] name = "ahash" version = "0.7.6" @@ -279,12 +203,6 @@ version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2d098ff73c1ca148721f37baad5ea6a465a13f9573aba8641fbbbae8164a54e" -[[package]] -name = "arc-swap" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bddcadddf5e9015d310179a59bb28c4d4b9920ad0f11e8e14dbadf654890c9a6" - [[package]] name = "ark-algebra-test-templates" version = "0.4.2" @@ -541,73 +459,6 @@ version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" -[[package]] -name = "asn1-rs" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30ff05a702273012438132f449575dbc804e27b2f3cbe3069aa237d26c98fa33" -dependencies = [ - "asn1-rs-derive 0.1.0", - "asn1-rs-impl", - "displaydoc", - "nom", - "num-traits", - "rusticata-macros", - "thiserror", - "time 0.3.21", -] - -[[package]] -name = "asn1-rs" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f6fd5ddaf0351dff5b8da21b2fb4ff8e08ddd02857f0bf69c47639106c0fff0" -dependencies = [ - "asn1-rs-derive 0.4.0", - "asn1-rs-impl", - "displaydoc", - "nom", - "num-traits", - "rusticata-macros", - "thiserror", - "time 0.3.21", -] - -[[package]] -name = "asn1-rs-derive" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db8b7511298d5b7784b40b092d9e9dcd3a627a5707e4b5e507931ab0d44eeebf" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", - "synstructure", -] - -[[package]] -name = "asn1-rs-derive" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "726535892e8eae7e70657b4c8ea93d26b8553afb1ce617caee529ef96d7dee6c" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", - "synstructure", -] - -[[package]] -name = "asn1-rs-impl" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2777730b2039ac0f95f093556e61b6d26cebed5393ca6f152717777cec3a42ed" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "assert_cmd" version = "2.0.11" @@ -726,12 +577,6 @@ dependencies = [ "pin-project-lite 0.2.9", ] -[[package]] -name = "atomic-waker" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1181e1e0d1fce796a03db1ae795d67167da795f9cf4a39c37589e85ef57f26d3" - [[package]] name = "atty" version = "0.2.14" @@ -770,12 +615,6 @@ version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4cbbc9d0964165b47557570cce6c952866c2678457aca742aafc9fb771d30270" -[[package]] -name = "base16ct" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "349a06037c7bf932dd7e7d1f653678b2038b9ad46a74102f1fc7bd7872678cce" - [[package]] name = "base16ct" version = "0.2.0" @@ -928,7 +767,7 @@ version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b" dependencies = [ - "block-padding 0.1.5", + "block-padding", "byte-tools", "byteorder", "generic-array 0.12.4", @@ -952,16 +791,6 @@ dependencies = [ "generic-array 0.14.7", ] -[[package]] -name = "block-modes" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57a0e8073e8baa88212fb5823574c02ebccb395136ba9a164ab89379ec6072f0" -dependencies = [ - "block-padding 0.2.1", - "cipher 0.2.5", -] - [[package]] name = "block-padding" version = "0.1.5" @@ -971,12 +800,6 @@ dependencies = [ "byte-tools", ] -[[package]] -name = "block-padding" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d696c370c750c948ada61c69a0ee2cbbb9c50b1019ddb86d9317157a99c2cae" - [[package]] name = "bounded-collections" version = "0.1.8" @@ -1119,17 +942,6 @@ dependencies = [ "jobserver", ] -[[package]] -name = "ccm" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aca1a8fbc20b50ac9673ff014abfb2b5f4085ee1a850d408f14a159c5853ac7" -dependencies = [ - "aead 0.3.2", - "cipher 0.2.5", - "subtle", -] - [[package]] name = "cexpr" version = "0.6.0" @@ -1167,7 +979,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5c80e5460aa66fe3b91d40bcbdab953a597b60053e34d684ac6903f863b680a6" dependencies = [ "cfg-if", - "cipher 0.3.0", + "cipher", "cpufeatures", "zeroize", ] @@ -1178,9 +990,9 @@ version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a18446b09be63d457bbec447509e85f662f32952b035ce892290396bc0b0cff5" dependencies = [ - "aead 0.4.3", + "aead", "chacha20", - "cipher 0.3.0", + "cipher", "poly1305", "zeroize", ] @@ -1209,7 +1021,7 @@ dependencies = [ "iana-time-zone", "js-sys", "num-traits", - "time 0.1.45", + "time", "wasm-bindgen", "winapi", ] @@ -1254,15 +1066,6 @@ dependencies = [ "unsigned-varint", ] -[[package]] -name = "cipher" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12f8e7987cbd042a63249497f41aed09f8e65add917ea6566effbc56578d6801" -dependencies = [ - "generic-array 0.14.7", -] - [[package]] name = "cipher" version = "0.3.0" @@ -1272,16 +1075,6 @@ dependencies = [ "generic-array 0.14.7", ] -[[package]] -name = "cipher" -version = "0.4.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad" -dependencies = [ - "crypto-common", - "inout", -] - [[package]] name = "ckb-merkle-mountain-range" version = "0.5.2" @@ -1588,21 +1381,6 @@ dependencies = [ "wasmtime-types", ] -[[package]] -name = "crc" -version = "3.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86ec7a15cbe22e59248fc7eadb1907dab5ba09372595da4d73dd805ed4417dfe" -dependencies = [ - "crc-catalog", -] - -[[package]] -name = "crc-catalog" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cace84e55f07e7301bae1c519df89cdad8cc3cd868413d3fdbdeca9ff3db484" - [[package]] name = "crc32fast" version = "1.3.2" @@ -1699,18 +1477,6 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" -[[package]] -name = "crypto-bigint" -version = "0.4.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef2b4b23cddf68b89b8f8069890e8c270d54e2d5fe1b143820234805e4cb17ef" -dependencies = [ - "generic-array 0.14.7", - "rand_core 0.6.4", - "subtle", - "zeroize", -] - [[package]] name = "crypto-bigint" version = "0.5.2" @@ -1730,7 +1496,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" dependencies = [ "generic-array 0.14.7", - "rand_core 0.6.4", "typenum", ] @@ -1770,16 +1535,7 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "049bb91fb4aaf0e3c7efa6cd5ef877dbbbd15b39dad06d9948de4ec8a75761ea" dependencies = [ - "cipher 0.3.0", -] - -[[package]] -name = "ctr" -version = "0.9.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0369ee1ad671834580515889b80f2ea915f23b8be8d0daa4bbaf2ac5c7590835" -dependencies = [ - "cipher 0.4.4", + "cipher", ] [[package]] @@ -1866,41 +1622,6 @@ dependencies = [ "syn 2.0.18", ] -[[package]] -name = "darling" -version = "0.14.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b750cb3417fd1b327431a470f388520309479ab0bf5e323505daf0290cd3850" -dependencies = [ - "darling_core", - "darling_macro", -] - -[[package]] -name = "darling_core" -version = "0.14.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "109c1ca6e6b7f82cc233a97004ea8ed7ca123a9af07a8230878fcfda9b158bf0" -dependencies = [ - "fnv", - "ident_case", - "proc-macro2", - "quote", - "strsim", - "syn 1.0.109", -] - -[[package]] -name = "darling_macro" -version = "0.14.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4aab4dbc9f7611d8b55048a3a16d2d010c2c8334e46304b40ac1cc14bf3b48e" -dependencies = [ - "darling_core", - "quote", - "syn 1.0.109", -] - [[package]] name = "data-encoding" version = "2.4.0" @@ -1927,17 +1648,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "der" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1a467a65c5e759bce6e65eaf91cc29f466cdc57cb65777bd646872a8a1fd4de" -dependencies = [ - "const-oid", - "pem-rfc7468", - "zeroize", -] - [[package]] name = "der" version = "0.7.6" @@ -1948,34 +1658,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "der-parser" -version = "7.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe398ac75057914d7d07307bf67dc7f3f574a26783b4fc7805a20ffa9f506e82" -dependencies = [ - "asn1-rs 0.3.1", - "displaydoc", - "nom", - "num-bigint", - "num-traits", - "rusticata-macros", -] - -[[package]] -name = "der-parser" -version = "8.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbd676fbbab537128ef0278adb5576cf363cff6aa22a7b24effe97347cfab61e" -dependencies = [ - "asn1-rs 0.5.2", - "displaydoc", - "nom", - "num-bigint", - "num-traits", - "rusticata-macros", -] - [[package]] name = "derivative" version = "2.2.0" @@ -1998,37 +1680,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "derive_builder" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d07adf7be193b71cc36b193d0f5fe60b918a3a9db4dad0449f57bcfd519704a3" -dependencies = [ - "derive_builder_macro", -] - -[[package]] -name = "derive_builder_core" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f91d4cfa921f1c05904dc3c57b4a32c38aed3340cce209f3a6fd1478babafc4" -dependencies = [ - "darling", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "derive_builder_macro" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f0314b72bed045f3a68671b3c86328386762c93f82d98c65c3cb5e5f573dd68" -dependencies = [ - "derive_builder_core", - "syn 1.0.109", -] - [[package]] name = "derive_more" version = "0.99.17" @@ -2124,19 +1775,8 @@ dependencies = [ ] [[package]] -name = "displaydoc" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.18", -] - -[[package]] -name = "dissimilar" -version = "1.0.6" +name = "dissimilar" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "210ec60ae7d710bed8683e333e9d2855a8a56a3e9892b38bad3bb0d4d29b0d5e" @@ -2218,30 +1858,18 @@ version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "68b0cf012f1230e43cd00ebb729c6bb58707ecfa8ad08b52ef3a4ccd2697fc30" -[[package]] -name = "ecdsa" -version = "0.14.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "413301934810f597c1d19ca71c8710e99a3f1ba28a0d2ebc01551a2daeea3c5c" -dependencies = [ - "der 0.6.1", - "elliptic-curve 0.12.3", - "rfc6979 0.3.1", - "signature 1.6.4", -] - [[package]] name = "ecdsa" version = "0.16.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0997c976637b606099b9985693efa3581e84e41f5c11ba5255f88711058ad428" dependencies = [ - "der 0.7.6", + "der", "digest 0.10.7", - "elliptic-curve 0.13.5", - "rfc6979 0.4.0", + "elliptic-curve", + "rfc6979", "signature 2.1.0", - "spki 0.7.2", + "spki", ] [[package]] @@ -2287,43 +1915,21 @@ version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91" -[[package]] -name = "elliptic-curve" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7bb888ab5300a19b8e5bceef25ac745ad065f3c9f7efc6de1b91958110891d3" -dependencies = [ - "base16ct 0.1.1", - "crypto-bigint 0.4.9", - "der 0.6.1", - "digest 0.10.7", - "ff 0.12.1", - "generic-array 0.14.7", - "group 0.12.1", - "hkdf", - "pem-rfc7468", - "pkcs8 0.9.0", - "rand_core 0.6.4", - "sec1 0.3.0", - "subtle", - "zeroize", -] - [[package]] name = "elliptic-curve" version = "0.13.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "968405c8fdc9b3bf4df0a6638858cc0b52462836ab6b1c87377785dd09cf1c0b" dependencies = [ - "base16ct 0.2.0", - "crypto-bigint 0.5.2", + "base16ct", + "crypto-bigint", "digest 0.10.7", - "ff 0.13.0", + "ff", "generic-array 0.14.7", - "group 0.13.0", - "pkcs8 0.10.2", + "group", + "pkcs8", "rand_core 0.6.4", - "sec1 0.7.2", + "sec1", "subtle", "zeroize", ] @@ -2477,16 +2083,6 @@ dependencies = [ "libc", ] -[[package]] -name = "ff" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d013fc25338cc558c5c2cfbad646908fb23591e2404481826742b651c9af7160" -dependencies = [ - "rand_core 0.6.4", - "subtle", -] - [[package]] name = "ff" version = "0.13.0" @@ -2567,7 +2163,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3b9429470923de8e8cbd4d2dc513535400b4b3fef0319fb5c4e1f520a7bef743" dependencies = [ "crc32fast", - "libz-sys", "miniz_oxide 0.7.1", ] @@ -3115,7 +2710,7 @@ checksum = "d2411eed028cdf8c8034eaf21f9915f956b6c3abec4d4c7949ee67f0721127bd" dependencies = [ "futures-io", "rustls 0.20.8", - "webpki 0.22.0", + "webpki", ] [[package]] @@ -3236,17 +2831,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1583cc1656d7839fd3732b80cf4f38850336cdb9b8ded1cd399ca62958de3c99" dependencies = [ "opaque-debug 0.3.0", - "polyval 0.5.3", -] - -[[package]] -name = "ghash" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d930750de5717d2dd0b8c0d42c076c0e884c81a73e6cab859bbd2339c71e3e40" -dependencies = [ - "opaque-debug 0.3.0", - "polyval 0.6.0", + "polyval", ] [[package]] @@ -3279,24 +2864,13 @@ dependencies = [ "regex", ] -[[package]] -name = "group" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5dfbfb3a6cfbd390d5c9564ab283a0349b9b9fcd46a706c1eb10e0db70bfbac7" -dependencies = [ - "ff 0.12.1", - "rand_core 0.6.4", - "subtle", -] - [[package]] name = "group" version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" dependencies = [ - "ff 0.13.0", + "ff", "rand_core 0.6.4", "subtle", ] @@ -3415,15 +2989,6 @@ version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ebdb29d2ea9ed0083cd8cece49bbd968021bd99b0849edb4a9a7ee0fdf6a4e0" -[[package]] -name = "hkdf" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "791a029f6b9fc27657f6f188ec6e5e43f6911f6f878e0dc5501396e09809d437" -dependencies = [ - "hmac 0.12.1", -] - [[package]] name = "hmac" version = "0.8.1" @@ -3611,12 +3176,6 @@ dependencies = [ "cc", ] -[[package]] -name = "ident_case" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" - [[package]] name = "idna" version = "0.2.3" @@ -3737,15 +3296,6 @@ dependencies = [ "unicode-width", ] -[[package]] -name = "inout" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0c10553d664a4d0bcff9f4215d0aac67a639cc68ef660840afe309b807bc9f5" -dependencies = [ - "generic-array 0.14.7", -] - [[package]] name = "instant" version = "0.1.12" @@ -3764,25 +3314,6 @@ dependencies = [ "num-traits", ] -[[package]] -name = "interceptor" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e8a11ae2da61704edada656798b61c94b35ecac2c58eb955156987d5e6be90b" -dependencies = [ - "async-trait", - "bytes", - "log", - "rand 0.8.5", - "rtcp", - "rtp", - "thiserror", - "tokio", - "waitgroup", - "webrtc-srtp", - "webrtc-util", -] - [[package]] name = "io-lifetimes" version = "1.0.11" @@ -4014,8 +3545,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cadb76004ed8e97623117f3df85b17aaa6626ab0b0831e6573f104df16cd1bcc" dependencies = [ "cfg-if", - "ecdsa 0.16.7", - "elliptic-curve 0.13.5", + "ecdsa", + "elliptic-curve", "once_cell", "sha2 0.10.7", ] @@ -4227,143 +3758,67 @@ version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f7012b1bbb0719e1097c47611d3898568c546d597c2e74d66f6087edd5233ff4" -[[package]] -name = "libp2p" -version = "0.51.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f210d259724eae82005b5c48078619b7745edb7b76de370b03f8ba59ea103097" -dependencies = [ - "bytes", - "futures", - "futures-timer", - "getrandom 0.2.9", - "instant", - "libp2p-allow-block-list 0.1.1", - "libp2p-connection-limits 0.1.0", - "libp2p-core 0.39.2", - "libp2p-dns 0.39.0", - "libp2p-identity 0.1.2", - "libp2p-kad 0.43.3", - "libp2p-mdns 0.43.1", - "libp2p-metrics 0.12.0", - "libp2p-quic", - "libp2p-swarm 0.42.2", - "libp2p-tcp 0.39.0", - "libp2p-wasm-ext", - "libp2p-webrtc", - "libp2p-websocket 0.41.0", - "multiaddr 0.17.1", - "pin-project", -] - [[package]] name = "libp2p" version = "0.52.0" -source = "git+https://github.com/melekes/rust-libp2p.git?branch=anton/upgrade-webrtc-to-0.8.0#63452cf7709b8b48303ba7b2251e169d97d48da9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "265b12faeb6ea2e770644ed98ba0e563d326088f8ba5a31080be772cb2800513" dependencies = [ "bytes", "futures", "futures-timer", "getrandom 0.2.9", "instant", - "libp2p-allow-block-list 0.2.0", - "libp2p-connection-limits 0.2.0", - "libp2p-core 0.40.0", - "libp2p-dns 0.40.0", + "libp2p-allow-block-list", + "libp2p-connection-limits", + "libp2p-core", + "libp2p-dns", "libp2p-identify", "libp2p-identity 0.2.0", - "libp2p-kad 0.44.0", - "libp2p-mdns 0.44.0", - "libp2p-metrics 0.13.0", - "libp2p-noise 0.43.0", + "libp2p-kad", + "libp2p-mdns", + "libp2p-metrics", + "libp2p-noise", "libp2p-ping", "libp2p-request-response", - "libp2p-swarm 0.43.0", - "libp2p-tcp 0.40.0", - "libp2p-websocket 0.42.0", + "libp2p-swarm", + "libp2p-tcp", + "libp2p-wasm-ext", + "libp2p-websocket", "libp2p-yamux", "multiaddr 0.18.0", "pin-project", ] -[[package]] -name = "libp2p-allow-block-list" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "510daa05efbc25184458db837f6f9a5143888f1caa742426d92e1833ddd38a50" -dependencies = [ - "libp2p-core 0.39.2", - "libp2p-identity 0.1.2", - "libp2p-swarm 0.42.2", - "void", -] - [[package]] name = "libp2p-allow-block-list" version = "0.2.0" -source = "git+https://github.com/melekes/rust-libp2p.git?branch=anton/upgrade-webrtc-to-0.8.0#63452cf7709b8b48303ba7b2251e169d97d48da9" -dependencies = [ - "libp2p-core 0.40.0", - "libp2p-identity 0.2.0", - "libp2p-swarm 0.43.0", - "void", -] - -[[package]] -name = "libp2p-connection-limits" -version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4caa33f1d26ed664c4fe2cca81a08c8e07d4c1c04f2f4ac7655c2dd85467fda0" +checksum = "55b46558c5c0bf99d3e2a1a38fd54ff5476ca66dd1737b12466a1824dd219311" dependencies = [ - "libp2p-core 0.39.2", - "libp2p-identity 0.1.2", - "libp2p-swarm 0.42.2", + "libp2p-core", + "libp2p-identity 0.2.0", + "libp2p-swarm", "void", ] [[package]] name = "libp2p-connection-limits" version = "0.2.0" -source = "git+https://github.com/melekes/rust-libp2p.git?branch=anton/upgrade-webrtc-to-0.8.0#63452cf7709b8b48303ba7b2251e169d97d48da9" -dependencies = [ - "libp2p-core 0.40.0", - "libp2p-identity 0.2.0", - "libp2p-swarm 0.43.0", - "void", -] - -[[package]] -name = "libp2p-core" -version = "0.39.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c1df63c0b582aa434fb09b2d86897fa2b419ffeccf934b36f87fcedc8e835c2" +checksum = "d45dd90e8f0e1fa59e85ff5316dd4d1ac41a9a507e79cda1b0e9b7be43ad1a56" dependencies = [ - "either", - "fnv", - "futures", - "futures-timer", - "instant", - "libp2p-identity 0.1.2", - "log", - "multiaddr 0.17.1", - "multihash 0.17.0", - "multistream-select 0.12.1", - "once_cell", - "parking_lot 0.12.1", - "pin-project", - "quick-protobuf", - "rand 0.8.5", - "rw-stream-sink 0.3.0", - "smallvec", - "thiserror", - "unsigned-varint", + "libp2p-core", + "libp2p-identity 0.2.0", + "libp2p-swarm", "void", ] [[package]] name = "libp2p-core" version = "0.40.0" -source = "git+https://github.com/melekes/rust-libp2p.git?branch=anton/upgrade-webrtc-to-0.8.0#63452cf7709b8b48303ba7b2251e169d97d48da9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef7dd7b09e71aac9271c60031d0e558966cdb3253ba0308ab369bb2de80630d0" dependencies = [ "either", "fnv", @@ -4380,34 +3835,21 @@ dependencies = [ "pin-project", "quick-protobuf", "rand 0.8.5", - "rw-stream-sink 0.4.0", + "rw-stream-sink", "smallvec", "thiserror", "unsigned-varint", "void", ] -[[package]] -name = "libp2p-dns" -version = "0.39.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "146ff7034daae62077c415c2376b8057368042df6ab95f5432ad5e88568b1554" -dependencies = [ - "futures", - "libp2p-core 0.39.2", - "log", - "parking_lot 0.12.1", - "smallvec", - "trust-dns-resolver", -] - [[package]] name = "libp2p-dns" version = "0.40.0" -source = "git+https://github.com/melekes/rust-libp2p.git?branch=anton/upgrade-webrtc-to-0.8.0#63452cf7709b8b48303ba7b2251e169d97d48da9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd4394c81c0c06d7b4a60f3face7e8e8a9b246840f98d2c80508d0721b032147" dependencies = [ "futures", - "libp2p-core 0.40.0", + "libp2p-core", "libp2p-identity 0.2.0", "log", "parking_lot 0.12.1", @@ -4418,19 +3860,20 @@ dependencies = [ [[package]] name = "libp2p-identify" version = "0.43.0" -source = "git+https://github.com/melekes/rust-libp2p.git?branch=anton/upgrade-webrtc-to-0.8.0#63452cf7709b8b48303ba7b2251e169d97d48da9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a29675a32dbcc87790db6cf599709e64308f1ae9d5ecea2d259155889982db8" dependencies = [ "asynchronous-codec", "either", "futures", "futures-timer", - "libp2p-core 0.40.0", + "libp2p-core", "libp2p-identity 0.2.0", - "libp2p-swarm 0.43.0", + "libp2p-swarm", "log", "lru", "quick-protobuf", - "quick-protobuf-codec 0.2.0", + "quick-protobuf-codec", "smallvec", "thiserror", "void", @@ -4471,38 +3914,11 @@ dependencies = [ "zeroize", ] -[[package]] -name = "libp2p-kad" -version = "0.43.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39d5ef876a2b2323d63c258e63c2f8e36f205fe5a11f0b3095d59635650790ff" -dependencies = [ - "arrayvec 0.7.4", - "asynchronous-codec", - "bytes", - "either", - "fnv", - "futures", - "futures-timer", - "instant", - "libp2p-core 0.39.2", - "libp2p-identity 0.1.2", - "libp2p-swarm 0.42.2", - "log", - "quick-protobuf", - "rand 0.8.5", - "sha2 0.10.7", - "smallvec", - "thiserror", - "uint", - "unsigned-varint", - "void", -] - [[package]] name = "libp2p-kad" version = "0.44.0" -source = "git+https://github.com/melekes/rust-libp2p.git?branch=anton/upgrade-webrtc-to-0.8.0#63452cf7709b8b48303ba7b2251e169d97d48da9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4e706c112fe122e824872df3ce43742134c27be0ef2103f78ea8a1d8024a771" dependencies = [ "arrayvec 0.7.4", "asynchronous-codec", @@ -4512,9 +3928,9 @@ dependencies = [ "futures", "futures-timer", "instant", - "libp2p-core 0.40.0", + "libp2p-core", "libp2p-identity 0.2.0", - "libp2p-swarm 0.43.0", + "libp2p-swarm", "log", "quick-protobuf", "rand 0.8.5", @@ -4526,38 +3942,18 @@ dependencies = [ "void", ] -[[package]] -name = "libp2p-mdns" -version = "0.43.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19983e1f949f979a928f2c603de1cf180cc0dc23e4ac93a62651ccb18341460b" -dependencies = [ - "data-encoding", - "futures", - "if-watch", - "libp2p-core 0.39.2", - "libp2p-identity 0.1.2", - "libp2p-swarm 0.42.2", - "log", - "rand 0.8.5", - "smallvec", - "socket2 0.4.9", - "tokio", - "trust-dns-proto", - "void", -] - [[package]] name = "libp2p-mdns" version = "0.44.0" -source = "git+https://github.com/melekes/rust-libp2p.git?branch=anton/upgrade-webrtc-to-0.8.0#63452cf7709b8b48303ba7b2251e169d97d48da9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42a2567c305232f5ef54185e9604579a894fd0674819402bb0ac0246da82f52a" dependencies = [ "data-encoding", "futures", "if-watch", - "libp2p-core 0.40.0", + "libp2p-core", "libp2p-identity 0.2.0", - "libp2p-swarm 0.43.0", + "libp2p-swarm", "log", "rand 0.8.5", "smallvec", @@ -4567,66 +3963,33 @@ dependencies = [ "void", ] -[[package]] -name = "libp2p-metrics" -version = "0.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a42ec91e227d7d0dafa4ce88b333cdf5f277253873ab087555c92798db2ddd46" -dependencies = [ - "libp2p-core 0.39.2", - "libp2p-kad 0.43.3", - "libp2p-swarm 0.42.2", - "prometheus-client 0.19.0", -] - [[package]] name = "libp2p-metrics" version = "0.13.0" -source = "git+https://github.com/melekes/rust-libp2p.git?branch=anton/upgrade-webrtc-to-0.8.0#63452cf7709b8b48303ba7b2251e169d97d48da9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3787ea81798dcc5bf1d8b40a8e8245cf894b168d04dd70aa48cb3ff2fff141d2" dependencies = [ "instant", - "libp2p-core 0.40.0", + "libp2p-core", "libp2p-identify", "libp2p-identity 0.2.0", - "libp2p-kad 0.44.0", + "libp2p-kad", "libp2p-ping", - "libp2p-swarm 0.43.0", + "libp2p-swarm", "once_cell", - "prometheus-client 0.21.1", -] - -[[package]] -name = "libp2p-noise" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c3673da89d29936bc6435bafc638e2f184180d554ce844db65915113f86ec5e" -dependencies = [ - "bytes", - "curve25519-dalek 3.2.0", - "futures", - "libp2p-core 0.39.2", - "libp2p-identity 0.1.2", - "log", - "once_cell", - "quick-protobuf", - "rand 0.8.5", - "sha2 0.10.7", - "snow", - "static_assertions", - "thiserror", - "x25519-dalek 1.1.1", - "zeroize", + "prometheus-client", ] [[package]] name = "libp2p-noise" version = "0.43.0" -source = "git+https://github.com/melekes/rust-libp2p.git?branch=anton/upgrade-webrtc-to-0.8.0#63452cf7709b8b48303ba7b2251e169d97d48da9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87945db2b3f977af09b62b9aa0a5f3e4870995a577ecd845cdeba94cdf6bbca7" dependencies = [ "bytes", "curve25519-dalek 3.2.0", "futures", - "libp2p-core 0.40.0", + "libp2p-core", "libp2p-identity 0.2.0", "log", "multiaddr 0.18.0", @@ -4638,97 +4001,58 @@ dependencies = [ "snow", "static_assertions", "thiserror", - "x25519-dalek 1.1.1", + "x25519-dalek", "zeroize", ] [[package]] name = "libp2p-ping" version = "0.43.0" -source = "git+https://github.com/melekes/rust-libp2p.git?branch=anton/upgrade-webrtc-to-0.8.0#63452cf7709b8b48303ba7b2251e169d97d48da9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3cd5ee3270229443a2b34b27ed0cb7470ef6b4a6e45e54e89a8771fa683bab48" dependencies = [ "either", "futures", "futures-timer", "instant", - "libp2p-core 0.40.0", + "libp2p-core", "libp2p-identity 0.2.0", - "libp2p-swarm 0.43.0", + "libp2p-swarm", "log", "rand 0.8.5", "void", ] -[[package]] -name = "libp2p-quic" -version = "0.7.0-alpha.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6b26abd81cd2398382a1edfe739b539775be8a90fa6914f39b2ab49571ec735" -dependencies = [ - "bytes", - "futures", - "futures-timer", - "if-watch", - "libp2p-core 0.39.2", - "libp2p-identity 0.1.2", - "libp2p-tls", - "log", - "parking_lot 0.12.1", - "quinn-proto", - "rand 0.8.5", - "rustls 0.20.8", - "thiserror", - "tokio", -] - [[package]] name = "libp2p-request-response" version = "0.25.0" -source = "git+https://github.com/melekes/rust-libp2p.git?branch=anton/upgrade-webrtc-to-0.8.0#63452cf7709b8b48303ba7b2251e169d97d48da9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20bd837798cdcce4283d2675f08bcd3756a650d56eab4d4367e1b3f27eed6887" dependencies = [ "async-trait", "futures", "instant", - "libp2p-core 0.40.0", + "libp2p-core", "libp2p-identity 0.2.0", - "libp2p-swarm 0.43.0", + "libp2p-swarm", "log", "rand 0.8.5", "smallvec", "void", ] -[[package]] -name = "libp2p-swarm" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "903b3d592d7694e56204d211f29d31bc004be99386644ba8731fc3e3ef27b296" -dependencies = [ - "either", - "fnv", - "futures", - "futures-timer", - "instant", - "libp2p-core 0.39.2", - "libp2p-identity 0.1.2", - "log", - "rand 0.8.5", - "smallvec", - "tokio", - "void", -] - [[package]] name = "libp2p-swarm" version = "0.43.0" -source = "git+https://github.com/melekes/rust-libp2p.git?branch=anton/upgrade-webrtc-to-0.8.0#63452cf7709b8b48303ba7b2251e169d97d48da9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6f1fe3817492f88c5298c8b5fbaa5ff3a0c802ecf4e79be4e341cf07abfa82f" dependencies = [ "either", "fnv", "futures", "futures-timer", "instant", - "libp2p-core 0.40.0", + "libp2p-core", "libp2p-identity 0.2.0", "libp2p-swarm-derive", "log", @@ -4743,7 +4067,8 @@ dependencies = [ [[package]] name = "libp2p-swarm-derive" version = "0.33.0" -source = "git+https://github.com/melekes/rust-libp2p.git?branch=anton/upgrade-webrtc-to-0.8.0#63452cf7709b8b48303ba7b2251e169d97d48da9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4d5ec2a3df00c7836d7696c136274c9c59705bac69133253696a6c932cd1d74" dependencies = [ "heck", "proc-macro-warning", @@ -4752,135 +4077,52 @@ dependencies = [ "syn 2.0.18", ] -[[package]] -name = "libp2p-tcp" -version = "0.39.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33d33698596d7722d85d3ab0c86c2c322254fce1241e91208e3679b4eb3026cf" -dependencies = [ - "futures", - "futures-timer", - "if-watch", - "libc", - "libp2p-core 0.39.2", - "log", - "socket2 0.4.9", - "tokio", -] - [[package]] name = "libp2p-tcp" version = "0.40.0" -source = "git+https://github.com/melekes/rust-libp2p.git?branch=anton/upgrade-webrtc-to-0.8.0#63452cf7709b8b48303ba7b2251e169d97d48da9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09bfdfb6f945c5c014b87872a0bdb6e0aef90e92f380ef57cd9013f118f9289d" dependencies = [ "futures", "futures-timer", "if-watch", "libc", - "libp2p-core 0.40.0", + "libp2p-core", "libp2p-identity 0.2.0", "log", "socket2 0.5.3", "tokio", ] -[[package]] -name = "libp2p-tls" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff08d13d0dc66e5e9ba6279c1de417b84fa0d0adc3b03e5732928c180ec02781" -dependencies = [ - "futures", - "futures-rustls", - "libp2p-core 0.39.2", - "libp2p-identity 0.1.2", - "rcgen 0.10.0", - "ring", - "rustls 0.20.8", - "thiserror", - "webpki 0.22.0", - "x509-parser 0.14.0", - "yasna", -] - [[package]] name = "libp2p-wasm-ext" -version = "0.39.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77dff9d32353a5887adb86c8afc1de1a94d9e8c3bc6df8b2201d7cdf5c848f43" -dependencies = [ - "futures", - "js-sys", - "libp2p-core 0.39.2", - "parity-send-wrapper", - "wasm-bindgen", - "wasm-bindgen-futures", -] - -[[package]] -name = "libp2p-webrtc" -version = "0.4.0-alpha.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dba48592edbc2f60b4bc7c10d65445b0c3964c07df26fdf493b6880d33be36f8" -dependencies = [ - "async-trait", - "asynchronous-codec", - "bytes", - "futures", - "futures-timer", - "hex", - "if-watch", - "libp2p-core 0.39.2", - "libp2p-identity 0.1.2", - "libp2p-noise 0.42.2", - "log", - "multihash 0.17.0", - "quick-protobuf", - "quick-protobuf-codec 0.1.0", - "rand 0.8.5", - "rcgen 0.9.3", - "serde", - "stun", - "thiserror", - "tinytemplate", - "tokio", - "tokio-util", - "webrtc", -] - -[[package]] -name = "libp2p-websocket" -version = "0.41.0" +version = "0.40.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "111273f7b3d3510524c752e8b7a5314b7f7a1fee7e68161c01a7d72cbb06db9f" +checksum = "1e5d8e3a9e07da0ef5b55a9f26c009c8fb3c725d492d8bb4b431715786eea79c" dependencies = [ - "either", "futures", - "futures-rustls", - "libp2p-core 0.39.2", - "log", - "parking_lot 0.12.1", - "quicksink", - "rw-stream-sink 0.3.0", - "soketto", - "url", - "webpki-roots 0.22.6", + "js-sys", + "libp2p-core", + "send_wrapper", + "wasm-bindgen", + "wasm-bindgen-futures", ] [[package]] name = "libp2p-websocket" version = "0.42.0" -source = "git+https://github.com/melekes/rust-libp2p.git?branch=anton/upgrade-webrtc-to-0.8.0#63452cf7709b8b48303ba7b2251e169d97d48da9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "956d981ebc84abc3377e5875483c06d94ff57bc6b25f725047f9fd52592f72d4" dependencies = [ "either", "futures", "futures-rustls", - "libp2p-core 0.40.0", + "libp2p-core", "libp2p-identity 0.2.0", "log", "parking_lot 0.12.1", "quicksink", - "rw-stream-sink 0.4.0", + "rw-stream-sink", "soketto", "url", "webpki-roots 0.23.1", @@ -4889,10 +4131,11 @@ dependencies = [ [[package]] name = "libp2p-yamux" version = "0.44.0" -source = "git+https://github.com/melekes/rust-libp2p.git?branch=anton/upgrade-webrtc-to-0.8.0#63452cf7709b8b48303ba7b2251e169d97d48da9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0a9b42ab6de15c6f076d8fb11dc5f48d899a10b55a2e16b12be9012a05287b0" dependencies = [ "futures", - "libp2p-core 0.40.0", + "libp2p-core", "log", "thiserror", "yamux", @@ -5191,15 +4434,6 @@ dependencies = [ "rawpointer", ] -[[package]] -name = "md-5" -version = "0.10.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6365506850d44bff6e2fbcb5176cf63650e48bd45ef2fe2665ae1570e0f4b9ca" -dependencies = [ - "digest 0.10.7", -] - [[package]] name = "memchr" version = "2.5.0" @@ -5224,15 +4458,6 @@ dependencies = [ "libc", ] -[[package]] -name = "memoffset" -version = "0.6.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" -dependencies = [ - "autocfg", -] - [[package]] name = "memoffset" version = "0.7.1" @@ -5499,7 +4724,8 @@ dependencies = [ [[package]] name = "multistream-select" version = "0.13.0" -source = "git+https://github.com/melekes/rust-libp2p.git?branch=anton/upgrade-webrtc-to-0.8.0#63452cf7709b8b48303ba7b2251e169d97d48da9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea0df8e5eec2298a62b326ee4f0d7fe1a6b90a09dfcf9df37b38f947a8c42f19" dependencies = [ "bytes", "futures", @@ -5620,7 +4846,6 @@ dependencies = [ "bitflags", "cfg-if", "libc", - "memoffset 0.6.5", ] [[package]] @@ -6148,24 +5373,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "oid-registry" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38e20717fa0541f39bd146692035c37bedfa532b3e5071b35761082407546b2a" -dependencies = [ - "asn1-rs 0.3.1", -] - -[[package]] -name = "oid-registry" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9bedf36ffb6ba96c2eb7144ef6270557b52e54b20c0a8e1eb2ff99a6c6959bff" -dependencies = [ - "asn1-rs 0.5.2", -] - [[package]] name = "once_cell" version = "1.18.0" @@ -6217,28 +5424,6 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" -[[package]] -name = "p256" -version = "0.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51f44edd08f51e2ade572f141051021c5af22677e42b7dd28a88155151c33594" -dependencies = [ - "ecdsa 0.14.8", - "elliptic-curve 0.12.3", - "sha2 0.10.7", -] - -[[package]] -name = "p384" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfc8c5bf642dde52bb9e87c0ecd8ca5a76faac2eeed98dedb7c717997e1080aa" -dependencies = [ - "ecdsa 0.14.8", - "elliptic-curve 0.12.3", - "sha2 0.10.7", -] - [[package]] name = "packed_simd_2" version = "0.3.8" @@ -7982,12 +7167,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "parity-send-wrapper" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa9777aa91b8ad9dd5aaa04a9b6bcb02c7f1deb952fca5a66034d5e63afc5c6f" - [[package]] name = "parity-wasm" version = "0.45.0" @@ -8084,24 +7263,6 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" -[[package]] -name = "pem" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8835c273a76a90455d7344889b0964598e3316e2a79ede8e36f16bdcf2228b8" -dependencies = [ - "base64 0.13.1", -] - -[[package]] -name = "pem-rfc7468" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24d159833a9105500e0398934e205e0773f0b27529557134ecfc51c27646adac" -dependencies = [ - "base64ct", -] - [[package]] name = "percent-encoding" version = "2.3.0" @@ -8200,24 +7361,14 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" -[[package]] -name = "pkcs8" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9eca2c590a5f85da82668fa685c09ce2888b9430e83299debf1f34b65fd4a4ba" -dependencies = [ - "der 0.6.1", - "spki 0.6.0", -] - [[package]] name = "pkcs8" version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" dependencies = [ - "der 0.7.6", - "spki 0.7.2", + "der", + "spki", ] [[package]] @@ -8284,7 +7435,7 @@ checksum = "048aeb476be11a4b6ca432ca569e375810de9294ae78f4774e78ea98a9246ede" dependencies = [ "cpufeatures", "opaque-debug 0.3.0", - "universal-hash 0.4.1", + "universal-hash", ] [[package]] @@ -8296,19 +7447,7 @@ dependencies = [ "cfg-if", "cpufeatures", "opaque-debug 0.3.0", - "universal-hash 0.4.1", -] - -[[package]] -name = "polyval" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ef234e08c11dfcb2e56f79fd70f6f2eb7f025c0ce2333e82f4f0518ecad30c6" -dependencies = [ - "cfg-if", - "cpufeatures", - "opaque-debug 0.3.0", - "universal-hash 0.5.1", + "universal-hash", ] [[package]] @@ -8479,18 +7618,6 @@ dependencies = [ "thiserror", ] -[[package]] -name = "prometheus-client" -version = "0.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d6fa99d535dd930d1249e6c79cb3c2915f9172a540fe2b02a4c8f9ca954721e" -dependencies = [ - "dtoa", - "itoa", - "parking_lot 0.12.1", - "prometheus-client-derive-encode", -] - [[package]] name = "prometheus-client" version = "0.21.1" @@ -8592,23 +7719,11 @@ dependencies = [ "byteorder", ] -[[package]] -name = "quick-protobuf-codec" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1693116345026436eb2f10b677806169c1a1260c1c60eaaffe3fb5a29ae23d8b" -dependencies = [ - "asynchronous-codec", - "bytes", - "quick-protobuf", - "thiserror", - "unsigned-varint", -] - [[package]] name = "quick-protobuf-codec" version = "0.2.0" -source = "git+https://github.com/melekes/rust-libp2p.git?branch=anton/upgrade-webrtc-to-0.8.0#63452cf7709b8b48303ba7b2251e169d97d48da9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8ededb1cd78531627244d51dd0c7139fbe736c7d57af0092a76f0ffb2f56e98" dependencies = [ "asynchronous-codec", "bytes", @@ -8637,24 +7752,6 @@ dependencies = [ "pin-project-lite 0.1.12", ] -[[package]] -name = "quinn-proto" -version = "0.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67c10f662eee9c94ddd7135043e544f3c82fa839a1e7b865911331961b53186c" -dependencies = [ - "bytes", - "rand 0.8.5", - "ring", - "rustc-hash", - "rustls 0.20.8", - "slab", - "thiserror", - "tinyvec", - "tracing", - "webpki 0.22.0", -] - [[package]] name = "quote" version = "1.0.28" @@ -8788,31 +7885,6 @@ dependencies = [ "num_cpus", ] -[[package]] -name = "rcgen" -version = "0.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6413f3de1edee53342e6138e75b56d32e7bc6e332b3bd62d497b1929d4cfbcdd" -dependencies = [ - "pem", - "ring", - "time 0.3.21", - "x509-parser 0.13.2", - "yasna", -] - -[[package]] -name = "rcgen" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffbe84efe2f38dea12e9bfc1f65377fdf03e53a18cb3b995faedf7934c7e785b" -dependencies = [ - "pem", - "ring", - "time 0.3.21", - "yasna", -] - [[package]] name = "redox_syscall" version = "0.2.16" @@ -8916,17 +7988,6 @@ dependencies = [ "quick-error", ] -[[package]] -name = "rfc6979" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7743f17af12fa0b03b803ba12cd6a8d9483a587e89c69445e3909655c0b9fabb" -dependencies = [ - "crypto-bigint 0.4.9", - "hmac 0.12.1", - "zeroize", -] - [[package]] name = "rfc6979" version = "0.4.0" @@ -8973,17 +8034,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "rtcp" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1919efd6d4a6a85d13388f9487549bb8e359f17198cc03ffd72f79b553873691" -dependencies = [ - "bytes", - "thiserror", - "webrtc-util", -] - [[package]] name = "rtnetlink" version = "0.10.1" @@ -9009,20 +8059,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "rtp" -version = "0.6.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2a095411ff00eed7b12e4c6a118ba984d113e1079582570d56a5ee723f11f80" -dependencies = [ - "async-trait", - "bytes", - "rand 0.8.5", - "serde", - "thiserror", - "webrtc-util", -] - [[package]] name = "rustc-demangle" version = "0.1.23" @@ -9059,15 +8095,6 @@ dependencies = [ "semver 1.0.17", ] -[[package]] -name = "rusticata-macros" -version = "4.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "faf0c4a6ece9950b9abdb62b1cfcf2a68b3b67a10ba445b3bb85be2a293d0632" -dependencies = [ - "nom", -] - [[package]] name = "rustix" version = "0.36.14" @@ -9096,19 +8123,6 @@ dependencies = [ "windows-sys 0.48.0", ] -[[package]] -name = "rustls" -version = "0.19.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35edb675feee39aec9c99fa5ff985081995a06d594114ae14cbe797ad7b7a6d7" -dependencies = [ - "base64 0.13.1", - "log", - "ring", - "sct 0.6.1", - "webpki 0.21.4", -] - [[package]] name = "rustls" version = "0.20.8" @@ -9117,8 +8131,8 @@ checksum = "fff78fc74d175294f4e83b28343315ffcfb114b156f0185e9741cb5570f50e2f" dependencies = [ "log", "ring", - "sct 0.7.0", - "webpki 0.22.0", + "sct", + "webpki", ] [[package]] @@ -9130,7 +8144,7 @@ dependencies = [ "log", "ring", "rustls-webpki", - "sct 0.7.0", + "sct", ] [[package]] @@ -9181,21 +8195,11 @@ dependencies = [ "tempfile", ] -[[package]] -name = "rw-stream-sink" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26338f5e09bb721b85b135ea05af7767c90b52f6de4f087d4f4a3a9d64e7dc04" -dependencies = [ - "futures", - "pin-project", - "static_assertions", -] - [[package]] name = "rw-stream-sink" version = "0.4.0" -source = "git+https://github.com/melekes/rust-libp2p.git?branch=anton/upgrade-webrtc-to-0.8.0#63452cf7709b8b48303ba7b2251e169d97d48da9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8c9026ff5d2f23da5e45bbc283f156383001bfb09c4e44256d02c1a685fe9a1" dependencies = [ "futures", "pin-project", @@ -9253,7 +8257,7 @@ dependencies = [ "futures", "futures-timer", "ip_network", - "libp2p 0.51.3", + "libp2p", "log", "multihash 0.17.0", "parity-scale-codec", @@ -9932,7 +8936,7 @@ dependencies = [ "futures", "futures-timer", "ip_network", - "libp2p 0.52.0", + "libp2p", "linked_hash_set", "log", "lru", @@ -10035,7 +9039,7 @@ dependencies = [ "ahash 0.8.3", "futures", "futures-timer", - "libp2p 0.51.3", + "libp2p", "log", "lru", "quickcheck", @@ -10076,7 +9080,7 @@ dependencies = [ "array-bytes 4.2.0", "async-channel", "futures", - "libp2p 0.51.3", + "libp2p", "log", "parity-scale-codec", "pin-project", @@ -10098,7 +9102,7 @@ dependencies = [ "fork-tree", "futures", "futures-timer", - "libp2p 0.51.3", + "libp2p", "log", "lru", "mockall", @@ -10134,7 +9138,7 @@ dependencies = [ "async-trait", "futures", "futures-timer", - "libp2p 0.51.3", + "libp2p", "log", "parking_lot 0.12.1", "rand 0.8.5", @@ -10164,7 +9168,7 @@ version = "0.10.0-dev" dependencies = [ "array-bytes 4.2.0", "futures", - "libp2p 0.51.3", + "libp2p", "log", "parity-scale-codec", "sc-network", @@ -10187,7 +9191,7 @@ dependencies = [ "hyper", "hyper-rustls 0.24.0", "lazy_static", - "libp2p 0.51.3", + "libp2p", "num_cpus", "once_cell", "parity-scale-codec", @@ -10534,7 +9538,7 @@ version = "4.0.0-dev" dependencies = [ "chrono", "futures", - "libp2p 0.51.3", + "libp2p", "log", "parking_lot 0.12.1", "pin-project", @@ -10727,16 +9731,6 @@ version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1792db035ce95be60c3f8853017b3999209281c24e2ba5bc8e59bf97a0c590c1" -[[package]] -name = "sct" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b362b83898e0e69f38515b82ee15aa80636befe47c3b6d3d89a911e78fc228ce" -dependencies = [ - "ring", - "untrusted", -] - [[package]] name = "sct" version = "0.7.0" @@ -10747,42 +9741,16 @@ dependencies = [ "untrusted", ] -[[package]] -name = "sdp" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d22a5ef407871893fd72b4562ee15e4742269b173959db4b8df6f538c414e13" -dependencies = [ - "rand 0.8.5", - "substring", - "thiserror", - "url", -] - -[[package]] -name = "sec1" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3be24c1842290c45df0a7bf069e0c268a747ad05a192f2fd7dcfdbc1cba40928" -dependencies = [ - "base16ct 0.1.1", - "der 0.6.1", - "generic-array 0.14.7", - "pkcs8 0.9.0", - "subtle", - "zeroize", -] - [[package]] name = "sec1" version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f0aec48e813d6b90b15f0b8948af3c63483992dee44c03e9930b3eebdabe046e" dependencies = [ - "base16ct 0.2.0", - "der 0.7.6", + "base16ct", + "der", "generic-array 0.14.7", - "pkcs8 0.10.2", + "pkcs8", "subtle", "zeroize", ] @@ -10870,6 +9838,12 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" +[[package]] +name = "send_wrapper" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd0b0ec5f1c1ca621c432a25813d8d60c88abe6d3e08a3eb9cf37d97a0fe3d73" + [[package]] name = "serde" version = "1.0.163" @@ -10923,17 +9897,6 @@ dependencies = [ "opaque-debug 0.3.0", ] -[[package]] -name = "sha1" -version = "0.10.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f04293dc80c3993519f2d7f6f511707ee7094fe0c6d3406feb330cdb3540eba3" -dependencies = [ - "cfg-if", - "cpufeatures", - "digest 0.10.7", -] - [[package]] name = "sha2" version = "0.8.2" @@ -11009,10 +9972,6 @@ name = "signature" version = "1.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "74233d3b3b2f6d4b006dc19dee745e73e2a6bfb6f93607cd3b02bd5b00797d7c" -dependencies = [ - "digest 0.10.7", - "rand_core 0.6.4", -] [[package]] name = "signature" @@ -11076,7 +10035,7 @@ version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5ccba027ba85743e09d15c03296797cad56395089b832b48b5a5217880f57733" dependencies = [ - "aes-gcm 0.9.4", + "aes-gcm", "blake2", "chacha20poly1305", "curve25519-dalek 4.0.0-rc.1", @@ -11115,7 +10074,6 @@ checksum = "41d1c5305e39e09653383c2c7244f2f78b3bcae37cf50c64cb4789c9f5096ec2" dependencies = [ "base64 0.13.1", "bytes", - "flate2", "futures", "http", "httparse", @@ -12098,23 +11056,13 @@ checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" [[package]] name = "spinners" -version = "4.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08615eea740067d9899969bc2891c68a19c315cb1f66640af9a9ecb91b13bcab" -dependencies = [ - "lazy_static", - "maplit", - "strum", -] - -[[package]] -name = "spki" -version = "0.6.0" +version = "4.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67cf02bbac7a337dc36e4f5a693db6c21e7863f45070f7064577eb4367a3212b" +checksum = "08615eea740067d9899969bc2891c68a19c315cb1f66640af9a9ecb91b13bcab" dependencies = [ - "base64ct", - "der 0.6.1", + "lazy_static", + "maplit", + "strum", ] [[package]] @@ -12124,7 +11072,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d1e996ef02c474957d681f1b05213dfb0abab947b446a62d37770b23500184a" dependencies = [ "base64ct", - "der 0.7.6", + "der", ] [[package]] @@ -12210,25 +11158,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "stun" -version = "0.4.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7e94b1ec00bad60e6410e058b52f1c66de3dc5fe4d62d09b3e52bb7d3b73e25" -dependencies = [ - "base64 0.13.1", - "crc", - "lazy_static", - "md-5", - "rand 0.8.5", - "ring", - "subtle", - "thiserror", - "tokio", - "url", - "webrtc-util", -] - [[package]] name = "subkey" version = "3.0.0" @@ -12526,15 +11455,6 @@ dependencies = [ "wasm-opt", ] -[[package]] -name = "substring" -version = "1.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42ee6433ecef213b2e72f587ef64a2f5943e7cd16fbd82dbe8bc07486c534c86" -dependencies = [ - "autocfg", -] - [[package]] name = "subtle" version = "2.4.1" @@ -12719,33 +11639,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "time" -version = "0.3.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f3403384eaacbca9923fa06940178ac13e4edb725486d70e8e15881d0c836cc" -dependencies = [ - "itoa", - "serde", - "time-core", - "time-macros", -] - -[[package]] -name = "time-core" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7300fbefb4dadc1af235a9cef3737cea692a9d97e1b9cbcd4ebdae6f8868e6fb" - -[[package]] -name = "time-macros" -version = "0.2.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "372950940a5f07bf38dbe211d7283c9e6d7327df53794992d293e534c733d09b" -dependencies = [ - "time-core", -] - [[package]] name = "tiny-bip39" version = "1.0.0" @@ -12848,7 +11741,7 @@ checksum = "c43ee83903113e03984cb9e5cebe6c04a5116269e900e3ddba8f068a62adda59" dependencies = [ "rustls 0.20.8", "tokio", - "webpki 0.22.0", + "webpki", ] [[package]] @@ -13253,25 +12146,6 @@ version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f4f195fd851901624eee5a58c4bb2b4f06399148fcd0ed336e6f1cb60a9881df" -[[package]] -name = "turn" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4712ee30d123ec7ae26d1e1b218395a16c87cdbaf4b3925d170d684af62ea5e8" -dependencies = [ - "async-trait", - "base64 0.13.1", - "futures", - "log", - "md-5", - "rand 0.8.5", - "ring", - "stun", - "thiserror", - "tokio", - "webrtc-util", -] - [[package]] name = "twox-hash" version = "1.6.3" @@ -13351,16 +12225,6 @@ dependencies = [ "subtle", ] -[[package]] -name = "universal-hash" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc1de2c688dc15305988b563c3854064043356019f97a4b46276fe734c4f07ea" -dependencies = [ - "crypto-common", - "subtle", -] - [[package]] name = "unsigned-varint" version = "0.7.1" @@ -13396,15 +12260,6 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" -[[package]] -name = "uuid" -version = "1.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "345444e32442451b267fc254ae85a209c64be56d2890e601a0c37ff0c3c5ecd2" -dependencies = [ - "getrandom 0.2.9", -] - [[package]] name = "valuable" version = "0.1.0" @@ -13462,15 +12317,6 @@ dependencies = [ "libc", ] -[[package]] -name = "waitgroup" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1f50000a783467e6c0200f9d10642f4bc424e39efc1b770203e88b488f79292" -dependencies = [ - "atomic-waker", -] - [[package]] name = "waker-fn" version = "1.1.0" @@ -13938,16 +12784,6 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "webpki" -version = "0.21.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8e38c0608262c46d4a56202ebabdeb094cef7e560ca7a226c6bf055188aa4ea" -dependencies = [ - "ring", - "untrusted", -] - [[package]] name = "webpki" version = "0.22.0" @@ -13964,7 +12800,7 @@ version = "0.22.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6c71e40d7d2c34a5106301fb632274ca37242cd0c9d3e64dbece371a40a2d87" dependencies = [ - "webpki 0.22.0", + "webpki", ] [[package]] @@ -13976,215 +12812,6 @@ dependencies = [ "rustls-webpki", ] -[[package]] -name = "webrtc" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d3bc9049bdb2cea52f5fd4f6f728184225bdb867ed0dc2410eab6df5bdd67bb" -dependencies = [ - "arc-swap", - "async-trait", - "bytes", - "hex", - "interceptor", - "lazy_static", - "log", - "rand 0.8.5", - "rcgen 0.9.3", - "regex", - "ring", - "rtcp", - "rtp", - "rustls 0.19.1", - "sdp", - "serde", - "serde_json", - "sha2 0.10.7", - "stun", - "thiserror", - "time 0.3.21", - "tokio", - "turn", - "url", - "waitgroup", - "webrtc-data", - "webrtc-dtls", - "webrtc-ice", - "webrtc-mdns", - "webrtc-media", - "webrtc-sctp", - "webrtc-srtp", - "webrtc-util", -] - -[[package]] -name = "webrtc-data" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ef36a4d12baa6e842582fe9ec16a57184ba35e1a09308307b67d43ec8883100" -dependencies = [ - "bytes", - "derive_builder", - "log", - "thiserror", - "tokio", - "webrtc-sctp", - "webrtc-util", -] - -[[package]] -name = "webrtc-dtls" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "942be5bd85f072c3128396f6e5a9bfb93ca8c1939ded735d177b7bcba9a13d05" -dependencies = [ - "aes 0.6.0", - "aes-gcm 0.10.2", - "async-trait", - "bincode", - "block-modes", - "byteorder", - "ccm", - "curve25519-dalek 3.2.0", - "der-parser 8.2.0", - "elliptic-curve 0.12.3", - "hkdf", - "hmac 0.12.1", - "log", - "oid-registry 0.6.1", - "p256", - "p384", - "rand 0.8.5", - "rand_core 0.6.4", - "rcgen 0.9.3", - "ring", - "rustls 0.19.1", - "sec1 0.3.0", - "serde", - "sha1", - "sha2 0.10.7", - "signature 1.6.4", - "subtle", - "thiserror", - "tokio", - "webpki 0.21.4", - "webrtc-util", - "x25519-dalek 2.0.0-pre.1", - "x509-parser 0.13.2", -] - -[[package]] -name = "webrtc-ice" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "465a03cc11e9a7d7b4f9f99870558fe37a102b65b93f8045392fef7c67b39e80" -dependencies = [ - "arc-swap", - "async-trait", - "crc", - "log", - "rand 0.8.5", - "serde", - "serde_json", - "stun", - "thiserror", - "tokio", - "turn", - "url", - "uuid", - "waitgroup", - "webrtc-mdns", - "webrtc-util", -] - -[[package]] -name = "webrtc-mdns" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f08dfd7a6e3987e255c4dbe710dde5d94d0f0574f8a21afa95d171376c143106" -dependencies = [ - "log", - "socket2 0.4.9", - "thiserror", - "tokio", - "webrtc-util", -] - -[[package]] -name = "webrtc-media" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f72e1650a8ae006017d1a5280efb49e2610c19ccc3c0905b03b648aee9554991" -dependencies = [ - "byteorder", - "bytes", - "rand 0.8.5", - "rtp", - "thiserror", -] - -[[package]] -name = "webrtc-sctp" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d47adcd9427eb3ede33d5a7f3424038f63c965491beafcc20bc650a2f6679c0" -dependencies = [ - "arc-swap", - "async-trait", - "bytes", - "crc", - "log", - "rand 0.8.5", - "thiserror", - "tokio", - "webrtc-util", -] - -[[package]] -name = "webrtc-srtp" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6183edc4c1c6c0175f8812eefdce84dfa0aea9c3ece71c2bf6ddd3c964de3da5" -dependencies = [ - "aead 0.4.3", - "aes 0.7.5", - "aes-gcm 0.9.4", - "async-trait", - "byteorder", - "bytes", - "ctr 0.8.0", - "hmac 0.11.0", - "log", - "rtcp", - "rtp", - "sha-1", - "subtle", - "thiserror", - "tokio", - "webrtc-util", -] - -[[package]] -name = "webrtc-util" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93f1db1727772c05cf7a2cfece52c3aca8045ca1e176cd517d323489aa3c6d87" -dependencies = [ - "async-trait", - "bitflags", - "bytes", - "cc", - "ipnet", - "lazy_static", - "libc", - "log", - "nix 0.24.3", - "rand 0.8.5", - "thiserror", - "tokio", - "winapi", -] - [[package]] name = "which" version = "4.4.0" @@ -14480,54 +13107,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "x25519-dalek" -version = "2.0.0-pre.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5da623d8af10a62342bcbbb230e33e58a63255a58012f8653c578e54bab48df" -dependencies = [ - "curve25519-dalek 3.2.0", - "rand_core 0.6.4", - "zeroize", -] - -[[package]] -name = "x509-parser" -version = "0.13.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fb9bace5b5589ffead1afb76e43e34cff39cd0f3ce7e170ae0c29e53b88eb1c" -dependencies = [ - "asn1-rs 0.3.1", - "base64 0.13.1", - "data-encoding", - "der-parser 7.0.0", - "lazy_static", - "nom", - "oid-registry 0.4.0", - "ring", - "rusticata-macros", - "thiserror", - "time 0.3.21", -] - -[[package]] -name = "x509-parser" -version = "0.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0ecbeb7b67ce215e40e3cc7f2ff902f94a223acf44995934763467e7b1febc8" -dependencies = [ - "asn1-rs 0.5.2", - "base64 0.13.1", - "data-encoding", - "der-parser 8.2.0", - "lazy_static", - "nom", - "oid-registry 0.6.1", - "rusticata-macros", - "thiserror", - "time 0.3.21", -] - [[package]] name = "xattr" version = "0.2.3" @@ -14557,15 +13136,6 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09041cd90cf85f7f8b2df60c646f853b7f535ce68f85244eb6731cf89fa498ec" -[[package]] -name = "yasna" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e17bb3549cc1321ae1296b9cdc2698e2b6cb1992adfa19a8c72e5b7a738f44cd" -dependencies = [ - "time 0.3.21", -] - [[package]] name = "zeroize" version = "1.6.0" diff --git a/Cargo.toml b/Cargo.toml index 428772eccbba6..f5bfedaeb819c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -336,8 +336,4 @@ inherits = "release" # https://doc.rust-lang.org/rustc/linker-plugin-lto.html lto = "fat" # https://doc.rust-lang.org/rustc/codegen-options/index.html#codegen-units -codegen-units = 1 - -# FIXME: remove -[patch.crates-io] -libp2p = { version = "0.52.0", git = "https://github.com/melekes/rust-libp2p.git", branch = "anton/upgrade-webrtc-to-0.8.0" } \ No newline at end of file +codegen-units = 1 \ No newline at end of file diff --git a/client/authority-discovery/Cargo.toml b/client/authority-discovery/Cargo.toml index da9a232714b09..d95a40f65313e 100644 --- a/client/authority-discovery/Cargo.toml +++ b/client/authority-discovery/Cargo.toml @@ -21,7 +21,7 @@ codec = { package = "parity-scale-codec", version = "3.2.2", default-features = futures = "0.3.21" futures-timer = "3.0.1" ip_network = "0.4.1" -libp2p = { version = "0.51.3", features = ["kad", "ed25519"] } +libp2p = { version = "0.52.0", features = ["kad", "ed25519"] } multihash = { version = "0.17.0", default-features = false, features = ["std", "sha2"] } log = "0.4.17" prost = "0.11" diff --git a/client/network-gossip/Cargo.toml b/client/network-gossip/Cargo.toml index a3616b403aca7..0e7dc6099d271 100644 --- a/client/network-gossip/Cargo.toml +++ b/client/network-gossip/Cargo.toml @@ -17,7 +17,7 @@ targets = ["x86_64-unknown-linux-gnu"] ahash = "0.8.2" futures = "0.3.21" futures-timer = "3.0.1" -libp2p = "0.51.3" +libp2p = "0.52.0" log = "0.4.17" lru = "0.10.0" tracing = "0.1.29" diff --git a/client/network/statement/Cargo.toml b/client/network/statement/Cargo.toml index 0b0782aa1ac87..117c99414acfa 100644 --- a/client/network/statement/Cargo.toml +++ b/client/network/statement/Cargo.toml @@ -17,7 +17,7 @@ array-bytes = "4.1" async-channel = "1.8.0" codec = { package = "parity-scale-codec", version = "3.2.2", features = ["derive"] } futures = "0.3.21" -libp2p = "0.51.3" +libp2p = "0.52.0" log = "0.4.17" pin-project = "1.0.12" prometheus-endpoint = { package = "substrate-prometheus-endpoint", version = "0.10.0-dev", path = "../../../utils/prometheus" } diff --git a/client/network/sync/Cargo.toml b/client/network/sync/Cargo.toml index d603c5c263479..de9522c1adef7 100644 --- a/client/network/sync/Cargo.toml +++ b/client/network/sync/Cargo.toml @@ -22,7 +22,7 @@ async-trait = "0.1.58" codec = { package = "parity-scale-codec", version = "3.2.2", features = ["derive"] } futures = "0.3.21" futures-timer = "3.0.2" -libp2p = "0.51.3" +libp2p = "0.52.0" log = "0.4.17" lru = "0.10.0" mockall = "0.11.3" diff --git a/client/network/test/Cargo.toml b/client/network/test/Cargo.toml index 4a1adbb94f1ee..a1ab5d38db3c7 100644 --- a/client/network/test/Cargo.toml +++ b/client/network/test/Cargo.toml @@ -17,7 +17,7 @@ tokio = "1.22.0" async-trait = "0.1.57" futures = "0.3.21" futures-timer = "3.0.1" -libp2p = "0.51.3" +libp2p = "0.52.0" log = "0.4.17" parking_lot = "0.12.1" rand = "0.8.5" diff --git a/client/network/transactions/Cargo.toml b/client/network/transactions/Cargo.toml index 002a332f356b2..b15ad879b8695 100644 --- a/client/network/transactions/Cargo.toml +++ b/client/network/transactions/Cargo.toml @@ -16,7 +16,7 @@ targets = ["x86_64-unknown-linux-gnu"] array-bytes = "4.1" codec = { package = "parity-scale-codec", version = "3.2.2", features = ["derive"] } futures = "0.3.21" -libp2p = "0.51.3" +libp2p = "0.52.0" log = "0.4.17" prometheus-endpoint = { package = "substrate-prometheus-endpoint", version = "0.10.0-dev", path = "../../../utils/prometheus" } sc-network = { version = "0.10.0-dev", path = "../" } diff --git a/client/offchain/Cargo.toml b/client/offchain/Cargo.toml index f32941418dc09..9a1c22d302aaa 100644 --- a/client/offchain/Cargo.toml +++ b/client/offchain/Cargo.toml @@ -21,7 +21,7 @@ futures = "0.3.21" futures-timer = "3.0.2" hyper = { version = "0.14.16", features = ["stream", "http2"] } hyper-rustls = { version = "0.24.0", features = ["http2"] } -libp2p = "0.51.3" +libp2p = "0.52.0" num_cpus = "1.13" once_cell = "1.8" parking_lot = "0.12.1" diff --git a/client/telemetry/Cargo.toml b/client/telemetry/Cargo.toml index f138557c8c229..2fcad2094d7e2 100644 --- a/client/telemetry/Cargo.toml +++ b/client/telemetry/Cargo.toml @@ -16,7 +16,7 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] chrono = "0.4.19" futures = "0.3.21" -libp2p = { version = "0.51.3", features = ["dns", "tcp", "tokio", "wasm-ext", "websocket"] } +libp2p = { version = "0.52.0", features = ["dns", "tcp", "tokio", "wasm-ext", "websocket"] } log = "0.4.17" parking_lot = "0.12.1" pin-project = "1.0.12" From 45ff8139617aed01b7800f0747559744c8b07f6d Mon Sep 17 00:00:00 2001 From: Anton Kaliaev Date: Wed, 21 Jun 2023 17:42:28 +0300 Subject: [PATCH 04/42] ToSwarm, FromBehaviour, ToBehaviour also LocalProtocolsChange and RemoteProtocolsChange --- client/network/src/discovery.rs | 73 +++++----- client/network/src/protocol.rs | 1 + .../src/protocol/notifications/handler.rs | 91 ++++++------- client/network/src/request_responses.rs | 125 ++++++++---------- client/network/src/service.rs | 106 +++++++-------- 5 files changed, 176 insertions(+), 220 deletions(-) diff --git a/client/network/src/discovery.rs b/client/network/src/discovery.rs index 6db265d70dedd..f46ad8add0b8e 100644 --- a/client/network/src/discovery.rs +++ b/client/network/src/discovery.rs @@ -317,7 +317,7 @@ impl DiscoveryBehaviour { pub fn add_known_address(&mut self, peer_id: PeerId, addr: Multiaddr) { let addrs_list = self.ephemeral_addresses.entry(peer_id).or_default(); if addrs_list.contains(&addr) { - return; + return } if let Some(k) = self.kademlia.as_mut() { @@ -345,7 +345,7 @@ impl DiscoveryBehaviour { target: "sub-libp2p", "Ignoring self-reported non-global address {} from {}.", addr, peer_id ); - return; + return } if let Some(matching_protocol) = supported_protocols @@ -428,9 +428,8 @@ impl DiscoveryBehaviour { let ip = match addr.iter().next() { Some(Protocol::Ip4(ip)) => IpNetwork::from(ip), Some(Protocol::Ip6(ip)) => IpNetwork::from(ip), - Some(Protocol::Dns(_)) | Some(Protocol::Dns4(_)) | Some(Protocol::Dns6(_)) => { - return true - }, + Some(Protocol::Dns(_)) | Some(Protocol::Dns4(_)) | Some(Protocol::Dns6(_)) => + return true, _ => return false, }; ip.is_global() @@ -666,7 +665,7 @@ impl NetworkBehaviour for DiscoveryBehaviour { ) -> Poll>> { // Immediately process the content of `discovered`. if let Some(ev) = self.pending_events.pop_front() { - return Poll::Ready(ToSwarm::GenerateEvent(ev)); + return Poll::Ready(ToSwarm::GenerateEvent(ev)) } // Poll the stream that fires when we need to start a random Kademlia query. @@ -700,7 +699,7 @@ impl NetworkBehaviour for DiscoveryBehaviour { if actually_started { let ev = DiscoveryOut::RandomKademliaStarted; - return Poll::Ready(ToSwarm::GenerateEvent(ev)); + return Poll::Ready(ToSwarm::GenerateEvent(ev)) } } } @@ -711,18 +710,18 @@ impl NetworkBehaviour for DiscoveryBehaviour { ToSwarm::GenerateEvent(ev) => match ev { KademliaEvent::RoutingUpdated { peer, .. } => { let ev = DiscoveryOut::Discovered(peer); - return Poll::Ready(ToSwarm::GenerateEvent(ev)); + return Poll::Ready(ToSwarm::GenerateEvent(ev)) }, KademliaEvent::UnroutablePeer { peer, .. } => { let ev = DiscoveryOut::UnroutablePeer(peer); - return Poll::Ready(ToSwarm::GenerateEvent(ev)); + return Poll::Ready(ToSwarm::GenerateEvent(ev)) }, KademliaEvent::RoutablePeer { peer, .. } => { let ev = DiscoveryOut::Discovered(peer); - return Poll::Ready(ToSwarm::GenerateEvent(ev)); + return Poll::Ready(ToSwarm::GenerateEvent(ev)) }, - KademliaEvent::PendingRoutablePeer { .. } - | KademliaEvent::InboundRequest { .. } => { + KademliaEvent::PendingRoutablePeer { .. } | + KademliaEvent::InboundRequest { .. } => { // We are not interested in this event at the moment. }, KademliaEvent::OutboundQueryProgressed { @@ -788,7 +787,7 @@ impl NetworkBehaviour for DiscoveryBehaviour { // We always need to remove the record to not leak any data! if let Some(record) = self.records_to_publish.remove(&id) { if cache_candidates.is_empty() { - continue; + continue } // Put the record to the `cache_candidates` that are nearest to @@ -802,7 +801,7 @@ impl NetworkBehaviour for DiscoveryBehaviour { } } - continue; + continue }, Err(e @ libp2p::kad::GetRecordError::NotFound { .. }) => { trace!( @@ -827,7 +826,7 @@ impl NetworkBehaviour for DiscoveryBehaviour { ) }, }; - return Poll::Ready(ToSwarm::GenerateEvent(ev)); + return Poll::Ready(ToSwarm::GenerateEvent(ev)) }, KademliaEvent::OutboundQueryProgressed { result: QueryResult::PutRecord(res), @@ -835,9 +834,8 @@ impl NetworkBehaviour for DiscoveryBehaviour { .. } => { let ev = match res { - Ok(ok) => { - DiscoveryOut::ValuePut(ok.key, stats.duration().unwrap_or_default()) - }, + Ok(ok) => + DiscoveryOut::ValuePut(ok.key, stats.duration().unwrap_or_default()), Err(e) => { debug!( target: "sub-libp2p", @@ -850,7 +848,7 @@ impl NetworkBehaviour for DiscoveryBehaviour { ) }, }; - return Poll::Ready(ToSwarm::GenerateEvent(ev)); + return Poll::Ready(ToSwarm::GenerateEvent(ev)) }, KademliaEvent::OutboundQueryProgressed { result: QueryResult::RepublishRecord(res), @@ -873,15 +871,12 @@ impl NetworkBehaviour for DiscoveryBehaviour { }, }, ToSwarm::Dial { opts } => return Poll::Ready(ToSwarm::Dial { opts }), - ToSwarm::NotifyHandler { peer_id, handler, event } => { - return Poll::Ready(ToSwarm::NotifyHandler { peer_id, handler, event }) - }, - ToSwarm::ReportObservedAddr { address, score } => { - return Poll::Ready(ToSwarm::ReportObservedAddr { address, score }) - }, - ToSwarm::CloseConnection { peer_id, connection } => { - return Poll::Ready(ToSwarm::CloseConnection { peer_id, connection }) - }, + ToSwarm::NotifyHandler { peer_id, handler, event } => + return Poll::Ready(ToSwarm::NotifyHandler { peer_id, handler, event }), + ToSwarm::ReportObservedAddr { address, score } => + return Poll::Ready(ToSwarm::ReportObservedAddr { address, score }), + ToSwarm::CloseConnection { peer_id, connection } => + return Poll::Ready(ToSwarm::CloseConnection { peer_id, connection }), } } @@ -892,13 +887,13 @@ impl NetworkBehaviour for DiscoveryBehaviour { ToSwarm::GenerateEvent(event) => match event { mdns::Event::Discovered(list) => { if self.num_connections >= self.discovery_only_if_under_num { - continue; + continue } self.pending_events .extend(list.map(|(peer_id, _)| DiscoveryOut::Discovered(peer_id))); if let Some(ev) = self.pending_events.pop_front() { - return Poll::Ready(ToSwarm::GenerateEvent(ev)); + return Poll::Ready(ToSwarm::GenerateEvent(ev)) } }, mdns::Event::Expired(_) => {}, @@ -909,12 +904,10 @@ impl NetworkBehaviour for DiscoveryBehaviour { ToSwarm::NotifyHandler { event, .. } => match event {}, /* `event` is an */ // enum with no // variant - ToSwarm::ReportObservedAddr { address, score } => { - return Poll::Ready(ToSwarm::ReportObservedAddr { address, score }) - }, - ToSwarm::CloseConnection { peer_id, connection } => { - return Poll::Ready(ToSwarm::CloseConnection { peer_id, connection }) - }, + ToSwarm::ReportObservedAddr { address, score } => + return Poll::Ready(ToSwarm::ReportObservedAddr { address, score }), + ToSwarm::CloseConnection { peer_id, connection } => + return Poll::Ready(ToSwarm::CloseConnection { peer_id, connection }), } } } @@ -1041,8 +1034,8 @@ mod tests { match e { SwarmEvent::Behaviour(behavior) => { match behavior { - DiscoveryOut::UnroutablePeer(other) - | DiscoveryOut::Discovered(other) => { + DiscoveryOut::UnroutablePeer(other) | + DiscoveryOut::Discovered(other) => { // Call `add_self_reported_address` to simulate identify // happening. let addr = swarms @@ -1082,12 +1075,12 @@ mod tests { // ignore non Behaviour events _ => {}, } - continue 'polling; + continue 'polling }, _ => {}, } } - break; + break } if to_discover.iter().all(|l| l.is_empty()) { diff --git a/client/network/src/protocol.rs b/client/network/src/protocol.rs index 3591601aa2576..320466e29ee38 100644 --- a/client/network/src/protocol.rs +++ b/client/network/src/protocol.rs @@ -353,6 +353,7 @@ pub enum CustomMessageOutcome { impl NetworkBehaviour for Protocol { type ConnectionHandler = ::ConnectionHandler; + type ToSwarm = CustomMessageOutcome; fn handle_established_inbound_connection( &mut self, diff --git a/client/network/src/protocol/notifications/handler.rs b/client/network/src/protocol/notifications/handler.rs index a1120ea5f4e36..fa6319a5ae878 100644 --- a/client/network/src/protocol/notifications/handler.rs +++ b/client/network/src/protocol/notifications/handler.rs @@ -435,6 +435,8 @@ pub enum NotifsHandlerError { } impl ConnectionHandler for NotifsHandler { + type FromBehaviour = NotifsHandlerIn; + type ToBehaviour = NotifsHandlerOut; type Error = NotifsHandlerError; type InboundProtocol = UpgradeCollec; type OutboundProtocol = NotificationsOut; @@ -486,13 +488,13 @@ impl ConnectionHandler for NotifsHandler { // in mind that it is invalid for the remote to open multiple such // substreams, and therefore sending a "RST" is the most correct thing // to do. - return; + return }, - State::Opening { ref mut in_substream, .. } - | State::Open { ref mut in_substream, .. } => { + State::Opening { ref mut in_substream, .. } | + State::Open { ref mut in_substream, .. } => { if in_substream.is_some() { // Same remark as above. - return; + return } // Create `handshake_message` on a separate line to be sure that the @@ -507,8 +509,8 @@ impl ConnectionHandler for NotifsHandler { let (new_open, protocol_index) = (outbound.protocol, outbound.info); match self.protocols[protocol_index].state { - State::Closed { ref mut pending_opening } - | State::OpenDesiredByRemote { ref mut pending_opening, .. } => { + State::Closed { ref mut pending_opening } | + State::OpenDesiredByRemote { ref mut pending_opening, .. } => { debug_assert!(*pending_opening); *pending_opening = false; }, @@ -547,12 +549,14 @@ impl ConnectionHandler for NotifsHandler { } }, ConnectionEvent::AddressChange(_address_change) => {}, + ConnectionEvent::LocalProtocolsChange(_protocols_change) => {}, + ConnectionEvent::RemoteProtocolsChange(_protocols_change) => {}, ConnectionEvent::DialUpgradeError(dial_upgrade_error) => match self.protocols [dial_upgrade_error.info] .state { - State::Closed { ref mut pending_opening } - | State::OpenDesiredByRemote { ref mut pending_opening, .. } => { + State::Closed { ref mut pending_opening } | + State::OpenDesiredByRemote { ref mut pending_opening, .. } => { debug_assert!(*pending_opening); *pending_opening = false; }, @@ -667,7 +671,7 @@ impl ConnectionHandler for NotifsHandler { fn connection_keep_alive(&self) -> KeepAlive { // `Yes` if any protocol has some activity. if self.protocols.iter().any(|p| !matches!(p.state, State::Closed { .. })) { - return KeepAlive::Yes; + return KeepAlive::Yes } // A grace period of `INITIAL_KEEPALIVE_TIME` must be given to leave time for the remote @@ -687,7 +691,7 @@ impl ConnectionHandler for NotifsHandler { >, > { if let Some(ev) = self.events_queue.pop_front() { - return Poll::Ready(ev); + return Poll::Ready(ev) } // For each open substream, try send messages from `notifications_sink_rx` to the @@ -702,11 +706,10 @@ impl ConnectionHandler for NotifsHandler { // available in `notifications_sink_rx`. This avoids waking up the task when // 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)) => { + Poll::Ready(Some(&NotificationsSinkMessage::ForceClose)) => return Poll::Ready(ConnectionHandlerEvent::Close( NotifsHandlerError::SyncNotificationsClogged, - )) - }, + )), Poll::Ready(Some(&NotificationsSinkMessage::Notification { .. })) => {}, Poll::Ready(None) | Poll::Pending => break, } @@ -720,15 +723,14 @@ impl ConnectionHandler for NotifsHandler { // Now that the substream is ready for a message, grab what to send. let message = match notifications_sink_rx.poll_next_unpin(cx) { - Poll::Ready(Some(NotificationsSinkMessage::Notification { message })) => { - message - }, - Poll::Ready(Some(NotificationsSinkMessage::ForceClose)) - | Poll::Ready(None) - | Poll::Pending => { + Poll::Ready(Some(NotificationsSinkMessage::Notification { message })) => + message, + Poll::Ready(Some(NotificationsSinkMessage::ForceClose)) | + Poll::Ready(None) | + Poll::Pending => { // Should never be reached, as per `poll_peek` above. debug_assert!(false); - break; + break }, }; @@ -753,15 +755,15 @@ impl ConnectionHandler for NotifsHandler { Poll::Ready(Err(_)) => { *out_substream = None; let event = NotifsHandlerOut::CloseDesired { protocol_index }; - return Poll::Ready(ConnectionHandlerEvent::Custom(event)); + return Poll::Ready(ConnectionHandlerEvent::Custom(event)) }, }; }, - State::Closed { .. } - | State::Opening { .. } - | State::Open { out_substream: None, .. } - | State::OpenDesiredByRemote { .. } => {}, + State::Closed { .. } | + State::Opening { .. } | + State::Open { out_substream: None, .. } | + State::OpenDesiredByRemote { .. } => {}, } } @@ -770,22 +772,21 @@ impl ConnectionHandler for NotifsHandler { // Inbound substreams being closed is always tolerated, except for the // `OpenDesiredByRemote` state which might need to be switched back to `Closed`. match &mut self.protocols[protocol_index].state { - State::Closed { .. } - | State::Open { in_substream: None, .. } - | State::Opening { in_substream: None } => {}, + State::Closed { .. } | + State::Open { in_substream: None, .. } | + State::Opening { in_substream: None } => {}, - State::Open { in_substream: in_substream @ Some(_), .. } => { + State::Open { in_substream: in_substream @ Some(_), .. } => match Stream::poll_next(Pin::new(in_substream.as_mut().unwrap()), cx) { Poll::Pending => {}, Poll::Ready(Some(Ok(message))) => { let event = NotifsHandlerOut::Notification { protocol_index, message }; - return Poll::Ready(ConnectionHandlerEvent::Custom(event)); + return Poll::Ready(ConnectionHandlerEvent::Custom(event)) }, Poll::Ready(None) | Poll::Ready(Some(Err(_))) => *in_substream = None, - } - }, + }, - State::OpenDesiredByRemote { in_substream, pending_opening } => { + State::OpenDesiredByRemote { in_substream, pending_opening } => match NotificationsInSubstream::poll_process(Pin::new(in_substream), cx) { Poll::Pending => {}, Poll::Ready(Ok(void)) => match void {}, @@ -794,12 +795,11 @@ impl ConnectionHandler for NotifsHandler { State::Closed { pending_opening: *pending_opening }; return Poll::Ready(ConnectionHandlerEvent::Custom( NotifsHandlerOut::CloseDesired { protocol_index }, - )); + )) }, - } - }, + }, - State::Opening { in_substream: in_substream @ Some(_), .. } => { + State::Opening { in_substream: in_substream @ Some(_), .. } => match NotificationsInSubstream::poll_process( Pin::new(in_substream.as_mut().unwrap()), cx, @@ -807,8 +807,7 @@ impl ConnectionHandler for NotifsHandler { Poll::Pending => {}, Poll::Ready(Ok(void)) => match void {}, Poll::Ready(Err(_)) => *in_substream = None, - } - }, + }, } } @@ -904,13 +903,12 @@ pub mod tests { let substream = if let Some(info) = self.connections.get_mut(&(peer, set)) { info } else { - return None; + return None }; futures::future::poll_fn(|cx| match substream.notifications.poll_next_unpin(cx) { - Poll::Ready(Some(NotificationsSinkMessage::Notification { message })) => { - Poll::Ready(Some(message)) - }, + Poll::Ready(Some(NotificationsSinkMessage::Notification { message })) => + Poll::Ready(Some(message)), Poll::Pending => Poll::Ready(None), Poll::Ready(Some(NotificationsSinkMessage::ForceClose)) | Poll::Ready(None) => { panic!("sink closed") @@ -990,9 +988,8 @@ pub mod tests { ) -> Poll> { match self.rx.poll_recv(cx) { Poll::Ready(Some(data)) => self.rx_buffer.extend_from_slice(&data), - Poll::Ready(None) => { - return Poll::Ready(Err(std::io::ErrorKind::UnexpectedEof.into())) - }, + Poll::Ready(None) => + return Poll::Ready(Err(std::io::ErrorKind::UnexpectedEof.into())), _ => {}, } @@ -1001,7 +998,7 @@ pub mod tests { buf[..nsize].copy_from_slice(&data[..]); if nsize > 0 { - return Poll::Ready(Ok(nsize)); + return Poll::Ready(Ok(nsize)) } Poll::Pending diff --git a/client/network/src/request_responses.rs b/client/network/src/request_responses.rs index ee9e9d988bea2..010ab1fadbe56 100644 --- a/client/network/src/request_responses.rs +++ b/client/network/src/request_responses.rs @@ -340,9 +340,7 @@ impl RequestResponsesBehaviour { match protocols.entry(protocol.name) { Entry::Vacant(e) => e.insert((rq_rp, protocol.inbound_queue)), - Entry::Occupied(e) => { - return Err(RegisterError::DuplicateProtocol(e.key().clone())) - }, + Entry::Occupied(e) => return Err(RegisterError::DuplicateProtocol(e.key().clone())), }; } @@ -472,18 +470,17 @@ impl NetworkBehaviour for RequestResponsesBehaviour { fn on_swarm_event(&mut self, event: FromSwarm) { match event { - FromSwarm::ConnectionEstablished(e) => { + FromSwarm::ConnectionEstablished(e) => for (p, _) in self.protocols.values_mut() { NetworkBehaviour::on_swarm_event(p, FromSwarm::ConnectionEstablished(e)); - } - }, + }, FromSwarm::ConnectionClosed(ConnectionClosed { peer_id, connection_id, endpoint, handler, remaining_established, - }) => { + }) => for (p_name, p_handler) in handler.into_iter() { if let Some((proto, _)) = self.protocols.get_mut(p_name.as_str()) { proto.on_swarm_event(FromSwarm::ConnectionClosed(ConnectionClosed { @@ -500,58 +497,47 @@ impl NetworkBehaviour for RequestResponsesBehaviour { p_name, ) } - } - }, - FromSwarm::DialFailure(e) => { + }, + FromSwarm::DialFailure(e) => for (p, _) in self.protocols.values_mut() { NetworkBehaviour::on_swarm_event(p, FromSwarm::DialFailure(e)); - } - }, - FromSwarm::ListenerClosed(e) => { + }, + FromSwarm::ListenerClosed(e) => for (p, _) in self.protocols.values_mut() { NetworkBehaviour::on_swarm_event(p, FromSwarm::ListenerClosed(e)); - } - }, - FromSwarm::ListenFailure(e) => { + }, + FromSwarm::ListenFailure(e) => for (p, _) in self.protocols.values_mut() { NetworkBehaviour::on_swarm_event(p, FromSwarm::ListenFailure(e)); - } - }, - FromSwarm::ListenerError(e) => { + }, + FromSwarm::ListenerError(e) => for (p, _) in self.protocols.values_mut() { NetworkBehaviour::on_swarm_event(p, FromSwarm::ListenerError(e)); - } - }, - FromSwarm::ExpiredExternalAddr(e) => { + }, + FromSwarm::ExpiredExternalAddr(e) => for (p, _) in self.protocols.values_mut() { NetworkBehaviour::on_swarm_event(p, FromSwarm::ExpiredExternalAddr(e)); - } - }, - FromSwarm::NewListener(e) => { + }, + FromSwarm::NewListener(e) => for (p, _) in self.protocols.values_mut() { NetworkBehaviour::on_swarm_event(p, FromSwarm::NewListener(e)); - } - }, - FromSwarm::ExpiredListenAddr(e) => { + }, + FromSwarm::ExpiredListenAddr(e) => for (p, _) in self.protocols.values_mut() { NetworkBehaviour::on_swarm_event(p, FromSwarm::ExpiredListenAddr(e)); - } - }, - FromSwarm::NewExternalAddr(e) => { + }, + FromSwarm::NewExternalAddr(e) => for (p, _) in self.protocols.values_mut() { NetworkBehaviour::on_swarm_event(p, FromSwarm::NewExternalAddr(e)); - } - }, - FromSwarm::AddressChange(e) => { + }, + FromSwarm::AddressChange(e) => for (p, _) in self.protocols.values_mut() { NetworkBehaviour::on_swarm_event(p, FromSwarm::AddressChange(e)); - } - }, - FromSwarm::NewListenAddr(e) => { + }, + FromSwarm::NewListenAddr(e) => for (p, _) in self.protocols.values_mut() { NetworkBehaviour::on_swarm_event(p, FromSwarm::NewListenAddr(e)); - } - }, + }, } } @@ -563,7 +549,7 @@ impl NetworkBehaviour for RequestResponsesBehaviour { ) { let p_name = event.0; if let Some((proto, _)) = self.protocols.get_mut(p_name.as_str()) { - return proto.on_connection_handler_event(peer_id, connection_id, event.1); + return proto.on_connection_handler_event(peer_id, connection_id, event.1) } else { log::warn!( target: "sub-libp2p", @@ -606,7 +592,7 @@ impl NetworkBehaviour for RequestResponsesBehaviour { resp_builder, get_peer_reputation, }); - return Poll::Pending; + return Poll::Pending }, Poll::Ready(reputation) => { // Once we get the reputation we can continue processing the request. @@ -622,7 +608,7 @@ impl NetworkBehaviour for RequestResponsesBehaviour { peer, reputation, ); - continue 'poll_all; + continue 'poll_all } let (tx, rx) = oneshot::channel(); @@ -663,7 +649,7 @@ impl NetworkBehaviour for RequestResponsesBehaviour { // This `continue` makes sure that `pending_responses` gets polled // after we have added the new element. - continue 'poll_all; + continue 'poll_all }, } } @@ -705,7 +691,7 @@ impl NetworkBehaviour for RequestResponsesBehaviour { return Poll::Ready(ToSwarm::GenerateEvent(Event::ReputationChanges { peer, changes: reputation_changes, - })); + })) } } @@ -724,21 +710,18 @@ impl NetworkBehaviour for RequestResponsesBehaviour { "The request-response isn't supposed to start dialing addresses" ); } - return Poll::Ready(ToSwarm::Dial { opts }); + return Poll::Ready(ToSwarm::Dial { opts }) }, - ToSwarm::NotifyHandler { peer_id, handler, event } => { + ToSwarm::NotifyHandler { peer_id, handler, event } => return Poll::Ready(ToSwarm::NotifyHandler { peer_id, handler, event: ((*protocol).to_string(), event), - }) - }, - ToSwarm::ReportObservedAddr { address, score } => { - return Poll::Ready(ToSwarm::ReportObservedAddr { address, score }) - }, - ToSwarm::CloseConnection { peer_id, connection } => { - return Poll::Ready(ToSwarm::CloseConnection { peer_id, connection }) - }, + }), + ToSwarm::ReportObservedAddr { address, score } => + return Poll::Ready(ToSwarm::ReportObservedAddr { address, score }), + ToSwarm::CloseConnection { peer_id, connection } => + return Poll::Ready(ToSwarm::CloseConnection { peer_id, connection }), }; match ev { @@ -768,7 +751,7 @@ impl NetworkBehaviour for RequestResponsesBehaviour { // This `continue` makes sure that `message_request` gets polled // after we have added the new element. - continue 'poll_all; + continue 'poll_all }, // Received a response from a remote to one of our requests. @@ -794,7 +777,7 @@ impl NetworkBehaviour for RequestResponsesBehaviour { request_id, ); debug_assert!(false); - continue; + continue }, }; @@ -805,7 +788,7 @@ impl NetworkBehaviour for RequestResponsesBehaviour { result: delivered, }; - return Poll::Ready(ToSwarm::GenerateEvent(out)); + return Poll::Ready(ToSwarm::GenerateEvent(out)) }, // One of our requests has failed. @@ -840,7 +823,7 @@ impl NetworkBehaviour for RequestResponsesBehaviour { request_id, ); debug_assert!(false); - continue; + continue }, }; @@ -851,7 +834,7 @@ impl NetworkBehaviour for RequestResponsesBehaviour { result: Err(RequestFailure::Network(error)), }; - return Poll::Ready(ToSwarm::GenerateEvent(out)); + return Poll::Ready(ToSwarm::GenerateEvent(out)) }, // An inbound request failed, either while reading the request or due to @@ -867,7 +850,7 @@ impl NetworkBehaviour for RequestResponsesBehaviour { protocol: protocol.clone(), result: Err(ResponseFailure::Network(error)), }; - return Poll::Ready(ToSwarm::GenerateEvent(out)); + return Poll::Ready(ToSwarm::GenerateEvent(out)) }, // A response to an inbound request has been sent. @@ -896,13 +879,13 @@ impl NetworkBehaviour for RequestResponsesBehaviour { result: Ok(arrival_time), }; - return Poll::Ready(ToSwarm::GenerateEvent(out)); + return Poll::Ready(ToSwarm::GenerateEvent(out)) }, }; } } - break Poll::Pending; + break Poll::Pending } } } @@ -934,7 +917,7 @@ pub struct GenericCodec { #[async_trait::async_trait] impl Codec for GenericCodec { - type Protocol = Vec; + type Protocol = String; type Request = Vec; type Response = Result, ()>; @@ -954,7 +937,7 @@ impl Codec for GenericCodec { return Err(io::Error::new( io::ErrorKind::InvalidInput, format!("Request size exceeds limit: {} > {}", length, self.max_request_size), - )); + )) } // Read the payload. @@ -981,9 +964,7 @@ impl Codec for GenericCodec { Ok(l) => l, Err(unsigned_varint::io::ReadError::Io(err)) if matches!(err.kind(), io::ErrorKind::UnexpectedEof) => - { - return Ok(Err(())) - }, + return Ok(Err(())), Err(err) => return Err(io::Error::new(io::ErrorKind::InvalidInput, err)), }; @@ -991,7 +972,7 @@ impl Codec for GenericCodec { return Err(io::Error::new( io::ErrorKind::InvalidInput, format!("Response size exceeds limit: {} > {}", length, self.max_response_size), - )); + )) } // Read the payload. @@ -1211,7 +1192,7 @@ mod tests { }, SwarmEvent::Behaviour(Event::RequestFinished { result, .. }) => { result.unwrap(); - break; + break }, _ => {}, } @@ -1280,7 +1261,7 @@ mod tests { match swarm.select_next_some().await { SwarmEvent::Behaviour(Event::InboundRequest { result, .. }) => { assert!(result.is_ok()); - break; + break }, _ => {}, } @@ -1314,7 +1295,7 @@ mod tests { }, SwarmEvent::Behaviour(Event::RequestFinished { result, .. }) => { assert!(result.is_err()); - break; + break }, _ => {}, } @@ -1483,7 +1464,7 @@ mod tests { num_responses += 1; result.unwrap(); if num_responses == 2 { - break; + break } }, _ => {}, diff --git a/client/network/src/service.rs b/client/network/src/service.rs index f96b4579a6ce5..b4e680941ab66 100644 --- a/client/network/src/service.rs +++ b/client/network/src/service.rs @@ -350,9 +350,8 @@ where match result { Ok(b) => b, - Err(crate::request_responses::RegisterError::DuplicateProtocol(proto)) => { - return Err(Error::DuplicateRequestResponseProtocol { protocol: proto }) - }, + Err(crate::request_responses::RegisterError::DuplicateProtocol(proto)) => + return Err(Error::DuplicateRequestResponseProtocol { protocol: proto }), } }; @@ -519,7 +518,7 @@ where addrs.into_iter().collect() } else { error!(target: "sub-libp2p", "Was not able to get known addresses for {:?}", peer_id); - return None; + return None }; let endpoint = if let Some(e) = @@ -529,7 +528,7 @@ where } else { error!(target: "sub-libp2p", "Found state inconsistency between custom protocol \ and debug information about {:?}", peer_id); - return None; + return None }; Some(( @@ -802,7 +801,7 @@ where fn add_reserved_peer(&self, peer: MultiaddrWithPeerId) -> Result<(), String> { // Make sure the local peer ID is never added to the PSM. if peer.peer_id == self.local_peer_id { - return Err("Local peer ID cannot be added as a reserved peer.".to_string()); + return Err("Local peer ID cannot be added as a reserved peer.".to_string()) } let _ = self @@ -828,7 +827,7 @@ where for (peer_id, addr) in peers_addrs.into_iter() { // Make sure the local peer ID is never added to the PSM. if peer_id == self.local_peer_id { - return Err("Local peer ID cannot be added as a reserved peer.".to_string()); + return Err("Local peer ID cannot be added as a reserved peer.".to_string()) } peers.insert(peer_id); @@ -857,7 +856,7 @@ where for (peer_id, addr) in peers.into_iter() { // Make sure the local peer ID is never added to the PSM. if peer_id == self.local_peer_id { - return Err("Local peer ID cannot be added as a reserved peer.".to_string()); + return Err("Local peer ID cannot be added as a reserved peer.".to_string()) } if !addr.is_empty() { @@ -917,7 +916,7 @@ where "Attempted to send notification on missing or closed substream: {}, {:?}", target, protocol, ); - return; + return } }; @@ -949,7 +948,7 @@ where if let Some(sink) = peers_notifications_sinks.get(&(target, protocol.clone())) { sink.clone() } else { - return Err(NotificationSenderError::Closed); + return Err(NotificationSenderError::Closed) } }; @@ -1228,12 +1227,10 @@ where /// Process the next message coming from the `NetworkService`. fn handle_worker_message(&mut self, msg: ServiceToWorkerMsg) { match msg { - ServiceToWorkerMsg::GetValue(key) => { - self.network_service.behaviour_mut().get_value(key) - }, - ServiceToWorkerMsg::PutValue(key, value) => { - self.network_service.behaviour_mut().put_value(key, value) - }, + ServiceToWorkerMsg::GetValue(key) => + self.network_service.behaviour_mut().get_value(key), + ServiceToWorkerMsg::PutValue(key, value) => + self.network_service.behaviour_mut().put_value(key, value), ServiceToWorkerMsg::SetReservedOnly(reserved_only) => self .network_service .behaviour_mut() @@ -1269,9 +1266,8 @@ where .behaviour_mut() .user_protocol_mut() .remove_set_reserved_peer(protocol, peer_id), - ServiceToWorkerMsg::AddKnownAddress(peer_id, addr) => { - self.network_service.behaviour_mut().add_known_address(peer_id, addr) - }, + ServiceToWorkerMsg::AddKnownAddress(peer_id, addr) => + self.network_service.behaviour_mut().add_known_address(peer_id, addr), ServiceToWorkerMsg::EventStream(sender) => self.event_streams.push(sender), ServiceToWorkerMsg::Request { target, @@ -1324,23 +1320,18 @@ where }, Err(err) => { let reason = match err { - ResponseFailure::Network(InboundFailure::Timeout) => { - Some("timeout") - }, + ResponseFailure::Network(InboundFailure::Timeout) => + Some("timeout"), ResponseFailure::Network(InboundFailure::UnsupportedProtocols) => // `UnsupportedProtocols` is reported for every single // inbound request whenever a request with an unsupported // protocol is received. This is not reported in order to // avoid confusions. - { - None - }, - ResponseFailure::Network(InboundFailure::ResponseOmission) => { - Some("busy-omitted") - }, - ResponseFailure::Network(InboundFailure::ConnectionClosed) => { - Some("connection-closed") - }, + None, + ResponseFailure::Network(InboundFailure::ResponseOmission) => + Some("busy-omitted"), + ResponseFailure::Network(InboundFailure::ConnectionClosed) => + Some("connection-closed"), }; if let Some(reason) = reason { @@ -1358,7 +1349,7 @@ where duration, result, .. - }) => { + }) => if let Some(metrics) = self.metrics.as_ref() { match result { Ok(_) => { @@ -1373,16 +1364,13 @@ where RequestFailure::UnknownProtocol => "unknown-protocol", RequestFailure::Refused => "refused", RequestFailure::Obsolete => "obsolete", - RequestFailure::Network(OutboundFailure::DialFailure) => { - "dial-failure" - }, + RequestFailure::Network(OutboundFailure::DialFailure) => + "dial-failure", RequestFailure::Network(OutboundFailure::Timeout) => "timeout", - RequestFailure::Network(OutboundFailure::ConnectionClosed) => { - "connection-closed" - }, - RequestFailure::Network(OutboundFailure::UnsupportedProtocols) => { - "unsupported" - }, + RequestFailure::Network(OutboundFailure::ConnectionClosed) => + "connection-closed", + RequestFailure::Network(OutboundFailure::UnsupportedProtocols) => + "unsupported", }; metrics @@ -1391,8 +1379,7 @@ where .inc(); }, } - } - }, + }, SwarmEvent::Behaviour(BehaviourOut::ReputationChanges { peer, changes }) => { for change in changes { self.network_service.behaviour().user_protocol().report_peer(peer, change); @@ -1633,22 +1620,21 @@ where if let Some(metrics) = self.metrics.as_ref() { #[allow(deprecated)] let reason = match error { - DialError::Denied { cause } => { + DialError::Denied { cause } => if cause.downcast::().is_ok() { Some("limit-reached") } else { None - } - }, + }, DialError::ConnectionLimit(_) => Some("limit-reached"), - DialError::InvalidPeerId(_) - | DialError::WrongPeerId { .. } - | DialError::LocalPeerId { .. } => Some("invalid-peer-id"), + DialError::InvalidPeerId(_) | + DialError::WrongPeerId { .. } | + DialError::LocalPeerId { .. } => Some("invalid-peer-id"), DialError::Transport(_) => Some("transport-error"), - DialError::Banned - | DialError::NoAddresses - | DialError::DialPeerConditionFalse(_) - | DialError::Aborted => None, // ignore them + DialError::Banned | + DialError::NoAddresses | + DialError::DialPeerConditionFalse(_) | + DialError::Aborted => None, // ignore them }; if let Some(reason) = reason { metrics.pending_connections_errors_total.with_label_values(&[reason]).inc(); @@ -1679,17 +1665,15 @@ where if let Some(metrics) = self.metrics.as_ref() { #[allow(deprecated)] let reason = match error { - ListenError::Denied { cause } => { + ListenError::Denied { cause } => if cause.downcast::().is_ok() { Some("limit-reached") } else { None - } - }, + }, ListenError::ConnectionLimit(_) => Some("limit-reached"), - ListenError::WrongPeerId { .. } | ListenError::LocalPeerId { .. } => { - Some("invalid-peer-id") - }, + ListenError::WrongPeerId { .. } | ListenError::LocalPeerId { .. } => + Some("invalid-peer-id"), ListenError::Transport(_) => Some("transport-error"), ListenError::Aborted => None, // ignore it }; @@ -1765,7 +1749,7 @@ fn ensure_addresses_consistent_with_transport<'a>( return Err(Error::AddressesForAnotherTransport { transport: transport.clone(), addresses, - }); + }) } } else { let addresses: Vec<_> = addresses @@ -1777,7 +1761,7 @@ fn ensure_addresses_consistent_with_transport<'a>( return Err(Error::AddressesForAnotherTransport { transport: transport.clone(), addresses, - }); + }) } } From 12ba133e0777d15d92964860c6f6012155c281e7 Mon Sep 17 00:00:00 2001 From: Anton Kaliaev Date: Thu, 22 Jun 2023 11:35:00 +0300 Subject: [PATCH 05/42] new NetworkBehaviour invariants --- client/network/src/discovery.rs | 16 +++++--- client/network/src/peer_info.rs | 41 ++++++++++++++----- client/network/src/protocol.rs | 12 +++++- .../src/protocol/notifications/behaviour.rs | 29 +++++++------ client/network/src/request_responses.rs | 17 +++++--- client/network/src/service.rs | 5 +-- 6 files changed, 78 insertions(+), 42 deletions(-) diff --git a/client/network/src/discovery.rs b/client/network/src/discovery.rs index f46ad8add0b8e..18d040fadc74f 100644 --- a/client/network/src/discovery.rs +++ b/client/network/src/discovery.rs @@ -482,6 +482,7 @@ pub enum DiscoveryOut { impl NetworkBehaviour for DiscoveryBehaviour { type ConnectionHandler = ToggleConnectionHandler>; + type ToSwarm = DiscoveryOut; fn handle_established_inbound_connection( &mut self, @@ -611,11 +612,11 @@ impl NetworkBehaviour for DiscoveryBehaviour { FromSwarm::ListenerError(e) => { self.kademlia.on_swarm_event(FromSwarm::ListenerError(e)); }, - FromSwarm::ExpiredExternalAddr(e) => { + FromSwarm::ExternalAddrExpired(e) => { // We intentionally don't remove the element from `known_external_addresses` in // order to not print the log line again. - self.kademlia.on_swarm_event(FromSwarm::ExpiredExternalAddr(e)); + self.kademlia.on_swarm_event(FromSwarm::ExternalAddrExpired(e)); }, FromSwarm::NewListener(e) => { self.kademlia.on_swarm_event(FromSwarm::NewListener(e)); @@ -646,6 +647,9 @@ impl NetworkBehaviour for DiscoveryBehaviour { FromSwarm::NewListenAddr(e) => { self.kademlia.on_swarm_event(FromSwarm::NewListenAddr(e)); }, + FromSwarm::ExternalAddrConfirmed(addr) => { + self.kademlia.on_swarm_event(FromSwarm::ExternalAddrConfirmed(addr)); + }, } } @@ -873,8 +877,8 @@ impl NetworkBehaviour for DiscoveryBehaviour { ToSwarm::Dial { opts } => return Poll::Ready(ToSwarm::Dial { opts }), ToSwarm::NotifyHandler { peer_id, handler, event } => return Poll::Ready(ToSwarm::NotifyHandler { peer_id, handler, event }), - ToSwarm::ReportObservedAddr { address, score } => - return Poll::Ready(ToSwarm::ReportObservedAddr { address, score }), + ToSwarm::NewExternalAddrCandidate(observed) => + return Poll::Ready(ToSwarm::NewExternalAddrCandidate(observed)), ToSwarm::CloseConnection { peer_id, connection } => return Poll::Ready(ToSwarm::CloseConnection { peer_id, connection }), } @@ -904,8 +908,8 @@ impl NetworkBehaviour for DiscoveryBehaviour { ToSwarm::NotifyHandler { event, .. } => match event {}, /* `event` is an */ // enum with no // variant - ToSwarm::ReportObservedAddr { address, score } => - return Poll::Ready(ToSwarm::ReportObservedAddr { address, score }), + ToSwarm::NewExternalAddrCandidate(observed) => + return Poll::Ready(ToSwarm::NewExternalAddrCandidate(observed)), ToSwarm::CloseConnection { peer_id, connection } => return Poll::Ready(ToSwarm::CloseConnection { peer_id, connection }), } diff --git a/client/network/src/peer_info.rs b/client/network/src/peer_info.rs index 8df7fbf462b0a..8e3ac72f05135 100644 --- a/client/network/src/peer_info.rs +++ b/client/network/src/peer_info.rs @@ -190,6 +190,7 @@ impl NetworkBehaviour for PeerInfoBehaviour { ::ConnectionHandler, ::ConnectionHandler, >; + type ToSwarm = PeerInfoEvent; fn handle_pending_inbound_connection( &mut self, @@ -355,9 +356,9 @@ impl NetworkBehaviour for PeerInfoBehaviour { self.ping.on_swarm_event(FromSwarm::ListenerError(e)); self.identify.on_swarm_event(FromSwarm::ListenerError(e)); }, - FromSwarm::ExpiredExternalAddr(e) => { - self.ping.on_swarm_event(FromSwarm::ExpiredExternalAddr(e)); - self.identify.on_swarm_event(FromSwarm::ExpiredExternalAddr(e)); + FromSwarm::ExternalAddrExpired(e) => { + self.ping.on_swarm_event(FromSwarm::ExternalAddrExpired(e)); + self.identify.on_swarm_event(FromSwarm::ExternalAddrExpired(e)); }, FromSwarm::NewListener(e) => { self.ping.on_swarm_event(FromSwarm::NewListener(e)); @@ -367,9 +368,13 @@ impl NetworkBehaviour for PeerInfoBehaviour { self.ping.on_swarm_event(FromSwarm::ExpiredListenAddr(e)); self.identify.on_swarm_event(FromSwarm::ExpiredListenAddr(e)); }, - FromSwarm::NewExternalAddr(e) => { - self.ping.on_swarm_event(FromSwarm::NewExternalAddr(e)); - self.identify.on_swarm_event(FromSwarm::NewExternalAddr(e)); + FromSwarm::NewExternalAddrCandidate(e) => { + self.ping.on_swarm_event(FromSwarm::NewExternalAddrCandidate(e)); + self.identify.on_swarm_event(FromSwarm::NewExternalAddrCandidate(e)); + }, + FromSwarm::ExternalAddrConfirmed(e) => { + self.ping.on_swarm_event(FromSwarm::ExternalAddrConfirmed(e)); + self.identify.on_swarm_event(FromSwarm::ExternalAddrConfirmed(e)); }, FromSwarm::AddressChange(e @ AddressChange { peer_id, old, new, .. }) => { self.ping.on_swarm_event(FromSwarm::AddressChange(e)); @@ -428,10 +433,18 @@ impl NetworkBehaviour for PeerInfoBehaviour { handler, event: Either::Left(event), }), - Poll::Ready(ToSwarm::ReportObservedAddr { address, score }) => - return Poll::Ready(ToSwarm::ReportObservedAddr { address, score }), Poll::Ready(ToSwarm::CloseConnection { peer_id, connection }) => return Poll::Ready(ToSwarm::CloseConnection { peer_id, connection }), + Poll::Ready(ToSwarm::NewExternalAddrCandidate(observed)) => + return Poll::Ready(ToSwarm::NewExternalAddrCandidate(observed)), + Poll::Ready(ToSwarm::ExternalAddrConfirmed(addr)) => + return Poll::Ready(ToSwarm::ExternalAddrConfirmed(addr)), + Poll::Ready(ToSwarm::ExternalAddrExpired(addr)) => + return Poll::Ready(ToSwarm::ExternalAddrExpired(addr)), + Poll::Ready(ToSwarm::ListenOn { opts }) => + return Poll::Ready(ToSwarm::ListenOn { opts }), + Poll::Ready(ToSwarm::RemoveListener { id }) => + return Poll::Ready(ToSwarm::RemoveListener { id }), } } @@ -457,10 +470,18 @@ impl NetworkBehaviour for PeerInfoBehaviour { handler, event: Either::Right(event), }), - Poll::Ready(ToSwarm::ReportObservedAddr { address, score }) => - return Poll::Ready(ToSwarm::ReportObservedAddr { address, score }), Poll::Ready(ToSwarm::CloseConnection { peer_id, connection }) => return Poll::Ready(ToSwarm::CloseConnection { peer_id, connection }), + Poll::Ready(ToSwarm::NewExternalAddrCandidate(observed)) => + return Poll::Ready(ToSwarm::NewExternalAddrCandidate(observed)), + Poll::Ready(ToSwarm::ExternalAddrConfirmed(addr)) => + return Poll::Ready(ToSwarm::ExternalAddrConfirmed(addr)), + Poll::Ready(ToSwarm::ExternalAddrExpired(addr)) => + return Poll::Ready(ToSwarm::ExternalAddrExpired(addr)), + Poll::Ready(ToSwarm::ListenOn { opts }) => + return Poll::Ready(ToSwarm::ListenOn { opts }), + Poll::Ready(ToSwarm::RemoveListener { id }) => + return Poll::Ready(ToSwarm::RemoveListener { id }), } } diff --git a/client/network/src/protocol.rs b/client/network/src/protocol.rs index 320466e29ee38..20f5707e2c764 100644 --- a/client/network/src/protocol.rs +++ b/client/network/src/protocol.rs @@ -438,10 +438,18 @@ impl NetworkBehaviour for Protocol { Poll::Ready(ToSwarm::Dial { opts }) => return Poll::Ready(ToSwarm::Dial { opts }), Poll::Ready(ToSwarm::NotifyHandler { peer_id, handler, event }) => return Poll::Ready(ToSwarm::NotifyHandler { peer_id, handler, event }), - Poll::Ready(ToSwarm::ReportObservedAddr { address, score }) => - return Poll::Ready(ToSwarm::ReportObservedAddr { address, score }), Poll::Ready(ToSwarm::CloseConnection { peer_id, connection }) => return Poll::Ready(ToSwarm::CloseConnection { peer_id, connection }), + Poll::Ready(ToSwarm::NewExternalAddrCandidate(observed)) => + return Poll::Ready(ToSwarm::NewExternalAddrCandidate(observed)), + Poll::Ready(ToSwarm::ExternalAddrConfirmed(addr)) => + return Poll::Ready(ToSwarm::ExternalAddrConfirmed(addr)), + Poll::Ready(ToSwarm::ExternalAddrExpired(addr)) => + return Poll::Ready(ToSwarm::ExternalAddrExpired(addr)), + Poll::Ready(ToSwarm::ListenOn { opts }) => + return Poll::Ready(ToSwarm::ListenOn { opts }), + Poll::Ready(ToSwarm::RemoveListener { id }) => + return Poll::Ready(ToSwarm::RemoveListener { id }), }; let outcome = match event { diff --git a/client/network/src/protocol/notifications/behaviour.rs b/client/network/src/protocol/notifications/behaviour.rs index 1df4809f7a064..8f26c78f96620 100644 --- a/client/network/src/protocol/notifications/behaviour.rs +++ b/client/network/src/protocol/notifications/behaviour.rs @@ -84,19 +84,17 @@ use std::{ /// the API of this behaviour and towards the peerset manager is aggregated in /// the following way: /// -/// 1. The enabled/disabled status is the same across all connections, as -/// decided by the peerset manager. -/// 2. `send_packet` and `write_notification` always send all data over -/// the same connection to preserve the ordering provided by the transport, -/// as long as that connection is open. If it closes, a second open -/// connection may take over, if one exists, but that case should be no -/// different than a single connection failing and being re-established -/// in terms of potential reordering and dropped messages. Messages can -/// be received on any connection. -/// 3. The behaviour reports `NotificationsOut::CustomProtocolOpen` when the -/// first connection reports `NotifsHandlerOut::OpenResultOk`. -/// 4. The behaviour reports `NotificationsOut::CustomProtocolClosed` when the -/// last connection reports `NotifsHandlerOut::ClosedResult`. +/// 1. The enabled/disabled status is the same across all connections, as decided by the peerset +/// manager. +/// 2. `send_packet` and `write_notification` always send all data over the same connection to +/// preserve the ordering provided by the transport, as long as that connection is open. If it +/// closes, a second open connection may take over, if one exists, but that case should be no +/// different than a single connection failing and being re-established in terms of potential +/// reordering and dropped messages. Messages can be received on any connection. +/// 3. The behaviour reports `NotificationsOut::CustomProtocolOpen` when the first connection +/// reports `NotifsHandlerOut::OpenResultOk`. +/// 4. The behaviour reports `NotificationsOut::CustomProtocolClosed` when the last connection +/// reports `NotifsHandlerOut::ClosedResult`. /// /// In this way, the number of actual established connections to the peer is /// an implementation detail of this behaviour. Note that, in practice and at @@ -1468,10 +1466,11 @@ impl NetworkBehaviour for Notifications { FromSwarm::ListenerClosed(_) => {}, FromSwarm::ListenFailure(_) => {}, FromSwarm::ListenerError(_) => {}, - FromSwarm::ExpiredExternalAddr(_) => {}, + FromSwarm::ExternalAddrExpired(_) => {}, FromSwarm::NewListener(_) => {}, FromSwarm::ExpiredListenAddr(_) => {}, - FromSwarm::NewExternalAddr(_) => {}, + FromSwarm::NewExternalAddrCandidate(_) => {}, + FromSwarm::ExternalAddrConfirmed(_) => {}, FromSwarm::AddressChange(_) => {}, FromSwarm::NewListenAddr(_) => {}, } diff --git a/client/network/src/request_responses.rs b/client/network/src/request_responses.rs index 010ab1fadbe56..ef0ae1fa99c1f 100644 --- a/client/network/src/request_responses.rs +++ b/client/network/src/request_responses.rs @@ -399,6 +399,7 @@ impl RequestResponsesBehaviour { impl NetworkBehaviour for RequestResponsesBehaviour { type ConnectionHandler = MultiHandler as NetworkBehaviour>::ConnectionHandler>; + type ToSwarm = Event; fn handle_pending_inbound_connection( &mut self, @@ -514,9 +515,9 @@ impl NetworkBehaviour for RequestResponsesBehaviour { for (p, _) in self.protocols.values_mut() { NetworkBehaviour::on_swarm_event(p, FromSwarm::ListenerError(e)); }, - FromSwarm::ExpiredExternalAddr(e) => + FromSwarm::ExternalAddrExpired(e) => for (p, _) in self.protocols.values_mut() { - NetworkBehaviour::on_swarm_event(p, FromSwarm::ExpiredExternalAddr(e)); + NetworkBehaviour::on_swarm_event(p, FromSwarm::ExternalAddrExpired(e)); }, FromSwarm::NewListener(e) => for (p, _) in self.protocols.values_mut() { @@ -526,9 +527,13 @@ impl NetworkBehaviour for RequestResponsesBehaviour { for (p, _) in self.protocols.values_mut() { NetworkBehaviour::on_swarm_event(p, FromSwarm::ExpiredListenAddr(e)); }, - FromSwarm::NewExternalAddr(e) => + FromSwarm::NewExternalAddrCandidate(e) => for (p, _) in self.protocols.values_mut() { - NetworkBehaviour::on_swarm_event(p, FromSwarm::NewExternalAddr(e)); + NetworkBehaviour::on_swarm_event(p, FromSwarm::NewExternalAddrCandidate(e)); + }, + FromSwarm::ExternalAddrConfirmed(e) => + for (p, _) in self.protocols.values_mut() { + NetworkBehaviour::on_swarm_event(p, FromSwarm::ExternalAddrConfirmed(e)); }, FromSwarm::AddressChange(e) => for (p, _) in self.protocols.values_mut() { @@ -718,8 +723,8 @@ impl NetworkBehaviour for RequestResponsesBehaviour { handler, event: ((*protocol).to_string(), event), }), - ToSwarm::ReportObservedAddr { address, score } => - return Poll::Ready(ToSwarm::ReportObservedAddr { address, score }), + ToSwarm::NewExternalAddrCandidate(observed) => + return Poll::Ready(ToSwarm::NewExternalAddrCandidate(observed)), ToSwarm::CloseConnection { peer_id, connection } => return Poll::Ready(ToSwarm::CloseConnection { peer_id, connection }), }; diff --git a/client/network/src/service.rs b/client/network/src/service.rs index b4e680941ab66..76eb3502344ba 100644 --- a/client/network/src/service.rs +++ b/client/network/src/service.rs @@ -592,7 +592,7 @@ where let peer_id = Swarm::>::local_peer_id(swarm).to_base58(); let listened_addresses = swarm.listeners().cloned().collect(); - let external_addresses = swarm.external_addresses().map(|r| &r.addr).cloned().collect(); + let external_addresses = swarm.external_addresses().cloned().collect(); NetworkState { peer_id, @@ -1185,8 +1185,7 @@ where self.network_service.behaviour_mut().user_protocol_mut().num_connected_peers(); self.num_connected.store(num_connected_peers, Ordering::Relaxed); { - let external_addresses = - self.network_service.external_addresses().map(|r| &r.addr).cloned().collect(); + let external_addresses = self.network_service.external_addresses().cloned().collect(); *self.external_addresses.lock() = external_addresses; let listen_addresses = From fe656e82352f7c307fdd88302f8f053e9f25c9a5 Mon Sep 17 00:00:00 2001 From: Anton Kaliaev Date: Thu, 22 Jun 2023 18:55:21 +0300 Subject: [PATCH 06/42] replace `Vec` with `StreamProtocol` --- client/network/src/behaviour.rs | 2 +- client/network/src/config.rs | 7 +--- client/network/src/discovery.rs | 54 ++++++++++++++++--------- client/network/src/peer_info.rs | 4 +- client/network/src/request_responses.rs | 12 +++++- client/network/src/service.rs | 11 +++-- 6 files changed, 54 insertions(+), 36 deletions(-) diff --git a/client/network/src/behaviour.rs b/client/network/src/behaviour.rs index 191382c5da2f9..496718f283c0d 100644 --- a/client/network/src/behaviour.rs +++ b/client/network/src/behaviour.rs @@ -247,7 +247,7 @@ impl Behaviour { pub fn add_self_reported_address_to_dht( &mut self, peer_id: &PeerId, - supported_protocols: &[impl AsRef<[u8]>], + supported_protocols: &[impl AsRef], addr: Multiaddr, ) { self.discovery.add_self_reported_address(peer_id, supported_protocols, addr); diff --git a/client/network/src/config.rs b/client/network/src/config.rs index 17ca8335653de..e2cde2b3c4f9e 100644 --- a/client/network/src/config.rs +++ b/client/network/src/config.rs @@ -107,8 +107,7 @@ pub fn parse_str_addr(addr_str: &str) -> Result<(PeerId, Multiaddr), ParseErr> { /// Splits a Multiaddress into a Multiaddress and PeerId. pub fn parse_addr(mut addr: Multiaddr) -> Result<(PeerId, Multiaddr), ParseErr> { let who = match addr.pop() { - Some(multiaddr::Protocol::P2p(key)) => - PeerId::from_multihash(key).map_err(|_| ParseErr::InvalidPeerId)?, + Some(multiaddr::Protocol::P2p(key)) => key, _ => return Err(ParseErr::PeerIdMissing), }; @@ -179,8 +178,6 @@ impl TryFrom for MultiaddrWithPeerId { pub enum ParseErr { /// Error while parsing the multiaddress. MultiaddrParse(multiaddr::Error), - /// Multihash of the peer ID is invalid. - InvalidPeerId, /// The peer ID is missing from the address. PeerIdMissing, } @@ -189,7 +186,6 @@ impl fmt::Display for ParseErr { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { Self::MultiaddrParse(err) => write!(f, "{}", err), - Self::InvalidPeerId => write!(f, "Peer id at the end of the address is invalid"), Self::PeerIdMissing => write!(f, "Peer id is missing from the address"), } } @@ -199,7 +195,6 @@ impl std::error::Error for ParseErr { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { match self { Self::MultiaddrParse(err) => Some(err), - Self::InvalidPeerId => None, Self::PeerIdMissing => None, } } diff --git a/client/network/src/discovery.rs b/client/network/src/discovery.rs index 18d040fadc74f..8859a3396de00 100644 --- a/client/network/src/discovery.rs +++ b/client/network/src/discovery.rs @@ -66,8 +66,8 @@ use libp2p::{ toggle::{Toggle, ToggleConnectionHandler}, DialFailure, FromSwarm, NewExternalAddrCandidate, }, - ConnectionDenied, ConnectionId, DialError, NetworkBehaviour, PollParameters, THandler, - THandlerInEvent, THandlerOutEvent, ToSwarm, + ConnectionDenied, ConnectionId, DialError, NetworkBehaviour, PollParameters, + StreamProtocol, THandler, THandlerInEvent, THandlerOutEvent, ToSwarm, }, PeerId, }; @@ -99,7 +99,7 @@ pub struct DiscoveryConfig { discovery_only_if_under_num: u64, enable_mdns: bool, kademlia_disjoint_query_paths: bool, - kademlia_protocols: Vec>, + kademlia_protocols: Vec, } impl DiscoveryConfig { @@ -336,7 +336,7 @@ impl DiscoveryBehaviour { pub fn add_self_reported_address( &mut self, peer_id: &PeerId, - supported_protocols: &[impl AsRef<[u8]>], + supported_protocols: &[impl AsRef], addr: Multiaddr, ) { if let Some(kademlia) = self.kademlia.as_mut() { @@ -355,7 +355,7 @@ impl DiscoveryBehaviour { trace!( target: "sub-libp2p", "Adding self-reported address {} from {} to Kademlia DHT {}.", - addr, peer_id, String::from_utf8_lossy(matching_protocol.as_ref()), + addr, peer_id, matching_protocol.as_ref(), ); kademlia.add_address(peer_id, addr.clone()); } else { @@ -877,10 +877,17 @@ impl NetworkBehaviour for DiscoveryBehaviour { ToSwarm::Dial { opts } => return Poll::Ready(ToSwarm::Dial { opts }), ToSwarm::NotifyHandler { peer_id, handler, event } => return Poll::Ready(ToSwarm::NotifyHandler { peer_id, handler, event }), - ToSwarm::NewExternalAddrCandidate(observed) => - return Poll::Ready(ToSwarm::NewExternalAddrCandidate(observed)), ToSwarm::CloseConnection { peer_id, connection } => return Poll::Ready(ToSwarm::CloseConnection { peer_id, connection }), + ToSwarm::NewExternalAddrCandidate(observed) => + return Poll::Ready(ToSwarm::NewExternalAddrCandidate(observed)), + ToSwarm::ExternalAddrConfirmed(addr) => + return Poll::Ready(ToSwarm::ExternalAddrConfirmed(addr)), + ToSwarm::ExternalAddrExpired(addr) => + return Poll::Ready(ToSwarm::ExternalAddrExpired(addr)), + ToSwarm::ListenOn { opts } => return Poll::Ready(ToSwarm::ListenOn { opts }), + ToSwarm::RemoveListener { id } => + return Poll::Ready(ToSwarm::RemoveListener { id }), } } @@ -908,10 +915,17 @@ impl NetworkBehaviour for DiscoveryBehaviour { ToSwarm::NotifyHandler { event, .. } => match event {}, /* `event` is an */ // enum with no // variant - ToSwarm::NewExternalAddrCandidate(observed) => - return Poll::Ready(ToSwarm::NewExternalAddrCandidate(observed)), ToSwarm::CloseConnection { peer_id, connection } => return Poll::Ready(ToSwarm::CloseConnection { peer_id, connection }), + ToSwarm::NewExternalAddrCandidate(observed) => + return Poll::Ready(ToSwarm::NewExternalAddrCandidate(observed)), + ToSwarm::ExternalAddrConfirmed(addr) => + return Poll::Ready(ToSwarm::ExternalAddrConfirmed(addr)), + ToSwarm::ExternalAddrExpired(addr) => + return Poll::Ready(ToSwarm::ExternalAddrExpired(addr)), + ToSwarm::ListenOn { opts } => return Poll::Ready(ToSwarm::ListenOn { opts }), + ToSwarm::RemoveListener { id } => + return Poll::Ready(ToSwarm::RemoveListener { id }), } } } @@ -921,21 +935,23 @@ impl NetworkBehaviour for DiscoveryBehaviour { } /// Legacy (fallback) Kademlia protocol name based on `protocol_id`. -fn legacy_kademlia_protocol_name(id: &ProtocolId) -> Vec { - let mut v = vec![b'/']; - v.extend_from_slice(id.as_ref().as_bytes()); - v.extend_from_slice(b"/kad"); - v +fn legacy_kademlia_protocol_name(id: &ProtocolId) -> StreamProtocol { + let name = format!("/{}/kad", id.as_ref()); + StreamProtocol::new(&name) } /// Kademlia protocol name based on `genesis_hash` and `fork_id`. -fn kademlia_protocol_name>(genesis_hash: Hash, fork_id: Option<&str>) -> Vec { +fn kademlia_protocol_name>( + genesis_hash: Hash, + fork_id: Option<&str>, +) -> StreamProtocol { let genesis_hash_hex = bytes2hex("", genesis_hash.as_ref()); - if let Some(fork_id) = fork_id { - format!("/{}/{}/kad", genesis_hash_hex, fork_id).as_bytes().into() + let name = if let Some(fork_id) = fork_id { + format!("/{}/{}/kad", genesis_hash_hex, fork_id) } else { - format!("/{}/kad", genesis_hash_hex).as_bytes().into() - } + format!("/{}/kad", genesis_hash_hex) + }; + StreamProtocol::new(&name) } #[cfg(test)] diff --git a/client/network/src/peer_info.rs b/client/network/src/peer_info.rs index 8e3ac72f05135..d7f9e6858fa31 100644 --- a/client/network/src/peer_info.rs +++ b/client/network/src/peer_info.rs @@ -127,12 +127,12 @@ impl PeerInfoBehaviour { ping_time: Duration, connection: ConnectionId, ) { - trace!(target: "sub-libp2p", "Ping time with {:?} via {}: {:?}", peer_id, connection, ping_time); + trace!(target: "sub-libp2p", "Ping time with {:?} via {:?}: {:?}", peer_id, connection, ping_time); if let Some(entry) = self.nodes_info.get_mut(peer_id) { entry.latest_ping = Some(ping_time); } else { error!(target: "sub-libp2p", - "Received ping from node we're not connected to {:?} ({})", peer_id, connection); + "Received ping from node we're not connected to {:?} via {:?}", peer_id, connection); } } diff --git a/client/network/src/request_responses.rs b/client/network/src/request_responses.rs index ef0ae1fa99c1f..87b5dd47965b8 100644 --- a/client/network/src/request_responses.rs +++ b/client/network/src/request_responses.rs @@ -723,10 +723,18 @@ impl NetworkBehaviour for RequestResponsesBehaviour { handler, event: ((*protocol).to_string(), event), }), - ToSwarm::NewExternalAddrCandidate(observed) => - return Poll::Ready(ToSwarm::NewExternalAddrCandidate(observed)), ToSwarm::CloseConnection { peer_id, connection } => return Poll::Ready(ToSwarm::CloseConnection { peer_id, connection }), + ToSwarm::NewExternalAddrCandidate(observed) => + return Poll::Ready(ToSwarm::NewExternalAddrCandidate(observed)), + ToSwarm::ExternalAddrConfirmed(addr) => + return Poll::Ready(ToSwarm::ExternalAddrConfirmed(addr)), + ToSwarm::ExternalAddrExpired(addr) => + return Poll::Ready(ToSwarm::ExternalAddrExpired(addr)), + ToSwarm::ListenOn { opts } => + return Poll::Ready(ToSwarm::ListenOn { opts }), + ToSwarm::RemoveListener { id } => + return Poll::Ready(ToSwarm::RemoveListener { id }), }; match ev { diff --git a/client/network/src/service.rs b/client/network/src/service.rs index 76eb3502344ba..96162e2caa307 100644 --- a/client/network/src/service.rs +++ b/client/network/src/service.rs @@ -670,8 +670,7 @@ impl NetworkService { .into_iter() .map(|mut addr| { let peer = match addr.pop() { - Some(multiaddr::Protocol::P2p(key)) => PeerId::from_multihash(key) - .map_err(|_| "Invalid PeerId format".to_string())?, + Some(multiaddr::Protocol::P2p(key)) => key, _ => return Err("Missing PeerId from address".to_string()), }; @@ -1556,7 +1555,7 @@ where endpoint, num_established, } => { - debug!(target: "sub-libp2p", "Libp2p => Disconnected({:?} via {}, {:?})", peer_id, connection_id, cause); + debug!(target: "sub-libp2p", "Libp2p => Disconnected({:?} via {:?}, {:?})", peer_id, connection_id, cause); if let Some(metrics) = self.metrics.as_ref() { let direction = match endpoint { ConnectedPoint::Dialer { .. } => "out", @@ -1598,7 +1597,7 @@ where if let Some(peer_id) = peer_id { trace!( target: "sub-libp2p", - "Libp2p => Failed to reach {:?} via {}: {}", + "Libp2p => Failed to reach {:?} via {:?}: {}", peer_id, connection_id, error, ); @@ -1644,7 +1643,7 @@ where trace!(target: "sub-libp2p", "Libp2p => Dialing({:?})", peer_id) }, SwarmEvent::IncomingConnection { connection_id, local_addr, send_back_addr } => { - trace!(target: "sub-libp2p", "Libp2p => IncomingConnection({},{},{}))", + trace!(target: "sub-libp2p", "Libp2p => IncomingConnection({:?},{},{}))", connection_id, local_addr, send_back_addr); if let Some(metrics) = self.metrics.as_ref() { metrics.incoming_connections_total.inc(); @@ -1658,7 +1657,7 @@ where } => { debug!( target: "sub-libp2p", - "Libp2p => IncomingConnectionError({},{},{}): {}", + "Libp2p => IncomingConnectionError({:?},{},{}): {}", connection_id, local_addr, send_back_addr, error, ); if let Some(metrics) = self.metrics.as_ref() { From 37e74088882ce1740cac945add23cadacacf0a37 Mon Sep 17 00:00:00 2001 From: Anton Kaliaev Date: Thu, 22 Jun 2023 19:41:12 +0300 Subject: [PATCH 07/42] rename ConnectionHandlerEvent::Custom to NotifyBehaviour --- .../src/protocol/notifications/handler.rs | 24 +++++++++---------- client/network/src/request_responses.rs | 4 ++-- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/client/network/src/protocol/notifications/handler.rs b/client/network/src/protocol/notifications/handler.rs index fa6319a5ae878..508b1c930402c 100644 --- a/client/network/src/protocol/notifications/handler.rs +++ b/client/network/src/protocol/notifications/handler.rs @@ -471,7 +471,7 @@ impl ConnectionHandler for NotifsHandler { match protocol_info.state { State::Closed { pending_opening } => { - self.events_queue.push_back(ConnectionHandlerEvent::Custom( + self.events_queue.push_back(ConnectionHandlerEvent::NotifyBehaviour( NotifsHandlerOut::OpenDesiredByRemote { protocol_index }, )); @@ -536,7 +536,7 @@ impl ConnectionHandler for NotifsHandler { in_substream: in_substream.take(), }; - self.events_queue.push_back(ConnectionHandlerEvent::Custom( + self.events_queue.push_back(ConnectionHandlerEvent::NotifyBehaviour( NotifsHandlerOut::OpenResultOk { protocol_index, negotiated_fallback: new_open.negotiated_fallback, @@ -565,7 +565,7 @@ impl ConnectionHandler for NotifsHandler { self.protocols[dial_upgrade_error.info].state = State::Closed { pending_opening: false }; - self.events_queue.push_back(ConnectionHandlerEvent::Custom( + self.events_queue.push_back(ConnectionHandlerEvent::NotifyBehaviour( NotifsHandlerOut::OpenResultErr { protocol_index: dial_upgrade_error.info }, )); }, @@ -651,7 +651,7 @@ impl ConnectionHandler for NotifsHandler { self.protocols[protocol_index].state = State::Closed { pending_opening: true }; - self.events_queue.push_back(ConnectionHandlerEvent::Custom( + self.events_queue.push_back(ConnectionHandlerEvent::NotifyBehaviour( NotifsHandlerOut::OpenResultErr { protocol_index }, )); }, @@ -661,7 +661,7 @@ impl ConnectionHandler for NotifsHandler { State::Closed { .. } => {}, } - self.events_queue.push_back(ConnectionHandlerEvent::Custom( + self.events_queue.push_back(ConnectionHandlerEvent::NotifyBehaviour( NotifsHandlerOut::CloseResult { protocol_index }, )); }, @@ -755,7 +755,7 @@ impl ConnectionHandler for NotifsHandler { Poll::Ready(Err(_)) => { *out_substream = None; let event = NotifsHandlerOut::CloseDesired { protocol_index }; - return Poll::Ready(ConnectionHandlerEvent::Custom(event)) + return Poll::Ready(ConnectionHandlerEvent::NotifyBehaviour(event)) }, }; }, @@ -781,7 +781,7 @@ impl ConnectionHandler for NotifsHandler { Poll::Pending => {}, Poll::Ready(Some(Ok(message))) => { let event = NotifsHandlerOut::Notification { protocol_index, message }; - return Poll::Ready(ConnectionHandlerEvent::Custom(event)) + return Poll::Ready(ConnectionHandlerEvent::NotifyBehaviour(event)) }, Poll::Ready(None) | Poll::Ready(Some(Err(_))) => *in_substream = None, }, @@ -793,7 +793,7 @@ impl ConnectionHandler for NotifsHandler { Poll::Ready(Err(_)) => { self.protocols[protocol_index].state = State::Closed { pending_opening: *pending_opening }; - return Poll::Ready(ConnectionHandlerEvent::Custom( + return Poll::Ready(ConnectionHandlerEvent::NotifyBehaviour( NotifsHandlerOut::CloseDesired { protocol_index }, )) }, @@ -1591,15 +1591,15 @@ pub mod tests { futures::future::poll_fn(|cx| { assert!(std::matches!( handler.poll(cx), - Poll::Ready(ConnectionHandlerEvent::Custom( + Poll::Ready(ConnectionHandlerEvent::NotifyBehaviour( NotifsHandlerOut::OpenDesiredByRemote { protocol_index: 0 }, )) )); assert!(std::matches!( handler.poll(cx), - Poll::Ready(ConnectionHandlerEvent::Custom(NotifsHandlerOut::CloseDesired { - protocol_index: 0 - },)) + Poll::Ready(ConnectionHandlerEvent::NotifyBehaviour( + NotifsHandlerOut::CloseDesired { protocol_index: 0 }, + )) )); Poll::Ready(()) }) diff --git a/client/network/src/request_responses.rs b/client/network/src/request_responses.rs index 87b5dd47965b8..5219e6c8c546b 100644 --- a/client/network/src/request_responses.rs +++ b/client/network/src/request_responses.rs @@ -332,8 +332,8 @@ impl RequestResponsesBehaviour { }; let rq_rp = Behaviour::new( - iter::once(protocol.name.as_bytes().to_vec()) - .chain(protocol.fallback_names.iter().map(|name| name.as_bytes().to_vec())) + iter::once(protocol.name) + .chain(protocol.fallback_names) .zip(iter::repeat(protocol_support)), cfg, ); From d5b819811851009b80defcd98ab8bf79e238517b Mon Sep 17 00:00:00 2001 From: Anton Kaliaev Date: Fri, 23 Jun 2023 10:30:50 +0300 Subject: [PATCH 08/42] remove DialError & ListenError invariants also fix pending_events --- client/network/src/discovery.rs | 6 +++-- client/network/src/service.rs | 45 +++++++++++++++------------------ 2 files changed, 24 insertions(+), 27 deletions(-) diff --git a/client/network/src/discovery.rs b/client/network/src/discovery.rs index 8859a3396de00..af793637da4bc 100644 --- a/client/network/src/discovery.rs +++ b/client/network/src/discovery.rs @@ -901,8 +901,10 @@ impl NetworkBehaviour for DiscoveryBehaviour { continue } - self.pending_events - .extend(list.map(|(peer_id, _)| DiscoveryOut::Discovered(peer_id))); + self.pending_events.extend( + list.into_iter() + .map(|(peer_id, _)| DiscoveryOut::Discovered(peer_id)), + ); if let Some(ev) = self.pending_events.pop_front() { return Poll::Ready(ToSwarm::GenerateEvent(ev)) } diff --git a/client/network/src/service.rs b/client/network/src/service.rs index 96162e2caa307..65f3f6a14da03 100644 --- a/client/network/src/service.rs +++ b/client/network/src/service.rs @@ -369,7 +369,6 @@ where SpawnImpl(params.executor), ) }; - #[allow(deprecated)] let builder = builder .connection_limits( ConnectionLimits::default() @@ -1555,7 +1554,7 @@ where endpoint, num_established, } => { - debug!(target: "sub-libp2p", "Libp2p => Disconnected({:?} via {:?}, {:?})", peer_id, connection_id, cause); + debug!(target: "sub-libp2p", "Libp2p => Disconnected({:?} via {:?}: {:?})", peer_id, connection_id, cause); if let Some(metrics) = self.metrics.as_ref() { let direction = match endpoint { ConnectedPoint::Dialer { .. } => "out", @@ -1624,12 +1623,9 @@ where } else { None }, - DialError::ConnectionLimit(_) => Some("limit-reached"), - DialError::InvalidPeerId(_) | - DialError::WrongPeerId { .. } | - DialError::LocalPeerId { .. } => Some("invalid-peer-id"), + DialError::WrongPeerId { .. } | DialError::LocalPeerId { .. } => + Some("invalid-peer-id"), DialError::Transport(_) => Some("transport-error"), - DialError::Banned | DialError::NoAddresses | DialError::DialPeerConditionFalse(_) | DialError::Aborted => None, // ignore them @@ -1639,12 +1635,12 @@ where } } }, - SwarmEvent::Dialing(peer_id) => { - trace!(target: "sub-libp2p", "Libp2p => Dialing({:?})", peer_id) + SwarmEvent::Dialing { peer_id, connection_id } => { + trace!(target: "sub-libp2p", "Libp2p => Dialing({:?} via {:?})", peer_id, connection_id) }, SwarmEvent::IncomingConnection { connection_id, local_addr, send_back_addr } => { - trace!(target: "sub-libp2p", "Libp2p => IncomingConnection({:?},{},{}))", - connection_id, local_addr, send_back_addr); + trace!(target: "sub-libp2p", "Libp2p => IncomingConnection({},{} via {:?}))", + local_addr, send_back_addr, connection_id); if let Some(metrics) = self.metrics.as_ref() { metrics.incoming_connections_total.inc(); } @@ -1657,8 +1653,8 @@ where } => { debug!( target: "sub-libp2p", - "Libp2p => IncomingConnectionError({:?},{},{}): {}", - connection_id, local_addr, send_back_addr, error, + "Libp2p => IncomingConnectionError({},{} via {:?}): {}", + local_addr, send_back_addr, connection_id, error, ); if let Some(metrics) = self.metrics.as_ref() { #[allow(deprecated)] @@ -1669,7 +1665,6 @@ where } else { None }, - ListenError::ConnectionLimit(_) => Some("limit-reached"), ListenError::WrongPeerId { .. } | ListenError::LocalPeerId { .. } => Some("invalid-peer-id"), ListenError::Transport(_) => Some("transport-error"), @@ -1684,17 +1679,17 @@ where } } }, - #[allow(deprecated)] - SwarmEvent::BannedPeer { peer_id, endpoint } => { - debug!( - target: "sub-libp2p", - "Libp2p => BannedPeer({}). Connected via {:?}.", - peer_id, endpoint, - ); - if let Some(metrics) = self.metrics.as_ref() { - metrics.incoming_connections_errors_total.with_label_values(&["banned"]).inc(); - } - }, + // #[allow(deprecated)] + // SwarmEvent::BannedPeer { peer_id, endpoint } => { + // debug!( + // target: "sub-libp2p", + // "Libp2p => BannedPeer({}). Connected via {:?}.", + // peer_id, endpoint, + // ); + // if let Some(metrics) = self.metrics.as_ref() { + // metrics.incoming_connections_errors_total.with_label_values(&["banned"]).inc(); + // } + // }, SwarmEvent::ListenerClosed { reason, addresses, .. } => { if let Some(metrics) = self.metrics.as_ref() { metrics.listeners_local_addresses.sub(addresses.len() as u64); From 81f5cd0277083eeff814972fed5e433684fbdfa8 Mon Sep 17 00:00:00 2001 From: Anton Kaliaev Date: Fri, 23 Jun 2023 18:11:05 +0300 Subject: [PATCH 09/42] use connection_limits::Behaviour See https://github.com/libp2p/rust-libp2p/pull/3885 --- client/network/src/behaviour.rs | 13 +++++++++++-- client/network/src/service.rs | 12 +++++------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/client/network/src/behaviour.rs b/client/network/src/behaviour.rs index 496718f283c0d..c47363efb358d 100644 --- a/client/network/src/behaviour.rs +++ b/client/network/src/behaviour.rs @@ -30,8 +30,13 @@ use crate::{ use bytes::Bytes; use futures::channel::oneshot; use libp2p::{ - core::Multiaddr, identify::Info as IdentifyInfo, identity::PublicKey, kad::RecordKey, - swarm::NetworkBehaviour, PeerId, + connection_limits::ConnectionLimits, + core::{connection, Multiaddr}, + identify::Info as IdentifyInfo, + identity::PublicKey, + kad::RecordKey, + swarm::NetworkBehaviour, + PeerId, }; use sc_network_common::role::{ObservedRole, Roles}; @@ -51,6 +56,8 @@ pub struct Behaviour { peer_info: peer_info::PeerInfoBehaviour, /// Discovers nodes of the network. discovery: DiscoveryBehaviour, + /// Connection limits. + connection_limits: libp2p::connection_limits::Behaviour, /// Generic request-response protocols. request_responses: request_responses::RequestResponsesBehaviour, } @@ -171,11 +178,13 @@ impl Behaviour { disco_config: DiscoveryConfig, request_response_protocols: Vec, peerset: PeersetHandle, + connection_limits: ConnectionLimits, ) -> Result { Ok(Self { substrate, peer_info: peer_info::PeerInfoBehaviour::new(user_agent, local_public_key), discovery: disco_config.finish(), + connection_limits: Behaviour::new(connection_limits), request_responses: request_responses::RequestResponsesBehaviour::new( request_response_protocols.into_iter(), peerset, diff --git a/client/network/src/service.rs b/client/network/src/service.rs index 65f3f6a14da03..201bf111106a0 100644 --- a/client/network/src/service.rs +++ b/client/network/src/service.rs @@ -346,6 +346,11 @@ where discovery_config, request_response_protocols, peerset_handle.clone(), + ConnectionLimits::default() + .with_max_established_per_peer(Some(crate::MAX_CONNECTIONS_PER_PEER as u32)) + .with_max_established_incoming(Some( + crate::MAX_CONNECTIONS_ESTABLISHED_INCOMING, + )), ); match result { @@ -370,13 +375,6 @@ where ) }; let builder = builder - .connection_limits( - ConnectionLimits::default() - .with_max_established_per_peer(Some(crate::MAX_CONNECTIONS_PER_PEER as u32)) - .with_max_established_incoming(Some( - crate::MAX_CONNECTIONS_ESTABLISHED_INCOMING, - )), - ) .substream_upgrade_protocol_override(upgrade::Version::V1Lazy) .notify_handler_buffer_size(NonZeroUsize::new(32).expect("32 != 0; qed")) // NOTE: 24 is somewhat arbitrary and should be tuned in the future if necessary. From 4d068dd332bd282b26975edb46513269114de58f Mon Sep 17 00:00:00 2001 From: Anton Kaliaev Date: Tue, 27 Jun 2023 12:21:39 +0400 Subject: [PATCH 10/42] impl `void::Void` for `BehaviourOut` also use `Behaviour::with_codec` --- Cargo.lock | 1 + client/network/Cargo.toml | 1 + client/network/src/behaviour.rs | 17 +++++++++-------- client/network/src/request_responses.rs | 8 ++++++-- 4 files changed, 17 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 08d8454bfbfd4..fbcc075ba6fa1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8974,6 +8974,7 @@ dependencies = [ "tokio-test", "tokio-util", "unsigned-varint", + "void", "wasm-timer", "zeroize", ] diff --git a/client/network/Cargo.toml b/client/network/Cargo.toml index 3c071f017b96b..38b174b211f23 100644 --- a/client/network/Cargo.toml +++ b/client/network/Cargo.toml @@ -39,6 +39,7 @@ serde_json = "1.0.85" smallvec = "1.8.0" thiserror = "1.0" unsigned-varint = { version = "0.7.1", features = ["futures", "asynchronous_codec"] } +void = "1" zeroize = "1.4.3" prometheus-endpoint = { package = "substrate-prometheus-endpoint", version = "0.10.0-dev", path = "../../utils/prometheus" } sc-block-builder = { version = "0.10.0-dev", path = "../block-builder" } diff --git a/client/network/src/behaviour.rs b/client/network/src/behaviour.rs index c47363efb358d..261ace55a0e54 100644 --- a/client/network/src/behaviour.rs +++ b/client/network/src/behaviour.rs @@ -30,13 +30,8 @@ use crate::{ use bytes::Bytes; use futures::channel::oneshot; use libp2p::{ - connection_limits::ConnectionLimits, - core::{connection, Multiaddr}, - identify::Info as IdentifyInfo, - identity::PublicKey, - kad::RecordKey, - swarm::NetworkBehaviour, - PeerId, + connection_limits::ConnectionLimits, core::Multiaddr, identify::Info as IdentifyInfo, + identity::PublicKey, kad::RecordKey, swarm::NetworkBehaviour, PeerId, }; use sc_network_common::role::{ObservedRole, Roles}; @@ -184,7 +179,7 @@ impl Behaviour { substrate, peer_info: peer_info::PeerInfoBehaviour::new(user_agent, local_public_key), discovery: disco_config.finish(), - connection_limits: Behaviour::new(connection_limits), + connection_limits: libp2p::connection_limits::Behaviour::new(connection_limits), request_responses: request_responses::RequestResponsesBehaviour::new( request_response_protocols.into_iter(), peerset, @@ -360,3 +355,9 @@ impl From for BehaviourOut { } } } + +impl From for BehaviourOut { + fn from(_e: void::Void) -> Self { + Self::None + } +} diff --git a/client/network/src/request_responses.rs b/client/network/src/request_responses.rs index 5219e6c8c546b..1eaca2b6008c4 100644 --- a/client/network/src/request_responses.rs +++ b/client/network/src/request_responses.rs @@ -331,7 +331,11 @@ impl RequestResponsesBehaviour { ProtocolSupport::Outbound }; - let rq_rp = Behaviour::new( + let rq_rp = Behaviour::with_codec( + GenericCodec { + max_request_size: protocol.max_request_size, + max_response_size: protocol.max_response_size, + }, iter::once(protocol.name) .chain(protocol.fallback_names) .zip(iter::repeat(protocol_support)), @@ -930,7 +934,7 @@ pub struct GenericCodec { #[async_trait::async_trait] impl Codec for GenericCodec { - type Protocol = String; + type Protocol = ProtocolName; type Request = Vec; type Response = Result, ()>; From 3e54dd13b803d9d6f88df8c95b9a210c60e8f244 Mon Sep 17 00:00:00 2001 From: Anton Kaliaev Date: Tue, 27 Jun 2023 17:16:33 +0400 Subject: [PATCH 11/42] KademliaHandler no longer public --- client/network/src/discovery.rs | 3 ++- client/network/src/protocol/notifications/handler.rs | 5 ++++- client/network/src/service.rs | 6 ++++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/client/network/src/discovery.rs b/client/network/src/discovery.rs index af793637da4bc..629cb73456f87 100644 --- a/client/network/src/discovery.rs +++ b/client/network/src/discovery.rs @@ -481,7 +481,8 @@ pub enum DiscoveryOut { } impl NetworkBehaviour for DiscoveryBehaviour { - type ConnectionHandler = ToggleConnectionHandler>; + type ConnectionHandler = + ToggleConnectionHandler< as NetworkBehaviour>::ConnectionHandler>; type ToSwarm = DiscoveryOut; fn handle_established_inbound_connection( diff --git a/client/network/src/protocol/notifications/handler.rs b/client/network/src/protocol/notifications/handler.rs index 508b1c930402c..fb9d8d064ef61 100644 --- a/client/network/src/protocol/notifications/handler.rs +++ b/client/network/src/protocol/notifications/handler.rs @@ -777,7 +777,10 @@ impl ConnectionHandler for NotifsHandler { State::Opening { in_substream: None } => {}, State::Open { in_substream: in_substream @ Some(_), .. } => - match Stream::poll_next(Pin::new(in_substream.as_mut().unwrap()), cx) { + match futures::prelude::Stream::poll_next( + Pin::new(in_substream.as_mut().unwrap()), + cx, + ) { Poll::Pending => {}, Poll::Ready(Some(Ok(message))) => { let event = NotifsHandlerOut::Notification { protocol_index, message }; diff --git a/client/network/src/service.rs b/client/network/src/service.rs index 201bf111106a0..83405c4ac28ce 100644 --- a/client/network/src/service.rs +++ b/client/network/src/service.rs @@ -1561,10 +1561,12 @@ where let reason = match cause { Some(ConnectionError::IO(_)) => "transport-error", Some(ConnectionError::Handler(Either::Left(Either::Left( - Either::Right(Either::Left(PingFailure::Timeout)), + Either::Right(Either::Left(Either::Left(PingFailure::Timeout))), )))) => "ping-timeout", Some(ConnectionError::Handler(Either::Left(Either::Left( - Either::Left(NotifsHandlerError::SyncNotificationsClogged), + Either::Left(Either::Left( + NotifsHandlerError::SyncNotificationsClogged, + )), )))) => "sync-notifications-clogged", Some(ConnectionError::Handler(_)) => "protocol-error", Some(ConnectionError::KeepAliveTimeout) => "keep-alive-timeout", From 076635bd98edd03d62675f8b40f4eef62cc7d129 Mon Sep 17 00:00:00 2001 From: Anton Kaliaev Date: Tue, 27 Jun 2023 19:51:16 +0400 Subject: [PATCH 12/42] fix StreamProtocol construction --- client/network/src/discovery.rs | 4 ++-- client/network/src/service.rs | 11 ++++++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/client/network/src/discovery.rs b/client/network/src/discovery.rs index 629cb73456f87..bb61153f6759f 100644 --- a/client/network/src/discovery.rs +++ b/client/network/src/discovery.rs @@ -940,7 +940,7 @@ impl NetworkBehaviour for DiscoveryBehaviour { /// Legacy (fallback) Kademlia protocol name based on `protocol_id`. fn legacy_kademlia_protocol_name(id: &ProtocolId) -> StreamProtocol { let name = format!("/{}/kad", id.as_ref()); - StreamProtocol::new(&name) + StreamProtocol::try_from_owned(name).expect("protocol name is valid. qed") } /// Kademlia protocol name based on `genesis_hash` and `fork_id`. @@ -954,7 +954,7 @@ fn kademlia_protocol_name>( } else { format!("/{}/kad", genesis_hash_hex) }; - StreamProtocol::new(&name) + StreamProtocol::try_from_owned(name).expect("protocol name is valid. qed") } #[cfg(test)] diff --git a/client/network/src/service.rs b/client/network/src/service.rs index 83405c4ac28ce..96754e7f9b07d 100644 --- a/client/network/src/service.rs +++ b/client/network/src/service.rs @@ -61,12 +61,13 @@ use libp2p::{ identify::Info as IdentifyInfo, kad::record::Key as KademliaKey, multiaddr, - ping::Failure as PingFailure, + // ping::Failure as PingFailure, swarm::{ ConnectionError, ConnectionId, DialError, Executor, ListenError, NetworkBehaviour, Swarm, SwarmBuilder, SwarmEvent, THandlerErr, }, - Multiaddr, PeerId, + Multiaddr, + PeerId, }; use log::{debug, error, info, trace, warn}; use metrics::{Histogram, HistogramVec, MetricSources, Metrics}; @@ -1560,9 +1561,9 @@ where }; let reason = match cause { Some(ConnectionError::IO(_)) => "transport-error", - Some(ConnectionError::Handler(Either::Left(Either::Left( - Either::Right(Either::Left(Either::Left(PingFailure::Timeout))), - )))) => "ping-timeout", + // Some(ConnectionError::Handler(Either::Left(Either::Left( + // Either::Right(PingFailure::Timeout), + // )))) => "ping-timeout", Some(ConnectionError::Handler(Either::Left(Either::Left( Either::Left(Either::Left( NotifsHandlerError::SyncNotificationsClogged, From d1fd05cc76a2811ca5830ad3f918124dd87dfbd6 Mon Sep 17 00:00:00 2001 From: Anton Kaliaev Date: Tue, 27 Jun 2023 20:12:17 +0400 Subject: [PATCH 13/42] update libp2p-identify to 0.2.0 --- Cargo.lock | 85 +++++++------------------ client/cli/Cargo.toml | 2 +- client/consensus/common/Cargo.toml | 2 +- client/network/bitswap/Cargo.toml | 2 +- client/network/common/Cargo.toml | 2 +- client/network/light/Cargo.toml | 2 +- client/network/src/request_responses.rs | 2 +- 7 files changed, 30 insertions(+), 67 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fbcc075ba6fa1..7b97c0d43b343 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3774,7 +3774,7 @@ dependencies = [ "libp2p-core", "libp2p-dns", "libp2p-identify", - "libp2p-identity 0.2.0", + "libp2p-identity", "libp2p-kad", "libp2p-mdns", "libp2p-metrics", @@ -3786,7 +3786,7 @@ dependencies = [ "libp2p-wasm-ext", "libp2p-websocket", "libp2p-yamux", - "multiaddr 0.18.0", + "multiaddr", "pin-project", ] @@ -3797,7 +3797,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "55b46558c5c0bf99d3e2a1a38fd54ff5476ca66dd1737b12466a1824dd219311" dependencies = [ "libp2p-core", - "libp2p-identity 0.2.0", + "libp2p-identity", "libp2p-swarm", "void", ] @@ -3809,7 +3809,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d45dd90e8f0e1fa59e85ff5316dd4d1ac41a9a507e79cda1b0e9b7be43ad1a56" dependencies = [ "libp2p-core", - "libp2p-identity 0.2.0", + "libp2p-identity", "libp2p-swarm", "void", ] @@ -3825,9 +3825,9 @@ dependencies = [ "futures", "futures-timer", "instant", - "libp2p-identity 0.2.0", + "libp2p-identity", "log", - "multiaddr 0.18.0", + "multiaddr", "multihash 0.19.0", "multistream-select 0.13.0", "once_cell", @@ -3850,7 +3850,7 @@ checksum = "fd4394c81c0c06d7b4a60f3face7e8e8a9b246840f98d2c80508d0721b032147" dependencies = [ "futures", "libp2p-core", - "libp2p-identity 0.2.0", + "libp2p-identity", "log", "parking_lot 0.12.1", "smallvec", @@ -3868,7 +3868,7 @@ dependencies = [ "futures", "futures-timer", "libp2p-core", - "libp2p-identity 0.2.0", + "libp2p-identity", "libp2p-swarm", "log", "lru", @@ -3879,24 +3879,6 @@ dependencies = [ "void", ] -[[package]] -name = "libp2p-identity" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e2d584751cecb2aabaa56106be6be91338a60a0f4e420cf2af639204f596fc1" -dependencies = [ - "bs58 0.4.0", - "ed25519-dalek", - "log", - "multiaddr 0.17.1", - "multihash 0.17.0", - "quick-protobuf", - "rand 0.8.5", - "sha2 0.10.7", - "thiserror", - "zeroize", -] - [[package]] name = "libp2p-identity" version = "0.2.0" @@ -3929,7 +3911,7 @@ dependencies = [ "futures-timer", "instant", "libp2p-core", - "libp2p-identity 0.2.0", + "libp2p-identity", "libp2p-swarm", "log", "quick-protobuf", @@ -3952,7 +3934,7 @@ dependencies = [ "futures", "if-watch", "libp2p-core", - "libp2p-identity 0.2.0", + "libp2p-identity", "libp2p-swarm", "log", "rand 0.8.5", @@ -3972,7 +3954,7 @@ dependencies = [ "instant", "libp2p-core", "libp2p-identify", - "libp2p-identity 0.2.0", + "libp2p-identity", "libp2p-kad", "libp2p-ping", "libp2p-swarm", @@ -3990,9 +3972,9 @@ dependencies = [ "curve25519-dalek 3.2.0", "futures", "libp2p-core", - "libp2p-identity 0.2.0", + "libp2p-identity", "log", - "multiaddr 0.18.0", + "multiaddr", "multihash 0.19.0", "once_cell", "quick-protobuf", @@ -4016,7 +3998,7 @@ dependencies = [ "futures-timer", "instant", "libp2p-core", - "libp2p-identity 0.2.0", + "libp2p-identity", "libp2p-swarm", "log", "rand 0.8.5", @@ -4033,7 +4015,7 @@ dependencies = [ "futures", "instant", "libp2p-core", - "libp2p-identity 0.2.0", + "libp2p-identity", "libp2p-swarm", "log", "rand 0.8.5", @@ -4053,7 +4035,7 @@ dependencies = [ "futures-timer", "instant", "libp2p-core", - "libp2p-identity 0.2.0", + "libp2p-identity", "libp2p-swarm-derive", "log", "multistream-select 0.13.0", @@ -4088,7 +4070,7 @@ dependencies = [ "if-watch", "libc", "libp2p-core", - "libp2p-identity 0.2.0", + "libp2p-identity", "log", "socket2 0.5.3", "tokio", @@ -4118,7 +4100,7 @@ dependencies = [ "futures", "futures-rustls", "libp2p-core", - "libp2p-identity 0.2.0", + "libp2p-identity", "log", "parking_lot 0.12.1", "quicksink", @@ -4598,25 +4580,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "multiaddr" -version = "0.17.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b36f567c7099511fa8612bbbb52dda2419ce0bdbacf31714e3a5ffdb766d3bd" -dependencies = [ - "arrayref", - "byteorder", - "data-encoding", - "log", - "multibase", - "multihash 0.17.0", - "percent-encoding", - "serde", - "static_assertions", - "unsigned-varint", - "url", -] - [[package]] name = "multiaddr" version = "0.18.0" @@ -4626,7 +4589,7 @@ dependencies = [ "arrayref", "byteorder", "data-encoding", - "libp2p-identity 0.2.0", + "libp2p-identity", "multibase", "multihash 0.19.0", "percent-encoding", @@ -8359,7 +8322,7 @@ dependencies = [ "fdlimit", "futures", "futures-timer", - "libp2p-identity 0.1.2", + "libp2p-identity", "log", "names", "parity-scale-codec", @@ -8460,7 +8423,7 @@ dependencies = [ "async-trait", "futures", "futures-timer", - "libp2p-identity 0.1.2", + "libp2p-identity", "log", "mockall", "parking_lot 0.12.1", @@ -8986,7 +8949,7 @@ dependencies = [ "async-channel", "cid", "futures", - "libp2p-identity 0.1.2", + "libp2p-identity", "log", "prost", "prost-build", @@ -9016,7 +8979,7 @@ dependencies = [ "bytes", "futures", "futures-timer", - "libp2p-identity 0.1.2", + "libp2p-identity", "parity-scale-codec", "prost-build", "sc-consensus", @@ -9060,7 +9023,7 @@ dependencies = [ "array-bytes 4.2.0", "async-channel", "futures", - "libp2p-identity 0.1.2", + "libp2p-identity", "log", "parity-scale-codec", "prost", diff --git a/client/cli/Cargo.toml b/client/cli/Cargo.toml index 08e3f18d3961a..0d3846b6d43e9 100644 --- a/client/cli/Cargo.toml +++ b/client/cli/Cargo.toml @@ -18,7 +18,7 @@ chrono = "0.4.10" clap = { version = "4.2.5", features = ["derive", "string"] } fdlimit = "0.2.1" futures = "0.3.21" -libp2p-identity = { version = "0.1.2", features = ["peerid", "ed25519"]} +libp2p-identity = { version = "0.2.0", features = ["peerid", "ed25519"]} log = "0.4.17" names = { version = "0.13.0", default-features = false } parity-scale-codec = "3.2.2" diff --git a/client/consensus/common/Cargo.toml b/client/consensus/common/Cargo.toml index adb6f0920beef..5a0e6776730b6 100644 --- a/client/consensus/common/Cargo.toml +++ b/client/consensus/common/Cargo.toml @@ -16,7 +16,7 @@ targets = ["x86_64-unknown-linux-gnu"] async-trait = "0.1.57" futures = { version = "0.3.21", features = ["thread-pool"] } futures-timer = "3.0.1" -libp2p-identity = { version = "0.1.2", features = ["peerid", "ed25519"] } +libp2p-identity = { version = "0.2.0", features = ["peerid", "ed25519"] } log = "0.4.17" mockall = "0.11.3" parking_lot = "0.12.1" diff --git a/client/network/bitswap/Cargo.toml b/client/network/bitswap/Cargo.toml index ac378bab18f1b..46039929e835e 100644 --- a/client/network/bitswap/Cargo.toml +++ b/client/network/bitswap/Cargo.toml @@ -19,7 +19,7 @@ prost-build = "0.11" async-channel = "1.8.0" cid = "0.8.6" futures = "0.3.21" -libp2p-identity = { version = "0.1.2", features = ["peerid"] } +libp2p-identity = { version = "0.2.0", features = ["peerid"] } log = "0.4.17" prost = "0.11" thiserror = "1.0" diff --git a/client/network/common/Cargo.toml b/client/network/common/Cargo.toml index b87508e0d8745..0253b358483b5 100644 --- a/client/network/common/Cargo.toml +++ b/client/network/common/Cargo.toml @@ -25,7 +25,7 @@ codec = { package = "parity-scale-codec", version = "3.2.2", features = [ ] } futures = "0.3.21" futures-timer = "3.0.2" -libp2p-identity = { version = "0.1.2", features = ["peerid"] } +libp2p-identity = { version = "0.2.0", features = ["peerid"] } prometheus-endpoint = { package = "substrate-prometheus-endpoint", version = "0.10.0-dev", path = "../../../utils/prometheus" } smallvec = "1.8.0" sc-consensus = { version = "0.10.0-dev", path = "../../consensus/common" } diff --git a/client/network/light/Cargo.toml b/client/network/light/Cargo.toml index 43d85a7a15699..0cf8cdac7c4dd 100644 --- a/client/network/light/Cargo.toml +++ b/client/network/light/Cargo.toml @@ -22,7 +22,7 @@ codec = { package = "parity-scale-codec", version = "3.2.2", features = [ "derive", ] } futures = "0.3.21" -libp2p-identity = { version = "0.1.2", features = ["peerid"] } +libp2p-identity = { version = "0.2.0", features = ["peerid"] } log = "0.4.16" prost = "0.11" sp-blockchain = { version = "4.0.0-dev", path = "../../../primitives/blockchain" } diff --git a/client/network/src/request_responses.rs b/client/network/src/request_responses.rs index 1eaca2b6008c4..1937367a7489e 100644 --- a/client/network/src/request_responses.rs +++ b/client/network/src/request_responses.rs @@ -336,7 +336,7 @@ impl RequestResponsesBehaviour { max_request_size: protocol.max_request_size, max_response_size: protocol.max_response_size, }, - iter::once(protocol.name) + iter::once(protocol.name.clone()) .chain(protocol.fallback_names) .zip(iter::repeat(protocol_support)), cfg, From f01de8b3ee69509abe0582b5a78f653ee472a66f Mon Sep 17 00:00:00 2001 From: Anton Kaliaev Date: Wed, 28 Jun 2023 11:37:08 +0400 Subject: [PATCH 14/42] remove non-existing methods from PollParameters rename ConnectionHandlerUpgrErr to StreamUpgradeError --- .../src/protocol/notifications/behaviour.rs | 24 +++---------------- .../src/protocol/notifications/handler.rs | 6 ++--- 2 files changed, 6 insertions(+), 24 deletions(-) diff --git a/client/network/src/protocol/notifications/behaviour.rs b/client/network/src/protocol/notifications/behaviour.rs index 8f26c78f96620..b8a303be96cb3 100644 --- a/client/network/src/protocol/notifications/behaviour.rs +++ b/client/network/src/protocol/notifications/behaviour.rs @@ -2105,7 +2105,6 @@ impl NetworkBehaviour for Notifications { mod tests { use super::*; use crate::{peerset::IncomingIndex, protocol::notifications::handler::tests::*}; - use libp2p::swarm::AddressRecord; use std::{collections::HashSet, iter}; impl PartialEq for ConnectionState { @@ -2124,31 +2123,14 @@ mod tests { } #[derive(Clone)] - struct MockPollParams { - peer_id: PeerId, - addr: Multiaddr, - } + struct MockPollParams {} impl PollParameters for MockPollParams { type SupportedProtocolsIter = std::vec::IntoIter>; - type ListenedAddressesIter = std::vec::IntoIter; - type ExternalAddressesIter = std::vec::IntoIter; fn supported_protocols(&self) -> Self::SupportedProtocolsIter { vec![].into_iter() } - - fn listened_addresses(&self) -> Self::ListenedAddressesIter { - vec![self.addr.clone()].into_iter() - } - - fn external_addresses(&self) -> Self::ExternalAddressesIter { - vec![].into_iter() - } - - fn local_peer_id(&self) -> &PeerId { - &self.peer_id - } } fn development_notifs() -> (Notifications, crate::peerset::PeersetHandle) { @@ -3669,7 +3651,7 @@ mod tests { assert!(notif.peers.get(&(peer, set_id)).is_some()); if tokio::time::timeout(Duration::from_secs(5), async { - let mut params = MockPollParams { peer_id: PeerId::random(), addr: Multiaddr::empty() }; + let mut params = MockPollParams {}; loop { futures::future::poll_fn(|cx| { @@ -3778,7 +3760,7 @@ mod tests { // verify that the code continues to keep the peer disabled by resetting the timer // after the first one expired. if tokio::time::timeout(Duration::from_secs(5), async { - let mut params = MockPollParams { peer_id: PeerId::random(), addr: Multiaddr::empty() }; + let mut params = MockPollParams {}; loop { futures::future::poll_fn(|cx| { diff --git a/client/network/src/protocol/notifications/handler.rs b/client/network/src/protocol/notifications/handler.rs index fb9d8d064ef61..660a752c07c84 100644 --- a/client/network/src/protocol/notifications/handler.rs +++ b/client/network/src/protocol/notifications/handler.rs @@ -830,7 +830,7 @@ pub mod tests { use asynchronous_codec::Framed; use libp2p::{ core::muxing::SubstreamBox, - swarm::{handler, ConnectionHandlerUpgrErr}, + swarm::{handler, StreamUpgradeError}, Multiaddr, }; use multistream_select::{dialer_select_proto, listener_select_proto, Negotiated, Version}; @@ -1451,7 +1451,7 @@ pub mod tests { // inject dial failure to an already closed substream and verify outbound state is reset handler.on_connection_event(handler::ConnectionEvent::DialUpgradeError( - handler::DialUpgradeError { info: 0, error: ConnectionHandlerUpgrErr::Timeout }, + handler::DialUpgradeError { info: 0, error: StreamUpgradeError::Timeout }, )); assert!(std::matches!( handler.protocols[0].state, @@ -1521,7 +1521,7 @@ pub mod tests { // inject dial failure to an already closed substream and verify outbound state is reset handler.on_connection_event(handler::ConnectionEvent::DialUpgradeError( - handler::DialUpgradeError { info: 0, error: ConnectionHandlerUpgrErr::Timeout }, + handler::DialUpgradeError { info: 0, error: StreamUpgradeError::Timeout }, )); assert!(std::matches!( handler.protocols[0].state, From bea250f4351be834a15e439c0eaa797b9ad43d35 Mon Sep 17 00:00:00 2001 From: Anton Kaliaev Date: Wed, 28 Jun 2023 11:47:43 +0400 Subject: [PATCH 15/42] `P2p` now contains `PeerId`, not `Multihash` --- client/authority-discovery/src/worker.rs | 7 +++---- client/authority-discovery/src/worker/addr_cache.rs | 4 ++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/client/authority-discovery/src/worker.rs b/client/authority-discovery/src/worker.rs index a29e74df9accc..aa6f737e054bd 100644 --- a/client/authority-discovery/src/worker.rs +++ b/client/authority-discovery/src/worker.rs @@ -34,8 +34,7 @@ use futures::{channel::mpsc, future, stream::Fuse, FutureExt, Stream, StreamExt} use addr_cache::AddrCache; use codec::{Decode, Encode}; use ip_network::IpNetwork; -use libp2p::{core::multiaddr, identity::PublicKey, multihash::Multihash, Multiaddr, PeerId}; -use multihash::{Code, MultihashDigest}; +use libp2p::{core::multiaddr, identity::PublicKey, Multiaddr, PeerId}; use log::{debug, error, log_enabled}; use prometheus_endpoint::{register, Counter, CounterVec, Gauge, Opts, U64}; @@ -304,7 +303,7 @@ where } fn addresses_to_publish(&self) -> impl Iterator { - let peer_id: Multihash = self.network.local_peer_id().into(); + let peer_id = self.network.local_peer_id(); let publish_non_global_ips = self.publish_non_global_ips; self.network .external_addresses() @@ -529,7 +528,7 @@ where .map_err(Error::ParsingMultiaddress)?; let get_peer_id = |a: &Multiaddr| match a.iter().last() { - Some(multiaddr::Protocol::P2p(key)) => PeerId::from_multihash(key).ok(), + Some(multiaddr::Protocol::P2p(peer_id)) => Some(peer_id), _ => None, }; diff --git a/client/authority-discovery/src/worker/addr_cache.rs b/client/authority-discovery/src/worker/addr_cache.rs index 8084b7f0a6dff..5a162b16539d4 100644 --- a/client/authority-discovery/src/worker/addr_cache.rs +++ b/client/authority-discovery/src/worker/addr_cache.rs @@ -162,8 +162,8 @@ impl AddrCache { fn peer_id_from_multiaddr(addr: &Multiaddr) -> Option { addr.iter().last().and_then(|protocol| { - if let Protocol::P2p(multihash) = protocol { - PeerId::from_multihash(multihash).ok() + if let Protocol::P2p(peer_id) = protocol { + Some(peer_id) } else { None } From 405ebcb515f17013d78f1255d66a27b28537a715 Mon Sep 17 00:00:00 2001 From: Anton Kaliaev Date: Wed, 28 Jun 2023 17:37:36 +0400 Subject: [PATCH 16/42] use multihash-codetable crate --- Cargo.lock | 101 ++++++++++++++---- client/authority-discovery/Cargo.toml | 2 +- client/authority-discovery/src/worker.rs | 3 +- .../src/worker/addr_cache.rs | 15 ++- 4 files changed, 93 insertions(+), 28 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7b97c0d43b343..083a7e4a07f42 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -759,6 +759,7 @@ dependencies = [ "cc", "cfg-if", "constant_time_eq", + "digest 0.10.7", ] [[package]] @@ -4621,7 +4622,7 @@ dependencies = [ "blake3", "core2", "digest 0.10.7", - "multihash-derive", + "multihash-derive 0.8.0", "sha2 0.10.7", "sha3", "unsigned-varint", @@ -4629,32 +4630,63 @@ dependencies = [ [[package]] name = "multihash" -version = "0.17.0" +version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "835d6ff01d610179fbce3de1694d007e500bf33a7f29689838941d6bf783ae40" +checksum = "2fd59dcc2bbe70baabeac52cd22ae52c55eefe6c38ff11a9439f16a350a939f2" dependencies = [ "core2", - "digest 0.10.7", - "multihash-derive", - "sha2 0.10.7", "unsigned-varint", ] [[package]] -name = "multihash" -version = "0.19.0" +name = "multihash-codetable" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fd59dcc2bbe70baabeac52cd22ae52c55eefe6c38ff11a9439f16a350a939f2" +checksum = "e46d7ff0b9b8d818e709e12135bfb6582fcde982ba2be48ea52e6e1df098c7a4" dependencies = [ + "blake2b_simd", + "blake2s_simd", + "blake3", "core2", - "unsigned-varint", + "digest 0.10.7", + "multihash-derive 0.9.0", + "ripemd", + "sha-1 0.10.1", + "sha2 0.10.7", + "sha3", + "strobe-rs", ] [[package]] name = "multihash-derive" -version = "0.8.1" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d6d4752e6230d8ef7adf7bd5d8c4b1f6561c1014c5ba9a37445ccefe18aa1db" +checksum = "fc076939022111618a5026d3be019fd8b366e76314538ff9a1b59ffbcbf98bcd" +dependencies = [ + "proc-macro-crate", + "proc-macro-error", + "proc-macro2", + "quote", + "syn 1.0.109", + "synstructure", +] + +[[package]] +name = "multihash-derive" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "890e72cb7396cb99ed98c1246a97b243cc16394470d94e0bc8b0c2c11d84290e" +dependencies = [ + "core2", + "multihash 0.19.0", + "multihash-derive-impl", +] + +[[package]] +name = "multihash-derive-impl" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d38685e08adb338659871ecfc6ee47ba9b22dcc8abcf6975d379cc49145c3040" dependencies = [ "proc-macro-crate", "proc-macro-error", @@ -7515,12 +7547,12 @@ dependencies = [ [[package]] name = "proc-macro-crate" -version = "1.1.3" +version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e17d47ce914bf4de440332250b0edd23ce48c005f59fab39d3335866b114f11a" +checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" dependencies = [ - "thiserror", - "toml 0.5.11", + "once_cell", + "toml_edit", ] [[package]] @@ -7976,6 +8008,15 @@ dependencies = [ "winapi", ] +[[package]] +name = "ripemd" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd124222d17ad93a644ed9d011a40f4fb64aa54275c08cc216524a9ea82fb09f" +dependencies = [ + "digest 0.10.7", +] + [[package]] name = "rocksdb" version = "0.21.0" @@ -8222,7 +8263,7 @@ dependencies = [ "ip_network", "libp2p", "log", - "multihash 0.17.0", + "multihash-codetable", "parity-scale-codec", "prost", "prost-build", @@ -9861,6 +9902,17 @@ dependencies = [ "opaque-debug 0.3.0", ] +[[package]] +name = "sha-1" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f5058ada175748e33390e40e872bd0fe59a19f265d0158daa551c5a88a76009c" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest 0.10.7", +] + [[package]] name = "sha2" version = "0.8.2" @@ -10043,7 +10095,7 @@ dependencies = [ "httparse", "log", "rand 0.8.5", - "sha-1", + "sha-1 0.9.8", ] [[package]] @@ -11094,6 +11146,19 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "strobe-rs" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fabb238a1cccccfa4c4fb703670c0d157e1256c1ba695abf1b93bd2bb14bab2d" +dependencies = [ + "bitflags", + "byteorder", + "keccak", + "subtle", + "zeroize", +] + [[package]] name = "strsim" version = "0.10.0" diff --git a/client/authority-discovery/Cargo.toml b/client/authority-discovery/Cargo.toml index d95a40f65313e..f434b8a7f4e34 100644 --- a/client/authority-discovery/Cargo.toml +++ b/client/authority-discovery/Cargo.toml @@ -22,7 +22,7 @@ futures = "0.3.21" futures-timer = "3.0.1" ip_network = "0.4.1" libp2p = { version = "0.52.0", features = ["kad", "ed25519"] } -multihash = { version = "0.17.0", default-features = false, features = ["std", "sha2"] } +multihash-codetable = { version = "0.1.0", features = ["std", "sha2", "digest"] } log = "0.4.17" prost = "0.11" rand = "0.8.5" diff --git a/client/authority-discovery/src/worker.rs b/client/authority-discovery/src/worker.rs index aa6f737e054bd..2552646c12559 100644 --- a/client/authority-discovery/src/worker.rs +++ b/client/authority-discovery/src/worker.rs @@ -34,7 +34,8 @@ use futures::{channel::mpsc, future, stream::Fuse, FutureExt, Stream, StreamExt} use addr_cache::AddrCache; use codec::{Decode, Encode}; use ip_network::IpNetwork; -use libp2p::{core::multiaddr, identity::PublicKey, Multiaddr, PeerId}; +use libp2p::{core::multiaddr, identity::PublicKey, Multiaddr}; +use multihash_codetable::{Code, MultihashDigest}; use log::{debug, error, log_enabled}; use prometheus_endpoint::{register, Counter, CounterVec, Gauge, Opts, U64}; diff --git a/client/authority-discovery/src/worker/addr_cache.rs b/client/authority-discovery/src/worker/addr_cache.rs index 5a162b16539d4..e3e17c0f0aad5 100644 --- a/client/authority-discovery/src/worker/addr_cache.rs +++ b/client/authority-discovery/src/worker/addr_cache.rs @@ -179,6 +179,7 @@ mod tests { use super::*; use libp2p::multihash::{self, Multihash}; + use multihash_codetable::Code; use quickcheck::{Arbitrary, Gen, QuickCheck, TestResult}; use sp_authority_discovery::{AuthorityId, AuthorityPair}; @@ -200,10 +201,9 @@ mod tests { impl Arbitrary for TestMultiaddr { fn arbitrary(g: &mut Gen) -> Self { let seed = (0..32).map(|_| u8::arbitrary(g)).collect::>(); - let peer_id = PeerId::from_multihash( - Multihash::wrap(multihash::Code::Sha2_256.into(), &seed).unwrap(), - ) - .unwrap(); + let peer_id = + PeerId::from_multihash(Multihash::wrap(Code::Sha2_256.into(), &seed).unwrap()) + .unwrap(); let multiaddr = "/ip6/2001:db8:0:0:0:0:0:2/tcp/30333" .parse::() .unwrap() @@ -219,10 +219,9 @@ mod tests { impl Arbitrary for TestMultiaddrsSamePeerCombo { fn arbitrary(g: &mut Gen) -> Self { let seed = (0..32).map(|_| u8::arbitrary(g)).collect::>(); - let peer_id = PeerId::from_multihash( - Multihash::wrap(multihash::Code::Sha2_256.into(), &seed).unwrap(), - ) - .unwrap(); + let peer_id = + PeerId::from_multihash(Multihash::wrap(Code::Sha2_256.into(), &seed).unwrap()) + .unwrap(); let multiaddr1 = "/ip6/2001:db8:0:0:0:0:0:2/tcp/30333" .parse::() .unwrap() From ac5cfd34dcaf162f6d1cf2b56b05395743d598cd Mon Sep 17 00:00:00 2001 From: Anton Kaliaev Date: Wed, 28 Jun 2023 17:49:06 +0400 Subject: [PATCH 17/42] update Cargo.lock --- Cargo.lock | 1573 +++++++++------------------------------------------- 1 file changed, 255 insertions(+), 1318 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d3c376952b7be..0f6522383d80d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -27,15 +27,6 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" -[[package]] -name = "aead" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fc95d1bdb8e6666b2b217308eeeb09f2d6728d104be3e31916cc74d15420331" -dependencies = [ - "generic-array 0.14.7", -] - [[package]] name = "aead" version = "0.4.3" @@ -43,28 +34,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b613b8e1e3cf911a086f53f03bf286f52fd7a7258e4fa606f0ef220d39d8877" dependencies = [ "generic-array 0.14.7", - "rand_core 0.6.4", -] - -[[package]] -name = "aead" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d122413f284cf2d62fb1b7db97e02edb8cda96d769b16e443a4f6195e35662b0" -dependencies = [ - "crypto-common", - "generic-array 0.14.7", -] - -[[package]] -name = "aes" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "884391ef1066acaa41e766ba8f596341b96e93ce34f9a43e7d24bf0a0eaf0561" -dependencies = [ - "aes-soft", - "aesni", - "cipher 0.2.5", ] [[package]] @@ -74,70 +43,25 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9e8b47f52ea9bae42228d07ec09eb676433d7c4ed1ebdf0f1d1c29ed446f1ab8" dependencies = [ "cfg-if", - "cipher 0.3.0", + "cipher", "cpufeatures", "opaque-debug 0.3.0", ] -[[package]] -name = "aes" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "433cfd6710c9986c576a25ca913c39d66a6474107b406f34f91d4a8923395241" -dependencies = [ - "cfg-if", - "cipher 0.4.4", - "cpufeatures", -] - [[package]] name = "aes-gcm" version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "df5f85a83a7d8b0442b6aa7b504b8212c1733da07b98aae43d4bc21b2cb3cdf6" dependencies = [ - "aead 0.4.3", - "aes 0.7.5", - "cipher 0.3.0", - "ctr 0.8.0", - "ghash 0.4.4", - "subtle", -] - -[[package]] -name = "aes-gcm" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "209b47e8954a928e1d72e86eca7000ebb6655fe1436d33eefc2201cad027e237" -dependencies = [ - "aead 0.5.2", - "aes 0.8.2", - "cipher 0.4.4", - "ctr 0.9.2", - "ghash 0.5.0", + "aead", + "aes", + "cipher", + "ctr", + "ghash", "subtle", ] -[[package]] -name = "aes-soft" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be14c7498ea50828a38d0e24a765ed2effe92a705885b57d029cd67d45744072" -dependencies = [ - "cipher 0.2.5", - "opaque-debug 0.3.0", -] - -[[package]] -name = "aesni" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea2e11f5e94c2f7d386164cc2aa1f97823fed6f259e486940a71c174dd01b0ce" -dependencies = [ - "cipher 0.2.5", - "opaque-debug 0.3.0", -] - [[package]] name = "ahash" version = "0.7.6" @@ -279,12 +203,6 @@ version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2d098ff73c1ca148721f37baad5ea6a465a13f9573aba8641fbbbae8164a54e" -[[package]] -name = "arc-swap" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bddcadddf5e9015d310179a59bb28c4d4b9920ad0f11e8e14dbadf654890c9a6" - [[package]] name = "ark-algebra-test-templates" version = "0.4.2" @@ -302,7 +220,7 @@ dependencies = [ "serde", "serde_derive", "serde_json", - "sha2 0.10.6", + "sha2 0.10.7", ] [[package]] @@ -537,76 +455,9 @@ checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" [[package]] name = "arrayvec" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8da52d66c7071e2e3fa2a1e5c6d088fec47b593032b254f5e980de8ea54454d6" - -[[package]] -name = "asn1-rs" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30ff05a702273012438132f449575dbc804e27b2f3cbe3069aa237d26c98fa33" -dependencies = [ - "asn1-rs-derive 0.1.0", - "asn1-rs-impl", - "displaydoc", - "nom", - "num-traits", - "rusticata-macros", - "thiserror", - "time 0.3.21", -] - -[[package]] -name = "asn1-rs" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f6fd5ddaf0351dff5b8da21b2fb4ff8e08ddd02857f0bf69c47639106c0fff0" -dependencies = [ - "asn1-rs-derive 0.4.0", - "asn1-rs-impl", - "displaydoc", - "nom", - "num-traits", - "rusticata-macros", - "thiserror", - "time 0.3.21", -] - -[[package]] -name = "asn1-rs-derive" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db8b7511298d5b7784b40b092d9e9dcd3a627a5707e4b5e507931ab0d44eeebf" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", - "synstructure", -] - -[[package]] -name = "asn1-rs-derive" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "726535892e8eae7e70657b4c8ea93d26b8553afb1ce617caee529ef96d7dee6c" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", - "synstructure", -] - -[[package]] -name = "asn1-rs-impl" -version = "0.1.0" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2777730b2039ac0f95f093556e61b6d26cebed5393ca6f152717777cec3a42ed" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] +checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" [[package]] name = "assert_cmd" @@ -656,7 +507,7 @@ dependencies = [ "polling", "rustix 0.37.19", "slab", - "socket2", + "socket2 0.4.9", "waker-fn", ] @@ -726,12 +577,6 @@ dependencies = [ "pin-project-lite 0.2.9", ] -[[package]] -name = "atomic-waker" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1181e1e0d1fce796a03db1ae795d67167da795f9cf4a39c37589e85ef57f26d3" - [[package]] name = "atty" version = "0.2.14" @@ -770,12 +615,6 @@ version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4cbbc9d0964165b47557570cce6c952866c2678457aca742aafc9fb771d30270" -[[package]] -name = "base16ct" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "349a06037c7bf932dd7e7d1f653678b2038b9ad46a74102f1fc7bd7872678cce" - [[package]] name = "base64" version = "0.13.1" @@ -788,12 +627,6 @@ version = "0.21.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "604178f6c5c21f02dc555784810edfb88d34ac2c73b2eae109655649ee73ce3d" -[[package]] -name = "base64ct" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" - [[package]] name = "basic-toml" version = "0.1.2" @@ -888,7 +721,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c2f0dc9a68c6317d884f97cc36cf5a3d20ba14ce404227df55e1af708ab04bc" dependencies = [ "arrayref", - "arrayvec 0.7.2", + "arrayvec 0.7.4", "constant_time_eq", ] @@ -899,7 +732,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6637f448b9e61dfadbdcbae9a885fadee1f3eaffb1f8d3c1965d3ade8bdfd44f" dependencies = [ "arrayref", - "arrayvec 0.7.2", + "arrayvec 0.7.4", "constant_time_eq", ] @@ -910,10 +743,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42ae2468a89544a466886840aa467a25b766499f4f04bf7d9fcd10ecee9fccef" dependencies = [ "arrayref", - "arrayvec 0.7.2", + "arrayvec 0.7.4", "cc", "cfg-if", "constant_time_eq", + "digest 0.10.7", ] [[package]] @@ -922,7 +756,7 @@ version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b" dependencies = [ - "block-padding 0.1.5", + "block-padding", "byte-tools", "byteorder", "generic-array 0.12.4", @@ -946,16 +780,6 @@ dependencies = [ "generic-array 0.14.7", ] -[[package]] -name = "block-modes" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57a0e8073e8baa88212fb5823574c02ebccb395136ba9a164ab89379ec6072f0" -dependencies = [ - "block-padding 0.2.1", - "cipher 0.2.5", -] - [[package]] name = "block-padding" version = "0.1.5" @@ -965,12 +789,6 @@ dependencies = [ "byte-tools", ] -[[package]] -name = "block-padding" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d696c370c750c948ada61c69a0ee2cbbb9c50b1019ddb86d9317157a99c2cae" - [[package]] name = "bounded-collections" version = "0.1.8" @@ -989,6 +807,15 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "771fe0050b883fcc3ea2359b1a96bcfbc090b7116eae7c3c512c7a083fdf23d3" +[[package]] +name = "bs58" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f5353f36341f7451062466f0b755b96ac3a9547e4d7f6b70d603fc721a7d7896" +dependencies = [ + "tinyvec", +] + [[package]] name = "bstr" version = "1.5.0" @@ -1104,17 +931,6 @@ dependencies = [ "jobserver", ] -[[package]] -name = "ccm" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aca1a8fbc20b50ac9673ff014abfb2b5f4085ee1a850d408f14a159c5853ac7" -dependencies = [ - "aead 0.3.2", - "cipher 0.2.5", - "subtle", -] - [[package]] name = "cexpr" version = "0.6.0" @@ -1152,7 +968,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5c80e5460aa66fe3b91d40bcbdab953a597b60053e34d684ac6903f863b680a6" dependencies = [ "cfg-if", - "cipher 0.3.0", + "cipher", "cpufeatures", "zeroize", ] @@ -1163,9 +979,9 @@ version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a18446b09be63d457bbec447509e85f662f32952b035ce892290396bc0b0cff5" dependencies = [ - "aead 0.4.3", + "aead", "chacha20", - "cipher 0.3.0", + "cipher", "poly1305", "zeroize", ] @@ -1194,7 +1010,7 @@ dependencies = [ "iana-time-zone", "js-sys", "num-traits", - "time 0.1.45", + "time", "wasm-bindgen", "winapi", ] @@ -1239,15 +1055,6 @@ dependencies = [ "unsigned-varint", ] -[[package]] -name = "cipher" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12f8e7987cbd042a63249497f41aed09f8e65add917ea6566effbc56578d6801" -dependencies = [ - "generic-array 0.14.7", -] - [[package]] name = "cipher" version = "0.3.0" @@ -1257,16 +1064,6 @@ dependencies = [ "generic-array 0.14.7", ] -[[package]] -name = "cipher" -version = "0.4.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad" -dependencies = [ - "crypto-common", - "inout", -] - [[package]] name = "ckb-merkle-mountain-range" version = "0.5.2" @@ -1414,12 +1211,6 @@ dependencies = [ "windows-sys 0.45.0", ] -[[package]] -name = "const-oid" -version = "0.9.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "520fbf3c07483f94e3e3ca9d0cfd913d7718ef2483d2cfd91c0d9e91474ab913" - [[package]] name = "constant_time_eq" version = "0.2.5" @@ -1573,21 +1364,6 @@ dependencies = [ "wasmtime-types", ] -[[package]] -name = "crc" -version = "3.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86ec7a15cbe22e59248fc7eadb1907dab5ba09372595da4d73dd805ed4417dfe" -dependencies = [ - "crc-catalog", -] - -[[package]] -name = "crc-catalog" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cace84e55f07e7301bae1c519df89cdad8cc3cd868413d3fdbdeca9ff3db484" - [[package]] name = "crc32fast" version = "1.3.2" @@ -1684,18 +1460,6 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" -[[package]] -name = "crypto-bigint" -version = "0.4.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef2b4b23cddf68b89b8f8069890e8c270d54e2d5fe1b143820234805e4cb17ef" -dependencies = [ - "generic-array 0.14.7", - "rand_core 0.6.4", - "subtle", - "zeroize", -] - [[package]] name = "crypto-common" version = "0.1.6" @@ -1703,7 +1467,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" dependencies = [ "generic-array 0.14.7", - "rand_core 0.6.4", "typenum", ] @@ -1743,16 +1506,7 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "049bb91fb4aaf0e3c7efa6cd5ef877dbbbd15b39dad06d9948de4ec8a75761ea" dependencies = [ - "cipher 0.3.0", -] - -[[package]] -name = "ctr" -version = "0.9.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0369ee1ad671834580515889b80f2ea915f23b8be8d0daa4bbaf2ac5c7590835" -dependencies = [ - "cipher 0.4.4", + "cipher", ] [[package]] @@ -1839,41 +1593,6 @@ dependencies = [ "syn 2.0.18", ] -[[package]] -name = "darling" -version = "0.14.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b750cb3417fd1b327431a470f388520309479ab0bf5e323505daf0290cd3850" -dependencies = [ - "darling_core", - "darling_macro", -] - -[[package]] -name = "darling_core" -version = "0.14.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "109c1ca6e6b7f82cc233a97004ea8ed7ca123a9af07a8230878fcfda9b158bf0" -dependencies = [ - "fnv", - "ident_case", - "proc-macro2", - "quote", - "strsim", - "syn 1.0.109", -] - -[[package]] -name = "darling_macro" -version = "0.14.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4aab4dbc9f7611d8b55048a3a16d2d010c2c8334e46304b40ac1cc14bf3b48e" -dependencies = [ - "darling_core", - "quote", - "syn 1.0.109", -] - [[package]] name = "data-encoding" version = "2.4.0" @@ -1900,45 +1619,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "der" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1a467a65c5e759bce6e65eaf91cc29f466cdc57cb65777bd646872a8a1fd4de" -dependencies = [ - "const-oid", - "pem-rfc7468", - "zeroize", -] - -[[package]] -name = "der-parser" -version = "7.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe398ac75057914d7d07307bf67dc7f3f574a26783b4fc7805a20ffa9f506e82" -dependencies = [ - "asn1-rs 0.3.1", - "displaydoc", - "nom", - "num-bigint", - "num-traits", - "rusticata-macros", -] - -[[package]] -name = "der-parser" -version = "8.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbd676fbbab537128ef0278adb5576cf363cff6aa22a7b24effe97347cfab61e" -dependencies = [ - "asn1-rs 0.5.2", - "displaydoc", - "nom", - "num-bigint", - "num-traits", - "rusticata-macros", -] - [[package]] name = "derivative" version = "2.2.0" @@ -1961,37 +1641,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "derive_builder" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d07adf7be193b71cc36b193d0f5fe60b918a3a9db4dad0449f57bcfd519704a3" -dependencies = [ - "derive_builder_macro", -] - -[[package]] -name = "derive_builder_core" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f91d4cfa921f1c05904dc3c57b4a32c38aed3340cce209f3a6fd1478babafc4" -dependencies = [ - "darling", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "derive_builder_macro" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f0314b72bed045f3a68671b3c86328386762c93f82d98c65c3cb5e5f573dd68" -dependencies = [ - "derive_builder_core", - "syn 1.0.109", -] - [[package]] name = "derive_more" version = "0.99.17" @@ -2085,17 +1734,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "displaydoc" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.18", -] - [[package]] name = "dissimilar" version = "1.0.6" @@ -2180,18 +1818,6 @@ version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "68b0cf012f1230e43cd00ebb729c6bb58707ecfa8ad08b52ef3a4ccd2697fc30" -[[package]] -name = "ecdsa" -version = "0.14.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "413301934810f597c1d19ca71c8710e99a3f1ba28a0d2ebc01551a2daeea3c5c" -dependencies = [ - "der", - "elliptic-curve", - "rfc6979", - "signature", -] - [[package]] name = "ed25519" version = "1.5.3" @@ -2235,28 +1861,6 @@ version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91" -[[package]] -name = "elliptic-curve" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7bb888ab5300a19b8e5bceef25ac745ad065f3c9f7efc6de1b91958110891d3" -dependencies = [ - "base16ct", - "crypto-bigint", - "der", - "digest 0.10.7", - "ff", - "generic-array 0.14.7", - "group", - "hkdf", - "pem-rfc7468", - "pkcs8", - "rand_core 0.6.4", - "sec1", - "subtle", - "zeroize", -] - [[package]] name = "encode_unicode" version = "0.3.6" @@ -2406,16 +2010,6 @@ dependencies = [ "libc", ] -[[package]] -name = "ff" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d013fc25338cc558c5c2cfbad646908fb23591e2404481826742b651c9af7160" -dependencies = [ - "rand_core 0.6.4", - "subtle", -] - [[package]] name = "fiat-crypto" version = "0.1.20" @@ -2486,7 +2080,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3b9429470923de8e8cbd4d2dc513535400b4b3fef0319fb5c4e1f520a7bef743" dependencies = [ "crc32fast", - "libz-sys", "miniz_oxide 0.7.1", ] @@ -3033,7 +2626,7 @@ checksum = "d2411eed028cdf8c8034eaf21f9915f956b6c3abec4d4c7949ee67f0721127bd" dependencies = [ "futures-io", "rustls 0.20.8", - "webpki 0.22.0", + "webpki", ] [[package]] @@ -3153,17 +2746,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1583cc1656d7839fd3732b80cf4f38850336cdb9b8ded1cd399ca62958de3c99" dependencies = [ "opaque-debug 0.3.0", - "polyval 0.5.3", -] - -[[package]] -name = "ghash" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d930750de5717d2dd0b8c0d42c076c0e884c81a73e6cab859bbd2339c71e3e40" -dependencies = [ - "opaque-debug 0.3.0", - "polyval 0.6.0", + "polyval", ] [[package]] @@ -3196,17 +2779,6 @@ dependencies = [ "regex", ] -[[package]] -name = "group" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5dfbfb3a6cfbd390d5c9564ab283a0349b9b9fcd46a706c1eb10e0db70bfbac7" -dependencies = [ - "ff", - "rand_core 0.6.4", - "subtle", -] - [[package]] name = "h2" version = "0.3.19" @@ -3321,15 +2893,6 @@ version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ebdb29d2ea9ed0083cd8cece49bbd968021bd99b0849edb4a9a7ee0fdf6a4e0" -[[package]] -name = "hkdf" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "791a029f6b9fc27657f6f188ec6e5e43f6911f6f878e0dc5501396e09809d437" -dependencies = [ - "hmac 0.12.1", -] - [[package]] name = "hmac" version = "0.8.1" @@ -3456,7 +3019,7 @@ dependencies = [ "httpdate", "itoa", "pin-project-lite 0.2.9", - "socket2", + "socket2 0.4.9", "tokio", "tower-service", "tracing", @@ -3476,7 +3039,7 @@ dependencies = [ "rustls-native-certs", "tokio", "tokio-rustls 0.23.4", - "webpki-roots", + "webpki-roots 0.22.6", ] [[package]] @@ -3517,12 +3080,6 @@ dependencies = [ "cc", ] -[[package]] -name = "ident_case" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" - [[package]] name = "idna" version = "0.2.3" @@ -3643,15 +3200,6 @@ dependencies = [ "unicode-width", ] -[[package]] -name = "inout" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0c10553d664a4d0bcff9f4215d0aac67a639cc68ef660840afe309b807bc9f5" -dependencies = [ - "generic-array 0.14.7", -] - [[package]] name = "instant" version = "0.1.12" @@ -3670,25 +3218,6 @@ dependencies = [ "num-traits", ] -[[package]] -name = "interceptor" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e8a11ae2da61704edada656798b61c94b35ecac2c58eb955156987d5e6be90b" -dependencies = [ - "async-trait", - "bytes", - "log", - "rand 0.8.5", - "rtcp", - "rtp", - "thiserror", - "tokio", - "waitgroup", - "webrtc-srtp", - "webrtc-util", -] - [[package]] name = "io-lifetimes" version = "1.0.11" @@ -3712,7 +3241,7 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bd302af1b90f2463a98fa5ad469fc212c8e3175a41c3068601bfa2727591c5be" dependencies = [ - "socket2", + "socket2 0.4.9", "widestring", "winapi", "winreg", @@ -3802,7 +3331,7 @@ dependencies = [ "tokio-rustls 0.23.4", "tokio-util", "tracing", - "webpki-roots", + "webpki-roots 0.22.6", ] [[package]] @@ -3812,7 +3341,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a4e70b4439a751a5de7dd5ed55eacff78ebf4ffe0fc009cb1ebb11417f5b536b" dependencies = [ "anyhow", - "arrayvec 0.7.2", + "arrayvec 0.7.4", "async-lock", "async-trait", "beef", @@ -4123,9 +3652,9 @@ checksum = "f7012b1bbb0719e1097c47611d3898568c546d597c2e74d66f6087edd5233ff4" [[package]] name = "libp2p" -version = "0.51.3" +version = "0.52.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f210d259724eae82005b5c48078619b7745edb7b76de370b03f8ba59ea103097" +checksum = "38039ba2df4f3255842050845daef4a004cc1f26da03dbc645535088b51910ef" dependencies = [ "bytes", "futures", @@ -4143,12 +3672,10 @@ dependencies = [ "libp2p-metrics", "libp2p-noise", "libp2p-ping", - "libp2p-quic", "libp2p-request-response", "libp2p-swarm", "libp2p-tcp", "libp2p-wasm-ext", - "libp2p-webrtc", "libp2p-websocket", "libp2p-yamux", "multiaddr", @@ -4157,9 +3684,9 @@ dependencies = [ [[package]] name = "libp2p-allow-block-list" -version = "0.1.1" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "510daa05efbc25184458db837f6f9a5143888f1caa742426d92e1833ddd38a50" +checksum = "55b46558c5c0bf99d3e2a1a38fd54ff5476ca66dd1737b12466a1824dd219311" dependencies = [ "libp2p-core", "libp2p-identity", @@ -4169,9 +3696,9 @@ dependencies = [ [[package]] name = "libp2p-connection-limits" -version = "0.1.0" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4caa33f1d26ed664c4fe2cca81a08c8e07d4c1c04f2f4ac7655c2dd85467fda0" +checksum = "d45dd90e8f0e1fa59e85ff5316dd4d1ac41a9a507e79cda1b0e9b7be43ad1a56" dependencies = [ "libp2p-core", "libp2p-identity", @@ -4181,9 +3708,9 @@ dependencies = [ [[package]] name = "libp2p-core" -version = "0.39.2" +version = "0.40.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c1df63c0b582aa434fb09b2d86897fa2b419ffeccf934b36f87fcedc8e835c2" +checksum = "ef7dd7b09e71aac9271c60031d0e558966cdb3253ba0308ab369bb2de80630d0" dependencies = [ "either", "fnv", @@ -4193,8 +3720,8 @@ dependencies = [ "libp2p-identity", "log", "multiaddr", - "multihash 0.17.0", - "multistream-select", + "multihash 0.19.0", + "multistream-select 0.13.0", "once_cell", "parking_lot 0.12.1", "pin-project", @@ -4209,12 +3736,13 @@ dependencies = [ [[package]] name = "libp2p-dns" -version = "0.39.0" +version = "0.40.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "146ff7034daae62077c415c2376b8057368042df6ab95f5432ad5e88568b1554" +checksum = "fd4394c81c0c06d7b4a60f3face7e8e8a9b246840f98d2c80508d0721b032147" dependencies = [ "futures", "libp2p-core", + "libp2p-identity", "log", "parking_lot 0.12.1", "smallvec", @@ -4223,9 +3751,9 @@ dependencies = [ [[package]] name = "libp2p-identify" -version = "0.42.2" +version = "0.43.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5455f472243e63b9c497ff320ded0314254a9eb751799a39c283c6f20b793f3c" +checksum = "6a29675a32dbcc87790db6cf599709e64308f1ae9d5ecea2d259155889982db8" dependencies = [ "asynchronous-codec", "either", @@ -4245,29 +3773,28 @@ dependencies = [ [[package]] name = "libp2p-identity" -version = "0.1.2" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e2d584751cecb2aabaa56106be6be91338a60a0f4e420cf2af639204f596fc1" +checksum = "d2874d9c6575f1d7a151022af5c42bb0ffdcdfbafe0a6fd039de870b384835a2" dependencies = [ - "bs58", + "bs58 0.5.0", "ed25519-dalek", "log", - "multiaddr", - "multihash 0.17.0", + "multihash 0.19.0", "quick-protobuf", "rand 0.8.5", - "sha2 0.10.6", + "sha2 0.10.7", "thiserror", "zeroize", ] [[package]] name = "libp2p-kad" -version = "0.43.3" +version = "0.44.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39d5ef876a2b2323d63c258e63c2f8e36f205fe5a11f0b3095d59635650790ff" +checksum = "5588b884dcb1dadc04e49de342f634f60cf28b6beaaca5a4fe3dd1f09bb30041" dependencies = [ - "arrayvec 0.7.2", + "arrayvec 0.7.4", "asynchronous-codec", "bytes", "either", @@ -4281,7 +3808,7 @@ dependencies = [ "log", "quick-protobuf", "rand 0.8.5", - "sha2 0.10.6", + "sha2 0.10.7", "smallvec", "thiserror", "uint", @@ -4291,9 +3818,9 @@ dependencies = [ [[package]] name = "libp2p-mdns" -version = "0.43.1" +version = "0.44.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19983e1f949f979a928f2c603de1cf180cc0dc23e4ac93a62651ccb18341460b" +checksum = "42a2567c305232f5ef54185e9604579a894fd0674819402bb0ac0246da82f52a" dependencies = [ "data-encoding", "futures", @@ -4304,7 +3831,7 @@ dependencies = [ "log", "rand 0.8.5", "smallvec", - "socket2", + "socket2 0.5.3", "tokio", "trust-dns-proto", "void", @@ -4312,23 +3839,26 @@ dependencies = [ [[package]] name = "libp2p-metrics" -version = "0.12.0" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a42ec91e227d7d0dafa4ce88b333cdf5f277253873ab087555c92798db2ddd46" +checksum = "3787ea81798dcc5bf1d8b40a8e8245cf894b168d04dd70aa48cb3ff2fff141d2" dependencies = [ + "instant", "libp2p-core", "libp2p-identify", + "libp2p-identity", "libp2p-kad", "libp2p-ping", "libp2p-swarm", + "once_cell", "prometheus-client", ] [[package]] name = "libp2p-noise" -version = "0.42.2" +version = "0.43.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c3673da89d29936bc6435bafc638e2f184180d554ce844db65915113f86ec5e" +checksum = "87945db2b3f977af09b62b9aa0a5f3e4870995a577ecd845cdeba94cdf6bbca7" dependencies = [ "bytes", "curve25519-dalek 3.2.0", @@ -4336,61 +3866,42 @@ dependencies = [ "libp2p-core", "libp2p-identity", "log", + "multiaddr", + "multihash 0.19.0", "once_cell", "quick-protobuf", "rand 0.8.5", - "sha2 0.10.6", + "sha2 0.10.7", "snow", "static_assertions", "thiserror", - "x25519-dalek 1.1.1", + "x25519-dalek", "zeroize", ] [[package]] name = "libp2p-ping" -version = "0.42.0" +version = "0.43.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e57759c19c28a73ef1eb3585ca410cefb72c1a709fcf6de1612a378e4219202" +checksum = "3cd5ee3270229443a2b34b27ed0cb7470ef6b4a6e45e54e89a8771fa683bab48" dependencies = [ "either", "futures", "futures-timer", "instant", "libp2p-core", + "libp2p-identity", "libp2p-swarm", "log", "rand 0.8.5", "void", ] -[[package]] -name = "libp2p-quic" -version = "0.7.0-alpha.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6b26abd81cd2398382a1edfe739b539775be8a90fa6914f39b2ab49571ec735" -dependencies = [ - "bytes", - "futures", - "futures-timer", - "if-watch", - "libp2p-core", - "libp2p-identity", - "libp2p-tls", - "log", - "parking_lot 0.12.1", - "quinn-proto", - "rand 0.8.5", - "rustls 0.20.8", - "thiserror", - "tokio", -] - [[package]] name = "libp2p-request-response" -version = "0.24.1" +version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ffdb374267d42dc5ed5bc53f6e601d4a64ac5964779c6e40bb9e4f14c1e30d5" +checksum = "20bd837798cdcce4283d2675f08bcd3756a650d56eab4d4367e1b3f27eed6887" dependencies = [ "async-trait", "futures", @@ -4398,15 +3909,17 @@ dependencies = [ "libp2p-core", "libp2p-identity", "libp2p-swarm", + "log", "rand 0.8.5", "smallvec", + "void", ] [[package]] name = "libp2p-swarm" -version = "0.42.2" +version = "0.43.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "903b3d592d7694e56204d211f29d31bc004be99386644ba8731fc3e3ef27b296" +checksum = "a6f1fe3817492f88c5298c8b5fbaa5ff3a0c802ecf4e79be4e341cf07abfa82f" dependencies = [ "either", "fnv", @@ -4417,6 +3930,8 @@ dependencies = [ "libp2p-identity", "libp2p-swarm-derive", "log", + "multistream-select 0.13.0", + "once_cell", "rand 0.8.5", "smallvec", "tokio", @@ -4425,119 +3940,73 @@ dependencies = [ [[package]] name = "libp2p-swarm-derive" -version = "0.32.0" +version = "0.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fba456131824ab6acd4c7bf61e9c0f0a3014b5fc9868ccb8e10d344594cdc4f" +checksum = "c4d5ec2a3df00c7836d7696c136274c9c59705bac69133253696a6c932cd1d74" dependencies = [ "heck", + "proc-macro-warning", + "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.18", ] [[package]] name = "libp2p-tcp" -version = "0.39.0" +version = "0.40.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33d33698596d7722d85d3ab0c86c2c322254fce1241e91208e3679b4eb3026cf" +checksum = "09bfdfb6f945c5c014b87872a0bdb6e0aef90e92f380ef57cd9013f118f9289d" dependencies = [ "futures", "futures-timer", "if-watch", "libc", "libp2p-core", + "libp2p-identity", "log", - "socket2", + "socket2 0.5.3", "tokio", ] -[[package]] -name = "libp2p-tls" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff08d13d0dc66e5e9ba6279c1de417b84fa0d0adc3b03e5732928c180ec02781" -dependencies = [ - "futures", - "futures-rustls", - "libp2p-core", - "libp2p-identity", - "rcgen 0.10.0", - "ring", - "rustls 0.20.8", - "thiserror", - "webpki 0.22.0", - "x509-parser 0.14.0", - "yasna", -] - [[package]] name = "libp2p-wasm-ext" -version = "0.39.0" +version = "0.40.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77dff9d32353a5887adb86c8afc1de1a94d9e8c3bc6df8b2201d7cdf5c848f43" +checksum = "1e5d8e3a9e07da0ef5b55a9f26c009c8fb3c725d492d8bb4b431715786eea79c" dependencies = [ "futures", "js-sys", "libp2p-core", - "parity-send-wrapper", + "send_wrapper", "wasm-bindgen", "wasm-bindgen-futures", ] -[[package]] -name = "libp2p-webrtc" -version = "0.4.0-alpha.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dba48592edbc2f60b4bc7c10d65445b0c3964c07df26fdf493b6880d33be36f8" -dependencies = [ - "async-trait", - "asynchronous-codec", - "bytes", - "futures", - "futures-timer", - "hex", - "if-watch", - "libp2p-core", - "libp2p-identity", - "libp2p-noise", - "log", - "multihash 0.17.0", - "quick-protobuf", - "quick-protobuf-codec", - "rand 0.8.5", - "rcgen 0.9.3", - "serde", - "stun", - "thiserror", - "tinytemplate", - "tokio", - "tokio-util", - "webrtc", -] - [[package]] name = "libp2p-websocket" -version = "0.41.0" +version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "111273f7b3d3510524c752e8b7a5314b7f7a1fee7e68161c01a7d72cbb06db9f" +checksum = "956d981ebc84abc3377e5875483c06d94ff57bc6b25f725047f9fd52592f72d4" dependencies = [ "either", "futures", "futures-rustls", "libp2p-core", + "libp2p-identity", "log", "parking_lot 0.12.1", "quicksink", "rw-stream-sink", "soketto", "url", - "webpki-roots", + "webpki-roots 0.23.1", ] [[package]] name = "libp2p-yamux" -version = "0.43.1" +version = "0.44.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4dcd21d950662700a385d4c6d68e2f5f54d778e97068cdd718522222ef513bda" +checksum = "c0a9b42ab6de15c6f076d8fb11dc5f48d899a10b55a2e16b12be9012a05287b0" dependencies = [ "futures", "libp2p-core", @@ -4695,9 +4164,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.18" +version = "0.4.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "518ef76f2f87365916b142844c16d8fefd85039bc5699050210a7778ee1cd1de" +checksum = "b06a4cde4c0f271a446782e3eff8de789548ce57dbc8eca9292c27f4a42004b4" [[package]] name = "lru" @@ -4839,15 +4308,6 @@ dependencies = [ "rawpointer", ] -[[package]] -name = "md-5" -version = "0.10.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6365506850d44bff6e2fbcb5176cf63650e48bd45ef2fe2665ae1570e0f4b9ca" -dependencies = [ - "digest 0.10.7", -] - [[package]] name = "memchr" version = "2.5.0" @@ -4872,15 +4332,6 @@ dependencies = [ "libc", ] -[[package]] -name = "memoffset" -version = "0.6.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" -dependencies = [ - "autocfg", -] - [[package]] name = "memoffset" version = "0.7.1" @@ -5023,16 +4474,16 @@ dependencies = [ [[package]] name = "multiaddr" -version = "0.17.1" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b36f567c7099511fa8612bbbb52dda2419ce0bdbacf31714e3a5ffdb766d3bd" +checksum = "92a651988b3ed3ad1bc8c87d016bb92f6f395b84ed1db9b926b32b1fc5a2c8b5" dependencies = [ "arrayref", "byteorder", "data-encoding", - "log", + "libp2p-identity", "multibase", - "multihash 0.17.0", + "multihash 0.19.0", "percent-encoding", "serde", "static_assertions", @@ -5062,30 +4513,71 @@ dependencies = [ "blake3", "core2", "digest 0.10.7", - "multihash-derive", - "sha2 0.10.6", + "multihash-derive 0.8.0", + "sha2 0.10.7", "sha3", "unsigned-varint", ] [[package]] name = "multihash" -version = "0.17.0" +version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "835d6ff01d610179fbce3de1694d007e500bf33a7f29689838941d6bf783ae40" +checksum = "2fd59dcc2bbe70baabeac52cd22ae52c55eefe6c38ff11a9439f16a350a939f2" dependencies = [ "core2", - "digest 0.10.7", - "multihash-derive", - "sha2 0.10.6", "unsigned-varint", ] +[[package]] +name = "multihash-codetable" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e46d7ff0b9b8d818e709e12135bfb6582fcde982ba2be48ea52e6e1df098c7a4" +dependencies = [ + "blake2b_simd", + "blake2s_simd", + "blake3", + "core2", + "digest 0.10.7", + "multihash-derive 0.9.0", + "ripemd", + "sha-1 0.10.1", + "sha2 0.10.7", + "sha3", + "strobe-rs", +] + [[package]] name = "multihash-derive" -version = "0.8.1" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc076939022111618a5026d3be019fd8b366e76314538ff9a1b59ffbcbf98bcd" +dependencies = [ + "proc-macro-crate", + "proc-macro-error", + "proc-macro2", + "quote", + "syn 1.0.109", + "synstructure", +] + +[[package]] +name = "multihash-derive" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d6d4752e6230d8ef7adf7bd5d8c4b1f6561c1014c5ba9a37445ccefe18aa1db" +checksum = "890e72cb7396cb99ed98c1246a97b243cc16394470d94e0bc8b0c2c11d84290e" +dependencies = [ + "core2", + "multihash 0.19.0", + "multihash-derive-impl", +] + +[[package]] +name = "multihash-derive-impl" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d38685e08adb338659871ecfc6ee47ba9b22dcc8abcf6975d379cc49145c3040" dependencies = [ "proc-macro-crate", "proc-macro-error", @@ -5115,6 +4607,20 @@ dependencies = [ "unsigned-varint", ] +[[package]] +name = "multistream-select" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea0df8e5eec2298a62b326ee4f0d7fe1a6b90a09dfcf9df37b38f947a8c42f19" +dependencies = [ + "bytes", + "futures", + "log", + "pin-project", + "smallvec", + "unsigned-varint", +] + [[package]] name = "nalgebra" version = "0.32.2" @@ -5226,7 +4732,6 @@ dependencies = [ "bitflags", "cfg-if", "libc", - "memoffset 0.6.5", ] [[package]] @@ -5668,7 +5173,7 @@ version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a652d9771a63711fd3c3deb670acfbe5c30a4072e664d7a3bf5a9e1056ac72c3" dependencies = [ - "arrayvec 0.7.2", + "arrayvec 0.7.4", "itoa", ] @@ -5743,24 +5248,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "oid-registry" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38e20717fa0541f39bd146692035c37bedfa532b3e5071b35761082407546b2a" -dependencies = [ - "asn1-rs 0.3.1", -] - -[[package]] -name = "oid-registry" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9bedf36ffb6ba96c2eb7144ef6270557b52e54b20c0a8e1eb2ff99a6c6959bff" -dependencies = [ - "asn1-rs 0.5.2", -] - [[package]] name = "once_cell" version = "1.18.0" @@ -5812,28 +5299,6 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" -[[package]] -name = "p256" -version = "0.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51f44edd08f51e2ade572f141051021c5af22677e42b7dd28a88155151c33594" -dependencies = [ - "ecdsa", - "elliptic-curve", - "sha2 0.10.6", -] - -[[package]] -name = "p384" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfc8c5bf642dde52bb9e87c0ecd8ca5a76faac2eeed98dedb7c717997e1080aa" -dependencies = [ - "ecdsa", - "elliptic-curve", - "sha2 0.10.6", -] - [[package]] name = "packed_simd_2" version = "0.3.8" @@ -7591,7 +7056,7 @@ version = "3.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2287753623c76f953acd29d15d8100bcab84d29db78fb6f352adb3c53e83b967" dependencies = [ - "arrayvec 0.7.2", + "arrayvec 0.7.4", "bitvec", "byte-slice-cast", "bytes", @@ -7612,12 +7077,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "parity-send-wrapper" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa9777aa91b8ad9dd5aaa04a9b6bcb02c7f1deb952fca5a66034d5e63afc5c6f" - [[package]] name = "parity-wasm" version = "0.45.0" @@ -7714,24 +7173,6 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" -[[package]] -name = "pem" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8835c273a76a90455d7344889b0964598e3316e2a79ede8e36f16bdcf2228b8" -dependencies = [ - "base64 0.13.1", -] - -[[package]] -name = "pem-rfc7468" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24d159833a9105500e0398934e205e0773f0b27529557134ecfc51c27646adac" -dependencies = [ - "base64ct", -] - [[package]] name = "percent-encoding" version = "2.3.0" @@ -7779,7 +7220,7 @@ checksum = "745a452f8eb71e39ffd8ee32b3c5f51d03845f99786fa9b68db6ff509c505411" dependencies = [ "once_cell", "pest", - "sha2 0.10.6", + "sha2 0.10.7", ] [[package]] @@ -7830,16 +7271,6 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" -[[package]] -name = "pkcs8" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9eca2c590a5f85da82668fa685c09ce2888b9430e83299debf1f34b65fd4a4ba" -dependencies = [ - "der", - "spki", -] - [[package]] name = "pkg-config" version = "0.3.27" @@ -7904,7 +7335,7 @@ checksum = "048aeb476be11a4b6ca432ca569e375810de9294ae78f4774e78ea98a9246ede" dependencies = [ "cpufeatures", "opaque-debug 0.3.0", - "universal-hash 0.4.1", + "universal-hash", ] [[package]] @@ -7916,19 +7347,7 @@ dependencies = [ "cfg-if", "cpufeatures", "opaque-debug 0.3.0", - "universal-hash 0.4.1", -] - -[[package]] -name = "polyval" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ef234e08c11dfcb2e56f79fd70f6f2eb7f025c0ce2333e82f4f0518ecad30c6" -dependencies = [ - "cfg-if", - "cpufeatures", - "opaque-debug 0.3.0", - "universal-hash 0.5.1", + "universal-hash", ] [[package]] @@ -8033,12 +7452,12 @@ dependencies = [ [[package]] name = "proc-macro-crate" -version = "1.1.3" +version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e17d47ce914bf4de440332250b0edd23ce48c005f59fab39d3335866b114f11a" +checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" dependencies = [ - "thiserror", - "toml 0.5.11", + "once_cell", + "toml_edit", ] [[package]] @@ -8101,9 +7520,9 @@ dependencies = [ [[package]] name = "prometheus-client" -version = "0.19.0" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d6fa99d535dd930d1249e6c79cb3c2915f9172a540fe2b02a4c8f9ca954721e" +checksum = "78c2f43e8969d51935d2a7284878ae053ba30034cd563f673cde37ba5205685e" dependencies = [ "dtoa", "itoa", @@ -8202,9 +7621,9 @@ dependencies = [ [[package]] name = "quick-protobuf-codec" -version = "0.1.0" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1693116345026436eb2f10b677806169c1a1260c1c60eaaffe3fb5a29ae23d8b" +checksum = "f8ededb1cd78531627244d51dd0c7139fbe736c7d57af0092a76f0ffb2f56e98" dependencies = [ "asynchronous-codec", "bytes", @@ -8233,24 +7652,6 @@ dependencies = [ "pin-project-lite 0.1.12", ] -[[package]] -name = "quinn-proto" -version = "0.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67c10f662eee9c94ddd7135043e544f3c82fa839a1e7b865911331961b53186c" -dependencies = [ - "bytes", - "rand 0.8.5", - "ring", - "rustc-hash", - "rustls 0.20.8", - "slab", - "thiserror", - "tinyvec", - "tracing", - "webpki 0.22.0", -] - [[package]] name = "quote" version = "1.0.28" @@ -8384,31 +7785,6 @@ dependencies = [ "num_cpus", ] -[[package]] -name = "rcgen" -version = "0.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6413f3de1edee53342e6138e75b56d32e7bc6e332b3bd62d497b1929d4cfbcdd" -dependencies = [ - "pem", - "ring", - "time 0.3.21", - "x509-parser 0.13.2", - "yasna", -] - -[[package]] -name = "rcgen" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffbe84efe2f38dea12e9bfc1f65377fdf03e53a18cb3b995faedf7934c7e785b" -dependencies = [ - "pem", - "ring", - "time 0.3.21", - "yasna", -] - [[package]] name = "redox_syscall" version = "0.2.16" @@ -8512,17 +7888,6 @@ dependencies = [ "quick-error", ] -[[package]] -name = "rfc6979" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7743f17af12fa0b03b803ba12cd6a8d9483a587e89c69445e3909655c0b9fabb" -dependencies = [ - "crypto-bigint", - "hmac 0.12.1", - "zeroize", -] - [[package]] name = "ring" version = "0.16.20" @@ -8538,6 +7903,15 @@ dependencies = [ "winapi", ] +[[package]] +name = "ripemd" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd124222d17ad93a644ed9d011a40f4fb64aa54275c08cc216524a9ea82fb09f" +dependencies = [ + "digest 0.10.7", +] + [[package]] name = "rocksdb" version = "0.21.0" @@ -8559,17 +7933,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "rtcp" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1919efd6d4a6a85d13388f9487549bb8e359f17198cc03ffd72f79b553873691" -dependencies = [ - "bytes", - "thiserror", - "webrtc-util", -] - [[package]] name = "rtnetlink" version = "0.10.1" @@ -8595,20 +7958,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "rtp" -version = "0.6.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2a095411ff00eed7b12e4c6a118ba984d113e1079582570d56a5ee723f11f80" -dependencies = [ - "async-trait", - "bytes", - "rand 0.8.5", - "serde", - "thiserror", - "webrtc-util", -] - [[package]] name = "rustc-demangle" version = "0.1.23" @@ -8645,15 +7994,6 @@ dependencies = [ "semver 1.0.17", ] -[[package]] -name = "rusticata-macros" -version = "4.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "faf0c4a6ece9950b9abdb62b1cfcf2a68b3b67a10ba445b3bb85be2a293d0632" -dependencies = [ - "nom", -] - [[package]] name = "rustix" version = "0.36.14" @@ -8682,19 +8022,6 @@ dependencies = [ "windows-sys 0.48.0", ] -[[package]] -name = "rustls" -version = "0.19.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35edb675feee39aec9c99fa5ff985081995a06d594114ae14cbe797ad7b7a6d7" -dependencies = [ - "base64 0.13.1", - "log", - "ring", - "sct 0.6.1", - "webpki 0.21.4", -] - [[package]] name = "rustls" version = "0.20.8" @@ -8703,8 +8030,8 @@ checksum = "fff78fc74d175294f4e83b28343315ffcfb114b156f0185e9741cb5570f50e2f" dependencies = [ "log", "ring", - "sct 0.7.0", - "webpki 0.22.0", + "sct", + "webpki", ] [[package]] @@ -8716,7 +8043,7 @@ dependencies = [ "log", "ring", "rustls-webpki", - "sct 0.7.0", + "sct", ] [[package]] @@ -8769,9 +8096,9 @@ dependencies = [ [[package]] name = "rw-stream-sink" -version = "0.3.0" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26338f5e09bb721b85b135ea05af7767c90b52f6de4f087d4f4a3a9d64e7dc04" +checksum = "d8c9026ff5d2f23da5e45bbc283f156383001bfb09c4e44256d02c1a685fe9a1" dependencies = [ "futures", "pin-project", @@ -8831,7 +8158,7 @@ dependencies = [ "ip_network", "libp2p", "log", - "multihash 0.17.0", + "multihash-codetable", "parity-scale-codec", "prost", "prost-build", @@ -9506,7 +8833,7 @@ dependencies = [ "linked_hash_set", "log", "mockall", - "multistream-select", + "multistream-select 0.12.1", "parity-scale-codec", "parking_lot 0.12.1", "partial_sort", @@ -9535,6 +8862,7 @@ dependencies = [ "tokio-test", "tokio-util", "unsigned-varint", + "void", "wasm-timer", "zeroize", ] @@ -10265,16 +9593,6 @@ version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1792db035ce95be60c3f8853017b3999209281c24e2ba5bc8e59bf97a0c590c1" -[[package]] -name = "sct" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b362b83898e0e69f38515b82ee15aa80636befe47c3b6d3d89a911e78fc228ce" -dependencies = [ - "ring", - "untrusted", -] - [[package]] name = "sct" version = "0.7.0" @@ -10285,32 +9603,6 @@ dependencies = [ "untrusted", ] -[[package]] -name = "sdp" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d22a5ef407871893fd72b4562ee15e4742269b173959db4b8df6f538c414e13" -dependencies = [ - "rand 0.8.5", - "substring", - "thiserror", - "url", -] - -[[package]] -name = "sec1" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3be24c1842290c45df0a7bf069e0c268a747ad05a192f2fd7dcfdbc1cba40928" -dependencies = [ - "base16ct", - "der", - "generic-array 0.14.7", - "pkcs8", - "subtle", - "zeroize", -] - [[package]] name = "secp256k1" version = "0.24.3" @@ -10394,6 +9686,12 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" +[[package]] +name = "send_wrapper" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd0b0ec5f1c1ca621c432a25813d8d60c88abe6d3e08a3eb9cf37d97a0fe3d73" + [[package]] name = "serde" version = "1.0.164" @@ -10448,10 +9746,10 @@ dependencies = [ ] [[package]] -name = "sha1" -version = "0.10.5" +name = "sha-1" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f04293dc80c3993519f2d7f6f511707ee7094fe0c6d3406feb330cdb3540eba3" +checksum = "f5058ada175748e33390e40e872bd0fe59a19f265d0158daa551c5a88a76009c" dependencies = [ "cfg-if", "cpufeatures", @@ -10485,9 +9783,9 @@ dependencies = [ [[package]] name = "sha2" -version = "0.10.6" +version = "0.10.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82e6b795fe2e3b1e845bafcb27aa35405c4d47cdfc92af5fc8d3002f76cebdc0" +checksum = "479fb9d862239e610720565ca91403019f2f00410f1864c5aa7479b950a76ed8" dependencies = [ "cfg-if", "cpufeatures", @@ -10533,10 +9831,6 @@ name = "signature" version = "1.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "74233d3b3b2f6d4b006dc19dee745e73e2a6bfb6f93607cd3b02bd5b00797d7c" -dependencies = [ - "digest 0.10.7", - "rand_core 0.6.4", -] [[package]] name = "simba" @@ -10590,14 +9884,14 @@ version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5ccba027ba85743e09d15c03296797cad56395089b832b48b5a5217880f57733" dependencies = [ - "aes-gcm 0.9.4", + "aes-gcm", "blake2", "chacha20poly1305", "curve25519-dalek 4.0.0-rc.1", "rand_core 0.6.4", "ring", "rustc_version 0.4.0", - "sha2 0.10.6", + "sha2 0.10.7", "subtle", ] @@ -10611,6 +9905,16 @@ dependencies = [ "winapi", ] +[[package]] +name = "socket2" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2538b18701741680e0322a2302176d3253a35388e2e62f172f64f4f16605f877" +dependencies = [ + "libc", + "windows-sys 0.48.0", +] + [[package]] name = "soketto" version = "0.7.1" @@ -10619,13 +9923,12 @@ checksum = "41d1c5305e39e09653383c2c7244f2f78b3bcae37cf50c64cb4789c9f5096ec2" dependencies = [ "base64 0.13.1", "bytes", - "flate2", "futures", "http", "httparse", "log", "rand 0.8.5", - "sha-1", + "sha-1 0.9.8", ] [[package]] @@ -10984,7 +10287,7 @@ dependencies = [ "bitflags", "blake2", "bounded-collections", - "bs58", + "bs58 0.4.0", "criterion", "dyn-clonable", "ed25519-zebra", @@ -11031,7 +10334,7 @@ dependencies = [ "blake2b_simd", "byteorder", "digest 0.10.7", - "sha2 0.10.6", + "sha2 0.10.7", "sha3", "twox-hash", ] @@ -11597,18 +10900,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08615eea740067d9899969bc2891c68a19c315cb1f66640af9a9ecb91b13bcab" dependencies = [ "lazy_static", - "maplit", - "strum", -] - -[[package]] -name = "spki" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67cf02bbac7a337dc36e4f5a693db6c21e7863f45070f7064577eb4367a3212b" -dependencies = [ - "base64ct", - "der", + "maplit", + "strum", ] [[package]] @@ -11666,6 +10959,19 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "strobe-rs" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fabb238a1cccccfa4c4fb703670c0d157e1256c1ba695abf1b93bd2bb14bab2d" +dependencies = [ + "bitflags", + "byteorder", + "keccak", + "subtle", + "zeroize", +] + [[package]] name = "strsim" version = "0.10.0" @@ -11694,25 +11000,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "stun" -version = "0.4.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7e94b1ec00bad60e6410e058b52f1c66de3dc5fe4d62d09b3e52bb7d3b73e25" -dependencies = [ - "base64 0.13.1", - "crc", - "lazy_static", - "md-5", - "rand 0.8.5", - "ring", - "subtle", - "thiserror", - "tokio", - "url", - "webrtc-util", -] - [[package]] name = "subkey" version = "3.0.0" @@ -11995,15 +11282,6 @@ dependencies = [ "wasm-opt", ] -[[package]] -name = "substring" -version = "1.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42ee6433ecef213b2e72f587ef64a2f5943e7cd16fbd82dbe8bc07486c534c86" -dependencies = [ - "autocfg", -] - [[package]] name = "subtle" version = "2.4.1" @@ -12188,33 +11466,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "time" -version = "0.3.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f3403384eaacbca9923fa06940178ac13e4edb725486d70e8e15881d0c836cc" -dependencies = [ - "itoa", - "serde", - "time-core", - "time-macros", -] - -[[package]] -name = "time-core" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7300fbefb4dadc1af235a9cef3737cea692a9d97e1b9cbcd4ebdae6f8868e6fb" - -[[package]] -name = "time-macros" -version = "0.2.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "372950940a5f07bf38dbe211d7283c9e6d7327df53794992d293e534c733d09b" -dependencies = [ - "time-core", -] - [[package]] name = "tiny-bip39" version = "1.0.0" @@ -12227,7 +11478,7 @@ dependencies = [ "pbkdf2 0.11.0", "rand 0.8.5", "rustc-hash", - "sha2 0.10.6", + "sha2 0.10.7", "thiserror", "unicode-normalization", "wasm-bindgen", @@ -12282,7 +11533,7 @@ dependencies = [ "parking_lot 0.12.1", "pin-project-lite 0.2.9", "signal-hook-registry", - "socket2", + "socket2 0.4.9", "tokio-macros", "windows-sys 0.48.0", ] @@ -12317,7 +11568,7 @@ checksum = "c43ee83903113e03984cb9e5cebe6c04a5116269e900e3ddba8f068a62adda59" dependencies = [ "rustls 0.20.8", "tokio", - "webpki 0.22.0", + "webpki", ] [[package]] @@ -12626,7 +11877,7 @@ dependencies = [ "lazy_static", "rand 0.8.5", "smallvec", - "socket2", + "socket2 0.4.9", "thiserror", "tinyvec", "tokio", @@ -12723,25 +11974,6 @@ version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f4f195fd851901624eee5a58c4bb2b4f06399148fcd0ed336e6f1cb60a9881df" -[[package]] -name = "turn" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4712ee30d123ec7ae26d1e1b218395a16c87cdbaf4b3925d170d684af62ea5e8" -dependencies = [ - "async-trait", - "base64 0.13.1", - "futures", - "log", - "md-5", - "rand 0.8.5", - "ring", - "stun", - "thiserror", - "tokio", - "webrtc-util", -] - [[package]] name = "twox-hash" version = "1.6.3" @@ -12821,16 +12053,6 @@ dependencies = [ "subtle", ] -[[package]] -name = "universal-hash" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc1de2c688dc15305988b563c3854064043356019f97a4b46276fe734c4f07ea" -dependencies = [ - "crypto-common", - "subtle", -] - [[package]] name = "unsigned-varint" version = "0.7.1" @@ -12866,15 +12088,6 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" -[[package]] -name = "uuid" -version = "1.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "345444e32442451b267fc254ae85a209c64be56d2890e601a0c37ff0c3c5ecd2" -dependencies = [ - "getrandom 0.2.9", -] - [[package]] name = "valuable" version = "0.1.0" @@ -12917,7 +12130,7 @@ dependencies = [ "rand 0.8.5", "rand_chacha 0.3.1", "rand_core 0.6.4", - "sha2 0.10.6", + "sha2 0.10.7", "sha3", "thiserror", "zeroize", @@ -12932,15 +12145,6 @@ dependencies = [ "libc", ] -[[package]] -name = "waitgroup" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1f50000a783467e6c0200f9d10642f4bc424e39efc1b770203e88b488f79292" -dependencies = [ - "atomic-waker", -] - [[package]] name = "waker-fn" version = "1.1.0" @@ -13233,7 +12437,7 @@ dependencies = [ "log", "rustix 0.36.14", "serde", - "sha2 0.10.6", + "sha2 0.10.7", "toml 0.5.11", "windows-sys 0.45.0", "zstd 0.11.2+zstd.1.5.2", @@ -13408,16 +12612,6 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "webpki" -version = "0.21.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8e38c0608262c46d4a56202ebabdeb094cef7e560ca7a226c6bf055188aa4ea" -dependencies = [ - "ring", - "untrusted", -] - [[package]] name = "webpki" version = "0.22.0" @@ -13434,216 +12628,16 @@ version = "0.22.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6c71e40d7d2c34a5106301fb632274ca37242cd0c9d3e64dbece371a40a2d87" dependencies = [ - "webpki 0.22.0", -] - -[[package]] -name = "webrtc" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d3bc9049bdb2cea52f5fd4f6f728184225bdb867ed0dc2410eab6df5bdd67bb" -dependencies = [ - "arc-swap", - "async-trait", - "bytes", - "hex", - "interceptor", - "lazy_static", - "log", - "rand 0.8.5", - "rcgen 0.9.3", - "regex", - "ring", - "rtcp", - "rtp", - "rustls 0.19.1", - "sdp", - "serde", - "serde_json", - "sha2 0.10.6", - "stun", - "thiserror", - "time 0.3.21", - "tokio", - "turn", - "url", - "waitgroup", - "webrtc-data", - "webrtc-dtls", - "webrtc-ice", - "webrtc-mdns", - "webrtc-media", - "webrtc-sctp", - "webrtc-srtp", - "webrtc-util", -] - -[[package]] -name = "webrtc-data" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ef36a4d12baa6e842582fe9ec16a57184ba35e1a09308307b67d43ec8883100" -dependencies = [ - "bytes", - "derive_builder", - "log", - "thiserror", - "tokio", - "webrtc-sctp", - "webrtc-util", -] - -[[package]] -name = "webrtc-dtls" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "942be5bd85f072c3128396f6e5a9bfb93ca8c1939ded735d177b7bcba9a13d05" -dependencies = [ - "aes 0.6.0", - "aes-gcm 0.10.2", - "async-trait", - "bincode", - "block-modes", - "byteorder", - "ccm", - "curve25519-dalek 3.2.0", - "der-parser 8.2.0", - "elliptic-curve", - "hkdf", - "hmac 0.12.1", - "log", - "oid-registry 0.6.1", - "p256", - "p384", - "rand 0.8.5", - "rand_core 0.6.4", - "rcgen 0.9.3", - "ring", - "rustls 0.19.1", - "sec1", - "serde", - "sha1", - "sha2 0.10.6", - "signature", - "subtle", - "thiserror", - "tokio", - "webpki 0.21.4", - "webrtc-util", - "x25519-dalek 2.0.0-pre.1", - "x509-parser 0.13.2", -] - -[[package]] -name = "webrtc-ice" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "465a03cc11e9a7d7b4f9f99870558fe37a102b65b93f8045392fef7c67b39e80" -dependencies = [ - "arc-swap", - "async-trait", - "crc", - "log", - "rand 0.8.5", - "serde", - "serde_json", - "stun", - "thiserror", - "tokio", - "turn", - "url", - "uuid", - "waitgroup", - "webrtc-mdns", - "webrtc-util", -] - -[[package]] -name = "webrtc-mdns" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f08dfd7a6e3987e255c4dbe710dde5d94d0f0574f8a21afa95d171376c143106" -dependencies = [ - "log", - "socket2", - "thiserror", - "tokio", - "webrtc-util", -] - -[[package]] -name = "webrtc-media" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f72e1650a8ae006017d1a5280efb49e2610c19ccc3c0905b03b648aee9554991" -dependencies = [ - "byteorder", - "bytes", - "rand 0.8.5", - "rtp", - "thiserror", -] - -[[package]] -name = "webrtc-sctp" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d47adcd9427eb3ede33d5a7f3424038f63c965491beafcc20bc650a2f6679c0" -dependencies = [ - "arc-swap", - "async-trait", - "bytes", - "crc", - "log", - "rand 0.8.5", - "thiserror", - "tokio", - "webrtc-util", -] - -[[package]] -name = "webrtc-srtp" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6183edc4c1c6c0175f8812eefdce84dfa0aea9c3ece71c2bf6ddd3c964de3da5" -dependencies = [ - "aead 0.4.3", - "aes 0.7.5", - "aes-gcm 0.9.4", - "async-trait", - "byteorder", - "bytes", - "ctr 0.8.0", - "hmac 0.11.0", - "log", - "rtcp", - "rtp", - "sha-1", - "subtle", - "thiserror", - "tokio", - "webrtc-util", + "webpki", ] [[package]] -name = "webrtc-util" -version = "0.7.0" +name = "webpki-roots" +version = "0.23.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93f1db1727772c05cf7a2cfece52c3aca8045ca1e176cd517d323489aa3c6d87" +checksum = "b03058f88386e5ff5310d9111d53f48b17d732b401aeb83a8d5190f2ac459338" dependencies = [ - "async-trait", - "bitflags", - "bytes", - "cc", - "ipnet", - "lazy_static", - "libc", - "log", - "nix 0.24.3", - "rand 0.8.5", - "thiserror", - "tokio", - "winapi", + "rustls-webpki", ] [[package]] @@ -13941,54 +12935,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "x25519-dalek" -version = "2.0.0-pre.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5da623d8af10a62342bcbbb230e33e58a63255a58012f8653c578e54bab48df" -dependencies = [ - "curve25519-dalek 3.2.0", - "rand_core 0.6.4", - "zeroize", -] - -[[package]] -name = "x509-parser" -version = "0.13.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fb9bace5b5589ffead1afb76e43e34cff39cd0f3ce7e170ae0c29e53b88eb1c" -dependencies = [ - "asn1-rs 0.3.1", - "base64 0.13.1", - "data-encoding", - "der-parser 7.0.0", - "lazy_static", - "nom", - "oid-registry 0.4.0", - "ring", - "rusticata-macros", - "thiserror", - "time 0.3.21", -] - -[[package]] -name = "x509-parser" -version = "0.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0ecbeb7b67ce215e40e3cc7f2ff902f94a223acf44995934763467e7b1febc8" -dependencies = [ - "asn1-rs 0.5.2", - "base64 0.13.1", - "data-encoding", - "der-parser 8.2.0", - "lazy_static", - "nom", - "oid-registry 0.6.1", - "rusticata-macros", - "thiserror", - "time 0.3.21", -] - [[package]] name = "xattr" version = "0.2.3" @@ -14018,15 +12964,6 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09041cd90cf85f7f8b2df60c646f853b7f535ce68f85244eb6731cf89fa498ec" -[[package]] -name = "yasna" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e17bb3549cc1321ae1296b9cdc2698e2b6cb1992adfa19a8c72e5b7a738f44cd" -dependencies = [ - "time 0.3.21", -] - [[package]] name = "zeroize" version = "1.6.0" From 3d0420728c86925f3695a30b46a097ebd9ee3eb3 Mon Sep 17 00:00:00 2001 From: Anton Kaliaev Date: Wed, 28 Jun 2023 17:49:36 +0400 Subject: [PATCH 18/42] reformat text --- client/consensus/babe/src/lib.rs | 8 ++-- client/consensus/beefy/src/worker.rs | 8 ++-- client/network/src/service/traits.rs | 4 +- client/rpc-spec-v2/src/chain_head/event.rs | 8 ++-- frame/benchmarking/src/lib.rs | 23 +++++------ frame/contracts/src/schedule.rs | 29 +++++++------ frame/im-online/src/lib.rs | 2 +- frame/recovery/src/lib.rs | 48 ++++++++++------------ frame/support/src/lib.rs | 16 ++++---- primitives/npos-elections/src/balancing.rs | 2 +- primitives/runtime/src/offchain/http.rs | 8 ++-- primitives/staking/src/offence.rs | 16 ++++---- utils/wasm-builder/src/builder.rs | 4 +- 13 files changed, 84 insertions(+), 92 deletions(-) diff --git a/client/consensus/babe/src/lib.rs b/client/consensus/babe/src/lib.rs index 219b52294952a..64ff00bb58c35 100644 --- a/client/consensus/babe/src/lib.rs +++ b/client/consensus/babe/src/lib.rs @@ -1152,10 +1152,10 @@ where // Verification for imported blocks is skipped in two cases: // 1. When importing blocks below the last finalized block during network initial // synchronization. - // 2. When importing whole state we don't calculate epoch descriptor, but rather - // read it from the state after import. We also skip all verifications - // because there's no parent state and we trust the sync module to verify - // that the state is correct and finalized. + // 2. When importing whole state we don't calculate epoch descriptor, but rather read it + // from the state after import. We also skip all verifications because there's no + // parent state and we trust the sync module to verify that the state is correct and + // finalized. return Ok(block) } diff --git a/client/consensus/beefy/src/worker.rs b/client/consensus/beefy/src/worker.rs index cbf58e56b2cdf..91b00ddb2cef0 100644 --- a/client/consensus/beefy/src/worker.rs +++ b/client/consensus/beefy/src/worker.rs @@ -78,11 +78,11 @@ pub(crate) struct VoterOracle { /// /// There are three voter states coresponding to three queue states: /// 1. voter uninitialized: queue empty, - /// 2. up-to-date - all mandatory blocks leading up to current GRANDPA finalized: - /// queue has ONE element, the 'current session' where `mandatory_done == true`, + /// 2. up-to-date - all mandatory blocks leading up to current GRANDPA finalized: queue has ONE + /// element, the 'current session' where `mandatory_done == true`, /// 3. lagging behind GRANDPA: queue has [1, N] elements, where all `mandatory_done == false`. - /// In this state, everytime a session gets its mandatory block BEEFY finalized, it's - /// popped off the queue, eventually getting to state `2. up-to-date`. + /// In this state, everytime a session gets its mandatory block BEEFY finalized, it's popped + /// off the queue, eventually getting to state `2. up-to-date`. sessions: VecDeque>, /// Min delta in block numbers between two blocks, BEEFY should vote on. min_block_delta: u32, diff --git a/client/network/src/service/traits.rs b/client/network/src/service/traits.rs index 97680a9eb73b7..bebf5a5713c45 100644 --- a/client/network/src/service/traits.rs +++ b/client/network/src/service/traits.rs @@ -402,9 +402,9 @@ pub trait NetworkNotification { /// a receiver. With a `NotificationSender` at hand, sending a notification is done in two /// steps: /// - /// 1. [`NotificationSender::ready`] is used to wait for the sender to become ready + /// 1. [`NotificationSender::ready`] is used to wait for the sender to become ready /// for another notification, yielding a [`NotificationSenderReady`] token. - /// 2. [`NotificationSenderReady::send`] enqueues the notification for sending. This operation + /// 2. [`NotificationSenderReady::send`] enqueues the notification for sending. This operation /// can only fail if the underlying notification substream or connection has suddenly closed. /// /// An error is returned by [`NotificationSenderReady::send`] if there exists no open diff --git a/client/rpc-spec-v2/src/chain_head/event.rs b/client/rpc-spec-v2/src/chain_head/event.rs index d0d4d1d43ac03..3c970729d6ab1 100644 --- a/client/rpc-spec-v2/src/chain_head/event.rs +++ b/client/rpc-spec-v2/src/chain_head/event.rs @@ -192,12 +192,10 @@ pub struct Finalized { /// The event generated by the `follow` method. /// /// The events are generated in the following order: -/// 1. Initialized - generated only once to signal the -/// latest finalized block +/// 1. Initialized - generated only once to signal the latest finalized block /// 2. NewBlock - a new block was added. -/// 3. BestBlockChanged - indicate that the best block -/// is now the one from this event. The block was -/// announced priorly with the `NewBlock` event. +/// 3. BestBlockChanged - indicate that the best block is now the one from this event. The block was +/// announced priorly with the `NewBlock` event. /// 4. Finalized - State the finalized and pruned blocks. #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] diff --git a/frame/benchmarking/src/lib.rs b/frame/benchmarking/src/lib.rs index b11e164fe8e44..e5ec61d622e95 100644 --- a/frame/benchmarking/src/lib.rs +++ b/frame/benchmarking/src/lib.rs @@ -246,22 +246,21 @@ pub use v1::*; /// of impls and structs required by the benchmarking engine. Additionally, a benchmark /// function is also generated that resembles the function definition you provide, with a few /// modifications: -/// 1. The function name is transformed from i.e. `original_name` to `_original_name` so as not -/// to collide with the struct `original_name` that is created for some of the benchmarking -/// engine impls. -/// 2. Appropriate `T: Config` and `I` (if this is an instance benchmark) generics are added to -/// the function automatically during expansion, so you should not add these manually on -/// your function definition (but you may make use of `T` and `I` anywhere within your -/// benchmark function, in any of the three sections (setup, call, verification). +/// 1. The function name is transformed from i.e. `original_name` to `_original_name` so as not to +/// collide with the struct `original_name` that is created for some of the benchmarking engine +/// impls. +/// 2. Appropriate `T: Config` and `I` (if this is an instance benchmark) generics are added to the +/// function automatically during expansion, so you should not add these manually on your +/// function definition (but you may make use of `T` and `I` anywhere within your benchmark +/// function, in any of the three sections (setup, call, verification). /// 3. Arguments such as `u: Linear<10, 100>` are converted to `u: u32` to make the function /// directly callable. -/// 4. A `verify: bool` param is added as the last argument. Specifying `true` will result in -/// the verification section of your function executing, while a value of `false` will skip +/// 4. A `verify: bool` param is added as the last argument. Specifying `true` will result in the +/// verification section of your function executing, while a value of `false` will skip /// verification. /// 5. If you specify a return type on the function definition, it must conform to the [rules -/// below](#support-for-result-benchmarkerror-and-the--operator), and the last statement of -/// the function definition must resolve to something compatible with `Result<(), -/// BenchmarkError>`. +/// below](#support-for-result-benchmarkerror-and-the--operator), and the last statement of the +/// function definition must resolve to something compatible with `Result<(), BenchmarkError>`. /// /// The reason we generate an actual function as part of the expansion is to allow the compiler /// to enforce several constraints that would otherwise be difficult to enforce and to reduce diff --git a/frame/contracts/src/schedule.rs b/frame/contracts/src/schedule.rs index c6eedb155d6a4..94307811b8689 100644 --- a/frame/contracts/src/schedule.rs +++ b/frame/contracts/src/schedule.rs @@ -145,21 +145,20 @@ impl Limits { /// There there is one field for each wasm instruction that describes the weight to /// execute one instruction of that name. There are a few exceptions: /// -/// 1. If there is a i64 and a i32 variant of an instruction we use the weight -/// of the former for both. -/// 2. The following instructions are free of charge because they merely structure the -/// wasm module and cannot be spammed without making the module invalid (and rejected): -/// End, Unreachable, Return, Else -/// 3. The following instructions cannot be benchmarked because they are removed by any -/// real world execution engine as a preprocessing step and therefore don't yield a -/// meaningful benchmark result. However, in contrast to the instructions mentioned -/// in 2. they can be spammed. We price them with the same weight as the "default" -/// instruction (i64.const): Block, Loop, Nop -/// 4. We price both i64.const and drop as InstructionWeights.i64const / 2. The reason -/// for that is that we cannot benchmark either of them on its own but we need their -/// individual values to derive (by subtraction) the weight of all other instructions -/// that use them as supporting instructions. Supporting means mainly pushing arguments -/// and dropping return values in order to maintain a valid module. +/// 1. If there is a i64 and a i32 variant of an instruction we use the weight of the former for +/// both. +/// 2. The following instructions are free of charge because they merely structure the wasm module +/// and cannot be spammed without making the module invalid (and rejected): End, Unreachable, +/// Return, Else +/// 3. The following instructions cannot be benchmarked because they are removed by any real world +/// execution engine as a preprocessing step and therefore don't yield a meaningful benchmark +/// result. However, in contrast to the instructions mentioned in 2. they can be spammed. We +/// price them with the same weight as the "default" instruction (i64.const): Block, Loop, Nop +/// 4. We price both i64.const and drop as InstructionWeights.i64const / 2. The reason for that is +/// that we cannot benchmark either of them on its own but we need their individual values to +/// derive (by subtraction) the weight of all other instructions that use them as supporting +/// instructions. Supporting means mainly pushing arguments and dropping return values in order +/// to maintain a valid module. #[cfg_attr(feature = "std", derive(Serialize, Deserialize))] #[derive(Clone, Encode, Decode, PartialEq, Eq, ScheduleDebug, TypeInfo)] #[scale_info(skip_type_params(T))] diff --git a/frame/im-online/src/lib.rs b/frame/im-online/src/lib.rs index 1f9557a427293..e1adbc062424f 100644 --- a/frame/im-online/src/lib.rs +++ b/frame/im-online/src/lib.rs @@ -656,7 +656,7 @@ impl Pallet { // // At index `idx`: // 1. A (ImOnline) public key to be used by a validator at index `idx` to send im-online - // heartbeats. + // heartbeats. let authorities = Keys::::get(); // local keystore diff --git a/frame/recovery/src/lib.rs b/frame/recovery/src/lib.rs index d66b5725fd4f7..8f70ebfe5ec67 100644 --- a/frame/recovery/src/lib.rs +++ b/frame/recovery/src/lib.rs @@ -48,34 +48,30 @@ //! ### Recovery Life Cycle //! //! The intended life cycle of a successful recovery takes the following steps: -//! 1. The account owner calls `create_recovery` to set up a recovery configuration -//! for their account. -//! 2. At some later time, the account owner loses access to their account and wants -//! to recover it. Likely, they will need to create a new account and fund it with -//! enough balance to support the transaction fees and the deposit for the -//! recovery process. -//! 3. Using this new account, they call `initiate_recovery`. -//! 4. Then the account owner would contact their configured friends to vouch for -//! the recovery attempt. The account owner would provide their old account id -//! and the new account id, and friends would call `vouch_recovery` with those -//! parameters. -//! 5. Once a threshold number of friends have vouched for the recovery attempt, -//! the account owner needs to wait until the delay period has passed, starting -//! when they initiated the recovery process. -//! 6. Now the account owner is able to call `claim_recovery`, which subsequently -//! allows them to call `as_recovered` and directly make calls on-behalf-of the lost +//! 1. The account owner calls `create_recovery` to set up a recovery configuration for their //! account. -//! 7. Using the now recovered account, the account owner can call `close_recovery` -//! on the recovery process they opened, reclaiming the recovery deposit they -//! placed. +//! 2. At some later time, the account owner loses access to their account and wants to recover it. +//! Likely, they will need to create a new account and fund it with enough balance to support the +//! transaction fees and the deposit for the recovery process. +//! 3. Using this new account, they call `initiate_recovery`. +//! 4. Then the account owner would contact their configured friends to vouch for the recovery +//! attempt. The account owner would provide their old account id and the new account id, and +//! friends would call `vouch_recovery` with those parameters. +//! 5. Once a threshold number of friends have vouched for the recovery attempt, the account owner +//! needs to wait until the delay period has passed, starting when they initiated the recovery +//! process. +//! 6. Now the account owner is able to call `claim_recovery`, which subsequently allows them to +//! call `as_recovered` and directly make calls on-behalf-of the lost account. +//! 7. Using the now recovered account, the account owner can call `close_recovery` on the recovery +//! process they opened, reclaiming the recovery deposit they placed. //! 8. Then the account owner should then call `remove_recovery` to remove the recovery -//! configuration on the recovered account and reclaim the recovery configuration -//! deposit they placed. -//! 9. Using `as_recovered`, the account owner is able to call any other pallets -//! to clean up their state and reclaim any reserved or locked funds. They -//! can then transfer all funds from the recovered account to the new account. -//! 10. When the recovered account becomes reaped (i.e. its free and reserved -//! balance drops to zero), the final recovery link is removed. +//! configuration on the recovered account and reclaim the recovery configuration deposit they +//! placed. +//! 9. Using `as_recovered`, the account owner is able to call any other pallets to clean up their +//! state and reclaim any reserved or locked funds. They can then transfer all funds from the +//! recovered account to the new account. +//! 10. When the recovered account becomes reaped (i.e. its free and reserved balance drops to +//! zero), the final recovery link is removed. //! //! ### Malicious Recovery Attempts //! diff --git a/frame/support/src/lib.rs b/frame/support/src/lib.rs index fe8ede54bac57..01eec8d2ef79f 100644 --- a/frame/support/src/lib.rs +++ b/frame/support/src/lib.rs @@ -2708,13 +2708,13 @@ pub mod pallet_prelude { /// - query the metadata using the `state_getMetadata` RPC and curl, or use `subsee -p /// > meta.json` /// 2. Generate the template upgrade for the pallet provided by `decl_storage` with the -/// environment variable `PRINT_PALLET_UPGRADE`: `PRINT_PALLET_UPGRADE=1 cargo check -p -/// my_pallet`. This template can be used as it contains all information for storages, -/// genesis config and genesis build. +/// environment variable `PRINT_PALLET_UPGRADE`: `PRINT_PALLET_UPGRADE=1 cargo check -p +/// my_pallet`. This template can be used as it contains all information for storages, +/// genesis config and genesis build. /// 3. Reorganize the pallet to have the trait `Config`, `decl_*` macros, -/// [`ValidateUnsigned`](`pallet_prelude::ValidateUnsigned`), -/// [`ProvideInherent`](`pallet_prelude::ProvideInherent`), and Origin` all together in one -/// file. Suggested order: +/// [`ValidateUnsigned`](`pallet_prelude::ValidateUnsigned`), +/// [`ProvideInherent`](`pallet_prelude::ProvideInherent`), and Origin` all together in one +/// file. Suggested order: /// * `Config`, /// * `decl_module`, /// * `decl_event`, @@ -2774,8 +2774,8 @@ pub mod pallet_prelude { /// 8. **migrate error**: rewrite it with attribute /// [`#[pallet::error]`](#error-palleterror-optional). /// 9. **migrate storage**: `decl_storage` provide an upgrade template (see 3.). All storages, -/// genesis config, genesis build and default implementation of genesis config can be -/// taken from it directly. +/// genesis config, genesis build and default implementation of genesis config can be taken +/// from it directly. /// /// Otherwise here is the manual process: /// diff --git a/primitives/npos-elections/src/balancing.rs b/primitives/npos-elections/src/balancing.rs index 234326ee94dd2..90dbe7eb71478 100644 --- a/primitives/npos-elections/src/balancing.rs +++ b/primitives/npos-elections/src/balancing.rs @@ -19,7 +19,7 @@ //! //! Given a committee `A` and an edge weight vector `w`, a balanced solution is one that //! -//! 1. it maximizes the sum of member supports, i.e `Argmax { sum(support(c)) }`. for all `c` in +//! 1. it maximizes the sum of member supports, i.e `Argmax { sum(support(c)) }`. for all `c` in //! `A`. //! 2. it minimizes the sum of supports squared, i.e `Argmin { sum(support(c).pow(2)) }` for all `c` //! in `A`. diff --git a/primitives/runtime/src/offchain/http.rs b/primitives/runtime/src/offchain/http.rs index 25e5c1007d5da..bacc0073825bb 100644 --- a/primitives/runtime/src/offchain/http.rs +++ b/primitives/runtime/src/offchain/http.rs @@ -343,10 +343,10 @@ impl Response { /// A buffered byte iterator over response body. /// /// Note that reading the body may return `None` in following cases: -/// 1. Either the deadline you've set is reached (check via `#error`; -/// In such case you can resume the reader by setting a new deadline) -/// 2. Or because of IOError. In such case the reader is not resumable and will keep -/// returning `None`. +/// 1. Either the deadline you've set is reached (check via `#error`; In such case you can resume +/// the reader by setting a new deadline) +/// 2. Or because of IOError. In such case the reader is not resumable and will keep returning +/// `None`. /// 3. The body has been returned. The reader will keep returning `None`. #[derive(Clone)] pub struct ResponseBody { diff --git a/primitives/staking/src/offence.rs b/primitives/staking/src/offence.rs index 6694c9055d4ff..8013166374e06 100644 --- a/primitives/staking/src/offence.rs +++ b/primitives/staking/src/offence.rs @@ -220,16 +220,16 @@ pub struct OffenceDetails { /// for a typical usage scenario: /// /// 1. An offence is detected and an evidence is submitted on-chain via the -/// [`OffenceReportSystem::publish_evidence`] method. This will construct -/// and submit an extrinsic transaction containing the offence evidence. +/// [`OffenceReportSystem::publish_evidence`] method. This will construct and submit an extrinsic +/// transaction containing the offence evidence. /// -/// 2. If the extrinsic is unsigned then the transaction receiver may want to -/// perform some preliminary checks before further processing. This is a good -/// place to call the [`OffenceReportSystem::check_evidence`] method. +/// 2. If the extrinsic is unsigned then the transaction receiver may want to perform some +/// preliminary checks before further processing. This is a good place to call the +/// [`OffenceReportSystem::check_evidence`] method. /// -/// 3. Finally the report extrinsic is executed on-chain. This is where the user -/// calls the [`OffenceReportSystem::process_evidence`] to consume the offence -/// report and enact any required action. +/// 3. Finally the report extrinsic is executed on-chain. This is where the user calls the +/// [`OffenceReportSystem::process_evidence`] to consume the offence report and enact any +/// required action. pub trait OffenceReportSystem { /// Longevity, in blocks, for the evidence report validity. /// diff --git a/utils/wasm-builder/src/builder.rs b/utils/wasm-builder/src/builder.rs index d0bed8d22a036..208b56077669e 100644 --- a/utils/wasm-builder/src/builder.rs +++ b/utils/wasm-builder/src/builder.rs @@ -80,8 +80,8 @@ impl WasmBuilderSelectProject { /// /// 1. Call [`WasmBuilder::new`] to create a new builder. /// 2. Select the project to build using the methods of [`WasmBuilderSelectProject`]. -/// 3. Set additional `RUST_FLAGS` or a different name for the file containing the WASM code -/// using methods of [`WasmBuilder`]. +/// 3. Set additional `RUST_FLAGS` or a different name for the file containing the WASM code using +/// methods of [`WasmBuilder`]. /// 4. Build the WASM binary using [`Self::build`]. pub struct WasmBuilder { /// Flags that should be appended to `RUST_FLAGS` env variable. From 5f511ccd0465c213b41c83bba45c28b72993478d Mon Sep 17 00:00:00 2001 From: Anton Kaliaev Date: Thu, 29 Jun 2023 11:29:49 +0400 Subject: [PATCH 19/42] comment out tests for now --- .../src/worker/addr_cache.rs | 2 +- .../src/protocol/notifications/behaviour.rs | 4 +- .../src/protocol/notifications/handler.rs | 1226 ++++++++--------- .../notifications/upgrade/notifications.rs | 422 +++--- 4 files changed, 825 insertions(+), 829 deletions(-) diff --git a/client/authority-discovery/src/worker/addr_cache.rs b/client/authority-discovery/src/worker/addr_cache.rs index e3e17c0f0aad5..647b85aec0a4c 100644 --- a/client/authority-discovery/src/worker/addr_cache.rs +++ b/client/authority-discovery/src/worker/addr_cache.rs @@ -178,7 +178,7 @@ fn addresses_to_peer_ids(addresses: &HashSet) -> HashSet { mod tests { use super::*; - use libp2p::multihash::{self, Multihash}; + use libp2p::multihash::Multihash; use multihash_codetable::Code; use quickcheck::{Arbitrary, Gen, QuickCheck, TestResult}; diff --git a/client/network/src/protocol/notifications/behaviour.rs b/client/network/src/protocol/notifications/behaviour.rs index b8a303be96cb3..0927ecf318be9 100644 --- a/client/network/src/protocol/notifications/behaviour.rs +++ b/client/network/src/protocol/notifications/behaviour.rs @@ -2994,7 +2994,7 @@ mod tests { notif.on_swarm_event(FromSwarm::DialFailure(libp2p::swarm::behaviour::DialFailure { peer_id: Some(peer), - error: &libp2p::swarm::DialError::Banned, + error: &libp2p::swarm::DialError::Aborted, connection_id: ConnectionId::new_unchecked(1337), })); @@ -3531,7 +3531,7 @@ mod tests { let now = Instant::now(); notif.on_swarm_event(FromSwarm::DialFailure(libp2p::swarm::behaviour::DialFailure { peer_id: Some(peer), - error: &libp2p::swarm::DialError::Banned, + error: &libp2p::swarm::DialError::Aborted, connection_id: ConnectionId::new_unchecked(0), })); diff --git a/client/network/src/protocol/notifications/handler.rs b/client/network/src/protocol/notifications/handler.rs index 660a752c07c84..337c39e5f94ff 100644 --- a/client/network/src/protocol/notifications/handler.rs +++ b/client/network/src/protocol/notifications/handler.rs @@ -824,22 +824,18 @@ impl ConnectionHandler for NotifsHandler { #[cfg(test)] pub mod tests { use super::*; - use crate::protocol::notifications::upgrade::{ - NotificationsInOpen, NotificationsInSubstreamHandshake, NotificationsOutOpen, - }; - use asynchronous_codec::Framed; - use libp2p::{ - core::muxing::SubstreamBox, - swarm::{handler, StreamUpgradeError}, - Multiaddr, - }; - use multistream_select::{dialer_select_proto, listener_select_proto, Negotiated, Version}; + // use crate::protocol::notifications::upgrade::{ + // NotificationsInOpen, NotificationsInSubstreamHandshake, NotificationsOutOpen, + // }; + // use asynchronous_codec::Framed; + // use libp2p::Multiaddr; + // use multistream_select::{dialer_select_proto, listener_select_proto, Negotiated, Version}; use std::{ collections::HashMap, io::{Error, IoSlice, IoSliceMut}, }; use tokio::sync::mpsc; - use unsigned_varint::codec::UviBytes; + // use unsigned_varint::codec::UviBytes; struct OpenSubstream { notifications: stream::Peekable< @@ -938,20 +934,20 @@ pub mod tests { ) } - /// Create new negotiated substream pair. - pub async fn negotiated() -> (Negotiated, Negotiated) { - let (socket1, socket2) = Self::new(); - let socket1 = SubstreamBox::new(socket1); - let socket2 = SubstreamBox::new(socket2); + // /// Create new negotiated substream pair. + // pub async fn negotiated() -> (Negotiated, Negotiated) { + // let (socket1, socket2) = Self::new(); + // let socket1 = SubstreamBox::new(socket1); + // let socket2 = SubstreamBox::new(socket2); - let protos = vec![b"/echo/1.0.0", b"/echo/2.5.0"]; - let (res1, res2) = tokio::join!( - dialer_select_proto(socket1, protos.clone(), Version::V1), - listener_select_proto(socket2, protos), - ); + // let protos = vec![b"/echo/1.0.0", b"/echo/2.5.0"]; + // let (res1, res2) = tokio::join!( + // dialer_select_proto(socket1, protos.clone(), Version::V1), + // listener_select_proto(socket2, protos), + // ); - (res1.unwrap().1, res2.unwrap().1) - } + // (res1.unwrap().1, res2.unwrap().1) + // } } impl AsyncWrite for MockSubstream { @@ -1016,596 +1012,596 @@ pub mod tests { } } - /// Create new [`NotifsHandler`]. - fn notifs_handler() -> NotifsHandler { - let proto = Protocol { - config: ProtocolConfig { - name: "/foo".into(), - fallback_names: vec![], - handshake: Arc::new(RwLock::new(b"hello, world".to_vec())), - max_notification_size: u64::MAX, - }, - in_upgrade: NotificationsIn::new("/foo", Vec::new(), u64::MAX), - state: State::Closed { pending_opening: false }, - }; - - NotifsHandler { - protocols: vec![proto], - when_connection_open: Instant::now(), - endpoint: ConnectedPoint::Listener { - local_addr: Multiaddr::empty(), - send_back_addr: Multiaddr::empty(), - }, - peer_id: PeerId::random(), - events_queue: VecDeque::new(), - } - } - - // verify that if another substream is attempted to be opened by remote while an inbound - // substream already exists, the new inbound stream is rejected and closed by the local node. - #[tokio::test] - async fn second_open_desired_by_remote_rejected() { - let mut handler = notifs_handler(); - let (io, mut io2) = MockSubstream::negotiated().await; - let mut codec = UviBytes::default(); - codec.set_max_len(usize::MAX); - - let notif_in = NotificationsInOpen { - handshake: b"hello, world".to_vec(), - negotiated_fallback: None, - substream: NotificationsInSubstream::new( - Framed::new(io, codec), - NotificationsInSubstreamHandshake::NotSent, - ), - }; - - handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedInbound( - handler::FullyNegotiatedInbound { protocol: (notif_in, 0), info: () }, - )); - - // verify that the substream is in (partly) opened state - assert!(std::matches!(handler.protocols[0].state, State::OpenDesiredByRemote { .. })); - futures::future::poll_fn(|cx| { - let mut buf = Vec::with_capacity(512); - assert!(std::matches!(Pin::new(&mut io2).poll_read(cx, &mut buf), Poll::Pending)); - Poll::Ready(()) - }) - .await; - - // attempt to open another inbound substream and verify that it is rejected - let (io, mut io2) = MockSubstream::negotiated().await; - let mut codec = UviBytes::default(); - codec.set_max_len(usize::MAX); - - let notif_in = NotificationsInOpen { - handshake: b"hello, world".to_vec(), - negotiated_fallback: None, - substream: NotificationsInSubstream::new( - Framed::new(io, codec), - NotificationsInSubstreamHandshake::NotSent, - ), - }; - - handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedInbound( - handler::FullyNegotiatedInbound { protocol: (notif_in, 0), info: () }, - )); - - // verify that the new substream is rejected and closed - futures::future::poll_fn(|cx| { - let mut buf = Vec::with_capacity(512); - - if let Poll::Ready(Err(err)) = Pin::new(&mut io2).poll_read(cx, &mut buf) { - assert_eq!(err.kind(), std::io::ErrorKind::UnexpectedEof,); - } - - Poll::Ready(()) - }) - .await; - } - - #[tokio::test] - async fn open_rejected_if_substream_is_opening() { - let mut handler = notifs_handler(); - let (io, mut io2) = MockSubstream::negotiated().await; - let mut codec = UviBytes::default(); - codec.set_max_len(usize::MAX); - - let notif_in = NotificationsInOpen { - handshake: b"hello, world".to_vec(), - negotiated_fallback: None, - substream: NotificationsInSubstream::new( - Framed::new(io, codec), - NotificationsInSubstreamHandshake::NotSent, - ), - }; - - handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedInbound( - handler::FullyNegotiatedInbound { protocol: (notif_in, 0), info: () }, - )); - - // verify that the substream is in (partly) opened state - assert!(std::matches!(handler.protocols[0].state, State::OpenDesiredByRemote { .. })); - futures::future::poll_fn(|cx| { - let mut buf = Vec::with_capacity(512); - assert!(std::matches!(Pin::new(&mut io2).poll_read(cx, &mut buf), Poll::Pending)); - Poll::Ready(()) - }) - .await; - - // move the handler state to 'Opening' - handler.on_behaviour_event(NotifsHandlerIn::Open { protocol_index: 0 }); - assert!(std::matches!( - handler.protocols[0].state, - State::Opening { in_substream: Some(_) } - )); - - // remote now tries to open another substream, verify that it is rejected and closed - let (io, mut io2) = MockSubstream::negotiated().await; - let mut codec = UviBytes::default(); - codec.set_max_len(usize::MAX); - - let notif_in = NotificationsInOpen { - handshake: b"hello, world".to_vec(), - negotiated_fallback: None, - substream: NotificationsInSubstream::new( - Framed::new(io, codec), - NotificationsInSubstreamHandshake::NotSent, - ), - }; - - handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedInbound( - handler::FullyNegotiatedInbound { protocol: (notif_in, 0), info: () }, - )); - - // verify that the new substream is rejected and closed but that the first substream is - // still in correct state - futures::future::poll_fn(|cx| { - let mut buf = Vec::with_capacity(512); - - if let Poll::Ready(Err(err)) = Pin::new(&mut io2).poll_read(cx, &mut buf) { - assert_eq!(err.kind(), std::io::ErrorKind::UnexpectedEof,); - } else { - panic!("unexpected result"); - } - - Poll::Ready(()) - }) - .await; - assert!(std::matches!( - handler.protocols[0].state, - State::Opening { in_substream: Some(_) } - )); - } - - #[tokio::test] - async fn open_rejected_if_substream_already_open() { - let mut handler = notifs_handler(); - let (io, mut io2) = MockSubstream::negotiated().await; - let mut codec = UviBytes::default(); - codec.set_max_len(usize::MAX); - - let notif_in = NotificationsInOpen { - handshake: b"hello, world".to_vec(), - negotiated_fallback: None, - substream: NotificationsInSubstream::new( - Framed::new(io, codec), - NotificationsInSubstreamHandshake::NotSent, - ), - }; - handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedInbound( - handler::FullyNegotiatedInbound { protocol: (notif_in, 0), info: () }, - )); - - // verify that the substream is in (partly) opened state - assert!(std::matches!(handler.protocols[0].state, State::OpenDesiredByRemote { .. })); - futures::future::poll_fn(|cx| { - let mut buf = Vec::with_capacity(512); - assert!(std::matches!(Pin::new(&mut io2).poll_read(cx, &mut buf), Poll::Pending)); - Poll::Ready(()) - }) - .await; - - // move the handler state to 'Opening' - handler.on_behaviour_event(NotifsHandlerIn::Open { protocol_index: 0 }); - assert!(std::matches!( - handler.protocols[0].state, - State::Opening { in_substream: Some(_) } - )); - - // accept the substream and move its state to `Open` - let (io, _io2) = MockSubstream::negotiated().await; - let mut codec = UviBytes::default(); - codec.set_max_len(usize::MAX); - - let notif_out = NotificationsOutOpen { - handshake: b"hello, world".to_vec(), - negotiated_fallback: None, - substream: NotificationsOutSubstream::new(Framed::new(io, codec)), - }; - handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedOutbound( - handler::FullyNegotiatedOutbound { protocol: notif_out, info: 0 }, - )); - - assert!(std::matches!( - handler.protocols[0].state, - State::Open { in_substream: Some(_), .. } - )); - - // remote now tries to open another substream, verify that it is rejected and closed - let (io, mut io2) = MockSubstream::negotiated().await; - let mut codec = UviBytes::default(); - codec.set_max_len(usize::MAX); - let notif_in = NotificationsInOpen { - handshake: b"hello, world".to_vec(), - negotiated_fallback: None, - substream: NotificationsInSubstream::new( - Framed::new(io, codec), - NotificationsInSubstreamHandshake::NotSent, - ), - }; - handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedInbound( - handler::FullyNegotiatedInbound { protocol: (notif_in, 0), info: () }, - )); - - // verify that the new substream is rejected and closed but that the first substream is - // still in correct state - futures::future::poll_fn(|cx| { - let mut buf = Vec::with_capacity(512); - - if let Poll::Ready(Err(err)) = Pin::new(&mut io2).poll_read(cx, &mut buf) { - assert_eq!(err.kind(), std::io::ErrorKind::UnexpectedEof); - } else { - panic!("unexpected result"); - } - - Poll::Ready(()) - }) - .await; - assert!(std::matches!( - handler.protocols[0].state, - State::Open { in_substream: Some(_), .. } - )); - } - - #[tokio::test] - async fn fully_negotiated_resets_state_for_closed_substream() { - let mut handler = notifs_handler(); - let (io, mut io2) = MockSubstream::negotiated().await; - let mut codec = UviBytes::default(); - codec.set_max_len(usize::MAX); - - let notif_in = NotificationsInOpen { - handshake: b"hello, world".to_vec(), - negotiated_fallback: None, - substream: NotificationsInSubstream::new( - Framed::new(io, codec), - NotificationsInSubstreamHandshake::NotSent, - ), - }; - handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedInbound( - handler::FullyNegotiatedInbound { protocol: (notif_in, 0), info: () }, - )); - - // verify that the substream is in (partly) opened state - assert!(std::matches!(handler.protocols[0].state, State::OpenDesiredByRemote { .. })); - futures::future::poll_fn(|cx| { - let mut buf = Vec::with_capacity(512); - assert!(std::matches!(Pin::new(&mut io2).poll_read(cx, &mut buf), Poll::Pending)); - Poll::Ready(()) - }) - .await; - - // first instruct the handler to open a connection and then close it right after - // so the handler is in state `Closed { pending_opening: true }` - handler.on_behaviour_event(NotifsHandlerIn::Open { protocol_index: 0 }); - assert!(std::matches!( - handler.protocols[0].state, - State::Opening { in_substream: Some(_) } - )); - - handler.on_behaviour_event(NotifsHandlerIn::Close { protocol_index: 0 }); - assert!(std::matches!(handler.protocols[0].state, State::Closed { pending_opening: true })); - - // verify that if the the outbound substream is successfully negotiated, the state is not - // changed as the substream was commanded to be closed by the handler. - let (io, _io2) = MockSubstream::negotiated().await; - let mut codec = UviBytes::default(); - codec.set_max_len(usize::MAX); - - let notif_out = NotificationsOutOpen { - handshake: b"hello, world".to_vec(), - negotiated_fallback: None, - substream: NotificationsOutSubstream::new(Framed::new(io, codec)), - }; - handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedOutbound( - handler::FullyNegotiatedOutbound { protocol: notif_out, info: 0 }, - )); - - assert!(std::matches!( - handler.protocols[0].state, - State::Closed { pending_opening: false } - )); - } - - #[tokio::test] - async fn fully_negotiated_resets_state_for_open_desired_substream() { - let mut handler = notifs_handler(); - let (io, mut io2) = MockSubstream::negotiated().await; - let mut codec = UviBytes::default(); - codec.set_max_len(usize::MAX); - - let notif_in = NotificationsInOpen { - handshake: b"hello, world".to_vec(), - negotiated_fallback: None, - substream: NotificationsInSubstream::new( - Framed::new(io, codec), - NotificationsInSubstreamHandshake::NotSent, - ), - }; - handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedInbound( - handler::FullyNegotiatedInbound { protocol: (notif_in, 0), info: () }, - )); - - // verify that the substream is in (partly) opened state - assert!(std::matches!(handler.protocols[0].state, State::OpenDesiredByRemote { .. })); - futures::future::poll_fn(|cx| { - let mut buf = Vec::with_capacity(512); - assert!(std::matches!(Pin::new(&mut io2).poll_read(cx, &mut buf), Poll::Pending)); - Poll::Ready(()) - }) - .await; - - // first instruct the handler to open a connection and then close it right after - // so the handler is in state `Closed { pending_opening: true }` - handler.on_behaviour_event(NotifsHandlerIn::Open { protocol_index: 0 }); - assert!(std::matches!( - handler.protocols[0].state, - State::Opening { in_substream: Some(_) } - )); - - handler.on_behaviour_event(NotifsHandlerIn::Close { protocol_index: 0 }); - assert!(std::matches!(handler.protocols[0].state, State::Closed { pending_opening: true })); - - // attempt to open another inbound substream and verify that it is rejected - let (io, _io2) = MockSubstream::negotiated().await; - let mut codec = UviBytes::default(); - codec.set_max_len(usize::MAX); - - let notif_in = NotificationsInOpen { - handshake: b"hello, world".to_vec(), - negotiated_fallback: None, - substream: NotificationsInSubstream::new( - Framed::new(io, codec), - NotificationsInSubstreamHandshake::NotSent, - ), - }; - handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedInbound( - handler::FullyNegotiatedInbound { protocol: (notif_in, 0), info: () }, - )); - - assert!(std::matches!( - handler.protocols[0].state, - State::OpenDesiredByRemote { pending_opening: true, .. } - )); - - // verify that if the the outbound substream is successfully negotiated, the state is not - // changed as the substream was commanded to be closed by the handler. - let (io, _io2) = MockSubstream::negotiated().await; - let mut codec = UviBytes::default(); - codec.set_max_len(usize::MAX); - - let notif_out = NotificationsOutOpen { - handshake: b"hello, world".to_vec(), - negotiated_fallback: None, - substream: NotificationsOutSubstream::new(Framed::new(io, codec)), - }; - - handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedOutbound( - handler::FullyNegotiatedOutbound { protocol: notif_out, info: 0 }, - )); - - assert!(std::matches!( - handler.protocols[0].state, - State::OpenDesiredByRemote { pending_opening: false, .. } - )); - } - - #[tokio::test] - async fn dial_upgrade_error_resets_closed_outbound_state() { - let mut handler = notifs_handler(); - let (io, mut io2) = MockSubstream::negotiated().await; - let mut codec = UviBytes::default(); - codec.set_max_len(usize::MAX); - - let notif_in = NotificationsInOpen { - handshake: b"hello, world".to_vec(), - negotiated_fallback: None, - substream: NotificationsInSubstream::new( - Framed::new(io, codec), - NotificationsInSubstreamHandshake::NotSent, - ), - }; - handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedInbound( - handler::FullyNegotiatedInbound { protocol: (notif_in, 0), info: () }, - )); - - // verify that the substream is in (partly) opened state - assert!(std::matches!(handler.protocols[0].state, State::OpenDesiredByRemote { .. })); - futures::future::poll_fn(|cx| { - let mut buf = Vec::with_capacity(512); - assert!(std::matches!(Pin::new(&mut io2).poll_read(cx, &mut buf), Poll::Pending)); - Poll::Ready(()) - }) - .await; - - // first instruct the handler to open a connection and then close it right after - // so the handler is in state `Closed { pending_opening: true }` - handler.on_behaviour_event(NotifsHandlerIn::Open { protocol_index: 0 }); - assert!(std::matches!( - handler.protocols[0].state, - State::Opening { in_substream: Some(_) } - )); - - handler.on_behaviour_event(NotifsHandlerIn::Close { protocol_index: 0 }); - assert!(std::matches!(handler.protocols[0].state, State::Closed { pending_opening: true })); - - // inject dial failure to an already closed substream and verify outbound state is reset - handler.on_connection_event(handler::ConnectionEvent::DialUpgradeError( - handler::DialUpgradeError { info: 0, error: StreamUpgradeError::Timeout }, - )); - assert!(std::matches!( - handler.protocols[0].state, - State::Closed { pending_opening: false } - )); - } - - #[tokio::test] - async fn dial_upgrade_error_resets_open_desired_state() { - let mut handler = notifs_handler(); - let (io, mut io2) = MockSubstream::negotiated().await; - let mut codec = UviBytes::default(); - codec.set_max_len(usize::MAX); - - let notif_in = NotificationsInOpen { - handshake: b"hello, world".to_vec(), - negotiated_fallback: None, - substream: NotificationsInSubstream::new( - Framed::new(io, codec), - NotificationsInSubstreamHandshake::NotSent, - ), - }; - handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedInbound( - handler::FullyNegotiatedInbound { protocol: (notif_in, 0), info: () }, - )); - - // verify that the substream is in (partly) opened state - assert!(std::matches!(handler.protocols[0].state, State::OpenDesiredByRemote { .. })); - futures::future::poll_fn(|cx| { - let mut buf = Vec::with_capacity(512); - assert!(std::matches!(Pin::new(&mut io2).poll_read(cx, &mut buf), Poll::Pending)); - Poll::Ready(()) - }) - .await; - - // first instruct the handler to open a connection and then close it right after - // so the handler is in state `Closed { pending_opening: true }` - handler.on_behaviour_event(NotifsHandlerIn::Open { protocol_index: 0 }); - assert!(std::matches!( - handler.protocols[0].state, - State::Opening { in_substream: Some(_) } - )); - - handler.on_behaviour_event(NotifsHandlerIn::Close { protocol_index: 0 }); - assert!(std::matches!(handler.protocols[0].state, State::Closed { pending_opening: true })); - - let (io, _io2) = MockSubstream::negotiated().await; - let mut codec = UviBytes::default(); - codec.set_max_len(usize::MAX); - - let notif_in = NotificationsInOpen { - handshake: b"hello, world".to_vec(), - negotiated_fallback: None, - substream: NotificationsInSubstream::new( - Framed::new(io, codec), - NotificationsInSubstreamHandshake::NotSent, - ), - }; - handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedInbound( - handler::FullyNegotiatedInbound { protocol: (notif_in, 0), info: () }, - )); - - assert!(std::matches!( - handler.protocols[0].state, - State::OpenDesiredByRemote { pending_opening: true, .. } - )); - - // inject dial failure to an already closed substream and verify outbound state is reset - handler.on_connection_event(handler::ConnectionEvent::DialUpgradeError( - handler::DialUpgradeError { info: 0, error: StreamUpgradeError::Timeout }, - )); - assert!(std::matches!( - handler.protocols[0].state, - State::OpenDesiredByRemote { pending_opening: false, .. } - )); - } - - #[tokio::test] - async fn sync_notifications_clogged() { - let mut handler = notifs_handler(); - let (io, _) = MockSubstream::negotiated().await; - let codec = UviBytes::default(); - - let (async_tx, async_rx) = futures::channel::mpsc::channel(ASYNC_NOTIFICATIONS_BUFFER_SIZE); - let (sync_tx, sync_rx) = futures::channel::mpsc::channel(1); - let notifications_sink = NotificationsSink { - inner: Arc::new(NotificationsSinkInner { - peer_id: PeerId::random(), - async_channel: FuturesMutex::new(async_tx), - sync_channel: Mutex::new(Some(sync_tx)), - }), - }; - - handler.protocols[0].state = State::Open { - notifications_sink_rx: stream::select(async_rx.fuse(), sync_rx.fuse()).peekable(), - out_substream: Some(NotificationsOutSubstream::new(Framed::new(io, codec))), - in_substream: None, - }; - - notifications_sink.send_sync_notification(vec![1, 3, 3, 7]); - notifications_sink.send_sync_notification(vec![1, 3, 3, 8]); - notifications_sink.send_sync_notification(vec![1, 3, 3, 9]); - notifications_sink.send_sync_notification(vec![1, 3, 4, 0]); - - futures::future::poll_fn(|cx| { - assert!(std::matches!( - handler.poll(cx), - Poll::Ready(ConnectionHandlerEvent::Close( - NotifsHandlerError::SyncNotificationsClogged, - )) - )); - Poll::Ready(()) - }) - .await; - } - - #[tokio::test] - async fn close_desired_by_remote() { - let mut handler = notifs_handler(); - let (io, io2) = MockSubstream::negotiated().await; - let mut codec = UviBytes::default(); - codec.set_max_len(usize::MAX); - - let notif_in = NotificationsInOpen { - handshake: b"hello, world".to_vec(), - negotiated_fallback: None, - substream: NotificationsInSubstream::new( - Framed::new(io, codec), - NotificationsInSubstreamHandshake::PendingSend(vec![1, 2, 3, 4]), - ), - }; - - // add new inbound substream but close it immediately and verify that correct events are - // emitted - handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedInbound( - handler::FullyNegotiatedInbound { protocol: (notif_in, 0), info: () }, - )); - drop(io2); - - futures::future::poll_fn(|cx| { - assert!(std::matches!( - handler.poll(cx), - Poll::Ready(ConnectionHandlerEvent::NotifyBehaviour( - NotifsHandlerOut::OpenDesiredByRemote { protocol_index: 0 }, - )) - )); - assert!(std::matches!( - handler.poll(cx), - Poll::Ready(ConnectionHandlerEvent::NotifyBehaviour( - NotifsHandlerOut::CloseDesired { protocol_index: 0 }, - )) - )); - Poll::Ready(()) - }) - .await; - } + // /// Create new [`NotifsHandler`]. + // fn notifs_handler() -> NotifsHandler { + // let proto = Protocol { + // config: ProtocolConfig { + // name: "/foo".into(), + // fallback_names: vec![], + // handshake: Arc::new(RwLock::new(b"hello, world".to_vec())), + // max_notification_size: u64::MAX, + // }, + // in_upgrade: NotificationsIn::new("/foo", Vec::new(), u64::MAX), + // state: State::Closed { pending_opening: false }, + // }; + + // NotifsHandler { + // protocols: vec![proto], + // when_connection_open: Instant::now(), + // endpoint: ConnectedPoint::Listener { + // local_addr: Multiaddr::empty(), + // send_back_addr: Multiaddr::empty(), + // }, + // peer_id: PeerId::random(), + // events_queue: VecDeque::new(), + // } + // } + + // // verify that if another substream is attempted to be opened by remote while an inbound + // // substream already exists, the new inbound stream is rejected and closed by the local node. + // #[tokio::test] + // async fn second_open_desired_by_remote_rejected() { + // let mut handler = notifs_handler(); + // let (io, mut io2) = MockSubstream::negotiated().await; + // let mut codec = UviBytes::default(); + // codec.set_max_len(usize::MAX); + + // let notif_in = NotificationsInOpen { + // handshake: b"hello, world".to_vec(), + // negotiated_fallback: None, + // substream: NotificationsInSubstream::new( + // Framed::new(io, codec), + // NotificationsInSubstreamHandshake::NotSent, + // ), + // }; + + // handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedInbound( + // handler::FullyNegotiatedInbound { protocol: (notif_in, 0), info: () }, + // )); + + // // verify that the substream is in (partly) opened state + // assert!(std::matches!(handler.protocols[0].state, State::OpenDesiredByRemote { .. })); + // futures::future::poll_fn(|cx| { + // let mut buf = Vec::with_capacity(512); + // assert!(std::matches!(Pin::new(&mut io2).poll_read(cx, &mut buf), Poll::Pending)); + // Poll::Ready(()) + // }) + // .await; + + // // attempt to open another inbound substream and verify that it is rejected + // let (io, mut io2) = MockSubstream::negotiated().await; + // let mut codec = UviBytes::default(); + // codec.set_max_len(usize::MAX); + + // let notif_in = NotificationsInOpen { + // handshake: b"hello, world".to_vec(), + // negotiated_fallback: None, + // substream: NotificationsInSubstream::new( + // Framed::new(io, codec), + // NotificationsInSubstreamHandshake::NotSent, + // ), + // }; + + // handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedInbound( + // handler::FullyNegotiatedInbound { protocol: (notif_in, 0), info: () }, + // )); + + // // verify that the new substream is rejected and closed + // futures::future::poll_fn(|cx| { + // let mut buf = Vec::with_capacity(512); + + // if let Poll::Ready(Err(err)) = Pin::new(&mut io2).poll_read(cx, &mut buf) { + // assert_eq!(err.kind(), std::io::ErrorKind::UnexpectedEof,); + // } + + // Poll::Ready(()) + // }) + // .await; + // } + + // #[tokio::test] + // async fn open_rejected_if_substream_is_opening() { + // let mut handler = notifs_handler(); + // let (io, mut io2) = MockSubstream::negotiated().await; + // let mut codec = UviBytes::default(); + // codec.set_max_len(usize::MAX); + + // let notif_in = NotificationsInOpen { + // handshake: b"hello, world".to_vec(), + // negotiated_fallback: None, + // substream: NotificationsInSubstream::new( + // Framed::new(io, codec), + // NotificationsInSubstreamHandshake::NotSent, + // ), + // }; + + // handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedInbound( + // handler::FullyNegotiatedInbound { protocol: (notif_in, 0), info: () }, + // )); + + // // verify that the substream is in (partly) opened state + // assert!(std::matches!(handler.protocols[0].state, State::OpenDesiredByRemote { .. })); + // futures::future::poll_fn(|cx| { + // let mut buf = Vec::with_capacity(512); + // assert!(std::matches!(Pin::new(&mut io2).poll_read(cx, &mut buf), Poll::Pending)); + // Poll::Ready(()) + // }) + // .await; + + // // move the handler state to 'Opening' + // handler.on_behaviour_event(NotifsHandlerIn::Open { protocol_index: 0 }); + // assert!(std::matches!( + // handler.protocols[0].state, + // State::Opening { in_substream: Some(_) } + // )); + + // // remote now tries to open another substream, verify that it is rejected and closed + // let (io, mut io2) = MockSubstream::negotiated().await; + // let mut codec = UviBytes::default(); + // codec.set_max_len(usize::MAX); + + // let notif_in = NotificationsInOpen { + // handshake: b"hello, world".to_vec(), + // negotiated_fallback: None, + // substream: NotificationsInSubstream::new( + // Framed::new(io, codec), + // NotificationsInSubstreamHandshake::NotSent, + // ), + // }; + + // handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedInbound( + // handler::FullyNegotiatedInbound { protocol: (notif_in, 0), info: () }, + // )); + + // // verify that the new substream is rejected and closed but that the first substream is + // // still in correct state + // futures::future::poll_fn(|cx| { + // let mut buf = Vec::with_capacity(512); + + // if let Poll::Ready(Err(err)) = Pin::new(&mut io2).poll_read(cx, &mut buf) { + // assert_eq!(err.kind(), std::io::ErrorKind::UnexpectedEof,); + // } else { + // panic!("unexpected result"); + // } + + // Poll::Ready(()) + // }) + // .await; + // assert!(std::matches!( + // handler.protocols[0].state, + // State::Opening { in_substream: Some(_) } + // )); + // } + + // #[tokio::test] + // async fn open_rejected_if_substream_already_open() { + // let mut handler = notifs_handler(); + // let (io, mut io2) = MockSubstream::negotiated().await; + // let mut codec = UviBytes::default(); + // codec.set_max_len(usize::MAX); + + // let notif_in = NotificationsInOpen { + // handshake: b"hello, world".to_vec(), + // negotiated_fallback: None, + // substream: NotificationsInSubstream::new( + // Framed::new(io, codec), + // NotificationsInSubstreamHandshake::NotSent, + // ), + // }; + // handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedInbound( + // handler::FullyNegotiatedInbound { protocol: (notif_in, 0), info: () }, + // )); + + // // verify that the substream is in (partly) opened state + // assert!(std::matches!(handler.protocols[0].state, State::OpenDesiredByRemote { .. })); + // futures::future::poll_fn(|cx| { + // let mut buf = Vec::with_capacity(512); + // assert!(std::matches!(Pin::new(&mut io2).poll_read(cx, &mut buf), Poll::Pending)); + // Poll::Ready(()) + // }) + // .await; + + // // move the handler state to 'Opening' + // handler.on_behaviour_event(NotifsHandlerIn::Open { protocol_index: 0 }); + // assert!(std::matches!( + // handler.protocols[0].state, + // State::Opening { in_substream: Some(_) } + // )); + + // // accept the substream and move its state to `Open` + // let (io, _io2) = MockSubstream::negotiated().await; + // let mut codec = UviBytes::default(); + // codec.set_max_len(usize::MAX); + + // let notif_out = NotificationsOutOpen { + // handshake: b"hello, world".to_vec(), + // negotiated_fallback: None, + // substream: NotificationsOutSubstream::new(Framed::new(io, codec)), + // }; + // handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedOutbound( + // handler::FullyNegotiatedOutbound { protocol: notif_out, info: 0 }, + // )); + + // assert!(std::matches!( + // handler.protocols[0].state, + // State::Open { in_substream: Some(_), .. } + // )); + + // // remote now tries to open another substream, verify that it is rejected and closed + // let (io, mut io2) = MockSubstream::negotiated().await; + // let mut codec = UviBytes::default(); + // codec.set_max_len(usize::MAX); + // let notif_in = NotificationsInOpen { + // handshake: b"hello, world".to_vec(), + // negotiated_fallback: None, + // substream: NotificationsInSubstream::new( + // Framed::new(io, codec), + // NotificationsInSubstreamHandshake::NotSent, + // ), + // }; + // handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedInbound( + // handler::FullyNegotiatedInbound { protocol: (notif_in, 0), info: () }, + // )); + + // // verify that the new substream is rejected and closed but that the first substream is + // // still in correct state + // futures::future::poll_fn(|cx| { + // let mut buf = Vec::with_capacity(512); + + // if let Poll::Ready(Err(err)) = Pin::new(&mut io2).poll_read(cx, &mut buf) { + // assert_eq!(err.kind(), std::io::ErrorKind::UnexpectedEof); + // } else { + // panic!("unexpected result"); + // } + + // Poll::Ready(()) + // }) + // .await; + // assert!(std::matches!( + // handler.protocols[0].state, + // State::Open { in_substream: Some(_), .. } + // )); + // } + + // #[tokio::test] + // async fn fully_negotiated_resets_state_for_closed_substream() { + // let mut handler = notifs_handler(); + // let (io, mut io2) = MockSubstream::negotiated().await; + // let mut codec = UviBytes::default(); + // codec.set_max_len(usize::MAX); + + // let notif_in = NotificationsInOpen { + // handshake: b"hello, world".to_vec(), + // negotiated_fallback: None, + // substream: NotificationsInSubstream::new( + // Framed::new(io, codec), + // NotificationsInSubstreamHandshake::NotSent, + // ), + // }; + // handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedInbound( + // handler::FullyNegotiatedInbound { protocol: (notif_in, 0), info: () }, + // )); + + // // verify that the substream is in (partly) opened state + // assert!(std::matches!(handler.protocols[0].state, State::OpenDesiredByRemote { .. })); + // futures::future::poll_fn(|cx| { + // let mut buf = Vec::with_capacity(512); + // assert!(std::matches!(Pin::new(&mut io2).poll_read(cx, &mut buf), Poll::Pending)); + // Poll::Ready(()) + // }) + // .await; + + // // first instruct the handler to open a connection and then close it right after + // // so the handler is in state `Closed { pending_opening: true }` + // handler.on_behaviour_event(NotifsHandlerIn::Open { protocol_index: 0 }); + // assert!(std::matches!( + // handler.protocols[0].state, + // State::Opening { in_substream: Some(_) } + // )); + + // handler.on_behaviour_event(NotifsHandlerIn::Close { protocol_index: 0 }); + // assert!(std::matches!(handler.protocols[0].state, State::Closed { pending_opening: true })); + + // // verify that if the the outbound substream is successfully negotiated, the state is not + // // changed as the substream was commanded to be closed by the handler. + // let (io, _io2) = MockSubstream::negotiated().await; + // let mut codec = UviBytes::default(); + // codec.set_max_len(usize::MAX); + + // let notif_out = NotificationsOutOpen { + // handshake: b"hello, world".to_vec(), + // negotiated_fallback: None, + // substream: NotificationsOutSubstream::new(Framed::new(io, codec)), + // }; + // handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedOutbound( + // handler::FullyNegotiatedOutbound { protocol: notif_out, info: 0 }, + // )); + + // assert!(std::matches!( + // handler.protocols[0].state, + // State::Closed { pending_opening: false } + // )); + // } + + // #[tokio::test] + // async fn fully_negotiated_resets_state_for_open_desired_substream() { + // let mut handler = notifs_handler(); + // let (io, mut io2) = MockSubstream::negotiated().await; + // let mut codec = UviBytes::default(); + // codec.set_max_len(usize::MAX); + + // let notif_in = NotificationsInOpen { + // handshake: b"hello, world".to_vec(), + // negotiated_fallback: None, + // substream: NotificationsInSubstream::new( + // Framed::new(io, codec), + // NotificationsInSubstreamHandshake::NotSent, + // ), + // }; + // handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedInbound( + // handler::FullyNegotiatedInbound { protocol: (notif_in, 0), info: () }, + // )); + + // // verify that the substream is in (partly) opened state + // assert!(std::matches!(handler.protocols[0].state, State::OpenDesiredByRemote { .. })); + // futures::future::poll_fn(|cx| { + // let mut buf = Vec::with_capacity(512); + // assert!(std::matches!(Pin::new(&mut io2).poll_read(cx, &mut buf), Poll::Pending)); + // Poll::Ready(()) + // }) + // .await; + + // // first instruct the handler to open a connection and then close it right after + // // so the handler is in state `Closed { pending_opening: true }` + // handler.on_behaviour_event(NotifsHandlerIn::Open { protocol_index: 0 }); + // assert!(std::matches!( + // handler.protocols[0].state, + // State::Opening { in_substream: Some(_) } + // )); + + // handler.on_behaviour_event(NotifsHandlerIn::Close { protocol_index: 0 }); + // assert!(std::matches!(handler.protocols[0].state, State::Closed { pending_opening: true })); + + // // attempt to open another inbound substream and verify that it is rejected + // let (io, _io2) = MockSubstream::negotiated().await; + // let mut codec = UviBytes::default(); + // codec.set_max_len(usize::MAX); + + // let notif_in = NotificationsInOpen { + // handshake: b"hello, world".to_vec(), + // negotiated_fallback: None, + // substream: NotificationsInSubstream::new( + // Framed::new(io, codec), + // NotificationsInSubstreamHandshake::NotSent, + // ), + // }; + // handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedInbound( + // handler::FullyNegotiatedInbound { protocol: (notif_in, 0), info: () }, + // )); + + // assert!(std::matches!( + // handler.protocols[0].state, + // State::OpenDesiredByRemote { pending_opening: true, .. } + // )); + + // // verify that if the the outbound substream is successfully negotiated, the state is not + // // changed as the substream was commanded to be closed by the handler. + // let (io, _io2) = MockSubstream::negotiated().await; + // let mut codec = UviBytes::default(); + // codec.set_max_len(usize::MAX); + + // let notif_out = NotificationsOutOpen { + // handshake: b"hello, world".to_vec(), + // negotiated_fallback: None, + // substream: NotificationsOutSubstream::new(Framed::new(io, codec)), + // }; + + // handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedOutbound( + // handler::FullyNegotiatedOutbound { protocol: notif_out, info: 0 }, + // )); + + // assert!(std::matches!( + // handler.protocols[0].state, + // State::OpenDesiredByRemote { pending_opening: false, .. } + // )); + // } + + // #[tokio::test] + // async fn dial_upgrade_error_resets_closed_outbound_state() { + // let mut handler = notifs_handler(); + // let (io, mut io2) = MockSubstream::negotiated().await; + // let mut codec = UviBytes::default(); + // codec.set_max_len(usize::MAX); + + // let notif_in = NotificationsInOpen { + // handshake: b"hello, world".to_vec(), + // negotiated_fallback: None, + // substream: NotificationsInSubstream::new( + // Framed::new(io, codec), + // NotificationsInSubstreamHandshake::NotSent, + // ), + // }; + // handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedInbound( + // handler::FullyNegotiatedInbound { protocol: (notif_in, 0), info: () }, + // )); + + // // verify that the substream is in (partly) opened state + // assert!(std::matches!(handler.protocols[0].state, State::OpenDesiredByRemote { .. })); + // futures::future::poll_fn(|cx| { + // let mut buf = Vec::with_capacity(512); + // assert!(std::matches!(Pin::new(&mut io2).poll_read(cx, &mut buf), Poll::Pending)); + // Poll::Ready(()) + // }) + // .await; + + // // first instruct the handler to open a connection and then close it right after + // // so the handler is in state `Closed { pending_opening: true }` + // handler.on_behaviour_event(NotifsHandlerIn::Open { protocol_index: 0 }); + // assert!(std::matches!( + // handler.protocols[0].state, + // State::Opening { in_substream: Some(_) } + // )); + + // handler.on_behaviour_event(NotifsHandlerIn::Close { protocol_index: 0 }); + // assert!(std::matches!(handler.protocols[0].state, State::Closed { pending_opening: true })); + + // // inject dial failure to an already closed substream and verify outbound state is reset + // handler.on_connection_event(handler::ConnectionEvent::DialUpgradeError( + // handler::DialUpgradeError { info: 0, error: StreamUpgradeError::Timeout }, + // )); + // assert!(std::matches!( + // handler.protocols[0].state, + // State::Closed { pending_opening: false } + // )); + // } + + // #[tokio::test] + // async fn dial_upgrade_error_resets_open_desired_state() { + // let mut handler = notifs_handler(); + // let (io, mut io2) = MockSubstream::negotiated().await; + // let mut codec = UviBytes::default(); + // codec.set_max_len(usize::MAX); + + // let notif_in = NotificationsInOpen { + // handshake: b"hello, world".to_vec(), + // negotiated_fallback: None, + // substream: NotificationsInSubstream::new( + // Framed::new(io, codec), + // NotificationsInSubstreamHandshake::NotSent, + // ), + // }; + // handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedInbound( + // handler::FullyNegotiatedInbound { protocol: (notif_in, 0), info: () }, + // )); + + // // verify that the substream is in (partly) opened state + // assert!(std::matches!(handler.protocols[0].state, State::OpenDesiredByRemote { .. })); + // futures::future::poll_fn(|cx| { + // let mut buf = Vec::with_capacity(512); + // assert!(std::matches!(Pin::new(&mut io2).poll_read(cx, &mut buf), Poll::Pending)); + // Poll::Ready(()) + // }) + // .await; + + // // first instruct the handler to open a connection and then close it right after + // // so the handler is in state `Closed { pending_opening: true }` + // handler.on_behaviour_event(NotifsHandlerIn::Open { protocol_index: 0 }); + // assert!(std::matches!( + // handler.protocols[0].state, + // State::Opening { in_substream: Some(_) } + // )); + + // handler.on_behaviour_event(NotifsHandlerIn::Close { protocol_index: 0 }); + // assert!(std::matches!(handler.protocols[0].state, State::Closed { pending_opening: true })); + + // let (io, _io2) = MockSubstream::negotiated().await; + // let mut codec = UviBytes::default(); + // codec.set_max_len(usize::MAX); + + // let notif_in = NotificationsInOpen { + // handshake: b"hello, world".to_vec(), + // negotiated_fallback: None, + // substream: NotificationsInSubstream::new( + // Framed::new(io, codec), + // NotificationsInSubstreamHandshake::NotSent, + // ), + // }; + // handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedInbound( + // handler::FullyNegotiatedInbound { protocol: (notif_in, 0), info: () }, + // )); + + // assert!(std::matches!( + // handler.protocols[0].state, + // State::OpenDesiredByRemote { pending_opening: true, .. } + // )); + + // // inject dial failure to an already closed substream and verify outbound state is reset + // handler.on_connection_event(handler::ConnectionEvent::DialUpgradeError( + // handler::DialUpgradeError { info: 0, error: StreamUpgradeError::Timeout }, + // )); + // assert!(std::matches!( + // handler.protocols[0].state, + // State::OpenDesiredByRemote { pending_opening: false, .. } + // )); + // } + + // #[tokio::test] + // async fn sync_notifications_clogged() { + // let mut handler = notifs_handler(); + // let (io, _) = MockSubstream::negotiated().await; + // let codec = UviBytes::default(); + + // let (async_tx, async_rx) = futures::channel::mpsc::channel(ASYNC_NOTIFICATIONS_BUFFER_SIZE); + // let (sync_tx, sync_rx) = futures::channel::mpsc::channel(1); + // let notifications_sink = NotificationsSink { + // inner: Arc::new(NotificationsSinkInner { + // peer_id: PeerId::random(), + // async_channel: FuturesMutex::new(async_tx), + // sync_channel: Mutex::new(Some(sync_tx)), + // }), + // }; + + // handler.protocols[0].state = State::Open { + // notifications_sink_rx: stream::select(async_rx.fuse(), sync_rx.fuse()).peekable(), + // out_substream: Some(NotificationsOutSubstream::new(Framed::new(io, codec))), + // in_substream: None, + // }; + + // notifications_sink.send_sync_notification(vec![1, 3, 3, 7]); + // notifications_sink.send_sync_notification(vec![1, 3, 3, 8]); + // notifications_sink.send_sync_notification(vec![1, 3, 3, 9]); + // notifications_sink.send_sync_notification(vec![1, 3, 4, 0]); + + // futures::future::poll_fn(|cx| { + // assert!(std::matches!( + // handler.poll(cx), + // Poll::Ready(ConnectionHandlerEvent::Close( + // NotifsHandlerError::SyncNotificationsClogged, + // )) + // )); + // Poll::Ready(()) + // }) + // .await; + // } + + // #[tokio::test] + // async fn close_desired_by_remote() { + // let mut handler = notifs_handler(); + // let (io, io2) = MockSubstream::negotiated().await; + // let mut codec = UviBytes::default(); + // codec.set_max_len(usize::MAX); + + // let notif_in = NotificationsInOpen { + // handshake: b"hello, world".to_vec(), + // negotiated_fallback: None, + // substream: NotificationsInSubstream::new( + // Framed::new(io, codec), + // NotificationsInSubstreamHandshake::PendingSend(vec![1, 2, 3, 4]), + // ), + // }; + + // // add new inbound substream but close it immediately and verify that correct events are + // // emitted + // handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedInbound( + // handler::FullyNegotiatedInbound { protocol: (notif_in, 0), info: () }, + // )); + // drop(io2); + + // futures::future::poll_fn(|cx| { + // assert!(std::matches!( + // handler.poll(cx), + // Poll::Ready(ConnectionHandlerEvent::NotifyBehaviour( + // NotifsHandlerOut::OpenDesiredByRemote { protocol_index: 0 }, + // )) + // )); + // assert!(std::matches!( + // handler.poll(cx), + // Poll::Ready(ConnectionHandlerEvent::NotifyBehaviour( + // NotifsHandlerOut::CloseDesired { protocol_index: 0 }, + // )) + // )); + // Poll::Ready(()) + // }) + // .await; + // } } diff --git a/client/network/src/protocol/notifications/upgrade/notifications.rs b/client/network/src/protocol/notifications/upgrade/notifications.rs index 4e1c033f33b68..d89f8a2b35a1a 100644 --- a/client/network/src/protocol/notifications/upgrade/notifications.rs +++ b/client/network/src/protocol/notifications/upgrade/notifications.rs @@ -114,12 +114,12 @@ pub struct NotificationsOutSubstream { socket: Framed>>>, } -#[cfg(test)] -impl NotificationsOutSubstream { - pub fn new(socket: Framed>>>) -> Self { - Self { socket } - } -} +// #[cfg(test)] +// impl NotificationsOutSubstream { +// pub fn new(socket: Framed>>>) -> Self { +// Self { socket } +// } +// } impl NotificationsIn { /// Builds a new potential upgrade. @@ -203,13 +203,13 @@ impl NotificationsInSubstream where TSubstream: AsyncRead + AsyncWrite + Unpin, { - #[cfg(test)] - pub fn new( - socket: Framed>>>, - handshake: NotificationsInSubstreamHandshake, - ) -> Self { - Self { socket, handshake } - } + // #[cfg(test)] + // pub fn new( + // socket: Framed>>>, + // handshake: NotificationsInSubstreamHandshake, + // ) -> Self { + // Self { socket, handshake } + // } /// Sends the handshake in order to inform the remote that we accept the substream. pub fn send_handshake(&mut self, message: impl Into>) { @@ -496,201 +496,201 @@ pub enum NotificationsOutError { Io(#[from] io::Error), } -#[cfg(test)] -mod tests { - use super::{NotificationsIn, NotificationsInOpen, NotificationsOut, NotificationsOutOpen}; - use futures::{channel::oneshot, prelude::*}; - use libp2p::core::upgrade; - use tokio::net::{TcpListener, TcpStream}; - use tokio_util::compat::TokioAsyncReadCompatExt; - - #[tokio::test] - async fn basic_works() { - const PROTO_NAME: &str = "/test/proto/1"; - let (listener_addr_tx, listener_addr_rx) = oneshot::channel(); - - let client = tokio::spawn(async move { - let socket = TcpStream::connect(listener_addr_rx.await.unwrap()).await.unwrap(); - let NotificationsOutOpen { handshake, mut substream, .. } = upgrade::apply_outbound( - socket.compat(), - NotificationsOut::new(PROTO_NAME, Vec::new(), &b"initial message"[..], 1024 * 1024), - upgrade::Version::V1, - ) - .await - .unwrap(); - - assert_eq!(handshake, b"hello world"); - substream.send(b"test message".to_vec()).await.unwrap(); - }); - - let listener = TcpListener::bind("127.0.0.1:0").await.unwrap(); - listener_addr_tx.send(listener.local_addr().unwrap()).unwrap(); - - let (socket, _) = listener.accept().await.unwrap(); - let NotificationsInOpen { handshake, mut substream, .. } = upgrade::apply_inbound( - socket.compat(), - NotificationsIn::new(PROTO_NAME, Vec::new(), 1024 * 1024), - ) - .await - .unwrap(); - - assert_eq!(handshake, b"initial message"); - substream.send_handshake(&b"hello world"[..]); - - let msg = substream.next().await.unwrap().unwrap(); - assert_eq!(msg.as_ref(), b"test message"); - - client.await.unwrap(); - } - - #[tokio::test] - async fn empty_handshake() { - // Check that everything still works when the handshake messages are empty. - - const PROTO_NAME: &str = "/test/proto/1"; - let (listener_addr_tx, listener_addr_rx) = oneshot::channel(); - - let client = tokio::spawn(async move { - let socket = TcpStream::connect(listener_addr_rx.await.unwrap()).await.unwrap(); - let NotificationsOutOpen { handshake, mut substream, .. } = upgrade::apply_outbound( - socket.compat(), - NotificationsOut::new(PROTO_NAME, Vec::new(), vec![], 1024 * 1024), - upgrade::Version::V1, - ) - .await - .unwrap(); - - assert!(handshake.is_empty()); - substream.send(Default::default()).await.unwrap(); - }); - - let listener = TcpListener::bind("127.0.0.1:0").await.unwrap(); - listener_addr_tx.send(listener.local_addr().unwrap()).unwrap(); - - let (socket, _) = listener.accept().await.unwrap(); - let NotificationsInOpen { handshake, mut substream, .. } = upgrade::apply_inbound( - socket.compat(), - NotificationsIn::new(PROTO_NAME, Vec::new(), 1024 * 1024), - ) - .await - .unwrap(); - - assert!(handshake.is_empty()); - substream.send_handshake(vec![]); - - let msg = substream.next().await.unwrap().unwrap(); - assert!(msg.as_ref().is_empty()); - - client.await.unwrap(); - } - - #[tokio::test] - async fn refused() { - const PROTO_NAME: &str = "/test/proto/1"; - let (listener_addr_tx, listener_addr_rx) = oneshot::channel(); - - let client = tokio::spawn(async move { - let socket = TcpStream::connect(listener_addr_rx.await.unwrap()).await.unwrap(); - let outcome = upgrade::apply_outbound( - socket.compat(), - NotificationsOut::new(PROTO_NAME, Vec::new(), &b"hello"[..], 1024 * 1024), - upgrade::Version::V1, - ) - .await; - - // Despite the protocol negotiation being successfully conducted on the listener - // side, we have to receive an error here because the listener didn't send the - // handshake. - assert!(outcome.is_err()); - }); - - let listener = TcpListener::bind("127.0.0.1:0").await.unwrap(); - listener_addr_tx.send(listener.local_addr().unwrap()).unwrap(); - - let (socket, _) = listener.accept().await.unwrap(); - let NotificationsInOpen { handshake, substream, .. } = upgrade::apply_inbound( - socket.compat(), - NotificationsIn::new(PROTO_NAME, Vec::new(), 1024 * 1024), - ) - .await - .unwrap(); - - assert_eq!(handshake, b"hello"); - - // We successfully upgrade to the protocol, but then close the substream. - drop(substream); - - client.await.unwrap(); - } - - #[tokio::test] - async fn large_initial_message_refused() { - const PROTO_NAME: &str = "/test/proto/1"; - let (listener_addr_tx, listener_addr_rx) = oneshot::channel(); - - let client = tokio::spawn(async move { - let socket = TcpStream::connect(listener_addr_rx.await.unwrap()).await.unwrap(); - let ret = upgrade::apply_outbound( - socket.compat(), - // We check that an initial message that is too large gets refused. - NotificationsOut::new( - PROTO_NAME, - Vec::new(), - (0..32768).map(|_| 0).collect::>(), - 1024 * 1024, - ), - upgrade::Version::V1, - ) - .await; - assert!(ret.is_err()); - }); - - let listener = TcpListener::bind("127.0.0.1:0").await.unwrap(); - listener_addr_tx.send(listener.local_addr().unwrap()).unwrap(); - - let (socket, _) = listener.accept().await.unwrap(); - let ret = upgrade::apply_inbound( - socket.compat(), - NotificationsIn::new(PROTO_NAME, Vec::new(), 1024 * 1024), - ) - .await; - assert!(ret.is_err()); - - client.await.unwrap(); - } - - #[tokio::test] - async fn large_handshake_refused() { - const PROTO_NAME: &str = "/test/proto/1"; - let (listener_addr_tx, listener_addr_rx) = oneshot::channel(); - - let client = tokio::spawn(async move { - let socket = TcpStream::connect(listener_addr_rx.await.unwrap()).await.unwrap(); - let ret = upgrade::apply_outbound( - socket.compat(), - NotificationsOut::new(PROTO_NAME, Vec::new(), &b"initial message"[..], 1024 * 1024), - upgrade::Version::V1, - ) - .await; - assert!(ret.is_err()); - }); - - let listener = TcpListener::bind("127.0.0.1:0").await.unwrap(); - listener_addr_tx.send(listener.local_addr().unwrap()).unwrap(); - - let (socket, _) = listener.accept().await.unwrap(); - let NotificationsInOpen { handshake, mut substream, .. } = upgrade::apply_inbound( - socket.compat(), - NotificationsIn::new(PROTO_NAME, Vec::new(), 1024 * 1024), - ) - .await - .unwrap(); - assert_eq!(handshake, b"initial message"); - - // We check that a handshake that is too large gets refused. - substream.send_handshake((0..32768).map(|_| 0).collect::>()); - let _ = substream.next().await; - - client.await.unwrap(); - } -} +// #[cfg(test)] +// mod tests { +// use super::{NotificationsIn, NotificationsInOpen, NotificationsOut, NotificationsOutOpen}; +// use futures::{channel::oneshot, prelude::*}; +// use libp2p::core::upgrade; +// use tokio::net::{TcpListener, TcpStream}; +// use tokio_util::compat::TokioAsyncReadCompatExt; + +// #[tokio::test] +// async fn basic_works() { +// const PROTO_NAME: &str = "/test/proto/1"; +// let (listener_addr_tx, listener_addr_rx) = oneshot::channel(); + +// let client = tokio::spawn(async move { +// let socket = TcpStream::connect(listener_addr_rx.await.unwrap()).await.unwrap(); +// let NotificationsOutOpen { handshake, mut substream, .. } = upgrade::apply_outbound( +// socket.compat(), +// NotificationsOut::new(PROTO_NAME, Vec::new(), &b"initial message"[..], 1024 * 1024), +// upgrade::Version::V1, +// ) +// .await +// .unwrap(); + +// assert_eq!(handshake, b"hello world"); +// substream.send(b"test message".to_vec()).await.unwrap(); +// }); + +// let listener = TcpListener::bind("127.0.0.1:0").await.unwrap(); +// listener_addr_tx.send(listener.local_addr().unwrap()).unwrap(); + +// let (socket, _) = listener.accept().await.unwrap(); +// let NotificationsInOpen { handshake, mut substream, .. } = upgrade::apply_inbound( +// socket.compat(), +// NotificationsIn::new(PROTO_NAME, Vec::new(), 1024 * 1024), +// ) +// .await +// .unwrap(); + +// assert_eq!(handshake, b"initial message"); +// substream.send_handshake(&b"hello world"[..]); + +// let msg = substream.next().await.unwrap().unwrap(); +// assert_eq!(msg.as_ref(), b"test message"); + +// client.await.unwrap(); +// } + +// #[tokio::test] +// async fn empty_handshake() { +// // Check that everything still works when the handshake messages are empty. + +// const PROTO_NAME: &str = "/test/proto/1"; +// let (listener_addr_tx, listener_addr_rx) = oneshot::channel(); + +// let client = tokio::spawn(async move { +// let socket = TcpStream::connect(listener_addr_rx.await.unwrap()).await.unwrap(); +// let NotificationsOutOpen { handshake, mut substream, .. } = upgrade::apply_outbound( +// socket.compat(), +// NotificationsOut::new(PROTO_NAME, Vec::new(), vec![], 1024 * 1024), +// upgrade::Version::V1, +// ) +// .await +// .unwrap(); + +// assert!(handshake.is_empty()); +// substream.send(Default::default()).await.unwrap(); +// }); + +// let listener = TcpListener::bind("127.0.0.1:0").await.unwrap(); +// listener_addr_tx.send(listener.local_addr().unwrap()).unwrap(); + +// let (socket, _) = listener.accept().await.unwrap(); +// let NotificationsInOpen { handshake, mut substream, .. } = upgrade::apply_inbound( +// socket.compat(), +// NotificationsIn::new(PROTO_NAME, Vec::new(), 1024 * 1024), +// ) +// .await +// .unwrap(); + +// assert!(handshake.is_empty()); +// substream.send_handshake(vec![]); + +// let msg = substream.next().await.unwrap().unwrap(); +// assert!(msg.as_ref().is_empty()); + +// client.await.unwrap(); +// } + +// #[tokio::test] +// async fn refused() { +// const PROTO_NAME: &str = "/test/proto/1"; +// let (listener_addr_tx, listener_addr_rx) = oneshot::channel(); + +// let client = tokio::spawn(async move { +// let socket = TcpStream::connect(listener_addr_rx.await.unwrap()).await.unwrap(); +// let outcome = upgrade::apply_outbound( +// socket.compat(), +// NotificationsOut::new(PROTO_NAME, Vec::new(), &b"hello"[..], 1024 * 1024), +// upgrade::Version::V1, +// ) +// .await; + +// // Despite the protocol negotiation being successfully conducted on the listener +// // side, we have to receive an error here because the listener didn't send the +// // handshake. +// assert!(outcome.is_err()); +// }); + +// let listener = TcpListener::bind("127.0.0.1:0").await.unwrap(); +// listener_addr_tx.send(listener.local_addr().unwrap()).unwrap(); + +// let (socket, _) = listener.accept().await.unwrap(); +// let NotificationsInOpen { handshake, substream, .. } = upgrade::apply_inbound( +// socket.compat(), +// NotificationsIn::new(PROTO_NAME, Vec::new(), 1024 * 1024), +// ) +// .await +// .unwrap(); + +// assert_eq!(handshake, b"hello"); + +// // We successfully upgrade to the protocol, but then close the substream. +// drop(substream); + +// client.await.unwrap(); +// } + +// #[tokio::test] +// async fn large_initial_message_refused() { +// const PROTO_NAME: &str = "/test/proto/1"; +// let (listener_addr_tx, listener_addr_rx) = oneshot::channel(); + +// let client = tokio::spawn(async move { +// let socket = TcpStream::connect(listener_addr_rx.await.unwrap()).await.unwrap(); +// let ret = upgrade::apply_outbound( +// socket.compat(), +// // We check that an initial message that is too large gets refused. +// NotificationsOut::new( +// PROTO_NAME, +// Vec::new(), +// (0..32768).map(|_| 0).collect::>(), +// 1024 * 1024, +// ), +// upgrade::Version::V1, +// ) +// .await; +// assert!(ret.is_err()); +// }); + +// let listener = TcpListener::bind("127.0.0.1:0").await.unwrap(); +// listener_addr_tx.send(listener.local_addr().unwrap()).unwrap(); + +// let (socket, _) = listener.accept().await.unwrap(); +// let ret = upgrade::apply_inbound( +// socket.compat(), +// NotificationsIn::new(PROTO_NAME, Vec::new(), 1024 * 1024), +// ) +// .await; +// assert!(ret.is_err()); + +// client.await.unwrap(); +// } + +// #[tokio::test] +// async fn large_handshake_refused() { +// const PROTO_NAME: &str = "/test/proto/1"; +// let (listener_addr_tx, listener_addr_rx) = oneshot::channel(); + +// let client = tokio::spawn(async move { +// let socket = TcpStream::connect(listener_addr_rx.await.unwrap()).await.unwrap(); +// let ret = upgrade::apply_outbound( +// socket.compat(), +// NotificationsOut::new(PROTO_NAME, Vec::new(), &b"initial message"[..], 1024 * 1024), +// upgrade::Version::V1, +// ) +// .await; +// assert!(ret.is_err()); +// }); + +// let listener = TcpListener::bind("127.0.0.1:0").await.unwrap(); +// listener_addr_tx.send(listener.local_addr().unwrap()).unwrap(); + +// let (socket, _) = listener.accept().await.unwrap(); +// let NotificationsInOpen { handshake, mut substream, .. } = upgrade::apply_inbound( +// socket.compat(), +// NotificationsIn::new(PROTO_NAME, Vec::new(), 1024 * 1024), +// ) +// .await +// .unwrap(); +// assert_eq!(handshake, b"initial message"); + +// // We check that a handshake that is too large gets refused. +// substream.send_handshake((0..32768).map(|_| 0).collect::>()); +// let _ = substream.next().await; + +// client.await.unwrap(); +// } +// } From 6970c11abf5d94e2213c71c35de0b12ff7bbc871 Mon Sep 17 00:00:00 2001 From: Anton Kaliaev Date: Thu, 29 Jun 2023 18:18:23 +0400 Subject: [PATCH 20/42] remove `.into()` from P2p --- client/authority-discovery/Cargo.toml | 2 +- client/authority-discovery/src/tests.rs | 2 +- client/authority-discovery/src/worker/addr_cache.rs | 8 ++++---- client/authority-discovery/src/worker/tests.rs | 6 +++--- client/network-gossip/src/lib.rs | 3 +-- client/network/src/config.rs | 2 +- client/network/src/discovery.rs | 2 +- client/network/src/service.rs | 2 +- 8 files changed, 13 insertions(+), 14 deletions(-) diff --git a/client/authority-discovery/Cargo.toml b/client/authority-discovery/Cargo.toml index 4d5493feaaa50..b6382b15574ba 100644 --- a/client/authority-discovery/Cargo.toml +++ b/client/authority-discovery/Cargo.toml @@ -22,7 +22,7 @@ futures = "0.3.21" futures-timer = "3.0.1" ip_network = "0.4.1" libp2p = { version = "0.52.0", features = ["kad", "ed25519"] } -multihash-codetable = { version = "0.1.0", features = ["std", "sha2", "digest"] } +multihash-codetable = { version = "0.1.0", features = ["sha2", "digest"] } log = "0.4.17" prost = "0.11" rand = "0.8.5" diff --git a/client/authority-discovery/src/tests.rs b/client/authority-discovery/src/tests.rs index 4fbc196c5ecd1..16700e35ca517 100644 --- a/client/authority-discovery/src/tests.rs +++ b/client/authority-discovery/src/tests.rs @@ -56,7 +56,7 @@ fn get_addresses_and_authority_id() { let remote_addr = "/ip6/2001:db8:0:0:0:0:0:2/tcp/30333" .parse::() .unwrap() - .with(Protocol::P2p(remote_peer_id.into())); + .with(Protocol::P2p(remote_peer_id)); let test_api = Arc::new(TestApi { authorities: vec![] }); diff --git a/client/authority-discovery/src/worker/addr_cache.rs b/client/authority-discovery/src/worker/addr_cache.rs index 647b85aec0a4c..ad7bf61d650f0 100644 --- a/client/authority-discovery/src/worker/addr_cache.rs +++ b/client/authority-discovery/src/worker/addr_cache.rs @@ -207,7 +207,7 @@ mod tests { let multiaddr = "/ip6/2001:db8:0:0:0:0:0:2/tcp/30333" .parse::() .unwrap() - .with(Protocol::P2p(peer_id.into())); + .with(Protocol::P2p(peer_id)); TestMultiaddr(multiaddr) } @@ -225,11 +225,11 @@ mod tests { let multiaddr1 = "/ip6/2001:db8:0:0:0:0:0:2/tcp/30333" .parse::() .unwrap() - .with(Protocol::P2p(peer_id.into())); + .with(Protocol::P2p(peer_id)); let multiaddr2 = "/ip6/2002:db8:0:0:0:0:0:2/tcp/30133" .parse::() .unwrap() - .with(Protocol::P2p(peer_id.into())); + .with(Protocol::P2p(peer_id)); TestMultiaddrsSamePeerCombo(multiaddr1, multiaddr2) } } @@ -366,7 +366,7 @@ mod tests { let mut addr_cache = AddrCache::new(); let peer_id = PeerId::random(); - let addr = Multiaddr::empty().with(Protocol::P2p(peer_id.into())); + let addr = Multiaddr::empty().with(Protocol::P2p(peer_id)); let authority_id0 = AuthorityPair::generate().0.public(); let authority_id1 = AuthorityPair::generate().0.public(); diff --git a/client/authority-discovery/src/worker/tests.rs b/client/authority-discovery/src/worker/tests.rs index c29120881940c..791f013cfedb7 100644 --- a/client/authority-discovery/src/worker/tests.rs +++ b/client/authority-discovery/src/worker/tests.rs @@ -415,7 +415,7 @@ fn dont_stop_polling_dht_event_stream_after_bogus_event() { let peer_id = PeerId::random(); let address: Multiaddr = "/ip6/2001:db8:0:0:0:0:0:1/tcp/30333".parse().unwrap(); - address.with(multiaddr::Protocol::P2p(peer_id.into())) + address.with(multiaddr::Protocol::P2p(peer_id)) }; let remote_key_store = MemoryKeystore::new(); let remote_public_key: AuthorityId = remote_key_store @@ -526,7 +526,7 @@ impl DhtValueFoundTester { let address: Multiaddr = format!("/ip6/2001:db8:0:0:0:0:0:{:x}/tcp/30333", idx).parse().unwrap(); - address.with(multiaddr::Protocol::P2p(peer_id.into())) + address.with(multiaddr::Protocol::P2p(peer_id)) } fn process_value_found( @@ -749,7 +749,7 @@ fn lookup_throttling() { let peer_id = PeerId::random(); let address: Multiaddr = "/ip6/2001:db8:0:0:0:0:0:1/tcp/30333".parse().unwrap(); - address.with(multiaddr::Protocol::P2p(peer_id.into())) + address.with(multiaddr::Protocol::P2p(peer_id)) }; let remote_key_store = MemoryKeystore::new(); let remote_public_keys: Vec = (0..20) diff --git a/client/network-gossip/src/lib.rs b/client/network-gossip/src/lib.rs index ef87dd599e010..49d2003f8c8e2 100644 --- a/client/network-gossip/src/lib.rs +++ b/client/network-gossip/src/lib.rs @@ -82,8 +82,7 @@ mod validator; /// Abstraction over a network. pub trait Network: NetworkPeers + NetworkEventStream + NetworkNotification { fn add_set_reserved(&self, who: PeerId, protocol: ProtocolName) { - let addr = - iter::once(multiaddr::Protocol::P2p(who.into())).collect::(); + let addr = iter::once(multiaddr::Protocol::P2p(who)).collect::(); let result = self.add_peers_to_reserved_set(protocol, iter::once(addr).collect()); if let Err(err) = result { log::error!(target: "gossip", "add_set_reserved failed: {}", err); diff --git a/client/network/src/config.rs b/client/network/src/config.rs index 1c881f9286eec..0da2e0410e52e 100644 --- a/client/network/src/config.rs +++ b/client/network/src/config.rs @@ -109,7 +109,7 @@ pub fn parse_str_addr(addr_str: &str) -> Result<(PeerId, Multiaddr), ParseErr> { /// Splits a Multiaddress into a Multiaddress and PeerId. pub fn parse_addr(mut addr: Multiaddr) -> Result<(PeerId, Multiaddr), ParseErr> { let who = match addr.pop() { - Some(multiaddr::Protocol::P2p(key)) => key, + Some(multiaddr::Protocol::P2p(peer_id)) => peer_id, _ => return Err(ParseErr::PeerIdMissing), }; diff --git a/client/network/src/discovery.rs b/client/network/src/discovery.rs index 561d6a35ba4d6..d05b961550da6 100644 --- a/client/network/src/discovery.rs +++ b/client/network/src/discovery.rs @@ -642,7 +642,7 @@ impl NetworkBehaviour for DiscoveryBehaviour { self.kademlia.on_swarm_event(FromSwarm::ExpiredListenAddr(e)); }, FromSwarm::NewExternalAddrCandidate(e @ NewExternalAddrCandidate { addr }) => { - let new_addr = addr.clone().with(Protocol::P2p(self.local_peer_id.into())); + let new_addr = addr.clone().with(Protocol::P2p(self.local_peer_id)); if Self::can_add_to_dht(addr) { // NOTE: we might re-discover the same address multiple times diff --git a/client/network/src/service.rs b/client/network/src/service.rs index 66b8000aca15e..7caa009d2d4b2 100644 --- a/client/network/src/service.rs +++ b/client/network/src/service.rs @@ -673,7 +673,7 @@ impl NetworkService { .into_iter() .map(|mut addr| { let peer = match addr.pop() { - Some(multiaddr::Protocol::P2p(key)) => key, + Some(multiaddr::Protocol::P2p(peer_id)) => peer_id, _ => return Err("Missing PeerId from address".to_string()), }; From 49e0ba7f8b22cd8983efaec0c4b7d59bc9df0b37 Mon Sep 17 00:00:00 2001 From: Anton Kaliaev Date: Tue, 4 Jul 2023 12:29:01 +0400 Subject: [PATCH 21/42] confirm observed addr manually See https://github.com/libp2p/rust-libp2p/blob/master/protocols/identify/CHANGELOG.md#0430 --- client/network-gossip/src/lib.rs | 7 +++++-- client/network/src/discovery.rs | 24 ++++++++++++------------ client/network/src/service.rs | 10 +++++++++- client/network/statement/src/lib.rs | 4 ++-- client/network/transactions/src/lib.rs | 4 ++-- client/service/src/lib.rs | 2 +- 6 files changed, 31 insertions(+), 20 deletions(-) diff --git a/client/network-gossip/src/lib.rs b/client/network-gossip/src/lib.rs index 49d2003f8c8e2..e1798a622e6de 100644 --- a/client/network-gossip/src/lib.rs +++ b/client/network-gossip/src/lib.rs @@ -67,7 +67,10 @@ pub use self::{ validator::{DiscardAll, MessageIntent, ValidationResult, Validator, ValidatorContext}, }; -use libp2p::{multiaddr, PeerId}; +use libp2p::{ + multiaddr::{Multiaddr, Protocol}, + PeerId, +}; use sc_network::{ types::ProtocolName, NetworkBlock, NetworkEventStream, NetworkNotification, NetworkPeers, }; @@ -82,7 +85,7 @@ mod validator; /// Abstraction over a network. pub trait Network: NetworkPeers + NetworkEventStream + NetworkNotification { fn add_set_reserved(&self, who: PeerId, protocol: ProtocolName) { - let addr = iter::once(multiaddr::Protocol::P2p(who)).collect::(); + let addr = Multiaddr::empty().with(Protocol::P2p(who)); let result = self.add_peers_to_reserved_set(protocol, iter::once(addr).collect()); if let Err(err) = result { log::error!(target: "gossip", "add_set_reserved failed: {}", err); diff --git a/client/network/src/discovery.rs b/client/network/src/discovery.rs index d05b961550da6..f5ae7cb726d76 100644 --- a/client/network/src/discovery.rs +++ b/client/network/src/discovery.rs @@ -64,7 +64,7 @@ use libp2p::{ swarm::{ behaviour::{ toggle::{Toggle, ToggleConnectionHandler}, - DialFailure, FromSwarm, NewExternalAddrCandidate, + DialFailure, ExternalAddrConfirmed, FromSwarm, }, ConnectionDenied, ConnectionId, DialError, NetworkBehaviour, PollParameters, StreamProtocol, THandler, THandlerInEvent, THandlerOutEvent, ToSwarm, @@ -641,7 +641,16 @@ impl NetworkBehaviour for DiscoveryBehaviour { FromSwarm::ExpiredListenAddr(e) => { self.kademlia.on_swarm_event(FromSwarm::ExpiredListenAddr(e)); }, - FromSwarm::NewExternalAddrCandidate(e @ NewExternalAddrCandidate { addr }) => { + FromSwarm::NewExternalAddrCandidate(e) => { + self.kademlia.on_swarm_event(FromSwarm::NewExternalAddrCandidate(e)); + }, + FromSwarm::AddressChange(e) => { + self.kademlia.on_swarm_event(FromSwarm::AddressChange(e)); + }, + FromSwarm::NewListenAddr(e) => { + self.kademlia.on_swarm_event(FromSwarm::NewListenAddr(e)); + }, + FromSwarm::ExternalAddrConfirmed(e @ ExternalAddrConfirmed { addr }) => { let new_addr = addr.clone().with(Protocol::P2p(self.local_peer_id)); if Self::can_add_to_dht(addr) { @@ -656,16 +665,7 @@ impl NetworkBehaviour for DiscoveryBehaviour { } } - self.kademlia.on_swarm_event(FromSwarm::NewExternalAddrCandidate(e)); - }, - FromSwarm::AddressChange(e) => { - self.kademlia.on_swarm_event(FromSwarm::AddressChange(e)); - }, - FromSwarm::NewListenAddr(e) => { - self.kademlia.on_swarm_event(FromSwarm::NewListenAddr(e)); - }, - FromSwarm::ExternalAddrConfirmed(addr) => { - self.kademlia.on_swarm_event(FromSwarm::ExternalAddrConfirmed(addr)); + self.kademlia.on_swarm_event(FromSwarm::ExternalAddrConfirmed(e)); }, } } diff --git a/client/network/src/service.rs b/client/network/src/service.rs index 7caa009d2d4b2..94871ccf5f6b8 100644 --- a/client/network/src/service.rs +++ b/client/network/src/service.rs @@ -1392,7 +1392,12 @@ where peer_id, info: IdentifyInfo { - protocol_version, agent_version, mut listen_addrs, protocols, .. + protocol_version, + agent_version, + mut listen_addrs, + protocols, + observed_addr, + .. }, }) => { if listen_addrs.len() > 30 { @@ -1409,6 +1414,9 @@ where .add_self_reported_address_to_dht(&peer_id, &protocols, addr); } self.network_service.behaviour_mut().user_protocol_mut().add_known_peer(peer_id); + // Confirm the reported address manually since they are no longer trusted by default + // (libp2p >= 0.52) + self.network_service.add_external_address(observed_addr); }, SwarmEvent::Behaviour(BehaviourOut::Discovered(peer_id)) => { self.network_service.behaviour_mut().user_protocol_mut().add_known_peer(peer_id); diff --git a/client/network/statement/src/lib.rs b/client/network/statement/src/lib.rs index 2c966a346ad87..a055cd07a0740 100644 --- a/client/network/statement/src/lib.rs +++ b/client/network/statement/src/lib.rs @@ -286,8 +286,8 @@ where fn handle_sync_event(&mut self, event: SyncEvent) { match event { SyncEvent::PeerConnected(remote) => { - let addr = iter::once(multiaddr::Protocol::P2p(remote.into())) - .collect::(); + let addr = + iter::once(multiaddr::Protocol::P2p(remote)).collect::(); let result = self.network.add_peers_to_reserved_set( self.protocol_name.clone(), iter::once(addr).collect(), diff --git a/client/network/transactions/src/lib.rs b/client/network/transactions/src/lib.rs index 78fd432ab0c4e..5d86e3c35d8ab 100644 --- a/client/network/transactions/src/lib.rs +++ b/client/network/transactions/src/lib.rs @@ -327,8 +327,8 @@ where fn handle_sync_event(&mut self, event: SyncEvent) { match event { SyncEvent::PeerConnected(remote) => { - let addr = iter::once(multiaddr::Protocol::P2p(remote.into())) - .collect::(); + let addr = + iter::once(multiaddr::Protocol::P2p(remote)).collect::(); let result = self.network.add_peers_to_reserved_set( self.protocol_name.clone(), iter::once(addr).collect(), diff --git a/client/service/src/lib.rs b/client/service/src/lib.rs index 4a896ecc87263..fe6193a9e3473 100644 --- a/client/service/src/lib.rs +++ b/client/service/src/lib.rs @@ -255,7 +255,7 @@ pub async fn build_system_rpc_future< let _ = sender.send(network_service.local_peer_id().to_base58()); }, sc_rpc::system::Request::LocalListenAddresses(sender) => { - let peer_id = (network_service.local_peer_id()).into(); + let peer_id = network_service.local_peer_id(); let p2p_proto_suffix = sc_network::multiaddr::Protocol::P2p(peer_id); let addresses = network_service .listen_addresses() From dd4a718419cfacc9f2429d8ca3f8a0676e7b1c82 Mon Sep 17 00:00:00 2001 From: Anton Kaliaev Date: Tue, 4 Jul 2023 12:54:11 +0400 Subject: [PATCH 22/42] remove SwarmEvent::Banned since we're not using `ban_peer_id`, this can be safely removed. we may want to introduce `libp2p::allow_block_list` module in the future. --- client/network/src/service.rs | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/client/network/src/service.rs b/client/network/src/service.rs index 94871ccf5f6b8..8aeb9962949ff 100644 --- a/client/network/src/service.rs +++ b/client/network/src/service.rs @@ -1707,17 +1707,6 @@ where } } }, - // #[allow(deprecated)] - // SwarmEvent::BannedPeer { peer_id, endpoint } => { - // debug!( - // target: "sub-libp2p", - // "Libp2p => BannedPeer({}). Connected via {:?}.", - // peer_id, endpoint, - // ); - // if let Some(metrics) = self.metrics.as_ref() { - // metrics.incoming_connections_errors_total.with_label_values(&["banned"]).inc(); - // } - // }, SwarmEvent::ListenerClosed { reason, addresses, .. } => { if let Some(metrics) = self.metrics.as_ref() { metrics.listeners_local_addresses.sub(addresses.len() as u64); From c4f0a9c54541252d0bb92a5a941a3802d72723af Mon Sep 17 00:00:00 2001 From: Anton Kaliaev Date: Tue, 4 Jul 2023 13:04:21 +0400 Subject: [PATCH 23/42] fix imports --- client/network-gossip/src/bridge.rs | 3 ++- client/network-gossip/src/state_machine.rs | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/client/network-gossip/src/bridge.rs b/client/network-gossip/src/bridge.rs index 2cd4e18171568..5f261d045901c 100644 --- a/client/network-gossip/src/bridge.rs +++ b/client/network-gossip/src/bridge.rs @@ -330,12 +330,13 @@ impl futures::future::FusedFuture for GossipEngine { #[cfg(test)] mod tests { use super::*; - use crate::{multiaddr::Multiaddr, ValidationResult, ValidatorContext}; + use crate::{ValidationResult, ValidatorContext}; use futures::{ channel::mpsc::{unbounded, UnboundedSender}, executor::{block_on, block_on_stream}, future::poll_fn, }; + use libp2p::multiaddr::Multiaddr; use quickcheck::{Arbitrary, Gen, QuickCheck}; use sc_network::{ config::MultiaddrWithPeerId, NetworkBlock, NetworkEventStream, NetworkNotification, diff --git a/client/network-gossip/src/state_machine.rs b/client/network-gossip/src/state_machine.rs index 24373cd402513..ff3e01a8d15ce 100644 --- a/client/network-gossip/src/state_machine.rs +++ b/client/network-gossip/src/state_machine.rs @@ -524,8 +524,8 @@ impl Metrics { #[cfg(test)] mod tests { use super::*; - use crate::multiaddr::Multiaddr; use futures::prelude::*; + use libp2p::multiaddr::Multiaddr; use sc_network::{ config::MultiaddrWithPeerId, event::Event, NetworkBlock, NetworkEventStream, NetworkNotification, NetworkPeers, NotificationSenderError, From 350902c0e17bd4ff6fca92085526eacb7030acab Mon Sep 17 00:00:00 2001 From: Anton Kaliaev Date: Tue, 4 Jul 2023 13:14:35 +0400 Subject: [PATCH 24/42] replace `libp2p` with smaller deps in network-gossip --- Cargo.lock | 3 ++- client/network-gossip/Cargo.toml | 3 ++- client/network-gossip/src/bridge.rs | 4 ++-- client/network-gossip/src/lib.rs | 6 ++---- client/network-gossip/src/state_machine.rs | 4 ++-- client/network-gossip/src/validator.rs | 2 +- client/network/src/discovery.rs | 1 - 7 files changed, 11 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3ed7cc2777b92..d5d0e93257da2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -9055,9 +9055,10 @@ dependencies = [ "ahash 0.8.3", "futures", "futures-timer", - "libp2p", + "libp2p-identity", "log", "lru", + "multiaddr", "quickcheck", "sc-network", "sc-network-common", diff --git a/client/network-gossip/Cargo.toml b/client/network-gossip/Cargo.toml index 0e7dc6099d271..cb5f94e0497ca 100644 --- a/client/network-gossip/Cargo.toml +++ b/client/network-gossip/Cargo.toml @@ -17,7 +17,8 @@ targets = ["x86_64-unknown-linux-gnu"] ahash = "0.8.2" futures = "0.3.21" futures-timer = "3.0.1" -libp2p = "0.52.0" +libp2p-identity = { version = "0.2.0", features = ["peerid", "ed25519"]} +multiaddr = "0.18.0" log = "0.4.17" lru = "0.10.0" tracing = "0.1.29" diff --git a/client/network-gossip/src/bridge.rs b/client/network-gossip/src/bridge.rs index 5f261d045901c..f3ad7983482b2 100644 --- a/client/network-gossip/src/bridge.rs +++ b/client/network-gossip/src/bridge.rs @@ -28,7 +28,7 @@ use futures::{ channel::mpsc::{channel, Receiver, Sender}, prelude::*, }; -use libp2p::PeerId; +use libp2p_identity::PeerId; use log::trace; use prometheus_endpoint::Registry; use sp_runtime::traits::Block as BlockT; @@ -336,7 +336,7 @@ mod tests { executor::{block_on, block_on_stream}, future::poll_fn, }; - use libp2p::multiaddr::Multiaddr; + use multiaddr::Multiaddr; use quickcheck::{Arbitrary, Gen, QuickCheck}; use sc_network::{ config::MultiaddrWithPeerId, NetworkBlock, NetworkEventStream, NetworkNotification, diff --git a/client/network-gossip/src/lib.rs b/client/network-gossip/src/lib.rs index e1798a622e6de..d126f85646e6c 100644 --- a/client/network-gossip/src/lib.rs +++ b/client/network-gossip/src/lib.rs @@ -67,10 +67,8 @@ pub use self::{ validator::{DiscardAll, MessageIntent, ValidationResult, Validator, ValidatorContext}, }; -use libp2p::{ - multiaddr::{Multiaddr, Protocol}, - PeerId, -}; +use libp2p_identity::PeerId; +use multiaddr::{Multiaddr, Protocol}; use sc_network::{ types::ProtocolName, NetworkBlock, NetworkEventStream, NetworkNotification, NetworkPeers, }; diff --git a/client/network-gossip/src/state_machine.rs b/client/network-gossip/src/state_machine.rs index ff3e01a8d15ce..c5c0eb5fe3320 100644 --- a/client/network-gossip/src/state_machine.rs +++ b/client/network-gossip/src/state_machine.rs @@ -19,7 +19,7 @@ use crate::{MessageIntent, Network, ValidationResult, Validator, ValidatorContext}; use ahash::AHashSet; -use libp2p::PeerId; +use libp2p_identity::PeerId; use lru::LruCache; use prometheus_endpoint::{register, Counter, PrometheusError, Registry, U64}; use sc_network::types::ProtocolName; @@ -525,7 +525,7 @@ impl Metrics { mod tests { use super::*; use futures::prelude::*; - use libp2p::multiaddr::Multiaddr; + use multiaddr::Multiaddr; use sc_network::{ config::MultiaddrWithPeerId, event::Event, NetworkBlock, NetworkEventStream, NetworkNotification, NetworkPeers, NotificationSenderError, diff --git a/client/network-gossip/src/validator.rs b/client/network-gossip/src/validator.rs index 2272efba50652..04585bb721849 100644 --- a/client/network-gossip/src/validator.rs +++ b/client/network-gossip/src/validator.rs @@ -16,7 +16,7 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -use libp2p::PeerId; +use libp2p_identity::PeerId; use sc_network_common::role::ObservedRole; use sp_runtime::traits::Block as BlockT; diff --git a/client/network/src/discovery.rs b/client/network/src/discovery.rs index 02dbe02de45eb..4b170ad90c086 100644 --- a/client/network/src/discovery.rs +++ b/client/network/src/discovery.rs @@ -653,7 +653,6 @@ impl NetworkBehaviour for DiscoveryBehaviour { if let Some(ref mut mdns) = self.mdns { mdns.on_swarm_event(FromSwarm::NewListenAddr(e)); } - }, FromSwarm::ExternalAddrConfirmed(e @ ExternalAddrConfirmed { addr }) => { let new_addr = addr.clone().with(Protocol::P2p(self.local_peer_id)); From b67be4609e481b9658b6a8fec479bcb733f596aa Mon Sep 17 00:00:00 2001 From: Anton Kaliaev Date: Tue, 4 Jul 2023 14:07:05 +0400 Subject: [PATCH 25/42] bring back tests --- Cargo.lock | 20 +- client/network/Cargo.toml | 2 +- .../notifications/upgrade/notifications.rs | 449 ++++++++++-------- 3 files changed, 249 insertions(+), 222 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d5d0e93257da2..64b84fa48b12d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3838,7 +3838,7 @@ dependencies = [ "log", "multiaddr", "multihash 0.19.0", - "multistream-select 0.13.0", + "multistream-select", "once_cell", "parking_lot 0.12.1", "pin-project", @@ -4047,7 +4047,7 @@ dependencies = [ "libp2p-identity", "libp2p-swarm-derive", "log", - "multistream-select 0.13.0", + "multistream-select", "once_cell", "rand 0.8.5", "smallvec", @@ -4710,20 +4710,6 @@ version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5ce46fe64a9d73be07dcbe690a38ce1b293be448fd8ce1e6c1b8062c9f72c6a" -[[package]] -name = "multistream-select" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8552ab875c1313b97b8d20cb857b9fd63e2d1d6a0a1b53ce9821e575405f27a" -dependencies = [ - "bytes", - "futures", - "log", - "pin-project", - "smallvec", - "unsigned-varint", -] - [[package]] name = "multistream-select" version = "0.13.0" @@ -8971,7 +8957,7 @@ dependencies = [ "linked_hash_set", "log", "mockall", - "multistream-select 0.12.1", + "multistream-select", "parity-scale-codec", "parking_lot 0.12.1", "partial_sort", diff --git a/client/network/Cargo.toml b/client/network/Cargo.toml index 3e12b646462ee..2e0da55f11155 100644 --- a/client/network/Cargo.toml +++ b/client/network/Cargo.toml @@ -53,7 +53,7 @@ wasm-timer = "0.2" [dev-dependencies] assert_matches = "1.3" mockall = "0.11.3" -multistream-select = "0.12.1" +multistream-select = "0.13.0" rand = "0.8.5" tempfile = "3.1.0" tokio = { version = "1.22.0", features = ["macros"] } diff --git a/client/network/src/protocol/notifications/upgrade/notifications.rs b/client/network/src/protocol/notifications/upgrade/notifications.rs index d89f8a2b35a1a..3bd59f0ac28ae 100644 --- a/client/network/src/protocol/notifications/upgrade/notifications.rs +++ b/client/network/src/protocol/notifications/upgrade/notifications.rs @@ -114,12 +114,12 @@ pub struct NotificationsOutSubstream { socket: Framed>>>, } -// #[cfg(test)] -// impl NotificationsOutSubstream { -// pub fn new(socket: Framed>>>) -> Self { -// Self { socket } -// } -// } +#[cfg(test)] +impl NotificationsOutSubstream { + pub fn new(socket: Framed>>>) -> Self { + Self { socket } + } +} impl NotificationsIn { /// Builds a new potential upgrade. @@ -496,201 +496,242 @@ pub enum NotificationsOutError { Io(#[from] io::Error), } -// #[cfg(test)] -// mod tests { -// use super::{NotificationsIn, NotificationsInOpen, NotificationsOut, NotificationsOutOpen}; -// use futures::{channel::oneshot, prelude::*}; -// use libp2p::core::upgrade; -// use tokio::net::{TcpListener, TcpStream}; -// use tokio_util::compat::TokioAsyncReadCompatExt; - -// #[tokio::test] -// async fn basic_works() { -// const PROTO_NAME: &str = "/test/proto/1"; -// let (listener_addr_tx, listener_addr_rx) = oneshot::channel(); - -// let client = tokio::spawn(async move { -// let socket = TcpStream::connect(listener_addr_rx.await.unwrap()).await.unwrap(); -// let NotificationsOutOpen { handshake, mut substream, .. } = upgrade::apply_outbound( -// socket.compat(), -// NotificationsOut::new(PROTO_NAME, Vec::new(), &b"initial message"[..], 1024 * 1024), -// upgrade::Version::V1, -// ) -// .await -// .unwrap(); - -// assert_eq!(handshake, b"hello world"); -// substream.send(b"test message".to_vec()).await.unwrap(); -// }); - -// let listener = TcpListener::bind("127.0.0.1:0").await.unwrap(); -// listener_addr_tx.send(listener.local_addr().unwrap()).unwrap(); - -// let (socket, _) = listener.accept().await.unwrap(); -// let NotificationsInOpen { handshake, mut substream, .. } = upgrade::apply_inbound( -// socket.compat(), -// NotificationsIn::new(PROTO_NAME, Vec::new(), 1024 * 1024), -// ) -// .await -// .unwrap(); - -// assert_eq!(handshake, b"initial message"); -// substream.send_handshake(&b"hello world"[..]); - -// let msg = substream.next().await.unwrap().unwrap(); -// assert_eq!(msg.as_ref(), b"test message"); - -// client.await.unwrap(); -// } - -// #[tokio::test] -// async fn empty_handshake() { -// // Check that everything still works when the handshake messages are empty. - -// const PROTO_NAME: &str = "/test/proto/1"; -// let (listener_addr_tx, listener_addr_rx) = oneshot::channel(); - -// let client = tokio::spawn(async move { -// let socket = TcpStream::connect(listener_addr_rx.await.unwrap()).await.unwrap(); -// let NotificationsOutOpen { handshake, mut substream, .. } = upgrade::apply_outbound( -// socket.compat(), -// NotificationsOut::new(PROTO_NAME, Vec::new(), vec![], 1024 * 1024), -// upgrade::Version::V1, -// ) -// .await -// .unwrap(); - -// assert!(handshake.is_empty()); -// substream.send(Default::default()).await.unwrap(); -// }); - -// let listener = TcpListener::bind("127.0.0.1:0").await.unwrap(); -// listener_addr_tx.send(listener.local_addr().unwrap()).unwrap(); - -// let (socket, _) = listener.accept().await.unwrap(); -// let NotificationsInOpen { handshake, mut substream, .. } = upgrade::apply_inbound( -// socket.compat(), -// NotificationsIn::new(PROTO_NAME, Vec::new(), 1024 * 1024), -// ) -// .await -// .unwrap(); - -// assert!(handshake.is_empty()); -// substream.send_handshake(vec![]); - -// let msg = substream.next().await.unwrap().unwrap(); -// assert!(msg.as_ref().is_empty()); - -// client.await.unwrap(); -// } - -// #[tokio::test] -// async fn refused() { -// const PROTO_NAME: &str = "/test/proto/1"; -// let (listener_addr_tx, listener_addr_rx) = oneshot::channel(); - -// let client = tokio::spawn(async move { -// let socket = TcpStream::connect(listener_addr_rx.await.unwrap()).await.unwrap(); -// let outcome = upgrade::apply_outbound( -// socket.compat(), -// NotificationsOut::new(PROTO_NAME, Vec::new(), &b"hello"[..], 1024 * 1024), -// upgrade::Version::V1, -// ) -// .await; - -// // Despite the protocol negotiation being successfully conducted on the listener -// // side, we have to receive an error here because the listener didn't send the -// // handshake. -// assert!(outcome.is_err()); -// }); - -// let listener = TcpListener::bind("127.0.0.1:0").await.unwrap(); -// listener_addr_tx.send(listener.local_addr().unwrap()).unwrap(); - -// let (socket, _) = listener.accept().await.unwrap(); -// let NotificationsInOpen { handshake, substream, .. } = upgrade::apply_inbound( -// socket.compat(), -// NotificationsIn::new(PROTO_NAME, Vec::new(), 1024 * 1024), -// ) -// .await -// .unwrap(); - -// assert_eq!(handshake, b"hello"); - -// // We successfully upgrade to the protocol, but then close the substream. -// drop(substream); - -// client.await.unwrap(); -// } - -// #[tokio::test] -// async fn large_initial_message_refused() { -// const PROTO_NAME: &str = "/test/proto/1"; -// let (listener_addr_tx, listener_addr_rx) = oneshot::channel(); - -// let client = tokio::spawn(async move { -// let socket = TcpStream::connect(listener_addr_rx.await.unwrap()).await.unwrap(); -// let ret = upgrade::apply_outbound( -// socket.compat(), -// // We check that an initial message that is too large gets refused. -// NotificationsOut::new( -// PROTO_NAME, -// Vec::new(), -// (0..32768).map(|_| 0).collect::>(), -// 1024 * 1024, -// ), -// upgrade::Version::V1, -// ) -// .await; -// assert!(ret.is_err()); -// }); - -// let listener = TcpListener::bind("127.0.0.1:0").await.unwrap(); -// listener_addr_tx.send(listener.local_addr().unwrap()).unwrap(); - -// let (socket, _) = listener.accept().await.unwrap(); -// let ret = upgrade::apply_inbound( -// socket.compat(), -// NotificationsIn::new(PROTO_NAME, Vec::new(), 1024 * 1024), -// ) -// .await; -// assert!(ret.is_err()); - -// client.await.unwrap(); -// } - -// #[tokio::test] -// async fn large_handshake_refused() { -// const PROTO_NAME: &str = "/test/proto/1"; -// let (listener_addr_tx, listener_addr_rx) = oneshot::channel(); - -// let client = tokio::spawn(async move { -// let socket = TcpStream::connect(listener_addr_rx.await.unwrap()).await.unwrap(); -// let ret = upgrade::apply_outbound( -// socket.compat(), -// NotificationsOut::new(PROTO_NAME, Vec::new(), &b"initial message"[..], 1024 * 1024), -// upgrade::Version::V1, -// ) -// .await; -// assert!(ret.is_err()); -// }); - -// let listener = TcpListener::bind("127.0.0.1:0").await.unwrap(); -// listener_addr_tx.send(listener.local_addr().unwrap()).unwrap(); - -// let (socket, _) = listener.accept().await.unwrap(); -// let NotificationsInOpen { handshake, mut substream, .. } = upgrade::apply_inbound( -// socket.compat(), -// NotificationsIn::new(PROTO_NAME, Vec::new(), 1024 * 1024), -// ) -// .await -// .unwrap(); -// assert_eq!(handshake, b"initial message"); - -// // We check that a handshake that is too large gets refused. -// substream.send_handshake((0..32768).map(|_| 0).collect::>()); -// let _ = substream.next().await; - -// client.await.unwrap(); -// } -// } +#[cfg(test)] +mod tests { + use super::{NotificationsIn, NotificationsInOpen, NotificationsOut, NotificationsOutOpen}; + use futures::{channel::oneshot, prelude::*}; + use libp2p::core::{upgrade, InboundUpgrade, OutboundUpgrade, UpgradeInfo}; + use tokio::net::{TcpListener, TcpStream}; + use tokio_util::compat::TokioAsyncReadCompatExt; + + #[tokio::test] + async fn basic_works() { + const PROTO_NAME: &str = "/test/proto/1"; + let (listener_addr_tx, listener_addr_rx) = oneshot::channel(); + + let client = tokio::spawn(async move { + let socket = TcpStream::connect(listener_addr_rx.await.unwrap()).await.unwrap(); + let notifs_out = + NotificationsOut::new(PROTO_NAME, Vec::new(), &b"initial message"[..], 1024 * 1024); + let (_, substream) = multistream_select::dialer_select_proto( + socket.compat(), + notifs_out.protocol_info().into_iter(), + upgrade::Version::V1, + ) + .await + .unwrap(); + let NotificationsOutOpen { handshake, mut substream, .. } = + ::upgrade_outbound( + notifs_out, + substream, + PROTO_NAME.into(), + ) + .await + .unwrap(); + + assert_eq!(handshake, b"hello world"); + substream.send(b"test message".to_vec()).await.unwrap(); + }); + + let listener = TcpListener::bind("127.0.0.1:0").await.unwrap(); + listener_addr_tx.send(listener.local_addr().unwrap()).unwrap(); + + let (socket, _) = listener.accept().await.unwrap(); + let notifs_in = NotificationsIn::new(PROTO_NAME, Vec::new(), 1024 * 1024); + let (_, substream) = + multistream_select::listener_select_proto(socket.compat(), notifs_in.protocol_info()) + .await + .unwrap(); + let NotificationsInOpen { handshake, mut substream, .. } = + ::upgrade_inbound( + notifs_in, + substream, + PROTO_NAME.into(), + ) + .await + .unwrap(); + + assert_eq!(handshake, b"initial message"); + substream.send_handshake(&b"hello world"[..]); + + let msg = substream.next().await.unwrap().unwrap(); + assert_eq!(msg.as_ref(), b"test message"); + + client.await.unwrap(); + } + + #[tokio::test] + async fn empty_handshake() { + // Check that everything still works when the handshake messages are empty. + + const PROTO_NAME: &str = "/test/proto/1"; + let (listener_addr_tx, listener_addr_rx) = oneshot::channel(); + + let client = tokio::spawn(async move { + let socket = TcpStream::connect(listener_addr_rx.await.unwrap()).await.unwrap(); + let notifs_out = NotificationsOut::new(PROTO_NAME, Vec::new(), vec![], 1024 * 1024); + let (_, substream) = multistream_select::dialer_select_proto( + socket.compat(), + notifs_out.protocol_info().into_iter(), + upgrade::Version::V1, + ) + .await + .unwrap(); + let NotificationsOutOpen { handshake, mut substream, .. } = + ::upgrade_outbound( + notifs_out, + substream, + PROTO_NAME.into(), + ) + .await + .unwrap(); + + assert!(handshake.is_empty()); + substream.send(Default::default()).await.unwrap(); + }); + + let listener = TcpListener::bind("127.0.0.1:0").await.unwrap(); + listener_addr_tx.send(listener.local_addr().unwrap()).unwrap(); + + let (socket, _) = listener.accept().await.unwrap(); + let notifs_in = NotificationsIn::new(PROTO_NAME, Vec::new(), 1024 * 1024); + let (_, substream) = + multistream_select::listener_select_proto(socket.compat(), notifs_in.protocol_info()) + .await + .unwrap(); + let NotificationsInOpen { handshake, mut substream, .. } = + ::upgrade_inbound( + notifs_in, + substream, + PROTO_NAME.into(), + ) + .await + .unwrap(); + + assert!(handshake.is_empty()); + substream.send_handshake(vec![]); + + let msg = substream.next().await.unwrap().unwrap(); + assert!(msg.as_ref().is_empty()); + + client.await.unwrap(); + } + + #[tokio::test] + async fn refused() { + const PROTO_NAME: &str = "/test/proto/1"; + let (listener_addr_tx, listener_addr_rx) = oneshot::channel(); + + let client = tokio::spawn(async move { + let socket = TcpStream::connect(listener_addr_rx.await.unwrap()).await.unwrap(); + let outcome = multistream_select::dialer_select_proto( + socket.compat(), + NotificationsOut::new(PROTO_NAME, Vec::new(), &b"hello"[..], 1024 * 1024) + .protocol_info() + .into_iter(), + upgrade::Version::V1, + ) + .await; + + // Despite the protocol negotiation being successfully conducted on the listener + // side, we have to receive an error here because the listener didn't send the + // handshake. + assert!(outcome.is_err()); + }); + + let listener = TcpListener::bind("127.0.0.1:0").await.unwrap(); + listener_addr_tx.send(listener.local_addr().unwrap()).unwrap(); + + let (socket, _) = listener.accept().await.unwrap(); + let NotificationsInOpen { handshake, substream, .. } = + multistream_select::listener_select_proto( + socket.compat(), + NotificationsIn::new(PROTO_NAME, Vec::new(), 1024 * 1024).protocol_info(), + ) + .await + .unwrap(); + + assert_eq!(handshake, b"hello"); + + // We successfully upgrade to the protocol, but then close the substream. + drop(substream); + + client.await.unwrap(); + } + + #[tokio::test] + async fn large_initial_message_refused() { + const PROTO_NAME: &str = "/test/proto/1"; + let (listener_addr_tx, listener_addr_rx) = oneshot::channel(); + + let client = tokio::spawn(async move { + let socket = TcpStream::connect(listener_addr_rx.await.unwrap()).await.unwrap(); + let ret = multistream_select::dialer_select_proto( + socket.compat(), + // We check that an initial message that is too large gets refused. + NotificationsOut::new( + PROTO_NAME, + Vec::new(), + (0..32768).map(|_| 0).collect::>(), + 1024 * 1024, + ) + .protocol_info() + .into_iter(), + upgrade::Version::V1, + ) + .await; + assert!(ret.is_err()); + }); + + let listener = TcpListener::bind("127.0.0.1:0").await.unwrap(); + listener_addr_tx.send(listener.local_addr().unwrap()).unwrap(); + + let (socket, _) = listener.accept().await.unwrap(); + let ret = multistream_select::listener_select_proto( + socket.compat(), + NotificationsIn::new(PROTO_NAME, Vec::new(), 1024 * 1024).protocol_info(), + ) + .await; + assert!(ret.is_err()); + + client.await.unwrap(); + } + + #[tokio::test] + async fn large_handshake_refused() { + const PROTO_NAME: &str = "/test/proto/1"; + let (listener_addr_tx, listener_addr_rx) = oneshot::channel(); + + let client = tokio::spawn(async move { + let socket = TcpStream::connect(listener_addr_rx.await.unwrap()).await.unwrap(); + let ret = multistream_select::dialer_select_proto( + socket.compat(), + NotificationsOut::new(PROTO_NAME, Vec::new(), &b"initial message"[..], 1024 * 1024) + .protocol_info() + .into_iter(), + upgrade::Version::V1, + ) + .await; + assert!(ret.is_err()); + }); + + let listener = TcpListener::bind("127.0.0.1:0").await.unwrap(); + listener_addr_tx.send(listener.local_addr().unwrap()).unwrap(); + + let (socket, _) = listener.accept().await.unwrap(); + let NotificationsInOpen { handshake, mut substream, .. } = + multistream_select::listener_select_proto( + socket.compat(), + NotificationsIn::new(PROTO_NAME, Vec::new(), 1024 * 1024).protocol_info(), + ) + .await + .unwrap(); + assert_eq!(handshake, b"initial message"); + + // We check that a handshake that is too large gets refused. + substream.send_handshake((0..32768).map(|_| 0).collect::>()); + let _ = substream.next().await; + + client.await.unwrap(); + } +} From 3c179f0a3441568b5790c014632357c2915f3b70 Mon Sep 17 00:00:00 2001 From: Anton Kaliaev Date: Tue, 4 Jul 2023 16:45:10 +0400 Subject: [PATCH 26/42] finish rewriting tests --- .../notifications/upgrade/notifications.rs | 224 +++++++----------- 1 file changed, 80 insertions(+), 144 deletions(-) diff --git a/client/network/src/protocol/notifications/upgrade/notifications.rs b/client/network/src/protocol/notifications/upgrade/notifications.rs index 3bd59f0ac28ae..0148fd22bd883 100644 --- a/client/network/src/protocol/notifications/upgrade/notifications.rs +++ b/client/network/src/protocol/notifications/upgrade/notifications.rs @@ -114,13 +114,6 @@ pub struct NotificationsOutSubstream { socket: Framed>>>, } -#[cfg(test)] -impl NotificationsOutSubstream { - pub fn new(socket: Framed>>>) -> Self { - Self { socket } - } -} - impl NotificationsIn { /// Builds a new potential upgrade. pub fn new( @@ -498,58 +491,92 @@ pub enum NotificationsOutError { #[cfg(test)] mod tests { - use super::{NotificationsIn, NotificationsInOpen, NotificationsOut, NotificationsOutOpen}; - use futures::{channel::oneshot, prelude::*}; + use super::*; + use futures::channel::oneshot; use libp2p::core::{upgrade, InboundUpgrade, OutboundUpgrade, UpgradeInfo}; use tokio::net::{TcpListener, TcpStream}; use tokio_util::compat::TokioAsyncReadCompatExt; - #[tokio::test] - async fn basic_works() { - const PROTO_NAME: &str = "/test/proto/1"; - let (listener_addr_tx, listener_addr_rx) = oneshot::channel(); - - let client = tokio::spawn(async move { - let socket = TcpStream::connect(listener_addr_rx.await.unwrap()).await.unwrap(); - let notifs_out = - NotificationsOut::new(PROTO_NAME, Vec::new(), &b"initial message"[..], 1024 * 1024); - let (_, substream) = multistream_select::dialer_select_proto( - socket.compat(), - notifs_out.protocol_info().into_iter(), - upgrade::Version::V1, + /// Opens a substream to the given address, negotiates the protocol, and returns the substream + /// along with the handshake message. + async fn dial( + addr: std::net::SocketAddr, + handshake: impl Into>, + ) -> Result< + ( + Vec, + NotificationsOutSubstream< + multistream_select::Negotiated>, + >, + ), + NotificationsHandshakeError, + > { + let socket = TcpStream::connect(addr).await.unwrap(); + let notifs_out = NotificationsOut::new("/test/proto/1", Vec::new(), handshake, 1024 * 1024); + let (_, substream) = multistream_select::dialer_select_proto( + socket.compat(), + notifs_out.protocol_info().into_iter(), + upgrade::Version::V1, + ) + .await + .unwrap(); + let NotificationsOutOpen { handshake, substream, .. } = + >::upgrade_outbound( + notifs_out, + substream, + "/test/proto/1".into(), ) - .await - .unwrap(); - let NotificationsOutOpen { handshake, mut substream, .. } = - ::upgrade_outbound( - notifs_out, - substream, - PROTO_NAME.into(), - ) - .await - .unwrap(); - - assert_eq!(handshake, b"hello world"); - substream.send(b"test message".to_vec()).await.unwrap(); - }); + .await?; + Ok((handshake, substream)) + } + /// Listens on a localhost, negotiates the protocol, and returns the substream along with the + /// handshake message. + /// + /// Also sends the listener address through the given channel. + async fn listen_on_localhost( + listener_addr_tx: oneshot::Sender, + ) -> Result< + ( + Vec, + NotificationsInSubstream< + multistream_select::Negotiated>, + >, + ), + NotificationsHandshakeError, + > { let listener = TcpListener::bind("127.0.0.1:0").await.unwrap(); listener_addr_tx.send(listener.local_addr().unwrap()).unwrap(); let (socket, _) = listener.accept().await.unwrap(); - let notifs_in = NotificationsIn::new(PROTO_NAME, Vec::new(), 1024 * 1024); + let notifs_in = NotificationsIn::new("/test/proto/1", Vec::new(), 1024 * 1024); let (_, substream) = multistream_select::listener_select_proto(socket.compat(), notifs_in.protocol_info()) .await .unwrap(); - let NotificationsInOpen { handshake, mut substream, .. } = - ::upgrade_inbound( + let NotificationsInOpen { handshake, substream, .. } = + >::upgrade_inbound( notifs_in, substream, - PROTO_NAME.into(), + "/test/proto/1".into(), ) - .await - .unwrap(); + .await?; + Ok((handshake, substream)) + } + + #[tokio::test] + async fn basic_works() { + let (listener_addr_tx, listener_addr_rx) = oneshot::channel(); + + let client = tokio::spawn(async move { + let (handshake, mut substream) = + dial(listener_addr_rx.await.unwrap(), &b"initial message"[..]).await.unwrap(); + + assert_eq!(handshake, b"hello world"); + substream.send(b"test message".to_vec()).await.unwrap(); + }); + + let (handshake, mut substream) = listen_on_localhost(listener_addr_tx).await.unwrap(); assert_eq!(handshake, b"initial message"); substream.send_handshake(&b"hello world"[..]); @@ -564,49 +591,17 @@ mod tests { async fn empty_handshake() { // Check that everything still works when the handshake messages are empty. - const PROTO_NAME: &str = "/test/proto/1"; let (listener_addr_tx, listener_addr_rx) = oneshot::channel(); let client = tokio::spawn(async move { - let socket = TcpStream::connect(listener_addr_rx.await.unwrap()).await.unwrap(); - let notifs_out = NotificationsOut::new(PROTO_NAME, Vec::new(), vec![], 1024 * 1024); - let (_, substream) = multistream_select::dialer_select_proto( - socket.compat(), - notifs_out.protocol_info().into_iter(), - upgrade::Version::V1, - ) - .await - .unwrap(); - let NotificationsOutOpen { handshake, mut substream, .. } = - ::upgrade_outbound( - notifs_out, - substream, - PROTO_NAME.into(), - ) - .await - .unwrap(); + let (handshake, mut substream) = + dial(listener_addr_rx.await.unwrap(), vec![]).await.unwrap(); assert!(handshake.is_empty()); substream.send(Default::default()).await.unwrap(); }); - let listener = TcpListener::bind("127.0.0.1:0").await.unwrap(); - listener_addr_tx.send(listener.local_addr().unwrap()).unwrap(); - - let (socket, _) = listener.accept().await.unwrap(); - let notifs_in = NotificationsIn::new(PROTO_NAME, Vec::new(), 1024 * 1024); - let (_, substream) = - multistream_select::listener_select_proto(socket.compat(), notifs_in.protocol_info()) - .await - .unwrap(); - let NotificationsInOpen { handshake, mut substream, .. } = - ::upgrade_inbound( - notifs_in, - substream, - PROTO_NAME.into(), - ) - .await - .unwrap(); + let (handshake, mut substream) = listen_on_localhost(listener_addr_tx).await.unwrap(); assert!(handshake.is_empty()); substream.send_handshake(vec![]); @@ -619,19 +614,10 @@ mod tests { #[tokio::test] async fn refused() { - const PROTO_NAME: &str = "/test/proto/1"; let (listener_addr_tx, listener_addr_rx) = oneshot::channel(); let client = tokio::spawn(async move { - let socket = TcpStream::connect(listener_addr_rx.await.unwrap()).await.unwrap(); - let outcome = multistream_select::dialer_select_proto( - socket.compat(), - NotificationsOut::new(PROTO_NAME, Vec::new(), &b"hello"[..], 1024 * 1024) - .protocol_info() - .into_iter(), - upgrade::Version::V1, - ) - .await; + let outcome = dial(listener_addr_rx.await.unwrap(), &b"hello"[..]).await; // Despite the protocol negotiation being successfully conducted on the listener // side, we have to receive an error here because the listener didn't send the @@ -639,17 +625,7 @@ mod tests { assert!(outcome.is_err()); }); - let listener = TcpListener::bind("127.0.0.1:0").await.unwrap(); - listener_addr_tx.send(listener.local_addr().unwrap()).unwrap(); - - let (socket, _) = listener.accept().await.unwrap(); - let NotificationsInOpen { handshake, substream, .. } = - multistream_select::listener_select_proto( - socket.compat(), - NotificationsIn::new(PROTO_NAME, Vec::new(), 1024 * 1024).protocol_info(), - ) - .await - .unwrap(); + let (handshake, substream) = listen_on_localhost(listener_addr_tx).await.unwrap(); assert_eq!(handshake, b"hello"); @@ -661,37 +637,16 @@ mod tests { #[tokio::test] async fn large_initial_message_refused() { - const PROTO_NAME: &str = "/test/proto/1"; let (listener_addr_tx, listener_addr_rx) = oneshot::channel(); let client = tokio::spawn(async move { - let socket = TcpStream::connect(listener_addr_rx.await.unwrap()).await.unwrap(); - let ret = multistream_select::dialer_select_proto( - socket.compat(), - // We check that an initial message that is too large gets refused. - NotificationsOut::new( - PROTO_NAME, - Vec::new(), - (0..32768).map(|_| 0).collect::>(), - 1024 * 1024, - ) - .protocol_info() - .into_iter(), - upgrade::Version::V1, - ) - .await; + let ret = + dial(listener_addr_rx.await.unwrap(), (0..32768).map(|_| 0).collect::>()) + .await; assert!(ret.is_err()); }); - let listener = TcpListener::bind("127.0.0.1:0").await.unwrap(); - listener_addr_tx.send(listener.local_addr().unwrap()).unwrap(); - - let (socket, _) = listener.accept().await.unwrap(); - let ret = multistream_select::listener_select_proto( - socket.compat(), - NotificationsIn::new(PROTO_NAME, Vec::new(), 1024 * 1024).protocol_info(), - ) - .await; + let ret = listen_on_localhost(listener_addr_tx).await; assert!(ret.is_err()); client.await.unwrap(); @@ -699,33 +654,14 @@ mod tests { #[tokio::test] async fn large_handshake_refused() { - const PROTO_NAME: &str = "/test/proto/1"; let (listener_addr_tx, listener_addr_rx) = oneshot::channel(); let client = tokio::spawn(async move { - let socket = TcpStream::connect(listener_addr_rx.await.unwrap()).await.unwrap(); - let ret = multistream_select::dialer_select_proto( - socket.compat(), - NotificationsOut::new(PROTO_NAME, Vec::new(), &b"initial message"[..], 1024 * 1024) - .protocol_info() - .into_iter(), - upgrade::Version::V1, - ) - .await; + let ret = dial(listener_addr_rx.await.unwrap(), &b"initial message"[..]).await; assert!(ret.is_err()); }); - let listener = TcpListener::bind("127.0.0.1:0").await.unwrap(); - listener_addr_tx.send(listener.local_addr().unwrap()).unwrap(); - - let (socket, _) = listener.accept().await.unwrap(); - let NotificationsInOpen { handshake, mut substream, .. } = - multistream_select::listener_select_proto( - socket.compat(), - NotificationsIn::new(PROTO_NAME, Vec::new(), 1024 * 1024).protocol_info(), - ) - .await - .unwrap(); + let (handshake, mut substream) = listen_on_localhost(listener_addr_tx).await.unwrap(); assert_eq!(handshake, b"initial message"); // We check that a handshake that is too large gets refused. From 720a06815887f4e10767c62b58864a7ec3a48e50 Mon Sep 17 00:00:00 2001 From: Anton Kaliaev Date: Wed, 5 Jul 2023 16:36:53 +0400 Subject: [PATCH 27/42] uncomment handler tests --- .../src/protocol/notifications/handler.rs | 1226 +++++++++-------- .../notifications/upgrade/notifications.rs | 21 +- 2 files changed, 629 insertions(+), 618 deletions(-) diff --git a/client/network/src/protocol/notifications/handler.rs b/client/network/src/protocol/notifications/handler.rs index 337c39e5f94ff..660a752c07c84 100644 --- a/client/network/src/protocol/notifications/handler.rs +++ b/client/network/src/protocol/notifications/handler.rs @@ -824,18 +824,22 @@ impl ConnectionHandler for NotifsHandler { #[cfg(test)] pub mod tests { use super::*; - // use crate::protocol::notifications::upgrade::{ - // NotificationsInOpen, NotificationsInSubstreamHandshake, NotificationsOutOpen, - // }; - // use asynchronous_codec::Framed; - // use libp2p::Multiaddr; - // use multistream_select::{dialer_select_proto, listener_select_proto, Negotiated, Version}; + use crate::protocol::notifications::upgrade::{ + NotificationsInOpen, NotificationsInSubstreamHandshake, NotificationsOutOpen, + }; + use asynchronous_codec::Framed; + use libp2p::{ + core::muxing::SubstreamBox, + swarm::{handler, StreamUpgradeError}, + Multiaddr, + }; + use multistream_select::{dialer_select_proto, listener_select_proto, Negotiated, Version}; use std::{ collections::HashMap, io::{Error, IoSlice, IoSliceMut}, }; use tokio::sync::mpsc; - // use unsigned_varint::codec::UviBytes; + use unsigned_varint::codec::UviBytes; struct OpenSubstream { notifications: stream::Peekable< @@ -934,20 +938,20 @@ pub mod tests { ) } - // /// Create new negotiated substream pair. - // pub async fn negotiated() -> (Negotiated, Negotiated) { - // let (socket1, socket2) = Self::new(); - // let socket1 = SubstreamBox::new(socket1); - // let socket2 = SubstreamBox::new(socket2); + /// Create new negotiated substream pair. + pub async fn negotiated() -> (Negotiated, Negotiated) { + let (socket1, socket2) = Self::new(); + let socket1 = SubstreamBox::new(socket1); + let socket2 = SubstreamBox::new(socket2); - // let protos = vec![b"/echo/1.0.0", b"/echo/2.5.0"]; - // let (res1, res2) = tokio::join!( - // dialer_select_proto(socket1, protos.clone(), Version::V1), - // listener_select_proto(socket2, protos), - // ); + let protos = vec![b"/echo/1.0.0", b"/echo/2.5.0"]; + let (res1, res2) = tokio::join!( + dialer_select_proto(socket1, protos.clone(), Version::V1), + listener_select_proto(socket2, protos), + ); - // (res1.unwrap().1, res2.unwrap().1) - // } + (res1.unwrap().1, res2.unwrap().1) + } } impl AsyncWrite for MockSubstream { @@ -1012,596 +1016,596 @@ pub mod tests { } } - // /// Create new [`NotifsHandler`]. - // fn notifs_handler() -> NotifsHandler { - // let proto = Protocol { - // config: ProtocolConfig { - // name: "/foo".into(), - // fallback_names: vec![], - // handshake: Arc::new(RwLock::new(b"hello, world".to_vec())), - // max_notification_size: u64::MAX, - // }, - // in_upgrade: NotificationsIn::new("/foo", Vec::new(), u64::MAX), - // state: State::Closed { pending_opening: false }, - // }; - - // NotifsHandler { - // protocols: vec![proto], - // when_connection_open: Instant::now(), - // endpoint: ConnectedPoint::Listener { - // local_addr: Multiaddr::empty(), - // send_back_addr: Multiaddr::empty(), - // }, - // peer_id: PeerId::random(), - // events_queue: VecDeque::new(), - // } - // } - - // // verify that if another substream is attempted to be opened by remote while an inbound - // // substream already exists, the new inbound stream is rejected and closed by the local node. - // #[tokio::test] - // async fn second_open_desired_by_remote_rejected() { - // let mut handler = notifs_handler(); - // let (io, mut io2) = MockSubstream::negotiated().await; - // let mut codec = UviBytes::default(); - // codec.set_max_len(usize::MAX); - - // let notif_in = NotificationsInOpen { - // handshake: b"hello, world".to_vec(), - // negotiated_fallback: None, - // substream: NotificationsInSubstream::new( - // Framed::new(io, codec), - // NotificationsInSubstreamHandshake::NotSent, - // ), - // }; - - // handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedInbound( - // handler::FullyNegotiatedInbound { protocol: (notif_in, 0), info: () }, - // )); - - // // verify that the substream is in (partly) opened state - // assert!(std::matches!(handler.protocols[0].state, State::OpenDesiredByRemote { .. })); - // futures::future::poll_fn(|cx| { - // let mut buf = Vec::with_capacity(512); - // assert!(std::matches!(Pin::new(&mut io2).poll_read(cx, &mut buf), Poll::Pending)); - // Poll::Ready(()) - // }) - // .await; - - // // attempt to open another inbound substream and verify that it is rejected - // let (io, mut io2) = MockSubstream::negotiated().await; - // let mut codec = UviBytes::default(); - // codec.set_max_len(usize::MAX); - - // let notif_in = NotificationsInOpen { - // handshake: b"hello, world".to_vec(), - // negotiated_fallback: None, - // substream: NotificationsInSubstream::new( - // Framed::new(io, codec), - // NotificationsInSubstreamHandshake::NotSent, - // ), - // }; - - // handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedInbound( - // handler::FullyNegotiatedInbound { protocol: (notif_in, 0), info: () }, - // )); - - // // verify that the new substream is rejected and closed - // futures::future::poll_fn(|cx| { - // let mut buf = Vec::with_capacity(512); - - // if let Poll::Ready(Err(err)) = Pin::new(&mut io2).poll_read(cx, &mut buf) { - // assert_eq!(err.kind(), std::io::ErrorKind::UnexpectedEof,); - // } - - // Poll::Ready(()) - // }) - // .await; - // } - - // #[tokio::test] - // async fn open_rejected_if_substream_is_opening() { - // let mut handler = notifs_handler(); - // let (io, mut io2) = MockSubstream::negotiated().await; - // let mut codec = UviBytes::default(); - // codec.set_max_len(usize::MAX); - - // let notif_in = NotificationsInOpen { - // handshake: b"hello, world".to_vec(), - // negotiated_fallback: None, - // substream: NotificationsInSubstream::new( - // Framed::new(io, codec), - // NotificationsInSubstreamHandshake::NotSent, - // ), - // }; - - // handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedInbound( - // handler::FullyNegotiatedInbound { protocol: (notif_in, 0), info: () }, - // )); - - // // verify that the substream is in (partly) opened state - // assert!(std::matches!(handler.protocols[0].state, State::OpenDesiredByRemote { .. })); - // futures::future::poll_fn(|cx| { - // let mut buf = Vec::with_capacity(512); - // assert!(std::matches!(Pin::new(&mut io2).poll_read(cx, &mut buf), Poll::Pending)); - // Poll::Ready(()) - // }) - // .await; - - // // move the handler state to 'Opening' - // handler.on_behaviour_event(NotifsHandlerIn::Open { protocol_index: 0 }); - // assert!(std::matches!( - // handler.protocols[0].state, - // State::Opening { in_substream: Some(_) } - // )); - - // // remote now tries to open another substream, verify that it is rejected and closed - // let (io, mut io2) = MockSubstream::negotiated().await; - // let mut codec = UviBytes::default(); - // codec.set_max_len(usize::MAX); - - // let notif_in = NotificationsInOpen { - // handshake: b"hello, world".to_vec(), - // negotiated_fallback: None, - // substream: NotificationsInSubstream::new( - // Framed::new(io, codec), - // NotificationsInSubstreamHandshake::NotSent, - // ), - // }; - - // handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedInbound( - // handler::FullyNegotiatedInbound { protocol: (notif_in, 0), info: () }, - // )); - - // // verify that the new substream is rejected and closed but that the first substream is - // // still in correct state - // futures::future::poll_fn(|cx| { - // let mut buf = Vec::with_capacity(512); - - // if let Poll::Ready(Err(err)) = Pin::new(&mut io2).poll_read(cx, &mut buf) { - // assert_eq!(err.kind(), std::io::ErrorKind::UnexpectedEof,); - // } else { - // panic!("unexpected result"); - // } - - // Poll::Ready(()) - // }) - // .await; - // assert!(std::matches!( - // handler.protocols[0].state, - // State::Opening { in_substream: Some(_) } - // )); - // } - - // #[tokio::test] - // async fn open_rejected_if_substream_already_open() { - // let mut handler = notifs_handler(); - // let (io, mut io2) = MockSubstream::negotiated().await; - // let mut codec = UviBytes::default(); - // codec.set_max_len(usize::MAX); - - // let notif_in = NotificationsInOpen { - // handshake: b"hello, world".to_vec(), - // negotiated_fallback: None, - // substream: NotificationsInSubstream::new( - // Framed::new(io, codec), - // NotificationsInSubstreamHandshake::NotSent, - // ), - // }; - // handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedInbound( - // handler::FullyNegotiatedInbound { protocol: (notif_in, 0), info: () }, - // )); - - // // verify that the substream is in (partly) opened state - // assert!(std::matches!(handler.protocols[0].state, State::OpenDesiredByRemote { .. })); - // futures::future::poll_fn(|cx| { - // let mut buf = Vec::with_capacity(512); - // assert!(std::matches!(Pin::new(&mut io2).poll_read(cx, &mut buf), Poll::Pending)); - // Poll::Ready(()) - // }) - // .await; - - // // move the handler state to 'Opening' - // handler.on_behaviour_event(NotifsHandlerIn::Open { protocol_index: 0 }); - // assert!(std::matches!( - // handler.protocols[0].state, - // State::Opening { in_substream: Some(_) } - // )); - - // // accept the substream and move its state to `Open` - // let (io, _io2) = MockSubstream::negotiated().await; - // let mut codec = UviBytes::default(); - // codec.set_max_len(usize::MAX); - - // let notif_out = NotificationsOutOpen { - // handshake: b"hello, world".to_vec(), - // negotiated_fallback: None, - // substream: NotificationsOutSubstream::new(Framed::new(io, codec)), - // }; - // handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedOutbound( - // handler::FullyNegotiatedOutbound { protocol: notif_out, info: 0 }, - // )); - - // assert!(std::matches!( - // handler.protocols[0].state, - // State::Open { in_substream: Some(_), .. } - // )); - - // // remote now tries to open another substream, verify that it is rejected and closed - // let (io, mut io2) = MockSubstream::negotiated().await; - // let mut codec = UviBytes::default(); - // codec.set_max_len(usize::MAX); - // let notif_in = NotificationsInOpen { - // handshake: b"hello, world".to_vec(), - // negotiated_fallback: None, - // substream: NotificationsInSubstream::new( - // Framed::new(io, codec), - // NotificationsInSubstreamHandshake::NotSent, - // ), - // }; - // handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedInbound( - // handler::FullyNegotiatedInbound { protocol: (notif_in, 0), info: () }, - // )); - - // // verify that the new substream is rejected and closed but that the first substream is - // // still in correct state - // futures::future::poll_fn(|cx| { - // let mut buf = Vec::with_capacity(512); - - // if let Poll::Ready(Err(err)) = Pin::new(&mut io2).poll_read(cx, &mut buf) { - // assert_eq!(err.kind(), std::io::ErrorKind::UnexpectedEof); - // } else { - // panic!("unexpected result"); - // } - - // Poll::Ready(()) - // }) - // .await; - // assert!(std::matches!( - // handler.protocols[0].state, - // State::Open { in_substream: Some(_), .. } - // )); - // } - - // #[tokio::test] - // async fn fully_negotiated_resets_state_for_closed_substream() { - // let mut handler = notifs_handler(); - // let (io, mut io2) = MockSubstream::negotiated().await; - // let mut codec = UviBytes::default(); - // codec.set_max_len(usize::MAX); - - // let notif_in = NotificationsInOpen { - // handshake: b"hello, world".to_vec(), - // negotiated_fallback: None, - // substream: NotificationsInSubstream::new( - // Framed::new(io, codec), - // NotificationsInSubstreamHandshake::NotSent, - // ), - // }; - // handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedInbound( - // handler::FullyNegotiatedInbound { protocol: (notif_in, 0), info: () }, - // )); - - // // verify that the substream is in (partly) opened state - // assert!(std::matches!(handler.protocols[0].state, State::OpenDesiredByRemote { .. })); - // futures::future::poll_fn(|cx| { - // let mut buf = Vec::with_capacity(512); - // assert!(std::matches!(Pin::new(&mut io2).poll_read(cx, &mut buf), Poll::Pending)); - // Poll::Ready(()) - // }) - // .await; - - // // first instruct the handler to open a connection and then close it right after - // // so the handler is in state `Closed { pending_opening: true }` - // handler.on_behaviour_event(NotifsHandlerIn::Open { protocol_index: 0 }); - // assert!(std::matches!( - // handler.protocols[0].state, - // State::Opening { in_substream: Some(_) } - // )); - - // handler.on_behaviour_event(NotifsHandlerIn::Close { protocol_index: 0 }); - // assert!(std::matches!(handler.protocols[0].state, State::Closed { pending_opening: true })); - - // // verify that if the the outbound substream is successfully negotiated, the state is not - // // changed as the substream was commanded to be closed by the handler. - // let (io, _io2) = MockSubstream::negotiated().await; - // let mut codec = UviBytes::default(); - // codec.set_max_len(usize::MAX); - - // let notif_out = NotificationsOutOpen { - // handshake: b"hello, world".to_vec(), - // negotiated_fallback: None, - // substream: NotificationsOutSubstream::new(Framed::new(io, codec)), - // }; - // handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedOutbound( - // handler::FullyNegotiatedOutbound { protocol: notif_out, info: 0 }, - // )); - - // assert!(std::matches!( - // handler.protocols[0].state, - // State::Closed { pending_opening: false } - // )); - // } - - // #[tokio::test] - // async fn fully_negotiated_resets_state_for_open_desired_substream() { - // let mut handler = notifs_handler(); - // let (io, mut io2) = MockSubstream::negotiated().await; - // let mut codec = UviBytes::default(); - // codec.set_max_len(usize::MAX); - - // let notif_in = NotificationsInOpen { - // handshake: b"hello, world".to_vec(), - // negotiated_fallback: None, - // substream: NotificationsInSubstream::new( - // Framed::new(io, codec), - // NotificationsInSubstreamHandshake::NotSent, - // ), - // }; - // handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedInbound( - // handler::FullyNegotiatedInbound { protocol: (notif_in, 0), info: () }, - // )); - - // // verify that the substream is in (partly) opened state - // assert!(std::matches!(handler.protocols[0].state, State::OpenDesiredByRemote { .. })); - // futures::future::poll_fn(|cx| { - // let mut buf = Vec::with_capacity(512); - // assert!(std::matches!(Pin::new(&mut io2).poll_read(cx, &mut buf), Poll::Pending)); - // Poll::Ready(()) - // }) - // .await; - - // // first instruct the handler to open a connection and then close it right after - // // so the handler is in state `Closed { pending_opening: true }` - // handler.on_behaviour_event(NotifsHandlerIn::Open { protocol_index: 0 }); - // assert!(std::matches!( - // handler.protocols[0].state, - // State::Opening { in_substream: Some(_) } - // )); - - // handler.on_behaviour_event(NotifsHandlerIn::Close { protocol_index: 0 }); - // assert!(std::matches!(handler.protocols[0].state, State::Closed { pending_opening: true })); - - // // attempt to open another inbound substream and verify that it is rejected - // let (io, _io2) = MockSubstream::negotiated().await; - // let mut codec = UviBytes::default(); - // codec.set_max_len(usize::MAX); - - // let notif_in = NotificationsInOpen { - // handshake: b"hello, world".to_vec(), - // negotiated_fallback: None, - // substream: NotificationsInSubstream::new( - // Framed::new(io, codec), - // NotificationsInSubstreamHandshake::NotSent, - // ), - // }; - // handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedInbound( - // handler::FullyNegotiatedInbound { protocol: (notif_in, 0), info: () }, - // )); - - // assert!(std::matches!( - // handler.protocols[0].state, - // State::OpenDesiredByRemote { pending_opening: true, .. } - // )); - - // // verify that if the the outbound substream is successfully negotiated, the state is not - // // changed as the substream was commanded to be closed by the handler. - // let (io, _io2) = MockSubstream::negotiated().await; - // let mut codec = UviBytes::default(); - // codec.set_max_len(usize::MAX); - - // let notif_out = NotificationsOutOpen { - // handshake: b"hello, world".to_vec(), - // negotiated_fallback: None, - // substream: NotificationsOutSubstream::new(Framed::new(io, codec)), - // }; - - // handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedOutbound( - // handler::FullyNegotiatedOutbound { protocol: notif_out, info: 0 }, - // )); - - // assert!(std::matches!( - // handler.protocols[0].state, - // State::OpenDesiredByRemote { pending_opening: false, .. } - // )); - // } - - // #[tokio::test] - // async fn dial_upgrade_error_resets_closed_outbound_state() { - // let mut handler = notifs_handler(); - // let (io, mut io2) = MockSubstream::negotiated().await; - // let mut codec = UviBytes::default(); - // codec.set_max_len(usize::MAX); - - // let notif_in = NotificationsInOpen { - // handshake: b"hello, world".to_vec(), - // negotiated_fallback: None, - // substream: NotificationsInSubstream::new( - // Framed::new(io, codec), - // NotificationsInSubstreamHandshake::NotSent, - // ), - // }; - // handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedInbound( - // handler::FullyNegotiatedInbound { protocol: (notif_in, 0), info: () }, - // )); - - // // verify that the substream is in (partly) opened state - // assert!(std::matches!(handler.protocols[0].state, State::OpenDesiredByRemote { .. })); - // futures::future::poll_fn(|cx| { - // let mut buf = Vec::with_capacity(512); - // assert!(std::matches!(Pin::new(&mut io2).poll_read(cx, &mut buf), Poll::Pending)); - // Poll::Ready(()) - // }) - // .await; - - // // first instruct the handler to open a connection and then close it right after - // // so the handler is in state `Closed { pending_opening: true }` - // handler.on_behaviour_event(NotifsHandlerIn::Open { protocol_index: 0 }); - // assert!(std::matches!( - // handler.protocols[0].state, - // State::Opening { in_substream: Some(_) } - // )); - - // handler.on_behaviour_event(NotifsHandlerIn::Close { protocol_index: 0 }); - // assert!(std::matches!(handler.protocols[0].state, State::Closed { pending_opening: true })); - - // // inject dial failure to an already closed substream and verify outbound state is reset - // handler.on_connection_event(handler::ConnectionEvent::DialUpgradeError( - // handler::DialUpgradeError { info: 0, error: StreamUpgradeError::Timeout }, - // )); - // assert!(std::matches!( - // handler.protocols[0].state, - // State::Closed { pending_opening: false } - // )); - // } - - // #[tokio::test] - // async fn dial_upgrade_error_resets_open_desired_state() { - // let mut handler = notifs_handler(); - // let (io, mut io2) = MockSubstream::negotiated().await; - // let mut codec = UviBytes::default(); - // codec.set_max_len(usize::MAX); - - // let notif_in = NotificationsInOpen { - // handshake: b"hello, world".to_vec(), - // negotiated_fallback: None, - // substream: NotificationsInSubstream::new( - // Framed::new(io, codec), - // NotificationsInSubstreamHandshake::NotSent, - // ), - // }; - // handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedInbound( - // handler::FullyNegotiatedInbound { protocol: (notif_in, 0), info: () }, - // )); - - // // verify that the substream is in (partly) opened state - // assert!(std::matches!(handler.protocols[0].state, State::OpenDesiredByRemote { .. })); - // futures::future::poll_fn(|cx| { - // let mut buf = Vec::with_capacity(512); - // assert!(std::matches!(Pin::new(&mut io2).poll_read(cx, &mut buf), Poll::Pending)); - // Poll::Ready(()) - // }) - // .await; - - // // first instruct the handler to open a connection and then close it right after - // // so the handler is in state `Closed { pending_opening: true }` - // handler.on_behaviour_event(NotifsHandlerIn::Open { protocol_index: 0 }); - // assert!(std::matches!( - // handler.protocols[0].state, - // State::Opening { in_substream: Some(_) } - // )); - - // handler.on_behaviour_event(NotifsHandlerIn::Close { protocol_index: 0 }); - // assert!(std::matches!(handler.protocols[0].state, State::Closed { pending_opening: true })); - - // let (io, _io2) = MockSubstream::negotiated().await; - // let mut codec = UviBytes::default(); - // codec.set_max_len(usize::MAX); - - // let notif_in = NotificationsInOpen { - // handshake: b"hello, world".to_vec(), - // negotiated_fallback: None, - // substream: NotificationsInSubstream::new( - // Framed::new(io, codec), - // NotificationsInSubstreamHandshake::NotSent, - // ), - // }; - // handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedInbound( - // handler::FullyNegotiatedInbound { protocol: (notif_in, 0), info: () }, - // )); - - // assert!(std::matches!( - // handler.protocols[0].state, - // State::OpenDesiredByRemote { pending_opening: true, .. } - // )); - - // // inject dial failure to an already closed substream and verify outbound state is reset - // handler.on_connection_event(handler::ConnectionEvent::DialUpgradeError( - // handler::DialUpgradeError { info: 0, error: StreamUpgradeError::Timeout }, - // )); - // assert!(std::matches!( - // handler.protocols[0].state, - // State::OpenDesiredByRemote { pending_opening: false, .. } - // )); - // } - - // #[tokio::test] - // async fn sync_notifications_clogged() { - // let mut handler = notifs_handler(); - // let (io, _) = MockSubstream::negotiated().await; - // let codec = UviBytes::default(); - - // let (async_tx, async_rx) = futures::channel::mpsc::channel(ASYNC_NOTIFICATIONS_BUFFER_SIZE); - // let (sync_tx, sync_rx) = futures::channel::mpsc::channel(1); - // let notifications_sink = NotificationsSink { - // inner: Arc::new(NotificationsSinkInner { - // peer_id: PeerId::random(), - // async_channel: FuturesMutex::new(async_tx), - // sync_channel: Mutex::new(Some(sync_tx)), - // }), - // }; - - // handler.protocols[0].state = State::Open { - // notifications_sink_rx: stream::select(async_rx.fuse(), sync_rx.fuse()).peekable(), - // out_substream: Some(NotificationsOutSubstream::new(Framed::new(io, codec))), - // in_substream: None, - // }; - - // notifications_sink.send_sync_notification(vec![1, 3, 3, 7]); - // notifications_sink.send_sync_notification(vec![1, 3, 3, 8]); - // notifications_sink.send_sync_notification(vec![1, 3, 3, 9]); - // notifications_sink.send_sync_notification(vec![1, 3, 4, 0]); - - // futures::future::poll_fn(|cx| { - // assert!(std::matches!( - // handler.poll(cx), - // Poll::Ready(ConnectionHandlerEvent::Close( - // NotifsHandlerError::SyncNotificationsClogged, - // )) - // )); - // Poll::Ready(()) - // }) - // .await; - // } - - // #[tokio::test] - // async fn close_desired_by_remote() { - // let mut handler = notifs_handler(); - // let (io, io2) = MockSubstream::negotiated().await; - // let mut codec = UviBytes::default(); - // codec.set_max_len(usize::MAX); - - // let notif_in = NotificationsInOpen { - // handshake: b"hello, world".to_vec(), - // negotiated_fallback: None, - // substream: NotificationsInSubstream::new( - // Framed::new(io, codec), - // NotificationsInSubstreamHandshake::PendingSend(vec![1, 2, 3, 4]), - // ), - // }; - - // // add new inbound substream but close it immediately and verify that correct events are - // // emitted - // handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedInbound( - // handler::FullyNegotiatedInbound { protocol: (notif_in, 0), info: () }, - // )); - // drop(io2); - - // futures::future::poll_fn(|cx| { - // assert!(std::matches!( - // handler.poll(cx), - // Poll::Ready(ConnectionHandlerEvent::NotifyBehaviour( - // NotifsHandlerOut::OpenDesiredByRemote { protocol_index: 0 }, - // )) - // )); - // assert!(std::matches!( - // handler.poll(cx), - // Poll::Ready(ConnectionHandlerEvent::NotifyBehaviour( - // NotifsHandlerOut::CloseDesired { protocol_index: 0 }, - // )) - // )); - // Poll::Ready(()) - // }) - // .await; - // } + /// Create new [`NotifsHandler`]. + fn notifs_handler() -> NotifsHandler { + let proto = Protocol { + config: ProtocolConfig { + name: "/foo".into(), + fallback_names: vec![], + handshake: Arc::new(RwLock::new(b"hello, world".to_vec())), + max_notification_size: u64::MAX, + }, + in_upgrade: NotificationsIn::new("/foo", Vec::new(), u64::MAX), + state: State::Closed { pending_opening: false }, + }; + + NotifsHandler { + protocols: vec![proto], + when_connection_open: Instant::now(), + endpoint: ConnectedPoint::Listener { + local_addr: Multiaddr::empty(), + send_back_addr: Multiaddr::empty(), + }, + peer_id: PeerId::random(), + events_queue: VecDeque::new(), + } + } + + // verify that if another substream is attempted to be opened by remote while an inbound + // substream already exists, the new inbound stream is rejected and closed by the local node. + #[tokio::test] + async fn second_open_desired_by_remote_rejected() { + let mut handler = notifs_handler(); + let (io, mut io2) = MockSubstream::negotiated().await; + let mut codec = UviBytes::default(); + codec.set_max_len(usize::MAX); + + let notif_in = NotificationsInOpen { + handshake: b"hello, world".to_vec(), + negotiated_fallback: None, + substream: NotificationsInSubstream::new( + Framed::new(io, codec), + NotificationsInSubstreamHandshake::NotSent, + ), + }; + + handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedInbound( + handler::FullyNegotiatedInbound { protocol: (notif_in, 0), info: () }, + )); + + // verify that the substream is in (partly) opened state + assert!(std::matches!(handler.protocols[0].state, State::OpenDesiredByRemote { .. })); + futures::future::poll_fn(|cx| { + let mut buf = Vec::with_capacity(512); + assert!(std::matches!(Pin::new(&mut io2).poll_read(cx, &mut buf), Poll::Pending)); + Poll::Ready(()) + }) + .await; + + // attempt to open another inbound substream and verify that it is rejected + let (io, mut io2) = MockSubstream::negotiated().await; + let mut codec = UviBytes::default(); + codec.set_max_len(usize::MAX); + + let notif_in = NotificationsInOpen { + handshake: b"hello, world".to_vec(), + negotiated_fallback: None, + substream: NotificationsInSubstream::new( + Framed::new(io, codec), + NotificationsInSubstreamHandshake::NotSent, + ), + }; + + handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedInbound( + handler::FullyNegotiatedInbound { protocol: (notif_in, 0), info: () }, + )); + + // verify that the new substream is rejected and closed + futures::future::poll_fn(|cx| { + let mut buf = Vec::with_capacity(512); + + if let Poll::Ready(Err(err)) = Pin::new(&mut io2).poll_read(cx, &mut buf) { + assert_eq!(err.kind(), std::io::ErrorKind::UnexpectedEof,); + } + + Poll::Ready(()) + }) + .await; + } + + #[tokio::test] + async fn open_rejected_if_substream_is_opening() { + let mut handler = notifs_handler(); + let (io, mut io2) = MockSubstream::negotiated().await; + let mut codec = UviBytes::default(); + codec.set_max_len(usize::MAX); + + let notif_in = NotificationsInOpen { + handshake: b"hello, world".to_vec(), + negotiated_fallback: None, + substream: NotificationsInSubstream::new( + Framed::new(io, codec), + NotificationsInSubstreamHandshake::NotSent, + ), + }; + + handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedInbound( + handler::FullyNegotiatedInbound { protocol: (notif_in, 0), info: () }, + )); + + // verify that the substream is in (partly) opened state + assert!(std::matches!(handler.protocols[0].state, State::OpenDesiredByRemote { .. })); + futures::future::poll_fn(|cx| { + let mut buf = Vec::with_capacity(512); + assert!(std::matches!(Pin::new(&mut io2).poll_read(cx, &mut buf), Poll::Pending)); + Poll::Ready(()) + }) + .await; + + // move the handler state to 'Opening' + handler.on_behaviour_event(NotifsHandlerIn::Open { protocol_index: 0 }); + assert!(std::matches!( + handler.protocols[0].state, + State::Opening { in_substream: Some(_) } + )); + + // remote now tries to open another substream, verify that it is rejected and closed + let (io, mut io2) = MockSubstream::negotiated().await; + let mut codec = UviBytes::default(); + codec.set_max_len(usize::MAX); + + let notif_in = NotificationsInOpen { + handshake: b"hello, world".to_vec(), + negotiated_fallback: None, + substream: NotificationsInSubstream::new( + Framed::new(io, codec), + NotificationsInSubstreamHandshake::NotSent, + ), + }; + + handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedInbound( + handler::FullyNegotiatedInbound { protocol: (notif_in, 0), info: () }, + )); + + // verify that the new substream is rejected and closed but that the first substream is + // still in correct state + futures::future::poll_fn(|cx| { + let mut buf = Vec::with_capacity(512); + + if let Poll::Ready(Err(err)) = Pin::new(&mut io2).poll_read(cx, &mut buf) { + assert_eq!(err.kind(), std::io::ErrorKind::UnexpectedEof,); + } else { + panic!("unexpected result"); + } + + Poll::Ready(()) + }) + .await; + assert!(std::matches!( + handler.protocols[0].state, + State::Opening { in_substream: Some(_) } + )); + } + + #[tokio::test] + async fn open_rejected_if_substream_already_open() { + let mut handler = notifs_handler(); + let (io, mut io2) = MockSubstream::negotiated().await; + let mut codec = UviBytes::default(); + codec.set_max_len(usize::MAX); + + let notif_in = NotificationsInOpen { + handshake: b"hello, world".to_vec(), + negotiated_fallback: None, + substream: NotificationsInSubstream::new( + Framed::new(io, codec), + NotificationsInSubstreamHandshake::NotSent, + ), + }; + handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedInbound( + handler::FullyNegotiatedInbound { protocol: (notif_in, 0), info: () }, + )); + + // verify that the substream is in (partly) opened state + assert!(std::matches!(handler.protocols[0].state, State::OpenDesiredByRemote { .. })); + futures::future::poll_fn(|cx| { + let mut buf = Vec::with_capacity(512); + assert!(std::matches!(Pin::new(&mut io2).poll_read(cx, &mut buf), Poll::Pending)); + Poll::Ready(()) + }) + .await; + + // move the handler state to 'Opening' + handler.on_behaviour_event(NotifsHandlerIn::Open { protocol_index: 0 }); + assert!(std::matches!( + handler.protocols[0].state, + State::Opening { in_substream: Some(_) } + )); + + // accept the substream and move its state to `Open` + let (io, _io2) = MockSubstream::negotiated().await; + let mut codec = UviBytes::default(); + codec.set_max_len(usize::MAX); + + let notif_out = NotificationsOutOpen { + handshake: b"hello, world".to_vec(), + negotiated_fallback: None, + substream: NotificationsOutSubstream::new(Framed::new(io, codec)), + }; + handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedOutbound( + handler::FullyNegotiatedOutbound { protocol: notif_out, info: 0 }, + )); + + assert!(std::matches!( + handler.protocols[0].state, + State::Open { in_substream: Some(_), .. } + )); + + // remote now tries to open another substream, verify that it is rejected and closed + let (io, mut io2) = MockSubstream::negotiated().await; + let mut codec = UviBytes::default(); + codec.set_max_len(usize::MAX); + let notif_in = NotificationsInOpen { + handshake: b"hello, world".to_vec(), + negotiated_fallback: None, + substream: NotificationsInSubstream::new( + Framed::new(io, codec), + NotificationsInSubstreamHandshake::NotSent, + ), + }; + handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedInbound( + handler::FullyNegotiatedInbound { protocol: (notif_in, 0), info: () }, + )); + + // verify that the new substream is rejected and closed but that the first substream is + // still in correct state + futures::future::poll_fn(|cx| { + let mut buf = Vec::with_capacity(512); + + if let Poll::Ready(Err(err)) = Pin::new(&mut io2).poll_read(cx, &mut buf) { + assert_eq!(err.kind(), std::io::ErrorKind::UnexpectedEof); + } else { + panic!("unexpected result"); + } + + Poll::Ready(()) + }) + .await; + assert!(std::matches!( + handler.protocols[0].state, + State::Open { in_substream: Some(_), .. } + )); + } + + #[tokio::test] + async fn fully_negotiated_resets_state_for_closed_substream() { + let mut handler = notifs_handler(); + let (io, mut io2) = MockSubstream::negotiated().await; + let mut codec = UviBytes::default(); + codec.set_max_len(usize::MAX); + + let notif_in = NotificationsInOpen { + handshake: b"hello, world".to_vec(), + negotiated_fallback: None, + substream: NotificationsInSubstream::new( + Framed::new(io, codec), + NotificationsInSubstreamHandshake::NotSent, + ), + }; + handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedInbound( + handler::FullyNegotiatedInbound { protocol: (notif_in, 0), info: () }, + )); + + // verify that the substream is in (partly) opened state + assert!(std::matches!(handler.protocols[0].state, State::OpenDesiredByRemote { .. })); + futures::future::poll_fn(|cx| { + let mut buf = Vec::with_capacity(512); + assert!(std::matches!(Pin::new(&mut io2).poll_read(cx, &mut buf), Poll::Pending)); + Poll::Ready(()) + }) + .await; + + // first instruct the handler to open a connection and then close it right after + // so the handler is in state `Closed { pending_opening: true }` + handler.on_behaviour_event(NotifsHandlerIn::Open { protocol_index: 0 }); + assert!(std::matches!( + handler.protocols[0].state, + State::Opening { in_substream: Some(_) } + )); + + handler.on_behaviour_event(NotifsHandlerIn::Close { protocol_index: 0 }); + assert!(std::matches!(handler.protocols[0].state, State::Closed { pending_opening: true })); + + // verify that if the the outbound substream is successfully negotiated, the state is not + // changed as the substream was commanded to be closed by the handler. + let (io, _io2) = MockSubstream::negotiated().await; + let mut codec = UviBytes::default(); + codec.set_max_len(usize::MAX); + + let notif_out = NotificationsOutOpen { + handshake: b"hello, world".to_vec(), + negotiated_fallback: None, + substream: NotificationsOutSubstream::new(Framed::new(io, codec)), + }; + handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedOutbound( + handler::FullyNegotiatedOutbound { protocol: notif_out, info: 0 }, + )); + + assert!(std::matches!( + handler.protocols[0].state, + State::Closed { pending_opening: false } + )); + } + + #[tokio::test] + async fn fully_negotiated_resets_state_for_open_desired_substream() { + let mut handler = notifs_handler(); + let (io, mut io2) = MockSubstream::negotiated().await; + let mut codec = UviBytes::default(); + codec.set_max_len(usize::MAX); + + let notif_in = NotificationsInOpen { + handshake: b"hello, world".to_vec(), + negotiated_fallback: None, + substream: NotificationsInSubstream::new( + Framed::new(io, codec), + NotificationsInSubstreamHandshake::NotSent, + ), + }; + handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedInbound( + handler::FullyNegotiatedInbound { protocol: (notif_in, 0), info: () }, + )); + + // verify that the substream is in (partly) opened state + assert!(std::matches!(handler.protocols[0].state, State::OpenDesiredByRemote { .. })); + futures::future::poll_fn(|cx| { + let mut buf = Vec::with_capacity(512); + assert!(std::matches!(Pin::new(&mut io2).poll_read(cx, &mut buf), Poll::Pending)); + Poll::Ready(()) + }) + .await; + + // first instruct the handler to open a connection and then close it right after + // so the handler is in state `Closed { pending_opening: true }` + handler.on_behaviour_event(NotifsHandlerIn::Open { protocol_index: 0 }); + assert!(std::matches!( + handler.protocols[0].state, + State::Opening { in_substream: Some(_) } + )); + + handler.on_behaviour_event(NotifsHandlerIn::Close { protocol_index: 0 }); + assert!(std::matches!(handler.protocols[0].state, State::Closed { pending_opening: true })); + + // attempt to open another inbound substream and verify that it is rejected + let (io, _io2) = MockSubstream::negotiated().await; + let mut codec = UviBytes::default(); + codec.set_max_len(usize::MAX); + + let notif_in = NotificationsInOpen { + handshake: b"hello, world".to_vec(), + negotiated_fallback: None, + substream: NotificationsInSubstream::new( + Framed::new(io, codec), + NotificationsInSubstreamHandshake::NotSent, + ), + }; + handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedInbound( + handler::FullyNegotiatedInbound { protocol: (notif_in, 0), info: () }, + )); + + assert!(std::matches!( + handler.protocols[0].state, + State::OpenDesiredByRemote { pending_opening: true, .. } + )); + + // verify that if the the outbound substream is successfully negotiated, the state is not + // changed as the substream was commanded to be closed by the handler. + let (io, _io2) = MockSubstream::negotiated().await; + let mut codec = UviBytes::default(); + codec.set_max_len(usize::MAX); + + let notif_out = NotificationsOutOpen { + handshake: b"hello, world".to_vec(), + negotiated_fallback: None, + substream: NotificationsOutSubstream::new(Framed::new(io, codec)), + }; + + handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedOutbound( + handler::FullyNegotiatedOutbound { protocol: notif_out, info: 0 }, + )); + + assert!(std::matches!( + handler.protocols[0].state, + State::OpenDesiredByRemote { pending_opening: false, .. } + )); + } + + #[tokio::test] + async fn dial_upgrade_error_resets_closed_outbound_state() { + let mut handler = notifs_handler(); + let (io, mut io2) = MockSubstream::negotiated().await; + let mut codec = UviBytes::default(); + codec.set_max_len(usize::MAX); + + let notif_in = NotificationsInOpen { + handshake: b"hello, world".to_vec(), + negotiated_fallback: None, + substream: NotificationsInSubstream::new( + Framed::new(io, codec), + NotificationsInSubstreamHandshake::NotSent, + ), + }; + handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedInbound( + handler::FullyNegotiatedInbound { protocol: (notif_in, 0), info: () }, + )); + + // verify that the substream is in (partly) opened state + assert!(std::matches!(handler.protocols[0].state, State::OpenDesiredByRemote { .. })); + futures::future::poll_fn(|cx| { + let mut buf = Vec::with_capacity(512); + assert!(std::matches!(Pin::new(&mut io2).poll_read(cx, &mut buf), Poll::Pending)); + Poll::Ready(()) + }) + .await; + + // first instruct the handler to open a connection and then close it right after + // so the handler is in state `Closed { pending_opening: true }` + handler.on_behaviour_event(NotifsHandlerIn::Open { protocol_index: 0 }); + assert!(std::matches!( + handler.protocols[0].state, + State::Opening { in_substream: Some(_) } + )); + + handler.on_behaviour_event(NotifsHandlerIn::Close { protocol_index: 0 }); + assert!(std::matches!(handler.protocols[0].state, State::Closed { pending_opening: true })); + + // inject dial failure to an already closed substream and verify outbound state is reset + handler.on_connection_event(handler::ConnectionEvent::DialUpgradeError( + handler::DialUpgradeError { info: 0, error: StreamUpgradeError::Timeout }, + )); + assert!(std::matches!( + handler.protocols[0].state, + State::Closed { pending_opening: false } + )); + } + + #[tokio::test] + async fn dial_upgrade_error_resets_open_desired_state() { + let mut handler = notifs_handler(); + let (io, mut io2) = MockSubstream::negotiated().await; + let mut codec = UviBytes::default(); + codec.set_max_len(usize::MAX); + + let notif_in = NotificationsInOpen { + handshake: b"hello, world".to_vec(), + negotiated_fallback: None, + substream: NotificationsInSubstream::new( + Framed::new(io, codec), + NotificationsInSubstreamHandshake::NotSent, + ), + }; + handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedInbound( + handler::FullyNegotiatedInbound { protocol: (notif_in, 0), info: () }, + )); + + // verify that the substream is in (partly) opened state + assert!(std::matches!(handler.protocols[0].state, State::OpenDesiredByRemote { .. })); + futures::future::poll_fn(|cx| { + let mut buf = Vec::with_capacity(512); + assert!(std::matches!(Pin::new(&mut io2).poll_read(cx, &mut buf), Poll::Pending)); + Poll::Ready(()) + }) + .await; + + // first instruct the handler to open a connection and then close it right after + // so the handler is in state `Closed { pending_opening: true }` + handler.on_behaviour_event(NotifsHandlerIn::Open { protocol_index: 0 }); + assert!(std::matches!( + handler.protocols[0].state, + State::Opening { in_substream: Some(_) } + )); + + handler.on_behaviour_event(NotifsHandlerIn::Close { protocol_index: 0 }); + assert!(std::matches!(handler.protocols[0].state, State::Closed { pending_opening: true })); + + let (io, _io2) = MockSubstream::negotiated().await; + let mut codec = UviBytes::default(); + codec.set_max_len(usize::MAX); + + let notif_in = NotificationsInOpen { + handshake: b"hello, world".to_vec(), + negotiated_fallback: None, + substream: NotificationsInSubstream::new( + Framed::new(io, codec), + NotificationsInSubstreamHandshake::NotSent, + ), + }; + handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedInbound( + handler::FullyNegotiatedInbound { protocol: (notif_in, 0), info: () }, + )); + + assert!(std::matches!( + handler.protocols[0].state, + State::OpenDesiredByRemote { pending_opening: true, .. } + )); + + // inject dial failure to an already closed substream and verify outbound state is reset + handler.on_connection_event(handler::ConnectionEvent::DialUpgradeError( + handler::DialUpgradeError { info: 0, error: StreamUpgradeError::Timeout }, + )); + assert!(std::matches!( + handler.protocols[0].state, + State::OpenDesiredByRemote { pending_opening: false, .. } + )); + } + + #[tokio::test] + async fn sync_notifications_clogged() { + let mut handler = notifs_handler(); + let (io, _) = MockSubstream::negotiated().await; + let codec = UviBytes::default(); + + let (async_tx, async_rx) = futures::channel::mpsc::channel(ASYNC_NOTIFICATIONS_BUFFER_SIZE); + let (sync_tx, sync_rx) = futures::channel::mpsc::channel(1); + let notifications_sink = NotificationsSink { + inner: Arc::new(NotificationsSinkInner { + peer_id: PeerId::random(), + async_channel: FuturesMutex::new(async_tx), + sync_channel: Mutex::new(Some(sync_tx)), + }), + }; + + handler.protocols[0].state = State::Open { + notifications_sink_rx: stream::select(async_rx.fuse(), sync_rx.fuse()).peekable(), + out_substream: Some(NotificationsOutSubstream::new(Framed::new(io, codec))), + in_substream: None, + }; + + notifications_sink.send_sync_notification(vec![1, 3, 3, 7]); + notifications_sink.send_sync_notification(vec![1, 3, 3, 8]); + notifications_sink.send_sync_notification(vec![1, 3, 3, 9]); + notifications_sink.send_sync_notification(vec![1, 3, 4, 0]); + + futures::future::poll_fn(|cx| { + assert!(std::matches!( + handler.poll(cx), + Poll::Ready(ConnectionHandlerEvent::Close( + NotifsHandlerError::SyncNotificationsClogged, + )) + )); + Poll::Ready(()) + }) + .await; + } + + #[tokio::test] + async fn close_desired_by_remote() { + let mut handler = notifs_handler(); + let (io, io2) = MockSubstream::negotiated().await; + let mut codec = UviBytes::default(); + codec.set_max_len(usize::MAX); + + let notif_in = NotificationsInOpen { + handshake: b"hello, world".to_vec(), + negotiated_fallback: None, + substream: NotificationsInSubstream::new( + Framed::new(io, codec), + NotificationsInSubstreamHandshake::PendingSend(vec![1, 2, 3, 4]), + ), + }; + + // add new inbound substream but close it immediately and verify that correct events are + // emitted + handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedInbound( + handler::FullyNegotiatedInbound { protocol: (notif_in, 0), info: () }, + )); + drop(io2); + + futures::future::poll_fn(|cx| { + assert!(std::matches!( + handler.poll(cx), + Poll::Ready(ConnectionHandlerEvent::NotifyBehaviour( + NotifsHandlerOut::OpenDesiredByRemote { protocol_index: 0 }, + )) + )); + assert!(std::matches!( + handler.poll(cx), + Poll::Ready(ConnectionHandlerEvent::NotifyBehaviour( + NotifsHandlerOut::CloseDesired { protocol_index: 0 }, + )) + )); + Poll::Ready(()) + }) + .await; + } } diff --git a/client/network/src/protocol/notifications/upgrade/notifications.rs b/client/network/src/protocol/notifications/upgrade/notifications.rs index 0148fd22bd883..83228f33b8160 100644 --- a/client/network/src/protocol/notifications/upgrade/notifications.rs +++ b/client/network/src/protocol/notifications/upgrade/notifications.rs @@ -114,6 +114,13 @@ pub struct NotificationsOutSubstream { socket: Framed>>>, } +#[cfg(test)] +impl NotificationsOutSubstream { + pub fn new(socket: Framed>>>) -> Self { + Self { socket } + } +} + impl NotificationsIn { /// Builds a new potential upgrade. pub fn new( @@ -196,13 +203,13 @@ impl NotificationsInSubstream where TSubstream: AsyncRead + AsyncWrite + Unpin, { - // #[cfg(test)] - // pub fn new( - // socket: Framed>>>, - // handshake: NotificationsInSubstreamHandshake, - // ) -> Self { - // Self { socket, handshake } - // } + #[cfg(test)] + pub fn new( + socket: Framed>>>, + handshake: NotificationsInSubstreamHandshake, + ) -> Self { + Self { socket, handshake } + } /// Sends the handshake in order to inform the remote that we accept the substream. pub fn send_handshake(&mut self, message: impl Into>) { From 7ffa62a7de2180ca42b8586e98e2c24d7818ca77 Mon Sep 17 00:00:00 2001 From: Anton Kaliaev Date: Thu, 6 Jul 2023 14:09:33 +0400 Subject: [PATCH 28/42] Revert "uncomment handler tests" This reverts commit 720a06815887f4e10767c62b58864a7ec3a48e50. --- .../src/protocol/notifications/handler.rs | 1226 ++++++++--------- .../notifications/upgrade/notifications.rs | 21 +- 2 files changed, 618 insertions(+), 629 deletions(-) diff --git a/client/network/src/protocol/notifications/handler.rs b/client/network/src/protocol/notifications/handler.rs index 660a752c07c84..337c39e5f94ff 100644 --- a/client/network/src/protocol/notifications/handler.rs +++ b/client/network/src/protocol/notifications/handler.rs @@ -824,22 +824,18 @@ impl ConnectionHandler for NotifsHandler { #[cfg(test)] pub mod tests { use super::*; - use crate::protocol::notifications::upgrade::{ - NotificationsInOpen, NotificationsInSubstreamHandshake, NotificationsOutOpen, - }; - use asynchronous_codec::Framed; - use libp2p::{ - core::muxing::SubstreamBox, - swarm::{handler, StreamUpgradeError}, - Multiaddr, - }; - use multistream_select::{dialer_select_proto, listener_select_proto, Negotiated, Version}; + // use crate::protocol::notifications::upgrade::{ + // NotificationsInOpen, NotificationsInSubstreamHandshake, NotificationsOutOpen, + // }; + // use asynchronous_codec::Framed; + // use libp2p::Multiaddr; + // use multistream_select::{dialer_select_proto, listener_select_proto, Negotiated, Version}; use std::{ collections::HashMap, io::{Error, IoSlice, IoSliceMut}, }; use tokio::sync::mpsc; - use unsigned_varint::codec::UviBytes; + // use unsigned_varint::codec::UviBytes; struct OpenSubstream { notifications: stream::Peekable< @@ -938,20 +934,20 @@ pub mod tests { ) } - /// Create new negotiated substream pair. - pub async fn negotiated() -> (Negotiated, Negotiated) { - let (socket1, socket2) = Self::new(); - let socket1 = SubstreamBox::new(socket1); - let socket2 = SubstreamBox::new(socket2); + // /// Create new negotiated substream pair. + // pub async fn negotiated() -> (Negotiated, Negotiated) { + // let (socket1, socket2) = Self::new(); + // let socket1 = SubstreamBox::new(socket1); + // let socket2 = SubstreamBox::new(socket2); - let protos = vec![b"/echo/1.0.0", b"/echo/2.5.0"]; - let (res1, res2) = tokio::join!( - dialer_select_proto(socket1, protos.clone(), Version::V1), - listener_select_proto(socket2, protos), - ); + // let protos = vec![b"/echo/1.0.0", b"/echo/2.5.0"]; + // let (res1, res2) = tokio::join!( + // dialer_select_proto(socket1, protos.clone(), Version::V1), + // listener_select_proto(socket2, protos), + // ); - (res1.unwrap().1, res2.unwrap().1) - } + // (res1.unwrap().1, res2.unwrap().1) + // } } impl AsyncWrite for MockSubstream { @@ -1016,596 +1012,596 @@ pub mod tests { } } - /// Create new [`NotifsHandler`]. - fn notifs_handler() -> NotifsHandler { - let proto = Protocol { - config: ProtocolConfig { - name: "/foo".into(), - fallback_names: vec![], - handshake: Arc::new(RwLock::new(b"hello, world".to_vec())), - max_notification_size: u64::MAX, - }, - in_upgrade: NotificationsIn::new("/foo", Vec::new(), u64::MAX), - state: State::Closed { pending_opening: false }, - }; - - NotifsHandler { - protocols: vec![proto], - when_connection_open: Instant::now(), - endpoint: ConnectedPoint::Listener { - local_addr: Multiaddr::empty(), - send_back_addr: Multiaddr::empty(), - }, - peer_id: PeerId::random(), - events_queue: VecDeque::new(), - } - } - - // verify that if another substream is attempted to be opened by remote while an inbound - // substream already exists, the new inbound stream is rejected and closed by the local node. - #[tokio::test] - async fn second_open_desired_by_remote_rejected() { - let mut handler = notifs_handler(); - let (io, mut io2) = MockSubstream::negotiated().await; - let mut codec = UviBytes::default(); - codec.set_max_len(usize::MAX); - - let notif_in = NotificationsInOpen { - handshake: b"hello, world".to_vec(), - negotiated_fallback: None, - substream: NotificationsInSubstream::new( - Framed::new(io, codec), - NotificationsInSubstreamHandshake::NotSent, - ), - }; - - handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedInbound( - handler::FullyNegotiatedInbound { protocol: (notif_in, 0), info: () }, - )); - - // verify that the substream is in (partly) opened state - assert!(std::matches!(handler.protocols[0].state, State::OpenDesiredByRemote { .. })); - futures::future::poll_fn(|cx| { - let mut buf = Vec::with_capacity(512); - assert!(std::matches!(Pin::new(&mut io2).poll_read(cx, &mut buf), Poll::Pending)); - Poll::Ready(()) - }) - .await; - - // attempt to open another inbound substream and verify that it is rejected - let (io, mut io2) = MockSubstream::negotiated().await; - let mut codec = UviBytes::default(); - codec.set_max_len(usize::MAX); - - let notif_in = NotificationsInOpen { - handshake: b"hello, world".to_vec(), - negotiated_fallback: None, - substream: NotificationsInSubstream::new( - Framed::new(io, codec), - NotificationsInSubstreamHandshake::NotSent, - ), - }; - - handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedInbound( - handler::FullyNegotiatedInbound { protocol: (notif_in, 0), info: () }, - )); - - // verify that the new substream is rejected and closed - futures::future::poll_fn(|cx| { - let mut buf = Vec::with_capacity(512); - - if let Poll::Ready(Err(err)) = Pin::new(&mut io2).poll_read(cx, &mut buf) { - assert_eq!(err.kind(), std::io::ErrorKind::UnexpectedEof,); - } - - Poll::Ready(()) - }) - .await; - } - - #[tokio::test] - async fn open_rejected_if_substream_is_opening() { - let mut handler = notifs_handler(); - let (io, mut io2) = MockSubstream::negotiated().await; - let mut codec = UviBytes::default(); - codec.set_max_len(usize::MAX); - - let notif_in = NotificationsInOpen { - handshake: b"hello, world".to_vec(), - negotiated_fallback: None, - substream: NotificationsInSubstream::new( - Framed::new(io, codec), - NotificationsInSubstreamHandshake::NotSent, - ), - }; - - handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedInbound( - handler::FullyNegotiatedInbound { protocol: (notif_in, 0), info: () }, - )); - - // verify that the substream is in (partly) opened state - assert!(std::matches!(handler.protocols[0].state, State::OpenDesiredByRemote { .. })); - futures::future::poll_fn(|cx| { - let mut buf = Vec::with_capacity(512); - assert!(std::matches!(Pin::new(&mut io2).poll_read(cx, &mut buf), Poll::Pending)); - Poll::Ready(()) - }) - .await; - - // move the handler state to 'Opening' - handler.on_behaviour_event(NotifsHandlerIn::Open { protocol_index: 0 }); - assert!(std::matches!( - handler.protocols[0].state, - State::Opening { in_substream: Some(_) } - )); - - // remote now tries to open another substream, verify that it is rejected and closed - let (io, mut io2) = MockSubstream::negotiated().await; - let mut codec = UviBytes::default(); - codec.set_max_len(usize::MAX); - - let notif_in = NotificationsInOpen { - handshake: b"hello, world".to_vec(), - negotiated_fallback: None, - substream: NotificationsInSubstream::new( - Framed::new(io, codec), - NotificationsInSubstreamHandshake::NotSent, - ), - }; - - handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedInbound( - handler::FullyNegotiatedInbound { protocol: (notif_in, 0), info: () }, - )); - - // verify that the new substream is rejected and closed but that the first substream is - // still in correct state - futures::future::poll_fn(|cx| { - let mut buf = Vec::with_capacity(512); - - if let Poll::Ready(Err(err)) = Pin::new(&mut io2).poll_read(cx, &mut buf) { - assert_eq!(err.kind(), std::io::ErrorKind::UnexpectedEof,); - } else { - panic!("unexpected result"); - } - - Poll::Ready(()) - }) - .await; - assert!(std::matches!( - handler.protocols[0].state, - State::Opening { in_substream: Some(_) } - )); - } - - #[tokio::test] - async fn open_rejected_if_substream_already_open() { - let mut handler = notifs_handler(); - let (io, mut io2) = MockSubstream::negotiated().await; - let mut codec = UviBytes::default(); - codec.set_max_len(usize::MAX); - - let notif_in = NotificationsInOpen { - handshake: b"hello, world".to_vec(), - negotiated_fallback: None, - substream: NotificationsInSubstream::new( - Framed::new(io, codec), - NotificationsInSubstreamHandshake::NotSent, - ), - }; - handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedInbound( - handler::FullyNegotiatedInbound { protocol: (notif_in, 0), info: () }, - )); - - // verify that the substream is in (partly) opened state - assert!(std::matches!(handler.protocols[0].state, State::OpenDesiredByRemote { .. })); - futures::future::poll_fn(|cx| { - let mut buf = Vec::with_capacity(512); - assert!(std::matches!(Pin::new(&mut io2).poll_read(cx, &mut buf), Poll::Pending)); - Poll::Ready(()) - }) - .await; - - // move the handler state to 'Opening' - handler.on_behaviour_event(NotifsHandlerIn::Open { protocol_index: 0 }); - assert!(std::matches!( - handler.protocols[0].state, - State::Opening { in_substream: Some(_) } - )); - - // accept the substream and move its state to `Open` - let (io, _io2) = MockSubstream::negotiated().await; - let mut codec = UviBytes::default(); - codec.set_max_len(usize::MAX); - - let notif_out = NotificationsOutOpen { - handshake: b"hello, world".to_vec(), - negotiated_fallback: None, - substream: NotificationsOutSubstream::new(Framed::new(io, codec)), - }; - handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedOutbound( - handler::FullyNegotiatedOutbound { protocol: notif_out, info: 0 }, - )); - - assert!(std::matches!( - handler.protocols[0].state, - State::Open { in_substream: Some(_), .. } - )); - - // remote now tries to open another substream, verify that it is rejected and closed - let (io, mut io2) = MockSubstream::negotiated().await; - let mut codec = UviBytes::default(); - codec.set_max_len(usize::MAX); - let notif_in = NotificationsInOpen { - handshake: b"hello, world".to_vec(), - negotiated_fallback: None, - substream: NotificationsInSubstream::new( - Framed::new(io, codec), - NotificationsInSubstreamHandshake::NotSent, - ), - }; - handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedInbound( - handler::FullyNegotiatedInbound { protocol: (notif_in, 0), info: () }, - )); - - // verify that the new substream is rejected and closed but that the first substream is - // still in correct state - futures::future::poll_fn(|cx| { - let mut buf = Vec::with_capacity(512); - - if let Poll::Ready(Err(err)) = Pin::new(&mut io2).poll_read(cx, &mut buf) { - assert_eq!(err.kind(), std::io::ErrorKind::UnexpectedEof); - } else { - panic!("unexpected result"); - } - - Poll::Ready(()) - }) - .await; - assert!(std::matches!( - handler.protocols[0].state, - State::Open { in_substream: Some(_), .. } - )); - } - - #[tokio::test] - async fn fully_negotiated_resets_state_for_closed_substream() { - let mut handler = notifs_handler(); - let (io, mut io2) = MockSubstream::negotiated().await; - let mut codec = UviBytes::default(); - codec.set_max_len(usize::MAX); - - let notif_in = NotificationsInOpen { - handshake: b"hello, world".to_vec(), - negotiated_fallback: None, - substream: NotificationsInSubstream::new( - Framed::new(io, codec), - NotificationsInSubstreamHandshake::NotSent, - ), - }; - handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedInbound( - handler::FullyNegotiatedInbound { protocol: (notif_in, 0), info: () }, - )); - - // verify that the substream is in (partly) opened state - assert!(std::matches!(handler.protocols[0].state, State::OpenDesiredByRemote { .. })); - futures::future::poll_fn(|cx| { - let mut buf = Vec::with_capacity(512); - assert!(std::matches!(Pin::new(&mut io2).poll_read(cx, &mut buf), Poll::Pending)); - Poll::Ready(()) - }) - .await; - - // first instruct the handler to open a connection and then close it right after - // so the handler is in state `Closed { pending_opening: true }` - handler.on_behaviour_event(NotifsHandlerIn::Open { protocol_index: 0 }); - assert!(std::matches!( - handler.protocols[0].state, - State::Opening { in_substream: Some(_) } - )); - - handler.on_behaviour_event(NotifsHandlerIn::Close { protocol_index: 0 }); - assert!(std::matches!(handler.protocols[0].state, State::Closed { pending_opening: true })); - - // verify that if the the outbound substream is successfully negotiated, the state is not - // changed as the substream was commanded to be closed by the handler. - let (io, _io2) = MockSubstream::negotiated().await; - let mut codec = UviBytes::default(); - codec.set_max_len(usize::MAX); - - let notif_out = NotificationsOutOpen { - handshake: b"hello, world".to_vec(), - negotiated_fallback: None, - substream: NotificationsOutSubstream::new(Framed::new(io, codec)), - }; - handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedOutbound( - handler::FullyNegotiatedOutbound { protocol: notif_out, info: 0 }, - )); - - assert!(std::matches!( - handler.protocols[0].state, - State::Closed { pending_opening: false } - )); - } - - #[tokio::test] - async fn fully_negotiated_resets_state_for_open_desired_substream() { - let mut handler = notifs_handler(); - let (io, mut io2) = MockSubstream::negotiated().await; - let mut codec = UviBytes::default(); - codec.set_max_len(usize::MAX); - - let notif_in = NotificationsInOpen { - handshake: b"hello, world".to_vec(), - negotiated_fallback: None, - substream: NotificationsInSubstream::new( - Framed::new(io, codec), - NotificationsInSubstreamHandshake::NotSent, - ), - }; - handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedInbound( - handler::FullyNegotiatedInbound { protocol: (notif_in, 0), info: () }, - )); - - // verify that the substream is in (partly) opened state - assert!(std::matches!(handler.protocols[0].state, State::OpenDesiredByRemote { .. })); - futures::future::poll_fn(|cx| { - let mut buf = Vec::with_capacity(512); - assert!(std::matches!(Pin::new(&mut io2).poll_read(cx, &mut buf), Poll::Pending)); - Poll::Ready(()) - }) - .await; - - // first instruct the handler to open a connection and then close it right after - // so the handler is in state `Closed { pending_opening: true }` - handler.on_behaviour_event(NotifsHandlerIn::Open { protocol_index: 0 }); - assert!(std::matches!( - handler.protocols[0].state, - State::Opening { in_substream: Some(_) } - )); - - handler.on_behaviour_event(NotifsHandlerIn::Close { protocol_index: 0 }); - assert!(std::matches!(handler.protocols[0].state, State::Closed { pending_opening: true })); - - // attempt to open another inbound substream and verify that it is rejected - let (io, _io2) = MockSubstream::negotiated().await; - let mut codec = UviBytes::default(); - codec.set_max_len(usize::MAX); - - let notif_in = NotificationsInOpen { - handshake: b"hello, world".to_vec(), - negotiated_fallback: None, - substream: NotificationsInSubstream::new( - Framed::new(io, codec), - NotificationsInSubstreamHandshake::NotSent, - ), - }; - handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedInbound( - handler::FullyNegotiatedInbound { protocol: (notif_in, 0), info: () }, - )); - - assert!(std::matches!( - handler.protocols[0].state, - State::OpenDesiredByRemote { pending_opening: true, .. } - )); - - // verify that if the the outbound substream is successfully negotiated, the state is not - // changed as the substream was commanded to be closed by the handler. - let (io, _io2) = MockSubstream::negotiated().await; - let mut codec = UviBytes::default(); - codec.set_max_len(usize::MAX); - - let notif_out = NotificationsOutOpen { - handshake: b"hello, world".to_vec(), - negotiated_fallback: None, - substream: NotificationsOutSubstream::new(Framed::new(io, codec)), - }; - - handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedOutbound( - handler::FullyNegotiatedOutbound { protocol: notif_out, info: 0 }, - )); - - assert!(std::matches!( - handler.protocols[0].state, - State::OpenDesiredByRemote { pending_opening: false, .. } - )); - } - - #[tokio::test] - async fn dial_upgrade_error_resets_closed_outbound_state() { - let mut handler = notifs_handler(); - let (io, mut io2) = MockSubstream::negotiated().await; - let mut codec = UviBytes::default(); - codec.set_max_len(usize::MAX); - - let notif_in = NotificationsInOpen { - handshake: b"hello, world".to_vec(), - negotiated_fallback: None, - substream: NotificationsInSubstream::new( - Framed::new(io, codec), - NotificationsInSubstreamHandshake::NotSent, - ), - }; - handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedInbound( - handler::FullyNegotiatedInbound { protocol: (notif_in, 0), info: () }, - )); - - // verify that the substream is in (partly) opened state - assert!(std::matches!(handler.protocols[0].state, State::OpenDesiredByRemote { .. })); - futures::future::poll_fn(|cx| { - let mut buf = Vec::with_capacity(512); - assert!(std::matches!(Pin::new(&mut io2).poll_read(cx, &mut buf), Poll::Pending)); - Poll::Ready(()) - }) - .await; - - // first instruct the handler to open a connection and then close it right after - // so the handler is in state `Closed { pending_opening: true }` - handler.on_behaviour_event(NotifsHandlerIn::Open { protocol_index: 0 }); - assert!(std::matches!( - handler.protocols[0].state, - State::Opening { in_substream: Some(_) } - )); - - handler.on_behaviour_event(NotifsHandlerIn::Close { protocol_index: 0 }); - assert!(std::matches!(handler.protocols[0].state, State::Closed { pending_opening: true })); - - // inject dial failure to an already closed substream and verify outbound state is reset - handler.on_connection_event(handler::ConnectionEvent::DialUpgradeError( - handler::DialUpgradeError { info: 0, error: StreamUpgradeError::Timeout }, - )); - assert!(std::matches!( - handler.protocols[0].state, - State::Closed { pending_opening: false } - )); - } - - #[tokio::test] - async fn dial_upgrade_error_resets_open_desired_state() { - let mut handler = notifs_handler(); - let (io, mut io2) = MockSubstream::negotiated().await; - let mut codec = UviBytes::default(); - codec.set_max_len(usize::MAX); - - let notif_in = NotificationsInOpen { - handshake: b"hello, world".to_vec(), - negotiated_fallback: None, - substream: NotificationsInSubstream::new( - Framed::new(io, codec), - NotificationsInSubstreamHandshake::NotSent, - ), - }; - handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedInbound( - handler::FullyNegotiatedInbound { protocol: (notif_in, 0), info: () }, - )); - - // verify that the substream is in (partly) opened state - assert!(std::matches!(handler.protocols[0].state, State::OpenDesiredByRemote { .. })); - futures::future::poll_fn(|cx| { - let mut buf = Vec::with_capacity(512); - assert!(std::matches!(Pin::new(&mut io2).poll_read(cx, &mut buf), Poll::Pending)); - Poll::Ready(()) - }) - .await; - - // first instruct the handler to open a connection and then close it right after - // so the handler is in state `Closed { pending_opening: true }` - handler.on_behaviour_event(NotifsHandlerIn::Open { protocol_index: 0 }); - assert!(std::matches!( - handler.protocols[0].state, - State::Opening { in_substream: Some(_) } - )); - - handler.on_behaviour_event(NotifsHandlerIn::Close { protocol_index: 0 }); - assert!(std::matches!(handler.protocols[0].state, State::Closed { pending_opening: true })); - - let (io, _io2) = MockSubstream::negotiated().await; - let mut codec = UviBytes::default(); - codec.set_max_len(usize::MAX); - - let notif_in = NotificationsInOpen { - handshake: b"hello, world".to_vec(), - negotiated_fallback: None, - substream: NotificationsInSubstream::new( - Framed::new(io, codec), - NotificationsInSubstreamHandshake::NotSent, - ), - }; - handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedInbound( - handler::FullyNegotiatedInbound { protocol: (notif_in, 0), info: () }, - )); - - assert!(std::matches!( - handler.protocols[0].state, - State::OpenDesiredByRemote { pending_opening: true, .. } - )); - - // inject dial failure to an already closed substream and verify outbound state is reset - handler.on_connection_event(handler::ConnectionEvent::DialUpgradeError( - handler::DialUpgradeError { info: 0, error: StreamUpgradeError::Timeout }, - )); - assert!(std::matches!( - handler.protocols[0].state, - State::OpenDesiredByRemote { pending_opening: false, .. } - )); - } - - #[tokio::test] - async fn sync_notifications_clogged() { - let mut handler = notifs_handler(); - let (io, _) = MockSubstream::negotiated().await; - let codec = UviBytes::default(); - - let (async_tx, async_rx) = futures::channel::mpsc::channel(ASYNC_NOTIFICATIONS_BUFFER_SIZE); - let (sync_tx, sync_rx) = futures::channel::mpsc::channel(1); - let notifications_sink = NotificationsSink { - inner: Arc::new(NotificationsSinkInner { - peer_id: PeerId::random(), - async_channel: FuturesMutex::new(async_tx), - sync_channel: Mutex::new(Some(sync_tx)), - }), - }; - - handler.protocols[0].state = State::Open { - notifications_sink_rx: stream::select(async_rx.fuse(), sync_rx.fuse()).peekable(), - out_substream: Some(NotificationsOutSubstream::new(Framed::new(io, codec))), - in_substream: None, - }; - - notifications_sink.send_sync_notification(vec![1, 3, 3, 7]); - notifications_sink.send_sync_notification(vec![1, 3, 3, 8]); - notifications_sink.send_sync_notification(vec![1, 3, 3, 9]); - notifications_sink.send_sync_notification(vec![1, 3, 4, 0]); - - futures::future::poll_fn(|cx| { - assert!(std::matches!( - handler.poll(cx), - Poll::Ready(ConnectionHandlerEvent::Close( - NotifsHandlerError::SyncNotificationsClogged, - )) - )); - Poll::Ready(()) - }) - .await; - } - - #[tokio::test] - async fn close_desired_by_remote() { - let mut handler = notifs_handler(); - let (io, io2) = MockSubstream::negotiated().await; - let mut codec = UviBytes::default(); - codec.set_max_len(usize::MAX); - - let notif_in = NotificationsInOpen { - handshake: b"hello, world".to_vec(), - negotiated_fallback: None, - substream: NotificationsInSubstream::new( - Framed::new(io, codec), - NotificationsInSubstreamHandshake::PendingSend(vec![1, 2, 3, 4]), - ), - }; - - // add new inbound substream but close it immediately and verify that correct events are - // emitted - handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedInbound( - handler::FullyNegotiatedInbound { protocol: (notif_in, 0), info: () }, - )); - drop(io2); - - futures::future::poll_fn(|cx| { - assert!(std::matches!( - handler.poll(cx), - Poll::Ready(ConnectionHandlerEvent::NotifyBehaviour( - NotifsHandlerOut::OpenDesiredByRemote { protocol_index: 0 }, - )) - )); - assert!(std::matches!( - handler.poll(cx), - Poll::Ready(ConnectionHandlerEvent::NotifyBehaviour( - NotifsHandlerOut::CloseDesired { protocol_index: 0 }, - )) - )); - Poll::Ready(()) - }) - .await; - } + // /// Create new [`NotifsHandler`]. + // fn notifs_handler() -> NotifsHandler { + // let proto = Protocol { + // config: ProtocolConfig { + // name: "/foo".into(), + // fallback_names: vec![], + // handshake: Arc::new(RwLock::new(b"hello, world".to_vec())), + // max_notification_size: u64::MAX, + // }, + // in_upgrade: NotificationsIn::new("/foo", Vec::new(), u64::MAX), + // state: State::Closed { pending_opening: false }, + // }; + + // NotifsHandler { + // protocols: vec![proto], + // when_connection_open: Instant::now(), + // endpoint: ConnectedPoint::Listener { + // local_addr: Multiaddr::empty(), + // send_back_addr: Multiaddr::empty(), + // }, + // peer_id: PeerId::random(), + // events_queue: VecDeque::new(), + // } + // } + + // // verify that if another substream is attempted to be opened by remote while an inbound + // // substream already exists, the new inbound stream is rejected and closed by the local node. + // #[tokio::test] + // async fn second_open_desired_by_remote_rejected() { + // let mut handler = notifs_handler(); + // let (io, mut io2) = MockSubstream::negotiated().await; + // let mut codec = UviBytes::default(); + // codec.set_max_len(usize::MAX); + + // let notif_in = NotificationsInOpen { + // handshake: b"hello, world".to_vec(), + // negotiated_fallback: None, + // substream: NotificationsInSubstream::new( + // Framed::new(io, codec), + // NotificationsInSubstreamHandshake::NotSent, + // ), + // }; + + // handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedInbound( + // handler::FullyNegotiatedInbound { protocol: (notif_in, 0), info: () }, + // )); + + // // verify that the substream is in (partly) opened state + // assert!(std::matches!(handler.protocols[0].state, State::OpenDesiredByRemote { .. })); + // futures::future::poll_fn(|cx| { + // let mut buf = Vec::with_capacity(512); + // assert!(std::matches!(Pin::new(&mut io2).poll_read(cx, &mut buf), Poll::Pending)); + // Poll::Ready(()) + // }) + // .await; + + // // attempt to open another inbound substream and verify that it is rejected + // let (io, mut io2) = MockSubstream::negotiated().await; + // let mut codec = UviBytes::default(); + // codec.set_max_len(usize::MAX); + + // let notif_in = NotificationsInOpen { + // handshake: b"hello, world".to_vec(), + // negotiated_fallback: None, + // substream: NotificationsInSubstream::new( + // Framed::new(io, codec), + // NotificationsInSubstreamHandshake::NotSent, + // ), + // }; + + // handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedInbound( + // handler::FullyNegotiatedInbound { protocol: (notif_in, 0), info: () }, + // )); + + // // verify that the new substream is rejected and closed + // futures::future::poll_fn(|cx| { + // let mut buf = Vec::with_capacity(512); + + // if let Poll::Ready(Err(err)) = Pin::new(&mut io2).poll_read(cx, &mut buf) { + // assert_eq!(err.kind(), std::io::ErrorKind::UnexpectedEof,); + // } + + // Poll::Ready(()) + // }) + // .await; + // } + + // #[tokio::test] + // async fn open_rejected_if_substream_is_opening() { + // let mut handler = notifs_handler(); + // let (io, mut io2) = MockSubstream::negotiated().await; + // let mut codec = UviBytes::default(); + // codec.set_max_len(usize::MAX); + + // let notif_in = NotificationsInOpen { + // handshake: b"hello, world".to_vec(), + // negotiated_fallback: None, + // substream: NotificationsInSubstream::new( + // Framed::new(io, codec), + // NotificationsInSubstreamHandshake::NotSent, + // ), + // }; + + // handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedInbound( + // handler::FullyNegotiatedInbound { protocol: (notif_in, 0), info: () }, + // )); + + // // verify that the substream is in (partly) opened state + // assert!(std::matches!(handler.protocols[0].state, State::OpenDesiredByRemote { .. })); + // futures::future::poll_fn(|cx| { + // let mut buf = Vec::with_capacity(512); + // assert!(std::matches!(Pin::new(&mut io2).poll_read(cx, &mut buf), Poll::Pending)); + // Poll::Ready(()) + // }) + // .await; + + // // move the handler state to 'Opening' + // handler.on_behaviour_event(NotifsHandlerIn::Open { protocol_index: 0 }); + // assert!(std::matches!( + // handler.protocols[0].state, + // State::Opening { in_substream: Some(_) } + // )); + + // // remote now tries to open another substream, verify that it is rejected and closed + // let (io, mut io2) = MockSubstream::negotiated().await; + // let mut codec = UviBytes::default(); + // codec.set_max_len(usize::MAX); + + // let notif_in = NotificationsInOpen { + // handshake: b"hello, world".to_vec(), + // negotiated_fallback: None, + // substream: NotificationsInSubstream::new( + // Framed::new(io, codec), + // NotificationsInSubstreamHandshake::NotSent, + // ), + // }; + + // handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedInbound( + // handler::FullyNegotiatedInbound { protocol: (notif_in, 0), info: () }, + // )); + + // // verify that the new substream is rejected and closed but that the first substream is + // // still in correct state + // futures::future::poll_fn(|cx| { + // let mut buf = Vec::with_capacity(512); + + // if let Poll::Ready(Err(err)) = Pin::new(&mut io2).poll_read(cx, &mut buf) { + // assert_eq!(err.kind(), std::io::ErrorKind::UnexpectedEof,); + // } else { + // panic!("unexpected result"); + // } + + // Poll::Ready(()) + // }) + // .await; + // assert!(std::matches!( + // handler.protocols[0].state, + // State::Opening { in_substream: Some(_) } + // )); + // } + + // #[tokio::test] + // async fn open_rejected_if_substream_already_open() { + // let mut handler = notifs_handler(); + // let (io, mut io2) = MockSubstream::negotiated().await; + // let mut codec = UviBytes::default(); + // codec.set_max_len(usize::MAX); + + // let notif_in = NotificationsInOpen { + // handshake: b"hello, world".to_vec(), + // negotiated_fallback: None, + // substream: NotificationsInSubstream::new( + // Framed::new(io, codec), + // NotificationsInSubstreamHandshake::NotSent, + // ), + // }; + // handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedInbound( + // handler::FullyNegotiatedInbound { protocol: (notif_in, 0), info: () }, + // )); + + // // verify that the substream is in (partly) opened state + // assert!(std::matches!(handler.protocols[0].state, State::OpenDesiredByRemote { .. })); + // futures::future::poll_fn(|cx| { + // let mut buf = Vec::with_capacity(512); + // assert!(std::matches!(Pin::new(&mut io2).poll_read(cx, &mut buf), Poll::Pending)); + // Poll::Ready(()) + // }) + // .await; + + // // move the handler state to 'Opening' + // handler.on_behaviour_event(NotifsHandlerIn::Open { protocol_index: 0 }); + // assert!(std::matches!( + // handler.protocols[0].state, + // State::Opening { in_substream: Some(_) } + // )); + + // // accept the substream and move its state to `Open` + // let (io, _io2) = MockSubstream::negotiated().await; + // let mut codec = UviBytes::default(); + // codec.set_max_len(usize::MAX); + + // let notif_out = NotificationsOutOpen { + // handshake: b"hello, world".to_vec(), + // negotiated_fallback: None, + // substream: NotificationsOutSubstream::new(Framed::new(io, codec)), + // }; + // handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedOutbound( + // handler::FullyNegotiatedOutbound { protocol: notif_out, info: 0 }, + // )); + + // assert!(std::matches!( + // handler.protocols[0].state, + // State::Open { in_substream: Some(_), .. } + // )); + + // // remote now tries to open another substream, verify that it is rejected and closed + // let (io, mut io2) = MockSubstream::negotiated().await; + // let mut codec = UviBytes::default(); + // codec.set_max_len(usize::MAX); + // let notif_in = NotificationsInOpen { + // handshake: b"hello, world".to_vec(), + // negotiated_fallback: None, + // substream: NotificationsInSubstream::new( + // Framed::new(io, codec), + // NotificationsInSubstreamHandshake::NotSent, + // ), + // }; + // handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedInbound( + // handler::FullyNegotiatedInbound { protocol: (notif_in, 0), info: () }, + // )); + + // // verify that the new substream is rejected and closed but that the first substream is + // // still in correct state + // futures::future::poll_fn(|cx| { + // let mut buf = Vec::with_capacity(512); + + // if let Poll::Ready(Err(err)) = Pin::new(&mut io2).poll_read(cx, &mut buf) { + // assert_eq!(err.kind(), std::io::ErrorKind::UnexpectedEof); + // } else { + // panic!("unexpected result"); + // } + + // Poll::Ready(()) + // }) + // .await; + // assert!(std::matches!( + // handler.protocols[0].state, + // State::Open { in_substream: Some(_), .. } + // )); + // } + + // #[tokio::test] + // async fn fully_negotiated_resets_state_for_closed_substream() { + // let mut handler = notifs_handler(); + // let (io, mut io2) = MockSubstream::negotiated().await; + // let mut codec = UviBytes::default(); + // codec.set_max_len(usize::MAX); + + // let notif_in = NotificationsInOpen { + // handshake: b"hello, world".to_vec(), + // negotiated_fallback: None, + // substream: NotificationsInSubstream::new( + // Framed::new(io, codec), + // NotificationsInSubstreamHandshake::NotSent, + // ), + // }; + // handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedInbound( + // handler::FullyNegotiatedInbound { protocol: (notif_in, 0), info: () }, + // )); + + // // verify that the substream is in (partly) opened state + // assert!(std::matches!(handler.protocols[0].state, State::OpenDesiredByRemote { .. })); + // futures::future::poll_fn(|cx| { + // let mut buf = Vec::with_capacity(512); + // assert!(std::matches!(Pin::new(&mut io2).poll_read(cx, &mut buf), Poll::Pending)); + // Poll::Ready(()) + // }) + // .await; + + // // first instruct the handler to open a connection and then close it right after + // // so the handler is in state `Closed { pending_opening: true }` + // handler.on_behaviour_event(NotifsHandlerIn::Open { protocol_index: 0 }); + // assert!(std::matches!( + // handler.protocols[0].state, + // State::Opening { in_substream: Some(_) } + // )); + + // handler.on_behaviour_event(NotifsHandlerIn::Close { protocol_index: 0 }); + // assert!(std::matches!(handler.protocols[0].state, State::Closed { pending_opening: true })); + + // // verify that if the the outbound substream is successfully negotiated, the state is not + // // changed as the substream was commanded to be closed by the handler. + // let (io, _io2) = MockSubstream::negotiated().await; + // let mut codec = UviBytes::default(); + // codec.set_max_len(usize::MAX); + + // let notif_out = NotificationsOutOpen { + // handshake: b"hello, world".to_vec(), + // negotiated_fallback: None, + // substream: NotificationsOutSubstream::new(Framed::new(io, codec)), + // }; + // handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedOutbound( + // handler::FullyNegotiatedOutbound { protocol: notif_out, info: 0 }, + // )); + + // assert!(std::matches!( + // handler.protocols[0].state, + // State::Closed { pending_opening: false } + // )); + // } + + // #[tokio::test] + // async fn fully_negotiated_resets_state_for_open_desired_substream() { + // let mut handler = notifs_handler(); + // let (io, mut io2) = MockSubstream::negotiated().await; + // let mut codec = UviBytes::default(); + // codec.set_max_len(usize::MAX); + + // let notif_in = NotificationsInOpen { + // handshake: b"hello, world".to_vec(), + // negotiated_fallback: None, + // substream: NotificationsInSubstream::new( + // Framed::new(io, codec), + // NotificationsInSubstreamHandshake::NotSent, + // ), + // }; + // handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedInbound( + // handler::FullyNegotiatedInbound { protocol: (notif_in, 0), info: () }, + // )); + + // // verify that the substream is in (partly) opened state + // assert!(std::matches!(handler.protocols[0].state, State::OpenDesiredByRemote { .. })); + // futures::future::poll_fn(|cx| { + // let mut buf = Vec::with_capacity(512); + // assert!(std::matches!(Pin::new(&mut io2).poll_read(cx, &mut buf), Poll::Pending)); + // Poll::Ready(()) + // }) + // .await; + + // // first instruct the handler to open a connection and then close it right after + // // so the handler is in state `Closed { pending_opening: true }` + // handler.on_behaviour_event(NotifsHandlerIn::Open { protocol_index: 0 }); + // assert!(std::matches!( + // handler.protocols[0].state, + // State::Opening { in_substream: Some(_) } + // )); + + // handler.on_behaviour_event(NotifsHandlerIn::Close { protocol_index: 0 }); + // assert!(std::matches!(handler.protocols[0].state, State::Closed { pending_opening: true })); + + // // attempt to open another inbound substream and verify that it is rejected + // let (io, _io2) = MockSubstream::negotiated().await; + // let mut codec = UviBytes::default(); + // codec.set_max_len(usize::MAX); + + // let notif_in = NotificationsInOpen { + // handshake: b"hello, world".to_vec(), + // negotiated_fallback: None, + // substream: NotificationsInSubstream::new( + // Framed::new(io, codec), + // NotificationsInSubstreamHandshake::NotSent, + // ), + // }; + // handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedInbound( + // handler::FullyNegotiatedInbound { protocol: (notif_in, 0), info: () }, + // )); + + // assert!(std::matches!( + // handler.protocols[0].state, + // State::OpenDesiredByRemote { pending_opening: true, .. } + // )); + + // // verify that if the the outbound substream is successfully negotiated, the state is not + // // changed as the substream was commanded to be closed by the handler. + // let (io, _io2) = MockSubstream::negotiated().await; + // let mut codec = UviBytes::default(); + // codec.set_max_len(usize::MAX); + + // let notif_out = NotificationsOutOpen { + // handshake: b"hello, world".to_vec(), + // negotiated_fallback: None, + // substream: NotificationsOutSubstream::new(Framed::new(io, codec)), + // }; + + // handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedOutbound( + // handler::FullyNegotiatedOutbound { protocol: notif_out, info: 0 }, + // )); + + // assert!(std::matches!( + // handler.protocols[0].state, + // State::OpenDesiredByRemote { pending_opening: false, .. } + // )); + // } + + // #[tokio::test] + // async fn dial_upgrade_error_resets_closed_outbound_state() { + // let mut handler = notifs_handler(); + // let (io, mut io2) = MockSubstream::negotiated().await; + // let mut codec = UviBytes::default(); + // codec.set_max_len(usize::MAX); + + // let notif_in = NotificationsInOpen { + // handshake: b"hello, world".to_vec(), + // negotiated_fallback: None, + // substream: NotificationsInSubstream::new( + // Framed::new(io, codec), + // NotificationsInSubstreamHandshake::NotSent, + // ), + // }; + // handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedInbound( + // handler::FullyNegotiatedInbound { protocol: (notif_in, 0), info: () }, + // )); + + // // verify that the substream is in (partly) opened state + // assert!(std::matches!(handler.protocols[0].state, State::OpenDesiredByRemote { .. })); + // futures::future::poll_fn(|cx| { + // let mut buf = Vec::with_capacity(512); + // assert!(std::matches!(Pin::new(&mut io2).poll_read(cx, &mut buf), Poll::Pending)); + // Poll::Ready(()) + // }) + // .await; + + // // first instruct the handler to open a connection and then close it right after + // // so the handler is in state `Closed { pending_opening: true }` + // handler.on_behaviour_event(NotifsHandlerIn::Open { protocol_index: 0 }); + // assert!(std::matches!( + // handler.protocols[0].state, + // State::Opening { in_substream: Some(_) } + // )); + + // handler.on_behaviour_event(NotifsHandlerIn::Close { protocol_index: 0 }); + // assert!(std::matches!(handler.protocols[0].state, State::Closed { pending_opening: true })); + + // // inject dial failure to an already closed substream and verify outbound state is reset + // handler.on_connection_event(handler::ConnectionEvent::DialUpgradeError( + // handler::DialUpgradeError { info: 0, error: StreamUpgradeError::Timeout }, + // )); + // assert!(std::matches!( + // handler.protocols[0].state, + // State::Closed { pending_opening: false } + // )); + // } + + // #[tokio::test] + // async fn dial_upgrade_error_resets_open_desired_state() { + // let mut handler = notifs_handler(); + // let (io, mut io2) = MockSubstream::negotiated().await; + // let mut codec = UviBytes::default(); + // codec.set_max_len(usize::MAX); + + // let notif_in = NotificationsInOpen { + // handshake: b"hello, world".to_vec(), + // negotiated_fallback: None, + // substream: NotificationsInSubstream::new( + // Framed::new(io, codec), + // NotificationsInSubstreamHandshake::NotSent, + // ), + // }; + // handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedInbound( + // handler::FullyNegotiatedInbound { protocol: (notif_in, 0), info: () }, + // )); + + // // verify that the substream is in (partly) opened state + // assert!(std::matches!(handler.protocols[0].state, State::OpenDesiredByRemote { .. })); + // futures::future::poll_fn(|cx| { + // let mut buf = Vec::with_capacity(512); + // assert!(std::matches!(Pin::new(&mut io2).poll_read(cx, &mut buf), Poll::Pending)); + // Poll::Ready(()) + // }) + // .await; + + // // first instruct the handler to open a connection and then close it right after + // // so the handler is in state `Closed { pending_opening: true }` + // handler.on_behaviour_event(NotifsHandlerIn::Open { protocol_index: 0 }); + // assert!(std::matches!( + // handler.protocols[0].state, + // State::Opening { in_substream: Some(_) } + // )); + + // handler.on_behaviour_event(NotifsHandlerIn::Close { protocol_index: 0 }); + // assert!(std::matches!(handler.protocols[0].state, State::Closed { pending_opening: true })); + + // let (io, _io2) = MockSubstream::negotiated().await; + // let mut codec = UviBytes::default(); + // codec.set_max_len(usize::MAX); + + // let notif_in = NotificationsInOpen { + // handshake: b"hello, world".to_vec(), + // negotiated_fallback: None, + // substream: NotificationsInSubstream::new( + // Framed::new(io, codec), + // NotificationsInSubstreamHandshake::NotSent, + // ), + // }; + // handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedInbound( + // handler::FullyNegotiatedInbound { protocol: (notif_in, 0), info: () }, + // )); + + // assert!(std::matches!( + // handler.protocols[0].state, + // State::OpenDesiredByRemote { pending_opening: true, .. } + // )); + + // // inject dial failure to an already closed substream and verify outbound state is reset + // handler.on_connection_event(handler::ConnectionEvent::DialUpgradeError( + // handler::DialUpgradeError { info: 0, error: StreamUpgradeError::Timeout }, + // )); + // assert!(std::matches!( + // handler.protocols[0].state, + // State::OpenDesiredByRemote { pending_opening: false, .. } + // )); + // } + + // #[tokio::test] + // async fn sync_notifications_clogged() { + // let mut handler = notifs_handler(); + // let (io, _) = MockSubstream::negotiated().await; + // let codec = UviBytes::default(); + + // let (async_tx, async_rx) = futures::channel::mpsc::channel(ASYNC_NOTIFICATIONS_BUFFER_SIZE); + // let (sync_tx, sync_rx) = futures::channel::mpsc::channel(1); + // let notifications_sink = NotificationsSink { + // inner: Arc::new(NotificationsSinkInner { + // peer_id: PeerId::random(), + // async_channel: FuturesMutex::new(async_tx), + // sync_channel: Mutex::new(Some(sync_tx)), + // }), + // }; + + // handler.protocols[0].state = State::Open { + // notifications_sink_rx: stream::select(async_rx.fuse(), sync_rx.fuse()).peekable(), + // out_substream: Some(NotificationsOutSubstream::new(Framed::new(io, codec))), + // in_substream: None, + // }; + + // notifications_sink.send_sync_notification(vec![1, 3, 3, 7]); + // notifications_sink.send_sync_notification(vec![1, 3, 3, 8]); + // notifications_sink.send_sync_notification(vec![1, 3, 3, 9]); + // notifications_sink.send_sync_notification(vec![1, 3, 4, 0]); + + // futures::future::poll_fn(|cx| { + // assert!(std::matches!( + // handler.poll(cx), + // Poll::Ready(ConnectionHandlerEvent::Close( + // NotifsHandlerError::SyncNotificationsClogged, + // )) + // )); + // Poll::Ready(()) + // }) + // .await; + // } + + // #[tokio::test] + // async fn close_desired_by_remote() { + // let mut handler = notifs_handler(); + // let (io, io2) = MockSubstream::negotiated().await; + // let mut codec = UviBytes::default(); + // codec.set_max_len(usize::MAX); + + // let notif_in = NotificationsInOpen { + // handshake: b"hello, world".to_vec(), + // negotiated_fallback: None, + // substream: NotificationsInSubstream::new( + // Framed::new(io, codec), + // NotificationsInSubstreamHandshake::PendingSend(vec![1, 2, 3, 4]), + // ), + // }; + + // // add new inbound substream but close it immediately and verify that correct events are + // // emitted + // handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedInbound( + // handler::FullyNegotiatedInbound { protocol: (notif_in, 0), info: () }, + // )); + // drop(io2); + + // futures::future::poll_fn(|cx| { + // assert!(std::matches!( + // handler.poll(cx), + // Poll::Ready(ConnectionHandlerEvent::NotifyBehaviour( + // NotifsHandlerOut::OpenDesiredByRemote { protocol_index: 0 }, + // )) + // )); + // assert!(std::matches!( + // handler.poll(cx), + // Poll::Ready(ConnectionHandlerEvent::NotifyBehaviour( + // NotifsHandlerOut::CloseDesired { protocol_index: 0 }, + // )) + // )); + // Poll::Ready(()) + // }) + // .await; + // } } diff --git a/client/network/src/protocol/notifications/upgrade/notifications.rs b/client/network/src/protocol/notifications/upgrade/notifications.rs index 83228f33b8160..0148fd22bd883 100644 --- a/client/network/src/protocol/notifications/upgrade/notifications.rs +++ b/client/network/src/protocol/notifications/upgrade/notifications.rs @@ -114,13 +114,6 @@ pub struct NotificationsOutSubstream { socket: Framed>>>, } -#[cfg(test)] -impl NotificationsOutSubstream { - pub fn new(socket: Framed>>>) -> Self { - Self { socket } - } -} - impl NotificationsIn { /// Builds a new potential upgrade. pub fn new( @@ -203,13 +196,13 @@ impl NotificationsInSubstream where TSubstream: AsyncRead + AsyncWrite + Unpin, { - #[cfg(test)] - pub fn new( - socket: Framed>>>, - handshake: NotificationsInSubstreamHandshake, - ) -> Self { - Self { socket, handshake } - } + // #[cfg(test)] + // pub fn new( + // socket: Framed>>>, + // handshake: NotificationsInSubstreamHandshake, + // ) -> Self { + // Self { socket, handshake } + // } /// Sends the handshake in order to inform the remote that we accept the substream. pub fn send_handshake(&mut self, message: impl Into>) { From 07f2db8f0e7a87a51077371b4fdf111548f73a8d Mon Sep 17 00:00:00 2001 From: Anton Kaliaev Date: Thu, 6 Jul 2023 14:10:47 +0400 Subject: [PATCH 29/42] add a fixme --- client/network/src/protocol/notifications/handler.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/client/network/src/protocol/notifications/handler.rs b/client/network/src/protocol/notifications/handler.rs index 337c39e5f94ff..95a5e92e4ec9a 100644 --- a/client/network/src/protocol/notifications/handler.rs +++ b/client/network/src/protocol/notifications/handler.rs @@ -1012,6 +1012,8 @@ pub mod tests { } } + // FIXME: find a way to rewrite these tests. + // /// Create new [`NotifsHandler`]. // fn notifs_handler() -> NotifsHandler { // let proto = Protocol { From b25efe58d97b6b7a560df05742b3f621701b47f2 Mon Sep 17 00:00:00 2001 From: Anton Kaliaev Date: Fri, 7 Jul 2023 10:10:11 +0400 Subject: [PATCH 30/42] update Cargo.lock --- Cargo.lock | 1617 +++++++++------------------------------------------- 1 file changed, 283 insertions(+), 1334 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fe67e1bec2df0..9bacfe0b25cdf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -27,15 +27,6 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" -[[package]] -name = "aead" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fc95d1bdb8e6666b2b217308eeeb09f2d6728d104be3e31916cc74d15420331" -dependencies = [ - "generic-array 0.14.7", -] - [[package]] name = "aead" version = "0.4.3" @@ -43,28 +34,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b613b8e1e3cf911a086f53f03bf286f52fd7a7258e4fa606f0ef220d39d8877" dependencies = [ "generic-array 0.14.7", - "rand_core 0.6.4", -] - -[[package]] -name = "aead" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d122413f284cf2d62fb1b7db97e02edb8cda96d769b16e443a4f6195e35662b0" -dependencies = [ - "crypto-common", - "generic-array 0.14.7", -] - -[[package]] -name = "aes" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "884391ef1066acaa41e766ba8f596341b96e93ce34f9a43e7d24bf0a0eaf0561" -dependencies = [ - "aes-soft", - "aesni", - "cipher 0.2.5", ] [[package]] @@ -74,70 +43,25 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9e8b47f52ea9bae42228d07ec09eb676433d7c4ed1ebdf0f1d1c29ed446f1ab8" dependencies = [ "cfg-if", - "cipher 0.3.0", + "cipher", "cpufeatures", "opaque-debug 0.3.0", ] -[[package]] -name = "aes" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "433cfd6710c9986c576a25ca913c39d66a6474107b406f34f91d4a8923395241" -dependencies = [ - "cfg-if", - "cipher 0.4.4", - "cpufeatures", -] - [[package]] name = "aes-gcm" version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "df5f85a83a7d8b0442b6aa7b504b8212c1733da07b98aae43d4bc21b2cb3cdf6" dependencies = [ - "aead 0.4.3", - "aes 0.7.5", - "cipher 0.3.0", - "ctr 0.8.0", - "ghash 0.4.4", + "aead", + "aes", + "cipher", + "ctr", + "ghash", "subtle", ] -[[package]] -name = "aes-gcm" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "209b47e8954a928e1d72e86eca7000ebb6655fe1436d33eefc2201cad027e237" -dependencies = [ - "aead 0.5.2", - "aes 0.8.2", - "cipher 0.4.4", - "ctr 0.9.2", - "ghash 0.5.0", - "subtle", -] - -[[package]] -name = "aes-soft" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be14c7498ea50828a38d0e24a765ed2effe92a705885b57d029cd67d45744072" -dependencies = [ - "cipher 0.2.5", - "opaque-debug 0.3.0", -] - -[[package]] -name = "aesni" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea2e11f5e94c2f7d386164cc2aa1f97823fed6f259e486940a71c174dd01b0ce" -dependencies = [ - "cipher 0.2.5", - "opaque-debug 0.3.0", -] - [[package]] name = "ahash" version = "0.7.6" @@ -279,12 +203,6 @@ version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2d098ff73c1ca148721f37baad5ea6a465a13f9573aba8641fbbbae8164a54e" -[[package]] -name = "arc-swap" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bddcadddf5e9015d310179a59bb28c4d4b9920ad0f11e8e14dbadf654890c9a6" - [[package]] name = "ark-algebra-test-templates" version = "0.4.2" @@ -302,7 +220,7 @@ dependencies = [ "serde", "serde_derive", "serde_json", - "sha2 0.10.6", + "sha2 0.10.7", ] [[package]] @@ -531,76 +449,9 @@ checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" [[package]] name = "arrayvec" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8da52d66c7071e2e3fa2a1e5c6d088fec47b593032b254f5e980de8ea54454d6" - -[[package]] -name = "asn1-rs" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30ff05a702273012438132f449575dbc804e27b2f3cbe3069aa237d26c98fa33" -dependencies = [ - "asn1-rs-derive 0.1.0", - "asn1-rs-impl", - "displaydoc", - "nom", - "num-traits", - "rusticata-macros", - "thiserror", - "time 0.3.21", -] - -[[package]] -name = "asn1-rs" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f6fd5ddaf0351dff5b8da21b2fb4ff8e08ddd02857f0bf69c47639106c0fff0" -dependencies = [ - "asn1-rs-derive 0.4.0", - "asn1-rs-impl", - "displaydoc", - "nom", - "num-traits", - "rusticata-macros", - "thiserror", - "time 0.3.21", -] - -[[package]] -name = "asn1-rs-derive" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db8b7511298d5b7784b40b092d9e9dcd3a627a5707e4b5e507931ab0d44eeebf" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", - "synstructure", -] - -[[package]] -name = "asn1-rs-derive" -version = "0.4.0" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "726535892e8eae7e70657b4c8ea93d26b8553afb1ce617caee529ef96d7dee6c" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", - "synstructure", -] - -[[package]] -name = "asn1-rs-impl" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2777730b2039ac0f95f093556e61b6d26cebed5393ca6f152717777cec3a42ed" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] +checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" [[package]] name = "assert_cmd" @@ -650,7 +501,7 @@ dependencies = [ "polling", "rustix 0.37.19", "slab", - "socket2", + "socket2 0.4.9", "waker-fn", ] @@ -720,12 +571,6 @@ dependencies = [ "pin-project-lite 0.2.9", ] -[[package]] -name = "atomic-waker" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1181e1e0d1fce796a03db1ae795d67167da795f9cf4a39c37589e85ef57f26d3" - [[package]] name = "atty" version = "0.2.14" @@ -764,12 +609,6 @@ version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4cbbc9d0964165b47557570cce6c952866c2678457aca742aafc9fb771d30270" -[[package]] -name = "base16ct" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "349a06037c7bf932dd7e7d1f653678b2038b9ad46a74102f1fc7bd7872678cce" - [[package]] name = "base16ct" version = "0.2.0" @@ -888,7 +727,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c2f0dc9a68c6317d884f97cc36cf5a3d20ba14ce404227df55e1af708ab04bc" dependencies = [ "arrayref", - "arrayvec 0.7.2", + "arrayvec 0.7.4", "constant_time_eq", ] @@ -899,7 +738,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6637f448b9e61dfadbdcbae9a885fadee1f3eaffb1f8d3c1965d3ade8bdfd44f" dependencies = [ "arrayref", - "arrayvec 0.7.2", + "arrayvec 0.7.4", "constant_time_eq", ] @@ -910,10 +749,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42ae2468a89544a466886840aa467a25b766499f4f04bf7d9fcd10ecee9fccef" dependencies = [ "arrayref", - "arrayvec 0.7.2", + "arrayvec 0.7.4", "cc", "cfg-if", "constant_time_eq", + "digest 0.10.7", ] [[package]] @@ -922,7 +762,7 @@ version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b" dependencies = [ - "block-padding 0.1.5", + "block-padding", "byte-tools", "byteorder", "generic-array 0.12.4", @@ -946,16 +786,6 @@ dependencies = [ "generic-array 0.14.7", ] -[[package]] -name = "block-modes" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57a0e8073e8baa88212fb5823574c02ebccb395136ba9a164ab89379ec6072f0" -dependencies = [ - "block-padding 0.2.1", - "cipher 0.2.5", -] - [[package]] name = "block-padding" version = "0.1.5" @@ -965,12 +795,6 @@ dependencies = [ "byte-tools", ] -[[package]] -name = "block-padding" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d696c370c750c948ada61c69a0ee2cbbb9c50b1019ddb86d9317157a99c2cae" - [[package]] name = "bounded-collections" version = "0.1.8" @@ -989,6 +813,15 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "771fe0050b883fcc3ea2359b1a96bcfbc090b7116eae7c3c512c7a083fdf23d3" +[[package]] +name = "bs58" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f5353f36341f7451062466f0b755b96ac3a9547e4d7f6b70d603fc721a7d7896" +dependencies = [ + "tinyvec", +] + [[package]] name = "bstr" version = "1.5.0" @@ -1104,17 +937,6 @@ dependencies = [ "jobserver", ] -[[package]] -name = "ccm" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aca1a8fbc20b50ac9673ff014abfb2b5f4085ee1a850d408f14a159c5853ac7" -dependencies = [ - "aead 0.3.2", - "cipher 0.2.5", - "subtle", -] - [[package]] name = "cexpr" version = "0.6.0" @@ -1152,7 +974,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5c80e5460aa66fe3b91d40bcbdab953a597b60053e34d684ac6903f863b680a6" dependencies = [ "cfg-if", - "cipher 0.3.0", + "cipher", "cpufeatures", "zeroize", ] @@ -1163,9 +985,9 @@ version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a18446b09be63d457bbec447509e85f662f32952b035ce892290396bc0b0cff5" dependencies = [ - "aead 0.4.3", + "aead", "chacha20", - "cipher 0.3.0", + "cipher", "poly1305", "zeroize", ] @@ -1194,7 +1016,7 @@ dependencies = [ "iana-time-zone", "js-sys", "num-traits", - "time 0.1.45", + "time", "wasm-bindgen", "winapi", ] @@ -1234,20 +1056,11 @@ checksum = "b9b68e3193982cd54187d71afdb2a271ad4cf8af157858e9cb911b91321de143" dependencies = [ "core2", "multibase", - "multihash", + "multihash 0.17.0", "serde", "unsigned-varint", ] -[[package]] -name = "cipher" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12f8e7987cbd042a63249497f41aed09f8e65add917ea6566effbc56578d6801" -dependencies = [ - "generic-array 0.14.7", -] - [[package]] name = "cipher" version = "0.3.0" @@ -1257,16 +1070,6 @@ dependencies = [ "generic-array 0.14.7", ] -[[package]] -name = "cipher" -version = "0.4.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad" -dependencies = [ - "crypto-common", - "inout", -] - [[package]] name = "ckb-merkle-mountain-range" version = "0.5.2" @@ -1573,21 +1376,6 @@ dependencies = [ "wasmtime-types", ] -[[package]] -name = "crc" -version = "3.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86ec7a15cbe22e59248fc7eadb1907dab5ba09372595da4d73dd805ed4417dfe" -dependencies = [ - "crc-catalog", -] - -[[package]] -name = "crc-catalog" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cace84e55f07e7301bae1c519df89cdad8cc3cd868413d3fdbdeca9ff3db484" - [[package]] name = "crc32fast" version = "1.3.2" @@ -1684,18 +1472,6 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" -[[package]] -name = "crypto-bigint" -version = "0.4.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef2b4b23cddf68b89b8f8069890e8c270d54e2d5fe1b143820234805e4cb17ef" -dependencies = [ - "generic-array 0.14.7", - "rand_core 0.6.4", - "subtle", - "zeroize", -] - [[package]] name = "crypto-bigint" version = "0.5.2" @@ -1715,7 +1491,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" dependencies = [ "generic-array 0.14.7", - "rand_core 0.6.4", "typenum", ] @@ -1755,16 +1530,7 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "049bb91fb4aaf0e3c7efa6cd5ef877dbbbd15b39dad06d9948de4ec8a75761ea" dependencies = [ - "cipher 0.3.0", -] - -[[package]] -name = "ctr" -version = "0.9.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0369ee1ad671834580515889b80f2ea915f23b8be8d0daa4bbaf2ac5c7590835" -dependencies = [ - "cipher 0.4.4", + "cipher", ] [[package]] @@ -1851,41 +1617,6 @@ dependencies = [ "syn 2.0.18", ] -[[package]] -name = "darling" -version = "0.14.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b750cb3417fd1b327431a470f388520309479ab0bf5e323505daf0290cd3850" -dependencies = [ - "darling_core", - "darling_macro", -] - -[[package]] -name = "darling_core" -version = "0.14.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "109c1ca6e6b7f82cc233a97004ea8ed7ca123a9af07a8230878fcfda9b158bf0" -dependencies = [ - "fnv", - "ident_case", - "proc-macro2", - "quote", - "strsim", - "syn 1.0.109", -] - -[[package]] -name = "darling_macro" -version = "0.14.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4aab4dbc9f7611d8b55048a3a16d2d010c2c8334e46304b40ac1cc14bf3b48e" -dependencies = [ - "darling_core", - "quote", - "syn 1.0.109", -] - [[package]] name = "data-encoding" version = "2.4.0" @@ -1912,17 +1643,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "der" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1a467a65c5e759bce6e65eaf91cc29f466cdc57cb65777bd646872a8a1fd4de" -dependencies = [ - "const-oid", - "pem-rfc7468", - "zeroize", -] - [[package]] name = "der" version = "0.7.6" @@ -1933,34 +1653,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "der-parser" -version = "7.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe398ac75057914d7d07307bf67dc7f3f574a26783b4fc7805a20ffa9f506e82" -dependencies = [ - "asn1-rs 0.3.1", - "displaydoc", - "nom", - "num-bigint", - "num-traits", - "rusticata-macros", -] - -[[package]] -name = "der-parser" -version = "8.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbd676fbbab537128ef0278adb5576cf363cff6aa22a7b24effe97347cfab61e" -dependencies = [ - "asn1-rs 0.5.2", - "displaydoc", - "nom", - "num-bigint", - "num-traits", - "rusticata-macros", -] - [[package]] name = "derivative" version = "2.2.0" @@ -1983,37 +1675,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "derive_builder" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d07adf7be193b71cc36b193d0f5fe60b918a3a9db4dad0449f57bcfd519704a3" -dependencies = [ - "derive_builder_macro", -] - -[[package]] -name = "derive_builder_core" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f91d4cfa921f1c05904dc3c57b4a32c38aed3340cce209f3a6fd1478babafc4" -dependencies = [ - "darling", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "derive_builder_macro" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f0314b72bed045f3a68671b3c86328386762c93f82d98c65c3cb5e5f573dd68" -dependencies = [ - "derive_builder_core", - "syn 1.0.109", -] - [[package]] name = "derive_more" version = "0.99.17" @@ -2108,17 +1769,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "displaydoc" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.18", -] - [[package]] name = "dissimilar" version = "1.0.6" @@ -2203,30 +1853,18 @@ version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "68b0cf012f1230e43cd00ebb729c6bb58707ecfa8ad08b52ef3a4ccd2697fc30" -[[package]] -name = "ecdsa" -version = "0.14.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "413301934810f597c1d19ca71c8710e99a3f1ba28a0d2ebc01551a2daeea3c5c" -dependencies = [ - "der 0.6.1", - "elliptic-curve 0.12.3", - "rfc6979 0.3.1", - "signature 1.6.4", -] - [[package]] name = "ecdsa" version = "0.16.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0997c976637b606099b9985693efa3581e84e41f5c11ba5255f88711058ad428" dependencies = [ - "der 0.7.6", + "der", "digest 0.10.7", - "elliptic-curve 0.13.5", - "rfc6979 0.4.0", + "elliptic-curve", + "rfc6979", "signature 2.1.0", - "spki 0.7.2", + "spki", ] [[package]] @@ -2272,43 +1910,21 @@ version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91" -[[package]] -name = "elliptic-curve" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7bb888ab5300a19b8e5bceef25ac745ad065f3c9f7efc6de1b91958110891d3" -dependencies = [ - "base16ct 0.1.1", - "crypto-bigint 0.4.9", - "der 0.6.1", - "digest 0.10.7", - "ff 0.12.1", - "generic-array 0.14.7", - "group 0.12.1", - "hkdf", - "pem-rfc7468", - "pkcs8 0.9.0", - "rand_core 0.6.4", - "sec1 0.3.0", - "subtle", - "zeroize", -] - [[package]] name = "elliptic-curve" version = "0.13.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "968405c8fdc9b3bf4df0a6638858cc0b52462836ab6b1c87377785dd09cf1c0b" dependencies = [ - "base16ct 0.2.0", - "crypto-bigint 0.5.2", + "base16ct", + "crypto-bigint", "digest 0.10.7", - "ff 0.13.0", + "ff", "generic-array 0.14.7", - "group 0.13.0", - "pkcs8 0.10.2", + "group", + "pkcs8", "rand_core 0.6.4", - "sec1 0.7.2", + "sec1", "subtle", "zeroize", ] @@ -2462,16 +2078,6 @@ dependencies = [ "libc", ] -[[package]] -name = "ff" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d013fc25338cc558c5c2cfbad646908fb23591e2404481826742b651c9af7160" -dependencies = [ - "rand_core 0.6.4", - "subtle", -] - [[package]] name = "ff" version = "0.13.0" @@ -2552,7 +2158,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3b9429470923de8e8cbd4d2dc513535400b4b3fef0319fb5c4e1f520a7bef743" dependencies = [ "crc32fast", - "libz-sys", "miniz_oxide 0.7.1", ] @@ -3101,7 +2706,7 @@ checksum = "d2411eed028cdf8c8034eaf21f9915f956b6c3abec4d4c7949ee67f0721127bd" dependencies = [ "futures-io", "rustls 0.20.8", - "webpki 0.22.0", + "webpki", ] [[package]] @@ -3222,17 +2827,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1583cc1656d7839fd3732b80cf4f38850336cdb9b8ded1cd399ca62958de3c99" dependencies = [ "opaque-debug 0.3.0", - "polyval 0.5.3", -] - -[[package]] -name = "ghash" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d930750de5717d2dd0b8c0d42c076c0e884c81a73e6cab859bbd2339c71e3e40" -dependencies = [ - "opaque-debug 0.3.0", - "polyval 0.6.0", + "polyval", ] [[package]] @@ -3265,24 +2860,13 @@ dependencies = [ "regex", ] -[[package]] -name = "group" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5dfbfb3a6cfbd390d5c9564ab283a0349b9b9fcd46a706c1eb10e0db70bfbac7" -dependencies = [ - "ff 0.12.1", - "rand_core 0.6.4", - "subtle", -] - [[package]] name = "group" version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" dependencies = [ - "ff 0.13.0", + "ff", "rand_core 0.6.4", "subtle", ] @@ -3401,15 +2985,6 @@ version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ebdb29d2ea9ed0083cd8cece49bbd968021bd99b0849edb4a9a7ee0fdf6a4e0" -[[package]] -name = "hkdf" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "791a029f6b9fc27657f6f188ec6e5e43f6911f6f878e0dc5501396e09809d437" -dependencies = [ - "hmac 0.12.1", -] - [[package]] name = "hmac" version = "0.8.1" @@ -3536,7 +3111,7 @@ dependencies = [ "httpdate", "itoa", "pin-project-lite 0.2.9", - "socket2", + "socket2 0.4.9", "tokio", "tower-service", "tracing", @@ -3556,7 +3131,7 @@ dependencies = [ "rustls-native-certs", "tokio", "tokio-rustls 0.23.4", - "webpki-roots", + "webpki-roots 0.22.6", ] [[package]] @@ -3597,12 +3172,6 @@ dependencies = [ "cc", ] -[[package]] -name = "ident_case" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" - [[package]] name = "idna" version = "0.2.3" @@ -3723,15 +3292,6 @@ dependencies = [ "unicode-width", ] -[[package]] -name = "inout" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0c10553d664a4d0bcff9f4215d0aac67a639cc68ef660840afe309b807bc9f5" -dependencies = [ - "generic-array 0.14.7", -] - [[package]] name = "instant" version = "0.1.12" @@ -3750,25 +3310,6 @@ dependencies = [ "num-traits", ] -[[package]] -name = "interceptor" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e8a11ae2da61704edada656798b61c94b35ecac2c58eb955156987d5e6be90b" -dependencies = [ - "async-trait", - "bytes", - "log", - "rand 0.8.5", - "rtcp", - "rtp", - "thiserror", - "tokio", - "waitgroup", - "webrtc-srtp", - "webrtc-util", -] - [[package]] name = "intx" version = "0.1.0" @@ -3798,7 +3339,7 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bd302af1b90f2463a98fa5ad469fc212c8e3175a41c3068601bfa2727591c5be" dependencies = [ - "socket2", + "socket2 0.4.9", "widestring", "winapi", "winreg", @@ -3888,7 +3429,7 @@ dependencies = [ "tokio-rustls 0.23.4", "tokio-util", "tracing", - "webpki-roots", + "webpki-roots 0.22.6", ] [[package]] @@ -3898,7 +3439,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a4e70b4439a751a5de7dd5ed55eacff78ebf4ffe0fc009cb1ebb11417f5b536b" dependencies = [ "anyhow", - "arrayvec 0.7.2", + "arrayvec 0.7.4", "async-lock", "async-trait", "beef", @@ -4006,10 +3547,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cadb76004ed8e97623117f3df85b17aaa6626ab0b0831e6573f104df16cd1bcc" dependencies = [ "cfg-if", - "ecdsa 0.16.7", - "elliptic-curve 0.13.5", + "ecdsa", + "elliptic-curve", "once_cell", - "sha2 0.10.6", + "sha2 0.10.7", ] [[package]] @@ -4222,9 +3763,9 @@ checksum = "f7012b1bbb0719e1097c47611d3898568c546d597c2e74d66f6087edd5233ff4" [[package]] name = "libp2p" -version = "0.51.3" +version = "0.52.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f210d259724eae82005b5c48078619b7745edb7b76de370b03f8ba59ea103097" +checksum = "38039ba2df4f3255842050845daef4a004cc1f26da03dbc645535088b51910ef" dependencies = [ "bytes", "futures", @@ -4242,12 +3783,10 @@ dependencies = [ "libp2p-metrics", "libp2p-noise", "libp2p-ping", - "libp2p-quic", "libp2p-request-response", "libp2p-swarm", "libp2p-tcp", "libp2p-wasm-ext", - "libp2p-webrtc", "libp2p-websocket", "libp2p-yamux", "multiaddr", @@ -4256,9 +3795,9 @@ dependencies = [ [[package]] name = "libp2p-allow-block-list" -version = "0.1.1" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "510daa05efbc25184458db837f6f9a5143888f1caa742426d92e1833ddd38a50" +checksum = "55b46558c5c0bf99d3e2a1a38fd54ff5476ca66dd1737b12466a1824dd219311" dependencies = [ "libp2p-core", "libp2p-identity", @@ -4268,9 +3807,9 @@ dependencies = [ [[package]] name = "libp2p-connection-limits" -version = "0.1.0" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4caa33f1d26ed664c4fe2cca81a08c8e07d4c1c04f2f4ac7655c2dd85467fda0" +checksum = "d45dd90e8f0e1fa59e85ff5316dd4d1ac41a9a507e79cda1b0e9b7be43ad1a56" dependencies = [ "libp2p-core", "libp2p-identity", @@ -4280,9 +3819,9 @@ dependencies = [ [[package]] name = "libp2p-core" -version = "0.39.2" +version = "0.40.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c1df63c0b582aa434fb09b2d86897fa2b419ffeccf934b36f87fcedc8e835c2" +checksum = "ef7dd7b09e71aac9271c60031d0e558966cdb3253ba0308ab369bb2de80630d0" dependencies = [ "either", "fnv", @@ -4292,7 +3831,7 @@ dependencies = [ "libp2p-identity", "log", "multiaddr", - "multihash", + "multihash 0.19.0", "multistream-select", "once_cell", "parking_lot 0.12.1", @@ -4308,12 +3847,13 @@ dependencies = [ [[package]] name = "libp2p-dns" -version = "0.39.0" +version = "0.40.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "146ff7034daae62077c415c2376b8057368042df6ab95f5432ad5e88568b1554" +checksum = "fd4394c81c0c06d7b4a60f3face7e8e8a9b246840f98d2c80508d0721b032147" dependencies = [ "futures", "libp2p-core", + "libp2p-identity", "log", "parking_lot 0.12.1", "smallvec", @@ -4322,9 +3862,9 @@ dependencies = [ [[package]] name = "libp2p-identify" -version = "0.42.2" +version = "0.43.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5455f472243e63b9c497ff320ded0314254a9eb751799a39c283c6f20b793f3c" +checksum = "6a29675a32dbcc87790db6cf599709e64308f1ae9d5ecea2d259155889982db8" dependencies = [ "asynchronous-codec", "either", @@ -4344,29 +3884,28 @@ dependencies = [ [[package]] name = "libp2p-identity" -version = "0.1.2" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e2d584751cecb2aabaa56106be6be91338a60a0f4e420cf2af639204f596fc1" +checksum = "d2874d9c6575f1d7a151022af5c42bb0ffdcdfbafe0a6fd039de870b384835a2" dependencies = [ - "bs58", + "bs58 0.5.0", "ed25519-dalek", "log", - "multiaddr", - "multihash", + "multihash 0.19.0", "quick-protobuf", "rand 0.8.5", - "sha2 0.10.6", + "sha2 0.10.7", "thiserror", "zeroize", ] [[package]] name = "libp2p-kad" -version = "0.43.3" +version = "0.44.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39d5ef876a2b2323d63c258e63c2f8e36f205fe5a11f0b3095d59635650790ff" +checksum = "5588b884dcb1dadc04e49de342f634f60cf28b6beaaca5a4fe3dd1f09bb30041" dependencies = [ - "arrayvec 0.7.2", + "arrayvec 0.7.4", "asynchronous-codec", "bytes", "either", @@ -4380,7 +3919,7 @@ dependencies = [ "log", "quick-protobuf", "rand 0.8.5", - "sha2 0.10.6", + "sha2 0.10.7", "smallvec", "thiserror", "uint", @@ -4390,9 +3929,9 @@ dependencies = [ [[package]] name = "libp2p-mdns" -version = "0.43.1" +version = "0.44.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19983e1f949f979a928f2c603de1cf180cc0dc23e4ac93a62651ccb18341460b" +checksum = "42a2567c305232f5ef54185e9604579a894fd0674819402bb0ac0246da82f52a" dependencies = [ "data-encoding", "futures", @@ -4403,7 +3942,7 @@ dependencies = [ "log", "rand 0.8.5", "smallvec", - "socket2", + "socket2 0.5.3", "tokio", "trust-dns-proto", "void", @@ -4411,23 +3950,26 @@ dependencies = [ [[package]] name = "libp2p-metrics" -version = "0.12.0" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a42ec91e227d7d0dafa4ce88b333cdf5f277253873ab087555c92798db2ddd46" +checksum = "3787ea81798dcc5bf1d8b40a8e8245cf894b168d04dd70aa48cb3ff2fff141d2" dependencies = [ + "instant", "libp2p-core", "libp2p-identify", + "libp2p-identity", "libp2p-kad", "libp2p-ping", "libp2p-swarm", + "once_cell", "prometheus-client", ] [[package]] name = "libp2p-noise" -version = "0.42.2" +version = "0.43.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c3673da89d29936bc6435bafc638e2f184180d554ce844db65915113f86ec5e" +checksum = "87945db2b3f977af09b62b9aa0a5f3e4870995a577ecd845cdeba94cdf6bbca7" dependencies = [ "bytes", "curve25519-dalek 3.2.0", @@ -4435,61 +3977,42 @@ dependencies = [ "libp2p-core", "libp2p-identity", "log", + "multiaddr", + "multihash 0.19.0", "once_cell", "quick-protobuf", "rand 0.8.5", - "sha2 0.10.6", + "sha2 0.10.7", "snow", "static_assertions", "thiserror", - "x25519-dalek 1.1.1", + "x25519-dalek", "zeroize", ] [[package]] name = "libp2p-ping" -version = "0.42.0" +version = "0.43.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e57759c19c28a73ef1eb3585ca410cefb72c1a709fcf6de1612a378e4219202" +checksum = "3cd5ee3270229443a2b34b27ed0cb7470ef6b4a6e45e54e89a8771fa683bab48" dependencies = [ "either", "futures", "futures-timer", "instant", "libp2p-core", + "libp2p-identity", "libp2p-swarm", "log", "rand 0.8.5", "void", ] -[[package]] -name = "libp2p-quic" -version = "0.7.0-alpha.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6b26abd81cd2398382a1edfe739b539775be8a90fa6914f39b2ab49571ec735" -dependencies = [ - "bytes", - "futures", - "futures-timer", - "if-watch", - "libp2p-core", - "libp2p-identity", - "libp2p-tls", - "log", - "parking_lot 0.12.1", - "quinn-proto", - "rand 0.8.5", - "rustls 0.20.8", - "thiserror", - "tokio", -] - [[package]] name = "libp2p-request-response" -version = "0.24.1" +version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ffdb374267d42dc5ed5bc53f6e601d4a64ac5964779c6e40bb9e4f14c1e30d5" +checksum = "20bd837798cdcce4283d2675f08bcd3756a650d56eab4d4367e1b3f27eed6887" dependencies = [ "async-trait", "futures", @@ -4497,15 +4020,17 @@ dependencies = [ "libp2p-core", "libp2p-identity", "libp2p-swarm", + "log", "rand 0.8.5", "smallvec", + "void", ] [[package]] name = "libp2p-swarm" -version = "0.42.2" +version = "0.43.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "903b3d592d7694e56204d211f29d31bc004be99386644ba8731fc3e3ef27b296" +checksum = "a6f1fe3817492f88c5298c8b5fbaa5ff3a0c802ecf4e79be4e341cf07abfa82f" dependencies = [ "either", "fnv", @@ -4516,6 +4041,8 @@ dependencies = [ "libp2p-identity", "libp2p-swarm-derive", "log", + "multistream-select", + "once_cell", "rand 0.8.5", "smallvec", "tokio", @@ -4524,119 +4051,73 @@ dependencies = [ [[package]] name = "libp2p-swarm-derive" -version = "0.32.0" +version = "0.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fba456131824ab6acd4c7bf61e9c0f0a3014b5fc9868ccb8e10d344594cdc4f" +checksum = "c4d5ec2a3df00c7836d7696c136274c9c59705bac69133253696a6c932cd1d74" dependencies = [ "heck", + "proc-macro-warning", + "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.18", ] [[package]] name = "libp2p-tcp" -version = "0.39.0" +version = "0.40.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33d33698596d7722d85d3ab0c86c2c322254fce1241e91208e3679b4eb3026cf" +checksum = "09bfdfb6f945c5c014b87872a0bdb6e0aef90e92f380ef57cd9013f118f9289d" dependencies = [ "futures", "futures-timer", "if-watch", "libc", "libp2p-core", + "libp2p-identity", "log", - "socket2", + "socket2 0.5.3", "tokio", ] -[[package]] -name = "libp2p-tls" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff08d13d0dc66e5e9ba6279c1de417b84fa0d0adc3b03e5732928c180ec02781" -dependencies = [ - "futures", - "futures-rustls", - "libp2p-core", - "libp2p-identity", - "rcgen 0.10.0", - "ring", - "rustls 0.20.8", - "thiserror", - "webpki 0.22.0", - "x509-parser 0.14.0", - "yasna", -] - [[package]] name = "libp2p-wasm-ext" -version = "0.39.0" +version = "0.40.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77dff9d32353a5887adb86c8afc1de1a94d9e8c3bc6df8b2201d7cdf5c848f43" +checksum = "1e5d8e3a9e07da0ef5b55a9f26c009c8fb3c725d492d8bb4b431715786eea79c" dependencies = [ "futures", "js-sys", "libp2p-core", - "parity-send-wrapper", + "send_wrapper", "wasm-bindgen", "wasm-bindgen-futures", ] -[[package]] -name = "libp2p-webrtc" -version = "0.4.0-alpha.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dba48592edbc2f60b4bc7c10d65445b0c3964c07df26fdf493b6880d33be36f8" -dependencies = [ - "async-trait", - "asynchronous-codec", - "bytes", - "futures", - "futures-timer", - "hex", - "if-watch", - "libp2p-core", - "libp2p-identity", - "libp2p-noise", - "log", - "multihash", - "quick-protobuf", - "quick-protobuf-codec", - "rand 0.8.5", - "rcgen 0.9.3", - "serde", - "stun", - "thiserror", - "tinytemplate", - "tokio", - "tokio-util", - "webrtc", -] - [[package]] name = "libp2p-websocket" -version = "0.41.0" +version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "111273f7b3d3510524c752e8b7a5314b7f7a1fee7e68161c01a7d72cbb06db9f" +checksum = "956d981ebc84abc3377e5875483c06d94ff57bc6b25f725047f9fd52592f72d4" dependencies = [ "either", "futures", "futures-rustls", "libp2p-core", + "libp2p-identity", "log", "parking_lot 0.12.1", "quicksink", "rw-stream-sink", "soketto", "url", - "webpki-roots", + "webpki-roots 0.23.1", ] [[package]] name = "libp2p-yamux" -version = "0.43.1" +version = "0.44.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4dcd21d950662700a385d4c6d68e2f5f54d778e97068cdd718522222ef513bda" +checksum = "c0a9b42ab6de15c6f076d8fb11dc5f48d899a10b55a2e16b12be9012a05287b0" dependencies = [ "futures", "libp2p-core", @@ -4794,9 +4275,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.18" +version = "0.4.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "518ef76f2f87365916b142844c16d8fefd85039bc5699050210a7778ee1cd1de" +checksum = "b06a4cde4c0f271a446782e3eff8de789548ce57dbc8eca9292c27f4a42004b4" [[package]] name = "lru" @@ -4938,15 +4419,6 @@ dependencies = [ "rawpointer", ] -[[package]] -name = "md-5" -version = "0.10.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6365506850d44bff6e2fbcb5176cf63650e48bd45ef2fe2665ae1570e0f4b9ca" -dependencies = [ - "digest 0.10.7", -] - [[package]] name = "memchr" version = "2.5.0" @@ -4971,15 +4443,6 @@ dependencies = [ "libc", ] -[[package]] -name = "memoffset" -version = "0.6.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" -dependencies = [ - "autocfg", -] - [[package]] name = "memoffset" version = "0.7.1" @@ -5122,56 +4585,110 @@ dependencies = [ [[package]] name = "multiaddr" -version = "0.17.1" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b36f567c7099511fa8612bbbb52dda2419ce0bdbacf31714e3a5ffdb766d3bd" +checksum = "92a651988b3ed3ad1bc8c87d016bb92f6f395b84ed1db9b926b32b1fc5a2c8b5" dependencies = [ "arrayref", "byteorder", "data-encoding", - "log", + "libp2p-identity", "multibase", - "multihash", + "multihash 0.19.0", "percent-encoding", "serde", "static_assertions", "unsigned-varint", - "url", + "url", +] + +[[package]] +name = "multibase" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b3539ec3c1f04ac9748a260728e855f261b4977f5c3406612c884564f329404" +dependencies = [ + "base-x", + "data-encoding", + "data-encoding-macro", +] + +[[package]] +name = "multihash" +version = "0.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "835d6ff01d610179fbce3de1694d007e500bf33a7f29689838941d6bf783ae40" +dependencies = [ + "blake2b_simd", + "blake2s_simd", + "blake3", + "core2", + "digest 0.10.7", + "multihash-derive 0.8.0", + "sha2 0.10.7", + "sha3", + "unsigned-varint", ] [[package]] -name = "multibase" -version = "0.9.1" +name = "multihash" +version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b3539ec3c1f04ac9748a260728e855f261b4977f5c3406612c884564f329404" +checksum = "2fd59dcc2bbe70baabeac52cd22ae52c55eefe6c38ff11a9439f16a350a939f2" dependencies = [ - "base-x", - "data-encoding", - "data-encoding-macro", + "core2", + "unsigned-varint", ] [[package]] -name = "multihash" -version = "0.17.0" +name = "multihash-codetable" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "835d6ff01d610179fbce3de1694d007e500bf33a7f29689838941d6bf783ae40" +checksum = "e46d7ff0b9b8d818e709e12135bfb6582fcde982ba2be48ea52e6e1df098c7a4" dependencies = [ "blake2b_simd", "blake2s_simd", "blake3", "core2", "digest 0.10.7", - "multihash-derive", - "sha2 0.10.6", + "multihash-derive 0.9.0", + "ripemd", + "sha-1 0.10.1", + "sha2 0.10.7", "sha3", - "unsigned-varint", + "strobe-rs", ] [[package]] name = "multihash-derive" -version = "0.8.1" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc076939022111618a5026d3be019fd8b366e76314538ff9a1b59ffbcbf98bcd" +dependencies = [ + "proc-macro-crate", + "proc-macro-error", + "proc-macro2", + "quote", + "syn 1.0.109", + "synstructure", +] + +[[package]] +name = "multihash-derive" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "890e72cb7396cb99ed98c1246a97b243cc16394470d94e0bc8b0c2c11d84290e" +dependencies = [ + "core2", + "multihash 0.19.0", + "multihash-derive-impl", +] + +[[package]] +name = "multihash-derive-impl" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d6d4752e6230d8ef7adf7bd5d8c4b1f6561c1014c5ba9a37445ccefe18aa1db" +checksum = "d38685e08adb338659871ecfc6ee47ba9b22dcc8abcf6975d379cc49145c3040" dependencies = [ "proc-macro-crate", "proc-macro-error", @@ -5189,9 +4706,9 @@ checksum = "e5ce46fe64a9d73be07dcbe690a38ce1b293be448fd8ce1e6c1b8062c9f72c6a" [[package]] name = "multistream-select" -version = "0.12.1" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8552ab875c1313b97b8d20cb857b9fd63e2d1d6a0a1b53ce9821e575405f27a" +checksum = "ea0df8e5eec2298a62b326ee4f0d7fe1a6b90a09dfcf9df37b38f947a8c42f19" dependencies = [ "bytes", "futures", @@ -5312,7 +4829,6 @@ dependencies = [ "bitflags", "cfg-if", "libc", - "memoffset 0.6.5", ] [[package]] @@ -5755,7 +5271,7 @@ version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a652d9771a63711fd3c3deb670acfbe5c30a4072e664d7a3bf5a9e1056ac72c3" dependencies = [ - "arrayvec 0.7.2", + "arrayvec 0.7.4", "itoa", ] @@ -5830,24 +5346,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "oid-registry" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38e20717fa0541f39bd146692035c37bedfa532b3e5071b35761082407546b2a" -dependencies = [ - "asn1-rs 0.3.1", -] - -[[package]] -name = "oid-registry" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9bedf36ffb6ba96c2eb7144ef6270557b52e54b20c0a8e1eb2ff99a6c6959bff" -dependencies = [ - "asn1-rs 0.5.2", -] - [[package]] name = "once_cell" version = "1.18.0" @@ -5899,28 +5397,6 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" -[[package]] -name = "p256" -version = "0.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51f44edd08f51e2ade572f141051021c5af22677e42b7dd28a88155151c33594" -dependencies = [ - "ecdsa 0.14.8", - "elliptic-curve 0.12.3", - "sha2 0.10.6", -] - -[[package]] -name = "p384" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfc8c5bf642dde52bb9e87c0ecd8ca5a76faac2eeed98dedb7c717997e1080aa" -dependencies = [ - "ecdsa 0.14.8", - "elliptic-curve 0.12.3", - "sha2 0.10.6", -] - [[package]] name = "packed_simd_2" version = "0.3.8" @@ -7677,7 +7153,7 @@ version = "3.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2287753623c76f953acd29d15d8100bcab84d29db78fb6f352adb3c53e83b967" dependencies = [ - "arrayvec 0.7.2", + "arrayvec 0.7.4", "bitvec", "byte-slice-cast", "bytes", @@ -7698,12 +7174,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "parity-send-wrapper" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa9777aa91b8ad9dd5aaa04a9b6bcb02c7f1deb952fca5a66034d5e63afc5c6f" - [[package]] name = "parity-wasm" version = "0.45.0" @@ -7800,24 +7270,6 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" -[[package]] -name = "pem" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8835c273a76a90455d7344889b0964598e3316e2a79ede8e36f16bdcf2228b8" -dependencies = [ - "base64 0.13.1", -] - -[[package]] -name = "pem-rfc7468" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24d159833a9105500e0398934e205e0773f0b27529557134ecfc51c27646adac" -dependencies = [ - "base64ct", -] - [[package]] name = "percent-encoding" version = "2.3.0" @@ -7865,7 +7317,7 @@ checksum = "745a452f8eb71e39ffd8ee32b3c5f51d03845f99786fa9b68db6ff509c505411" dependencies = [ "once_cell", "pest", - "sha2 0.10.6", + "sha2 0.10.7", ] [[package]] @@ -7916,24 +7368,14 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" -[[package]] -name = "pkcs8" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9eca2c590a5f85da82668fa685c09ce2888b9430e83299debf1f34b65fd4a4ba" -dependencies = [ - "der 0.6.1", - "spki 0.6.0", -] - [[package]] name = "pkcs8" version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" dependencies = [ - "der 0.7.6", - "spki 0.7.2", + "der", + "spki", ] [[package]] @@ -8000,7 +7442,7 @@ checksum = "048aeb476be11a4b6ca432ca569e375810de9294ae78f4774e78ea98a9246ede" dependencies = [ "cpufeatures", "opaque-debug 0.3.0", - "universal-hash 0.4.1", + "universal-hash", ] [[package]] @@ -8012,19 +7454,7 @@ dependencies = [ "cfg-if", "cpufeatures", "opaque-debug 0.3.0", - "universal-hash 0.4.1", -] - -[[package]] -name = "polyval" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ef234e08c11dfcb2e56f79fd70f6f2eb7f025c0ce2333e82f4f0518ecad30c6" -dependencies = [ - "cfg-if", - "cpufeatures", - "opaque-debug 0.3.0", - "universal-hash 0.5.1", + "universal-hash", ] [[package]] @@ -8129,12 +7559,12 @@ dependencies = [ [[package]] name = "proc-macro-crate" -version = "1.1.3" +version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e17d47ce914bf4de440332250b0edd23ce48c005f59fab39d3335866b114f11a" +checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" dependencies = [ - "thiserror", - "toml 0.5.11", + "once_cell", + "toml_edit", ] [[package]] @@ -8197,9 +7627,9 @@ dependencies = [ [[package]] name = "prometheus-client" -version = "0.19.0" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d6fa99d535dd930d1249e6c79cb3c2915f9172a540fe2b02a4c8f9ca954721e" +checksum = "78c2f43e8969d51935d2a7284878ae053ba30034cd563f673cde37ba5205685e" dependencies = [ "dtoa", "itoa", @@ -8298,9 +7728,9 @@ dependencies = [ [[package]] name = "quick-protobuf-codec" -version = "0.1.0" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1693116345026436eb2f10b677806169c1a1260c1c60eaaffe3fb5a29ae23d8b" +checksum = "f8ededb1cd78531627244d51dd0c7139fbe736c7d57af0092a76f0ffb2f56e98" dependencies = [ "asynchronous-codec", "bytes", @@ -8329,24 +7759,6 @@ dependencies = [ "pin-project-lite 0.1.12", ] -[[package]] -name = "quinn-proto" -version = "0.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67c10f662eee9c94ddd7135043e544f3c82fa839a1e7b865911331961b53186c" -dependencies = [ - "bytes", - "rand 0.8.5", - "ring", - "rustc-hash", - "rustls 0.20.8", - "slab", - "thiserror", - "tinyvec", - "tracing", - "webpki 0.22.0", -] - [[package]] name = "quote" version = "1.0.28" @@ -8480,31 +7892,6 @@ dependencies = [ "num_cpus", ] -[[package]] -name = "rcgen" -version = "0.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6413f3de1edee53342e6138e75b56d32e7bc6e332b3bd62d497b1929d4cfbcdd" -dependencies = [ - "pem", - "ring", - "time 0.3.21", - "x509-parser 0.13.2", - "yasna", -] - -[[package]] -name = "rcgen" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffbe84efe2f38dea12e9bfc1f65377fdf03e53a18cb3b995faedf7934c7e785b" -dependencies = [ - "pem", - "ring", - "time 0.3.21", - "yasna", -] - [[package]] name = "redox_syscall" version = "0.2.16" @@ -8608,17 +7995,6 @@ dependencies = [ "quick-error", ] -[[package]] -name = "rfc6979" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7743f17af12fa0b03b803ba12cd6a8d9483a587e89c69445e3909655c0b9fabb" -dependencies = [ - "crypto-bigint 0.4.9", - "hmac 0.12.1", - "zeroize", -] - [[package]] name = "rfc6979" version = "0.4.0" @@ -8644,6 +8020,15 @@ dependencies = [ "winapi", ] +[[package]] +name = "ripemd" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd124222d17ad93a644ed9d011a40f4fb64aa54275c08cc216524a9ea82fb09f" +dependencies = [ + "digest 0.10.7", +] + [[package]] name = "rocksdb" version = "0.21.0" @@ -8665,17 +8050,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "rtcp" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1919efd6d4a6a85d13388f9487549bb8e359f17198cc03ffd72f79b553873691" -dependencies = [ - "bytes", - "thiserror", - "webrtc-util", -] - [[package]] name = "rtnetlink" version = "0.10.1" @@ -8701,20 +8075,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "rtp" -version = "0.6.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2a095411ff00eed7b12e4c6a118ba984d113e1079582570d56a5ee723f11f80" -dependencies = [ - "async-trait", - "bytes", - "rand 0.8.5", - "serde", - "thiserror", - "webrtc-util", -] - [[package]] name = "rustc-demangle" version = "0.1.23" @@ -8751,15 +8111,6 @@ dependencies = [ "semver 1.0.17", ] -[[package]] -name = "rusticata-macros" -version = "4.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "faf0c4a6ece9950b9abdb62b1cfcf2a68b3b67a10ba445b3bb85be2a293d0632" -dependencies = [ - "nom", -] - [[package]] name = "rustix" version = "0.36.14" @@ -8788,19 +8139,6 @@ dependencies = [ "windows-sys 0.48.0", ] -[[package]] -name = "rustls" -version = "0.19.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35edb675feee39aec9c99fa5ff985081995a06d594114ae14cbe797ad7b7a6d7" -dependencies = [ - "base64 0.13.1", - "log", - "ring", - "sct 0.6.1", - "webpki 0.21.4", -] - [[package]] name = "rustls" version = "0.20.8" @@ -8809,8 +8147,8 @@ checksum = "fff78fc74d175294f4e83b28343315ffcfb114b156f0185e9741cb5570f50e2f" dependencies = [ "log", "ring", - "sct 0.7.0", - "webpki 0.22.0", + "sct", + "webpki", ] [[package]] @@ -8822,7 +8160,7 @@ dependencies = [ "log", "ring", "rustls-webpki", - "sct 0.7.0", + "sct", ] [[package]] @@ -8875,9 +8213,9 @@ dependencies = [ [[package]] name = "rw-stream-sink" -version = "0.3.0" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26338f5e09bb721b85b135ea05af7767c90b52f6de4f087d4f4a3a9d64e7dc04" +checksum = "d8c9026ff5d2f23da5e45bbc283f156383001bfb09c4e44256d02c1a685fe9a1" dependencies = [ "futures", "pin-project", @@ -8937,7 +8275,7 @@ dependencies = [ "ip_network", "libp2p", "log", - "multihash", + "multihash-codetable", "parity-scale-codec", "prost", "prost-build", @@ -9641,6 +8979,7 @@ dependencies = [ "tokio-test", "tokio-util", "unsigned-varint", + "void", "wasm-timer", "zeroize", ] @@ -9695,9 +9034,10 @@ dependencies = [ "ahash 0.8.3", "futures", "futures-timer", - "libp2p", + "libp2p-identity", "log", "lru", + "multiaddr", "quickcheck", "sc-network", "sc-network-common", @@ -10371,16 +9711,6 @@ version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1792db035ce95be60c3f8853017b3999209281c24e2ba5bc8e59bf97a0c590c1" -[[package]] -name = "sct" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b362b83898e0e69f38515b82ee15aa80636befe47c3b6d3d89a911e78fc228ce" -dependencies = [ - "ring", - "untrusted", -] - [[package]] name = "sct" version = "0.7.0" @@ -10391,42 +9721,16 @@ dependencies = [ "untrusted", ] -[[package]] -name = "sdp" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d22a5ef407871893fd72b4562ee15e4742269b173959db4b8df6f538c414e13" -dependencies = [ - "rand 0.8.5", - "substring", - "thiserror", - "url", -] - -[[package]] -name = "sec1" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3be24c1842290c45df0a7bf069e0c268a747ad05a192f2fd7dcfdbc1cba40928" -dependencies = [ - "base16ct 0.1.1", - "der 0.6.1", - "generic-array 0.14.7", - "pkcs8 0.9.0", - "subtle", - "zeroize", -] - [[package]] name = "sec1" version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f0aec48e813d6b90b15f0b8948af3c63483992dee44c03e9930b3eebdabe046e" dependencies = [ - "base16ct 0.2.0", - "der 0.7.6", + "base16ct", + "der", "generic-array 0.14.7", - "pkcs8 0.10.2", + "pkcs8", "subtle", "zeroize", ] @@ -10514,6 +9818,12 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" +[[package]] +name = "send_wrapper" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd0b0ec5f1c1ca621c432a25813d8d60c88abe6d3e08a3eb9cf37d97a0fe3d73" + [[package]] name = "serde" version = "1.0.164" @@ -10568,10 +9878,10 @@ dependencies = [ ] [[package]] -name = "sha1" -version = "0.10.5" +name = "sha-1" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f04293dc80c3993519f2d7f6f511707ee7094fe0c6d3406feb330cdb3540eba3" +checksum = "f5058ada175748e33390e40e872bd0fe59a19f265d0158daa551c5a88a76009c" dependencies = [ "cfg-if", "cpufeatures", @@ -10605,9 +9915,9 @@ dependencies = [ [[package]] name = "sha2" -version = "0.10.6" +version = "0.10.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82e6b795fe2e3b1e845bafcb27aa35405c4d47cdfc92af5fc8d3002f76cebdc0" +checksum = "479fb9d862239e610720565ca91403019f2f00410f1864c5aa7479b950a76ed8" dependencies = [ "cfg-if", "cpufeatures", @@ -10653,10 +9963,6 @@ name = "signature" version = "1.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "74233d3b3b2f6d4b006dc19dee745e73e2a6bfb6f93607cd3b02bd5b00797d7c" -dependencies = [ - "digest 0.10.7", - "rand_core 0.6.4", -] [[package]] name = "signature" @@ -10720,14 +10026,14 @@ version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5ccba027ba85743e09d15c03296797cad56395089b832b48b5a5217880f57733" dependencies = [ - "aes-gcm 0.9.4", + "aes-gcm", "blake2", "chacha20poly1305", "curve25519-dalek 4.0.0-rc.1", "rand_core 0.6.4", "ring", "rustc_version 0.4.0", - "sha2 0.10.6", + "sha2 0.10.7", "subtle", ] @@ -10741,6 +10047,16 @@ dependencies = [ "winapi", ] +[[package]] +name = "socket2" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2538b18701741680e0322a2302176d3253a35388e2e62f172f64f4f16605f877" +dependencies = [ + "libc", + "windows-sys 0.48.0", +] + [[package]] name = "soketto" version = "0.7.1" @@ -10749,13 +10065,12 @@ checksum = "41d1c5305e39e09653383c2c7244f2f78b3bcae37cf50c64cb4789c9f5096ec2" dependencies = [ "base64 0.13.1", "bytes", - "flate2", "futures", "http", "httparse", "log", "rand 0.8.5", - "sha-1", + "sha-1 0.9.8", ] [[package]] @@ -11115,7 +10430,7 @@ dependencies = [ "bitflags", "blake2", "bounded-collections", - "bs58", + "bs58 0.4.0", "criterion", "dyn-clonable", "ed25519-zebra", @@ -11162,7 +10477,7 @@ dependencies = [ "blake2b_simd", "byteorder", "digest 0.10.7", - "sha2 0.10.6", + "sha2 0.10.7", "sha3", "twox-hash", ] @@ -11728,18 +11043,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08615eea740067d9899969bc2891c68a19c315cb1f66640af9a9ecb91b13bcab" dependencies = [ "lazy_static", - "maplit", - "strum", -] - -[[package]] -name = "spki" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67cf02bbac7a337dc36e4f5a693db6c21e7863f45070f7064577eb4367a3212b" -dependencies = [ - "base64ct", - "der 0.6.1", + "maplit", + "strum", ] [[package]] @@ -11749,7 +11054,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d1e996ef02c474957d681f1b05213dfb0abab947b446a62d37770b23500184a" dependencies = [ "base64ct", - "der 0.7.6", + "der", ] [[package]] @@ -11807,6 +11112,19 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "strobe-rs" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fabb238a1cccccfa4c4fb703670c0d157e1256c1ba695abf1b93bd2bb14bab2d" +dependencies = [ + "bitflags", + "byteorder", + "keccak", + "subtle", + "zeroize", +] + [[package]] name = "strsim" version = "0.10.0" @@ -11835,25 +11153,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "stun" -version = "0.4.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7e94b1ec00bad60e6410e058b52f1c66de3dc5fe4d62d09b3e52bb7d3b73e25" -dependencies = [ - "base64 0.13.1", - "crc", - "lazy_static", - "md-5", - "rand 0.8.5", - "ring", - "subtle", - "thiserror", - "tokio", - "url", - "webrtc-util", -] - [[package]] name = "subkey" version = "3.0.0" @@ -12136,15 +11435,6 @@ dependencies = [ "wasm-opt", ] -[[package]] -name = "substring" -version = "1.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42ee6433ecef213b2e72f587ef64a2f5943e7cd16fbd82dbe8bc07486c534c86" -dependencies = [ - "autocfg", -] - [[package]] name = "subtle" version = "2.4.1" @@ -12330,33 +11620,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "time" -version = "0.3.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f3403384eaacbca9923fa06940178ac13e4edb725486d70e8e15881d0c836cc" -dependencies = [ - "itoa", - "serde", - "time-core", - "time-macros", -] - -[[package]] -name = "time-core" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7300fbefb4dadc1af235a9cef3737cea692a9d97e1b9cbcd4ebdae6f8868e6fb" - -[[package]] -name = "time-macros" -version = "0.2.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "372950940a5f07bf38dbe211d7283c9e6d7327df53794992d293e534c733d09b" -dependencies = [ - "time-core", -] - [[package]] name = "tiny-bip39" version = "1.0.0" @@ -12369,7 +11632,7 @@ dependencies = [ "pbkdf2 0.11.0", "rand 0.8.5", "rustc-hash", - "sha2 0.10.6", + "sha2 0.10.7", "thiserror", "unicode-normalization", "wasm-bindgen", @@ -12424,7 +11687,7 @@ dependencies = [ "parking_lot 0.12.1", "pin-project-lite 0.2.9", "signal-hook-registry", - "socket2", + "socket2 0.4.9", "tokio-macros", "windows-sys 0.48.0", ] @@ -12459,7 +11722,7 @@ checksum = "c43ee83903113e03984cb9e5cebe6c04a5116269e900e3ddba8f068a62adda59" dependencies = [ "rustls 0.20.8", "tokio", - "webpki 0.22.0", + "webpki", ] [[package]] @@ -12768,7 +12031,7 @@ dependencies = [ "lazy_static", "rand 0.8.5", "smallvec", - "socket2", + "socket2 0.4.9", "thiserror", "tinyvec", "tokio", @@ -12865,25 +12128,6 @@ version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f4f195fd851901624eee5a58c4bb2b4f06399148fcd0ed336e6f1cb60a9881df" -[[package]] -name = "turn" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4712ee30d123ec7ae26d1e1b218395a16c87cdbaf4b3925d170d684af62ea5e8" -dependencies = [ - "async-trait", - "base64 0.13.1", - "futures", - "log", - "md-5", - "rand 0.8.5", - "ring", - "stun", - "thiserror", - "tokio", - "webrtc-util", -] - [[package]] name = "twox-hash" version = "1.6.3" @@ -12963,16 +12207,6 @@ dependencies = [ "subtle", ] -[[package]] -name = "universal-hash" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc1de2c688dc15305988b563c3854064043356019f97a4b46276fe734c4f07ea" -dependencies = [ - "crypto-common", - "subtle", -] - [[package]] name = "unsigned-varint" version = "0.7.1" @@ -13008,15 +12242,6 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" -[[package]] -name = "uuid" -version = "1.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "345444e32442451b267fc254ae85a209c64be56d2890e601a0c37ff0c3c5ecd2" -dependencies = [ - "getrandom 0.2.9", -] - [[package]] name = "valuable" version = "0.1.0" @@ -13059,7 +12284,7 @@ dependencies = [ "rand 0.8.5", "rand_chacha 0.3.1", "rand_core 0.6.4", - "sha2 0.10.6", + "sha2 0.10.7", "sha3", "thiserror", "zeroize", @@ -13074,15 +12299,6 @@ dependencies = [ "libc", ] -[[package]] -name = "waitgroup" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1f50000a783467e6c0200f9d10642f4bc424e39efc1b770203e88b488f79292" -dependencies = [ - "atomic-waker", -] - [[package]] name = "waker-fn" version = "1.1.0" @@ -13377,7 +12593,7 @@ dependencies = [ "log", "rustix 0.36.14", "serde", - "sha2 0.10.6", + "sha2 0.10.7", "toml 0.5.11", "windows-sys 0.45.0", "zstd 0.11.2+zstd.1.5.2", @@ -13552,16 +12768,6 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "webpki" -version = "0.21.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8e38c0608262c46d4a56202ebabdeb094cef7e560ca7a226c6bf055188aa4ea" -dependencies = [ - "ring", - "untrusted", -] - [[package]] name = "webpki" version = "0.22.0" @@ -13578,216 +12784,16 @@ version = "0.22.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6c71e40d7d2c34a5106301fb632274ca37242cd0c9d3e64dbece371a40a2d87" dependencies = [ - "webpki 0.22.0", -] - -[[package]] -name = "webrtc" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d3bc9049bdb2cea52f5fd4f6f728184225bdb867ed0dc2410eab6df5bdd67bb" -dependencies = [ - "arc-swap", - "async-trait", - "bytes", - "hex", - "interceptor", - "lazy_static", - "log", - "rand 0.8.5", - "rcgen 0.9.3", - "regex", - "ring", - "rtcp", - "rtp", - "rustls 0.19.1", - "sdp", - "serde", - "serde_json", - "sha2 0.10.6", - "stun", - "thiserror", - "time 0.3.21", - "tokio", - "turn", - "url", - "waitgroup", - "webrtc-data", - "webrtc-dtls", - "webrtc-ice", - "webrtc-mdns", - "webrtc-media", - "webrtc-sctp", - "webrtc-srtp", - "webrtc-util", -] - -[[package]] -name = "webrtc-data" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ef36a4d12baa6e842582fe9ec16a57184ba35e1a09308307b67d43ec8883100" -dependencies = [ - "bytes", - "derive_builder", - "log", - "thiserror", - "tokio", - "webrtc-sctp", - "webrtc-util", -] - -[[package]] -name = "webrtc-dtls" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "942be5bd85f072c3128396f6e5a9bfb93ca8c1939ded735d177b7bcba9a13d05" -dependencies = [ - "aes 0.6.0", - "aes-gcm 0.10.2", - "async-trait", - "bincode", - "block-modes", - "byteorder", - "ccm", - "curve25519-dalek 3.2.0", - "der-parser 8.2.0", - "elliptic-curve 0.12.3", - "hkdf", - "hmac 0.12.1", - "log", - "oid-registry 0.6.1", - "p256", - "p384", - "rand 0.8.5", - "rand_core 0.6.4", - "rcgen 0.9.3", - "ring", - "rustls 0.19.1", - "sec1 0.3.0", - "serde", - "sha1", - "sha2 0.10.6", - "signature 1.6.4", - "subtle", - "thiserror", - "tokio", - "webpki 0.21.4", - "webrtc-util", - "x25519-dalek 2.0.0-pre.1", - "x509-parser 0.13.2", -] - -[[package]] -name = "webrtc-ice" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "465a03cc11e9a7d7b4f9f99870558fe37a102b65b93f8045392fef7c67b39e80" -dependencies = [ - "arc-swap", - "async-trait", - "crc", - "log", - "rand 0.8.5", - "serde", - "serde_json", - "stun", - "thiserror", - "tokio", - "turn", - "url", - "uuid", - "waitgroup", - "webrtc-mdns", - "webrtc-util", -] - -[[package]] -name = "webrtc-mdns" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f08dfd7a6e3987e255c4dbe710dde5d94d0f0574f8a21afa95d171376c143106" -dependencies = [ - "log", - "socket2", - "thiserror", - "tokio", - "webrtc-util", -] - -[[package]] -name = "webrtc-media" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f72e1650a8ae006017d1a5280efb49e2610c19ccc3c0905b03b648aee9554991" -dependencies = [ - "byteorder", - "bytes", - "rand 0.8.5", - "rtp", - "thiserror", -] - -[[package]] -name = "webrtc-sctp" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d47adcd9427eb3ede33d5a7f3424038f63c965491beafcc20bc650a2f6679c0" -dependencies = [ - "arc-swap", - "async-trait", - "bytes", - "crc", - "log", - "rand 0.8.5", - "thiserror", - "tokio", - "webrtc-util", -] - -[[package]] -name = "webrtc-srtp" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6183edc4c1c6c0175f8812eefdce84dfa0aea9c3ece71c2bf6ddd3c964de3da5" -dependencies = [ - "aead 0.4.3", - "aes 0.7.5", - "aes-gcm 0.9.4", - "async-trait", - "byteorder", - "bytes", - "ctr 0.8.0", - "hmac 0.11.0", - "log", - "rtcp", - "rtp", - "sha-1", - "subtle", - "thiserror", - "tokio", - "webrtc-util", + "webpki", ] [[package]] -name = "webrtc-util" -version = "0.7.0" +name = "webpki-roots" +version = "0.23.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93f1db1727772c05cf7a2cfece52c3aca8045ca1e176cd517d323489aa3c6d87" +checksum = "b03058f88386e5ff5310d9111d53f48b17d732b401aeb83a8d5190f2ac459338" dependencies = [ - "async-trait", - "bitflags", - "bytes", - "cc", - "ipnet", - "lazy_static", - "libc", - "log", - "nix 0.24.3", - "rand 0.8.5", - "thiserror", - "tokio", - "winapi", + "rustls-webpki", ] [[package]] @@ -14070,54 +13076,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "x25519-dalek" -version = "2.0.0-pre.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5da623d8af10a62342bcbbb230e33e58a63255a58012f8653c578e54bab48df" -dependencies = [ - "curve25519-dalek 3.2.0", - "rand_core 0.6.4", - "zeroize", -] - -[[package]] -name = "x509-parser" -version = "0.13.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fb9bace5b5589ffead1afb76e43e34cff39cd0f3ce7e170ae0c29e53b88eb1c" -dependencies = [ - "asn1-rs 0.3.1", - "base64 0.13.1", - "data-encoding", - "der-parser 7.0.0", - "lazy_static", - "nom", - "oid-registry 0.4.0", - "ring", - "rusticata-macros", - "thiserror", - "time 0.3.21", -] - -[[package]] -name = "x509-parser" -version = "0.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0ecbeb7b67ce215e40e3cc7f2ff902f94a223acf44995934763467e7b1febc8" -dependencies = [ - "asn1-rs 0.5.2", - "base64 0.13.1", - "data-encoding", - "der-parser 8.2.0", - "lazy_static", - "nom", - "oid-registry 0.6.1", - "rusticata-macros", - "thiserror", - "time 0.3.21", -] - [[package]] name = "xattr" version = "0.2.3" @@ -14147,15 +13105,6 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09041cd90cf85f7f8b2df60c646f853b7f535ce68f85244eb6731cf89fa498ec" -[[package]] -name = "yasna" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e17bb3549cc1321ae1296b9cdc2698e2b6cb1992adfa19a8c72e5b7a738f44cd" -dependencies = [ - "time 0.3.21", -] - [[package]] name = "zeroize" version = "1.6.0" From 343a86e54b0e011c9ff9aae977caeca32b146ba8 Mon Sep 17 00:00:00 2001 From: Anton Kaliaev Date: Fri, 7 Jul 2023 10:15:18 +0400 Subject: [PATCH 31/42] remove extra From --- client/network/src/config.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/network/src/config.rs b/client/network/src/config.rs index 954f7dbe4d36d..e13b6ac0a370d 100644 --- a/client/network/src/config.rs +++ b/client/network/src/config.rs @@ -142,7 +142,7 @@ pub struct MultiaddrWithPeerId { impl MultiaddrWithPeerId { /// Concatenates the multiaddress and peer ID into one multiaddress containing both. pub fn concat(&self) -> Multiaddr { - let proto = multiaddr::Protocol::P2p(From::from(self.peer_id)); + let proto = multiaddr::Protocol::P2p(self.peer_id); self.multiaddr.clone().with(proto) } } From 3b1c8f2e578db1da1b7ed12032ab2b99d91a3f9a Mon Sep 17 00:00:00 2001 From: Anton Kaliaev Date: Mon, 17 Jul 2023 10:56:17 +0400 Subject: [PATCH 32/42] make void uninhabited --- client/network/src/behaviour.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/network/src/behaviour.rs b/client/network/src/behaviour.rs index 261ace55a0e54..4799807d2cb33 100644 --- a/client/network/src/behaviour.rs +++ b/client/network/src/behaviour.rs @@ -357,7 +357,7 @@ impl From for BehaviourOut { } impl From for BehaviourOut { - fn from(_e: void::Void) -> Self { - Self::None + fn from(e: void::Void) -> Self { + void::unreachable(e) } } From a506670e4fafd6658f54fd1070b865cb26c032d0 Mon Sep 17 00:00:00 2001 From: Anton Kaliaev Date: Mon, 17 Jul 2023 11:00:20 +0400 Subject: [PATCH 33/42] fix discovery test --- Cargo.lock | 18 ++++++++++-------- client/authority-discovery/Cargo.toml | 2 +- client/network/Cargo.toml | 3 ++- client/network/src/discovery.rs | 2 ++ client/network/statement/Cargo.toml | 2 +- client/network/sync/Cargo.toml | 2 +- client/network/test/Cargo.toml | 2 +- client/network/transactions/Cargo.toml | 2 +- client/offchain/Cargo.toml | 2 +- client/telemetry/Cargo.toml | 2 +- 10 files changed, 21 insertions(+), 16 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3d7d3644bfde8..a04a4da6c3741 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3902,9 +3902,9 @@ dependencies = [ [[package]] name = "libp2p-kad" -version = "0.44.1" +version = "0.44.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5588b884dcb1dadc04e49de342f634f60cf28b6beaaca5a4fe3dd1f09bb30041" +checksum = "f0eeb75763862ff762c3240722fbed06ff6bb025d6afbdf2ce887f3610657789" dependencies = [ "arrayvec 0.7.4", "asynchronous-codec", @@ -4029,9 +4029,9 @@ dependencies = [ [[package]] name = "libp2p-swarm" -version = "0.43.0" +version = "0.43.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6f1fe3817492f88c5298c8b5fbaa5ff3a0c802ecf4e79be4e341cf07abfa82f" +checksum = "5de15b2097fc3bde063df8c202803538ff467fedb18f01c13bc5da55913d246c" dependencies = [ "either", "fnv", @@ -8949,6 +8949,7 @@ dependencies = [ "futures-timer", "ip_network", "libp2p", + "libp2p-kad", "linked_hash_set", "log", "mockall", @@ -10012,9 +10013,9 @@ checksum = "826167069c09b99d56f31e9ae5c99049e932a98c9dc2dac47645b08dbbf76ba7" [[package]] name = "smallvec" -version = "1.10.0" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" +checksum = "62bb4feee49fdd9f707ef802e22365a35de4b7b299de4763d44bfea899442ff9" [[package]] name = "snap" @@ -11678,11 +11679,12 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.28.2" +version = "1.29.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94d7b1cfd2aa4011f2de74c2c4c63665e27a71006b0a192dcd2710272e73dfa2" +checksum = "532826ff75199d5833b9d2c5fe410f29235e25704ee5f0ef599fb51c21f4a4da" dependencies = [ "autocfg", + "backtrace", "bytes", "libc", "mio", diff --git a/client/authority-discovery/Cargo.toml b/client/authority-discovery/Cargo.toml index b6382b15574ba..2203b619b18a2 100644 --- a/client/authority-discovery/Cargo.toml +++ b/client/authority-discovery/Cargo.toml @@ -21,7 +21,7 @@ codec = { package = "parity-scale-codec", version = "3.6.1", default-features = futures = "0.3.21" futures-timer = "3.0.1" ip_network = "0.4.1" -libp2p = { version = "0.52.0", features = ["kad", "ed25519"] } +libp2p = { version = "0.52.1", features = ["kad", "ed25519"] } multihash-codetable = { version = "0.1.0", features = ["sha2", "digest"] } log = "0.4.17" prost = "0.11" diff --git a/client/network/Cargo.toml b/client/network/Cargo.toml index 53b857e97bfbb..76cea439e3c1e 100644 --- a/client/network/Cargo.toml +++ b/client/network/Cargo.toml @@ -25,7 +25,8 @@ fnv = "1.0.6" futures = "0.3.21" futures-timer = "3.0.2" ip_network = "0.4.1" -libp2p = { version = "0.52.0", features = ["dns", "identify", "kad", "macros", "mdns", "noise", "ping", "tcp", "tokio", "yamux", "websocket", "request-response"] } +libp2p = { version = "0.52.1", features = ["dns", "identify", "kad", "macros", "mdns", "noise", "ping", "tcp", "tokio", "yamux", "websocket", "request-response"] } +libp2p-kad = { version = "0.44.2" } linked_hash_set = "0.1.3" log = "0.4.17" mockall = "0.11.3" diff --git a/client/network/src/discovery.rs b/client/network/src/discovery.rs index 4b170ad90c086..ee31afb755491 100644 --- a/client/network/src/discovery.rs +++ b/client/network/src/discovery.rs @@ -55,6 +55,7 @@ use ip_network::IpNetwork; use libp2p::{ core::{Endpoint, Multiaddr}, kad::{ + self, record::store::{MemoryStore, RecordStore}, GetClosestPeersError, GetRecordOk, Kademlia, KademliaBucketInserts, KademliaConfig, KademliaEvent, QueryId, QueryResult, Quorum, Record, RecordKey, @@ -222,6 +223,7 @@ impl DiscoveryConfig { let store = MemoryStore::new(local_peer_id); let mut kad = Kademlia::with_config(local_peer_id, store, config); + kad.set_mode(Some(kad::Mode::Server)); for (peer_id, addr) in &permanent_addresses { kad.add_address(peer_id, addr.clone()); diff --git a/client/network/statement/Cargo.toml b/client/network/statement/Cargo.toml index 2b0425262bd2e..e70fc5e929ab3 100644 --- a/client/network/statement/Cargo.toml +++ b/client/network/statement/Cargo.toml @@ -17,7 +17,7 @@ array-bytes = "6.1" async-channel = "1.8.0" codec = { package = "parity-scale-codec", version = "3.6.1", features = ["derive"] } futures = "0.3.21" -libp2p = "0.52.0" +libp2p = "0.52.1" log = "0.4.17" prometheus-endpoint = { package = "substrate-prometheus-endpoint", version = "0.10.0-dev", path = "../../../utils/prometheus" } sc-network-common = { version = "0.10.0-dev", path = "../common" } diff --git a/client/network/sync/Cargo.toml b/client/network/sync/Cargo.toml index 9ea1aa00b14d4..2c17c7fa52210 100644 --- a/client/network/sync/Cargo.toml +++ b/client/network/sync/Cargo.toml @@ -22,7 +22,7 @@ async-trait = "0.1.58" codec = { package = "parity-scale-codec", version = "3.6.1", features = ["derive"] } futures = "0.3.21" futures-timer = "3.0.2" -libp2p = "0.52.0" +libp2p = "0.52.1" log = "0.4.17" mockall = "0.11.3" prost = "0.11" diff --git a/client/network/test/Cargo.toml b/client/network/test/Cargo.toml index 3843eaaa2809c..c1c546e0458d1 100644 --- a/client/network/test/Cargo.toml +++ b/client/network/test/Cargo.toml @@ -17,7 +17,7 @@ tokio = "1.22.0" async-trait = "0.1.57" futures = "0.3.21" futures-timer = "3.0.1" -libp2p = "0.52.0" +libp2p = "0.52.1" log = "0.4.17" parking_lot = "0.12.1" rand = "0.8.5" diff --git a/client/network/transactions/Cargo.toml b/client/network/transactions/Cargo.toml index e7c63f74b3169..e212afe743ebc 100644 --- a/client/network/transactions/Cargo.toml +++ b/client/network/transactions/Cargo.toml @@ -16,7 +16,7 @@ targets = ["x86_64-unknown-linux-gnu"] array-bytes = "6.1" codec = { package = "parity-scale-codec", version = "3.6.1", features = ["derive"] } futures = "0.3.21" -libp2p = "0.52.0" +libp2p = "0.52.1" log = "0.4.17" prometheus-endpoint = { package = "substrate-prometheus-endpoint", version = "0.10.0-dev", path = "../../../utils/prometheus" } sc-network = { version = "0.10.0-dev", path = "../" } diff --git a/client/offchain/Cargo.toml b/client/offchain/Cargo.toml index 2c2ebe72e79e9..07c081beeb682 100644 --- a/client/offchain/Cargo.toml +++ b/client/offchain/Cargo.toml @@ -21,7 +21,7 @@ futures = "0.3.21" futures-timer = "3.0.2" hyper = { version = "0.14.16", features = ["stream", "http2"] } hyper-rustls = { version = "0.24.0", features = ["http2"] } -libp2p = "0.52.0" +libp2p = "0.52.1" num_cpus = "1.13" once_cell = "1.8" parking_lot = "0.12.1" diff --git a/client/telemetry/Cargo.toml b/client/telemetry/Cargo.toml index 2fcad2094d7e2..c56f89517a418 100644 --- a/client/telemetry/Cargo.toml +++ b/client/telemetry/Cargo.toml @@ -16,7 +16,7 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] chrono = "0.4.19" futures = "0.3.21" -libp2p = { version = "0.52.0", features = ["dns", "tcp", "tokio", "wasm-ext", "websocket"] } +libp2p = { version = "0.52.1", features = ["dns", "tcp", "tokio", "wasm-ext", "websocket"] } log = "0.4.17" parking_lot = "0.12.1" pin-project = "1.0.12" From 6c78a7409e7149f44986f4570c8a2f1961f2baec Mon Sep 17 00:00:00 2001 From: Anton Kaliaev Date: Mon, 17 Jul 2023 11:01:32 +0400 Subject: [PATCH 34/42] use autonat protocols confirming external addresses manually is unsafe in open networks --- Cargo.lock | 20 ++++++++++++++++++++ client/network/Cargo.toml | 2 +- client/network/src/behaviour.rs | 15 ++++++++++++++- client/network/src/discovery.rs | 2 +- client/network/src/service.rs | 25 +++++++++++++------------ 5 files changed, 49 insertions(+), 15 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a04a4da6c3741..f38fee209d006 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3774,6 +3774,7 @@ dependencies = [ "getrandom 0.2.9", "instant", "libp2p-allow-block-list", + "libp2p-autonat", "libp2p-connection-limits", "libp2p-core", "libp2p-dns", @@ -3806,6 +3807,25 @@ dependencies = [ "void", ] +[[package]] +name = "libp2p-autonat" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e907be08be5e4152317a79d310a6f501a1b5c02a81dcb065dc865475bbae9498" +dependencies = [ + "async-trait", + "futures", + "futures-timer", + "instant", + "libp2p-core", + "libp2p-identity", + "libp2p-request-response", + "libp2p-swarm", + "log", + "quick-protobuf", + "rand 0.8.5", +] + [[package]] name = "libp2p-connection-limits" version = "0.2.0" diff --git a/client/network/Cargo.toml b/client/network/Cargo.toml index 76cea439e3c1e..d07993aae8cf0 100644 --- a/client/network/Cargo.toml +++ b/client/network/Cargo.toml @@ -25,7 +25,7 @@ fnv = "1.0.6" futures = "0.3.21" futures-timer = "3.0.2" ip_network = "0.4.1" -libp2p = { version = "0.52.1", features = ["dns", "identify", "kad", "macros", "mdns", "noise", "ping", "tcp", "tokio", "yamux", "websocket", "request-response"] } +libp2p = { version = "0.52.1", features = ["autonat", "dns", "identify", "kad", "macros", "mdns", "noise", "ping", "tcp", "tokio", "yamux", "websocket", "request-response"] } libp2p-kad = { version = "0.44.2" } linked_hash_set = "0.1.3" log = "0.4.17" diff --git a/client/network/src/behaviour.rs b/client/network/src/behaviour.rs index 4799807d2cb33..40bbdf66d89e3 100644 --- a/client/network/src/behaviour.rs +++ b/client/network/src/behaviour.rs @@ -30,7 +30,7 @@ use crate::{ use bytes::Bytes; use futures::channel::oneshot; use libp2p::{ - connection_limits::ConnectionLimits, core::Multiaddr, identify::Info as IdentifyInfo, + autonat, connection_limits::ConnectionLimits, core::Multiaddr, identify::Info as IdentifyInfo, identity::PublicKey, kad::RecordKey, swarm::NetworkBehaviour, PeerId, }; @@ -55,6 +55,8 @@ pub struct Behaviour { connection_limits: libp2p::connection_limits::Behaviour, /// Generic request-response protocols. request_responses: request_responses::RequestResponsesBehaviour, + // AutoNAT. + auto_nat: autonat::Behaviour, } /// Event generated by `Behaviour`. @@ -160,6 +162,9 @@ pub enum BehaviourOut { /// request duration. Dht(DhtEvent, Duration), + /// Event generated by the AutoNAT. + AutoNAT(autonat::Event), + /// Ignored event generated by lower layers. None, } @@ -175,6 +180,7 @@ impl Behaviour { peerset: PeersetHandle, connection_limits: ConnectionLimits, ) -> Result { + let local_peer_id = local_public_key.to_peer_id(); Ok(Self { substrate, peer_info: peer_info::PeerInfoBehaviour::new(user_agent, local_public_key), @@ -184,6 +190,7 @@ impl Behaviour { request_response_protocols.into_iter(), peerset, )?, + auto_nat: autonat::Behaviour::new(local_peer_id, autonat::Config::default()), }) } @@ -356,6 +363,12 @@ impl From for BehaviourOut { } } +impl From for BehaviourOut { + fn from(event: autonat::Event) -> Self { + BehaviourOut::AutoNAT(event) + } +} + impl From for BehaviourOut { fn from(e: void::Void) -> Self { void::unreachable(e) diff --git a/client/network/src/discovery.rs b/client/network/src/discovery.rs index ee31afb755491..c0ecd17b62aff 100644 --- a/client/network/src/discovery.rs +++ b/client/network/src/discovery.rs @@ -1106,7 +1106,7 @@ mod tests { .add_self_reported_address( &other, &[protocol_name], - addr, + addr.clone(), ); to_discover[swarm_n].remove(&other); diff --git a/client/network/src/service.rs b/client/network/src/service.rs index 8aeb9962949ff..35f001e0075d8 100644 --- a/client/network/src/service.rs +++ b/client/network/src/service.rs @@ -1392,12 +1392,7 @@ where peer_id, info: IdentifyInfo { - protocol_version, - agent_version, - mut listen_addrs, - protocols, - observed_addr, - .. + protocol_version, agent_version, mut listen_addrs, protocols, .. }, }) => { if listen_addrs.len() > 30 { @@ -1409,14 +1404,13 @@ where listen_addrs.truncate(30); } for addr in listen_addrs { - self.network_service - .behaviour_mut() - .add_self_reported_address_to_dht(&peer_id, &protocols, addr); + self.network_service.behaviour_mut().add_self_reported_address_to_dht( + &peer_id, + &protocols, + addr.clone(), + ); } self.network_service.behaviour_mut().user_protocol_mut().add_known_peer(peer_id); - // Confirm the reported address manually since they are no longer trusted by default - // (libp2p >= 0.52) - self.network_service.add_external_address(observed_addr); }, SwarmEvent::Behaviour(BehaviourOut::Discovered(peer_id)) => { self.network_service.behaviour_mut().user_protocol_mut().add_known_peer(peer_id); @@ -1533,6 +1527,13 @@ where self.event_streams.send(Event::Dht(event)); }, + SwarmEvent::Behaviour(BehaviourOut::AutoNAT(event)) => { + debug!( + target: "sub-libp2p", + "AutoNAT => {:?}", + event, + ); + }, SwarmEvent::Behaviour(BehaviourOut::None) => { // Ignored event from lower layers. }, From 09f1ab6db007499635cb72f49c6a0f1adc588498 Mon Sep 17 00:00:00 2001 From: Anton Kaliaev Date: Mon, 17 Jul 2023 11:02:18 +0400 Subject: [PATCH 35/42] fix SyncNotificationsClogged invariant --- client/network/src/service.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/network/src/service.rs b/client/network/src/service.rs index 35f001e0075d8..acee73eb9c50b 100644 --- a/client/network/src/service.rs +++ b/client/network/src/service.rs @@ -1581,9 +1581,9 @@ where // Either::Right(PingFailure::Timeout), // )))) => "ping-timeout", Some(ConnectionError::Handler(Either::Left(Either::Left( - Either::Left(Either::Left( + Either::Left(Either::Left(Either::Left( NotifsHandlerError::SyncNotificationsClogged, - )), + ))), )))) => "sync-notifications-clogged", Some(ConnectionError::Handler(_)) => "protocol-error", Some(ConnectionError::KeepAliveTimeout) => "keep-alive-timeout", From 2b1377ca2340c12ade5920d792582bb1c7aae01f Mon Sep 17 00:00:00 2001 From: Anton Kaliaev Date: Mon, 17 Jul 2023 11:34:50 +0400 Subject: [PATCH 36/42] only set server mode manually in tests doubt that we need to set it on node since we're adding public addresses --- client/network/src/discovery.rs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/client/network/src/discovery.rs b/client/network/src/discovery.rs index c0ecd17b62aff..0e2a3503197fe 100644 --- a/client/network/src/discovery.rs +++ b/client/network/src/discovery.rs @@ -55,7 +55,6 @@ use ip_network::IpNetwork; use libp2p::{ core::{Endpoint, Multiaddr}, kad::{ - self, record::store::{MemoryStore, RecordStore}, GetClosestPeersError, GetRecordOk, Kademlia, KademliaBucketInserts, KademliaConfig, KademliaEvent, QueryId, QueryResult, Quorum, Record, RecordKey, @@ -223,7 +222,6 @@ impl DiscoveryConfig { let store = MemoryStore::new(local_peer_id); let mut kad = Kademlia::with_config(local_peer_id, store, config); - kad.set_mode(Some(kad::Mode::Server)); for (peer_id, addr) in &permanent_addresses { kad.add_address(peer_id, addr.clone()); @@ -992,7 +990,7 @@ mod tests { upgrade, }, identity::Keypair, - noise, + kad, noise, swarm::{Executor, Swarm, SwarmBuilder, SwarmEvent}, yamux, Multiaddr, }; @@ -1046,6 +1044,16 @@ mod tests { TokioExecutor(runtime), ) .build(); + // Set the Kademlia mode to server so that it can accept incoming requests. + // + // Note: the server mode is set automatically when the node learns its external + // address, but that does not happen in tests => hence we set it manually. + swarm + .behaviour_mut() + .kademlia + .as_mut() + .unwrap() + .set_mode(Some(kad::Mode::Server)); let listen_addr: Multiaddr = format!("/memory/{}", rand::random::()).parse().unwrap(); From c45b4655e0a948d9c004dc74a90e2adafb1dfc59 Mon Sep 17 00:00:00 2001 From: Anton Kaliaev Date: Tue, 18 Jul 2023 11:14:01 +0400 Subject: [PATCH 37/42] address @dmitry-markin comments --- Cargo.lock | 148 ++++++++++++++++++++++++++++---- client/network/src/discovery.rs | 17 ++-- client/network/src/service.rs | 12 ++- 3 files changed, 148 insertions(+), 29 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 45ca960ab74d8..0b3297d5feb8c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -36,6 +36,16 @@ dependencies = [ "generic-array 0.14.7", ] +[[package]] +name = "aead" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d122413f284cf2d62fb1b7db97e02edb8cda96d769b16e443a4f6195e35662b0" +dependencies = [ + "crypto-common", + "generic-array 0.14.7", +] + [[package]] name = "aes" version = "0.7.5" @@ -43,22 +53,47 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9e8b47f52ea9bae42228d07ec09eb676433d7c4ed1ebdf0f1d1c29ed446f1ab8" dependencies = [ "cfg-if", - "cipher", + "cipher 0.3.0", "cpufeatures", "opaque-debug 0.3.0", ] +[[package]] +name = "aes" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac1f845298e95f983ff1944b728ae08b8cebab80d684f0a832ed0fc74dfa27e2" +dependencies = [ + "cfg-if", + "cipher 0.4.4", + "cpufeatures", +] + [[package]] name = "aes-gcm" version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "df5f85a83a7d8b0442b6aa7b504b8212c1733da07b98aae43d4bc21b2cb3cdf6" dependencies = [ - "aead", - "aes", - "cipher", - "ctr", - "ghash", + "aead 0.4.3", + "aes 0.7.5", + "cipher 0.3.0", + "ctr 0.8.0", + "ghash 0.4.4", + "subtle", +] + +[[package]] +name = "aes-gcm" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "209b47e8954a928e1d72e86eca7000ebb6655fe1436d33eefc2201cad027e237" +dependencies = [ + "aead 0.5.2", + "aes 0.8.3", + "cipher 0.4.4", + "ctr 0.9.2", + "ghash 0.5.0", "subtle", ] @@ -988,7 +1023,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5c80e5460aa66fe3b91d40bcbdab953a597b60053e34d684ac6903f863b680a6" dependencies = [ "cfg-if", - "cipher", + "cipher 0.3.0", "cpufeatures", "zeroize", ] @@ -999,9 +1034,9 @@ version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a18446b09be63d457bbec447509e85f662f32952b035ce892290396bc0b0cff5" dependencies = [ - "aead", + "aead 0.4.3", "chacha20", - "cipher", + "cipher 0.3.0", "poly1305", "zeroize", ] @@ -1084,6 +1119,16 @@ dependencies = [ "generic-array 0.14.7", ] +[[package]] +name = "cipher" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad" +dependencies = [ + "crypto-common", + "inout", +] + [[package]] name = "ckb-merkle-mountain-range" version = "0.5.2" @@ -1505,6 +1550,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" dependencies = [ "generic-array 0.14.7", + "rand_core 0.6.4", "typenum", ] @@ -1544,7 +1590,16 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "049bb91fb4aaf0e3c7efa6cd5ef877dbbbd15b39dad06d9948de4ec8a75761ea" dependencies = [ - "cipher", + "cipher 0.3.0", +] + +[[package]] +name = "ctr" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0369ee1ad671834580515889b80f2ea915f23b8be8d0daa4bbaf2ac5c7590835" +dependencies = [ + "cipher 0.4.4", ] [[package]] @@ -2843,7 +2898,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1583cc1656d7839fd3732b80cf4f38850336cdb9b8ded1cd399ca62958de3c99" dependencies = [ "opaque-debug 0.3.0", - "polyval", + "polyval 0.5.3", +] + +[[package]] +name = "ghash" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d930750de5717d2dd0b8c0d42c076c0e884c81a73e6cab859bbd2339c71e3e40" +dependencies = [ + "opaque-debug 0.3.0", + "polyval 0.6.1", ] [[package]] @@ -3001,6 +3066,15 @@ version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ebdb29d2ea9ed0083cd8cece49bbd968021bd99b0849edb4a9a7ee0fdf6a4e0" +[[package]] +name = "hkdf" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "791a029f6b9fc27657f6f188ec6e5e43f6911f6f878e0dc5501396e09809d437" +dependencies = [ + "hmac 0.12.1", +] + [[package]] name = "hmac" version = "0.8.1" @@ -3327,6 +3401,15 @@ dependencies = [ "unicode-width", ] +[[package]] +name = "inout" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0c10553d664a4d0bcff9f4215d0aac67a639cc68ef660840afe309b807bc9f5" +dependencies = [ + "generic-array 0.14.7", +] + [[package]] name = "instant" version = "0.1.12" @@ -4041,7 +4124,7 @@ dependencies = [ "snow", "static_assertions", "thiserror", - "x25519-dalek", + "x25519-dalek 1.1.1", "zeroize", ] @@ -7500,7 +7583,7 @@ checksum = "048aeb476be11a4b6ca432ca569e375810de9294ae78f4774e78ea98a9246ede" dependencies = [ "cpufeatures", "opaque-debug 0.3.0", - "universal-hash", + "universal-hash 0.4.1", ] [[package]] @@ -7512,7 +7595,19 @@ dependencies = [ "cfg-if", "cpufeatures", "opaque-debug 0.3.0", - "universal-hash", + "universal-hash 0.4.1", +] + +[[package]] +name = "polyval" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d52cff9d1d4dee5fe6d03729099f4a310a41179e0a10dbf542039873f2e826fb" +dependencies = [ + "cfg-if", + "cpufeatures", + "opaque-debug 0.3.0", + "universal-hash 0.5.1", ] [[package]] @@ -10093,7 +10188,7 @@ version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5ccba027ba85743e09d15c03296797cad56395089b832b48b5a5217880f57733" dependencies = [ - "aes-gcm", + "aes-gcm 0.9.4", "blake2", "chacha20poly1305", "curve25519-dalek 4.0.0-rc.1", @@ -10936,7 +11031,7 @@ dependencies = [ "parity-scale-codec", "rand 0.8.5", "scale-info", - "sha2 0.10.6", + "sha2 0.10.7", "sp-api", "sp-application-crypto", "sp-core", @@ -12286,6 +12381,16 @@ dependencies = [ "subtle", ] +[[package]] +name = "universal-hash" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc1de2c688dc15305988b563c3854064043356019f97a4b46276fe734c4f07ea" +dependencies = [ + "crypto-common", + "subtle", +] + [[package]] name = "unsigned-varint" version = "0.7.1" @@ -13155,6 +13260,17 @@ dependencies = [ "zeroize", ] +[[package]] +name = "x25519-dalek" +version = "2.0.0-pre.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5da623d8af10a62342bcbbb230e33e58a63255a58012f8653c578e54bab48df" +dependencies = [ + "curve25519-dalek 3.2.0", + "rand_core 0.6.4", + "zeroize", +] + [[package]] name = "xattr" version = "0.2.3" diff --git a/client/network/src/discovery.rs b/client/network/src/discovery.rs index ba0d9a9980687..d1b09be75aedb 100644 --- a/client/network/src/discovery.rs +++ b/client/network/src/discovery.rs @@ -1044,16 +1044,21 @@ mod tests { TokioExecutor(runtime), ) .build(); + // Set the Kademlia mode to server so that it can accept incoming requests. // // Note: the server mode is set automatically when the node learns its external // address, but that does not happen in tests => hence we set it manually. - swarm - .behaviour_mut() - .kademlia - .as_mut() - .unwrap() - .set_mode(Some(kad::Mode::Server)); + if i != 0 { + // leave the first swarm in client mode + swarm + .behaviour_mut() + .kademlia + .as_mut() + .unwrap() + .set_mode(Some(kad::Mode::Server)); + } + let listen_addr: Multiaddr = format!("/memory/{}", rand::random::()).parse().unwrap(); diff --git a/client/network/src/service.rs b/client/network/src/service.rs index acee73eb9c50b..f187d9087e5f8 100644 --- a/client/network/src/service.rs +++ b/client/network/src/service.rs @@ -61,13 +61,11 @@ use libp2p::{ identify::Info as IdentifyInfo, kad::record::Key as KademliaKey, multiaddr, - // ping::Failure as PingFailure, swarm::{ ConnectionError, ConnectionId, DialError, Executor, ListenError, NetworkBehaviour, Swarm, SwarmBuilder, SwarmEvent, THandlerErr, }, - Multiaddr, - PeerId, + Multiaddr, PeerId, }; use log::{debug, error, info, trace, warn}; use metrics::{Histogram, HistogramVec, MetricSources, Metrics}; @@ -1577,9 +1575,9 @@ where }; let reason = match cause { Some(ConnectionError::IO(_)) => "transport-error", - // Some(ConnectionError::Handler(Either::Left(Either::Left( - // Either::Right(PingFailure::Timeout), - // )))) => "ping-timeout", + Some(ConnectionError::Handler(Either::Left(Either::Left( + Either::Left(Either::Right(_)), + )))) => "ping-timeout", Some(ConnectionError::Handler(Either::Left(Either::Left( Either::Left(Either::Left(Either::Left( NotifsHandlerError::SyncNotificationsClogged, @@ -1683,7 +1681,7 @@ where debug!( target: "sub-libp2p", "Libp2p => IncomingConnectionError({},{} via {:?}): {}", - local_addr, send_back_addr, connection_id, error, + local_addr, send_back_addr, connection_id, error, ); if let Some(metrics) = self.metrics.as_ref() { #[allow(deprecated)] From d464408c81a83bf355758bc9c128cb12626b9ff0 Mon Sep 17 00:00:00 2001 From: Anton Kaliaev Date: Tue, 18 Jul 2023 13:00:30 +0400 Subject: [PATCH 38/42] remove autonat --- Cargo.lock | 20 -------------------- client/network/Cargo.toml | 2 +- client/network/src/behaviour.rs | 14 +------------- client/network/src/discovery.rs | 15 ++++++--------- client/network/src/service.rs | 22 ++++++++++++---------- 5 files changed, 20 insertions(+), 53 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0b3297d5feb8c..56f521599d6c7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3891,7 +3891,6 @@ dependencies = [ "getrandom 0.2.9", "instant", "libp2p-allow-block-list", - "libp2p-autonat", "libp2p-connection-limits", "libp2p-core", "libp2p-dns", @@ -3924,25 +3923,6 @@ dependencies = [ "void", ] -[[package]] -name = "libp2p-autonat" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e907be08be5e4152317a79d310a6f501a1b5c02a81dcb065dc865475bbae9498" -dependencies = [ - "async-trait", - "futures", - "futures-timer", - "instant", - "libp2p-core", - "libp2p-identity", - "libp2p-request-response", - "libp2p-swarm", - "log", - "quick-protobuf", - "rand 0.8.5", -] - [[package]] name = "libp2p-connection-limits" version = "0.2.0" diff --git a/client/network/Cargo.toml b/client/network/Cargo.toml index d07993aae8cf0..76cea439e3c1e 100644 --- a/client/network/Cargo.toml +++ b/client/network/Cargo.toml @@ -25,7 +25,7 @@ fnv = "1.0.6" futures = "0.3.21" futures-timer = "3.0.2" ip_network = "0.4.1" -libp2p = { version = "0.52.1", features = ["autonat", "dns", "identify", "kad", "macros", "mdns", "noise", "ping", "tcp", "tokio", "yamux", "websocket", "request-response"] } +libp2p = { version = "0.52.1", features = ["dns", "identify", "kad", "macros", "mdns", "noise", "ping", "tcp", "tokio", "yamux", "websocket", "request-response"] } libp2p-kad = { version = "0.44.2" } linked_hash_set = "0.1.3" log = "0.4.17" diff --git a/client/network/src/behaviour.rs b/client/network/src/behaviour.rs index 40bbdf66d89e3..7eae870839f55 100644 --- a/client/network/src/behaviour.rs +++ b/client/network/src/behaviour.rs @@ -30,7 +30,7 @@ use crate::{ use bytes::Bytes; use futures::channel::oneshot; use libp2p::{ - autonat, connection_limits::ConnectionLimits, core::Multiaddr, identify::Info as IdentifyInfo, + connection_limits::ConnectionLimits, core::Multiaddr, identify::Info as IdentifyInfo, identity::PublicKey, kad::RecordKey, swarm::NetworkBehaviour, PeerId, }; @@ -55,8 +55,6 @@ pub struct Behaviour { connection_limits: libp2p::connection_limits::Behaviour, /// Generic request-response protocols. request_responses: request_responses::RequestResponsesBehaviour, - // AutoNAT. - auto_nat: autonat::Behaviour, } /// Event generated by `Behaviour`. @@ -162,9 +160,6 @@ pub enum BehaviourOut { /// request duration. Dht(DhtEvent, Duration), - /// Event generated by the AutoNAT. - AutoNAT(autonat::Event), - /// Ignored event generated by lower layers. None, } @@ -190,7 +185,6 @@ impl Behaviour { request_response_protocols.into_iter(), peerset, )?, - auto_nat: autonat::Behaviour::new(local_peer_id, autonat::Config::default()), }) } @@ -363,12 +357,6 @@ impl From for BehaviourOut { } } -impl From for BehaviourOut { - fn from(event: autonat::Event) -> Self { - BehaviourOut::AutoNAT(event) - } -} - impl From for BehaviourOut { fn from(e: void::Void) -> Self { void::unreachable(e) diff --git a/client/network/src/discovery.rs b/client/network/src/discovery.rs index d1b09be75aedb..77224c3a0fd5b 100644 --- a/client/network/src/discovery.rs +++ b/client/network/src/discovery.rs @@ -1049,15 +1049,12 @@ mod tests { // // Note: the server mode is set automatically when the node learns its external // address, but that does not happen in tests => hence we set it manually. - if i != 0 { - // leave the first swarm in client mode - swarm - .behaviour_mut() - .kademlia - .as_mut() - .unwrap() - .set_mode(Some(kad::Mode::Server)); - } + swarm + .behaviour_mut() + .kademlia + .as_mut() + .unwrap() + .set_mode(Some(kad::Mode::Server)); let listen_addr: Multiaddr = format!("/memory/{}", rand::random::()).parse().unwrap(); diff --git a/client/network/src/service.rs b/client/network/src/service.rs index f187d9087e5f8..28ad85074c466 100644 --- a/client/network/src/service.rs +++ b/client/network/src/service.rs @@ -1390,7 +1390,12 @@ where peer_id, info: IdentifyInfo { - protocol_version, agent_version, mut listen_addrs, protocols, .. + protocol_version, + agent_version, + mut listen_addrs, + protocols, + observed_addr, + .. }, }) => { if listen_addrs.len() > 30 { @@ -1409,6 +1414,10 @@ where ); } self.network_service.behaviour_mut().user_protocol_mut().add_known_peer(peer_id); + // Confirm the observed address manually since they are no longer trusted by + // default (libp2p >= 0.52) + // TODO: remove this when/if AutoNAT is implemented. + self.network_service.add_external_address(observed_addr); }, SwarmEvent::Behaviour(BehaviourOut::Discovered(peer_id)) => { self.network_service.behaviour_mut().user_protocol_mut().add_known_peer(peer_id); @@ -1525,13 +1534,6 @@ where self.event_streams.send(Event::Dht(event)); }, - SwarmEvent::Behaviour(BehaviourOut::AutoNAT(event)) => { - debug!( - target: "sub-libp2p", - "AutoNAT => {:?}", - event, - ); - }, SwarmEvent::Behaviour(BehaviourOut::None) => { // Ignored event from lower layers. }, @@ -1579,9 +1581,9 @@ where Either::Left(Either::Right(_)), )))) => "ping-timeout", Some(ConnectionError::Handler(Either::Left(Either::Left( - Either::Left(Either::Left(Either::Left( + Either::Left(Either::Left( NotifsHandlerError::SyncNotificationsClogged, - ))), + )), )))) => "sync-notifications-clogged", Some(ConnectionError::Handler(_)) => "protocol-error", Some(ConnectionError::KeepAliveTimeout) => "keep-alive-timeout", From 8b9309d542a1c6c171af2921beb4a757ed1c0386 Mon Sep 17 00:00:00 2001 From: Anton Kaliaev Date: Tue, 18 Jul 2023 13:11:43 +0400 Subject: [PATCH 39/42] removed unused var --- client/network/src/behaviour.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/client/network/src/behaviour.rs b/client/network/src/behaviour.rs index 7eae870839f55..4799807d2cb33 100644 --- a/client/network/src/behaviour.rs +++ b/client/network/src/behaviour.rs @@ -175,7 +175,6 @@ impl Behaviour { peerset: PeersetHandle, connection_limits: ConnectionLimits, ) -> Result { - let local_peer_id = local_public_key.to_peer_id(); Ok(Self { substrate, peer_info: peer_info::PeerInfoBehaviour::new(user_agent, local_public_key), From 73df4d5ae55d1fe054fc10a4b31cfbecc6327cfd Mon Sep 17 00:00:00 2001 From: Anton Kaliaev Date: Tue, 18 Jul 2023 13:28:42 +0400 Subject: [PATCH 40/42] fix EOL --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 8a253fdc9b2dc..95acf0b9702cb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -340,4 +340,4 @@ inherits = "release" # https://doc.rust-lang.org/rustc/linker-plugin-lto.html lto = "fat" # https://doc.rust-lang.org/rustc/codegen-options/index.html#codegen-units -codegen-units = 1 \ No newline at end of file +codegen-units = 1 From d44efb593721f5f711f0a602c0468df2775c2484 Mon Sep 17 00:00:00 2001 From: Anton Kaliaev Date: Wed, 19 Jul 2023 10:42:53 +0400 Subject: [PATCH 41/42] update smallvec and sha2 in attempt to compile polkadot --- client/network/Cargo.toml | 2 +- client/network/sync/Cargo.toml | 2 +- frame/support/Cargo.toml | 2 +- primitives/core/hashing/Cargo.toml | 2 +- primitives/state-machine/Cargo.toml | 2 +- primitives/statement-store/Cargo.toml | 2 +- primitives/weights/Cargo.toml | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/client/network/Cargo.toml b/client/network/Cargo.toml index 76cea439e3c1e..e716978f409fa 100644 --- a/client/network/Cargo.toml +++ b/client/network/Cargo.toml @@ -36,7 +36,7 @@ pin-project = "1.0.12" rand = "0.8.5" serde = { version = "1.0.163", features = ["derive"] } serde_json = "1.0.85" -smallvec = "1.8.0" +smallvec = "1.11.0" thiserror = "1.0" unsigned-varint = { version = "0.7.1", features = ["futures", "asynchronous_codec"] } void = "1" diff --git a/client/network/sync/Cargo.toml b/client/network/sync/Cargo.toml index 2c17c7fa52210..53bb987a6f486 100644 --- a/client/network/sync/Cargo.toml +++ b/client/network/sync/Cargo.toml @@ -27,7 +27,7 @@ log = "0.4.17" mockall = "0.11.3" prost = "0.11" schnellru = "0.2.1" -smallvec = "1.8.0" +smallvec = "1.11.0" thiserror = "1.0" fork-tree = { version = "3.0.0", path = "../../../utils/fork-tree" } prometheus-endpoint = { package = "substrate-prometheus-endpoint", version = "0.10.0-dev", path = "../../../utils/prometheus" } diff --git a/frame/support/Cargo.toml b/frame/support/Cargo.toml index f483c632a9698..34678890b2598 100644 --- a/frame/support/Cargo.toml +++ b/frame/support/Cargo.toml @@ -35,7 +35,7 @@ paste = "1.0" sp-state-machine = { version = "0.28.0", default-features = false, optional = true, path = "../../primitives/state-machine" } bitflags = "1.3" impl-trait-for-tuples = "0.2.2" -smallvec = "1.8.0" +smallvec = "1.11.0" log = { version = "0.4.17", default-features = false } sp-core-hashing-proc-macro = { version = "9.0.0", path = "../../primitives/core/hashing/proc-macro" } k256 = { version = "0.13.0", default-features = false, features = ["ecdsa"] } diff --git a/primitives/core/hashing/Cargo.toml b/primitives/core/hashing/Cargo.toml index 9b7fdabd3d481..43a13883358ea 100644 --- a/primitives/core/hashing/Cargo.toml +++ b/primitives/core/hashing/Cargo.toml @@ -16,7 +16,7 @@ targets = ["x86_64-unknown-linux-gnu"] blake2b_simd = { version = "1.0.1", default-features = false } byteorder = { version = "1.3.2", default-features = false } digest = { version = "0.10.3", default-features = false } -sha2 = { version = "0.10.2", default-features = false } +sha2 = { version = "0.10.7", default-features = false } sha3 = { version = "0.10.0", default-features = false } twox-hash = { version = "1.6.3", default-features = false, features = ["digest_0_10"] } diff --git a/primitives/state-machine/Cargo.toml b/primitives/state-machine/Cargo.toml index cffa4236c2a2f..302f05324c8b1 100644 --- a/primitives/state-machine/Cargo.toml +++ b/primitives/state-machine/Cargo.toml @@ -19,7 +19,7 @@ hash-db = { version = "0.16.0", default-features = false } log = { version = "0.4.17", default-features = false } parking_lot = { version = "0.12.1", optional = true } rand = { version = "0.8.5", optional = true } -smallvec = "1.8.0" +smallvec = "1.11.0" thiserror = { version = "1.0.30", optional = true } tracing = { version = "0.1.29", optional = true } sp-core = { version = "21.0.0", default-features = false, path = "../core" } diff --git a/primitives/statement-store/Cargo.toml b/primitives/statement-store/Cargo.toml index 02ee6f4c15521..ea240e6e2527e 100644 --- a/primitives/statement-store/Cargo.toml +++ b/primitives/statement-store/Cargo.toml @@ -30,7 +30,7 @@ x25519-dalek = { version = "2.0.0-pre.1", optional = true } curve25519-dalek = { version = "3.2", optional = true } aes-gcm = { version = "0.10", optional = true } hkdf = { version = "0.12.0", optional = true } -sha2 = { version = "0.10.0", optional = true } +sha2 = { version = "0.10.7", optional = true } rand = { version = "0.8.5", features = ["small_rng"], optional = true } [features] diff --git a/primitives/weights/Cargo.toml b/primitives/weights/Cargo.toml index 32c0d486cb11f..05fc58a10e105 100644 --- a/primitives/weights/Cargo.toml +++ b/primitives/weights/Cargo.toml @@ -16,7 +16,7 @@ targets = ["x86_64-unknown-linux-gnu"] codec = { package = "parity-scale-codec", version = "3.6.1", default-features = false, features = ["derive"] } scale-info = { version = "2.5.0", default-features = false, features = ["derive"] } serde = { version = "1.0.163", default-features = false, optional = true, features = ["derive", "alloc"] } -smallvec = "1.8.0" +smallvec = "1.11.0" sp-arithmetic = { version = "16.0.0", default-features = false, path = "../arithmetic" } sp-core = { version = "21.0.0", default-features = false, path = "../core" } sp-debug-derive = { version = "8.0.0", default-features = false, path = "../debug-derive" } From ff76e2a25c2edcb7c931ff75ccdce62cfd471988 Mon Sep 17 00:00:00 2001 From: Anton Kaliaev Date: Wed, 19 Jul 2023 15:15:44 +0400 Subject: [PATCH 42/42] bump k256 in attempt to build cumulus --- frame/support/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/support/Cargo.toml b/frame/support/Cargo.toml index 34678890b2598..cadfd02b4cc75 100644 --- a/frame/support/Cargo.toml +++ b/frame/support/Cargo.toml @@ -38,7 +38,7 @@ impl-trait-for-tuples = "0.2.2" smallvec = "1.11.0" log = { version = "0.4.17", default-features = false } sp-core-hashing-proc-macro = { version = "9.0.0", path = "../../primitives/core/hashing/proc-macro" } -k256 = { version = "0.13.0", default-features = false, features = ["ecdsa"] } +k256 = { version = "0.13.1", default-features = false, features = ["ecdsa"] } environmental = { version = "1.1.4", default-features = false } aquamarine = { version = "0.3.2" }