diff --git a/.github/mergify.yml b/.github/mergify.yml index c630d23cea0..b464c9aba87 100644 --- a/.github/mergify.yml +++ b/.github/mergify.yml @@ -52,22 +52,22 @@ pull_request_rules: message: Approvals have been dismissed because the PR was updated after the `send-it` label was applied. changes_requested: false - - name: Approve trivial maintainer PRs - conditions: - - base=master - - label=trivial - - author=@libp2p/rust-libp2p-maintainers - actions: - review: + # - name: Approve trivial maintainer PRs + # conditions: + # - base=master + # - label=trivial + # - author=@libp2p/rust-libp2p-maintainers + # actions: + # review: - - name: Approve dependabot PRs of semver-compatible updates - conditions: - - author=dependabot[bot] - - or: - - title~=bump [^\s]+ from ([1-9]+)\..+ to \1\. # For major >= 1 versions, only approve updates with the same major version. - - title~=bump [^\s]+ from 0\.([\d]+)\..+ to 0\.\1\. # For major == 0 versions, only approve updates with the same minor version. - actions: - review: + # - name: Approve dependabot PRs of semver-compatible updates + # conditions: + # - author=dependabot[bot] + # - or: + # - title~=bump [^\s]+ from ([1-9]+)\..+ to \1\. # For major >= 1 versions, only approve updates with the same major version. + # - title~=bump [^\s]+ from 0\.([\d]+)\..+ to 0\.\1\. # For major == 0 versions, only approve updates with the same minor version. + # actions: + # review: queue_rules: - name: default diff --git a/Cargo.lock b/Cargo.lock index 6af9844477f..401b6114aa6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -144,9 +144,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.79" +version = "1.0.80" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "080e9890a082662b09c1ad45f567faeeb47f22b5fb23895fbe1e651e718e25ca" +checksum = "5ad32ce52e4161730f7098c077cd2ed6229b5804ccf99e5366be1ab72a98b4e1" [[package]] name = "arbitrary" @@ -312,7 +312,7 @@ dependencies = [ "futures-lite 2.0.1", "parking", "polling 3.3.0", - "rustix 0.38.28", + "rustix 0.38.31", "slab", "tracing", "windows-sys 0.52.0", @@ -408,7 +408,7 @@ dependencies = [ "futures-util", "hickory-resolver", "pin-utils", - "socket2 0.5.5", + "socket2 0.5.6", ] [[package]] @@ -425,7 +425,7 @@ checksum = "c980ee35e870bd1a4d2c8294d4c04d0499e67bca1e4b5cefcc693c2fa00caea9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.51", ] [[package]] @@ -947,7 +947,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.51", ] [[package]] @@ -1001,17 +1001,6 @@ version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "795bc6e66a8e340f075fcf6227e417a2dc976b92b91f3cdc778bb858778b6747" -[[package]] -name = "cookie" -version = "0.16.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e859cd57d0710d9e06c381b550c06e76992472a8c6d527aecd2fc673dcc231fb" -dependencies = [ - "percent-encoding", - "time", - "version_check", -] - [[package]] name = "core-foundation" version = "0.9.3" @@ -1224,7 +1213,7 @@ checksum = "83fdaf97f4804dcebfa5862639bc9ce4121e82140bec2a987ac5140294865b5b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.51", ] [[package]] @@ -1341,7 +1330,7 @@ checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.51", ] [[package]] @@ -1446,7 +1435,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.51", ] [[package]] @@ -1515,28 +1504,6 @@ dependencies = [ "pin-project-lite", ] -[[package]] -name = "fantoccini" -version = "0.20.0-rc.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5eb32b0001134a1d3b9e16010eb4b119451edf68446963a30a8130a0d056e98" -dependencies = [ - "base64 0.13.1", - "cookie", - "futures-core", - "futures-util", - "http 0.2.9", - "hyper 0.14.27", - "hyper-rustls", - "mime", - "serde", - "serde_json", - "time", - "tokio", - "url", - "webdriver", -] - [[package]] name = "fastrand" version = "1.9.0" @@ -1548,9 +1515,9 @@ dependencies = [ [[package]] name = "fastrand" -version = "2.0.0" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6999dc1837253364c2ebb0704ba97994bd874e8f195d665c50b7548f6ea92764" +checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5" [[package]] name = "ff" @@ -1572,12 +1539,11 @@ checksum = "d0870c84016d4b481be5c9f323c24f65e31e901ae618f0e80f4308fb00de1d2d" name = "file-sharing-example" version = "0.1.0" dependencies = [ - "async-std", "clap", - "either", "futures", "libp2p", "serde", + "tokio", "tracing", "tracing-subscriber", "void", @@ -1631,11 +1597,11 @@ dependencies = [ [[package]] name = "futures-bounded" version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1e2774cc104e198ef3d3e1ff4ab40f86fa3245d6cb6a3a46174f21463cee173" dependencies = [ - "futures", "futures-timer", "futures-util", - "tokio", ] [[package]] @@ -1705,7 +1671,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.51", ] [[package]] @@ -1715,7 +1681,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "35bd3cf68c183738046838e300353e4716c674dc5e56890de4826801a6622a28" dependencies = [ "futures-io", - "rustls 0.21.9", + "rustls", ] [[package]] @@ -1755,9 +1721,9 @@ dependencies = [ [[package]] name = "futures-timer" -version = "3.0.2" +version = "3.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e64b03909df88034c26dc1547e8970b91f98bdb65165d6a4e9110d94263dbb2c" +checksum = "f288b0a4f20f9a56b5d1da57e2227c661b7b16168e2f72365f57b63326e29b24" dependencies = [ "gloo-timers", "send_wrapper 0.4.0", @@ -1993,7 +1959,7 @@ dependencies = [ "ipnet", "once_cell", "rand 0.8.5", - "socket2 0.5.5", + "socket2 0.5.6", "thiserror", "tinyvec", "tokio", @@ -2213,15 +2179,14 @@ dependencies = [ [[package]] name = "hyper-rustls" -version = "0.23.2" +version = "0.24.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1788965e61b367cd03a62950836d5cd41560c3577d90e40e0819373194d1661c" +checksum = "ec3efd23720e2049821a693cbc7e65ea87c72f1c58ff2f9522ff332b1491e590" dependencies = [ + "futures-util", "http 0.2.9", "hyper 0.14.27", - "log", - "rustls 0.20.8", - "rustls-native-certs", + "rustls", "tokio", "tokio-rustls", ] @@ -2264,7 +2229,7 @@ dependencies = [ "http-body 1.0.0", "hyper 1.1.0", "pin-project-lite", - "socket2 0.5.5", + "socket2 0.5.6", "tokio", "tracing", ] @@ -2468,7 +2433,7 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b58db92f96b720de98181bbbe63c831e87005ab460c1bf306eb2622b4707997f" dependencies = [ - "socket2 0.5.5", + "socket2 0.5.6", "widestring", "windows-sys 0.48.0", "winreg", @@ -2515,7 +2480,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" dependencies = [ "hermit-abi", - "rustix 0.38.28", + "rustix 0.38.31", "windows-sys 0.48.0", ] @@ -2947,7 +2912,7 @@ dependencies = [ "libp2p-yamux", "rand 0.8.5", "smallvec", - "socket2 0.5.5", + "socket2 0.5.6", "tokio", "tracing", "tracing-subscriber", @@ -3163,8 +3128,8 @@ dependencies = [ "quinn", "rand 0.8.5", "ring 0.16.20", - "rustls 0.21.9", - "socket2 0.5.5", + "rustls", + "socket2 0.5.6", "thiserror", "tokio", "tracing", @@ -3281,7 +3246,7 @@ dependencies = [ [[package]] name = "libp2p-stream" -version = "0.1.0-alpha" +version = "0.1.0-alpha.1" dependencies = [ "futures", "libp2p-core", @@ -3336,7 +3301,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.51", ] [[package]] @@ -3368,7 +3333,7 @@ dependencies = [ "libc", "libp2p-core", "libp2p-identity", - "socket2 0.5.5", + "socket2 0.5.6", "tokio", "tracing", "tracing-subscriber", @@ -3388,7 +3353,7 @@ dependencies = [ "libp2p-yamux", "rcgen", "ring 0.16.20", - "rustls 0.21.9", + "rustls", "rustls-webpki", "thiserror", "tokio", @@ -4100,7 +4065,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.51", ] [[package]] @@ -4407,7 +4372,7 @@ checksum = "266c042b60c9c76b8d53061e52b2e0d1116abc57cefc8c5cd671619a56ac3690" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.51", ] [[package]] @@ -4508,7 +4473,7 @@ dependencies = [ "cfg-if", "concurrent-queue", "pin-project-lite", - "rustix 0.38.28", + "rustix 0.38.31", "tracing", "windows-sys 0.48.0", ] @@ -4604,7 +4569,7 @@ checksum = "440f724eba9f6996b75d63681b0a92b06947f1457076d503a4d2e2c8f56442b8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.51", ] [[package]] @@ -4692,7 +4657,7 @@ dependencies = [ "quinn-proto", "quinn-udp", "rustc-hash", - "rustls 0.21.9", + "rustls", "thiserror", "tokio", "tracing", @@ -4708,7 +4673,7 @@ dependencies = [ "rand 0.8.5", "ring 0.16.20", "rustc-hash", - "rustls 0.21.9", + "rustls", "slab", "thiserror", "tinyvec", @@ -4723,7 +4688,7 @@ checksum = "6df19e284d93757a9fb91d63672f7741b129246a669db09d1c0063071debc0c0" dependencies = [ "bytes", "libc", - "socket2 0.5.5", + "socket2 0.5.6", "tracing", "windows-sys 0.48.0", ] @@ -4880,15 +4845,6 @@ dependencies = [ "bitflags 1.3.2", ] -[[package]] -name = "redox_syscall" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" -dependencies = [ - "bitflags 1.3.2", -] - [[package]] name = "redox_users" version = "0.4.3" @@ -4985,6 +4941,7 @@ dependencies = [ "http 0.2.9", "http-body 0.4.5", "hyper 0.14.27", + "hyper-rustls", "hyper-tls", "ipnet", "js-sys", @@ -4994,6 +4951,7 @@ dependencies = [ "once_cell", "percent-encoding", "pin-project-lite", + "rustls", "rustls-pemfile", "serde", "serde_json", @@ -5002,11 +4960,13 @@ dependencies = [ "system-configuration", "tokio", "tokio-native-tls", + "tokio-rustls", "tower-service", "url", "wasm-bindgen", "wasm-bindgen-futures", "web-sys", + "webpki-roots", "winreg", ] @@ -5132,9 +5092,9 @@ dependencies = [ [[package]] name = "rust-embed" -version = "8.2.0" +version = "8.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a82c0bbc10308ed323529fd3c1dce8badda635aa319a5ff0e6466f33b8101e3f" +checksum = "fb78f46d0066053d16d4ca7b898e9343bc3530f71c61d5ad84cd404ada068745" dependencies = [ "rust-embed-impl", "rust-embed-utils", @@ -5143,23 +5103,23 @@ dependencies = [ [[package]] name = "rust-embed-impl" -version = "8.2.0" +version = "8.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6227c01b1783cdfee1bcf844eb44594cd16ec71c35305bf1c9fb5aade2735e16" +checksum = "b91ac2a3c6c0520a3fb3dd89321177c3c692937c4eb21893378219da10c44fc8" dependencies = [ "proc-macro2", "quote", "rust-embed-utils", "shellexpand", - "syn 2.0.48", + "syn 2.0.51", "walkdir", ] [[package]] name = "rust-embed-utils" -version = "8.2.0" +version = "8.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8cb0a25bfbb2d4b4402179c2cf030387d9990857ce08a32592c6238db9fa8665" +checksum = "86f69089032567ffff4eada41c573fc43ff466c7db7c5688b2e7969584345581" dependencies = [ "globset", "sha2 0.10.8", @@ -5212,9 +5172,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.28" +version = "0.38.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72e572a5e8ca657d7366229cdde4bd14c4eb5499a9573d4d366fe1b599daa316" +checksum = "6ea3e1a662af26cd7a3ba09c0297a31af215563ecf42817c98df621387f4e949" dependencies = [ "bitflags 2.4.1", "errno", @@ -5223,18 +5183,6 @@ dependencies = [ "windows-sys 0.52.0", ] -[[package]] -name = "rustls" -version = "0.20.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fff78fc74d175294f4e83b28343315ffcfb114b156f0185e9741cb5570f50e2f" -dependencies = [ - "log", - "ring 0.16.20", - "sct", - "webpki", -] - [[package]] name = "rustls" version = "0.21.9" @@ -5247,18 +5195,6 @@ dependencies = [ "sct", ] -[[package]] -name = "rustls-native-certs" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9aace74cb666635c918e9c12bc0d348266037aa8eb599b5cba565709a8dff00" -dependencies = [ - "openssl-probe", - "rustls-pemfile", - "schannel", - "security-framework", -] - [[package]] name = "rustls-pemfile" version = "1.0.3" @@ -5421,29 +5357,29 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.196" +version = "1.0.197" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "870026e60fa08c69f064aa766c10f10b1d62db9ccd4d0abb206472bee0ce3b32" +checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.196" +version = "1.0.197" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33c85360c95e7d137454dc81d9a4ed2b8efd8fbe19cee57357b32b9771fccb67" +checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.51", ] [[package]] name = "serde_json" -version = "1.0.113" +version = "1.0.114" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69801b70b1c3dac963ecb03a364ba0ceda9cf60c71cfe475e99864759c8b8a79" +checksum = "c5f09b1bd632ef549eaa9f60a1f8de742bdbc698e6cee2095fc84dde5f549ae0" dependencies = [ "indexmap 2.2.1", "itoa", @@ -5463,13 +5399,13 @@ dependencies = [ [[package]] name = "serde_repr" -version = "0.1.16" +version = "0.1.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8725e1dfadb3a50f7e5ce0b1a540466f6ed3fe7a0fca2ac2b8b831d31316bd00" +checksum = "0b2e6b945e9d3df726b65d6ee24060aff8e3533d431f677a9695db04eff9dfdb" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.51", ] [[package]] @@ -5659,12 +5595,12 @@ dependencies = [ [[package]] name = "socket2" -version = "0.5.5" +version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b5fac59a5cb5dd637972e5fca70daf0523c9067fcdc4842f053dae04a18f8e9" +checksum = "05ffd9c0a93b7543e062e759284fcf5f5e3b098501104bfbdde4d404db792871" dependencies = [ "libc", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] @@ -5739,18 +5675,40 @@ version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" +[[package]] +name = "strum" +version = "0.25.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "290d54ea6f91c969195bdbcd7442c8c2a2ba87da8bf60a7ee86a235d4bc1e125" +dependencies = [ + "strum_macros", +] + +[[package]] +name = "strum_macros" +version = "0.25.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23dc1fa9ac9c169a78ba62f0b841814b7abae11bdd047b9c58f893439e309ea0" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "rustversion", + "syn 2.0.51", +] + [[package]] name = "stun" -version = "0.5.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7beb1624a3ea34778d58d30e2b8606b4d29fe65e87c4d50b87ed30afd5c3830c" +checksum = "d3f371788132e9d623e6eab4ba28aac083763a4133f045e6ebaee5ceb869803d" dependencies = [ "base64 0.21.7", "crc", "lazy_static", "md-5", "rand 0.8.5", - "ring 0.16.20", + "ring 0.17.5", "subtle", "thiserror", "tokio", @@ -5786,9 +5744,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.48" +version = "2.0.51" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f" +checksum = "6ab617d94515e94ae53b8406c628598680aa0c9587474ecbe58188f7b345d66c" dependencies = [ "proc-macro2", "quote", @@ -5851,14 +5809,13 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.9.0" +version = "3.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01ce4141aa927a6d1bd34a041795abd0db1cccba5d5f24b009f694bdf3a1f3fa" +checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1" dependencies = [ "cfg-if", - "fastrand 2.0.0", - "redox_syscall 0.4.1", - "rustix 0.38.28", + "fastrand 2.0.1", + "rustix 0.38.31", "windows-sys 0.52.0", ] @@ -5873,27 +5830,27 @@ dependencies = [ [[package]] name = "thirtyfour" -version = "0.32.0-rc.8" +version = "0.32.0-rc.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf0fe180d5f1f7dd32bb5f1a8d19231bb63dc9bbb1985e1dbb6f07163b6a8578" +checksum = "bcc8d557d4ac49c0d0bf13722bf7414506ef50b28ac40894400dcd0b8ed25c4d" dependencies = [ "async-trait", "base64 0.21.7", - "cookie", - "fantoccini", "futures", - "http 0.2.9", - "indexmap 1.9.3", - "log", + "http 1.0.0", + "indexmap 2.2.1", "parking_lot", "paste", + "reqwest", "serde", "serde_json", "serde_repr", "stringmatch", + "strum", "thirtyfour-macros", "thiserror", "tokio", + "tracing", "url", ] @@ -5911,22 +5868,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.56" +version = "1.0.57" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d54378c645627613241d077a3a79db965db602882668f9136ac42af9ecb730ad" +checksum = "1e45bcbe8ed29775f228095caf2cd67af7a4ccf756ebff23a306bf3e8b47b24b" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.56" +version = "1.0.57" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa0faa943b50f3db30a20aa7e265dbc66076993efed8463e8de414e5d06d3471" +checksum = "a953cb265bef375dae3de6663da4d3804eee9682ea80d8e2542529b73c531c81" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.51", ] [[package]] @@ -6027,7 +5984,7 @@ dependencies = [ "parking_lot", "pin-project-lite", "signal-hook-registry", - "socket2 0.5.5", + "socket2 0.5.6", "tokio-macros", "windows-sys 0.48.0", ] @@ -6050,7 +6007,7 @@ checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.51", ] [[package]] @@ -6065,13 +6022,12 @@ dependencies = [ [[package]] name = "tokio-rustls" -version = "0.23.4" +version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c43ee83903113e03984cb9e5cebe6c04a5116269e900e3ddba8f068a62adda59" +checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081" dependencies = [ - "rustls 0.20.8", + "rustls", "tokio", - "webpki", ] [[package]] @@ -6205,7 +6161,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.51", ] [[package]] @@ -6391,12 +6347,6 @@ dependencies = [ "tinyvec", ] -[[package]] -name = "unicode-segmentation" -version = "1.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36" - [[package]] name = "unicode-xid" version = "0.2.4" @@ -6580,7 +6530,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.51", "wasm-bindgen-shared", ] @@ -6614,7 +6564,7 @@ checksum = "642f325be6301eb8107a83d12a8ac6c1e1c54345a7ef1a9261962dfefda09e66" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.51", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -6627,9 +6577,9 @@ checksum = "4f186bd2dcf04330886ce82d6f33dd75a7bfcf69ecf5763b89fcde53b6ac9838" [[package]] name = "wasm-bindgen-test" -version = "0.3.39" +version = "0.3.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2cf9242c0d27999b831eae4767b2a146feb0b27d332d553e605864acd2afd403" +checksum = "143ddeb4f833e2ed0d252e618986e18bfc7b0e52f2d28d77d05b2f045dd8eb61" dependencies = [ "console_error_panic_hook", "js-sys", @@ -6641,13 +6591,13 @@ dependencies = [ [[package]] name = "wasm-bindgen-test-macro" -version = "0.3.39" +version = "0.3.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "794645f5408c9a039fd09f4d113cdfb2e7eba5ff1956b07bcf701cf4b394fe89" +checksum = "a5211b7550606857312bba1d978a8ec75692eae187becc5e680444fffc5e6f89" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.51", ] [[package]] @@ -6663,9 +6613,9 @@ dependencies = [ [[package]] name = "web-sys" -version = "0.3.67" +version = "0.3.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58cd2333b6e0be7a39605f0e255892fd7418a682d8da8fe042fe25128794d2ed" +checksum = "96565907687f7aceb35bc5fc03770a8a0471d82e479f25832f54a0e3f4b28446" dependencies = [ "js-sys", "wasm-bindgen", @@ -6681,35 +6631,6 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "webdriver" -version = "0.46.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9973cb72c8587d5ad5efdb91e663d36177dc37725e6c90ca86c626b0cc45c93f" -dependencies = [ - "base64 0.13.1", - "bytes", - "cookie", - "http 0.2.9", - "log", - "serde", - "serde_derive", - "serde_json", - "time", - "unicode-segmentation", - "url", -] - -[[package]] -name = "webpki" -version = "0.22.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07ecc0cd7cac091bf682ec5efa18b1cff79d617b84181f38b3951dbe135f607f" -dependencies = [ - "ring 0.16.20", - "untrusted 0.7.1", -] - [[package]] name = "webpki-roots" version = "0.25.2" @@ -6737,7 +6658,7 @@ dependencies = [ "ring 0.16.20", "rtcp", "rtp", - "rustls 0.21.9", + "rustls", "sdp", "serde", "serde_json", @@ -6798,7 +6719,7 @@ dependencies = [ "rand_core 0.6.4", "rcgen", "ring 0.16.20", - "rustls 0.21.9", + "rustls", "sec1", "serde", "sha1", @@ -6842,7 +6763,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "62bebbd40e7f8b630a0f1a74783dbfff1edfc0ccaae891c4689891156a8c4d8c" dependencies = [ "log", - "socket2 0.5.5", + "socket2 0.5.6", "thiserror", "tokio", "webrtc-util", @@ -6903,14 +6824,13 @@ dependencies = [ [[package]] name = "webrtc-util" -version = "0.8.0" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1adc96bee68417e1f4d19dd7698124a7f859db55ae2fd3eedbbb7e732f614735" +checksum = "5e85154ef743d9a2a116d104faaaa82740a281b8b4bed5ee691a2df6c133d873" dependencies = [ "async-trait", "bitflags 1.3.2", "bytes", - "cc", "ipnet", "lazy_static", "libc", @@ -7140,9 +7060,9 @@ dependencies = [ [[package]] name = "x25519-dalek" -version = "2.0.0" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb66477291e7e8d2b0ff1bcb900bf29489a9692816d79874bea351e7a8b6de96" +checksum = "c7e468321c81fb07fa7f4c636c3972b9100f0346e5b6a9f2bd0603a52f7ed277" dependencies = [ "curve25519-dalek", "rand_core 0.6.4", @@ -7240,7 +7160,7 @@ checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.51", ] [[package]] @@ -7260,5 +7180,5 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.51", ] diff --git a/Cargo.toml b/Cargo.toml index 44a7acb2000..277214def1e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,7 +22,6 @@ members = [ "interop-tests", "misc/allow-block-list", "misc/connection-limits", - "misc/futures-bounded", "misc/keygen", "misc/memory-connection-limits", "misc/metrics", @@ -74,7 +73,7 @@ rust-version = "1.73.0" [workspace.dependencies] asynchronous-codec = { version = "0.7.0" } -futures-bounded = { version = "0.2.3", path = "misc/futures-bounded" } +futures-bounded = { version = "0.2.3" } libp2p = { version = "0.53.2", path = "libp2p" } libp2p-allow-block-list = { version = "0.3.0", path = "misc/allow-block-list" } libp2p-autonat = { version = "0.13.0", path = "protocols/autonat" } @@ -100,7 +99,7 @@ libp2p-relay = { version = "0.17.1", path = "protocols/relay" } libp2p-rendezvous = { version = "0.14.0", path = "protocols/rendezvous" } libp2p-request-response = { version = "0.26.2", path = "protocols/request-response" } libp2p-server = { version = "0.12.6", path = "misc/server" } -libp2p-stream = { version = "0.1.0-alpha", path = "protocols/stream" } +libp2p-stream = { version = "0.1.0-alpha.1", path = "protocols/stream" } libp2p-swarm = { version = "0.44.2", path = "swarm" } libp2p-swarm-derive = { version = "=0.34.3", path = "swarm-derive" } # `libp2p-swarm-derive` may not be compatible with different `libp2p-swarm` non-breaking releases. E.g. `libp2p-swarm` might introduce a new enum variant `FromSwarm` (which is `#[non-exhaustive]`) in a non-breaking release. Older versions of `libp2p-swarm-derive` would not forward this enum variant within the `NetworkBehaviour` hierarchy. Thus the version pinning is required. libp2p-swarm-test = { version = "0.3.0", path = "swarm-test" } diff --git a/core/src/connection.rs b/core/src/connection.rs index f03e881884d..bb6639842c9 100644 --- a/core/src/connection.rs +++ b/core/src/connection.rs @@ -63,7 +63,7 @@ pub enum ConnectedPoint { /// Multiaddress that was successfully dialed. address: Multiaddr, /// Whether the role of the local node on the connection should be - /// overriden. I.e. whether the local node should act as a listener on + /// overridden. I.e. whether the local node should act as a listener on /// the outgoing connection. /// /// This option is needed for NAT and firewall hole punching. diff --git a/core/src/transport/upgrade.rs b/core/src/transport/upgrade.rs index 215c85e8709..2a90172e710 100644 --- a/core/src/transport/upgrade.rs +++ b/core/src/transport/upgrade.rs @@ -508,7 +508,7 @@ where fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { // We use a `this` variable because the compiler can't mutably borrow multiple times - // accross a `Deref`. + // across a `Deref`. let this = &mut *self; loop { @@ -567,7 +567,7 @@ where fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { // We use a `this` variable because the compiler can't mutably borrow multiple times - // accross a `Deref`. + // across a `Deref`. let this = &mut *self; loop { diff --git a/examples/browser-webrtc/Cargo.toml b/examples/browser-webrtc/Cargo.toml index 79068cdca87..a01ebe71e5f 100644 --- a/examples/browser-webrtc/Cargo.toml +++ b/examples/browser-webrtc/Cargo.toml @@ -16,7 +16,7 @@ release = false crate-type = ["cdylib"] [dependencies] -anyhow = "1.0.79" +anyhow = "1.0.80" futures = "0.3.30" rand = "0.8" tracing = "0.1.37" @@ -26,7 +26,7 @@ tracing-subscriber = { version = "0.3", features = ["env-filter"] } axum = "0.7.4" libp2p = { path = "../../libp2p", features = [ "ed25519", "macros", "ping", "tokio"] } libp2p-webrtc = { workspace = true, features = ["tokio"] } -rust-embed = { version = "8.2.0", features = ["include-exclude", "interpolate-folder-path"] } +rust-embed = { version = "8.3.0", features = ["include-exclude", "interpolate-folder-path"] } tokio = { version = "1.36", features = ["macros", "net", "rt", "signal"] } tokio-util = { version = "0.7", features = ["compat"] } tower = "0.4" diff --git a/examples/file-sharing/Cargo.toml b/examples/file-sharing/Cargo.toml index e38039a11bb..8d20a702718 100644 --- a/examples/file-sharing/Cargo.toml +++ b/examples/file-sharing/Cargo.toml @@ -10,11 +10,10 @@ release = false [dependencies] serde = { version = "1.0", features = ["derive"] } -async-std = { version = "1.12", features = ["attributes"] } +tokio = { version = "1.36.0", features = ["full"] } clap = { version = "4.4.16", features = ["derive"] } -either = "1.9" futures = "0.3.30" -libp2p = { path = "../../libp2p", features = [ "async-std", "cbor", "dns", "kad", "noise", "macros", "request-response", "tcp", "websocket", "yamux"] } +libp2p = { path = "../../libp2p", features = [ "tokio", "cbor", "dns", "kad", "noise", "macros", "request-response", "tcp", "websocket", "yamux"] } tracing = "0.1.37" tracing-subscriber = { version = "0.3", features = ["env-filter"] } void = "1.0.2" diff --git a/examples/file-sharing/src/main.rs b/examples/file-sharing/src/main.rs index a834ee0600e..5f6be83dc11 100644 --- a/examples/file-sharing/src/main.rs +++ b/examples/file-sharing/src/main.rs @@ -22,8 +22,8 @@ mod network; -use async_std::task::spawn; use clap::Parser; +use tokio::task::spawn; use futures::prelude::*; use futures::StreamExt; @@ -33,7 +33,7 @@ use std::io::Write; use std::path::PathBuf; use tracing_subscriber::EnvFilter; -#[async_std::main] +#[tokio::main] async fn main() -> Result<(), Box> { let _ = tracing_subscriber::fmt() .with_env_filter(EnvFilter::from_default_env()) diff --git a/examples/file-sharing/src/network.rs b/examples/file-sharing/src/network.rs index 59625fc39ea..a74afd1c0da 100644 --- a/examples/file-sharing/src/network.rs +++ b/examples/file-sharing/src/network.rs @@ -1,5 +1,6 @@ use futures::channel::{mpsc, oneshot}; use futures::prelude::*; +use futures::StreamExt; use libp2p::{ core::Multiaddr, @@ -40,7 +41,7 @@ pub(crate) async fn new( let peer_id = id_keys.public().to_peer_id(); let mut swarm = libp2p::SwarmBuilder::with_existing_identity(id_keys) - .with_async_std() + .with_tokio() .with_tcp( tcp::Config::default(), noise::Config::new, @@ -197,8 +198,8 @@ impl EventLoop { pub(crate) async fn run(mut self) { loop { - futures::select! { - event = self.swarm.next() => self.handle_event(event.expect("Swarm stream to be infinite.")).await , + tokio::select! { + event = self.swarm.select_next_some() => self.handle_event(event).await, command = self.command_receiver.next() => match command { Some(c) => self.handle_command(c).await, // Command channel closed, thus shutting down the network event loop. diff --git a/examples/ipfs-kad/Cargo.toml b/examples/ipfs-kad/Cargo.toml index e82031ce64f..5581728794e 100644 --- a/examples/ipfs-kad/Cargo.toml +++ b/examples/ipfs-kad/Cargo.toml @@ -14,7 +14,7 @@ async-trait = "0.1" clap = { version = "4.4.16", features = ["derive"] } env_logger = "0.10" futures = "0.3.30" -anyhow = "1.0.79" +anyhow = "1.0.80" libp2p = { path = "../../libp2p", features = [ "tokio", "dns", "kad", "noise", "tcp", "yamux", "rsa"] } tracing = "0.1.37" tracing-subscriber = { version = "0.3", features = ["env-filter"] } diff --git a/hole-punching-tests/Cargo.toml b/hole-punching-tests/Cargo.toml index 9e6fb15965d..c8e6cde98e0 100644 --- a/hole-punching-tests/Cargo.toml +++ b/hole-punching-tests/Cargo.toml @@ -13,6 +13,6 @@ libp2p = { path = "../libp2p", features = ["tokio", "dcutr", "identify", "macros tracing = "0.1.37" redis = { version = "0.23.0", default-features = false, features = ["tokio-comp"] } tokio = { version = "1.36.0", features = ["full"] } -serde = { version = "1.0.196", features = ["derive"] } -serde_json = "1.0.113" +serde = { version = "1.0.197", features = ["derive"] } +serde_json = "1.0.114" either = "1.9.0" diff --git a/interop-tests/Cargo.toml b/interop-tests/Cargo.toml index 81c17e19303..410d3dbce2b 100644 --- a/interop-tests/Cargo.toml +++ b/interop-tests/Cargo.toml @@ -31,9 +31,9 @@ mime_guess = "2.0" redis = { version = "0.23.3", default-features = false, features = [ "tokio-comp", ] } -rust-embed = "8.2" +rust-embed = "8.3" serde_json = "1" -thirtyfour = "=0.32.0-rc.8" # https://github.com/stevepryde/thirtyfour/issues/169 +thirtyfour = "=0.32.0-rc.10" # https://github.com/stevepryde/thirtyfour/issues/169 tokio = { version = "1.36.0", features = ["full"] } tower-http = { version = "0.5", features = ["cors", "fs", "trace"] } tracing = "0.1.37" @@ -49,7 +49,7 @@ wasm-logger = { version = "0.2.0" } instant = "0.1.12" reqwest = { version = "0.11", features = ["json"] } console_error_panic_hook = { version = "0.1.7" } -futures-timer = "3.0.2" +futures-timer = "3.0.3" [lints] workspace = true diff --git a/libp2p/src/tutorials/ping.rs b/libp2p/src/tutorials/ping.rs index 1413531cd72..309d5b36baa 100644 --- a/libp2p/src/tutorials/ping.rs +++ b/libp2p/src/tutorials/ping.rs @@ -216,7 +216,7 @@ //! libp2p::yamux::Config::default, //! )? //! .with_behaviour(|_| ping::Behaviour::default())? -//! .with_swarm_config(|cfg| cfg.with_idle_connection_timeout(Duration::from_secs(30))) // Allows us to observe pings for 30 seconds. +//! .with_swarm_config(|cfg| cfg.with_idle_connection_timeout(Duration::from_secs(u64::MAX))) // Allows us to observe pings indefinitely. //! .build(); //! //! Ok(()) @@ -267,7 +267,7 @@ //! libp2p::yamux::Config::default, //! )? //! .with_behaviour(|_| ping::Behaviour::default())? -//! .with_swarm_config(|cfg| cfg.with_idle_connection_timeout(Duration::from_secs(30))) // Allows us to observe pings for 30 seconds. +//! .with_swarm_config(|cfg| cfg.with_idle_connection_timeout(Duration::from_secs(u64::MAX))) // Allows us to observe pings indefinitely.. //! .build(); //! //! // Tell the swarm to listen on all interfaces and a random, OS-assigned @@ -312,7 +312,7 @@ //! libp2p::yamux::Config::default, //! )? //! .with_behaviour(|_| ping::Behaviour::default())? -//! .with_swarm_config(|cfg| cfg.with_idle_connection_timeout(Duration::from_secs(30))) // Allows us to observe pings for 30 seconds. +//! .with_swarm_config(|cfg| cfg.with_idle_connection_timeout(Duration::from_secs(u64::MAX))) // Allows us to observe pings indefinitely. //! .build(); //! //! // Tell the swarm to listen on all interfaces and a random, OS-assigned diff --git a/misc/futures-bounded/CHANGELOG.md b/misc/futures-bounded/CHANGELOG.md deleted file mode 100644 index 72b0b4f457d..00000000000 --- a/misc/futures-bounded/CHANGELOG.md +++ /dev/null @@ -1,23 +0,0 @@ -## 0.2.3 - -- Introduce `FuturesTupleSet`, holding tuples of a `Future` together with an arbitrary piece of data. - See [PR 4841](https://github.com/libp2p/rust-libp2p/pull/4841). - -## 0.2.2 - -- Fix an issue where `{Futures,Stream}Map` returns `Poll::Pending` despite being ready after an item has been replaced as part of `try_push`. - See [PR 4865](https://github.com/libp2p/rust-libp2p/pull/4865). - -## 0.2.1 - -- Add `.len()` getter to `FuturesMap`, `FuturesSet`, `StreamMap` and `StreamSet`. - See [PR 4745](https://github.com/libp2p/rust-libp2p/pull/4745). - -## 0.2.0 - -- Add `StreamMap` type and remove `Future`-suffix from `PushError::ReplacedFuture` to reuse it for `StreamMap`. - See [PR 4616](https://github.com/libp2p/rust-libp2p/pull/4616). - -## 0.1.0 - -Initial release. diff --git a/misc/futures-bounded/Cargo.toml b/misc/futures-bounded/Cargo.toml deleted file mode 100644 index 89288b6f70c..00000000000 --- a/misc/futures-bounded/Cargo.toml +++ /dev/null @@ -1,24 +0,0 @@ -[package] -name = "futures-bounded" -version = "0.2.3" -edition = "2021" -rust-version.workspace = true -license = "MIT" -repository = "https://github.com/libp2p/rust-libp2p" -keywords = ["futures", "async", "backpressure"] -categories = ["data-structures", "asynchronous"] -description = "Utilities for bounding futures in size and time." -publish = true - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -futures-util = { version = "0.3.30" } -futures-timer = "3.0.2" - -[dev-dependencies] -tokio = { version = "1.36.0", features = ["macros", "rt", "sync"] } -futures = "0.3.30" - -[lints] -workspace = true diff --git a/misc/futures-bounded/src/futures_map.rs b/misc/futures-bounded/src/futures_map.rs deleted file mode 100644 index fba3543f67b..00000000000 --- a/misc/futures-bounded/src/futures_map.rs +++ /dev/null @@ -1,319 +0,0 @@ -use std::future::Future; -use std::hash::Hash; -use std::pin::Pin; -use std::task::{Context, Poll, Waker}; -use std::time::Duration; -use std::{future, mem}; - -use futures_timer::Delay; -use futures_util::future::BoxFuture; -use futures_util::stream::FuturesUnordered; -use futures_util::{FutureExt, StreamExt}; - -use crate::{PushError, Timeout}; - -/// Represents a map of [`Future`]s. -/// -/// Each future must finish within the specified time and the map never outgrows its capacity. -pub struct FuturesMap { - timeout: Duration, - capacity: usize, - inner: FuturesUnordered>>>, - empty_waker: Option, - full_waker: Option, -} - -impl FuturesMap { - pub fn new(timeout: Duration, capacity: usize) -> Self { - Self { - timeout, - capacity, - inner: Default::default(), - empty_waker: None, - full_waker: None, - } - } -} - -impl FuturesMap -where - ID: Clone + Hash + Eq + Send + Unpin + 'static, - O: 'static, -{ - /// Push a future into the map. - /// - /// This method inserts the given future with defined `future_id` to the set. - /// If the length of the map is equal to the capacity, this method returns [PushError::BeyondCapacity], - /// that contains the passed future. In that case, the future is not inserted to the map. - /// If a future with the given `future_id` already exists, then the old future will be replaced by a new one. - /// In that case, the returned error [PushError::Replaced] contains the old future. - pub fn try_push(&mut self, future_id: ID, future: F) -> Result<(), PushError>> - where - F: Future + Send + 'static, - { - if self.inner.len() >= self.capacity { - return Err(PushError::BeyondCapacity(future.boxed())); - } - - if let Some(waker) = self.empty_waker.take() { - waker.wake(); - } - - let old = self.remove(future_id.clone()); - self.inner.push(TaggedFuture { - tag: future_id, - inner: TimeoutFuture { - inner: future.boxed(), - timeout: Delay::new(self.timeout), - cancelled: false, - }, - }); - match old { - None => Ok(()), - Some(old) => Err(PushError::Replaced(old)), - } - } - - pub fn remove(&mut self, id: ID) -> Option> { - let tagged = self.inner.iter_mut().find(|s| s.tag == id)?; - - let inner = mem::replace(&mut tagged.inner.inner, future::pending().boxed()); - tagged.inner.cancelled = true; - - Some(inner) - } - - pub fn len(&self) -> usize { - self.inner.len() - } - - pub fn is_empty(&self) -> bool { - self.inner.is_empty() - } - - #[allow(unknown_lints, clippy::needless_pass_by_ref_mut)] // &mut Context is idiomatic. - pub fn poll_ready_unpin(&mut self, cx: &mut Context<'_>) -> Poll<()> { - if self.inner.len() < self.capacity { - return Poll::Ready(()); - } - - self.full_waker = Some(cx.waker().clone()); - - Poll::Pending - } - - pub fn poll_unpin(&mut self, cx: &mut Context<'_>) -> Poll<(ID, Result)> { - loop { - let maybe_result = futures_util::ready!(self.inner.poll_next_unpin(cx)); - - match maybe_result { - None => { - self.empty_waker = Some(cx.waker().clone()); - return Poll::Pending; - } - Some((id, Ok(output))) => return Poll::Ready((id, Ok(output))), - Some((id, Err(TimeoutError::Timeout))) => { - return Poll::Ready((id, Err(Timeout::new(self.timeout)))) - } - Some((_, Err(TimeoutError::Cancelled))) => continue, - } - } - } -} - -struct TimeoutFuture { - inner: F, - timeout: Delay, - - cancelled: bool, -} - -impl Future for TimeoutFuture -where - F: Future + Unpin, -{ - type Output = Result; - - fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { - if self.cancelled { - return Poll::Ready(Err(TimeoutError::Cancelled)); - } - - if self.timeout.poll_unpin(cx).is_ready() { - return Poll::Ready(Err(TimeoutError::Timeout)); - } - - self.inner.poll_unpin(cx).map(Ok) - } -} - -enum TimeoutError { - Timeout, - Cancelled, -} - -struct TaggedFuture { - tag: T, - inner: F, -} - -impl Future for TaggedFuture -where - T: Clone + Unpin, - F: Future + Unpin, -{ - type Output = (T, F::Output); - - fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { - let output = futures_util::ready!(self.inner.poll_unpin(cx)); - - Poll::Ready((self.tag.clone(), output)) - } -} - -#[cfg(test)] -mod tests { - use futures::channel::oneshot; - use futures_util::task::noop_waker_ref; - use std::future::{pending, poll_fn, ready}; - use std::pin::Pin; - use std::time::Instant; - - use super::*; - - #[test] - fn cannot_push_more_than_capacity_tasks() { - let mut futures = FuturesMap::new(Duration::from_secs(10), 1); - - assert!(futures.try_push("ID_1", ready(())).is_ok()); - matches!( - futures.try_push("ID_2", ready(())), - Err(PushError::BeyondCapacity(_)) - ); - } - - #[test] - fn cannot_push_the_same_id_few_times() { - let mut futures = FuturesMap::new(Duration::from_secs(10), 5); - - assert!(futures.try_push("ID", ready(())).is_ok()); - matches!( - futures.try_push("ID", ready(())), - Err(PushError::Replaced(_)) - ); - } - - #[tokio::test] - async fn futures_timeout() { - let mut futures = FuturesMap::new(Duration::from_millis(100), 1); - - let _ = futures.try_push("ID", pending::<()>()); - Delay::new(Duration::from_millis(150)).await; - let (_, result) = poll_fn(|cx| futures.poll_unpin(cx)).await; - - assert!(result.is_err()) - } - - #[test] - fn resources_of_removed_future_are_cleaned_up() { - let mut futures = FuturesMap::new(Duration::from_millis(100), 1); - - let _ = futures.try_push("ID", pending::<()>()); - futures.remove("ID"); - - let poll = futures.poll_unpin(&mut Context::from_waker(noop_waker_ref())); - assert!(poll.is_pending()); - - assert_eq!(futures.len(), 0); - } - - #[tokio::test] - async fn replaced_pending_future_is_polled() { - let mut streams = FuturesMap::new(Duration::from_millis(100), 3); - - let (_tx1, rx1) = oneshot::channel(); - let (tx2, rx2) = oneshot::channel(); - - let _ = streams.try_push("ID1", rx1); - let _ = streams.try_push("ID2", rx2); - - let _ = tx2.send(2); - let (id, res) = poll_fn(|cx| streams.poll_unpin(cx)).await; - assert_eq!(id, "ID2"); - assert_eq!(res.unwrap().unwrap(), 2); - - let (new_tx1, new_rx1) = oneshot::channel(); - let replaced = streams.try_push("ID1", new_rx1); - assert!(matches!(replaced.unwrap_err(), PushError::Replaced(_))); - - let _ = new_tx1.send(4); - let (id, res) = poll_fn(|cx| streams.poll_unpin(cx)).await; - - assert_eq!(id, "ID1"); - assert_eq!(res.unwrap().unwrap(), 4); - } - - // Each future causes a delay, `Task` only has a capacity of 1, meaning they must be processed in sequence. - // We stop after NUM_FUTURES tasks, meaning the overall execution must at least take DELAY * NUM_FUTURES. - #[tokio::test] - async fn backpressure() { - const DELAY: Duration = Duration::from_millis(100); - const NUM_FUTURES: u32 = 10; - - let start = Instant::now(); - Task::new(DELAY, NUM_FUTURES, 1).await; - let duration = start.elapsed(); - - assert!(duration >= DELAY * NUM_FUTURES); - } - - struct Task { - future: Duration, - num_futures: usize, - num_processed: usize, - inner: FuturesMap, - } - - impl Task { - fn new(future: Duration, num_futures: u32, capacity: usize) -> Self { - Self { - future, - num_futures: num_futures as usize, - num_processed: 0, - inner: FuturesMap::new(Duration::from_secs(60), capacity), - } - } - } - - impl Future for Task { - type Output = (); - - fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { - let this = self.get_mut(); - - while this.num_processed < this.num_futures { - if let Poll::Ready((_, result)) = this.inner.poll_unpin(cx) { - if result.is_err() { - panic!("Timeout is great than future delay") - } - - this.num_processed += 1; - continue; - } - - if let Poll::Ready(()) = this.inner.poll_ready_unpin(cx) { - // We push the constant future's ID to prove that user can use the same ID - // if the future was finished - let maybe_future = this.inner.try_push(1u8, Delay::new(this.future)); - assert!(maybe_future.is_ok(), "we polled for readiness"); - - continue; - } - - return Poll::Pending; - } - - Poll::Ready(()) - } - } -} diff --git a/misc/futures-bounded/src/futures_set.rs b/misc/futures-bounded/src/futures_set.rs deleted file mode 100644 index af7cedfcc85..00000000000 --- a/misc/futures-bounded/src/futures_set.rs +++ /dev/null @@ -1,65 +0,0 @@ -use std::future::Future; -use std::task::{ready, Context, Poll}; -use std::time::Duration; - -use futures_util::future::BoxFuture; - -use crate::{FuturesMap, PushError, Timeout}; - -/// Represents a list of [Future]s. -/// -/// Each future must finish within the specified time and the list never outgrows its capacity. -pub struct FuturesSet { - id: u32, - inner: FuturesMap, -} - -impl FuturesSet { - pub fn new(timeout: Duration, capacity: usize) -> Self { - Self { - id: 0, - inner: FuturesMap::new(timeout, capacity), - } - } -} - -impl FuturesSet -where - O: 'static, -{ - /// Push a future into the list. - /// - /// This method adds the given future to the list. - /// If the length of the list is equal to the capacity, this method returns a error that contains the passed future. - /// In that case, the future is not added to the set. - pub fn try_push(&mut self, future: F) -> Result<(), BoxFuture> - where - F: Future + Send + 'static, - { - self.id = self.id.wrapping_add(1); - - match self.inner.try_push(self.id, future) { - Ok(()) => Ok(()), - Err(PushError::BeyondCapacity(w)) => Err(w), - Err(PushError::Replaced(_)) => unreachable!("we never reuse IDs"), - } - } - - pub fn len(&self) -> usize { - self.inner.len() - } - - pub fn is_empty(&self) -> bool { - self.inner.is_empty() - } - - pub fn poll_ready_unpin(&mut self, cx: &mut Context<'_>) -> Poll<()> { - self.inner.poll_ready_unpin(cx) - } - - pub fn poll_unpin(&mut self, cx: &mut Context<'_>) -> Poll> { - let (_, res) = ready!(self.inner.poll_unpin(cx)); - - Poll::Ready(res) - } -} diff --git a/misc/futures-bounded/src/futures_tuple_set.rs b/misc/futures-bounded/src/futures_tuple_set.rs deleted file mode 100644 index e19b236aaf8..00000000000 --- a/misc/futures-bounded/src/futures_tuple_set.rs +++ /dev/null @@ -1,94 +0,0 @@ -use std::collections::HashMap; -use std::future::Future; -use std::task::{ready, Context, Poll}; -use std::time::Duration; - -use futures_util::future::BoxFuture; - -use crate::{FuturesMap, PushError, Timeout}; - -/// Represents a list of tuples of a [Future] and an associated piece of data. -/// -/// Each future must finish within the specified time and the list never outgrows its capacity. -pub struct FuturesTupleSet { - id: u32, - inner: FuturesMap, - data: HashMap, -} - -impl FuturesTupleSet { - pub fn new(timeout: Duration, capacity: usize) -> Self { - Self { - id: 0, - inner: FuturesMap::new(timeout, capacity), - data: HashMap::new(), - } - } -} - -impl FuturesTupleSet -where - O: 'static, -{ - /// Push a future into the list. - /// - /// This method adds the given future to the list. - /// If the length of the list is equal to the capacity, this method returns a error that contains the passed future. - /// In that case, the future is not added to the set. - pub fn try_push(&mut self, future: F, data: D) -> Result<(), (BoxFuture, D)> - where - F: Future + Send + 'static, - { - self.id = self.id.wrapping_add(1); - - match self.inner.try_push(self.id, future) { - Ok(()) => {} - Err(PushError::BeyondCapacity(w)) => return Err((w, data)), - Err(PushError::Replaced(_)) => unreachable!("we never reuse IDs"), - } - self.data.insert(self.id, data); - - Ok(()) - } - - pub fn len(&self) -> usize { - self.inner.len() - } - - pub fn is_empty(&self) -> bool { - self.inner.is_empty() - } - - pub fn poll_ready_unpin(&mut self, cx: &mut Context<'_>) -> Poll<()> { - self.inner.poll_ready_unpin(cx) - } - - pub fn poll_unpin(&mut self, cx: &mut Context<'_>) -> Poll<(Result, D)> { - let (id, res) = ready!(self.inner.poll_unpin(cx)); - let data = self.data.remove(&id).expect("must have data for future"); - - Poll::Ready((res, data)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use futures_util::future::poll_fn; - use futures_util::FutureExt; - use std::future::ready; - - #[test] - fn tracks_associated_data_of_future() { - let mut set = FuturesTupleSet::new(Duration::from_secs(10), 10); - - let _ = set.try_push(ready(1), 1); - let _ = set.try_push(ready(2), 2); - - let (res1, data1) = poll_fn(|cx| set.poll_unpin(cx)).now_or_never().unwrap(); - let (res2, data2) = poll_fn(|cx| set.poll_unpin(cx)).now_or_never().unwrap(); - - assert_eq!(res1.unwrap(), data1); - assert_eq!(res2.unwrap(), data2); - } -} diff --git a/misc/futures-bounded/src/lib.rs b/misc/futures-bounded/src/lib.rs deleted file mode 100644 index da8483a595f..00000000000 --- a/misc/futures-bounded/src/lib.rs +++ /dev/null @@ -1,46 +0,0 @@ -mod futures_map; -mod futures_set; -mod futures_tuple_set; -mod stream_map; -mod stream_set; - -pub use futures_map::FuturesMap; -pub use futures_set::FuturesSet; -pub use futures_tuple_set::FuturesTupleSet; -pub use stream_map::StreamMap; -pub use stream_set::StreamSet; - -use std::fmt; -use std::fmt::Formatter; -use std::time::Duration; - -/// A future failed to complete within the given timeout. -#[derive(Debug)] -pub struct Timeout { - limit: Duration, -} - -impl Timeout { - fn new(duration: Duration) -> Self { - Self { limit: duration } - } -} - -impl fmt::Display for Timeout { - fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { - write!(f, "future failed to complete within {:?}", self.limit) - } -} - -/// Error of a future pushing -#[derive(PartialEq, Debug)] -pub enum PushError { - /// The length of the set is equal to the capacity - BeyondCapacity(T), - /// The map already contained an item with this key. - /// - /// The old item is returned. - Replaced(T), -} - -impl std::error::Error for Timeout {} diff --git a/misc/futures-bounded/src/stream_map.rs b/misc/futures-bounded/src/stream_map.rs deleted file mode 100644 index 8464f432d02..00000000000 --- a/misc/futures-bounded/src/stream_map.rs +++ /dev/null @@ -1,362 +0,0 @@ -use std::mem; -use std::pin::Pin; -use std::task::{Context, Poll, Waker}; -use std::time::Duration; - -use futures_timer::Delay; -use futures_util::stream::{BoxStream, SelectAll}; -use futures_util::{stream, FutureExt, Stream, StreamExt}; - -use crate::{PushError, Timeout}; - -/// Represents a map of [`Stream`]s. -/// -/// Each stream must finish within the specified time and the map never outgrows its capacity. -pub struct StreamMap { - timeout: Duration, - capacity: usize, - inner: SelectAll>>>, - empty_waker: Option, - full_waker: Option, -} - -impl StreamMap -where - ID: Clone + Unpin, -{ - pub fn new(timeout: Duration, capacity: usize) -> Self { - Self { - timeout, - capacity, - inner: Default::default(), - empty_waker: None, - full_waker: None, - } - } -} - -impl StreamMap -where - ID: Clone + PartialEq + Send + Unpin + 'static, - O: Send + 'static, -{ - /// Push a stream into the map. - pub fn try_push(&mut self, id: ID, stream: F) -> Result<(), PushError>> - where - F: Stream + Send + 'static, - { - if self.inner.len() >= self.capacity { - return Err(PushError::BeyondCapacity(stream.boxed())); - } - - if let Some(waker) = self.empty_waker.take() { - waker.wake(); - } - - let old = self.remove(id.clone()); - self.inner.push(TaggedStream::new( - id, - TimeoutStream { - inner: stream.boxed(), - timeout: Delay::new(self.timeout), - }, - )); - - match old { - None => Ok(()), - Some(old) => Err(PushError::Replaced(old)), - } - } - - pub fn remove(&mut self, id: ID) -> Option> { - let tagged = self.inner.iter_mut().find(|s| s.key == id)?; - - let inner = mem::replace(&mut tagged.inner.inner, stream::pending().boxed()); - tagged.exhausted = true; // Setting this will emit `None` on the next poll and ensure `SelectAll` cleans up the resources. - - Some(inner) - } - - pub fn len(&self) -> usize { - self.inner.len() - } - - pub fn is_empty(&self) -> bool { - self.inner.is_empty() - } - - #[allow(unknown_lints, clippy::needless_pass_by_ref_mut)] // &mut Context is idiomatic. - pub fn poll_ready_unpin(&mut self, cx: &mut Context<'_>) -> Poll<()> { - if self.inner.len() < self.capacity { - return Poll::Ready(()); - } - - self.full_waker = Some(cx.waker().clone()); - - Poll::Pending - } - - pub fn poll_next_unpin( - &mut self, - cx: &mut Context<'_>, - ) -> Poll<(ID, Option>)> { - match futures_util::ready!(self.inner.poll_next_unpin(cx)) { - None => { - self.empty_waker = Some(cx.waker().clone()); - Poll::Pending - } - Some((id, Some(Ok(output)))) => Poll::Ready((id, Some(Ok(output)))), - Some((id, Some(Err(())))) => { - self.remove(id.clone()); // Remove stream, otherwise we keep reporting the timeout. - - Poll::Ready((id, Some(Err(Timeout::new(self.timeout))))) - } - Some((id, None)) => Poll::Ready((id, None)), - } - } -} - -struct TimeoutStream { - inner: S, - timeout: Delay, -} - -impl Stream for TimeoutStream -where - F: Stream + Unpin, -{ - type Item = Result; - - fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> { - if self.timeout.poll_unpin(cx).is_ready() { - return Poll::Ready(Some(Err(()))); - } - - self.inner.poll_next_unpin(cx).map(|a| a.map(Ok)) - } -} - -struct TaggedStream { - key: K, - inner: S, - - exhausted: bool, -} - -impl TaggedStream { - fn new(key: K, inner: S) -> Self { - Self { - key, - inner, - exhausted: false, - } - } -} - -impl Stream for TaggedStream -where - K: Clone + Unpin, - S: Stream + Unpin, -{ - type Item = (K, Option); - - fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> { - if self.exhausted { - return Poll::Ready(None); - } - - match futures_util::ready!(self.inner.poll_next_unpin(cx)) { - Some(item) => Poll::Ready(Some((self.key.clone(), Some(item)))), - None => { - self.exhausted = true; - - Poll::Ready(Some((self.key.clone(), None))) - } - } - } -} - -#[cfg(test)] -mod tests { - use futures::channel::mpsc; - use futures_util::stream::{once, pending}; - use futures_util::SinkExt; - use std::future::{poll_fn, ready, Future}; - use std::pin::Pin; - use std::time::Instant; - - use super::*; - - #[test] - fn cannot_push_more_than_capacity_tasks() { - let mut streams = StreamMap::new(Duration::from_secs(10), 1); - - assert!(streams.try_push("ID_1", once(ready(()))).is_ok()); - matches!( - streams.try_push("ID_2", once(ready(()))), - Err(PushError::BeyondCapacity(_)) - ); - } - - #[test] - fn cannot_push_the_same_id_few_times() { - let mut streams = StreamMap::new(Duration::from_secs(10), 5); - - assert!(streams.try_push("ID", once(ready(()))).is_ok()); - matches!( - streams.try_push("ID", once(ready(()))), - Err(PushError::Replaced(_)) - ); - } - - #[tokio::test] - async fn streams_timeout() { - let mut streams = StreamMap::new(Duration::from_millis(100), 1); - - let _ = streams.try_push("ID", pending::<()>()); - Delay::new(Duration::from_millis(150)).await; - let (_, result) = poll_fn(|cx| streams.poll_next_unpin(cx)).await; - - assert!(result.unwrap().is_err()) - } - - #[tokio::test] - async fn timed_out_stream_gets_removed() { - let mut streams = StreamMap::new(Duration::from_millis(100), 1); - - let _ = streams.try_push("ID", pending::<()>()); - Delay::new(Duration::from_millis(150)).await; - poll_fn(|cx| streams.poll_next_unpin(cx)).await; - - let poll = streams.poll_next_unpin(&mut Context::from_waker( - futures_util::task::noop_waker_ref(), - )); - assert!(poll.is_pending()) - } - - #[test] - fn removing_stream() { - let mut streams = StreamMap::new(Duration::from_millis(100), 1); - - let _ = streams.try_push("ID", stream::once(ready(()))); - - { - let cancelled_stream = streams.remove("ID"); - assert!(cancelled_stream.is_some()); - } - - let poll = streams.poll_next_unpin(&mut Context::from_waker( - futures_util::task::noop_waker_ref(), - )); - - assert!(poll.is_pending()); - assert_eq!( - streams.len(), - 0, - "resources of cancelled streams are cleaned up properly" - ); - } - - #[tokio::test] - async fn replaced_stream_is_still_registered() { - let mut streams = StreamMap::new(Duration::from_millis(100), 3); - - let (mut tx1, rx1) = mpsc::channel(5); - let (mut tx2, rx2) = mpsc::channel(5); - - let _ = streams.try_push("ID1", rx1); - let _ = streams.try_push("ID2", rx2); - - let _ = tx2.send(2).await; - let _ = tx1.send(1).await; - let _ = tx2.send(3).await; - let (id, res) = poll_fn(|cx| streams.poll_next_unpin(cx)).await; - assert_eq!(id, "ID1"); - assert_eq!(res.unwrap().unwrap(), 1); - let (id, res) = poll_fn(|cx| streams.poll_next_unpin(cx)).await; - assert_eq!(id, "ID2"); - assert_eq!(res.unwrap().unwrap(), 2); - let (id, res) = poll_fn(|cx| streams.poll_next_unpin(cx)).await; - assert_eq!(id, "ID2"); - assert_eq!(res.unwrap().unwrap(), 3); - - let (mut new_tx1, new_rx1) = mpsc::channel(5); - let replaced = streams.try_push("ID1", new_rx1); - assert!(matches!(replaced.unwrap_err(), PushError::Replaced(_))); - - let _ = new_tx1.send(4).await; - let (id, res) = poll_fn(|cx| streams.poll_next_unpin(cx)).await; - - assert_eq!(id, "ID1"); - assert_eq!(res.unwrap().unwrap(), 4); - } - - // Each stream emits 1 item with delay, `Task` only has a capacity of 1, meaning they must be processed in sequence. - // We stop after NUM_STREAMS tasks, meaning the overall execution must at least take DELAY * NUM_STREAMS. - #[tokio::test] - async fn backpressure() { - const DELAY: Duration = Duration::from_millis(100); - const NUM_STREAMS: u32 = 10; - - let start = Instant::now(); - Task::new(DELAY, NUM_STREAMS, 1).await; - let duration = start.elapsed(); - - assert!(duration >= DELAY * NUM_STREAMS); - } - - struct Task { - item_delay: Duration, - num_streams: usize, - num_processed: usize, - inner: StreamMap, - } - - impl Task { - fn new(item_delay: Duration, num_streams: u32, capacity: usize) -> Self { - Self { - item_delay, - num_streams: num_streams as usize, - num_processed: 0, - inner: StreamMap::new(Duration::from_secs(60), capacity), - } - } - } - - impl Future for Task { - type Output = (); - - fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { - let this = self.get_mut(); - - while this.num_processed < this.num_streams { - match this.inner.poll_next_unpin(cx) { - Poll::Ready((_, Some(result))) => { - if result.is_err() { - panic!("Timeout is great than item delay") - } - - this.num_processed += 1; - continue; - } - Poll::Ready((_, None)) => { - continue; - } - _ => {} - } - - if let Poll::Ready(()) = this.inner.poll_ready_unpin(cx) { - // We push the constant ID to prove that user can use the same ID if the stream was finished - let maybe_future = this.inner.try_push(1u8, once(Delay::new(this.item_delay))); - assert!(maybe_future.is_ok(), "we polled for readiness"); - - continue; - } - - return Poll::Pending; - } - - Poll::Ready(()) - } - } -} diff --git a/misc/futures-bounded/src/stream_set.rs b/misc/futures-bounded/src/stream_set.rs deleted file mode 100644 index bb32835065f..00000000000 --- a/misc/futures-bounded/src/stream_set.rs +++ /dev/null @@ -1,64 +0,0 @@ -use futures_util::stream::BoxStream; -use futures_util::Stream; -use std::task::{ready, Context, Poll}; -use std::time::Duration; - -use crate::{PushError, StreamMap, Timeout}; - -/// Represents a set of [Stream]s. -/// -/// Each stream must finish within the specified time and the list never outgrows its capacity. -pub struct StreamSet { - id: u32, - inner: StreamMap, -} - -impl StreamSet { - pub fn new(timeout: Duration, capacity: usize) -> Self { - Self { - id: 0, - inner: StreamMap::new(timeout, capacity), - } - } -} - -impl StreamSet -where - O: Send + 'static, -{ - /// Push a stream into the list. - /// - /// This method adds the given stream to the list. - /// If the length of the list is equal to the capacity, this method returns a error that contains the passed stream. - /// In that case, the stream is not added to the set. - pub fn try_push(&mut self, stream: F) -> Result<(), BoxStream> - where - F: Stream + Send + 'static, - { - self.id = self.id.wrapping_add(1); - - match self.inner.try_push(self.id, stream) { - Ok(()) => Ok(()), - Err(PushError::BeyondCapacity(w)) => Err(w), - Err(PushError::Replaced(_)) => unreachable!("we never reuse IDs"), - } - } - - pub fn len(&self) -> usize { - self.inner.len() - } - - pub fn is_empty(&self) -> bool { - self.inner.is_empty() - } - - pub fn poll_ready_unpin(&mut self, cx: &mut Context<'_>) -> Poll<()> { - self.inner.poll_ready_unpin(cx) - } - - pub fn poll_next_unpin(&mut self, cx: &mut Context<'_>) -> Poll>> { - let (_, res) = ready!(self.inner.poll_next_unpin(cx)); - - Poll::Ready(res) - } -} diff --git a/misc/keygen/Cargo.toml b/misc/keygen/Cargo.toml index c7989fb4793..9fe9e926d76 100644 --- a/misc/keygen/Cargo.toml +++ b/misc/keygen/Cargo.toml @@ -15,8 +15,8 @@ release = false [dependencies] clap = { version = "4.4.16", features = ["derive"] } zeroize = "1" -serde = { version = "1.0.196", features = ["derive"] } -serde_json = "1.0.113" +serde = { version = "1.0.197", features = ["derive"] } +serde_json = "1.0.114" libp2p-core = { workspace = true } base64 = "0.21.7" libp2p-identity = { workspace = true } diff --git a/misc/multistream-select/src/protocol.rs b/misc/multistream-select/src/protocol.rs index d5c2bfa773a..aef9f16c4cf 100644 --- a/misc/multistream-select/src/protocol.rs +++ b/misc/multistream-select/src/protocol.rs @@ -49,7 +49,7 @@ const MSG_PROTOCOL_NA: &[u8] = b"na\n"; /// The encoded form of a multistream-select 'ls' message. const MSG_LS: &[u8] = b"ls\n"; -/// The multistream-select header lines preceeding negotiation. +/// The multistream-select header lines preceding negotiation. /// /// Every [`Version`] has a corresponding header line. #[derive(Copy, Clone, Debug, PartialEq, Eq)] diff --git a/misc/server/Cargo.toml b/misc/server/Cargo.toml index 9653ddc5d76..af71a57561a 100644 --- a/misc/server/Cargo.toml +++ b/misc/server/Cargo.toml @@ -18,7 +18,7 @@ futures-timer = "3" hyper = { version = "0.14", features = ["server", "tcp", "http1"] } libp2p = { workspace = true, features = ["autonat", "dns", "tokio", "noise", "tcp", "yamux", "identify", "kad", "ping", "relay", "metrics", "rsa", "macros", "quic", "websocket"] } prometheus-client = { workspace = true } -serde = "1.0.196" +serde = "1.0.197" serde_derive = "1.0.125" serde_json = "1.0" tokio = { version = "1", features = ["rt-multi-thread", "macros"] } diff --git a/muxers/test-harness/Cargo.toml b/muxers/test-harness/Cargo.toml index 7aad5f1985a..bfe1e61b9b6 100644 --- a/muxers/test-harness/Cargo.toml +++ b/muxers/test-harness/Cargo.toml @@ -13,7 +13,7 @@ release = false [dependencies] libp2p-core = { workspace = true } futures = "0.3.30" -futures-timer = "3.0.2" +futures-timer = "3.0.3" futures_ringbuf = "0.4.0" tracing = "0.1.37" diff --git a/protocols/floodsub/Cargo.toml b/protocols/floodsub/Cargo.toml index 177334d2145..e1bd23fe2d1 100644 --- a/protocols/floodsub/Cargo.toml +++ b/protocols/floodsub/Cargo.toml @@ -23,7 +23,7 @@ quick-protobuf = "0.8" quick-protobuf-codec = { workspace = true } rand = "0.8" smallvec = "1.12.0" -thiserror = "1.0.56" +thiserror = "1.0.57" tracing = "0.1.37" # Passing arguments to the docsrs builder in order to properly document cfg's. diff --git a/protocols/identify/Cargo.toml b/protocols/identify/Cargo.toml index 2fb51d87627..a8da8d0e762 100644 --- a/protocols/identify/Cargo.toml +++ b/protocols/identify/Cargo.toml @@ -13,7 +13,7 @@ categories = ["network-programming", "asynchronous"] [dependencies] asynchronous-codec = { workspace = true } futures = "0.3.30" -futures-timer = "3.0.2" +futures-timer = "3.0.3" futures-bounded = { workspace = true } libp2p-core = { workspace = true } libp2p-swarm = { workspace = true } diff --git a/protocols/kad/Cargo.toml b/protocols/kad/Cargo.toml index bde0d5f7c84..3bf74808f4a 100644 --- a/protocols/kad/Cargo.toml +++ b/protocols/kad/Cargo.toml @@ -28,7 +28,7 @@ sha2 = "0.10.8" smallvec = "1.12.0" uint = "0.9" void = "1.0" -futures-timer = "3.0.2" +futures-timer = "3.0.3" instant = "0.1.12" serde = { version = "1.0", optional = true, features = ["derive"] } thiserror = "1" diff --git a/protocols/mdns/Cargo.toml b/protocols/mdns/Cargo.toml index ef273781b78..311c479fe72 100644 --- a/protocols/mdns/Cargo.toml +++ b/protocols/mdns/Cargo.toml @@ -21,7 +21,7 @@ libp2p-swarm = { workspace = true } libp2p-identity = { workspace = true } rand = "0.8.3" smallvec = "1.12.0" -socket2 = { version = "0.5.5", features = ["all"] } +socket2 = { version = "0.5.6", features = ["all"] } tokio = { version = "1.36", default-features = false, features = ["net", "time"], optional = true} tracing = "0.1.37" hickory-proto = { version = "0.24.0", default-features = false, features = ["mdns"] } diff --git a/protocols/ping/Cargo.toml b/protocols/ping/Cargo.toml index a4d9259e9aa..5f08ac6fbbd 100644 --- a/protocols/ping/Cargo.toml +++ b/protocols/ping/Cargo.toml @@ -13,7 +13,7 @@ categories = ["network-programming", "asynchronous"] [dependencies] either = "1.9.0" futures = "0.3.30" -futures-timer = "3.0.2" +futures-timer = "3.0.3" instant = "0.1.12" libp2p-core = { workspace = true } libp2p-swarm = { workspace = true } diff --git a/protocols/rendezvous/Cargo.toml b/protocols/rendezvous/Cargo.toml index f9272d011e3..e588c6d7a6b 100644 --- a/protocols/rendezvous/Cargo.toml +++ b/protocols/rendezvous/Cargo.toml @@ -15,7 +15,7 @@ asynchronous-codec = { workspace = true } async-trait = "0.1" bimap = "0.6.3" futures = { version = "0.3", default-features = false, features = ["std"] } -futures-timer = "3.0.2" +futures-timer = "3.0.3" instant = "0.1.12" libp2p-core = { workspace = true } libp2p-swarm = { workspace = true } diff --git a/protocols/request-response/Cargo.toml b/protocols/request-response/Cargo.toml index 7e27c824615..1f2d0bfe1a1 100644 --- a/protocols/request-response/Cargo.toml +++ b/protocols/request-response/Cargo.toml @@ -20,11 +20,11 @@ libp2p-swarm = { workspace = true } libp2p-identity = { workspace = true } rand = "0.8" serde = { version = "1.0", optional = true} -serde_json = { version = "1.0.113", optional = true } +serde_json = { version = "1.0.114", optional = true } smallvec = "1.12.0" tracing = "0.1.37" void = "1.0.2" -futures-timer = "3.0.2" +futures-timer = "3.0.3" futures-bounded = { workspace = true } [features] @@ -32,7 +32,7 @@ json = ["dep:serde", "dep:serde_json", "libp2p-swarm/macros"] cbor = ["dep:serde", "dep:cbor4ii", "libp2p-swarm/macros"] [dev-dependencies] -anyhow = "1.0.79" +anyhow = "1.0.80" async-std = { version = "1.6.2", features = ["attributes"] } libp2p-noise = { workspace = true } libp2p-tcp = { workspace = true, features = ["async-io"] } diff --git a/protocols/stream/CHANGELOG.md b/protocols/stream/CHANGELOG.md index 2e177e2f1bc..1e3b85da0b9 100644 --- a/protocols/stream/CHANGELOG.md +++ b/protocols/stream/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.1.0-alpha.1 +- Implement Error for `OpenStreamError`. + See [PR 5169](https://github.com/libp2p/rust-libp2p/pull/5169). + ## 0.1.0-alpha Initial release. diff --git a/protocols/stream/Cargo.toml b/protocols/stream/Cargo.toml index be340939720..6a39794c196 100644 --- a/protocols/stream/Cargo.toml +++ b/protocols/stream/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "libp2p-stream" -version = "0.1.0-alpha" +version = "0.1.0-alpha.1" edition = "2021" rust-version.workspace = true description = "Generic stream protocols for libp2p" diff --git a/protocols/stream/src/control.rs b/protocols/stream/src/control.rs index 6aabaaff30e..036d285b2a3 100644 --- a/protocols/stream/src/control.rs +++ b/protocols/stream/src/control.rs @@ -103,6 +103,15 @@ impl fmt::Display for OpenStreamError { } } +impl std::error::Error for OpenStreamError { + fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { + match self { + Self::Io(error) => Some(error), + _ => None, + } + } +} + /// A handle to inbound streams for a particular protocol. #[must_use = "Streams do nothing unless polled."] pub struct IncomingStreams { diff --git a/protocols/upnp/Cargo.toml b/protocols/upnp/Cargo.toml index a9c9a3c8621..3119804bf60 100644 --- a/protocols/upnp/Cargo.toml +++ b/protocols/upnp/Cargo.toml @@ -12,7 +12,7 @@ publish = true [dependencies] futures = "0.3.30" -futures-timer = "3.0.2" +futures-timer = "3.0.3" igd-next = "0.14.3" libp2p-core = { workspace = true } libp2p-swarm = { workspace = true } diff --git a/swarm-derive/Cargo.toml b/swarm-derive/Cargo.toml index f3c75749602..c355acaea14 100644 --- a/swarm-derive/Cargo.toml +++ b/swarm-derive/Cargo.toml @@ -16,7 +16,7 @@ proc-macro = true [dependencies] heck = "0.4" quote = "1.0" -syn = { version = "2.0.43", default-features = false, features = ["clone-impls", "derive", "parsing", "printing", "proc-macro"] } +syn = { version = "2.0.51", default-features = false, features = ["clone-impls", "derive", "parsing", "printing", "proc-macro"] } proc-macro2 = "1.0" # Passing arguments to the docsrs builder in order to properly document cfg's. diff --git a/swarm-test/Cargo.toml b/swarm-test/Cargo.toml index ca66e115746..ab27e141a4b 100644 --- a/swarm-test/Cargo.toml +++ b/swarm-test/Cargo.toml @@ -22,7 +22,7 @@ libp2p-yamux = { workspace = true } futures = "0.3.30" rand = "0.8.5" tracing = "0.1.37" -futures-timer = "3.0.2" +futures-timer = "3.0.3" [lints] workspace = true diff --git a/swarm/Cargo.toml b/swarm/Cargo.toml index a700c1c1c5a..4e0d4da0e87 100644 --- a/swarm/Cargo.toml +++ b/swarm/Cargo.toml @@ -14,7 +14,7 @@ categories = ["network-programming", "asynchronous"] either = "1.9.0" fnv = "1.0" futures = "0.3.30" -futures-timer = "3.0.2" +futures-timer = "3.0.3" getrandom = { version = "0.2.12", features = ["js"], optional = true } # Explicit dependency to be used in `wasm-bindgen` feature instant = "0.1.12" libp2p-core = { workspace = true } diff --git a/swarm/src/handler/multi.rs b/swarm/src/handler/multi.rs index 0b4549ed733..96a77626c01 100644 --- a/swarm/src/handler/multi.rs +++ b/swarm/src/handler/multi.rs @@ -437,7 +437,7 @@ where pub struct DuplicateProtonameError(Vec); impl DuplicateProtonameError { - /// The protocol name bytes that occured in more than one handler. + /// The protocol name bytes that occurred in more than one handler. pub fn protocol_name(&self) -> &[u8] { &self.0 } diff --git a/transports/noise/Cargo.toml b/transports/noise/Cargo.toml index 6e346cf7c0e..83bb6de8c0e 100644 --- a/transports/noise/Cargo.toml +++ b/transports/noise/Cargo.toml @@ -22,7 +22,7 @@ quick-protobuf = "0.8" rand = "0.8.3" sha2 = "0.10.8" static_assertions = "1" -thiserror = "1.0.56" +thiserror = "1.0.57" tracing = "0.1.37" x25519-dalek = "2" zeroize = "1" diff --git a/transports/quic/Cargo.toml b/transports/quic/Cargo.toml index 5f9232eaca4..abfbf0742f4 100644 --- a/transports/quic/Cargo.toml +++ b/transports/quic/Cargo.toml @@ -12,7 +12,7 @@ license = "MIT" async-std = { version = "1.12.0", optional = true } bytes = "1.5.0" futures = "0.3.30" -futures-timer = "3.0.2" +futures-timer = "3.0.3" if-watch = "3.2.0" libp2p-core = { workspace = true } libp2p-tls = { workspace = true } @@ -21,10 +21,10 @@ parking_lot = "0.12.0" quinn = { version = "0.10.2", default-features = false, features = ["tls-rustls", "futures-io"] } rand = "0.8.5" rustls = { version = "0.21.9", default-features = false } -thiserror = "1.0.56" +thiserror = "1.0.57" tokio = { version = "1.36.0", default-features = false, features = ["net", "rt", "time"], optional = true } tracing = "0.1.37" -socket2 = "0.5.5" +socket2 = "0.5.6" ring = "0.16.20" [features] diff --git a/transports/tcp/Cargo.toml b/transports/tcp/Cargo.toml index 515d47d2a5a..26528eab840 100644 --- a/transports/tcp/Cargo.toml +++ b/transports/tcp/Cargo.toml @@ -18,7 +18,7 @@ if-watch = "3.2.0" libc = "0.2.153" libp2p-core = { workspace = true } libp2p-identity = { workspace = true } -socket2 = { version = "0.5.5", features = ["all"] } +socket2 = { version = "0.5.6", features = ["all"] } tokio = { version = "1.36.0", default-features = false, features = ["net"], optional = true } tracing = "0.1.37" diff --git a/transports/tls/Cargo.toml b/transports/tls/Cargo.toml index a5059327bec..0ca134d418b 100644 --- a/transports/tls/Cargo.toml +++ b/transports/tls/Cargo.toml @@ -15,7 +15,7 @@ libp2p-core = { workspace = true } libp2p-identity = { workspace = true } rcgen = "0.11.3" ring = "0.16.20" -thiserror = "1.0.56" +thiserror = "1.0.57" webpki = { version = "0.101.4", package = "rustls-webpki", features = ["std"] } x509-parser = "0.15.1" yasna = "0.5.2" diff --git a/transports/uds/Cargo.toml b/transports/uds/Cargo.toml index 19c8178b45c..7b01e0e38d5 100644 --- a/transports/uds/Cargo.toml +++ b/transports/uds/Cargo.toml @@ -18,7 +18,7 @@ tokio = { version = "1.36", default-features = false, features = ["net"], option tracing = "0.1.37" [dev-dependencies] -tempfile = "3.9" +tempfile = "3.10" # 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/webrtc-websys/Cargo.toml b/transports/webrtc-websys/Cargo.toml index 781afc94475..728b6575f0a 100644 --- a/transports/webrtc-websys/Cargo.toml +++ b/transports/webrtc-websys/Cargo.toml @@ -25,7 +25,7 @@ thiserror = "1" tracing = "0.1.37" wasm-bindgen = { version = "0.2.90" } wasm-bindgen-futures = { version = "0.4.41" } -web-sys = { version = "0.3.67", features = ["Document", "Location", "MessageEvent", "Navigator", "RtcCertificate", "RtcConfiguration", "RtcDataChannel", "RtcDataChannelEvent", "RtcDataChannelInit", "RtcDataChannelState", "RtcDataChannelType", "RtcPeerConnection", "RtcSdpType", "RtcSessionDescription", "RtcSessionDescriptionInit", "Window"] } +web-sys = { version = "0.3.68", features = ["Document", "Location", "MessageEvent", "Navigator", "RtcCertificate", "RtcConfiguration", "RtcDataChannel", "RtcDataChannelEvent", "RtcDataChannelInit", "RtcDataChannelState", "RtcDataChannelType", "RtcPeerConnection", "RtcSdpType", "RtcSessionDescription", "RtcSessionDescriptionInit", "Window"] } [lints] workspace = true diff --git a/transports/websocket-websys/Cargo.toml b/transports/websocket-websys/Cargo.toml index 2b65f3f07a3..5855b582c80 100644 --- a/transports/websocket-websys/Cargo.toml +++ b/transports/websocket-websys/Cargo.toml @@ -18,9 +18,9 @@ libp2p-core = { workspace = true } tracing = "0.1.37" parking_lot = "0.12.1" send_wrapper = "0.6.0" -thiserror = "1.0.56" +thiserror = "1.0.57" wasm-bindgen = "0.2.90" -web-sys = { version = "0.3.67", features = ["BinaryType", "CloseEvent", "MessageEvent", "WebSocket", "Window", "WorkerGlobalScope"] } +web-sys = { version = "0.3.68", features = ["BinaryType", "CloseEvent", "MessageEvent", "WebSocket", "Window", "WorkerGlobalScope"] } # 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/webtransport-websys/Cargo.toml b/transports/webtransport-websys/Cargo.toml index f1c92e3ca17..b9f8f36d760 100644 --- a/transports/webtransport-websys/Cargo.toml +++ b/transports/webtransport-websys/Cargo.toml @@ -22,11 +22,11 @@ libp2p-noise = { workspace = true } multiaddr = { workspace = true } multihash = { workspace = true } send_wrapper = { version = "0.6.0", features = ["futures"] } -thiserror = "1.0.56" +thiserror = "1.0.57" tracing = "0.1.37" wasm-bindgen = "0.2.90" wasm-bindgen-futures = "0.4.41" -web-sys = { version = "0.3.67", features = [ +web-sys = { version = "0.3.68", features = [ "ReadableStreamDefaultReader", "WebTransport", "WebTransportBidirectionalStream", diff --git a/transports/webtransport-websys/src/utils.rs b/transports/webtransport-websys/src/utils.rs index fcde226be87..55bad08e00c 100644 --- a/transports/webtransport-websys/src/utils.rs +++ b/transports/webtransport-websys/src/utils.rs @@ -55,7 +55,7 @@ where } } -/// Parse reponse from `ReadableStreamDefaultReader::read`. +/// Parse response from `ReadableStreamDefaultReader::read`. // // Ref: https://streams.spec.whatwg.org/#default-reader-prototype pub(crate) fn parse_reader_response(resp: &JsValue) -> Result, JsValue> { diff --git a/wasm-tests/webtransport-tests/Cargo.toml b/wasm-tests/webtransport-tests/Cargo.toml index ef728f80fb0..c9f5170b114 100644 --- a/wasm-tests/webtransport-tests/Cargo.toml +++ b/wasm-tests/webtransport-tests/Cargo.toml @@ -19,8 +19,8 @@ multiaddr = { workspace = true } multihash = { workspace = true } wasm-bindgen = "0.2.90" wasm-bindgen-futures = "0.4.41" -wasm-bindgen-test = "0.3.39" -web-sys = { version = "0.3.67", features = ["Response", "Window"] } +wasm-bindgen-test = "0.3.41" +web-sys = { version = "0.3.68", features = ["Response", "Window"] } [lints] workspace = true