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: implementing port 0 support #2125

Merged
merged 26 commits into from
Oct 27, 2023
Merged

Conversation

gabrielmer
Copy link
Contributor

@gabrielmer gabrielmer commented Oct 13, 2023

Description

Updating data structures to correctly reflect port number when the port is dynamically allocated by the kernel.

Changes

  • Updating NetConfig
  • Updating ENR record
  • Updating wakuDiscV5
  • Updating announcedAddresses

Issue

closes #2042

@gabrielmer gabrielmer changed the title Feat implementing port 0 support feat: implementing port 0 support Oct 13, 2023
@github-actions
Copy link

github-actions bot commented Oct 13, 2023

You can find the image built from this PR at

quay.io/wakuorg/nwaku-pr:2125

Built from b0fd5f0

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.

Beautiful PR! It looks nice so far!
I've added a few comments and I'll study it again once it becomes "ready".

@gabrielmer gabrielmer force-pushed the feat-implementing-port-0-support branch from fcd8c15 to 7a25d49 Compare October 19, 2023 13:06
@gabrielmer gabrielmer marked this pull request as ready for review October 19, 2023 13:44
let wsAddress = initTAddress(a).valueOr:
return err(error)
websocketPort = some(wsAddress.port)
elif not a.isWsAddress() and tcpPort.isNone():
Copy link
Member

Choose a reason for hiding this comment

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

It's a nitpick, but how about

if a.WsAddress():
  ...handle wsPort...
else:
  ...handle nonWsPort...

Just to skip doing the ws address check twice

Copy link
Member

Choose a reason for hiding this comment

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

Another thing - this will obviously take a port from the first listen address it encounters - is that possible an issue? Could it mean we use non-public port instead of a public one, or is that not a problem anymore with all the previous changes regarding listen addresses?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you! Just refactored it to avoid doing the ws address check twice :)

Regarding the ports, the proc takes the tcp and ws(s) ports the switch got bound to - there should be only one of each (this listenAddrs seq is part of the switch's struct).
Afterwards we recreate the App's and WakuNode's netConfig as if we had manually configured to bind to those ports.

These lines should not concern public ports: if we configured previously an extPort, then NetConfig will be recreated with the same extPort as before. And on the other hand, if we use the ext-multi-addr-only CLI flag, we would still only (and blindly) announce the multiaddresses passed by the user.

Copy link
Member

@vpavlin vpavlin left a comment

Choose a reason for hiding this comment

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

Tested locally with few options combinations and it worked as promised:)

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.

Wonderful PR! Thanks for it! 💯
Just added a few nitpicks ;P

@gabrielmer
Copy link
Contributor Author

Wonderful PR! Thanks for it! 💯 Just added a few nitpicks ;P

Done! Thanks for the feedback! :)

@gabrielmer gabrielmer merged commit f7b9afc into master Oct 27, 2023
@gabrielmer gabrielmer deleted the feat-implementing-port-0-support branch October 27, 2023 07:11
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.

feat: allowing users to choose port 0 for dynamically allocated ports
4 participants