From 36fef87a4208dc02521c8db0d284126ecda713d1 Mon Sep 17 00:00:00 2001 From: Shawn Date: Tue, 17 Dec 2024 19:59:35 +0800 Subject: [PATCH] fix: got local docker network running again. --- Cargo.lock | 201 +++++++++++++++++++--------------------- docker-compose.yaml | 6 ++ zilliqa/src/p2p_node.rs | 38 ++++---- 3 files changed, 120 insertions(+), 125 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f8520a7f8..94fb69333 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -361,7 +361,7 @@ dependencies = [ "serde_json", "tokio", "tokio-stream", - "tower 0.5.2", + "tower 0.5.1", "tracing", "wasmtimer", ] @@ -537,7 +537,7 @@ dependencies = [ "serde_json", "thiserror 1.0.69", "tokio", - "tower 0.5.2", + "tower 0.5.1", "tracing", "url", "wasmtimer", @@ -1032,7 +1032,7 @@ dependencies = [ "rustversion", "serde", "sync_wrapper 1.0.2", - "tower 0.5.2", + "tower 0.5.1", "tower-layer", "tower-service", ] @@ -1415,9 +1415,9 @@ dependencies = [ [[package]] name = "bstr" -version = "1.11.1" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "786a307d683a5bf92e6fd5fd69a7eb613751668d1d8d67d802846dfe367c62c8" +checksum = "1a68f1f47cdf0ec8ee4b941b2eee2a80cb796db73118c0dd09ac63fbe405be22" dependencies = [ "memchr", "serde", @@ -1544,7 +1544,7 @@ checksum = "2d886547e41f740c616ae73108f6eb70afe6d940c7bc697cb30f13daec073037" dependencies = [ "camino", "cargo-platform", - "semver 1.0.24", + "semver 1.0.23", "serde", "serde_json", "thiserror 1.0.69", @@ -1567,9 +1567,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.2.4" +version = "1.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9157bbaa6b165880c27a4293a474c91cdcf265cc68cc829bf10be0964a391caf" +checksum = "27f657647bcff5394bf56c7317665bbf790a137a50eaaa5c6bfbb9e27a518f2d" dependencies = [ "jobserver", "libc", @@ -1725,9 +1725,9 @@ dependencies = [ [[package]] name = "clap-verbosity-flag" -version = "3.0.2" +version = "3.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2678fade3b77aa3a8ff3aae87e9c008d3fb00473a41c71fbf74e91c8c7b37e84" +checksum = "54381ae56ad222eea3f529c692879e9c65e07945ae48d3dc4d1cb18dbec8cf44" dependencies = [ "clap", "log", @@ -1875,15 +1875,15 @@ dependencies = [ [[package]] name = "console" -version = "0.15.10" +version = "0.15.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea3c6ecd8059b57859df5c69830340ed3c41d30e3da0c1cbed90a96ac853041b" +checksum = "0e1f83fc076bd6dd27517eacdf25fef6c4dfe5f1d7448bafaaf3a26f13b5e4eb" dependencies = [ "encode_unicode", + "lazy_static", "libc", - "once_cell", - "unicode-width 0.2.0", - "windows-sys 0.59.0", + "unicode-width 0.1.14", + "windows-sys 0.52.0", ] [[package]] @@ -2011,9 +2011,9 @@ dependencies = [ [[package]] name = "crossbeam-deque" -version = "0.8.6" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9dd111b7b7f7d55b72c0a6ae361660ee5853c9af73f70c3c2ef6858b950e2e51" +checksum = "613f8cc01fe9cf1a3eb3d7f488fd2fa8388403e97039e2f73692932e291a770d" dependencies = [ "crossbeam-epoch", "crossbeam-utils", @@ -2030,9 +2030,9 @@ dependencies = [ [[package]] name = "crossbeam-utils" -version = "0.8.21" +version = "0.8.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28" +checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" [[package]] name = "crunchy" @@ -2482,9 +2482,9 @@ dependencies = [ [[package]] name = "encode_unicode" -version = "1.0.0" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34aa73646ffb006b8f5147f3dc182bd4bcb190227ce861fc4a4844bf8e3cb2c0" +checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" [[package]] name = "encoding_rs" @@ -2824,7 +2824,7 @@ dependencies = [ "chrono", "ethers-core", "reqwest 0.11.27", - "semver 1.0.24", + "semver 1.0.23", "serde", "serde_json", "thiserror 1.0.69", @@ -2934,7 +2934,7 @@ dependencies = [ "path-slash", "rayon", "regex", - "semver 1.0.24", + "semver 1.0.23", "serde", "serde_json", "solang-parser", @@ -3013,17 +3013,6 @@ dependencies = [ "bytes", ] -[[package]] -name = "fastrlp" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce8dba4714ef14b8274c371879b175aa55b16b30f269663f19d576f380018dc4" -dependencies = [ - "arrayvec", - "auto_impl", - "bytes", -] - [[package]] name = "ff" version = "0.13.0" @@ -3142,7 +3131,7 @@ dependencies = [ "md-5", "path-slash", "rayon", - "semver 1.0.24", + "semver 1.0.23", "serde", "serde_json", "sha2", @@ -3177,7 +3166,7 @@ dependencies = [ "md-5", "path-slash", "rayon", - "semver 1.0.24", + "semver 1.0.23", "serde", "serde_json", "serde_repr", @@ -3198,7 +3187,7 @@ dependencies = [ "foundry-compilers-artifacts-solc", "foundry-compilers-core", "path-slash", - "semver 1.0.24", + "semver 1.0.23", "serde", ] @@ -3213,7 +3202,7 @@ dependencies = [ "dunce", "path-slash", "regex", - "semver 1.0.24", + "semver 1.0.23", "serde", "serde_json", "svm-rs 0.5.7", @@ -3351,7 +3340,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a8f2f12607f92c69b12ed746fabf9ca4f5c482cba46679c1a75b874ed7c26adb" dependencies = [ "futures-io", - "rustls 0.23.20", + "rustls 0.23.19", "rustls-pki-types", ] @@ -3419,7 +3408,7 @@ dependencies = [ "async-stream", "async-trait", "dyn-clone", - "hyper 1.5.2", + "hyper 1.5.1", "log", "reqwest 0.12.9", "serde", @@ -3805,11 +3794,11 @@ dependencies = [ [[package]] name = "home" -version = "0.5.11" +version = "0.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "589533453244b0995c858700322199b2becb13b627df2851f64a2775d024abcf" +checksum = "e3d1354bf6b7235cb4a0576c2619fd4ed18183f689b12b006a0ee7329eeff9a5" dependencies = [ - "windows-sys 0.59.0", + "windows-sys 0.52.0", ] [[package]] @@ -3908,9 +3897,9 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" [[package]] name = "hyper" -version = "0.14.32" +version = "0.14.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41dfc780fdec9373c01bae43289ea34c972e40ee3c9f6b3c8801a35f35586ce7" +checksum = "8c08302e8fa335b151b788c775ff56e7a03ae64ff85c548ee820fecb70356e85" dependencies = [ "bytes", "futures-channel", @@ -3932,9 +3921,9 @@ dependencies = [ [[package]] name = "hyper" -version = "1.5.2" +version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "256fb8d4bd6413123cc9d91832d78325c48ff41677595be797d90f42969beae0" +checksum = "97818827ef4f364230e16705d4706e2897df2bb60617d6ca15d598025a3c481f" dependencies = [ "bytes", "futures-channel", @@ -3959,7 +3948,7 @@ checksum = "ec3efd23720e2049821a693cbc7e65ea87c72f1c58ff2f9522ff332b1491e590" dependencies = [ "futures-util", "http 0.2.12", - "hyper 0.14.32", + "hyper 0.14.31", "rustls 0.21.12", "tokio", "tokio-rustls 0.24.1", @@ -3973,7 +3962,7 @@ checksum = "399c78f9338483cb7e630c8474b07268983c6bd5acee012e4211f9f7bb21b070" dependencies = [ "futures-util", "http 0.2.12", - "hyper 0.14.32", + "hyper 0.14.31", "log", "rustls 0.22.4", "rustls-native-certs 0.7.3", @@ -3990,10 +3979,10 @@ checksum = "08afdbb5c31130e3034af566421053ab03787c640246a446327f550d11bcb333" dependencies = [ "futures-util", "http 1.2.0", - "hyper 1.5.2", + "hyper 1.5.1", "hyper-util", "log", - "rustls 0.23.20", + "rustls 0.23.19", "rustls-native-certs 0.8.1", "rustls-pki-types", "tokio", @@ -4008,7 +3997,7 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b90d566bffbce6a75bd8b09a05aa8c2cb1fabb6cb348f8840c9e4c90a0d83b0" dependencies = [ - "hyper 1.5.2", + "hyper 1.5.1", "hyper-util", "pin-project-lite", "tokio", @@ -4022,7 +4011,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" dependencies = [ "bytes", - "hyper 0.14.32", + "hyper 0.14.31", "native-tls", "tokio", "tokio-native-tls", @@ -4039,7 +4028,7 @@ dependencies = [ "futures-util", "http 1.2.0", "http-body 1.0.1", - "hyper 1.5.2", + "hyper 1.5.1", "pin-project-lite", "socket2", "tokio", @@ -4260,7 +4249,7 @@ dependencies = [ "futures", "http 1.2.0", "http-body-util", - "hyper 1.5.2", + "hyper 1.5.1", "hyper-util", "log", "rand", @@ -4572,7 +4561,7 @@ dependencies = [ "http 1.2.0", "jsonrpsee-core", "pin-project", - "rustls 0.23.20", + "rustls 0.23.19", "rustls-pki-types", "rustls-platform-verifier", "soketto", @@ -4620,12 +4609,12 @@ dependencies = [ "async-trait", "base64 0.22.1", "http-body 1.0.1", - "hyper 1.5.2", + "hyper 1.5.1", "hyper-rustls 0.27.3", "hyper-util", "jsonrpsee-core", "jsonrpsee-types", - "rustls 0.23.20", + "rustls 0.23.19", "rustls-platform-verifier", "serde", "serde_json", @@ -4659,7 +4648,7 @@ dependencies = [ "http 1.2.0", "http-body 1.0.1", "http-body-util", - "hyper 1.5.2", + "hyper 1.5.1", "hyper-util", "jsonrpsee-core", "jsonrpsee-types", @@ -5176,7 +5165,7 @@ dependencies = [ "quinn", "rand", "ring 0.17.8", - "rustls 0.23.20", + "rustls 0.23.19", "socket2", "thiserror 2.0.7", "tokio", @@ -5263,7 +5252,7 @@ dependencies = [ "libp2p-identity", "rcgen", "ring 0.17.8", - "rustls 0.23.20", + "rustls 0.23.19", "rustls-webpki 0.101.7", "thiserror 2.0.7", "x509-parser", @@ -5894,7 +5883,7 @@ dependencies = [ "http 1.2.0", "http-body 1.0.1", "http-body-util", - "hyper 1.5.2", + "hyper 1.5.1", "hyper-rustls 0.27.3", "hyper-timeout", "hyper-util", @@ -5909,7 +5898,7 @@ dependencies = [ "serde_urlencoded", "snafu", "tokio", - "tower 0.5.2", + "tower 0.5.1", "tower-http", "tracing", "url", @@ -6180,7 +6169,7 @@ checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" dependencies = [ "cfg-if", "libc", - "redox_syscall 0.5.8", + "redox_syscall 0.5.7", "smallvec", "windows-targets 0.52.6", ] @@ -6805,7 +6794,7 @@ dependencies = [ "quinn-proto", "quinn-udp", "rustc-hash 2.1.0", - "rustls 0.23.20", + "rustls 0.23.19", "socket2", "thiserror 2.0.7", "tokio", @@ -6823,7 +6812,7 @@ dependencies = [ "rand", "ring 0.17.8", "rustc-hash 2.1.0", - "rustls 0.23.20", + "rustls 0.23.19", "rustls-pki-types", "slab", "thiserror 2.0.7", @@ -6944,9 +6933,9 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.5.8" +version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03a862b389f93e68874fbf580b9de08dd02facb9a788ebadaf4a3fd33cf58834" +checksum = "9b6dfecf2c74bce2466cabf93f6664d6998a69eb21e39f4207930065b27b771f" dependencies = [ "bitflags 2.6.0", ] @@ -7030,7 +7019,7 @@ dependencies = [ "h2 0.3.26", "http 0.2.12", "http-body 0.4.6", - "hyper 0.14.32", + "hyper 0.14.31", "hyper-rustls 0.24.2", "hyper-tls", "ipnet", @@ -7076,7 +7065,7 @@ dependencies = [ "http 1.2.0", "http-body 1.0.1", "http-body-util", - "hyper 1.5.2", + "hyper 1.5.1", "hyper-rustls 0.27.3", "hyper-util", "ipnet", @@ -7087,7 +7076,7 @@ dependencies = [ "percent-encoding", "pin-project-lite", "quinn", - "rustls 0.23.20", + "rustls 0.23.19", "rustls-native-certs 0.8.1", "rustls-pemfile 2.2.0", "rustls-pki-types", @@ -7326,18 +7315,16 @@ dependencies = [ [[package]] name = "ruint" -version = "1.12.4" +version = "1.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5ef8fb1dd8de3870cb8400d51b4c2023854bbafd5431a3ac7e7317243e22d2f" +checksum = "2c3cc4c2511671f327125da14133d0c5c5d137f006a1017a16f557bc85b16286" dependencies = [ "alloy-rlp", "ark-ff 0.3.0", "ark-ff 0.4.2", "bytes", - "fastrlp 0.3.1", - "fastrlp 0.4.0", + "fastrlp", "num-bigint", - "num-integer", "num-traits", "parity-scale-codec", "primitive-types", @@ -7412,7 +7399,7 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" dependencies = [ - "semver 1.0.24", + "semver 1.0.23", ] [[package]] @@ -7465,9 +7452,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.23.20" +version = "0.23.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5065c3f250cbd332cd894be57c40fa52387247659b14a2d6041d121547903b1b" +checksum = "934b404430bb06b3fae2cba809eb45a1ab1aecd64491213d7c3301b88393f8d1" dependencies = [ "aws-lc-rs", "log", @@ -7524,9 +7511,9 @@ dependencies = [ [[package]] name = "rustls-pki-types" -version = "1.10.1" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2bf47e6ff922db3825eb750c4e2ff784c6ff8fb9e13046ef6a1d1c5401b0b37" +checksum = "16f1201b3c9a7ee8039bcadc17b7e605e2945b27eee7631788c1bd2b0643674b" dependencies = [ "web-time", ] @@ -7542,7 +7529,7 @@ dependencies = [ "jni", "log", "once_cell", - "rustls 0.23.20", + "rustls 0.23.19", "rustls-native-certs 0.7.3", "rustls-platform-verifier-android", "rustls-webpki 0.102.8", @@ -7665,9 +7652,9 @@ dependencies = [ [[package]] name = "scc" -version = "2.2.6" +version = "2.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94b13f8ea6177672c49d12ed964cca44836f59621981b04a3e26b87e675181de" +checksum = "66b202022bb57c049555430e11fc22fea12909276a80a4c3d368da36ac1d88ed" dependencies = [ "sdd", ] @@ -7752,9 +7739,9 @@ dependencies = [ [[package]] name = "sdd" -version = "3.0.5" +version = "3.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "478f121bb72bbf63c52c93011ea1791dca40140dfe13f8336c4c5ac952c33aa9" +checksum = "49c1eeaf4b6a87c7479688c6d52b9f1153cedd3c489300564f932b065c6eab95" [[package]] name = "seahash" @@ -7853,9 +7840,9 @@ dependencies = [ [[package]] name = "semver" -version = "1.0.24" +version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3cb6eb87a131f756572d7fb904f6e7b68633f09cca868c5df1c4b8d1a694bbba" +checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" dependencies = [ "serde", ] @@ -8244,7 +8231,7 @@ dependencies = [ "either", "num-bigint", "num-rational", - "semver 1.0.24", + "semver 1.0.23", "solar-data-structures", "solar-interface", "solar-macros", @@ -8453,7 +8440,7 @@ dependencies = [ "hex", "once_cell", "reqwest 0.11.27", - "semver 1.0.24", + "semver 1.0.23", "serde", "serde_json", "sha2", @@ -8472,14 +8459,14 @@ dependencies = [ "dirs", "fs4", "reqwest 0.12.9", - "semver 1.0.24", + "semver 1.0.23", "serde", "serde_json", "sha2", "tempfile", "thiserror 1.0.69", "url", - "zip 2.2.2", + "zip 2.2.1", ] [[package]] @@ -8490,7 +8477,7 @@ checksum = "f2fa0f145894cb4d1c14446f08098ee5f21fc37ccbd1a7dd9dd355bbc806de3b" dependencies = [ "build_const", "const-hex", - "semver 1.0.24", + "semver 1.0.23", "serde_json", "svm-rs 0.5.7", ] @@ -8940,7 +8927,7 @@ version = "0.26.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5f6d0975eaace0cf0fcadee4e4aaa5da15b5c079146f2cffb67c113be122bf37" dependencies = [ - "rustls 0.23.20", + "rustls 0.23.19", "tokio", ] @@ -9046,7 +9033,7 @@ dependencies = [ "http 1.2.0", "http-body 1.0.1", "http-body-util", - "hyper 1.5.2", + "hyper 1.5.1", "hyper-timeout", "hyper-util", "percent-encoding", @@ -9083,14 +9070,14 @@ dependencies = [ [[package]] name = "tower" -version = "0.5.2" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d039ad9159c98b70ecfd540b2573b97f7f52c3e8d9f8ad57a24b916a536975f9" +checksum = "2873938d487c3cfb9aed7546dc9f2711d867c9f90c46b889989a2cb84eba6b4f" dependencies = [ "futures-core", "futures-util", "pin-project-lite", - "sync_wrapper 1.0.2", + "sync_wrapper 0.1.2", "tokio", "tokio-util", "tower-layer", @@ -9111,7 +9098,7 @@ dependencies = [ "http-body 1.0.1", "iri-string", "pin-project-lite", - "tower 0.5.2", + "tower 0.5.1", "tower-layer", "tower-service", "tracing", @@ -9424,7 +9411,7 @@ dependencies = [ "flate2", "log", "once_cell", - "rustls 0.23.20", + "rustls 0.23.19", "rustls-pki-types", "url", "webpki-roots 0.26.7", @@ -10149,7 +10136,7 @@ dependencies = [ "base64 0.21.7", "futures", "http 0.2.12", - "hyper 0.14.32", + "hyper 0.14.31", "hyper-rustls 0.25.0", "itertools 0.12.1", "log", @@ -10206,7 +10193,7 @@ dependencies = [ "reqwest 0.12.9", "revm", "rs-leveldb", - "rustls 0.23.20", + "rustls 0.23.19", "scopeguard", "serde", "serde_json", @@ -10340,7 +10327,7 @@ dependencies = [ "futures", "hex", "http 1.2.0", - "hyper 1.5.2", + "hyper 1.5.1", "indicatif", "itertools 0.13.0", "jsonrpsee", @@ -10367,7 +10354,7 @@ dependencies = [ "rusqlite", "scilla-parser 2.0.0", "scopeguard", - "semver 1.0.24", + "semver 1.0.23", "serde", "serde_bytes", "serde_json", @@ -10453,9 +10440,9 @@ dependencies = [ [[package]] name = "zip" -version = "2.2.2" +version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae9c1ea7b3a5e1f4b922ff856a129881167511563dc219869afe3787fc0c1a45" +checksum = "99d52293fc86ea7cf13971b3bb81eb21683636e7ae24c729cdaf1b7c4157a352" dependencies = [ "arbitrary", "crc32fast", @@ -10500,7 +10487,7 @@ dependencies = [ "rand_chacha", "regex", "reqwest 0.11.27", - "semver 1.0.24", + "semver 1.0.23", "serde", "serde_json", "serde_yaml", diff --git a/docker-compose.yaml b/docker-compose.yaml index 0ec78eb46..0f16b2f4d 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -2,6 +2,8 @@ version: "3" services: node0: + depends_on: + - node3 environment: RUST_BACKTRACE: 1 RUST_LOG: zilliqa=info @@ -21,6 +23,8 @@ services: ipv4_address: 198.51.100.100 node1: + depends_on: + - node3 environment: RUST_BACKTRACE: 1 RUST_LOG: zilliqa=info @@ -35,6 +39,8 @@ services: ipv4_address: 198.51.100.101 node2: + depends_on: + - node3 environment: RUST_BACKTRACE: 1 RUST_LOG: zilliqa=info diff --git a/zilliqa/src/p2p_node.rs b/zilliqa/src/p2p_node.rs index 112a53a09..3e3d5e127 100644 --- a/zilliqa/src/p2p_node.rs +++ b/zilliqa/src/p2p_node.rs @@ -18,10 +18,9 @@ use libp2p::{ multiaddr::{Multiaddr, Protocol}, noise, request_response::{self, OutboundFailure, ProtocolSupport}, - swarm::{dial_opts::DialOpts, NetworkBehaviour, SwarmEvent}, + swarm::{NetworkBehaviour, SwarmEvent}, tcp, yamux, PeerId, StreamProtocol, Swarm, }; -use rand::rngs::OsRng; use tokio::{ select, signal::{self, unix::SignalKind}, @@ -125,13 +124,17 @@ impl P2pNode { .map_err(|e| anyhow!(e))?, ) .map_err(|e| anyhow!(e))?, - autonat_client: autonat::v2::client::Behaviour::new(OsRng, Default::default()), - autonat_server: autonat::v2::server::Behaviour::new(OsRng), + autonat_client: autonat::v2::client::Behaviour::default(), + autonat_server: autonat::v2::server::Behaviour::default(), + kademlia: kad::Behaviour::new(peer_id, MemoryStore::new(peer_id)), + // FIXME: This is a hack. + // By exposing the listen addresses, the nodes are able to get the correct remote ip/port to connect to. + // Otherwise, when running locally in docker, the nodes connect to each other via the gateway acting as a NAT router. + // So, the nodes are unable to see each other directly and remain isolated, defeating kademlia and autonat. identify: identify::Behaviour::new( - identify::Config::new("/zilliqa/1.0.0".to_owned(), key_pair.public()) - .with_hide_listen_addrs(true), + identify::Config::new("zilliqa/1.0.0".into(), key_pair.public()) + .with_hide_listen_addrs(!cfg!(debug_assertions)), ), - kademlia: kad::Behaviour::new(peer_id, MemoryStore::new(peer_id)), }) })? // Set the idle connection timeout to 10 seconds. Some protocols (such as autonat) rely on using a @@ -231,17 +234,8 @@ impl P2pNode { if let Some((peer, address)) = &self.config.bootstrap_address { if self.swarm.local_peer_id() != peer { - self.swarm.dial( - DialOpts::peer_id(*peer) - .override_role() // hole-punch - .addresses(vec![address.clone()]) - .build(), - )?; - self.swarm - .behaviour_mut() - .kademlia - .add_address(peer, address.clone()); - self.swarm.behaviour_mut().kademlia.bootstrap()?; + self.swarm.dial(address.clone())?; + self.swarm.add_peer_address(*peer, address.clone()); } } @@ -256,6 +250,14 @@ impl P2pNode { SwarmEvent::NewListenAddr { address, .. } => { info!(%address, "P2P swarm listening on"); } + SwarmEvent::Behaviour(BehaviourEvent::Identify(identify::Event::Received { peer_id, info: identify::Info{ listen_addrs, observed_addr, protocols, .. }, .. })) => { + self.swarm.add_external_address(observed_addr); + if protocols.iter().any(|p| *p == kad::PROTOCOL_NAME) { + for addr in listen_addrs { + self.swarm.add_peer_address(peer_id, addr); + } + } + } SwarmEvent::NewExternalAddrOfPeer { peer_id, address } => { self.swarm .behaviour_mut()