Skip to content

Commit

Permalink
chore(deps): Split libp2p and add CI test for minimal versions
Browse files Browse the repository at this point in the history
  • Loading branch information
oblique committed Jan 26, 2024
1 parent e737dbe commit b1c0e82
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 86 deletions.
41 changes: 39 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -62,6 +99,6 @@ jobs:
tool: [email protected]

- name: Check for unused dependencies
run: cargo +nightly udeps --all-features --all-targets
run: cargo +nightly udeps --all-targets
env:
RUSTFLAGS: -D warnings
76 changes: 15 additions & 61 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"] }

Expand Down
14 changes: 6 additions & 8 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -415,7 +413,7 @@ where
pub(crate) struct ClientConnectionHandler<const S: usize> {
protocol: StreamProtocol,
stream_requested: bool,
sink: Option<FramedWrite<libp2p::Stream, Codec>>,
sink: Option<FramedWrite<libp2p_swarm::Stream, Codec>>,
/// Wantlist to be send
wantlist: Option<ProtoWantlist>,
/// Sending state of peer.
Expand All @@ -431,7 +429,7 @@ impl<const S: usize> ClientConnectionHandler<S> {
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;
Expand Down
17 changes: 7 additions & 10 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -257,7 +254,7 @@ impl<const MAX_MULTIHASH_SIZE: usize> ConnectionHandler
/// Wrapper that converts `Option<Result<Message>>` to `Option<Message>`.
///
/// By returning `None` on error, we instruct `SelectAll` to drop the stream.
struct StreamFramedRead(FramedRead<libp2p::Stream, Codec>);
struct StreamFramedRead(FramedRead<libp2p_swarm::Stream, Codec>);

impl fmt::Debug for StreamFramedRead {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
Expand Down
2 changes: 1 addition & 1 deletion src/multihasher.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/utils.rs
Original file line number Diff line number Diff line change
@@ -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};

Expand Down

0 comments on commit b1c0e82

Please sign in to comment.