diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 44c54b6..d6b0359 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -43,7 +43,44 @@ jobs: cargo- - name: Run tests - run: cargo test + run: cargo test --locked + + + test-minimal-versions: + runs-on: ubuntu-latest + name: test (minimal versions) + steps: + - uses: actions/checkout@v1 + + - name: Install toolchain + uses: dtolnay/rust-toolchain@nightly + + - name: Generate Cargo.lock with minimal versions + run: | + rm Cargo.lock + cargo +nightly update -Zminimal-versions + + # multistream-select 0.13 depends on log 0.4, however it can only + # compile with log 0.4.4 and above. When multistream-select 0.14 + # is released, this will not be needed. + cargo update -p log --precise 0.4.4 + + - name: Set up cargo cache + uses: actions/cache@v3 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: cargo-${{ hashFiles('**/Cargo.lock') }} + restore-keys: + cargo-${{ hashFiles('**/Cargo.lock') }} + cargo- + + - name: Run tests + run: cargo test --locked unused-deps: @@ -62,6 +99,6 @@ jobs: tool: cargo-udeps@0.1.43 - name: Check for unused dependencies - run: cargo +nightly udeps --all-features --all-targets + run: cargo +nightly udeps --all-targets env: RUSTFLAGS: -D warnings diff --git a/Cargo.lock b/Cargo.lock index 469b95b..cb4f077 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -104,8 +104,9 @@ dependencies = [ "futures", "futures-timer", "hex", - "libp2p", - "multihash", + "libp2p-core", + "libp2p-identity", + "libp2p-swarm", "multihash-codetable", "quick-protobuf", "smallvec", @@ -559,9 +560,9 @@ checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" [[package]] name = "hermit-abi" -version = "0.3.3" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d77f7ec81a6d05a3abb01ab6eb7590f6083d08449fe5a1c8b1e620283546ccb7" +checksum = "5d3d0e0f38255e7fa3cf31335b3a56f05febd18025f4db5ef7a0cfb4f8da651f" [[package]] name = "hex" @@ -640,53 +641,6 @@ version = "0.2.152" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "13e3bf6590cbc649f4d1a3eefc9d5d6eb746f5200ffb04e5e142700b8faa56e7" -[[package]] -name = "libp2p" -version = "0.53.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "681fb3f183edfbedd7a57d32ebe5dcdc0b9f94061185acf3c30249349cc6fc99" -dependencies = [ - "bytes", - "either", - "futures", - "futures-timer", - "getrandom", - "instant", - "libp2p-allow-block-list", - "libp2p-connection-limits", - "libp2p-core", - "libp2p-identity", - "libp2p-swarm", - "multiaddr", - "pin-project", - "rw-stream-sink", - "thiserror", -] - -[[package]] -name = "libp2p-allow-block-list" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "107b238b794cb83ab53b74ad5dcf7cca3200899b72fe662840cfb52f5b0a32e6" -dependencies = [ - "libp2p-core", - "libp2p-identity", - "libp2p-swarm", - "void", -] - -[[package]] -name = "libp2p-connection-limits" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7cd50a78ccfada14de94cbacd3ce4b0138157f376870f13d3a8422cd075b4fd" -dependencies = [ - "libp2p-core", - "libp2p-identity", - "libp2p-swarm", - "void", -] - [[package]] name = "libp2p-core" version = "0.41.2" @@ -939,18 +893,18 @@ checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "pin-project" -version = "1.1.3" +version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fda4ed1c6c173e3fc7a83629421152e01d7b1f9b7f65fb301e490e8cfc656422" +checksum = "0302c4a0442c456bd56f841aee5c3bfd17967563f6fadc9ceb9f9c23cf3807e0" dependencies = [ "pin-project-internal", ] [[package]] name = "pin-project-internal" -version = "1.1.3" +version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4359fd9c9171ec6e8c62926d6faaf553a8dc3f64e1507e76da7911b4f6a04405" +checksum = "266c042b60c9c76b8d53061e52b2e0d1116abc57cefc8c5cd671619a56ac3690" dependencies = [ "proc-macro2", "quote", @@ -1027,9 +981,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.76" +version = "1.0.78" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95fc56cda0b5c3325f5fbbd7ff9fda9e02bb00bb3dac51252d2f1bfa1cb8cc8c" +checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae" dependencies = [ "unicode-ident", ] @@ -1216,9 +1170,9 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.12.0" +version = "1.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2593d31f82ead8df961d8bd23a64c2ccf2eb5dd34b0a34bfb4dd54011c72009e" +checksum = "e6ecd384b10a64542d77071bd64bd7b231f4ed5940fba55e98c3de13824cf3d7" [[package]] name = "spki" @@ -1402,9 +1356,9 @@ checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" [[package]] name = "unicode-bidi" -version = "0.3.14" +version = "0.3.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f2528f27a9eb2b21e69c95319b30bd0efd85d09c379741b0f78ea1d86be2416" +checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" [[package]] name = "unicode-ident" diff --git a/Cargo.toml b/Cargo.toml index 41e50ad..f05fe6a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,8 +13,9 @@ cid = "0.11.0" fnv = "1.0.7" futures = "0.3.30" futures-timer = "3.0.2" -libp2p = "0.53.2" -multihash = "0.19.1" +libp2p-core = "0.41.2" +libp2p-identity = "0.2.8" +libp2p-swarm = "0.44.1" multihash-codetable = "0.1.1" quick-protobuf = "0.8.1" smallvec = "1.12.0" @@ -24,6 +25,7 @@ void = "1.0.2" [dev-dependencies] hex = "0.4.3" +libp2p-identity = { version = "0.2.8", features = ["rand"] } multihash-codetable = { version = "0.1.1", features = ["digest", "sha2"] } tokio = { version = "1.35.1", features = ["rt", "macros", "time"] } diff --git a/src/client.rs b/src/client.rs index 9695ab1..aa78786 100644 --- a/src/client.rs +++ b/src/client.rs @@ -13,12 +13,10 @@ use futures::stream::FuturesUnordered; use futures::task::AtomicWaker; use futures::{FutureExt, SinkExt, StreamExt}; use futures_timer::Delay; -use libp2p::swarm::NotifyHandler; -use libp2p::PeerId; -use libp2p::{ - core::upgrade::ReadyUpgrade, - swarm::{ConnectionHandlerEvent, SubstreamProtocol, ToSwarm}, - StreamProtocol, +use libp2p_core::upgrade::ReadyUpgrade; +use libp2p_identity::PeerId; +use libp2p_swarm::{ + ConnectionHandlerEvent, NotifyHandler, StreamProtocol, SubstreamProtocol, ToSwarm, }; use smallvec::SmallVec; use std::sync::Mutex; @@ -415,7 +413,7 @@ where pub(crate) struct ClientConnectionHandler { protocol: StreamProtocol, stream_requested: bool, - sink: Option>, + sink: Option>, /// Wantlist to be send wantlist: Option, /// Sending state of peer. @@ -431,7 +429,7 @@ impl ClientConnectionHandler { self.stream_requested } - pub(crate) fn set_stream(&mut self, stream: libp2p::Stream) { + pub(crate) fn set_stream(&mut self, stream: libp2p_swarm::Stream) { // Convert `AsyncWrite` stream to `Sink` self.sink = Some(FramedWrite::new(stream, Codec)); self.stream_requested = false; diff --git a/src/lib.rs b/src/lib.rs index 5fc3aa2..614cb89 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -8,15 +8,12 @@ use blockstore::{Blockstore, BlockstoreError}; use cid::CidGeneric; use client::SendingState; use futures::{stream::SelectAll, StreamExt}; -use libp2p::swarm::ConnectionClosed; -use libp2p::{ - core::{upgrade::ReadyUpgrade, Endpoint}, - swarm::{ - handler::ConnectionEvent, ConnectionDenied, ConnectionHandler, ConnectionHandlerEvent, - ConnectionId, FromSwarm, NetworkBehaviour, StreamProtocol, SubstreamProtocol, - THandlerInEvent, THandlerOutEvent, ToSwarm, - }, - Multiaddr, PeerId, +use libp2p_core::{multiaddr::Multiaddr, upgrade::ReadyUpgrade, Endpoint}; +use libp2p_identity::PeerId; +use libp2p_swarm::{ + handler::ConnectionEvent, ConnectionClosed, ConnectionDenied, ConnectionHandler, + ConnectionHandlerEvent, ConnectionId, FromSwarm, NetworkBehaviour, StreamProtocol, + SubstreamProtocol, THandlerInEvent, THandlerOutEvent, ToSwarm, }; mod builder; @@ -257,7 +254,7 @@ impl ConnectionHandler /// Wrapper that converts `Option>` to `Option`. /// /// By returning `None` on error, we instruct `SelectAll` to drop the stream. -struct StreamFramedRead(FramedRead); +struct StreamFramedRead(FramedRead); impl fmt::Debug for StreamFramedRead { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { diff --git a/src/multihasher.rs b/src/multihasher.rs index ce643a6..26b7f14 100644 --- a/src/multihasher.rs +++ b/src/multihasher.rs @@ -1,7 +1,7 @@ use std::collections::VecDeque; use std::fmt; -use multihash::Multihash; +use libp2p_core::multihash::Multihash; use multihash_codetable::MultihashDigest; use crate::utils::convert_multihash; diff --git a/src/utils.rs b/src/utils.rs index a23eb3c..f736cb8 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -1,6 +1,6 @@ use cid::CidGeneric; -use libp2p::StreamProtocol; -use multihash::Multihash; +use libp2p_core::multihash::Multihash; +use libp2p_swarm::StreamProtocol; use crate::{BitswapError, Result};