From 72dba692569b2aa449050a8acaeff209886f0874 Mon Sep 17 00:00:00 2001 From: Simon Paitrault Date: Thu, 22 Jun 2023 17:47:04 +0200 Subject: [PATCH] chore: wip Signed-off-by: Simon Paitrault --- Cargo.lock | 300 ++++++++---------- Cargo.toml | 3 +- crates/topos-p2p/Cargo.toml | 2 +- crates/topos-p2p/src/behaviour.rs | 2 +- crates/topos-p2p/src/behaviour/discovery.rs | 7 +- crates/topos-p2p/src/behaviour/peer_info.rs | 2 +- .../topos-p2p/src/behaviour/transmission.rs | 14 +- .../src/behaviour/transmission/codec.rs | 5 +- .../src/behaviour/transmission/protocol.rs | 8 - crates/topos-p2p/src/runtime/handle_event.rs | 14 +- .../src/runtime/handle_event/gossipsub.rs | 3 +- .../src/runtime/handle_event/peer_info.rs | 14 +- crates/topos-p2p/src/runtime/mod.rs | 3 +- tools/docker-compose.yml | 66 +++- tools/env/base.env | 2 +- tools/env/node.env | 2 +- tools/env/spammer.env | 4 +- tools/grafana/config.monitoring | 3 + tools/prometheus.yaml | 7 +- tools/prometheus/prometheus.yml | 23 ++ 20 files changed, 259 insertions(+), 225 deletions(-) create mode 100644 tools/grafana/config.monitoring create mode 100644 tools/prometheus/prometheus.yml diff --git a/Cargo.lock b/Cargo.lock index 17e6e7d10..8744d391f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1582,7 +1582,7 @@ dependencies = [ "hashbrown 0.12.3", "lock_api", "once_cell", - "parking_lot_core 0.9.8", + "parking_lot_core", ] [[package]] @@ -2606,13 +2606,12 @@ dependencies = [ [[package]] name = "futures-rustls" -version = "0.22.2" +version = "0.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2411eed028cdf8c8034eaf21f9915f956b6c3abec4d4c7949ee67f0721127bd" +checksum = "35bd3cf68c183738046838e300353e4716c674dc5e56890de4826801a6622a28" dependencies = [ "futures-io", - "rustls 0.20.8", - "webpki 0.22.0", + "rustls 0.21.2", ] [[package]] @@ -2627,6 +2626,17 @@ version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "76d3d132be6c0e6aa1534069c705a74a5997a356c0dc2f86a47765e5617c5b65" +[[package]] +name = "futures-ticker" +version = "0.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9763058047f713632a52e916cc7f6a4b3fc6e9fc1ff8c5b1dc49e5a89041682e" +dependencies = [ + "futures", + "futures-timer", + "instant", +] + [[package]] name = "futures-timer" version = "3.0.2" @@ -3505,9 +3515,8 @@ checksum = "f7012b1bbb0719e1097c47611d3898568c546d597c2e74d66f6087edd5233ff4" [[package]] name = "libp2p" -version = "0.51.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f210d259724eae82005b5c48078619b7745edb7b76de370b03f8ba59ea103097" +version = "0.52.0" +source = "git+https://github.com/libp2p/rust-libp2p.git?branch=bump-yamux#96176d8da3107c82047f265dc2a5a8b0e59b02f6" dependencies = [ "bytes", "futures", @@ -3524,7 +3533,6 @@ dependencies = [ "libp2p-kad", "libp2p-mdns", "libp2p-metrics", - "libp2p-mplex", "libp2p-noise", "libp2p-quic", "libp2p-request-response", @@ -3538,9 +3546,8 @@ dependencies = [ [[package]] name = "libp2p-allow-block-list" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "510daa05efbc25184458db837f6f9a5143888f1caa742426d92e1833ddd38a50" +version = "0.2.0" +source = "git+https://github.com/libp2p/rust-libp2p.git?branch=bump-yamux#96176d8da3107c82047f265dc2a5a8b0e59b02f6" dependencies = [ "libp2p-core", "libp2p-identity", @@ -3550,9 +3557,8 @@ dependencies = [ [[package]] name = "libp2p-connection-limits" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4caa33f1d26ed664c4fe2cca81a08c8e07d4c1c04f2f4ac7655c2dd85467fda0" +version = "0.2.0" +source = "git+https://github.com/libp2p/rust-libp2p.git?branch=bump-yamux#96176d8da3107c82047f265dc2a5a8b0e59b02f6" dependencies = [ "libp2p-core", "libp2p-identity", @@ -3562,9 +3568,8 @@ dependencies = [ [[package]] name = "libp2p-core" -version = "0.39.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c1df63c0b582aa434fb09b2d86897fa2b419ffeccf934b36f87fcedc8e835c2" +version = "0.40.0" +source = "git+https://github.com/libp2p/rust-libp2p.git?branch=bump-yamux#96176d8da3107c82047f265dc2a5a8b0e59b02f6" dependencies = [ "either", "fnv", @@ -3577,7 +3582,7 @@ dependencies = [ "multihash", "multistream-select", "once_cell", - "parking_lot 0.12.1", + "parking_lot", "pin-project", "quick-protobuf", "rand 0.8.5", @@ -3591,23 +3596,22 @@ dependencies = [ [[package]] name = "libp2p-dns" -version = "0.39.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "146ff7034daae62077c415c2376b8057368042df6ab95f5432ad5e88568b1554" +version = "0.40.0" +source = "git+https://github.com/libp2p/rust-libp2p.git?branch=bump-yamux#96176d8da3107c82047f265dc2a5a8b0e59b02f6" dependencies = [ "futures", "libp2p-core", + "libp2p-identity", "log", - "parking_lot 0.12.1", + "parking_lot", "smallvec", "trust-dns-resolver", ] [[package]] name = "libp2p-gossipsub" -version = "0.44.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70b34b6da8165c0bde35c82db8efda39b824776537e73973549e76cadb3a77c5" +version = "0.45.0" +source = "git+https://github.com/libp2p/rust-libp2p.git?branch=bump-yamux#96176d8da3107c82047f265dc2a5a8b0e59b02f6" dependencies = [ "asynchronous-codec", "base64 0.21.2", @@ -3616,6 +3620,8 @@ dependencies = [ "either", "fnv", "futures", + "futures-ticker", + "getrandom 0.2.10", "hex_fmt", "instant", "libp2p-core", @@ -3630,17 +3636,14 @@ dependencies = [ "serde", "sha2 0.10.7", "smallvec", - "thiserror", "unsigned-varint", "void", - "wasm-timer", ] [[package]] name = "libp2p-identify" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5455f472243e63b9c497ff320ded0314254a9eb751799a39c283c6f20b793f3c" +version = "0.43.0" +source = "git+https://github.com/libp2p/rust-libp2p.git?branch=bump-yamux#96176d8da3107c82047f265dc2a5a8b0e59b02f6" dependencies = [ "asynchronous-codec", "either", @@ -3660,9 +3663,8 @@ dependencies = [ [[package]] name = "libp2p-identity" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e2d584751cecb2aabaa56106be6be91338a60a0f4e420cf2af639204f596fc1" +version = "0.2.0" +source = "git+https://github.com/libp2p/rust-libp2p.git?branch=bump-yamux#96176d8da3107c82047f265dc2a5a8b0e59b02f6" dependencies = [ "bs58", "ed25519-dalek", @@ -3679,9 +3681,8 @@ dependencies = [ [[package]] name = "libp2p-kad" -version = "0.43.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39d5ef876a2b2323d63c258e63c2f8e36f205fe5a11f0b3095d59635650790ff" +version = "0.44.0" +source = "git+https://github.com/libp2p/rust-libp2p.git?branch=bump-yamux#96176d8da3107c82047f265dc2a5a8b0e59b02f6" dependencies = [ "arrayvec", "asynchronous-codec", @@ -3708,9 +3709,8 @@ dependencies = [ [[package]] name = "libp2p-mdns" -version = "0.43.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19983e1f949f979a928f2c603de1cf180cc0dc23e4ac93a62651ccb18341460b" +version = "0.44.0" +source = "git+https://github.com/libp2p/rust-libp2p.git?branch=bump-yamux#96176d8da3107c82047f265dc2a5a8b0e59b02f6" dependencies = [ "data-encoding", "futures", @@ -3721,7 +3721,7 @@ dependencies = [ "log", "rand 0.8.5", "smallvec", - "socket2 0.4.9", + "socket2 0.5.3", "tokio", "trust-dns-proto", "void", @@ -3729,41 +3729,24 @@ dependencies = [ [[package]] name = "libp2p-metrics" -version = "0.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a42ec91e227d7d0dafa4ce88b333cdf5f277253873ab087555c92798db2ddd46" +version = "0.13.0" +source = "git+https://github.com/libp2p/rust-libp2p.git?branch=bump-yamux#96176d8da3107c82047f265dc2a5a8b0e59b02f6" dependencies = [ + "instant", "libp2p-core", "libp2p-gossipsub", "libp2p-identify", + "libp2p-identity", "libp2p-kad", "libp2p-swarm", + "once_cell", "prometheus-client", ] -[[package]] -name = "libp2p-mplex" -version = "0.39.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d34780b514b159e6f3fd70ba3e72664ec89da28dca2d1e7856ee55e2c7031ba" -dependencies = [ - "asynchronous-codec", - "bytes", - "futures", - "libp2p-core", - "log", - "nohash-hasher", - "parking_lot 0.12.1", - "rand 0.8.5", - "smallvec", - "unsigned-varint", -] - [[package]] name = "libp2p-noise" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c3673da89d29936bc6435bafc638e2f184180d554ce844db65915113f86ec5e" +version = "0.43.0" +source = "git+https://github.com/libp2p/rust-libp2p.git?branch=bump-yamux#96176d8da3107c82047f265dc2a5a8b0e59b02f6" dependencies = [ "bytes", "curve25519-dalek 3.2.0", @@ -3784,9 +3767,8 @@ dependencies = [ [[package]] name = "libp2p-quic" -version = "0.7.0-alpha.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6b26abd81cd2398382a1edfe739b539775be8a90fa6914f39b2ab49571ec735" +version = "0.8.0-alpha" +source = "git+https://github.com/libp2p/rust-libp2p.git?branch=bump-yamux#96176d8da3107c82047f265dc2a5a8b0e59b02f6" dependencies = [ "bytes", "futures", @@ -3796,19 +3778,18 @@ dependencies = [ "libp2p-identity", "libp2p-tls", "log", - "parking_lot 0.12.1", + "parking_lot", "quinn-proto", "rand 0.8.5", - "rustls 0.20.8", + "rustls 0.21.2", "thiserror", "tokio", ] [[package]] name = "libp2p-request-response" -version = "0.24.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ffdb374267d42dc5ed5bc53f6e601d4a64ac5964779c6e40bb9e4f14c1e30d5" +version = "0.25.0" +source = "git+https://github.com/libp2p/rust-libp2p.git?branch=bump-yamux#96176d8da3107c82047f265dc2a5a8b0e59b02f6" dependencies = [ "async-trait", "futures", @@ -3816,15 +3797,16 @@ dependencies = [ "libp2p-core", "libp2p-identity", "libp2p-swarm", + "log", "rand 0.8.5", "smallvec", + "void", ] [[package]] name = "libp2p-swarm" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "903b3d592d7694e56204d211f29d31bc004be99386644ba8731fc3e3ef27b296" +version = "0.43.0" +source = "git+https://github.com/libp2p/rust-libp2p.git?branch=bump-yamux#96176d8da3107c82047f265dc2a5a8b0e59b02f6" dependencies = [ "either", "fnv", @@ -3835,6 +3817,8 @@ dependencies = [ "libp2p-identity", "libp2p-swarm-derive", "log", + "multistream-select", + "once_cell", "rand 0.8.5", "smallvec", "tokio", @@ -3843,36 +3827,36 @@ dependencies = [ [[package]] name = "libp2p-swarm-derive" -version = "0.32.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fba456131824ab6acd4c7bf61e9c0f0a3014b5fc9868ccb8e10d344594cdc4f" +version = "0.33.0" +source = "git+https://github.com/libp2p/rust-libp2p.git?branch=bump-yamux#96176d8da3107c82047f265dc2a5a8b0e59b02f6" dependencies = [ "heck 0.4.1", + "proc-macro-warning", + "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.18", ] [[package]] name = "libp2p-tcp" -version = "0.39.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33d33698596d7722d85d3ab0c86c2c322254fce1241e91208e3679b4eb3026cf" +version = "0.40.0" +source = "git+https://github.com/libp2p/rust-libp2p.git?branch=bump-yamux#96176d8da3107c82047f265dc2a5a8b0e59b02f6" dependencies = [ "futures", "futures-timer", "if-watch", "libc", "libp2p-core", + "libp2p-identity", "log", - "socket2 0.4.9", + "socket2 0.5.3", "tokio", ] [[package]] name = "libp2p-tls" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff08d13d0dc66e5e9ba6279c1de417b84fa0d0adc3b03e5732928c180ec02781" +version = "0.2.0" +source = "git+https://github.com/libp2p/rust-libp2p.git?branch=bump-yamux#96176d8da3107c82047f265dc2a5a8b0e59b02f6" dependencies = [ "futures", "futures-rustls", @@ -3880,18 +3864,17 @@ dependencies = [ "libp2p-identity", "rcgen 0.10.0", "ring", - "rustls 0.20.8", + "rustls 0.21.2", "thiserror", "webpki 0.22.0", - "x509-parser 0.14.0", + "x509-parser 0.15.0", "yasna", ] [[package]] name = "libp2p-webrtc" -version = "0.4.0-alpha.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dba48592edbc2f60b4bc7c10d65445b0c3964c07df26fdf493b6880d33be36f8" +version = "0.5.0-alpha" +source = "git+https://github.com/libp2p/rust-libp2p.git?branch=bump-yamux#96176d8da3107c82047f265dc2a5a8b0e59b02f6" dependencies = [ "async-trait", "asynchronous-codec", @@ -3910,6 +3893,7 @@ dependencies = [ "rand 0.8.5", "rcgen 0.9.3", "serde", + "sha2 0.10.7", "stun", "thiserror", "tinytemplate", @@ -3920,9 +3904,8 @@ dependencies = [ [[package]] name = "libp2p-yamux" -version = "0.43.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4dcd21d950662700a385d4c6d68e2f5f54d778e97068cdd718522222ef513bda" +version = "0.44.0" +source = "git+https://github.com/libp2p/rust-libp2p.git?branch=bump-yamux#96176d8da3107c82047f265dc2a5a8b0e59b02f6" dependencies = [ "futures", "libp2p-core", @@ -4225,11 +4208,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "835d6ff01d610179fbce3de1694d007e500bf33a7f29689838941d6bf783ae40" dependencies = [ "core2", - "digest 0.10.7", "multihash-derive", "serde", "serde-big-array", - "sha2 0.10.7", "unsigned-varint", ] @@ -4255,9 +4236,8 @@ checksum = "e5ce46fe64a9d73be07dcbe690a38ce1b293be448fd8ce1e6c1b8062c9f72c6a" [[package]] name = "multistream-select" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8552ab875c1313b97b8d20cb857b9fd63e2d1d6a0a1b53ce9821e575405f27a" +version = "0.13.0" +source = "git+https://github.com/libp2p/rust-libp2p.git?branch=bump-yamux#96176d8da3107c82047f265dc2a5a8b0e59b02f6" dependencies = [ "bytes", "futures", @@ -4492,7 +4472,7 @@ version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" dependencies = [ - "parking_lot_core 0.9.8", + "parking_lot_core", ] [[package]] @@ -4725,17 +4705,6 @@ version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "14f2252c834a40ed9bb5422029649578e63aa341ac401f74e719dd1afda8394e" -[[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.1" @@ -4743,21 +4712,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" dependencies = [ "lock_api", - "parking_lot_core 0.9.8", -] - -[[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", + "parking_lot_core", ] [[package]] @@ -4877,9 +4832,9 @@ checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" [[package]] name = "pest" -version = "2.6.1" +version = "2.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16833386b02953ca926d19f64af613b9bf742c48dcd5e09b32fbfc9740bf84e2" +checksum = "f73935e4d55e2abf7f130186537b19e7a4abc886a0252380b59248af473a3fc9" dependencies = [ "thiserror", "ucd-trie", @@ -4887,9 +4842,9 @@ dependencies = [ [[package]] name = "pest_derive" -version = "2.6.1" +version = "2.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7763190f9406839f99e5197afee8c9e759969f7dbfa40ad3b8dbee8757b745b5" +checksum = "aef623c9bbfa0eedf5a0efba11a5ee83209c326653ca31ff019bec3a95bfff2b" dependencies = [ "pest", "pest_generator", @@ -4897,9 +4852,9 @@ dependencies = [ [[package]] name = "pest_generator" -version = "2.6.1" +version = "2.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "249061b22e99973da1f5f5f1410284419e283bb60b79255bf5f42a94b66a2e00" +checksum = "b3e8cba4ec22bada7fc55ffe51e2deb6a0e0db2d0b7ab0b103acc80d2510c190" dependencies = [ "pest", "pest_meta", @@ -4910,9 +4865,9 @@ dependencies = [ [[package]] name = "pest_meta" -version = "2.6.1" +version = "2.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "457c310cfc9cf3f22bc58901cc7f0d3410ac5d6298e432a4f9a6138565cb6df6" +checksum = "a01f71cb40bd8bb94232df14b946909e14660e33fc05db3e50ae2a82d7ea0ca0" dependencies = [ "once_cell", "pest", @@ -5232,6 +5187,17 @@ dependencies = [ "version_check", ] +[[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.18", +] + [[package]] name = "proc-macro2" version = "1.0.60" @@ -5259,20 +5225,20 @@ dependencies = [ "fnv", "lazy_static", "memchr", - "parking_lot 0.12.1", + "parking_lot", "protobuf", "thiserror", ] [[package]] name = "prometheus-client" -version = "0.19.0" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d6fa99d535dd930d1249e6c79cb3c2915f9172a540fe2b02a4c8f9ca954721e" +checksum = "78c2f43e8969d51935d2a7284878ae053ba30034cd563f673cde37ba5205685e" dependencies = [ "dtoa", "itoa", - "parking_lot 0.12.1", + "parking_lot", "prometheus-client-derive-encode", ] @@ -5380,9 +5346,8 @@ dependencies = [ [[package]] name = "quick-protobuf-codec" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1693116345026436eb2f10b677806169c1a1260c1c60eaaffe3fb5a29ae23d8b" +version = "0.2.0" +source = "git+https://github.com/libp2p/rust-libp2p.git?branch=bump-yamux#96176d8da3107c82047f265dc2a5a8b0e59b02f6" dependencies = [ "asynchronous-codec", "bytes", @@ -5393,20 +5358,19 @@ dependencies = [ [[package]] name = "quinn-proto" -version = "0.9.3" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67c10f662eee9c94ddd7135043e544f3c82fa839a1e7b865911331961b53186c" +checksum = "85af4ed6ee5a89f26a26086e9089a6643650544c025158449a3626ebf72884b3" dependencies = [ "bytes", "rand 0.8.5", "ring", "rustc-hash", - "rustls 0.20.8", + "rustls 0.21.2", "slab", "thiserror", "tinyvec", "tracing", - "webpki 0.22.0", ] [[package]] @@ -5943,9 +5907,8 @@ checksum = "4f3208ce4d8448b3f3e7d168a73f5e0c43a61e32930de3bceeccedb388b6bf06" [[package]] name = "rw-stream-sink" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26338f5e09bb721b85b135ea05af7767c90b52f6de4f087d4f4a3a9d64e7dc04" +version = "0.4.0" +source = "git+https://github.com/libp2p/rust-libp2p.git?branch=bump-yamux#96176d8da3107c82047f265dc2a5a8b0e59b02f6" dependencies = [ "futures", "pin-project", @@ -6284,7 +6247,7 @@ dependencies = [ "futures", "lazy_static", "log", - "parking_lot 0.12.1", + "parking_lot", "serial_test_derive", ] @@ -6532,7 +6495,7 @@ checksum = "f91138e76242f575eb1d3b38b4f1362f10d3a43f47d182a5b359af488a02293b" dependencies = [ "new_debug_unreachable", "once_cell", - "parking_lot 0.12.1", + "parking_lot", "phf_shared 0.10.0", "precomputed-hash", ] @@ -6907,7 +6870,7 @@ dependencies = [ "libc", "mio", "num_cpus", - "parking_lot 0.12.1", + "parking_lot", "pin-project-lite", "signal-hook-registry", "socket2 0.4.9", @@ -7726,9 +7689,9 @@ dependencies = [ [[package]] name = "tracing-attributes" -version = "0.1.25" +version = "0.1.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8803eee176538f94ae9a14b55b2804eb7e1441f8210b1c31290b3bccdccff73b" +checksum = "5f4f31f56159e98206da9efd823404b79b6ef3143b4a7ab76e67b1751b25a4ab" dependencies = [ "proc-macro2", "quote", @@ -7847,7 +7810,7 @@ dependencies = [ "ipconfig", "lazy_static", "lru-cache", - "parking_lot 0.12.1", + "parking_lot", "resolv-conf", "smallvec", "thiserror", @@ -8225,21 +8188,6 @@ version = "0.2.87" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ca6ad05a4870b2bf5fe995117d3728437bd27d7cd5f06f13c17443ef369775a1" -[[package]] -name = "wasm-timer" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be0ecb0db480561e9a7642b5d3e4187c128914e58aa84330b9493e3eb68c5e7f" -dependencies = [ - "futures", - "js-sys", - "parking_lot 0.11.2", - "pin-utils", - "wasm-bindgen", - "wasm-bindgen-futures", - "web-sys", -] - [[package]] name = "web-sys" version = "0.3.64" @@ -8834,12 +8782,11 @@ dependencies = [ [[package]] name = "x509-parser" -version = "0.14.0" +version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0ecbeb7b67ce215e40e3cc7f2ff902f94a223acf44995934763467e7b1febc8" +checksum = "bab0c2f54ae1d92f4fcb99c0b7ccf0b1e3451cbd395e5f115ccbdbcb18d4f634" dependencies = [ "asn1-rs 0.5.2", - "base64 0.13.1", "data-encoding", "der-parser 8.2.0", "lazy_static", @@ -8870,14 +8817,15 @@ dependencies = [ [[package]] name = "yamux" -version = "0.10.2" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5d9ba232399af1783a58d8eb26f6b5006fbefe2dc9ef36bd283324792d03ea5" +checksum = "0875ad26dfbf0e7126d4a200747c78496aa3f0225d094a8c867b0e98bb19f9d7" dependencies = [ "futures", "log", "nohash-hasher", - "parking_lot 0.12.1", + "parking_lot", + "pin-project", "rand 0.8.5", "static_assertions", ] diff --git a/Cargo.toml b/Cargo.toml index d84508c64..aa3d2bef7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -46,7 +46,8 @@ async-graphql = "5" async-graphql-axum = "5" # P2P related -libp2p = { version = "0.51", default-features = false, features = ["noise"]} +# libp2p = { version = "0.52", default-features = false, features = ["noise"]} +libp2p = { branch = "bump-yamux", git = "https://github.com/libp2p/rust-libp2p.git", default-features = false, features = ["noise"]} # Serialization & Deserialization bincode = { version = "1.3", default-features = false } diff --git a/crates/topos-p2p/Cargo.toml b/crates/topos-p2p/Cargo.toml index f41a3a3b5..2f31a1755 100644 --- a/crates/topos-p2p/Cargo.toml +++ b/crates/topos-p2p/Cargo.toml @@ -13,7 +13,7 @@ tokio-stream.workspace = true tokio = { workspace = true, features = ["full"] } tracing = { workspace = true, features = ["attributes"] } -libp2p = { workspace = true, features = ["macros", "gossipsub", "tcp", "dns", "tokio", "request-response", "identify", "mplex", "kad", "serde", "yamux"] } +libp2p = { workspace = true, features = ["macros", "gossipsub", "tcp", "dns", "tokio", "request-response", "identify", "kad", "serde", "yamux"] } void = "1" topos-metrics = { path = "../topos-metrics/" } diff --git a/crates/topos-p2p/src/behaviour.rs b/crates/topos-p2p/src/behaviour.rs index 70296ad7c..ec0db9ea2 100644 --- a/crates/topos-p2p/src/behaviour.rs +++ b/crates/topos-p2p/src/behaviour.rs @@ -17,7 +17,7 @@ pub(crate) mod topos; pub(crate) mod transmission; #[derive(NetworkBehaviour)] -#[behaviour(out_event = "ComposedEvent")] +#[behaviour(to_swarm = "ComposedEvent")] pub(crate) struct Behaviour { /// All the topos-specific protocols. // pub(crate) topos: ToposBehaviour, diff --git a/crates/topos-p2p/src/behaviour/discovery.rs b/crates/topos-p2p/src/behaviour/discovery.rs index d3b485c33..2d35fb2db 100644 --- a/crates/topos-p2p/src/behaviour/discovery.rs +++ b/crates/topos-p2p/src/behaviour/discovery.rs @@ -2,15 +2,16 @@ use std::{borrow::Cow, collections::HashMap, num::NonZeroUsize, time::Duration}; use crate::{ config::DiscoveryConfig, + constant::TRANSMISSION_PROTOCOL, error::{CommandExecutionError, P2PError}, }; -use libp2p::kad::KademliaEvent; use libp2p::{ identity::Keypair, kad::{store::MemoryStore, Kademlia, KademliaBucketInserts, KademliaConfig}, swarm::{behaviour, NetworkBehaviour}, Multiaddr, PeerId, }; +use libp2p::{kad::KademliaEvent, StreamProtocol}; use tokio::sync::oneshot; use tracing::{debug, info, warn}; @@ -19,7 +20,7 @@ pub type PendingRecordRequest = oneshot::Sender, CommandEx /// DiscoveryBehaviour is responsible to discover and manage connections with peers #[derive(NetworkBehaviour)] -#[behaviour(out_event = "KademliaEvent")] +#[behaviour(to_swarm = "KademliaEvent")] pub(crate) struct DiscoveryBehaviour { pub(crate) inner: Kademlia, } @@ -34,7 +35,7 @@ impl DiscoveryBehaviour { ) -> Self { let local_peer_id = peer_key.public().to_peer_id(); let kademlia_config = KademliaConfig::default() - .set_protocol_names(vec![discovery_protocol]) + .set_protocol_names(vec![StreamProtocol::new(TRANSMISSION_PROTOCOL)]) .set_replication_factor(config.replication_factor) .set_kbucket_inserts(KademliaBucketInserts::Manual) .set_replication_interval(config.replication_interval) diff --git a/crates/topos-p2p/src/behaviour/peer_info.rs b/crates/topos-p2p/src/behaviour/peer_info.rs index 3528e1d77..a95337b15 100644 --- a/crates/topos-p2p/src/behaviour/peer_info.rs +++ b/crates/topos-p2p/src/behaviour/peer_info.rs @@ -4,7 +4,7 @@ use libp2p::{ }; #[derive(NetworkBehaviour)] -#[behaviour(out_event = "IdentifyEvent")] +#[behaviour(to_swarm = "IdentifyEvent")] pub struct PeerInfoBehaviour { identify: Identify, } diff --git a/crates/topos-p2p/src/behaviour/transmission.rs b/crates/topos-p2p/src/behaviour/transmission.rs index 9b8ec2b4d..68ff86903 100644 --- a/crates/topos-p2p/src/behaviour/transmission.rs +++ b/crates/topos-p2p/src/behaviour/transmission.rs @@ -1,8 +1,11 @@ -use crate::error::CommandExecutionError; +use crate::{constant::TRANSMISSION_PROTOCOL, error::CommandExecutionError}; use self::{codec::TransmissionCodec, protocol::TransmissionProtocol}; -use libp2p::request_response::{Behaviour, Config, ProtocolSupport, RequestId}; +use libp2p::{ + request_response::{Behaviour, Config, ProtocolSupport, RequestId}, + StreamProtocol, +}; use std::{collections::HashMap, iter, time::Duration}; use tokio::sync::oneshot; @@ -21,9 +24,12 @@ impl TransmissionBehaviour { cfg.set_connection_keep_alive(Duration::from_secs(60)); cfg.set_request_timeout(Duration::from_secs(30)); - Behaviour::new( + Behaviour::with_codec( TransmissionCodec(), - iter::once((TransmissionProtocol(), ProtocolSupport::Full)), + iter::once(( + StreamProtocol::new(TRANSMISSION_PROTOCOL), + ProtocolSupport::Full, + )), cfg, ) } diff --git a/crates/topos-p2p/src/behaviour/transmission/codec.rs b/crates/topos-p2p/src/behaviour/transmission/codec.rs index 3ab735c6b..ab72649ad 100644 --- a/crates/topos-p2p/src/behaviour/transmission/codec.rs +++ b/crates/topos-p2p/src/behaviour/transmission/codec.rs @@ -1,10 +1,13 @@ use std::io; +use crate::constant::TRANSMISSION_PROTOCOL; + use super::protocol::TransmissionProtocol; use futures::{AsyncRead, AsyncWrite, AsyncWriteExt}; use libp2p::{ core::upgrade::{read_length_prefixed, write_length_prefixed}, request_response::Codec, + StreamProtocol, }; #[derive(Clone)] @@ -18,7 +21,7 @@ pub struct TransmissionResponse(pub(crate) Vec); #[async_trait::async_trait] impl Codec for TransmissionCodec { - type Protocol = TransmissionProtocol; + type Protocol = StreamProtocol; type Request = TransmissionRequest; type Response = TransmissionResponse; diff --git a/crates/topos-p2p/src/behaviour/transmission/protocol.rs b/crates/topos-p2p/src/behaviour/transmission/protocol.rs index 38e89eb0c..eb1fd1a85 100644 --- a/crates/topos-p2p/src/behaviour/transmission/protocol.rs +++ b/crates/topos-p2p/src/behaviour/transmission/protocol.rs @@ -1,12 +1,4 @@ -use libp2p::core::ProtocolName; - use crate::constant::TRANSMISSION_PROTOCOL; #[derive(Debug, Clone)] pub(crate) struct TransmissionProtocol(); - -impl ProtocolName for TransmissionProtocol { - fn protocol_name(&self) -> &[u8] { - TRANSMISSION_PROTOCOL.as_bytes() - } -} diff --git a/crates/topos-p2p/src/runtime/handle_event.rs b/crates/topos-p2p/src/runtime/handle_event.rs index 7f688f06d..a2886eef7 100644 --- a/crates/topos-p2p/src/runtime/handle_event.rs +++ b/crates/topos-p2p/src/runtime/handle_event.rs @@ -3,7 +3,7 @@ use std::io; use libp2p::{ core::either, multiaddr::Protocol, - swarm::{derive_prelude::Either, ConnectionHandlerUpgrErr, NetworkBehaviour, SwarmEvent}, + swarm::{derive_prelude::Either, NetworkBehaviour, SwarmEvent}, }; use tracing::{debug, error, info, warn}; @@ -48,10 +48,7 @@ impl SwarmEvent< ComposedEvent, Either< - Either< - Either, ConnectionHandlerUpgrErr>, - void::Void, - >, + Either, void::Void>, void::Void>, void::Void, >, >, @@ -62,10 +59,7 @@ impl event: SwarmEvent< ComposedEvent, Either< - Either< - Either, ConnectionHandlerUpgrErr>, - void::Void, - >, + Either, void::Void>, void::Void>, void::Void, >, >, @@ -148,7 +142,7 @@ impl } } - SwarmEvent::Dialing(peer_id) => {} + SwarmEvent::Dialing { peer_id, .. } => {} SwarmEvent::Behaviour(event) => { self.handle(event).await; diff --git a/crates/topos-p2p/src/runtime/handle_event/gossipsub.rs b/crates/topos-p2p/src/runtime/handle_event/gossipsub.rs index 5d47d5c04..e320e9d25 100644 --- a/crates/topos-p2p/src/runtime/handle_event/gossipsub.rs +++ b/crates/topos-p2p/src/runtime/handle_event/gossipsub.rs @@ -44,7 +44,8 @@ impl EventHandler> for Runtime { if let Err(e) = self .event_sender - .try_send(Event::Gossip { from: source, data }) + .send(Event::Gossip { from: source, data }) + .await { tracing::error!("Failed to send gossip event to runtime: {:?}", e); } diff --git a/crates/topos-p2p/src/runtime/handle_event/peer_info.rs b/crates/topos-p2p/src/runtime/handle_event/peer_info.rs index 97da53e4c..97f3b1562 100644 --- a/crates/topos-p2p/src/runtime/handle_event/peer_info.rs +++ b/crates/topos-p2p/src/runtime/handle_event/peer_info.rs @@ -1,12 +1,12 @@ use std::borrow::Cow; -use libp2p::{ - identify::{Event as IdentifyEvent, Info as IdentifyInfo}, - request_response::ProtocolName, -}; +use libp2p::identify::{Event as IdentifyEvent, Info as IdentifyInfo}; use tracing::info; -use crate::{behaviour::transmission::protocol::TransmissionProtocol, Runtime}; +use crate::{ + behaviour::transmission::protocol::TransmissionProtocol, constant::TRANSMISSION_PROTOCOL, + Runtime, +}; use super::EventHandler; @@ -22,14 +22,14 @@ impl EventHandler> for Runtime { } = info; if !self.peer_set.contains(&peer_id) - && protocol_version.as_bytes() == TransmissionProtocol().protocol_name() + && protocol_version.as_bytes() == TRANSMISSION_PROTOCOL.as_bytes() && protocols.iter().any(|p| { self.swarm .behaviour() .discovery .inner .protocol_names() - .contains(&Cow::Borrowed(p.as_bytes())) + .contains(&Cow::Borrowed(p)) }) { self.peer_set.insert(peer_id); diff --git a/crates/topos-p2p/src/runtime/mod.rs b/crates/topos-p2p/src/runtime/mod.rs index 18ed48ae2..c91f42f79 100644 --- a/crates/topos-p2p/src/runtime/mod.rs +++ b/crates/topos-p2p/src/runtime/mod.rs @@ -226,7 +226,7 @@ impl Runtime { )) => {} SwarmEvent::ConnectionEstablished { .. } => {} - SwarmEvent::Dialing(_) => {} + SwarmEvent::Dialing { .. } => {} SwarmEvent::IncomingConnection { .. } => {} SwarmEvent::NewListenAddr { .. } => {} SwarmEvent::Behaviour(ComposedEvent::Gossipsub(_)) => {} @@ -235,6 +235,7 @@ impl Runtime { local_addr, send_back_addr, error, + .. } => { warn!("IncomingConnectionError: local_addr: {local_addr:?}, send_back_addr: {send_back_addr:?}, error: {error:?}"); } diff --git a/tools/docker-compose.yml b/tools/docker-compose.yml index a98956592..3ec5f3f02 100644 --- a/tools/docker-compose.yml +++ b/tools/docker-compose.yml @@ -122,6 +122,70 @@ services: - AUTOHEAL_INTERVAL=30 - CURL_TIMEOUT=30 + prometheus: + image: prom/prometheus + restart: always + volumes: + - ./prometheus:/etc/prometheus/ + - prometheus_data:/prometheus + command: + - '--config.file=/etc/prometheus/prometheus.yml' + - '--storage.tsdb.path=/prometheus' + - '--web.console.libraries=/usr/share/prometheus/console_libraries' + - '--web.console.templates=/usr/share/prometheus/consoles' + ports: + - 9090:9090 + links: + - cadvisor:cadvisor + depends_on: + - cadvisor + # + # node-exporter: + # image: prom/node-exporter + # volumes: + # - /proc:/host/proc:ro + # - /sys:/host/sys:ro + # - /:/rootfs:ro + # command: + # - '--path.procfs=/host/proc' + # - '--path.sysfs=/host/sys' + # - --collector.filesystem.ignored-mount-points + # - '^/(sys|proc|dev|host|etc|rootfs/var/lib/docker/containers|rootfs/var/lib/docker/overlay2|rootfs/run/docker/netns|rootfs/var/lib/docker/aufs)($$|/)' + # ports: + # - 9100:9100 + # restart: always + # deploy: + # mode: global + + cadvisor: + image: gcr.io/cadvisor/cadvisor + volumes: + - /:/rootfs:ro + - /var/run:/var/run:rw + - /sys:/sys:ro + - /var/lib/docker/:/var/lib/docker:ro + ports: + - 8080:8080 + restart: always + deploy: + mode: global + + grafana: + image: grafana/grafana + user: '472' + restart: always + environment: + GF_INSTALL_PLUGINS: 'grafana-clock-panel,grafana-simple-json-datasource' + volumes: + - grafana_data:/var/lib/grafana + - ./grafana/provisioning/:/etc/grafana/provisioning/ + env_file: + - ./grafana/config.monitoring + ports: + - 6000:3000 + depends_on: + - prometheus + volumes: shared: prometheus_data: {} @@ -131,5 +195,3 @@ volumes: networks: monitoring: driver: bridge - - diff --git a/tools/env/base.env b/tools/env/base.env index ad590a804..dff3066d2 100644 --- a/tools/env/base.env +++ b/tools/env/base.env @@ -1,3 +1,3 @@ -RUST_LOG=info +RUST_LOG=warn TOOLCHAIN_VERSION=stable RUST_BACKTRACE=full diff --git a/tools/env/node.env b/tools/env/node.env index 07f6bf117..c58bae732 100644 --- a/tools/env/node.env +++ b/tools/env/node.env @@ -1,4 +1,4 @@ -RUST_LOG=warn,topos=debug +RUST_LOG=warn,topos=warn LOCAL_TEST_NET=true TCE_DB_PATH=/tmp/default-db diff --git a/tools/env/spammer.env b/tools/env/spammer.env index 3a6ea0bbb..a8aa23fbc 100644 --- a/tools/env/spammer.env +++ b/tools/env/spammer.env @@ -1,7 +1,7 @@ RUST_LOG=info -TOPOS_NETWORK_SPAMMER_CERT_PER_BATCH=50 +TOPOS_NETWORK_SPAMMER_CERT_PER_BATCH=20 TOPOS_NETWORK_SPAMMER_BATCH_INTERVAL=1000 TOPOS_NETWORK_SPAMMER_TARGET_NODES_PATH=/tmp/shared/peer_nodes.json TOPOS_NETWORK_SPAMMER_NUMBER_OF_SUBNETS=1 -TOPOS_NETWORK_SPAMMER_NUMBER_OF_BATCHES=10 +TOPOS_NETWORK_SPAMMER_NUMBER_OF_BATCHES=60 TOPOS_OTLP_SERVICE_NAME=simon-spammer diff --git a/tools/grafana/config.monitoring b/tools/grafana/config.monitoring new file mode 100644 index 000000000..4f72974d2 --- /dev/null +++ b/tools/grafana/config.monitoring @@ -0,0 +1,3 @@ +GF_SECURITY_ADMIN_USER=admin +GF_SECURITY_ADMIN_PASSWORD=admin +GF_USERS_ALLOW_SIGN_UP=false diff --git a/tools/prometheus.yaml b/tools/prometheus.yaml index a8477547e..318c6d16d 100644 --- a/tools/prometheus.yaml +++ b/tools/prometheus.yaml @@ -1,6 +1,5 @@ scrape_configs: - - job_name: 'otel-collector' - scrape_interval: 10s + - job_name: 'peers' + scrape_interval: 1s static_configs: - - targets: ['otel-collector:8889'] - - targets: ['otel-collector:8888'] + - targets: ['boot:3000', 'peer_1:3000'] diff --git a/tools/prometheus/prometheus.yml b/tools/prometheus/prometheus.yml new file mode 100644 index 000000000..b1543d440 --- /dev/null +++ b/tools/prometheus/prometheus.yml @@ -0,0 +1,23 @@ +# my global config +global: + scrape_interval: 15s # By default, scrape targets every 15 seconds. + evaluation_interval: 15s # By default, scrape targets every 15 seconds. +scrape_configs: + + # - job_name: app + # scrape_interval: 5s + # static_configs: + # - targets: ['host.docker.internal:8000'] + # + - job_name: 'prometheus' + + # Override the global default and scrape targets from this job every 5 seconds. + scrape_interval: 5s + + static_configs: + - targets: ['localhost:9090'] + + - job_name: 'peers' + scrape_interval: 1s + static_configs: + - targets: ['boot:3000', 'tools-peer-1:3000']