From caf0f4bcee90fc405de73b1cb445ea69e4761c58 Mon Sep 17 00:00:00 2001 From: Diva M Date: Wed, 9 Feb 2022 18:37:19 -0500 Subject: [PATCH] libp2p upgrade + gossipsub interval fix fix rpc NB impl use commit hash update tests more test updates more test updates --- Cargo.lock | 381 ++++++++++-------- beacon_node/client/src/builder.rs | 2 +- beacon_node/http_api/tests/common.rs | 2 +- beacon_node/http_metrics/src/lib.rs | 2 +- beacon_node/http_metrics/src/metrics.rs | 2 +- beacon_node/lighthouse_network/Cargo.toml | 6 +- .../lighthouse_network/src/discovery/mod.rs | 18 - beacon_node/lighthouse_network/src/lib.rs | 2 +- .../src/peer_manager/network_behaviour.rs | 13 +- beacon_node/lighthouse_network/src/rpc/mod.rs | 37 +- beacon_node/lighthouse_network/src/service.rs | 2 +- .../tests/common/behaviour.rs | 127 ++++-- beacon_node/network/src/service.rs | 2 +- 13 files changed, 340 insertions(+), 256 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a3446fce255..4e33767dec7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -214,7 +214,7 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b88d82667eca772c4aa12f0f1348b3ae643424c8876448f3f7bd5787032e234c" dependencies = [ - "autocfg 1.0.1", + "autocfg 1.1.0", ] [[package]] @@ -241,15 +241,18 @@ dependencies = [ [[package]] name = "autocfg" -version = "0.1.7" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d49d90015b3c36167a20fe2810c5cd875ad504b39cff3d4eae7977e6b7c1cb2" +checksum = "0dde43e75fd43e8a1bf86103336bc699aa8d17ad1be60c76c0bdfd4828e19b78" +dependencies = [ + "autocfg 1.1.0", +] [[package]] name = "autocfg" -version = "1.0.1" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "backtrace" @@ -430,13 +433,11 @@ dependencies = [ [[package]] name = "blake2" -version = "0.9.2" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a4e37d16930f5459780f5621038b6382b9bb37c19016f39fb6b5808d831f174" +checksum = "b94ba84325db59637ffc528bbe8c7f86c02c57cff5c0e2b9b00f9a851f42f309" dependencies = [ - "crypto-mac 0.8.0", - "digest 0.9.0", - "opaque-debug", + "digest 0.10.1", ] [[package]] @@ -451,9 +452,9 @@ dependencies = [ [[package]] name = "block-buffer" -version = "0.10.1" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03588e54c62ae6d763e2a80090d50353b785795361b4ff5b3bf0a5097fc31c0b" +checksum = "0bf7fe51849ea569fd452f37822f606a5cabb684dc918707a0193fd4664ff324" dependencies = [ "generic-array", ] @@ -646,21 +647,21 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chacha20" -version = "0.7.1" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fee7ad89dc1128635074c268ee661f90c3f7e83d9fd12910608c36b47d6c3412" +checksum = "01b72a433d0cf2aef113ba70f62634c56fddb0f244e6377185c56a7cadbd8f91" dependencies = [ "cfg-if", "cipher", - "cpufeatures 0.1.5", + "cpufeatures 0.2.1", "zeroize", ] [[package]] name = "chacha20poly1305" -version = "0.8.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1580317203210c517b6d44794abfbe600698276db18127e37ad3e69bf5e848e5" +checksum = "3b84ed6d1d5f7aa9bdde921a5090e0ca4d934d250ea3b402a5fab3a994e28a2a" dependencies = [ "aead", "chacha20", @@ -815,9 +816,9 @@ checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" [[package]] name = "core-foundation" -version = "0.9.2" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6888e10551bb93e424d8df1d07f1a8b4fceb0001a3a4b048bfc47554946f47b3" +checksum = "194a7a9e6de53fa55116934067c844d9d749312f75c6f6d0980e8c252f8c2146" dependencies = [ "core-foundation-sys", "libc", @@ -829,6 +830,15 @@ version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" +[[package]] +name = "core2" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b49ba7ef1ad6107f8824dbe97de947cbaac53c44e7f9756a1fba0d37c1eec505" +dependencies = [ + "memchr", +] + [[package]] name = "cpufeatures" version = "0.1.5" @@ -849,9 +859,9 @@ dependencies = [ [[package]] name = "crc32fast" -version = "1.3.1" +version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2209c310e29876f7f0b2721e7e26b84aff178aa3da5d091f9bfbf47669e60e3" +checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" dependencies = [ "cfg-if", ] @@ -1025,6 +1035,19 @@ dependencies = [ "zeroize", ] +[[package]] +name = "curve25519-dalek" +version = "4.0.0-pre.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4033478fbf70d6acf2655ac70da91ee65852d69daf7a67bf7a2f518fb47aafcf" +dependencies = [ + "byteorder", + "digest 0.9.0", + "rand_core 0.6.3", + "subtle", + "zeroize", +] + [[package]] name = "darling" version = "0.13.1" @@ -1161,9 +1184,10 @@ version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b697d66081d42af4fba142d56918a3cb21dc8eb63372c6b85d14f44fb9c5979b" dependencies = [ - "block-buffer 0.10.1", + "block-buffer 0.10.2", "crypto-common", "generic-array", + "subtle", ] [[package]] @@ -1233,7 +1257,7 @@ dependencies = [ "hex", "hkdf", "lazy_static", - "libp2p-core 0.30.0", + "libp2p-core 0.30.2", "lru", "parking_lot", "rand 0.8.4", @@ -1282,7 +1306,7 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c762bae6dcaf24c4c84667b8579785430908723d5c889f469d76a41d59cc7a9d" dependencies = [ - "curve25519-dalek", + "curve25519-dalek 3.2.0", "ed25519", "rand 0.7.3", "serde", @@ -1985,9 +2009,9 @@ checksum = "fed34cd105917e91daa4da6b3728c47b068749d6a62c59811f06ed2ac71d9da7" [[package]] name = "futures" -version = "0.3.19" +version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28560757fe2bb34e79f907794bb6b22ae8b0e5c669b638a1132f2592b19035b4" +checksum = "f73fe65f54d1e12b726f517d3e2135ca3125a437b6d998caf1962961f7172d9e" dependencies = [ "futures-channel", "futures-core", @@ -2000,9 +2024,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.19" +version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba3dda0b6588335f360afc675d0564c17a77a2bda81ca178a4b6081bd86c7f0b" +checksum = "c3083ce4b914124575708913bca19bfe887522d6e2e6d0952943f5eac4a74010" dependencies = [ "futures-core", "futures-sink", @@ -2010,15 +2034,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.19" +version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0c8ff0461b82559810cdccfde3215c3f373807f5e5232b71479bff7bb2583d7" +checksum = "0c09fd04b7e4073ac7156a9539b57a484a8ea920f79c7c675d05d289ab6110d3" [[package]] name = "futures-executor" -version = "0.3.19" +version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29d6d2ff5bb10fb95c85b8ce46538a2e5f5e7fdc755623a7d4529ab8a4ed9d2a" +checksum = "9420b90cfa29e327d0429f19be13e7ddb68fa1cccb09d65e5706b8c7a749b8a6" dependencies = [ "futures-core", "futures-task", @@ -2028,15 +2052,15 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.19" +version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1f9d34af5a1aac6fb380f735fe510746c38067c5bf16c7fd250280503c971b2" +checksum = "fc4045962a5a5e935ee2fdedaa4e08284547402885ab326734432bed5d12966b" [[package]] name = "futures-macro" -version = "0.3.19" +version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6dbd947adfffb0efc70599b3ddcf7b5597bb5fa9e245eb99f62b3a5f7bb8bd3c" +checksum = "33c1e13800337f4d4d7a316bf45a567dbcb6ffe087f16424852d97e97a91f512" dependencies = [ "proc-macro2", "quote", @@ -2056,15 +2080,15 @@ dependencies = [ [[package]] name = "futures-sink" -version = "0.3.19" +version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3055baccb68d74ff6480350f8d6eb8fcfa3aa11bdc1a1ae3afdd0514617d508" +checksum = "21163e139fa306126e6eedaf49ecdb4588f939600f0b1e770f4205ee4b7fa868" [[package]] name = "futures-task" -version = "0.3.19" +version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ee7c6485c30167ce4dfb83ac568a849fe53274c831081476ee13e0dce1aad72" +checksum = "57c66a976bf5909d801bbef33416c41372779507e7a6b3a5e25e4749c58f776a" [[package]] name = "futures-timer" @@ -2074,9 +2098,9 @@ checksum = "e64b03909df88034c26dc1547e8970b91f98bdb65165d6a4e9110d94263dbb2c" [[package]] name = "futures-util" -version = "0.3.19" +version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9b5cf40b47a271f77a8b1bec03ca09044d99d2372c0de244e66430761127164" +checksum = "d8b7abd5d659d9b90c8cba917f6ec750a74e2dc23902ef9cd4cc8c8b22e6036a" dependencies = [ "futures-channel", "futures-core", @@ -2435,9 +2459,9 @@ dependencies = [ [[package]] name = "httparse" -version = "1.5.1" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "acd94fdbe1d4ff688b67b04eee2e17bd50995534a61539e45adfefb45e5e5503" +checksum = "9100414882e15fb7feccb4897e5f0ff0ff1ca7d1a86a23208ada4d7a18e6c6c4" [[package]] name = "httpdate" @@ -2596,9 +2620,9 @@ dependencies = [ [[package]] name = "impl-trait-for-tuples" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5dacb10c5b3bb92d46ba347505a9041e676bb20ad220101326bffb0c93031ee" +checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb" dependencies = [ "proc-macro2", "quote", @@ -2611,7 +2635,7 @@ version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282a6247722caba404c065016bbfa522806e51714c34f5dfc3e4a3a46fcb4223" dependencies = [ - "autocfg 1.0.1", + "autocfg 1.1.0", "hashbrown", ] @@ -2841,9 +2865,9 @@ dependencies = [ [[package]] name = "libm" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7d73b3f436185384286bd8098d17ec07c9a7d2388a6599f824d8502b529702a" +checksum = "33a33a362ce288760ec6a508b94caaec573ae7d3bbbd91b87aa0bad4456839db" [[package]] name = "libmdbx" @@ -2863,9 +2887,8 @@ dependencies = [ [[package]] name = "libp2p" -version = "0.42.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98b2368208a825a2eee46fc5f2db54204074404f102b22b24cd7666a5e622ed8" +version = "0.43.0" +source = "git+https://github.com/sigp/rust-libp2p?rev=e213703e616eaba3c482d7714775e0d37c4ae8e5#e213703e616eaba3c482d7714775e0d37c4ae8e5" dependencies = [ "atomic", "bytes", @@ -2874,7 +2897,7 @@ dependencies = [ "getrandom 0.2.4", "instant", "lazy_static", - "libp2p-core 0.31.0", + "libp2p-core 0.32.0", "libp2p-dns", "libp2p-gossipsub", "libp2p-identify", @@ -2887,7 +2910,7 @@ dependencies = [ "libp2p-tcp", "libp2p-websocket", "libp2p-yamux", - "multiaddr", + "multiaddr 0.14.0", "parking_lot", "pin-project 1.0.10", "rand 0.7.3", @@ -2896,9 +2919,9 @@ dependencies = [ [[package]] name = "libp2p-core" -version = "0.30.0" +version = "0.30.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef22d9bba1e8bcb7ec300073e6802943fe8abb8190431842262b5f1c30abba1" +checksum = "86aad7d54df283db817becded03e611137698a6509d4237a96881976a162340c" dependencies = [ "asn1_der", "bs58", @@ -2907,11 +2930,12 @@ dependencies = [ "fnv", "futures", "futures-timer", + "instant", "lazy_static", "libsecp256k1 0.7.0", "log", - "multiaddr", - "multihash", + "multiaddr 0.13.0", + "multihash 0.14.0", "multistream-select 0.10.4", "parking_lot", "pin-project 1.0.10", @@ -2930,9 +2954,8 @@ dependencies = [ [[package]] name = "libp2p-core" -version = "0.31.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a24250cce58fb6ccb32e26647c1c25b48b6f7bd2d6fb3d6dba72001a6694b385" +version = "0.32.0" +source = "git+https://github.com/sigp/rust-libp2p?rev=e213703e616eaba3c482d7714775e0d37c4ae8e5#e213703e616eaba3c482d7714775e0d37c4ae8e5" dependencies = [ "asn1_der", "bs58", @@ -2945,8 +2968,8 @@ dependencies = [ "lazy_static", "libsecp256k1 0.7.0", "log", - "multiaddr", - "multihash", + "multiaddr 0.14.0", + "multihash 0.16.1", "multistream-select 0.11.0", "parking_lot", "pin-project 1.0.10", @@ -2965,12 +2988,11 @@ dependencies = [ [[package]] name = "libp2p-dns" -version = "0.31.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39d4a2e7efe62c738833b6be6c0f158cf7ffccba462320f4b3bebe43e1050e7b" +version = "0.32.0" +source = "git+https://github.com/sigp/rust-libp2p?rev=e213703e616eaba3c482d7714775e0d37c4ae8e5#e213703e616eaba3c482d7714775e0d37c4ae8e5" dependencies = [ "futures", - "libp2p-core 0.31.0", + "libp2p-core 0.32.0", "log", "smallvec", "trust-dns-resolver", @@ -2978,9 +3000,8 @@ dependencies = [ [[package]] name = "libp2p-gossipsub" -version = "0.35.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "385ae5f44e84f51e17014c9f1d98464121d3b1b182c167a0b4482d6250c61926" +version = "0.36.0" +source = "git+https://github.com/sigp/rust-libp2p?rev=e213703e616eaba3c482d7714775e0d37c4ae8e5#e213703e616eaba3c482d7714775e0d37c4ae8e5" dependencies = [ "asynchronous-codec", "base64 0.13.0", @@ -2988,32 +3009,30 @@ dependencies = [ "bytes", "fnv", "futures", - "futures-timer", "hex_fmt", "instant", - "libp2p-core 0.31.0", + "libp2p-core 0.32.0", "libp2p-swarm", "log", - "open-metrics-client", - "pin-project 1.0.10", + "prometheus-client", "prost", "prost-build", "rand 0.7.3", "regex", "sha2 0.10.1", "smallvec", + "tokio", "unsigned-varint 0.7.1", ] [[package]] name = "libp2p-identify" -version = "0.33.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae5d84b4e57cb66abb9dd28ea36f69620816e004a7479c0ad76f45002820f99b" +version = "0.34.0" +source = "git+https://github.com/sigp/rust-libp2p?rev=e213703e616eaba3c482d7714775e0d37c4ae8e5#e213703e616eaba3c482d7714775e0d37c4ae8e5" dependencies = [ "futures", "futures-timer", - "libp2p-core 0.31.0", + "libp2p-core 0.32.0", "libp2p-swarm", "log", "lru", @@ -3024,27 +3043,25 @@ dependencies = [ [[package]] name = "libp2p-metrics" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0791098ddec13b0c2f9ed37a29175f7c712ce8804ebaba7cbd8bddbc83120190" +version = "0.4.0" +source = "git+https://github.com/sigp/rust-libp2p?rev=e213703e616eaba3c482d7714775e0d37c4ae8e5#e213703e616eaba3c482d7714775e0d37c4ae8e5" dependencies = [ - "libp2p-core 0.31.0", + "libp2p-core 0.32.0", "libp2p-gossipsub", "libp2p-identify", "libp2p-swarm", - "open-metrics-client", + "prometheus-client", ] [[package]] name = "libp2p-mplex" -version = "0.31.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49d470ee73a74340e429fa278469ed274a648738e3fb8de2e8d113482441732f" +version = "0.32.0" +source = "git+https://github.com/sigp/rust-libp2p?rev=e213703e616eaba3c482d7714775e0d37c4ae8e5#e213703e616eaba3c482d7714775e0d37c4ae8e5" dependencies = [ "asynchronous-codec", "bytes", "futures", - "libp2p-core 0.31.0", + "libp2p-core 0.32.0", "log", "nohash-hasher", "parking_lot", @@ -3055,15 +3072,14 @@ dependencies = [ [[package]] name = "libp2p-noise" -version = "0.34.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3676dc2df10a7f4f6a80fbeaf2ce4168a0ca6567273e3105b21fa4c877be9017" +version = "0.35.0" +source = "git+https://github.com/sigp/rust-libp2p?rev=e213703e616eaba3c482d7714775e0d37c4ae8e5#e213703e616eaba3c482d7714775e0d37c4ae8e5" dependencies = [ "bytes", - "curve25519-dalek", + "curve25519-dalek 3.2.0", "futures", "lazy_static", - "libp2p-core 0.31.0", + "libp2p-core 0.32.0", "log", "prost", "prost-build", @@ -3077,14 +3093,13 @@ dependencies = [ [[package]] name = "libp2p-plaintext" -version = "0.31.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83203abb14ae77de42c49be8dbed7ea8dfb83e76773226aa664a96e6c5e18c5d" +version = "0.32.0" +source = "git+https://github.com/sigp/rust-libp2p?rev=e213703e616eaba3c482d7714775e0d37c4ae8e5#e213703e616eaba3c482d7714775e0d37c4ae8e5" dependencies = [ "asynchronous-codec", "bytes", "futures", - "libp2p-core 0.31.0", + "libp2p-core 0.32.0", "log", "prost", "prost-build", @@ -3094,15 +3109,14 @@ dependencies = [ [[package]] name = "libp2p-swarm" -version = "0.33.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db8ae0811c7a05b6edc6684eb5cc69b055cbb715ad780e6b97872d90308503c1" +version = "0.34.0" +source = "git+https://github.com/sigp/rust-libp2p?rev=e213703e616eaba3c482d7714775e0d37c4ae8e5#e213703e616eaba3c482d7714775e0d37c4ae8e5" dependencies = [ "either", "futures", "futures-timer", "instant", - "libp2p-core 0.31.0", + "libp2p-core 0.32.0", "log", "rand 0.7.3", "smallvec", @@ -3112,8 +3126,7 @@ dependencies = [ [[package]] name = "libp2p-swarm-derive" version = "0.26.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33b4d0acd47739fe0b570728d8d11bbb535050d84c0cf05d6477a4891fceae10" +source = "git+https://github.com/sigp/rust-libp2p?rev=e213703e616eaba3c482d7714775e0d37c4ae8e5#e213703e616eaba3c482d7714775e0d37c4ae8e5" dependencies = [ "quote", "syn", @@ -3121,16 +3134,15 @@ dependencies = [ [[package]] name = "libp2p-tcp" -version = "0.31.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52042e8796c5b58d0415bceb1bcb1bcca28b222339978e52b1a0305800bb5199" +version = "0.32.0" +source = "git+https://github.com/sigp/rust-libp2p?rev=e213703e616eaba3c482d7714775e0d37c4ae8e5#e213703e616eaba3c482d7714775e0d37c4ae8e5" dependencies = [ "futures", "futures-timer", "if-addrs 0.7.0", "ipnet", "libc", - "libp2p-core 0.31.0", + "libp2p-core 0.32.0", "log", "socket2 0.4.4", "tokio", @@ -3138,14 +3150,13 @@ dependencies = [ [[package]] name = "libp2p-websocket" -version = "0.33.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83d788da0ab952632d6ead2486baf38a98db92907d4bc5d0f324af0d0fab803d" +version = "0.34.0" +source = "git+https://github.com/sigp/rust-libp2p?rev=e213703e616eaba3c482d7714775e0d37c4ae8e5#e213703e616eaba3c482d7714775e0d37c4ae8e5" dependencies = [ "either", "futures", "futures-rustls", - "libp2p-core 0.31.0", + "libp2p-core 0.32.0", "log", "quicksink", "rw-stream-sink", @@ -3156,12 +3167,11 @@ dependencies = [ [[package]] name = "libp2p-yamux" -version = "0.35.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "053d13ce0670d29f9c5a974cf371e6cc4d2d864da1c72bf6870ac5d5e45e2036" +version = "0.36.0" +source = "git+https://github.com/sigp/rust-libp2p?rev=e213703e616eaba3c482d7714775e0d37c4ae8e5#e213703e616eaba3c482d7714775e0d37c4ae8e5" dependencies = [ "futures", - "libp2p-core 0.31.0", + "libp2p-core 0.32.0", "parking_lot", "thiserror", "yamux", @@ -3348,8 +3358,8 @@ dependencies = [ "lighthouse_metrics", "lighthouse_version", "lru", - "open-metrics-client", "parking_lot", + "prometheus-client", "rand 0.7.3", "regex", "serde", @@ -3520,7 +3530,7 @@ version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" dependencies = [ - "autocfg 1.0.1", + "autocfg 1.1.0", ] [[package]] @@ -3576,7 +3586,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a92518e98c078586bc6c934028adcca4c92a53d6a958196de835170a01d84e4b" dependencies = [ "adler", - "autocfg 1.0.1", + "autocfg 1.1.0", ] [[package]] @@ -3631,7 +3641,25 @@ dependencies = [ "bs58", "byteorder", "data-encoding", - "multihash", + "multihash 0.14.0", + "percent-encoding", + "serde", + "static_assertions", + "unsigned-varint 0.7.1", + "url", +] + +[[package]] +name = "multiaddr" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c580bfdd8803cce319b047d239559a22f809094aaea4ac13902a1fdcfcd4261" +dependencies = [ + "arrayref", + "bs58", + "byteorder", + "data-encoding", + "multihash 0.16.1", "percent-encoding", "serde", "static_assertions", @@ -3647,11 +3675,24 @@ checksum = "752a61cd890ff691b4411423d23816d5866dd5621e4d1c5687a53b94b5a979d8" dependencies = [ "digest 0.9.0", "generic-array", - "multihash-derive", + "multihash-derive 0.7.2", "sha2 0.9.9", "unsigned-varint 0.7.1", ] +[[package]] +name = "multihash" +version = "0.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7392bffd88bc0c4f8297e36a777ab9f80b7127409c4a1acb8fee99c9f27addcd" +dependencies = [ + "core2", + "digest 0.10.1", + "multihash-derive 0.8.0", + "sha2 0.10.1", + "unsigned-varint 0.7.1", +] + [[package]] name = "multihash-derive" version = "0.7.2" @@ -3666,6 +3707,20 @@ dependencies = [ "synstructure", ] +[[package]] +name = "multihash-derive" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc076939022111618a5026d3be019fd8b366e76314538ff9a1b59ffbcbf98bcd" +dependencies = [ + "proc-macro-crate", + "proc-macro-error", + "proc-macro2", + "quote", + "syn", + "synstructure", +] + [[package]] name = "multimap" version = "0.8.3" @@ -3725,8 +3780,7 @@ dependencies = [ [[package]] name = "multistream-select" version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "363a84be6453a70e63513660f4894ef815daf88e3356bffcda9ca27d810ce83b" +source = "git+https://github.com/sigp/rust-libp2p?rev=e213703e616eaba3c482d7714775e0d37c4ae8e5#e213703e616eaba3c482d7714775e0d37c4ae8e5" dependencies = [ "bytes", "futures", @@ -3874,7 +3928,7 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f93ab6289c7b344a8a9f60f88d80aa20032336fe78da341afc91c8a2341fc75f" dependencies = [ - "autocfg 1.0.1", + "autocfg 1.1.0", "num-integer", "num-traits", ] @@ -3885,7 +3939,7 @@ version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5d51546d704f52ef14b3c962b5776e53d5b862e5790e40a350d366c209bd7f7a" dependencies = [ - "autocfg 0.1.7", + "autocfg 0.1.8", "byteorder", "lazy_static", "libm", @@ -3904,7 +3958,7 @@ version = "0.1.44" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d2cc698a63b549a70bc047073d2949cce27cd1c7b0a4a862d08a8031bc2801db" dependencies = [ - "autocfg 1.0.1", + "autocfg 1.1.0", "num-traits", ] @@ -3914,7 +3968,7 @@ version = "0.1.42" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b2021c8337a54d21aca0d59a92577a029af9431cb59b909b03252b9c164fad59" dependencies = [ - "autocfg 1.0.1", + "autocfg 1.1.0", "num-integer", "num-traits", ] @@ -3925,7 +3979,7 @@ version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290" dependencies = [ - "autocfg 1.0.1", + "autocfg 1.1.0", ] [[package]] @@ -3974,29 +4028,6 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" -[[package]] -name = "open-metrics-client" -version = "0.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f85842b073145726190373213c63f852020fb884c841a3a1f390637267a2fb8c" -dependencies = [ - "dtoa", - "itoa 1.0.1", - "open-metrics-client-derive-text-encode", - "owning_ref", -] - -[[package]] -name = "open-metrics-client-derive-text-encode" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a15c83b586f00268c619c1cb3340ec1a6f59dd9ba1d9833a273a68e6d5cd8ffc" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "openssl" version = "0.10.38" @@ -4032,7 +4063,7 @@ version = "0.9.72" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7e46109c383602735fa0a2e48dd2b7c892b048e1bf69e5c3b1d804b7d9c203cb" dependencies = [ - "autocfg 1.0.1", + "autocfg 1.1.0", "cc", "libc", "openssl-src", @@ -4439,6 +4470,29 @@ dependencies = [ "thiserror", ] +[[package]] +name = "prometheus-client" +version = "0.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9a896938cc6018c64f279888b8c7559d3725210d5db9a3a1ee6bc7188d51d34" +dependencies = [ + "dtoa", + "itoa 1.0.1", + "owning_ref", + "prometheus-client-derive-text-encode", +] + +[[package]] +name = "prometheus-client-derive-text-encode" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8e12d01b9d66ad9eb4529c57666b6263fc1993cb30261d83ead658fdd932652" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "prost" version = "0.9.0" @@ -4722,7 +4776,7 @@ version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c06aca804d41dbc8ba42dfd964f0d01334eceb64314b9ecf7c5fad5188a06d90" dependencies = [ - "autocfg 1.0.1", + "autocfg 1.1.0", "crossbeam-deque", "either", "rayon-core", @@ -5501,9 +5555,9 @@ dependencies = [ [[package]] name = "slog-term" -version = "2.8.0" +version = "2.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95c1e7e5aab61ced6006149ea772770b84a0d16ce0f7885def313e4829946d76" +checksum = "f3668dd2252f4381d64de0c79e6c8dc6bd509d1cab3535b35a3fc9bafd1241d5" dependencies = [ "atty", "chrono", @@ -5560,20 +5614,19 @@ checksum = "45456094d1983e2ee2a18fdfebce3189fa451699d0502cb8e3b49dba5ba41451" [[package]] name = "snow" -version = "0.8.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6142f7c25e94f6fd25a32c3348ec230df9109b463f59c8c7acc4bd34936babb7" +checksum = "774d05a3edae07ce6d68ea6984f3c05e9bba8927e3dd591e3b479e5b03213d0d" dependencies = [ "aes-gcm", "blake2", "chacha20poly1305", - "rand 0.8.4", + "curve25519-dalek 4.0.0-pre.1", "rand_core 0.6.3", "ring", - "rustc_version 0.3.3", - "sha2 0.9.9", + "rustc_version 0.4.0", + "sha2 0.10.1", "subtle", - "x25519-dalek", ] [[package]] @@ -6494,9 +6547,9 @@ dependencies = [ [[package]] name = "unicode-segmentation" -version = "1.8.0" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8895849a949e7845e06bd6dc1aa51731a103c42707010a5b591c0038fb73385b" +checksum = "7e8820f5d777f6224dc4be3632222971ac30164d4a258d595640799554ebfd99" [[package]] name = "unicode-width" @@ -7073,7 +7126,7 @@ version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5a0c105152107e3b96f6a00a65e86ce82d9b125230e1c4302940eca58ff71f4f" dependencies = [ - "curve25519-dalek", + "curve25519-dalek 3.2.0", "rand_core 0.5.1", "zeroize", ] @@ -7118,9 +7171,9 @@ dependencies = [ [[package]] name = "zeroize" -version = "1.5.2" +version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c88870063c39ee00ec285a2f8d6a966e5b6fb2becc4e8dac77ed0d370ed6006" +checksum = "d68d9dcec5f9b43a30d38c49f91dfedfaac384cb8f085faca366c26207dd1619" dependencies = [ "zeroize_derive", ] diff --git a/beacon_node/client/src/builder.rs b/beacon_node/client/src/builder.rs index c0f9be0936e..f5045418ab8 100644 --- a/beacon_node/client/src/builder.rs +++ b/beacon_node/client/src/builder.rs @@ -18,7 +18,7 @@ use eth2::{ }; use execution_layer::ExecutionLayer; use genesis::{interop_genesis_state, Eth1GenesisService, DEFAULT_ETH1_BLOCK_HASH}; -use lighthouse_network::{open_metrics_client::registry::Registry, NetworkGlobals}; +use lighthouse_network::{prometheus_client::registry::Registry, NetworkGlobals}; use monitoring_api::{MonitoringHttpClient, ProcessType}; use network::{NetworkConfig, NetworkMessage, NetworkService}; use slasher::Slasher; diff --git a/beacon_node/http_api/tests/common.rs b/beacon_node/http_api/tests/common.rs index 758c29a60fa..cf20e2f686a 100644 --- a/beacon_node/http_api/tests/common.rs +++ b/beacon_node/http_api/tests/common.rs @@ -120,7 +120,7 @@ pub async fn create_api_server( send_back_addr: EXTERNAL_ADDR.parse().unwrap(), }; let con_id = ConnectionId::new(1); - pm.inject_connection_established(&peer_id, &con_id, &connected_point, None); + pm.inject_connection_established(&peer_id, &con_id, &connected_point, None, 0); *network_globals.sync_state.write() = SyncState::Synced; let eth1_service = eth1::Service::new(eth1::Config::default(), log.clone(), chain.spec.clone()); diff --git a/beacon_node/http_metrics/src/lib.rs b/beacon_node/http_metrics/src/lib.rs index 89e6a8e2d10..729d92ee9e1 100644 --- a/beacon_node/http_metrics/src/lib.rs +++ b/beacon_node/http_metrics/src/lib.rs @@ -4,7 +4,7 @@ mod metrics; use beacon_chain::{BeaconChain, BeaconChainTypes}; -use lighthouse_network::open_metrics_client::registry::Registry; +use lighthouse_network::prometheus_client::registry::Registry; use lighthouse_version::version_with_platform; use serde::{Deserialize, Serialize}; use slog::{crit, info, Logger}; diff --git a/beacon_node/http_metrics/src/metrics.rs b/beacon_node/http_metrics/src/metrics.rs index 66c961956c8..9b156942112 100644 --- a/beacon_node/http_metrics/src/metrics.rs +++ b/beacon_node/http_metrics/src/metrics.rs @@ -1,7 +1,7 @@ use crate::Context; use beacon_chain::BeaconChainTypes; use lighthouse_metrics::{Encoder, TextEncoder}; -use lighthouse_network::open_metrics_client::encoding::text::encode; +use lighthouse_network::prometheus_client::encoding::text::encode; use malloc_utils::scrape_allocator_metrics; pub use lighthouse_metrics::*; diff --git a/beacon_node/lighthouse_network/Cargo.toml b/beacon_node/lighthouse_network/Cargo.toml index 7ac8c8c2ea4..bb30aac55af 100644 --- a/beacon_node/lighthouse_network/Cargo.toml +++ b/beacon_node/lighthouse_network/Cargo.toml @@ -38,10 +38,12 @@ directory = { path = "../../common/directory" } regex = "1.3.9" strum = { version = "0.21.0", features = ["derive"] } superstruct = "0.4.0" -open-metrics-client = "0.14.0" +prometheus-client = "0.15.0" [dependencies.libp2p] -version = "0.42.1" +git = "https://github.com/sigp/rust-libp2p" +# branch libp2p-gossipsub-interval-hotfix +rev = "e213703e616eaba3c482d7714775e0d37c4ae8e5" default-features = false features = ["websocket", "identify", "mplex", "yamux", "noise", "gossipsub", "dns-tokio", "tcp-tokio", "plaintext", "secp256k1"] diff --git a/beacon_node/lighthouse_network/src/discovery/mod.rs b/beacon_node/lighthouse_network/src/discovery/mod.rs index 35178c18fea..5cc059c2a81 100644 --- a/beacon_node/lighthouse_network/src/discovery/mod.rs +++ b/beacon_node/lighthouse_network/src/discovery/mod.rs @@ -927,24 +927,6 @@ impl NetworkBehaviour for Discovery { } } - fn inject_connected(&mut self, _peer_id: &PeerId) {} - fn inject_disconnected(&mut self, _peer_id: &PeerId) {} - fn inject_connection_established( - &mut self, - _peer_id: &PeerId, - _connection_id: &ConnectionId, - _endpoint: &ConnectedPoint, - _failed_addresses: Option<&Vec>, - ) { - } - fn inject_connection_closed( - &mut self, - _: &PeerId, - _: &ConnectionId, - _connected_point: &ConnectedPoint, - _handler: Self::ProtocolsHandler, - ) { - } fn inject_event( &mut self, _: PeerId, diff --git a/beacon_node/lighthouse_network/src/lib.rs b/beacon_node/lighthouse_network/src/lib.rs index 0460a42c8a9..f679b7e6572 100644 --- a/beacon_node/lighthouse_network/src/lib.rs +++ b/beacon_node/lighthouse_network/src/lib.rs @@ -67,7 +67,7 @@ pub use crate::types::{ SubnetDiscovery, }; -pub use open_metrics_client; +pub use prometheus_client; pub use behaviour::{BehaviourEvent, Gossipsub, PeerRequestId, Request, Response}; pub use config::Config as NetworkConfig; diff --git a/beacon_node/lighthouse_network/src/peer_manager/network_behaviour.rs b/beacon_node/lighthouse_network/src/peer_manager/network_behaviour.rs index 9d57161e75c..d4eef65b0c4 100644 --- a/beacon_node/lighthouse_network/src/peer_manager/network_behaviour.rs +++ b/beacon_node/lighthouse_network/src/peer_manager/network_behaviour.rs @@ -110,6 +110,7 @@ impl NetworkBehaviour for PeerManager { _connection_id: &ConnectionId, endpoint: &ConnectedPoint, _failed_addresses: Option<&Vec>, + _other_established: usize, ) { debug!(self.log, "Connection established"; "peer_id" => %peer_id, "connection" => ?endpoint.to_endpoint()); // Check NAT if metrics are enabled @@ -172,8 +173,18 @@ impl NetworkBehaviour for PeerManager { self.update_connected_peer_metrics(); metrics::inc_counter(&metrics::PEER_CONNECT_EVENT_COUNT); } + fn inject_connection_closed( + &mut self, + peer_id: &PeerId, + _: &ConnectionId, + _: &ConnectedPoint, + _: DummyProtocolsHandler, + remaining_established: usize, + ) { + if remaining_established > 0 { + return; + } - fn inject_disconnected(&mut self, peer_id: &PeerId) { // There are no more connections if self .network_globals diff --git a/beacon_node/lighthouse_network/src/rpc/mod.rs b/beacon_node/lighthouse_network/src/rpc/mod.rs index ebd62406168..8c4a0b14c71 100644 --- a/beacon_node/lighthouse_network/src/rpc/mod.rs +++ b/beacon_node/lighthouse_network/src/rpc/mod.rs @@ -202,36 +202,25 @@ where } // Use connection established/closed instead of these currently - fn inject_connected(&mut self, peer_id: &PeerId) { - // find the peer's meta-data - debug!(self.log, "Requesting new peer's metadata"; "peer_id" => %peer_id); - let rpc_event = - RPCSend::Request(RequestId::Behaviour, OutboundRequest::MetaData(PhantomData)); - self.events.push(NetworkBehaviourAction::NotifyHandler { - peer_id: *peer_id, - handler: NotifyHandler::Any, - event: rpc_event, - }); - } - - fn inject_disconnected(&mut self, _peer_id: &PeerId) {} - fn inject_connection_established( &mut self, - _peer_id: &PeerId, + peer_id: &PeerId, _connection_id: &ConnectionId, _endpoint: &ConnectedPoint, _failed_addresses: Option<&Vec>, + other_established: usize, ) { - } - - fn inject_connection_closed( - &mut self, - _peer_id: &PeerId, - _: &ConnectionId, - _connected_point: &ConnectedPoint, - _handler: Self::ProtocolsHandler, - ) { + if other_established == 0 { + // find the peer's meta-data + debug!(self.log, "Requesting new peer's metadata"; "peer_id" => %peer_id); + let rpc_event = + RPCSend::Request(RequestId::Behaviour, OutboundRequest::MetaData(PhantomData)); + self.events.push(NetworkBehaviourAction::NotifyHandler { + peer_id: *peer_id, + handler: NotifyHandler::Any, + event: rpc_event, + }); + } } fn inject_event( diff --git a/beacon_node/lighthouse_network/src/service.rs b/beacon_node/lighthouse_network/src/service.rs index 0ccdd28fdff..7dcee51870b 100644 --- a/beacon_node/lighthouse_network/src/service.rs +++ b/beacon_node/lighthouse_network/src/service.rs @@ -21,7 +21,7 @@ use libp2p::{ swarm::{SwarmBuilder, SwarmEvent}, PeerId, Swarm, Transport, }; -use open_metrics_client::registry::Registry; +use prometheus_client::registry::Registry; use slog::{crit, debug, info, o, trace, warn, Logger}; use ssz::Decode; use std::fs::File; diff --git a/beacon_node/lighthouse_network/tests/common/behaviour.rs b/beacon_node/lighthouse_network/tests/common/behaviour.rs index ab4ae901f2d..75797e63d1c 100644 --- a/beacon_node/lighthouse_network/tests/common/behaviour.rs +++ b/beacon_node/lighthouse_network/tests/common/behaviour.rs @@ -100,10 +100,8 @@ where inner: TInner, pub addresses_of_peer: Vec, - pub inject_connected: Vec, - pub inject_disconnected: Vec, - pub inject_connection_established: Vec<(PeerId, ConnectionId, ConnectedPoint)>, - pub inject_connection_closed: Vec<(PeerId, ConnectionId, ConnectedPoint)>, + pub inject_connection_established: Vec<(PeerId, ConnectionId, ConnectedPoint, usize)>, + pub inject_connection_closed: Vec<(PeerId, ConnectionId, ConnectedPoint, usize)>, pub inject_event: Vec<( PeerId, ConnectionId, @@ -128,8 +126,6 @@ where Self { inner, addresses_of_peer: Vec::new(), - inject_connected: Vec::new(), - inject_disconnected: Vec::new(), inject_connection_established: Vec::new(), inject_connection_closed: Vec::new(), inject_event: Vec::new(), @@ -148,8 +144,6 @@ where #[allow(dead_code)] pub fn reset(&mut self) { self.addresses_of_peer = Vec::new(); - self.inject_connected = Vec::new(); - self.inject_disconnected = Vec::new(); self.inject_connection_established = Vec::new(); self.inject_connection_closed = Vec::new(); self.inject_event = Vec::new(); @@ -176,7 +170,13 @@ where expected_disconnections: usize, ) -> bool { if self.inject_connection_closed.len() == expected_closed_connections { - assert_eq!(self.inject_disconnected.len(), expected_disconnections); + assert_eq!( + self.inject_connection_closed + .iter() + .filter(|(.., remaining_established)| { *remaining_established == 0 }) + .count(), + expected_disconnections + ); return true; } @@ -193,7 +193,15 @@ where expected_connections: usize, ) -> bool { if self.inject_connection_established.len() == expected_established_connections { - assert_eq!(self.inject_connected.len(), expected_connections); + assert_eq!( + self.inject_connection_established + .iter() + .filter(|(.., reported_aditional_connections)| { + *reported_aditional_connections == 0 + }) + .count(), + expected_connections + ); return true; } @@ -219,37 +227,45 @@ where self.inner.addresses_of_peer(p) } - fn inject_connected(&mut self, peer: &PeerId) { - assert!( - self.inject_connection_established - .iter() - .any(|(peer_id, _, _)| peer_id == peer), - "`inject_connected` is called after at least one `inject_connection_established`." - ); - self.inject_connected.push(*peer); - self.inner.inject_connected(peer); - } - fn inject_connection_established( &mut self, p: &PeerId, c: &ConnectionId, e: &ConnectedPoint, errors: Option<&Vec>, + other_established: usize, ) { - self.inject_connection_established.push((*p, *c, e.clone())); - self.inner.inject_connection_established(p, c, e, errors); - } - - fn inject_disconnected(&mut self, peer: &PeerId) { - assert!( - self.inject_connection_closed - .iter() - .any(|(peer_id, _, _)| peer_id == peer), - "`inject_disconnected` is called after at least one `inject_connection_closed`." - ); - self.inject_disconnected.push(*peer); - self.inner.inject_disconnected(peer); + let mut other_peer_connections = self + .inject_connection_established + .iter() + .rev() // take last to first + .filter_map(|(peer, .., other_established)| { + if p == peer { + Some(other_established) + } else { + None + } + }) + .take(other_established); + + // We are informed that there are `other_established` additional connections. Ensure that the + // number of previous connections is consistent with this + if let Some(&prev) = other_peer_connections.next() { + if prev < other_established { + assert_eq!( + prev, + other_established - 1, + "Inconsistent connection reporting" + ) + } + assert_eq!(other_peer_connections.count(), other_established - 1); + } else { + assert_eq!(other_established, 0) + } + self.inject_connection_established + .push((*p, *c, e.clone(), other_established)); + self.inner + .inject_connection_established(p, c, e, errors, other_established); } fn inject_connection_closed( @@ -258,15 +274,46 @@ where c: &ConnectionId, e: &ConnectedPoint, handler: ::Handler, + remaining_established: usize, ) { - let connection = (*p, *c, e.clone()); + let mut other_closed_connections = self + .inject_connection_established + .iter() + .rev() // take last to first + .filter_map(|(peer, .., remaining_established)| { + if p == peer { + Some(remaining_established) + } else { + None + } + }) + .take(remaining_established); + + // We are informed that there are `other_established` additional connections. Ensure that the + // number of previous connections is consistent with this + if let Some(&prev) = other_closed_connections.next() { + if prev < remaining_established { + assert_eq!( + prev, + remaining_established - 1, + "Inconsistent closed connection reporting" + ) + } + assert_eq!(other_closed_connections.count(), remaining_established - 1); + } else { + assert_eq!(remaining_established, 0) + } assert!( - self.inject_connection_established.contains(&connection), + self.inject_connection_established + .iter() + .any(|(peer, conn_id, endpoint, _)| (peer, conn_id, endpoint) == (p, c, e)), "`inject_connection_closed` is called only for connections for \ which `inject_connection_established` was called first." ); - self.inject_connection_closed.push(connection); - self.inner.inject_connection_closed(p, c, e, handler); + self.inject_connection_closed + .push((*p, *c, e.clone(), remaining_established)); + self.inner + .inject_connection_closed(p, c, e, handler, remaining_established); } fn inject_event( @@ -278,14 +325,14 @@ where assert!( self.inject_connection_established .iter() - .any(|(peer_id, conn_id, _)| *peer_id == p && c == *conn_id), + .any(|(peer_id, conn_id, ..)| *peer_id == p && c == *conn_id), "`inject_event` is called for reported connections." ); assert!( !self .inject_connection_closed .iter() - .any(|(peer_id, conn_id, _)| *peer_id == p && c == *conn_id), + .any(|(peer_id, conn_id, ..)| *peer_id == p && c == *conn_id), "`inject_event` is never called for closed connections." ); diff --git a/beacon_node/network/src/service.rs b/beacon_node/network/src/service.rs index c6f68d5faa6..a16c2c677c0 100644 --- a/beacon_node/network/src/service.rs +++ b/beacon_node/network/src/service.rs @@ -11,7 +11,7 @@ use futures::channel::mpsc::Sender; use futures::future::OptionFuture; use futures::prelude::*; use lighthouse_network::{ - open_metrics_client::registry::Registry, MessageAcceptance, Service as LibP2PService, + prometheus_client::registry::Registry, MessageAcceptance, Service as LibP2PService, }; use lighthouse_network::{ rpc::{GoodbyeReason, RPCResponseErrorCode, RequestId},