Skip to content
This repository has been archived by the owner on Oct 23, 2022. It is now read-only.

Update libp2p to v0.43.0 #499

Merged
merged 27 commits into from
Apr 1, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
f601b8d
fix: update libp2p and renamed the changed types
rand0m-cloud Mar 18, 2022
c3a48c9
fix: updated libp2p in the bitswap crate
rand0m-cloud Mar 18, 2022
4e5ff4d
more libp2p updating
rand0m-cloud Mar 18, 2022
918d4d8
more updating of types
rand0m-cloud Mar 18, 2022
c1a5bba
some updates to pubsub
rand0m-cloud Mar 18, 2022
7e9da72
fix the pubsub network behaviour action type
rand0m-cloud Mar 18, 2022
085be77
replaced todo placeholders
rand0m-cloud Mar 18, 2022
e4002d6
re-add connection closed and established
rand0m-cloud Mar 18, 2022
a996922
added change to changelog
rand0m-cloud Mar 18, 2022
bdf977c
enable event_process for BehaviourEvent
rand0m-cloud Mar 18, 2022
93b31b3
chore: clean up type signature
rand0m-cloud Mar 18, 2022
25c8d58
fix: removed unneeded BehaviourEvent struct
rand0m-cloud Mar 18, 2022
3b59193
temp fix: changed field order to workaround bug in libp2p
rand0m-cloud Mar 18, 2022
31262b5
chore: more updating to libp2p
rand0m-cloud Mar 18, 2022
6c6fc3d
fix: update libp2p and renamed the changed types
rand0m-cloud Mar 18, 2022
77291ee
fix(swarm-test): add biased to tokio::select for non-random behavior
rand0m-cloud Mar 18, 2022
888e6f1
wip: re-add code fragment to handle dial failure
rand0m-cloud Mar 18, 2022
72ff95d
fix(swarm): corrected dial failure logic
rand0m-cloud Mar 21, 2022
1cee67d
fix: corrected faulty Vec::retain logic and updated WrongPeerId test
rand0m-cloud Mar 21, 2022
897c16f
fix: apply review suggestions and fix clippy lints
rand0m-cloud Mar 24, 2022
d4d3def
fix(pubsub): tell Floodsub about the peers we want to hear from
rand0m-cloud Mar 25, 2022
87a4114
ci(win): use windows-2019 image
koivunej Mar 30, 2022
82453e5
fix(build): stop building while writing an error
koivunej Mar 30, 2022
277954b
test(pubsub): disjoint topics as new test case
koivunej Apr 1, 2022
50ad10f
test(pubsub): simplify, comment
koivunej Apr 1, 2022
081a598
test(conf): ignore pubsub tests on windows for now
koivunej Apr 1, 2022
bf7a807
doc(p2p): add fixme for possible issue
koivunej Apr 1, 2022
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
Prev Previous commit
Next Next commit
replaced todo placeholders
  • Loading branch information
rand0m-cloud authored and koivunej committed Apr 1, 2022
commit 085be771fe3061c1d732cddd444efcfb1766758c
3 changes: 2 additions & 1 deletion bitswap/src/behaviour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,12 @@ impl Bitswap {
/// Called from Kademlia behaviour.
pub fn connect(&mut self, peer_id: PeerId) {
if self.target_peers.insert(peer_id) {
let handler = self.new_handler();
self.events.push_back(NetworkBehaviourAction::Dial {
opts: DialOpts::peer_id(peer_id)
.condition(PeerCondition::Disconnected)
.build(),
handler: todo!(),
handler,
});
}
}
Expand Down
3 changes: 1 addition & 2 deletions src/p2p/pubsub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ use libp2p::core::{
};
use libp2p::floodsub::{Floodsub, FloodsubConfig, FloodsubEvent, FloodsubMessage, Topic};
use libp2p::swarm::{
ConnectionHandler, DialError, IntoConnectionHandler, NetworkBehaviour, NetworkBehaviourAction,
PollParameters,
ConnectionHandler, DialError, NetworkBehaviour, NetworkBehaviourAction, PollParameters,
};

/// Currently a thin wrapper around Floodsub, perhaps supporting both Gossipsub and Floodsub later.
Expand Down
6 changes: 4 additions & 2 deletions src/p2p/swarm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,14 @@ impl SwarmApi {
.connect_registry
.create_subscription(addr.clone().into(), None);

let handler = self.new_handler();
self.events.push_back(NetworkBehaviourAction::Dial {
// rationale: this is sort of explicit command, perhaps the old address is no longer
// valid. Always would be even better but it's bugged at the moment.
opts: DialOpts::peer_id(addr.peer_id)
.condition(PeerCondition::NotDialing)
.build(),
handler: todo!(),
handler,
});

self.pending_addresses
Expand Down Expand Up @@ -308,11 +309,12 @@ impl NetworkBehaviour for SwarmApi {
if self.pending_addresses.contains_key(&peer_id) {
// it is possible that these addresses have not been tried yet; they will be asked
// for soon.
let handler = self.new_handler();
self.events.push_back(swarm::NetworkBehaviourAction::Dial {
Copy link
Contributor Author

@rand0m-cloud rand0m-cloud Mar 18, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like this needs to be removed? I'm not sure how to adapt the behavior because inject_dial_failure only tells us when a connection failed to dial.

I think this current block was made for attempting another connection when one fails.

Copy link
Collaborator

@koivunej koivunej Mar 21, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All right ... Looking at the networkbehaviour, I think this is how it used to work:

  1. dial event is given to swarm
  2. swarm collects all of the known addresses with NetworkBehaviour::addresses_of_peer, dials them somehow
  3. for each of the dials, we used to get a signal that this multiaddr failed and we would signal that future as failure
  4. there used to be another trait method for having exhausted the addresses, when we'd know to launch a new dial if we'd still have addresses

While writing this @mxinden replied. Oki yeah it would appear the failures have now moved within the dialerror, which I did not expect, AND there is only one "notification" for all of the attempts.

However I think the idea with the original impl was that since there would be one gathering of addresses for the peer (NetworkBehaviour::addresses_of_peer) per dial events (caused either by "swarm_api" or by any other place) it would be possible to add new addresses during a dial attempt, and those would be noticed at (4) in the above ordered list, and thus get dialed afterwards.

I now realize that this all should had been in the swarm api implementation as comments, but I guess I was expecting the datastructures and network behaviour api to make this "apparent" and did not account for possible future changes in the network behaviour api.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think for the next steps would be to gather the failed addresses from the error (if found), then continue dialing to the remaining addresses, if any.

opts: DialOpts::peer_id(peer_id)
.condition(PeerCondition::NotDialing)
.build(),
handler: todo!(),
handler,
});
}

Expand Down