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

feat: running periodicaly peer exchange if discv5 is disabled #3150

Merged
merged 9 commits into from
Oct 30, 2024

Conversation

gabrielmer
Copy link
Contributor

@gabrielmer gabrielmer commented Oct 25, 2024

Description

As part of

Use nwaku in runPeerExchangeLoop. Might not be necessary if nwaku already handles this?

in #3076, we are adding the functionality for nwaku edge nodes to periodically query Peer Exchange for new peers.

Currently the periodic search for peers is done by Discv5, so I activated the periodic Peer Exchange queries whenever Peer Exchange is enabled and Discv5 is disabled.

Let me know what you think, we could also create a flag to turn it on and off, but as we try not to add too many flags and over-complicate the configurations, I initially added it in this use case which should be the most common/logical.

Changes

  • for edge nodes with Peer Exchange activated, query for peers every minute
  • avoid exiting the program if first Peer Exchange request fails

Copy link

github-actions bot commented Oct 25, 2024

You can find the image built from this PR at

quay.io/wakuorg/nwaku-pr:3150

Built from a122086

Copy link
Collaborator

@Ivansete-status Ivansete-status left a comment

Choose a reason for hiding this comment

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

Thanks for this! It will give a much more robust PX procedure 🥳

I've added a couple of comments that I hope you find reasonable ;P

waku/factory/node_factory.nim Outdated Show resolved Hide resolved
waku/node/waku_node.nim Outdated Show resolved Hide resolved
Copy link
Collaborator

@Ivansete-status Ivansete-status left a comment

Choose a reason for hiding this comment

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

Lovely! Thanks for it! 💯
I just added a nitpick comment

waku/node/waku_node.nim Outdated Show resolved Hide resolved
waku/node/waku_node.nim Show resolved Hide resolved
@gabrielmer gabrielmer force-pushed the feat-running-px-loop-if-not-discv5 branch from 3a72eb0 to 32cf0e0 Compare October 29, 2024 22:11
Copy link
Contributor

@NagyZoltanPeter NagyZoltanPeter left a comment

Choose a reason for hiding this comment

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

Great extension, but unsure from where it will get PX service peer to provide peers instead of discv5. Maybe I overlooked sthg.


# Use px to periodically get peers if discv5 is disabled, as discv5 nodes have their own
# periodic loop to find peers and px returned peers actually come from discv5
if conf.peerExchange and not conf.discv5Discovery:
Copy link
Contributor

Choose a reason for hiding this comment

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

If have no discv5 but want to use PX, how can we ensure to get some initial PX service peer?
Isn't it conf.peerExchangeNode setting ensure it?

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 tested it even without setting peerExchangeNode and worked :))

If there isn't a peerExchangeNode set, then any peer we have in the store with the PX codec is chosen randomly, so we just need to be connected to at least one peer that supports PX

pm.serviceSlots.withValue(proto, serviceSlot):
trace "Got peer from service slots",
peerId = serviceSlot[].peerId, multi = serviceSlot[].addrs[0], protocol = proto
return some(serviceSlot[])
# If not slotted, we select a random peer for the given protocol
if peers.len > 0:
trace "Got peer from peerstore",
peerId = peers[0].peerId, multi = peers[0].addrs[0], protocol = proto
return some(peers[0])
trace "No peer found for protocol", protocol = proto
return none(RemotePeerInfo)

It can be any of our normal bootstrap nodes or a static node also.

Then, the peers we receive via PX if they also support it will enter to the pool from which we choose randomly, so it's just a matter of having a point where to start from, and luckily it must not necessarily be a configured peerExchangeNode :)

waku/node/waku_node.nim Outdated Show resolved Hide resolved
@gabrielmer gabrielmer merged commit 400d7a5 into master Oct 30, 2024
9 of 11 checks passed
@gabrielmer gabrielmer deleted the feat-running-px-loop-if-not-discv5 branch October 30, 2024 10:51
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.

4 participants