diff --git a/Cargo.lock b/Cargo.lock index 1d12f46..a7a6efe 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -17,6 +17,12 @@ version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" +[[package]] +name = "adler32" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aae1277d39aeec15cb388266ecc24b11c80469deae6067e17a1a7aa9e5c1f234" + [[package]] name = "aead" version = "0.5.2" @@ -139,7 +145,7 @@ dependencies = [ "async-channel", "clap", "client", - "dirs", + "dirs 5.0.1", "futures", "regex", "sensitive_url", @@ -150,6 +156,21 @@ dependencies = [ "tracing-subscriber", ] +[[package]] +name = "android-tzdata" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" + +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + [[package]] name = "anstream" version = "0.6.15" @@ -214,6 +235,12 @@ dependencies = [ "derive_arbitrary", ] +[[package]] +name = "arc-swap" +version = "1.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69f7f8c3906b62b754cd5326047894316021dcfe5a194c8ea52bdd94934a3457" + [[package]] name = "archery" version = "0.4.0" @@ -585,6 +612,12 @@ version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" +[[package]] +name = "base64" +version = "0.21.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" + [[package]] name = "base64" version = "0.22.1" @@ -666,7 +699,7 @@ dependencies = [ [[package]] name = "bls" version = "0.2.0" -source = "git+https://github.com/sigp/lighthouse?branch=anchor#73743a53d1255f342a928092f801013662d2a5bf" +source = "git+https://github.com/sigp/lighthouse?branch=unstable#e31ac508d404700c35d99936028a5fd74749c335" dependencies = [ "alloy-primitives", "arbitrary", @@ -747,6 +780,27 @@ dependencies = [ "serde", ] +[[package]] +name = "bzip2" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bdb116a6ef3f6c3698828873ad02c3014b3c85cadb88496095628e3ef1e347f8" +dependencies = [ + "bzip2-sys", + "libc", +] + +[[package]] +name = "bzip2-sys" +version = "0.1.11+1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "736a955f3fa7875102d57c82b8cac37ec45224a07fd32d58f9f7a186b6cd4cdc" +dependencies = [ + "cc", + "libc", + "pkg-config", +] + [[package]] name = "c-kzg" version = "1.0.3" @@ -766,6 +820,8 @@ version = "1.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "812acba72f0a070b003d3697490d2b55b837230ae7c6c6497f05cc2ddbb8d938" dependencies = [ + "jobserver", + "libc", "shlex", ] @@ -799,6 +855,18 @@ dependencies = [ "zeroize", ] +[[package]] +name = "chrono" +version = "0.4.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401" +dependencies = [ + "android-tzdata", + "iana-time-zone", + "num-traits", + "windows-targets 0.52.6", +] + [[package]] name = "cipher" version = "0.4.4" @@ -851,24 +919,41 @@ version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1462739cb27611015575c0c11df5df7601141071f07518d56fcc1be504cbec97" +[[package]] +name = "clap_utils" +version = "0.1.0" +source = "git+https://github.com/sigp/lighthouse?branch=unstable#e31ac508d404700c35d99936028a5fd74749c335" +dependencies = [ + "alloy-primitives", + "clap", + "dirs 3.0.2", + "eth2_network_config", + "ethereum_ssz", + "hex", + "serde", + "serde_json", + "serde_yaml", + "types", +] + [[package]] name = "client" version = "0.1.0" dependencies = [ "clap", - "dirs", + "dirs 5.0.1", "ethereum_hashing", "fdlimit", - "git-version", "http_api", "hyper 1.4.1", - "regex", + "network", "sensitive_url", "serde", "strum", - "target_info", "task_executor", "tracing", + "unused_port", + "version", ] [[package]] @@ -880,7 +965,7 @@ checksum = "d3fd119d74b830634cea2a0f58bbd0d54540518a14397557951e79340abc28c0" [[package]] name = "compare_fields" version = "0.2.0" -source = "git+https://github.com/sigp/lighthouse?branch=anchor#73743a53d1255f342a928092f801013662d2a5bf" +source = "git+https://github.com/sigp/lighthouse?branch=unstable#e31ac508d404700c35d99936028a5fd74749c335" dependencies = [ "itertools 0.10.5", ] @@ -888,7 +973,7 @@ dependencies = [ [[package]] name = "compare_fields_derive" version = "0.2.0" -source = "git+https://github.com/sigp/lighthouse?branch=anchor#73743a53d1255f342a928092f801013662d2a5bf" +source = "git+https://github.com/sigp/lighthouse?branch=unstable#e31ac508d404700c35d99936028a5fd74749c335" dependencies = [ "quote", "syn 1.0.109", @@ -922,6 +1007,12 @@ version = "0.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" +[[package]] +name = "constant_time_eq" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" + [[package]] name = "convert_case" version = "0.6.0" @@ -1017,6 +1108,24 @@ dependencies = [ "sha2 0.10.8", ] +[[package]] +name = "crc32fast" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a97769d94ddab943e4510d138150169a2758b5ef3eb191a9ee688de3e23ef7b3" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "crossbeam-channel" +version = "0.5.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33480d6946193aa8033910124896ca395333cae7e2d1113d1fef6c3272217df2" +dependencies = [ + "crossbeam-utils", +] + [[package]] name = "crossbeam-deque" version = "0.8.5" @@ -1187,6 +1296,12 @@ dependencies = [ "syn 2.0.79", ] +[[package]] +name = "dary_heap" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04d2cd9c18b9f454ed67da600630b021a8a80bf33f8c95896ab33aaf1c26b728" + [[package]] name = "data-encoding" version = "2.6.0" @@ -1213,6 +1328,27 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "delay_map" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4355c25cbf99edcb6b4a0e906f6bdc6956eda149e84455bea49696429b2f8e8" +dependencies = [ + "futures", + "tokio-util", +] + +[[package]] +name = "delay_map" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df941644b671f05f59433e481ba0d31ac10e3667de725236a4c0d587c496fba1" +dependencies = [ + "futures", + "tokio", + "tokio-util", +] + [[package]] name = "der" version = "0.7.9" @@ -1220,6 +1356,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f55bf8e7b65898637379c1b74eb1551107c8294ed26d855ceb9fd1a09cfc9bc0" dependencies = [ "const-oid", + "pem-rfc7468", "zeroize", ] @@ -1311,13 +1448,53 @@ dependencies = [ "subtle", ] +[[package]] +name = "directory" +version = "0.1.0" +source = "git+https://github.com/sigp/lighthouse?branch=unstable#e31ac508d404700c35d99936028a5fd74749c335" +dependencies = [ + "clap", + "clap_utils", + "eth2_network_config", +] + +[[package]] +name = "dirs" +version = "3.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30baa043103c9d0c2a57cf537cc2f35623889dc0d405e6c3cccfadbc81c71309" +dependencies = [ + "dirs-sys 0.3.7", +] + [[package]] name = "dirs" version = "5.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "44c45a9d03d6676652bcb5e724c7e988de1acad23a711b5217ab9cbecbec2225" dependencies = [ - "dirs-sys", + "dirs-sys 0.4.1", +] + +[[package]] +name = "dirs-next" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b98cf8ebf19c3d1b223e151f99a4f9f0690dca41414773390fc824184ac833e1" +dependencies = [ + "cfg-if", + "dirs-sys-next", +] + +[[package]] +name = "dirs-sys" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b1d1d91c932ef41c0f2663aa8b0ca0342d444d842c06914aa0a7e352d0bada6" +dependencies = [ + "libc", + "redox_users", + "winapi", ] [[package]] @@ -1332,6 +1509,81 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "dirs-sys-next" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ebda144c4fe02d1f7ea1a7d9641b6fc6b580adcfa024ae48797ecdeb6825b4d" +dependencies = [ + "libc", + "redox_users", + "winapi", +] + +[[package]] +name = "discv5" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f569b8c367554666c8652305621e8bae3634a2ff5c6378081d5bd8c399c99f23" +dependencies = [ + "aes", + "aes-gcm", + "alloy-rlp", + "arrayvec", + "ctr", + "delay_map 0.3.0", + "enr", + "fnv", + "futures", + "hashlink 0.8.4", + "hex", + "hkdf", + "lazy_static", + "libp2p-identity", + "lru", + "more-asserts", + "multiaddr", + "parking_lot 0.11.2", + "rand", + "smallvec", + "socket2 0.4.10", + "tokio", + "tracing", + "uint 0.9.5", + "zeroize", +] + +[[package]] +name = "discv5" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23e6b70634e26c909d1edbb3142b3eaf3b89da0e52f284f00ca7c80d9901ad9e" +dependencies = [ + "aes", + "aes-gcm", + "alloy-rlp", + "arrayvec", + "ctr", + "delay_map 0.4.0", + "enr", + "fnv", + "futures", + "hashlink 0.9.1", + "hex", + "hkdf", + "lazy_static", + "lru", + "more-asserts", + "parking_lot 0.12.3", + "rand", + "smallvec", + "socket2 0.5.7", + "tokio", + "tracing", + "uint 0.10.0", + "zeroize", +] + [[package]] name = "displaydoc" version = "0.2.5" @@ -1406,6 +1658,7 @@ dependencies = [ "ff", "generic-array", "group", + "pem-rfc7468", "pkcs8", "rand_core", "sec1", @@ -1413,6 +1666,34 @@ dependencies = [ "zeroize", ] +[[package]] +name = "encoding_rs" +version = "0.8.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75030f3c4f45dafd7586dd6780965a8c7e8e285a5ecb86713e63a79c5b2766f3" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "enr" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "972070166c68827e64bd1ebc8159dd8e32d9bc2da7ebe8f20b61308f7974ad30" +dependencies = [ + "alloy-rlp", + "base64 0.21.7", + "bytes", + "ed25519-dalek", + "hex", + "k256", + "log", + "rand", + "serde", + "sha3", + "zeroize", +] + [[package]] name = "enum-as-inner" version = "0.6.1" @@ -1450,10 +1731,29 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "error-chain" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d2f06b9cac1506ece98fe3231e3cc9c4410ec3d5b1f24ae1c8946f0742cdefc" +dependencies = [ + "backtrace", + "version_check", +] + +[[package]] +name = "eth2_config" +version = "0.2.0" +source = "git+https://github.com/sigp/lighthouse?branch=unstable#e31ac508d404700c35d99936028a5fd74749c335" +dependencies = [ + "paste", + "types", +] + [[package]] name = "eth2_interop_keypairs" version = "0.2.0" -source = "git+https://github.com/sigp/lighthouse?branch=anchor#73743a53d1255f342a928092f801013662d2a5bf" +source = "git+https://github.com/sigp/lighthouse?branch=unstable#e31ac508d404700c35d99936028a5fd74749c335" dependencies = [ "bls", "ethereum_hashing", @@ -1463,6 +1763,27 @@ dependencies = [ "serde_yaml", ] +[[package]] +name = "eth2_network_config" +version = "0.2.0" +source = "git+https://github.com/sigp/lighthouse?branch=unstable#e31ac508d404700c35d99936028a5fd74749c335" +dependencies = [ + "bytes", + "discv5 0.7.0", + "eth2_config", + "kzg", + "logging", + "pretty_reqwest_error", + "reqwest", + "sensitive_url", + "serde_yaml", + "sha2 0.9.9", + "slog", + "types", + "url", + "zip", +] + [[package]] name = "ethereum_hashing" version = "0.7.0" @@ -1593,6 +1914,16 @@ version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "28dea519a9695b9977216879a3ebfddf92f1c08c05d984f8996aecd6ecdc811d" +[[package]] +name = "field-offset" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38e2275cc4e4fc009b0669731a1e5ab7ebf11f469eaede2bab9309a5b4d6057f" +dependencies = [ + "memoffset", + "rustc_version 0.4.1", +] + [[package]] name = "fixed-hash" version = "0.8.0" @@ -1608,12 +1939,22 @@ dependencies = [ [[package]] name = "fixed_bytes" version = "0.1.0" -source = "git+https://github.com/sigp/lighthouse?branch=anchor#73743a53d1255f342a928092f801013662d2a5bf" +source = "git+https://github.com/sigp/lighthouse?branch=unstable#e31ac508d404700c35d99936028a5fd74749c335" dependencies = [ "alloy-primitives", "safe_arith", ] +[[package]] +name = "flate2" +version = "1.0.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1b589b4dc103969ad3cf85c950899926ec64300a1a46d76c03a6072957036f0" +dependencies = [ + "crc32fast", + "miniz_oxide", +] + [[package]] name = "fnv" version = "1.0.7" @@ -1626,6 +1967,21 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f81ec6369c545a7d40e4589b5597581fa1c441fe1cce96dd1de43159910a36a2" +[[package]] +name = "foreign-types" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" +dependencies = [ + "foreign-types-shared", +] + +[[package]] +name = "foreign-types-shared" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" + [[package]] name = "form_urlencoded" version = "1.2.1" @@ -1728,7 +2084,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a8f2f12607f92c69b12ed746fabf9ca4f5c482cba46679c1a75b874ed7c26adb" dependencies = [ "futures-io", - "rustls", + "rustls 0.23.15", "rustls-pki-types", ] @@ -1844,9 +2200,39 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" [[package]] -name = "group" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" +name = "gossipsub" +version = "0.5.0" +source = "git+https://github.com/sigp/lighthouse?branch=unstable#e31ac508d404700c35d99936028a5fd74749c335" +dependencies = [ + "async-channel", + "asynchronous-codec", + "base64 0.21.7", + "byteorder", + "bytes", + "either", + "fnv", + "futures", + "futures-ticker", + "futures-timer", + "getrandom", + "hashlink 0.9.1", + "hex_fmt", + "libp2p", + "prometheus-client", + "quick-protobuf", + "quick-protobuf-codec", + "rand", + "regex", + "sha2 0.10.8", + "tracing", + "void", + "web-time", +] + +[[package]] +name = "group" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" dependencies = [ "ff", @@ -1906,6 +2292,15 @@ dependencies = [ "hashbrown 0.14.5", ] +[[package]] +name = "hashlink" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ba4ff7128dee98c7dc9794b6a411377e1404dba1c97deb8d1a55297bd25d8af" +dependencies = [ + "hashbrown 0.14.5", +] + [[package]] name = "heck" version = "0.4.1" @@ -1968,7 +2363,7 @@ dependencies = [ "ipnet", "once_cell", "rand", - "socket2", + "socket2 0.5.7", "thiserror", "tinyvec", "tokio", @@ -1988,7 +2383,7 @@ dependencies = [ "ipconfig", "lru-cache", "once_cell", - "parking_lot", + "parking_lot 0.12.3", "rand", "resolv-conf", "smallvec", @@ -2144,7 +2539,7 @@ dependencies = [ "httpdate", "itoa", "pin-project-lite", - "socket2", + "socket2 0.5.7", "tokio", "tower-service", "tracing", @@ -2170,6 +2565,33 @@ dependencies = [ "tokio", ] +[[package]] +name = "hyper-rustls" +version = "0.24.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec3efd23720e2049821a693cbc7e65ea87c72f1c58ff2f9522ff332b1491e590" +dependencies = [ + "futures-util", + "http 0.2.12", + "hyper 0.14.31", + "rustls 0.21.12", + "tokio", + "tokio-rustls", +] + +[[package]] +name = "hyper-tls" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" +dependencies = [ + "bytes", + "hyper 0.14.31", + "native-tls", + "tokio", + "tokio-native-tls", +] + [[package]] name = "hyper-util" version = "0.1.9" @@ -2186,6 +2608,29 @@ dependencies = [ "tower-service", ] +[[package]] +name = "iana-time-zone" +version = "0.1.61" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "235e081f3925a06703c2d0117ea8b91f042756fd6e7a6e5d901e8ca1a996b220" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "wasm-bindgen", + "windows-core", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" +dependencies = [ + "cc", +] + [[package]] name = "ident_case" version = "1.0.1" @@ -2313,7 +2758,7 @@ dependencies = [ [[package]] name = "int_to_bytes" version = "0.2.0" -source = "git+https://github.com/sigp/lighthouse?branch=anchor#73743a53d1255f342a928092f801013662d2a5bf" +source = "git+https://github.com/sigp/lighthouse?branch=unstable#e31ac508d404700c35d99936028a5fd74749c335" dependencies = [ "bytes", ] @@ -2324,8 +2769,8 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b58db92f96b720de98181bbbe63c831e87005ab460c1bf306eb2622b4707997f" dependencies = [ - "socket2", - "widestring", + "socket2 0.5.7", + "widestring 1.1.0", "windows-sys 0.48.0", "winreg", ] @@ -2336,6 +2781,17 @@ version = "2.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ddc24109865250148c2e0f3d25d4f0f479571723792d3802153c60922a4fb708" +[[package]] +name = "is-terminal" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "261f68e344040fbd0edea105bef17c66edf46f984ddb1115b775ce31be948f4b" +dependencies = [ + "hermit-abi 0.4.0", + "libc", + "windows-sys 0.52.0", +] + [[package]] name = "is_terminal_polyfill" version = "1.70.1" @@ -2366,6 +2822,15 @@ version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" +[[package]] +name = "jobserver" +version = "0.1.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48d1dbcbbeb6a7fec7e059840aa538bd62aaccf972c7346c4d9d2059312853d0" +dependencies = [ + "libc", +] + [[package]] name = "js-sys" version = "0.3.72" @@ -2386,6 +2851,7 @@ dependencies = [ "elliptic-curve", "once_cell", "sha2 0.10.8", + "signature", ] [[package]] @@ -2410,7 +2876,7 @@ dependencies = [ [[package]] name = "kzg" version = "0.1.0" -source = "git+https://github.com/sigp/lighthouse?branch=anchor#73743a53d1255f342a928092f801013662d2a5bf" +source = "git+https://github.com/sigp/lighthouse?branch=unstable#e31ac508d404700c35d99936028a5fd74749c335" dependencies = [ "arbitrary", "c-kzg", @@ -2438,6 +2904,30 @@ version = "0.2.159" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "561d97a539a36e26a9a5fad1ea11a3039a67714694aaa379433e580854bc3dc5" +[[package]] +name = "libflate" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "45d9dfdc14ea4ef0900c1cddbc8dcd553fbaacd8a4a282cf4018ae9dd04fb21e" +dependencies = [ + "adler32", + "core2", + "crc32fast", + "dary_heap", + "libflate_lz77", +] + +[[package]] +name = "libflate_lz77" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6e0d73b369f386f1c44abd9c570d5318f55ccde816ff4b562fa452e5182863d" +dependencies = [ + "core2", + "hashbrown 0.14.5", + "rle-decode-fast", +] + [[package]] name = "libm" version = "0.2.8" @@ -2466,6 +2956,7 @@ dependencies = [ "libp2p-metrics", "libp2p-noise", "libp2p-ping", + "libp2p-plaintext", "libp2p-quic", "libp2p-swarm", "libp2p-tcp", @@ -2516,7 +3007,7 @@ dependencies = [ "multihash", "multistream-select", "once_cell", - "parking_lot", + "parking_lot 0.12.3", "pin-project", "quick-protobuf", "rand", @@ -2540,7 +3031,7 @@ dependencies = [ "hickory-resolver", "libp2p-core", "libp2p-identity", - "parking_lot", + "parking_lot 0.12.3", "smallvec", "tracing", ] @@ -2611,11 +3102,14 @@ dependencies = [ "hkdf", "libsecp256k1", "multihash", + "p256", "quick-protobuf", "rand", + "sec1", "sha2 0.10.8", "thiserror", "tracing", + "void", "zeroize", ] @@ -2634,7 +3128,7 @@ dependencies = [ "libp2p-swarm", "rand", "smallvec", - "socket2", + "socket2 0.5.7", "tokio", "tracing", "void", @@ -2658,6 +3152,25 @@ dependencies = [ "web-time", ] +[[package]] +name = "libp2p-mplex" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41187ab8f6c835ad864edf94224f666f636ee2d270601422c1441f739e0abccc" +dependencies = [ + "asynchronous-codec", + "bytes", + "futures", + "libp2p-core", + "libp2p-identity", + "nohash-hasher", + "parking_lot 0.12.3", + "rand", + "smallvec", + "tracing", + "unsigned-varint 0.8.0", +] + [[package]] name = "libp2p-noise" version = "0.45.0" @@ -2702,6 +3215,22 @@ dependencies = [ "web-time", ] +[[package]] +name = "libp2p-plaintext" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b63d926c6be56a2489e0e7316b17fe95a70bc5c4f3e85740bb3e67c0f3c6a44" +dependencies = [ + "asynchronous-codec", + "bytes", + "futures", + "libp2p-core", + "libp2p-identity", + "quick-protobuf", + "quick-protobuf-codec", + "tracing", +] + [[package]] name = "libp2p-quic" version = "0.11.1" @@ -2715,12 +3244,12 @@ dependencies = [ "libp2p-core", "libp2p-identity", "libp2p-tls", - "parking_lot", + "parking_lot 0.12.3", "quinn", "rand", "ring 0.17.8", - "rustls", - "socket2", + "rustls 0.23.15", + "socket2 0.5.7", "thiserror", "tokio", "tracing", @@ -2774,7 +3303,7 @@ dependencies = [ "libc", "libp2p-core", "libp2p-identity", - "socket2", + "socket2 0.5.7", "tokio", "tracing", ] @@ -2791,7 +3320,7 @@ dependencies = [ "libp2p-identity", "rcgen", "ring 0.17.8", - "rustls", + "rustls 0.23.15", "rustls-webpki 0.101.7", "thiserror", "x509-parser", @@ -2898,6 +3427,65 @@ dependencies = [ "vcpkg", ] +[[package]] +name = "lighthouse_network" +version = "0.2.0" +source = "git+https://github.com/sigp/lighthouse?branch=unstable#e31ac508d404700c35d99936028a5fd74749c335" +dependencies = [ + "alloy-primitives", + "alloy-rlp", + "bytes", + "delay_map 0.3.0", + "directory", + "dirs 3.0.2", + "discv5 0.7.0", + "either", + "error-chain", + "ethereum_ssz", + "ethereum_ssz_derive", + "fnv", + "futures", + "gossipsub", + "hex", + "itertools 0.10.5", + "libp2p", + "libp2p-mplex", + "lighthouse_version", + "lru", + "lru_cache", + "metrics", + "parking_lot 0.12.3", + "prometheus-client", + "rand", + "regex", + "serde", + "sha2 0.9.9", + "slog", + "smallvec", + "snap", + "ssz_types", + "strum", + "superstruct", + "task_executor", + "tiny-keccak", + "tokio", + "tokio-io-timeout", + "tokio-util", + "types", + "unsigned-varint 0.8.0", + "unused_port", + "void", +] + +[[package]] +name = "lighthouse_version" +version = "0.1.0" +source = "git+https://github.com/sigp/lighthouse?branch=unstable#e31ac508d404700c35d99936028a5fd74749c335" +dependencies = [ + "git-version", + "target_info", +] + [[package]] name = "linked-hash-map" version = "0.5.6" @@ -2926,6 +3514,28 @@ version = "0.4.22" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" +[[package]] +name = "logging" +version = "0.2.0" +source = "git+https://github.com/sigp/lighthouse?branch=unstable#e31ac508d404700c35d99936028a5fd74749c335" +dependencies = [ + "chrono", + "metrics", + "parking_lot 0.12.3", + "serde", + "serde_json", + "slog", + "slog-term", + "sloggers", + "take_mut", + "tokio", + "tracing", + "tracing-appender", + "tracing-core", + "tracing-log", + "tracing-subscriber", +] + [[package]] name = "lru" version = "0.12.5" @@ -2944,6 +3554,14 @@ dependencies = [ "linked-hash-map", ] +[[package]] +name = "lru_cache" +version = "0.1.0" +source = "git+https://github.com/sigp/lighthouse?branch=unstable#e31ac508d404700c35d99936028a5fd74749c335" +dependencies = [ + "fnv", +] + [[package]] name = "maplit" version = "1.0.2" @@ -2977,10 +3595,19 @@ version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" +[[package]] +name = "memoffset" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "488016bfae457b036d996092f6cb448677611ce4449e970ceaf42695203f218a" +dependencies = [ + "autocfg", +] + [[package]] name = "merkle_proof" version = "0.2.0" -source = "git+https://github.com/sigp/lighthouse?branch=anchor#73743a53d1255f342a928092f801013662d2a5bf" +source = "git+https://github.com/sigp/lighthouse?branch=unstable#e31ac508d404700c35d99936028a5fd74749c335" dependencies = [ "alloy-primitives", "ethereum_hashing", @@ -3014,7 +3641,7 @@ dependencies = [ [[package]] name = "metrics" version = "0.2.0" -source = "git+https://github.com/sigp/lighthouse?branch=anchor#73743a53d1255f342a928092f801013662d2a5bf" +source = "git+https://github.com/sigp/lighthouse?branch=unstable#e31ac508d404700c35d99936028a5fd74749c335" dependencies = [ "prometheus", ] @@ -3032,7 +3659,7 @@ dependencies = [ "ethereum_ssz", "ethereum_ssz_derive", "itertools 0.13.0", - "parking_lot", + "parking_lot 0.12.3", "rayon", "serde", "smallvec", @@ -3075,6 +3702,12 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "more-asserts" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fafa6961cabd9c63bcd77a45d7e3b7f3b552b70417831fb0f56db717e72407e" + [[package]] name = "multiaddr" version = "0.18.2" @@ -3129,6 +3762,23 @@ dependencies = [ "unsigned-varint 0.7.2", ] +[[package]] +name = "native-tls" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8614eb2c83d59d1c8cc974dd3f920198647674a0a035e1af1fa58707e317466" +dependencies = [ + "libc", + "log", + "openssl", + "openssl-probe", + "openssl-sys", + "schannel", + "security-framework", + "security-framework-sys", + "tempfile", +] + [[package]] name = "netlink-packet-core" version = "0.4.2" @@ -3195,6 +3845,23 @@ dependencies = [ "tokio", ] +[[package]] +name = "network" +version = "0.1.0" +dependencies = [ + "async-channel", + "dirs 5.0.1", + "discv5 0.8.0", + "futures", + "libp2p", + "lighthouse_network", + "serde", + "task_executor", + "tokio", + "tracing", + "version", +] + [[package]] name = "nix" version = "0.24.3" @@ -3311,26 +3978,81 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" [[package]] -name = "option-ext" -version = "0.2.0" +name = "openssl" +version = "0.10.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" +checksum = "6174bc48f102d208783c2c84bf931bb75927a617866870de8a4ea85597f871f5" +dependencies = [ + "bitflags 2.6.0", + "cfg-if", + "foreign-types", + "libc", + "once_cell", + "openssl-macros", + "openssl-sys", +] [[package]] -name = "overload" +name = "openssl-macros" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" +checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.79", +] [[package]] -name = "p2p_network" -version = "0.1.0" +name = "openssl-probe" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" + +[[package]] +name = "openssl-src" +version = "300.4.0+3.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a709e02f2b4aca747929cca5ed248880847c650233cf8b8cdc48f40aaf4898a6" dependencies = [ - "async-channel", - "futures", - "libp2p", - "task_executor", - "tokio", + "cc", +] + +[[package]] +name = "openssl-sys" +version = "0.9.104" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "45abf306cbf99debc8195b66b7346498d7b10c210de50418b5ccd7ceba08c741" +dependencies = [ + "cc", + "libc", + "openssl-src", + "pkg-config", + "vcpkg", +] + +[[package]] +name = "option-ext" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" + +[[package]] +name = "overload" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" + +[[package]] +name = "p256" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9863ad85fa8f4460f9c48cb909d38a0d689dba1f6f6988a5e3e0d31071bcd4b" +dependencies = [ + "ecdsa", + "elliptic-curve", + "primeorder", + "sha2 0.10.8", ] [[package]] @@ -3374,6 +4096,17 @@ version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f38d5652c16fde515bb1ecef450ab0f6a219d619a7274976324d5e377f7dceba" +[[package]] +name = "parking_lot" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99" +dependencies = [ + "instant", + "lock_api", + "parking_lot_core 0.8.6", +] + [[package]] name = "parking_lot" version = "0.12.3" @@ -3381,7 +4114,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f1bf18183cf54e8d6059647fc3063646a1801cf30896933ec2311622cc4b9a27" dependencies = [ "lock_api", - "parking_lot_core", + "parking_lot_core 0.9.10", +] + +[[package]] +name = "parking_lot_core" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60a2cfe6f0ad2bfc16aefa463b497d5c7a5ecd44a23efa72aa342d90177356dc" +dependencies = [ + "cfg-if", + "instant", + "libc", + "redox_syscall 0.2.16", + "smallvec", + "winapi", ] [[package]] @@ -3392,17 +4139,40 @@ checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" dependencies = [ "cfg-if", "libc", - "redox_syscall", + "redox_syscall 0.5.7", "smallvec", "windows-targets 0.52.6", ] +[[package]] +name = "password-hash" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7676374caaee8a325c9e7a2ae557f216c5563a171d6997b0ef8a65af35147700" +dependencies = [ + "base64ct", + "rand_core", + "subtle", +] + [[package]] name = "paste" version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" +[[package]] +name = "pbkdf2" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83a0692ec44e4cf1ef28ca317f14f8f07da2d95ec3fa01f86e4467b725e60917" +dependencies = [ + "digest 0.10.7", + "hmac 0.12.1", + "password-hash", + "sha2 0.10.8", +] + [[package]] name = "pem" version = "3.0.4" @@ -3413,6 +4183,15 @@ dependencies = [ "serde", ] +[[package]] +name = "pem-rfc7468" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88b39c9bfcfc231068454382784bb460aae594343fb030d46e9f50a645418412" +dependencies = [ + "base64ct", +] + [[package]] name = "percent-encoding" version = "2.3.1" @@ -3537,6 +4316,24 @@ dependencies = [ "zerocopy", ] +[[package]] +name = "pretty_reqwest_error" +version = "0.1.0" +source = "git+https://github.com/sigp/lighthouse?branch=unstable#e31ac508d404700c35d99936028a5fd74749c335" +dependencies = [ + "reqwest", + "sensitive_url", +] + +[[package]] +name = "primeorder" +version = "0.13.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "353e1ca18966c16d9deb1c69278edbc5f194139612772bd9537af60ac231e1e6" +dependencies = [ + "elliptic-curve", +] + [[package]] name = "primitive-types" version = "0.12.2" @@ -3545,7 +4342,7 @@ checksum = "0b34d9fd68ae0b74a41b21c03c2f62847aa0ffea044eee893b4c140b37e244e2" dependencies = [ "fixed-hash", "impl-codec", - "uint", + "uint 0.9.5", ] [[package]] @@ -3576,7 +4373,7 @@ dependencies = [ "fnv", "lazy_static", "memchr", - "parking_lot", + "parking_lot 0.12.3", "protobuf", "thiserror", ] @@ -3589,7 +4386,7 @@ checksum = "504ee9ff529add891127c4827eb481bd69dc0ebc72e9a682e187db4caa60c3ca" dependencies = [ "dtoa", "itoa", - "parking_lot", + "parking_lot 0.12.3", "prometheus-client-derive-encode", ] @@ -3692,8 +4489,8 @@ dependencies = [ "quinn-proto", "quinn-udp", "rustc-hash", - "rustls", - "socket2", + "rustls 0.23.15", + "socket2 0.5.7", "thiserror", "tokio", "tracing", @@ -3709,7 +4506,7 @@ dependencies = [ "rand", "ring 0.17.8", "rustc-hash", - "rustls", + "rustls 0.23.15", "slab", "thiserror", "tinyvec", @@ -3724,7 +4521,7 @@ checksum = "4fe68c2e9e1a1234e218683dbdf9f9dfcb094113c5ac2b938dfcb9bab4c4140b" dependencies = [ "libc", "once_cell", - "socket2", + "socket2 0.5.7", "tracing", "windows-sys 0.59.0", ] @@ -3816,6 +4613,15 @@ dependencies = [ "yasna", ] +[[package]] +name = "redox_syscall" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" +dependencies = [ + "bitflags 1.3.2", +] + [[package]] name = "redox_syscall" version = "0.5.7" @@ -3838,9 +4644,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.11.0" +version = "1.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38200e5ee88914975b69f657f0801b6f6dccafd44fd9326302a4aaeecfacb1d8" +checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" dependencies = [ "aho-corasick", "memchr", @@ -3880,6 +4686,52 @@ version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" +[[package]] +name = "reqwest" +version = "0.11.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd67538700a17451e7cba03ac727fb961abb7607553461627b97de0b89cf4a62" +dependencies = [ + "base64 0.21.7", + "bytes", + "encoding_rs", + "futures-core", + "futures-util", + "h2", + "http 0.2.12", + "http-body 0.4.6", + "hyper 0.14.31", + "hyper-rustls", + "hyper-tls", + "ipnet", + "js-sys", + "log", + "mime", + "native-tls", + "once_cell", + "percent-encoding", + "pin-project-lite", + "rustls 0.21.12", + "rustls-pemfile", + "serde", + "serde_json", + "serde_urlencoded", + "sync_wrapper 0.1.2", + "system-configuration", + "tokio", + "tokio-native-tls", + "tokio-rustls", + "tokio-util", + "tower-service", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "wasm-streams", + "web-sys", + "webpki-roots", + "winreg", +] + [[package]] name = "resolv-conf" version = "0.7.0" @@ -3930,6 +4782,12 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "rle-decode-fast" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3582f63211428f83597b51b2ddb88e2a91a9d52d12831f9d08f5e624e8977422" + [[package]] name = "rlp" version = "0.5.2" @@ -4004,7 +4862,7 @@ dependencies = [ "bitflags 1.3.2", "fallible-iterator", "fallible-streaming-iterator", - "hashlink", + "hashlink 0.8.4", "libsqlite3-sys", "smallvec", ] @@ -4081,6 +4939,18 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "rustls" +version = "0.21.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f56a14d1f48b391359b22f731fd4bd7e43c97f3c50eee276f3aa09c94784d3e" +dependencies = [ + "log", + "ring 0.17.8", + "rustls-webpki 0.101.7", + "sct", +] + [[package]] name = "rustls" version = "0.23.15" @@ -4095,6 +4965,15 @@ dependencies = [ "zeroize", ] +[[package]] +name = "rustls-pemfile" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c74cae0a4cf6ccbbf5f359f08efdf8ee7e1dc532573bf0db71968cb56b1448c" +dependencies = [ + "base64 0.21.7", +] + [[package]] name = "rustls-pki-types" version = "1.10.0" @@ -4160,7 +5039,16 @@ checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" [[package]] name = "safe_arith" version = "0.1.0" -source = "git+https://github.com/sigp/lighthouse?branch=anchor#73743a53d1255f342a928092f801013662d2a5bf" +source = "git+https://github.com/sigp/lighthouse?branch=unstable#e31ac508d404700c35d99936028a5fd74749c335" + +[[package]] +name = "schannel" +version = "0.1.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01227be5826fa0690321a2ba6c5cd57a19cf3f6a09e76973b58e61de6ab9d1c1" +dependencies = [ + "windows-sys 0.59.0", +] [[package]] name = "scopeguard" @@ -4168,6 +5056,16 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" +[[package]] +name = "sct" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da046153aa2352493d6cb7da4b6e5c0c057d8a1d0a9aa8560baffdd945acd414" +dependencies = [ + "ring 0.17.8", + "untrusted 0.9.0", +] + [[package]] name = "sec1" version = "0.7.3" @@ -4182,6 +5080,29 @@ dependencies = [ "zeroize", ] +[[package]] +name = "security-framework" +version = "2.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02" +dependencies = [ + "bitflags 2.6.0", + "core-foundation", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "2.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea4a292869320c0272d7bc55a5a6aafaff59b4f63404a003887b679a2e05b4b6" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "semver" version = "0.11.0" @@ -4209,7 +5130,7 @@ dependencies = [ [[package]] name = "sensitive_url" version = "0.1.0" -source = "git+https://github.com/sigp/lighthouse?branch=anchor#73743a53d1255f342a928092f801013662d2a5bf" +source = "git+https://github.com/sigp/lighthouse?branch=unstable#e31ac508d404700c35d99936028a5fd74749c335" dependencies = [ "serde", "url", @@ -4282,6 +5203,17 @@ dependencies = [ "unsafe-libyaml", ] +[[package]] +name = "sha1" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest 0.10.7", +] + [[package]] name = "sha2" version = "0.9.9" @@ -4378,13 +5310,106 @@ dependencies = [ "erased-serde", ] +[[package]] +name = "slog-async" +version = "2.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72c8038f898a2c79507940990f05386455b3a317d8f18d4caea7cbc3d5096b84" +dependencies = [ + "crossbeam-channel", + "slog", + "take_mut", + "thread_local", +] + +[[package]] +name = "slog-json" +version = "2.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e1e53f61af1e3c8b852eef0a9dee29008f55d6dd63794f3f12cef786cf0f219" +dependencies = [ + "serde", + "serde_json", + "slog", + "time", +] + +[[package]] +name = "slog-kvfilter" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae939ed7d169eed9699f4f5cd440f046f5dc5dfc27c19e3cd311619594c175e0" +dependencies = [ + "regex", + "slog", +] + +[[package]] +name = "slog-scope" +version = "4.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f95a4b4c3274cd2869549da82b57ccc930859bdbf5bcea0424bc5f140b3c786" +dependencies = [ + "arc-swap", + "lazy_static", + "slog", +] + +[[package]] +name = "slog-stdlog" +version = "4.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6706b2ace5bbae7291d3f8d2473e2bfab073ccd7d03670946197aec98471fa3e" +dependencies = [ + "log", + "slog", + "slog-scope", +] + +[[package]] +name = "slog-term" +version = "2.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6e022d0b998abfe5c3782c1f03551a596269450ccd677ea51c56f8b214610e8" +dependencies = [ + "is-terminal", + "slog", + "term", + "thread_local", + "time", +] + +[[package]] +name = "sloggers" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75062c2738b82cd45ae633623caae3393f43eb00aada1dc2d3ebe88db6b0db9b" +dependencies = [ + "chrono", + "libc", + "libflate", + "once_cell", + "regex", + "serde", + "slog", + "slog-async", + "slog-json", + "slog-kvfilter", + "slog-scope", + "slog-stdlog", + "slog-term", + "trackable", + "winapi", + "windows-acl", +] + [[package]] name = "slot_clock" version = "0.2.0" -source = "git+https://github.com/sigp/lighthouse?branch=anchor#73743a53d1255f342a928092f801013662d2a5bf" +source = "git+https://github.com/sigp/lighthouse?branch=unstable#e31ac508d404700c35d99936028a5fd74749c335" dependencies = [ "metrics", - "parking_lot", + "parking_lot 0.12.3", "types", ] @@ -4397,6 +5422,12 @@ dependencies = [ "arbitrary", ] +[[package]] +name = "snap" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b6b67fb9a61334225b5b790716f609cd58395f895b3fe8b328786812a40bc3b" + [[package]] name = "snow" version = "0.9.6" @@ -4414,6 +5445,16 @@ dependencies = [ "subtle", ] +[[package]] +name = "socket2" +version = "0.4.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f7916fc008ca5542385b89a3d3ce689953c143e9304a9bf8beec1de48994c0d" +dependencies = [ + "libc", + "winapi", +] + [[package]] name = "socket2" version = "0.5.7" @@ -4533,7 +5574,7 @@ dependencies = [ [[package]] name = "swap_or_not_shuffle" version = "0.2.0" -source = "git+https://github.com/sigp/lighthouse?branch=anchor#73743a53d1255f342a928092f801013662d2a5bf" +source = "git+https://github.com/sigp/lighthouse?branch=unstable#e31ac508d404700c35d99936028a5fd74749c335" dependencies = [ "alloy-primitives", "ethereum_hashing", @@ -4606,6 +5647,12 @@ dependencies = [ "libc", ] +[[package]] +name = "take_mut" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f764005d11ee5f36500a149ace24e00e3da98b0158b3e2d53a7495660d3f4d60" + [[package]] name = "tap" version = "1.0.1" @@ -4621,11 +5668,14 @@ checksum = "c63f48baada5c52e65a29eef93ab4f8982681b67f9e8d29c7b05abcfec2b9ffe" [[package]] name = "task_executor" version = "0.1.0" -source = "git+https://github.com/sigp/lighthouse?branch=anchor#73743a53d1255f342a928092f801013662d2a5bf" +source = "git+https://github.com/sigp/lighthouse?branch=unstable#e31ac508d404700c35d99936028a5fd74749c335" dependencies = [ "async-channel", "futures", + "logging", "metrics", + "slog", + "sloggers", "tokio", "tracing", ] @@ -4643,6 +5693,17 @@ dependencies = [ "windows-sys 0.59.0", ] +[[package]] +name = "term" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c59df8ac95d96ff9bede18eb7300b0fda5e5d8d90960e76f8e14ae765eedbf1f" +dependencies = [ + "dirs-next", + "rustversion", + "winapi", +] + [[package]] name = "terminal_size" version = "0.4.0" @@ -4656,7 +5717,7 @@ dependencies = [ [[package]] name = "test_random_derive" version = "0.2.0" -source = "git+https://github.com/sigp/lighthouse?branch=anchor#73743a53d1255f342a928092f801013662d2a5bf" +source = "git+https://github.com/sigp/lighthouse?branch=unstable#e31ac508d404700c35d99936028a5fd74749c335" dependencies = [ "quote", "syn 1.0.109", @@ -4768,11 +5829,21 @@ dependencies = [ "mio", "pin-project-lite", "signal-hook-registry", - "socket2", + "socket2 0.5.7", "tokio-macros", "windows-sys 0.52.0", ] +[[package]] +name = "tokio-io-timeout" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30b74022ada614a1b4834de765f9bb43877f910cc8ce4be40e89042c9223a8bf" +dependencies = [ + "pin-project-lite", + "tokio", +] + [[package]] name = "tokio-macros" version = "2.4.0" @@ -4784,6 +5855,26 @@ dependencies = [ "syn 2.0.79", ] +[[package]] +name = "tokio-native-tls" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2" +dependencies = [ + "native-tls", + "tokio", +] + +[[package]] +name = "tokio-rustls" +version = "0.24.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081" +dependencies = [ + "rustls 0.21.12", + "tokio", +] + [[package]] name = "tokio-util" version = "0.7.12" @@ -4792,8 +5883,10 @@ checksum = "61e7c3654c13bcd040d4a03abee2c75b1d14a37b423cf5a813ceae1cc903ec6a" dependencies = [ "bytes", "futures-core", + "futures-io", "futures-sink", "pin-project-lite", + "slab", "tokio", ] @@ -4854,6 +5947,18 @@ dependencies = [ "tracing-core", ] +[[package]] +name = "tracing-appender" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3566e8ce28cc0a3fe42519fc80e6b4c943cc4c8cef275620eb8dac2d3d4e06cf" +dependencies = [ + "crossbeam-channel", + "thiserror", + "time", + "tracing-subscriber", +] + [[package]] name = "tracing-attributes" version = "0.1.27" @@ -4904,6 +6009,25 @@ dependencies = [ "tracing-log", ] +[[package]] +name = "trackable" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b15bd114abb99ef8cee977e517c8f37aee63f184f2d08e3e6ceca092373369ae" +dependencies = [ + "trackable_derive", +] + +[[package]] +name = "trackable_derive" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebeb235c5847e2f82cfe0f07eb971d1e5f6804b18dac2ae16349cc604380f82f" +dependencies = [ + "quote", + "syn 1.0.109", +] + [[package]] name = "tree_hash" version = "0.8.0" @@ -4952,7 +6076,7 @@ checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" [[package]] name = "types" version = "0.2.1" -source = "git+https://github.com/sigp/lighthouse?branch=anchor#73743a53d1255f342a928092f801013662d2a5bf" +source = "git+https://github.com/sigp/lighthouse?branch=unstable#e31ac508d404700c35d99936028a5fd74749c335" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -4976,7 +6100,7 @@ dependencies = [ "merkle_proof", "metastruct", "milhouse", - "parking_lot", + "parking_lot 0.12.3", "rand", "rand_xorshift", "rayon", @@ -5016,6 +6140,18 @@ dependencies = [ "static_assertions", ] +[[package]] +name = "uint" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "909988d098b2f738727b161a106cfc7cab00c539c2687a8836f8e565976fb53e" +dependencies = [ + "byteorder", + "crunchy", + "hex", + "static_assertions", +] + [[package]] name = "unarray" version = "0.1.4" @@ -5082,6 +6218,11 @@ name = "unsigned-varint" version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eb066959b24b5196ae73cb057f45598450d2c5f71460e98c49b738086eff9c06" +dependencies = [ + "asynchronous-codec", + "bytes", + "tokio-util", +] [[package]] name = "untrusted" @@ -5095,6 +6236,15 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" +[[package]] +name = "unused_port" +version = "0.1.0" +source = "git+https://github.com/sigp/lighthouse?branch=unstable#e31ac508d404700c35d99936028a5fd74749c335" +dependencies = [ + "lru_cache", + "parking_lot 0.12.3", +] + [[package]] name = "url" version = "2.5.2" @@ -5130,6 +6280,15 @@ version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" +[[package]] +name = "version" +version = "0.1.0" +dependencies = [ + "git-version", + "regex", + "target_info", +] + [[package]] name = "version_check" version = "0.9.5" @@ -5192,6 +6351,18 @@ dependencies = [ "wasm-bindgen-shared", ] +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc7ec4f8827a71586374db3e87abdb5a2bb3a15afed140221307c3ec06b1f63b" +dependencies = [ + "cfg-if", + "js-sys", + "wasm-bindgen", + "web-sys", +] + [[package]] name = "wasm-bindgen-macro" version = "0.2.95" @@ -5221,6 +6392,19 @@ version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "65fc09f10666a9f147042251e0dda9c18f166ff7de300607007e96bdebc1068d" +[[package]] +name = "wasm-streams" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e072d4e72f700fb3443d8fe94a39315df013eef1104903cdb0a2abd322bbecd" +dependencies = [ + "futures-util", + "js-sys", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", +] + [[package]] name = "web-sys" version = "0.3.72" @@ -5241,6 +6425,18 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "webpki-roots" +version = "0.25.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f20c57d8d7db6d3b86154206ae5d8fba62dd39573114de97c2cb0578251f8e1" + +[[package]] +name = "widestring" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c168940144dd21fd8046987c16a46a33d5fc84eec29ef9dcddc2ac9e31526b7c" + [[package]] name = "widestring" version = "1.1.0" @@ -5279,6 +6475,18 @@ dependencies = [ "windows-targets 0.48.5", ] +[[package]] +name = "windows-acl" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "177b1723986bcb4c606058e77f6e8614b51c7f9ad2face6f6fd63dd5c8b3cec3" +dependencies = [ + "field-offset", + "libc", + "widestring 0.4.3", + "winapi", +] + [[package]] name = "windows-core" version = "0.51.1" @@ -5517,7 +6725,7 @@ dependencies = [ "futures", "log", "nohash-hasher", - "parking_lot", + "parking_lot 0.12.3", "pin-project", "rand", "static_assertions", @@ -5532,7 +6740,7 @@ dependencies = [ "futures", "log", "nohash-hasher", - "parking_lot", + "parking_lot 0.12.3", "pin-project", "rand", "static_assertions", @@ -5588,3 +6796,52 @@ dependencies = [ "quote", "syn 2.0.79", ] + +[[package]] +name = "zip" +version = "0.6.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "760394e246e4c28189f19d488c058bf16f564016aefac5d32bb1f3b51d5e9261" +dependencies = [ + "aes", + "byteorder", + "bzip2", + "constant_time_eq", + "crc32fast", + "crossbeam-utils", + "flate2", + "hmac 0.12.1", + "pbkdf2", + "sha1", + "time", + "zstd", +] + +[[package]] +name = "zstd" +version = "0.11.2+zstd.1.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20cc960326ece64f010d2d2107537f26dc589a6573a316bd5b1dba685fa5fde4" +dependencies = [ + "zstd-safe", +] + +[[package]] +name = "zstd-safe" +version = "5.0.2+zstd.1.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d2a5585e04f9eea4b2a3d1eca508c4dee9592a89ef6f450c11719da0726f4db" +dependencies = [ + "libc", + "zstd-sys", +] + +[[package]] +name = "zstd-sys" +version = "2.0.13+zstd.1.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38ff0f21cfee8f97d94cef41359e0c89aa6113028ab0291aa8ca0038995a95aa" +dependencies = [ + "cc", + "pkg-config", +] diff --git a/Cargo.toml b/Cargo.toml index bc6eb13..3b52ffb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [workspace] # Extra tooling projects will be added. -members = ["anchor", "anchor/client", "anchor/http_api", "anchor/qbft", "anchor/p2p_network"] +members = ["anchor", "anchor/client", "anchor/http_api", "anchor/qbft", "anchor/network", "anchor/common/version"] resolver = "2" [workspace.package] @@ -10,19 +10,23 @@ edition = "2021" client = { path = "anchor/client" } qbft = { path = "anchor/qbft" } http_api = { path = "anchor/http_api" } -task_executor = { git = "https://github.com/sigp/lighthouse", branch = "anchor", default-features = false, features = [ +network = { path ="anchor/network"} +version = { path ="anchor/common/version"} +lighthouse_network = { git = "https://github.com/sigp/lighthouse", branch = "unstable"} +task_executor = { git = "https://github.com/sigp/lighthouse", branch = "unstable", default-features = false, features = [ "tracing", ] } -sensitive_url = { git = "https://github.com/sigp/lighthouse", branch = "anchor" } -slot_clock = { git = "https://github.com/sigp/lighthouse", branch = "anchor" } +sensitive_url = { git = "https://github.com/sigp/lighthouse", branch = "unstable" } +slot_clock = { git = "https://github.com/sigp/lighthouse", branch = "unstable" } +unused_port = { git = "https://github.com/sigp/lighthouse", branch = "unstable" } derive_more = { version = "1.0.0", features = ["full"] } async-channel = "1.9" axum = "0.7.7" clap = { version = "4.5.15", features = ["derive", "wrap_help"]} +discv5 = "0.8.0" dirs = "5.0.1" either = "1.13.0" futures = "0.3.30" -# dirs = "3" hyper = "1.4" serde = { version = "1.0.208", features = ["derive"] } strum = { version = "0.24", features = ["derive"] } diff --git a/anchor/client/Cargo.toml b/anchor/client/Cargo.toml index 0a6aa32..5fac91c 100644 --- a/anchor/client/Cargo.toml +++ b/anchor/client/Cargo.toml @@ -11,6 +11,7 @@ path = "src/lib.rs" [dependencies] task_executor = { workspace = true } http_api = { workspace = true } +version = { workspace = true } clap = { workspace = true } serde = { workspace = true } strum = { workspace = true } @@ -18,12 +19,8 @@ sensitive_url = { workspace = true } dirs = { workspace = true } hyper = { workspace = true } tracing = { workspace = true } +network = { workspace = true } +unused_port = { workspace = true } # Local dependencies fdlimit = "0.3" ethereum_hashing = "0.7.0" -git-version = "0.3.9" -target_info = "0.1.0" - -[dev-dependencies] -regex = "1.11" - diff --git a/anchor/client/src/cli.rs b/anchor/client/src/cli.rs index cad3677..2677431 100644 --- a/anchor/client/src/cli.rs +++ b/anchor/client/src/cli.rs @@ -4,11 +4,11 @@ use clap::{Parser, ValueEnum}; use serde::{Deserialize, Serialize}; use strum::Display; // use clap_utils::{get_color_style, FLAG_HEADER}; -use crate::version::VERSION; use ethereum_hashing::have_sha_extensions; use std::net::IpAddr; use std::path::PathBuf; use std::sync::LazyLock; +use version::VERSION; pub static SHORT_VERSION: LazyLock = LazyLock::new(|| VERSION.replace("Anchor/", "")); pub static LONG_VERSION: LazyLock = LazyLock::new(|| { @@ -210,6 +210,40 @@ pub struct Anchor { )] pub http_allow_origin: Option, + /* Network related arguments */ + #[clap( + long, + value_name = "ADDRESS", + help = "The address anchor will listen for UDP and TCP connections. To listen \ + over IpV4 and IpV6 set this flag twice with the different values.\n\ + Examples:\n\ + - --listen-address '0.0.0.0' will listen over IPv4.\n\ + - --listen-address '::' will listen over IPv6.\n\ + - --listen-address '0.0.0.0' --listen-address '::' will listen over both \ + IPv4 and IPv6. The order of the given addresses is not relevant. However, \ + multiple IPv4, or multiple IPv6 addresses will not be accepted.", + num_args(0..2), + default_value = "0.0.0.0", + )] + pub listen_addresses: Vec, + + // TODO: finish CLI + #[clap(skip)] + pub port: u16, + #[clap(skip)] + pub port6: Option, + #[clap(skip)] + pub discovery_port: Option, + #[clap(skip)] + pub discovery_port6: Option, + #[clap(skip)] + pub quic_port: Option, + #[clap(skip)] + pub quic_port6: Option, + // TODO: make it hidden + #[clap(skip)] + pub use_zero_ports: bool, + /* Prometheus metrics HTTP server related arguments */ #[clap( long, @@ -237,7 +271,7 @@ pub struct Anchor { default_value_if("metrics", ArgPredicate::IsPresent, "5064"), requires = "metrics" )] - pub metrics_port: u16, + pub metrics_port: Option, #[clap( long, diff --git a/anchor/client/src/config.rs b/anchor/client/src/config.rs index 92f5e5b..a73b6d2 100644 --- a/anchor/client/src/config.rs +++ b/anchor/client/src/config.rs @@ -1,12 +1,14 @@ // use crate::{http_api, http_metrics}; // use clap_utils::{flags::DISABLE_MALLOC_TUNING_FLAG, parse_optional, parse_required}; +use crate::cli::Anchor; +use network::{ListenAddr, ListenAddress}; use sensitive_url::SensitiveUrl; use serde::{Deserialize, Serialize}; use std::fs; +use std::net::IpAddr; use std::path::PathBuf; - -use crate::cli::Anchor; +use tracing::warn; pub const DEFAULT_BEACON_NODE: &str = "http://localhost:5052/"; pub const DEFAULT_EXECUTION_NODE: &str = "http://localhost:8545/"; @@ -34,6 +36,8 @@ pub struct Config { pub allow_unsynced_beacon_node: bool, /// Configuration for the HTTP REST API. pub http_api: http_api::Config, + /// Configuration for the network stack. + pub network: network::Config, /// Configuration for the HTTP REST API. // TODO: // pub http_metrics: http_metrics::Config, @@ -68,6 +72,7 @@ impl Default for Config { allow_unsynced_beacon_node: false, http_api: <_>::default(), // http_metrics: <_>::default(), + network: <_>::default(), beacon_nodes_tls_certs: None, execution_nodes_tls_certs: None, } @@ -119,6 +124,11 @@ pub fn from_cli(cli_args: &Anchor) -> Result { .map_err(|e| format!("Unable to parse execution node URL: {:?}", e))?; } + /* + * Network related + */ + config.network.listen_addresses = parse_listening_addresses(cli_args)?; + config.beacon_nodes_tls_certs = cli_args.beacon_nodes_tls_certs.clone(); config.execution_nodes_tls_certs = cli_args.execution_nodes_tls_certs.clone(); @@ -190,6 +200,182 @@ pub fn from_cli(cli_args: &Anchor) -> Result { Ok(config) } +/// Gets the listening_addresses for lighthouse based on the cli options. +pub fn parse_listening_addresses(cli_args: &Anchor) -> Result { + // parse the possible ips + let mut maybe_ipv4 = None; + let mut maybe_ipv6 = None; + for addr in cli_args.listen_addresses.iter() { + match addr { + IpAddr::V4(v4_addr) => match &maybe_ipv4 { + Some(first_ipv4_addr) => { + return Err(format!( + "When setting the --listen-address option twice, use an IpV4 address and an Ipv6 address. \ + Got two IpV4 addresses {first_ipv4_addr} and {v4_addr}" + )); + } + None => maybe_ipv4 = Some(v4_addr), + }, + IpAddr::V6(v6_addr) => match &maybe_ipv6 { + Some(first_ipv6_addr) => { + return Err(format!( + "When setting the --listen-address option twice, use an IpV4 address and an Ipv6 address. \ + Got two IpV6 addresses {first_ipv6_addr} and {v6_addr}" + )); + } + None => maybe_ipv6 = Some(v6_addr), + }, + } + } + + // Now put everything together + let listening_addresses = match (maybe_ipv4, maybe_ipv6) { + (None, None) => { + // This should never happen unless clap is broken + return Err("No listening addresses provided".into()); + } + (None, Some(ipv6)) => { + // A single ipv6 address was provided. Set the ports + if cli_args.port6.is_some() { + warn!("When listening only over IPv6, use the --port flag. The value of --port6 will be ignored."); + } + + if cli_args.discovery_port6.is_some() { + warn!("When listening only over IPv6, use the --discovery-port flag. The value of --discovery-port6 will be ignored.") + } + + if cli_args.quic_port6.is_some() { + warn!("When listening only over IPv6, use the --quic-port flag. The value of --quic-port6 will be ignored.") + } + + // use zero ports if required. If not, use the given port. + let tcp_port = cli_args + .use_zero_ports + .then(unused_port::unused_tcp6_port) + .transpose()? + .unwrap_or(cli_args.port); + + // use zero ports if required. If not, use the specific udp port. If none given, use + // the tcp port. + let disc_port = cli_args + .use_zero_ports + .then(unused_port::unused_udp6_port) + .transpose()? + .or(cli_args.discovery_port) + .unwrap_or(tcp_port); + + let quic_port = cli_args + .use_zero_ports + .then(unused_port::unused_udp6_port) + .transpose()? + .or(cli_args.quic_port) + .unwrap_or(if tcp_port == 0 { 0 } else { tcp_port + 1 }); + + ListenAddress::V6(ListenAddr { + addr: *ipv6, + quic_port, + disc_port, + tcp_port, + }) + } + (Some(ipv4), None) => { + // A single ipv4 address was provided. Set the ports + + // use zero ports if required. If not, use the given port. + let tcp_port = cli_args + .use_zero_ports + .then(unused_port::unused_tcp4_port) + .transpose()? + .unwrap_or(cli_args.port); + // use zero ports if required. If not, use the specific discovery port. If none given, use + // the tcp port. + let disc_port = cli_args + .use_zero_ports + .then(unused_port::unused_udp4_port) + .transpose()? + .or(cli_args.discovery_port) + .unwrap_or(tcp_port); + // use zero ports if required. If not, use the specific quic port. If none given, use + // the tcp port + 1. + let quic_port = cli_args + .use_zero_ports + .then(unused_port::unused_udp4_port) + .transpose()? + .or(cli_args.quic_port) + .unwrap_or(if tcp_port == 0 { 0 } else { tcp_port + 1 }); + + ListenAddress::V4(ListenAddr { + addr: *ipv4, + disc_port, + quic_port, + tcp_port, + }) + } + (Some(ipv4), Some(ipv6)) => { + let ipv4_tcp_port = cli_args + .use_zero_ports + .then(unused_port::unused_tcp4_port) + .transpose()? + .unwrap_or(cli_args.port); + let ipv4_disc_port = cli_args + .use_zero_ports + .then(unused_port::unused_udp4_port) + .transpose()? + .or(cli_args.discovery_port) + .unwrap_or(ipv4_tcp_port); + let ipv4_quic_port = cli_args + .use_zero_ports + .then(unused_port::unused_udp4_port) + .transpose()? + .or(cli_args.quic_port) + .unwrap_or(if ipv4_tcp_port == 0 { + 0 + } else { + ipv4_tcp_port + 1 + }); + + let ipv6_tcp_port = cli_args + .use_zero_ports + .then(unused_port::unused_tcp6_port) + .transpose()? + .unwrap_or(cli_args.port); + let ipv6_disc_port = cli_args + .use_zero_ports + .then(unused_port::unused_udp6_port) + .transpose()? + .or(cli_args.discovery_port6) + .unwrap_or(ipv6_tcp_port); + let ipv6_quic_port = cli_args + .use_zero_ports + .then(unused_port::unused_udp6_port) + .transpose()? + .or(cli_args.quic_port6) + .unwrap_or(if ipv6_tcp_port == 0 { + 0 + } else { + ipv6_tcp_port + 1 + }); + + ListenAddress::DualStack( + ListenAddr { + addr: *ipv4, + disc_port: ipv4_disc_port, + quic_port: ipv4_quic_port, + tcp_port: ipv4_tcp_port, + }, + ListenAddr { + addr: *ipv6, + disc_port: ipv6_disc_port, + quic_port: ipv6_quic_port, + tcp_port: ipv6_tcp_port, + }, + ) + } + }; + + Ok(listening_addresses) +} + #[cfg(test)] mod tests { use super::*; diff --git a/anchor/client/src/lib.rs b/anchor/client/src/lib.rs index cbc9d27..063b5d0 100644 --- a/anchor/client/src/lib.rs +++ b/anchor/client/src/lib.rs @@ -2,10 +2,10 @@ mod cli; pub mod config; -mod version; pub use cli::Anchor; use config::Config; +use network::Network; use task_executor::TaskExecutor; use tracing::{debug, error, info}; @@ -13,7 +13,7 @@ pub struct Client {} impl Client { /// Runs the Anchor Client - pub async fn run(_executor: TaskExecutor, config: Config) -> Result<(), String> { + pub async fn run(executor: TaskExecutor, config: Config) -> Result<(), String> { // Attempt to raise soft fd limit. The behavior is OS specific: // `linux` - raise soft fd limit to hard // `macos` - raise soft fd limit to `min(kernel limit, hard fd limit)` @@ -76,6 +76,10 @@ impl Client { error!(error, "Failed to run HTTP API"); return Err("HTTP API Failed".to_string()); } + + info!("Starting the network service"); + Network::spawn(executor, &config.network); + Ok(()) } } diff --git a/anchor/common/version/Cargo.toml b/anchor/common/version/Cargo.toml new file mode 100644 index 0000000..a893e3c --- /dev/null +++ b/anchor/common/version/Cargo.toml @@ -0,0 +1,11 @@ +[package] +name = "version" +version = "0.1.0" +edition = "2021" + +[dependencies] +git-version = "0.3.9" +target_info = "0.1.0" + +[dev-dependencies] +regex = "1.11" \ No newline at end of file diff --git a/anchor/client/src/version.rs b/anchor/common/version/src/lib.rs similarity index 100% rename from anchor/client/src/version.rs rename to anchor/common/version/src/lib.rs diff --git a/anchor/p2p_network/Cargo.toml b/anchor/network/Cargo.toml similarity index 68% rename from anchor/p2p_network/Cargo.toml rename to anchor/network/Cargo.toml index 9968fd1..73801a6 100644 --- a/anchor/p2p_network/Cargo.toml +++ b/anchor/network/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "p2p_network" +name = "network" version = "0.1.0" edition = { workspace = true } authors = ["Sigma Prime "] @@ -9,6 +9,12 @@ tokio = { workspace = true } libp2p = { version = "0.54", default-features = false, features = ["identify", "yamux", "noise", "secp256k1", "tcp", "tokio", "macros", "gossipsub", "quic", "ping"] } futures = { workspace = true } task_executor = { workspace = true } +version = { workspace = true } +lighthouse_network = { workspace = true} +discv5 = { workspace = true } +dirs = { workspace = true } +serde = { workspace = true } +tracing = { workspace = true } [dev-dependencies] async-channel = { workspace = true } \ No newline at end of file diff --git a/anchor/p2p_network/src/behaviour.rs b/anchor/network/src/behaviour.rs similarity index 90% rename from anchor/p2p_network/src/behaviour.rs rename to anchor/network/src/behaviour.rs index f013bc2..23e88fe 100644 --- a/anchor/p2p_network/src/behaviour.rs +++ b/anchor/network/src/behaviour.rs @@ -2,7 +2,7 @@ use libp2p::swarm::NetworkBehaviour; use libp2p::{identify, ping}; #[derive(NetworkBehaviour)] -pub(crate) struct AnchorBehaviour { +pub struct AnchorBehaviour { /// Provides IP addresses and peer information. pub identify: identify::Behaviour, /// Used for connection health checks. diff --git a/anchor/network/src/config.rs b/anchor/network/src/config.rs new file mode 100644 index 0000000..921c663 --- /dev/null +++ b/anchor/network/src/config.rs @@ -0,0 +1,101 @@ +use discv5::Enr; +use libp2p::Multiaddr; +use lighthouse_network::types::GossipKind; +use lighthouse_network::{ListenAddr, ListenAddress}; +use serde::{Deserialize, Serialize}; +use std::net::{Ipv4Addr, Ipv6Addr}; +use std::num::NonZeroU16; +use std::path::PathBuf; + +/// This is a default network directory, but it will be overridden by the cli defaults. +const DEFAULT_NETWORK_DIR: &str = ".anchor/network"; + +pub const DEFAULT_IPV4_ADDRESS: Ipv4Addr = Ipv4Addr::UNSPECIFIED; +pub const DEFAULT_TCP_PORT: u16 = 9100u16; +pub const DEFAULT_DISC_PORT: u16 = 9100u16; +pub const DEFAULT_QUIC_PORT: u16 = 9101u16; + +/// Configuration for setting up the p2p network. +#[derive(Clone, Serialize, Deserialize)] +pub struct Config { + /// Data directory where node's keyfile is stored + pub network_dir: PathBuf, + + /// IP addresses to listen on. + pub listen_addresses: ListenAddress, + + /// The address to broadcast to peers about which address we are listening on. None indicates + /// that no discovery address has been set in the CLI args. + pub enr_address: (Option, Option), + + /// The udp ipv4 port to broadcast to peers in order to reach back for discovery. + pub enr_udp4_port: Option, + + /// The quic ipv4 port to broadcast to peers in order to reach back for libp2p services. + pub enr_quic4_port: Option, + + /// The tcp ipv4 port to broadcast to peers in order to reach back for libp2p services. + pub enr_tcp4_port: Option, + + /// The udp ipv6 port to broadcast to peers in order to reach back for discovery. + pub enr_udp6_port: Option, + + /// The tcp ipv6 port to broadcast to peers in order to reach back for libp2p services. + pub enr_tcp6_port: Option, + + /// The quic ipv6 port to broadcast to peers in order to reach back for libp2p services. + pub enr_quic6_port: Option, + + /// List of nodes to initially connect to. + pub boot_nodes_enr: Vec, + + /// List of nodes to initially connect to, on Multiaddr format. + pub boot_nodes_multiaddr: Vec, + + /// Disables peer scoring altogether. + pub disable_peer_scoring: bool, + + /// Disables quic support. + pub disable_quic_support: bool, + + /// List of extra topics to initially subscribe to as strings. + pub topics: Vec, + + /// Target number of connected peers. + pub target_peers: usize, +} + +impl Default for Config { + fn default() -> Self { + // WARNING: this directory default should be always overwritten with parameters + // from cli for specific networks. + let network_dir = dirs::home_dir() + .unwrap_or_else(|| PathBuf::from(".")) + .join(DEFAULT_NETWORK_DIR); + + let listen_addresses = ListenAddress::V4(ListenAddr { + addr: DEFAULT_IPV4_ADDRESS, + disc_port: DEFAULT_DISC_PORT, + quic_port: DEFAULT_QUIC_PORT, + tcp_port: DEFAULT_TCP_PORT, + }); + + Self { + network_dir, + listen_addresses, + enr_address: (None, None), + enr_udp4_port: None, + enr_quic4_port: None, + enr_tcp4_port: None, + enr_udp6_port: None, + enr_tcp6_port: None, + enr_quic6_port: None, + target_peers: 50, + boot_nodes_enr: vec![], + boot_nodes_multiaddr: vec![], + disable_peer_scoring: false, + disable_quic_support: false, + topics: vec![], + } + } +} diff --git a/anchor/network/src/lib.rs b/anchor/network/src/lib.rs new file mode 100644 index 0000000..bd37a11 --- /dev/null +++ b/anchor/network/src/lib.rs @@ -0,0 +1,11 @@ +#![allow(dead_code)] + +mod behaviour; +mod config; +mod network; +mod transport; +mod types; + +pub use config::Config; +pub use lighthouse_network::{ListenAddr, ListenAddress}; +pub use network::Network; diff --git a/anchor/network/src/network.rs b/anchor/network/src/network.rs new file mode 100644 index 0000000..7c6b66b --- /dev/null +++ b/anchor/network/src/network.rs @@ -0,0 +1,184 @@ +use crate::behaviour::AnchorBehaviour; +use crate::transport::build_transport; +use crate::Config; +use futures::{SinkExt, StreamExt}; +use libp2p::core::muxing::StreamMuxerBox; +use libp2p::core::transport::Boxed; +use libp2p::identity::{secp256k1, Keypair}; +use libp2p::multiaddr::Protocol; +use libp2p::{futures, identify, ping, PeerId, Swarm, SwarmBuilder}; +use std::num::{NonZeroU8, NonZeroUsize}; +use std::pin::Pin; +use task_executor::{ShutdownReason, TaskExecutor}; +use tracing::{error, info}; + +pub struct Network { + swarm: Swarm, + peer_id: PeerId, +} + +impl Network { + pub fn spawn(executor: TaskExecutor, config: &Config) { + // TODO: generate / load local key + let secp256k1_kp: secp256k1::Keypair = secp256k1::SecretKey::generate().into(); + let local_keypair: Keypair = secp256k1_kp.into(); + + let transport = build_transport(local_keypair.clone(), !config.disable_quic_support); + let behaviour = build_anchor_behaviour(local_keypair.clone()); + let peer_id = local_keypair.public().to_peer_id(); + + let network = Network { + swarm: build_swarm( + executor.clone(), + local_keypair, + transport, + behaviour, + config, + ), + peer_id, + }; + + executor.spawn(network.start(config.clone(), executor.clone()), "network"); + // TODO: this function should return input & output channels + } + + async fn start(mut self, config: Config, executor: TaskExecutor) { + info!("Network starting"); + + for listen_multiaddr in config.listen_addresses.libp2p_addresses() { + // If QUIC is disabled, ignore listening on QUIC ports + if config.disable_quic_support && listen_multiaddr.iter().any(|v| v == Protocol::QuicV1) + { + continue; + } + + match self.swarm.listen_on(listen_multiaddr.clone()) { + Ok(_) => { + let mut log_address = listen_multiaddr; + log_address.push(Protocol::P2p(self.peer_id)); + info!(address = %log_address, "Listening established"); + } + Err(err) => { + error!( + %listen_multiaddr, + error = ?err, + "Unable to listen on libp2p address" + ); + let _ = executor + .shutdown_sender() + .send(ShutdownReason::Failure( + "Unable to listen on libp2p address", + )) + .await; + return; + } + }; + } + /* + TODO + - Dial peers + - Subscribe gossip topics + */ + + self.run().await; + } + + /// Main loop for polling and handling swarm and channels. + async fn run(mut self) { + loop { + tokio::select! { + _swarm_message = self.swarm.select_next_some() => { + // TODO handle and match swarm messages + } + // TODO match input channels + } + } + } +} + +fn build_anchor_behaviour(local_keypair: Keypair) -> AnchorBehaviour { + // setup gossipsub + // discv5 + let identify = { + let local_public_key = local_keypair.public(); + let identify_config = identify::Config::new("anchor".into(), local_public_key) + .with_agent_version(version::version_with_platform()) + .with_cache_size(0); + identify::Behaviour::new(identify_config) + }; + + AnchorBehaviour { + identify, + ping: ping::Behaviour::default(), + // gossipsub: gossipsub::Behaviour::default(), + } +} + +fn build_swarm( + executor: TaskExecutor, + local_keypair: Keypair, + transport: Boxed<(PeerId, StreamMuxerBox)>, + behaviour: AnchorBehaviour, + _config: &Config, +) -> Swarm { + // use the executor for libp2p + struct Executor(task_executor::TaskExecutor); + impl libp2p::swarm::Executor for Executor { + fn exec(&self, f: Pin + Send>>) { + self.0.spawn(f, "libp2p"); + } + } + + // TODO: revisit once peer manager is integrated + // let connection_limits = { + // let limits = libp2p::connection_limits::ConnectionLimits::default() + // .with_max_pending_incoming(Some(5)) + // .with_max_pending_outgoing(Some(16)) + // .with_max_established_incoming(Some( + // (config.target_peers as f32 + // * (1.0 + PEER_EXCESS_FACTOR - MIN_OUTBOUND_ONLY_FACTOR)) + // .ceil() as u32, + // )) + // .with_max_established_outgoing(Some( + // (config.target_peers as f32 * (1.0 + PEER_EXCESS_FACTOR)).ceil() as u32, + // )) + // .with_max_established(Some( + // (config.target_peers as f32 * (1.0 + PEER_EXCESS_FACTOR + PRIORITY_PEER_EXCESS)) + // .ceil() as u32, + // )) + // .with_max_established_per_peer(Some(1)); + // + // libp2p::connection_limits::Behaviour::new(limits) + // }; + + let swarm_config = libp2p::swarm::Config::with_executor(Executor(executor)) + .with_notify_handler_buffer_size(NonZeroUsize::new(7).expect("Not zero")) + .with_per_connection_event_buffer_size(4) + .with_dial_concurrency_factor(NonZeroU8::new(1).unwrap()); + + // TODO add metrics later + SwarmBuilder::with_existing_identity(local_keypair) + .with_tokio() + .with_other_transport(|_key| transport) + .expect("infalible") + .with_behaviour(|_| behaviour) + .expect("infalible") + .with_swarm_config(|_| swarm_config) + .build() +} + +#[cfg(test)] +mod test { + use crate::network::Network; + use crate::Config; + use task_executor::TaskExecutor; + + #[test] + fn create_network() { + let handle = tokio::runtime::Handle::current(); + let (_signal, exit) = async_channel::bounded(1); + let (shutdown_tx, _) = futures::channel::mpsc::channel(1); + let task_executor = TaskExecutor::new(handle, exit, shutdown_tx); + Network::spawn(task_executor, &Config::default()); + } +} diff --git a/anchor/p2p_network/src/transport.rs b/anchor/network/src/transport.rs similarity index 67% rename from anchor/p2p_network/src/transport.rs rename to anchor/network/src/transport.rs index 16e553b..496ecda 100644 --- a/anchor/p2p_network/src/transport.rs +++ b/anchor/network/src/transport.rs @@ -7,7 +7,10 @@ use std::time::Duration; /// The implementation supports TCP/IP, QUIC over UDP, noise as the encryption layer, and /// yamux as the multiplexing layer (when using TCP). -pub(crate) fn build_transport(local_private_key: Keypair) -> Boxed<(PeerId, StreamMuxerBox)> { +pub(crate) fn build_transport( + local_private_key: Keypair, + quic_support: bool, +) -> Boxed<(PeerId, StreamMuxerBox)> { let yamux_config = yamux::Config::default(); let tcp = tcp::tokio::Transport::new(tcp::Config::default().nodelay(true)) @@ -19,15 +22,18 @@ pub(crate) fn build_transport(local_private_key: Keypair) -> Boxed<(PeerId, Stre let quic_config = quic::Config::new(&local_private_key); let quic = quic::tokio::Transport::new(quic_config); - let transport = tcp - .or_transport(quic) - .map(|either_output, _| match either_output { - Either::Left((peer_id, muxer)) => (peer_id, StreamMuxerBox::new(muxer)), - Either::Right((peer_id, muxer)) => (peer_id, StreamMuxerBox::new(muxer)), - }); - // TODO: Do we need to enable DNS? - transport.boxed() + if quic_support { + let transport = tcp + .or_transport(quic) + .map(|either_output, _| match either_output { + Either::Left((peer_id, muxer)) => (peer_id, StreamMuxerBox::new(muxer)), + Either::Right((peer_id, muxer)) => (peer_id, StreamMuxerBox::new(muxer)), + }); + transport.boxed() + } else { + tcp.boxed() + } } /// Generate authenticated XX Noise config from identity keys diff --git a/anchor/network/src/types.rs b/anchor/network/src/types.rs new file mode 100644 index 0000000..7608df2 --- /dev/null +++ b/anchor/network/src/types.rs @@ -0,0 +1 @@ +mod gossip_kind; diff --git a/anchor/network/src/types/gossip_kind.rs b/anchor/network/src/types/gossip_kind.rs new file mode 100644 index 0000000..381c833 --- /dev/null +++ b/anchor/network/src/types/gossip_kind.rs @@ -0,0 +1,3 @@ +pub enum GossipKind { + SsvTopic, +} diff --git a/anchor/p2p_network/src/lib.rs b/anchor/p2p_network/src/lib.rs deleted file mode 100644 index 8cf90d1..0000000 --- a/anchor/p2p_network/src/lib.rs +++ /dev/null @@ -1,5 +0,0 @@ -#![allow(dead_code)] - -mod behaviour; -mod network; -mod transport; diff --git a/anchor/p2p_network/src/network.rs b/anchor/p2p_network/src/network.rs deleted file mode 100644 index fda5862..0000000 --- a/anchor/p2p_network/src/network.rs +++ /dev/null @@ -1,110 +0,0 @@ -use crate::behaviour::AnchorBehaviour; -use crate::transport::build_transport; -use libp2p::core::muxing::StreamMuxerBox; -use libp2p::core::transport::Boxed; -use libp2p::identity::{secp256k1, Keypair}; -use libp2p::{futures, identify, ping, PeerId, Swarm, SwarmBuilder}; -use std::num::{NonZeroU8, NonZeroUsize}; -use std::pin::Pin; -use task_executor::TaskExecutor; - -pub struct Network { - #[allow(dead_code)] - pub swarm: Swarm, -} - -#[derive(Debug)] -pub enum NetworkError {} - -impl Network { - async fn new(executor: TaskExecutor) -> Result { - // TODO: generate / load local key - let secp256k1_kp: secp256k1::Keypair = secp256k1::SecretKey::generate().into(); - let local_keypair: Keypair = secp256k1_kp.into(); - - let transport = build_transport(local_keypair.clone()); - let behaviour = build_anchor_behaviour(local_keypair.clone()); - let network = Network { - swarm: build_swarm(executor, local_keypair, transport, behaviour), - }; - network.start().await?; - - Ok(network) - } - - async fn start(&self) -> Result<(), NetworkError> { - /* - - Set up listening address - - Dial peers - - Subscribe gossip topics - */ - Ok(()) - } - - // implement `poll_network` from `self.swarm`. -} - -fn build_anchor_behaviour(local_keypair: Keypair) -> AnchorBehaviour { - // setup gossipsub - // discv5 - // TODO: update protocol and agent versions. - let identify = { - let local_public_key = local_keypair.public(); - let identify_config = identify::Config::new("ssv/1.0.0".into(), local_public_key) - .with_agent_version("0.0.1".to_string()) - .with_cache_size(0); - identify::Behaviour::new(identify_config) - }; - - AnchorBehaviour { - identify, - ping: ping::Behaviour::default(), - // gossipsub: gossipsub::Behaviour::default(), - } -} - -fn build_swarm( - executor: TaskExecutor, - local_keypair: Keypair, - transport: Boxed<(PeerId, StreamMuxerBox)>, - behaviour: AnchorBehaviour, -) -> Swarm { - // use the executor for libp2p - struct Executor(task_executor::TaskExecutor); - impl libp2p::swarm::Executor for Executor { - fn exec(&self, f: Pin + Send>>) { - self.0.spawn(f, "libp2p"); - } - } - - let swarm_config = libp2p::swarm::Config::with_executor(Executor(executor)) - .with_notify_handler_buffer_size(NonZeroUsize::new(7).expect("Not zero")) - .with_per_connection_event_buffer_size(4) - .with_dial_concurrency_factor(NonZeroU8::new(1).unwrap()); - - SwarmBuilder::with_existing_identity(local_keypair) - .with_tokio() - .with_other_transport(|_key| transport) - .expect("infalible") - .with_behaviour(|_| behaviour) - .expect("infalible") - .with_swarm_config(|_| swarm_config) - .build() -} - -#[cfg(test)] -mod test { - use crate::network::Network; - use task_executor::TaskExecutor; - - #[tokio::test] - async fn create_network() { - let handle = tokio::runtime::Handle::current(); - let (_signal, exit) = async_channel::bounded(1); - let (shutdown_tx, _) = futures::channel::mpsc::channel(1); - let task_executor = TaskExecutor::new(handle, exit, shutdown_tx); - let _network = Network::new(task_executor) - .await - .expect("network should start"); - } -} diff --git a/anchor/src/environment.rs b/anchor/src/environment.rs index ca216c8..0deb0ec 100644 --- a/anchor/src/environment.rs +++ b/anchor/src/environment.rs @@ -7,6 +7,7 @@ use std::sync::Arc; use task_executor::{ShutdownReason, TaskExecutor}; use tokio::runtime::{Builder as RuntimeBuilder, Runtime}; use tracing::{error, info, warn}; +use tracing_subscriber::EnvFilter; use { futures::Future, std::{pin::Pin, task::Context, task::Poll}, @@ -34,7 +35,13 @@ impl Default for Environment { /// If a more fine-grained executor is required, a more general function should be built. fn default() -> Self { // Default logging for the time being - tracing_subscriber::fmt::init(); + // tracing_subscriber::fmt::init(); + // FIXME: fix this + let env_filter = EnvFilter::new("debug"); + let _ = tracing_subscriber::fmt() + .compact() + .with_env_filter(env_filter) + .try_init(); // Create a multi-threaded task executor let runtime = match RuntimeBuilder::new_multi_thread().enable_all().build() {