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

Allow cancelling IWANT using IDONTWANT #591

Merged
merged 1 commit into from
Dec 30, 2024
Merged

Conversation

ppopth
Copy link
Contributor

@ppopth ppopth commented Dec 29, 2024

As specified in the Gossipsub v1.2 spec, we should allow cancelling IWANT by IDONTWANT.

That is if IDONTWANT already arrived, we should not process IWANT.

However due to the code structure, we can cancel IWANT only in handleIWant.

https://github.com/libp2p/specs/blob/master/pubsub/gossipsub/gossipsub-v1.2.md#cancelling-iwant

@ppopth ppopth marked this pull request as ready for review December 29, 2024 18:56
As specified in the Gossipsub v1.2 spec, we should allow cancelling
IWANT by IDONTWANT.

That is if IDONTWANT already arrived, we should not process IWANT.

However due to the code structure, we can cancel IWANT only in
handleIWant.
Copy link
Collaborator

@vyzo vyzo left a comment

Choose a reason for hiding this comment

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

Not so sure we need this to be honest, i'd like some more opinions.

@@ -839,6 +839,11 @@ func (gs *GossipSubRouter) handleIWant(p peer.ID, ctl *pb.ControlMessage) []*pb.
ihave := make(map[string]*pb.Message)
for _, iwant := range ctl.GetIwant() {
for _, mid := range iwant.GetMessageIDs() {
// Check if that peer has sent IDONTWANT before, if so don't send them the message
if _, ok := gs.unwanted[p][computeChecksum(mid)]; ok {
Copy link
Collaborator

Choose a reason for hiding this comment

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

how expensive is this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You meant computeChecksum? no, it's just one hash function.

@vyzo
Copy link
Collaborator

vyzo commented Dec 30, 2024

@nisdas want to chime in?

@nisdas
Copy link
Contributor

nisdas commented Dec 30, 2024

Is it common for non-mesh peers to send us IDONTWANTs ? The way i see it both control messages target different peers.

IDONTWANT - mesh , IWANT - non mesh

@ppopth
Copy link
Contributor Author

ppopth commented Dec 30, 2024

Is it common for non-mesh peers to send us IDONTWANTs ?

I don't think it's quite useful either, but it's specified in the spec and Lighthouse is already sending IDONTWANT after it sends IWANT. See https://github.com/sigp/lighthouse/blob/stable/beacon_node/lighthouse_network/gossipsub/src/behaviour.rs#L2733

While we don't send IDONTWANT to non-mesh peers ourselves, I think it's useful to handle IDONTWANT for Lighthouse, otherwise their IDONTWANT will be wasteful.

So yes, it's common.

Copy link
Collaborator

@vyzo vyzo left a comment

Choose a reason for hiding this comment

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

ok, lets merge

@vyzo vyzo merged commit bf5b583 into libp2p:master Dec 30, 2024
9 checks passed
@nisdas
Copy link
Contributor

nisdas commented Dec 31, 2024

@ppopth One thing that is important to confirm is if other implementations correctly ignore this for scoring. As of gossipsub v1.1 , unfulfilled promises lead to the downscoring of peers. So if you advertise an IHAVE and I reply back with an IWANT . I will normally expect you to send me the full message.

However with IDONTWANT we are now skipping sending the full message. Peers which send both IWANT and IDONTWANT for the same message should also not penalize peers for not fulfilling the promise.

@ppopth
Copy link
Contributor Author

ppopth commented Dec 31, 2024

So if you advertise an IHAVE and I reply back with an IWANT . I will normally expect you to send me the full message.

Yeah, it's specified in the spec that if I don't reply to IWANT, I would be downscored. But I don't worry about it because if you downscore me, but you sent both IWANT and IDONTWANT, you seem more misbehaving.

https://github.com/libp2p/specs/blob/master/pubsub/gossipsub/gossipsub-v1.1.md#spam-protection-measures

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants