-
Notifications
You must be signed in to change notification settings - Fork 43
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: remove initialising peer-exchange while creating a node #1158
Conversation
size-limit report 📦
|
Wow, I actually have been thinking of doing this PR because it creates conflict with the new libp2p API so it's great to see that it also makes sense from your POV. However, you only updated the |
based on your reply, im confused now as it makes sense. it's a protocol that we need to mount to our node to be able to dial relevant px nodes
i might be missing something but thought it might be better to get a fresh perspective on this |
That's the thing, we don't need the waku node to expose the peer exchange API. We just need peer exchange to access the right libp2p components to operate. |
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.
Did not do a full review as there is a fundamental show stopper.
@@ -61,11 +62,11 @@ export async function waitForRemotePeer( | |||
} | |||
|
|||
if (protocols.includes(Protocols.PeerExchange)) { |
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.
We do not expect users to use peer exchange directly but only as a libp2p peer discovery protocol. Hence peer exchange support can be dropped from waitForRemotePeer
and also potentially from the Protocols
enum.
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.
based on this comment, #1160 (comment) and libp2p/js-libp2p-interfaces#338 should no longer be a problem for us at this moment.
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.
based on this comment, #1160 (comment) and libp2p/js-libp2p-interfaces#338 should no longer be a problem for us at this moment.
Yep I agree.
efbdb99
to
10249b7
Compare
10249b7
to
c6bd894
Compare
- also removes the manual test for peer-exchange (assumption is that the only way to initialise peer-exchange is through libp2p's peerDiscovery and not manually) (ref: #1158 (comment)) # Please enter the commit message for your changes. Lines starting
@fryorcraken it's ready for review again. |
); | ||
|
||
expect(receivedCallback).to.be.true; | ||
const pxPeers = waku.libp2p |
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.
might help to abstract this into a generic helper like getPeersForProtocols
|
||
expect(receivedCallback).to.be.true; | ||
const pxPeers = waku.libp2p | ||
.getConnections() |
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.
This strategies makes the test slow to run every time.
Instead of waiting 40s and then checking connection do this: listen on new connection events on libp2p
. for each new connection, check tag. As soon as one with a peer exchange tag is found, test can stop.
You can also wrap that in a timeout so it does not wait forever.
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.
great idea!
i saw a flaw while i revisited this: we assume that a peer exchange node will definitely connect but as we know (ref: waku-org/nwaku#1521), it's very probable that no connections are made. thus, i have refactored this to listen for discovery instead of connections
Problem
PeerExchange
is being initialised when a node was created, similar to other protocols like Filter and LightPush. This is however incorrect as PeerExchange is a discovery protocol and is to be initialised through libp2p'speerDiscovery
or manually.Solution
Remove initialising
PeerExchange
by default while creating nodesNotes
- blocked by fix!: bump libp2p dependencies #1160 (comment)