Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
578f972
Move the legacy protocol handshake to the legacy substream
tomaka May 5, 2020
0e7d51f
Merge remote-tracking branch 'upstream/master' into move-legacy-hands…
tomaka May 7, 2020
4b5e146
Merge remote-tracking branch 'upstream/master' into move-legacy-hands…
tomaka May 12, 2020
6b14a35
Merge remote-tracking branch 'upstream/master' into move-legacy-hands…
tomaka May 14, 2020
9ca434b
Fix tests
tomaka May 14, 2020
1971d2d
Remove line that wasn't supposed to be committed
tomaka May 14, 2020
b154b80
Merge remote-tracking branch 'upstream/master' into move-legacy-hands…
tomaka May 18, 2020
5d41c60
Remove hack
tomaka May 18, 2020
7f068c8
Merge remote-tracking branch 'upstream/master' into move-legacy-hands…
tomaka May 25, 2020
5795d6f
Rework how it's done
tomaka May 25, 2020
2653c0d
Some little changes
tomaka May 25, 2020
88c4da6
update_chain wasn't doing its thing
tomaka May 25, 2020
53cce8d
Merge remote-tracking branch 'upstream/master' into move-legacy-hands…
tomaka Jun 3, 2020
6c50854
Fix service tests not calling update_chain
tomaka Jun 3, 2020
5be320f
Merge remote-tracking branch 'upstream/master' into move-legacy-hands…
tomaka Jun 3, 2020
ecde0df
Merge branch 'fix-service-test-update-chain' into move-legacy-handshake
tomaka Jun 3, 2020
8a52b8e
Update client/network/src/protocol/generic_proto/behaviour.rs
tomaka Jun 9, 2020
b0fe448
Merge remote-tracking branch 'upstream/master' into move-legacy-hands…
tomaka Jun 12, 2020
2b892e6
[WIP]
tomaka Jun 15, 2020
3b89594
Merge remote-tracking branch 'upstream/master' into move-legacy-hands…
tomaka Jun 17, 2020
d4ddc96
Revert "[WIP]"
tomaka Jun 18, 2020
f83e529
Update client/network/src/protocol.rs
tomaka Jun 19, 2020
d16d620
Merge remote-tracking branch 'upstream/master' into move-legacy-hands…
tomaka Jun 22, 2020
a8b0301
Fix received message not being handshake
tomaka Jun 22, 2020
84e7852
Update client/network/src/protocol/generic_proto/behaviour.rs
tomaka Jun 23, 2020
ee09a83
Merge remote-tracking branch 'upstream/master' into move-legacy-hands…
tomaka Jun 29, 2020
a82fba7
Merge branch 'master' into move-legacy-handshake
tomaka Jun 30, 2020
bf644f5
Merge remote-tracking branch 'upstream/master' into move-legacy-hands…
tomaka Jul 6, 2020
78f4ca6
Merge remote-tracking branch 'upstream/master' into move-legacy-hands…
tomaka Jul 13, 2020
81eee50
Merge remote-tracking branch 'upstream/master' into move-legacy-hands…
tomaka Jul 14, 2020
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
Revert "[WIP]"
This reverts commit 2b892e6.
  • Loading branch information
tomaka committed Jun 18, 2020
commit d4ddc963f64294e8bd4cf6ce1f5fe8765012eaaf
34 changes: 10 additions & 24 deletions client/network/src/protocol/generic_proto/behaviour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -688,9 +688,7 @@ impl GenericProto {
self.events.push_back(NetworkBehaviourAction::NotifyHandler {
peer_id: occ_entry.key().clone(),
handler: NotifyHandler::All,
event: NotifsHandlerIn::Enable {
send_legacy_handshake: true,
},
event: NotifsHandlerIn::Enable,
});
*occ_entry.into_mut() = PeerState::Enabled { open };
},
Expand All @@ -709,9 +707,7 @@ impl GenericProto {
self.events.push_back(NetworkBehaviourAction::NotifyHandler {
peer_id: occ_entry.key().clone(),
handler: NotifyHandler::All,
event: NotifsHandlerIn::Enable {
send_legacy_handshake: true,
},
event: NotifsHandlerIn::Enable,
});
*occ_entry.into_mut() = PeerState::Enabled { open: SmallVec::new() };
},
Expand Down Expand Up @@ -831,9 +827,7 @@ impl GenericProto {
self.events.push_back(NetworkBehaviourAction::NotifyHandler {
peer_id: incoming.peer_id,
handler: NotifyHandler::All,
event: NotifsHandlerIn::Enable {
send_legacy_handshake: true,
},
event: NotifsHandlerIn::Enable,
});
*state = PeerState::Enabled { open: SmallVec::new() };
}
Expand Down Expand Up @@ -913,9 +907,7 @@ impl NetworkBehaviour for GenericProto {
self.events.push_back(NetworkBehaviourAction::NotifyHandler {
peer_id: peer_id.clone(),
handler: NotifyHandler::One(*conn),
event: NotifsHandlerIn::Enable {
send_legacy_handshake: true,
}
event: NotifsHandlerIn::Enable
});
}

Expand Down Expand Up @@ -975,9 +967,7 @@ impl NetworkBehaviour for GenericProto {
self.events.push_back(NetworkBehaviourAction::NotifyHandler {
peer_id: peer_id.clone(),
handler: NotifyHandler::One(*conn),
event: NotifsHandlerIn::Enable {
send_legacy_handshake: false,
}
event: NotifsHandlerIn::Enable
});
}

Expand Down Expand Up @@ -1419,15 +1409,11 @@ impl NetworkBehaviour for GenericProto {

PeerState::DisabledPendingEnable { timer, open, .. } if *timer == delay_id => {
debug!(target: "sub-libp2p", "Handler({:?}) <= Enable (ban expired)", peer_id);
for (index_in_open, open) in open.iter().enumerate() {
self.events.push_back(NetworkBehaviourAction::NotifyHandler {
peer_id: peer_id.clone(),
handler: NotifyHandler::One(*open),
event: NotifsHandlerIn::Enable {
send_legacy_handshake: index_in_open == 0,
},
});
}
self.events.push_back(NetworkBehaviourAction::NotifyHandler {
peer_id,
handler: NotifyHandler::All,
event: NotifsHandlerIn::Enable,
});
*peer_state = PeerState::Enabled { open: mem::replace(open, Default::default()) };
}

Expand Down
19 changes: 3 additions & 16 deletions client/network/src/protocol/generic_proto/handler/group.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,20 +148,7 @@ impl IntoProtocolsHandler for NotifsHandlerProto {
#[derive(Debug, Clone)]
pub enum NotifsHandlerIn {
/// The node should start using custom protocols.
Enable {
/// In the legacy protocol, the `Status` message (that serves as a handshake) is only ever
/// sent on the first substream that is open with a given peer. If a second substream with
/// that same peer is later opened (no matter whether it is on the same connection or a
/// different one), no `Status` message is sent.
///
/// This flag indicates whether or not this connection should send a `Status` message.
///
/// Note that this only concerns the `Status` message that our node sends out. Whatever
/// the value of this flag is, we should always propagate any `Status` sent by the remote,
/// and consider as successful the lack of `Status` message. If it the role of the upper
/// layers to properly enforce the uniqueness of the `Status` message sent by the remote.
send_legacy_handshake: bool,
},
Enable,

/// The node should stop using custom protocols.
Disable,
Expand Down Expand Up @@ -344,12 +331,12 @@ impl ProtocolsHandler for NotifsHandler {

fn inject_event(&mut self, message: NotifsHandlerIn) {
match message {
NotifsHandlerIn::Enable { send_legacy_handshake } => {
NotifsHandlerIn::Enable => {
if let EnabledState::Enabled = self.enabled {
debug!("enabling already-enabled handler");
}
self.enabled = EnabledState::Enabled;
self.legacy.inject_event(LegacyProtoHandlerIn::Enable { send_legacy_handshake });
self.legacy.inject_event(LegacyProtoHandlerIn::Enable);
for (handler, initial_message) in &mut self.out_handlers {
// We create `initial_message` on a separate line to be sure that the lock
// is released as soon as possible.
Expand Down
15 changes: 5 additions & 10 deletions client/network/src/protocol/generic_proto/handler/legacy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,10 +200,7 @@ enum ProtocolState {
#[derive(Debug)]
pub enum LegacyProtoHandlerIn {
/// The node should start using custom protocols.
Enable {
/// See the documentation of this flag in the parent module.
send_legacy_handshake: bool,
},
Enable,

/// The node should stop using custom protocols.
Disable,
Expand All @@ -222,9 +219,8 @@ pub enum LegacyProtoHandlerOut {
CustomProtocolOpen {
/// Version of the protocol that has been opened.
version: u8,
/// First message that has been sent to us.
/// This can be a "Status" message, or a non-"Status" message in case this is not the
/// first substream that's been opened, but this out of the concern of this code.
/// Handshake message that has been sent to us.
/// This is normally a "Status" message, but this out of the concern of this code.
received_handshake: Vec<u8>,
/// The connected endpoint.
endpoint: ConnectedPoint,
Expand Down Expand Up @@ -274,7 +270,7 @@ impl LegacyProtoHandler {
}

/// Enables the handler.
fn enable(&mut self, send_legacy_handshake: bool) {
fn enable(&mut self) {
self.state = match mem::replace(&mut self.state, ProtocolState::Poisoned) {
ProtocolState::Poisoned => {
error!(target: "sub-libp2p", "Handler with {:?} is in poisoned state",
Expand Down Expand Up @@ -564,8 +560,7 @@ impl ProtocolsHandler for LegacyProtoHandler {
fn inject_event(&mut self, message: LegacyProtoHandlerIn) {
match message {
LegacyProtoHandlerIn::Disable => self.disable(),
LegacyProtoHandlerIn::Enable { send_legacy_handshake } =>
self.enable(send_legacy_handshake),
LegacyProtoHandlerIn::Enable => self.enable(),
LegacyProtoHandlerIn::SendCustomMessage { message } =>
self.send_message(message),
}
Expand Down