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

fix: avoid segfault by setting a default num peers requested in PX #3122

Merged
merged 3 commits into from
Oct 16, 2024

Conversation

gabrielmer
Copy link
Contributor

Description

When using Peer Exchange in nwaku, we are setting the number of peers requested by using a Relay-specific parameter, which isn't set if we use nwaku as a light client and produces a segfault.

Therefore, defined a DefaultPXNumPeersReq constant with a value of 5 to use whenever no argument is provided or whenever Relay is not mounted

Changes

  • defined and integrated DefaultPXNumPeersReq constant
  • fixed segfault by not reading Relay's parameters if Relay is not mounted

Issue

#3115

Copy link

github-actions bot commented Oct 16, 2024

You can find the image built from this PR at

quay.io/wakuorg/nwaku-pr:3122

Built from 9fd30c5

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 it!

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.

It is a great catch! Thank you for it.
Left some opinions... :-)

@@ -57,7 +58,7 @@ type
requestRateLimiter*: RequestRateLimiter

proc request*(
wpx: WakuPeerExchange, numPeers: uint64, conn: Connection
wpx: WakuPeerExchange, numPeers = DefaultPXNumPeersReq, conn: Connection
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it necessary to apply default here? ... and for other variants?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Over here it's not necessary! But added it because given that we now defined a default, it would make sense for that number to be used whenever no value is provided

waku/factory/node_factory.nim Outdated Show resolved Hide resolved
@gabrielmer gabrielmer force-pushed the fix-px-segfault-when-relay-not-mounted branch from 8de6ae9 to c93e0a8 Compare October 16, 2024 12:07
@gabrielmer gabrielmer merged commit 82fd5dd into master Oct 16, 2024
10 of 11 checks passed
@gabrielmer gabrielmer deleted the fix-px-segfault-when-relay-not-mounted branch October 16, 2024 14:04
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