diff --git a/Cargo.lock b/Cargo.lock index 4fe2b3573..b7a14e173 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -130,15 +130,6 @@ name = "amcl" version = "0.3.0" source = "git+https://github.com/sigp/milagro_bls?tag=v1.4.2#16655aa033175a90c10ef02aa144e2835de23aec" -[[package]] -name = "ansi_term" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" -dependencies = [ - "winapi", -] - [[package]] name = "ansi_term" version = "0.12.1" @@ -150,9 +141,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.47" +version = "1.0.51" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38d9ff5d688f1c13395289f67db01d4826b46dd694e7580accdc3e8430f2d98e" +checksum = "8b26702f315f53b6071259e15dd9d64528213b44d61de1ec926eca7715d62203" [[package]] name = "arbitrary" @@ -195,9 +186,9 @@ checksum = "e22d1f4b888c298a027c99dc9048015fac177587de20fc30232a057dfbe24a21" [[package]] name = "async-trait" -version = "0.1.51" +version = "0.1.52" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44318e776df68115a881de9a8fd1b9e53368d7a4a5ce4cc48517da3393233a5e" +checksum = "061a7acccaa286c011ddc30970520b98fa40e00c9d644633fb26b5fc63a265e3" dependencies = [ "proc-macro2", "quote", @@ -291,7 +282,7 @@ checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" name = "beacon_chain" version = "0.2.0" dependencies = [ - "bitvec 0.19.5", + "bitvec 0.19.6", "bls", "derivative", "environment", @@ -380,9 +371,9 @@ dependencies = [ [[package]] name = "bindgen" -version = "0.59.1" +version = "0.59.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "453c49e5950bb0eb63bb3df640e31618846c89d5b7faa54040d76e98e0134375" +checksum = "2bd2a9a458e8f4304c52c43ebb0cfbd520289f8379a52e329a38afda99bf8eb8" dependencies = [ "bitflags", "cexpr", @@ -415,9 +406,9 @@ dependencies = [ [[package]] name = "bitvec" -version = "0.19.5" +version = "0.19.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8942c8d352ae1838c9dda0b0ca2ab657696ef2232a20147cf1b30ae1a9cb4321" +checksum = "55f93d0ef3363c364d5976646a38f04cf67cfe1d4c8d160cdea02cab2c116b33" dependencies = [ "funty", "radium 0.5.3", @@ -444,7 +435,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0a4e37d16930f5459780f5621038b6382b9bb37c19016f39fb6b5808d831f174" dependencies = [ "crypto-mac 0.8.0", - "digest", + "digest 0.9.0", "opaque-debug", ] @@ -458,6 +449,15 @@ dependencies = [ "generic-array", ] +[[package]] +name = "block-buffer" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1d36a02058e76b040de25a4464ba1c80935655595b661505c8b39b664828b95" +dependencies = [ + "generic-array", +] + [[package]] name = "block-padding" version = "0.2.1" @@ -631,11 +631,11 @@ checksum = "22a9137b95ea06864e018375b72adfb7db6e6f68cfc8df5a04d00288050485ee" [[package]] name = "cexpr" -version = "0.5.0" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db507a7679252d2276ed0dd8113c6875ec56d3089f9225b2b42c30cc1f8e5c89" +checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766" dependencies = [ - "nom 6.1.2", + "nom 7.1.0", ] [[package]] @@ -704,11 +704,11 @@ dependencies = [ [[package]] name = "clap" -version = "2.33.3" +version = "2.34.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37e58ac78573c40708d45522f0d80fa2f01cc4f9b4e2bf749807255454312002" +checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c" dependencies = [ - "ansi_term 0.11.0", + "ansi_term", "atty", "bitflags", "strsim 0.8.0", @@ -807,6 +807,12 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "279bc8fc53f788a75c7804af68237d1fce02cde1e275a886a4b320604dc2aeda" +[[package]] +name = "const-oid" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4c78c047431fee22c1a7bb92e00ad095a02a983affe4d8a72e2a2c62c1b94f3" + [[package]] name = "convert_case" version = "0.4.0" @@ -849,9 +855,9 @@ dependencies = [ [[package]] name = "crc32fast" -version = "1.2.1" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81156fece84ab6a9f2afdb109ce3ae577e42b1228441eded99bd77f627953b1a" +checksum = "738c290dfaea84fc1ca15ad9c168d083b05a714e1efddd8edaab678dc28d2836" dependencies = [ "cfg-if", ] @@ -942,6 +948,27 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" +[[package]] +name = "crypto-bigint" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03c6a1d5fa1de37e071642dfa44ec552ca5b299adb128fab16138e24b548fd21" +dependencies = [ + "generic-array", + "rand_core 0.6.3", + "subtle", + "zeroize", +] + +[[package]] +name = "crypto-common" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "683d6b536309245c849479fba3da410962a43ed8e51c26b729208ec0ac2798d0" +dependencies = [ + "generic-array", +] + [[package]] name = "crypto-mac" version = "0.8.0" @@ -970,7 +997,7 @@ checksum = "22813a6dc45b335f9bade10bf7271dc477e81113e89eb251a0bc2a8a81c536e1" dependencies = [ "bstr", "csv-core", - "itoa", + "itoa 0.4.8", "ryu", "serde", ] @@ -995,11 +1022,11 @@ dependencies = [ [[package]] name = "ctrlc" -version = "3.2.0" +version = "3.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "377c9b002a72a0b2c1a18c62e2f3864bdfea4a015e3683a96e24aa45dd6c02d1" +checksum = "a19c6cedffdc8c03a3346d723eb20bd85a13362bb96dc2ac000842c6381ec7bf" dependencies = [ - "nix 0.22.2", + "nix 0.23.1", "winapi", ] @@ -1010,7 +1037,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b9fdf9972b2bd6af2d913799d9ebc165ea4d2e65878e329d9c6b372c4491b61" dependencies = [ "byteorder", - "digest", + "digest 0.9.0", "rand_core 0.5.1", "subtle", "zeroize", @@ -1018,9 +1045,9 @@ dependencies = [ [[package]] name = "darling" -version = "0.13.0" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "757c0ded2af11d8e739c4daea1ac623dd1624b06c844cf3f5a39f1bdbd99bb12" +checksum = "d0d720b8683f8dd83c65155f0530560cba68cd2bf395f6513a483caee57ff7f4" dependencies = [ "darling_core", "darling_macro", @@ -1028,9 +1055,9 @@ dependencies = [ [[package]] name = "darling_core" -version = "0.13.0" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c34d8efb62d0c2d7f60ece80f75e5c63c1588ba68032740494b0b9a996466e3" +checksum = "7a340f241d2ceed1deb47ae36c4144b2707ec7dd0b649f894cb39bb595986324" dependencies = [ "fnv", "ident_case", @@ -1042,9 +1069,9 @@ dependencies = [ [[package]] name = "darling_macro" -version = "0.13.0" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ade7bff147130fe5e6d39f089c6bd49ec0250f35d70b2eebf72afdfc919f15cc" +checksum = "72c41b3b7352feb3211a0d743dc5700a4e3b60f51bd2b368892d1e0f9a95f44b" dependencies = [ "darling_core", "quote", @@ -1087,7 +1114,7 @@ dependencies = [ "hex", "reqwest", "serde_json", - "sha2", + "sha2 0.9.8", "tree_hash", "types", ] @@ -1098,10 +1125,19 @@ version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2eeb9d92785d1facb50567852ce75d0858630630e7eabea59cf7eb7474051087" dependencies = [ - "const-oid", + "const-oid 0.5.2", "typenum", ] +[[package]] +name = "der" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6919815d73839e7ad218de758883aae3a257ba6759ce7a9992501efbb53d705c" +dependencies = [ + "const-oid 0.7.1", +] + [[package]] name = "derivative" version = "2.2.0" @@ -1146,6 +1182,17 @@ dependencies = [ "generic-array", ] +[[package]] +name = "digest" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b697d66081d42af4fba142d56918a3cb21dc8eb63372c6b85d14f44fb9c5979b" +dependencies = [ + "block-buffer 0.10.0", + "crypto-common", + "generic-array", +] + [[package]] name = "directory" version = "0.1.0" @@ -1198,14 +1245,14 @@ dependencies = [ [[package]] name = "discv5" -version = "0.1.0-beta.11" +version = "0.1.0-beta.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a4968631f2eb03ef8dff74fe355440bcf4bd1c514c4326325fc739640c4ec53" +checksum = "ed8f54486179d5a7f11e1f5526f49d925a411a96c1141a707bd5f071be2ab630" dependencies = [ "aes", "aes-gcm", "arrayvec 0.7.2", - "digest", + "digest 0.10.1", "enr", "fnv", "futures", @@ -1213,12 +1260,12 @@ dependencies = [ "hex", "hkdf", "lazy_static", - "libp2p-core 0.29.0", + "libp2p-core 0.30.0", "lru", "parking_lot", "rand 0.8.4", "rlp 0.5.1", - "sha2", + "sha2 0.9.8", "smallvec", "tokio", "tokio-stream", @@ -1241,12 +1288,24 @@ version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "34d33b390ab82f2e1481e331dbd0530895640179d2128ef9a79cc690b78d1eba" dependencies = [ - "der", - "elliptic-curve", + "der 0.3.5", + "elliptic-curve 0.9.12", "hmac 0.11.0", "signature", ] +[[package]] +name = "ecdsa" +version = "0.13.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e91ae02c7618ee05108cd86a0be2f5586d1f0d965bede7ecfd46815f1b860227" +dependencies = [ + "der 0.5.1", + "elliptic-curve 0.11.6", + "rfc6979", + "signature", +] + [[package]] name = "ed25519" version = "1.3.0" @@ -1266,7 +1325,7 @@ dependencies = [ "ed25519", "rand 0.7.3", "serde", - "sha2", + "sha2 0.9.8", "zeroize", ] @@ -1313,9 +1372,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c13e9b0c3c4170dcc2a12783746c4205d98e18957f57854251eea3f9750fe005" dependencies = [ "bitvec 0.20.4", - "ff", + "ff 0.9.0", "generic-array", - "group", + "group 0.9.0", "pkcs8", "rand_core 0.6.3", "subtle", @@ -1323,10 +1382,27 @@ dependencies = [ ] [[package]] -name = "encoding_rs" -version = "0.8.29" +name = "elliptic-curve" +version = "0.11.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a74ea89a0a1b98f6332de42c95baff457ada66d1cb4030f9ff151b2041a1c746" +checksum = "decb3a27ea454a5f23f96eb182af0671c12694d64ecc33dada74edd1301f6cfc" +dependencies = [ + "crypto-bigint", + "der 0.5.1", + "ff 0.11.0", + "generic-array", + "group 0.11.0", + "rand_core 0.6.3", + "sec1", + "subtle", + "zeroize", +] + +[[package]] +name = "encoding_rs" +version = "0.8.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7896dc8abb250ffdda33912550faa54c88ec8b998dec0b2c55ab224921ce11df" dependencies = [ "cfg-if", ] @@ -1500,7 +1576,7 @@ dependencies = [ "lazy_static", "ring", "rustc-hex", - "sha2", + "sha2 0.9.8", "wasm-bindgen-test", ] @@ -1513,7 +1589,7 @@ dependencies = [ "cpufeatures 0.1.5", "lazy_static", "ring", - "sha2", + "sha2 0.9.8", ] [[package]] @@ -1539,7 +1615,7 @@ dependencies = [ "hex", "num-bigint-dig", "ring", - "sha2", + "sha2 0.9.8", "zeroize", ] @@ -1558,7 +1634,7 @@ dependencies = [ "serde", "serde_json", "serde_repr", - "sha2", + "sha2 0.9.8", "tempfile", "unicode-normalization", "uuid", @@ -1826,6 +1902,16 @@ dependencies = [ "subtle", ] +[[package]] +name = "ff" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2958d04124b9f27f175eaeb9a9f383d026098aa837eadd8ba22c11f13a05b9e" +dependencies = [ + "rand_core 0.6.3", + "subtle", +] + [[package]] name = "ffi-opaque" version = "2.0.1" @@ -1874,12 +1960,6 @@ dependencies = [ "static_assertions", ] -[[package]] -name = "fixedbitset" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37ab347416e802de484e4d03c7316c48f1ecb56574dfd4a46a80f173ce1de04d" - [[package]] name = "fixedbitset" version = "0.4.0" @@ -1960,9 +2040,9 @@ checksum = "fed34cd105917e91daa4da6b3728c47b068749d6a62c59811f06ed2ac71d9da7" [[package]] name = "futures" -version = "0.3.17" +version = "0.3.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a12aa0eb539080d55c3f2d45a67c3b58b6b0773c1a3ca2dfec66d58c97fd66ca" +checksum = "28560757fe2bb34e79f907794bb6b22ae8b0e5c669b638a1132f2592b19035b4" dependencies = [ "futures-channel", "futures-core", @@ -1975,9 +2055,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.17" +version = "0.3.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5da6ba8c3bb3c165d3c7319fc1cc8304facf1fb8db99c5de877183c08a273888" +checksum = "ba3dda0b6588335f360afc675d0564c17a77a2bda81ca178a4b6081bd86c7f0b" dependencies = [ "futures-core", "futures-sink", @@ -1985,15 +2065,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.17" +version = "0.3.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88d1c26957f23603395cd326b0ffe64124b818f4449552f960d815cfba83a53d" +checksum = "d0c8ff0461b82559810cdccfde3215c3f373807f5e5232b71479bff7bb2583d7" [[package]] name = "futures-executor" -version = "0.3.17" +version = "0.3.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45025be030969d763025784f7f355043dc6bc74093e4ecc5000ca4dc50d8745c" +checksum = "29d6d2ff5bb10fb95c85b8ce46538a2e5f5e7fdc755623a7d4529ab8a4ed9d2a" dependencies = [ "futures-core", "futures-task", @@ -2003,18 +2083,16 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.17" +version = "0.3.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "522de2a0fe3e380f1bc577ba0474108faf3f6b18321dbf60b3b9c39a75073377" +checksum = "b1f9d34af5a1aac6fb380f735fe510746c38067c5bf16c7fd250280503c971b2" [[package]] name = "futures-macro" -version = "0.3.17" +version = "0.3.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18e4a4b95cea4b4ccbcf1c5675ca7c4ee4e9e75eb79944d07defde18068f79bb" +checksum = "6dbd947adfffb0efc70599b3ddcf7b5597bb5fa9e245eb99f62b3a5f7bb8bd3c" dependencies = [ - "autocfg 1.0.1", - "proc-macro-hack", "proc-macro2", "quote", "syn", @@ -2027,21 +2105,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d383f0425d991a05e564c2f3ec150bd6dde863179c131dd60d8aa73a05434461" dependencies = [ "futures-io", - "rustls 0.20.1", + "rustls 0.20.2", "webpki 0.22.0", ] [[package]] name = "futures-sink" -version = "0.3.17" +version = "0.3.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36ea153c13024fe480590b3e3d4cad89a0cfacecc24577b68f86c6ced9c2bc11" +checksum = "e3055baccb68d74ff6480350f8d6eb8fcfa3aa11bdc1a1ae3afdd0514617d508" [[package]] name = "futures-task" -version = "0.3.17" +version = "0.3.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d3d00f4eddb73e498a54394f228cd55853bdf059259e8e7bc6e69d408892e99" +checksum = "6ee7c6485c30167ce4dfb83ac568a849fe53274c831081476ee13e0dce1aad72" [[package]] name = "futures-timer" @@ -2051,11 +2129,10 @@ checksum = "e64b03909df88034c26dc1547e8970b91f98bdb65165d6a4e9110d94263dbb2c" [[package]] name = "futures-util" -version = "0.3.17" +version = "0.3.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36568465210a3a6ee45e1f165136d68671471a501e632e9a98d96872222b5481" +checksum = "d9b5cf40b47a271f77a8b1bec03ca09044d99d2372c0de244e66430761127164" dependencies = [ - "autocfg 1.0.1", "futures-channel", "futures-core", "futures-io", @@ -2065,8 +2142,6 @@ dependencies = [ "memchr", "pin-project-lite 0.2.7", "pin-utils", - "proc-macro-hack", - "proc-macro-nested", "slab", ] @@ -2175,16 +2250,27 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "61b3c1e8b4f1ca07e6605ea1be903a5f6956aec5c8a67fd44d56076631675ed8" dependencies = [ - "ff", + "ff 0.9.0", + "rand_core 0.6.3", + "subtle", +] + +[[package]] +name = "group" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc5ac374b108929de78460075f3dc439fa66df9d8fc77e8f12caa5165fcf0c89" +dependencies = [ + "ff 0.11.0", "rand_core 0.6.3", "subtle", ] [[package]] name = "h2" -version = "0.3.7" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fd819562fcebdac5afc5c113c3ec36f902840b70fd4fc458799c8ce4607ae55" +checksum = "8f072413d126e57991455e0a922b31e4c8ba7c2ffbebf6b78b4f8521397d65cd" dependencies = [ "bytes", "fnv", @@ -2293,7 +2379,7 @@ version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "01706d578d5c281058480e673ae4086a9f4710d8df1ad80a5b03e39ece5f886b" dependencies = [ - "digest", + "digest 0.9.0", "hmac 0.11.0", ] @@ -2304,7 +2390,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "126888268dcc288495a26bf004b38c5fdbb31682f992c84ceb046a1f0fe38840" dependencies = [ "crypto-mac 0.8.0", - "digest", + "digest 0.9.0", ] [[package]] @@ -2314,7 +2400,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2a2a2320eb7ec0ebe8da8f744d7812d9fc4cb4d09344ac01898dbcb6a20ae69b" dependencies = [ "crypto-mac 0.11.1", - "digest", + "digest 0.9.0", ] [[package]] @@ -2323,7 +2409,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "17ea0a1394df5b6574da6e0c1ade9e78868c9fb0a4e5ef4428e32da4676b85b1" dependencies = [ - "digest", + "digest 0.9.0", "generic-array", "hmac 0.8.1", ] @@ -2347,7 +2433,7 @@ checksum = "1323096b05d41827dadeaee54c9981958c0f94e670bc94ed80037d1a7b8b186b" dependencies = [ "bytes", "fnv", - "itoa", + "itoa 0.4.8", ] [[package]] @@ -2433,9 +2519,9 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" [[package]] name = "hyper" -version = "0.14.15" +version = "0.14.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "436ec0091e4f20e655156a30a0df3770fe2900aa301e548e08446ec794b6953c" +checksum = "b7ec3e62bdc98a2f0393a5048e4c30ef659440ea6e0e572965103e72bd836f55" dependencies = [ "bytes", "futures-channel", @@ -2446,7 +2532,7 @@ dependencies = [ "http-body", "httparse", "httpdate", - "itoa", + "itoa 0.4.8", "pin-project-lite 0.2.7", "socket2 0.4.2", "tokio", @@ -2496,6 +2582,16 @@ dependencies = [ "winapi", ] +[[package]] +name = "if-addrs" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cbc0fa01ffc752e9dbc72818cdb072cd028b86be5e09dd04c5a643704fe101a9" +dependencies = [ + "libc", + "winapi", +] + [[package]] name = "if-addrs-sys" version = "0.3.2" @@ -2641,9 +2737,9 @@ checksum = "68f2d64f2edebec4ce84ad108148e67e1064789bee435edc5b60ad398714a3a9" [[package]] name = "itertools" -version = "0.10.1" +version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69ddb889f9d0d08a67338271fa9b62996bc788c7796a5c18cf057420aaed5eaf" +checksum = "a9a9d19fa1e79b6215ff29b9d6880b706147f16e9b1dbb1e4e5947b5b02bc5e3" dependencies = [ "either", ] @@ -2654,6 +2750,12 @@ version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4" +[[package]] +name = "itoa" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1aab8fc367588b89dcee83ab0fd66b72b50b72fa1904d7095045ace2b0c81c35" + [[package]] name = "js-sys" version = "0.3.55" @@ -2685,9 +2787,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8c3e8e491ed22bc161583a1c77e42313672c483eba6bd9d7afec0f1131d0b9ce" dependencies = [ "cfg-if", - "ecdsa", - "elliptic-curve", - "sha2", + "ecdsa 0.11.1", + "elliptic-curve 0.9.12", + "sha2 0.9.8", ] [[package]] @@ -2769,9 +2871,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.107" +version = "0.2.112" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbe5e23404da5b4f555ef85ebed98fb4083e55a00c317800bc2a50ede9f3d219" +checksum = "1b03d17f364a3a042d5e5d46b053bbbf82c92c9430c592dd4c064dc6ee997125" [[package]] name = "libflate" @@ -2827,9 +2929,8 @@ dependencies = [ [[package]] name = "libp2p" -version = "0.41.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "782229f90bf7d5b12ee3ee08f7e160ba99f0d75eee7d118d9c1a688b13f6e64a" +version = "0.42.0" +source = "git+https://github.com/libp2p/rust-libp2p?rev=17861d9cac121f7e448585a7f052d5eab4618826#17861d9cac121f7e448585a7f052d5eab4618826" dependencies = [ "atomic", "bytes", @@ -2838,7 +2939,7 @@ dependencies = [ "getrandom 0.2.3", "instant", "lazy_static", - "libp2p-core 0.30.0", + "libp2p-core 0.31.0", "libp2p-dns", "libp2p-gossipsub", "libp2p-identify", @@ -2858,40 +2959,6 @@ dependencies = [ "smallvec", ] -[[package]] -name = "libp2p-core" -version = "0.29.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af9b4abdeaa420593a297c8592f63fad4234f4b88dc9343b8fd8e736c35faa59" -dependencies = [ - "asn1_der", - "bs58", - "ed25519-dalek", - "either", - "fnv", - "futures", - "futures-timer", - "lazy_static", - "libsecp256k1 0.5.0", - "log", - "multiaddr", - "multihash", - "multistream-select", - "parking_lot", - "pin-project 1.0.8", - "prost 0.8.0", - "prost-build 0.8.0", - "rand 0.7.3", - "ring", - "rw-stream-sink", - "sha2", - "smallvec", - "thiserror", - "unsigned-varint 0.7.1", - "void", - "zeroize", -] - [[package]] name = "libp2p-core" version = "0.30.0" @@ -2910,15 +2977,50 @@ dependencies = [ "log", "multiaddr", "multihash", - "multistream-select", + "multistream-select 0.10.4", "parking_lot", "pin-project 1.0.8", - "prost 0.9.0", - "prost-build 0.9.0", + "prost", + "prost-build", "rand 0.8.4", "ring", "rw-stream-sink", - "sha2", + "sha2 0.9.8", + "smallvec", + "thiserror", + "unsigned-varint 0.7.1", + "void", + "zeroize", +] + +[[package]] +name = "libp2p-core" +version = "0.31.0" +source = "git+https://github.com/libp2p/rust-libp2p?rev=17861d9cac121f7e448585a7f052d5eab4618826#17861d9cac121f7e448585a7f052d5eab4618826" +dependencies = [ + "asn1_der", + "bs58", + "ed25519-dalek", + "either", + "fnv", + "futures", + "futures-timer", + "instant", + "lazy_static", + "libsecp256k1 0.7.0", + "log", + "multiaddr", + "multihash", + "multistream-select 0.11.0", + "p256", + "parking_lot", + "pin-project 1.0.8", + "prost", + "prost-build", + "rand 0.8.4", + "ring", + "rw-stream-sink", + "sha2 0.10.0", "smallvec", "thiserror", "unsigned-varint 0.7.1", @@ -2928,12 +3030,11 @@ dependencies = [ [[package]] name = "libp2p-dns" -version = "0.30.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb8f89d15cb6e3c5bc22afff7513b11bab7856f2872d3cfba86f7f63a06bc498" +version = "0.31.0" +source = "git+https://github.com/libp2p/rust-libp2p?rev=17861d9cac121f7e448585a7f052d5eab4618826#17861d9cac121f7e448585a7f052d5eab4618826" dependencies = [ "futures", - "libp2p-core 0.30.0", + "libp2p-core 0.31.0", "log", "smallvec", "trust-dns-resolver", @@ -2941,9 +3042,8 @@ dependencies = [ [[package]] name = "libp2p-gossipsub" -version = "0.34.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98942284cc1a91f24527a8b1e5bc06f7dd22fc6cee5be3d9bf5785bf902eb934" +version = "0.35.0" +source = "git+https://github.com/libp2p/rust-libp2p?rev=17861d9cac121f7e448585a7f052d5eab4618826#17861d9cac121f7e448585a7f052d5eab4618826" dependencies = [ "asynchronous-codec", "base64 0.13.0", @@ -2954,44 +3054,42 @@ dependencies = [ "futures-timer", "hex_fmt", "instant", - "libp2p-core 0.30.0", + "libp2p-core 0.31.0", "libp2p-swarm", "log", "open-metrics-client", "pin-project 1.0.8", - "prost 0.9.0", - "prost-build 0.9.0", + "prost", + "prost-build", "rand 0.7.3", "regex", - "sha2", + "sha2 0.10.0", "smallvec", "unsigned-varint 0.7.1", ] [[package]] name = "libp2p-identify" -version = "0.32.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec6d59e3f88435a83797fc3734f18385f6f54e0fe081e12543573364687c7db5" +version = "0.33.0" +source = "git+https://github.com/libp2p/rust-libp2p?rev=17861d9cac121f7e448585a7f052d5eab4618826#17861d9cac121f7e448585a7f052d5eab4618826" dependencies = [ "futures", "futures-timer", - "libp2p-core 0.30.0", + "libp2p-core 0.31.0", "libp2p-swarm", "log", "lru", - "prost 0.9.0", - "prost-build 0.9.0", + "prost", + "prost-build", "smallvec", ] [[package]] name = "libp2p-metrics" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d59f3be49edeecff13ef0d0dc28295ba4a33910611715f04236325d08e4119e0" +version = "0.3.0" +source = "git+https://github.com/libp2p/rust-libp2p?rev=17861d9cac121f7e448585a7f052d5eab4618826#17861d9cac121f7e448585a7f052d5eab4618826" dependencies = [ - "libp2p-core 0.30.0", + "libp2p-core 0.31.0", "libp2p-gossipsub", "libp2p-identify", "libp2p-swarm", @@ -3000,14 +3098,13 @@ dependencies = [ [[package]] name = "libp2p-mplex" -version = "0.30.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f2cd64ef597f40e14bfce0497f50ecb63dd6d201c61796daeb4227078834fbf" +version = "0.31.0" +source = "git+https://github.com/libp2p/rust-libp2p?rev=17861d9cac121f7e448585a7f052d5eab4618826#17861d9cac121f7e448585a7f052d5eab4618826" dependencies = [ "asynchronous-codec", "bytes", "futures", - "libp2p-core 0.30.0", + "libp2p-core 0.31.0", "log", "nohash-hasher", "parking_lot", @@ -3018,20 +3115,19 @@ dependencies = [ [[package]] name = "libp2p-noise" -version = "0.33.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8772c7a99088221bb7ca9c5c0574bf55046a7ab4c319f3619b275f28c8fb87a" +version = "0.34.0" +source = "git+https://github.com/libp2p/rust-libp2p?rev=17861d9cac121f7e448585a7f052d5eab4618826#17861d9cac121f7e448585a7f052d5eab4618826" dependencies = [ "bytes", "curve25519-dalek", "futures", "lazy_static", - "libp2p-core 0.30.0", + "libp2p-core 0.31.0", "log", - "prost 0.9.0", - "prost-build 0.9.0", + "prost", + "prost-build", "rand 0.8.4", - "sha2", + "sha2 0.10.0", "snow", "static_assertions", "x25519-dalek", @@ -3040,32 +3136,30 @@ dependencies = [ [[package]] name = "libp2p-plaintext" -version = "0.30.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fba1a6ff33e4a274c89a3b1d78b9f34f32af13265cc5c46c16938262d4e945a" +version = "0.31.0" +source = "git+https://github.com/libp2p/rust-libp2p?rev=17861d9cac121f7e448585a7f052d5eab4618826#17861d9cac121f7e448585a7f052d5eab4618826" dependencies = [ "asynchronous-codec", "bytes", "futures", - "libp2p-core 0.30.0", + "libp2p-core 0.31.0", "log", - "prost 0.9.0", - "prost-build 0.9.0", + "prost", + "prost-build", "unsigned-varint 0.7.1", "void", ] [[package]] name = "libp2p-swarm" -version = "0.32.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb84d40627cd109bbbf43da9269d4ef75903f42356c88d98b2b55c47c430c792" +version = "0.33.0" +source = "git+https://github.com/libp2p/rust-libp2p?rev=17861d9cac121f7e448585a7f052d5eab4618826#17861d9cac121f7e448585a7f052d5eab4618826" dependencies = [ "either", "futures", "futures-timer", "instant", - "libp2p-core 0.30.0", + "libp2p-core 0.31.0", "log", "rand 0.7.3", "smallvec", @@ -3074,9 +3168,8 @@ dependencies = [ [[package]] name = "libp2p-swarm-derive" -version = "0.26.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7dd93a7dad9b61c39797572e4fb4fdba8415d6348b4e745b3d4cb008f84331ab" +version = "0.26.1" +source = "git+https://github.com/libp2p/rust-libp2p?rev=17861d9cac121f7e448585a7f052d5eab4618826#17861d9cac121f7e448585a7f052d5eab4618826" dependencies = [ "quote", "syn", @@ -3084,16 +3177,15 @@ dependencies = [ [[package]] name = "libp2p-tcp" -version = "0.30.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7399c5b6361ef525d41c11fcf51635724f832baf5819b30d3d873eabb4fbae4b" +version = "0.31.0" +source = "git+https://github.com/libp2p/rust-libp2p?rev=17861d9cac121f7e448585a7f052d5eab4618826#17861d9cac121f7e448585a7f052d5eab4618826" dependencies = [ "futures", "futures-timer", - "if-addrs", + "if-addrs 0.7.0", "ipnet", "libc", - "libp2p-core 0.30.0", + "libp2p-core 0.31.0", "log", "socket2 0.4.2", "tokio", @@ -3101,14 +3193,13 @@ dependencies = [ [[package]] name = "libp2p-websocket" -version = "0.32.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa92005fbd67695715c821e1acfe4d7be9fd2d88738574e93d645c49ec2831c8" +version = "0.33.0" +source = "git+https://github.com/libp2p/rust-libp2p?rev=17861d9cac121f7e448585a7f052d5eab4618826#17861d9cac121f7e448585a7f052d5eab4618826" dependencies = [ "either", "futures", "futures-rustls", - "libp2p-core 0.30.0", + "libp2p-core 0.31.0", "log", "quicksink", "rw-stream-sink", @@ -3119,36 +3210,16 @@ dependencies = [ [[package]] name = "libp2p-yamux" -version = "0.34.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e7362abb8867d7187e7e93df17f460d554c997fc5c8ac57dc1259057f6889af" +version = "0.35.0" +source = "git+https://github.com/libp2p/rust-libp2p?rev=17861d9cac121f7e448585a7f052d5eab4618826#17861d9cac121f7e448585a7f052d5eab4618826" dependencies = [ "futures", - "libp2p-core 0.30.0", + "libp2p-core 0.31.0", "parking_lot", "thiserror", "yamux", ] -[[package]] -name = "libsecp256k1" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd1137239ab33b41aa9637a88a28249e5e70c40a42ccc92db7f12cc356c1fcd7" -dependencies = [ - "arrayref", - "base64 0.12.3", - "digest", - "hmac-drbg", - "libsecp256k1-core 0.2.2", - "libsecp256k1-gen-ecmult 0.2.1", - "libsecp256k1-gen-genmult 0.2.1", - "rand 0.7.3", - "serde", - "sha2", - "typenum", -] - [[package]] name = "libsecp256k1" version = "0.6.0" @@ -3157,14 +3228,14 @@ checksum = "c9d220bc1feda2ac231cb78c3d26f27676b8cf82c96971f7aeef3d0cf2797c73" dependencies = [ "arrayref", "base64 0.12.3", - "digest", + "digest 0.9.0", "hmac-drbg", "libsecp256k1-core 0.2.2", "libsecp256k1-gen-ecmult 0.2.1", "libsecp256k1-gen-genmult 0.2.1", "rand 0.7.3", "serde", - "sha2", + "sha2 0.9.8", "typenum", ] @@ -3176,14 +3247,14 @@ checksum = "b0452aac8bab02242429380e9b2f94ea20cea2b37e2c1777a1358799bbe97f37" dependencies = [ "arrayref", "base64 0.13.0", - "digest", + "digest 0.9.0", "hmac-drbg", "libsecp256k1-core 0.3.0", "libsecp256k1-gen-ecmult 0.3.0", "libsecp256k1-gen-genmult 0.3.0", "rand 0.8.4", "serde", - "sha2", + "sha2 0.9.8", "typenum", ] @@ -3194,7 +3265,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d0f6ab710cec28cef759c5f18671a27dae2a5f952cdaaee1d8e2908cb2478a80" dependencies = [ "crunchy", - "digest", + "digest 0.9.0", "subtle", ] @@ -3205,7 +3276,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5be9b9bb642d8522a44d533eab56c16c738301965504753b03ad1de3425d5451" dependencies = [ "crunchy", - "digest", + "digest 0.9.0", "subtle", ] @@ -3330,12 +3401,13 @@ dependencies = [ "lighthouse_metrics", "lighthouse_version", "lru", + "open-metrics-client", "parking_lot", "rand 0.7.3", "regex", "serde", "serde_derive", - "sha2", + "sha2 0.9.8", "slog", "slog-async", "slog-term", @@ -3408,9 +3480,9 @@ dependencies = [ [[package]] name = "lru" -version = "0.6.6" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ea2d928b485416e8908cff2d97d621db22b27f7b3b6729e438bcf42c671ba91" +checksum = "469898e909a1774d844793b347135a0cd344ca2f69d082013ecb8061a2229a3a" dependencies = [ "hashbrown", ] @@ -3464,9 +3536,9 @@ checksum = "ffbee8634e0d45d258acb448e7eaab3fce7a0a467395d4d9f228e3c1f01fb2e4" [[package]] name = "matchers" -version = "0.0.1" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f099785f7595cc4b4553a174ce30dd7589ef93391ff414dbb67f62392b9e0ce1" +checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558" dependencies = [ "regex-automata", ] @@ -3497,9 +3569,9 @@ checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a" [[package]] name = "memoffset" -version = "0.6.4" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59accc507f1338036a0477ef61afdae33cde60840f4dfe481319ce3ad116ddf9" +checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" dependencies = [ "autocfg 1.0.1", ] @@ -3544,6 +3616,12 @@ dependencies = [ "unicase", ] +[[package]] +name = "minimal-lexical" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" + [[package]] name = "miniz_oxide" version = "0.4.4" @@ -3620,10 +3698,10 @@ version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "752a61cd890ff691b4411423d23816d5866dd5621e4d1c5687a53b94b5a979d8" dependencies = [ - "digest", + "digest 0.9.0", "generic-array", "multihash-derive", - "sha2", + "sha2 0.9.8", "unsigned-varint 0.7.1", ] @@ -3697,6 +3775,19 @@ dependencies = [ "unsigned-varint 0.7.1", ] +[[package]] +name = "multistream-select" +version = "0.11.0" +source = "git+https://github.com/libp2p/rust-libp2p?rev=17861d9cac121f7e448585a7f052d5eab4618826#17861d9cac121f7e448585a7f052d5eab4618826" +dependencies = [ + "bytes", + "futures", + "log", + "pin-project 1.0.8", + "smallvec", + "unsigned-varint 0.7.1", +] + [[package]] name = "native-tls" version = "0.2.8" @@ -3730,7 +3821,7 @@ dependencies = [ "genesis", "hashset_delay", "hex", - "if-addrs", + "if-addrs 0.6.7", "igd", "itertools", "lazy_static", @@ -3772,9 +3863,9 @@ dependencies = [ [[package]] name = "nix" -version = "0.22.2" +version = "0.23.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3bb9a13fa32bc5aeb64150cd3f32d6cf4c748f8f8a417cce5d2eb976a8370ba" +checksum = "9f866317acbd3a240710c63f065ffb1e4fd466259045ccb504130b7f668f35c6" dependencies = [ "bitflags", "cc", @@ -3811,13 +3902,12 @@ checksum = "cf51a729ecf40266a2368ad335a5fdde43471f545a967109cd62146ecf8b66ff" [[package]] name = "nom" -version = "6.1.2" +version = "7.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7413f999671bd4745a7b624bd370a569fb6bc574b23c83a3c5ed2e453f3d5e2" +checksum = "1b1d11e1ef389c76fe5b81bcaf2ea32cf88b62bc494e19f493d0b30e7a930109" dependencies = [ - "bitvec 0.19.5", - "funty", "memchr", + "minimal-lexical", "version_check", ] @@ -3892,9 +3982,9 @@ dependencies = [ [[package]] name = "num_cpus" -version = "1.13.0" +version = "1.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05499f3756671c15885fee9034446956fff3f243d6077b91e5767df161f766b3" +checksum = "19e64526ebdee182341572e50e9ad03965aa510cd94427a4549448f285e957a1" dependencies = [ "hermit-abi", "libc", @@ -3911,9 +4001,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.8.0" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "692fcb63b64b1758029e0a96ee63e049ce8c5948587f2f7208df04625e5f6b56" +checksum = "da32515d9f6e6e489d7bc9d84c71b060db7247dc035bbe44eac88cf87486d8d5" [[package]] name = "oorandom" @@ -3929,12 +4019,12 @@ checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" [[package]] name = "open-metrics-client" -version = "0.12.0" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7337d80c23c2d8b1349563981bc4fb531220733743ba8115454a67b181173f0d" +checksum = "9e224744b2e4da5b241857d2363a13bce60425f7b6ae2a5ff88d4d5557d9cc85" dependencies = [ "dtoa", - "itoa", + "itoa 0.4.8", "open-metrics-client-derive-text-encode", "owning_ref", ] @@ -4022,6 +4112,18 @@ dependencies = [ "stable_deref_trait", ] +[[package]] +name = "p256" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0e0c5310031b5d4528ac6534bccc1446c289ac45c47b277d5aa91089c5f74fa" +dependencies = [ + "ecdsa 0.13.3", + "elliptic-curve 0.11.6", + "sec1", + "sha2 0.9.8", +] + [[package]] name = "parity-scale-codec" version = "1.3.7" @@ -4130,23 +4232,13 @@ dependencies = [ "ucd-trie", ] -[[package]] -name = "petgraph" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "467d164a6de56270bd7c4d070df81d07beace25012d5103ced4e9ff08d6afdb7" -dependencies = [ - "fixedbitset 0.2.0", - "indexmap", -] - [[package]] name = "petgraph" version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4a13a2fa9d0b63e5f22328828741e523766fff0ee9e779316902290dff3f824f" dependencies = [ - "fixedbitset 0.4.0", + "fixedbitset", "indexmap", ] @@ -4214,15 +4306,15 @@ version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c9c2f795bc591cb3384cb64082a578b89207ac92bb89c9d98c1ea2ace7cd8110" dependencies = [ - "der", + "der 0.3.5", "spki", ] [[package]] name = "pkg-config" -version = "0.3.22" +version = "0.3.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12295df4f294471248581bc09bef3c38a5e46f1e36d6a37353621a0c6c357e1f" +checksum = "58893f751c9b0412871a09abd62ecd2a00298c6c83befa223ef98c52aef40cbe" [[package]] name = "platforms" @@ -4366,17 +4458,11 @@ version = "0.5.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5" -[[package]] -name = "proc-macro-nested" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc881b2c22681370c6a780e47af9840ef841837bc98118431d4e1868bd0c1086" - [[package]] name = "proc-macro2" -version = "1.0.32" +version = "1.0.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba508cc11742c0dc5c1659771673afbab7a0efab23aa17e854cbab0837ed0b43" +checksum = "2f84e92c0f7c9d58328b85a78557813e4bd845130db68d7184635344399423b1" dependencies = [ "unicode-xid", ] @@ -4408,16 +4494,6 @@ dependencies = [ "thiserror", ] -[[package]] -name = "prost" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de5e2533f59d08fcf364fd374ebda0692a70bd6d7e66ef97f306f45c6c5d8020" -dependencies = [ - "bytes", - "prost-derive 0.8.0", -] - [[package]] name = "prost" version = "0.9.0" @@ -4425,25 +4501,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "444879275cb4fd84958b1a1d5420d15e6fcf7c235fe47f053c9c2a80aceb6001" dependencies = [ "bytes", - "prost-derive 0.9.0", -] - -[[package]] -name = "prost-build" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "355f634b43cdd80724ee7848f95770e7e70eefa6dcf14fea676216573b8fd603" -dependencies = [ - "bytes", - "heck", - "itertools", - "log", - "multimap", - "petgraph 0.5.1", - "prost 0.8.0", - "prost-types 0.8.0", - "tempfile", - "which", + "prost-derive", ] [[package]] @@ -4458,27 +4516,14 @@ dependencies = [ "lazy_static", "log", "multimap", - "petgraph 0.6.0", - "prost 0.9.0", - "prost-types 0.9.0", + "petgraph", + "prost", + "prost-types", "regex", "tempfile", "which", ] -[[package]] -name = "prost-derive" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "600d2f334aa05acb02a755e217ef1ab6dea4d51b58b7846588b747edec04efba" -dependencies = [ - "anyhow", - "itertools", - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "prost-derive" version = "0.9.0" @@ -4492,16 +4537,6 @@ dependencies = [ "syn", ] -[[package]] -name = "prost-types" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "603bbd6394701d13f3f25aada59c7de9d35a6a5887cfc156181234a44002771b" -dependencies = [ - "bytes", - "prost 0.8.0", -] - [[package]] name = "prost-types" version = "0.9.0" @@ -4509,7 +4544,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "534b7a0e836e3c482d2693070f982e39e7611da9695d4d1f5a4b186b51faef0a" dependencies = [ "bytes", - "prost 0.9.0", + "prost", ] [[package]] @@ -4807,9 +4842,9 @@ dependencies = [ [[package]] name = "reqwest" -version = "0.11.6" +version = "0.11.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66d2927ca2f685faf0fc620ac4834690d29e7abb153add10f5812eef20b5e280" +checksum = "7c4e0a76dc12a116108933f6301b95e83634e0c47b0afbed6abbaa0601e99258" dependencies = [ "base64 0.13.0", "bytes", @@ -4833,6 +4868,7 @@ dependencies = [ "serde_urlencoded", "tokio", "tokio-native-tls", + "tokio-util", "url", "wasm-bindgen", "wasm-bindgen-futures", @@ -4850,6 +4886,17 @@ dependencies = [ "quick-error", ] +[[package]] +name = "rfc6979" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96ef608575f6392792f9ecf7890c00086591d29a83910939d430753f7c050525" +dependencies = [ + "crypto-bigint", + "hmac 0.11.0", + "zeroize", +] + [[package]] name = "ring" version = "0.16.20" @@ -4975,9 +5022,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.20.1" +version = "0.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dac4581f0fc0e0efd529d069e8189ec7b90b8e7680e21beb35141bdc45f36040" +checksum = "d37e5e2290f3e040b594b1a9e04377c2c671f1a1cfd9bfdef82106ac1c113f84" dependencies = [ "log", "ring", @@ -4987,9 +5034,9 @@ dependencies = [ [[package]] name = "rustversion" -version = "1.0.5" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61b3909d758bb75c79f23d4736fac9433868679d3ad2ea7a61e3c25cfda9a088" +checksum = "f2cc38e8fa666e2de3c4aba7edeb5ffc5246c1c2ed0e3d17e560aeeba736b23f" [[package]] name = "rw-stream-sink" @@ -5004,9 +5051,9 @@ dependencies = [ [[package]] name = "ryu" -version = "1.0.5" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" +checksum = "73b4b750c782965c211b42f022f59af1fbceabdd026623714f104152f1ec149f" [[package]] name = "safe_arith" @@ -5076,7 +5123,7 @@ dependencies = [ "hmac 0.11.0", "pbkdf2 0.8.0", "salsa20", - "sha2", + "sha2 0.9.8", ] [[package]] @@ -5099,6 +5146,18 @@ dependencies = [ "untrusted", ] +[[package]] +name = "sec1" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08da66b8b0965a5555b6bd6639e68ccba85e1e2506f5fbb089e93f8a04e1a2d1" +dependencies = [ + "der 0.5.1", + "generic-array", + "subtle", + "zeroize", +] + [[package]] name = "secp256k1" version = "0.20.3" @@ -5189,9 +5248,9 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.130" +version = "1.0.132" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f12d06de37cf59146fbdecab66aa99f9fe4f78722e3607577a5375d66bd0c913" +checksum = "8b9875c23cf305cd1fd7eb77234cbb705f21ea6a72c637a5c6db5fe4b8e7f008" dependencies = [ "serde_derive", ] @@ -5208,9 +5267,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.130" +version = "1.0.132" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7bc1a1ab1961464eae040d96713baa5a724a8152c1222492465b54322ec508b" +checksum = "ecc0db5cb2556c0e558887d9bbdcf6ac4471e83ff66cf696e5419024d1606276" dependencies = [ "proc-macro2", "quote", @@ -5219,11 +5278,11 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.71" +version = "1.0.73" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "063bf466a64011ac24040a49009724ee60a57da1b437617ceb32e53ad61bfb19" +checksum = "bcbd0344bc6533bc7ec56df11d42fb70f1b912351c0825ccb7211b59d8af7cf5" dependencies = [ - "itoa", + "itoa 1.0.1", "ryu", "serde", ] @@ -5246,19 +5305,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "edfa57a7f8d9c1d260a549e7224100f6c43d43f9103e06dd8b4095a9b2b43ce9" dependencies = [ "form_urlencoded", - "itoa", + "itoa 0.4.8", "ryu", "serde", ] [[package]] name = "serde_yaml" -version = "0.8.21" +version = "0.8.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8c608a35705a5d3cdc9fbe403147647ff34b921f8e833e49306df898f9b20af" +checksum = "a4a521f2940385c165a24ee286aa8599633d162077a54bdcae2a6fd5a7bfa7a0" dependencies = [ - "dtoa", "indexmap", + "ryu", "serde", "yaml-rust", ] @@ -5269,10 +5328,10 @@ version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "99cd6713db3cf16b6c84e06321e049a9b9f699826e16096d23bbcc44d15d51a6" dependencies = [ - "block-buffer", + "block-buffer 0.9.0", "cfg-if", "cpufeatures 0.2.1", - "digest", + "digest 0.9.0", "opaque-debug", ] @@ -5282,21 +5341,32 @@ version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b69f9a4c9740d74c5baa3fd2e547f9525fa8088a8a958e0ca2409a514e33f5fa" dependencies = [ - "block-buffer", + "block-buffer 0.9.0", "cfg-if", "cpufeatures 0.2.1", - "digest", + "digest 0.9.0", "opaque-debug", ] +[[package]] +name = "sha2" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "900d964dd36bb15bcf2f2b35694c072feab74969a54f2bbeec7a2d725d2bdcb6" +dependencies = [ + "cfg-if", + "cpufeatures 0.2.1", + "digest 0.10.1", +] + [[package]] name = "sha3" version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f81199417d4e5de3f04b1e871023acea7389672c4135918f05aa9cbf2f2fa809" dependencies = [ - "block-buffer", - "digest", + "block-buffer 0.9.0", + "digest 0.9.0", "keccak", "opaque-debug", ] @@ -5331,7 +5401,7 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f2807892cfa58e081aa1f1111391c7a0649d4fa127a4ffbe34bcbfb35a1171a4" dependencies = [ - "digest", + "digest 0.9.0", "rand_core 0.6.3", ] @@ -5557,7 +5627,7 @@ dependencies = [ "rand_core 0.6.3", "ring", "rustc_version 0.3.3", - "sha2", + "sha2 0.9.8", "subtle", "x25519-dalek", ] @@ -5626,7 +5696,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9dae7e047abc519c96350e9484a96c6bf1492348af912fd3446dd2dc323f6268" dependencies = [ - "der", + "der 0.3.5", ] [[package]] @@ -5960,7 +6030,7 @@ dependencies = [ "pbkdf2 0.4.0", "rand 0.7.3", "rustc-hash", - "sha2", + "sha2 0.9.8", "thiserror", "unicode-normalization", "wasm-bindgen", @@ -6012,11 +6082,10 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" [[package]] name = "tokio" -version = "1.14.0" +version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70e992e41e0d2fb9f755b37446f20900f64446ef54874f40a60c78f021ac6144" +checksum = "fbbf1c778ec206785635ce8ad57fe52b3009ae9e0c9f574a728f3049d3e55838" dependencies = [ - "autocfg 1.0.1", "bytes", "libc", "memchr", @@ -6042,9 +6111,9 @@ dependencies = [ [[package]] name = "tokio-macros" -version = "1.6.0" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c9efc1aba077437943f7515666aa2b882dfabfbfdf89c819ea75a8d6e9eaba5e" +checksum = "b557f72f448c511a979e2564e55d74e6c4432fc96ff4f6241bc6bded342643b7" dependencies = [ "proc-macro2", "quote", @@ -6195,36 +6264,22 @@ dependencies = [ "tracing-core", ] -[[package]] -name = "tracing-serde" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb65ea441fbb84f9f6748fd496cf7f63ec9af5bca94dd86456978d055e8eb28b" -dependencies = [ - "serde", - "tracing-core", -] - [[package]] name = "tracing-subscriber" -version = "0.2.25" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e0d2eaa99c3c2e41547cfa109e910a68ea03823cccad4a0525dcbc9b01e8c71" +checksum = "245da694cc7fc4729f3f418b304cb57789f1bed2a78c575407ab8a23f53cb4d3" dependencies = [ - "ansi_term 0.12.1", - "chrono", + "ansi_term", "lazy_static", "matchers", "regex", - "serde", - "serde_json", "sharded-slab", "smallvec", "thread_local", "tracing", "tracing-core", "tracing-log", - "tracing-serde", ] [[package]] diff --git a/beacon_node/beacon_chain/Cargo.toml b/beacon_node/beacon_chain/Cargo.toml index c4bd3bf7b..d4e187bd8 100644 --- a/beacon_node/beacon_chain/Cargo.toml +++ b/beacon_node/beacon_chain/Cargo.toml @@ -43,7 +43,7 @@ genesis = { path = "../genesis" } int_to_bytes = { path = "../../consensus/int_to_bytes" } rand = "0.7.3" proto_array = { path = "../../consensus/proto_array" } -lru = "0.6.0" +lru = "0.7.1" tempfile = "3.1.0" bitvec = "0.19.3" bls = { path = "../../crypto/bls" } diff --git a/beacon_node/client/Cargo.toml b/beacon_node/client/Cargo.toml index d2e673f60..acb8376db 100644 --- a/beacon_node/client/Cargo.toml +++ b/beacon_node/client/Cargo.toml @@ -31,7 +31,7 @@ task_executor = { path = "../../common/task_executor" } environment = { path = "../../lighthouse/environment" } lazy_static = "1.4.0" lighthouse_metrics = { path = "../../common/lighthouse_metrics" } -time = "0.3.3" +time = "0.3.5" directory = {path = "../../common/directory"} http_api = { path = "../http_api" } http_metrics = { path = "../http_metrics" } diff --git a/beacon_node/client/src/builder.rs b/beacon_node/client/src/builder.rs index 30bc34dda..d497af648 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::NetworkGlobals; +use lighthouse_network::{open_metrics_client::registry::Registry, NetworkGlobals}; use monitoring_api::{MonitoringHttpClient, ProcessType}; use network::{NetworkConfig, NetworkMessage, NetworkService}; use slasher::Slasher; @@ -65,6 +65,7 @@ pub struct ClientBuilder { eth1_service: Option, network_globals: Option>>, network_send: Option>>, + gossipsub_registry: Option, db_path: Option, freezer_db_path: Option, http_api_config: http_api::Config, @@ -96,6 +97,7 @@ where eth1_service: None, network_globals: None, network_send: None, + gossipsub_registry: None, db_path: None, freezer_db_path: None, http_api_config: <_>::default(), @@ -448,13 +450,27 @@ where .ok_or("network requires a runtime_context")? .clone(); - let (network_globals, network_send) = - NetworkService::start(beacon_chain, config, context.executor) - .await - .map_err(|e| format!("Failed to start network: {:?}", e))?; + // If gossipsub metrics are required we build a registry to record them + let mut gossipsub_registry = if config.metrics_enabled { + Some(Registry::default()) + } else { + None + }; + + let (network_globals, network_send) = NetworkService::start( + beacon_chain, + config, + context.executor, + gossipsub_registry + .as_mut() + .map(|registry| registry.sub_registry_with_prefix("gossipsub")), + ) + .await + .map_err(|e| format!("Failed to start network: {:?}", e))?; self.network_globals = Some(network_globals); self.network_send = Some(network_send); + self.gossipsub_registry = gossipsub_registry; Ok(self) } @@ -562,13 +578,13 @@ where Ok(self) } - /// Consumers the builder, returning a `Client` if all necessary components have been + /// Consumes the builder, returning a `Client` if all necessary components have been /// specified. /// /// If type inference errors are being raised, see the comment on the definition of `Self`. #[allow(clippy::type_complexity)] pub fn build( - self, + mut self, ) -> Result>, String> { let runtime_context = self @@ -615,6 +631,7 @@ where chain: self.beacon_chain.clone(), db_path: self.db_path.clone(), freezer_db_path: self.freezer_db_path.clone(), + gossipsub_registry: self.gossipsub_registry.take().map(std::sync::Mutex::new), log: log.clone(), }); diff --git a/beacon_node/execution_layer/Cargo.toml b/beacon_node/execution_layer/Cargo.toml index ea09b1f7c..c166024c0 100644 --- a/beacon_node/execution_layer/Cargo.toml +++ b/beacon_node/execution_layer/Cargo.toml @@ -23,7 +23,7 @@ bytes = "1.1.0" task_executor = { path = "../../common/task_executor" } hex = "0.4.2" eth2_ssz_types = "0.2.2" -lru = "0.6.0" +lru = "0.7.1" exit-future = "0.2.0" tree_hash = "0.4.1" tree_hash_derive = { path = "../../consensus/tree_hash_derive"} diff --git a/beacon_node/http_api/src/lib.rs b/beacon_node/http_api/src/lib.rs index 4df5c940b..85c464466 100644 --- a/beacon_node/http_api/src/lib.rs +++ b/beacon_node/http_api/src/lib.rs @@ -2275,6 +2275,22 @@ pub fn serve( }) }); + // GET lighthouse/nat + let get_lighthouse_nat = warp::path("lighthouse") + .and(warp::path("nat")) + .and(warp::path::end()) + .and_then(|| { + blocking_json_task(move || { + Ok(api_types::GenericResponse::from( + lighthouse_network::metrics::NAT_OPEN + .as_ref() + .map(|v| v.get()) + .unwrap_or(0) + != 0, + )) + }) + }); + // GET lighthouse/peers let get_lighthouse_peers = warp::path("lighthouse") .and(warp::path("peers")) @@ -2622,6 +2638,7 @@ pub fn serve( .or(get_validator_sync_committee_contribution.boxed()) .or(get_lighthouse_health.boxed()) .or(get_lighthouse_syncing.boxed()) + .or(get_lighthouse_nat.boxed()) .or(get_lighthouse_peers.boxed()) .or(get_lighthouse_peers_connected.boxed()) .or(get_lighthouse_proto_array.boxed()) diff --git a/beacon_node/http_metrics/src/lib.rs b/beacon_node/http_metrics/src/lib.rs index 66c7a6a6f..89e6a8e2d 100644 --- a/beacon_node/http_metrics/src/lib.rs +++ b/beacon_node/http_metrics/src/lib.rs @@ -4,6 +4,7 @@ mod metrics; use beacon_chain::{BeaconChain, BeaconChainTypes}; +use lighthouse_network::open_metrics_client::registry::Registry; use lighthouse_version::version_with_platform; use serde::{Deserialize, Serialize}; use slog::{crit, info, Logger}; @@ -39,6 +40,7 @@ pub struct Context { pub chain: Option>>, pub db_path: Option, pub freezer_db_path: Option, + pub gossipsub_registry: Option>, pub log: Logger, } diff --git a/beacon_node/http_metrics/src/metrics.rs b/beacon_node/http_metrics/src/metrics.rs index c86211f31..66c961956 100644 --- a/beacon_node/http_metrics/src/metrics.rs +++ b/beacon_node/http_metrics/src/metrics.rs @@ -1,6 +1,7 @@ use crate::Context; use beacon_chain::BeaconChainTypes; use lighthouse_metrics::{Encoder, TextEncoder}; +use lighthouse_network::open_metrics_client::encoding::text::encode; use malloc_utils::scrape_allocator_metrics; pub use lighthouse_metrics::*; @@ -51,6 +52,12 @@ pub fn gather_prometheus_metrics( encoder .encode(&lighthouse_metrics::gather(), &mut buffer) .unwrap(); + // encode gossipsub metrics also if they exist + if let Some(registry) = ctx.gossipsub_registry.as_ref() { + if let Ok(registry_locked) = registry.lock() { + let _ = encode(&mut buffer, ®istry_locked); + } + } String::from_utf8(buffer).map_err(|e| format!("Failed to encode prometheus info: {:?}", e)) } diff --git a/beacon_node/http_metrics/tests/tests.rs b/beacon_node/http_metrics/tests/tests.rs index 633b81115..fd8733cfe 100644 --- a/beacon_node/http_metrics/tests/tests.rs +++ b/beacon_node/http_metrics/tests/tests.rs @@ -25,6 +25,7 @@ async fn returns_200_ok() { chain: None, db_path: None, freezer_db_path: None, + gossipsub_registry: None, log, }); diff --git a/beacon_node/lighthouse_network/Cargo.toml b/beacon_node/lighthouse_network/Cargo.toml index 7dcccd8ca..e148ae2db 100644 --- a/beacon_node/lighthouse_network/Cargo.toml +++ b/beacon_node/lighthouse_network/Cargo.toml @@ -5,7 +5,7 @@ authors = ["Sigma Prime "] edition = "2018" [dependencies] -discv5 = { version = "0.1.0-beta.11", features = ["libp2p"] } +discv5 = { version = "0.1.0-beta.13", features = ["libp2p"] } unsigned-varint = { version = "0.6.0", features = ["codec"] } types = { path = "../../consensus/types" } hashset_delay = { path = "../../common/hashset_delay" } @@ -25,7 +25,7 @@ lazy_static = "1.4.0" lighthouse_metrics = { path = "../../common/lighthouse_metrics" } smallvec = "1.6.1" tokio-io-timeout = "1.1.1" -lru = "0.6.0" +lru = "0.7.1" parking_lot = "0.11.0" sha2 = "0.9.1" snap = "1.0.1" @@ -38,18 +38,21 @@ directory = { path = "../../common/directory" } regex = "1.3.9" strum = { version = "0.21.0", features = ["derive"] } superstruct = "0.3.0" +open-metrics-client = "0.13.0" [dependencies.libp2p] -version = "0.41.0" +# version = "0.41.0" default-features = false -features = ["websocket", "identify", "mplex", "yamux", "noise", "gossipsub", "dns-tokio", "tcp-tokio"] +git = "https://github.com/libp2p/rust-libp2p" +# Latest libp2p master +rev = "17861d9cac121f7e448585a7f052d5eab4618826" +features = ["websocket", "identify", "mplex", "yamux", "noise", "gossipsub", "dns-tokio", "tcp-tokio", "plaintext"] [dev-dependencies] slog-term = "2.6.0" slog-async = "2.5.0" tempfile = "3.1.0" exit-future = "0.2.0" -libp2p = { version = "0.41.0", default-features = false, features = ["plaintext"] } void = "1" [features] diff --git a/beacon_node/lighthouse_network/src/behaviour/mod.rs b/beacon_node/lighthouse_network/src/behaviour/mod.rs index 51699d236..f14d24aac 100644 --- a/beacon_node/lighthouse_network/src/behaviour/mod.rs +++ b/beacon_node/lighthouse_network/src/behaviour/mod.rs @@ -8,18 +8,19 @@ use crate::peer_manager::{ ConnectionDirection, PeerManager, PeerManagerEvent, }; use crate::rpc::*; -use crate::service::METADATA_FILENAME; +use crate::service::{Context as ServiceContext, METADATA_FILENAME}; use crate::types::{ subnet_from_topic_hash, GossipEncoding, GossipKind, GossipTopic, SnappyTransform, Subnet, SubnetDiscovery, }; use crate::Eth2Enr; -use crate::{error, metrics, Enr, NetworkConfig, NetworkGlobals, PubsubMessage, TopicHash}; +use crate::{error, metrics, Enr, NetworkGlobals, PubsubMessage, TopicHash}; use libp2p::{ core::{ connection::ConnectionId, identity::Keypair, multiaddr::Protocol as MProtocol, Multiaddr, }, gossipsub::{ + metrics::Config as GossipsubMetricsConfig, subscription_filter::{MaxCountSubscriptionFilter, WhitelistSubscriptionFilter}, Gossipsub as BaseGossipsub, GossipsubEvent, IdentTopic as Topic, MessageAcceptance, MessageAuthenticity, MessageId, @@ -45,7 +46,7 @@ use std::{ task::{Context, Poll}, }; use types::{ - consts::altair::SYNC_COMMITTEE_SUBNET_COUNT, ChainSpec, EnrForkId, EthSpec, ForkContext, + consts::altair::SYNC_COMMITTEE_SUBNET_COUNT, EnrForkId, EthSpec, ForkContext, SignedBeaconBlock, Slot, SubnetId, SyncSubnetId, }; @@ -182,14 +183,14 @@ pub struct Behaviour { impl Behaviour { pub async fn new( local_key: &Keypair, - mut config: NetworkConfig, + ctx: ServiceContext<'_>, network_globals: Arc>, log: &slog::Logger, - fork_context: Arc, - chain_spec: &ChainSpec, ) -> error::Result { let behaviour_log = log.new(o!()); + let mut config = ctx.config.clone(); + // Set up the Identify Behaviour let identify_config = if config.private { IdentifyConfig::new( @@ -215,25 +216,29 @@ impl Behaviour { .eth2() .expect("Local ENR must have a fork id"); - let possible_fork_digests = fork_context.all_fork_digests(); + let possible_fork_digests = ctx.fork_context.all_fork_digests(); let filter = MaxCountSubscriptionFilter { filter: Self::create_whitelist_filter( possible_fork_digests, - chain_spec.attestation_subnet_count, + ctx.chain_spec.attestation_subnet_count, SYNC_COMMITTEE_SUBNET_COUNT, ), max_subscribed_topics: 200, max_subscriptions_per_request: 150, // 148 in theory = (64 attestation + 4 sync committee + 6 core topics) * 2 }; - config.gs_config = gossipsub_config(fork_context.clone()); + config.gs_config = gossipsub_config(ctx.fork_context.clone()); + + // If metrics are enabled for gossipsub build the configuration + let gossipsub_metrics = ctx + .gossipsub_registry + .map(|registry| (registry, GossipsubMetricsConfig::default())); - // Build and configure the Gossipsub behaviour let snappy_transform = SnappyTransform::new(config.gs_config.max_transmit_size()); let mut gossipsub = Gossipsub::new_with_subscription_filter_and_transform( MessageAuthenticity::Anonymous, config.gs_config.clone(), - None, // No metrics for the time being + gossipsub_metrics, filter, snappy_transform, ) @@ -246,7 +251,7 @@ impl Behaviour { let thresholds = lighthouse_gossip_thresholds(); - let score_settings = PeerScoreSettings::new(chain_spec, &config.gs_config); + let score_settings = PeerScoreSettings::new(ctx.chain_spec, &config.gs_config); // Prepare scoring parameters let params = score_settings.get_peer_score_params( @@ -267,6 +272,7 @@ impl Behaviour { let peer_manager_cfg = PeerManagerCfg { discovery_enabled: !config.disable_discovery, + metrics_enabled: config.metrics_enabled, target_peer_count: config.target_peers, ..Default::default() }; @@ -274,7 +280,7 @@ impl Behaviour { Ok(Behaviour { // Sub-behaviours gossipsub, - eth2_rpc: RPC::new(fork_context.clone(), log.clone()), + eth2_rpc: RPC::new(ctx.fork_context.clone(), log.clone()), discovery, identify: Identify::new(identify_config), // Auxiliary fields @@ -287,7 +293,7 @@ impl Behaviour { network_dir: config.network_dir.clone(), log: behaviour_log, score_settings, - fork_context, + fork_context: ctx.fork_context, update_gossipsub_scores, }) } @@ -393,14 +399,15 @@ impl Behaviour { .remove(&topic); // unsubscribe from the topic - let topic: Topic = topic.into(); + let libp2p_topic: Topic = topic.clone().into(); - match self.gossipsub.unsubscribe(&topic) { + match self.gossipsub.unsubscribe(&libp2p_topic) { Err(_) => { - warn!(self.log, "Failed to unsubscribe from topic"; "topic" => %topic); + warn!(self.log, "Failed to unsubscribe from topic"; "topic" => %libp2p_topic); false } Ok(v) => { + // Inform the network debug!(self.log, "Unsubscribed to topic"; "topic" => %topic); v } @@ -732,6 +739,18 @@ impl Behaviour { /// Convenience function to propagate a request. fn propagate_request(&mut self, id: PeerRequestId, peer_id: PeerId, request: Request) { + // Increment metrics + match &request { + Request::Status(_) => { + metrics::inc_counter_vec(&metrics::TOTAL_RPC_REQUESTS, &["status"]) + } + Request::BlocksByRange { .. } => { + metrics::inc_counter_vec(&metrics::TOTAL_RPC_REQUESTS, &["blocks_by_range"]) + } + Request::BlocksByRoot { .. } => { + metrics::inc_counter_vec(&metrics::TOTAL_RPC_REQUESTS, &["blocks_by_root"]) + } + } self.add_event(BehaviourEvent::RequestReceived { peer_id, id, diff --git a/beacon_node/lighthouse_network/src/discovery/enr.rs b/beacon_node/lighthouse_network/src/discovery/enr.rs index 3f2ae759b..1d542a7f3 100644 --- a/beacon_node/lighthouse_network/src/discovery/enr.rs +++ b/beacon_node/lighthouse_network/src/discovery/enr.rs @@ -127,7 +127,7 @@ pub fn use_or_load_enr( pub fn build_or_load_enr( local_key: Keypair, config: &NetworkConfig, - enr_fork_id: EnrForkId, + enr_fork_id: &EnrForkId, log: &slog::Logger, ) -> Result { // Build the local ENR. @@ -163,7 +163,7 @@ pub fn create_enr_builder_from_config( pub fn build_enr( enr_key: &CombinedKey, config: &NetworkConfig, - enr_fork_id: EnrForkId, + enr_fork_id: &EnrForkId, ) -> Result { let mut builder = create_enr_builder_from_config(config, true); diff --git a/beacon_node/lighthouse_network/src/discovery/mod.rs b/beacon_node/lighthouse_network/src/discovery/mod.rs index ae7335b5c..33e8c2c17 100644 --- a/beacon_node/lighthouse_network/src/discovery/mod.rs +++ b/beacon_node/lighthouse_network/src/discovery/mod.rs @@ -1039,6 +1039,7 @@ impl NetworkBehaviour for Discovery { Discv5Event::SocketUpdated(socket) => { info!(self.log, "Address updated"; "ip" => %socket.ip(), "udp_port" => %socket.port()); metrics::inc_counter(&metrics::ADDRESS_UPDATE_COUNT); + metrics::check_nat(); // Discv5 will have updated our local ENR. We save the updated version // to disk. let enr = self.discv5.local_enr(); @@ -1096,7 +1097,7 @@ mod tests { ..Default::default() }; let enr_key: CombinedKey = CombinedKey::from_libp2p(&keypair).unwrap(); - let enr: Enr = build_enr::(&enr_key, &config, EnrForkId::default()).unwrap(); + let enr: Enr = build_enr::(&enr_key, &config, &EnrForkId::default()).unwrap(); let log = build_log(slog::Level::Debug, false); let globals = NetworkGlobals::new( enr, diff --git a/beacon_node/lighthouse_network/src/lib.rs b/beacon_node/lighthouse_network/src/lib.rs index 058b38ceb..0460a42c8 100644 --- a/beacon_node/lighthouse_network/src/lib.rs +++ b/beacon_node/lighthouse_network/src/lib.rs @@ -10,7 +10,7 @@ mod config; #[allow(clippy::mutable_key_type)] // PeerId in hashmaps are no longer permitted by clippy pub mod discovery; -mod metrics; +pub mod metrics; pub mod peer_manager; pub mod rpc; mod service; @@ -66,13 +66,16 @@ pub use crate::types::{ error, Enr, EnrSyncCommitteeBitfield, GossipTopic, NetworkGlobals, PubsubMessage, Subnet, SubnetDiscovery, }; + +pub use open_metrics_client; + pub use behaviour::{BehaviourEvent, Gossipsub, PeerRequestId, Request, Response}; pub use config::Config as NetworkConfig; pub use discovery::{CombinedKeyExt, EnrExt, Eth2Enr}; pub use discv5; pub use libp2p; pub use libp2p::bandwidth::BandwidthSinks; -pub use libp2p::gossipsub::{MessageAcceptance, MessageId, Topic, TopicHash}; +pub use libp2p::gossipsub::{IdentTopic, MessageAcceptance, MessageId, Topic, TopicHash}; pub use libp2p::{core::ConnectedPoint, PeerId, Swarm}; pub use libp2p::{multiaddr, Multiaddr}; pub use metrics::scrape_discovery_metrics; @@ -82,4 +85,4 @@ pub use peer_manager::{ peerdb::PeerDB, ConnectionDirection, PeerConnectionStatus, PeerInfo, PeerManager, SyncInfo, SyncStatus, }; -pub use service::{load_private_key, Libp2pEvent, Service, NETWORK_KEY_FILENAME}; +pub use service::{load_private_key, Context, Libp2pEvent, Service, NETWORK_KEY_FILENAME}; diff --git a/beacon_node/lighthouse_network/src/metrics.rs b/beacon_node/lighthouse_network/src/metrics.rs index 4767f287f..b8fd8c584 100644 --- a/beacon_node/lighthouse_network/src/metrics.rs +++ b/beacon_node/lighthouse_network/src/metrics.rs @@ -1,16 +1,19 @@ pub use lighthouse_metrics::*; lazy_static! { + pub static ref NAT_OPEN: Result = try_create_int_counter( + "nat_open", + "An estimate indicating if the local node is exposed to the internet." + ); pub static ref ADDRESS_UPDATE_COUNT: Result = try_create_int_counter( "libp2p_address_update_total", "Count of libp2p socked updated events (when our view of our IP address has changed)" ); pub static ref PEERS_CONNECTED: Result = try_create_int_gauge( - "libp2p_peer_connected_peers_total", + "libp2p_peers", "Count of libp2p peers currently connected" ); - pub static ref PEERS_CONNECTED_INTEROP: Result = - try_create_int_gauge("libp2p_peers", "Count of libp2p peers currently connected"); + pub static ref PEER_CONNECT_EVENT_COUNT: Result = try_create_int_counter( "libp2p_peer_connect_event_total", "Count of libp2p peer connect events (not the current number of connected peers)" @@ -19,6 +22,14 @@ lazy_static! { "libp2p_peer_disconnect_event_total", "Count of libp2p peer disconnect events" ); + pub static ref DISCOVERY_SENT_BYTES: Result = try_create_int_gauge( + "discovery_sent_bytes", + "The number of bytes sent in discovery" + ); + pub static ref DISCOVERY_RECV_BYTES: Result = try_create_int_gauge( + "discovery_recv_bytes", + "The number of bytes received in discovery" + ); pub static ref DISCOVERY_QUEUE: Result = try_create_int_gauge( "discovery_queue_size", "The number of discovery queries awaiting execution" @@ -31,11 +42,7 @@ lazy_static! { "discovery_sessions", "The number of active discovery sessions with peers" ); - pub static ref DISCOVERY_REQS_IP: Result = try_create_float_gauge_vec( - "discovery_reqs_per_ip", - "Unsolicited discovery requests per ip per second", - &["Addresses"] - ); + pub static ref PEERS_PER_CLIENT: Result = try_create_int_gauge_vec( "libp2p_peers_per_client", "The connected peers via client implementation", @@ -57,6 +64,11 @@ lazy_static! { "RPC errors per client", &["client", "rpc_error", "direction"] ); + pub static ref TOTAL_RPC_REQUESTS: Result = try_create_int_counter_vec( + "libp2p_rpc_requests_total", + "RPC requests total", + &["type"] + ); pub static ref PEER_ACTION_EVENTS_PER_CLIENT: Result = try_create_int_counter_vec( "libp2p_peer_actions_per_client", @@ -69,26 +81,57 @@ lazy_static! { "Gossipsub messages that we did not accept, per client", &["client", "validation_result"] ); + + pub static ref PEER_SCORE_DISTRIBUTION: Result = + try_create_int_gauge_vec( + "peer_score_distribution", + "The distribution of connected peer scores", + &["position"] + ); + + pub static ref PEER_SCORE_PER_CLIENT: Result = + try_create_float_gauge_vec( + "peer_score_per_client", + "Average score per client", + &["client"] + ); + + /* + * Inbound/Outbound peers + */ + /// The number of peers that dialed us. + pub static ref NETWORK_INBOUND_PEERS: Result = + try_create_int_gauge("network_inbound_peers","The number of peers that are currently connected that have dialed us."); + + /// The number of peers that we dialed us. + pub static ref NETWORK_OUTBOUND_PEERS: Result = + try_create_int_gauge("network_outbound_peers","The number of peers that are currently connected that we dialed."); +} + +/// Checks if we consider the NAT open. +/// +/// Conditions for an open NAT: +/// 1. We have 1 or more SOCKET_UPDATED messages. This occurs when discovery has a majority of +/// users reporting an external port and our ENR gets updated. +/// 2. We have 0 SOCKET_UPDATED messages (can be true if the port was correct on boot), then we +/// rely on whether we have any inbound messages. If we have no socket update messages, but +/// manage to get at least one inbound peer, we are exposed correctly. +pub fn check_nat() { + // NAT is already deemed open. + if NAT_OPEN.as_ref().map(|v| v.get()).unwrap_or(0) != 0 { + return; + } + if ADDRESS_UPDATE_COUNT.as_ref().map(|v| v.get()).unwrap_or(0) == 0 + || NETWORK_INBOUND_PEERS.as_ref().map(|v| v.get()).unwrap_or(0) != 0_i64 + { + inc_counter(&NAT_OPEN); + } } pub fn scrape_discovery_metrics() { let metrics = discv5::metrics::Metrics::from(discv5::Discv5::raw_metrics()); - set_float_gauge(&DISCOVERY_REQS, metrics.unsolicited_requests_per_second); - set_gauge(&DISCOVERY_SESSIONS, metrics.active_sessions as i64); - - let process_gauge_vec = |gauge: &Result, metrics: discv5::metrics::Metrics| { - if let Ok(gauge_vec) = gauge { - gauge_vec.reset(); - for (ip, value) in metrics.requests_per_ip_per_second.iter() { - if let Ok(metric) = gauge_vec.get_metric_with_label_values(&[&format!("{:?}", ip)]) - { - metric.set(*value); - } - } - } - }; - - process_gauge_vec(&DISCOVERY_REQS_IP, metrics); + set_gauge(&DISCOVERY_SENT_BYTES, metrics.bytes_sent as i64); + set_gauge(&DISCOVERY_RECV_BYTES, metrics.bytes_recv as i64); } diff --git a/beacon_node/lighthouse_network/src/peer_manager/config.rs b/beacon_node/lighthouse_network/src/peer_manager/config.rs index aef8f9650..6c5523de4 100644 --- a/beacon_node/lighthouse_network/src/peer_manager/config.rs +++ b/beacon_node/lighthouse_network/src/peer_manager/config.rs @@ -16,6 +16,8 @@ pub struct Config { /* Peer count related configurations */ /// Whether discovery is enabled. pub discovery_enabled: bool, + /// Whether metrics are enabled. + pub metrics_enabled: bool, /// Target number of peers to connect to. pub target_peer_count: usize, @@ -34,6 +36,7 @@ impl Default for Config { fn default() -> Self { Config { discovery_enabled: true, + metrics_enabled: false, target_peer_count: DEFAULT_TARGET_PEERS, status_interval: DEFAULT_STATUS_INTERVAL, ping_interval_inbound: DEFAULT_PING_INTERVAL_INBOUND, diff --git a/beacon_node/lighthouse_network/src/peer_manager/mod.rs b/beacon_node/lighthouse_network/src/peer_manager/mod.rs index 8695d1496..202738c25 100644 --- a/beacon_node/lighthouse_network/src/peer_manager/mod.rs +++ b/beacon_node/lighthouse_network/src/peer_manager/mod.rs @@ -8,13 +8,14 @@ use crate::{Subnet, SubnetDiscovery}; use discv5::Enr; use hashset_delay::HashSetDelay; use libp2p::identify::IdentifyInfo; -use peerdb::{BanOperation, BanResult, ScoreUpdateResult}; +use peerdb::{client::ClientKind, BanOperation, BanResult, ScoreUpdateResult}; use slog::{debug, error, warn}; use smallvec::SmallVec; use std::{ sync::Arc, time::{Duration, Instant}, }; +use strum::IntoEnumIterator; use types::{EthSpec, SyncSubnetId}; pub use libp2p::core::{identity::Keypair, Multiaddr}; @@ -71,6 +72,8 @@ pub struct PeerManager { heartbeat: tokio::time::Interval, /// Keeps track of whether the discovery service is enabled or not. discovery_enabled: bool, + /// Keeps track if the current instance is reporting metrics or not. + metrics_enabled: bool, /// The logger associated with the `PeerManager`. log: slog::Logger, } @@ -111,6 +114,7 @@ impl PeerManager { ) -> error::Result { let config::Config { discovery_enabled, + metrics_enabled, target_peer_count, status_interval, ping_interval_inbound, @@ -130,6 +134,7 @@ impl PeerManager { sync_committee_subnets: Default::default(), heartbeat, discovery_enabled, + metrics_enabled, log: log.clone(), }) } @@ -378,19 +383,21 @@ impl PeerManager { "protocols" => ?info.protocols ); - // update the peer client kind metric - if let Some(v) = metrics::get_int_gauge( - &metrics::PEERS_PER_CLIENT, - &[&peer_info.client().kind.to_string()], + // update the peer client kind metric if the peer is connected + if matches!( + peer_info.connection_status(), + PeerConnectionStatus::Connected { .. } + | PeerConnectionStatus::Disconnecting { .. } ) { - v.inc() - }; - if let Some(v) = metrics::get_int_gauge( - &metrics::PEERS_PER_CLIENT, - &[&previous_kind.to_string()], - ) { - v.dec() - }; + metrics::inc_gauge_vec( + &metrics::PEERS_PER_CLIENT, + &[&peer_info.client().kind.to_string()], + ); + metrics::dec_gauge_vec( + &metrics::PEERS_PER_CLIENT, + &[&previous_kind.to_string()], + ); + } } } else { error!(self.log, "Received an Identify response from an unknown peer"; "peer_id" => peer_id.to_string()); @@ -606,6 +613,46 @@ impl PeerManager { } } + // This function updates metrics for all connected peers. + fn update_connected_peer_metrics(&self) { + // Do nothing if we don't have metrics enabled. + if !self.metrics_enabled { + return; + } + + let mut connected_peer_count = 0; + let mut inbound_connected_peers = 0; + let mut outbound_connected_peers = 0; + let mut clients_per_peer = HashMap::new(); + + for (_peer, peer_info) in self.network_globals.peers.read().connected_peers() { + connected_peer_count += 1; + if let PeerConnectionStatus::Connected { n_in, .. } = peer_info.connection_status() { + if *n_in > 0 { + inbound_connected_peers += 1; + } else { + outbound_connected_peers += 1; + } + } + *clients_per_peer + .entry(peer_info.client().kind.to_string()) + .or_default() += 1; + } + + metrics::set_gauge(&metrics::PEERS_CONNECTED, connected_peer_count); + metrics::set_gauge(&metrics::NETWORK_INBOUND_PEERS, inbound_connected_peers); + metrics::set_gauge(&metrics::NETWORK_OUTBOUND_PEERS, outbound_connected_peers); + + for client_kind in ClientKind::iter() { + let value = clients_per_peer.get(&client_kind.to_string()).unwrap_or(&0); + metrics::set_gauge_vec( + &metrics::PEERS_PER_CLIENT, + &[&client_kind.to_string()], + *value as i64, + ); + } + } + /* Internal functions */ /// Sets a peer as connected as long as their reputation allows it @@ -705,22 +752,6 @@ impl PeerManager { // increment prometheus metrics metrics::inc_counter(&metrics::PEER_CONNECT_EVENT_COUNT); metrics::set_gauge(&metrics::PEERS_CONNECTED, connected_peers); - metrics::set_gauge(&metrics::PEERS_CONNECTED_INTEROP, connected_peers); - - // Increment the PEERS_PER_CLIENT metric - if let Some(kind) = self - .network_globals - .peers - .read() - .peer_info(peer_id) - .map(|peer_info| peer_info.client().kind.clone()) - { - if let Some(v) = - metrics::get_int_gauge(&metrics::PEERS_PER_CLIENT, &[&kind.to_string()]) - { - v.inc() - }; - } true } @@ -802,6 +833,9 @@ impl PeerManager { self.handle_score_action(&peer_id, action, None); } + // Update peer score metrics; + self.update_peer_score_metrics(); + // Maintain minimum count for sync committee peers. self.maintain_sync_committee_peers(); @@ -840,6 +874,75 @@ impl PeerManager { self.disconnect_peer(peer_id, GoodbyeReason::TooManyPeers); } } + + // Update metrics related to peer scoring. + fn update_peer_score_metrics(&self) { + if !self.metrics_enabled { + return; + } + // reset the gauges + let _ = metrics::PEER_SCORE_DISTRIBUTION + .as_ref() + .map(|gauge| gauge.reset()); + let _ = metrics::PEER_SCORE_PER_CLIENT + .as_ref() + .map(|gauge| gauge.reset()); + + let mut avg_score_per_client: HashMap = HashMap::with_capacity(5); + { + let peers_db_read_lock = self.network_globals.peers.read(); + let connected_peers = peers_db_read_lock.best_peers_by_status(PeerInfo::is_connected); + let total_peers = connected_peers.len(); + for (id, (_peer, peer_info)) in connected_peers.into_iter().enumerate() { + // First quartile + if id == 0 { + metrics::set_gauge_vec( + &metrics::PEER_SCORE_DISTRIBUTION, + &["1st"], + peer_info.score().score() as i64, + ); + } else if id == (total_peers * 3 / 4).saturating_sub(1) { + metrics::set_gauge_vec( + &metrics::PEER_SCORE_DISTRIBUTION, + &["3/4"], + peer_info.score().score() as i64, + ); + } else if id == (total_peers / 2).saturating_sub(1) { + metrics::set_gauge_vec( + &metrics::PEER_SCORE_DISTRIBUTION, + &["1/2"], + peer_info.score().score() as i64, + ); + } else if id == (total_peers / 4).saturating_sub(1) { + metrics::set_gauge_vec( + &metrics::PEER_SCORE_DISTRIBUTION, + &["1/4"], + peer_info.score().score() as i64, + ); + } else if id == total_peers.saturating_sub(1) { + metrics::set_gauge_vec( + &metrics::PEER_SCORE_DISTRIBUTION, + &["last"], + peer_info.score().score() as i64, + ); + } + + let mut score_peers: &mut (f64, usize) = avg_score_per_client + .entry(peer_info.client().kind.to_string()) + .or_default(); + score_peers.0 += peer_info.score().score(); + score_peers.1 += 1; + } + } // read lock ended + + for (client, (score, peers)) in avg_score_per_client { + metrics::set_float_gauge_vec( + &metrics::PEER_SCORE_PER_CLIENT, + &[&client.to_string()], + score / (peers as f64), + ); + } + } } enum ConnectingType { 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 a11f3739e..d194deffd 100644 --- a/beacon_node/lighthouse_network/src/peer_manager/network_behaviour.rs +++ b/beacon_node/lighthouse_network/src/peer_manager/network_behaviour.rs @@ -111,8 +111,11 @@ impl NetworkBehaviour for PeerManager { endpoint: &ConnectedPoint, _failed_addresses: Option<&Vec>, ) { - // Log the connection debug!(self.log, "Connection established"; "peer_id" => %peer_id, "connection" => ?endpoint.to_endpoint()); + // Check NAT if metrics are enabled + if self.network_globals.local_enr.read().udp().is_some() { + metrics::check_nat(); + } // Check to make sure the peer is not supposed to be banned match self.ban_status(peer_id) { @@ -150,10 +153,8 @@ impl NetworkBehaviour for PeerManager { return; } - // Register the newly connected peer (regardless if we are about to disconnect them). // NOTE: We don't register peers that we are disconnecting immediately. The network service // does not need to know about these peers. - // let enr match endpoint { ConnectedPoint::Listener { send_back_addr, .. } => { self.inject_connect_ingoing(peer_id, send_back_addr.clone(), None); @@ -167,12 +168,9 @@ impl NetworkBehaviour for PeerManager { } } - let connected_peers = self.network_globals.connected_peers() as i64; - // increment prometheus metrics + self.update_connected_peer_metrics(); metrics::inc_counter(&metrics::PEER_CONNECT_EVENT_COUNT); - metrics::set_gauge(&metrics::PEERS_CONNECTED, connected_peers); - metrics::set_gauge(&metrics::PEERS_CONNECTED_INTEROP, connected_peers); } fn inject_disconnected(&mut self, peer_id: &PeerId) { @@ -190,21 +188,6 @@ impl NetworkBehaviour for PeerManager { self.events .push(PeerManagerEvent::PeerDisconnected(*peer_id)); debug!(self.log, "Peer disconnected"; "peer_id" => %peer_id); - - // Decrement the PEERS_PER_CLIENT metric - if let Some(kind) = self - .network_globals - .peers - .read() - .peer_info(peer_id) - .map(|info| info.client().kind.clone()) - { - if let Some(v) = - metrics::get_int_gauge(&metrics::PEERS_PER_CLIENT, &[&kind.to_string()]) - { - v.dec() - }; - } } // NOTE: It may be the case that a rejected node, due to too many peers is disconnected @@ -212,12 +195,9 @@ impl NetworkBehaviour for PeerManager { // reference so that peer manager can track this peer. self.inject_disconnect(peer_id); - let connected_peers = self.network_globals.connected_peers() as i64; - // Update the prometheus metrics + self.update_connected_peer_metrics(); metrics::inc_counter(&metrics::PEER_DISCONNECT_EVENT_COUNT); - metrics::set_gauge(&metrics::PEERS_CONNECTED, connected_peers); - metrics::set_gauge(&metrics::PEERS_CONNECTED_INTEROP, connected_peers); } fn inject_address_change( diff --git a/beacon_node/lighthouse_network/src/peer_manager/peerdb/client.rs b/beacon_node/lighthouse_network/src/peer_manager/peerdb/client.rs index 8f1738ac6..7cc84516a 100644 --- a/beacon_node/lighthouse_network/src/peer_manager/peerdb/client.rs +++ b/beacon_node/lighthouse_network/src/peer_manager/peerdb/client.rs @@ -4,7 +4,7 @@ use libp2p::identify::IdentifyInfo; use serde::Serialize; -use strum::{AsRefStr, AsStaticStr}; +use strum::{AsRefStr, AsStaticStr, EnumIter}; /// Various client and protocol information related to a node. #[derive(Clone, Debug, Serialize)] @@ -21,7 +21,7 @@ pub struct Client { pub agent_string: Option, } -#[derive(Clone, Debug, Serialize, PartialEq, AsRefStr, AsStaticStr)] +#[derive(Clone, Debug, Serialize, PartialEq, AsRefStr, AsStaticStr, EnumIter)] pub enum ClientKind { /// A lighthouse node (the best kind). Lighthouse, diff --git a/beacon_node/lighthouse_network/src/peer_manager/peerdb/peer_info.rs b/beacon_node/lighthouse_network/src/peer_manager/peerdb/peer_info.rs index 3ff5dc04a..941ca7e6c 100644 --- a/beacon_node/lighthouse_network/src/peer_manager/peerdb/peer_info.rs +++ b/beacon_node/lighthouse_network/src/peer_manager/peerdb/peer_info.rs @@ -19,8 +19,6 @@ use PeerConnectionStatus::*; #[derive(Clone, Debug, Serialize)] #[serde(bound = "T: EthSpec")] pub struct PeerInfo { - /// The connection status of the peer - _status: PeerStatus, /// The peers reputation score: Score, /// Client managing this peer @@ -57,7 +55,6 @@ pub struct PeerInfo { impl Default for PeerInfo { fn default() -> PeerInfo { PeerInfo { - _status: Default::default(), score: Score::default(), client: Client::default(), connection_status: Default::default(), @@ -387,21 +384,6 @@ impl PeerInfo { } } -#[derive(Clone, Debug, Serialize)] -/// The current health status of the peer. -pub enum PeerStatus { - /// The peer is healthy. - Healthy, - /// The peer is clogged. It has not been responding to requests on time. - _Clogged, -} - -impl Default for PeerStatus { - fn default() -> Self { - PeerStatus::Healthy - } -} - /// Connection Direction of connection. #[derive(Debug, Clone, Serialize, AsRefStr)] #[strum(serialize_all = "snake_case")] diff --git a/beacon_node/lighthouse_network/src/service.rs b/beacon_node/lighthouse_network/src/service.rs index 60252385d..23c198290 100644 --- a/beacon_node/lighthouse_network/src/service.rs +++ b/beacon_node/lighthouse_network/src/service.rs @@ -20,6 +20,7 @@ use libp2p::{ swarm::{SwarmBuilder, SwarmEvent}, PeerId, Swarm, Transport, }; +use open_metrics_client::registry::Registry; use slog::{crit, debug, info, o, trace, warn, Logger}; use ssz::Decode; use std::fs::File; @@ -62,27 +63,34 @@ pub struct Service { pub log: Logger, } +pub struct Context<'a> { + pub config: &'a NetworkConfig, + pub enr_fork_id: EnrForkId, + pub fork_context: Arc, + pub chain_spec: &'a ChainSpec, + pub gossipsub_registry: Option<&'a mut Registry>, +} + impl Service { pub async fn new( executor: task_executor::TaskExecutor, - config: &NetworkConfig, - enr_fork_id: EnrForkId, + ctx: Context<'_>, log: &Logger, - fork_context: Arc, - chain_spec: &ChainSpec, ) -> error::Result<(Arc>, Self)> { let log = log.new(o!("service"=> "libp2p")); trace!(log, "Libp2p Service starting"); + let config = ctx.config; // initialise the node's ID let local_keypair = load_private_key(config, &log); // Create an ENR or load from disk if appropriate let enr = - enr::build_or_load_enr::(local_keypair.clone(), config, enr_fork_id, &log)?; + enr::build_or_load_enr::(local_keypair.clone(), config, &ctx.enr_fork_id, &log)?; let local_peer_id = enr.peer_id(); + // Construct the metadata let meta_data = load_or_build_metadata(&config.network_dir, &log); // set up a collection of variables accessible outside of the network crate @@ -113,15 +121,8 @@ impl Service { .map_err(|e| format!("Failed to build transport: {:?}", e))?; // Lighthouse network behaviour - let behaviour = Behaviour::new( - &local_keypair, - config.clone(), - network_globals.clone(), - &log, - fork_context, - chain_spec, - ) - .await?; + let behaviour = + Behaviour::new(&local_keypair, ctx, network_globals.clone(), &log).await?; // use the executor for libp2p struct Executor(task_executor::TaskExecutor); diff --git a/beacon_node/lighthouse_network/tests/common/mod.rs b/beacon_node/lighthouse_network/tests/common/mod.rs index 520921e87..7397fe7ea 100644 --- a/beacon_node/lighthouse_network/tests/common/mod.rs +++ b/beacon_node/lighthouse_network/tests/common/mod.rs @@ -128,19 +128,18 @@ pub async fn build_libp2p_instance( let (signal, exit) = exit_future::signal(); let (shutdown_tx, _) = futures::channel::mpsc::channel(1); let executor = task_executor::TaskExecutor::new(rt, exit, log.clone(), shutdown_tx); - let fork_context = Arc::new(fork_context()); + let libp2p_context = lighthouse_network::Context { + config: &config, + enr_fork_id: EnrForkId::default(), + fork_context: Arc::new(fork_context()), + chain_spec: &ChainSpec::minimal(), + gossipsub_registry: None, + }; Libp2pInstance( - LibP2PService::new( - executor, - &config, - EnrForkId::default(), - &log, - fork_context, - &ChainSpec::minimal(), - ) - .await - .expect("should build libp2p instance") - .1, + LibP2PService::new(executor, libp2p_context, &log) + .await + .expect("should build libp2p instance") + .1, signal, ) } diff --git a/beacon_node/network/src/metrics.rs b/beacon_node/network/src/metrics.rs index 35c5b4dce..a10d23876 100644 --- a/beacon_node/network/src/metrics.rs +++ b/beacon_node/network/src/metrics.rs @@ -4,216 +4,42 @@ use beacon_chain::{ }; use fnv::FnvHashMap; pub use lighthouse_metrics::*; -use lighthouse_network::PubsubMessage; use lighthouse_network::{ - types::GossipKind, BandwidthSinks, GossipTopic, Gossipsub, NetworkGlobals, TopicHash, + types::GossipKind, BandwidthSinks, GossipTopic, Gossipsub, NetworkGlobals, }; -use std::{collections::HashMap, sync::Arc}; +use std::sync::Arc; use strum::AsStaticRef; -use types::{ - consts::altair::SYNC_COMMITTEE_SUBNET_COUNT, subnet_id::subnet_id_to_string, - sync_subnet_id::sync_subnet_id_to_string, EthSpec, -}; +use types::EthSpec; lazy_static! { - /* - * Gossip subnets and scoring - */ - pub static ref PEERS_PER_PROTOCOL: Result = try_create_int_gauge_vec( - "gossipsub_peers_per_protocol", - "Peers via supported protocol", - &["protocol"] - ); - - pub static ref GOSSIPSUB_SUBSCRIBED_ATTESTATION_SUBNET_TOPIC: Result = try_create_int_gauge_vec( - "gossipsub_subscribed_attestation_subnets", - "Attestation subnets currently subscribed to", - &["subnet"] - ); - - pub static ref GOSSIPSUB_SUBSCRIBED_SYNC_SUBNET_TOPIC: Result = try_create_int_gauge_vec( - "gossipsub_subscribed_sync_subnets", - "Sync subnets currently subscribed to", - &["subnet"] - ); - - pub static ref GOSSIPSUB_SUBSCRIBED_PEERS_ATTESTATION_SUBNET_TOPIC: Result = try_create_int_gauge_vec( - "gossipsub_peers_per_attestation_subnet_topic_count", - "Peers subscribed per attestation subnet topic", - &["subnet"] - ); - - pub static ref GOSSIPSUB_SUBSCRIBED_PEERS_SYNC_SUBNET_TOPIC: Result = try_create_int_gauge_vec( - "gossipsub_peers_per_sync_subnet_topic_count", - "Peers subscribed per sync subnet topic", - &["subnet"] - ); - - pub static ref MESH_PEERS_PER_MAIN_TOPIC: Result = try_create_int_gauge_vec( - "gossipsub_mesh_peers_per_main_topic", - "Mesh peers per main topic", - &["topic_hash"] - ); - - pub static ref MESH_PEERS_PER_ATTESTATION_SUBNET_TOPIC: Result = try_create_int_gauge_vec( - "gossipsub_mesh_peers_per_subnet_topic", - "Mesh peers per subnet topic", - &["subnet"] - ); - - pub static ref MESH_PEERS_PER_SYNC_SUBNET_TOPIC: Result = try_create_int_gauge_vec( - "gossipsub_mesh_peers_per_subnet_topic", - "Mesh peers per subnet topic", - &["subnet"] - ); - - pub static ref AVG_GOSSIPSUB_PEER_SCORE_PER_MAIN_TOPIC: Result = try_create_float_gauge_vec( - "gossipsub_avg_peer_score_per_topic", - "Average peer's score per topic", - &["topic_hash"] - ); - - pub static ref AVG_GOSSIPSUB_PEER_SCORE_PER_ATTESTATION_SUBNET_TOPIC: Result = try_create_float_gauge_vec( - "gossipsub_avg_peer_score_per_attestation_subnet_topic", - "Average peer's score per attestation subnet topic", - &["subnet"] - ); - - pub static ref AVG_GOSSIPSUB_PEER_SCORE_PER_SYNC_SUBNET_TOPIC: Result = try_create_float_gauge_vec( - "gossipsub_avg_peer_score_per_sync_subnet_topic", - "Average peer's score per sync committee subnet topic", - &["subnet"] - ); - - pub static ref ATTESTATIONS_PUBLISHED_PER_SUBNET_PER_SLOT: Result = try_create_int_counter_vec( - "gossipsub_attestations_published_per_subnet_per_slot", - "Failed attestation publishes per subnet", - &["subnet"] - ); - - pub static ref SCORES_BELOW_ZERO_PER_CLIENT: Result = try_create_float_gauge_vec( - "gossipsub_scores_below_zero_per_client", - "Relative number of scores below zero per client", - &["Client"] - ); - pub static ref SCORES_BELOW_GOSSIP_THRESHOLD_PER_CLIENT: Result = try_create_float_gauge_vec( - "gossipsub_scores_below_gossip_threshold_per_client", - "Relative number of scores below gossip threshold per client", - &["Client"] - ); - pub static ref SCORES_BELOW_PUBLISH_THRESHOLD_PER_CLIENT: Result = try_create_float_gauge_vec( - "gossipsub_scores_below_publish_threshold_per_client", - "Relative number of scores below publish threshold per client", - &["Client"] - ); - pub static ref SCORES_BELOW_GREYLIST_THRESHOLD_PER_CLIENT: Result = try_create_float_gauge_vec( - "gossipsub_scores_below_greylist_threshold_per_client", - "Relative number of scores below greylist threshold per client", - &["Client"] - ); - - pub static ref MIN_SCORES_PER_CLIENT: Result = try_create_float_gauge_vec( - "gossipsub_min_scores_per_client", - "Minimum scores per client", - &["Client"] - ); - pub static ref MEDIAN_SCORES_PER_CLIENT: Result = try_create_float_gauge_vec( - "gossipsub_median_scores_per_client", - "Median scores per client", - &["Client"] - ); - pub static ref MEAN_SCORES_PER_CLIENT: Result = try_create_float_gauge_vec( - "gossipsub_mean_scores_per_client", - "Mean scores per client", - &["Client"] - ); - pub static ref MAX_SCORES_PER_CLIENT: Result = try_create_float_gauge_vec( - "gossipsub_max_scores_per_client", - "Max scores per client", - &["Client"] - ); pub static ref BEACON_BLOCK_MESH_PEERS_PER_CLIENT: Result = - try_create_int_gauge_vec( - "block_mesh_peers_per_client", - "Number of mesh peers for BeaconBlock topic per client", - &["Client"] - ); + try_create_int_gauge_vec( + "block_mesh_peers_per_client", + "Number of mesh peers for BeaconBlock topic per client", + &["Client"] + ); + pub static ref BEACON_AGGREGATE_AND_PROOF_MESH_PEERS_PER_CLIENT: Result = try_create_int_gauge_vec( "beacon_aggregate_and_proof_mesh_peers_per_client", "Number of mesh peers for BeaconAggregateAndProof topic per client", &["Client"] ); -} - -lazy_static! { - /* - * Gossip Rx - */ - pub static ref GOSSIP_BLOCKS_RX: Result = try_create_int_counter( - "gossipsub_blocks_rx_total", - "Count of gossip blocks received" - ); - pub static ref GOSSIP_UNAGGREGATED_ATTESTATIONS_RX: Result = try_create_int_counter( - "gossipsub_unaggregated_attestations_rx_total", - "Count of gossip unaggregated attestations received" - ); - pub static ref GOSSIP_AGGREGATED_ATTESTATIONS_RX: Result = try_create_int_counter( - "gossipsub_aggregated_attestations_rx_total", - "Count of gossip aggregated attestations received" - ); - pub static ref GOSSIP_SYNC_COMMITTEE_MESSAGE_RX: Result = try_create_int_counter( - "gossipsub_sync_committee_message_rx_total", - "Count of gossip sync committee messages received" - ); - pub static ref GOSSIP_SYNC_COMMITTEE_CONTRIBUTION_RX: Result = try_create_int_counter( - "gossipsub_sync_committee_contribution_received_total", - "Count of gossip sync committee contributions received" - ); - - - /* - * Gossip Tx - */ - pub static ref GOSSIP_BLOCKS_TX: Result = try_create_int_counter( - "gossipsub_blocks_tx_total", - "Count of gossip blocks transmitted" - ); - pub static ref GOSSIP_UNAGGREGATED_ATTESTATIONS_TX: Result = try_create_int_counter( - "gossipsub_unaggregated_attestations_tx_total", - "Count of gossip unaggregated attestations transmitted" - ); - pub static ref GOSSIP_AGGREGATED_ATTESTATIONS_TX: Result = try_create_int_counter( - "gossipsub_aggregated_attestations_tx_total", - "Count of gossip aggregated attestations transmitted" - ); - pub static ref GOSSIP_SYNC_COMMITTEE_MESSAGE_TX: Result = try_create_int_counter( - "gossipsub_sync_committee_message_tx_total", - "Count of gossip sync committee messages transmitted" - ); - pub static ref GOSSIP_SYNC_COMMITTEE_CONTRIBUTION_TX: Result = try_create_int_counter( - "gossipsub_sync_committee_contribution_tx_total", - "Count of gossip sync committee contributions transmitted" - ); /* * Attestation subnet subscriptions */ pub static ref SUBNET_SUBSCRIPTION_REQUESTS: Result = try_create_int_counter( - "gossipsub_attestation_subnet_subscriptions_total", + "validator_attestation_subnet_subscriptions_total", "Count of validator attestation subscription requests." ); pub static ref SUBNET_SUBSCRIPTION_AGGREGATOR_REQUESTS: Result = try_create_int_counter( - "gossipsub_subnet_subscriptions_aggregator_total", + "validator_subnet_subscriptions_aggregator_total", "Count of validator subscription requests where the subscriber is an aggregator." ); - - /* - * Sync committee subnet subscriptions - */ - pub static ref SYNC_COMMITTEE_SUBSCRIPTION_REQUESTS: Result = try_create_int_counter( - "gossipsub_sync_committee_subnet_subscriptions_total", + pub static ref SYNC_COMMITTEE_SUBSCRIPTION_REQUESTS: Result = try_create_int_counter( + "validator_sync_committee_subnet_subscriptions_total", "Count of validator sync committee subscription requests." ); @@ -406,14 +232,13 @@ lazy_static! { "beacon_processor_sync_contribution_verified_total", "Total number of sync committee contributions verified for gossip." ); + pub static ref BEACON_PROCESSOR_SYNC_CONTRIBUTION_IMPORTED_TOTAL: Result = try_create_int_counter( "beacon_processor_sync_contribution_imported_total", "Total number of sync committee contributions imported to fork choice, etc." ); -} - -lazy_static! { + /// Errors and Debugging Stats pub static ref GOSSIP_ATTESTATION_ERRORS_PER_TYPE: Result = try_create_int_counter_vec( "gossipsub_attestation_errors_per_type", @@ -426,8 +251,16 @@ lazy_static! { "Gossipsub sync_committee errors per error type", &["type"] ); +} + +lazy_static! { + + /* + * Bandwidth metrics + */ pub static ref INBOUND_LIBP2P_BYTES: Result = try_create_int_gauge("libp2p_inbound_bytes", "The inbound bandwidth over libp2p"); + pub static ref OUTBOUND_LIBP2P_BYTES: Result = try_create_int_gauge( "libp2p_outbound_bytes", "The outbound bandwidth over libp2p" @@ -436,18 +269,8 @@ lazy_static! { "libp2p_total_bandwidth", "The total inbound/outbound bandwidth over libp2p" ); -} -pub fn update_bandwidth_metrics(bandwidth: Arc) { - set_gauge(&INBOUND_LIBP2P_BYTES, bandwidth.total_inbound() as i64); - set_gauge(&OUTBOUND_LIBP2P_BYTES, bandwidth.total_outbound() as i64); - set_gauge( - &TOTAL_LIBP2P_BANDWIDTH, - (bandwidth.total_inbound() + bandwidth.total_outbound()) as i64, - ); -} -lazy_static! { /* * Sync related metrics */ @@ -489,11 +312,21 @@ lazy_static! { ); pub static ref BEACON_PROCESSOR_REPROCESSING_QUEUE_EXPIRED_ATTESTATIONS: Result = try_create_int_counter( "beacon_processor_reprocessing_queue_expired_attestations", - "Number of queued attestations which have expired before a matching block has been found" + "Number of queued attestations which have expired before a matching block has been found." ); pub static ref BEACON_PROCESSOR_REPROCESSING_QUEUE_MATCHED_ATTESTATIONS: Result = try_create_int_counter( "beacon_processor_reprocessing_queue_matched_attestations", - "Number of queued attestations where as matching block has been imported" + "Number of queued attestations where as matching block has been imported." + ); + +} + +pub fn update_bandwidth_metrics(bandwidth: Arc) { + set_gauge(&INBOUND_LIBP2P_BYTES, bandwidth.total_inbound() as i64); + set_gauge(&OUTBOUND_LIBP2P_BYTES, bandwidth.total_outbound() as i64); + set_gauge( + &TOTAL_LIBP2P_BANDWIDTH, + (bandwidth.total_inbound() + bandwidth.total_outbound()) as i64, ); } @@ -505,402 +338,51 @@ pub fn register_sync_committee_error(error: &SyncCommitteeError) { inc_counter_vec(&GOSSIP_SYNC_COMMITTEE_ERRORS_PER_TYPE, &[error.as_ref()]); } -/// Inspects the `messages` that were being sent to the network and updates Prometheus metrics. -pub fn expose_publish_metrics(messages: &[PubsubMessage]) { - for message in messages { - match message { - PubsubMessage::BeaconBlock(_) => inc_counter(&GOSSIP_BLOCKS_TX), - PubsubMessage::Attestation(subnet_id) => { - inc_counter_vec( - &ATTESTATIONS_PUBLISHED_PER_SUBNET_PER_SLOT, - &[subnet_id.0.as_ref()], - ); - inc_counter(&GOSSIP_UNAGGREGATED_ATTESTATIONS_TX) - } - PubsubMessage::AggregateAndProofAttestation(_) => { - inc_counter(&GOSSIP_AGGREGATED_ATTESTATIONS_TX) - } - PubsubMessage::SyncCommitteeMessage(_) => { - inc_counter(&GOSSIP_SYNC_COMMITTEE_MESSAGE_TX) - } - PubsubMessage::SignedContributionAndProof(_) => { - inc_counter(&GOSSIP_SYNC_COMMITTEE_CONTRIBUTION_TX) - } - _ => {} - } - } -} - -/// Inspects a `message` received from the network and updates Prometheus metrics. -pub fn expose_receive_metrics(message: &PubsubMessage) { - match message { - PubsubMessage::BeaconBlock(_) => inc_counter(&GOSSIP_BLOCKS_RX), - PubsubMessage::Attestation(_) => inc_counter(&GOSSIP_UNAGGREGATED_ATTESTATIONS_RX), - PubsubMessage::AggregateAndProofAttestation(_) => { - inc_counter(&GOSSIP_AGGREGATED_ATTESTATIONS_RX) - } - PubsubMessage::SyncCommitteeMessage(_) => inc_counter(&GOSSIP_SYNC_COMMITTEE_MESSAGE_RX), - PubsubMessage::SignedContributionAndProof(_) => { - inc_counter(&GOSSIP_SYNC_COMMITTEE_CONTRIBUTION_RX) - } - _ => {} - } -} - pub fn update_gossip_metrics( gossipsub: &Gossipsub, network_globals: &Arc>, ) { - // Clear the metrics - let _ = PEERS_PER_PROTOCOL.as_ref().map(|gauge| gauge.reset()); - let _ = PEERS_PER_PROTOCOL.as_ref().map(|gauge| gauge.reset()); - let _ = MESH_PEERS_PER_MAIN_TOPIC - .as_ref() - .map(|gauge| gauge.reset()); - let _ = AVG_GOSSIPSUB_PEER_SCORE_PER_MAIN_TOPIC - .as_ref() - .map(|gauge| gauge.reset()); - let _ = AVG_GOSSIPSUB_PEER_SCORE_PER_ATTESTATION_SUBNET_TOPIC - .as_ref() - .map(|gauge| gauge.reset()); - let _ = AVG_GOSSIPSUB_PEER_SCORE_PER_SYNC_SUBNET_TOPIC - .as_ref() - .map(|gauge| gauge.reset()); - - let _ = SCORES_BELOW_ZERO_PER_CLIENT - .as_ref() - .map(|gauge| gauge.reset()); - let _ = SCORES_BELOW_GOSSIP_THRESHOLD_PER_CLIENT - .as_ref() - .map(|gauge| gauge.reset()); - let _ = SCORES_BELOW_PUBLISH_THRESHOLD_PER_CLIENT - .as_ref() - .map(|gauge| gauge.reset()); - let _ = SCORES_BELOW_GREYLIST_THRESHOLD_PER_CLIENT - .as_ref() - .map(|gauge| gauge.reset()); - let _ = MIN_SCORES_PER_CLIENT.as_ref().map(|gauge| gauge.reset()); - let _ = MEDIAN_SCORES_PER_CLIENT.as_ref().map(|gauge| gauge.reset()); - let _ = MEAN_SCORES_PER_CLIENT.as_ref().map(|gauge| gauge.reset()); - let _ = MAX_SCORES_PER_CLIENT.as_ref().map(|gauge| gauge.reset()); - - let _ = BEACON_BLOCK_MESH_PEERS_PER_CLIENT - .as_ref() - .map(|gauge| gauge.reset()); - let _ = BEACON_AGGREGATE_AND_PROOF_MESH_PEERS_PER_CLIENT - .as_ref() - .map(|gauge| gauge.reset()); - - // reset the mesh peers, showing all subnets - for subnet_id in 0..T::default_spec().attestation_subnet_count { - let _ = get_int_gauge( - &MESH_PEERS_PER_ATTESTATION_SUBNET_TOPIC, - &[subnet_id_to_string(subnet_id)], - ) - .map(|v| v.set(0)); - - let _ = get_int_gauge( - &GOSSIPSUB_SUBSCRIBED_ATTESTATION_SUBNET_TOPIC, - &[subnet_id_to_string(subnet_id)], - ) - .map(|v| v.set(0)); - - let _ = get_int_gauge( - &GOSSIPSUB_SUBSCRIBED_PEERS_ATTESTATION_SUBNET_TOPIC, - &[subnet_id_to_string(subnet_id)], - ) - .map(|v| v.set(0)); - } - - for subnet_id in 0..SYNC_COMMITTEE_SUBNET_COUNT { - let _ = get_int_gauge( - &MESH_PEERS_PER_SYNC_SUBNET_TOPIC, - &[sync_subnet_id_to_string(subnet_id)], - ) - .map(|v| v.set(0)); - - let _ = get_int_gauge( - &GOSSIPSUB_SUBSCRIBED_SYNC_SUBNET_TOPIC, - &[sync_subnet_id_to_string(subnet_id)], - ) - .map(|v| v.set(0)); - - let _ = get_int_gauge( - &GOSSIPSUB_SUBSCRIBED_PEERS_SYNC_SUBNET_TOPIC, - &[sync_subnet_id_to_string(subnet_id)], - ) - .map(|v| v.set(0)); - } - - // Subnet topics subscribed to - for topic_hash in gossipsub.topics() { - if let Ok(topic) = GossipTopic::decode(topic_hash.as_str()) { - if let GossipKind::Attestation(subnet_id) = topic.kind() { - let _ = get_int_gauge( - &GOSSIPSUB_SUBSCRIBED_ATTESTATION_SUBNET_TOPIC, - &[subnet_id_to_string(subnet_id.into())], - ) - .map(|v| v.set(1)); - } - } - } - - // Peers per subscribed subnet - let mut peers_per_topic: HashMap = HashMap::new(); - for (peer_id, topics) in gossipsub.all_peers() { - for topic_hash in topics { - *peers_per_topic.entry(topic_hash.clone()).or_default() += 1; - - if let Ok(topic) = GossipTopic::decode(topic_hash.as_str()) { - match topic.kind() { - GossipKind::Attestation(subnet_id) => { - if let Some(v) = get_int_gauge( - &GOSSIPSUB_SUBSCRIBED_PEERS_ATTESTATION_SUBNET_TOPIC, - &[subnet_id_to_string(subnet_id.into())], - ) { - v.inc() - }; - - // average peer scores - if let Some(score) = gossipsub.peer_score(peer_id) { - if let Some(v) = get_gauge( - &AVG_GOSSIPSUB_PEER_SCORE_PER_ATTESTATION_SUBNET_TOPIC, - &[subnet_id_to_string(subnet_id.into())], - ) { - v.add(score) - }; - } - } - GossipKind::SyncCommitteeMessage(subnet_id) => { - if let Some(v) = get_int_gauge( - &GOSSIPSUB_SUBSCRIBED_PEERS_SYNC_SUBNET_TOPIC, - &[sync_subnet_id_to_string(subnet_id.into())], - ) { - v.inc() - }; - - // average peer scores - if let Some(score) = gossipsub.peer_score(peer_id) { - if let Some(v) = get_gauge( - &AVG_GOSSIPSUB_PEER_SCORE_PER_SYNC_SUBNET_TOPIC, - &[sync_subnet_id_to_string(subnet_id.into())], - ) { - v.add(score) - }; - } - } - kind => { - // main topics - if let Some(score) = gossipsub.peer_score(peer_id) { - if let Some(v) = get_gauge( - &AVG_GOSSIPSUB_PEER_SCORE_PER_MAIN_TOPIC, - &[kind.as_ref()], - ) { - v.add(score) - }; - } - } - } - } - } - } - // adjust to average scores by dividing by number of peers - for (topic_hash, peers) in peers_per_topic.iter() { - if let Ok(topic) = GossipTopic::decode(topic_hash.as_str()) { - match topic.kind() { - GossipKind::Attestation(subnet_id) => { - // average peer scores - if let Some(v) = get_gauge( - &AVG_GOSSIPSUB_PEER_SCORE_PER_ATTESTATION_SUBNET_TOPIC, - &[subnet_id_to_string(subnet_id.into())], - ) { - v.set(v.get() / (*peers as f64)) - }; - } - GossipKind::SyncCommitteeMessage(subnet_id) => { - // average peer scores - if let Some(v) = get_gauge( - &AVG_GOSSIPSUB_PEER_SCORE_PER_SYNC_SUBNET_TOPIC, - &[sync_subnet_id_to_string(subnet_id.into())], - ) { - v.set(v.get() / (*peers as f64)) - }; - } - kind => { - // main topics - if let Some(v) = - get_gauge(&AVG_GOSSIPSUB_PEER_SCORE_PER_MAIN_TOPIC, &[kind.as_ref()]) - { - v.set(v.get() / (*peers as f64)) - }; - } - } - } - } - - // mesh peers - for topic_hash in gossipsub.topics() { - let peers = gossipsub.mesh_peers(topic_hash).count(); - if let Ok(topic) = GossipTopic::decode(topic_hash.as_str()) { - match topic.kind() { - GossipKind::Attestation(subnet_id) => { - if let Some(v) = get_int_gauge( - &MESH_PEERS_PER_ATTESTATION_SUBNET_TOPIC, - &[subnet_id_to_string(subnet_id.into())], - ) { - v.set(peers as i64) - }; - } - GossipKind::SyncCommitteeMessage(subnet_id) => { - if let Some(v) = get_int_gauge( - &MESH_PEERS_PER_SYNC_SUBNET_TOPIC, - &[sync_subnet_id_to_string(subnet_id.into())], - ) { - v.set(peers as i64) - }; - } - kind => { - // main topics - if let Some(v) = get_int_gauge(&MESH_PEERS_PER_MAIN_TOPIC, &[kind.as_ref()]) { - v.set(peers as i64) - }; - } - } - } - } - - // protocol peers - let mut peers_per_protocol: HashMap<&'static str, i64> = HashMap::new(); - for (_peer, protocol) in gossipsub.peer_protocol() { - *peers_per_protocol - .entry(protocol.as_static_ref()) - .or_default() += 1; - } - - for (protocol, peers) in peers_per_protocol.iter() { - if let Some(v) = get_int_gauge(&PEERS_PER_PROTOCOL, &[protocol]) { - v.set(*peers) - }; - } - - let mut peer_to_client = HashMap::new(); - let mut scores_per_client: HashMap<&'static str, Vec> = HashMap::new(); - { - let peers = network_globals.peers.read(); - for (peer_id, _) in gossipsub.all_peers() { - let client = peers - .peer_info(peer_id) - .map(|peer_info| peer_info.client().kind.as_static()) - .unwrap_or_else(|| "Unknown"); - - peer_to_client.insert(peer_id, client); - let score = gossipsub.peer_score(peer_id).unwrap_or(0.0); - scores_per_client.entry(client).or_default().push(score); - } - } - - // mesh peers per client + // Mesh peers per client for topic_hash in gossipsub.topics() { if let Ok(topic) = GossipTopic::decode(topic_hash.as_str()) { match topic.kind() { + GossipKind::Attestation(_subnet_id) => {} GossipKind::BeaconBlock => { - for peer in gossipsub.mesh_peers(topic_hash) { - if let Some(client) = peer_to_client.get(peer) { - if let Some(v) = - get_int_gauge(&BEACON_BLOCK_MESH_PEERS_PER_CLIENT, &[client]) - { - v.inc() - }; - } + for peer_id in gossipsub.mesh_peers(topic_hash) { + let client = network_globals + .peers + .read() + .peer_info(peer_id) + .map(|peer_info| peer_info.client().kind.as_static()) + .unwrap_or_else(|| "Unknown"); + if let Some(v) = + get_int_gauge(&BEACON_BLOCK_MESH_PEERS_PER_CLIENT, &[client]) + { + v.inc() + }; } } GossipKind::BeaconAggregateAndProof => { - for peer in gossipsub.mesh_peers(topic_hash) { - if let Some(client) = peer_to_client.get(peer) { - if let Some(v) = get_int_gauge( - &BEACON_AGGREGATE_AND_PROOF_MESH_PEERS_PER_CLIENT, - &[client], - ) { - v.inc() - }; - } + for peer_id in gossipsub.mesh_peers(topic_hash) { + let client = network_globals + .peers + .read() + .peer_info(peer_id) + .map(|peer_info| peer_info.client().kind.as_static()) + .unwrap_or_else(|| "Unknown"); + if let Some(v) = get_int_gauge( + &BEACON_AGGREGATE_AND_PROOF_MESH_PEERS_PER_CLIENT, + &[client], + ) { + v.inc() + }; } } - _ => (), + GossipKind::SyncCommitteeMessage(_subnet_id) => {} + _kind => {} } } } - - for (client, scores) in scores_per_client.into_iter() { - let c = &[client]; - let len = scores.len(); - if len > 0 { - let mut below0 = 0; - let mut below_gossip_threshold = 0; - let mut below_publish_threshold = 0; - let mut below_greylist_threshold = 0; - let mut min = f64::INFINITY; - let mut sum = 0.0; - let mut max = f64::NEG_INFINITY; - - let count = scores.len() as f64; - - for &score in &scores { - if score < 0.0 { - below0 += 1; - } - if score < -4000.0 { - //TODO not hardcode - below_gossip_threshold += 1; - } - if score < -8000.0 { - //TODO not hardcode - below_publish_threshold += 1; - } - if score < -16000.0 { - //TODO not hardcode - below_greylist_threshold += 1; - } - if score < min { - min = score; - } - if score > max { - max = score; - } - sum += score; - } - - let median = if len == 0 { - 0.0 - } else if len % 2 == 0 { - (scores[len / 2 - 1] + scores[len / 2]) / 2.0 - } else { - scores[len / 2] - }; - - set_gauge_entry(&SCORES_BELOW_ZERO_PER_CLIENT, c, below0 as f64 / count); - set_gauge_entry( - &SCORES_BELOW_GOSSIP_THRESHOLD_PER_CLIENT, - c, - below_gossip_threshold as f64 / count, - ); - set_gauge_entry( - &SCORES_BELOW_PUBLISH_THRESHOLD_PER_CLIENT, - c, - below_publish_threshold as f64 / count, - ); - set_gauge_entry( - &SCORES_BELOW_GREYLIST_THRESHOLD_PER_CLIENT, - c, - below_greylist_threshold as f64 / count, - ); - - set_gauge_entry(&MIN_SCORES_PER_CLIENT, c, min); - set_gauge_entry(&MEDIAN_SCORES_PER_CLIENT, c, median); - set_gauge_entry(&MEAN_SCORES_PER_CLIENT, c, sum / count); - set_gauge_entry(&MAX_SCORES_PER_CLIENT, c, max); - } - } } pub fn update_sync_metrics(network_globals: &Arc>) { diff --git a/beacon_node/network/src/service.rs b/beacon_node/network/src/service.rs index ce8aca472..485b0a98f 100644 --- a/beacon_node/network/src/service.rs +++ b/beacon_node/network/src/service.rs @@ -9,15 +9,18 @@ use crate::{ use beacon_chain::{BeaconChain, BeaconChainError, BeaconChainTypes}; use futures::future::OptionFuture; use futures::prelude::*; +use lighthouse_network::{ + open_metrics_client::registry::Registry, MessageAcceptance, Service as LibP2PService, +}; use lighthouse_network::{ rpc::{GoodbyeReason, RPCResponseErrorCode, RequestId}, - Libp2pEvent, PeerAction, PeerRequestId, PubsubMessage, ReportSource, Request, Response, Subnet, + Context, Libp2pEvent, PeerAction, PeerRequestId, PubsubMessage, ReportSource, Request, + Response, Subnet, }; use lighthouse_network::{ types::{GossipEncoding, GossipTopic}, BehaviourEvent, MessageId, NetworkGlobals, PeerId, }; -use lighthouse_network::{MessageAcceptance, Service as LibP2PService}; use slog::{crit, debug, error, info, o, trace, warn}; use std::{net::SocketAddr, pin::Pin, sync::Arc, time::Duration}; use store::HotColdDB; @@ -32,7 +35,7 @@ use types::{ mod tests; /// The interval (in seconds) that various network metrics will update. -const METRIC_UPDATE_INTERVAL: u64 = 1; +const METRIC_UPDATE_INTERVAL: u64 = 5; /// Number of slots before the fork when we should subscribe to the new fork topics. const SUBSCRIBE_DELAY_SLOTS: u64 = 2; /// Delay after a fork where we unsubscribe from pre-fork topics. @@ -154,6 +157,7 @@ impl NetworkService { beacon_chain: Arc>, config: &NetworkConfig, executor: task_executor::TaskExecutor, + gossipsub_registry: Option<&'_ mut Registry>, ) -> error::Result<( Arc>, mpsc::UnboundedSender>, @@ -199,16 +203,18 @@ impl NetworkService { debug!(network_log, "Current fork"; "fork_name" => ?fork_context.current_fork()); - // launch libp2p service - let (network_globals, mut libp2p) = LibP2PService::new( - executor.clone(), + // construct the libp2p service context + let service_context = Context { config, enr_fork_id, - &network_log, - fork_context.clone(), - &beacon_chain.spec, - ) - .await?; + fork_context: fork_context.clone(), + chain_spec: &beacon_chain.spec, + gossipsub_registry, + }; + + // launch libp2p service + let (network_globals, mut libp2p) = + LibP2PService::new(executor.clone(), service_context, &network_log).await?; // Repopulate the DHT with stored ENR's if discovery is not disabled. if !config.disable_discovery { @@ -324,21 +330,13 @@ fn spawn_service( // spawn on the current executor executor.spawn(async move { - let mut metric_update_counter = 0; loop { // build the futures to check simultaneously tokio::select! { _ = service.metrics_update.tick(), if service.metrics_enabled => { // update various network metrics - metric_update_counter +=1; - if metric_update_counter % T::EthSpec::default_spec().seconds_per_slot == 0 { - // if a slot has occurred, reset the metrics - let _ = metrics::ATTESTATIONS_PUBLISHED_PER_SUBNET_PER_SLOT - .as_ref() - .map(|gauge| gauge.reset()); - } metrics::update_gossip_metrics::( - service.libp2p.swarm.behaviour_mut().gs(), + service.libp2p.swarm.behaviour().gs(), &service.network_globals, ); // update sync metrics @@ -445,7 +443,6 @@ fn spawn_service( "count" => messages.len(), "topics" => ?topic_kinds ); - metrics::expose_publish_metrics(&messages); service.libp2p.swarm.behaviour_mut().publish(messages); } NetworkMessage::ReportPeer { peer_id, action, source } => service.libp2p.report_peer(&peer_id, action, source), @@ -643,9 +640,6 @@ fn spawn_service( message, .. } => { - // Update prometheus metrics. - metrics::expose_receive_metrics(&message); - match message { // attestation information gets processed in the attestation service PubsubMessage::Attestation(ref subnet_and_attestation) => { diff --git a/beacon_node/network/src/service/tests.rs b/beacon_node/network/src/service/tests.rs index 33b190e48..d78b1fe4f 100644 --- a/beacon_node/network/src/service/tests.rs +++ b/beacon_node/network/src/service/tests.rs @@ -67,9 +67,10 @@ mod tests { // Create a new network service which implicitly gets dropped at the // end of the block. - let _network_service = NetworkService::start(beacon_chain.clone(), &config, executor) - .await - .unwrap(); + let _network_service = + NetworkService::start(beacon_chain.clone(), &config, executor, None) + .await + .unwrap(); drop(signal); }); diff --git a/beacon_node/store/Cargo.toml b/beacon_node/store/Cargo.toml index 121e22fc6..66a6cf5d2 100644 --- a/beacon_node/store/Cargo.toml +++ b/beacon_node/store/Cargo.toml @@ -22,6 +22,6 @@ serde = "1.0.116" serde_derive = "1.0.116" lazy_static = "1.4.0" lighthouse_metrics = { path = "../../common/lighthouse_metrics" } -lru = "0.6.0" +lru = "0.7.1" sloggers = { version = "2.1.1", features = ["json"] } directory = { path = "../../common/directory" } diff --git a/common/lighthouse_metrics/src/lib.rs b/common/lighthouse_metrics/src/lib.rs index 4b7160ae0..98973de1a 100644 --- a/common/lighthouse_metrics/src/lib.rs +++ b/common/lighthouse_metrics/src/lib.rs @@ -307,6 +307,12 @@ pub fn set_float_gauge(gauge: &Result, value: f64) { } } +pub fn set_float_gauge_vec(gauge_vec: &Result, name: &[&str], value: f64) { + if let Some(gauge) = get_gauge(gauge_vec, name) { + gauge.set(value); + } +} + pub fn inc_gauge(gauge: &Result) { if let Ok(gauge) = gauge { gauge.inc(); diff --git a/lcli/src/generate_bootnode_enr.rs b/lcli/src/generate_bootnode_enr.rs index cb65bb438..6f39392d1 100644 --- a/lcli/src/generate_bootnode_enr.rs +++ b/lcli/src/generate_bootnode_enr.rs @@ -39,7 +39,7 @@ pub fn run(matches: &ArgMatches) -> Result<(), String> { next_fork_version: genesis_fork_version, next_fork_epoch: Epoch::max_value(), // FAR_FUTURE_EPOCH }; - let enr = build_enr::(&enr_key, &config, enr_fork_id) + let enr = build_enr::(&enr_key, &config, &enr_fork_id) .map_err(|e| format!("Unable to create ENR: {:?}", e))?; fs::create_dir_all(&output_dir).map_err(|e| format!("Unable to create output-dir: {:?}", e))?; diff --git a/slasher/Cargo.toml b/slasher/Cargo.toml index 01beda7e9..c319c2de1 100644 --- a/slasher/Cargo.toml +++ b/slasher/Cargo.toml @@ -14,7 +14,7 @@ lazy_static = "1.4.0" lighthouse_metrics = { path = "../common/lighthouse_metrics" } filesystem = { path = "../common/filesystem" } mdbx = { package = "libmdbx", version = "0.1.0" } -lru = "0.6.6" +lru = "0.7.1" parking_lot = "0.11.0" rand = "0.7.3" safe_arith = { path = "../consensus/safe_arith" }