From 4aa06c9555786a24197b12c3261b7cfc406938c9 Mon Sep 17 00:00:00 2001 From: Age Manning Date: Thu, 3 Jun 2021 11:11:33 +1000 Subject: [PATCH] Network upgrades (#2345) --- Cargo.lock | 634 ++++++++++-------- beacon_node/eth2_libp2p/Cargo.toml | 6 +- .../src/behaviour/handler/delegate.rs | 8 +- .../eth2_libp2p/src/behaviour/handler/mod.rs | 1 - beacon_node/eth2_libp2p/src/behaviour/mod.rs | 37 +- beacon_node/eth2_libp2p/src/config.rs | 1 + beacon_node/eth2_libp2p/src/service.rs | 26 +- beacon_node/eth2_libp2p/tests/common/mod.rs | 4 +- beacon_node/eth2_libp2p/tests/rpc_tests.rs | 32 +- beacon_node/http_api/Cargo.toml | 1 - beacon_node/http_api/tests/tests.rs | 2 +- beacon_node/network/Cargo.toml | 1 - .../network/src/beacon_processor/tests.rs | 2 +- beacon_node/network/src/persisted_dht.rs | 7 + beacon_node/network/src/service.rs | 39 +- common/eth2_network_config/Cargo.toml | 2 +- 16 files changed, 449 insertions(+), 354 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 49d0706f8..d0a68be3e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -83,33 +83,13 @@ checksum = "aae1277d39aeec15cb388266ecc24b11c80469deae6067e17a1a7aa9e5c1f234" [[package]] name = "aead" -version = "0.3.2" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fc95d1bdb8e6666b2b217308eeeb09f2d6728d104be3e31916cc74d15420331" +checksum = "6e3e798aa0c8239776f54415bc06f3d74b1850f3f830b45c35cfc80556973f70" dependencies = [ "generic-array 0.14.4", ] -[[package]] -name = "aead" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "922b33332f54fc0ad13fa3e514601e8d30fb54e1f3eadc36643f6526db645621" -dependencies = [ - "generic-array 0.14.4", -] - -[[package]] -name = "aes" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd2bc6d3f370b5666245ff421e231cba4353df936e26986d2918e61a8fd6aef6" -dependencies = [ - "aes-soft", - "aesni", - "block-cipher", -] - [[package]] name = "aes" version = "0.7.4" @@ -123,52 +103,18 @@ dependencies = [ "opaque-debug 0.3.0", ] -[[package]] -name = "aes-gcm" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0301c9e9c443494d970a07885e8cf3e587bae8356a1d5abd0999068413f7205f" -dependencies = [ - "aead 0.3.2", - "aes 0.5.0", - "block-cipher", - "ghash 0.3.1", - "subtle 2.4.0", -] - [[package]] name = "aes-gcm" version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bc3be92e19a7ef47457b8e6f90707e12b6ac5d20c6f3866584fa3be0787d839f" dependencies = [ - "aead 0.4.1", - "aes 0.7.4", + "aead", + "aes", "cipher 0.3.0", "ctr", - "ghash 0.4.2", - "subtle 2.4.0", -] - -[[package]] -name = "aes-soft" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "63dd91889c49327ad7ef3b500fd1109dbd3c509a03db0d4a9ce413b79f575cb6" -dependencies = [ - "block-cipher", - "byteorder", - "opaque-debug 0.3.0", -] - -[[package]] -name = "aesni" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a6fe808308bb07d393e2ea47780043ec47683fcf19cf5efc8ca51c50cc8c68a" -dependencies = [ - "block-cipher", - "opaque-debug 0.3.0", + "ghash", + "subtle 2.4.1", ] [[package]] @@ -211,9 +157,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.41" +version = "1.0.42" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15af2628f6890fe2609a3b91bef4c83450512802e59489f9c1cb1fa5df064a61" +checksum = "595d3cfa7a60d4555cb5067b99f07142a08ea778de5cf993f7b75c7d8fabc486" [[package]] name = "arbitrary" @@ -257,31 +203,12 @@ dependencies = [ "term", ] -[[package]] -name = "asn1_der" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fce6b6a0ffdafebd82c87e79e3f40e8d2c523e5fea5566ff6b90509bf98d638" -dependencies = [ - "asn1_der_derive", -] - [[package]] name = "asn1_der" version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d6e24d2cce90c53b948c46271bfb053e4bdc2db9b5d3f65e20f8cf28a1b7fc3" -[[package]] -name = "asn1_der_derive" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d0864d84b8e07b145449be9a8537db86bf9de5ce03b913214694643b4743502" -dependencies = [ - "quote", - "syn", -] - [[package]] name = "assert-json-diff" version = "2.0.1" @@ -737,15 +664,6 @@ dependencies = [ "generic-array 0.14.4", ] -[[package]] -name = "block-cipher" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f337a3e6da609650eb74e02bc9fac7b735049f7623ab12f2e4c719316fcc7e80" -dependencies = [ - "generic-array 0.14.4", -] - [[package]] name = "block-padding" version = "0.1.5" @@ -943,18 +861,18 @@ dependencies = [ [[package]] name = "cast" -version = "0.2.6" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57cdfa5d50aad6cb4d44dcab6101a7f79925bd59d82ca42f38a9856a28865374" +checksum = "4c24dab4283a142afa2fdca129b80ad2c6284e073930f964c3a1293c225ee39a" dependencies = [ - "rustc_version 0.3.3", + "rustc_version 0.4.0", ] [[package]] name = "cc" -version = "1.0.68" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a72c244c1ff497a746a7e1fb3d14bd08420ecda70c8f25c7112f2781652d787" +checksum = "e70cc2f62c6ce1868963827bd677764c62d07c3d9a3e1fb1177ee1a9ab199eb2" [[package]] name = "cfg-if" @@ -970,24 +888,26 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chacha20" -version = "0.5.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "244fbce0d47e97e8ef2f63b81d5e05882cb518c68531eb33194990d7b7e85845" +checksum = "fee7ad89dc1128635074c268ee661f90c3f7e83d9fd12910608c36b47d6c3412" dependencies = [ - "stream-cipher", + "cfg-if 1.0.0", + "cipher 0.3.0", + "cpufeatures", "zeroize", ] [[package]] name = "chacha20poly1305" -version = "0.6.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9bf18d374d66df0c05cdddd528a7db98f78c28e2519b120855c4f84c5027b1f5" +checksum = "1580317203210c517b6d44794abfbe600698276db18127e37ad3e69bf5e848e5" dependencies = [ - "aead 0.3.2", + "aead", "chacha20", + "cipher 0.3.0", "poly1305", - "stream-cipher", "zeroize", ] @@ -1190,12 +1110,6 @@ dependencies = [ "libc", ] -[[package]] -name = "cpuid-bool" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcb25d077389e53838a8158c8e99174c5a9d902dee4904320db714f3c653ffba" - [[package]] name = "crc32fast" version = "1.2.1" @@ -1308,7 +1222,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b584a330336237c1eecd3e94266efb216c56ed91225d634cb2991c5f3fd1aeab" dependencies = [ "generic-array 0.14.4", - "subtle 2.4.0", + "subtle 2.4.1", ] [[package]] @@ -1318,7 +1232,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4857fd85a0c34b3c3297875b747c1e02e06b6a0ea32dd892d8192b9ce0813ea6" dependencies = [ "generic-array 0.14.4", - "subtle 2.4.0", + "subtle 2.4.1", ] [[package]] @@ -1328,7 +1242,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "25fab6889090c8133f3deb8f73ba3c65a7f456f66436fc012a1b1e272b1e103e" dependencies = [ "generic-array 0.14.4", - "subtle 2.4.0", + "subtle 2.4.1", ] [[package]] @@ -1422,7 +1336,7 @@ dependencies = [ "byteorder", "digest 0.9.0", "rand_core 0.5.1", - "subtle 2.4.0", + "subtle 2.4.1", "zeroize", ] @@ -1541,13 +1455,14 @@ dependencies = [ [[package]] name = "derive_more" -version = "0.99.14" +version = "0.99.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cc7b9cef1e351660e5443924e4f43ab25fbbed3e9a5f052df3677deb4d6b320" +checksum = "40eebddd2156ce1bb37b20bbe5151340a31828b1f2d22ba4141f3531710e38df" dependencies = [ "convert_case", "proc-macro2", "quote", + "rustc_version 0.3.3", "syn", ] @@ -1640,12 +1555,12 @@ checksum = "212d0f5754cb6769937f4501cc0e67f4f4483c8d2c3e1e922ee9edbe4ab4c7c0" [[package]] name = "discv5" -version = "0.1.0-beta.5" +version = "0.1.0-beta.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f5a5132ff1173d356fd78d09cd33d82fe8f7e6b4016d8c891edf2680a8cebe6" +checksum = "7ea68ad7b3b04274980a33fd1579517540b9d341dfe634b17b6b49fa972cfb86" dependencies = [ - "aes 0.7.4", - "aes-gcm 0.9.2", + "aes", + "aes-gcm", "arrayvec 0.7.1", "digest 0.9.0", "enr", @@ -1654,7 +1569,7 @@ dependencies = [ "hex", "hkdf", "lazy_static", - "libp2p-core 0.28.3", + "libp2p-core 0.29.0", "lru", "lru_time_cache", "parking_lot", @@ -1758,7 +1673,7 @@ dependencies = [ "group", "pkcs8", "rand_core 0.6.3", - "subtle 2.4.0", + "subtle 2.4.1", "zeroize", ] @@ -1800,6 +1715,18 @@ dependencies = [ "zeroize", ] +[[package]] +name = "enum-as-inner" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c5f0096a91d210159eceb2ff5e1c4da18388a170e1e3ce948aac9c8fdbbf595" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "env_logger" version = "0.7.1" @@ -1980,7 +1907,7 @@ dependencies = [ name = "eth2_keystore" version = "0.1.0" dependencies = [ - "aes 0.7.4", + "aes", "bls", "eth2_key_derivation", "eth2_ssz", @@ -2133,9 +2060,9 @@ dependencies = [ [[package]] name = "ethabi" -version = "14.0.0" +version = "14.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c52991643379afc90bfe2df3c64d53983e59c35a82ba6e75c997cfc2880d8524" +checksum = "a01317735d563b3bad2d5f90d2e1799f414165408251abb762510f40e790e69a" dependencies = [ "anyhow", "ethereum-types 0.11.0", @@ -2258,7 +2185,7 @@ checksum = "72a4d941a5b7c2a75222e2d44fcdf634a67133d9db31e177ae5ff6ecda852bfe" dependencies = [ "bitvec 0.20.4", "rand_core 0.6.3", - "subtle 2.4.0", + "subtle 2.4.1", ] [[package]] @@ -2580,16 +2507,6 @@ dependencies = [ "wasi 0.10.2+wasi-snapshot-preview1", ] -[[package]] -name = "ghash" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97304e4cd182c3846f7575ced3890c53012ce534ad9114046b0a9e00bb30a375" -dependencies = [ - "opaque-debug 0.3.0", - "polyval 0.4.5", -] - [[package]] name = "ghash" version = "0.4.2" @@ -2597,7 +2514,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7bbd60caa311237d508927dbba7594b483db3ef05faa55172fcf89b1bcda7853" dependencies = [ "opaque-debug 0.3.0", - "polyval 0.5.1", + "polyval", ] [[package]] @@ -2655,7 +2572,7 @@ checksum = "61b3c1e8b4f1ca07e6605ea1be903a5f6956aec5c8a67fd44d56076631675ed8" dependencies = [ "ff", "rand_core 0.6.3", - "subtle 2.4.0", + "subtle 2.4.1", ] [[package]] @@ -2843,6 +2760,17 @@ dependencies = [ "hmac 0.8.1", ] +[[package]] +name = "hostname" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c731c3e10504cc8ed35cfe2f1db4c9274c3d35fa486e3b31df46f068ef3e867" +dependencies = [ + "libc", + "match_cfg", + "winapi", +] + [[package]] name = "http" version = "0.2.4" @@ -2871,7 +2799,6 @@ version = "0.1.0" dependencies = [ "beacon_chain", "bs58", - "discv5", "environment", "eth1", "eth2", @@ -2971,9 +2898,9 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" [[package]] name = "hyper" -version = "0.14.9" +version = "0.14.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07d6baa1b441335f3ce5098ac421fb6547c46dda735ca1bc6d0153c838f9dd83" +checksum = "7728a72c4c7d72665fde02204bcbd93b247721025b222ef78606f14513e0fd03" dependencies = [ "bytes 1.0.1", "futures-channel", @@ -3044,22 +2971,6 @@ dependencies = [ "libc", ] -[[package]] -name = "if-watch" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97b8538953a3f0d0d3868f0a706eb4273535e10d72acb5c82c1c23ae48835c85" -dependencies = [ - "async-io", - "futures", - "futures-lite", - "if-addrs", - "ipnet", - "libc", - "log", - "winapi", -] - [[package]] name = "igd" version = "0.11.1" @@ -3150,9 +3061,9 @@ dependencies = [ [[package]] name = "instant" -version = "0.1.9" +version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61124eeebbd69b8190558df225adf7e4caafce0d743919e5d6b19652314ec5ec" +checksum = "bee0328b1209d157ef001c94dd85b4f8f64139adb0eac2659f4b08382b2f474d" dependencies = [ "cfg-if 1.0.0", ] @@ -3175,6 +3086,18 @@ dependencies = [ "num-traits", ] +[[package]] +name = "ipconfig" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7e2f18aece9709094573a9f24f483c4f65caa4298e2f7ae1b71cc65d853fad7" +dependencies = [ + "socket2 0.3.19", + "widestring", + "winapi", + "winreg 0.6.2", +] + [[package]] name = "ipnet" version = "2.3.1" @@ -3390,9 +3313,9 @@ checksum = "db13adb97ab515a3691f56e4dbab09283d0b86cb45abd991d8634a9d6f501760" [[package]] name = "libc" -version = "0.2.97" +version = "0.2.98" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12b8adadd720df158f4d70dfe7ccc6adb0472d7c55ca83445f6a5ab3e36f8fb6" +checksum = "320cfe77175da3a483efed4bc0adc1968ca050b098ce4f2f1c13a56626128790" [[package]] name = "libflate" @@ -3432,15 +3355,15 @@ dependencies = [ [[package]] name = "libp2p" -version = "0.35.1" +version = "0.38.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adc225a49973cf9ab10d0cdd6a4b8f0cda299df9b760824bbb623f15f8f0c95a" +checksum = "ebbb17eece4aec5bb970880c73825c16ca59ca05a4e41803751e68c7e5f0c618" dependencies = [ "atomic", "bytes 1.0.1", "futures", "lazy_static", - "libp2p-core 0.27.1", + "libp2p-core 0.28.3", "libp2p-dns", "libp2p-gossipsub", "libp2p-identify", @@ -3460,11 +3383,11 @@ dependencies = [ [[package]] name = "libp2p-core" -version = "0.27.1" +version = "0.28.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a2d56aadc2c2bf22cd7797f86e56a65b5b3994a0136b65be3106938acae7a26" +checksum = "554d3e7e9e65f939d66b75fd6a4c67f258fe250da61b91f46c545fc4a89b51d9" dependencies = [ - "asn1_der 0.6.3", + "asn1_der", "bs58", "ed25519-dalek", "either", @@ -3474,13 +3397,13 @@ dependencies = [ "lazy_static", "libsecp256k1 0.3.5", "log", - "multihash", + "multihash 0.13.2", "multistream-select", "parity-multiaddr", "parking_lot", "pin-project 1.0.7", - "prost", - "prost-build", + "prost 0.7.0", + "prost-build 0.7.0", "rand 0.7.3", "ring", "rw-stream-sink", @@ -3494,11 +3417,11 @@ dependencies = [ [[package]] name = "libp2p-core" -version = "0.28.3" +version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "554d3e7e9e65f939d66b75fd6a4c67f258fe250da61b91f46c545fc4a89b51d9" +checksum = "af9b4abdeaa420593a297c8592f63fad4234f4b88dc9343b8fd8e736c35faa59" dependencies = [ - "asn1_der 0.7.4", + "asn1_der", "bs58", "ed25519-dalek", "either", @@ -3506,15 +3429,15 @@ dependencies = [ "futures", "futures-timer", "lazy_static", - "libsecp256k1 0.3.5", + "libsecp256k1 0.5.0", "log", - "multihash", + "multiaddr", + "multihash 0.14.0", "multistream-select", - "parity-multiaddr", "parking_lot", "pin-project 1.0.7", - "prost", - "prost-build", + "prost 0.8.0", + "prost-build 0.8.0", "rand 0.7.3", "ring", "rw-stream-sink", @@ -3528,20 +3451,22 @@ dependencies = [ [[package]] name = "libp2p-dns" -version = "0.27.0" +version = "0.28.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5153b6db68fd4baa3b304e377db744dd8fea8ff4e4504509ee636abcde88d3e3" +checksum = "62e63dab8b5ff35e0c101a3e51e843ba782c07bbb1682f5fd827622e0d02b98b" dependencies = [ "futures", - "libp2p-core 0.27.1", + "libp2p-core 0.28.3", "log", + "smallvec", + "trust-dns-resolver", ] [[package]] name = "libp2p-gossipsub" -version = "0.28.0" +version = "0.31.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "502dc5fcbfec4aa1c63ef3f7307ffe20e90c1a1387bf23ed0bec087f2dde58a1" +checksum = "e562308761818b0c52f2a81a0544b9c22d0cf56d7b2d928a0ff61382404498ce" dependencies = [ "asynchronous-codec", "base64 0.13.0", @@ -3550,11 +3475,11 @@ dependencies = [ "fnv", "futures", "hex_fmt", - "libp2p-core 0.27.1", + "libp2p-core 0.28.3", "libp2p-swarm", "log", - "prost", - "prost-build", + "prost 0.7.0", + "prost-build 0.7.0", "rand 0.7.3", "regex", "sha2 0.9.5", @@ -3565,30 +3490,30 @@ dependencies = [ [[package]] name = "libp2p-identify" -version = "0.27.0" +version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b40fb36a059b7a8cce1514bd8b546fa612e006c9937caa7f5950cb20021fe91e" +checksum = "5f668f00efd9883e8b7bcc582eaf0164615792608f886f6577da18bcbeea0a46" dependencies = [ "futures", - "libp2p-core 0.27.1", + "libp2p-core 0.28.3", "libp2p-swarm", "log", - "prost", - "prost-build", + "prost 0.7.0", + "prost-build 0.7.0", "smallvec", "wasm-timer", ] [[package]] name = "libp2p-mplex" -version = "0.27.1" +version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "350ce8b3923594aedabd5d6e3f875d058435052a29c3f32df378bc70d10be464" +checksum = "85e9b544335d1ed30af71daa96edbefadef6f19c7a55f078b9fc92c87163105d" dependencies = [ "asynchronous-codec", "bytes 1.0.1", "futures", - "libp2p-core 0.27.1", + "libp2p-core 0.28.3", "log", "nohash-hasher", "parking_lot", @@ -3599,19 +3524,19 @@ dependencies = [ [[package]] name = "libp2p-noise" -version = "0.29.0" +version = "0.31.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4aca322b52a0c5136142a7c3971446fb1e9964923a526c9cc6ef3b7c94e57778" +checksum = "57a2aa6fc4e6855eaf9ea1941a14f7ec4df35636fb6b85951e17481df8dcecf6" dependencies = [ "bytes 1.0.1", "curve25519-dalek", "futures", "lazy_static", - "libp2p-core 0.27.1", + "libp2p-core 0.28.3", "log", - "prost", - "prost-build", - "rand 0.7.3", + "prost 0.7.0", + "prost-build 0.7.0", + "rand 0.8.4", "sha2 0.9.5", "snow", "static_assertions", @@ -3621,13 +3546,13 @@ dependencies = [ [[package]] name = "libp2p-swarm" -version = "0.27.2" +version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7955b973e1fd2bd61ffd43ce261c1223f61f4aacd5bae362a924993f9a25fd98" +checksum = "1e04d8e1eef675029ec728ba14e8d0da7975d84b6679b699b4ae91a1de9c3a92" dependencies = [ "either", "futures", - "libp2p-core 0.27.1", + "libp2p-core 0.28.3", "log", "rand 0.7.3", "smallvec", @@ -3637,9 +3562,9 @@ dependencies = [ [[package]] name = "libp2p-swarm-derive" -version = "0.22.0" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c564ebaa36a64839f51eaddb0243aaaa29ce64affb56129193cc3248b72af273" +checksum = "365b0a699fea5168676840567582a012ea297b1ca02eee467e58301b9c9c5eed" dependencies = [ "quote", "syn", @@ -3647,33 +3572,31 @@ dependencies = [ [[package]] name = "libp2p-tcp" -version = "0.27.1" +version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88a5aef80e519a6cb8e2663605142f97baaaea1a252eecbf8756184765f7471b" +checksum = "2b1a27d21c477951799e99d5c105d78868258502ce092988040a808d5a19bbd9" dependencies = [ - "async-io", "futures", "futures-timer", "if-addrs", - "if-watch", "ipnet", "libc", - "libp2p-core 0.27.1", + "libp2p-core 0.28.3", "log", - "socket2 0.3.19", + "socket2 0.4.0", "tokio 1.8.1", ] [[package]] name = "libp2p-websocket" -version = "0.28.0" +version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3b1c6a3431045da8b925ed83384e4c5163e14b990572307fca9c507435d4d22" +checksum = "cace60995ef6f637e4752cccbb2590f6bc358e8741a0d066307636c69a4b3a74" dependencies = [ "either", "futures", "futures-rustls", - "libp2p-core 0.27.1", + "libp2p-core 0.28.3", "log", "quicksink", "rw-stream-sink", @@ -3684,12 +3607,12 @@ dependencies = [ [[package]] name = "libp2p-yamux" -version = "0.30.1" +version = "0.32.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4819358c542a86ff95f6ae691efb4b94ddaf477079b01a686f5705b79bfc232a" +checksum = "f35da42cfc6d5cb0dcf3ad6881bc68d146cdf38f98655e09e33fbba4d13eabc4" dependencies = [ "futures", - "libp2p-core 0.27.1", + "libp2p-core 0.28.3", "parking_lot", "thiserror", "yamux", @@ -3707,7 +3630,7 @@ dependencies = [ "hmac-drbg 0.2.0", "rand 0.7.3", "sha2 0.8.2", - "subtle 2.4.0", + "subtle 2.4.1", "typenum", ] @@ -3738,7 +3661,7 @@ checksum = "4ee11012b293ea30093c129173cac4335513064094619f4639a25b310fd33c11" dependencies = [ "crunchy", "digest 0.9.0", - "subtle 2.4.0", + "subtle 2.4.1", ] [[package]] @@ -3912,6 +3835,15 @@ dependencies = [ "hashbrown 0.9.1", ] +[[package]] +name = "lru-cache" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31e24f1ad8321ca0e8a1e0ac13f23cb668e6f5466c2c57319f6a5cf1cc8e3b1c" +dependencies = [ + "linked-hash-map", +] + [[package]] name = "lru_cache" version = "0.1.0" @@ -3950,6 +3882,12 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d" +[[package]] +name = "match_cfg" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffbee8634e0d45d258acb448e7eaab3fce7a0a467395d4d9f228e3c1f01fb2e4" + [[package]] name = "matchers" version = "0.0.1" @@ -4073,6 +4011,24 @@ dependencies = [ "tokio 1.8.1", ] +[[package]] +name = "multiaddr" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48ee4ea82141951ac6379f964f71b20876d43712bea8faf6dd1a375e08a46499" +dependencies = [ + "arrayref", + "bs58", + "byteorder", + "data-encoding", + "multihash 0.14.0", + "percent-encoding", + "serde", + "static_assertions", + "unsigned-varint 0.7.0", + "url", +] + [[package]] name = "multihash" version = "0.13.2" @@ -4086,6 +4042,19 @@ dependencies = [ "unsigned-varint 0.5.1", ] +[[package]] +name = "multihash" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "752a61cd890ff691b4411423d23816d5866dd5621e4d1c5687a53b94b5a979d8" +dependencies = [ + "digest 0.9.0", + "generic-array 0.14.4", + "multihash-derive", + "sha2 0.9.5", + "unsigned-varint 0.7.0", +] + [[package]] name = "multihash-derive" version = "0.7.2" @@ -4161,7 +4130,6 @@ name = "network" version = "0.2.0" dependencies = [ "beacon_chain", - "discv5", "environment", "error-chain", "eth2_libp2p", @@ -4457,7 +4425,7 @@ dependencies = [ "bs58", "byteorder", "data-encoding", - "multihash", + "multihash 0.13.2", "percent-encoding", "serde", "static_assertions", @@ -4687,9 +4655,9 @@ dependencies = [ [[package]] name = "plotters-backend" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd8be10f7485c8a323ea100b20d6052c27cf5968f08f8e3a56ee9f0cf38ebd3d" +checksum = "d88417318da0eaf0fdcdb51a0ee6c3bed624333bff8f946733049380be67ac1c" [[package]] name = "plotters-svg" @@ -4715,21 +4683,11 @@ dependencies = [ [[package]] name = "poly1305" -version = "0.6.2" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b7456bc1ad2d4cf82b3a016be4c2ac48daf11bf990c1603ebd447fe6f30fca8" +checksum = "4fe800695325da85083cd23b56826fccb2e2dc29b218e7811a6f33bc93f414be" dependencies = [ - "cpuid-bool", - "universal-hash", -] - -[[package]] -name = "polyval" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eebcc4aa140b9abd2bc40d9c3f7ccec842679cd79045ac3a7ac698c1a064b7cd" -dependencies = [ - "cpuid-bool", + "cpufeatures", "opaque-debug 0.3.0", "universal-hash", ] @@ -4873,7 +4831,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9e6984d2f1a23009bd270b8bb56d0926810a3d483f59c987d77969e9d8e840b2" dependencies = [ "bytes 1.0.1", - "prost-derive", + "prost-derive 0.7.0", +] + +[[package]] +name = "prost" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de5e2533f59d08fcf364fd374ebda0692a70bd6d7e66ef97f306f45c6c5d8020" +dependencies = [ + "bytes 1.0.1", + "prost-derive 0.8.0", ] [[package]] @@ -4888,8 +4856,26 @@ dependencies = [ "log", "multimap", "petgraph", - "prost", - "prost-types", + "prost 0.7.0", + "prost-types 0.7.0", + "tempfile", + "which", +] + +[[package]] +name = "prost-build" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "355f634b43cdd80724ee7848f95770e7e70eefa6dcf14fea676216573b8fd603" +dependencies = [ + "bytes 1.0.1", + "heck", + "itertools 0.10.1", + "log", + "multimap", + "petgraph", + "prost 0.8.0", + "prost-types 0.8.0", "tempfile", "which", ] @@ -4907,6 +4893,19 @@ dependencies = [ "syn", ] +[[package]] +name = "prost-derive" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "600d2f334aa05acb02a755e217ef1ab6dea4d51b58b7846588b747edec04efba" +dependencies = [ + "anyhow", + "itertools 0.10.1", + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "prost-types" version = "0.7.0" @@ -4914,7 +4913,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b518d7cdd93dab1d1122cf07fa9a60771836c668dde9d9e2a139f957f0d9f1bb" dependencies = [ "bytes 1.0.1", - "prost", + "prost 0.7.0", +] + +[[package]] +name = "prost-types" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "603bbd6394701d13f3f25aada59c7de9d35a6a5887cfc156181234a44002771b" +dependencies = [ + "bytes 1.0.1", + "prost 0.8.0", ] [[package]] @@ -5336,7 +5345,17 @@ dependencies = [ "wasm-bindgen", "wasm-bindgen-futures", "web-sys", - "winreg", + "winreg 0.7.0", +] + +[[package]] +name = "resolv-conf" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52e44394d2086d010551b14b53b1f24e31647570cd1deb0379e2c21b329aba00" +dependencies = [ + "hostname", + "quick-error", ] [[package]] @@ -5440,6 +5459,15 @@ dependencies = [ "semver 0.11.0", ] +[[package]] +name = "rustc_version" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" +dependencies = [ + "semver 1.0.3", +] + [[package]] name = "rustls" version = "0.19.1" @@ -5616,6 +5644,12 @@ dependencies = [ "semver-parser 0.10.2", ] +[[package]] +name = "semver" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f3aac57ee7f3272d8395c6e4f502f434f0e289fcd62876f70daa008c20dcabe" + [[package]] name = "semver-parser" version = "0.7.0" @@ -5894,7 +5928,7 @@ dependencies = [ "serde", "serde_derive", "slog", - "sloggers 2.0.0", + "sloggers 2.0.1", "tempfile", "tree_hash", "tree_hash_derive", @@ -6035,9 +6069,9 @@ dependencies = [ [[package]] name = "sloggers" -version = "2.0.0" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92ee08a52260ed355f96069884bf8873f2439231f8754cbd545291d647ebbd75" +checksum = "7071b1119e436e93157c2e9e134138d9d8716dfe5e2f472500119bcbe4f45a4e" dependencies = [ "chrono", "libc", @@ -6089,19 +6123,19 @@ checksum = "45456094d1983e2ee2a18fdfebce3189fa451699d0502cb8e3b49dba5ba41451" [[package]] name = "snow" -version = "0.7.2" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "795dd7aeeee24468e5a32661f6d27f7b5cbed802031b2d7640c7b10f8fb2dd50" +checksum = "6142f7c25e94f6fd25a32c3348ec230df9109b463f59c8c7acc4bd34936babb7" dependencies = [ - "aes-gcm 0.7.0", + "aes-gcm", "blake2", "chacha20poly1305", - "rand 0.7.3", - "rand_core 0.5.1", + "rand 0.8.4", + "rand_core 0.6.3", "ring", - "rustc_version 0.2.3", + "rustc_version 0.3.3", "sha2 0.9.5", - "subtle 2.4.0", + "subtle 2.4.1", "x25519-dalek", ] @@ -6285,16 +6319,6 @@ dependencies = [ "types", ] -[[package]] -name = "stream-cipher" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c80e15f898d8d8f25db24c253ea615cc14acf418ff307822995814e7d42cfa89" -dependencies = [ - "block-cipher", - "generic-array 0.14.4", -] - [[package]] name = "string_cache" version = "0.8.1" @@ -6348,9 +6372,9 @@ checksum = "2d67a5a62ba6e01cb2192ff309324cb4875d0c451d55fe2319433abe7a05a8ee" [[package]] name = "subtle" -version = "2.4.0" +version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e81da0851ada1f3e9d4312c704aa4f8806f0f9d69faaf8df2f3464b4a9437c2" +checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" [[package]] name = "superstruct" @@ -6387,9 +6411,9 @@ dependencies = [ [[package]] name = "synstructure" -version = "0.12.4" +version = "0.12.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b834f2d66f734cb897113e34aaff2f1ab4719ca946f9a7358dba8f8064148701" +checksum = "474aaa926faa1603c40b7885a9eaea29b444d1cb2850cb7c0e37bb1a4182f4fa" dependencies = [ "proc-macro2", "quote", @@ -6487,18 +6511,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.25" +version = "1.0.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa6f76457f59514c7eeb4e59d891395fab0b2fd1d40723ae737d64153392e9c6" +checksum = "93119e4feac1cbe6c798c34d3a53ea0026b0b1de6a120deef895137c0529bfe2" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.25" +version = "1.0.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a36768c0fbf1bb15eca10defa29526bda730a2376c2ab4393ccfa16fb1a318d" +checksum = "060d69a0afe7796bf42e9e2ff91f5ee691fb15c53d38b4b62a9a53eb23164745" dependencies = [ "proc-macro2", "quote", @@ -6704,9 +6728,9 @@ dependencies = [ [[package]] name = "tokio-macros" -version = "1.2.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c49e3df43841dafb86046472506755d8501c5615673955f6aa17181125d13c37" +checksum = "54473be61f4ebe4efd09cec9bd5d16fa51d70ea0192213d754d2d500457db110" dependencies = [ "proc-macro2", "quote", @@ -6725,9 +6749,9 @@ dependencies = [ [[package]] name = "tokio-stream" -version = "0.1.6" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8864d706fdb3cc0843a49647ac892720dac98a6eeb818b77190592cf4994066" +checksum = "7b2f3f698253f03119ac0102beaa64f67a67e08074d03a22d18784104543727f" dependencies = [ "futures-core", "pin-project-lite 0.2.7", @@ -6906,6 +6930,51 @@ dependencies = [ "syn", ] +[[package]] +name = "trust-dns-proto" +version = "0.20.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad0d7f5db438199a6e2609debe3f69f808d074e0a2888ee0bccb45fe234d03f4" +dependencies = [ + "async-trait", + "cfg-if 1.0.0", + "data-encoding", + "enum-as-inner", + "futures-channel", + "futures-io", + "futures-util", + "idna", + "ipnet", + "lazy_static", + "log", + "rand 0.8.4", + "smallvec", + "thiserror", + "tinyvec", + "tokio 1.8.1", + "url", +] + +[[package]] +name = "trust-dns-resolver" +version = "0.20.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6ad17b608a64bd0735e67bde16b0636f8aa8591f831a25d18443ed00a699770" +dependencies = [ + "cfg-if 1.0.0", + "futures-util", + "ipconfig", + "lazy_static", + "log", + "lru-cache", + "parking_lot", + "resolv-conf", + "smallvec", + "thiserror", + "tokio 1.8.1", + "trust-dns-proto", +] + [[package]] name = "try-lock" version = "0.2.3" @@ -7057,9 +7126,9 @@ dependencies = [ [[package]] name = "unicode-segmentation" -version = "1.7.1" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb0d2e7be6ae3a5fa87eed5fb451aff96f2573d2694942e40543ae0bbe19c796" +checksum = "8895849a949e7845e06bd6dc1aa51731a103c42707010a5b591c0038fb73385b" [[package]] name = "unicode-width" @@ -7080,7 +7149,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8326b2c654932e3e4f9196e69d08fdf7cfd718e1dc6f66b347e6024a0c961402" dependencies = [ "generic-array 0.14.4", - "subtle 2.4.0", + "subtle 2.4.1", ] [[package]] @@ -7467,7 +7536,7 @@ dependencies = [ "base64 0.13.0", "bytes 1.0.1", "derive_more", - "ethabi 14.0.0", + "ethabi 14.1.0", "ethereum-types 0.11.0", "futures", "futures-timer", @@ -7589,6 +7658,15 @@ dependencies = [ "winapi", ] +[[package]] +name = "winreg" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2986deb581c4fe11b621998a5e53361efe6b48a151178d0cd9eeffa4dc6acc9" +dependencies = [ + "winapi", +] + [[package]] name = "winreg" version = "0.7.0" @@ -7641,15 +7719,15 @@ dependencies = [ [[package]] name = "yamux" -version = "0.8.1" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cc7bd8c983209ed5d527f44b01c41b7dc146fd960c61cf9e1d25399841dc271" +checksum = "e7d9028f208dd5e63c614be69f115c1b53cacc1111437d4c765185856666c107" dependencies = [ "futures", "log", "nohash-hasher", "parking_lot", - "rand 0.7.3", + "rand 0.8.4", "static_assertions", ] diff --git a/beacon_node/eth2_libp2p/Cargo.toml b/beacon_node/eth2_libp2p/Cargo.toml index 662f29444..4411517c9 100644 --- a/beacon_node/eth2_libp2p/Cargo.toml +++ b/beacon_node/eth2_libp2p/Cargo.toml @@ -5,7 +5,7 @@ authors = ["Sigma Prime "] edition = "2018" [dependencies] -discv5 = { version = "0.1.0-beta.5", features = ["libp2p"] } +discv5 = { version = "0.1.0-beta.4", features = ["libp2p"] } unsigned-varint = { version = "0.6.0", features = ["codec"] } types = { path = "../../consensus/types" } hashset_delay = { path = "../../common/hashset_delay" } @@ -42,9 +42,9 @@ regex = "1.3.9" strum = { version = "0.20", features = ["derive"] } [dependencies.libp2p] -version = "0.35.1" +version = "0.38.0" default-features = false -features = ["websocket", "identify", "mplex", "yamux", "noise", "gossipsub", "dns", "tcp-tokio"] +features = ["websocket", "identify", "mplex", "yamux", "noise", "gossipsub", "dns-tokio", "tcp-tokio"] [dev-dependencies] tokio = { version = "1.1.0", features = ["full"] } diff --git a/beacon_node/eth2_libp2p/src/behaviour/handler/delegate.rs b/beacon_node/eth2_libp2p/src/behaviour/handler/delegate.rs index f849114f3..62a01d8cb 100644 --- a/beacon_node/eth2_libp2p/src/behaviour/handler/delegate.rs +++ b/beacon_node/eth2_libp2p/src/behaviour/handler/delegate.rs @@ -56,7 +56,7 @@ impl DelegatingHandler { /// Wrapper around the `ProtocolsHandler::InEvent` types of the handlers. /// Simply delegated to the corresponding behaviour's handler. -#[derive(Debug, Clone)] +#[derive(Debug)] pub enum DelegateIn { Gossipsub(::InEvent), RPC( as ProtocolsHandler>::InEvent), @@ -141,8 +141,8 @@ impl ProtocolsHandler for DelegatingHandler { .max(identify_proto.timeout()); let select = SelectUpgrade::new( - gossip_proto.into_upgrade().1, - SelectUpgrade::new(rpc_proto.into_upgrade().1, identify_proto.into_upgrade().1), + gossip_proto.into_upgrade().0, + SelectUpgrade::new(rpc_proto.into_upgrade().0, identify_proto.into_upgrade().0), ); SubstreamProtocol::new(select, ()).with_timeout(timeout) @@ -202,7 +202,7 @@ impl ProtocolsHandler for DelegatingHandler { match event { DelegateIn::Gossipsub(ev) => self.gossip_handler.inject_event(ev), DelegateIn::RPC(ev) => self.rpc_handler.inject_event(ev), - DelegateIn::Identify(()) => self.identify_handler.inject_event(()), + DelegateIn::Identify(ev) => self.identify_handler.inject_event(ev), } } diff --git a/beacon_node/eth2_libp2p/src/behaviour/handler/mod.rs b/beacon_node/eth2_libp2p/src/behaviour/handler/mod.rs index d587ea654..4cacea920 100644 --- a/beacon_node/eth2_libp2p/src/behaviour/handler/mod.rs +++ b/beacon_node/eth2_libp2p/src/behaviour/handler/mod.rs @@ -34,7 +34,6 @@ impl BehaviourHandler { } } -#[derive(Clone)] pub enum BehaviourHandlerIn { Delegate(DelegateIn), /// Start the shutdown process. diff --git a/beacon_node/eth2_libp2p/src/behaviour/mod.rs b/beacon_node/eth2_libp2p/src/behaviour/mod.rs index fd37030e1..058d6665a 100644 --- a/beacon_node/eth2_libp2p/src/behaviour/mod.rs +++ b/beacon_node/eth2_libp2p/src/behaviour/mod.rs @@ -24,7 +24,7 @@ use libp2p::{ Gossipsub as BaseGossipsub, GossipsubEvent, IdentTopic as Topic, MessageAcceptance, MessageAuthenticity, MessageId, PeerScoreThresholds, }, - identify::{Identify, IdentifyEvent}, + identify::{Identify, IdentifyConfig, IdentifyEvent}, swarm::{ AddressScore, NetworkBehaviour, NetworkBehaviourAction as NBAction, NotifyHandler, PollParameters, ProtocolsHandler, @@ -151,18 +151,14 @@ impl Behaviour { ) -> error::Result { let behaviour_log = log.new(o!()); - let identify = if net_conf.private { - Identify::new( - "".into(), + let identify_config = if net_conf.private { + IdentifyConfig::new( "".into(), local_key.public(), // Still send legitimate public key ) } else { - Identify::new( - "lighthouse/libp2p".into(), - lighthouse_version::version_with_platform(), - local_key.public(), - ) + IdentifyConfig::new("eth2/1.0.0".into(), local_key.public()) + .with_agent_version(lighthouse_version::version_with_platform()) }; let enr_fork_id = network_globals @@ -221,7 +217,7 @@ impl Behaviour { Ok(Behaviour { eth2_rpc: RPC::new(log.clone()), gossipsub, - identify, + identify: Identify::new(identify_config), peer_manager: PeerManager::new(local_key, net_conf, network_globals.clone(), log) .await?, events: VecDeque::new(), @@ -902,11 +898,7 @@ impl Behaviour { fn on_identify_event(&mut self, event: IdentifyEvent) { match event { - IdentifyEvent::Received { - peer_id, - mut info, - observed_addr, - } => { + IdentifyEvent::Received { peer_id, mut info } => { if info.listen_addrs.len() > MAX_IDENTIFY_ADDRESSES { debug!( self.log, @@ -921,12 +913,13 @@ impl Behaviour { "protocol_version" => info.protocol_version, "agent_version" => info.agent_version, "listening_ addresses" => ?info.listen_addrs, - "observed_address" => ?observed_addr, + "observed_address" => ?info.observed_addr, "protocols" => ?info.protocols ); } IdentifyEvent::Sent { .. } => {} IdentifyEvent::Error { .. } => {} + IdentifyEvent::Pushed { .. } => {} } } @@ -1171,12 +1164,16 @@ impl NetworkBehaviour for Behaviour { delegate_to_behaviours!(self, inject_dial_failure, peer_id); } - fn inject_new_listen_addr(&mut self, addr: &Multiaddr) { - delegate_to_behaviours!(self, inject_new_listen_addr, addr); + fn inject_new_listener(&mut self, id: ListenerId) { + delegate_to_behaviours!(self, inject_new_listener, id); } - fn inject_expired_listen_addr(&mut self, addr: &Multiaddr) { - delegate_to_behaviours!(self, inject_expired_listen_addr, addr); + fn inject_new_listen_addr(&mut self, id: ListenerId, addr: &Multiaddr) { + delegate_to_behaviours!(self, inject_new_listen_addr, id, addr); + } + + fn inject_expired_listen_addr(&mut self, id: ListenerId, addr: &Multiaddr) { + delegate_to_behaviours!(self, inject_expired_listen_addr, id, addr); } fn inject_new_external_addr(&mut self, addr: &Multiaddr) { diff --git a/beacon_node/eth2_libp2p/src/config.rs b/beacon_node/eth2_libp2p/src/config.rs index 8b1979b4a..c21593118 100644 --- a/beacon_node/eth2_libp2p/src/config.rs +++ b/beacon_node/eth2_libp2p/src/config.rs @@ -163,6 +163,7 @@ impl Default for Config { .query_parallelism(5) .disable_report_discovered_peers() .ip_limit() // limits /24 IP's in buckets. + .incoming_bucket_limit(8) // half the bucket size .ping_interval(Duration::from_secs(300)) .build(); diff --git a/beacon_node/eth2_libp2p/src/service.rs b/beacon_node/eth2_libp2p/src/service.rs index 21c75836e..11b1070ac 100644 --- a/beacon_node/eth2_libp2p/src/service.rs +++ b/beacon_node/eth2_libp2p/src/service.rs @@ -221,7 +221,7 @@ impl Service { let mut subscribed_topics: Vec = vec![]; for topic_kind in &config.topics { - if swarm.subscribe_kind(topic_kind.clone()) { + if swarm.behaviour_mut().subscribe_kind(topic_kind.clone()) { subscribed_topics.push(topic_kind.clone()); } else { warn!(log, "Could not subscribe to topic"; "topic" => %topic_kind); @@ -244,7 +244,9 @@ impl Service { /// Sends a request to a peer, with a given Id. pub fn send_request(&mut self, peer_id: PeerId, request_id: RequestId, request: Request) { - self.swarm.send_request(peer_id, request_id, request); + self.swarm + .behaviour_mut() + .send_request(peer_id, request_id, request); } /// Informs the peer that their request failed. @@ -255,22 +257,30 @@ impl Service { error: RPCResponseErrorCode, reason: String, ) { - self.swarm._send_error_reponse(peer_id, id, error, reason); + self.swarm + .behaviour_mut() + ._send_error_reponse(peer_id, id, error, reason); } /// Report a peer's action. pub fn report_peer(&mut self, peer_id: &PeerId, action: PeerAction, source: ReportSource) { - self.swarm.report_peer(peer_id, action, source); + self.swarm + .behaviour_mut() + .report_peer(peer_id, action, source); } /// Disconnect and ban a peer, providing a reason. pub fn goodbye_peer(&mut self, peer_id: &PeerId, reason: GoodbyeReason, source: ReportSource) { - self.swarm.goodbye_peer(peer_id, reason, source); + self.swarm + .behaviour_mut() + .goodbye_peer(peer_id, reason, source); } /// Sends a response to a peer's request. pub fn send_response(&mut self, peer_id: PeerId, id: PeerRequestId, response: Response) { - self.swarm.send_successful_response(peer_id, id, response); + self.swarm + .behaviour_mut() + .send_successful_response(peer_id, id, response); } pub async fn next_event(&mut self) -> Libp2pEvent { @@ -350,8 +360,8 @@ type BoxedTransport = Boxed<(PeerId, StreamMuxerBox)>; fn build_transport( local_private_key: Keypair, ) -> std::io::Result<(BoxedTransport, Arc)> { - let transport = libp2p::tcp::TokioTcpConfig::new().nodelay(true); - let transport = libp2p::dns::DnsConfig::new(transport)?; + let tcp = libp2p::tcp::TokioTcpConfig::new().nodelay(true); + let transport = libp2p::dns::TokioDnsConfig::system(tcp)?; #[cfg(feature = "libp2p-websocket")] let transport = { let trans_clone = transport.clone(); diff --git a/beacon_node/eth2_libp2p/tests/common/mod.rs b/beacon_node/eth2_libp2p/tests/common/mod.rs index a09f800d0..a7ee22d8c 100644 --- a/beacon_node/eth2_libp2p/tests/common/mod.rs +++ b/beacon_node/eth2_libp2p/tests/common/mod.rs @@ -126,7 +126,7 @@ pub async fn build_libp2p_instance( #[allow(dead_code)] pub fn get_enr(node: &LibP2PService) -> Enr { - node.swarm.local_enr() + node.swarm.behaviour().local_enr() } // Returns `n` libp2p peers in fully connected topology. @@ -171,7 +171,7 @@ pub async fn build_node_pair( let mut sender = build_libp2p_instance(rt.clone(), vec![], sender_log).await; let mut receiver = build_libp2p_instance(rt, vec![], receiver_log).await; - let receiver_multiaddr = receiver.swarm.local_enr().multiaddr()[1].clone(); + let receiver_multiaddr = receiver.swarm.behaviour_mut().local_enr().multiaddr()[1].clone(); // let the two nodes set up listeners let sender_fut = async { diff --git a/beacon_node/eth2_libp2p/tests/rpc_tests.rs b/beacon_node/eth2_libp2p/tests/rpc_tests.rs index 1b565a465..1aafba46f 100644 --- a/beacon_node/eth2_libp2p/tests/rpc_tests.rs +++ b/beacon_node/eth2_libp2p/tests/rpc_tests.rs @@ -56,7 +56,7 @@ fn test_status_rpc() { Libp2pEvent::Behaviour(BehaviourEvent::PeerDialed(peer_id)) => { // Send a STATUS message debug!(log, "Sending RPC"); - sender.swarm.send_request( + sender.swarm.behaviour_mut().send_request( peer_id, RequestId::Sync(10), rpc_request.clone(), @@ -90,7 +90,7 @@ fn test_status_rpc() { if request == rpc_request { // send the response debug!(log, "Receiver Received"); - receiver.swarm.send_successful_response( + receiver.swarm.behaviour_mut().send_successful_response( peer_id, id, rpc_response.clone(), @@ -152,7 +152,7 @@ fn test_blocks_by_range_chunked_rpc() { Libp2pEvent::Behaviour(BehaviourEvent::PeerDialed(peer_id)) => { // Send a STATUS message debug!(log, "Sending RPC"); - sender.swarm.send_request( + sender.swarm.behaviour_mut().send_request( peer_id, RequestId::Sync(10), rpc_request.clone(), @@ -197,14 +197,14 @@ fn test_blocks_by_range_chunked_rpc() { // send the response warn!(log, "Receiver got request"); for _ in 1..=messages_to_send { - receiver.swarm.send_successful_response( + receiver.swarm.behaviour_mut().send_successful_response( peer_id, id, rpc_response.clone(), ); } // send the stream termination - receiver.swarm.send_successful_response( + receiver.swarm.behaviour_mut().send_successful_response( peer_id, id, Response::BlocksByRange(None), @@ -266,7 +266,7 @@ fn test_blocks_by_range_chunked_rpc_terminates_correctly() { Libp2pEvent::Behaviour(BehaviourEvent::PeerDialed(peer_id)) => { // Send a STATUS message debug!(log, "Sending RPC"); - sender.swarm.send_request( + sender.swarm.behaviour_mut().send_request( peer_id, RequestId::Sync(10), rpc_request.clone(), @@ -335,7 +335,7 @@ fn test_blocks_by_range_chunked_rpc_terminates_correctly() { if message_info.is_some() { messages_sent += 1; let (peer_id, stream_id) = message_info.as_ref().unwrap(); - receiver.swarm.send_successful_response( + receiver.swarm.behaviour_mut().send_successful_response( *peer_id, *stream_id, rpc_response.clone(), @@ -398,7 +398,7 @@ fn test_blocks_by_range_single_empty_rpc() { Libp2pEvent::Behaviour(BehaviourEvent::PeerDialed(peer_id)) => { // Send a STATUS message debug!(log, "Sending RPC"); - sender.swarm.send_request( + sender.swarm.behaviour_mut().send_request( peer_id, RequestId::Sync(10), rpc_request.clone(), @@ -441,14 +441,14 @@ fn test_blocks_by_range_single_empty_rpc() { warn!(log, "Receiver got request"); for _ in 1..=messages_to_send { - receiver.swarm.send_successful_response( + receiver.swarm.behaviour_mut().send_successful_response( peer_id, id, rpc_response.clone(), ); } // send the stream termination - receiver.swarm.send_successful_response( + receiver.swarm.behaviour_mut().send_successful_response( peer_id, id, Response::BlocksByRange(None), @@ -513,7 +513,7 @@ fn test_blocks_by_root_chunked_rpc() { Libp2pEvent::Behaviour(BehaviourEvent::PeerDialed(peer_id)) => { // Send a STATUS message debug!(log, "Sending RPC"); - sender.swarm.send_request( + sender.swarm.behaviour_mut().send_request( peer_id, RequestId::Sync(10), rpc_request.clone(), @@ -556,7 +556,7 @@ fn test_blocks_by_root_chunked_rpc() { debug!(log, "Receiver got request"); for _ in 1..=messages_to_send { - receiver.swarm.send_successful_response( + receiver.swarm.behaviour_mut().send_successful_response( peer_id, id, rpc_response.clone(), @@ -564,7 +564,7 @@ fn test_blocks_by_root_chunked_rpc() { debug!(log, "Sending message"); } // send the stream termination - receiver.swarm.send_successful_response( + receiver.swarm.behaviour_mut().send_successful_response( peer_id, id, Response::BlocksByRange(None), @@ -634,7 +634,7 @@ fn test_blocks_by_root_chunked_rpc_terminates_correctly() { Libp2pEvent::Behaviour(BehaviourEvent::PeerDialed(peer_id)) => { // Send a STATUS message debug!(log, "Sending RPC"); - sender.swarm.send_request( + sender.swarm.behaviour_mut().send_request( peer_id, RequestId::Sync(10), rpc_request.clone(), @@ -703,7 +703,7 @@ fn test_blocks_by_root_chunked_rpc_terminates_correctly() { if message_info.is_some() { messages_sent += 1; let (peer_id, stream_id) = message_info.as_ref().unwrap(); - receiver.swarm.send_successful_response( + receiver.swarm.behaviour_mut().send_successful_response( *peer_id, *stream_id, rpc_response.clone(), @@ -749,7 +749,7 @@ fn test_goodbye_rpc() { Libp2pEvent::Behaviour(BehaviourEvent::PeerDialed(peer_id)) => { // Send a goodbye and disconnect debug!(log, "Sending RPC"); - sender.swarm.goodbye_peer( + sender.swarm.behaviour_mut().goodbye_peer( &peer_id, GoodbyeReason::IrrelevantNetwork, ReportSource::SyncService, diff --git a/beacon_node/http_api/Cargo.toml b/beacon_node/http_api/Cargo.toml index ddea773f7..4efbfa7a1 100644 --- a/beacon_node/http_api/Cargo.toml +++ b/beacon_node/http_api/Cargo.toml @@ -34,5 +34,4 @@ futures = "0.3.8" store = { path = "../store" } environment = { path = "../../lighthouse/environment" } tree_hash = "0.1.1" -discv5 = { version = "0.1.0-beta.5", features = ["libp2p"] } sensitive_url = { path = "../../common/sensitive_url" } diff --git a/beacon_node/http_api/tests/tests.rs b/beacon_node/http_api/tests/tests.rs index b82dd25fa..205b638c1 100644 --- a/beacon_node/http_api/tests/tests.rs +++ b/beacon_node/http_api/tests/tests.rs @@ -5,11 +5,11 @@ use beacon_chain::{ test_utils::{AttestationStrategy, BeaconChainHarness, BlockStrategy, EphemeralHarnessType}, BeaconChain, StateSkipConfig, WhenSlotSkipped, MAXIMUM_GOSSIP_CLOCK_DISPARITY, }; -use discv5::enr::{CombinedKey, EnrBuilder}; use environment::null_logger; use eth2::Error; use eth2::StatusCode; use eth2::{types::*, BeaconNodeHttpClient, Timeouts}; +use eth2_libp2p::discv5::enr::{CombinedKey, EnrBuilder}; use eth2_libp2p::{ rpc::methods::MetaData, types::{EnrBitfield, SyncState}, diff --git a/beacon_node/network/Cargo.toml b/beacon_node/network/Cargo.toml index 10808c58e..a650e61f0 100644 --- a/beacon_node/network/Cargo.toml +++ b/beacon_node/network/Cargo.toml @@ -15,7 +15,6 @@ slog-term = "2.6.0" slog-async = "2.5.0" logging = { path = "../../common/logging" } environment = { path = "../../lighthouse/environment" } -discv5 = { version = "0.1.0-beta.3" } [dependencies] beacon_chain = { path = "../beacon_chain" } diff --git a/beacon_node/network/src/beacon_processor/tests.rs b/beacon_node/network/src/beacon_processor/tests.rs index 5584a97ec..617b9a871 100644 --- a/beacon_node/network/src/beacon_processor/tests.rs +++ b/beacon_node/network/src/beacon_processor/tests.rs @@ -8,8 +8,8 @@ use beacon_chain::test_utils::{ AttestationStrategy, BeaconChainHarness, BlockStrategy, EphemeralHarnessType, }; use beacon_chain::{BeaconChain, MAXIMUM_GOSSIP_CLOCK_DISPARITY}; -use discv5::enr::{CombinedKey, EnrBuilder}; use environment::{null_logger, Environment, EnvironmentBuilder}; +use eth2_libp2p::discv5::enr::{CombinedKey, EnrBuilder}; use eth2_libp2p::{rpc::methods::MetaData, types::EnrBitfield, MessageId, NetworkGlobals, PeerId}; use slot_clock::SlotClock; use std::cmp; diff --git a/beacon_node/network/src/persisted_dht.rs b/beacon_node/network/src/persisted_dht.rs index 59b0bd9ab..881be15a7 100644 --- a/beacon_node/network/src/persisted_dht.rs +++ b/beacon_node/network/src/persisted_dht.rs @@ -27,6 +27,13 @@ pub fn persist_dht, Cold: ItemStore>( store.put_item(&DHT_DB_KEY, &PersistedDht { enrs }) } +/// Attempts to clear any DHT entries. +pub fn clear_dht, Cold: ItemStore>( + store: Arc>, +) -> Result<(), store::Error> { + store.hot_db.delete::(&DHT_DB_KEY) +} + /// Wrapper around DHT for persistence to disk. pub struct PersistedDht { pub enrs: Vec, diff --git a/beacon_node/network/src/service.rs b/beacon_node/network/src/service.rs index 75786cdc5..e604aee73 100644 --- a/beacon_node/network/src/service.rs +++ b/beacon_node/network/src/service.rs @@ -1,4 +1,4 @@ -use crate::persisted_dht::{load_dht, persist_dht}; +use crate::persisted_dht::{clear_dht, load_dht, persist_dht}; use crate::router::{Router, RouterMessage}; use crate::{ attestation_service::{AttServiceMessage, AttestationService}, @@ -178,7 +178,7 @@ impl NetworkService { "Loading peers into the routing table"; "peers" => enrs_to_load.len() ); for enr in enrs_to_load { - libp2p.swarm.add_enr(enr.clone()); + libp2p.swarm.behaviour_mut().add_enr(enr.clone()); } } @@ -251,7 +251,7 @@ fn spawn_service( .map(|gauge| gauge.reset()); } metrics::update_gossip_metrics::( - &service.libp2p.swarm.gs(), + &service.libp2p.swarm.behaviour_mut().gs(), &service.network_globals, ); // update sync metrics @@ -287,8 +287,7 @@ fn spawn_service( }) ) }).unwrap_or(None) { - if (*service.libp2p.swarm) - .update_gossipsub_parameters(active_validators, slot).is_err() { + if service.libp2p.swarm.behaviour_mut().update_gossipsub_parameters(active_validators, slot).is_err() { error!( service.log, "Failed to update gossipsub parameters"; @@ -314,7 +313,7 @@ fn spawn_service( service.upnp_mappings = (tcp_socket.map(|s| s.port()), udp_socket.map(|s| s.port())); // If there is an external TCP port update, modify our local ENR. if let Some(tcp_socket) = tcp_socket { - if let Err(e) = service.libp2p.swarm.peer_manager().discovery_mut().update_enr_tcp_port(tcp_socket.port()) { + if let Err(e) = service.libp2p.swarm.behaviour_mut().peer_manager().discovery_mut().update_enr_tcp_port(tcp_socket.port()) { warn!(service.log, "Failed to update ENR"; "error" => e); } } @@ -322,7 +321,7 @@ fn spawn_service( // UPnP mappings if !service.discovery_auto_update { if let Some(udp_socket) = udp_socket { - if let Err(e) = service.libp2p.swarm.peer_manager().discovery_mut().update_enr_udp_socket(udp_socket) { + if let Err(e) = service.libp2p.swarm.behaviour_mut().peer_manager().discovery_mut().update_enr_udp_socket(udp_socket) { warn!(service.log, "Failed to update ENR"; "error" => e); } } @@ -341,6 +340,7 @@ fn spawn_service( service .libp2p .swarm + .behaviour_mut() .report_message_validation_result( &propagation_source, message_id, validation_result ); @@ -359,7 +359,7 @@ fn spawn_service( "topics" => ?topic_kinds ); metrics::expose_publish_metrics(&messages); - service.libp2p.swarm.publish(messages); + service.libp2p.swarm.behaviour_mut().publish(messages); } NetworkMessage::ReportPeer { peer_id, action, source } => service.libp2p.report_peer(&peer_id, action, source), NetworkMessage::GoodbyePeer { peer_id, reason, source } => service.libp2p.goodbye_peer(&peer_id, reason, source), @@ -375,7 +375,7 @@ fn spawn_service( let already_subscribed = service.network_globals.gossipsub_subscriptions.read().clone(); let already_subscribed = already_subscribed.iter().map(|x| x.kind()).collect::>(); for topic_kind in eth2_libp2p::types::CORE_TOPICS.iter().filter(|topic| already_subscribed.get(topic).is_none()) { - if service.libp2p.swarm.subscribe_kind(topic_kind.clone()) { + if service.libp2p.swarm.behaviour_mut().subscribe_kind(topic_kind.clone()) { subscribed_topics.push(topic_kind.clone()); } else { warn!(service.log, "Could not subscribe to topic"; "topic" => %topic_kind); @@ -387,9 +387,9 @@ fn spawn_service( for subnet_id in 0..<::EthSpec as EthSpec>::SubnetBitfieldLength::to_u64() { let subnet_id = SubnetId::new(subnet_id); let topic_kind = eth2_libp2p::types::GossipKind::Attestation(subnet_id); - if service.libp2p.swarm.subscribe_kind(topic_kind.clone()) { + if service.libp2p.swarm.behaviour_mut().subscribe_kind(topic_kind.clone()) { // Update the ENR bitfield. - service.libp2p.swarm.update_enr_subnet(subnet_id, true); + service.libp2p.swarm.behaviour_mut().update_enr_subnet(subnet_id, true); subscribed_topics.push(topic_kind.clone()); } else { warn!(service.log, "Could not subscribe to topic"; "topic" => %topic_kind); @@ -407,19 +407,19 @@ fn spawn_service( Some(attestation_service_message) = service.attestation_service.next() => { match attestation_service_message { AttServiceMessage::Subscribe(subnet_id) => { - service.libp2p.swarm.subscribe_to_subnet(subnet_id); + service.libp2p.swarm.behaviour_mut().subscribe_to_subnet(subnet_id); } AttServiceMessage::Unsubscribe(subnet_id) => { - service.libp2p.swarm.unsubscribe_from_subnet(subnet_id); + service.libp2p.swarm.behaviour_mut().unsubscribe_from_subnet(subnet_id); } AttServiceMessage::EnrAdd(subnet_id) => { - service.libp2p.swarm.update_enr_subnet(subnet_id, true); + service.libp2p.swarm.behaviour_mut().update_enr_subnet(subnet_id, true); } AttServiceMessage::EnrRemove(subnet_id) => { - service.libp2p.swarm.update_enr_subnet(subnet_id, false); + service.libp2p.swarm.behaviour_mut().update_enr_subnet(subnet_id, false); } AttServiceMessage::DiscoverPeers(subnets_to_discover) => { - service.libp2p.swarm.discover_subnet_peers(subnets_to_discover); + service.libp2p.swarm.behaviour_mut().discover_subnet_peers(subnets_to_discover); } } } @@ -541,6 +541,7 @@ fn spawn_service( service .libp2p .swarm + .behaviour_mut() .update_fork_version(service.beacon_chain.enr_fork_id()); service.next_fork_update = next_fork_delay(&service.beacon_chain); } @@ -566,12 +567,16 @@ fn next_fork_delay( impl Drop for NetworkService { fn drop(&mut self) { // network thread is terminating - let enrs = self.libp2p.swarm.enr_entries(); + let enrs = self.libp2p.swarm.behaviour_mut().enr_entries(); debug!( self.log, "Persisting DHT to store"; "Number of peers" => enrs.len(), ); + if let Err(e) = clear_dht::(self.store.clone()) { + error!(self.log, "Failed to clear old DHT entries"; "error" => ?e); + } + // Still try to update new entries match persist_dht::(self.store.clone(), enrs) { Err(e) => error!( self.log, diff --git a/common/eth2_network_config/Cargo.toml b/common/eth2_network_config/Cargo.toml index b11f93672..bab813d19 100644 --- a/common/eth2_network_config/Cargo.toml +++ b/common/eth2_network_config/Cargo.toml @@ -19,4 +19,4 @@ serde_yaml = "0.8.13" types = { path = "../../consensus/types"} eth2_ssz = "0.1.2" eth2_config = { path = "../eth2_config"} -enr = { version = "0.5.0", features = ["ed25519", "k256"] } +enr = { version = "0.5.1", features = ["ed25519", "k256"] }