diff --git a/.github/mergify.yml b/.github/mergify.yml index 048d838894c..c630d23cea0 100644 --- a/.github/mergify.yml +++ b/.github/mergify.yml @@ -33,6 +33,14 @@ pull_request_rules: actions: queue: + - name: Add approved dependabot PRs to merge queue + conditions: + # All branch protection rules are implicit: https://docs.mergify.com/conditions/#about-branch-protection + - author=dependabot[bot] + - base=master + actions: + queue: + - name: Remove reviews on updates after PR is queued for merging conditions: - base=master @@ -52,6 +60,15 @@ pull_request_rules: 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 conditions: [] diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d148c9e1474..89b756d1d72 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -212,7 +212,7 @@ jobs: fail-fast: false matrix: rust-version: [ - 1.70.0, # current stable + 1.71.0, # current stable beta ] steps: diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 1d38e7a8aaf..8513493b41a 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -24,7 +24,7 @@ jobs: echo "" > target/doc/index.html cp -r target/doc/* ./host-docs - name: Upload documentation - uses: actions/upload-pages-artifact@v1.0.9 + uses: actions/upload-pages-artifact@v2.0.0 with: path: "host-docs/" diff --git a/Cargo.lock b/Cargo.lock index 004f76df4f9..c4d62b1e4c5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -162,6 +162,12 @@ dependencies = [ "memchr", ] +[[package]] +name = "allocator-api2" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" + [[package]] name = "anes" version = "0.1.6" @@ -219,9 +225,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.71" +version = "1.0.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c7d0618f0e0b7e8ff11427422b64564d5fb0be1940354bfe2e0529b18a9d9b8" +checksum = "3b13c32d80ecc7ab747b80c3784bce54ee8a7a0cc4fbda9bf4cda2cf6fe90854" [[package]] name = "arbitrary" @@ -498,7 +504,7 @@ checksum = "a564d521dd56509c4c47480d00b80ee55f7e385ae48db5744c67ad50c92d2ebf" dependencies = [ "proc-macro2", "quote", - "syn 2.0.25", + "syn 2.0.27", ] [[package]] @@ -563,9 +569,9 @@ dependencies = [ [[package]] name = "axum" -version = "0.6.18" +version = "0.6.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8175979259124331c1d7bf6586ee7e0da434155e4b2d48ec2c8386281d8df39" +checksum = "a6a1de45611fdb535bfde7b7de4fd54f4fd2b17b1737c0a59b69bf9b92074b8c" dependencies = [ "async-trait", "axum-core", @@ -797,6 +803,15 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" +[[package]] +name = "cbor4ii" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13e8c816014cad3f58c2f0607677e8d2c6f76754dd8e735461a440b27b95199c" +dependencies = [ + "serde", +] + [[package]] name = "cc" version = "1.0.79" @@ -920,9 +935,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.3.11" +version = "4.3.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1640e5cc7fb47dbb8338fd471b105e7ed6c3cb2aeb00c2e067127ffd3764a05d" +checksum = "3eab9e8ceb9afdade1ab3f0fd8dbce5b1b2f468ad653baf10e771781b2b67b73" dependencies = [ "clap_builder", "clap_derive", @@ -931,9 +946,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.3.11" +version = "4.3.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98c59138d527eeaf9b53f35a77fcc1fad9d883116070c63d5de1c7dc7b00c72b" +checksum = "9f2763db829349bf00cfc06251268865ed4363b93a943174f638daf3ecdba2cd" dependencies = [ "anstream", "anstyle", @@ -943,14 +958,14 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.3.2" +version = "4.3.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8cd2b2a819ad6eec39e8f1d6b53001af1e5469f8c177579cdaeb313115b825f" +checksum = "54a9bb5758fc5dfe728d1019941681eccaf0cf8a4189b692a0ee2f2ecf90a050" dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.25", + "syn 2.0.27", ] [[package]] @@ -1537,7 +1552,7 @@ checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.25", + "syn 2.0.27", ] [[package]] @@ -1649,7 +1664,7 @@ dependencies = [ "pem-rfc7468 0.7.0", "pkcs8 0.10.2", "rand_core 0.6.4", - "sec1 0.7.2", + "sec1 0.7.3", "subtle", "zeroize", ] @@ -1925,7 +1940,7 @@ checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" dependencies = [ "proc-macro2", "quote", - "syn 2.0.25", + "syn 2.0.27", ] [[package]] @@ -2156,19 +2171,14 @@ checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" [[package]] name = "hashbrown" -version = "0.13.2" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" +checksum = "2c6201b9ff9fd90a5a3bac2e56a830d0caa509576f0e503818ee82c181b3437a" dependencies = [ "ahash", + "allocator-api2", ] -[[package]] -name = "hashbrown" -version = "0.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c6201b9ff9fd90a5a3bac2e56a830d0caa509576f0e503818ee82c181b3437a" - [[package]] name = "heck" version = "0.4.1" @@ -2777,7 +2787,7 @@ dependencies = [ [[package]] name = "libp2p" -version = "0.52.1" +version = "0.52.2" dependencies = [ "async-std", "async-trait", @@ -3067,7 +3077,7 @@ dependencies = [ "rand 0.8.5", "ring", "rmp-serde", - "sec1 0.7.2", + "sec1 0.7.3", "serde", "serde_json", "sha2 0.10.7", @@ -3138,7 +3148,7 @@ dependencies = [ [[package]] name = "libp2p-metrics" -version = "0.13.0" +version = "0.13.1" dependencies = [ "instant", "libp2p-core", @@ -3332,7 +3342,7 @@ dependencies = [ [[package]] name = "libp2p-relay" -version = "0.16.0" +version = "0.16.1" dependencies = [ "asynchronous-codec", "bytes 1.4.0", @@ -3389,10 +3399,11 @@ dependencies = [ [[package]] name = "libp2p-request-response" -version = "0.25.0" +version = "0.25.1" dependencies = [ "async-std", "async-trait", + "cbor4ii", "env_logger 0.10.0", "futures", "futures_ringbuf", @@ -3407,7 +3418,6 @@ dependencies = [ "log", "rand 0.8.5", "serde", - "serde_cbor", "serde_json", "smallvec", "void", @@ -3454,7 +3464,7 @@ dependencies = [ "proc-macro-warning", "proc-macro2", "quote", - "syn 2.0.25", + "syn 2.0.27", ] [[package]] @@ -3747,11 +3757,11 @@ dependencies = [ [[package]] name = "lru" -version = "0.10.1" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "718e8fae447df0c7e1ba7f5189829e63fd536945c8988d61444c19039f16b670" +checksum = "eedb2bdbad7e0634f83989bf596f497b070130daaa398ab22d84c39e266deec5" dependencies = [ - "hashbrown 0.13.2", + "hashbrown 0.14.0", ] [[package]] @@ -4171,7 +4181,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.25", + "syn 2.0.27", ] [[package]] @@ -4327,7 +4337,7 @@ checksum = "ec2e072ecce94ec471b13398d5402c188e76ac03cf74dd1a975161b23a3f6d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.25", + "syn 2.0.27", ] [[package]] @@ -4533,23 +4543,23 @@ checksum = "70550716265d1ec349c41f70dd4f964b4fd88394efe4405f0c1da679c4799a07" dependencies = [ "proc-macro2", "quote", - "syn 2.0.25", + "syn 2.0.27", ] [[package]] name = "proc-macro2" -version = "1.0.63" +version = "1.0.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b368fba921b0dce7e60f5e04ec15e565b3303972b42bcfde1d0713b881959eb" +checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9" dependencies = [ "unicode-ident", ] [[package]] name = "prometheus-client" -version = "0.21.1" +version = "0.21.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78c2f43e8969d51935d2a7284878ae053ba30034cd563f673cde37ba5205685e" +checksum = "3c99afa9a01501019ac3a14d71d9f94050346f55ca471ce90c799a15c58f61e2" dependencies = [ "dtoa", "itoa", @@ -4643,9 +4653,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.29" +version = "1.0.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "573015e8ab27661678357f27dc26460738fd2b6c86e46f386fde94cb5d913105" +checksum = "5fe8a65d69dd0808184ebb5f836ab526bb259db23c657efa38711b1072ee47f0" dependencies = [ "proc-macro2", ] @@ -5040,7 +5050,7 @@ dependencies = [ "proc-macro2", "quote", "rust-embed-utils", - "syn 2.0.25", + "syn 2.0.27", "walkdir", ] @@ -5307,9 +5317,9 @@ dependencies = [ [[package]] name = "sec1" -version = "0.7.2" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0aec48e813d6b90b15f0b8948af3c63483992dee44c03e9930b3eebdabe046e" +checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc" dependencies = [ "base16ct 0.2.0", "der 0.7.7", @@ -5380,32 +5390,22 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.168" +version = "1.0.171" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d614f89548720367ded108b3c843be93f3a341e22d5674ca0dd5cd57f34926af" +checksum = "30e27d1e4fd7659406c492fd6cfaf2066ba8773de45ca75e855590f856dc34a9" dependencies = [ "serde_derive", ] -[[package]] -name = "serde_cbor" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bef2ebfde456fb76bbcf9f59315333decc4fda0b2b44b420243c11e0f5ec1f5" -dependencies = [ - "half", - "serde", -] - [[package]] name = "serde_derive" -version = "1.0.168" +version = "1.0.171" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4fe589678c688e44177da4f27152ee2d190757271dc7f1d5b6b9f68d869d641" +checksum = "389894603bd18c46fa56231694f8d827779c0951a667087194cf9de94ed24682" dependencies = [ "proc-macro2", "quote", - "syn 2.0.25", + "syn 2.0.27", ] [[package]] @@ -5449,7 +5449,7 @@ checksum = "6f0a21fba416426ac927b1691996e82079f8b6156e920c85345f135b2e9ba2de" dependencies = [ "proc-macro2", "quote", - "syn 2.0.25", + "syn 2.0.27", ] [[package]] @@ -5873,9 +5873,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.25" +version = "2.0.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15e3fc8c0c74267e2df136e5e5fb656a464158aa57624053375eb9c8c6e25ae2" +checksum = "b60f673f44a8255b9c8c657daf66a596d435f2da81a555b06dc644d080ba45e0" dependencies = [ "proc-macro2", "quote", @@ -5984,22 +5984,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.40" +version = "1.0.43" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "978c9a314bd8dc99be594bc3c175faaa9794be04a5a5e153caba6915336cebac" +checksum = "a35fc5b8971143ca348fa6df4f024d4d55264f3468c71ad1c2f365b0a4d58c42" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.40" +version = "1.0.43" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" +checksum = "463fe12d7993d3b327787537ce8dd4dfa058de32fc2b195ef3cde03dc4771e8f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.25", + "syn 2.0.27", ] [[package]] @@ -6130,7 +6130,7 @@ checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.25", + "syn 2.0.27", ] [[package]] @@ -6243,7 +6243,7 @@ checksum = "5f4f31f56159e98206da9efd823404b79b6ef3143b4a7ab76e67b1751b25a4ab" dependencies = [ "proc-macro2", "quote", - "syn 2.0.25", + "syn 2.0.27", ] [[package]] @@ -6612,7 +6612,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.25", + "syn 2.0.27", "wasm-bindgen-shared", ] @@ -6646,7 +6646,7 @@ checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.25", + "syn 2.0.27", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -7297,5 +7297,5 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.25", + "syn 2.0.27", ] diff --git a/Cargo.toml b/Cargo.toml index 7f59d5e9529..1d595d6ea6f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -76,7 +76,7 @@ libp2p-identify = { version = "0.43.0", path = "protocols/identify" } libp2p-identity = { version = "0.2.1" } libp2p-kad = { version = "0.44.2", path = "protocols/kad" } libp2p-mdns = { version = "0.44.0", path = "protocols/mdns" } -libp2p-metrics = { version = "0.13.0", path = "misc/metrics" } +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" } libp2p-noise = { version = "0.43.0", path = "transports/noise" } @@ -85,10 +85,10 @@ 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.8.0-alpha", path = "transports/quic" } -libp2p-relay = { version = "0.16.0", path = "protocols/relay" } +libp2p-relay = { version = "0.16.1", path = "protocols/relay" } libp2p-rendezvous = { version = "0.13.0", path = "protocols/rendezvous" } -libp2p-request-response = { version = "0.25.0", path = "protocols/request-response" } libp2p-upnp = { version = "0.1.0", path = "protocols/upnp" } +libp2p-request-response = { version = "0.25.1", path = "protocols/request-response" } libp2p-swarm = { version = "0.43.1", path = "swarm" } libp2p-swarm-derive = { version = "0.33.0", path = "swarm-derive" } libp2p-swarm-test = { version = "0.2.0", path = "swarm-test" } diff --git a/core/src/upgrade/apply.rs b/core/src/upgrade/apply.rs index 50aa8e2c0dd..aa997435673 100644 --- a/core/src/upgrade/apply.rs +++ b/core/src/upgrade/apply.rs @@ -55,7 +55,7 @@ where { InboundUpgradeApply { inner: InboundUpgradeApplyState::Init { - future: multistream_select::listener_select_proto(conn, up.protocol_info().into_iter()), + future: multistream_select::listener_select_proto(conn, up.protocol_info()), upgrade: up, }, } diff --git a/examples/autonat/Cargo.toml b/examples/autonat/Cargo.toml index 6c7b642c4a3..9f40dbbc3f3 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.11", features = ["derive"] } +clap = { version = "4.3.12", 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/dcutr/Cargo.toml b/examples/dcutr/Cargo.toml index d37dfcaca62..5a6389f00c0 100644 --- a/examples/dcutr/Cargo.toml +++ b/examples/dcutr/Cargo.toml @@ -6,7 +6,7 @@ publish = false license = "MIT" [dependencies] -clap = { version = "4.3.11", features = ["derive"] } +clap = { version = "4.3.12", features = ["derive"] } env_logger = "0.10.0" futures = "0.3.28" futures-timer = "3.0" diff --git a/examples/distributed-key-value-store/src/main.rs b/examples/distributed-key-value-store/src/main.rs index 226a438f2cc..ce0998a9ac5 100644 --- a/examples/distributed-key-value-store/src/main.rs +++ b/examples/distributed-key-value-store/src/main.rs @@ -24,6 +24,7 @@ use async_std::io; use futures::{prelude::*, select}; use libp2p::core::upgrade::Version; use libp2p::kad::record::store::MemoryStore; +use libp2p::kad::Mode; use libp2p::kad::{ record::Key, AddProviderOk, GetProvidersOk, GetRecordOk, Kademlia, KademliaEvent, PeerRecord, PutRecordOk, QueryResult, Quorum, Record, @@ -85,6 +86,8 @@ async fn main() -> Result<(), Box> { SwarmBuilder::with_async_std_executor(transport, behaviour, local_peer_id).build() }; + swarm.behaviour_mut().kademlia.set_mode(Some(Mode::Server)); + // Read full lines from stdin let mut stdin = io::BufReader::new(io::stdin()).lines().fuse(); diff --git a/examples/file-sharing/Cargo.toml b/examples/file-sharing/Cargo.toml index b631a7cf194..8055ee8216d 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.11", features = ["derive"] } +clap = { version = "4.3.12", features = ["derive"] } either = "1.8" env_logger = "0.10" futures = "0.3.28" diff --git a/examples/metrics/Cargo.toml b/examples/metrics/Cargo.toml index 463b98a2383..f883127ee25 100644 --- a/examples/metrics/Cargo.toml +++ b/examples/metrics/Cargo.toml @@ -12,4 +12,4 @@ 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" tokio = { version = "1", features = ["rt-multi-thread"] } -prometheus-client = "0.21.0" +prometheus-client = "0.21.2" diff --git a/examples/relay-server/Cargo.toml b/examples/relay-server/Cargo.toml index ce5825e02ff..263a25b34ba 100644 --- a/examples/relay-server/Cargo.toml +++ b/examples/relay-server/Cargo.toml @@ -6,7 +6,7 @@ publish = false license = "MIT" [dependencies] -clap = { version = "4.3.11", features = ["derive"] } +clap = { version = "4.3.12", features = ["derive"] } async-std = { version = "1.12", features = ["attributes"] } async-trait = "0.1" env_logger = "0.10.0" diff --git a/libp2p/CHANGELOG.md b/libp2p/CHANGELOG.md index fa299284667..4161ed054c5 100644 --- a/libp2p/CHANGELOG.md +++ b/libp2p/CHANGELOG.md @@ -1,3 +1,14 @@ +## 0.52.2 - unreleased + +- Include gossipsub when compiling for wasm. + See [PR 4217]. + +- Add `json` feature which exposes `request_response::json`. + See [PR 4188]. + +[PR 4188]: https://github.com/libp2p/rust-libp2p/pull/4188 +[PR 4217]: https://github.com/libp2p/rust-libp2p/pull/4217 + ## 0.52.1 - Add `libp2p-webtransport-websys` providing WebTransport for WASM environments. diff --git a/libp2p/Cargo.toml b/libp2p/Cargo.toml index 369e6df6bbe..73a8b285fbc 100644 --- a/libp2p/Cargo.toml +++ b/libp2p/Cargo.toml @@ -3,7 +3,7 @@ name = "libp2p" edition = "2021" rust-version = "1.65.0" description = "Peer-to-peer networking library" -version = "0.52.1" +version = "0.52.2" authors = ["Parity Technologies "] license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" @@ -23,6 +23,7 @@ full = [ "floodsub", "gossipsub", "identify", + "json", "kad", "macros", "mdns", @@ -62,6 +63,7 @@ ed25519 = ["libp2p-identity/ed25519"] floodsub = ["dep:libp2p-floodsub"] gossipsub = ["dep:libp2p-gossipsub", "libp2p-metrics?/gossipsub"] identify = ["dep:libp2p-identify", "libp2p-metrics?/identify"] +json = ["libp2p-request-response?/json"] kad = ["dep:libp2p-kad", "libp2p-metrics?/kad"] macros = ["libp2p-swarm/macros"] mdns = ["dep:libp2p-mdns"] diff --git a/libp2p/src/lib.rs b/libp2p/src/lib.rs index 6dc05bf422e..393614d7849 100644 --- a/libp2p/src/lib.rs +++ b/libp2p/src/lib.rs @@ -65,7 +65,6 @@ pub use libp2p_dns as dns; #[doc(inline)] pub use libp2p_floodsub as floodsub; #[cfg(feature = "gossipsub")] -#[cfg(not(target_os = "unknown"))] #[doc(inline)] pub use libp2p_gossipsub as gossipsub; #[cfg(feature = "identify")] diff --git a/misc/allow-block-list/src/lib.rs b/misc/allow-block-list/src/lib.rs index a9e3280c417..eed79d740a1 100644 --- a/misc/allow-block-list/src/lib.rs +++ b/misc/allow-block-list/src/lib.rs @@ -354,9 +354,16 @@ mod tests { .block_peer(*listener.local_peer_id()); let ( - [SwarmEvent::ConnectionClosed { peer_id: closed_dialer_peer, .. }], - [SwarmEvent::ConnectionClosed { peer_id: closed_listener_peer, .. }] - ) = libp2p_swarm_test::drive(&mut dialer, &mut listener).await else { + [SwarmEvent::ConnectionClosed { + peer_id: closed_dialer_peer, + .. + }], + [SwarmEvent::ConnectionClosed { + peer_id: closed_listener_peer, + .. + }], + ) = libp2p_swarm_test::drive(&mut dialer, &mut listener).await + else { panic!("unexpected events") }; assert_eq!(closed_dialer_peer, *listener.local_peer_id()); @@ -417,9 +424,22 @@ mod tests { .unwrap(); let ( - [SwarmEvent::OutgoingConnectionError { error: DialError::Denied { cause: outgoing_cause }, .. }], - [_, SwarmEvent::IncomingConnectionError { error: ListenError::Denied { cause: incoming_cause }, .. }], - ) = libp2p_swarm_test::drive(&mut dialer, &mut listener).await else { + [SwarmEvent::OutgoingConnectionError { + error: + DialError::Denied { + cause: outgoing_cause, + }, + .. + }], + [_, SwarmEvent::IncomingConnectionError { + error: + ListenError::Denied { + cause: incoming_cause, + }, + .. + }], + ) = libp2p_swarm_test::drive(&mut dialer, &mut listener).await + else { panic!("unexpected events") }; assert!(outgoing_cause.downcast::().is_ok()); @@ -447,9 +467,16 @@ mod tests { .list .disallow_peer(*listener.local_peer_id()); let ( - [SwarmEvent::ConnectionClosed { peer_id: closed_dialer_peer, .. }], - [SwarmEvent::ConnectionClosed { peer_id: closed_listener_peer, .. }] - ) = libp2p_swarm_test::drive(&mut dialer, &mut listener).await else { + [SwarmEvent::ConnectionClosed { + peer_id: closed_dialer_peer, + .. + }], + [SwarmEvent::ConnectionClosed { + peer_id: closed_listener_peer, + .. + }], + ) = libp2p_swarm_test::drive(&mut dialer, &mut listener).await + else { panic!("unexpected events") }; assert_eq!(closed_dialer_peer, *listener.local_peer_id()); diff --git a/misc/keygen/Cargo.toml b/misc/keygen/Cargo.toml index d70f741b542..e1fa1f9f5cf 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.11", features = ["derive"] } +clap = { version = "4.3.12", features = ["derive"] } zeroize = "1" -serde = { version = "1.0.164", features = ["derive"] } +serde = { version = "1.0.171", features = ["derive"] } serde_json = "1.0.100" libp2p-core = { workspace = true } base64 = "0.21.2" diff --git a/misc/metrics/CHANGELOG.md b/misc/metrics/CHANGELOG.md index f1f6c343caa..cca9ced5ec7 100644 --- a/misc/metrics/CHANGELOG.md +++ b/misc/metrics/CHANGELOG.md @@ -1,3 +1,10 @@ +## 0.13.1 - unreleased + +- 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 - Previously `libp2p-metrics::identify` would increase a counter / gauge / histogram on each diff --git a/misc/metrics/Cargo.toml b/misc/metrics/Cargo.toml index 7a579408409..e93d1f663ed 100644 --- a/misc/metrics/Cargo.toml +++ b/misc/metrics/Cargo.toml @@ -3,7 +3,7 @@ name = "libp2p-metrics" edition = "2021" rust-version = "1.65.0" description = "Metrics for libp2p" -version = "0.13.0" +version = "0.13.1" authors = ["Max Inden "] license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" @@ -11,32 +11,30 @@ keywords = ["peer-to-peer", "libp2p", "networking"] categories = ["network-programming", "asynchronous"] [features] +dcutr = ["libp2p-dcutr"] gossipsub = ["libp2p-gossipsub"] identify = ["libp2p-identify"] kad = ["libp2p-kad"] ping = ["libp2p-ping"] relay = ["libp2p-relay"] -dcutr = ["libp2p-dcutr"] [dependencies] instant = "0.1.12" libp2p-core = { workspace = true } libp2p-dcutr = { workspace = true, optional = true } +libp2p-gossipsub = { workspace = true, optional = true } libp2p-identify = { workspace = true, optional = true } +libp2p-identity = { workspace = true } libp2p-kad = { workspace = true, optional = true } libp2p-ping = { workspace = true, optional = true } libp2p-relay = { workspace = true, optional = true } libp2p-swarm = { workspace = true } -libp2p-identity = { workspace = true } -prometheus-client = { version = "0.21.1"} once_cell = "1.18.0" - -[target.'cfg(not(target_os = "unknown"))'.dependencies] -libp2p-gossipsub = { workspace = true, optional = true } +prometheus-client = { version = "0.21.2"} # Passing arguments to the docsrs builder in order to properly document cfg's. # More information: https://docs.rs/about/builds#cross-compiling [package.metadata.docs.rs] all-features = true -rustdoc-args = ["--cfg", "docsrs"] rustc-args = ["--cfg", "docsrs"] +rustdoc-args = ["--cfg", "docsrs"] diff --git a/misc/metrics/src/identify.rs b/misc/metrics/src/identify.rs index 0e2527c09df..4e320e7b0a0 100644 --- a/misc/metrics/src/identify.rs +++ b/misc/metrics/src/identify.rs @@ -64,7 +64,6 @@ const ALLOWED_PROTOCOLS: &[StreamProtocol] = &[ #[cfg(feature = "dcutr")] libp2p_dcutr::PROTOCOL_NAME, // #[cfg(feature = "gossipsub")] - // #[cfg(not(target_os = "unknown"))] // TODO: Add Gossipsub protocol name libp2p_identify::PROTOCOL_NAME, libp2p_identify::PUSH_PROTOCOL_NAME, diff --git a/misc/metrics/src/lib.rs b/misc/metrics/src/lib.rs index ec166eebecc..fd977537d96 100644 --- a/misc/metrics/src/lib.rs +++ b/misc/metrics/src/lib.rs @@ -30,7 +30,6 @@ #[cfg(feature = "dcutr")] mod dcutr; #[cfg(feature = "gossipsub")] -#[cfg(not(target_os = "unknown"))] mod gossipsub; #[cfg(feature = "identify")] mod identify; @@ -50,7 +49,6 @@ pub struct Metrics { #[cfg(feature = "dcutr")] dcutr: dcutr::Metrics, #[cfg(feature = "gossipsub")] - #[cfg(not(target_os = "unknown"))] gossipsub: gossipsub::Metrics, #[cfg(feature = "identify")] identify: identify::Metrics, @@ -78,7 +76,6 @@ impl Metrics { #[cfg(feature = "dcutr")] dcutr: dcutr::Metrics::new(sub_registry), #[cfg(feature = "gossipsub")] - #[cfg(not(target_os = "unknown"))] gossipsub: gossipsub::Metrics::new(sub_registry), #[cfg(feature = "identify")] identify: identify::Metrics::new(sub_registry), @@ -107,7 +104,6 @@ impl Recorder for Metrics { } #[cfg(feature = "gossipsub")] -#[cfg(not(target_os = "unknown"))] impl Recorder for Metrics { fn record(&self, event: &libp2p_gossipsub::Event) { self.gossipsub.record(event) diff --git a/misc/multistream-select/src/length_delimited.rs b/misc/multistream-select/src/length_delimited.rs index 85f6ffc141d..cff2f4abc39 100644 --- a/misc/multistream-select/src/length_delimited.rs +++ b/misc/multistream-select/src/length_delimited.rs @@ -411,7 +411,7 @@ mod tests { assert!(len < (1 << 15)); let frame = (0..len).map(|n| (n & 0xff) as u8).collect::>(); let mut data = vec![(len & 0x7f) as u8 | 0x80, (len >> 7) as u8]; - data.extend(frame.clone().into_iter()); + data.extend(frame.clone()); let mut framed = LengthDelimited::new(Cursor::new(data)); let recved = futures::executor::block_on(async move { framed.next().await }).unwrap(); assert_eq!(recved.unwrap(), frame); diff --git a/misc/multistream-select/tests/dialer_select.rs b/misc/multistream-select/tests/dialer_select.rs index 18f8238cd25..d1b276458c4 100644 --- a/misc/multistream-select/tests/dialer_select.rs +++ b/misc/multistream-select/tests/dialer_select.rs @@ -47,10 +47,9 @@ fn select_proto_basic() { let client = async_std::task::spawn(async move { let protos = vec!["/proto3", "/proto2"]; - let (proto, mut io) = - dialer_select_proto(client_connection, protos.into_iter(), version) - .await - .unwrap(); + let (proto, mut io) = dialer_select_proto(client_connection, protos, version) + .await + .unwrap(); assert_eq!(proto, "/proto2"); io.write_all(b"ping").await.unwrap(); @@ -99,25 +98,21 @@ fn negotiation_failed() { } }); - let client = - async_std::task::spawn(async move { - let mut io = - match dialer_select_proto(client_connection, dial_protos.into_iter(), version) - .await - { - Err(NegotiationError::Failed) => return, - Ok((_, io)) => io, - Err(_) => panic!(), - }; - // The dialer may write a payload that is even sent before it - // got confirmation of the last proposed protocol, when `V1Lazy` - // is used. - io.write_all(&dial_payload).await.unwrap(); - match io.complete().await { - Err(NegotiationError::Failed) => {} - _ => panic!(), - } - }); + let client = async_std::task::spawn(async move { + let mut io = match dialer_select_proto(client_connection, dial_protos, version).await { + Err(NegotiationError::Failed) => return, + Ok((_, io)) => io, + Err(_) => panic!(), + }; + // The dialer may write a payload that is even sent before it + // got confirmation of the last proposed protocol, when `V1Lazy` + // is used. + io.write_all(&dial_payload).await.unwrap(); + match io.complete().await { + Err(NegotiationError::Failed) => {} + _ => panic!(), + } + }); server.await; client.await; @@ -185,10 +180,9 @@ async fn v1_lazy_do_not_wait_for_negotiation_on_poll_close() { let client = async_std::task::spawn(async move { // Single protocol to allow for lazy (or optimistic) protocol negotiation. let protos = vec!["/proto1"]; - let (proto, mut io) = - dialer_select_proto(client_connection, protos.into_iter(), Version::V1Lazy) - .await - .unwrap(); + let (proto, mut io) = dialer_select_proto(client_connection, protos, Version::V1Lazy) + .await + .unwrap(); assert_eq!(proto, "/proto1"); // client can close the connection even though protocol negotiation is not yet done, i.e. diff --git a/muxers/mplex/src/lib.rs b/muxers/mplex/src/lib.rs index fa36fecfefb..81c5147af69 100644 --- a/muxers/mplex/src/lib.rs +++ b/muxers/mplex/src/lib.rs @@ -55,6 +55,7 @@ where fn upgrade_inbound(self, socket: C, _: Self::Info) -> Self::Future { future::ready(Ok(Multiplex { + #[allow(unknown_lints, clippy::arc_with_non_send_sync)] // `T` is not enforced to be `Send` but we don't want to constrain it either. io: Arc::new(Mutex::new(io::Multiplexed::new(socket, self))), })) } @@ -70,6 +71,7 @@ where fn upgrade_outbound(self, socket: C, _: Self::Info) -> Self::Future { future::ready(Ok(Multiplex { + #[allow(unknown_lints, clippy::arc_with_non_send_sync)] // `T` is not enforced to be `Send` but we don't want to constrain it either. io: Arc::new(Mutex::new(io::Multiplexed::new(socket, self))), })) } diff --git a/protocols/dcutr/Cargo.toml b/protocols/dcutr/Cargo.toml index 7cbfa11a80f..27a927e6f67 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.11", features = ["derive"] } +clap = { version = "4.3.12", features = ["derive"] } env_logger = "0.10.0" libp2p-dns = { workspace = true, features = ["async-std"] } libp2p-identify = { workspace = true } diff --git a/protocols/floodsub/Cargo.toml b/protocols/floodsub/Cargo.toml index 3b3e7dc7271..1905c8d36d7 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.11.0" -thiserror = "1.0.40" +thiserror = "1.0.43" # 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/protocols/gossipsub/Cargo.toml b/protocols/gossipsub/Cargo.toml index adb3a2a9cdc..25232ff5bfd 100644 --- a/protocols/gossipsub/Cargo.toml +++ b/protocols/gossipsub/Cargo.toml @@ -40,7 +40,7 @@ unsigned-varint = { version = "0.7.0", features = ["asynchronous_codec"] } void = "1.0.2" # Metrics dependencies -prometheus-client = "0.21.0" +prometheus-client = "0.21.2" [dev-dependencies] async-std = { version = "1.6.3", features = ["unstable"] } diff --git a/protocols/gossipsub/src/behaviour/tests.rs b/protocols/gossipsub/src/behaviour/tests.rs index 37f25631ae4..b2414fd7afc 100644 --- a/protocols/gossipsub/src/behaviour/tests.rs +++ b/protocols/gossipsub/src/behaviour/tests.rs @@ -858,7 +858,7 @@ fn test_handle_received_subscriptions() { // UNSUBSCRIBE - Remove topic from peer_topics for peer. // - Remove peer from topic_peers. - let topics = vec!["topic1", "topic2", "topic3", "topic4"] + let topics = ["topic1", "topic2", "topic3", "topic4"] .iter() .map(|&t| String::from(t)) .collect(); @@ -1280,7 +1280,7 @@ fn test_handle_graft_is_not_subscribed() { #[test] // tests multiple topics in a single graft message fn test_handle_graft_multiple_topics() { - let topics: Vec = vec!["topic1", "topic2", "topic3", "topic4"] + let topics: Vec = ["topic1", "topic2", "topic3", "topic4"] .iter() .map(|&t| String::from(t)) .collect(); diff --git a/protocols/gossipsub/src/subscription_filter.rs b/protocols/gossipsub/src/subscription_filter.rs index 8ec633d0717..9f883f12a1b 100644 --- a/protocols/gossipsub/src/subscription_filter.rs +++ b/protocols/gossipsub/src/subscription_filter.rs @@ -222,7 +222,7 @@ mod test { let t1 = TopicHash::from_raw("t1"); let t2 = TopicHash::from_raw("t2"); - let old = BTreeSet::from_iter(vec![t1.clone()].into_iter()); + let old = BTreeSet::from_iter(vec![t1.clone()]); let subscriptions = vec![ Subscription { action: Unsubscribe, diff --git a/protocols/identify/Cargo.toml b/protocols/identify/Cargo.toml index aa9587a0d36..8fc9339c7d0 100644 --- a/protocols/identify/Cargo.toml +++ b/protocols/identify/Cargo.toml @@ -18,7 +18,7 @@ libp2p-core = { workspace = true } libp2p-swarm = { workspace = true } libp2p-identity = { workspace = true } log = "0.4.19" -lru = "0.10.1" +lru = "0.11.0" quick-protobuf-codec = { workspace = true } quick-protobuf = "0.8" smallvec = "1.11.0" diff --git a/protocols/perf/Cargo.toml b/protocols/perf/Cargo.toml index 6f5903e7635..5374c68ac9a 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.11", features = ["derive"] } +clap = { version = "4.3.12", features = ["derive"] } env_logger = "0.10.0" futures = "0.3.28" instant = "0.1.12" diff --git a/protocols/relay/CHANGELOG.md b/protocols/relay/CHANGELOG.md index 8ca61f8993e..1f8d57058bd 100644 --- a/protocols/relay/CHANGELOG.md +++ b/protocols/relay/CHANGELOG.md @@ -1,3 +1,10 @@ +## 0.16.1 - unreleased + +- Add functions to access data within `Limit`. + See [PR 4162]. + +[PR 4162]: https://github.com/libp2p/rust-libp2p/pull/4162 + ## 0.16.0 - Raise MSRV to 1.65. diff --git a/protocols/relay/Cargo.toml b/protocols/relay/Cargo.toml index daba876d021..7830dcddb39 100644 --- a/protocols/relay/Cargo.toml +++ b/protocols/relay/Cargo.toml @@ -3,7 +3,7 @@ name = "libp2p-relay" edition = "2021" rust-version = { workspace = true } description = "Communications relaying for libp2p" -version = "0.16.0" +version = "0.16.1" authors = ["Parity Technologies ", "Max Inden "] license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" diff --git a/protocols/relay/src/protocol.rs b/protocols/relay/src/protocol.rs index 4376f64cc0b..f9b1e1ac0d1 100644 --- a/protocols/relay/src/protocol.rs +++ b/protocols/relay/src/protocol.rs @@ -39,6 +39,16 @@ pub struct Limit { data_in_bytes: Option, } +impl Limit { + pub fn duration(&self) -> Option { + self.duration + } + + pub fn data_in_bytes(&self) -> Option { + self.data_in_bytes + } +} + impl From for Limit { fn from(limit: proto::Limit) -> Self { Limit { diff --git a/protocols/request-response/CHANGELOG.md b/protocols/request-response/CHANGELOG.md index 203fb3aeea6..292cb812103 100644 --- a/protocols/request-response/CHANGELOG.md +++ b/protocols/request-response/CHANGELOG.md @@ -1,4 +1,11 @@ -## 0.25.0 +## 0.25.1 - unreleased + +- Replace unmaintained `serde_cbor` dependency with `cbor4ii`. + See [PR 4187]. + +[PR 4187]: https://github.com/libp2p/rust-libp2p/pull/4187 + +## 0.25.0 - Add `request_response::json::Behaviour` and `request_response::cbor::Behaviour` building on top of the `serde` traits. To conveniently construct these, we remove the `Codec` parameter from `Behaviour::new` and add `Behaviour::with_codec`. diff --git a/protocols/request-response/Cargo.toml b/protocols/request-response/Cargo.toml index 47e6c9e5fc6..ddb87316f86 100644 --- a/protocols/request-response/Cargo.toml +++ b/protocols/request-response/Cargo.toml @@ -3,7 +3,7 @@ name = "libp2p-request-response" edition = "2021" rust-version = { workspace = true } description = "Generic Request/Response Protocols" -version = "0.25.0" +version = "0.25.1" authors = ["Parity Technologies "] license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" @@ -12,6 +12,7 @@ categories = ["network-programming", "asynchronous"] [dependencies] async-trait = "0.1" +cbor4ii = { version = "0.3.1", features = ["serde1", "use_std"], optional = true } futures = "0.3.28" instant = "0.1.12" libp2p-core = { workspace = true } @@ -20,14 +21,13 @@ libp2p-identity = { workspace = true } rand = "0.8" serde = { version = "1.0", optional = true} serde_json = { version = "1.0.100", optional = true } -serde_cbor = { version = "0.11.2", optional = true } smallvec = "1.11.0" void = "1.0.2" log = "0.4.19" [features] json = ["dep:serde", "dep:serde_json", "libp2p-swarm/macros"] -cbor = ["dep:serde", "dep:serde_cbor", "libp2p-swarm/macros"] +cbor = ["dep:serde", "dep:cbor4ii", "libp2p-swarm/macros"] [dev-dependencies] async-std = { version = "1.6.2", features = ["attributes"] } diff --git a/protocols/request-response/src/cbor.rs b/protocols/request-response/src/cbor.rs index b7c520c72b9..ff56aa52ddf 100644 --- a/protocols/request-response/src/cbor.rs +++ b/protocols/request-response/src/cbor.rs @@ -18,7 +18,8 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -/// A request-response behaviour using [`serde_cbor`] for serializing and deserializing the messages. +/// A request-response behaviour using [`cbor4ii::serde`] for serializing and +/// deserializing the messages. /// /// # Example /// @@ -44,11 +45,12 @@ pub type Behaviour = crate::Behaviour>; mod codec { use async_trait::async_trait; + use cbor4ii::core::error::DecodeError; use futures::prelude::*; use futures::{AsyncRead, AsyncWrite}; use libp2p_swarm::StreamProtocol; use serde::{de::DeserializeOwned, Serialize}; - use std::{io, marker::PhantomData}; + use std::{collections::TryReserveError, convert::Infallible, io, marker::PhantomData}; /// Max request size in bytes const REQUEST_SIZE_MAXIMUM: u64 = 1024 * 1024; @@ -91,7 +93,7 @@ mod codec { io.take(REQUEST_SIZE_MAXIMUM).read_to_end(&mut vec).await?; - serde_cbor::from_slice(vec.as_slice()).map_err(into_io_error) + cbor4ii::serde::from_slice(vec.as_slice()).map_err(decode_into_io_error) } async fn read_response(&mut self, _: &Self::Protocol, io: &mut T) -> io::Result @@ -102,7 +104,7 @@ mod codec { io.take(RESPONSE_SIZE_MAXIMUM).read_to_end(&mut vec).await?; - serde_cbor::from_slice(vec.as_slice()).map_err(into_io_error) + cbor4ii::serde::from_slice(vec.as_slice()).map_err(decode_into_io_error) } async fn write_request( @@ -114,7 +116,8 @@ mod codec { where T: AsyncWrite + Unpin + Send, { - let data: Vec = serde_cbor::to_vec(&req).map_err(into_io_error)?; + let data: Vec = + cbor4ii::serde::to_vec(Vec::new(), &req).map_err(encode_into_io_error)?; io.write_all(data.as_ref()).await?; @@ -130,7 +133,8 @@ mod codec { where T: AsyncWrite + Unpin + Send, { - let data: Vec = serde_cbor::to_vec(&resp).map_err(into_io_error).unwrap(); + let data: Vec = + cbor4ii::serde::to_vec(Vec::new(), &resp).map_err(encode_into_io_error)?; io.write_all(data.as_ref()).await?; @@ -138,15 +142,25 @@ mod codec { } } - fn into_io_error(err: serde_cbor::Error) -> io::Error { - if err.is_syntax() || err.is_data() { - return io::Error::new(io::ErrorKind::InvalidData, err); - } - - if err.is_eof() { - return io::Error::new(io::ErrorKind::UnexpectedEof, err); + fn decode_into_io_error(err: cbor4ii::serde::DecodeError) -> io::Error { + match err { + cbor4ii::serde::DecodeError::Core(DecodeError::Read(e)) => { + io::Error::new(io::ErrorKind::Other, e) + } + cbor4ii::serde::DecodeError::Core(e @ DecodeError::Unsupported { .. }) => { + io::Error::new(io::ErrorKind::Unsupported, e) + } + cbor4ii::serde::DecodeError::Core(e @ DecodeError::Eof { .. }) => { + io::Error::new(io::ErrorKind::UnexpectedEof, e) + } + cbor4ii::serde::DecodeError::Core(e) => io::Error::new(io::ErrorKind::InvalidData, e), + cbor4ii::serde::DecodeError::Custom(e) => { + io::Error::new(io::ErrorKind::Other, e.to_string()) + } } + } + fn encode_into_io_error(err: cbor4ii::serde::EncodeError) -> io::Error { io::Error::new(io::ErrorKind::Other, err) } } diff --git a/swarm-derive/Cargo.toml b/swarm-derive/Cargo.toml index 4346aafe089..87c3a2fec4a 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.25", default-features = false, features = ["clone-impls", "derive", "parsing", "printing", "proc-macro"] } +syn = { version = "2.0.27", default-features = false, features = ["clone-impls", "derive", "parsing", "printing", "proc-macro"] } proc-macro-warning = "0.4.0" proc-macro2 = "1.0" diff --git a/transports/dns/src/lib.rs b/transports/dns/src/lib.rs index c39b9ad05ec..771c7dbc94a 100644 --- a/transports/dns/src/lib.rs +++ b/transports/dns/src/lib.rs @@ -129,7 +129,10 @@ where } #[cfg(feature = "async-std")] -impl DnsConfig { +impl DnsConfig +where + T: Send, +{ /// Creates a new [`DnsConfig`] from the OS's DNS configuration and defaults. pub async fn system(inner: T) -> Result, io::Error> { let (cfg, opts) = system_conf::read_system_conf()?; @@ -150,7 +153,10 @@ impl DnsConfig { } #[cfg(feature = "tokio")] -impl TokioDnsConfig { +impl TokioDnsConfig +where + T: Send, +{ /// Creates a new [`TokioDnsConfig`] from the OS's DNS configuration and defaults. pub fn system(inner: T) -> Result, io::Error> { let (cfg, opts) = system_conf::read_system_conf()?; diff --git a/transports/noise/Cargo.toml b/transports/noise/Cargo.toml index 484d9a3773b..355858e82fe 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.7" static_assertions = "1" -thiserror = "1.0.40" +thiserror = "1.0.43" x25519-dalek = "1.1.0" zeroize = "1" diff --git a/transports/noise/tests/webtransport_certhashes.rs b/transports/noise/tests/webtransport_certhashes.rs index 41341fe8655..95ce0bf58db 100644 --- a/transports/noise/tests/webtransport_certhashes.rs +++ b/transports/noise/tests/webtransport_certhashes.rs @@ -40,9 +40,10 @@ fn webtransport_server_empty_certhashes() { // Invalid case, because a MITM attacker may strip certificates of the server. let Err(noise::Error::UnknownWebTransportCerthashes(expected, received)) = - handshake_with_certhashes(vec![certhash1, certhash2], vec![]) else { - panic!("unexpected result"); - }; + handshake_with_certhashes(vec![certhash1, certhash2], vec![]) + else { + panic!("unexpected result"); + }; assert_eq!(expected, HashSet::from([certhash1, certhash2])); assert_eq!(received, HashSet::new()); @@ -68,9 +69,10 @@ fn webtransport_server_uninit_certhashes() { // Invalid case, because a MITM attacker may strip certificates of the server. let Err(noise::Error::UnknownWebTransportCerthashes(expected, received)) = - handshake_with_certhashes(vec![certhash1, certhash2], None) else { - panic!("unexpected result"); - }; + handshake_with_certhashes(vec![certhash1, certhash2], None) + else { + panic!("unexpected result"); + }; assert_eq!(expected, HashSet::from([certhash1, certhash2])); assert_eq!(received, HashSet::new()); @@ -81,9 +83,10 @@ fn webtransport_different_server_certhashes() { let (certhash1, certhash2, certhash3) = certhashes(); let Err(noise::Error::UnknownWebTransportCerthashes(expected, received)) = - handshake_with_certhashes(vec![certhash1, certhash3], vec![certhash1, certhash2]) else { - panic!("unexpected result"); - }; + handshake_with_certhashes(vec![certhash1, certhash3], vec![certhash1, certhash2]) + else { + panic!("unexpected result"); + }; assert_eq!(expected, HashSet::from([certhash1, certhash3])); assert_eq!(received, HashSet::from([certhash1, certhash2])); @@ -94,9 +97,10 @@ fn webtransport_superset_of_certhashes() { let (certhash1, certhash2, _) = certhashes(); let Err(noise::Error::UnknownWebTransportCerthashes(expected, received)) = - handshake_with_certhashes(vec![certhash1, certhash2], vec![certhash1]) else { - panic!("unexpected result"); - }; + handshake_with_certhashes(vec![certhash1, certhash2], vec![certhash1]) + else { + panic!("unexpected result"); + }; assert_eq!(expected, HashSet::from([certhash1, certhash2])); assert_eq!(received, HashSet::from([certhash1])); diff --git a/transports/quic/Cargo.toml b/transports/quic/Cargo.toml index 6c531ec30bd..338fa8147b7 100644 --- a/transports/quic/Cargo.toml +++ b/transports/quic/Cargo.toml @@ -22,7 +22,7 @@ parking_lot = "0.12.0" quinn-proto = { 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.40" +thiserror = "1.0.43" tokio = { version = "1.29.1", default-features = false, features = ["net", "rt", "time"], optional = true } [features] diff --git a/transports/quic/src/transport.rs b/transports/quic/src/transport.rs index afdaf86cdf4..84f9e479ee8 100644 --- a/transports/quic/src/transport.rs +++ b/transports/quic/src/transport.rs @@ -747,7 +747,7 @@ fn is_quic_addr(addr: &Multiaddr, support_draft_29: bool) -> bool { matches!(third, QuicV1) } && matches!(fourth, Some(P2p(_)) | None) - && matches!(fifth, None) + && fifth.is_none() } /// Turns an IP address and port into the corresponding QUIC multiaddr. diff --git a/transports/tls/Cargo.toml b/transports/tls/Cargo.toml index c7a03afcedf..c793201f395 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.10.0" ring = "0.16.20" -thiserror = "1.0.40" +thiserror = "1.0.43" webpki = { version = "0.22.0", features = ["std"] } x509-parser = "0.15.0" yasna = "0.5.2" diff --git a/transports/uds/src/lib.rs b/transports/uds/src/lib.rs index 78a6b0f05b8..3cd71552d18 100644 --- a/transports/uds/src/lib.rs +++ b/transports/uds/src/lib.rs @@ -97,6 +97,7 @@ macro_rules! codegen { addr: Multiaddr, ) -> Result<(), TransportError> { if let Ok(path) = multiaddr_to_path(&addr) { + #[allow(clippy::redundant_closure_call)] let listener = $build_listener(path) .map_err(Err) .map_ok(move |listener| { diff --git a/transports/websocket/src/framed.rs b/transports/websocket/src/framed.rs index b5a0b1b98f1..fc3f6514f12 100644 --- a/transports/websocket/src/framed.rs +++ b/transports/websocket/src/framed.rs @@ -57,7 +57,10 @@ pub struct WsConfig { listener_protos: HashMap>, } -impl WsConfig { +impl WsConfig +where + T: Send, +{ /// Create a new websocket transport based on another transport. pub fn new(transport: T) -> Self { WsConfig { diff --git a/transports/webtransport-websys/Cargo.toml b/transports/webtransport-websys/Cargo.toml index db554bc1982..ba6baa2efe0 100644 --- a/transports/webtransport-websys/Cargo.toml +++ b/transports/webtransport-websys/Cargo.toml @@ -23,7 +23,7 @@ log = "0.4.19" multiaddr = { workspace = true } multihash = { workspace = true } send_wrapper = { version = "0.6.0", features = ["futures"] } -thiserror = "1.0.40" +thiserror = "1.0.43" wasm-bindgen = "0.2.87" wasm-bindgen-futures = "0.4.37" web-sys = { version = "0.3.64", features = [