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(discv5): advertise custom multiaddresses #1512

Merged
merged 8 commits into from
Feb 7, 2023
Merged

Conversation

rymnc
Copy link
Contributor

@rymnc rymnc commented Jan 26, 2023

Should fix #1475, as a follow up to #1509. Makes discv5 broadcast custom-set multiaddrs

@rymnc rymnc added this to the Release 0.15.0 milestone Jan 26, 2023
@rymnc rymnc self-assigned this Jan 26, 2023
waku/v2/node/waku_node.nim Outdated Show resolved Hide resolved
waku/v2/node/waku_node.nim Outdated Show resolved Hide resolved
@LNSD
Copy link
Contributor

LNSD commented Jan 26, 2023

@rymnc I do not agree with moving discv5 to the waku_node module.

I think that all the discovery mechanisms should be managed and orchestrated by the peer manager. As a consequence, these mechanisms should be:

  • Either the wakunode2 app should register the event handlers to the discovery services and handle them by the peer manager instance.
  • Or dependency of the peer manager and passed into the peer manager constructor.

@rymnc
Copy link
Contributor Author

rymnc commented Jan 26, 2023

@rymnc I do not agree with moving discv5 to the waku_node module.

I think that all the discovery mechanisms should be managed and orchestrated by the peer manager. As a consequence, these mechanisms should be:

  • Either the wakunode2 app should register the event handlers to the discovery services and handle them by the peer manager instance.
  • Or dependency of the peer manager and passed into the peer manager constructor.

I am not sure if the PeerManager was intended to have this functionality, i.e discovery. It is currently used to manage dialing, adding and removing peers. But yes, I agree with your point.

Maybe @alrevuelta can weigh in here, was this something you intended for the PeerManager to do?

@LNSD
Copy link
Contributor

LNSD commented Jan 26, 2023

I am not sure if the PeerManager was intended to have this functionality, i.e discovery. It is currently used to manage dialing, adding and removing peers.

Note the following from my comment:

Either the wakunode2 app should register the event handlers to the discovery services and handle them by the peer manager instance.

This would be something like:

discoveryMechanism.onPeerDiscovered do (peer: PeerId):
  peerManager.addPeer(peer)

Copy link
Contributor

@alrevuelta alrevuelta left a comment

Choose a reason for hiding this comment

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

thanks! some comments

tests/v2/test_waku_discv5.nim Outdated Show resolved Hide resolved
tests/v2/test_waku_discv5.nim Outdated Show resolved Hide resolved
waku/v2/node/waku_node.nim Outdated Show resolved Hide resolved
waku/v2/node/waku_node.nim Outdated Show resolved Hide resolved
@status-im-auto
Copy link
Collaborator

status-im-auto commented Jan 26, 2023

Jenkins Builds

Click to see older builds (5)
Commit #️⃣ Finished (UTC) Duration Platform Result
185a10a #1 2023-01-26 23:03:12 ~15 min macos 📄log
bffcca7 #2 2023-01-27 22:54:52 ~7 min macos 📄log
✔️ b060cf2 #3 2023-01-30 23:02:36 ~15 min macos 📦bin
✔️ f69810d #4 2023-01-31 23:01:03 ~13 min macos 📦bin
✔️ 9c0e294 #5 2023-02-01 23:01:23 ~14 min macos 📦bin
Commit #️⃣ Finished (UTC) Duration Platform Result
29a3f11 #6 2023-02-02 15:24:21 ~13 min macos 📄log
✔️ 29a3f11 #7 2023-02-02 15:50:49 ~13 min macos 📦bin
✔️ 032b3a3 #8 2023-02-06 15:17:20 ~29 min macos 📦bin

Copy link
Contributor

@jm-clius jm-clius left a comment

Choose a reason for hiding this comment

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

Thanks, this is more or less the direction I had in mind too. I've added some comments re keeping the config vs initialisation a bit cleaner and consolidating the two different ENRs into one.

@rymnc rymnc marked this pull request as ready for review January 27, 2023 11:23
@rymnc rymnc requested review from LNSD and jm-clius January 27, 2023 11:24
Copy link
Contributor

@LNSD LNSD left a comment

Choose a reason for hiding this comment

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

As I said in my initial comment, I see a bad idea in moving the discovery mechanisms inside the waku_node module.

Some comments second this idea: moving the code inside the node module means you have to thread down the configuration. But it also implies that the WakuNode type has more than one responsibility (besides of orchestrating the different protocols and configuring the switch it also generates the local ENR, configures the discv5 service and holds the discv5 state). So... you cannot test the WakuNode without the discovery instantiated.

In summary, this couples the node code with the discovery code.


If everybody agrees, I won't block the PR. But I think we should go in the opposite direction: splitting the content of the big modules instead of merging them into big modules.

waku/v2/node/waku_node.nim Outdated Show resolved Hide resolved
@rymnc
Copy link
Contributor Author

rymnc commented Jan 30, 2023

Moving this PR to draft to decouple disc and WakuNode initialization.

@rymnc rymnc removed the request for review from jm-clius January 30, 2023 10:29
@rymnc rymnc marked this pull request as draft January 30, 2023 10:29
@jm-clius
Copy link
Contributor

Agree with @LNSD here. The issue is currently our configuration and initialisation is very convoluted.

  • WakuDiscv5 requires some addresses only available in WakuNode initialisation for its own initialisation
  • WakuNode requires an initialised WakuDiscv5 to be constructed with a consolidated ENR

Perhaps an increment to make it a bit better is extracting those parts of initialisation to do with constructing addresses and making sure that that's available to both WakuDiscv5 and WakuNode during initialisation? That way WakuDiscv5 initialisation can be decoupled and performed before WakuNode initialisation.

For this, the constructor arguments for WakuDiscv5 may also have to change so that it can be initialised from config.

I know from previously looking at this that there are some intricacies and gotchas, so I'm okay with incrementing here in reasonable steps to something cleaner and decoupled.

@alrevuelta
Copy link
Contributor

thanks for addressing the comments, resolved them all.

Maybe @alrevuelta can weigh in here, was this something you intended for the PeerManager to do?

missed this comment. I think we can keep the peer manager and discovery separated. Peer manager should be agnostic on how the peers are discovered/added to the peer manager.

@rymnc rymnc force-pushed the add-ext-discv5-enr branch 3 times, most recently from 1facb06 to 4dca394 Compare January 31, 2023 04:15
@rymnc rymnc changed the title feat(discv5): move discv5 setup from wakunode2 to waku_node feat(discv5): advertise custom multiaddresses Jan 31, 2023
@rymnc rymnc force-pushed the add-ext-discv5-enr branch from 3fc1910 to f69810d Compare January 31, 2023 05:05
@rymnc
Copy link
Contributor Author

rymnc commented Jan 31, 2023

@LNSD, I've decoupled the discv5 and waku_node setup. Added a deprecated flag to the original Wakunode.new() proc in favor of the WakuNodeAddrMeta variant (because there are a lot of usages of Wakunode.new()).

@rymnc rymnc marked this pull request as ready for review January 31, 2023 10:33
@rymnc rymnc requested a review from LNSD January 31, 2023 15:43
feat(discv5): allow custom multiaddr advertisement in discv5

feat(discv5): move discv5 setup from wakunode2 to waku_node

fix(waku_node): def param

test(discv5): test for ext multiaddr

fix(discv5): address comments

fix(discv5): address comments

fix(wakunode2): discoveryconfig in var before init

fix(discv5): pass multiaddr to discv5 directly

fix(discv5): make multiaddrs optional

fix(test): discv5 init

fix(discv5): split discv5 mounting from waku_node

chore(discv5): s/WakuAddressMetadata/WakuNodeAddrMeta/g
@rymnc rymnc force-pushed the add-ext-discv5-enr branch from f69810d to c1874a4 Compare February 1, 2023 05:45
@rymnc rymnc requested a review from jm-clius February 1, 2023 05:47
Copy link
Contributor

@LNSD LNSD left a comment

Choose a reason for hiding this comment

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

Please, check my comments :)

apps/wakunode2/wakunode2.nim Outdated Show resolved Hide resolved
waku/v2/node/waku_node.nim Outdated Show resolved Hide resolved
waku/v2/node/waku_node.nim Outdated Show resolved Hide resolved
waku/v2/node/waku_node.nim Outdated Show resolved Hide resolved
waku/v2/utils/peers.nim Outdated Show resolved Hide resolved
@rymnc rymnc marked this pull request as draft February 2, 2023 11:13
@rymnc rymnc removed the request for review from jm-clius February 2, 2023 11:13
Copy link
Contributor

@LNSD LNSD left a comment

Choose a reason for hiding this comment

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

LGTM ✅

@rymnc rymnc marked this pull request as ready for review February 6, 2023 06:32
@rymnc rymnc requested a review from jm-clius February 6, 2023 06:32
Copy link
Contributor

@jm-clius jm-clius left a comment

Choose a reason for hiding this comment

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

Thanks! I think this is a great step forward to also clean up the confusing address configuration and initialisation. It may be worth adding a unit test suite for other aspects of NetConfig (e.g. populating sensible announcedAddresses) in future PRs.

@rymnc rymnc merged commit 9ddf0fe into master Feb 7, 2023
@rymnc rymnc deleted the add-ext-discv5-enr branch February 7, 2023 13:06
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: ability to manually specify additional multiaddrs
5 participants