diff --git a/Cargo.lock b/Cargo.lock index 88da896..f32c560 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -528,6 +528,12 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "349a06037c7bf932dd7e7d1f653678b2038b9ad46a74102f1fc7bd7872678cce" +[[package]] +name = "base16ct" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" + [[package]] name = "base64" version = "0.13.1" @@ -746,6 +752,15 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "771fe0050b883fcc3ea2359b1a96bcfbc090b7116eae7c3c512c7a083fdf23d3" +[[package]] +name = "bs58" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f5353f36341f7451062466f0b755b96ac3a9547e4d7f6b70d603fc721a7d7896" +dependencies = [ + "tinyvec", +] + [[package]] name = "buf_redux" version = "0.8.4" @@ -1159,6 +1174,18 @@ dependencies = [ "zeroize", ] +[[package]] +name = "crypto-bigint" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf4c2f4e1afd912bc40bfd6fed5d9dc1f288e0ba01bfcc835cc5bc3eb13efe15" +dependencies = [ + "generic-array", + "rand_core 0.6.4", + "subtle", + "zeroize", +] + [[package]] name = "crypto-common" version = "0.1.6" @@ -1399,7 +1426,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f1a467a65c5e759bce6e65eaf91cc29f466cdc57cb65777bd646872a8a1fd4de" dependencies = [ "const-oid", - "pem-rfc7468", + "pem-rfc7468 0.6.0", + "zeroize", +] + +[[package]] +name = "der" +version = "0.7.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c7ed52955ce76b1554f509074bb357d3fb8ac9b51288a65a3fd480d1dfba946" +dependencies = [ + "const-oid", + "pem-rfc7468 0.7.0", "zeroize", ] @@ -1511,6 +1549,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer 0.10.4", + "const-oid", "crypto-common", "subtle", ] @@ -1623,22 +1662,24 @@ version = "0.14.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "413301934810f597c1d19ca71c8710e99a3f1ba28a0d2ebc01551a2daeea3c5c" dependencies = [ - "der", - "elliptic-curve", - "rfc6979", + "der 0.6.1", + "elliptic-curve 0.12.3", + "rfc6979 0.3.1", "signature 1.6.4", ] [[package]] name = "ecdsa" -version = "0.15.1" +version = "0.16.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12844141594ad74185a926d030f3b605f6a903b4e3fec351f3ea338ac5b7637e" +checksum = "a4b1e0c257a9e9f25f90ff76d7a68360ed497ee519c8e428d1825ef0000799d4" dependencies = [ - "der", - "elliptic-curve", - "rfc6979", + "der 0.7.7", + "digest 0.10.7", + "elliptic-curve 0.13.5", + "rfc6979 0.4.0", "signature 2.0.0", + "spki 0.7.2", ] [[package]] @@ -1676,18 +1717,38 @@ version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e7bb888ab5300a19b8e5bceef25ac745ad065f3c9f7efc6de1b91958110891d3" dependencies = [ - "base16ct", - "crypto-bigint", - "der", + "base16ct 0.1.1", + "crypto-bigint 0.4.9", + "der 0.6.1", "digest 0.10.7", - "ff", + "ff 0.12.1", "generic-array", - "group", + "group 0.12.1", "hkdf", - "pem-rfc7468", - "pkcs8", + "pem-rfc7468 0.6.0", + "pkcs8 0.9.0", "rand_core 0.6.4", - "sec1", + "sec1 0.3.0", + "subtle", + "zeroize", +] + +[[package]] +name = "elliptic-curve" +version = "0.13.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "968405c8fdc9b3bf4df0a6638858cc0b52462836ab6b1c87377785dd09cf1c0b" +dependencies = [ + "base16ct 0.2.0", + "crypto-bigint 0.5.2", + "digest 0.10.7", + "ff 0.13.0", + "generic-array", + "group 0.13.0", + "pem-rfc7468 0.7.0", + "pkcs8 0.10.2", + "rand_core 0.6.4", + "sec1 0.7.3", "subtle", "zeroize", ] @@ -1708,7 +1769,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "26fa0a0be8915790626d5759eb51fe47435a8eac92c2f212bd2da9aa7f30ea56" dependencies = [ "base64 0.13.1", - "bs58", + "bs58 0.4.0", "bytes", "hex", "k256", @@ -1727,7 +1788,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "492a7e5fc2504d5fdce8e124d3e263b244a68b283cac67a69eda0cd43e0aebad" dependencies = [ "base64 0.13.1", - "bs58", + "bs58 0.4.0", "bytes", "ed25519-dalek", "hex", @@ -2022,7 +2083,7 @@ source = "git+https://github.com/ralexstokes//ethereum-consensus?rev=9b0ee0a8a45 dependencies = [ "async-stream", "blst", - "bs58", + "bs58 0.4.0", "enr 0.6.2", "hex", "integer-sqrt", @@ -2125,7 +2186,7 @@ dependencies = [ "arrayvec", "bytes", "chrono", - "elliptic-curve", + "elliptic-curve 0.12.3", "ethabi 18.0.0", "generic-array", "hex", @@ -2245,6 +2306,16 @@ dependencies = [ "subtle", ] +[[package]] +name = "ff" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" +dependencies = [ + "rand_core 0.6.4", + "subtle", +] + [[package]] name = "ffi-opaque" version = "2.0.1" @@ -2513,6 +2584,7 @@ checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ "typenum", "version_check", + "zeroize", ] [[package]] @@ -2619,7 +2691,18 @@ version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5dfbfb3a6cfbd390d5c9564ab283a0349b9b9fcd46a706c1eb10e0db70bfbac7" dependencies = [ - "ff", + "ff 0.12.1", + "rand_core 0.6.4", + "subtle", +] + +[[package]] +name = "group" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" +dependencies = [ + "ff 0.13.0", "rand_core 0.6.4", "subtle", ] @@ -2856,7 +2939,7 @@ version = "0.1.0" source = "git+https://github.com/ackintosh/lighthouse.git?rev=fe3bec9f46f4ec360cb4d231c9b0825d00674ef4#fe3bec9f46f4ec360cb4d231c9b0825d00674ef4" dependencies = [ "beacon_chain", - "bs58", + "bs58 0.4.0", "directory", "eth1", "eth2", @@ -3287,7 +3370,7 @@ checksum = "72c1e0b51e7ec0a97369623508396067a486bd0cbed95a2659a4b863d28cfc8b" dependencies = [ "cfg-if", "ecdsa 0.14.8", - "elliptic-curve", + "elliptic-curve 0.12.3", "sha2 0.10.7", "sha3 0.10.8", ] @@ -3398,7 +3481,7 @@ dependencies = [ "libp2p-identify", "libp2p-mdns 0.42.0", "libp2p-metrics", - "libp2p-mplex 0.38.0", + "libp2p-mplex", "libp2p-noise 0.41.0", "libp2p-plaintext", "libp2p-quic", @@ -3415,9 +3498,9 @@ dependencies = [ [[package]] name = "libp2p" -version = "0.51.3" +version = "0.52.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f210d259724eae82005b5c48078619b7745edb7b76de370b03f8ba59ea103097" +checksum = "38039ba2df4f3255842050845daef4a004cc1f26da03dbc645535088b51910ef" dependencies = [ "bytes", "futures", @@ -3426,42 +3509,39 @@ dependencies = [ "instant", "libp2p-allow-block-list", "libp2p-connection-limits", - "libp2p-core 0.39.2", - "libp2p-dns 0.39.0", - "libp2p-identity", - "libp2p-mdns 0.43.1", - "libp2p-mplex 0.39.0", - "libp2p-noise 0.42.2", - "libp2p-quic", - "libp2p-swarm 0.42.2", - "libp2p-tcp 0.39.0", - "libp2p-webrtc", - "libp2p-yamux 0.43.1", - "multiaddr 0.17.1", + "libp2p-core 0.40.0", + "libp2p-dns 0.40.0", + "libp2p-identity 0.2.2", + "libp2p-mdns 0.44.0", + "libp2p-noise 0.43.0", + "libp2p-swarm 0.43.2", + "libp2p-tcp 0.40.0", + "libp2p-yamux 0.44.0", + "multiaddr 0.18.0", "pin-project", ] [[package]] name = "libp2p-allow-block-list" -version = "0.1.1" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "510daa05efbc25184458db837f6f9a5143888f1caa742426d92e1833ddd38a50" +checksum = "55b46558c5c0bf99d3e2a1a38fd54ff5476ca66dd1737b12466a1824dd219311" dependencies = [ - "libp2p-core 0.39.2", - "libp2p-identity", - "libp2p-swarm 0.42.2", + "libp2p-core 0.40.0", + "libp2p-identity 0.2.2", + "libp2p-swarm 0.43.2", "void", ] [[package]] name = "libp2p-connection-limits" -version = "0.1.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4caa33f1d26ed664c4fe2cca81a08c8e07d4c1c04f2f4ac7655c2dd85467fda0" +checksum = "2f5107ad45cb20b2f6c3628c7b6014b996fcb13a88053f4569c872c6e30abf58" dependencies = [ - "libp2p-core 0.39.2", - "libp2p-identity", - "libp2p-swarm 0.42.2", + "libp2p-core 0.40.0", + "libp2p-identity 0.2.2", + "libp2p-swarm 0.43.2", "void", ] @@ -3472,7 +3552,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b1fff5bd889c82a0aec668f2045edd066f559d4e5c40354e5a4c77ac00caac38" dependencies = [ "asn1_der", - "bs58", + "bs58 0.4.0", "ed25519-dalek", "either", "fnv", @@ -3491,7 +3571,7 @@ dependencies = [ "prost", "prost-build", "rand 0.8.5", - "rw-stream-sink", + "rw-stream-sink 0.3.0", "sha2 0.10.7", "smallvec", "thiserror", @@ -3507,7 +3587,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6a8fcd392ff67af6cc3f03b1426c41f7f26b6b9aff2dc632c1c56dd649e571f" dependencies = [ "asn1_der", - "bs58", + "bs58 0.4.0", "ed25519-dalek", "either", "fnv", @@ -3526,8 +3606,8 @@ dependencies = [ "prost", "prost-build", "rand 0.8.5", - "rw-stream-sink", - "sec1", + "rw-stream-sink 0.3.0", + "sec1 0.3.0", "sha2 0.10.7", "smallvec", "thiserror", @@ -3547,7 +3627,7 @@ dependencies = [ "futures", "futures-timer", "instant", - "libp2p-identity", + "libp2p-identity 0.1.2", "log", "multiaddr 0.17.1", "multihash 0.17.0", @@ -3557,7 +3637,35 @@ dependencies = [ "pin-project", "quick-protobuf", "rand 0.8.5", - "rw-stream-sink", + "rw-stream-sink 0.3.0", + "smallvec", + "thiserror", + "unsigned-varint 0.7.1", + "void", +] + +[[package]] +name = "libp2p-core" +version = "0.40.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef7dd7b09e71aac9271c60031d0e558966cdb3253ba0308ab369bb2de80630d0" +dependencies = [ + "either", + "fnv", + "futures", + "futures-timer", + "instant", + "libp2p-identity 0.2.2", + "log", + "multiaddr 0.18.0", + "multihash 0.19.0", + "multistream-select 0.13.0", + "once_cell", + "parking_lot 0.12.1", + "pin-project", + "quick-protobuf", + "rand 0.8.5", + "rw-stream-sink 0.4.0", "smallvec", "thiserror", "unsigned-varint 0.7.1", @@ -3580,12 +3688,13 @@ dependencies = [ [[package]] name = "libp2p-dns" -version = "0.39.0" +version = "0.40.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "146ff7034daae62077c415c2376b8057368042df6ab95f5432ad5e88568b1554" +checksum = "fd4394c81c0c06d7b4a60f3face7e8e8a9b246840f98d2c80508d0721b032147" dependencies = [ "futures", - "libp2p-core 0.39.2", + "libp2p-core 0.40.0", + "libp2p-identity 0.2.2", "log", "parking_lot 0.12.1", "smallvec", @@ -3649,17 +3758,34 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9e2d584751cecb2aabaa56106be6be91338a60a0f4e420cf2af639204f596fc1" dependencies = [ - "asn1_der", - "bs58", + "bs58 0.4.0", "ed25519-dalek", - "libsecp256k1", "log", "multiaddr 0.17.1", "multihash 0.17.0", - "p256 0.12.0", "quick-protobuf", "rand 0.8.5", - "sec1", + "sha2 0.10.7", + "thiserror", + "zeroize", +] + +[[package]] +name = "libp2p-identity" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a38d6012784fe4cc14e6d443eb415b11fc7c456dc15d9f0d90d9b70bc7ac3ec1" +dependencies = [ + "asn1_der", + "bs58 0.5.0", + "ed25519-dalek", + "libsecp256k1", + "log", + "multihash 0.19.0", + "p256 0.13.2", + "quick-protobuf", + "rand 0.8.5", + "sec1 0.7.3", "sha2 0.10.7", "thiserror", "void", @@ -3688,20 +3814,20 @@ dependencies = [ [[package]] name = "libp2p-mdns" -version = "0.43.1" +version = "0.44.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19983e1f949f979a928f2c603de1cf180cc0dc23e4ac93a62651ccb18341460b" +checksum = "42a2567c305232f5ef54185e9604579a894fd0674819402bb0ac0246da82f52a" dependencies = [ "data-encoding", "futures", "if-watch", - "libp2p-core 0.39.2", - "libp2p-identity", - "libp2p-swarm 0.42.2", + "libp2p-core 0.40.0", + "libp2p-identity 0.2.2", + "libp2p-swarm 0.43.2", "log", "rand 0.8.5", "smallvec", - "socket2 0.4.9", + "socket2 0.5.3", "tokio", "trust-dns-proto", "void", @@ -3739,37 +3865,42 @@ dependencies = [ ] [[package]] -name = "libp2p-mplex" -version = "0.39.0" +name = "libp2p-noise" +version = "0.41.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d34780b514b159e6f3fd70ba3e72664ec89da28dca2d1e7856ee55e2c7031ba" +checksum = "a978cb57efe82e892ec6f348a536bfbd9fee677adbe5689d7a93ad3a9bffbf2e" dependencies = [ - "asynchronous-codec", "bytes", + "curve25519-dalek 3.2.0", "futures", - "libp2p-core 0.39.2", + "libp2p-core 0.38.0", "log", - "nohash-hasher", - "parking_lot 0.12.1", + "once_cell", + "prost", + "prost-build", "rand 0.8.5", - "smallvec", - "unsigned-varint 0.7.1", + "sha2 0.10.7", + "snow", + "static_assertions", + "thiserror", + "x25519-dalek 1.1.1", + "zeroize", ] [[package]] name = "libp2p-noise" -version = "0.41.0" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a978cb57efe82e892ec6f348a536bfbd9fee677adbe5689d7a93ad3a9bffbf2e" +checksum = "9c3673da89d29936bc6435bafc638e2f184180d554ce844db65915113f86ec5e" dependencies = [ "bytes", "curve25519-dalek 3.2.0", "futures", - "libp2p-core 0.38.0", + "libp2p-core 0.39.2", + "libp2p-identity 0.1.2", "log", "once_cell", - "prost", - "prost-build", + "quick-protobuf", "rand 0.8.5", "sha2 0.10.7", "snow", @@ -3781,16 +3912,18 @@ dependencies = [ [[package]] name = "libp2p-noise" -version = "0.42.2" +version = "0.43.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c3673da89d29936bc6435bafc638e2f184180d554ce844db65915113f86ec5e" +checksum = "87945db2b3f977af09b62b9aa0a5f3e4870995a577ecd845cdeba94cdf6bbca7" dependencies = [ "bytes", "curve25519-dalek 3.2.0", "futures", - "libp2p-core 0.39.2", - "libp2p-identity", + "libp2p-core 0.40.0", + "libp2p-identity 0.2.2", "log", + "multiaddr 0.18.0", + "multihash 0.19.0", "once_cell", "quick-protobuf", "rand 0.8.5", @@ -3830,7 +3963,7 @@ dependencies = [ "futures-timer", "if-watch", "libp2p-core 0.39.2", - "libp2p-identity", + "libp2p-identity 0.1.2", "libp2p-tls", "log", "parking_lot 0.12.1", @@ -3865,19 +3998,21 @@ dependencies = [ [[package]] name = "libp2p-swarm" -version = "0.42.2" +version = "0.43.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "903b3d592d7694e56204d211f29d31bc004be99386644ba8731fc3e3ef27b296" +checksum = "43106820057e0f65c77b01a3873593f66e676da4e40c70c3a809b239109f1d30" dependencies = [ "either", "fnv", "futures", "futures-timer", "instant", - "libp2p-core 0.39.2", - "libp2p-identity", - "libp2p-swarm-derive 0.32.0", + "libp2p-core 0.40.0", + "libp2p-identity 0.2.2", + "libp2p-swarm-derive 0.33.0", "log", + "multistream-select 0.13.0", + "once_cell", "rand 0.8.5", "smallvec", "tokio", @@ -3897,13 +4032,15 @@ dependencies = [ [[package]] name = "libp2p-swarm-derive" -version = "0.32.0" +version = "0.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fba456131824ab6acd4c7bf61e9c0f0a3014b5fc9868ccb8e10d344594cdc4f" +checksum = "c4d5ec2a3df00c7836d7696c136274c9c59705bac69133253696a6c932cd1d74" dependencies = [ "heck", + "proc-macro-warning", + "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.27", ] [[package]] @@ -3924,17 +4061,18 @@ dependencies = [ [[package]] name = "libp2p-tcp" -version = "0.39.0" +version = "0.40.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33d33698596d7722d85d3ab0c86c2c322254fce1241e91208e3679b4eb3026cf" +checksum = "09bfdfb6f945c5c014b87872a0bdb6e0aef90e92f380ef57cd9013f118f9289d" dependencies = [ "futures", "futures-timer", "if-watch", "libc", - "libp2p-core 0.39.2", + "libp2p-core 0.40.0", + "libp2p-identity 0.2.2", "log", - "socket2 0.4.9", + "socket2 0.5.3", "tokio", ] @@ -3947,7 +4085,7 @@ dependencies = [ "futures", "futures-rustls", "libp2p-core 0.39.2", - "libp2p-identity", + "libp2p-identity 0.1.2", "rcgen 0.10.0", "ring", "rustls 0.20.8", @@ -3971,7 +4109,7 @@ dependencies = [ "hex", "if-watch", "libp2p-core 0.39.2", - "libp2p-identity", + "libp2p-identity 0.1.2", "libp2p-noise 0.42.2", "log", "multihash 0.17.0", @@ -4001,7 +4139,7 @@ dependencies = [ "log", "parking_lot 0.12.1", "quicksink", - "rw-stream-sink", + "rw-stream-sink 0.3.0", "soketto", "url", "webpki-roots", @@ -4023,12 +4161,12 @@ dependencies = [ [[package]] name = "libp2p-yamux" -version = "0.43.1" +version = "0.44.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4dcd21d950662700a385d4c6d68e2f5f54d778e97068cdd718522222ef513bda" +checksum = "c0a9b42ab6de15c6f076d8fb11dc5f48d899a10b55a2e16b12be9012a05287b0" dependencies = [ "futures", - "libp2p-core 0.39.2", + "libp2p-core 0.40.0", "log", "thiserror", "yamux", @@ -4487,7 +4625,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c580bfdd8803cce319b047d239559a22f809094aaea4ac13902a1fdcfcd4261" dependencies = [ "arrayref", - "bs58", + "bs58 0.4.0", "byteorder", "data-encoding", "multihash 0.16.3", @@ -4535,6 +4673,25 @@ dependencies = [ "url", ] +[[package]] +name = "multiaddr" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92a651988b3ed3ad1bc8c87d016bb92f6f395b84ed1db9b926b32b1fc5a2c8b5" +dependencies = [ + "arrayref", + "byteorder", + "data-encoding", + "libp2p-identity 0.2.2", + "multibase", + "multihash 0.19.0", + "percent-encoding", + "serde", + "static_assertions", + "unsigned-varint 0.7.1", + "url", +] + [[package]] name = "multibase" version = "0.9.1" @@ -4572,6 +4729,16 @@ dependencies = [ "unsigned-varint 0.7.1", ] +[[package]] +name = "multihash" +version = "0.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2fd59dcc2bbe70baabeac52cd22ae52c55eefe6c38ff11a9439f16a350a939f2" +dependencies = [ + "core2", + "unsigned-varint 0.7.1", +] + [[package]] name = "multihash-derive" version = "0.8.1" @@ -4638,6 +4805,20 @@ dependencies = [ "unsigned-varint 0.7.1", ] +[[package]] +name = "multistream-select" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea0df8e5eec2298a62b326ee4f0d7fe1a6b90a09dfcf9df37b38f947a8c42f19" +dependencies = [ + "bytes", + "futures", + "log", + "pin-project", + "smallvec", + "unsigned-varint 0.7.1", +] + [[package]] name = "native-tls" version = "0.2.11" @@ -5079,18 +5260,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "51f44edd08f51e2ade572f141051021c5af22677e42b7dd28a88155151c33594" dependencies = [ "ecdsa 0.14.8", - "elliptic-curve", + "elliptic-curve 0.12.3", "sha2 0.10.7", ] [[package]] name = "p256" -version = "0.12.0" +version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49c124b3cbce43bcbac68c58ec181d98ed6cc7e6d0aa7c3ba97b2563410b0e55" +checksum = "c9863ad85fa8f4460f9c48cb909d38a0d689dba1f6f6988a5e3e0d31071bcd4b" dependencies = [ - "ecdsa 0.15.1", - "elliptic-curve", + "ecdsa 0.16.8", + "elliptic-curve 0.13.5", "primeorder", "sha2 0.10.7", ] @@ -5102,7 +5283,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dfc8c5bf642dde52bb9e87c0ecd8ca5a76faac2eeed98dedb7c717997e1080aa" dependencies = [ "ecdsa 0.14.8", - "elliptic-curve", + "elliptic-curve 0.12.3", "sha2 0.10.7", ] @@ -5287,6 +5468,15 @@ dependencies = [ "base64ct", ] +[[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.0" @@ -5347,8 +5537,18 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9eca2c590a5f85da82668fa685c09ce2888b9430e83299debf1f34b65fd4a4ba" dependencies = [ - "der", - "spki", + "der 0.6.1", + "spki 0.6.0", +] + +[[package]] +name = "pkcs8" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" +dependencies = [ + "der 0.7.7", + "spki 0.7.2", ] [[package]] @@ -5438,11 +5638,11 @@ dependencies = [ [[package]] name = "primeorder" -version = "0.12.1" +version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b54f7131b3dba65a2f414cf5bd25b66d4682e4608610668eae785750ba4c5b2" +checksum = "3c2fcef82c0ec6eefcc179b978446c399b3cdf73c392c35604e399eee6df1ee3" dependencies = [ - "elliptic-curve", + "elliptic-curve 0.13.5", ] [[package]] @@ -5512,6 +5712,17 @@ version = "0.5.20+deprecated" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc375e1527247fe1a97d8b7156678dfe7c1af2fc075c9a4db3690ecd2a148068" +[[package]] +name = "proc-macro-warning" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70550716265d1ec349c41f70dd4f964b4fd88394efe4405f0c1da679c4799a07" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.27", +] + [[package]] name = "proc-macro2" version = "1.0.66" @@ -5871,7 +6082,7 @@ dependencies = [ "ethereum_ssz_derive", "futures", "hex", - "libp2p 0.51.3", + "libp2p 0.52.1", "lighthouse_network", "lru 0.11.0", "network", @@ -6066,11 +6277,21 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7743f17af12fa0b03b803ba12cd6a8d9483a587e89c69445e3909655c0b9fabb" dependencies = [ - "crypto-bigint", + "crypto-bigint 0.4.9", "hmac 0.12.1", "zeroize", ] +[[package]] +name = "rfc6979" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2" +dependencies = [ + "hmac 0.12.1", + "subtle", +] + [[package]] name = "ring" version = "0.16.20" @@ -6291,6 +6512,17 @@ dependencies = [ "static_assertions", ] +[[package]] +name = "rw-stream-sink" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8c9026ff5d2f23da5e45bbc283f156383001bfb09c4e44256d02c1a685fe9a1" +dependencies = [ + "futures", + "pin-project", + "static_assertions", +] + [[package]] name = "ryu" version = "1.0.15" @@ -6421,10 +6653,24 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3be24c1842290c45df0a7bf069e0c268a747ad05a192f2fd7dcfdbc1cba40928" dependencies = [ - "base16ct", - "der", + "base16ct 0.1.1", + "der 0.6.1", "generic-array", - "pkcs8", + "pkcs8 0.9.0", + "subtle", + "zeroize", +] + +[[package]] +name = "sec1" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc" +dependencies = [ + "base16ct 0.2.0", + "der 0.7.7", + "generic-array", + "pkcs8 0.10.2", "subtle", "zeroize", ] @@ -6972,7 +7218,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "67cf02bbac7a337dc36e4f5a693db6c21e7863f45070f7064577eb4367a3212b" dependencies = [ "base64ct", - "der", + "der 0.6.1", +] + +[[package]] +name = "spki" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d1e996ef02c474957d681f1b05213dfb0abab947b446a62d37770b23500184a" +dependencies = [ + "base64ct", + "der 0.7.7", ] [[package]] @@ -8427,7 +8683,7 @@ dependencies = [ "ccm", "curve25519-dalek 3.2.0", "der-parser 8.2.0", - "elliptic-curve", + "elliptic-curve 0.12.3", "hkdf", "hmac 0.12.1", "log", @@ -8439,7 +8695,7 @@ dependencies = [ "rcgen 0.9.3", "ring", "rustls 0.19.1", - "sec1", + "sec1 0.3.0", "serde", "sha1", "sha2 0.10.7", diff --git a/Cargo.toml b/Cargo.toml index 0a4f97c..e27e937 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,8 +15,7 @@ delay_map = "0.3.0" discv5 = "0.2.2" futures = "0.3.28" hex = "0.4.3" -libp2p = { version = "0.51.0", default-features = false, features = ["dns", "tokio", "ecdsa", "noise", "macros", "mplex", "secp256k1", "tcp", "yamux"] } -#libp2p-identity = { version = "0.2.1", features = ["secp256k1"] } +libp2p = { version = "0.52.1", default-features = false, features = ["dns", "tokio", "ecdsa", "noise", "macros", "secp256k1", "tcp", "yamux"] } lru = "0.11.0" parking_lot = "0.12.1" primitive-types = "0.12.1" diff --git a/src/discovery/behaviour.rs b/src/discovery/behaviour.rs index 8253aa4..b4706b6 100644 --- a/src/discovery/behaviour.rs +++ b/src/discovery/behaviour.rs @@ -1,13 +1,13 @@ use crate::discovery::DiscoveryEvent; -use crate::identity::peer_id_to_node_id; use discv5::enr::{CombinedKey, NodeId}; use discv5::{Discv5, Discv5ConfigBuilder, Discv5Event, Enr, QueryError}; use futures::stream::FuturesUnordered; use futures::{Future, FutureExt, StreamExt}; +use libp2p::core::Endpoint; use libp2p::swarm::dummy::ConnectionHandler as DummyConnectionHandler; use libp2p::swarm::{ - ConnectionId, DialError, DialFailure, FromSwarm, NetworkBehaviour, PollParameters, - THandlerInEvent, THandlerOutEvent, ToSwarm, + ConnectionDenied, ConnectionId, DialError, DialFailure, FromSwarm, NetworkBehaviour, + PollParameters, THandler, THandlerInEvent, THandlerOutEvent, ToSwarm, }; use libp2p::{Multiaddr, PeerId}; use lru::LruCache; @@ -102,15 +102,13 @@ impl Behaviour { fn on_dial_failure(&self, peer_id: Option, dial_error: &DialError) { if let Some(peer_id) = peer_id { match dial_error { - DialError::Banned - | DialError::LocalPeerId { .. } + DialError::LocalPeerId { .. } | DialError::NoAddresses - | DialError::InvalidPeerId(_) | DialError::WrongPeerId { .. } | DialError::Denied { .. } | DialError::Transport(_) => { debug!("[{peer_id}] Marking peer disconnected in DHT. error: {dial_error}"); - match peer_id_to_node_id(&peer_id) { + match crate::identity::peer_id_to_node_id(&peer_id) { Ok(node_id) => { let _ = self.discv5.disconnect_node(&node_id); } @@ -121,9 +119,7 @@ impl Behaviour { } } } - DialError::Aborted - | DialError::ConnectionLimit(_) - | DialError::DialPeerConditionFalse(_) => {} + DialError::Aborted | DialError::DialPeerConditionFalse(_) => {} } } } @@ -132,70 +128,71 @@ impl Behaviour { // ************************************************ // *** Discovery is not a real NetworkBehaviour *** // ************************************************ -// SEE https://github.com/sigp/lighthouse/blob/73ec29c267f057e70e89856403060c4c35b5c0c8/beacon_node/eth2_libp2p/src/discovery/mod.rs#L911 +// A NetworkBehaviour represent a protocol's state across all peers and connections. +// SEE https://github.com/libp2p/rust-libp2p/releases/tag/libp2p-v0.52.0 // NetworkBehaviour defines "what" bytes to send on the network. // SEE https://docs.rs/libp2p/0.39.1/libp2p/tutorial/index.html#network-behaviour impl NetworkBehaviour for Behaviour { type ConnectionHandler = DummyConnectionHandler; - type OutEvent = DiscoveryEvent; + type ToSwarm = DiscoveryEvent; - fn new_handler(&mut self) -> Self::ConnectionHandler { - DummyConnectionHandler {} + fn handle_established_inbound_connection( + &mut self, + _connection_id: ConnectionId, + _peer: PeerId, + _local_addr: &Multiaddr, + _remote_addr: &Multiaddr, + ) -> Result, ConnectionDenied> { + Ok(DummyConnectionHandler) } - fn addresses_of_peer(&mut self, peer_id: &PeerId) -> Vec { - trace!("addresses_of_peer: peer_id: {}", peer_id); - - // First search the local cache. - if let Some(enr) = self.cached_enrs.get(peer_id) { - let multiaddr = crate::identity::enr_to_multiaddrs(enr); - trace!( - "addresses_of_peer: Found from the cached_enrs. peer_id: {}, multiaddr: {:?}", - peer_id, - multiaddr, - ); - return multiaddr; - } + fn handle_pending_outbound_connection( + &mut self, + _connection_id: ConnectionId, + maybe_peer: Option, + _addresses: &[Multiaddr], + _effective_role: Endpoint, + ) -> Result, ConnectionDenied> { + if let Some(peer_id) = maybe_peer { + trace!("[{peer_id}] handle_pending_outbound_connection"); + // First search the local cache. + if let Some(enr) = self.cached_enrs.get(&peer_id) { + let multiaddr = crate::identity::enr_to_multiaddrs(enr); + trace!("[{peer_id}] handle_pending_outbound_connection: Found from the cached_enrs. multiaddr: {multiaddr:?}"); + return Ok(multiaddr); + } - // Not in the local cache, look in the routing table. - match crate::identity::peer_id_to_node_id(peer_id) { - Ok(node_id) => match self.discv5.find_enr(&node_id) { - Some(enr) => { - let multiaddr = crate::identity::enr_to_multiaddrs(&enr); - trace!( - "addresses_of_peer: Found from the DHT. peer_id: {}, node_id: {}, multiaddr: {:?}", - peer_id, - node_id, - multiaddr, - ); - multiaddr - } - None => { - warn!( - "addresses_of_peer: No addresses found. peer_id: {}, node_id: {}", - peer_id, node_id, - ); - vec![] + // Not in the local cache, look in the routing table. + match crate::identity::peer_id_to_node_id(&peer_id) { + Ok(node_id) => match self.discv5.find_enr(&node_id) { + Some(enr) => { + let multiaddr = crate::identity::enr_to_multiaddrs(&enr); + trace!("[{peer_id}] handle_pending_outbound_connection: Found from the DHT. node_id: {node_id}, multiaddr: {multiaddr:?}"); + Ok(multiaddr) + } + None => { + warn!("[{peer_id}] handle_pending_outbound_connection: No addresses found. node_id: {node_id}"); + Ok(vec![]) + } + }, + Err(e) => { + warn!("[{peer_id}] handle_pending_outbound_connection: Failed to derive node_id from peer_id. error: {:?}", e); + Ok(vec![]) } - }, - Err(e) => { - warn!( - "addresses_of_peer: Failed to derive node_id from peer_id. error: {:?}, peer_id: {}", - e, - peer_id, - ); - vec![] } + } else { + Ok(vec![]) } } - fn on_connection_handler_event( + fn handle_established_outbound_connection( &mut self, - _peer_id: PeerId, _connection_id: ConnectionId, - _event: THandlerOutEvent, - ) { - // Nothing to do. + _peer: PeerId, + _addr: &Multiaddr, + _role_override: Endpoint, + ) -> Result, ConnectionDenied> { + Ok(DummyConnectionHandler) } fn on_swarm_event(&mut self, event: FromSwarm) { @@ -216,19 +213,29 @@ impl NetworkBehaviour for Behaviour { | FromSwarm::ExpiredListenAddr(_) | FromSwarm::ListenerError(_) | FromSwarm::ListenerClosed(_) - | FromSwarm::NewExternalAddr(_) - | FromSwarm::ExpiredExternalAddr(_) => { + | FromSwarm::NewExternalAddrCandidate(_) + | FromSwarm::ExternalAddrExpired(_) + | FromSwarm::ExternalAddrConfirmed(_) => { // Ignore events not relevant to discovery } } } + fn on_connection_handler_event( + &mut self, + _peer_id: PeerId, + _connection_id: ConnectionId, + _event: THandlerOutEvent, + ) { + // Nothing to do. + } + #[allow(clippy::single_match)] fn poll( &mut self, cx: &mut Context<'_>, _params: &mut impl PollParameters, - ) -> Poll>> { + ) -> Poll>> { trace!("poll"); if let Poll::Ready(Some(query_result)) = self.active_queries.poll_next_unpin(cx) { diff --git a/src/peer_manager/behaviour.rs b/src/peer_manager/behaviour.rs index 502a107..76eebff 100644 --- a/src/peer_manager/behaviour.rs +++ b/src/peer_manager/behaviour.rs @@ -17,7 +17,7 @@ use tracing::log::{error, trace}; // SEE https://github.com/sigp/lighthouse/blob/eee0260a68696db58e92385ebd11a9a08e4c4665/beacon_node/lighthouse_network/src/peer_manager/network_behaviour.rs#L21 impl NetworkBehaviour for PeerManager { type ConnectionHandler = DummyConnectionHandler; - type OutEvent = PeerManagerEvent; + type ToSwarm = PeerManagerEvent; fn handle_established_inbound_connection( &mut self, @@ -97,16 +97,24 @@ impl NetworkBehaviour for PeerManager { connection_closed.peer_id, connection_closed.endpoint ); } - FromSwarm::AddressChange(_) => {} - FromSwarm::DialFailure(_) => {} - FromSwarm::ListenFailure(_) => {} - FromSwarm::NewListener(_) => {} - FromSwarm::NewListenAddr(_) => {} - FromSwarm::ExpiredListenAddr(_) => {} - FromSwarm::ListenerError(_) => {} - FromSwarm::ListenerClosed(_) => {} - FromSwarm::NewExternalAddr(_) => {} - FromSwarm::ExpiredExternalAddr(_) => {} + FromSwarm::DialFailure(_) => { + // TODO: https://github.com/sigp/lighthouse/blob/ff9b09d9646b712b2fd9fe26feeed5758daa0aa6/beacon_node/lighthouse_network/src/peer_manager/network_behaviour.rs#L130 + } + FromSwarm::ExternalAddrConfirmed(_) => { + // TODO:https://github.com/sigp/lighthouse/blob/ff9b09d9646b712b2fd9fe26feeed5758daa0aa6/beacon_node/lighthouse_network/src/peer_manager/network_behaviour.rs#L138 + } + FromSwarm::AddressChange(_) + | FromSwarm::ListenFailure(_) + | FromSwarm::NewListener(_) + | FromSwarm::NewListenAddr(_) + | FromSwarm::ExpiredListenAddr(_) + | FromSwarm::ListenerError(_) + | FromSwarm::ListenerClosed(_) + | FromSwarm::NewExternalAddrCandidate(_) + | FromSwarm::ExternalAddrExpired(_) => { + // The rest of the events we ignore since they are handled in their associated + // `SwarmEvent` + } } } @@ -123,7 +131,7 @@ impl NetworkBehaviour for PeerManager { &mut self, cx: &mut Context<'_>, _params: &mut impl PollParameters, - ) -> Poll>> { + ) -> Poll>> { trace!("poll"); while self.heartbeat.poll_tick(cx).is_ready() { diff --git a/src/rpc/behaviour.rs b/src/rpc/behaviour.rs index da95afa..00d0e6b 100644 --- a/src/rpc/behaviour.rs +++ b/src/rpc/behaviour.rs @@ -1,11 +1,12 @@ use crate::network::ReqId; use crate::rpc::handler::{Handler, HandlerReceived, SubstreamId}; use crate::rpc::{ReceivedRequest, ReceivedResponse, RpcEvent}; +use libp2p::core::Endpoint; use libp2p::swarm::{ - ConnectionId, FromSwarm, NetworkBehaviour, NotifyHandler, PollParameters, THandlerInEvent, - THandlerOutEvent, ToSwarm, + ConnectionDenied, ConnectionId, FromSwarm, NetworkBehaviour, NotifyHandler, PollParameters, + THandler, THandlerInEvent, THandlerOutEvent, ToSwarm, }; -use libp2p::PeerId; +use libp2p::{Multiaddr, PeerId}; use std::sync::Arc; use std::task::{Context, Poll}; use tracing::{info, trace}; @@ -113,16 +114,32 @@ impl Behaviour { // SEE https://docs.rs/libp2p/0.39.1/libp2p/tutorial/index.html#network-behaviour impl NetworkBehaviour for Behaviour { type ConnectionHandler = Handler; - type OutEvent = RpcEvent; + type ToSwarm = RpcEvent; - fn new_handler(&mut self) -> Self::ConnectionHandler { - Handler::new(self.fork_context.clone()) + fn handle_established_inbound_connection( + &mut self, + _connection_id: ConnectionId, + peer_id: PeerId, + _local_addr: &Multiaddr, + _remote_addr: &Multiaddr, + ) -> Result, ConnectionDenied> { + Ok(Handler::new(peer_id, self.fork_context.clone())) + } + + fn handle_established_outbound_connection( + &mut self, + _connection_id: ConnectionId, + peer_id: PeerId, + _addr: &Multiaddr, + _role_override: Endpoint, + ) -> Result, ConnectionDenied> { + Ok(Handler::new(peer_id, self.fork_context.clone())) } fn on_swarm_event(&mut self, event: FromSwarm) { match event { - FromSwarm::ConnectionEstablished(_) - | FromSwarm::ConnectionClosed(_) + FromSwarm::ConnectionClosed(_) + | FromSwarm::ConnectionEstablished(_) | FromSwarm::AddressChange(_) | FromSwarm::DialFailure(_) | FromSwarm::ListenFailure(_) @@ -131,8 +148,9 @@ impl NetworkBehaviour for Behaviour { | FromSwarm::ExpiredListenAddr(_) | FromSwarm::ListenerError(_) | FromSwarm::ListenerClosed(_) - | FromSwarm::NewExternalAddr(_) - | FromSwarm::ExpiredExternalAddr(_) => { + | FromSwarm::NewExternalAddrCandidate(_) + | FromSwarm::ExternalAddrExpired(_) + | FromSwarm::ExternalAddrConfirmed(_) => { // Rpc Behaviour does not act on these swarm events. We use a comprehensive match // statement to ensure future events are dealt with appropriately. } @@ -180,7 +198,7 @@ impl NetworkBehaviour for Behaviour { &mut self, _cx: &mut Context<'_>, _params: &mut impl PollParameters, - ) -> Poll>> { + ) -> Poll>> { if !self.events.is_empty() { return Poll::Ready(self.events.remove(0)); } diff --git a/src/rpc/handler.rs b/src/rpc/handler.rs index 2c24cbd..b82f943 100644 --- a/src/rpc/handler.rs +++ b/src/rpc/handler.rs @@ -6,10 +6,8 @@ use crate::rpc::protocol::{ }; use futures::{FutureExt, SinkExt, StreamExt}; use libp2p::swarm::handler::{ConnectionEvent, FullyNegotiatedInbound, FullyNegotiatedOutbound}; -use libp2p::swarm::{ - ConnectionHandler, ConnectionHandlerEvent, KeepAlive, NegotiatedSubstream, SubstreamProtocol, -}; -use libp2p::PeerId; +use libp2p::swarm::{ConnectionHandler, ConnectionHandlerEvent, KeepAlive, SubstreamProtocol}; +use libp2p::{PeerId, Stream}; use lighthouse_network::rpc::methods::RPCCodedResponse; use smallvec::SmallVec; use std::collections::hash_map::Entry; @@ -48,9 +46,9 @@ pub struct SubstreamId(usize); enum InboundSubstreamState { // The underlying substream is not being used. - Idle(InboundFramed), + Idle(InboundFramed), // The underlying substream is processing responses. - Busy(Pin, String>> + Send>>), + Busy(Pin, String>> + Send>>), // Temporary state during processing Poisoned, } @@ -120,11 +118,11 @@ pub(crate) struct Handler { // Sequential ID generator for outbound substreams. outbound_substream_id: SubstreamIdGenerator, // The PeerId this handler communicate to. Note this is just for debugging. - peer_id: Option, + peer_id: PeerId, } impl Handler { - pub(crate) fn new(fork_context: Arc) -> Self { + pub(crate) fn new(peer_id: PeerId, fork_context: Arc) -> Self { // SEE: https://github.com/sigp/lighthouse/blob/fff4dd6311695c1d772a9d6991463915edf223d5/beacon_node/lighthouse_network/src/rpc/protocol.rs#L114 let max_rpc_size = 10 * 1_048_576; // 10M Handler { @@ -137,16 +135,10 @@ impl Handler { inbound_substream_id: SubstreamIdGenerator::new(), outbound_substreams: HashMap::new(), outbound_substream_id: SubstreamIdGenerator::new(), - peer_id: None, + peer_id, } } - fn peer_id(&self) -> String { - self.peer_id - .map(|p| p.to_string()) - .unwrap_or("no_peer_id".to_string()) - } - // Status // https://github.com/ethereum/consensus-specs/blob/dev/specs/phase0/p2p-interface.md#status fn send_status( @@ -170,8 +162,7 @@ impl Handler { if !matches!(self.state, HandlerState::Active) { warn!( "[{}] [send_goodbye_and_shutdown] the handler state is not Active: {:?}", - self.peer_id(), - self.state + self.peer_id, self.state ); return; } @@ -194,7 +185,7 @@ impl Handler { // Update the state to start shutdown process. info!( "[{}] [send_goodbye_and_shutdown] Updated the handler state to `ShuttingDown`", - self.peer_id() + self.peer_id ); self.state = HandlerState::ShuttingDown(Box::pin(sleep_until( Instant::now() + Duration::from_secs(SHUTDOWN_TIMEOUT_SECS), @@ -243,7 +234,7 @@ impl Handler { let (request, substream) = inbound.protocol; info!( "[{}] on_fully_negotiated_inbound. request: {request:?}", - self.peer_id() + self.peer_id ); let inbound_substream_id = self.inbound_substream_id.next(); @@ -258,8 +249,7 @@ impl Handler { ) { error!( "[{}] inbound_substream_id is duplicated. substream_id: {}", - self.peer_id(), - inbound_substream_id.0 + self.peer_id, inbound_substream_id.0 ); } @@ -288,10 +278,8 @@ impl Handler { RpcRequestProtocol, lighthouse_network::rpc::outbound::OutboundRequest, >, - // stream: ::Output, - // info: Self::OutboundOpenInfo, ) { - info!("[{}] on_fully_negotiated_outbound", self.peer_id(),); + info!("[{}] on_fully_negotiated_outbound", self.peer_id,); let request = outbound.info; let outbound_substream_id = self.outbound_substream_id.next(); @@ -311,8 +299,8 @@ impl Handler { // SEE https://github.com/sigp/lighthouse/blob/4af6fcfafd2c29bca82474ee378cda9ac254783a/beacon_node/eth2_libp2p/src/rpc/handler.rs#L311 impl ConnectionHandler for Handler { - type InEvent = InstructionToHandler; - type OutEvent = HandlerReceived; + type FromBehaviour = InstructionToHandler; + type ToBehaviour = HandlerReceived; type Error = RPCError; type InboundProtocol = RpcProtocol; type OutboundProtocol = RpcRequestProtocol; @@ -320,7 +308,7 @@ impl ConnectionHandler for Handler { type OutboundOpenInfo = lighthouse_network::rpc::outbound::OutboundRequest; fn listen_protocol(&self) -> SubstreamProtocol { - info!("[{}] [ConnectionHandler::listen_protocol]", self.peer_id()); + info!("[{}] [ConnectionHandler::listen_protocol]", self.peer_id); SubstreamProtocol::new( RpcProtocol::new(self.fork_context.clone(), self.max_rpc_size, self.peer_id), @@ -344,7 +332,7 @@ impl ConnectionHandler for Handler { ConnectionHandlerEvent< Self::OutboundProtocol, Self::OutboundOpenInfo, - Self::OutEvent, + Self::ToBehaviour, Self::Error, >, > { @@ -390,7 +378,9 @@ impl ConnectionHandler for Handler { // `crate::rpc::Behaviour::inject_event()` is called with the event returned here. // ///////////////////////////////////////////////////////////////////////////////////////////////// if !self.out_events.is_empty() { - return Poll::Ready(ConnectionHandlerEvent::Custom(self.out_events.remove(0))); + return Poll::Ready(ConnectionHandlerEvent::NotifyBehaviour( + self.out_events.remove(0), + )); } // ///////////////////////////////////////////////////////////////////////////////////////////////// @@ -451,12 +441,7 @@ impl ConnectionHandler for Handler { // The pending messages have been sent successfully and the stream has // terminated Poll::Ready(Ok(_stream)) => { - trace!( - "[{}] Sent a response successfully.", - self.peer_id - .map(|p| p.to_string()) - .unwrap_or("no_peer_id".to_string()) - ); + trace!("[{}] Sent a response successfully.", self.peer_id,); inbound_substreams_to_remove.push(*substream_id); // There is nothing more to process on this substream as it has // been closed. Move on to the next one. @@ -467,10 +452,7 @@ impl ConnectionHandler for Handler { // TODO: Report the error that occurred during the send process error!( "[{}] Failed to send a response. error: {}", - self.peer_id - .map(|p| p.to_string()) - .unwrap_or("no_peer_id".to_string()), - error_message + self.peer_id, error_message, ); inbound_substreams_to_remove.push(*substream_id); break; @@ -496,7 +478,6 @@ impl ConnectionHandler for Handler { // Drive outbound streams that need to be processed // ///////////////////////////////////////////////////////////////////////////////////////////////// for outbound_substream_id in self.outbound_substreams.keys().copied().collect::>() { - let peer_id = self.peer_id(); let mut entry = match self.outbound_substreams.entry(outbound_substream_id) { Entry::Occupied(entry) => entry, Entry::Vacant(_) => unreachable!(), @@ -505,8 +486,8 @@ impl ConnectionHandler for Handler { match entry.get_mut().poll_next_unpin(cx) { Poll::Ready(Some(Ok(rpc_coded_response))) => match rpc_coded_response { RPCCodedResponse::Success(response) => { - info!("[{}] received a response: {response:?}", self.peer_id()); - return Poll::Ready(ConnectionHandlerEvent::Custom( + info!("[{}] received a response: {response:?}", self.peer_id); + return Poll::Ready(ConnectionHandlerEvent::NotifyBehaviour( HandlerReceived::Response(response), )); } @@ -520,7 +501,7 @@ impl ConnectionHandler for Handler { Poll::Ready(Some(Err(e))) => { error!( "[{}] An error occurred while processing outbound stream. error: {:?}", - peer_id, e, + self.peer_id, e, ); } Poll::Ready(None) => { @@ -529,7 +510,7 @@ impl ConnectionHandler for Handler { // //////////////// info!( "[{}] Stream closed by remote. outbound_substream_id: {:?}", - peer_id, outbound_substream_id + self.peer_id, outbound_substream_id ); // drop the stream entry.remove_entry(); @@ -545,28 +526,20 @@ impl ConnectionHandler for Handler { Poll::Pending } - fn on_behaviour_event(&mut self, event: Self::InEvent) { - info!( - "[{}] on_behaviour_event. event: {:?}", - self.peer_id(), - event - ); + fn on_behaviour_event(&mut self, event: Self::FromBehaviour) { + info!("[{}] on_behaviour_event. event: {:?}", self.peer_id, event); match event { InstructionToHandler::Status(request_id, status_message, peer_id) => { - self.peer_id = Some(peer_id); // This is just for debugging. self.send_status(request_id, peer_id, status_message); } InstructionToHandler::Goodbye(request_id, reason, peer_id) => { - self.peer_id = Some(peer_id); // This is just for debugging. self.shutdown(Some((request_id, peer_id, reason))); } InstructionToHandler::Request(request_id, request, peer_id) => { - self.peer_id = Some(peer_id); // This is just for debugging. self.send_request(request_id, peer_id, request); } InstructionToHandler::Response(substream_id, response, peer_id) => { - self.peer_id = Some(peer_id); // This is just for debugging. self.send_response(peer_id, substream_id, response) } }; @@ -588,19 +561,28 @@ impl ConnectionHandler for Handler { ConnectionEvent::FullyNegotiatedOutbound(fully_negotiated_outbound) => { self.on_fully_negotiated_outbound(fully_negotiated_outbound); } - ConnectionEvent::AddressChange(_) => {} + ConnectionEvent::AddressChange(_) => { + // We dont care about these changes as they have no bearing on our RPC internal + // logic. + } ConnectionEvent::DialUpgradeError(dial_upgrade_error) => { warn!( "[{}] dial_upgrade_error. info: {}, error: {}", - self.peer_id(), - dial_upgrade_error.info, - dial_upgrade_error.error, + self.peer_id, dial_upgrade_error.info, dial_upgrade_error.error, ); // TODO // ref: https://github.com/sigp/lighthouse/blob/3dd50bda11cefb3c17d851cbb8811610385c20aa/beacon_node/lighthouse_network/src/rpc/handler.rs#L453 } ConnectionEvent::ListenUpgradeError(_) => {} + ConnectionEvent::LocalProtocolsChange(_) => { + // This shouldn't effect this handler, we will still negotiate streams if we support + // the protocol as usual. + } + ConnectionEvent::RemoteProtocolsChange(_) => { + // This shouldn't effect this handler, we will still negotiate streams if we support + // the protocol as usual. + } } } } diff --git a/src/rpc/protocol.rs b/src/rpc/protocol.rs index 5772a9a..896fb7c 100644 --- a/src/rpc/protocol.rs +++ b/src/rpc/protocol.rs @@ -1,9 +1,8 @@ use ::types::fork_context::ForkContext; use futures::future::BoxFuture; use futures::prelude::*; -use libp2p::core::{ProtocolName, UpgradeInfo}; -use libp2p::swarm::NegotiatedSubstream; -use libp2p::{InboundUpgrade, OutboundUpgrade, PeerId}; +use libp2p::core::UpgradeInfo; +use libp2p::{InboundUpgrade, OutboundUpgrade, PeerId, Stream}; use std::fmt::{Display, Formatter}; use std::sync::Arc; use std::time::Duration; @@ -140,9 +139,9 @@ impl ProtocolId { } } -impl ProtocolName for ProtocolId { - fn protocol_name(&self) -> &[u8] { - self.protocol_id.as_bytes() +impl AsRef for ProtocolId { + fn as_ref(&self) -> &str { + self.protocol_id.as_ref() } } @@ -178,21 +177,15 @@ impl UpgradeInfo for RpcRequestProtocol { } } -pub(crate) type OutboundFramed = Framed< - Compat, - lighthouse_network::rpc::codec::OutboundCodec, ->; +pub(crate) type OutboundFramed = + Framed, lighthouse_network::rpc::codec::OutboundCodec>; -impl OutboundUpgrade for RpcRequestProtocol { +impl OutboundUpgrade for RpcRequestProtocol { type Output = OutboundFramed; type Error = lighthouse_network::rpc::RPCError; type Future = BoxFuture<'static, Result>; - fn upgrade_outbound( - self, - socket: NegotiatedSubstream, - protocol_id: Self::Info, - ) -> Self::Future { + fn upgrade_outbound(self, socket: Stream, protocol_id: Self::Info) -> Self::Future { info!( "[{}] RpcRequestProtocol::upgrade_outbound: request: {:?}", self.request.peer_id, self.request.request @@ -241,14 +234,14 @@ pub(crate) struct RpcProtocol { pub(crate) fork_context: Arc, pub(crate) max_rpc_size: usize, // The PeerId this communicate to. Note this is just for debugging. - peer_id: Option, + peer_id: PeerId, } impl RpcProtocol { pub(crate) fn new( fork_context: Arc, max_rpc_size: usize, - peer_id: Option, + peer_id: PeerId, ) -> RpcProtocol { RpcProtocol { fork_context, @@ -256,12 +249,6 @@ impl RpcProtocol { peer_id, } } - - fn peer_id(&self) -> String { - self.peer_id - .map(|p| p.to_string()) - .unwrap_or("no_peer_id".to_string()) - } } impl UpgradeInfo for RpcProtocol { @@ -307,8 +294,7 @@ where fn upgrade_inbound(self, socket: TSocket, protocol_id: Self::Info) -> Self::Future { info!( "[{}] [RpcProtocol::upgrade_inbound] protocol_id: {:?}", - self.peer_id(), - protocol_id, + self.peer_id, protocol_id, ); async move { @@ -338,13 +324,13 @@ where { Err(_e) => todo!(), Ok((Some(Ok(request)), stream)) => { - info!("[{}] [RpcProtocol::upgrade_inbound] received inbound message: {:?}", self.peer_id(), request); + info!("[{}] [RpcProtocol::upgrade_inbound] received inbound message: {:?}", self.peer_id, request); Ok((request, stream)) }, Ok((Some(Err(rpc_error)), _)) => { error!( "[{}] [RpcProtocol::upgrade_inbound] protocol_id: {protocol_id:?}, rpc_error: {rpc_error:?}", - self.peer_id() + self.peer_id ); Err(rpc_error) }