-
Notifications
You must be signed in to change notification settings - Fork 9
feat: implement gossipsub partial messages extension #577
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
base: sigp-gossipsub
Are you sure you want to change the base?
Conversation
…sipsub-partial-messages
protocols/gossipsub/src/behaviour.rs
Outdated
| { | ||
| // Return err if trying to publish the same partial message state we currently have. | ||
| if existing.available_parts() == partial_message.available_parts() { | ||
| return Err(PublishError::Duplicate); |
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 don't think this is correct.
- Imagine you have parts 1,2,3.
- You tell your peers about those parts.
- A peer comes back and says I want part 2.
- You republish with the same parts in order to respond.
- You get this error and fail to respond.
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.
thanks for explaining Marco, updated as we spoke
protocols/gossipsub/src/behaviour.rs
Outdated
| data_transform: D, | ||
|
|
||
| /// Partial messages received. | ||
| partial_messages: HashMap<TopicHash, HashMap<Vec<u8>, P>>, |
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.
Do you need to store P here? I think it's better if P is owned solely by the application.
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.
yup, you are right, thanks Marco!
protocols/gossipsub/src/types.rs
Outdated
| pub(crate) struct PartialData { | ||
| pub(crate) ihave: Vec<u8>, | ||
| pub(crate) iwant: Vec<u8>, | ||
| pub(crate) message: Vec<u8>, |
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.
Is it useful to store the message here? It seems like wasted space, you only use it to check if the peer is sending you a duplicate.
Might be simpler to let the application handle dupes.
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.
thanks Marco, I only left wanted and has wanted to avoid sending the same message and has to avoid notifying the application layer of duplicates.
Thanks!
cb0e925 to
e6f1ae4
Compare
e6f1ae4 to
69c2d95
Compare
and create a paralel list for the partial_only topics.
Pull-Request: libp2p#6171.
protocols/gossipsub/src/partial.rs
Outdated
| /// 5. Received partial data is integrated using `extend_from_encoded_partial_message()` | ||
| /// 6. The `group_id()` ties all parts of the same logical message together | ||
| pub trait Partial { | ||
| type Metadata: Metadata; |
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.
should parts_metadata return this?
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.
After discussion, I think the way to go is to remove the assoc type and keep parts_metadata the way it is for now :)
protocols/gossipsub/src/behaviour.rs
Outdated
| pub fn publish_partial<P: Partial>( | ||
| &mut self, | ||
| topic: impl Into<TopicHash>, | ||
| partial_message: P, |
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.
&P? 🙏
…-partial-messages
I noticed two issues during testing. 1. We allow our mesh to grow greater than `mesh_n_high`, intentionally 2. There is a potential underflow in the heartbeat that can cause a panic For the first 1. This looks like its intentional but I can't recall why we would have added it. I think its counter-intuitive to allow our mesh to grow larger than the specified parameter. I suspect we added it to prevent our mesh from being filled with inbound peers and potentially being eclipsed. I suspect the best approach here is to remove inbound peers in the mesh maintenance rather than exceeding the mesh_n_high configuration. For 2. There is an underflow which this PR prevents. It can be triggered for low mesh_n_high values, i.e 0. This shouldn't be a concern for regular users, but we shouldn't have code that can panic based on user configuration. Pull-Request: libp2p#6183.
Pull-Request: libp2p#6181.
Adds links to related tech mentioned in examples/README. This is useful to people new to the field, like me. Pull-Request: libp2p#6016.
Split off from libp2p#6183, to quote: >I noticed two issues during testing. > >We allow our mesh to grow greater than mesh_n_high, intentionally >This looks like its intentional but I can't recall why we would have added it. I think its counter-intuitive to allow our mesh to grow larger than the specified parameter. I suspect we added it to prevent our mesh from being filled with inbound peers and potentially being eclipsed. I suspect the best approach here is to remove inbound peers in the mesh maintenance rather than exceeding the mesh_n_high configuration. Pull-Request: libp2p#6184.
protocols/gossipsub/src/behaviour.rs
Outdated
| .connected_peers | ||
| .iter() | ||
| .filter(|(_, p)| p.topics.contains(&topic_hash)) | ||
| .filter(|(_, peer)| { |
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.
Additionally, I think we need a filter like this here:
.filter(|(_, p)| p.topics.contains(&topic_hash))
protocols/gossipsub/src/behaviour.rs
Outdated
| /// Helper function to get a subset of random gossipsub peers for a `topic_hash` | ||
| /// filtered by the function `f`. The number of peers to get equals the output of `n_map` | ||
| /// that gets as input the number of filtered peers. | ||
| #[allow(unused, reason = "partial is used with partial_messages feature")] |
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.
| #[allow(unused, reason = "partial is used with partial_messages feature")] | |
| #[allow(unused, reason = "exclude_partial is used with partial_messages feature")] |
protocols/gossipsub/src/behaviour.rs
Outdated
|
|
||
| /// Helper function to get a set of `n` random gossipsub peers for a `topic_hash` | ||
| /// filtered by the function `f`. | ||
| #[allow(unused, reason = "partial is used with partial_messages feature")] |
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.
| #[allow(unused, reason = "partial is used with partial_messages feature")] | |
| #[allow(unused, reason = "exclude_partial is used with partial_messages feature")] |
protocols/gossipsub/src/behaviour.rs
Outdated
| let mut gossip_peers = connected_peers | ||
| .iter() | ||
| .filter(|(_, p)| p.topics.contains(topic_hash)) | ||
| .filter_map(|(peer_id, peer)| { |
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.
Additionally, I think we need a filter like this here:
.filter(|(_, p)| p.topics.contains(&topic_hash))## Description Changelog was incorrect as we didn't release version `0.5.1` cc @RolandSherwin
9efdb00 to
f728315
Compare
58d211b to
c256ac6
Compare
c256ac6 to
9545140
Compare
Description
This is a draft implementation of partial messages for gossipsub following the spec PR and based on the Go implementation. Still WIP but should give a good idea of the direction we're heading.