-
Notifications
You must be signed in to change notification settings - Fork 57
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: Enable Hole Punching service #1766
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for this @diegomrsantos!
does a private node with this code get inbound connections out of the box as it is in the waku network?
waku/v2/node/waku_node.nim
Outdated
@@ -186,7 +197,8 @@ proc new*(T: type WakuNode, | |||
sendSignedPeerRecord = sendSignedPeerRecord, | |||
agentString = agentString, | |||
peerStoreCapacity = peerStoreCapacity, | |||
services = @[Service(getAutonatService(rng))], | |||
services = @[Service(hpservice)], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just to make sure i got it right: autonatservice is included indirectly in hpservice
? so no need for services=[hpservice, autonatservice]
?
wondering what would happen if i try:
services=[hpservice, autonatservice]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, autonatservice
is added at line 184. Regarding your second question, it'd create two autonatservice
, I didn't test it tbh, but it shouldn't be done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see the hpservice
as a wrapper around autonatservice
, so I think we don't need to add it twice.
@@ -54,6 +54,9 @@ proc setupNat*(natConf, clientId: string, | |||
endpoint.udpPort = some(extUdpPort) | |||
|
|||
else: # NatNone | |||
if natConf == "none": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isnt this redundant? its the else case of if strategy != NatNone:
so it will always be none?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but before it executed the code below:
if not natConf.startsWith("extip:"):
return err("not a valid NAT mechanism: " & $natConf)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shall we just return an error in this case (else: # NatNone
)?
I have the impression that the next is always run:
return err("not a valid NAT mechanism: " & $natConf)
waku/v2/node/waku_node.nim
Outdated
@@ -42,6 +46,8 @@ import | |||
./peer_manager, | |||
./waku_switch | |||
|
|||
export chronos |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Menduist do you have more info about this issue? Is there a PR related to that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't remember, what happens without this line?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't remember the error now, but it is related to generic procs. I think adding the export
is the only way to fix it. I believe in this case it is caused by the new
proc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, if you use a package inside a generic proc, you need to export it
Not a bug, just a design quirk of nim
waku/v2/node/waku_node.nim
Outdated
let relayClient = RelayClient.new() | ||
let autoRelayService = AutoRelayService.new(1, relayClient, nil, rng) | ||
let autonatService = getAutonatService(rng) | ||
let hpservice = HPService.new(autonatService, autoRelayService) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wondering if we should have hole punching behind a flag or always on by default. specially now at the begining that its new. opinion? @jm-clius
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe a flag that is true by default
Thanks so much indeed for submitting this PR @diegomrsantos !
You'll need to set an appropriate PR's title. And, in order to fix the conflicts I would make this in your working branch:
|
@Ivansete-status Sure, I'll do it. Sorry, should have created it as a draft. |
73083f8
to
19fc616
Compare
19fc616
to
f02ca75
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks great indeed!
I've added a little nitpicky comment.
How could we test it?
.withAutonat() | ||
|
||
if relay != nil: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Little nitpick:
if relay != nil: | |
if not isNil(relay): |
waku/v2/node/waku_node.nim
Outdated
@@ -186,7 +197,8 @@ proc new*(T: type WakuNode, | |||
sendSignedPeerRecord = sendSignedPeerRecord, | |||
agentString = agentString, | |||
peerStoreCapacity = peerStoreCapacity, | |||
services = @[Service(getAutonatService(rng))], | |||
services = @[Service(hpservice)], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see the hpservice
as a wrapper around autonatservice
, so I think we don't need to add it twice.
@Ivansete-status @jm-clius I'm putting this work on hold for now. The Hole Punching Service requires that a private peer's relay address be advertised to peers interested in connecting to it. We are going to use the Rendezvous protocol for that, but the current nwaku version is just mounting the protocol. Advertising the peer's signed record, requesting other peers ones, and using it to discover new peers need to be implemented. It seems those things are already in place in go-waku. Please let me know when those have been implemented in nwaku and fully tested with go. |
Thanks for the comment @diegomrsantos! Is there anything that we should do to help this feature progress? |
@Ivansete-status If I get it right, circuit-relay addresses from private nodes aren't discoverable through discv5, because they are too big. For that reason, nwaku nodes need to use Rendezvous to advertise such addresses when they are private. Likewise, they also need to ask Rendezvous Points for such node's addresses. |
Thanks for the answer @diegomrsantos!
|
That's correct. Regarding the first point, nwaku could use Rendezvous to advertise its addresses all the time, not only when it's private. This would probably make the implementation easier, but I'm not sure about the interaction with the current discv5 usage. This can be decided by the team, the only requirement for Hole Punching is that circuit-relay addresses of private nodes are advertised, discoverable, and dialed by other nodes. |
I have added the advertising part (in all cases, not only when the node is private) here f64d12b. It can be used as inspiration, I'm not sure I did it properly. It requires some fixes that are being done here vacp2p/nim-libp2p#951. |
Thank you so much indeed for this PR @diegomrsantos! |
Description:
Enable the Hole Punching Service.