-
Notifications
You must be signed in to change notification settings - Fork 784
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
Implement gossipsub IDONTWANT #5422
Conversation
b25f0e7
to
64364d1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work. Just a few comments
93626cd
to
66658a4
Compare
66658a4
to
ae0b6b2
Compare
that returns true if peer speaks any version of gossipsub
…impl-gossipsub-idontwant
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed that IDONTWANT control messages are not decoded while I was testing this. I think we should add some code here to decode IDONTWANT:
lighthouse/beacon_node/lighthouse_network/gossipsub/src/protocol.rs
Lines 419 to 491 in ae0b6b2
if let Some(rpc_control) = rpc.control { | |
// Collect the gossipsub control messages | |
let ihave_msgs: Vec<ControlAction> = rpc_control | |
.ihave | |
.into_iter() | |
.map(|ihave| { | |
ControlAction::IHave(IHave { | |
topic_hash: TopicHash::from_raw(ihave.topic_id.unwrap_or_default()), | |
message_ids: ihave | |
.message_ids | |
.into_iter() | |
.map(MessageId::from) | |
.collect::<Vec<_>>(), | |
}) | |
}) | |
.collect(); | |
let iwant_msgs: Vec<ControlAction> = rpc_control | |
.iwant | |
.into_iter() | |
.map(|iwant| { | |
ControlAction::IWant(IWant { | |
message_ids: iwant | |
.message_ids | |
.into_iter() | |
.map(MessageId::from) | |
.collect::<Vec<_>>(), | |
}) | |
}) | |
.collect(); | |
let graft_msgs: Vec<ControlAction> = rpc_control | |
.graft | |
.into_iter() | |
.map(|graft| { | |
ControlAction::Graft(Graft { | |
topic_hash: TopicHash::from_raw(graft.topic_id.unwrap_or_default()), | |
}) | |
}) | |
.collect(); | |
let mut prune_msgs = Vec::new(); | |
for prune in rpc_control.prune { | |
// filter out invalid peers | |
let peers = prune | |
.peers | |
.into_iter() | |
.filter_map(|info| { | |
info.peer_id | |
.as_ref() | |
.and_then(|id| PeerId::from_bytes(id).ok()) | |
.map(|peer_id| | |
//TODO signedPeerRecord, see https://github.com/libp2p/specs/pull/217 | |
PeerInfo { | |
peer_id: Some(peer_id), | |
}) | |
}) | |
.collect::<Vec<PeerInfo>>(); | |
let topic_hash = TopicHash::from_raw(prune.topic_id.unwrap_or_default()); | |
prune_msgs.push(ControlAction::Prune(Prune { | |
topic_hash, | |
peers, | |
backoff: prune.backoff, | |
})); | |
} | |
control_msgs.extend(ihave_msgs); | |
control_msgs.extend(iwant_msgs); | |
control_msgs.extend(graft_msgs); | |
control_msgs.extend(prune_msgs); | |
} |
@jxs @AgeManning I have submitted a PR to address the issue I previously mentioned. Could you please review it? |
Yeah looks like you're right. We probably should have a test for this. I'll add the test and double check this corrects it. I'll push your changes to this branch |
thanks @ackintosh! |
@AgeManning @jxs I submitted a PR to address the failing tests. Could you please review it when you have a chance? 🙏 |
…sh-fix-test Fix `test_ignore_too_many_messages_in_ihave` test
…into impl-gossipsub-idontwant
…into impl-gossipsub-idontwant
@Mergifyio queue |
✅ The pull request has been merged automaticallyThe pull request has been merged automatically at d46ac6c |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets goo!
@Mergifyio refresh |
✅ Pull request refreshed |
This PR implements gossipsub 1.2 beta bringing changes over from lighthouse ref PR: sigp/lighthouse#5422 Please include any relevant issues in here, for example: libp2p/specs#548 Pull-Request: #5697.
This PR implements gossipsub 1.2 beta bringing changes over from lighthouse ref PR: sigp/lighthouse#5422 Please include any relevant issues in here, for example: libp2p/specs#548 Pull-Request: libp2p#5697.
Issue Addressed
implement IDONTWANT message sending and addressing when forwarding.
Follows libp2p/specs#548
Should be reviewed after #5401 is merged