From 0060ec51e4a2bb3383028c06e688816a6aaafd80 Mon Sep 17 00:00:00 2001 From: Yiannis Marangos Date: Mon, 8 Jul 2024 14:54:25 +0300 Subject: [PATCH] fix(node): Patch unreleased libp2p version to include syncing bug fixes (#290) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Mikołaj Florkiewicz Co-authored-by: Maciej Zwoliński --- Cargo.lock | 192 ++++++++++++++--------------------------- Cargo.toml | 14 ++- node-wasm/Cargo.toml | 5 ++ node-wasm/src/utils.rs | 2 +- node/src/p2p.rs | 18 +--- 5 files changed, 86 insertions(+), 145 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 68bf34b5..c8833269 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -360,19 +360,6 @@ dependencies = [ "syn 2.0.66", ] -[[package]] -name = "asynchronous-codec" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4057f2c32adbb2fc158e22fb38433c8e9bbf76b75a4732c7c0cbaf695fb65568" -dependencies = [ - "bytes", - "futures-sink", - "futures-util", - "memchr", - "pin-project-lite", -] - [[package]] name = "asynchronous-codec" version = "0.7.0" @@ -510,12 +497,6 @@ version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4cbbc9d0964165b47557570cce6c952866c2678457aca742aafc9fb771d30270" -[[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" @@ -549,7 +530,7 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "defcc80a305e89c8fb185e4ce9d068ea48f03baebf1dbc8549fb36131dbc61ce" dependencies = [ - "asynchronous-codec 0.7.0", + "asynchronous-codec", "blockstore", "bytes", "cid", @@ -828,7 +809,7 @@ dependencies = [ name = "celestia-types" version = "0.2.0" dependencies = [ - "base64 0.22.1", + "base64", "bech32", "blockstore", "bytes", @@ -2413,7 +2394,7 @@ version = "0.23.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "039db9fe25cd63b7221c3f8788c1ef4ea07987d40ec25a1e7d7a3c3e3e3fd130" dependencies = [ - "base64 0.22.1", + "base64", "futures-channel", "futures-util", "gloo-net", @@ -2466,7 +2447,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fb25cab482c8512c4f3323a5c90b95a3b8f7c90681a87bf7a68b942d52f08933" dependencies = [ "async-trait", - "base64 0.22.1", + "base64", "http-body 1.0.0", "hyper 1.3.1", "hyper-rustls", @@ -2574,16 +2555,14 @@ checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" [[package]] name = "libp2p" -version = "0.53.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "681fb3f183edfbedd7a57d32ebe5dcdc0b9f94061185acf3c30249349cc6fc99" +version = "0.54.0" +source = "git+https://github.com/libp2p/rust-libp2p?rev=60e32c9d3b4bee42ac698791e917e1587eaa1388#60e32c9d3b4bee42ac698791e917e1587eaa1388" dependencies = [ "bytes", "either", "futures", "futures-timer", "getrandom", - "instant", "libp2p-allow-block-list", "libp2p-autonat", "libp2p-connection-limits", @@ -2613,8 +2592,7 @@ dependencies = [ [[package]] name = "libp2p-allow-block-list" version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "107b238b794cb83ab53b74ad5dcf7cca3200899b72fe662840cfb52f5b0a32e6" +source = "git+https://github.com/libp2p/rust-libp2p?rev=60e32c9d3b4bee42ac698791e917e1587eaa1388#60e32c9d3b4bee42ac698791e917e1587eaa1388" dependencies = [ "libp2p-core", "libp2p-identity", @@ -2624,30 +2602,28 @@ dependencies = [ [[package]] name = "libp2p-autonat" -version = "0.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d95151726170e41b591735bf95c42b888fe4aa14f65216a9fbf0edcc04510586" +version = "0.12.1" +source = "git+https://github.com/libp2p/rust-libp2p?rev=60e32c9d3b4bee42ac698791e917e1587eaa1388#60e32c9d3b4bee42ac698791e917e1587eaa1388" dependencies = [ "async-trait", - "asynchronous-codec 0.6.2", + "asynchronous-codec", "futures", "futures-timer", - "instant", "libp2p-core", "libp2p-identity", "libp2p-request-response", "libp2p-swarm", "quick-protobuf", - "quick-protobuf-codec 0.2.0", + "quick-protobuf-codec", "rand", "tracing", + "web-time", ] [[package]] name = "libp2p-connection-limits" version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7cd50a78ccfada14de94cbacd3ce4b0138157f376870f13d3a8422cd075b4fd" +source = "git+https://github.com/libp2p/rust-libp2p?rev=60e32c9d3b4bee42ac698791e917e1587eaa1388#60e32c9d3b4bee42ac698791e917e1587eaa1388" dependencies = [ "libp2p-core", "libp2p-identity", @@ -2657,15 +2633,13 @@ dependencies = [ [[package]] name = "libp2p-core" -version = "0.41.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8130a8269e65a2554d55131c770bdf4bcd94d2b8d4efb24ca23699be65066c05" +version = "0.41.3" +source = "git+https://github.com/libp2p/rust-libp2p?rev=60e32c9d3b4bee42ac698791e917e1587eaa1388#60e32c9d3b4bee42ac698791e917e1587eaa1388" dependencies = [ "either", "fnv", "futures", "futures-timer", - "instant", "libp2p-identity", "multiaddr", "multihash", @@ -2682,13 +2656,13 @@ dependencies = [ "tracing", "unsigned-varint 0.8.0", "void", + "web-time", ] [[package]] name = "libp2p-dns" version = "0.41.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d17cbcf7160ff35c3e8e560de4a068fe9d6cb777ea72840e48eb76ff9576c4b6" +source = "git+https://github.com/libp2p/rust-libp2p?rev=60e32c9d3b4bee42ac698791e917e1587eaa1388#60e32c9d3b4bee42ac698791e917e1587eaa1388" dependencies = [ "async-trait", "futures", @@ -2702,12 +2676,11 @@ dependencies = [ [[package]] name = "libp2p-gossipsub" -version = "0.46.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d665144a616dadebdc5fff186b1233488cdcd8bfb1223218ff084b6d052c94f7" +version = "0.46.2" +source = "git+https://github.com/libp2p/rust-libp2p?rev=60e32c9d3b4bee42ac698791e917e1587eaa1388#60e32c9d3b4bee42ac698791e917e1587eaa1388" dependencies = [ - "asynchronous-codec 0.7.0", - "base64 0.21.7", + "asynchronous-codec", + "base64", "byteorder", "bytes", "either", @@ -2716,13 +2689,12 @@ dependencies = [ "futures-ticker", "getrandom", "hex_fmt", - "instant", "libp2p-core", "libp2p-identity", "libp2p-swarm", "prometheus-client", "quick-protobuf", - "quick-protobuf-codec 0.3.1", + "quick-protobuf-codec", "rand", "regex", "serde", @@ -2730,15 +2702,15 @@ dependencies = [ "smallvec", "tracing", "void", + "web-time", ] [[package]] name = "libp2p-identify" version = "0.44.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5d635ebea5ca0c3c3e77d414ae9b67eccf2a822be06091b9c1a0d13029a1e2f" +source = "git+https://github.com/libp2p/rust-libp2p?rev=60e32c9d3b4bee42ac698791e917e1587eaa1388#60e32c9d3b4bee42ac698791e917e1587eaa1388" dependencies = [ - "asynchronous-codec 0.7.0", + "asynchronous-codec", "either", "futures", "futures-bounded", @@ -2748,7 +2720,7 @@ dependencies = [ "libp2p-swarm", "lru", "quick-protobuf", - "quick-protobuf-codec 0.3.1", + "quick-protobuf-codec", "smallvec", "thiserror", "tracing", @@ -2776,24 +2748,22 @@ dependencies = [ [[package]] name = "libp2p-kad" -version = "0.45.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cc5767727d062c4eac74dd812c998f0e488008e82cce9c33b463d38423f9ad2" +version = "0.46.0" +source = "git+https://github.com/libp2p/rust-libp2p?rev=60e32c9d3b4bee42ac698791e917e1587eaa1388#60e32c9d3b4bee42ac698791e917e1587eaa1388" dependencies = [ "arrayvec", - "asynchronous-codec 0.7.0", + "asynchronous-codec", "bytes", "either", "fnv", "futures", "futures-bounded", "futures-timer", - "instant", "libp2p-core", "libp2p-identity", "libp2p-swarm", "quick-protobuf", - "quick-protobuf-codec 0.3.1", + "quick-protobuf-codec", "rand", "serde", "sha2 0.10.8", @@ -2802,13 +2772,13 @@ dependencies = [ "tracing", "uint", "void", + "web-time", ] [[package]] name = "libp2p-mdns" version = "0.45.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49007d9a339b3e1d7eeebc4d67c05dbf23d300b7d091193ec2d3f26802d7faf2" +source = "git+https://github.com/libp2p/rust-libp2p?rev=60e32c9d3b4bee42ac698791e917e1587eaa1388#60e32c9d3b4bee42ac698791e917e1587eaa1388" dependencies = [ "data-encoding", "futures", @@ -2827,12 +2797,10 @@ dependencies = [ [[package]] name = "libp2p-metrics" -version = "0.14.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fdac91ae4f291046a3b2660c039a2830c931f84df2ee227989af92f7692d3357" +version = "0.14.2" +source = "git+https://github.com/libp2p/rust-libp2p?rev=60e32c9d3b4bee42ac698791e917e1587eaa1388#60e32c9d3b4bee42ac698791e917e1587eaa1388" dependencies = [ "futures", - "instant", "libp2p-core", "libp2p-gossipsub", "libp2p-identify", @@ -2842,15 +2810,15 @@ dependencies = [ "libp2p-swarm", "pin-project", "prometheus-client", + "web-time", ] [[package]] name = "libp2p-noise" version = "0.44.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ecd0545ce077f6ea5434bcb76e8d0fe942693b4380aaad0d34a358c2bd05793" +source = "git+https://github.com/libp2p/rust-libp2p?rev=60e32c9d3b4bee42ac698791e917e1587eaa1388#60e32c9d3b4bee42ac698791e917e1587eaa1388" dependencies = [ - "asynchronous-codec 0.7.0", + "asynchronous-codec", "bytes", "curve25519-dalek", "futures", @@ -2872,27 +2840,25 @@ dependencies = [ [[package]] name = "libp2p-ping" -version = "0.44.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1de5a6cf64fba7f7e8f2102711c9c6c043a8e56b86db8cd306492c517da3fb3" +version = "0.44.2" +source = "git+https://github.com/libp2p/rust-libp2p?rev=60e32c9d3b4bee42ac698791e917e1587eaa1388#60e32c9d3b4bee42ac698791e917e1587eaa1388" dependencies = [ "either", "futures", "futures-timer", - "instant", "libp2p-core", "libp2p-identity", "libp2p-swarm", "rand", "tracing", "void", + "web-time", ] [[package]] name = "libp2p-quic" version = "0.10.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c67296ad4e092e23f92aea3d2bdb6f24eab79c0929ed816dfb460ea2f4567d2b" +source = "git+https://github.com/libp2p/rust-libp2p?rev=60e32c9d3b4bee42ac698791e917e1587eaa1388#60e32c9d3b4bee42ac698791e917e1587eaa1388" dependencies = [ "bytes", "futures", @@ -2914,15 +2880,13 @@ dependencies = [ [[package]] name = "libp2p-request-response" -version = "0.26.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c314fe28368da5e3a262553fb0ad575c1c8934c461e10de10265551478163836" +version = "0.26.4" +source = "git+https://github.com/libp2p/rust-libp2p?rev=60e32c9d3b4bee42ac698791e917e1587eaa1388#60e32c9d3b4bee42ac698791e917e1587eaa1388" dependencies = [ "async-trait", "futures", "futures-bounded", "futures-timer", - "instant", "libp2p-core", "libp2p-identity", "libp2p-swarm", @@ -2930,20 +2894,19 @@ dependencies = [ "smallvec", "tracing", "void", + "web-time", ] [[package]] name = "libp2p-swarm" -version = "0.44.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80cae6cb75f89dbca53862f9ebe0b9f463aa7b302762fcfaafb9e51dcc9b0f7e" +version = "0.44.3" +source = "git+https://github.com/libp2p/rust-libp2p?rev=60e32c9d3b4bee42ac698791e917e1587eaa1388#60e32c9d3b4bee42ac698791e917e1587eaa1388" dependencies = [ "either", "fnv", "futures", "futures-timer", "getrandom", - "instant", "libp2p-core", "libp2p-identity", "libp2p-swarm-derive", @@ -2956,13 +2919,13 @@ dependencies = [ "tracing", "void", "wasm-bindgen-futures", + "web-time", ] [[package]] name = "libp2p-swarm-derive" version = "0.34.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5daceb9dd908417b6dfcfe8e94098bc4aac54500c282e78120b885dadc09b999" +source = "git+https://github.com/libp2p/rust-libp2p?rev=60e32c9d3b4bee42ac698791e917e1587eaa1388#60e32c9d3b4bee42ac698791e917e1587eaa1388" dependencies = [ "heck 0.5.0", "proc-macro2", @@ -2972,9 +2935,8 @@ dependencies = [ [[package]] name = "libp2p-tcp" -version = "0.41.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b2460fc2748919adff99ecbc1aab296e4579e41f374fb164149bd2c9e529d4c" +version = "0.41.1" +source = "git+https://github.com/libp2p/rust-libp2p?rev=60e32c9d3b4bee42ac698791e917e1587eaa1388#60e32c9d3b4bee42ac698791e917e1587eaa1388" dependencies = [ "futures", "futures-timer", @@ -2990,8 +2952,7 @@ dependencies = [ [[package]] name = "libp2p-tls" version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "251b17aebdd29df7e8f80e4d94b782fae42e934c49086e1a81ba23b60a8314f2" +source = "git+https://github.com/libp2p/rust-libp2p?rev=60e32c9d3b4bee42ac698791e917e1587eaa1388#60e32c9d3b4bee42ac698791e917e1587eaa1388" dependencies = [ "futures", "futures-rustls", @@ -3009,8 +2970,7 @@ dependencies = [ [[package]] name = "libp2p-upnp" version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cccf04b0e3ff3de52d07d5fd6c3b061d0e7f908ffc683c32d9638caedce86fc8" +source = "git+https://github.com/libp2p/rust-libp2p?rev=60e32c9d3b4bee42ac698791e917e1587eaa1388#60e32c9d3b4bee42ac698791e917e1587eaa1388" dependencies = [ "futures", "futures-timer", @@ -3024,9 +2984,8 @@ dependencies = [ [[package]] name = "libp2p-webtransport-websys" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "840b63681e3bedbdb3df3e4f2dd48e9a20d2c6714264829ab90c6fce8549d627" +version = "0.3.0" +source = "git+https://github.com/libp2p/rust-libp2p?rev=60e32c9d3b4bee42ac698791e917e1587eaa1388#60e32c9d3b4bee42ac698791e917e1587eaa1388" dependencies = [ "futures", "js-sys", @@ -3045,9 +3004,8 @@ dependencies = [ [[package]] name = "libp2p-yamux" -version = "0.45.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "200cbe50349a44760927d50b431d77bed79b9c0a3959de1af8d24a63434b71e5" +version = "0.45.2" +source = "git+https://github.com/libp2p/rust-libp2p?rev=60e32c9d3b4bee42ac698791e917e1587eaa1388#60e32c9d3b4bee42ac698791e917e1587eaa1388" dependencies = [ "either", "futures", @@ -3385,15 +3343,14 @@ checksum = "defc4c55412d89136f966bbb339008b474350e5e6e78d2714439c386b3137a03" [[package]] name = "multistream-select" version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea0df8e5eec2298a62b326ee4f0d7fe1a6b90a09dfcf9df37b38f947a8c42f19" +source = "git+https://github.com/libp2p/rust-libp2p?rev=60e32c9d3b4bee42ac698791e917e1587eaa1388#60e32c9d3b4bee42ac698791e917e1587eaa1388" dependencies = [ "bytes", "futures", - "log", "pin-project", "smallvec", - "unsigned-varint 0.7.2", + "tracing", + "unsigned-varint 0.8.0", ] [[package]] @@ -3682,7 +3639,7 @@ version = "3.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e459365e590736a54c3fa561947c84837534b8e9af6fc5bf781307e82658fae" dependencies = [ - "base64 0.22.1", + "base64", "serde", ] @@ -3984,26 +3941,12 @@ dependencies = [ "byteorder", ] -[[package]] -name = "quick-protobuf-codec" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8ededb1cd78531627244d51dd0c7139fbe736c7d57af0092a76f0ffb2f56e98" -dependencies = [ - "asynchronous-codec 0.6.2", - "bytes", - "quick-protobuf", - "thiserror", - "unsigned-varint 0.7.2", -] - [[package]] name = "quick-protobuf-codec" version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15a0580ab32b169745d7a39db2ba969226ca16738931be152a3209b409de2474" +source = "git+https://github.com/libp2p/rust-libp2p?rev=60e32c9d3b4bee42ac698791e917e1587eaa1388#60e32c9d3b4bee42ac698791e917e1587eaa1388" dependencies = [ - "asynchronous-codec 0.7.0", + "asynchronous-codec", "bytes", "quick-protobuf", "thiserror", @@ -4479,7 +4422,7 @@ version = "2.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "29993a25686778eb88d4189742cd713c9bce943bc54251a33509dc63cbacf73d" dependencies = [ - "base64 0.22.1", + "base64", "rustls-pki-types", ] @@ -4546,8 +4489,7 @@ checksum = "955d28af4278de8121b7ebeb796b6a45735dc01436d898801014aced2773a3d6" [[package]] name = "rw-stream-sink" version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8c9026ff5d2f23da5e45bbc283f156383001bfb09c4e44256d02c1a685fe9a1" +source = "git+https://github.com/libp2p/rust-libp2p?rev=60e32c9d3b4bee42ac698791e917e1587eaa1388#60e32c9d3b4bee42ac698791e917e1587eaa1388" dependencies = [ "futures", "pin-project", @@ -4860,7 +4802,7 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "37468c595637c10857701c990f93a40ce0e357cedb0953d1c26c8d8027f9bb53" dependencies = [ - "base64 0.22.1", + "base64", "bytes", "futures", "httparse", @@ -5421,10 +5363,6 @@ name = "unsigned-varint" version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6889a77d49f1f013504cec6bf97a2c730394adedaeb1deb5ea08949a50541105" -dependencies = [ - "asynchronous-codec 0.6.2", - "bytes", -] [[package]] name = "unsigned-varint" diff --git a/Cargo.toml b/Cargo.toml index 1418f602..11a158a9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,7 +9,7 @@ lumina-node-wasm = { version = "0.1.1", path = "node-wasm" } celestia-proto = { version = "0.2.0", path = "proto" } celestia-rpc = { version = "0.2.0", path = "rpc", default-features = false } celestia-types = { version = "0.2.0", path = "types", default-features = false } -libp2p = "0.53.2" +libp2p = "0.54" nmt-rs = "0.2.0" celestia-tendermint = { version = "0.32.1", default-features = false } celestia-tendermint-proto = "0.32.1" @@ -20,3 +20,15 @@ celestia-tendermint-proto = "0.32.1" #celestia-tendermint = { path = "../celestia-tendermint-rs/tendermint" } #celestia-tendermint-proto = { path = "../celestia-tendermint-rs/proto" } #nmt-rs = { path = "../nmt-rs" } +#libp2p = { path = "../../rust-libp2p/libp2p" } +#libp2p-core = { path = "../../rust-libp2p/core" } +#libp2p-swarm = { path = "../../rust-libp2p/swarm" } + +libp2p = { git = "https://github.com/libp2p/rust-libp2p", rev = "60e32c9d3b4bee42ac698791e917e1587eaa1388" } +libp2p-core = { git = "https://github.com/libp2p/rust-libp2p", rev = "60e32c9d3b4bee42ac698791e917e1587eaa1388" } +libp2p-swarm = { git = "https://github.com/libp2p/rust-libp2p", rev = "60e32c9d3b4bee42ac698791e917e1587eaa1388" } + +# Uncomment this if you need debug symbols in release. +# Also check node-wasm's `Cargo.toml`. +#[profile.release] +#debug = true diff --git a/node-wasm/Cargo.toml b/node-wasm/Cargo.toml index d9efdc46..82f3fb54 100644 --- a/node-wasm/Cargo.toml +++ b/node-wasm/Cargo.toml @@ -72,3 +72,8 @@ web-sys = { version = "0.3.69", features = [ [package.metadata.docs.rs] targets = ["wasm32-unknown-unknown"] + +# Uncomment this if you need debug symbols in release. +# Also check workspace's `Cargo.toml`. +#[package.metadata.wasm-pack.profile.release] +#wasm-opt = ['-O4', '-g'] diff --git a/node-wasm/src/utils.rs b/node-wasm/src/utils.rs index 9e857bb9..3c41180b 100644 --- a/node-wasm/src/utils.rs +++ b/node-wasm/src/utils.rs @@ -45,7 +45,7 @@ pub fn setup_logging() { console_error_panic_hook::set_once(); let fmt_layer = tracing_subscriber::fmt::layer() - .with_ansi(true) // Only partially supported across browsers, but we target only chrome now + .with_ansi(false) .with_timer(UtcTime::rfc_3339()) // std::time is not available in browsers .with_writer(MakeConsoleWriter) // write events to the console .with_filter(LevelFilter::INFO); // TODO: allow customizing the log level diff --git a/node/src/p2p.rs b/node/src/p2p.rs index b6f11175..50053631 100644 --- a/node/src/p2p.rs +++ b/node/src/p2p.rs @@ -48,7 +48,6 @@ use tokio::select; use tokio::sync::{mpsc, oneshot, watch}; use tokio_util::sync::CancellationToken; use tracing::{debug, info, instrument, trace, warn}; -use web_time::Instant; mod header_ex; mod header_session; @@ -77,14 +76,6 @@ pub use crate::p2p::header_ex::HeaderExError; // more aggresively. const MIN_CONNECTED_PEERS: u64 = 4; -// Bootstrap procedure is a bit misleading as a name. It is actually -// scanning the network thought the already known peers and find new -// ones. It also recovers connectivity of previously known peers and -// refreshes the routing table. -// -// libp2p team suggests to start bootstrap procedure every 5 minute. -const KADEMLIA_BOOTSTRAP_PERIOD: Duration = Duration::from_secs(5 * 60); - // Maximum size of a [`Multihash`]. pub(crate) const MAX_MH_SIZE: usize = 64; @@ -655,7 +646,6 @@ where async fn run(&mut self) { let mut report_interval = Interval::new(Duration::from_secs(60)).await; let mut kademlia_interval = Interval::new(Duration::from_secs(30)).await; - let mut kademlia_last_bootstrap = Instant::now(); // Initiate discovery let _ = self.swarm.behaviour_mut().kademlia.bootstrap(); @@ -667,11 +657,9 @@ where } _ = kademlia_interval.tick() => { if self.peer_tracker.info().num_connected_peers < MIN_CONNECTED_PEERS - || kademlia_last_bootstrap.elapsed() > KADEMLIA_BOOTSTRAP_PERIOD { debug!("Running kademlia bootstrap procedure."); let _ = self.swarm.behaviour_mut().kademlia.bootstrap(); - kademlia_last_bootstrap = Instant::now(); } } _ = poll_closed(&mut self.bitswap_queries) => { @@ -1116,13 +1104,11 @@ where S: Store, { let local_peer_id = PeerId::from(args.local_keypair.public()); - let mut config = kad::Config::default(); + let store = kad::store::MemoryStore::new(local_peer_id); let protocol_id = celestia_protocol_id(&args.network_id, "/kad/1.0.0"); + let config = kad::Config::new(protocol_id); - config.set_protocol_names(vec![protocol_id]); - - let store = kad::store::MemoryStore::new(local_peer_id); let mut kademlia = kad::Behaviour::with_config(local_peer_id, store, config); for addr in &args.bootnodes {