diff --git a/.github/workflows/cache-factory.yml b/.github/workflows/cache-factory.yml index 8d25eb9acab..860f0a0de2c 100644 --- a/.github/workflows/cache-factory.yml +++ b/.github/workflows/cache-factory.yml @@ -22,7 +22,7 @@ jobs: - uses: dtolnay/rust-toolchain@stable - - uses: Swatinem/rust-cache@b8a6852b4f997182bdea832df3f9e153038b5191 # v2.6.0 + - uses: Swatinem/rust-cache@578b235f6e5f613f7727f1c17bd3305b4d4d4e1f # v2.6.1 with: shared-key: stable-cache diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c61e673b855..470016d68ef 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -33,11 +33,11 @@ jobs: steps: - uses: actions/checkout@v3 - - uses: r7kamura/rust-problem-matchers@d58b70c4a13c4866d96436315da451d8106f8f08 #v1.3.0 + - uses: r7kamura/rust-problem-matchers@2c2f1016021a7455a6b5b4bbae31145f3b3cd83a #v1.4.0 - uses: dtolnay/rust-toolchain@stable - - uses: Swatinem/rust-cache@b8a6852b4f997182bdea832df3f9e153038b5191 # v2.6.0 + - uses: Swatinem/rust-cache@578b235f6e5f613f7727f1c17bd3305b4d4d4e1f # v2.6.1 with: shared-key: stable-cache save-if: false @@ -134,9 +134,9 @@ jobs: with: target: ${{ matrix.target }} - - uses: r7kamura/rust-problem-matchers@d58b70c4a13c4866d96436315da451d8106f8f08 #v1.3.0 + - uses: r7kamura/rust-problem-matchers@2c2f1016021a7455a6b5b4bbae31145f3b3cd83a #v1.4.0 - - uses: Swatinem/rust-cache@b8a6852b4f997182bdea832df3f9e153038b5191 # v2.6.0 + - uses: Swatinem/rust-cache@578b235f6e5f613f7727f1c17bd3305b4d4d4e1f # v2.6.1 with: key: ${{ matrix.target }} save-if: ${{ github.ref == 'refs/heads/master' }} @@ -159,9 +159,9 @@ jobs: with: toolchain: ${{ env.MSRV }} - - uses: r7kamura/rust-problem-matchers@d58b70c4a13c4866d96436315da451d8106f8f08 #v1.3.0 + - uses: r7kamura/rust-problem-matchers@2c2f1016021a7455a6b5b4bbae31145f3b3cd83a #v1.4.0 - - uses: Swatinem/rust-cache@b8a6852b4f997182bdea832df3f9e153038b5191 # v2.6.0 + - uses: Swatinem/rust-cache@578b235f6e5f613f7727f1c17bd3305b4d4d4e1f # v2.6.1 with: save-if: ${{ github.ref == 'refs/heads/master' }} @@ -180,9 +180,9 @@ jobs: - uses: dtolnay/rust-toolchain@stable - - uses: r7kamura/rust-problem-matchers@d58b70c4a13c4866d96436315da451d8106f8f08 #v1.3.0 + - uses: r7kamura/rust-problem-matchers@2c2f1016021a7455a6b5b4bbae31145f3b3cd83a #v1.4.0 - - uses: Swatinem/rust-cache@b8a6852b4f997182bdea832df3f9e153038b5191 # v2.6.0 + - uses: Swatinem/rust-cache@578b235f6e5f613f7727f1c17bd3305b4d4d4e1f # v2.6.1 with: key: ${{ matrix.features }} save-if: ${{ github.ref == 'refs/heads/master' }} @@ -197,9 +197,9 @@ jobs: - uses: dtolnay/rust-toolchain@stable - - uses: r7kamura/rust-problem-matchers@d58b70c4a13c4866d96436315da451d8106f8f08 #v1.3.0 + - uses: r7kamura/rust-problem-matchers@2c2f1016021a7455a6b5b4bbae31145f3b3cd83a #v1.4.0 - - uses: Swatinem/rust-cache@b8a6852b4f997182bdea832df3f9e153038b5191 # v2.6.0 + - uses: Swatinem/rust-cache@578b235f6e5f613f7727f1c17bd3305b4d4d4e1f # v2.6.1 with: save-if: ${{ github.ref == 'refs/heads/master' }} @@ -223,9 +223,9 @@ jobs: toolchain: ${{ matrix.rust-version }} components: clippy - - uses: r7kamura/rust-problem-matchers@d58b70c4a13c4866d96436315da451d8106f8f08 #v1.3.0 + - uses: r7kamura/rust-problem-matchers@2c2f1016021a7455a6b5b4bbae31145f3b3cd83a #v1.4.0 - - uses: Swatinem/rust-cache@b8a6852b4f997182bdea832df3f9e153038b5191 # v2.6.0 + - uses: Swatinem/rust-cache@578b235f6e5f613f7727f1c17bd3305b4d4d4e1f # v2.6.1 with: save-if: ${{ github.ref == 'refs/heads/master' }} @@ -240,9 +240,9 @@ jobs: - uses: dtolnay/rust-toolchain@stable - - uses: r7kamura/rust-problem-matchers@d58b70c4a13c4866d96436315da451d8106f8f08 #v1.3.0 + - uses: r7kamura/rust-problem-matchers@2c2f1016021a7455a6b5b4bbae31145f3b3cd83a #v1.4.0 - - uses: Swatinem/rust-cache@b8a6852b4f997182bdea832df3f9e153038b5191 # v2.6.0 + - uses: Swatinem/rust-cache@578b235f6e5f613f7727f1c17bd3305b4d4d4e1f # v2.6.1 with: save-if: ${{ github.ref == 'refs/heads/master' }} @@ -256,9 +256,9 @@ jobs: - uses: dtolnay/rust-toolchain@stable - - uses: r7kamura/rust-problem-matchers@d58b70c4a13c4866d96436315da451d8106f8f08 #v1.3.0 + - uses: r7kamura/rust-problem-matchers@2c2f1016021a7455a6b5b4bbae31145f3b3cd83a #v1.4.0 - - uses: Swatinem/rust-cache@b8a6852b4f997182bdea832df3f9e153038b5191 # v2.6.0 + - uses: Swatinem/rust-cache@578b235f6e5f613f7727f1c17bd3305b4d4d4e1f # v2.6.1 with: shared-key: stable-cache save-if: false @@ -280,7 +280,7 @@ jobs: with: components: rustfmt - - uses: r7kamura/rust-problem-matchers@d58b70c4a13c4866d96436315da451d8106f8f08 #v1.3.0 + - uses: r7kamura/rust-problem-matchers@2c2f1016021a7455a6b5b4bbae31145f3b3cd83a #v1.4.0 - name: Check formatting run: cargo fmt -- --check @@ -292,7 +292,7 @@ jobs: - uses: dtolnay/rust-toolchain@stable - - uses: r7kamura/rust-problem-matchers@d58b70c4a13c4866d96436315da451d8106f8f08 #v1.3.0 + - uses: r7kamura/rust-problem-matchers@2c2f1016021a7455a6b5b4bbae31145f3b3cd83a #v1.4.0 - name: Ensure `full` feature contains all features run: | @@ -326,7 +326,7 @@ jobs: steps: - uses: actions/checkout@v3 - - uses: Swatinem/rust-cache@b8a6852b4f997182bdea832df3f9e153038b5191 # v2.6.0 + - uses: Swatinem/rust-cache@578b235f6e5f613f7727f1c17bd3305b4d4d4e1f # v2.6.1 - run: cargo install --version 0.10.0 pb-rs --locked @@ -352,5 +352,5 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - uses: Swatinem/rust-cache@b8a6852b4f997182bdea832df3f9e153038b5191 # v2.6.0 + - uses: Swatinem/rust-cache@578b235f6e5f613f7727f1c17bd3305b4d4d4e1f # v2.6.1 - run: cargo metadata --locked --format-version=1 > /dev/null diff --git a/Cargo.lock b/Cargo.lock index c753da3918f..7459ef7b154 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -455,7 +455,7 @@ dependencies = [ "log", "memchr", "once_cell", - "pin-project-lite 0.2.10", + "pin-project-lite 0.2.12", "pin-utils", "slab", "wasm-bindgen-futures", @@ -484,9 +484,9 @@ checksum = "ecc7ab41815b3c653ccd2978ec3255c81349336702dfdf62ee6f7069b12a3aae" [[package]] name = "async-trait" -version = "0.1.72" +version = "0.1.73" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc6dde6e4ed435a4c1ee4e73592f5ba9da2151af10076cc04858746af9352d09" +checksum = "bc00ceb34980c03614e35a3a4e218276a0a824e911d07651cd0d858a51e8c0f0" dependencies = [ "proc-macro2", "quote", @@ -503,7 +503,7 @@ dependencies = [ "futures-sink", "futures-util", "memchr", - "pin-project-lite 0.2.10", + "pin-project-lite 0.2.12", ] [[package]] @@ -531,9 +531,9 @@ dependencies = [ [[package]] name = "axum" -version = "0.6.19" +version = "0.6.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6a1de45611fdb535bfde7b7de4fd54f4fd2b17b1737c0a59b69bf9b92074b8c" +checksum = "3b829e4e32b91e643de6eafe82b1d90675f5874230191a4ffbc1b336dec4d6bf" dependencies = [ "async-trait", "axum-core", @@ -548,7 +548,7 @@ dependencies = [ "memchr", "mime", "percent-encoding", - "pin-project-lite 0.2.10", + "pin-project-lite 0.2.12", "rustversion", "serde", "serde_json", @@ -831,7 +831,6 @@ dependencies = [ "env_logger 0.10.0", "futures", "libp2p", - "libp2p-quic", ] [[package]] @@ -891,9 +890,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.3.19" +version = "4.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fd304a20bff958a57f04c4e96a2e7594cc4490a0e809cbd48bb6437edaa452d" +checksum = "c27cdf28c0f604ba3f512b0c9a409f8de8513e4816705deb0498b627e7c3a3fd" dependencies = [ "clap_builder", "clap_derive", @@ -902,9 +901,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.3.19" +version = "4.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01c6a3f08f1fe5662a35cfe393aec09c4df95f60ee93b7556505260f75eee9e1" +checksum = "08a9f1ab5e9f01a9b81f202e8562eb9a10de70abf9eaeac1be465c28b75aa4aa" dependencies = [ "anstream", "anstyle", @@ -945,7 +944,7 @@ dependencies = [ "bytes", "futures-core", "memchr", - "pin-project-lite 0.2.10", + "pin-project-lite 0.2.12", "tokio", "tokio-util", ] @@ -1227,18 +1226,32 @@ dependencies = [ [[package]] name = "curve25519-dalek" -version = "4.0.0-rc.1" +version = "4.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d4ba9852b42210c7538b75484f9daa0655e9a3ac04f693747bb0f02cf3cfe16" +checksum = "f711ade317dd348950a9910f81c5947e3d8907ebd2b83f76203ff1807e6a2bc2" dependencies = [ "cfg-if 1.0.0", + "cpufeatures", + "curve25519-dalek-derive", + "digest 0.10.7", "fiat-crypto", - "packed_simd_2", "platforms", + "rustc_version", "subtle", "zeroize", ] +[[package]] +name = "curve25519-dalek-derive" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83fdaf97f4804dcebfa5862639bc9ce4121e82140bec2a987ac5140294865b5b" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.28", +] + [[package]] name = "darling" version = "0.14.4" @@ -1309,7 +1322,6 @@ dependencies = [ "futures", "futures-timer", "libp2p", - "libp2p-quic", "log", ] @@ -1471,24 +1483,25 @@ dependencies = [ [[package]] name = "ed25519" -version = "1.5.3" +version = "2.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91cff35c70bba8a626e3185d8cd48cc11b5437e1a5bcd15b9b5fa3c64b6dfee7" +checksum = "60f6d271ca33075c88028be6f04d502853d63a5ece419d269c15315d4fc1cf1d" dependencies = [ - "signature 1.6.4", + "pkcs8 0.10.2", + "signature 2.1.0", ] [[package]] name = "ed25519-dalek" -version = "1.0.1" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c762bae6dcaf24c4c84667b8579785430908723d5c889f469d76a41d59cc7a9d" +checksum = "7277392b266383ef8396db7fdeb1e77b6c52fed775f5df15bb24f35b72156980" dependencies = [ - "curve25519-dalek 3.2.0", + "curve25519-dalek 4.0.0", "ed25519", - "rand 0.7.3", + "rand_core 0.6.4", "serde", - "sha2 0.9.9", + "sha2 0.10.7", "zeroize", ] @@ -1794,7 +1807,7 @@ dependencies = [ "futures-io", "memchr", "parking", - "pin-project-lite 0.2.10", + "pin-project-lite 0.2.12", "waker-fn", ] @@ -1876,7 +1889,7 @@ dependencies = [ "futures-sink", "futures-task", "memchr", - "pin-project-lite 0.2.10", + "pin-project-lite 0.2.12", "pin-utils", "slab", ] @@ -2134,7 +2147,7 @@ checksum = "d5f38f16d184e36f2408a55281cd658ecbd3ca05cce6d6510a176eca393e26d1" dependencies = [ "bytes", "http", - "pin-project-lite 0.2.10", + "pin-project-lite 0.2.12", ] [[package]] @@ -2177,7 +2190,7 @@ dependencies = [ "httparse", "httpdate", "itoa", - "pin-project-lite 0.2.10", + "pin-project-lite 0.2.12", "socket2 0.4.9", "tokio", "tower-service", @@ -2354,7 +2367,6 @@ dependencies = [ "instant", "libp2p", "libp2p-mplex", - "libp2p-quic", "libp2p-webrtc", "log", "mime_guess", @@ -2504,15 +2516,9 @@ version = "0.2.147" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" -[[package]] -name = "libm" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fc7aa29613bd6a620df431842069224d8bc9011086b1db4c0e0cd47fa03ec9a" - [[package]] name = "libp2p" -version = "0.52.2" +version = "0.52.3" dependencies = [ "async-std", "async-trait", @@ -2537,11 +2543,13 @@ dependencies = [ "libp2p-identity", "libp2p-kad", "libp2p-mdns", + "libp2p-memory-connection-limits", "libp2p-metrics", "libp2p-noise", "libp2p-ping", "libp2p-plaintext", "libp2p-pnet", + "libp2p-quic", "libp2p-relay", "libp2p-rendezvous", "libp2p-request-response", @@ -2784,7 +2792,7 @@ dependencies = [ [[package]] name = "libp2p-identity" -version = "0.2.2" +version = "0.2.3" dependencies = [ "asn1_der", "base64 0.21.2", @@ -2870,6 +2878,24 @@ dependencies = [ "void", ] +[[package]] +name = "libp2p-memory-connection-limits" +version = "0.1.0" +dependencies = [ + "async-std", + "libp2p-core", + "libp2p-identify", + "libp2p-identity", + "libp2p-swarm", + "libp2p-swarm-derive", + "libp2p-swarm-test", + "log", + "memory-stats", + "rand 0.8.5", + "sysinfo", + "void", +] + [[package]] name = "libp2p-metrics" version = "0.13.1" @@ -3039,7 +3065,7 @@ dependencies = [ [[package]] name = "libp2p-quic" -version = "0.9.0-alpha" +version = "0.9.2" dependencies = [ "async-std", "bytes", @@ -3060,6 +3086,7 @@ dependencies = [ "quinn", "rand 0.8.5", "rustls 0.21.5", + "socket2 0.5.3", "thiserror", "tokio", ] @@ -3149,7 +3176,7 @@ dependencies = [ [[package]] name = "libp2p-swarm" -version = "0.43.2" +version = "0.43.3" dependencies = [ "async-std", "either", @@ -3244,7 +3271,7 @@ dependencies = [ "thiserror", "tokio", "webpki 0.22.0", - "x509-parser 0.15.0", + "x509-parser 0.15.1", "yasna", ] @@ -3329,7 +3356,7 @@ dependencies = [ "rw-stream-sink", "soketto", "url", - "webpki-roots 0.25.1", + "webpki-roots 0.25.2", ] [[package]] @@ -3443,9 +3470,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.19" +version = "0.4.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b06a4cde4c0f271a446782e3eff8de789548ce57dbc8eca9292c27f4a42004b4" +checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" dependencies = [ "value-bag", ] @@ -3528,6 +3555,16 @@ dependencies = [ "autocfg", ] +[[package]] +name = "memory-stats" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34f79cf9964c5c9545493acda1263f1912f8d2c56c8a2ffee2606cb960acaacc" +dependencies = [ + "libc", + "winapi", +] + [[package]] name = "metrics-example" version = "0.1.0" @@ -3758,6 +3795,15 @@ dependencies = [ "minimal-lexical", ] +[[package]] +name = "ntapi" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8a3895c6391c39d7fe7ebc444a87eb2991b2a0bc718fdabd071eec617fc68e4" +dependencies = [ + "winapi", +] + [[package]] name = "nu-ansi-term" version = "0.46.0" @@ -3937,16 +3983,6 @@ dependencies = [ "sha2 0.10.7", ] -[[package]] -name = "packed_simd_2" -version = "0.3.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1914cd452d8fccd6f9db48147b29fd4ae05bea9dc5d9ad578509f72415de282" -dependencies = [ - "cfg-if 1.0.0", - "libm", -] - [[package]] name = "parking" version = "2.1.0" @@ -4043,9 +4079,9 @@ checksum = "257b64915a082f7811703966789728173279bdebb956b143dbcd23f6f970a777" [[package]] name = "pin-project-lite" -version = "0.2.10" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c40d25201921e5ff0c862a505c6557ea88568a4e3ace775ab55e93f2f4f9d57" +checksum = "12cc1b0bf1727a77a54b6654e7b5f1af8604923edc8b81885f8ec92f9e3f0a05" [[package]] name = "pin-utils" @@ -4135,7 +4171,7 @@ dependencies = [ "concurrent-queue", "libc", "log", - "pin-project-lite 0.2.10", + "pin-project-lite 0.2.12", "windows-sys", ] @@ -4322,7 +4358,7 @@ dependencies = [ "async-std", "bytes", "futures-io", - "pin-project-lite 0.2.10", + "pin-project-lite 0.2.12", "quinn-proto", "quinn-udp", "rustc-hash", @@ -4501,7 +4537,7 @@ dependencies = [ "futures-util", "itoa", "percent-encoding", - "pin-project-lite 0.2.10", + "pin-project-lite 0.2.12", "ryu", "tokio", "tokio-util", @@ -4519,13 +4555,13 @@ dependencies = [ [[package]] name = "regex" -version = "1.9.1" +version = "1.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2eae68fc220f7cf2532e4494aded17545fce192d59cd996e0fe7887f4ceb575" +checksum = "81bc1d4caf89fac26a70747fe603c130093b53c773888797a6329091246d651a" dependencies = [ "aho-corasick", "memchr", - "regex-automata 0.3.4", + "regex-automata 0.3.6", "regex-syntax 0.7.4", ] @@ -4540,9 +4576,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.3.4" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7b6d6190b7594385f61bd3911cd1be99dfddcfc365a4160cc2ab5bff4aed294" +checksum = "fed1ceff11a1dddaee50c9dc8e4938bd106e9d89ae372f192311e7da498e3b69" dependencies = [ "aho-corasick", "memchr", @@ -4571,7 +4607,6 @@ dependencies = [ "env_logger 0.10.0", "futures", "libp2p", - "libp2p-quic", ] [[package]] @@ -4610,7 +4645,7 @@ dependencies = [ "native-tls", "once_cell", "percent-encoding", - "pin-project-lite 0.2.10", + "pin-project-lite 0.2.12", "serde", "serde_json", "serde_urlencoded", @@ -5067,18 +5102,18 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.179" +version = "1.0.183" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a5bf42b8d227d4abf38a1ddb08602e229108a517cd4e5bb28f9c7eaafdce5c0" +checksum = "32ac8da02677876d532745a130fc9d8e6edfa81a269b107c5b00829b91d8eb3c" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.179" +version = "1.0.183" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "741e124f5485c7e60c03b043f79f320bff3527f4bbf12cf3831750dc46a0ec2c" +checksum = "aafe972d60b0b9bee71a91b92fee2d4fb3c9d7e8f6b179aa99f27203d99a4816" dependencies = [ "proc-macro2", "quote", @@ -5279,14 +5314,14 @@ dependencies = [ [[package]] name = "snow" -version = "0.9.2" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ccba027ba85743e09d15c03296797cad56395089b832b48b5a5217880f57733" +checksum = "0c9d1425eb528a21de2755c75af4c9b5d57f50a0d4c3b7f1828a4cd03f8ba155" dependencies = [ "aes-gcm 0.9.2", "blake2", "chacha20poly1305", - "curve25519-dalek 4.0.0-rc.1", + "curve25519-dalek 4.0.0", "rand_core 0.6.4", "ring", "rustc_version", @@ -5450,6 +5485,21 @@ dependencies = [ "unicode-xid", ] +[[package]] +name = "sysinfo" +version = "0.29.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "165d6d8539689e3d3bc8b98ac59541e1f21c7de7c85d60dc80e43ae0ed2113db" +dependencies = [ + "cfg-if 1.0.0", + "core-foundation-sys", + "libc", + "ntapi", + "once_cell", + "rayon", + "winapi", +] + [[package]] name = "system-configuration" version = "0.5.1" @@ -5615,20 +5665,19 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.29.1" +version = "1.31.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "532826ff75199d5833b9d2c5fe410f29235e25704ee5f0ef599fb51c21f4a4da" +checksum = "40de3a2ba249dcb097e01be5e67a5ff53cf250397715a071a81543e8a832a920" dependencies = [ - "autocfg", "backtrace", "bytes", "libc", "mio", "num_cpus", "parking_lot", - "pin-project-lite 0.2.10", + "pin-project-lite 0.2.12", "signal-hook-registry", - "socket2 0.4.9", + "socket2 0.5.3", "tokio-macros", "windows-sys", ] @@ -5675,7 +5724,7 @@ dependencies = [ "futures-core", "futures-io", "futures-sink", - "pin-project-lite 0.2.10", + "pin-project-lite 0.2.12", "tokio", "tracing", ] @@ -5689,7 +5738,7 @@ dependencies = [ "futures-core", "futures-util", "pin-project", - "pin-project-lite 0.2.10", + "pin-project-lite 0.2.12", "tokio", "tower-layer", "tower-service", @@ -5713,7 +5762,7 @@ dependencies = [ "mime", "mime_guess", "percent-encoding", - "pin-project-lite 0.2.10", + "pin-project-lite 0.2.12", "tokio", "tokio-util", "tower-layer", @@ -5741,7 +5790,7 @@ checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" dependencies = [ "cfg-if 1.0.0", "log", - "pin-project-lite 0.2.10", + "pin-project-lite 0.2.12", "tracing-attributes", "tracing-core", ] @@ -6252,9 +6301,9 @@ dependencies = [ [[package]] name = "webpki-roots" -version = "0.25.1" +version = "0.25.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c9c6eda1c830a36f361e7721c87fd79ea84293b54f8c48c959f85ec636f0f196" +checksum = "14247bb57be4f377dfb94c72830b8ce8fc6beac03cf4bf7b9732eadd414123fc" [[package]] name = "webrtc" @@ -6712,9 +6761,9 @@ dependencies = [ [[package]] name = "x509-parser" -version = "0.15.0" +version = "0.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bab0c2f54ae1d92f4fcb99c0b7ccf0b1e3451cbd395e5f115ccbdbcb18d4f634" +checksum = "7069fba5b66b9193bd2c5d3d4ff12b839118f6bcbef5328efafafb5395cf63da" dependencies = [ "asn1-rs 0.5.2", "data-encoding", diff --git a/Cargo.toml b/Cargo.toml index cf73ebc0056..e42a905bc39 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,6 +18,7 @@ members = [ "misc/allow-block-list", "misc/connection-limits", "misc/keygen", + "misc/memory-connection-limits", "misc/metrics", "misc/multistream-select", "misc/quick-protobuf-codec", @@ -72,9 +73,10 @@ libp2p-dns = { version = "0.40.0", path = "transports/dns" } libp2p-floodsub = { version = "0.43.0", path = "protocols/floodsub" } libp2p-gossipsub = { version = "0.45.1", path = "protocols/gossipsub" } libp2p-identify = { version = "0.43.0", path = "protocols/identify" } -libp2p-identity = { version = "0.2.2" } +libp2p-identity = { version = "0.2.3" } libp2p-kad = { version = "0.44.4", path = "protocols/kad" } libp2p-mdns = { version = "0.44.0", path = "protocols/mdns" } +libp2p-memory-connection-limits = { version = "0.1.0", path = "misc/memory-connection-limits" } libp2p-metrics = { version = "0.13.1", path = "misc/metrics" } libp2p-mplex = { version = "0.40.0", path = "muxers/mplex" } libp2p-muxer-test-harness = { path = "muxers/test-harness" } @@ -83,11 +85,11 @@ libp2p-perf = { version = "0.2.0", path = "protocols/perf" } libp2p-ping = { version = "0.43.0", path = "protocols/ping" } libp2p-plaintext = { version = "0.40.0", path = "transports/plaintext" } libp2p-pnet = { version = "0.23.0", path = "transports/pnet" } -libp2p-quic = { version = "0.9.0-alpha", path = "transports/quic" } +libp2p-quic = { version = "0.9.2", path = "transports/quic" } libp2p-relay = { version = "0.16.1", path = "protocols/relay" } libp2p-rendezvous = { version = "0.13.0", path = "protocols/rendezvous" } libp2p-request-response = { version = "0.25.1", path = "protocols/request-response" } -libp2p-swarm = { version = "0.43.2", path = "swarm" } +libp2p-swarm = { version = "0.43.3", path = "swarm" } libp2p-swarm-derive = { version = "0.33.0", path = "swarm-derive" } libp2p-swarm-test = { version = "0.2.0", path = "swarm-test" } libp2p-tcp = { version = "0.40.0", path = "transports/tcp" } diff --git a/README.md b/README.md index da228391ff1..6bd528fc680 100644 --- a/README.md +++ b/README.md @@ -103,4 +103,4 @@ used and maintained by [Actyx](https://www.actyx.com). - [Subspace](https://github.com/subspace/subspace) - Subspace Network reference implementation - [Substrate](https://github.com/paritytech/substrate) - Framework for blockchain innovation, used by [Polkadot](https://www.parity.io/technologies/polkadot/). -- [Ursa](https://github.com/fleek-network/ursa) - Decentralized Content Delivery & Edge Compute. +- [Taple](https://github.com/opencanarias/taple-core) - Sustainable DLT for asset and process traceability by [OpenCanarias](https://www.opencanarias.com/en/). \ No newline at end of file diff --git a/ROADMAP.md b/ROADMAP.md index fc0ad003f49..0d5533f91fa 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -1,96 +1,93 @@ # rust-libp2p Roadmap -Below is a high level roadmap for the rust-libp2p project. Items are ordered by priority (high to -low). +Below is a high level roadmap for the rust-libp2p project. +Items are ordered by priority (high to low). -This is a living document. Input is always welcome e.g. via GitHub issues or pull requests. +This is a living document. +Input is always welcome e.g. via GitHub issues or pull requests. -This is the roadmap of the Rust implementation of libp2p. See also the [general libp2p project -roadmap](https://github.com/libp2p/specs/blob/master/ROADMAP.md). +This is the roadmap of the Rust implementation of libp2p. +See also the [general libp2p project roadmap](https://github.com/libp2p/specs/blob/master/ROADMAP.md). -## Attempt to switch from webrtc-rs to str0m +## In the works -| Category | Status | Target Completion | Tracking | Dependencies | Dependents | -|--------------|--------|-------------------|---------------------------------------------------|--------------|------------| -| Connectivity | todo | | https://github.com/libp2p/rust-libp2p/issues/3659 | | | +### WebTransport -Reduce maintenance burden and reduce dependency footprint. - -## Address pipeline - -| Category | Status | Target Completion | Tracking | Dependencies | Dependents | -|--------------|--------|-------------------|----------|--------------|------------| -| Connectivity | todo | Q4/2023 | | AutoNATv2 | AutoNATv2 | +| Category | Status | Target Completion | Tracking | Dependencies | Dependents | +|-----------------------------|--------|-------------------|---------------------------------------------------|------------------------------------|------------| +| Connectivity / optimization | todo | | https://github.com/libp2p/rust-libp2p/issues/2993 | [QUIC](#experimental-quic-support) | | -Be smart on address prioritization. go-libp2p made a lot of progress here. Lots to learn. See https://github.com/libp2p/go-libp2p/issues/2229 and https://github.com/libp2p/rust-libp2p/issues/1896#issuecomment-1537774383. +A WebTransport implementation in rust-libp2p will enable browsers to connect to rust-libp2p server nodes where the latter only have a self-signed TLS certificate. +Compared to WebRTC, this would likely be more stable and performant. -## AutoNATv2 +### AutoNATv2 | Category | Status | Target Completion | Tracking | Dependencies | Dependents | |--------------|--------|-------------------|----------|------------------|------------------| | Connectivity | todo | Q4/2023 | | Address pipeline | Address pipeline | -Implement the new AutoNAT v2 specification. See https://github.com/libp2p/specs/pull/538. +Implement the new AutoNAT v2 specification. +See https://github.com/libp2p/specs/pull/538. -## Optimize Hole punching +### Address pipeline + +| Category | Status | Target Completion | Tracking | Dependencies | Dependents | +|--------------|--------|-------------------|----------|--------------|------------| +| Connectivity | todo | Q4/2023 | | AutoNATv2 | AutoNATv2 | + +Be smart on address prioritization. +go-libp2p made a lot of progress here. +Lots to learn. +See https://github.com/libp2p/go-libp2p/issues/2229 and https://github.com/libp2p/rust-libp2p/issues/1896#issuecomment-1537774383. + +### Optimize Hole punching | Category | Status | Target Completion | Tracking | Dependencies | Dependents | |--------------|--------|-------------------|----------|--------------|------------| | Optimization | todo | | | | | -We released hole punching support with [rust-libp2p -`v0.43.0`](https://github.com/libp2p/rust-libp2p/releases/tag/v0.43.0), see also -https://github.com/libp2p/rust-libp2p/issues/2052. We are currently collecting data via the -[punchr](https://github.com/dennis-tra/punchr) project on the hole punching success rate. See also -[call for -action](https://discuss.libp2p.io/t/decentralized-nat-hole-punching-measurement-campaign/1616) in -case you want to help. Based on this data we will likely find many optimizations we can do to our -hole punching stack. +We released hole punching support with [rust-libp2p `v0.43.0`](https://github.com/libp2p/rust-libp2p/releases/tag/v0.43.0), see also https://github.com/libp2p/rust-libp2p/issues/2052. +We are currently collecting data via the [punchr](https://github.com/dennis-tra/punchr) project on the hole punching success rate. +See also [call for action](https://discuss.libp2p.io/t/decentralized-nat-hole-punching-measurement-campaign/1616) in case you want to help. +Based on this data we will likely find many optimizations we can do to our hole punching stack. -## Improved Wasm support +### Improved Wasm support | Category | Status | Target Completion | Tracking | Dependencies | Dependents | |----------------------|--------|-------------------|---------------------------------------------------|--------------|----------------------------------------------| | Developer ergonomics | todo | | https://github.com/libp2p/rust-libp2p/issues/2617 | | [WebRTC](#webrtc-support-browser-to-browser) | The project supports Wasm already today, though the developer experience is cumbersome at best. -Properly supporting Wasm opens rust-libp2p to a whole new set of use-cases. I would love for this to -happen earlier. Though (a) I think we should prioritize improving existing functionality over new -functionality and (b) we don't have high demand for this feature from the community. (One could -argue that that demand follows this roadmap item and not the other way round.) +Properly supporting Wasm opens rust-libp2p to a whole new set of use-cases. +I would love for this to happen earlier. +Though (a) I think we should prioritize improving existing functionality over new functionality and (b) we don't have high demand for this feature from the community. +(One could argue that that demand follows this roadmap item and not the other way round.) -## WebRTC in the browser via WASM +### WebRTC in the browser via WASM | Category | Status | Target Completion | Tracking | Dependencies | Dependents | |--------------|--------|-------------------|--------------------------------------------|-------------------------------------------------------------------------------------------|------------| -| Connectivity | todo | | https://github.com/libp2p/specs/issues/475 | [Improved WASM support](#improved-wasm-support), https://github.com/libp2p/specs/pull/497 | | +| Connectivity | In progress | | https://github.com/libp2p/specs/issues/475 | [Improved WASM support](#improved-wasm-support), https://github.com/libp2p/specs/pull/497 | https://github.com/libp2p/rust-libp2p/pull/4248 | -Use the browser's WebRTC stack to support -[`/webrtc`](https://github.com/libp2p/specs/blob/master/webrtc/webrtc.md) and -[`/webrtc-direct`](https://github.com/libp2p/specs/blob/master/webrtc/webrtc-direct.md) from within -the browser using rust-libp2p compiled to WASM. This makes rust-libp2p a truly end-to-end solution, -enabling users to use rust-libp2p on both the client (browser) and server side. +Use the browser's WebRTC stack to support [`/webrtc`](https://github.com/libp2p/specs/blob/master/webrtc/webrtc.md) and [`/webrtc-direct`](https://github.com/libp2p/specs/blob/master/webrtc/webrtc-direct.md) from within the browser using rust-libp2p compiled to WASM. +This makes rust-libp2p a truly end-to-end solution, enabling users to use rust-libp2p on both the client (browser) and server side. -## WebTransport +### Attempt to switch from webrtc-rs to str0m -| Category | Status | Target Completion | Tracking | Dependencies | Dependents | -|-----------------------------|--------|-------------------|---------------------------------------------------|------------------------------------|------------| -| Connectivity / optimization | todo | | https://github.com/libp2p/rust-libp2p/issues/2993 | [QUIC](#experimental-quic-support) | | +| Category | Status | Target Completion | Tracking | Dependencies | Dependents | +|--------------|--------|-------------------|---------------------------------------------------|--------------|------------| +| Connectivity | todo | | https://github.com/libp2p/rust-libp2p/issues/3659 | | | -A WebTransport implementation in rust-libp2p will enable browsers to connect to rust-libp2p nodes -where the latter only have a self-signed TLS certificate. Compared to WebRTC, this would likely be -more performant. It is dependent on QUIC support in rust-libp2p. Given that we will support WebRTC -(browser-to-server) this is not a high priority. +Reduce maintenance burden and reduce dependency footprint. -## Automate port-forwarding e.g. via UPnP +### Automate port-forwarding e.g. via UPnP | Category | Status | Target Completion | Tracking | Dependencies | Dependents | |--------------|--------|-------------------|---------------------------------------------------|--------------|------------| | Connectivity | todo | | https://github.com/libp2p/rust-libp2p/issues/3903 | | | -Leverage protocols like UPnP to configure port-forwarding on ones router when behind NAT and/or -firewall. Another technique in addition to hole punching increasing the probability for a node to -become publicly reachable when behind a firewall and/or NAT. +Leverage protocols like UPnP to configure port-forwarding on ones router when behind NAT and/or firewall. +Another technique in addition to hole punching increasing the probability for a node to become publicly reachable when behind a firewall and/or NAT. ## Done @@ -100,9 +97,9 @@ become publicly reachable when behind a firewall and/or NAT. |--------------|--------|-------------------|---------------------------------------------------|------------------------------------------------|------------| | Connectivity | Done | Q4/2022 | https://github.com/libp2p/rust-libp2p/issues/2883 | https://github.com/libp2p/test-plans/issues/53 | | -QUIC has been on the roadmap for a long time. It enables various performance improvements as well as -higher hole punching success rates. We are close to finishing a first version with -https://github.com/libp2p/rust-libp2p/pull/2289. +QUIC has been on the roadmap for a long time. +It enables various performance improvements as well as higher hole punching success rates. +We are close to finishing a first version with https://github.com/libp2p/rust-libp2p/pull/2289. ### WebRTC support (browser-to-server) @@ -110,13 +107,13 @@ https://github.com/libp2p/rust-libp2p/pull/2289. |--------------|--------|-------------------|------------------------------------------|-----------------------------------------------|-------------------------------------------------------------------| | Connectivity | Done | Q4/2022 | https://github.com/libp2p/specs/pull/412 | https://github.com/libp2p/test-plans/pull/100 | [WebRTC (browser-to-browser)](#webrtc-support-browser-to-browser) | -We are currently implementing WebRTC for **browser-to-server** connectivity in -https://github.com/libp2p/rust-libp2p/pull/2622. More specifically the server side. This will enable -browser nodes to connect to rust-libp2p nodes where the latter only have self-signed TLS -certificates. See https://github.com/libp2p/specs/pull/412 for in-depth motivation. +We are currently implementing WebRTC for **browser-to-server** connectivity in https://github.com/libp2p/rust-libp2p/pull/2622. +More specifically the server side. +This will enable browser nodes to connect to rust-libp2p nodes where the latter only have self-signed TLS certificates. +See https://github.com/libp2p/specs/pull/412 for in-depth motivation. -Long term we should enable rust-libp2p running in the browser via Wasm to use the browser's WebRTC -stack. Though that should only happen after improved Wasm support, see below. +Long term we should enable rust-libp2p running in the browser via Wasm to use the browser's WebRTC stack. +Though that should only happen after improved Wasm support, see below. ### Kademlia efficient querying @@ -124,8 +121,8 @@ stack. Though that should only happen after improved Wasm support, see below. |--------------|-------------|-------------------|-------------------------------------------------|--------------|------------| | Optimization | done | Q1/2023 | https://github.com/libp2p/rust-libp2p/pull/2712 | | | -Users of rust-libp2p like [iroh](https://github.com/n0-computer/iroh) need this for low latency -usage of `libp2p-kad`. The rust-libp2p maintainers can pick this up unless iroh folks finish the +Users of rust-libp2p like [iroh](https://github.com/n0-computer/iroh) need this for low latency usage of `libp2p-kad`. +The rust-libp2p maintainers can pick this up unless iroh folks finish the work before that. ### Generic connection management @@ -134,9 +131,10 @@ work before that. |----------------------|--------|-------------------|---------------------------------------------------|--------------|------------| | Developer Ergonomics | done | Q1/2023 | https://github.com/libp2p/rust-libp2p/issues/2824 | | | -Today connection management functionality in rust-libp2p is limited. Building abstractions on top is -cumbersome and inefficient. See https://github.com/libp2p/rust-libp2p/issues/2824. Making connection -management generic allows users to build advanced and efficient abstractions on top of rust-libp2p. +Today connection management functionality in rust-libp2p is limited. +Building abstractions on top is cumbersome and inefficient. +See https://github.com/libp2p/rust-libp2p/issues/2824. +Making connection management generic allows users to build advanced and efficient abstractions on top of rust-libp2p. ### Cross Behaviour communication @@ -144,16 +142,13 @@ management generic allows users to build advanced and efficient abstractions on |----------------------|--------|-------------------|---------------------------------------------------|---------------------------------------------------|-----------------------------------------------| | Developer ergonomics | Done | Q1/2023 | https://github.com/libp2p/rust-libp2p/issues/2680 | https://github.com/libp2p/rust-libp2p/issues/2832 | [Kademlia client mode](#kademlia-client-mode) | -Today `NetworkBehaviour` implementations like Kademlia, GossipSub or Circuit Relay v2 can not -communicate with each other, i.e. cannot make use of information known by another -`NetworkBehaviour` implementation. Users need to write the wiring code by hand to e.g. enable -Kademlia to learn protocols supported by a remote peer from Identify. +Today `NetworkBehaviour` implementations like Kademlia, GossipSub or Circuit Relay v2 can not communicate with each other, i.e. cannot make use of information known by another `NetworkBehaviour` implementation. +Users need to write the wiring code by hand to e.g. enable Kademlia to learn protocols supported by a remote peer from Identify. -This roadmap item contains exchanging standard information about remote peers (e.g. supported -protocols) between `NetworkBehaviour` implementations. +This roadmap item contains exchanging standard information about remote peers (e.g. supported protocols) between `NetworkBehaviour` implementations. -Long term we might consider a generic approach for `NetworkBehaviours` to exchange data. Though that -would deserve its own roadmap item. +Long term we might consider a generic approach for `NetworkBehaviours` to exchange data. +Though that would deserve its own roadmap item. ## QUIC - implement hole punching @@ -161,8 +156,8 @@ would deserve its own roadmap item. |--------------|--------|-------------------|---------------------------------------------------|--------------|------------| | Connectivity | done | Q3/2023 | https://github.com/libp2p/rust-libp2p/issues/2883 | | | -Add hole punching support for QUIC. See also [DCUtR specification on usage with -QUIC](https://github.com/libp2p/specs/blob/master/relay/DCUtR.md#the-protocol). +Add hole punching support for QUIC. +See also [DCUtR specification on usage with QUIC](https://github.com/libp2p/specs/blob/master/relay/DCUtR.md#the-protocol). ## Kademlia client mode @@ -179,4 +174,5 @@ Kademlia operations. |--------------|--------|-------------------|---------------------------------------------------|--------------|------------| | Connectivity | done | Q3/2023 | https://github.com/libp2p/rust-libp2p/issues/2883 | | | -We added alpha support for QUIC in Q4/2022 wrapping `quinn-proto`. Evaluate using `quinn` directly, replacing the wrapper. +We added alpha support for QUIC in Q4/2022 wrapping `quinn-proto`. +Evaluate using `quinn` directly, replacing the wrapper. diff --git a/examples/autonat/Cargo.toml b/examples/autonat/Cargo.toml index 9f40dbbc3f3..9ca936b638a 100644 --- a/examples/autonat/Cargo.toml +++ b/examples/autonat/Cargo.toml @@ -7,7 +7,7 @@ license = "MIT" [dependencies] async-std = { version = "1.12", features = ["attributes"] } -clap = { version = "4.3.12", features = ["derive"] } +clap = { version = "4.3.21", features = ["derive"] } env_logger = "0.10.0" futures = "0.3.28" libp2p = { path = "../../libp2p", features = ["async-std", "tcp", "noise", "yamux", "autonat", "identify", "macros"] } diff --git a/examples/chat-example/Cargo.toml b/examples/chat-example/Cargo.toml index 1d865711ea8..cfc417cf3cb 100644 --- a/examples/chat-example/Cargo.toml +++ b/examples/chat-example/Cargo.toml @@ -10,5 +10,4 @@ async-std = { version = "1.12", features = ["attributes"] } async-trait = "0.1" env_logger = "0.10.0" futures = "0.3.28" -libp2p = { path = "../../libp2p", features = ["async-std", "gossipsub", "mdns", "noise", "macros", "tcp", "yamux"] } -libp2p-quic = { path = "../../transports/quic", features = ["async-std"] } +libp2p = { path = "../../libp2p", features = ["async-std", "gossipsub", "mdns", "noise", "macros", "tcp", "yamux", "quic"] } diff --git a/examples/chat-example/src/main.rs b/examples/chat-example/src/main.rs index 9dc2d92a56f..95a16f388d9 100644 --- a/examples/chat-example/src/main.rs +++ b/examples/chat-example/src/main.rs @@ -24,12 +24,11 @@ use async_std::io; use futures::{future::Either, prelude::*, select}; use libp2p::{ core::{muxing::StreamMuxerBox, transport::OrTransport, upgrade}, - gossipsub, identity, mdns, noise, + gossipsub, identity, mdns, noise, quic, swarm::NetworkBehaviour, swarm::{SwarmBuilder, SwarmEvent}, tcp, yamux, PeerId, Transport, }; -use libp2p_quic as quic; use std::collections::hash_map::DefaultHasher; use std::error::Error; use std::hash::{Hash, Hasher}; diff --git a/examples/dcutr/Cargo.toml b/examples/dcutr/Cargo.toml index 5a6389f00c0..7a13dd23910 100644 --- a/examples/dcutr/Cargo.toml +++ b/examples/dcutr/Cargo.toml @@ -6,10 +6,9 @@ publish = false license = "MIT" [dependencies] -clap = { version = "4.3.12", features = ["derive"] } +clap = { version = "4.3.21", features = ["derive"] } env_logger = "0.10.0" futures = "0.3.28" futures-timer = "3.0" -libp2p = { path = "../../libp2p", features = ["async-std", "dns", "dcutr", "identify", "macros", "noise", "ping", "relay", "rendezvous", "tcp", "tokio", "yamux"] } -libp2p-quic = { path = "../../transports/quic", features = ["async-std"] } +libp2p = { path = "../../libp2p", features = ["async-std", "dns", "dcutr", "identify", "macros", "noise", "ping", "quic", "relay", "rendezvous", "tcp", "tokio", "yamux"] } log = "0.4" diff --git a/examples/dcutr/src/main.rs b/examples/dcutr/src/main.rs index 8359bb1902a..8837df783b4 100644 --- a/examples/dcutr/src/main.rs +++ b/examples/dcutr/src/main.rs @@ -35,11 +35,10 @@ use libp2p::{ }, dcutr, dns::DnsConfig, - identify, identity, noise, ping, relay, + identify, identity, noise, ping, quic, relay, swarm::{NetworkBehaviour, SwarmBuilder, SwarmEvent}, tcp, yamux, PeerId, }; -use libp2p_quic as quic; use log::info; use std::error::Error; use std::str::FromStr; diff --git a/examples/file-sharing/Cargo.toml b/examples/file-sharing/Cargo.toml index 348b62fd854..a2aa47cebb3 100644 --- a/examples/file-sharing/Cargo.toml +++ b/examples/file-sharing/Cargo.toml @@ -8,7 +8,7 @@ license = "MIT" [dependencies] serde = { version = "1.0", features = ["derive"] } async-std = { version = "1.12", features = ["attributes"] } -clap = { version = "4.3.12", features = ["derive"] } +clap = { version = "4.3.21", features = ["derive"] } either = "1.9" env_logger = "0.10" futures = "0.3.28" diff --git a/examples/metrics/Cargo.toml b/examples/metrics/Cargo.toml index f883127ee25..b81c0142fd9 100644 --- a/examples/metrics/Cargo.toml +++ b/examples/metrics/Cargo.toml @@ -10,6 +10,6 @@ env_logger = "0.10.0" futures = "0.3.27" hyper = { version = "0.14", features = ["server", "tcp", "http1"] } libp2p = { path = "../../libp2p", features = ["async-std", "metrics", "ping", "noise", "identify", "tcp", "yamux", "macros"] } -log = "0.4.19" +log = "0.4.20" tokio = { version = "1", features = ["rt-multi-thread"] } prometheus-client = "0.21.2" diff --git a/examples/relay-server/Cargo.toml b/examples/relay-server/Cargo.toml index 263a25b34ba..62d3cc0a710 100644 --- a/examples/relay-server/Cargo.toml +++ b/examples/relay-server/Cargo.toml @@ -6,10 +6,9 @@ publish = false license = "MIT" [dependencies] -clap = { version = "4.3.12", features = ["derive"] } +clap = { version = "4.3.21", features = ["derive"] } async-std = { version = "1.12", features = ["attributes"] } async-trait = "0.1" env_logger = "0.10.0" futures = "0.3.28" -libp2p = { path = "../../libp2p", features = ["async-std", "noise", "macros", "ping", "tcp", "identify", "yamux", "relay"] } -libp2p-quic = { path = "../../transports/quic", features = ["async-std"] } +libp2p = { path = "../../libp2p", features = ["async-std", "noise", "macros", "ping", "tcp", "identify", "yamux", "relay", "quic"] } diff --git a/examples/relay-server/src/main.rs b/examples/relay-server/src/main.rs index 6a1d956b5a5..7526a076e92 100644 --- a/examples/relay-server/src/main.rs +++ b/examples/relay-server/src/main.rs @@ -31,11 +31,10 @@ use libp2p::{ core::{Multiaddr, Transport}, identify, identity, identity::PeerId, - noise, ping, relay, + noise, ping, quic, relay, swarm::{NetworkBehaviour, SwarmBuilder, SwarmEvent}, tcp, }; -use libp2p_quic as quic; use std::error::Error; use std::net::{Ipv4Addr, Ipv6Addr}; diff --git a/examples/rendezvous/Cargo.toml b/examples/rendezvous/Cargo.toml index ffbde3fd7dc..e0cf39bafab 100644 --- a/examples/rendezvous/Cargo.toml +++ b/examples/rendezvous/Cargo.toml @@ -12,4 +12,4 @@ env_logger = "0.10.0" futures = "0.3.28" libp2p = { path = "../../libp2p", features = ["async-std", "identify", "macros", "noise", "ping", "rendezvous", "tcp", "tokio", "yamux"] } log = "0.4" -tokio = { version = "1.29", features = [ "rt-multi-thread", "macros", "time" ] } +tokio = { version = "1.31", features = [ "rt-multi-thread", "macros", "time" ] } diff --git a/identity/CHANGELOG.md b/identity/CHANGELOG.md index bfe46076a3a..b52f001827f 100644 --- a/identity/CHANGELOG.md +++ b/identity/CHANGELOG.md @@ -1,3 +1,11 @@ +## 0.2.3 + +- Fix [RUSTSEC-2022-0093] by updating `ed25519-dalek` to `2.0`. + See [PR 4337] + +[RUSTSEC-2022-0093]: https://rustsec.org/advisories/RUSTSEC-2022-0093 +[PR 4337]: https://github.com/libp2p/rust-libp2p/pull/4337 + ## 0.2.2 - Implement `from_protobuf_encoding` for RSA `Keypair`. diff --git a/identity/Cargo.toml b/identity/Cargo.toml index 09ba3c155ee..ed74c5e9836 100644 --- a/identity/Cargo.toml +++ b/identity/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "libp2p-identity" -version = "0.2.2" +version = "0.2.3" edition = "2021" description = "Data structures and algorithms for identifying peers in libp2p." rust-version = { workspace = true } @@ -14,7 +14,7 @@ categories = ["cryptography"] [dependencies] asn1_der = { version = "0.7.6", optional = true } bs58 = { version = "0.5.0", optional = true } -ed25519-dalek = { version = "1.0.1", optional = true } +ed25519-dalek = { version = "2.0", optional = true, features = ["rand_core"] } libsecp256k1 = { version = "0.7.0", optional = true } log = "0.4" multihash = { version = "0.19.0", optional = true } diff --git a/identity/src/ed25519.rs b/identity/src/ed25519.rs index bcd3eb44359..23d11932425 100644 --- a/identity/src/ed25519.rs +++ b/identity/src/ed25519.rs @@ -25,12 +25,12 @@ use core::cmp; use core::fmt; use core::hash; use ed25519_dalek::{self as ed25519, Signer as _, Verifier as _}; -use rand::RngCore; use std::convert::TryFrom; use zeroize::Zeroize; /// An Ed25519 keypair. -pub struct Keypair(ed25519::Keypair); +#[derive(Clone)] +pub struct Keypair(ed25519::SigningKey); impl Keypair { /// Generate a new random Ed25519 keypair. @@ -42,7 +42,7 @@ impl Keypair { /// of the secret scalar and the compressed public point, /// an informal standard for encoding Ed25519 keypairs. pub fn to_bytes(&self) -> [u8; 64] { - self.0.to_bytes() + self.0.to_keypair_bytes() } /// Try to parse a keypair from the [binary format](https://datatracker.ietf.org/doc/html/rfc8032#section-5.1.5) @@ -50,7 +50,10 @@ impl Keypair { /// /// Note that this binary format is the same as `ed25519_dalek`'s and `ed25519_zebra`'s. pub fn try_from_bytes(kp: &mut [u8]) -> Result { - ed25519::Keypair::from_bytes(kp) + let bytes = <[u8; 64]>::try_from(&*kp) + .map_err(|e| DecodingError::failed_to_parse("Ed25519 keypair", e))?; + + ed25519::SigningKey::from_keypair_bytes(&bytes) .map(|k| { kp.zeroize(); Keypair(k) @@ -65,60 +68,41 @@ impl Keypair { /// Get the public key of this keypair. pub fn public(&self) -> PublicKey { - PublicKey(self.0.public) + PublicKey(self.0.verifying_key()) } /// Get the secret key of this keypair. pub fn secret(&self) -> SecretKey { - SecretKey::try_from_bytes(&mut self.0.secret.to_bytes()) - .expect("ed25519::SecretKey::from_bytes(to_bytes(k)) != k") + SecretKey(self.0.to_bytes()) } } impl fmt::Debug for Keypair { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Keypair") - .field("public", &self.0.public) + .field("public", &self.0.verifying_key()) .finish() } } -impl Clone for Keypair { - fn clone(&self) -> Keypair { - let mut sk_bytes = self.0.secret.to_bytes(); - let secret = SecretKey::try_from_bytes(&mut sk_bytes) - .expect("ed25519::SecretKey::from_bytes(to_bytes(k)) != k") - .0; - - Keypair(ed25519::Keypair { - secret, - public: self.0.public, - }) - } -} - /// Demote an Ed25519 keypair to a secret key. impl From for SecretKey { fn from(kp: Keypair) -> SecretKey { - SecretKey(kp.0.secret) + SecretKey(kp.0.to_bytes()) } } /// Promote an Ed25519 secret key into a keypair. impl From for Keypair { fn from(sk: SecretKey) -> Keypair { - let secret: ed25519::ExpandedSecretKey = (&sk.0).into(); - let public = ed25519::PublicKey::from(&secret); - Keypair(ed25519::Keypair { - secret: sk.0, - public, - }) + let signing = ed25519::SigningKey::from_bytes(&sk.0); + Keypair(signing) } } /// An Ed25519 public key. #[derive(Eq, Clone)] -pub struct PublicKey(ed25519::PublicKey); +pub struct PublicKey(ed25519::VerifyingKey); impl fmt::Debug for PublicKey { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { @@ -170,27 +154,22 @@ impl PublicKey { /// Try to parse a public key from a byte array containing the actual key as produced by `to_bytes`. pub fn try_from_bytes(k: &[u8]) -> Result { - ed25519::PublicKey::from_bytes(k) + let k = <[u8; 32]>::try_from(k) + .map_err(|e| DecodingError::failed_to_parse("Ed25519 public key", e))?; + ed25519::VerifyingKey::from_bytes(&k) .map_err(|e| DecodingError::failed_to_parse("Ed25519 public key", e)) .map(PublicKey) } } /// An Ed25519 secret key. +#[derive(Clone)] pub struct SecretKey(ed25519::SecretKey); /// View the bytes of the secret key. impl AsRef<[u8]> for SecretKey { fn as_ref(&self) -> &[u8] { - self.0.as_bytes() - } -} - -impl Clone for SecretKey { - fn clone(&self) -> SecretKey { - let mut sk_bytes = self.0.to_bytes(); - Self::try_from_bytes(&mut sk_bytes) - .expect("ed25519::SecretKey::from_bytes(to_bytes(k)) != k") + &self.0[..] } } @@ -203,13 +182,8 @@ impl fmt::Debug for SecretKey { impl SecretKey { /// Generate a new Ed25519 secret key. pub fn generate() -> SecretKey { - let mut bytes = [0u8; 32]; - rand::thread_rng().fill_bytes(&mut bytes); - SecretKey( - ed25519::SecretKey::from_bytes(&bytes).expect( - "this returns `Err` only if the length is wrong; the length is correct; qed", - ), - ) + let signing = ed25519::SigningKey::generate(&mut rand::rngs::OsRng); + SecretKey(signing.to_bytes()) } /// Try to parse an Ed25519 secret key from a byte slice @@ -218,7 +192,7 @@ impl SecretKey { /// returned. pub fn try_from_bytes(mut sk_bytes: impl AsMut<[u8]>) -> Result { let sk_bytes = sk_bytes.as_mut(); - let secret = ed25519::SecretKey::from_bytes(&*sk_bytes) + let secret = <[u8; 32]>::try_from(&*sk_bytes) .map_err(|e| DecodingError::failed_to_parse("Ed25519 secret key", e))?; sk_bytes.zeroize(); Ok(SecretKey(secret)) @@ -231,7 +205,7 @@ mod tests { use quickcheck::*; fn eq_keypairs(kp1: &Keypair, kp2: &Keypair) -> bool { - kp1.public() == kp2.public() && kp1.0.secret.as_bytes() == kp2.0.secret.as_bytes() + kp1.public() == kp2.public() && kp1.0.to_bytes() == kp2.0.to_bytes() } #[test] @@ -249,7 +223,7 @@ mod tests { fn ed25519_keypair_from_secret() { fn prop() -> bool { let kp1 = Keypair::generate(); - let mut sk = kp1.0.secret.to_bytes(); + let mut sk = kp1.0.to_bytes(); let kp2 = Keypair::from(SecretKey::try_from_bytes(&mut sk).unwrap()); eq_keypairs(&kp1, &kp2) && sk == [0u8; 32] } diff --git a/interop-tests/Cargo.toml b/interop-tests/Cargo.toml index 2d0d8ea25b7..1c9ef732e7c 100644 --- a/interop-tests/Cargo.toml +++ b/interop-tests/Cargo.toml @@ -19,8 +19,7 @@ rand = "0.8.5" [target.'cfg(not(target_arch = "wasm32"))'.dependencies] axum = "0.6" -libp2p = { path = "../libp2p", features = ["ping", "noise", "tls", "rsa", "macros", "websocket", "tokio", "yamux", "tcp", "dns", "identify"] } -libp2p-quic = { workspace = true, features = ["tokio"] } +libp2p = { path = "../libp2p", features = ["ping", "noise", "tls", "rsa", "macros", "websocket", "tokio", "yamux", "tcp", "dns", "identify", "quic"] } libp2p-webrtc = { workspace = true, features = ["tokio"] } libp2p-mplex = { path = "../muxers/mplex" } mime_guess = "2.0" @@ -28,7 +27,7 @@ redis = { version = "0.23.0", default-features = false, features = ["tokio-comp" rust-embed = "6.8" serde_json = "1" thirtyfour = "=0.32.0-rc.8" # https://github.com/stevepryde/thirtyfour/issues/169 -tokio = { version = "1.29.1", features = ["full"] } +tokio = { version = "1.31.0", features = ["full"] } tower-http = { version = "0.4", features = ["cors", "fs", "trace"] } tracing = "0.1" tracing-subscriber = { version = "0.3", features = ["env-filter"] } diff --git a/interop-tests/src/arch.rs b/interop-tests/src/arch.rs index 2f4a7495a04..2b2181f2459 100644 --- a/interop-tests/src/arch.rs +++ b/interop-tests/src/arch.rs @@ -26,9 +26,8 @@ pub(crate) mod native { use libp2p::identity::Keypair; use libp2p::swarm::{NetworkBehaviour, SwarmBuilder}; use libp2p::websocket::WsConfig; - use libp2p::{noise, tcp, tls, yamux, PeerId, Transport as _}; + use libp2p::{noise, quic, tcp, tls, yamux, PeerId, Transport as _}; use libp2p_mplex as mplex; - use libp2p_quic as quic; use libp2p_webrtc as webrtc; use redis::AsyncCommands; diff --git a/libp2p/CHANGELOG.md b/libp2p/CHANGELOG.md index 4161ed054c5..642d4103729 100644 --- a/libp2p/CHANGELOG.md +++ b/libp2p/CHANGELOG.md @@ -1,4 +1,8 @@ -## 0.52.2 - unreleased +## 0.52.3 - unreleased + +- Add `libp2p-quic` stable release. + +## 0.52.2 - Include gossipsub when compiling for wasm. See [PR 4217]. @@ -6,8 +10,12 @@ - Add `json` feature which exposes `request_response::json`. See [PR 4188]. +- Add `libp2p-memory-connection-limits` providing memory usage based connection limit configurations. + See [PR 4281]. + [PR 4188]: https://github.com/libp2p/rust-libp2p/pull/4188 [PR 4217]: https://github.com/libp2p/rust-libp2p/pull/4217 +[PR 4281]: https://github.com/libp2p/rust-libp2p/pull/4281 ## 0.52.1 diff --git a/libp2p/Cargo.toml b/libp2p/Cargo.toml index fd9290cf506..5cb8741afa0 100644 --- a/libp2p/Cargo.toml +++ b/libp2p/Cargo.toml @@ -1,9 +1,9 @@ [package] name = "libp2p" edition = "2021" -rust-version = "1.65.0" +rust-version = { workspace = true } description = "Peer-to-peer networking library" -version = "0.52.2" +version = "0.52.3" authors = ["Parity Technologies "] license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" @@ -27,11 +27,13 @@ full = [ "kad", "macros", "mdns", + "memory-connection-limits", "metrics", "noise", "ping", "plaintext", "pnet", + "quic", "relay", "rendezvous", "request-response", @@ -50,7 +52,7 @@ full = [ "yamux", ] -async-std = ["libp2p-swarm/async-std", "libp2p-mdns?/async-io", "libp2p-tcp?/async-io", "libp2p-dns?/async-std"] +async-std = ["libp2p-swarm/async-std", "libp2p-mdns?/async-io", "libp2p-tcp?/async-io", "libp2p-dns?/async-std", "libp2p-quic?/async-std"] autonat = ["dep:libp2p-autonat"] cbor = ["libp2p-request-response?/cbor"] dcutr = ["dep:libp2p-dcutr", "libp2p-metrics?/dcutr"] @@ -65,11 +67,13 @@ json = ["libp2p-request-response?/json"] kad = ["dep:libp2p-kad", "libp2p-metrics?/kad"] macros = ["libp2p-swarm/macros"] mdns = ["dep:libp2p-mdns"] +memory-connection-limits = ["dep:libp2p-memory-connection-limits"] metrics = ["dep:libp2p-metrics"] noise = ["dep:libp2p-noise"] ping = ["dep:libp2p-ping", "libp2p-metrics?/ping"] plaintext = ["dep:libp2p-plaintext"] pnet = ["dep:libp2p-pnet"] +quic = ["dep:libp2p-quic"] relay = ["dep:libp2p-relay", "libp2p-metrics?/relay"] rendezvous = ["dep:libp2p-rendezvous"] request-response = ["dep:libp2p-request-response"] @@ -78,7 +82,7 @@ secp256k1 = ["libp2p-identity/secp256k1"] serde = ["libp2p-core/serde", "libp2p-kad?/serde", "libp2p-gossipsub?/serde"] tcp = ["dep:libp2p-tcp"] tls = ["dep:libp2p-tls"] -tokio = ["libp2p-swarm/tokio", "libp2p-mdns?/tokio", "libp2p-tcp?/tokio", "libp2p-dns?/tokio"] +tokio = ["libp2p-swarm/tokio", "libp2p-mdns?/tokio", "libp2p-tcp?/tokio", "libp2p-dns?/tokio", "libp2p-quic?/tokio"] uds = ["dep:libp2p-uds"] wasm-bindgen = ["futures-timer/wasm-bindgen", "instant/wasm-bindgen", "getrandom/js", "libp2p-swarm/wasm-bindgen", "libp2p-gossipsub?/wasm-bindgen"] wasm-ext = ["dep:libp2p-wasm-ext"] @@ -124,6 +128,8 @@ pin-project = "1.0.0" libp2p-deflate = { workspace = true, optional = true } libp2p-dns = { workspace = true, optional = true } libp2p-mdns = { workspace = true, optional = true } +libp2p-memory-connection-limits = { workspace = true, optional = true } +libp2p-quic = { workspace = true, optional = true } libp2p-tcp = { workspace = true, optional = true } libp2p-tls = { workspace = true, optional = true } libp2p-uds = { workspace = true, optional = true } diff --git a/libp2p/src/lib.rs b/libp2p/src/lib.rs index d22e4c25d30..349427ffdfe 100644 --- a/libp2p/src/lib.rs +++ b/libp2p/src/lib.rs @@ -78,6 +78,11 @@ pub use libp2p_kad as kad; #[cfg_attr(docsrs, doc(cfg(feature = "mdns")))] #[doc(inline)] pub use libp2p_mdns as mdns; +#[cfg(feature = "memory-connection-limits")] +#[cfg(not(target_arch = "wasm32"))] +#[cfg_attr(docsrs, doc(cfg(feature = "memory-connection-limits")))] +#[doc(inline)] +pub use libp2p_memory_connection_limits as memory_connection_limits; #[cfg(feature = "metrics")] #[doc(inline)] pub use libp2p_metrics as metrics; @@ -93,6 +98,9 @@ pub use libp2p_plaintext as plaintext; #[cfg(feature = "pnet")] #[doc(inline)] pub use libp2p_pnet as pnet; +#[cfg(feature = "quic")] +#[cfg(not(target_arch = "wasm32"))] +pub use libp2p_quic as quic; #[cfg(feature = "relay")] #[doc(inline)] pub use libp2p_relay as relay; diff --git a/misc/keygen/Cargo.toml b/misc/keygen/Cargo.toml index 4ad9df487a1..6de32895ccb 100644 --- a/misc/keygen/Cargo.toml +++ b/misc/keygen/Cargo.toml @@ -10,9 +10,9 @@ categories = ["network-programming", "asynchronous"] publish = false [dependencies] -clap = { version = "4.3.12", features = ["derive"] } +clap = { version = "4.3.21", features = ["derive"] } zeroize = "1" -serde = { version = "1.0.179", features = ["derive"] } +serde = { version = "1.0.183", features = ["derive"] } serde_json = "1.0.100" libp2p-core = { workspace = true } base64 = "0.21.2" diff --git a/misc/memory-connection-limits/CHANGELOG.md b/misc/memory-connection-limits/CHANGELOG.md new file mode 100644 index 00000000000..951a5a3f138 --- /dev/null +++ b/misc/memory-connection-limits/CHANGELOG.md @@ -0,0 +1,3 @@ +## 0.1.0 + +- Initial release. diff --git a/misc/memory-connection-limits/Cargo.toml b/misc/memory-connection-limits/Cargo.toml new file mode 100644 index 00000000000..6bfecfd2b0e --- /dev/null +++ b/misc/memory-connection-limits/Cargo.toml @@ -0,0 +1,26 @@ +[package] +name = "libp2p-memory-connection-limits" +edition = "2021" +rust-version = { workspace = true } +description = "Memory usage based connection limits for libp2p." +version = "0.1.0" +license = "MIT" +repository = "https://github.com/libp2p/rust-libp2p" +keywords = ["peer-to-peer", "libp2p", "networking"] +categories = ["network-programming", "asynchronous"] + +[dependencies] +memory-stats = { version = "1", features = ["always_use_statm"] } +libp2p-core = { workspace = true } +libp2p-swarm = { workspace = true } +libp2p-identity = { workspace = true, features = ["peerid"] } +log = "0.4" +sysinfo = "0.29" +void = "1" + +[dev-dependencies] +async-std = { version = "1.12.0", features = ["attributes"] } +libp2p-identify = { workspace = true } +libp2p-swarm-derive = { path = "../../swarm-derive" } +libp2p-swarm-test = { path = "../../swarm-test" } +rand = "0.8.5" diff --git a/misc/memory-connection-limits/src/lib.rs b/misc/memory-connection-limits/src/lib.rs new file mode 100644 index 00000000000..33e40b11843 --- /dev/null +++ b/misc/memory-connection-limits/src/lib.rs @@ -0,0 +1,232 @@ +// Copyright 2023 Protocol Labs. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + +use libp2p_core::{Endpoint, Multiaddr}; +use libp2p_identity::PeerId; +use libp2p_swarm::{ + dummy, ConnectionDenied, ConnectionId, FromSwarm, NetworkBehaviour, PollParameters, THandler, + THandlerInEvent, THandlerOutEvent, ToSwarm, +}; +use void::Void; + +use std::{ + fmt, + task::{Context, Poll}, + time::{Duration, Instant}, +}; + +/// A [`NetworkBehaviour`] that enforces a set of memory usage based limits. +/// +/// For these limits to take effect, this needs to be composed into the behaviour tree of your application. +/// +/// If a connection is denied due to a limit, either a [`SwarmEvent::IncomingConnectionError`](libp2p_swarm::SwarmEvent::IncomingConnectionError) +/// or [`SwarmEvent::OutgoingConnectionError`](libp2p_swarm::SwarmEvent::OutgoingConnectionError) will be emitted. +/// The [`ListenError::Denied`](libp2p_swarm::ListenError::Denied) and respectively the [`DialError::Denied`](libp2p_swarm::DialError::Denied) variant +/// contain a [`ConnectionDenied`](libp2p_swarm::ConnectionDenied) type that can be downcast to [`MemoryUsageLimitExceeded`] error if (and only if) **this** +/// behaviour denied the connection. +/// +/// If you employ multiple [`NetworkBehaviour`]s that manage connections, it may also be a different error. +/// +/// [Behaviour::with_max_bytes] and [Behaviour::with_max_percentage] are mutually exclusive. +/// If you need to employ both of them, compose two instances of [Behaviour] into your custom behaviour. +/// +/// # Example +/// +/// ```rust +/// # use libp2p_identify as identify; +/// # use libp2p_swarm_derive::NetworkBehaviour; +/// # use libp2p_memory_connection_limits as memory_connection_limits; +/// +/// #[derive(NetworkBehaviour)] +/// # #[behaviour(prelude = "libp2p_swarm::derive_prelude")] +/// struct MyBehaviour { +/// identify: identify::Behaviour, +/// limits: memory_connection_limits::Behaviour +/// } +/// ``` +pub struct Behaviour { + max_allowed_bytes: usize, + process_physical_memory_bytes: usize, + last_refreshed: Instant, +} + +/// The maximum duration for which the retrieved memory-stats of the process are allowed to be stale. +/// +/// Once exceeded, we will retrieve new stats. +const MAX_STALE_DURATION: Duration = Duration::from_millis(100); + +impl Behaviour { + /// Sets the process memory usage threshold in absolute bytes. + /// + /// New inbound and outbound connections will be denied when the threshold is reached. + pub fn with_max_bytes(max_allowed_bytes: usize) -> Self { + Self { + max_allowed_bytes, + process_physical_memory_bytes: memory_stats::memory_stats() + .map(|s| s.physical_mem) + .unwrap_or_default(), + last_refreshed: Instant::now(), + } + } + + /// Sets the process memory usage threshold in the percentage of the total physical memory. + /// + /// New inbound and outbound connections will be denied when the threshold is reached. + pub fn with_max_percentage(percentage: f64) -> Self { + use sysinfo::{RefreshKind, SystemExt}; + + let system_memory_bytes = + sysinfo::System::new_with_specifics(RefreshKind::new().with_memory()).total_memory(); + + Self::with_max_bytes((system_memory_bytes as f64 * percentage).round() as usize) + } + + /// Gets the process memory usage threshold in bytes. + pub fn max_allowed_bytes(&self) -> usize { + self.max_allowed_bytes + } + + fn check_limit(&mut self) -> Result<(), ConnectionDenied> { + self.refresh_memory_stats_if_needed(); + + if self.process_physical_memory_bytes > self.max_allowed_bytes { + return Err(ConnectionDenied::new(MemoryUsageLimitExceeded { + process_physical_memory_bytes: self.process_physical_memory_bytes, + max_allowed_bytes: self.max_allowed_bytes, + })); + } + + Ok(()) + } + + fn refresh_memory_stats_if_needed(&mut self) { + let now = Instant::now(); + + if self.last_refreshed + MAX_STALE_DURATION > now { + // Memory stats are reasonably recent, don't refresh. + return; + } + + let stats = match memory_stats::memory_stats() { + Some(stats) => stats, + None => { + log::warn!("Failed to retrieve process memory stats"); + return; + } + }; + + self.last_refreshed = now; + self.process_physical_memory_bytes = stats.physical_mem; + } +} + +impl NetworkBehaviour for Behaviour { + type ConnectionHandler = dummy::ConnectionHandler; + type ToSwarm = Void; + + fn handle_pending_inbound_connection( + &mut self, + _: ConnectionId, + _: &Multiaddr, + _: &Multiaddr, + ) -> Result<(), ConnectionDenied> { + self.check_limit() + } + + fn handle_established_inbound_connection( + &mut self, + _: ConnectionId, + _: PeerId, + _: &Multiaddr, + _: &Multiaddr, + ) -> Result, ConnectionDenied> { + Ok(dummy::ConnectionHandler) + } + + fn handle_pending_outbound_connection( + &mut self, + _: ConnectionId, + _: Option, + _: &[Multiaddr], + _: Endpoint, + ) -> Result, ConnectionDenied> { + self.check_limit()?; + Ok(vec![]) + } + + fn handle_established_outbound_connection( + &mut self, + _: ConnectionId, + _: PeerId, + _: &Multiaddr, + _: Endpoint, + ) -> Result, ConnectionDenied> { + Ok(dummy::ConnectionHandler) + } + + fn on_swarm_event(&mut self, _: FromSwarm) {} + + fn on_connection_handler_event( + &mut self, + _id: PeerId, + _: ConnectionId, + event: THandlerOutEvent, + ) { + void::unreachable(event) + } + + fn poll( + &mut self, + _: &mut Context<'_>, + _: &mut impl PollParameters, + ) -> Poll>> { + Poll::Pending + } +} + +/// A connection limit has been exceeded. +#[derive(Debug, Clone, Copy)] +pub struct MemoryUsageLimitExceeded { + process_physical_memory_bytes: usize, + max_allowed_bytes: usize, +} + +impl MemoryUsageLimitExceeded { + pub fn process_physical_memory_bytes(&self) -> usize { + self.process_physical_memory_bytes + } + + pub fn max_allowed_bytes(&self) -> usize { + self.max_allowed_bytes + } +} + +impl std::error::Error for MemoryUsageLimitExceeded {} + +impl fmt::Display for MemoryUsageLimitExceeded { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!( + f, + "process physical memory usage limit exceeded: process memory: {} bytes, max allowed: {} bytes", + self.process_physical_memory_bytes, + self.max_allowed_bytes, + ) + } +} diff --git a/misc/memory-connection-limits/tests/max_bytes.rs b/misc/memory-connection-limits/tests/max_bytes.rs new file mode 100644 index 00000000000..af86b048785 --- /dev/null +++ b/misc/memory-connection-limits/tests/max_bytes.rs @@ -0,0 +1,89 @@ +// Copyright 2023 Protocol Labs. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + +mod util; + +use libp2p_core::Multiaddr; +use libp2p_identity::PeerId; +use libp2p_memory_connection_limits::*; +use std::time::Duration; +use util::*; + +use libp2p_swarm::{dial_opts::DialOpts, DialError, Swarm}; +use libp2p_swarm_test::SwarmExt; + +#[test] +fn max_bytes() { + const CONNECTION_LIMIT: usize = 20; + let max_allowed_bytes = CONNECTION_LIMIT * 1024 * 1024; + + let mut network = Swarm::new_ephemeral(|_| TestBehaviour { + connection_limits: Behaviour::with_max_bytes(max_allowed_bytes), + mem_consumer: ConsumeMemoryBehaviour1MBPending0Established::default(), + }); + + let addr: Multiaddr = "/memory/1234".parse().unwrap(); + let target = PeerId::random(); + + // Exercise `dial` function to get more stable memory stats later + network + .dial( + DialOpts::peer_id(target) + .addresses(vec![addr.clone()]) + .build(), + ) + .expect("Unexpected connection limit."); + + // Adds current mem usage to the limit and update + let max_allowed_bytes_plus_base_usage = + max_allowed_bytes + memory_stats::memory_stats().unwrap().physical_mem; + network.behaviour_mut().connection_limits = + Behaviour::with_max_bytes(max_allowed_bytes_plus_base_usage); + + for _ in 0..CONNECTION_LIMIT { + network + .dial( + DialOpts::peer_id(target) + .addresses(vec![addr.clone()]) + .build(), + ) + .expect("Unexpected connection limit."); + } + + std::thread::sleep(Duration::from_millis(100)); // Memory stats are only updated every 100ms internally, ensure they are up-to-date when we try to exceed it. + + match network + .dial(DialOpts::peer_id(target).addresses(vec![addr]).build()) + .expect_err("Unexpected dialing success.") + { + DialError::Denied { cause } => { + let exceeded = cause + .downcast::() + .expect("connection denied because of limit"); + + assert_eq!( + exceeded.max_allowed_bytes(), + max_allowed_bytes_plus_base_usage + ); + assert!(exceeded.process_physical_memory_bytes() >= exceeded.max_allowed_bytes()); + } + e => panic!("Unexpected error: {e:?}"), + } +} diff --git a/misc/memory-connection-limits/tests/max_percentage.rs b/misc/memory-connection-limits/tests/max_percentage.rs new file mode 100644 index 00000000000..ea3f20e6cbc --- /dev/null +++ b/misc/memory-connection-limits/tests/max_percentage.rs @@ -0,0 +1,88 @@ +// Copyright 2023 Protocol Labs. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + +mod util; + +use libp2p_core::Multiaddr; +use libp2p_identity::PeerId; +use libp2p_memory_connection_limits::*; +use std::time::Duration; +use sysinfo::{RefreshKind, SystemExt}; +use util::*; + +use libp2p_swarm::{dial_opts::DialOpts, DialError, Swarm}; +use libp2p_swarm_test::SwarmExt; + +#[test] +fn max_percentage() { + const CONNECTION_LIMIT: usize = 20; + let system_info = sysinfo::System::new_with_specifics(RefreshKind::new().with_memory()); + + let mut network = Swarm::new_ephemeral(|_| TestBehaviour { + connection_limits: Behaviour::with_max_percentage(0.1), + mem_consumer: ConsumeMemoryBehaviour1MBPending0Established::default(), + }); + + let addr: Multiaddr = "/memory/1234".parse().unwrap(); + let target = PeerId::random(); + + // Exercise `dial` function to get more stable memory stats later + network + .dial( + DialOpts::peer_id(target) + .addresses(vec![addr.clone()]) + .build(), + ) + .expect("Unexpected connection limit."); + + // Adds current mem usage to the limit and update + let current_mem = memory_stats::memory_stats().unwrap().physical_mem; + let max_allowed_bytes = current_mem + CONNECTION_LIMIT * 1024 * 1024; + network.behaviour_mut().connection_limits = Behaviour::with_max_percentage( + max_allowed_bytes as f64 / system_info.total_memory() as f64, + ); + + for _ in 0..CONNECTION_LIMIT { + network + .dial( + DialOpts::peer_id(target) + .addresses(vec![addr.clone()]) + .build(), + ) + .expect("Unexpected connection limit."); + } + + std::thread::sleep(Duration::from_millis(100)); // Memory stats are only updated every 100ms internally, ensure they are up-to-date when we try to exceed it. + + match network + .dial(DialOpts::peer_id(target).addresses(vec![addr]).build()) + .expect_err("Unexpected dialing success.") + { + DialError::Denied { cause } => { + let exceeded = cause + .downcast::() + .expect("connection denied because of limit"); + + assert_eq!(exceeded.max_allowed_bytes(), max_allowed_bytes); + assert!(exceeded.process_physical_memory_bytes() >= exceeded.max_allowed_bytes()); + } + e => panic!("Unexpected error: {e:?}"), + } +} diff --git a/misc/memory-connection-limits/tests/util.rs b/misc/memory-connection-limits/tests/util.rs new file mode 100644 index 00000000000..a2fd7c20fed --- /dev/null +++ b/misc/memory-connection-limits/tests/util.rs @@ -0,0 +1,128 @@ +// Copyright 2023 Protocol Labs. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + +use std::task::{Context, Poll}; + +use libp2p_core::{Endpoint, Multiaddr}; +use libp2p_identity::PeerId; +use libp2p_swarm::{ + dummy, ConnectionDenied, ConnectionId, FromSwarm, NetworkBehaviour, PollParameters, THandler, + THandlerInEvent, THandlerOutEvent, ToSwarm, +}; +use void::Void; + +#[derive(libp2p_swarm_derive::NetworkBehaviour)] +#[behaviour(prelude = "libp2p_swarm::derive_prelude")] +pub(crate) struct TestBehaviour { + pub(crate) connection_limits: libp2p_memory_connection_limits::Behaviour, + pub(crate) mem_consumer: ConsumeMemoryBehaviour1MBPending0Established, +} + +pub(crate) type ConsumeMemoryBehaviour1MBPending0Established = + ConsumeMemoryBehaviour<{ 1024 * 1024 }, 0>; + +#[derive(Default)] +pub(crate) struct ConsumeMemoryBehaviour { + mem_pending: Vec>, + mem_established: Vec>, +} + +impl + ConsumeMemoryBehaviour +{ + fn handle_pending(&mut self) { + // 1MB + self.mem_pending.push(vec![1; MEM_PENDING]); + } + + fn handle_established(&mut self) { + // 1MB + self.mem_established.push(vec![1; MEM_ESTABLISHED]); + } +} + +impl NetworkBehaviour + for ConsumeMemoryBehaviour +{ + type ConnectionHandler = dummy::ConnectionHandler; + type ToSwarm = Void; + + fn handle_pending_inbound_connection( + &mut self, + _: ConnectionId, + _: &Multiaddr, + _: &Multiaddr, + ) -> Result<(), ConnectionDenied> { + self.handle_pending(); + Ok(()) + } + + fn handle_pending_outbound_connection( + &mut self, + _: ConnectionId, + _: Option, + _: &[Multiaddr], + _: Endpoint, + ) -> Result, ConnectionDenied> { + self.handle_pending(); + Ok(vec![]) + } + + fn handle_established_inbound_connection( + &mut self, + _: ConnectionId, + _: PeerId, + _: &Multiaddr, + _: &Multiaddr, + ) -> Result, ConnectionDenied> { + self.handle_established(); + Ok(dummy::ConnectionHandler) + } + + fn handle_established_outbound_connection( + &mut self, + _: ConnectionId, + _: PeerId, + _: &Multiaddr, + _: Endpoint, + ) -> Result, ConnectionDenied> { + self.handle_established(); + Ok(dummy::ConnectionHandler) + } + + fn on_swarm_event(&mut self, _: FromSwarm) {} + + fn on_connection_handler_event( + &mut self, + _id: PeerId, + _: ConnectionId, + event: THandlerOutEvent, + ) { + void::unreachable(event) + } + + fn poll( + &mut self, + _: &mut Context<'_>, + _: &mut impl PollParameters, + ) -> Poll>> { + Poll::Pending + } +} diff --git a/misc/metrics/CHANGELOG.md b/misc/metrics/CHANGELOG.md index cca9ced5ec7..5c3d3c140ba 100644 --- a/misc/metrics/CHANGELOG.md +++ b/misc/metrics/CHANGELOG.md @@ -1,11 +1,11 @@ -## 0.13.1 - unreleased +## 0.13.1 - Enable gossipsub related data-type fields when compiling for wasm. See [PR 4217]. [PR 4217]: https://github.com/libp2p/rust-libp2p/pull/4217 -## 0.13.0 +## 0.13.0 - Previously `libp2p-metrics::identify` would increase a counter / gauge / histogram on each received identify information. These metrics are misleading, as e.g. they depend on the identify diff --git a/misc/metrics/Cargo.toml b/misc/metrics/Cargo.toml index e93d1f663ed..1ea026a9202 100644 --- a/misc/metrics/Cargo.toml +++ b/misc/metrics/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "libp2p-metrics" edition = "2021" -rust-version = "1.65.0" +rust-version = { workspace = true } description = "Metrics for libp2p" version = "0.13.1" authors = ["Max Inden "] diff --git a/muxers/yamux/CHANGELOG.md b/muxers/yamux/CHANGELOG.md index caea4e5359e..92e9fbebc02 100644 --- a/muxers/yamux/CHANGELOG.md +++ b/muxers/yamux/CHANGELOG.md @@ -1,4 +1,4 @@ -## 0.44.1 - unreleased +## 0.44.1 - Update to `yamux` `v0.12` which brings performance improvements and introduces an ACK backlog of 256 inbound streams. When interacting with other libp2p nodes that are also running this or a newer version, the creation of inbound streams will be backpressured once the ACK backlog is hit. @@ -6,7 +6,7 @@ [PR 3013]: https://github.com/libp2p/rust-libp2p/pull/3013 -## 0.44.0 +## 0.44.0 - Raise MSRV to 1.65. See [PR 3715]. diff --git a/protocols/dcutr/Cargo.toml b/protocols/dcutr/Cargo.toml index 5ef81f0dcf3..2b9d3c3a669 100644 --- a/protocols/dcutr/Cargo.toml +++ b/protocols/dcutr/Cargo.toml @@ -27,7 +27,7 @@ void = "1" [dev-dependencies] async-std = { version = "1.12.0", features = ["attributes"] } -clap = { version = "4.3.12", features = ["derive"] } +clap = { version = "4.3.21", features = ["derive"] } env_logger = "0.10.0" libp2p-dns = { workspace = true, features = ["async-std"] } libp2p-identify = { workspace = true } diff --git a/protocols/gossipsub/CHANGELOG.md b/protocols/gossipsub/CHANGELOG.md index ab483bdd8a1..a1f4ef6c973 100644 --- a/protocols/gossipsub/CHANGELOG.md +++ b/protocols/gossipsub/CHANGELOG.md @@ -1,4 +1,4 @@ -## 0.45.1 - unreleased +## 0.45.1 - Add getter function to obtain `TopicScoreParams`. See [PR 4231]. diff --git a/protocols/gossipsub/Cargo.toml b/protocols/gossipsub/Cargo.toml index 9989a0fae3e..acbab0c82e9 100644 --- a/protocols/gossipsub/Cargo.toml +++ b/protocols/gossipsub/Cargo.toml @@ -28,11 +28,11 @@ instant = "0.1.12" libp2p-core = { workspace = true } libp2p-identity = { workspace = true } libp2p-swarm = { workspace = true } -log = "0.4.19" +log = "0.4.20" quick-protobuf = "0.8" quick-protobuf-codec = { workspace = true } rand = "0.8" -regex = "1.9.1" +regex = "1.9.3" serde = { version = "1", optional = true, features = ["derive"] } sha2 = "0.10.7" smallvec = "1.11.0" diff --git a/protocols/identify/Cargo.toml b/protocols/identify/Cargo.toml index 61d38ede934..fb207dd7e8a 100644 --- a/protocols/identify/Cargo.toml +++ b/protocols/identify/Cargo.toml @@ -17,7 +17,7 @@ futures-timer = "3.0.2" libp2p-core = { workspace = true } libp2p-swarm = { workspace = true } libp2p-identity = { workspace = true } -log = "0.4.19" +log = "0.4.20" lru = "0.11.0" quick-protobuf-codec = { workspace = true } quick-protobuf = "0.8" diff --git a/protocols/kad/CHANGELOG.md b/protocols/kad/CHANGELOG.md index e3da07294fb..a9cde76dd76 100644 --- a/protocols/kad/CHANGELOG.md +++ b/protocols/kad/CHANGELOG.md @@ -1,9 +1,12 @@ -## 0.44.4 - unreleased +## 0.44.4 - Implement common traits on `RoutingUpdate`. See [PR 4270]. +- Reduce noise of "remote supports our protocol" log. + See [PR 4278]. [PR 4270]: https://github.com/libp2p/rust-libp2p/pull/4270 +[PR 4278]: https://github.com/libp2p/rust-libp2p/pull/4278 ## 0.44.3 diff --git a/protocols/kad/Cargo.toml b/protocols/kad/Cargo.toml index 80e8946f871..fa937033908 100644 --- a/protocols/kad/Cargo.toml +++ b/protocols/kad/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "libp2p-kad" edition = "2021" -rust-version = "1.65.0" +rust-version = { workspace = true } description = "Kademlia protocol for libp2p" version = "0.44.4" authors = ["Parity Technologies "] diff --git a/protocols/kad/src/behaviour.rs b/protocols/kad/src/behaviour.rs index fa582496a9d..340fefb276a 100644 --- a/protocols/kad/src/behaviour.rs +++ b/protocols/kad/src/behaviour.rs @@ -2081,6 +2081,7 @@ where connected_point, peer, self.mode, + connection_id, )) } @@ -2103,6 +2104,7 @@ where connected_point, peer, self.mode, + connection_id, )) } diff --git a/protocols/kad/src/handler.rs b/protocols/kad/src/handler.rs index 948f14f30eb..d695420ec2b 100644 --- a/protocols/kad/src/handler.rs +++ b/protocols/kad/src/handler.rs @@ -35,7 +35,7 @@ use libp2p_swarm::handler::{ ConnectionEvent, DialUpgradeError, FullyNegotiatedInbound, FullyNegotiatedOutbound, }; use libp2p_swarm::{ - ConnectionHandler, ConnectionHandlerEvent, KeepAlive, Stream, StreamUpgradeError, + ConnectionHandler, ConnectionHandlerEvent, ConnectionId, KeepAlive, Stream, StreamUpgradeError, SubstreamProtocol, SupportedProtocols, }; use log::trace; @@ -94,6 +94,9 @@ pub struct KademliaHandler { protocol_status: ProtocolStatus, remote_supported_protocols: SupportedProtocols, + + /// The ID of this connection. + connection_id: ConnectionId, } /// The states of protocol confirmation that a connection @@ -474,6 +477,7 @@ impl KademliaHandler { endpoint: ConnectedPoint, remote_peer_id: PeerId, mode: Mode, + connection_id: ConnectionId, ) -> Self { match &endpoint { ConnectedPoint::Dialer { .. } => { @@ -504,6 +508,7 @@ impl KademliaHandler { keep_alive, protocol_status: ProtocolStatus::Unknown, remote_supported_protocols: Default::default(), + connection_id, } } @@ -803,17 +808,19 @@ impl ConnectionHandler for KademliaHandler { match (remote_supports_our_kademlia_protocols, self.protocol_status) { (true, ProtocolStatus::Confirmed | ProtocolStatus::Reported) => {} (true, _) => { - log::info!( - "Remote {} now supports our kademlia protocol", - self.remote_peer_id + log::debug!( + "Remote {} now supports our kademlia protocol on connection {}", + self.remote_peer_id, + self.connection_id, ); self.protocol_status = ProtocolStatus::Confirmed; } (false, ProtocolStatus::Confirmed | ProtocolStatus::Reported) => { - log::info!( - "Remote {} no longer supports our kademlia protocol", - self.remote_peer_id + log::debug!( + "Remote {} no longer supports our kademlia protocol on connection {}", + self.remote_peer_id, + self.connection_id, ); self.protocol_status = ProtocolStatus::NotSupported; diff --git a/protocols/mdns/Cargo.toml b/protocols/mdns/Cargo.toml index 830547e7bbd..14a30e6b923 100644 --- a/protocols/mdns/Cargo.toml +++ b/protocols/mdns/Cargo.toml @@ -18,11 +18,11 @@ if-watch = "3.0.1" libp2p-core = { workspace = true } libp2p-swarm = { workspace = true } libp2p-identity = { workspace = true } -log = "0.4.19" +log = "0.4.20" rand = "0.8.3" smallvec = "1.11.0" socket2 = { version = "0.5.3", features = ["all"] } -tokio = { version = "1.29", default-features = false, features = ["net", "time"], optional = true} +tokio = { version = "1.31", default-features = false, features = ["net", "time"], optional = true} trust-dns-proto = { version = "0.22.0", default-features = false, features = ["mdns", "tokio-runtime"] } void = "1.0.2" @@ -37,7 +37,7 @@ libp2p-noise = { workspace = true } libp2p-swarm = { workspace = true, features = ["tokio", "async-std"] } libp2p-tcp = { workspace = true, features = ["tokio", "async-io"] } libp2p-yamux = { workspace = true } -tokio = { version = "1.29", default-features = false, features = ["macros", "rt", "rt-multi-thread", "time"] } +tokio = { version = "1.31", default-features = false, features = ["macros", "rt", "rt-multi-thread", "time"] } libp2p-swarm-test = { path = "../../swarm-test" } [[test]] diff --git a/protocols/perf/Cargo.toml b/protocols/perf/Cargo.toml index 5374c68ac9a..499cfd82834 100644 --- a/protocols/perf/Cargo.toml +++ b/protocols/perf/Cargo.toml @@ -13,7 +13,7 @@ categories = ["network-programming", "asynchronous"] [dependencies] anyhow = "1" async-trait = "0.1" -clap = { version = "4.3.12", features = ["derive"] } +clap = { version = "4.3.21", features = ["derive"] } env_logger = "0.10.0" futures = "0.3.28" instant = "0.1.12" @@ -30,7 +30,7 @@ log = "0.4" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" thiserror = "1.0" -tokio = { version = "1.29.1", features = ["full"] } +tokio = { version = "1.31.0", features = ["full"] } void = "1" [dev-dependencies] diff --git a/protocols/ping/Cargo.toml b/protocols/ping/Cargo.toml index aebc473512b..f66222efff7 100644 --- a/protocols/ping/Cargo.toml +++ b/protocols/ping/Cargo.toml @@ -18,7 +18,7 @@ instant = "0.1.12" libp2p-core = { workspace = true } libp2p-swarm = { workspace = true } libp2p-identity = { workspace = true } -log = "0.4.19" +log = "0.4.20" rand = "0.8" void = "1.0" diff --git a/protocols/relay/CHANGELOG.md b/protocols/relay/CHANGELOG.md index c79034c24d4..6af89e25d71 100644 --- a/protocols/relay/CHANGELOG.md +++ b/protocols/relay/CHANGELOG.md @@ -1,4 +1,4 @@ -## 0.16.1 - unreleased +## 0.16.1 - Export `RateLimiter` type. See [PR 3742]. diff --git a/protocols/rendezvous/Cargo.toml b/protocols/rendezvous/Cargo.toml index b24781dcd74..7929d3c4a06 100644 --- a/protocols/rendezvous/Cargo.toml +++ b/protocols/rendezvous/Cargo.toml @@ -37,7 +37,7 @@ libp2p-identify = { workspace = true } libp2p-yamux = { workspace = true } libp2p-tcp = { workspace = true, features = ["tokio"] } rand = "0.8" -tokio = { version = "1.29", features = [ "rt-multi-thread", "time", "macros", "sync", "process", "fs", "net" ] } +tokio = { version = "1.31", features = [ "rt-multi-thread", "time", "macros", "sync", "process", "fs", "net" ] } libp2p-swarm-test = { path = "../../swarm-test" } # Passing arguments to the docsrs builder in order to properly document cfg's. diff --git a/protocols/request-response/CHANGELOG.md b/protocols/request-response/CHANGELOG.md index 292cb812103..693145c6f72 100644 --- a/protocols/request-response/CHANGELOG.md +++ b/protocols/request-response/CHANGELOG.md @@ -1,4 +1,4 @@ -## 0.25.1 - unreleased +## 0.25.1 - Replace unmaintained `serde_cbor` dependency with `cbor4ii`. See [PR 4187]. diff --git a/protocols/request-response/Cargo.toml b/protocols/request-response/Cargo.toml index ddb87316f86..40e65f1cccc 100644 --- a/protocols/request-response/Cargo.toml +++ b/protocols/request-response/Cargo.toml @@ -23,7 +23,7 @@ serde = { version = "1.0", optional = true} serde_json = { version = "1.0.100", optional = true } smallvec = "1.11.0" void = "1.0.2" -log = "0.4.19" +log = "0.4.20" [features] json = ["dep:serde", "dep:serde_json", "libp2p-swarm/macros"] diff --git a/swarm-test/Cargo.toml b/swarm-test/Cargo.toml index 69aa312b428..67753b1c522 100644 --- a/swarm-test/Cargo.toml +++ b/swarm-test/Cargo.toml @@ -2,7 +2,7 @@ name = "libp2p-swarm-test" version = "0.2.0" edition = "2021" -rust-version = "1.65.0" +rust-version = { workspace = true } license = "MIT" description = "Test framework for code building on top of libp2p-swarm" repository = "https://github.com/libp2p/rust-libp2p" @@ -12,7 +12,7 @@ categories = ["network-programming", "asynchronous"] # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -async-trait = "0.1.72" +async-trait = "0.1.73" libp2p-core = { workspace = true } libp2p-identity = { workspace = true } libp2p-plaintext = { workspace = true } @@ -20,6 +20,6 @@ libp2p-swarm = { workspace = true } libp2p-tcp = { workspace = true, features = ["async-io"] } libp2p-yamux = { workspace = true } futures = "0.3.28" -log = "0.4.19" +log = "0.4.20" rand = "0.8.5" futures-timer = "3.0.2" diff --git a/swarm/CHANGELOG.md b/swarm/CHANGELOG.md index 1d4108ac92c..37a5cbc6157 100644 --- a/swarm/CHANGELOG.md +++ b/swarm/CHANGELOG.md @@ -1,3 +1,10 @@ +## 0.43.3 + +- Implement `Display` for `ConnectionId`. + See [PR 4278]. + +[PR 4278]: https://github.com/libp2p/rust-libp2p/pull/4278 + ## 0.43.2 - Display the cause of a `ListenError::Denied`. See [PR 4232] diff --git a/swarm/Cargo.toml b/swarm/Cargo.toml index 752491cda7e..1290bfdddf4 100644 --- a/swarm/Cargo.toml +++ b/swarm/Cargo.toml @@ -3,7 +3,7 @@ name = "libp2p-swarm" edition = "2021" rust-version = { workspace = true } description = "The libp2p swarm" -version = "0.43.2" +version = "0.43.3" authors = ["Parity Technologies "] license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" @@ -30,7 +30,7 @@ multistream-select = { workspace = true } [target.'cfg(not(any(target_os = "emscripten", target_os = "wasi", target_os = "unknown")))'.dependencies] async-std = { version = "1.6.2", optional = true } -tokio = { version = "1.29", features = ["rt"], optional = true } +tokio = { version = "1.31", features = ["rt"], optional = true } [features] macros = ["dep:libp2p-swarm-derive"] @@ -48,9 +48,9 @@ libp2p-identity = { workspace = true, features = ["ed25519"] } libp2p-kad = { path = "../protocols/kad" } # Using `path` here because this is a cyclic dev-dependency which otherwise breaks releasing. libp2p-ping = { path = "../protocols/ping" } # Using `path` here because this is a cyclic dev-dependency which otherwise breaks releasing. libp2p-plaintext = { path = "../transports/plaintext" } # Using `path` here because this is a cyclic dev-dependency which otherwise breaks releasing. -libp2p-swarm-derive = { path = "../swarm-derive" } +libp2p-swarm-derive = { path = "../swarm-derive" } # Using `path` here because this is a cyclic dev-dependency which otherwise breaks releasing. libp2p-swarm-test = { path = "../swarm-test" } # Using `path` here because this is a cyclic dev-dependency which otherwise breaks releasing. -libp2p-yamux = { workspace = true } +libp2p-yamux = { path = "../muxers/yamux" } # Using `path` here because this is a cyclic dev-dependency which otherwise breaks releasing. quickcheck = { workspace = true } void = "1" once_cell = "1.18.0" diff --git a/swarm/src/connection.rs b/swarm/src/connection.rs index 6646967f590..3796d9a027d 100644 --- a/swarm/src/connection.rs +++ b/swarm/src/connection.rs @@ -53,6 +53,7 @@ use libp2p_core::upgrade::{NegotiationError, ProtocolError}; use libp2p_core::Endpoint; use libp2p_identity::PeerId; use std::collections::HashSet; +use std::fmt::{Display, Formatter}; use std::future::Future; use std::sync::atomic::{AtomicUsize, Ordering}; use std::task::Waker; @@ -82,6 +83,12 @@ impl ConnectionId { } } +impl Display for ConnectionId { + fn fmt(&self, f: &mut Formatter) -> fmt::Result { + write!(f, "{}", self.0) + } +} + /// Information about a successfully established connection. #[derive(Debug, Clone, PartialEq, Eq)] pub(crate) struct Connected { diff --git a/transports/dns/Cargo.toml b/transports/dns/Cargo.toml index d1afd0411f9..a85307aad32 100644 --- a/transports/dns/Cargo.toml +++ b/transports/dns/Cargo.toml @@ -13,7 +13,7 @@ categories = ["network-programming", "asynchronous"] [dependencies] libp2p-core = { workspace = true } libp2p-identity = { workspace = true } -log = "0.4.19" +log = "0.4.20" futures = "0.3.28" async-std-resolver = { version = "0.22", optional = true } parking_lot = "0.12.0" diff --git a/transports/plaintext/Cargo.toml b/transports/plaintext/Cargo.toml index 6990a846c27..1f15004d3f4 100644 --- a/transports/plaintext/Cargo.toml +++ b/transports/plaintext/Cargo.toml @@ -16,7 +16,7 @@ bytes = "1" futures = "0.3.28" libp2p-core = { workspace = true } libp2p-identity = { workspace = true } -log = "0.4.19" +log = "0.4.20" quick-protobuf = "0.8" unsigned-varint = { version = "0.7", features = ["asynchronous_codec"] } diff --git a/transports/pnet/Cargo.toml b/transports/pnet/Cargo.toml index 6deee7d7e9a..597709c5330 100644 --- a/transports/pnet/Cargo.toml +++ b/transports/pnet/Cargo.toml @@ -12,7 +12,7 @@ categories = ["network-programming", "asynchronous"] [dependencies] futures = "0.3.28" -log = "0.4.19" +log = "0.4.20" salsa20 = "0.10" sha3 = "0.10" rand = "0.8" @@ -27,7 +27,7 @@ libp2p-tcp = { workspace = true, features = ["tokio"] } libp2p-websocket = { workspace = true } libp2p-yamux = { workspace = true } quickcheck = { workspace = true } -tokio = { version = "1.29.1", features = ["full"] } +tokio = { version = "1.31.0", features = ["full"] } # Passing arguments to the docsrs builder in order to properly document cfg's. # More information: https://docs.rs/about/builds#cross-compiling diff --git a/transports/quic/CHANGELOG.md b/transports/quic/CHANGELOG.md index 11ee1e63394..c7da2895b58 100644 --- a/transports/quic/CHANGELOG.md +++ b/transports/quic/CHANGELOG.md @@ -1,3 +1,21 @@ +## 0.9.2 - unreleased + +- Cut stable release. + +## 0.9.2-alpha + +- Add support for reusing an existing socket when dialing localhost address. + See [PR 4304]. + +[PR 4304]: https://github.com/libp2p/rust-libp2p/pull/4304 + +## 0.9.1-alpha + +- Allow listening on ipv4 and ipv6 separately. + See [PR 4289]. + +[PR 4289]: https://github.com/libp2p/rust-libp2p/pull/4289 + ## 0.9.0-alpha - Use `quinn` instead of `quinn-proto`. diff --git a/transports/quic/Cargo.toml b/transports/quic/Cargo.toml index 5d810860912..13fbe9bb3c5 100644 --- a/transports/quic/Cargo.toml +++ b/transports/quic/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "libp2p-quic" -version = "0.9.0-alpha" +version = "0.9.2" authors = ["Parity Technologies "] edition = "2021" rust-version = { workspace = true } @@ -23,7 +23,8 @@ quinn = { version = "0.10.1", default-features = false, features = ["tls-rustls" rand = "0.8.5" rustls = { version = "0.21.2", default-features = false } thiserror = "1.0.44" -tokio = { version = "1.29.1", default-features = false, features = ["net", "rt", "time"], optional = true } +tokio = { version = "1.31.0", default-features = false, features = ["net", "rt", "time"], optional = true } +socket2 = "0.5.3" [features] tokio = ["dep:tokio", "if-watch/tokio", "quinn/runtime-tokio"] @@ -44,7 +45,7 @@ libp2p-noise = { workspace = true } libp2p-tcp = { workspace = true, features = ["async-io"] } libp2p-yamux = { workspace = true } quickcheck = "1" -tokio = { version = "1.29.1", features = ["macros", "rt-multi-thread", "time"] } +tokio = { version = "1.31.0", features = ["macros", "rt-multi-thread", "time"] } [[test]] name = "stream_compliance" diff --git a/transports/quic/src/transport.rs b/transports/quic/src/transport.rs index d4a1db35604..16ffbc5a163 100644 --- a/transports/quic/src/transport.rs +++ b/transports/quic/src/transport.rs @@ -37,12 +37,13 @@ use libp2p_core::{ Transport, }; use libp2p_identity::PeerId; +use socket2::{Domain, Socket, Type}; use std::collections::hash_map::{DefaultHasher, Entry}; -use std::collections::HashMap; -use std::fmt; +use std::collections::{HashMap, HashSet}; use std::hash::{Hash, Hasher}; use std::net::{IpAddr, Ipv4Addr, Ipv6Addr, UdpSocket}; use std::time::Duration; +use std::{fmt, io}; use std::{ net::SocketAddr, pin::Pin, @@ -154,9 +155,16 @@ impl GenTransport

{ if l.is_closed { return false; } - let listen_addr = l.socket_addr(); - SocketFamily::is_same(&listen_addr.ip(), &socket_addr.ip()) - && listen_addr.ip().is_loopback() == socket_addr.ip().is_loopback() + SocketFamily::is_same(&l.socket_addr().ip(), &socket_addr.ip()) + }) + .filter(|l| { + if socket_addr.ip().is_loopback() { + l.listening_addresses + .iter() + .any(|ip_addr| ip_addr.is_loopback()) + } else { + true + } }) .collect(); match listeners.len() { @@ -172,6 +180,21 @@ impl GenTransport

{ } } } + + fn create_socket(&self, socket_addr: SocketAddr) -> io::Result { + let socket = Socket::new( + Domain::for_address(socket_addr), + Type::DGRAM, + Some(socket2::Protocol::UDP), + )?; + if socket_addr.is_ipv6() { + socket.set_only_v6(true)?; + } + + socket.bind(&socket_addr.into())?; + + Ok(socket.into()) + } } impl Transport for GenTransport

{ @@ -188,7 +211,8 @@ impl Transport for GenTransport

{ let (socket_addr, version, _peer_id) = self.remote_multiaddr_to_socketaddr(addr, false)?; let endpoint_config = self.quinn_config.endpoint_config.clone(); let server_config = self.quinn_config.server_config.clone(); - let socket = UdpSocket::bind(socket_addr).map_err(Self::Error::from)?; + let socket = self.create_socket(socket_addr).map_err(Self::Error::from)?; + let socket_c = socket.try_clone().map_err(Self::Error::from)?; let endpoint = Self::new_endpoint(endpoint_config, Some(server_config), socket)?; let listener = Listener::new( @@ -411,6 +435,8 @@ struct Listener { /// The stream must be awaken after it has been closed to deliver the last event. close_listener_waker: Option, + + listening_addresses: HashSet, } impl Listener

{ @@ -423,12 +449,14 @@ impl Listener

{ ) -> Result { let if_watcher; let pending_event; + let mut listening_addresses = HashSet::new(); let local_addr = socket.local_addr()?; if local_addr.ip().is_unspecified() { if_watcher = Some(P::new_if_watcher()?); pending_event = None; } else { if_watcher = None; + listening_addresses.insert(local_addr.ip()); let ma = socketaddr_to_multiaddr(&local_addr, version); pending_event = Some(TransportEvent::NewAddress { listener_id, @@ -450,6 +478,7 @@ impl Listener

{ is_closed: false, pending_event, close_listener_waker: None, + listening_addresses, }) } @@ -496,7 +525,8 @@ impl Listener

{ if let Some(listen_addr) = ip_to_listenaddr(&endpoint_addr, inet.addr(), self.version) { - log::debug!("New listen address: {}", listen_addr); + log::debug!("New listen address: {listen_addr}"); + self.listening_addresses.insert(inet.addr()); return Poll::Ready(TransportEvent::NewAddress { listener_id: self.listener_id, listen_addr, @@ -507,7 +537,8 @@ impl Listener

{ if let Some(listen_addr) = ip_to_listenaddr(&endpoint_addr, inet.addr(), self.version) { - log::debug!("Expired listen address: {}", listen_addr); + log::debug!("Expired listen address: {listen_addr}"); + self.listening_addresses.remove(&inet.addr()); return Poll::Ready(TransportEvent::AddressExpired { listener_id: self.listener_id, listen_addr, @@ -713,7 +744,7 @@ fn socketaddr_to_multiaddr(socket_addr: &SocketAddr, version: ProtocolVersion) - #[cfg(test)] #[cfg(any(feature = "async-std", feature = "tokio"))] -mod test { +mod tests { use futures::future::poll_fn; use std::net::{IpAddr, Ipv4Addr, Ipv6Addr}; @@ -888,4 +919,29 @@ mod test { .unwrap(); assert!(!transport.dialer.contains_key(&SocketFamily::Ipv4)); } + + #[cfg(feature = "tokio")] + #[tokio::test] + async fn test_listens_ipv4_ipv6_separately() { + let keypair = libp2p_identity::Keypair::generate_ed25519(); + let config = Config::new(&keypair); + let mut transport = crate::tokio::Transport::new(config); + let port = { + let socket = UdpSocket::bind("127.0.0.1:0").unwrap(); + socket.local_addr().unwrap().port() + }; + + transport + .listen_on( + ListenerId::next(), + format!("/ip4/0.0.0.0/udp/{port}/quic-v1").parse().unwrap(), + ) + .unwrap(); + transport + .listen_on( + ListenerId::next(), + format!("/ip6/::/udp/{port}/quic-v1").parse().unwrap(), + ) + .unwrap(); + } } diff --git a/transports/quic/tests/smoke.rs b/transports/quic/tests/smoke.rs index 93adfa68013..a0c43b9ebdd 100644 --- a/transports/quic/tests/smoke.rs +++ b/transports/quic/tests/smoke.rs @@ -414,6 +414,49 @@ async fn write_after_peer_dropped_stream() { stream_b.close().await.expect("Close failed."); } +/// - A listens on 0.0.0.0:0 +/// - B listens on 127.0.0.1:0 +/// - A dials B +/// - Source port of A at B is the A's listen port +#[cfg(feature = "tokio")] +#[tokio::test] +async fn test_local_listener_reuse() { + let (_, mut a_transport) = create_default_transport::(); + let (_, mut b_transport) = create_default_transport::(); + + a_transport + .listen_on( + ListenerId::next(), + "/ip4/0.0.0.0/udp/0/quic-v1".parse().unwrap(), + ) + .unwrap(); + + // wait until a listener reports a loopback address + let a_listen_addr = 'outer: loop { + let ev = a_transport.next().await.unwrap(); + let listen_addr = ev.into_new_address().unwrap(); + for proto in listen_addr.iter() { + if let Protocol::Ip4(ip4) = proto { + if ip4.is_loopback() { + break 'outer listen_addr; + } + } + } + }; + // If we do not poll until the end, `NewAddress` events may be `Ready` and `connect` function + // below will panic due to an unexpected event. + poll_fn(|cx| { + let mut pinned = Pin::new(&mut a_transport); + while pinned.as_mut().poll(cx).is_ready() {} + Poll::Ready(()) + }) + .await; + + let b_addr = start_listening(&mut b_transport, "/ip4/127.0.0.1/udp/0/quic-v1").await; + let (_, send_back_addr, _) = connect(&mut b_transport, &mut a_transport, b_addr).await.0; + assert_eq!(send_back_addr, a_listen_addr); +} + async fn smoke() { let _ = env_logger::try_init(); diff --git a/transports/tcp/Cargo.toml b/transports/tcp/Cargo.toml index aaf409169dc..5aa01133335 100644 --- a/transports/tcp/Cargo.toml +++ b/transports/tcp/Cargo.toml @@ -18,9 +18,9 @@ if-watch = "3.0.1" libc = "0.2.147" libp2p-core = { workspace = true } libp2p-identity = { workspace = true } -log = "0.4.19" +log = "0.4.20" socket2 = { version = "0.5.3", features = ["all"] } -tokio = { version = "1.29.1", default-features = false, features = ["net"], optional = true } +tokio = { version = "1.31.0", default-features = false, features = ["net"], optional = true } [features] tokio = ["dep:tokio", "if-watch/tokio"] @@ -28,7 +28,7 @@ async-io = ["dep:async-io", "if-watch/smol"] [dev-dependencies] async-std = { version = "1.6.5", features = ["attributes"] } -tokio = { version = "1.29.1", default-features = false, features = ["full"] } +tokio = { version = "1.31.0", default-features = false, features = ["full"] } env_logger = "0.10.0" # Passing arguments to the docsrs builder in order to properly document cfg's. diff --git a/transports/tcp/src/lib.rs b/transports/tcp/src/lib.rs index b1737cf7bed..5efdf16fff5 100644 --- a/transports/tcp/src/lib.rs +++ b/transports/tcp/src/lib.rs @@ -346,13 +346,12 @@ where } } - fn create_socket(&self, socket_addr: &SocketAddr) -> io::Result { - let domain = if socket_addr.is_ipv4() { - Domain::IPV4 - } else { - Domain::IPV6 - }; - let socket = Socket::new(domain, Type::STREAM, Some(socket2::Protocol::TCP))?; + fn create_socket(&self, socket_addr: SocketAddr) -> io::Result { + let socket = Socket::new( + Domain::for_address(socket_addr), + Type::STREAM, + Some(socket2::Protocol::TCP), + )?; if socket_addr.is_ipv6() { socket.set_only_v6(true)?; } @@ -375,7 +374,7 @@ where id: ListenerId, socket_addr: SocketAddr, ) -> io::Result> { - let socket = self.create_socket(&socket_addr)?; + let socket = self.create_socket(socket_addr)?; socket.bind(&socket_addr.into())?; socket.listen(self.config.backlog as _)?; socket.set_nonblocking(true)?; @@ -476,7 +475,7 @@ where log::debug!("dialing {}", socket_addr); let socket = self - .create_socket(&socket_addr) + .create_socket(socket_addr) .map_err(TransportError::Other)?; if let Some(addr) = self.port_reuse.local_dial_addr(&socket_addr.ip()) { @@ -1329,4 +1328,42 @@ mod tests { assert!(rt.block_on(cycle_listeners::())); } } + + #[test] + fn test_listens_ipv4_ipv6_separately() { + fn test() { + let port = { + let listener = TcpListener::bind("127.0.0.1:0").unwrap(); + listener.local_addr().unwrap().port() + }; + let mut tcp = Transport::::default().boxed(); + let listener_id = ListenerId::next(); + tcp.listen_on( + listener_id, + format!("/ip4/0.0.0.0/tcp/{port}").parse().unwrap(), + ) + .unwrap(); + tcp.listen_on( + ListenerId::next(), + format!("/ip6/::/tcp/{port}").parse().unwrap(), + ) + .unwrap(); + } + #[cfg(feature = "async-io")] + { + async_std::task::block_on(async { + test::(); + }) + } + #[cfg(feature = "tokio")] + { + let rt = ::tokio::runtime::Builder::new_current_thread() + .enable_io() + .build() + .unwrap(); + rt.block_on(async { + test::(); + }); + } + } } diff --git a/transports/tls/Cargo.toml b/transports/tls/Cargo.toml index 351fc7037f6..191a24d6741 100644 --- a/transports/tls/Cargo.toml +++ b/transports/tls/Cargo.toml @@ -17,7 +17,7 @@ rcgen = "0.10.0" ring = "0.16.20" thiserror = "1.0.44" webpki = { version = "0.22.0", features = ["std"] } -x509-parser = "0.15.0" +x509-parser = "0.15.1" yasna = "0.5.2" # Exposed dependencies. Breaking changes to these are breaking changes to us. @@ -33,7 +33,7 @@ libp2p-core = { workspace = true } libp2p-identity = { workspace = true, features = ["ed25519", "rsa", "secp256k1", "ecdsa"] } libp2p-swarm = { workspace = true } libp2p-yamux = { workspace = true } -tokio = { version = "1.29.1", features = ["full"] } +tokio = { version = "1.31.0", features = ["full"] } # Passing arguments to the docsrs builder in order to properly document cfg's. # More information: https://docs.rs/about/builds#cross-compiling diff --git a/transports/uds/Cargo.toml b/transports/uds/Cargo.toml index be011b5ca8d..269eced5fa3 100644 --- a/transports/uds/Cargo.toml +++ b/transports/uds/Cargo.toml @@ -13,9 +13,9 @@ categories = ["network-programming", "asynchronous"] [dependencies] async-std = { version = "1.6.2", optional = true } libp2p-core = { workspace = true } -log = "0.4.19" +log = "0.4.20" futures = "0.3.28" -tokio = { version = "1.29", default-features = false, features = ["net"], optional = true } +tokio = { version = "1.31", default-features = false, features = ["net"], optional = true } [dev-dependencies] tempfile = "3.7" diff --git a/transports/webrtc/Cargo.toml b/transports/webrtc/Cargo.toml index 70d5553e293..05271951a33 100644 --- a/transports/webrtc/Cargo.toml +++ b/transports/webrtc/Cargo.toml @@ -32,7 +32,7 @@ serde = { version = "1.0", features = ["derive"] } stun = "0.4" thiserror = "1" tinytemplate = "1.2" -tokio = { version = "1.29", features = ["net"], optional = true} +tokio = { version = "1.31", features = ["net"], optional = true} tokio-util = { version = "0.7", features = ["compat"], optional = true } webrtc = { version = "0.8.0", optional = true } @@ -46,7 +46,7 @@ env_logger = "0.10" hex-literal = "0.4" libp2p-swarm = { workspace = true, features = ["macros", "tokio"] } libp2p-ping = { workspace = true } -tokio = { version = "1.29", features = ["full"] } +tokio = { version = "1.31", features = ["full"] } unsigned-varint = { version = "0.7", features = ["asynchronous_codec"] } void = "1" quickcheck = "1.0.3" diff --git a/transports/websocket/Cargo.toml b/transports/websocket/Cargo.toml index 3ebeb83bc16..39a96d69901 100644 --- a/transports/websocket/Cargo.toml +++ b/transports/websocket/Cargo.toml @@ -16,7 +16,7 @@ either = "1.9.0" futures = "0.3.28" libp2p-core = { workspace = true } libp2p-identity = { workspace = true } -log = "0.4.19" +log = "0.4.20" parking_lot = "0.12.0" quicksink = "0.1" rw-stream-sink = { workspace = true } diff --git a/transports/webtransport-websys/Cargo.toml b/transports/webtransport-websys/Cargo.toml index 21ca077fce9..695a62f4cde 100644 --- a/transports/webtransport-websys/Cargo.toml +++ b/transports/webtransport-websys/Cargo.toml @@ -19,7 +19,7 @@ js-sys = "0.3.64" libp2p-core = { workspace = true } libp2p-identity = { workspace = true } libp2p-noise = { workspace = true } -log = "0.4.19" +log = "0.4.20" multiaddr = { workspace = true } multihash = { workspace = true } send_wrapper = { version = "0.6.0", features = ["futures"] } diff --git a/wasm-tests/webtransport-tests/echo-server/go.mod b/wasm-tests/webtransport-tests/echo-server/go.mod index 5856827d798..669124e1f69 100644 --- a/wasm-tests/webtransport-tests/echo-server/go.mod +++ b/wasm-tests/webtransport-tests/echo-server/go.mod @@ -3,7 +3,7 @@ module echo-server go 1.20 require ( - github.com/libp2p/go-libp2p v0.27.5 + github.com/libp2p/go-libp2p v0.27.8 github.com/multiformats/go-multiaddr v0.9.0 ) @@ -44,8 +44,8 @@ require ( github.com/prometheus/common v0.42.0 // indirect github.com/prometheus/procfs v0.9.0 // indirect github.com/quic-go/qpack v0.4.0 // indirect - github.com/quic-go/qtls-go1-19 v0.3.2 // indirect - github.com/quic-go/qtls-go1-20 v0.2.2 // indirect + github.com/quic-go/qtls-go1-19 v0.3.3 // indirect + github.com/quic-go/qtls-go1-20 v0.2.3 // indirect github.com/quic-go/quic-go v0.33.0 // indirect github.com/quic-go/webtransport-go v0.5.2 // indirect github.com/spaolacci/murmur3 v1.1.0 // indirect diff --git a/wasm-tests/webtransport-tests/echo-server/go.sum b/wasm-tests/webtransport-tests/echo-server/go.sum index ab2832bce75..2e4b66d2ec0 100644 --- a/wasm-tests/webtransport-tests/echo-server/go.sum +++ b/wasm-tests/webtransport-tests/echo-server/go.sum @@ -97,8 +97,8 @@ github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/libp2p/go-buffer-pool v0.1.0 h1:oK4mSFcQz7cTQIfqbe4MIj9gLW+mnanjyFtc6cdF0Y8= github.com/libp2p/go-buffer-pool v0.1.0/go.mod h1:N+vh8gMqimBzdKkSMVuydVDq+UV5QTWy5HSiZacSbPg= -github.com/libp2p/go-libp2p v0.27.5 h1:KwA7pXKXpz8hG6Cr1fMA7UkgleogcwQj0sxl5qquWRg= -github.com/libp2p/go-libp2p v0.27.5/go.mod h1:oMfQGTb9CHnrOuSM6yMmyK2lXz3qIhnkn2+oK3B1Y2g= +github.com/libp2p/go-libp2p v0.27.8 h1:IX5x/4yKwyPQeVS2AXHZ3J4YATM9oHBGH1gBc23jBAI= +github.com/libp2p/go-libp2p v0.27.8/go.mod h1:eCFFtd0s5i/EVKR7+5Ki8bM7qwkNW3TPTTSSW9sz8NE= github.com/libp2p/go-msgio v0.3.0 h1:mf3Z8B1xcFN314sWX+2vOTShIE0Mmn2TXn3YCUQGNj0= github.com/libp2p/go-netroute v0.2.1 h1:V8kVrpD8GK0Riv15/7VN6RbUQ3URNZVosw7H2v9tksU= github.com/libp2p/go-netroute v0.2.1/go.mod h1:hraioZr0fhBjG0ZRXJJ6Zj2IVEVNx6tDTFQfSmcq7mQ= @@ -158,10 +158,10 @@ github.com/prometheus/procfs v0.9.0 h1:wzCHvIvM5SxWqYvwgVL7yJY8Lz3PKn49KQtpgMYJf github.com/prometheus/procfs v0.9.0/go.mod h1:+pB4zwohETzFnmlpe6yd2lSc+0/46IYZRB/chUwxUZY= github.com/quic-go/qpack v0.4.0 h1:Cr9BXA1sQS2SmDUWjSofMPNKmvF6IiIfDRmgU0w1ZCo= github.com/quic-go/qpack v0.4.0/go.mod h1:UZVnYIfi5GRk+zI9UMaCPsmZ2xKJP7XBUvVyT1Knj9A= -github.com/quic-go/qtls-go1-19 v0.3.2 h1:tFxjCFcTQzK+oMxG6Zcvp4Dq8dx4yD3dDiIiyc86Z5U= -github.com/quic-go/qtls-go1-19 v0.3.2/go.mod h1:ySOI96ew8lnoKPtSqx2BlI5wCpUVPT05RMAlajtnyOI= -github.com/quic-go/qtls-go1-20 v0.2.2 h1:WLOPx6OY/hxtTxKV1Zrq20FtXtDEkeY00CGQm8GEa3E= -github.com/quic-go/qtls-go1-20 v0.2.2/go.mod h1:JKtK6mjbAVcUTN/9jZpvLbGxvdWIKS8uT7EiStoU1SM= +github.com/quic-go/qtls-go1-19 v0.3.3 h1:wznEHvJwd+2X3PqftRha0SUKmGsnb6dfArMhy9PeJVE= +github.com/quic-go/qtls-go1-19 v0.3.3/go.mod h1:ySOI96ew8lnoKPtSqx2BlI5wCpUVPT05RMAlajtnyOI= +github.com/quic-go/qtls-go1-20 v0.2.3 h1:m575dovXn1y2ATOb1XrRFcrv0F+EQmlowTkoraNkDPI= +github.com/quic-go/qtls-go1-20 v0.2.3/go.mod h1:JKtK6mjbAVcUTN/9jZpvLbGxvdWIKS8uT7EiStoU1SM= github.com/quic-go/quic-go v0.33.0 h1:ItNoTDN/Fm/zBlq769lLJc8ECe9gYaW40veHCCco7y0= github.com/quic-go/quic-go v0.33.0/go.mod h1:YMuhaAV9/jIu0XclDXwZPAsP/2Kgr5yMYhe9oxhhOFA= github.com/quic-go/webtransport-go v0.5.2 h1:GA6Bl6oZY+g/flt00Pnu0XtivSD8vukOu3lYhJjnGEk=