Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(deps): Split libp2p and add CI test for minimal versions #18

Merged
merged 2 commits into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.

38 changes: 20 additions & 18 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,28 @@ license = "Apache-2.0"
description = "Implementation of bitswap protocol for libp2p"

[dependencies]
asynchronous-codec = "0.7.0"
blockstore = "0.1.1"
bytes = "1.5.0"
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"
multihash-codetable = "0.1.1"
quick-protobuf = "0.8.1"
smallvec = "1.12.0"
thiserror = "1.0.56"
unsigned-varint = "0.8.0"
void = "1.0.2"
asynchronous-codec = "0.7"
blockstore = "0.1"
bytes = "1"
cid = "0.11"
fnv = "1.0.5"
futures = "0.3"
futures-timer = "3"
libp2p-core = "0.41"
libp2p-identity = "0.2"
libp2p-swarm = "0.44"
multihash-codetable = "0.1"
quick-protobuf = "0.8"
smallvec = "1"
thiserror = "1"
unsigned-varint = "0.8"
void = "1"

[dev-dependencies]
hex = "0.4.3"
multihash-codetable = { version = "0.1.1", features = ["digest", "sha2"] }
tokio = { version = "1.35.1", features = ["rt", "macros", "time"] }
hex = "0.4"
libp2p-identity = { version = "0.2", features = ["rand"] }
multihash-codetable = { version = "0.1", features = ["digest", "sha2"] }
tokio = { version = "1", features = ["rt", "macros", "time"] }

[features]
wasm-bindgen = ["futures-timer/wasm-bindgen"]
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
Loading