-
Notifications
You must be signed in to change notification settings - Fork 998
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
protocols/{relay,dcutr}: Replace std::time::SystemTime
with instant::SystemTime
#2991
Conversation
Thanks for taking care @thomaseizinger I'm getting panics bc of this one too https://github.com/libp2p/rust-libp2p/blob/master/protocols/dcutr/src/protocol/outbound.rs#L29 |
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 one small nit.
Thanks @thomaseizinger for the fix.
@fgimenez I am not sure how your WASM setup looks like. In case your local WASM node can not listen for incoming connections, I don't see a way how you can succeed in hole punching and thus I don't see the need for libp2p-dcutr
. I am not saying we shouldn't do this change. Just a heads up. This will e.g. change for the browser world once we have WebRTC support. See libp2p/specs#412.
Thanks for the heads up @mxinden, let me explain a bit the setup I've come up with, please don't hesitate to let me know if anything is wrong or should be done in a different way. My goal was to verify connectivity between WASM browser nodes through a relay v2 node, I was aiming to achieve something similar to what was described in this comment libp2p/js-libp2p-webrtc-direct#98 (comment). I have a wasm-pack based test case that spins up 2 browser nodes and a backend relay node, the setup looks like this:
Regarding the test case itself:
The test is passing with the changes in this PR, I've attached logs for the 3 nodes
As explained above, this setup is working fine just with websockets, and as I understand it, it requires libp2p-dcutr to work, is that correct? please let me know if I'm missing something, or if this is not the right approach. |
std::time::SystemTime
with instant::SystemTime
std::time::SystemTime
with instant::SystemTime
std::time::SystemTime
with instant::SystemTime
std::time::SystemTime
with instant::SystemTime
@fgimenez I am not sure I am following. Is the final connection between the two nodes a relayed or a direct connection? DCUtR upgrades a relayed connection to a direct connection. In case you can not establish a direct connection (between two browsers), I don't see how DCUtR can help you. libp2p/specs#412 will give you browser-to-server connectivity. For your WASM node you would need to adapt Long term, libp2p/specs#412 will give you browser-to-browser connectivity including hole punching. |
@mxinden you are right, one of the browsers is dialing the other on the relayed address, following the hole-punching example I added the DCUtR behaviour but I can see in the logs how the upgrade fails, the error comes from https://github.com/libp2p/rust-libp2p/blob/master/protocols/dcutr/src/protocol/inbound.rs#L57
Awesome, would love to work on it, should be similar to what is done here for websockets right? https://github.com/libp2p/rust-libp2p/tree/master/transports/wasm-ext/src
Very cool 👍 |
Yes. Correct. Though it does include an additional Noise handshake and message framing. See libp2p/specs#412. |
Description
I tried to safeguard against this by banning
std::time::SystemTime::now
via clippy.toml but unfortunately, it doesn't work becauseinstant
re-exportsstd
when not compiling for wasm so it still gets flagged.Links to any relevant issues
Open Questions
Change checklist
I have added tests that prove my fix is effective or that my feature works