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

GS: Relay messages to direct peers #949

Merged
merged 6 commits into from
Sep 15, 2023
Merged

GS: Relay messages to direct peers #949

merged 6 commits into from
Sep 15, 2023

Conversation

Menduist
Copy link
Contributor

@Menduist Menduist commented Sep 13, 2023

Currently, only the published messages are relayed to direct peers
However the spec states that all valid messages should be

Also, forceDial the direct peers to dial them even if we are full

@codecov
Copy link

codecov bot commented Sep 13, 2023

Codecov Report

Merging #949 (c7fc7a9) into unstable (20b0e40) will decrease coverage by 0.02%.
The diff coverage is 76.92%.

Impacted file tree graph

@@             Coverage Diff              @@
##           unstable     #949      +/-   ##
============================================
- Coverage     83.10%   83.08%   -0.02%     
============================================
  Files            91       91              
  Lines         15235    15238       +3     
============================================
  Hits          12661    12661              
- Misses         2574     2577       +3     
Files Changed Coverage
libp2p/protocols/pubsub/gossipsub/behavior.nim 66.66%
libp2p/protocols/pubsub/gossipsub.nim 80.00%

@@ -359,6 +359,10 @@ proc validateAndRelay(g: GossipSub,
break
toSendPeers.excl(seenPeers)

# add always direct peers
for topic in msg.topicIds:
toSendPeers.incl(g.explicit.getOrDefault(topic))
Copy link
Collaborator

Choose a reason for hiding this comment

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

maybe we can use a more descriptive name for direct peers than "explicit"

trace "Attempting to dial a direct peer", peer = id
if g.switch.isConnected(id):
info "We are connected to a direct peer, but GossipSub isn't setup with him!", id
Copy link
Collaborator

@diegomrsantos diegomrsantos Sep 15, 2023

Choose a reason for hiding this comment

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

Suggested change
info "We are connected to a direct peer, but GossipSub isn't setup with him!", id
debug "We are connected to a direct peer, but it isn't a GossipSub peer!", id

Copy link
Collaborator

Choose a reason for hiding this comment

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

Btw should we do something more in this case? If it's unexpected, maybe it should be a warn.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's basically a user error, but not critical, so info seems like a good fit

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd use debug or warn.

if peer.peerId in g.parameters.directPeers:
# receiving a graft from a direct peer should yield a more prominent warning (protocol violation)
warn "an explicit peer attempted to graft us, peering agreements should be reciprocal",
warn "a direct peer attempted to graft us, peering agreements should be reciprocal",
Copy link
Contributor

Choose a reason for hiding this comment

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

this can cause a log spam issue if they keep doing 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.

I think we are supposed to trust them somewhat
The other solution would be to remove them from the trusted set in that case
(descoring isn't an option as we will never kick them due to bad score)

Copy link
Contributor

Choose a reason for hiding this comment

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

hm, right about the trust - let's make a comment about it

@@ -359,6 +359,10 @@ proc validateAndRelay(g: GossipSub,
break
toSendPeers.excl(seenPeers)

# add always direct peers
for topic in msg.topicIds:
toSendPeers.incl(g.subscribedDirectPeers.getOrDefault(topic))
Copy link
Contributor

Choose a reason for hiding this comment

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

I'll assume this gets filtered somewhere so we don't send to peers that have already seen the message?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It wasn't, fixed

arnetheduck
arnetheduck previously approved these changes Sep 15, 2023
@Menduist Menduist enabled auto-merge (squash) September 15, 2023 15:15
@Menduist Menduist merged commit b2eac7e into unstable Sep 15, 2023
9 of 10 checks passed
@Menduist Menduist deleted the fixdirectpeer branch September 15, 2023 15:22
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