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

Implement gossipsub IDONTWANT #5422

Merged
merged 30 commits into from
Jul 9, 2024
Merged

Conversation

jxs
Copy link
Member

@jxs jxs commented Mar 17, 2024

Issue Addressed

implement IDONTWANT message sending and addressing when forwarding.
Follows libp2p/specs#548

Should be reviewed after #5401 is merged

@jxs jxs force-pushed the impl-gossipsub-idontwant branch from b25f0e7 to 64364d1 Compare March 17, 2024 18:20
@jxs jxs requested a review from AgeManning March 17, 2024 19:36
Copy link
Member

@AgeManning AgeManning left a 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

beacon_node/gossipsub/src/behaviour.rs Outdated Show resolved Hide resolved
beacon_node/gossipsub/src/behaviour.rs Outdated Show resolved Hide resolved
beacon_node/gossipsub/src/protocol.rs Outdated Show resolved Hide resolved
beacon_node/gossipsub/src/types.rs Outdated Show resolved Hide resolved
beacon_node/gossipsub/src/types.rs Outdated Show resolved Hide resolved
beacon_node/gossipsub/src/types.rs Outdated Show resolved Hide resolved
beacon_node/gossipsub/src/behaviour.rs Outdated Show resolved Hide resolved
@jxs jxs force-pushed the impl-gossipsub-idontwant branch from 93626cd to 66658a4 Compare March 19, 2024 22:34
@jxs jxs force-pushed the impl-gossipsub-idontwant branch from 66658a4 to ae0b6b2 Compare March 20, 2024 13:05
jxs added 2 commits March 20, 2024 15:21
that returns true if peer speaks any version of gossipsub
@jxs jxs force-pushed the separate-gossipsub branch from 646bd40 to 30967b4 Compare March 20, 2024 16:47
@jimmygchen jimmygchen added ready-for-review The code is ready for review Networking labels Mar 21, 2024
@jxs jxs changed the base branch from separate-gossipsub to unstable March 26, 2024 10:51
Copy link
Member

@ackintosh ackintosh left a 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:

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);
}

@ackintosh
Copy link
Member

@jxs @AgeManning I have submitted a PR to address the issue I previously mentioned. Could you please review it?

jxs#4

@AgeManning
Copy link
Member

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

@jxs
Copy link
Member Author

jxs commented Apr 23, 2024

thanks @ackintosh!

@ackintosh
Copy link
Member

@AgeManning @jxs I submitted a PR to address the failing tests. Could you please review it when you have a chance? 🙏

jxs#5

@AgeManning
Copy link
Member

@Mergifyio queue

Copy link

mergify bot commented Jul 8, 2024

queue

✅ The pull request has been merged automatically

The pull request has been merged automatically at d46ac6c

Copy link
Member

@AgeManning AgeManning left a comment

Choose a reason for hiding this comment

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

Lets goo!

@AgeManning
Copy link
Member

@Mergifyio refresh

Copy link

mergify bot commented Jul 9, 2024

refresh

✅ Pull request refreshed

mergify bot added a commit that referenced this pull request Jul 9, 2024
@mergify mergify bot merged commit d46ac6c into sigp:unstable Jul 9, 2024
28 checks passed
mergify bot pushed a commit to libp2p/rust-libp2p that referenced this pull request Dec 27, 2024
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.
jxs pushed a commit to jxs/rust-libp2p that referenced this pull request Jan 6, 2025
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Networking ready-for-review The code is ready for review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants