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

wasm-node: Add support for WebRTC #1712

Closed
2 tasks done
tomaka opened this issue Nov 30, 2021 · 9 comments · Fixed by #2579
Closed
2 tasks done

wasm-node: Add support for WebRTC #1712

tomaka opened this issue Nov 30, 2021 · 9 comments · Fixed by #2579
Assignees

Comments

@tomaka
Copy link
Contributor

tomaka commented Nov 30, 2021

See https://github.com/libp2p/specs/ for how to implement this.

Two things need to be done:

  • Modify the networking code to support transport protocols that natively support substreams.
  • Modify bindings-smoldot-light.js to support WebRTC.
@tomaka
Copy link
Contributor Author

tomaka commented Jan 20, 2022

cc libp2p/specs#220

@tomaka
Copy link
Contributor Author

tomaka commented Jan 21, 2022

As a small note, WebRTC is unfortunately not available from within JS workers (despite WebSockets being available, don't ask me), so we would have to do some messages exchanges between outside and inside the worker to make that work.

@tomaka
Copy link
Contributor Author

tomaka commented Jan 21, 2022

Considering that we might need to add another encryption layer within the DTLS+SCTP stream, it makes sense to me to simply open one SCTP channel for everything and apply Noise+Yamux to it.

As such, I've crossed out the first point.

Modify the networking code to support transport protocols that natively support substreams.

Maybe it turns out that in the end we'll need to do it, but for now it's not necessary.

@tomaka
Copy link
Contributor Author

tomaka commented Jan 23, 2022

WebRTC should solve a problem related to blacklisted IP addresses, which I won't go into details to avoid someone "exploiting" this (though it's not really an exploit, just a way to be annoying).

@melekes
Copy link
Contributor

melekes commented Apr 28, 2022

What's left from the transport perspective:

@tomaka
Copy link
Contributor Author

tomaka commented Jun 7, 2022

After #2352:

  • Add support for a /webrtc (or similar) protocol in Multiaddr.
  • Actually add support for WebRTC in the smoldot JS code (bindings-smoldot-js.ts).
  • Finish the areas where Add support for "multi-stream connections" #2352 has left todos, mainly wasm-node/rust/src/platform. This will be more easily done once the JS supports WebRTC, so that we can actually test if things work.

melekes added a commit to melekes/substrate that referenced this issue Jun 30, 2022
warning: uses my fork of libp2p and webrtc-rs library
Impl: libp2p/rust-libp2p#2622
Spec: libp2p/specs#412

Refs paritytech/smoldot#1712
@mergify mergify bot closed this as completed in #2579 Sep 20, 2022
mergify bot added a commit that referenced this issue Sep 20, 2022
Closes #1712

Co-authored-by: Pierre Krieger <[email protected]>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
@tomaka
Copy link
Contributor Author

tomaka commented Sep 20, 2022

After #2579, what remains to do is:

@tomaka tomaka reopened this Sep 20, 2022
melekes added a commit to melekes/substrate that referenced this issue Oct 17, 2022
@tomaka
Copy link
Contributor Author

tomaka commented Oct 18, 2022

Another thing to do is fix compatibility with Firefox.
As explained here, Firefox doesn't support getFingerprints and you have to find the fingerprints in the local SDP offer.

mergify bot added a commit that referenced this issue Oct 19, 2022
cc libp2p/specs#412
cc #1712

This PR finishes implementing the WebRTC spec by adding the last
remaining item: the messages framing.

Implementing this messages framing while minimizing the amount of data
copies is rather challenging.
Instead of going for the complicated solution, I went for the more easy
solution of having an intermediate read buffer where data is first
copied.
Going for the simple solution decreases the chances of bugs and
increases the ease of debugging, so it's preferable at the moment.

In the future, once WebRTC is fully working, we can rewrite this
messages framing code in a more optimized way.

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
melekes added a commit to melekes/substrate that referenced this issue Oct 19, 2022
melekes added a commit to melekes/substrate that referenced this issue Nov 22, 2022
Refs paritytech/smoldot#1712
Impl libp2p/rust-libp2p#2622

- WebRTC transport is enabled for non-validators and developers by default.
- The transport will generate and store the certificate, which is required for WebRTC identity, in
base dir. In the future, when a new version of `ring` library is released, the certificate will be
deterministically derived from the node's peer ID.
melekes added a commit to melekes/substrate that referenced this issue Nov 22, 2022
Refs paritytech/smoldot#1712
Impl libp2p/rust-libp2p#2622

- WebRTC transport is enabled for non-validators and developers by default.
- The transport will generate and store the certificate, which is required for WebRTC identity, in
base dir. In the future, when a new version of `ring` library is released, the certificate will be
deterministically derived from the node's peer ID.
@tomaka
Copy link
Contributor Author

tomaka commented Nov 22, 2022

Closing as done.

@tomaka tomaka closed this as completed Nov 22, 2022
melekes added a commit to melekes/substrate that referenced this issue Nov 28, 2022
Refs paritytech/smoldot#1712
Impl libp2p/rust-libp2p#2622

- WebRTC transport is enabled for non-validators and developers by default.
- The transport will generate and store the certificate, which is required for WebRTC identity, in
base dir. In the future, when a new version of `ring` library is released, the certificate will be
deterministically derived from the node's peer ID.
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 a pull request may close this issue.

2 participants